{"record":{"id":"68d214fc7eef30c9","repo":"can1357/oh-my-pi","slug":"plugin-must-implement-onconsolidate","errorCode":null,"errorMessage":"Plugin must implement onConsolidate","messagePattern":"Plugin must implement onConsolidate","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/mnemopi/src/core/plugins.ts","lineNumber":43,"sourceCode":"\t\tthis.enabled = (ctor.prototype.enabled as boolean | undefined) ?? this.enabled;\n\t}\n\n\tinitialize(): void {\n\t\tthis.initialized = true;\n\t}\n\n\tshutdown(): void {\n\t\tthis.initialized = false;\n\t}\n\n\tonRemember(_memory: MemoryDict): void {\n\t\tthrow new TypeError(\"Plugin must implement onRemember\");\n\t}\n\tonRecall(_memory: MemoryDict): void {\n\t\tthrow new TypeError(\"Plugin must implement onRecall\");\n\t}\n\tonConsolidate(_summary: MemoryDict): void {\n\t\tthrow new TypeError(\"Plugin must implement onConsolidate\");\n\t}\n\tonInvalidate(_memoryId: string): void {\n\t\tthrow new TypeError(\"Plugin must implement onInvalidate\");\n\t}\n\ttoDict(): Record<string, unknown> {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tversion: this.version,\n\t\t\tenabled: this.enabled,\n\t\t\tinitialized: this.initialized,\n\t\t\tconfig: this.config,\n\t\t};\n\t}\n}\n\nfunction previewContent(content: unknown, maxLen = 80): string {\n\tconst text = typeof content === \"string\" ? content : \"\";\n\tif (text.length <= maxLen) return text;","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/mnemopi/src/core/plugins.ts#L25-L61","documentation":"MnemopiPlugin's onConsolidate is a throwing stub that subclasses must override; the host calls it when working memories are consolidated into a summary. This TypeError means the plugin received a consolidation event without implementing the hook.","triggerScenarios":"A registered plugin subclass lacking an onConsolidate override, triggered during a memory-consolidation run when the host calls plugin.onConsolidate(summary).","commonSituations":"Plugins written before consolidation events existed; a plugin that implemented the other three hooks but forgot this one; calling the stub via super.onConsolidate() from a partial override.","solutions":["Override onConsolidate(summary: MemoryDict): void in the plugin subclass","Add an empty override if consolidation summaries don't matter to the plugin","Check that the plugin class hierarchy actually extends the version of MnemopiPlugin you think it does (duplicate installs can cause base-class stubs to win)"],"exampleFix":"// before\nclass MyPlugin extends MnemopiPlugin { /* no onConsolidate */ }\n// after\nclass MyPlugin extends MnemopiPlugin { override onConsolidate(s: MemoryDict): void { /* ... */ } }","handlingStrategy":"type-guard","validationCode":"function implementsOnConsolidate(p: MnemopiPlugin): boolean {\n  return p.onConsolidate !== MnemopiPlugin.prototype.onConsolidate;\n}\nif (!implementsOnConsolidate(plugin)) throw new Error(`plugin ${plugin.name} must override onConsolidate`);","typeGuard":"function overridesOnConsolidate<P extends MnemopiPlugin>(p: P): p is P & { onConsolidate(s: MemoryDict): void } {\n  return p.onConsolidate !== MnemopiPlugin.prototype.onConsolidate;\n}","tryCatchPattern":"try {\n  host.consolidate(summary);\n} catch (err) {\n  if (err instanceof TypeError && err.message === \"Plugin must implement onConsolidate\") {\n    logger.error(`plugin ${plugin.name} lacks onConsolidate; excluding from consolidation runs`);\n  } else throw err;\n}","preventionTips":["Implement every hook, even if consolidation is a no-op for your plugin","Exercise a consolidation run in plugin CI so missing overrides surface before production","Use `override` keyword for compile-time protection","Watch for duplicate MnemopiPlugin copies in node_modules that break prototype identity"],"tags":["typescript","plugins","unimplemented-method"],"backgroundTag":"unimplemented-hook-method","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}