cognitive-core 0.0.2 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.json +88 -0
- package/.claude/settings.local.json +11 -0
- package/.entire/settings.json +4 -0
- package/README.md +563 -107
- package/SKILL.md +193 -0
- package/dist/agents/index.d.ts +3 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +5 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/mock-provider.d.ts +23 -0
- package/dist/agents/mock-provider.d.ts.map +1 -0
- package/dist/agents/mock-provider.js +71 -0
- package/dist/agents/mock-provider.js.map +1 -0
- package/dist/agents/types.d.ts +98 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +44 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/atlas.d.ts +334 -0
- package/dist/atlas.d.ts.map +1 -0
- package/dist/atlas.js +702 -0
- package/dist/atlas.js.map +1 -0
- package/dist/bin/cognitive-core.d.ts +18 -0
- package/dist/bin/cognitive-core.d.ts.map +1 -0
- package/dist/bin/cognitive-core.js +419 -0
- package/dist/bin/cognitive-core.js.map +1 -0
- package/dist/embeddings/bm25.d.ts +104 -0
- package/dist/embeddings/bm25.d.ts.map +1 -0
- package/dist/embeddings/bm25.js +264 -0
- package/dist/embeddings/bm25.js.map +1 -0
- package/dist/embeddings/index.d.ts +12 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +16 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/embeddings/manager.d.ts +112 -0
- package/dist/embeddings/manager.d.ts.map +1 -0
- package/dist/embeddings/manager.js +215 -0
- package/dist/embeddings/manager.js.map +1 -0
- package/dist/embeddings/provider.d.ts +101 -0
- package/dist/embeddings/provider.d.ts.map +1 -0
- package/dist/embeddings/provider.js +235 -0
- package/dist/embeddings/provider.js.map +1 -0
- package/dist/embeddings/vector-store.d.ts +101 -0
- package/dist/embeddings/vector-store.d.ts.map +1 -0
- package/dist/embeddings/vector-store.js +256 -0
- package/dist/embeddings/vector-store.js.map +1 -0
- package/dist/factory.d.ts +193 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +109 -0
- package/dist/factory.js.map +1 -0
- package/dist/index.d.ts +32 -453
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +115 -509
- package/dist/index.js.map +1 -0
- package/dist/learning/analyzer.d.ts +110 -0
- package/dist/learning/analyzer.d.ts.map +1 -0
- package/dist/learning/analyzer.js +213 -0
- package/dist/learning/analyzer.js.map +1 -0
- package/dist/learning/effectiveness.d.ts +158 -0
- package/dist/learning/effectiveness.d.ts.map +1 -0
- package/dist/learning/effectiveness.js +251 -0
- package/dist/learning/effectiveness.js.map +1 -0
- package/dist/learning/index.d.ts +12 -0
- package/dist/learning/index.d.ts.map +1 -0
- package/dist/learning/index.js +17 -0
- package/dist/learning/index.js.map +1 -0
- package/dist/learning/knowledge-extractor.d.ts +56 -0
- package/dist/learning/knowledge-extractor.d.ts.map +1 -0
- package/dist/learning/knowledge-extractor.js +336 -0
- package/dist/learning/knowledge-extractor.js.map +1 -0
- package/dist/learning/llm-extractor.d.ts +88 -0
- package/dist/learning/llm-extractor.d.ts.map +1 -0
- package/dist/learning/llm-extractor.js +372 -0
- package/dist/learning/llm-extractor.js.map +1 -0
- package/dist/learning/meta-learner.d.ts +87 -0
- package/dist/learning/meta-learner.d.ts.map +1 -0
- package/dist/learning/meta-learner.js +398 -0
- package/dist/learning/meta-learner.js.map +1 -0
- package/dist/learning/pipeline.d.ts +89 -0
- package/dist/learning/pipeline.d.ts.map +1 -0
- package/dist/learning/pipeline.js +236 -0
- package/dist/learning/pipeline.js.map +1 -0
- package/dist/learning/playbook-extractor.d.ts +113 -0
- package/dist/learning/playbook-extractor.d.ts.map +1 -0
- package/dist/learning/playbook-extractor.js +523 -0
- package/dist/learning/playbook-extractor.js.map +1 -0
- package/dist/learning/team-ingester.d.ts +152 -0
- package/dist/learning/team-ingester.d.ts.map +1 -0
- package/dist/learning/team-ingester.js +333 -0
- package/dist/learning/team-ingester.js.map +1 -0
- package/dist/learning/team-meta-learner.d.ts +50 -0
- package/dist/learning/team-meta-learner.d.ts.map +1 -0
- package/dist/learning/team-meta-learner.js +417 -0
- package/dist/learning/team-meta-learner.js.map +1 -0
- package/dist/learning/team-pipeline.d.ts +76 -0
- package/dist/learning/team-pipeline.d.ts.map +1 -0
- package/dist/learning/team-pipeline.js +266 -0
- package/dist/learning/team-pipeline.js.map +1 -0
- package/dist/learning/trajectory-sources/dataclaw.d.ts +41 -0
- package/dist/learning/trajectory-sources/dataclaw.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/dataclaw.js +330 -0
- package/dist/learning/trajectory-sources/dataclaw.js.map +1 -0
- package/dist/learning/trajectory-sources/entire.d.ts +28 -0
- package/dist/learning/trajectory-sources/entire.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/entire.js +182 -0
- package/dist/learning/trajectory-sources/entire.js.map +1 -0
- package/dist/learning/trajectory-sources/file.d.ts +23 -0
- package/dist/learning/trajectory-sources/file.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/file.js +101 -0
- package/dist/learning/trajectory-sources/file.js.map +1 -0
- package/dist/learning/trajectory-sources/huggingface.d.ts +36 -0
- package/dist/learning/trajectory-sources/huggingface.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/huggingface.js +157 -0
- package/dist/learning/trajectory-sources/huggingface.js.map +1 -0
- package/dist/learning/trajectory-sources/in-memory.d.ts +21 -0
- package/dist/learning/trajectory-sources/in-memory.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/in-memory.js +43 -0
- package/dist/learning/trajectory-sources/in-memory.js.map +1 -0
- package/dist/learning/trajectory-sources/index.d.ts +7 -0
- package/dist/learning/trajectory-sources/index.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/index.js +7 -0
- package/dist/learning/trajectory-sources/index.js.map +1 -0
- package/dist/learning/trajectory-sources/pipeline.d.ts +24 -0
- package/dist/learning/trajectory-sources/pipeline.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/pipeline.js +47 -0
- package/dist/learning/trajectory-sources/pipeline.js.map +1 -0
- package/dist/learning/usage-inference.d.ts +82 -0
- package/dist/learning/usage-inference.d.ts.map +1 -0
- package/dist/learning/usage-inference.js +261 -0
- package/dist/learning/usage-inference.js.map +1 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +6 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/playbook-server.d.ts +120 -0
- package/dist/mcp/playbook-server.d.ts.map +1 -0
- package/dist/mcp/playbook-server.js +427 -0
- package/dist/mcp/playbook-server.js.map +1 -0
- package/dist/memory/curated-loader.d.ts +62 -0
- package/dist/memory/curated-loader.d.ts.map +1 -0
- package/dist/memory/curated-loader.js +106 -0
- package/dist/memory/curated-loader.js.map +1 -0
- package/dist/memory/experience.d.ts +122 -0
- package/dist/memory/experience.d.ts.map +1 -0
- package/dist/memory/experience.js +392 -0
- package/dist/memory/experience.js.map +1 -0
- package/dist/memory/graph-layers/base.d.ts +29 -0
- package/dist/memory/graph-layers/base.d.ts.map +1 -0
- package/dist/memory/graph-layers/base.js +143 -0
- package/dist/memory/graph-layers/base.js.map +1 -0
- package/dist/memory/graph-layers/causal.d.ts +14 -0
- package/dist/memory/graph-layers/causal.d.ts.map +1 -0
- package/dist/memory/graph-layers/causal.js +14 -0
- package/dist/memory/graph-layers/causal.js.map +1 -0
- package/dist/memory/graph-layers/entity.d.ts +14 -0
- package/dist/memory/graph-layers/entity.d.ts.map +1 -0
- package/dist/memory/graph-layers/entity.js +14 -0
- package/dist/memory/graph-layers/entity.js.map +1 -0
- package/dist/memory/graph-layers/index.d.ts +6 -0
- package/dist/memory/graph-layers/index.d.ts.map +1 -0
- package/dist/memory/graph-layers/index.js +6 -0
- package/dist/memory/graph-layers/index.js.map +1 -0
- package/dist/memory/graph-layers/semantic.d.ts +14 -0
- package/dist/memory/graph-layers/semantic.d.ts.map +1 -0
- package/dist/memory/graph-layers/semantic.js +14 -0
- package/dist/memory/graph-layers/semantic.js.map +1 -0
- package/dist/memory/graph-layers/temporal.d.ts +14 -0
- package/dist/memory/graph-layers/temporal.d.ts.map +1 -0
- package/dist/memory/graph-layers/temporal.js +14 -0
- package/dist/memory/graph-layers/temporal.js.map +1 -0
- package/dist/memory/index.d.ts +14 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +19 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/knowledge-bank.d.ts +220 -0
- package/dist/memory/knowledge-bank.d.ts.map +1 -0
- package/dist/memory/knowledge-bank.js +1003 -0
- package/dist/memory/knowledge-bank.js.map +1 -0
- package/dist/memory/knowledge-defrag.d.ts +49 -0
- package/dist/memory/knowledge-defrag.d.ts.map +1 -0
- package/dist/memory/knowledge-defrag.js +257 -0
- package/dist/memory/knowledge-defrag.js.map +1 -0
- package/dist/memory/knowledge-graph.d.ts +41 -0
- package/dist/memory/knowledge-graph.d.ts.map +1 -0
- package/dist/memory/knowledge-graph.js +273 -0
- package/dist/memory/knowledge-graph.js.map +1 -0
- package/dist/memory/meta.d.ts +90 -0
- package/dist/memory/meta.d.ts.map +1 -0
- package/dist/memory/meta.js +362 -0
- package/dist/memory/meta.js.map +1 -0
- package/dist/memory/playbook.d.ts +133 -0
- package/dist/memory/playbook.d.ts.map +1 -0
- package/dist/memory/playbook.js +357 -0
- package/dist/memory/playbook.js.map +1 -0
- package/dist/memory/search-provider.d.ts +31 -0
- package/dist/memory/search-provider.d.ts.map +1 -0
- package/dist/memory/search-provider.js +2 -0
- package/dist/memory/search-provider.js.map +1 -0
- package/dist/memory/search-providers/index.d.ts +3 -0
- package/dist/memory/search-providers/index.d.ts.map +1 -0
- package/dist/memory/search-providers/index.js +3 -0
- package/dist/memory/search-providers/index.js.map +1 -0
- package/dist/memory/search-providers/minimem.d.ts +43 -0
- package/dist/memory/search-providers/minimem.d.ts.map +1 -0
- package/dist/memory/search-providers/minimem.js +56 -0
- package/dist/memory/search-providers/minimem.js.map +1 -0
- package/dist/memory/search-providers/text-similarity.d.ts +15 -0
- package/dist/memory/search-providers/text-similarity.d.ts.map +1 -0
- package/dist/memory/search-providers/text-similarity.js +21 -0
- package/dist/memory/search-providers/text-similarity.js.map +1 -0
- package/dist/memory/skill-exporter.d.ts +75 -0
- package/dist/memory/skill-exporter.d.ts.map +1 -0
- package/dist/memory/skill-exporter.js +248 -0
- package/dist/memory/skill-exporter.js.map +1 -0
- package/dist/memory/system.d.ts +179 -0
- package/dist/memory/system.d.ts.map +1 -0
- package/dist/memory/system.js +421 -0
- package/dist/memory/system.js.map +1 -0
- package/dist/memory/team-experience.d.ts +298 -0
- package/dist/memory/team-experience.d.ts.map +1 -0
- package/dist/memory/team-experience.js +355 -0
- package/dist/memory/team-experience.js.map +1 -0
- package/dist/runtime/backends/acp-protocol.d.ts +49 -0
- package/dist/runtime/backends/acp-protocol.d.ts.map +1 -0
- package/dist/runtime/backends/acp-protocol.js +166 -0
- package/dist/runtime/backends/acp-protocol.js.map +1 -0
- package/dist/runtime/backends/acp.d.ts +67 -0
- package/dist/runtime/backends/acp.d.ts.map +1 -0
- package/dist/runtime/backends/acp.js +166 -0
- package/dist/runtime/backends/acp.js.map +1 -0
- package/dist/runtime/backends/index.d.ts +7 -0
- package/dist/runtime/backends/index.d.ts.map +1 -0
- package/dist/runtime/backends/index.js +8 -0
- package/dist/runtime/backends/index.js.map +1 -0
- package/dist/runtime/backends/macro-agent.d.ts +104 -0
- package/dist/runtime/backends/macro-agent.d.ts.map +1 -0
- package/dist/runtime/backends/macro-agent.js +107 -0
- package/dist/runtime/backends/macro-agent.js.map +1 -0
- package/dist/runtime/backends/mock.d.ts +67 -0
- package/dist/runtime/backends/mock.d.ts.map +1 -0
- package/dist/runtime/backends/mock.js +153 -0
- package/dist/runtime/backends/mock.js.map +1 -0
- package/dist/runtime/backends/subprocess.d.ts +56 -0
- package/dist/runtime/backends/subprocess.d.ts.map +1 -0
- package/dist/runtime/backends/subprocess.js +260 -0
- package/dist/runtime/backends/subprocess.js.map +1 -0
- package/dist/runtime/compute-provider.d.ts +87 -0
- package/dist/runtime/compute-provider.d.ts.map +1 -0
- package/dist/runtime/compute-provider.js +87 -0
- package/dist/runtime/compute-provider.js.map +1 -0
- package/dist/runtime/flows/learning.d.ts +73 -0
- package/dist/runtime/flows/learning.d.ts.map +1 -0
- package/dist/runtime/flows/learning.js +116 -0
- package/dist/runtime/flows/learning.js.map +1 -0
- package/dist/runtime/flows/validation.d.ts +122 -0
- package/dist/runtime/flows/validation.d.ts.map +1 -0
- package/dist/runtime/flows/validation.js +223 -0
- package/dist/runtime/flows/validation.js.map +1 -0
- package/dist/runtime/index.d.ts +7 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +10 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/manager.d.ts +149 -0
- package/dist/runtime/manager.d.ts.map +1 -0
- package/dist/runtime/manager.js +535 -0
- package/dist/runtime/manager.js.map +1 -0
- package/dist/runtime/types.d.ts +176 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +2 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/search/evaluator.d.ts +109 -0
- package/dist/search/evaluator.d.ts.map +1 -0
- package/dist/search/evaluator.js +372 -0
- package/dist/search/evaluator.js.map +1 -0
- package/dist/search/index.d.ts +8 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +13 -0
- package/dist/search/index.js.map +1 -0
- package/dist/search/refinement-loop.d.ts +90 -0
- package/dist/search/refinement-loop.d.ts.map +1 -0
- package/dist/search/refinement-loop.js +316 -0
- package/dist/search/refinement-loop.js.map +1 -0
- package/dist/search/refinement-types.d.ts +154 -0
- package/dist/search/refinement-types.d.ts.map +1 -0
- package/dist/search/refinement-types.js +99 -0
- package/dist/search/refinement-types.js.map +1 -0
- package/dist/search/router.d.ts +61 -0
- package/dist/search/router.d.ts.map +1 -0
- package/dist/search/router.js +197 -0
- package/dist/search/router.js.map +1 -0
- package/dist/search/solver.d.ts +75 -0
- package/dist/search/solver.d.ts.map +1 -0
- package/dist/search/solver.js +216 -0
- package/dist/search/solver.js.map +1 -0
- package/dist/search/team-router.d.ts +91 -0
- package/dist/search/team-router.d.ts.map +1 -0
- package/dist/search/team-router.js +315 -0
- package/dist/search/team-router.js.map +1 -0
- package/dist/search/verification-runner.d.ts +125 -0
- package/dist/search/verification-runner.d.ts.map +1 -0
- package/dist/search/verification-runner.js +440 -0
- package/dist/search/verification-runner.js.map +1 -0
- package/dist/session-bank/git-reader.d.ts +39 -0
- package/dist/session-bank/git-reader.d.ts.map +1 -0
- package/dist/session-bank/git-reader.js +165 -0
- package/dist/session-bank/git-reader.js.map +1 -0
- package/dist/session-bank/index.d.ts +5 -0
- package/dist/session-bank/index.d.ts.map +1 -0
- package/dist/session-bank/index.js +4 -0
- package/dist/session-bank/index.js.map +1 -0
- package/dist/session-bank/parser.d.ts +39 -0
- package/dist/session-bank/parser.d.ts.map +1 -0
- package/dist/session-bank/parser.js +231 -0
- package/dist/session-bank/parser.js.map +1 -0
- package/dist/session-bank/session-bank.d.ts +35 -0
- package/dist/session-bank/session-bank.d.ts.map +1 -0
- package/dist/session-bank/session-bank.js +326 -0
- package/dist/session-bank/session-bank.js.map +1 -0
- package/dist/session-bank/types.d.ts +129 -0
- package/dist/session-bank/types.d.ts.map +1 -0
- package/dist/session-bank/types.js +7 -0
- package/dist/session-bank/types.js.map +1 -0
- package/dist/surfacing/index.d.ts +6 -0
- package/dist/surfacing/index.d.ts.map +1 -0
- package/dist/surfacing/index.js +5 -0
- package/dist/surfacing/index.js.map +1 -0
- package/dist/surfacing/publisher.d.ts +22 -0
- package/dist/surfacing/publisher.d.ts.map +1 -0
- package/dist/surfacing/publisher.js +9 -0
- package/dist/surfacing/publisher.js.map +1 -0
- package/dist/surfacing/skill-library.d.ts +170 -0
- package/dist/surfacing/skill-library.d.ts.map +1 -0
- package/dist/surfacing/skill-library.js +455 -0
- package/dist/surfacing/skill-library.js.map +1 -0
- package/dist/surfacing/skill-publisher.d.ts +43 -0
- package/dist/surfacing/skill-publisher.d.ts.map +1 -0
- package/dist/surfacing/skill-publisher.js +197 -0
- package/dist/surfacing/skill-publisher.js.map +1 -0
- package/dist/surfacing/sqlite-storage-adapter.d.ts +42 -0
- package/dist/surfacing/sqlite-storage-adapter.d.ts.map +1 -0
- package/dist/surfacing/sqlite-storage-adapter.js +207 -0
- package/dist/surfacing/sqlite-storage-adapter.js.map +1 -0
- package/dist/surfacing/team-skill-library.d.ts +180 -0
- package/dist/surfacing/team-skill-library.d.ts.map +1 -0
- package/dist/surfacing/team-skill-library.js +384 -0
- package/dist/surfacing/team-skill-library.js.map +1 -0
- package/dist/types/config.d.ts +2287 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +490 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/dataclaw.d.ts +286 -0
- package/dist/types/dataclaw.d.ts.map +1 -0
- package/dist/types/dataclaw.js +84 -0
- package/dist/types/dataclaw.js.map +1 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +26 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/knowledge-graph.d.ts +148 -0
- package/dist/types/knowledge-graph.d.ts.map +1 -0
- package/dist/types/knowledge-graph.js +40 -0
- package/dist/types/knowledge-graph.js.map +1 -0
- package/dist/types/knowledge.d.ts +280 -0
- package/dist/types/knowledge.d.ts.map +1 -0
- package/dist/types/knowledge.js +191 -0
- package/dist/types/knowledge.js.map +1 -0
- package/dist/types/memory.d.ts +339 -0
- package/dist/types/memory.d.ts.map +1 -0
- package/dist/types/memory.js +207 -0
- package/dist/types/memory.js.map +1 -0
- package/dist/types/meta.d.ts +146 -0
- package/dist/types/meta.d.ts.map +1 -0
- package/dist/types/meta.js +51 -0
- package/dist/types/meta.js.map +1 -0
- package/dist/types/outcome.d.ts +42 -0
- package/dist/types/outcome.d.ts.map +1 -0
- package/dist/types/outcome.js +50 -0
- package/dist/types/outcome.js.map +1 -0
- package/dist/types/playbook.d.ts +119 -0
- package/dist/types/playbook.d.ts.map +1 -0
- package/dist/types/playbook.js +71 -0
- package/dist/types/playbook.js.map +1 -0
- package/dist/types/step.d.ts +44 -0
- package/dist/types/step.d.ts.map +1 -0
- package/dist/types/step.js +32 -0
- package/dist/types/step.js.map +1 -0
- package/dist/types/task.d.ts +91 -0
- package/dist/types/task.d.ts.map +1 -0
- package/dist/types/task.js +39 -0
- package/dist/types/task.js.map +1 -0
- package/dist/types/team-meta.d.ts +160 -0
- package/dist/types/team-meta.d.ts.map +1 -0
- package/dist/types/team-meta.js +42 -0
- package/dist/types/team-meta.js.map +1 -0
- package/dist/types/team-playbook.d.ts +276 -0
- package/dist/types/team-playbook.d.ts.map +1 -0
- package/dist/types/team-playbook.js +85 -0
- package/dist/types/team-playbook.js.map +1 -0
- package/dist/types/team-trajectory.d.ts +305 -0
- package/dist/types/team-trajectory.d.ts.map +1 -0
- package/dist/types/team-trajectory.js +304 -0
- package/dist/types/team-trajectory.js.map +1 -0
- package/dist/types/trajectory-source.d.ts +39 -0
- package/dist/types/trajectory-source.d.ts.map +1 -0
- package/dist/types/trajectory-source.js +2 -0
- package/dist/types/trajectory-source.js.map +1 -0
- package/dist/types/trajectory.d.ts +221 -0
- package/dist/types/trajectory.d.ts.map +1 -0
- package/dist/types/trajectory.js +60 -0
- package/dist/types/trajectory.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +34 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +93 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/similarity.d.ts +31 -0
- package/dist/utils/similarity.d.ts.map +1 -0
- package/dist/utils/similarity.js +107 -0
- package/dist/utils/similarity.js.map +1 -0
- package/dist/utils/storage.d.ts +106 -0
- package/dist/utils/storage.d.ts.map +1 -0
- package/dist/utils/storage.js +203 -0
- package/dist/utils/storage.js.map +1 -0
- package/dist/utils/validation.d.ts +129 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +171 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/workspace/index.d.ts +6 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +11 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/runner.d.ts +50 -0
- package/dist/workspace/runner.d.ts.map +1 -0
- package/dist/workspace/runner.js +219 -0
- package/dist/workspace/runner.js.map +1 -0
- package/dist/workspace/skill-converter.d.ts +18 -0
- package/dist/workspace/skill-converter.d.ts.map +1 -0
- package/dist/workspace/skill-converter.js +257 -0
- package/dist/workspace/skill-converter.js.map +1 -0
- package/dist/workspace/templates/index.d.ts +11 -0
- package/dist/workspace/templates/index.d.ts.map +1 -0
- package/dist/workspace/templates/index.js +21 -0
- package/dist/workspace/templates/index.js.map +1 -0
- package/dist/workspace/templates/knowledge-defrag.d.ts +25 -0
- package/dist/workspace/templates/knowledge-defrag.d.ts.map +1 -0
- package/dist/workspace/templates/knowledge-defrag.js +154 -0
- package/dist/workspace/templates/knowledge-defrag.js.map +1 -0
- package/dist/workspace/templates/knowledge-extraction.d.ts +25 -0
- package/dist/workspace/templates/knowledge-extraction.d.ts.map +1 -0
- package/dist/workspace/templates/knowledge-extraction.js +246 -0
- package/dist/workspace/templates/knowledge-extraction.js.map +1 -0
- package/dist/workspace/templates/meta-reflection.d.ts +47 -0
- package/dist/workspace/templates/meta-reflection.d.ts.map +1 -0
- package/dist/workspace/templates/meta-reflection.js +135 -0
- package/dist/workspace/templates/meta-reflection.js.map +1 -0
- package/dist/workspace/templates/playbook-extraction.d.ts +20 -0
- package/dist/workspace/templates/playbook-extraction.d.ts.map +1 -0
- package/dist/workspace/templates/playbook-extraction.js +189 -0
- package/dist/workspace/templates/playbook-extraction.js.map +1 -0
- package/dist/workspace/templates/refinement-analysis.d.ts +31 -0
- package/dist/workspace/templates/refinement-analysis.d.ts.map +1 -0
- package/dist/workspace/templates/refinement-analysis.js +107 -0
- package/dist/workspace/templates/refinement-analysis.js.map +1 -0
- package/dist/workspace/templates/solution-evaluation.d.ts +21 -0
- package/dist/workspace/templates/solution-evaluation.d.ts.map +1 -0
- package/dist/workspace/templates/solution-evaluation.js +131 -0
- package/dist/workspace/templates/solution-evaluation.js.map +1 -0
- package/dist/workspace/templates/team-playbook-extraction.d.ts +44 -0
- package/dist/workspace/templates/team-playbook-extraction.d.ts.map +1 -0
- package/dist/workspace/templates/team-playbook-extraction.js +497 -0
- package/dist/workspace/templates/team-playbook-extraction.js.map +1 -0
- package/dist/workspace/templates/team-trajectory-analysis.d.ts +19 -0
- package/dist/workspace/templates/team-trajectory-analysis.d.ts.map +1 -0
- package/dist/workspace/templates/team-trajectory-analysis.js +442 -0
- package/dist/workspace/templates/team-trajectory-analysis.js.map +1 -0
- package/dist/workspace/templates/trajectory-analysis.d.ts +19 -0
- package/dist/workspace/templates/trajectory-analysis.d.ts.map +1 -0
- package/dist/workspace/templates/trajectory-analysis.js +170 -0
- package/dist/workspace/templates/trajectory-analysis.js.map +1 -0
- package/dist/workspace/templates/usage-inference.d.ts +19 -0
- package/dist/workspace/templates/usage-inference.d.ts.map +1 -0
- package/dist/workspace/templates/usage-inference.js +125 -0
- package/dist/workspace/templates/usage-inference.js.map +1 -0
- package/dist/workspace/types.d.ts +145 -0
- package/dist/workspace/types.d.ts.map +1 -0
- package/dist/workspace/types.js +17 -0
- package/dist/workspace/types.js.map +1 -0
- package/docs/DESIGN-agentic-workspace.md +2057 -0
- package/docs/DESIGN-semantic-memory-knowledge-bank.md +1789 -0
- package/docs/DESIGN-session-bank.md +1134 -0
- package/docs/DESIGN-team-extraction-pipeline.md +1369 -0
- package/docs/DESIGN-workspace-migration.md +1079 -0
- package/docs/PLAN-agentic-workspace-implementation.md +717 -0
- package/docs/PLAN-graph-migration.md +299 -0
- package/docs/PLAN-session-bank-implementation.md +474 -0
- package/docs/PROPOSAL-team-aware-learning.md +1080 -0
- package/docs/RESEARCH-semantic-memory-knowledge-structures.md +517 -0
- package/docs/RESEARCH-team-trajectory-learning.md +553 -0
- package/gaps.md +204 -0
- package/package.json +67 -33
- package/references/agent-workspace/CLAUDE.md +74 -0
- package/references/agent-workspace/README.md +587 -0
- package/references/agent-workspace/media/banner.png +0 -0
- package/references/agent-workspace/package-lock.json +2061 -0
- package/references/agent-workspace/package.json +54 -0
- package/references/agent-workspace/src/handle.ts +122 -0
- package/references/agent-workspace/src/index.ts +32 -0
- package/references/agent-workspace/src/manager.ts +102 -0
- package/references/agent-workspace/src/readers/json.ts +71 -0
- package/references/agent-workspace/src/readers/markdown.ts +37 -0
- package/references/agent-workspace/src/readers/raw.ts +27 -0
- package/references/agent-workspace/src/types.ts +68 -0
- package/references/agent-workspace/src/validation.ts +93 -0
- package/references/agent-workspace/src/writers/json.ts +17 -0
- package/references/agent-workspace/src/writers/markdown.ts +27 -0
- package/references/agent-workspace/src/writers/raw.ts +22 -0
- package/references/agent-workspace/tests/errors.test.ts +652 -0
- package/references/agent-workspace/tests/handle.test.ts +144 -0
- package/references/agent-workspace/tests/manager.test.ts +124 -0
- package/references/agent-workspace/tests/readers.test.ts +205 -0
- package/references/agent-workspace/tests/validation.test.ts +196 -0
- package/references/agent-workspace/tests/writers.test.ts +108 -0
- package/references/agent-workspace/tsconfig.json +20 -0
- package/references/agent-workspace/tsup.config.ts +9 -0
- package/references/minimem/.claude/settings.json +7 -0
- package/references/minimem/.sudocode/issues.jsonl +18 -0
- package/references/minimem/.sudocode/specs.jsonl +1 -0
- package/references/minimem/CLAUDE.md +310 -0
- package/references/minimem/README.md +556 -0
- package/references/minimem/claude-plugin/.claude-plugin/plugin.json +10 -0
- package/references/minimem/claude-plugin/.mcp.json +7 -0
- package/references/minimem/claude-plugin/README.md +158 -0
- package/references/minimem/claude-plugin/commands/recall.md +47 -0
- package/references/minimem/claude-plugin/commands/remember.md +41 -0
- package/references/minimem/claude-plugin/hooks/__tests__/hooks.test.ts +272 -0
- package/references/minimem/claude-plugin/hooks/hooks.json +27 -0
- package/references/minimem/claude-plugin/hooks/session-end.sh +86 -0
- package/references/minimem/claude-plugin/hooks/session-start.sh +85 -0
- package/references/minimem/claude-plugin/skills/memory/SKILL.md +108 -0
- package/references/minimem/package-lock.json +5373 -0
- package/references/minimem/package.json +60 -0
- package/references/minimem/scripts/postbuild.js +35 -0
- package/references/minimem/src/__tests__/edge-cases.test.ts +371 -0
- package/references/minimem/src/__tests__/errors.test.ts +265 -0
- package/references/minimem/src/__tests__/helpers.ts +199 -0
- package/references/minimem/src/__tests__/internal.test.ts +407 -0
- package/references/minimem/src/__tests__/knowledge.test.ts +287 -0
- package/references/minimem/src/__tests__/minimem.integration.test.ts +1127 -0
- package/references/minimem/src/__tests__/session.test.ts +190 -0
- package/references/minimem/src/cli/__tests__/commands.test.ts +759 -0
- package/references/minimem/src/cli/commands/__tests__/conflicts.test.ts +141 -0
- package/references/minimem/src/cli/commands/append.ts +76 -0
- package/references/minimem/src/cli/commands/config.ts +262 -0
- package/references/minimem/src/cli/commands/conflicts.ts +413 -0
- package/references/minimem/src/cli/commands/daemon.ts +169 -0
- package/references/minimem/src/cli/commands/index.ts +12 -0
- package/references/minimem/src/cli/commands/init.ts +88 -0
- package/references/minimem/src/cli/commands/mcp.ts +177 -0
- package/references/minimem/src/cli/commands/push-pull.ts +213 -0
- package/references/minimem/src/cli/commands/search.ts +158 -0
- package/references/minimem/src/cli/commands/status.ts +84 -0
- package/references/minimem/src/cli/commands/sync-init.ts +290 -0
- package/references/minimem/src/cli/commands/sync.ts +70 -0
- package/references/minimem/src/cli/commands/upsert.ts +197 -0
- package/references/minimem/src/cli/config.ts +584 -0
- package/references/minimem/src/cli/index.ts +264 -0
- package/references/minimem/src/cli/shared.ts +161 -0
- package/references/minimem/src/cli/sync/__tests__/central.test.ts +152 -0
- package/references/minimem/src/cli/sync/__tests__/conflicts.test.ts +209 -0
- package/references/minimem/src/cli/sync/__tests__/daemon.test.ts +118 -0
- package/references/minimem/src/cli/sync/__tests__/detection.test.ts +207 -0
- package/references/minimem/src/cli/sync/__tests__/integration.test.ts +476 -0
- package/references/minimem/src/cli/sync/__tests__/registry.test.ts +363 -0
- package/references/minimem/src/cli/sync/__tests__/state.test.ts +255 -0
- package/references/minimem/src/cli/sync/__tests__/validation.test.ts +193 -0
- package/references/minimem/src/cli/sync/__tests__/watcher.test.ts +178 -0
- package/references/minimem/src/cli/sync/central.ts +292 -0
- package/references/minimem/src/cli/sync/conflicts.ts +204 -0
- package/references/minimem/src/cli/sync/daemon.ts +407 -0
- package/references/minimem/src/cli/sync/detection.ts +138 -0
- package/references/minimem/src/cli/sync/index.ts +107 -0
- package/references/minimem/src/cli/sync/operations.ts +373 -0
- package/references/minimem/src/cli/sync/registry.ts +279 -0
- package/references/minimem/src/cli/sync/state.ts +355 -0
- package/references/minimem/src/cli/sync/validation.ts +206 -0
- package/references/minimem/src/cli/sync/watcher.ts +234 -0
- package/references/minimem/src/cli/version.ts +34 -0
- package/references/minimem/src/core/index.ts +9 -0
- package/references/minimem/src/core/indexer.ts +628 -0
- package/references/minimem/src/core/searcher.ts +221 -0
- package/references/minimem/src/db/schema.ts +183 -0
- package/references/minimem/src/db/sqlite-vec.ts +24 -0
- package/references/minimem/src/embeddings/__tests__/embeddings.test.ts +431 -0
- package/references/minimem/src/embeddings/batch-gemini.ts +392 -0
- package/references/minimem/src/embeddings/batch-openai.ts +409 -0
- package/references/minimem/src/embeddings/embeddings.ts +434 -0
- package/references/minimem/src/index.ts +109 -0
- package/references/minimem/src/internal.ts +299 -0
- package/references/minimem/src/minimem.ts +1276 -0
- package/references/minimem/src/search/__tests__/hybrid.test.ts +247 -0
- package/references/minimem/src/search/graph.ts +234 -0
- package/references/minimem/src/search/hybrid.ts +151 -0
- package/references/minimem/src/search/search.ts +256 -0
- package/references/minimem/src/server/__tests__/mcp.test.ts +341 -0
- package/references/minimem/src/server/__tests__/tools.test.ts +364 -0
- package/references/minimem/src/server/mcp.ts +326 -0
- package/references/minimem/src/server/tools.ts +720 -0
- package/references/minimem/src/session.ts +460 -0
- package/references/minimem/tsconfig.json +19 -0
- package/references/minimem/tsup.config.ts +26 -0
- package/references/minimem/vitest.config.ts +24 -0
- package/references/skill-tree/.claude/settings.json +6 -0
- package/references/skill-tree/.sudocode/issues.jsonl +11 -0
- package/references/skill-tree/.sudocode/specs.jsonl +1 -0
- package/references/skill-tree/CLAUDE.md +150 -0
- package/references/skill-tree/README.md +324 -0
- package/references/skill-tree/docs/GAPS_v1.md +221 -0
- package/references/skill-tree/docs/INTEGRATION_PLAN.md +467 -0
- package/references/skill-tree/docs/TODOS.md +91 -0
- package/references/skill-tree/docs/anthropic_skill_guide.md +1364 -0
- package/references/skill-tree/docs/design/federated-skill-trees.md +524 -0
- package/references/skill-tree/docs/design/multi-agent-sync.md +759 -0
- package/references/skill-tree/docs/scraper/BRAINSTORM.md +583 -0
- package/references/skill-tree/docs/scraper/POC_PLAN.md +420 -0
- package/references/skill-tree/docs/scraper/README.md +170 -0
- package/references/skill-tree/examples/basic-usage.ts +190 -0
- package/references/skill-tree/package-lock.json +1509 -0
- package/references/skill-tree/package.json +66 -0
- package/references/skill-tree/scraper/README.md +123 -0
- package/references/skill-tree/scraper/docs/DESIGN.md +683 -0
- package/references/skill-tree/scraper/docs/PLAN.md +336 -0
- package/references/skill-tree/scraper/drizzle.config.ts +10 -0
- package/references/skill-tree/scraper/package-lock.json +6329 -0
- package/references/skill-tree/scraper/package.json +68 -0
- package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-description.md +7 -0
- package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-name.md +7 -0
- package/references/skill-tree/scraper/test/fixtures/minimal-skill/SKILL.md +27 -0
- package/references/skill-tree/scraper/test/fixtures/skill-json/SKILL.json +21 -0
- package/references/skill-tree/scraper/test/fixtures/skill-with-meta/SKILL.md +54 -0
- package/references/skill-tree/scraper/test/fixtures/skill-with-meta/_meta.json +24 -0
- package/references/skill-tree/scraper/test/fixtures/valid-skill/SKILL.md +93 -0
- package/references/skill-tree/scraper/test/fixtures/valid-skill/_meta.json +22 -0
- package/references/skill-tree/scraper/tsup.config.ts +14 -0
- package/references/skill-tree/scraper/vitest.config.ts +17 -0
- package/references/skill-tree/scripts/convert-to-vitest.ts +166 -0
- package/references/skill-tree/skills/skill-writer/SKILL.md +339 -0
- package/references/skill-tree/skills/skill-writer/references/examples.md +326 -0
- package/references/skill-tree/skills/skill-writer/references/patterns.md +210 -0
- package/references/skill-tree/skills/skill-writer/references/quality-checklist.md +123 -0
- package/references/skill-tree/test/run-all.ts +106 -0
- package/references/skill-tree/test/utils.ts +128 -0
- package/references/skill-tree/vitest.config.ts +16 -0
- package/scripts/migrate-to-playbooks.ts +307 -0
- package/src/agents/index.ts +14 -0
- package/src/agents/mock-provider.ts +93 -0
- package/src/agents/types.ts +137 -0
- package/src/atlas.ts +1072 -0
- package/src/bin/cognitive-core.ts +470 -0
- package/src/embeddings/bm25.ts +337 -0
- package/src/embeddings/index.ts +39 -0
- package/src/embeddings/manager.ts +288 -0
- package/src/embeddings/provider.ts +318 -0
- package/src/embeddings/vector-store.ts +353 -0
- package/src/factory.ts +263 -0
- package/src/index.ts +368 -0
- package/src/learning/analyzer.ts +335 -0
- package/src/learning/effectiveness.ts +428 -0
- package/src/learning/index.ts +93 -0
- package/src/learning/knowledge-extractor.ts +470 -0
- package/src/learning/meta-learner.ts +570 -0
- package/src/learning/pipeline.ts +323 -0
- package/src/learning/playbook-extractor.ts +702 -0
- package/src/learning/team-ingester.ts +499 -0
- package/src/learning/team-meta-learner.ts +558 -0
- package/src/learning/team-pipeline.ts +364 -0
- package/src/learning/trajectory-sources/dataclaw.ts +403 -0
- package/src/learning/trajectory-sources/entire.ts +240 -0
- package/src/learning/trajectory-sources/file.ts +136 -0
- package/src/learning/trajectory-sources/huggingface.ts +248 -0
- package/src/learning/trajectory-sources/in-memory.ts +61 -0
- package/src/learning/trajectory-sources/index.ts +15 -0
- package/src/learning/trajectory-sources/pipeline.ts +69 -0
- package/src/learning/usage-inference.ts +372 -0
- package/src/mcp/index.ts +12 -0
- package/src/mcp/playbook-server.ts +565 -0
- package/src/memory/curated-loader.ts +160 -0
- package/src/memory/experience.ts +515 -0
- package/src/memory/graph-layers/base.ts +184 -0
- package/src/memory/graph-layers/causal.ts +16 -0
- package/src/memory/graph-layers/entity.ts +16 -0
- package/src/memory/graph-layers/index.ts +5 -0
- package/src/memory/graph-layers/semantic.ts +16 -0
- package/src/memory/graph-layers/temporal.ts +16 -0
- package/src/memory/index.ts +72 -0
- package/src/memory/knowledge-bank.ts +1260 -0
- package/src/memory/knowledge-defrag.ts +329 -0
- package/src/memory/knowledge-graph.ts +361 -0
- package/src/memory/meta.ts +506 -0
- package/src/memory/playbook.ts +493 -0
- package/src/memory/search-provider.ts +35 -0
- package/src/memory/search-providers/index.ts +3 -0
- package/src/memory/search-providers/minimem.ts +84 -0
- package/src/memory/search-providers/text-similarity.ts +35 -0
- package/src/memory/skill-exporter.ts +357 -0
- package/src/memory/system.ts +604 -0
- package/src/memory/team-experience.ts +604 -0
- package/src/runtime/backends/acp-protocol.ts +231 -0
- package/src/runtime/backends/acp.ts +239 -0
- package/src/runtime/backends/index.ts +38 -0
- package/src/runtime/backends/macro-agent.ts +177 -0
- package/src/runtime/backends/mock.ts +218 -0
- package/src/runtime/backends/subprocess.ts +356 -0
- package/src/runtime/compute-provider.ts +206 -0
- package/src/runtime/flows/learning.ts +183 -0
- package/src/runtime/flows/validation.ts +381 -0
- package/src/runtime/index.ts +75 -0
- package/src/runtime/manager.ts +685 -0
- package/src/runtime/types.ts +198 -0
- package/src/search/evaluator.ts +499 -0
- package/src/search/index.ts +68 -0
- package/src/search/refinement-loop.ts +457 -0
- package/src/search/refinement-types.ts +159 -0
- package/src/search/router.ts +261 -0
- package/src/search/solver.ts +303 -0
- package/src/search/team-router.ts +459 -0
- package/src/search/verification-runner.ts +570 -0
- package/src/session-bank/git-reader.ts +190 -0
- package/src/session-bank/index.ts +24 -0
- package/src/session-bank/parser.ts +366 -0
- package/src/session-bank/session-bank.ts +464 -0
- package/src/session-bank/types.ts +173 -0
- package/src/surfacing/index.ts +29 -0
- package/src/surfacing/publisher.ts +23 -0
- package/src/surfacing/skill-library.ts +625 -0
- package/src/surfacing/skill-publisher.ts +223 -0
- package/src/surfacing/sqlite-storage-adapter.ts +301 -0
- package/src/surfacing/team-skill-library.ts +610 -0
- package/src/types/config.ts +585 -0
- package/src/types/dataclaw.ts +99 -0
- package/src/types/huggingface-transformers.d.ts +12 -0
- package/src/types/index.ts +286 -0
- package/src/types/knowledge-graph.ts +246 -0
- package/src/types/knowledge.ts +388 -0
- package/src/types/memory.ts +270 -0
- package/src/types/meta.ts +218 -0
- package/src/types/outcome.ts +66 -0
- package/src/types/playbook.ts +196 -0
- package/src/types/step.ts +40 -0
- package/src/types/task.ts +52 -0
- package/src/types/team-meta.ts +212 -0
- package/src/types/team-playbook.ts +384 -0
- package/src/types/team-trajectory.ts +673 -0
- package/src/types/trajectory-source.ts +47 -0
- package/src/types/trajectory.ts +80 -0
- package/src/utils/frontmatter.ts +118 -0
- package/src/utils/index.ts +45 -0
- package/src/utils/similarity.ts +139 -0
- package/src/utils/storage.ts +249 -0
- package/src/utils/validation.ts +286 -0
- package/src/workspace/index.ts +48 -0
- package/src/workspace/runner.ts +281 -0
- package/src/workspace/skill-converter.ts +288 -0
- package/src/workspace/templates/index.ts +64 -0
- package/src/workspace/templates/knowledge-defrag.ts +223 -0
- package/src/workspace/templates/knowledge-extraction.ts +337 -0
- package/src/workspace/templates/meta-reflection.ts +208 -0
- package/src/workspace/templates/playbook-extraction.ts +240 -0
- package/src/workspace/templates/refinement-analysis.ts +162 -0
- package/src/workspace/templates/solution-evaluation.ts +199 -0
- package/src/workspace/templates/team-playbook-extraction.ts +631 -0
- package/src/workspace/templates/team-trajectory-analysis.ts +564 -0
- package/src/workspace/templates/trajectory-analysis.ts +234 -0
- package/src/workspace/templates/usage-inference.ts +163 -0
- package/src/workspace/types.ts +233 -0
- package/tests/atlas-knowledge.test.ts +165 -0
- package/tests/embeddings/bm25.test.ts +130 -0
- package/tests/embeddings/manager.test.ts +205 -0
- package/tests/gap-fixes.test.ts +1103 -0
- package/tests/integration/atlas.test.ts +266 -0
- package/tests/integration/dataclaw-e2e.test.ts +559 -0
- package/tests/integration/e2e.test.ts +1336 -0
- package/tests/integration/entire-e2e.test.ts +187 -0
- package/tests/integration/huggingface-e2e.test.ts +627 -0
- package/tests/integration/session-bank.test.ts +225 -0
- package/tests/integration/skill-tree-wiring.test.ts +152 -0
- package/tests/learning/analyzer.test.ts +426 -0
- package/tests/learning/dataclaw-trajectory-source.test.ts +642 -0
- package/tests/learning/effectiveness.test.ts +542 -0
- package/tests/learning/entire-trajectory-source.test.ts +380 -0
- package/tests/learning/huggingface-trajectory-source.test.ts +817 -0
- package/tests/learning/knowledge-extractor.test.ts +491 -0
- package/tests/learning/pipeline.test.ts +176 -0
- package/tests/learning/playbook-extractor-provenance.test.ts +114 -0
- package/tests/learning/team-ingester.test.ts +349 -0
- package/tests/learning/team-meta-learner.test.ts +618 -0
- package/tests/learning/team-pipeline.test.ts +334 -0
- package/tests/learning/trajectory-sources.test.ts +312 -0
- package/tests/learning/usage-inference.test.ts +254 -0
- package/tests/mcp/playbook-server.test.ts +252 -0
- package/tests/memory/experience.test.ts +198 -0
- package/tests/memory/graph-layers/semantic.test.ts +219 -0
- package/tests/memory/knowledge-bank-extraction.test.ts +558 -0
- package/tests/memory/knowledge-bank.test.ts +705 -0
- package/tests/memory/knowledge-defrag.test.ts +366 -0
- package/tests/memory/knowledge-evolution.test.ts +563 -0
- package/tests/memory/knowledge-graph.test.ts +492 -0
- package/tests/memory/knowledge-inbox.test.ts +258 -0
- package/tests/memory/knowledge-minimem.test.ts +251 -0
- package/tests/memory/playbook.test.ts +338 -0
- package/tests/memory/provenance.test.ts +639 -0
- package/tests/memory/skill-exporter.test.ts +470 -0
- package/tests/memory/system.test.ts +325 -0
- package/tests/memory/team-experience.test.ts +411 -0
- package/tests/runtime/agent-manager.test.ts +512 -0
- package/tests/runtime/compute-provider.test.ts +288 -0
- package/tests/runtime/delegate.test.ts +349 -0
- package/tests/runtime/macro-agent-backend.test.ts +266 -0
- package/tests/runtime/mock-backend.test.ts +248 -0
- package/tests/search/refinement-loop.test.ts +468 -0
- package/tests/search/refinement.test.ts +267 -0
- package/tests/search/router.test.ts +427 -0
- package/tests/search/team-router.test.ts +376 -0
- package/tests/session-bank/fixtures/multi-tool-session/full.jsonl +12 -0
- package/tests/session-bank/fixtures/multi-tool-session/metadata.json +28 -0
- package/tests/session-bank/fixtures/root-metadata.json +18 -0
- package/tests/session-bank/fixtures/simple-session/full.jsonl +6 -0
- package/tests/session-bank/fixtures/simple-session/metadata.json +38 -0
- package/tests/session-bank/git-reader.test.ts +232 -0
- package/tests/session-bank/parser.test.ts +321 -0
- package/tests/session-bank/session-bank.test.ts +546 -0
- package/tests/surfacing/skill-library.test.ts +292 -0
- package/tests/surfacing/skill-publisher.test.ts +398 -0
- package/tests/surfacing/sqlite-storage-adapter.test.ts +218 -0
- package/tests/surfacing/team-skill-library.test.ts +444 -0
- package/tests/types/outcome.test.ts +147 -0
- package/tests/types/step.test.ts +133 -0
- package/tests/types/task.test.ts +158 -0
- package/tests/types/team-meta.test.ts +147 -0
- package/tests/types/team-playbook.test.ts +246 -0
- package/tests/types/team-trajectory.test.ts +557 -0
- package/tests/types/trajectory.test.ts +253 -0
- package/tests/utils/frontmatter.test.ts +208 -0
- package/tests/utils/similarity.test.ts +188 -0
- package/tests/utils/validation.test.ts +252 -0
- package/tests/workspace/full-flow.test.ts +839 -0
- package/tests/workspace/manager.test.ts +215 -0
- package/tests/workspace/runner.test.ts +330 -0
- package/tests/workspace/skill-converter.test.ts +205 -0
- package/tests/workspace/templates/knowledge-extraction.test.ts +235 -0
- package/tests/workspace/templates/team-playbook-extraction.test.ts +341 -0
- package/tests/workspace/templates/team-trajectory-analysis.test.ts +417 -0
- package/tsconfig.json +25 -0
- package/vitest.config.ts +22 -0
- package/dist/index.d.mts +0 -466
- package/dist/index.mjs +0 -478
|
@@ -0,0 +1,1789 @@
|
|
|
1
|
+
# Design: Semantic Memory & Knowledge Bank
|
|
2
|
+
|
|
3
|
+
> **Status**: Implemented (Phases 1-5 complete)
|
|
4
|
+
> **Authors**: Alex Ngai, Claude
|
|
5
|
+
> **Date**: 2026-02-18
|
|
6
|
+
> **Related**: [A-MEM](https://arxiv.org/abs/2502.12110), [MAGMA](https://arxiv.org/abs/2601.03236), [Zep](https://arxiv.org/pdf/2501.13956), [Memory Survey](https://arxiv.org/abs/2512.13564)
|
|
7
|
+
|
|
8
|
+
## 1. Motivation
|
|
9
|
+
|
|
10
|
+
cognitive-core has strong **procedural memory** (PlaybookLibrary — *how* to do things) and **episodic memory** (ExperienceMemory — *what happened*), but lacks **semantic memory** — a structured knowledge bank that stores *facts, concepts, and relationships* independently of any specific task or procedure.
|
|
11
|
+
|
|
12
|
+
Today, an agent that learns "Prisma requires `db push` before `migrate dev` when the schema has drifted" can only encode that as:
|
|
13
|
+
- A playbook tactic (procedural — loses the standalone factual nature)
|
|
14
|
+
- An experience tuple (episodic — buried in a specific task context, hard to generalize)
|
|
15
|
+
|
|
16
|
+
Neither representation lets the agent answer "What do I know about Prisma?" or "What changed about our database setup recently?" These are **semantic queries** that require a dedicated knowledge store.
|
|
17
|
+
|
|
18
|
+
### The minimem Opportunity
|
|
19
|
+
|
|
20
|
+
[minimem](https://github.com/alexngai/minimem) already provides a file-based, versioned memory system with hybrid search (vector + BM25). Agents can read and write markdown memory files directly. However, minimem currently lacks:
|
|
21
|
+
|
|
22
|
+
- **Organization structure** — agents dump unstructured notes with no consistent taxonomy
|
|
23
|
+
- **Relationship tracking** — no links between related knowledge
|
|
24
|
+
- **Extraction pipeline** — knowledge must be manually written, not extracted from experience
|
|
25
|
+
- **Evolution tracking** — no confidence, staleness, or contradiction detection
|
|
26
|
+
|
|
27
|
+
This design proposes adding a **Knowledge Bank** to cognitive-core that uses the filesystem as its universal primary index (compatible with minimem), while adding extraction, organization, graph indexing, and evolution on top.
|
|
28
|
+
|
|
29
|
+
## 2. Architecture Overview
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
33
|
+
│ cognitive-core │
|
|
34
|
+
│ │
|
|
35
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌──────────────────┐ │
|
|
36
|
+
│ │ Playbook │ │ Experience │ │ Knowledge Bank │ │
|
|
37
|
+
│ │ Library │ │ Memory │ │ (NEW) │ │
|
|
38
|
+
│ │ (procedural)│ │ (episodic) │ │ (semantic) │ │
|
|
39
|
+
│ └──────┬───── ┘ └──────┬──────┘ └───────┬──────────┘ │
|
|
40
|
+
│ │ │ │ │
|
|
41
|
+
│ │ ┌──────────┴──────────┐ │ │
|
|
42
|
+
│ └─────┤ Learning Pipeline ├───────┘ │
|
|
43
|
+
│ │ │ │
|
|
44
|
+
│ │ PlaybookExtractor │ │
|
|
45
|
+
│ │ KnowledgeExtractor │ ← NEW │
|
|
46
|
+
│ │ (parallel paths) │ │
|
|
47
|
+
│ └─────────┬───────────┘ │
|
|
48
|
+
│ │ │
|
|
49
|
+
│ Trajectories │
|
|
50
|
+
└─────────────────────────────────────────────────────────────┘
|
|
51
|
+
│
|
|
52
|
+
writes/reads
|
|
53
|
+
│
|
|
54
|
+
┌─────────────────────────▼───────────────────────────────────┐
|
|
55
|
+
│ Filesystem (minimem-compatible) │
|
|
56
|
+
│ │
|
|
57
|
+
│ memory/ │
|
|
58
|
+
│ ├── knowledge/ ← structured by domain/entity │
|
|
59
|
+
│ │ ├── domains/ ← domain summaries │
|
|
60
|
+
│ │ ├── entities/ ← tool/library/pattern notes │
|
|
61
|
+
│ │ └── observations/ ← atomic facts │
|
|
62
|
+
│ ├── episodes/ ← episodic summaries │
|
|
63
|
+
│ └── .knowledge/ ← graph overlay + index metadata │
|
|
64
|
+
│ ├── graph.json │
|
|
65
|
+
│ └── manifest.json │
|
|
66
|
+
│ │
|
|
67
|
+
│ (Agent can read/write these files directly via filesystem │
|
|
68
|
+
│ or minimem MCP. cognitive-core maintains the structure.) │
|
|
69
|
+
└─────────────────────────────────────────────────────────────┘
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Design Principles
|
|
73
|
+
|
|
74
|
+
1. **Filesystem is the universal primary index.** Any agent with filesystem access (or minimem MCP) can browse, grep, and read knowledge — no special API required.
|
|
75
|
+
|
|
76
|
+
2. **cognitive-core is the organizer, not the gatekeeper.** Agents can write raw notes directly. cognitive-core periodically runs an "index/defragmentation" process to organize, link, and consolidate.
|
|
77
|
+
|
|
78
|
+
3. **Graph overlay is a derived index.** The graph can be rebuilt from file frontmatter. It accelerates relationship queries but is not the source of truth.
|
|
79
|
+
|
|
80
|
+
4. **Parallel to playbooks, not a replacement.** Knowledge notes answer "what/why"; playbooks answer "how". They cross-reference each other.
|
|
81
|
+
|
|
82
|
+
5. **minimem provides versioning and sync.** cognitive-core doesn't reimplement these — it assumes a filesystem that may be backed by minimem for versioning, sync, and hybrid search.
|
|
83
|
+
|
|
84
|
+
## 3. Knowledge Note Format
|
|
85
|
+
|
|
86
|
+
Each knowledge unit is a markdown file with structured YAML frontmatter. Inspired by A-MEM's Zettelkasten notes but adapted for file-based storage.
|
|
87
|
+
|
|
88
|
+
### 3.1 Anatomy of a Knowledge Note
|
|
89
|
+
|
|
90
|
+
```markdown
|
|
91
|
+
---
|
|
92
|
+
id: k-prisma-schema-push-before-migrate
|
|
93
|
+
type: observation # observation | entity | domain-summary
|
|
94
|
+
domain: [database, orm]
|
|
95
|
+
entities: [prisma, postgresql]
|
|
96
|
+
tags: [migration, schema-drift, dev-workflow]
|
|
97
|
+
confidence: 0.85 # 0-1, grows with reinforcing evidence
|
|
98
|
+
source:
|
|
99
|
+
origin: extracted # extracted | agent-authored | imported
|
|
100
|
+
trajectories: [t-2025-01-15-abc, t-2025-01-18-def]
|
|
101
|
+
playbooks: [playbook-prisma-setup] # cross-references
|
|
102
|
+
links:
|
|
103
|
+
- target: k-prisma-migration-workflow
|
|
104
|
+
relation: related-to
|
|
105
|
+
- target: k-typescript-enum-const-export
|
|
106
|
+
relation: co-occurred
|
|
107
|
+
created: 2025-01-15T10:30:00Z
|
|
108
|
+
updated: 2025-01-18T14:00:00Z
|
|
109
|
+
supersedes: null # ID of note this replaces, if any
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
# Prisma requires schema push before migrate in dev
|
|
113
|
+
|
|
114
|
+
When using Prisma with PostgreSQL in development, `prisma db push`
|
|
115
|
+
must be run before `prisma migrate dev` if the schema has diverged
|
|
116
|
+
from the database state. Otherwise the migration will fail with
|
|
117
|
+
a drift detection error.
|
|
118
|
+
|
|
119
|
+
## Context
|
|
120
|
+
|
|
121
|
+
- Applies to: Prisma 5.x+, PostgreSQL
|
|
122
|
+
- Does NOT apply to: SQLite (push is the only option for SQLite)
|
|
123
|
+
|
|
124
|
+
## Evidence
|
|
125
|
+
|
|
126
|
+
- Observed in project-auth (Jan 15): migration failed until push was run first
|
|
127
|
+
- Confirmed in project-api (Jan 18): same pattern, different schema change
|
|
128
|
+
|
|
129
|
+
## Related
|
|
130
|
+
|
|
131
|
+
- See also: [Prisma migration workflow](k-prisma-migration-workflow.md)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 3.2 Note Types
|
|
135
|
+
|
|
136
|
+
| Type | Purpose | Granularity | Example |
|
|
137
|
+
|---|---|---|---|
|
|
138
|
+
| `observation` | Atomic factual statement learned from experience | One fact per file | "React 19 changed the compiler model" |
|
|
139
|
+
| `entity` | Accumulated knowledge about a specific tool/lib/pattern | One entity per file, multiple sections | "Everything I know about Prisma" |
|
|
140
|
+
| `domain-summary` | High-level summary of a knowledge domain | One domain per file | "Database knowledge overview" |
|
|
141
|
+
|
|
142
|
+
**Entity notes** are living documents that grow as more observations are made. They serve as **consolidation targets** — when multiple observations about the same entity accumulate, they get merged into the entity note.
|
|
143
|
+
|
|
144
|
+
**Domain summaries** are periodically regenerated from entity notes and observations within that domain. They provide high-level orientation ("what do I know about testing?").
|
|
145
|
+
|
|
146
|
+
### 3.3 Frontmatter Schema
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
interface KnowledgeNoteFrontmatter {
|
|
150
|
+
/** Unique identifier (kebab-case, prefixed with k-) */
|
|
151
|
+
id: string;
|
|
152
|
+
|
|
153
|
+
/** Note type determines organization and lifecycle */
|
|
154
|
+
type: 'observation' | 'entity' | 'domain-summary';
|
|
155
|
+
|
|
156
|
+
/** Knowledge domains this note belongs to */
|
|
157
|
+
domain: string[];
|
|
158
|
+
|
|
159
|
+
/** Specific entities (tools, libraries, patterns) referenced */
|
|
160
|
+
entities: string[];
|
|
161
|
+
|
|
162
|
+
/** Freeform tags for additional categorization */
|
|
163
|
+
tags: string[];
|
|
164
|
+
|
|
165
|
+
/** Confidence in this knowledge (0-1) */
|
|
166
|
+
confidence: number;
|
|
167
|
+
|
|
168
|
+
/** Where this knowledge came from */
|
|
169
|
+
source: {
|
|
170
|
+
origin: 'extracted' | 'agent-authored' | 'imported';
|
|
171
|
+
/** Trajectory IDs that contributed to this knowledge */
|
|
172
|
+
trajectories?: string[];
|
|
173
|
+
/** Playbook IDs that relate to this knowledge */
|
|
174
|
+
playbooks?: string[];
|
|
175
|
+
/** For agent-authored: which agent wrote it */
|
|
176
|
+
agentId?: string;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/** Explicit links to other knowledge notes */
|
|
180
|
+
links: Array<{
|
|
181
|
+
target: string; // ID of linked note
|
|
182
|
+
relation: LinkRelation;
|
|
183
|
+
layer?: GraphLayerName; // Which graph layer this edge belongs to (default: inferred from relation)
|
|
184
|
+
}>;
|
|
185
|
+
|
|
186
|
+
created: string; // ISO 8601
|
|
187
|
+
updated: string; // ISO 8601
|
|
188
|
+
|
|
189
|
+
/** If this note replaces a previous one (contradiction resolution) */
|
|
190
|
+
supersedes?: string;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Link relations, organized by which graph layer they naturally belong to.
|
|
195
|
+
* When `layer` is not specified in frontmatter, the layer is inferred from the relation type.
|
|
196
|
+
*/
|
|
197
|
+
|
|
198
|
+
// Semantic layer relations (conceptual relationships)
|
|
199
|
+
// 'related-to' — General association
|
|
200
|
+
// 'depends-on' — A requires B
|
|
201
|
+
// 'specializes' — A is a more specific case of B
|
|
202
|
+
// 'generalizes' — A is a more general case of B
|
|
203
|
+
// 'supports' — A provides evidence for B (also used for playbook cross-refs)
|
|
204
|
+
|
|
205
|
+
// Temporal layer relations (when things happened/changed)
|
|
206
|
+
// 'observed-before' — A was learned before B
|
|
207
|
+
// 'observed-after' — A was learned after B
|
|
208
|
+
// 'co-occurred' — Observed together in same trajectory
|
|
209
|
+
// 'supersedes' — A replaces B (newer/corrected knowledge)
|
|
210
|
+
|
|
211
|
+
// Causal layer relations (cause-effect chains)
|
|
212
|
+
// 'caused-by' — A was caused by B
|
|
213
|
+
// 'led-to' — A led to the discovery/occurrence of B
|
|
214
|
+
// 'broke' — A broke B (e.g., upgrade broke feature)
|
|
215
|
+
// 'enabled' — A enabled B to work
|
|
216
|
+
// 'prevented' — A prevented B from happening
|
|
217
|
+
|
|
218
|
+
// Entity layer relations (tool/component interactions)
|
|
219
|
+
// 'uses' — A uses B
|
|
220
|
+
// 'part-of' — A is a component of B
|
|
221
|
+
// 'interacts-with' — A interacts with B
|
|
222
|
+
// 'contradicts' — A conflicts with B (one should be superseded)
|
|
223
|
+
// 'created-by' — A was created by B
|
|
224
|
+
|
|
225
|
+
type LinkRelation =
|
|
226
|
+
// Semantic
|
|
227
|
+
| 'related-to' | 'depends-on' | 'specializes' | 'generalizes' | 'supports'
|
|
228
|
+
// Temporal
|
|
229
|
+
| 'observed-before' | 'observed-after' | 'co-occurred' | 'supersedes'
|
|
230
|
+
// Causal
|
|
231
|
+
| 'caused-by' | 'led-to' | 'broke' | 'enabled' | 'prevented'
|
|
232
|
+
// Entity
|
|
233
|
+
| 'uses' | 'part-of' | 'interacts-with' | 'contradicts' | 'created-by';
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## 4. Filesystem Organization
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
memory/
|
|
240
|
+
├── knowledge/
|
|
241
|
+
│ ├── domains/ # Domain summaries
|
|
242
|
+
│ │ ├── database.md # Auto-generated from entities + observations
|
|
243
|
+
│ │ ├── typescript.md
|
|
244
|
+
│ │ ├── react.md
|
|
245
|
+
│ │ └── testing.md
|
|
246
|
+
│ │
|
|
247
|
+
│ ├── entities/ # Entity-level knowledge (living docs)
|
|
248
|
+
│ │ ├── prisma.md # Everything about Prisma
|
|
249
|
+
│ │ ├── vitest.md
|
|
250
|
+
│ │ ├── next-js-app-router.md
|
|
251
|
+
│ │ └── typescript-enums.md
|
|
252
|
+
│ │
|
|
253
|
+
│ └── observations/ # Atomic facts (high volume)
|
|
254
|
+
│ ├── k-prisma-schema-push.md
|
|
255
|
+
│ ├── k-react19-compiler-change.md
|
|
256
|
+
│ ├── k-ts54-enum-const-break.md
|
|
257
|
+
│ └── k-vitest-workspace-config.md
|
|
258
|
+
│
|
|
259
|
+
├── episodes/ # Episodic summaries (existing minimem pattern)
|
|
260
|
+
│ ├── 2025-01-15.md
|
|
261
|
+
│ └── 2025-01-16.md
|
|
262
|
+
│
|
|
263
|
+
├── inbox/ # Agent-authored raw notes (pre-organization)
|
|
264
|
+
│ └── *.md # Unstructured notes from agent direct writes
|
|
265
|
+
│
|
|
266
|
+
└── .knowledge/ # Index metadata (derived, rebuildable)
|
|
267
|
+
├── graph.json # Relationship graph overlay
|
|
268
|
+
├── manifest.json # Note registry with quick-lookup metadata
|
|
269
|
+
└── domain-index.json # Domain → note ID mapping
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### 4.1 Directory Semantics
|
|
273
|
+
|
|
274
|
+
**`knowledge/observations/`** — High-volume, atomic facts. One fact per file. Created by the extraction pipeline or agent direct writes. Naming convention: `k-{entity}-{descriptor}.md`.
|
|
275
|
+
|
|
276
|
+
**`knowledge/entities/`** — Medium-volume, living documents. One per notable entity (library, tool, pattern, API). Grows over time as observations consolidate. Naming convention: `{entity-name}.md`.
|
|
277
|
+
|
|
278
|
+
**`knowledge/domains/`** — Low-volume summaries. One per knowledge domain. Periodically regenerated. Naming convention: `{domain-name}.md`.
|
|
279
|
+
|
|
280
|
+
**`inbox/`** — Raw agent-authored notes that haven't been organized yet. The defragmentation process reads these, extracts structured knowledge, and moves/merges them into the appropriate locations.
|
|
281
|
+
|
|
282
|
+
**`.knowledge/`** — Derived index files. Can be fully rebuilt from the markdown files' frontmatter. Not intended for direct agent reading (though it's available if useful).
|
|
283
|
+
|
|
284
|
+
### 4.2 Why This Structure Works for File-Based Retrieval
|
|
285
|
+
|
|
286
|
+
An agent without any special tooling can:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# "What do I know about Prisma?"
|
|
290
|
+
cat memory/knowledge/entities/prisma.md
|
|
291
|
+
|
|
292
|
+
# "What domains do I have knowledge about?"
|
|
293
|
+
ls memory/knowledge/domains/
|
|
294
|
+
|
|
295
|
+
# "Any facts about TypeScript enums?"
|
|
296
|
+
grep -rl "enum" memory/knowledge/observations/
|
|
297
|
+
|
|
298
|
+
# "What changed recently?"
|
|
299
|
+
ls -lt memory/knowledge/observations/ | head -10
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
This is the filesystem-as-primary-index principle — the directory structure itself is a queryable taxonomy.
|
|
303
|
+
|
|
304
|
+
## 5. Graph Overlay (Multi-Graph Architecture)
|
|
305
|
+
|
|
306
|
+
The graph overlay is a derived data structure that accelerates relationship queries. It is stored as JSON and can be rebuilt from frontmatter. Inspired by MAGMA, the graph is decomposed into **orthogonal layers** that each capture a different dimension of knowledge relationships. Layers are pluggable — each can be independently enabled/disabled.
|
|
307
|
+
|
|
308
|
+
### 5.1 Multi-Graph Design
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
┌─────────────────────────────────────────────────────┐
|
|
312
|
+
│ KnowledgeGraphManager │
|
|
313
|
+
│ │
|
|
314
|
+
│ Unified query interface over pluggable graph layers │
|
|
315
|
+
│ │
|
|
316
|
+
│ ┌─────────┐ ┌──────────┐ ┌────────┐ ┌──────────┐ │
|
|
317
|
+
│ │Semantic │ │Temporal │ │Causal │ │Entity │ │
|
|
318
|
+
│ │Graph │ │Graph │ │Graph │ │Graph │ │
|
|
319
|
+
│ │(default) │ │(optional)│ │(opt.) │ │(opt.) │ │
|
|
320
|
+
│ └─────────┘ └──────────┘ └────────┘ └──────────┘ │
|
|
321
|
+
│ │ │ │ │ │
|
|
322
|
+
│ └────────────┴───────────┴───────────┘ │
|
|
323
|
+
│ │ │
|
|
324
|
+
│ Shared node set │
|
|
325
|
+
│ (one GraphNode per knowledge note) │
|
|
326
|
+
└─────────────────────────────────────────────────────┘
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
All layers share the same node set (one node per knowledge note). Each layer maintains its own edges, capturing a different relationship dimension. The `KnowledgeGraphManager` provides a unified interface that can query across layers or target a specific one.
|
|
330
|
+
|
|
331
|
+
| Layer | Edge Semantics | Captures | Example Query |
|
|
332
|
+
|---|---|---|---|
|
|
333
|
+
| **Semantic** | `related-to`, `specializes`, `generalizes`, `depends-on`, `supports` | Conceptual relationships between knowledge | "What concepts relate to Prisma?" |
|
|
334
|
+
| **Temporal** | `observed-before`, `observed-after`, `supersedes`, `co-occurred` | When knowledge was learned, how it evolved | "What changed since last month?" |
|
|
335
|
+
| **Causal** | `caused-by`, `led-to`, `broke`, `enabled`, `prevented` | Cause-effect chains between facts | "Why did the build fail?" |
|
|
336
|
+
| **Entity** | `uses`, `part-of`, `created-by`, `interacts-with`, `contradicts` | Relationships between tools/libs/components | "What does this service depend on?" |
|
|
337
|
+
|
|
338
|
+
### 5.2 Graph Types
|
|
339
|
+
|
|
340
|
+
```typescript
|
|
341
|
+
/** Shared node — one per knowledge note, used by all layers */
|
|
342
|
+
interface GraphNode {
|
|
343
|
+
/** Knowledge note ID */
|
|
344
|
+
id: string;
|
|
345
|
+
|
|
346
|
+
/** Relative file path from memory root */
|
|
347
|
+
file: string;
|
|
348
|
+
|
|
349
|
+
/** Note type */
|
|
350
|
+
type: 'observation' | 'entity' | 'domain-summary';
|
|
351
|
+
|
|
352
|
+
/** Domains for fast filtering */
|
|
353
|
+
domains: string[];
|
|
354
|
+
|
|
355
|
+
/** Entities for fast filtering */
|
|
356
|
+
entities: string[];
|
|
357
|
+
|
|
358
|
+
/** Tags for fast filtering */
|
|
359
|
+
tags: string[];
|
|
360
|
+
|
|
361
|
+
/** Current confidence */
|
|
362
|
+
confidence: number;
|
|
363
|
+
|
|
364
|
+
/** Last updated timestamp */
|
|
365
|
+
updated: string;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** Edge within a specific graph layer */
|
|
369
|
+
interface GraphEdge {
|
|
370
|
+
/** Source note ID */
|
|
371
|
+
from: string;
|
|
372
|
+
|
|
373
|
+
/** Target note ID */
|
|
374
|
+
to: string;
|
|
375
|
+
|
|
376
|
+
/** Relationship type (layer determines valid relation types) */
|
|
377
|
+
relation: string;
|
|
378
|
+
|
|
379
|
+
/** Edge weight (0-1, for ranked traversal) */
|
|
380
|
+
weight: number;
|
|
381
|
+
|
|
382
|
+
/** When this edge was established */
|
|
383
|
+
created: string;
|
|
384
|
+
|
|
385
|
+
/** Whether this edge crosses into another system */
|
|
386
|
+
crossSystem?: 'playbook' | 'experience';
|
|
387
|
+
|
|
388
|
+
/** Source trajectory that produced this edge, if any */
|
|
389
|
+
sourceTrajectory?: string;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** A single graph layer */
|
|
393
|
+
interface GraphLayer {
|
|
394
|
+
/** Layer identifier */
|
|
395
|
+
name: GraphLayerName;
|
|
396
|
+
|
|
397
|
+
/** Whether this layer is currently enabled */
|
|
398
|
+
enabled: boolean;
|
|
399
|
+
|
|
400
|
+
/** Edges in this layer */
|
|
401
|
+
edges: GraphEdge[];
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
type GraphLayerName = 'semantic' | 'temporal' | 'causal' | 'entity';
|
|
405
|
+
|
|
406
|
+
/** Top-level multi-graph structure */
|
|
407
|
+
interface KnowledgeMultiGraph {
|
|
408
|
+
/** Schema version for migration */
|
|
409
|
+
version: number;
|
|
410
|
+
|
|
411
|
+
/** Last rebuild timestamp */
|
|
412
|
+
lastRebuilt: string;
|
|
413
|
+
|
|
414
|
+
/** Shared node registry */
|
|
415
|
+
nodes: Record<string, GraphNode>;
|
|
416
|
+
|
|
417
|
+
/** Graph layers — each independently toggleable */
|
|
418
|
+
layers: Record<GraphLayerName, GraphLayer>;
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### 5.3 Pluggable Layer Interface
|
|
423
|
+
|
|
424
|
+
Each graph layer implements the same interface, making them interchangeable and independently testable:
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
interface GraphLayerOperations {
|
|
428
|
+
/** Get edges from/to a node in this layer */
|
|
429
|
+
getEdges(nodeId: string, direction?: 'outgoing' | 'incoming' | 'both'): GraphEdge[];
|
|
430
|
+
|
|
431
|
+
/** BFS neighbors within this layer */
|
|
432
|
+
neighbors(nodeId: string, depth?: number): GraphNode[];
|
|
433
|
+
|
|
434
|
+
/** Shortest path between two nodes within this layer */
|
|
435
|
+
pathBetween(fromId: string, toId: string): GraphNode[] | null;
|
|
436
|
+
|
|
437
|
+
/** Add an edge to this layer */
|
|
438
|
+
addEdge(edge: GraphEdge): void;
|
|
439
|
+
|
|
440
|
+
/** Remove an edge from this layer */
|
|
441
|
+
removeEdge(fromId: string, toId: string, relation: string): void;
|
|
442
|
+
|
|
443
|
+
/** Rebuild this layer from frontmatter */
|
|
444
|
+
rebuild(notes: KnowledgeNote[]): void;
|
|
445
|
+
}
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
The `KnowledgeGraphManager` aggregates these operations:
|
|
449
|
+
|
|
450
|
+
```typescript
|
|
451
|
+
interface KnowledgeGraphManager {
|
|
452
|
+
/** Get a specific layer */
|
|
453
|
+
getLayer(name: GraphLayerName): GraphLayerOperations | null;
|
|
454
|
+
|
|
455
|
+
/** Query across all enabled layers (union of edges) */
|
|
456
|
+
neighbors(nodeId: string, options?: {
|
|
457
|
+
depth?: number;
|
|
458
|
+
layers?: GraphLayerName[]; // restrict to specific layers
|
|
459
|
+
minWeight?: number;
|
|
460
|
+
}): GraphNode[];
|
|
461
|
+
|
|
462
|
+
/** Cross-layer path: can traverse edges from any enabled layer */
|
|
463
|
+
pathBetween(fromId: string, toId: string, options?: {
|
|
464
|
+
layers?: GraphLayerName[];
|
|
465
|
+
}): Array<{ node: GraphNode; edge: GraphEdge; layer: GraphLayerName }>;
|
|
466
|
+
|
|
467
|
+
/** Filter nodes by criteria */
|
|
468
|
+
filterNodes(filter: {
|
|
469
|
+
domains?: string[];
|
|
470
|
+
entities?: string[];
|
|
471
|
+
tags?: string[];
|
|
472
|
+
type?: GraphNode['type'];
|
|
473
|
+
minConfidence?: number;
|
|
474
|
+
}): GraphNode[];
|
|
475
|
+
|
|
476
|
+
/** Get cross-system links (to playbooks/experiences) */
|
|
477
|
+
crossSystemLinks(nodeId: string): GraphEdge[];
|
|
478
|
+
|
|
479
|
+
/** Extract domain-scoped subgraph (all layers) */
|
|
480
|
+
subgraph(domain: string): KnowledgeMultiGraph;
|
|
481
|
+
|
|
482
|
+
/** Rebuild all enabled layers from frontmatter */
|
|
483
|
+
rebuildAll(notes: KnowledgeNote[]): void;
|
|
484
|
+
}
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### 5.4 Layer-Specific Query Patterns
|
|
488
|
+
|
|
489
|
+
Each layer enables different reasoning patterns:
|
|
490
|
+
|
|
491
|
+
**Semantic layer** (enabled by default):
|
|
492
|
+
- "What concepts relate to this?" → `semantic.neighbors(id)`
|
|
493
|
+
- "Is A a special case of B?" → check for `specializes` path
|
|
494
|
+
- "What playbooks support this knowledge?" → `semantic.getEdges(id)` filtered by `crossSystem`
|
|
495
|
+
|
|
496
|
+
**Temporal layer** (optional):
|
|
497
|
+
- "What did I learn recently about X?" → filter by `created` timestamp
|
|
498
|
+
- "What knowledge superseded previous understanding?" → follow `supersedes` edges
|
|
499
|
+
- "What did I learn in the same session?" → follow `co-occurred` edges
|
|
500
|
+
|
|
501
|
+
**Causal layer** (optional):
|
|
502
|
+
- "What caused this failure?" → follow `caused-by` chain backward
|
|
503
|
+
- "What could break if I change X?" → follow `led-to` / `broke` edges forward
|
|
504
|
+
- "What enabled this to work?" → follow `enabled` edges
|
|
505
|
+
|
|
506
|
+
**Entity layer** (optional):
|
|
507
|
+
- "What does Prisma interact with?" → `entity.neighbors('prisma')`
|
|
508
|
+
- "What are the components of this system?" → follow `part-of` edges
|
|
509
|
+
- "What tools does this project use?" → filter by `uses` edges
|
|
510
|
+
|
|
511
|
+
### 5.5 Storage Layout
|
|
512
|
+
|
|
513
|
+
Each layer is stored in its own JSON file for independent loading and git-friendly diffs:
|
|
514
|
+
|
|
515
|
+
```
|
|
516
|
+
.knowledge/
|
|
517
|
+
├── nodes.json # Shared node registry
|
|
518
|
+
├── layers/
|
|
519
|
+
│ ├── semantic.json # Semantic relationships (always present)
|
|
520
|
+
│ ├── temporal.json # Temporal relationships (if enabled)
|
|
521
|
+
│ ├── causal.json # Causal chains (if enabled)
|
|
522
|
+
│ └── entity.json # Entity relationships (if enabled)
|
|
523
|
+
├── manifest.json # Note registry with quick-lookup metadata
|
|
524
|
+
└── domain-index.json # Domain → note ID mapping
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
For large knowledge bases, layers can be further split by domain:
|
|
528
|
+
|
|
529
|
+
```
|
|
530
|
+
.knowledge/layers/
|
|
531
|
+
├── semantic.json # Small: keep flat
|
|
532
|
+
├── semantic-database.json # Large: split by domain
|
|
533
|
+
├── semantic-typescript.json
|
|
534
|
+
└── semantic-cross-domain.json # Cross-domain semantic edges
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### 5.6 Configuration
|
|
538
|
+
|
|
539
|
+
```typescript
|
|
540
|
+
interface GraphConfig {
|
|
541
|
+
/** Which graph layers to enable */
|
|
542
|
+
enabledLayers: GraphLayerName[]; // default: ['semantic']
|
|
543
|
+
|
|
544
|
+
/** Whether to auto-infer temporal edges from timestamps */
|
|
545
|
+
inferTemporalEdges: boolean; // default: true (when temporal enabled)
|
|
546
|
+
|
|
547
|
+
/** Whether to auto-infer causal edges from failure→recovery patterns */
|
|
548
|
+
inferCausalEdges: boolean; // default: true (when causal enabled)
|
|
549
|
+
|
|
550
|
+
/** Whether to auto-infer entity edges from shared entity tags */
|
|
551
|
+
inferEntityEdges: boolean; // default: true (when entity enabled)
|
|
552
|
+
|
|
553
|
+
/** Split layer files by domain when node count exceeds this */
|
|
554
|
+
domainSplitThreshold: number; // default: 500
|
|
555
|
+
|
|
556
|
+
/** Promote to SQLite when total edge count exceeds this */
|
|
557
|
+
sqlitePromotionThreshold: number; // default: 10000
|
|
558
|
+
}
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
## 6. Knowledge Extraction Pipeline
|
|
562
|
+
|
|
563
|
+
Runs parallel to the existing PlaybookExtractor within the LearningPipeline.
|
|
564
|
+
|
|
565
|
+
### 6.1 Extraction Flow
|
|
566
|
+
|
|
567
|
+
```
|
|
568
|
+
Trajectory
|
|
569
|
+
│
|
|
570
|
+
▼
|
|
571
|
+
TrajectoryAnalyzer (existing)
|
|
572
|
+
│
|
|
573
|
+
├──▶ PlaybookExtractor (existing)
|
|
574
|
+
│ │
|
|
575
|
+
│ ▼
|
|
576
|
+
│ PlaybookLibrary
|
|
577
|
+
│
|
|
578
|
+
└──▶ KnowledgeExtractor (NEW)
|
|
579
|
+
│
|
|
580
|
+
▼
|
|
581
|
+
KnowledgeBank
|
|
582
|
+
│
|
|
583
|
+
├── Create new observations
|
|
584
|
+
├── Update existing entity notes
|
|
585
|
+
├── Detect contradictions
|
|
586
|
+
└── Update graph overlay
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### 6.2 What Gets Extracted
|
|
590
|
+
|
|
591
|
+
From a trajectory's steps and outcome, the extractor identifies:
|
|
592
|
+
|
|
593
|
+
| Signal | Source | Example |
|
|
594
|
+
|---|---|---|
|
|
595
|
+
| **Domain facts** | Step observations, error messages | "Prisma requires push before migrate" |
|
|
596
|
+
| **Version-specific behavior** | Error messages, configs | "Vitest 2.0 changed config format" |
|
|
597
|
+
| **Causal chains** | Failure → recovery sequences | "Upgrading TS 5.4 broke enum const exports" |
|
|
598
|
+
| **Tool/library behavior** | Tool call results | "React 19 compiler eliminates need for useMemo" |
|
|
599
|
+
| **Environment constraints** | Configuration observations | "Node 22 required for sqlite native module" |
|
|
600
|
+
| **Negative knowledge** | Failure modes | "Library X does NOT support feature Y" |
|
|
601
|
+
|
|
602
|
+
### 6.3 Extraction Strategies
|
|
603
|
+
|
|
604
|
+
**Heuristic extraction** (no LLM required):
|
|
605
|
+
- Error message patterns → observations about tool behavior
|
|
606
|
+
- Configuration file changes → facts about tool requirements
|
|
607
|
+
- Version strings in errors → version-specific knowledge
|
|
608
|
+
- Repeated patterns across trajectories → reinforcement of existing knowledge
|
|
609
|
+
|
|
610
|
+
**LLM-assisted extraction** (via workspace template):
|
|
611
|
+
- Analyze trajectory narrative for implicit factual statements
|
|
612
|
+
- Identify causal relationships between steps
|
|
613
|
+
- Generate entity summaries from accumulated observations
|
|
614
|
+
- Detect contradictions with existing knowledge
|
|
615
|
+
|
|
616
|
+
### 6.4 KnowledgeExtractor Interface
|
|
617
|
+
|
|
618
|
+
```typescript
|
|
619
|
+
interface ExtractedKnowledge {
|
|
620
|
+
/** New observations to create */
|
|
621
|
+
observations: KnowledgeNote[];
|
|
622
|
+
|
|
623
|
+
/** Updates to existing entity notes (append sections) */
|
|
624
|
+
entityUpdates: EntityUpdate[];
|
|
625
|
+
|
|
626
|
+
/** Contradictions detected with existing knowledge */
|
|
627
|
+
contradictions: Contradiction[];
|
|
628
|
+
|
|
629
|
+
/** New links to add to the graph */
|
|
630
|
+
links: NewLink[];
|
|
631
|
+
|
|
632
|
+
/** Cross-references to playbooks */
|
|
633
|
+
playbookLinks: PlaybookLink[];
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
interface EntityUpdate {
|
|
637
|
+
/** Entity note ID to update */
|
|
638
|
+
entityId: string;
|
|
639
|
+
/** Section to append */
|
|
640
|
+
section: string;
|
|
641
|
+
/** Evidence source */
|
|
642
|
+
trajectoryId: string;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
interface Contradiction {
|
|
646
|
+
/** Existing note that is contradicted */
|
|
647
|
+
existingNoteId: string;
|
|
648
|
+
/** New observation that contradicts it */
|
|
649
|
+
newObservation: KnowledgeNote;
|
|
650
|
+
/** How they conflict */
|
|
651
|
+
conflictDescription: string;
|
|
652
|
+
/** Recommendation */
|
|
653
|
+
resolution: 'supersede' | 'coexist' | 'review';
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
interface PlaybookLink {
|
|
657
|
+
/** Knowledge note ID */
|
|
658
|
+
noteId: string;
|
|
659
|
+
/** Playbook ID */
|
|
660
|
+
playbookId: string;
|
|
661
|
+
/** Relationship direction */
|
|
662
|
+
relation: 'supports' | 'contradicts' | 'contextualizes';
|
|
663
|
+
}
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
### 6.5 Integration with LearningPipeline
|
|
667
|
+
|
|
668
|
+
> **Implementation note**: In practice, knowledge extraction is **decoupled** from `LearningPipeline.processTrajectory()`. Instead of auto-wiring extraction into the pipeline, callers invoke `KnowledgeBank.extractFromTrajectory()` directly. This keeps the pipeline's contract unchanged and gives callers explicit control over when extraction runs. The original design below shows the auto-wired approach for reference.
|
|
669
|
+
|
|
670
|
+
```typescript
|
|
671
|
+
// Option A (implemented): Direct invocation by caller
|
|
672
|
+
const knowledge = await knowledgeBank.extractFromTrajectory(trajectory, analysis, taskRunner);
|
|
673
|
+
|
|
674
|
+
// Option B (original design, not implemented): Auto-wired in pipeline
|
|
675
|
+
// In LearningPipeline.processTrajectory():
|
|
676
|
+
async processTrajectory(trajectory: Trajectory): Promise<ProcessResult> {
|
|
677
|
+
await this.memory.storeTrajectory(trajectory);
|
|
678
|
+
|
|
679
|
+
const analysis = await this.analyzer.analyze(trajectory);
|
|
680
|
+
|
|
681
|
+
// Existing: accumulate for batch playbook extraction
|
|
682
|
+
this.accumulated.push(trajectory);
|
|
683
|
+
this.accumulatedAnalyses.push(analysis);
|
|
684
|
+
|
|
685
|
+
// NEW: extract knowledge (can run per-trajectory, not just batch)
|
|
686
|
+
if (this.knowledgeExtractor) {
|
|
687
|
+
const knowledge = await this.knowledgeExtractor.extract(
|
|
688
|
+
trajectory,
|
|
689
|
+
analysis,
|
|
690
|
+
this.knowledgeBank
|
|
691
|
+
);
|
|
692
|
+
await this.knowledgeBank.applyExtraction(knowledge);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
return { /* ... */ };
|
|
696
|
+
}
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
**Key difference from playbook extraction**: Knowledge extraction can run on every trajectory (not just batches), because individual facts are valuable. Playbook extraction needs pattern frequency across multiple trajectories.
|
|
700
|
+
|
|
701
|
+
## 7. Knowledge Evolution
|
|
702
|
+
|
|
703
|
+
Parallel to PlaybookEvolution but adapted for factual knowledge.
|
|
704
|
+
|
|
705
|
+
### 7.1 Lifecycle
|
|
706
|
+
|
|
707
|
+
```
|
|
708
|
+
┌──────────────────────────────────────┐
|
|
709
|
+
│ │
|
|
710
|
+
▼ │
|
|
711
|
+
┌─────────────────┐ │
|
|
712
|
+
│ Observation │ confidence: 0.3 │
|
|
713
|
+
│ (extracted) │ single trajectory source │
|
|
714
|
+
└────────┬────────┘ │
|
|
715
|
+
│ │
|
|
716
|
+
│ reinforced by more trajectories │
|
|
717
|
+
▼ │
|
|
718
|
+
┌─────────────────┐ │
|
|
719
|
+
│ Observation │ confidence: 0.5-0.8 │
|
|
720
|
+
│ (validated) │ multiple trajectory sources │
|
|
721
|
+
└────────┬────────┘ │
|
|
722
|
+
│ │
|
|
723
|
+
│ consolidated into entity note │
|
|
724
|
+
▼ │
|
|
725
|
+
┌─────────────────┐ │
|
|
726
|
+
│ Entity Note │ accumulates observations │
|
|
727
|
+
│ (living doc) │ grows over time │
|
|
728
|
+
└────────┬────────┘ │
|
|
729
|
+
│ │
|
|
730
|
+
│ domain summary regenerated │
|
|
731
|
+
▼ │
|
|
732
|
+
┌─────────────────┐ │
|
|
733
|
+
│ Domain Summary │ high-level orientation │
|
|
734
|
+
│ (generated) │ periodically refreshed │
|
|
735
|
+
└─────────────────┘ │
|
|
736
|
+
│
|
|
737
|
+
┌─────────────────┐ │
|
|
738
|
+
│ Contradiction │ new evidence conflicts ─────┘
|
|
739
|
+
│ (detected) │ → supersede or coexist
|
|
740
|
+
└─────────────────┘
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
### 7.2 Evolution Operations
|
|
744
|
+
|
|
745
|
+
**Reinforcement** — Same fact observed again in a different trajectory:
|
|
746
|
+
- Increment confidence (EMA: `newConf = 0.9 * oldConf + 0.1 * 1.0`)
|
|
747
|
+
- Add trajectory ID to sources
|
|
748
|
+
- Update `updated` timestamp
|
|
749
|
+
|
|
750
|
+
**Contradiction** — New observation conflicts with existing:
|
|
751
|
+
- Create new observation with `supersedes` pointing to old note
|
|
752
|
+
- Lower confidence of old note
|
|
753
|
+
- Add `contradicts` edge in graph
|
|
754
|
+
- If resolution is clear: mark old note superseded
|
|
755
|
+
- If ambiguous: flag for review (both may be context-dependent)
|
|
756
|
+
|
|
757
|
+
**Consolidation** — Multiple observations about same entity:
|
|
758
|
+
- Merge observation content into entity note as new sections
|
|
759
|
+
- Observations are retained (atomic source of truth) but entity note provides the summary
|
|
760
|
+
- Add `generalizes` links from entity to observations
|
|
761
|
+
|
|
762
|
+
**Staleness/Decay** — Knowledge not validated in a configurable period:
|
|
763
|
+
- Gradually decrease confidence
|
|
764
|
+
- Mark with `stale` tag after threshold
|
|
765
|
+
- Don't delete — stale knowledge may still be valid, just unconfirmed
|
|
766
|
+
|
|
767
|
+
**Agent-authored updates** — Agent directly edits a knowledge file:
|
|
768
|
+
- Detect via file watcher or inbox processing
|
|
769
|
+
- Attempt to parse frontmatter; if missing, treat as inbox item for defragmentation
|
|
770
|
+
- Agent-authored notes start at configurable confidence (default: 0.5)
|
|
771
|
+
|
|
772
|
+
### 7.3 Confidence Model
|
|
773
|
+
|
|
774
|
+
```typescript
|
|
775
|
+
interface ConfidenceConfig {
|
|
776
|
+
/** Initial confidence for extracted observations */
|
|
777
|
+
extractedInitial: number; // default: 0.3
|
|
778
|
+
|
|
779
|
+
/** Initial confidence for agent-authored notes */
|
|
780
|
+
agentAuthoredInitial: number; // default: 0.5
|
|
781
|
+
|
|
782
|
+
/** EMA alpha for reinforcement */
|
|
783
|
+
reinforcementAlpha: number; // default: 0.1
|
|
784
|
+
|
|
785
|
+
/** Confidence reduction on contradiction */
|
|
786
|
+
contradictionPenalty: number; // default: 0.3
|
|
787
|
+
|
|
788
|
+
/** Daily confidence decay rate for unvalidated knowledge */
|
|
789
|
+
dailyDecayRate: number; // default: 0.001
|
|
790
|
+
|
|
791
|
+
/** Confidence below which to mark as stale */
|
|
792
|
+
staleThreshold: number; // default: 0.2
|
|
793
|
+
|
|
794
|
+
/** Days without validation before decay begins */
|
|
795
|
+
decayGracePeriodDays: number; // default: 90
|
|
796
|
+
}
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
## 8. Defragmentation Process
|
|
800
|
+
|
|
801
|
+
The "index/defrag" process that cognitive-core runs periodically to maintain knowledge organization. This is the key differentiator from raw minimem usage.
|
|
802
|
+
|
|
803
|
+
### 8.1 What Defragmentation Does
|
|
804
|
+
|
|
805
|
+
```
|
|
806
|
+
1. INBOX PROCESSING
|
|
807
|
+
- Read raw notes from inbox/
|
|
808
|
+
- Extract structured frontmatter (or generate it)
|
|
809
|
+
- Classify into observation/entity/domain-summary
|
|
810
|
+
- Move to appropriate directory
|
|
811
|
+
- Add to graph
|
|
812
|
+
|
|
813
|
+
2. CONSOLIDATION
|
|
814
|
+
- Find observations that cluster around the same entity
|
|
815
|
+
- Merge into entity notes (append sections, update summary)
|
|
816
|
+
- Add generalizes/specializes links
|
|
817
|
+
|
|
818
|
+
3. CONTRADICTION DETECTION
|
|
819
|
+
- Compare new observations against existing knowledge
|
|
820
|
+
- Flag contradictions for review or auto-resolve
|
|
821
|
+
|
|
822
|
+
4. GRAPH REBUILD
|
|
823
|
+
- Scan all frontmatter for link declarations
|
|
824
|
+
- Rebuild graph.json from source of truth
|
|
825
|
+
- Compute inferred links (co-occurrence, domain proximity)
|
|
826
|
+
|
|
827
|
+
5. DOMAIN SUMMARY REGENERATION
|
|
828
|
+
- For each domain with significant changes since last regen
|
|
829
|
+
- Collect entity notes + observations in that domain
|
|
830
|
+
- Generate/update domain summary
|
|
831
|
+
|
|
832
|
+
6. STALENESS SWEEP
|
|
833
|
+
- Apply confidence decay to knowledge not validated recently
|
|
834
|
+
- Tag stale items
|
|
835
|
+
- Optionally archive (move to archive/ subdirectory)
|
|
836
|
+
|
|
837
|
+
7. MANIFEST UPDATE
|
|
838
|
+
- Rebuild manifest.json with note registry
|
|
839
|
+
- Update domain-index.json
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
### 8.2 Defragmentation Configuration
|
|
843
|
+
|
|
844
|
+
```typescript
|
|
845
|
+
interface DefragConfig {
|
|
846
|
+
/** How often to run defrag (milliseconds) */
|
|
847
|
+
interval: number; // default: 3600000 (1 hour)
|
|
848
|
+
|
|
849
|
+
/** Minimum inbox items before triggering defrag */
|
|
850
|
+
minInboxItems: number; // default: 5
|
|
851
|
+
|
|
852
|
+
/** Whether to auto-consolidate observations into entities */
|
|
853
|
+
autoConsolidate: boolean; // default: true
|
|
854
|
+
|
|
855
|
+
/** Minimum observations about an entity before consolidation */
|
|
856
|
+
consolidationThreshold: number; // default: 3
|
|
857
|
+
|
|
858
|
+
/** Whether to auto-regenerate domain summaries */
|
|
859
|
+
autoRegenerateSummaries: boolean; // default: true
|
|
860
|
+
|
|
861
|
+
/** Use LLM for summary generation (vs heuristic concatenation) */
|
|
862
|
+
llmSummaryGeneration: boolean; // default: false
|
|
863
|
+
|
|
864
|
+
/** Whether to auto-resolve simple contradictions */
|
|
865
|
+
autoResolveContradictions: boolean; // default: false
|
|
866
|
+
}
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
### 8.3 Heuristic vs Agentic Defragmentation
|
|
870
|
+
|
|
871
|
+
Like the existing playbook extraction, defrag has two modes:
|
|
872
|
+
|
|
873
|
+
**Heuristic** (no LLM):
|
|
874
|
+
- Parse frontmatter, rebuild indexes
|
|
875
|
+
- Detect exact/near-duplicate observations
|
|
876
|
+
- Consolidate by entity name matching
|
|
877
|
+
- Simple contradiction detection (same entity + conflicting statements)
|
|
878
|
+
|
|
879
|
+
**Agentic** (via workspace template):
|
|
880
|
+
- Semantic similarity for consolidation
|
|
881
|
+
- Natural language contradiction detection
|
|
882
|
+
- Generated domain summaries
|
|
883
|
+
- Inferred relationships between observations
|
|
884
|
+
|
|
885
|
+
## 9. Retrieval & Surfacing
|
|
886
|
+
|
|
887
|
+
### 9.1 Retrieval Modes
|
|
888
|
+
|
|
889
|
+
| Mode | How | Returns | Use Case |
|
|
890
|
+
|---|---|---|---|
|
|
891
|
+
| **File browse** | `ls`, `cat` on filesystem | Raw markdown | Agent exploring knowledge |
|
|
892
|
+
| **Semantic search** | minimem hybrid search | Ranked chunks | "What do I know about X?" |
|
|
893
|
+
| **Graph traversal** | Walk edges from node | Connected notes | "What's related to X?" |
|
|
894
|
+
| **Domain query** | Read domain summary + index | Structured overview | "Brief me on database knowledge" |
|
|
895
|
+
| **Cross-system** | Follow graph edges to playbooks | Knowledge + procedures | "Facts relevant to this playbook" |
|
|
896
|
+
|
|
897
|
+
### 9.2 Independent Surfacing (Decoupled from Playbooks)
|
|
898
|
+
|
|
899
|
+
Knowledge surfacing operates **independently** from playbook/skill surfacing. They are separate systems with separate retrieval paths. In practice, agents receive traced, versioned snapshots of skills, playbooks, and knowledge — the input data is colocated at the point of analysis regardless of how it was surfaced.
|
|
900
|
+
|
|
901
|
+
This means:
|
|
902
|
+
- `SkillLibrary` continues to surface playbooks as it does today (unchanged)
|
|
903
|
+
- `KnowledgeBank` has its own surfacing path with its own retrieval logic
|
|
904
|
+
- Both produce independent context sections that the agent receives
|
|
905
|
+
- The learning pipeline sees both together when analyzing trajectories (colocated for analysis)
|
|
906
|
+
- No coupling between playbook selection and knowledge selection
|
|
907
|
+
|
|
908
|
+
```typescript
|
|
909
|
+
// Knowledge surfacing is its own independent path:
|
|
910
|
+
class KnowledgeBank {
|
|
911
|
+
/**
|
|
912
|
+
* Surface relevant knowledge for a task.
|
|
913
|
+
* Independent from playbook surfacing — does not reference SkillLibrary.
|
|
914
|
+
*/
|
|
915
|
+
async getRelevantKnowledge(task: Task, options?: {
|
|
916
|
+
maxNotes?: number;
|
|
917
|
+
maxTokens?: number;
|
|
918
|
+
layers?: GraphLayerName[]; // which graph layers to traverse
|
|
919
|
+
}): Promise<KnowledgeMatch[]>;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// Agent context assembly happens at a higher level (Atlas or AgentManager):
|
|
923
|
+
// Both systems contribute independently to the agent's context.
|
|
924
|
+
const skillContext = skillLibrary.formatForSystemPrompt(skills);
|
|
925
|
+
const knowledgeContext = knowledgeBank.formatKnowledgeForPrompt(knowledge);
|
|
926
|
+
// Agent receives both as separate sections
|
|
927
|
+
```
|
|
928
|
+
|
|
929
|
+
**Knowledge surfacing tiers** (parallel to, but independent from, skill tiers):
|
|
930
|
+
|
|
931
|
+
| Tier | Criteria | Injection |
|
|
932
|
+
|---|---|---|
|
|
933
|
+
| **Domain knowledge** | Task domain matches note domain | Include domain summary |
|
|
934
|
+
| **Entity knowledge** | Task mentions specific entity | Include entity note |
|
|
935
|
+
| **Contextual** | Semantic match to task description | Include top-N observations |
|
|
936
|
+
|
|
937
|
+
**Traceability:** When an agent executes a task, the trajectory metadata records which knowledge notes were surfaced (by ID and version timestamp), alongside which playbooks were surfaced. The learning pipeline can then analyze effectiveness of both independently or correlate them during trajectory analysis.
|
|
938
|
+
|
|
939
|
+
### 9.3 Formatting for Agent Consumption
|
|
940
|
+
|
|
941
|
+
```typescript
|
|
942
|
+
formatKnowledgeForPrompt(notes: KnowledgeNote[]): string {
|
|
943
|
+
// Returns markdown section:
|
|
944
|
+
// ## Relevant Knowledge
|
|
945
|
+
//
|
|
946
|
+
// ### About Prisma (85% confidence)
|
|
947
|
+
// - Requires schema push before migrate in dev (Prisma 5.x+, PostgreSQL)
|
|
948
|
+
// - Migration drift detection triggers on schema divergence
|
|
949
|
+
//
|
|
950
|
+
// ### About TypeScript Enums
|
|
951
|
+
// - TS 5.4 changed const enum export behavior (caution when upgrading)
|
|
952
|
+
}
|
|
953
|
+
```
|
|
954
|
+
|
|
955
|
+
## 10. KnowledgeBank Interface
|
|
956
|
+
|
|
957
|
+
The main module that ties everything together.
|
|
958
|
+
|
|
959
|
+
```typescript
|
|
960
|
+
class KnowledgeBank {
|
|
961
|
+
/** The multi-graph manager (pluggable layers) */
|
|
962
|
+
public readonly graph: KnowledgeGraphManager;
|
|
963
|
+
|
|
964
|
+
constructor(
|
|
965
|
+
memoryDir: string, // Root directory (minimem-compatible)
|
|
966
|
+
config?: KnowledgeBankConfig
|
|
967
|
+
);
|
|
968
|
+
|
|
969
|
+
// === LIFECYCLE ===
|
|
970
|
+
async init(): Promise<void>;
|
|
971
|
+
async close(): Promise<void>;
|
|
972
|
+
|
|
973
|
+
// === WRITE ===
|
|
974
|
+
/** Create a new knowledge note */
|
|
975
|
+
async addObservation(note: KnowledgeNote): Promise<string>;
|
|
976
|
+
/** Update an existing entity note */
|
|
977
|
+
async updateEntity(entityId: string, update: EntityUpdate): Promise<void>;
|
|
978
|
+
/** Process raw agent-authored content from inbox */
|
|
979
|
+
async processInbox(): Promise<InboxResult>;
|
|
980
|
+
|
|
981
|
+
// === READ ===
|
|
982
|
+
/** Get a specific note by ID */
|
|
983
|
+
async getNote(id: string): Promise<KnowledgeNote | null>;
|
|
984
|
+
/** Get entity note for a named entity */
|
|
985
|
+
async getEntity(entityName: string): Promise<KnowledgeNote | null>;
|
|
986
|
+
/** Get domain summary */
|
|
987
|
+
async getDomainSummary(domain: string): Promise<KnowledgeNote | null>;
|
|
988
|
+
/** List all known entities */
|
|
989
|
+
async listEntities(): Promise<string[]>;
|
|
990
|
+
/** List all known domains */
|
|
991
|
+
async listDomains(): Promise<string[]>;
|
|
992
|
+
|
|
993
|
+
// === SEARCH ===
|
|
994
|
+
/** Semantic search across all knowledge */
|
|
995
|
+
async search(query: string, options?: SearchOptions): Promise<KnowledgeMatch[]>;
|
|
996
|
+
/**
|
|
997
|
+
* Get knowledge relevant to a task.
|
|
998
|
+
* Independent from playbook surfacing — does not reference SkillLibrary.
|
|
999
|
+
*/
|
|
1000
|
+
async getRelevantKnowledge(task: Task, options?: {
|
|
1001
|
+
maxNotes?: number;
|
|
1002
|
+
maxTokens?: number;
|
|
1003
|
+
layers?: GraphLayerName[];
|
|
1004
|
+
}): Promise<KnowledgeMatch[]>;
|
|
1005
|
+
|
|
1006
|
+
// === GRAPH (delegates to KnowledgeGraphManager) ===
|
|
1007
|
+
/** Get related notes via multi-layer graph traversal */
|
|
1008
|
+
async getRelated(noteId: string, options?: {
|
|
1009
|
+
depth?: number;
|
|
1010
|
+
layers?: GraphLayerName[];
|
|
1011
|
+
minWeight?: number;
|
|
1012
|
+
}): Promise<KnowledgeMatch[]>;
|
|
1013
|
+
/** Get cross-system links (to playbooks) */
|
|
1014
|
+
async getPlaybookLinks(noteId: string): Promise<PlaybookLink[]>;
|
|
1015
|
+
/** Get knowledge linked to a specific playbook */
|
|
1016
|
+
async getKnowledgeForPlaybook(playbookId: string): Promise<KnowledgeMatch[]>;
|
|
1017
|
+
/** Get causal chain for a note (requires causal layer) */
|
|
1018
|
+
async getCausalChain(noteId: string, direction: 'causes' | 'effects'): Promise<KnowledgeMatch[]>;
|
|
1019
|
+
/** Get temporal neighbors (requires temporal layer) */
|
|
1020
|
+
async getTemporalNeighbors(noteId: string, window?: { before?: number; after?: number }): Promise<KnowledgeMatch[]>;
|
|
1021
|
+
|
|
1022
|
+
// === EVOLUTION ===
|
|
1023
|
+
/** Reinforce a note with additional evidence */
|
|
1024
|
+
async reinforce(noteId: string, trajectoryId: string): Promise<void>;
|
|
1025
|
+
/** Record a contradiction */
|
|
1026
|
+
async recordContradiction(contradiction: Contradiction): Promise<void>;
|
|
1027
|
+
/** Apply confidence decay to stale knowledge */
|
|
1028
|
+
async applyDecay(): Promise<DecayResult>;
|
|
1029
|
+
|
|
1030
|
+
// === EXTRACTION ===
|
|
1031
|
+
/** Apply extraction results from KnowledgeExtractor */
|
|
1032
|
+
async applyExtraction(extraction: ExtractedKnowledge): Promise<void>;
|
|
1033
|
+
|
|
1034
|
+
// === DEFRAGMENTATION ===
|
|
1035
|
+
/** Run full defragmentation cycle */
|
|
1036
|
+
async defragment(): Promise<DefragResult>;
|
|
1037
|
+
|
|
1038
|
+
// === SURFACING (independent from SkillLibrary) ===
|
|
1039
|
+
/** Format knowledge notes for agent context injection */
|
|
1040
|
+
formatKnowledgeForPrompt(notes: KnowledgeMatch[], options?: {
|
|
1041
|
+
maxTokens?: number;
|
|
1042
|
+
includeEvidence?: boolean;
|
|
1043
|
+
includeLinks?: boolean;
|
|
1044
|
+
}): string;
|
|
1045
|
+
|
|
1046
|
+
// === STATS ===
|
|
1047
|
+
async getStats(): Promise<KnowledgeStats>;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
interface KnowledgeStats {
|
|
1051
|
+
observationCount: number;
|
|
1052
|
+
entityCount: number;
|
|
1053
|
+
domainCount: number;
|
|
1054
|
+
inboxCount: number;
|
|
1055
|
+
graph: {
|
|
1056
|
+
nodeCount: number;
|
|
1057
|
+
edgeCountByLayer: Record<GraphLayerName, number>;
|
|
1058
|
+
enabledLayers: GraphLayerName[];
|
|
1059
|
+
};
|
|
1060
|
+
avgConfidence: number;
|
|
1061
|
+
staleCount: number;
|
|
1062
|
+
domainBreakdown: Record<string, number>;
|
|
1063
|
+
}
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
## 11. Configuration
|
|
1067
|
+
|
|
1068
|
+
Addition to `AtlasConfig`:
|
|
1069
|
+
|
|
1070
|
+
```typescript
|
|
1071
|
+
// In AtlasConfigSchema:
|
|
1072
|
+
knowledgeBank: KnowledgeBankConfigSchema.default({})
|
|
1073
|
+
|
|
1074
|
+
// KnowledgeBankConfigSchema:
|
|
1075
|
+
interface KnowledgeBankConfig {
|
|
1076
|
+
/** Enable knowledge bank */
|
|
1077
|
+
enabled: boolean; // default: false
|
|
1078
|
+
|
|
1079
|
+
/** Root directory for knowledge files */
|
|
1080
|
+
memoryDir: string; // default: '{baseDir}/memory'
|
|
1081
|
+
|
|
1082
|
+
/** Extraction config */
|
|
1083
|
+
extraction: {
|
|
1084
|
+
/** Enable automatic knowledge extraction from trajectories */
|
|
1085
|
+
enabled: boolean; // default: true
|
|
1086
|
+
/** Use LLM-assisted extraction (vs heuristic only) */
|
|
1087
|
+
useLlmExtraction: boolean; // default: false
|
|
1088
|
+
/** Minimum trajectory attribution score for extraction */
|
|
1089
|
+
minAttributionScore: number; // default: 0.3
|
|
1090
|
+
};
|
|
1091
|
+
|
|
1092
|
+
/** Defragmentation config */
|
|
1093
|
+
defrag: DefragConfig;
|
|
1094
|
+
|
|
1095
|
+
/** Confidence model config */
|
|
1096
|
+
confidence: ConfidenceConfig;
|
|
1097
|
+
|
|
1098
|
+
/** Graph overlay config */
|
|
1099
|
+
graph: GraphConfig;
|
|
1100
|
+
|
|
1101
|
+
/** Surfacing config (independent from SkillLibrary) */
|
|
1102
|
+
surfacing: {
|
|
1103
|
+
/** Include domain summaries in task context */
|
|
1104
|
+
includeDomainSummaries: boolean; // default: true
|
|
1105
|
+
/** Include entity notes in task context */
|
|
1106
|
+
includeEntityNotes: boolean; // default: true
|
|
1107
|
+
/** Maximum knowledge notes to surface per task */
|
|
1108
|
+
maxNotesPerTask: number; // default: 5
|
|
1109
|
+
/** Maximum tokens for knowledge context */
|
|
1110
|
+
maxTokensForKnowledge: number; // default: 1500
|
|
1111
|
+
/** Include evidence citations in surfaced notes */
|
|
1112
|
+
includeEvidence: boolean; // default: false
|
|
1113
|
+
/** Include graph links in surfaced notes */
|
|
1114
|
+
includeLinks: boolean; // default: false
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
/** Whether to manage minimem-specific features (sync, versioning) */
|
|
1118
|
+
minimemAware: boolean; // default: false
|
|
1119
|
+
}
|
|
1120
|
+
```
|
|
1121
|
+
|
|
1122
|
+
## 12. Implementation Phases
|
|
1123
|
+
|
|
1124
|
+
### Cross-Cutting Concerns
|
|
1125
|
+
|
|
1126
|
+
Before diving into phases, these concerns apply throughout all implementation:
|
|
1127
|
+
|
|
1128
|
+
**Frontmatter compatibility.** minimem's built-in parser (`parseFrontmatter` in `minimem/src/session.ts`) only supports 2-level nesting and inline `[a, b]` arrays — it cannot parse our `links` array-of-objects or deeply nested `source` structures. We will implement our own full-fidelity parser in cognitive-core (`src/utils/frontmatter.ts`) that handles the complete `KnowledgeNoteFrontmatter` schema, while keeping the simple top-level fields (`created`, `updated`, `tags`) compatible so minimem can still partially read our files.
|
|
1129
|
+
|
|
1130
|
+
**Export pattern.** Every new module follows the existing convention: a barrel `index.ts` in its directory, re-exported up through `src/memory/index.ts` → `src/index.ts`. New types go in `src/types/`, re-exported from `src/types/index.ts`.
|
|
1131
|
+
|
|
1132
|
+
**Config pattern.** New config schemas use Zod with `.default({})` at each level, nested under `AtlasConfig`. The `createDefaultConfig()` helper in `src/types/config.ts` merges partial user config over defaults.
|
|
1133
|
+
|
|
1134
|
+
**Test pattern.** Tests live in `tests/` mirroring `src/` structure. Each phase has its own test file(s). Tests use the filesystem directly (tmp dirs) — no mocking of the file layer, since filesystem-as-primary-index is a core invariant.
|
|
1135
|
+
|
|
1136
|
+
**Feature flag.** The entire knowledge bank is behind `knowledgeBank.enabled: false` by default. All Atlas/MemorySystem integration is guarded by this flag so existing behavior is unchanged unless opted in.
|
|
1137
|
+
|
|
1138
|
+
---
|
|
1139
|
+
|
|
1140
|
+
### Phase 1: Foundation (Core Types + Filesystem + Multi-Graph)
|
|
1141
|
+
|
|
1142
|
+
**Goal**: Standalone KnowledgeBank that can create, read, update, and delete knowledge notes on the filesystem, with a multi-layer graph overlay. No integration with the learning pipeline or Atlas yet — this phase is a self-contained module with its own tests.
|
|
1143
|
+
|
|
1144
|
+
#### Step 1.1 — Types (`src/types/knowledge.ts`)
|
|
1145
|
+
|
|
1146
|
+
New file. Defines the core data model using Zod schemas (matching the existing pattern in `src/types/`).
|
|
1147
|
+
|
|
1148
|
+
**What to define:**
|
|
1149
|
+
- `KnowledgeNoteFrontmatter` — the full frontmatter schema from Section 3.3 (id, type, domain, entities, tags, confidence, source, links, created, updated, supersedes)
|
|
1150
|
+
- `KnowledgeNote` — frontmatter + body (markdown content) + filePath (resolved at load time)
|
|
1151
|
+
- `NoteType` — `'observation' | 'entity' | 'domain-summary'`
|
|
1152
|
+
- `LinkRelation` — the union type from Section 3.3
|
|
1153
|
+
- `KnowledgeMatch` — a note + relevance score (for search results)
|
|
1154
|
+
- `EntityUpdate`, `Contradiction`, `PlaybookLink` — from Section 6.4
|
|
1155
|
+
- `ExtractedKnowledge` — from Section 6.4
|
|
1156
|
+
- Factory functions: `createKnowledgeNote()`, `createObservation()`, `createEntityNote()`
|
|
1157
|
+
- `InboxResult`, `DefragResult`, `DecayResult` — result types for lifecycle operations
|
|
1158
|
+
|
|
1159
|
+
**Key decisions:**
|
|
1160
|
+
- IDs are kebab-case, prefixed `k-` for observations, entity name for entities, domain name for domain summaries
|
|
1161
|
+
- Zod schemas validate frontmatter on read; malformed files get logged and skipped (not crash)
|
|
1162
|
+
- `KnowledgeNote` carries its `filePath` so the graph can reference it, but the path is not in frontmatter (it's derived from type + name)
|
|
1163
|
+
|
|
1164
|
+
#### Step 1.2 — Graph types (`src/types/knowledge-graph.ts`)
|
|
1165
|
+
|
|
1166
|
+
New file. Types for the multi-graph overlay from Section 5.
|
|
1167
|
+
|
|
1168
|
+
**What to define:**
|
|
1169
|
+
- `GraphNode`, `GraphEdge`, `GraphLayer`, `GraphLayerName`
|
|
1170
|
+
- `KnowledgeMultiGraph` — the top-level JSON structure
|
|
1171
|
+
- `GraphLayerOperations` — the per-layer interface (getEdges, neighbors, pathBetween, addEdge, removeEdge, rebuild)
|
|
1172
|
+
- `KnowledgeGraphManager` — the aggregate interface (neighbors across layers, filterNodes, crossSystemLinks, subgraph, rebuildAll)
|
|
1173
|
+
- `GraphConfig` — from Section 5.6
|
|
1174
|
+
|
|
1175
|
+
#### Step 1.3 — Config integration (`src/types/config.ts`)
|
|
1176
|
+
|
|
1177
|
+
Modify existing file. Add `KnowledgeBankConfig` (Section 11) as a new Zod schema nested under `AtlasConfigSchema`.
|
|
1178
|
+
|
|
1179
|
+
**What to add:**
|
|
1180
|
+
- `KnowledgeBankConfigSchema` with all sub-schemas (extraction, defrag, confidence, graph, surfacing)
|
|
1181
|
+
- Default: `enabled: false`, so no behavior change for existing users
|
|
1182
|
+
- Add `knowledgeBank: KnowledgeBankConfigSchema.default({})` to `AtlasConfigSchema`
|
|
1183
|
+
|
|
1184
|
+
**What to re-export:**
|
|
1185
|
+
- Add `KnowledgeBankConfig` type export to `src/types/index.ts`
|
|
1186
|
+
|
|
1187
|
+
#### Step 1.4 — Frontmatter parser (`src/utils/frontmatter.ts`)
|
|
1188
|
+
|
|
1189
|
+
New file. Full-fidelity YAML frontmatter parser/serializer for knowledge notes.
|
|
1190
|
+
|
|
1191
|
+
**Why not reuse minimem's parser:** minimem's `parseSimpleYaml` only handles 2-level nesting and inline arrays. Our frontmatter has `links: [{ target: ..., relation: ..., layer: ... }]` and `source: { origin: ..., trajectories: [...] }`. We need to parse these correctly.
|
|
1192
|
+
|
|
1193
|
+
**What to implement:**
|
|
1194
|
+
- `parseKnowledgeFrontmatter(content: string): { frontmatter: KnowledgeNoteFrontmatter | null; body: string }` — parse `---` delimited YAML block into typed frontmatter. Uses a lightweight approach: regex for `---` delimiters, then either a small YAML parser (consider `yaml` npm package which is already a common dependency) or a hand-rolled parser that handles 3 levels + `- item` list syntax.
|
|
1195
|
+
- `serializeKnowledgeFrontmatter(frontmatter: KnowledgeNoteFrontmatter): string` — produce `---\n...\n---\n` block. Keep simple fields (`created`, `updated`, `tags`) in the same format minimem uses so its parser can read those fields.
|
|
1196
|
+
- `serializeKnowledgeNote(note: KnowledgeNote): string` — frontmatter + body combined.
|
|
1197
|
+
|
|
1198
|
+
**Decision: YAML library or hand-rolled?**
|
|
1199
|
+
- If `yaml` (npm) is already in the dependency tree or acceptable to add: use it. It's 60KB, zero dependencies, well-maintained.
|
|
1200
|
+
- If zero-dependency is a hard constraint: hand-roll a parser that handles the specific shapes we need (nested objects, arrays of objects, arrays of strings). Not a general YAML parser — just enough for our schema.
|
|
1201
|
+
- **Recommendation:** Use the `yaml` package. The frontmatter schema will evolve and a hand-rolled parser will be a maintenance burden.
|
|
1202
|
+
|
|
1203
|
+
#### Step 1.5 — KnowledgeBank class (`src/memory/knowledge-bank.ts`)
|
|
1204
|
+
|
|
1205
|
+
New file. The main class from Section 10.
|
|
1206
|
+
|
|
1207
|
+
**Phase 1 scope** (subset of the full interface):
|
|
1208
|
+
- Constructor: takes `memoryDir` path and `KnowledgeBankConfig`
|
|
1209
|
+
- `init()` — create directory structure (`knowledge/observations/`, `knowledge/entities/`, `knowledge/domains/`, `inbox/`, `.knowledge/layers/`) if not exists. Load graph from disk if present.
|
|
1210
|
+
- `close()` — flush graph to disk.
|
|
1211
|
+
- **Write ops:** `addObservation(note)`, `updateEntity(entityId, update)` — write markdown files to correct directory, update graph overlay in memory.
|
|
1212
|
+
- **Read ops:** `getNote(id)`, `getEntity(entityName)`, `getDomainSummary(domain)`, `listEntities()`, `listDomains()` — scan filesystem, parse frontmatter, return typed `KnowledgeNote`.
|
|
1213
|
+
- **Graph delegation:** `getRelated(noteId, options)` — delegates to `KnowledgeGraphManager`.
|
|
1214
|
+
- **Stats:** `getStats()` — count files in each directory, graph stats.
|
|
1215
|
+
|
|
1216
|
+
**Internal helpers:**
|
|
1217
|
+
- `private noteIdToPath(id: string, type: NoteType): string` — resolve note ID to filesystem path based on type
|
|
1218
|
+
- `private scanDirectory(dir: string): Promise<KnowledgeNote[]>` — read all `.md` files, parse frontmatter
|
|
1219
|
+
- `private writeNote(note: KnowledgeNote): Promise<void>` — serialize and write to disk
|
|
1220
|
+
- `private buildManifest(): Promise<void>` — scan all notes, write `.knowledge/manifest.json`
|
|
1221
|
+
|
|
1222
|
+
**Not in Phase 1:** `search()`, `getRelevantKnowledge()`, `processInbox()`, `defragment()`, `applyExtraction()`, `reinforce()`, `recordContradiction()`, `applyDecay()`, `formatKnowledgeForPrompt()`. These are stubs that throw "not implemented" or return empty results.
|
|
1223
|
+
|
|
1224
|
+
#### Step 1.6 — KnowledgeGraphManager (`src/memory/knowledge-graph.ts`)
|
|
1225
|
+
|
|
1226
|
+
New file. Implements `KnowledgeGraphManager` interface.
|
|
1227
|
+
|
|
1228
|
+
**What to implement:**
|
|
1229
|
+
- Constructor: takes `GraphConfig`, initializes enabled layers
|
|
1230
|
+
- `getLayer(name)` — return a layer by name (or null if disabled)
|
|
1231
|
+
- `neighbors(nodeId, options)` — BFS across all enabled layers (or subset specified in options), union results, deduplicate by node ID, sort by edge weight
|
|
1232
|
+
- `filterNodes(filter)` — linear scan of node registry with domain/entity/tag/type/confidence predicates
|
|
1233
|
+
- `crossSystemLinks(nodeId)` — filter edges where `crossSystem` is set
|
|
1234
|
+
- `rebuildAll(notes)` — rebuild shared node set from notes, then delegate `rebuild()` to each enabled layer
|
|
1235
|
+
- **Persistence:** `loadFromDisk(dir)`, `saveToDisk(dir)` — read/write `nodes.json` + `layers/*.json`
|
|
1236
|
+
|
|
1237
|
+
**Not in Phase 1:** `pathBetween()` (BFS shortest path — implement but can be basic), `subgraph()` (stub).
|
|
1238
|
+
|
|
1239
|
+
#### Step 1.7 — Semantic graph layer (`src/memory/graph-layers/semantic.ts`)
|
|
1240
|
+
|
|
1241
|
+
New file. Implements `GraphLayerOperations` for the semantic layer.
|
|
1242
|
+
|
|
1243
|
+
**What to implement:**
|
|
1244
|
+
- In-memory adjacency list (`Map<string, GraphEdge[]>`) for fast lookups
|
|
1245
|
+
- `getEdges(nodeId, direction)` — O(1) lookup
|
|
1246
|
+
- `neighbors(nodeId, depth)` — BFS with depth limit
|
|
1247
|
+
- `pathBetween(from, to)` — BFS shortest path
|
|
1248
|
+
- `addEdge(edge)` / `removeEdge(from, to, relation)` — mutate adjacency list
|
|
1249
|
+
- `rebuild(notes)` — iterate all notes' `links` where relation is a semantic type, build adjacency list
|
|
1250
|
+
|
|
1251
|
+
#### Step 1.8 — Layer stubs (`src/memory/graph-layers/temporal.ts`, `causal.ts`, `entity.ts`)
|
|
1252
|
+
|
|
1253
|
+
New files. Minimal implementations that share the same adjacency-list structure as semantic. Each only differs in which `LinkRelation` values they accept in `rebuild()`. Disabled by default in `GraphConfig.enabledLayers`.
|
|
1254
|
+
|
|
1255
|
+
The implementation is identical to semantic — extract a shared `BaseGraphLayer` class that the four layers extend, each overriding only the set of valid relation types for their layer.
|
|
1256
|
+
|
|
1257
|
+
#### Step 1.9 — Wire into MemorySystem (`src/memory/system.ts`)
|
|
1258
|
+
|
|
1259
|
+
Modify existing file.
|
|
1260
|
+
|
|
1261
|
+
**What to add:**
|
|
1262
|
+
- `public readonly knowledgeBank: KnowledgeBank | null` — initialized when `config.knowledgeBank.enabled` is true
|
|
1263
|
+
- In `init()`: `if (this.knowledgeBank) await this.knowledgeBank.init()`
|
|
1264
|
+
- In `close()`: `if (this.knowledgeBank) await this.knowledgeBank.close()`
|
|
1265
|
+
- In `getStats()`: add `knowledgeBank` stats if enabled
|
|
1266
|
+
|
|
1267
|
+
**What NOT to change:** Everything else in MemorySystem stays the same. KnowledgeBank is an additive, optional subsystem.
|
|
1268
|
+
|
|
1269
|
+
#### Step 1.10 — Wire into Atlas (`src/atlas.ts`)
|
|
1270
|
+
|
|
1271
|
+
Modify existing file.
|
|
1272
|
+
|
|
1273
|
+
**What to add:**
|
|
1274
|
+
- In constructor: no change (MemorySystem handles initialization)
|
|
1275
|
+
- In `init()`: after memory init, if `this.memory.knowledgeBank`, store reference for later use
|
|
1276
|
+
- `getKnowledgeBank(): KnowledgeBank | null` accessor
|
|
1277
|
+
- In `getStats()`: add `knowledgeBank` section to `AtlasStats` if enabled
|
|
1278
|
+
- In `close()`: no change (MemorySystem handles cleanup)
|
|
1279
|
+
|
|
1280
|
+
**What NOT to change:** `solve()`, `processTrajectory()`, learning pipeline integration — all Phase 2+.
|
|
1281
|
+
|
|
1282
|
+
#### Step 1.11 — Exports
|
|
1283
|
+
|
|
1284
|
+
- New barrel: `src/memory/graph-layers/index.ts` — exports layer classes
|
|
1285
|
+
- Update `src/memory/index.ts` — add KnowledgeBank exports
|
|
1286
|
+
- Update `src/types/index.ts` — add knowledge types + graph types
|
|
1287
|
+
- Update `src/index.ts` — add KnowledgeBank + types to top-level exports
|
|
1288
|
+
|
|
1289
|
+
#### Step 1.12 — Tests
|
|
1290
|
+
|
|
1291
|
+
New test files:
|
|
1292
|
+
- `tests/memory/knowledge-bank.test.ts` — CRUD operations, directory structure creation, note serialization round-trip, ID-to-path resolution, stats
|
|
1293
|
+
- `tests/memory/knowledge-graph.test.ts` — graph manager lifecycle (build from notes, query neighbors, filter nodes, cross-layer queries, persistence round-trip)
|
|
1294
|
+
- `tests/memory/graph-layers/semantic.test.ts` — semantic layer edge operations, BFS, rebuild from notes
|
|
1295
|
+
- `tests/utils/frontmatter.test.ts` — parse/serialize round-trip for all frontmatter shapes, compatibility with minimem's simple fields, malformed input handling
|
|
1296
|
+
|
|
1297
|
+
**Phase 1 deliverable:** A standalone `KnowledgeBank` that can be instantiated, writes structured markdown files to disk, maintains a graph overlay, and passes all CRUD + graph tests. Can be used independently of the learning pipeline.
|
|
1298
|
+
|
|
1299
|
+
---
|
|
1300
|
+
|
|
1301
|
+
### Phase 2: Extraction Pipeline
|
|
1302
|
+
|
|
1303
|
+
**Goal**: Automatically extract knowledge from trajectories, running parallel to the existing PlaybookExtractor within the LearningPipeline.
|
|
1304
|
+
|
|
1305
|
+
**Depends on:** Phase 1 complete (KnowledgeBank with working CRUD + graph).
|
|
1306
|
+
|
|
1307
|
+
#### Step 2.1 — KnowledgeExtractor (`src/learning/knowledge-extractor.ts`)
|
|
1308
|
+
|
|
1309
|
+
New file. The heuristic extraction engine.
|
|
1310
|
+
|
|
1311
|
+
**What to implement:**
|
|
1312
|
+
|
|
1313
|
+
```typescript
|
|
1314
|
+
class KnowledgeExtractor {
|
|
1315
|
+
constructor(config?: KnowledgeExtractionConfig);
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Extract knowledge from a single trajectory + its analysis.
|
|
1319
|
+
* Returns observations, entity updates, contradictions, and links.
|
|
1320
|
+
*/
|
|
1321
|
+
async extract(
|
|
1322
|
+
trajectory: Trajectory,
|
|
1323
|
+
analysis: AnalysisResult,
|
|
1324
|
+
knowledgeBank: KnowledgeBank
|
|
1325
|
+
): Promise<ExtractedKnowledge>;
|
|
1326
|
+
}
|
|
1327
|
+
```
|
|
1328
|
+
|
|
1329
|
+
**Heuristic extraction strategies** (no LLM required):
|
|
1330
|
+
|
|
1331
|
+
1. **Error pattern extraction** — Scan `trajectory.steps` for steps with `type: 'error'` or failed outcomes. Extract tool/library name from error message + what fixed it → observation note. Pattern: `"{tool} fails when {condition}; fix: {resolution}"`.
|
|
1332
|
+
|
|
1333
|
+
2. **Configuration facts** — Detect steps that read/write config files (package.json, tsconfig.json, etc.). Extract version constraints and settings → observation notes. Pattern: `"{tool} {version} requires {setting}"`.
|
|
1334
|
+
|
|
1335
|
+
3. **Causal chain extraction** — Find failure→recovery sequences in steps (consecutive failure then success involving the same tool). Extract the causal relationship → observation + causal graph edge.
|
|
1336
|
+
|
|
1337
|
+
4. **Entity identification** — Extract entity names from trajectory step descriptions and tool calls. Group extracted observations by entity. If an entity note exists, produce an `EntityUpdate`; if not, record the entity name for future consolidation.
|
|
1338
|
+
|
|
1339
|
+
5. **Contradiction detection** — For each new observation, search existing KnowledgeBank for notes with overlapping entities + domain. Use `textSimilarity()` (from `src/utils/similarity.ts`) to find similar existing notes. If similarity is high but content conflicts (detected by presence of negation words, different version numbers, etc.), produce a `Contradiction`.
|
|
1340
|
+
|
|
1341
|
+
6. **Cross-reference detection** — If the trajectory was guided by a playbook (available in trajectory metadata from `SolveResult.injectedPlaybooks`), produce `PlaybookLink` entries connecting new observations to those playbooks.
|
|
1342
|
+
|
|
1343
|
+
**Key decision — extraction per-trajectory vs batch:**
|
|
1344
|
+
Knowledge extraction runs on **every trajectory** (unlike playbook extraction which batches). Individual facts are valuable immediately. The `extract()` method is called in `processTrajectory()`, not `runBatchLearning()`.
|
|
1345
|
+
|
|
1346
|
+
#### Step 2.2 — Integrate into LearningPipeline (`src/learning/pipeline.ts`)
|
|
1347
|
+
|
|
1348
|
+
Modify existing file.
|
|
1349
|
+
|
|
1350
|
+
**What to change in constructor:**
|
|
1351
|
+
- Accept optional `KnowledgeBank` (from `MemorySystem.knowledgeBank`)
|
|
1352
|
+
- If provided, create a `KnowledgeExtractor` instance
|
|
1353
|
+
|
|
1354
|
+
**What to change in `processTrajectory()`:**
|
|
1355
|
+
- After analysis, if `knowledgeExtractor` exists:
|
|
1356
|
+
```
|
|
1357
|
+
const knowledge = await this.knowledgeExtractor.extract(trajectory, analysis, knowledgeBank);
|
|
1358
|
+
await knowledgeBank.applyExtraction(knowledge);
|
|
1359
|
+
```
|
|
1360
|
+
- Add `knowledgeExtracted: boolean` to `ProcessResult`
|
|
1361
|
+
|
|
1362
|
+
**What NOT to change:** Batch learning flow, playbook extraction — those continue as-is.
|
|
1363
|
+
|
|
1364
|
+
#### Step 2.3 — `applyExtraction()` on KnowledgeBank (`src/memory/knowledge-bank.ts`)
|
|
1365
|
+
|
|
1366
|
+
Implement the previously-stubbed method.
|
|
1367
|
+
|
|
1368
|
+
**What it does:**
|
|
1369
|
+
1. For each `observation` in `ExtractedKnowledge`: call `addObservation()` to write the file
|
|
1370
|
+
2. For each `entityUpdate`: read the entity note, append the new section, update `updated` timestamp, write back
|
|
1371
|
+
3. For each `contradiction`: call `recordContradiction()` (stub in Phase 1, full implementation in Phase 3)
|
|
1372
|
+
4. For each `link`: add edge to the appropriate graph layer
|
|
1373
|
+
5. For each `playbookLink`: add cross-system edge to semantic layer with `crossSystem: 'playbook'`
|
|
1374
|
+
6. Persist graph to disk
|
|
1375
|
+
|
|
1376
|
+
#### Step 2.4 — Workspace template for LLM-assisted extraction (`src/workspace/templates/knowledge-extraction.ts`)
|
|
1377
|
+
|
|
1378
|
+
New file. Follows the `AgenticTaskTemplate<Input, Output>` pattern from `trajectory-analysis.ts`.
|
|
1379
|
+
|
|
1380
|
+
**Template structure:**
|
|
1381
|
+
- `taskType: 'knowledge-extraction'`
|
|
1382
|
+
- `assessComplexity(input)`: `'heuristic'` for short trajectories (< 5 steps), `'lightweight'` for medium (5-15 steps), `'standard'` for long/complex
|
|
1383
|
+
- `heuristicFallback(input)`: delegates to `KnowledgeExtractor.extract()` (the heuristic engine from Step 2.1)
|
|
1384
|
+
- Agent prompt: "Analyze this trajectory and extract factual knowledge. For each fact, produce a structured observation with domain, entities, tags, confidence, and evidence."
|
|
1385
|
+
- Output spec: validates against `ExtractedKnowledge` schema
|
|
1386
|
+
|
|
1387
|
+
**Integration:** In `LearningPipeline.processTrajectory()`, if `taskRunner` is available and extraction config has `useLlmExtraction: true`, use the template instead of direct heuristic extraction (same pattern as `analyzeWithTemplate`).
|
|
1388
|
+
|
|
1389
|
+
#### Step 2.5 — Tests
|
|
1390
|
+
|
|
1391
|
+
New test files:
|
|
1392
|
+
- `tests/learning/knowledge-extractor.test.ts` — Feed sample trajectories (with errors, config changes, version issues) and verify correct observations, entity updates, and contradictions are extracted. Test each heuristic strategy independently.
|
|
1393
|
+
- `tests/learning/pipeline-knowledge.test.ts` — Integration test: process a trajectory through LearningPipeline with KnowledgeBank enabled, verify notes appear on filesystem and graph is updated.
|
|
1394
|
+
|
|
1395
|
+
**Phase 2 deliverable:** Processing a trajectory through the LearningPipeline now automatically extracts knowledge observations, writes them to disk, and updates the graph. Heuristic extraction works without an LLM; LLM-assisted extraction is available via workspace template.
|
|
1396
|
+
|
|
1397
|
+
---
|
|
1398
|
+
|
|
1399
|
+
### Phase 3: Evolution & Defragmentation
|
|
1400
|
+
|
|
1401
|
+
**Goal**: Knowledge evolves with reinforcement, contradiction resolution, staleness decay, and periodic defragmentation that consolidates and organizes the knowledge base.
|
|
1402
|
+
|
|
1403
|
+
**Depends on:** Phase 2 complete (extraction pipeline producing observations).
|
|
1404
|
+
|
|
1405
|
+
#### Step 3.1 — Reinforcement (`src/memory/knowledge-bank.ts`)
|
|
1406
|
+
|
|
1407
|
+
Implement the previously-stubbed `reinforce()` method.
|
|
1408
|
+
|
|
1409
|
+
**What it does:**
|
|
1410
|
+
- Look up note by ID
|
|
1411
|
+
- Apply EMA confidence update: `newConf = (1 - alpha) * oldConf + alpha * 1.0` (alpha from `ConfidenceConfig.reinforcementAlpha`, default 0.1)
|
|
1412
|
+
- Add trajectory ID to `source.trajectories` array
|
|
1413
|
+
- Update `updated` timestamp
|
|
1414
|
+
- Write note back to disk
|
|
1415
|
+
- Update graph node's `confidence` and `updated`
|
|
1416
|
+
|
|
1417
|
+
**Called from:** `KnowledgeExtractor.extract()` when a new observation matches an existing one (similarity > threshold), instead of creating a duplicate.
|
|
1418
|
+
|
|
1419
|
+
#### Step 3.2 — Contradiction resolution (`src/memory/knowledge-bank.ts`)
|
|
1420
|
+
|
|
1421
|
+
Implement the previously-stubbed `recordContradiction()` method.
|
|
1422
|
+
|
|
1423
|
+
**What it does:**
|
|
1424
|
+
- Based on `Contradiction.resolution`:
|
|
1425
|
+
- `'supersede'`: Create new observation with `supersedes` pointing to old note's ID. Lower old note's confidence by `contradictionPenalty`. Add `supersedes` edge in temporal layer + `contradicts` edge in entity layer.
|
|
1426
|
+
- `'coexist'`: Both notes kept. Add `contradicts` edge. Both get a slight confidence reduction (half of penalty) since truth is ambiguous.
|
|
1427
|
+
- `'review'`: Add `contradicts` edge. Tag both notes with `needs-review`. No confidence change — leave for the defrag process or human review.
|
|
1428
|
+
|
|
1429
|
+
#### Step 3.3 — Staleness decay (`src/memory/knowledge-bank.ts`)
|
|
1430
|
+
|
|
1431
|
+
Implement the previously-stubbed `applyDecay()` method.
|
|
1432
|
+
|
|
1433
|
+
**What it does:**
|
|
1434
|
+
- Scan all observation and entity notes
|
|
1435
|
+
- For each note: calculate days since `updated`
|
|
1436
|
+
- If days > `decayGracePeriodDays`: apply decay `newConf = oldConf * (1 - dailyDecayRate) ^ (days - gracePeriod)`
|
|
1437
|
+
- If confidence drops below `staleThreshold`: add `stale` tag to note
|
|
1438
|
+
- Return `DecayResult` with counts (decayed, newly stale, already stale)
|
|
1439
|
+
|
|
1440
|
+
**When called:** By defragmentation process (Step 3.5) or explicitly via `KnowledgeBank.applyDecay()`.
|
|
1441
|
+
|
|
1442
|
+
#### Step 3.4 — Inbox processing (`src/memory/knowledge-bank.ts`)
|
|
1443
|
+
|
|
1444
|
+
Implement the previously-stubbed `processInbox()` method.
|
|
1445
|
+
|
|
1446
|
+
**What it does:**
|
|
1447
|
+
1. Scan `inbox/` directory for `.md` files
|
|
1448
|
+
2. For each file:
|
|
1449
|
+
a. Try to parse frontmatter. If valid `KnowledgeNoteFrontmatter`: classify by `type`, move to correct directory (`observations/`, `entities/`, `domains/`), add to graph.
|
|
1450
|
+
b. If no frontmatter or invalid: attempt heuristic classification — extract entities from title/content, assign default frontmatter (type: `observation`, confidence: `agentAuthoredInitial`), generate ID from filename, move to `observations/`.
|
|
1451
|
+
3. Return `InboxResult` with counts (processed, failed, moved to each directory)
|
|
1452
|
+
|
|
1453
|
+
#### Step 3.5 — Defragmentation orchestrator (`src/memory/knowledge-defrag.ts`)
|
|
1454
|
+
|
|
1455
|
+
New file. Implements the 7-step defrag process from Section 8.1.
|
|
1456
|
+
|
|
1457
|
+
```typescript
|
|
1458
|
+
class KnowledgeDefragmenter {
|
|
1459
|
+
constructor(
|
|
1460
|
+
private knowledgeBank: KnowledgeBank,
|
|
1461
|
+
private config: DefragConfig
|
|
1462
|
+
);
|
|
1463
|
+
|
|
1464
|
+
async defragment(): Promise<DefragResult>;
|
|
1465
|
+
}
|
|
1466
|
+
```
|
|
1467
|
+
|
|
1468
|
+
**Defrag steps (all heuristic in Phase 3):**
|
|
1469
|
+
|
|
1470
|
+
1. **Inbox processing** — delegate to `knowledgeBank.processInbox()`
|
|
1471
|
+
2. **Consolidation** — find entities with `>= consolidationThreshold` observations. For each: read observations, merge content into entity note (append sections with evidence citations), add `generalizes` links from entity → observations.
|
|
1472
|
+
3. **Contradiction detection** — pairwise similarity scan across observations in the same domain. Flag high-similarity + conflicting content pairs. (Reuses the same logic from `KnowledgeExtractor` contradiction detection.)
|
|
1473
|
+
4. **Graph rebuild** — `knowledgeBank.graph.rebuildAll(allNotes)` — full rebuild from frontmatter.
|
|
1474
|
+
5. **Domain summary regeneration** — for each domain with changes since last regen: collect entity notes + observations, generate a concatenated summary (heuristic: list entities + top observations by confidence). Write to `domains/{domain}.md`.
|
|
1475
|
+
6. **Staleness sweep** — `knowledgeBank.applyDecay()`
|
|
1476
|
+
7. **Manifest update** — rebuild `.knowledge/manifest.json` (note ID → path mapping) and `.knowledge/domain-index.json` (domain → note IDs)
|
|
1477
|
+
|
|
1478
|
+
**`KnowledgeBank.defragment()`** delegates to `KnowledgeDefragmenter.defragment()`.
|
|
1479
|
+
|
|
1480
|
+
#### Step 3.6 — Workspace template for agentic defrag (`src/workspace/templates/knowledge-defrag.ts`)
|
|
1481
|
+
|
|
1482
|
+
New file. Template for LLM-assisted defragmentation.
|
|
1483
|
+
|
|
1484
|
+
**When used:** When `DefragConfig.llmSummaryGeneration` is true, or for consolidation that requires semantic understanding (merging observations into coherent entity notes rather than just concatenating).
|
|
1485
|
+
|
|
1486
|
+
**Template scope:**
|
|
1487
|
+
- Generate natural-language domain summaries (vs heuristic concatenation)
|
|
1488
|
+
- Semantic consolidation — merge related observations into entity notes with proper narrative flow
|
|
1489
|
+
- Nuanced contradiction detection — understand context-dependent truths
|
|
1490
|
+
|
|
1491
|
+
#### Step 3.7 — Defrag scheduling
|
|
1492
|
+
|
|
1493
|
+
**Where:** In `KnowledgeBank.init()`, optionally start a defrag timer:
|
|
1494
|
+
- If `defrag.interval > 0`: schedule `setInterval(defragment, interval)`
|
|
1495
|
+
- Also expose `defragment()` for manual/on-demand runs
|
|
1496
|
+
- In `close()`: clear the timer
|
|
1497
|
+
|
|
1498
|
+
Alternatively (simpler): don't auto-schedule. Instead, the `LearningPipeline` triggers defrag after batch learning completes, or Atlas triggers it periodically. This avoids background timers and keeps the control flow explicit.
|
|
1499
|
+
|
|
1500
|
+
**Recommendation:** No auto-scheduling in Phase 3. Add a `shouldDefragment(): boolean` check (inbox count > minInboxItems) and let the caller decide when to run it.
|
|
1501
|
+
|
|
1502
|
+
#### Step 3.8 — Tests
|
|
1503
|
+
|
|
1504
|
+
New test files:
|
|
1505
|
+
- `tests/memory/knowledge-evolution.test.ts` — reinforcement (confidence increases correctly), contradiction resolution (supersede/coexist/review paths), staleness decay (grace period, threshold, tagging)
|
|
1506
|
+
- `tests/memory/knowledge-defrag.test.ts` — full defrag cycle: seed inbox files → process → verify organization. Consolidation: seed 4 observations about same entity → verify entity note created with merged content. Domain summary: verify regeneration after entity changes. Manifest: verify JSON index accuracy.
|
|
1507
|
+
|
|
1508
|
+
**Phase 3 deliverable:** Knowledge base is self-organizing. Inbox notes get classified and filed. Observations consolidate into entity notes. Contradictions are detected and handled. Stale knowledge decays. The filesystem stays clean and well-structured without manual intervention.
|
|
1509
|
+
|
|
1510
|
+
---
|
|
1511
|
+
|
|
1512
|
+
### Phase 4: Retrieval & Surfacing
|
|
1513
|
+
|
|
1514
|
+
**Goal**: Knowledge is surfaced to agents during task execution as an independent context section alongside (but decoupled from) playbook/skill surfacing.
|
|
1515
|
+
|
|
1516
|
+
**Depends on:** Phase 1 complete for core read/graph operations. Can be developed in parallel with Phase 2-3 for the surfacing-specific code, but full integration requires Phase 2 (extraction populates the knowledge base).
|
|
1517
|
+
|
|
1518
|
+
#### Step 4.1 — Knowledge retrieval (`src/memory/knowledge-bank.ts`)
|
|
1519
|
+
|
|
1520
|
+
Implement the previously-stubbed search and retrieval methods.
|
|
1521
|
+
|
|
1522
|
+
**`search(query, options)`:**
|
|
1523
|
+
- If `EmbeddingManager` is available (from the existing embedding infrastructure in `src/embeddings/`): use vector search over knowledge notes. This requires indexing knowledge notes into the existing `SqliteVectorStore` — add knowledge notes as a new `MemoryItemType` alongside experiences and playbooks.
|
|
1524
|
+
- Fallback: `BM25Index` text search (already available in `src/embeddings/bm25.ts`).
|
|
1525
|
+
- Filter results by domain, entity, confidence, type if options specify.
|
|
1526
|
+
|
|
1527
|
+
**`getRelevantKnowledge(task, options)`:**
|
|
1528
|
+
- Independent from `SkillLibrary.getSkillsForAgent()` — does not reference playbooks.
|
|
1529
|
+
- Three-tier retrieval (parallel to but independent from skill tiers):
|
|
1530
|
+
1. **Domain match** — if `task.domain` matches a knowledge domain, include the domain summary
|
|
1531
|
+
2. **Entity match** — scan task description for known entity names (from `listEntities()`), include matching entity notes
|
|
1532
|
+
3. **Semantic match** — run `search(task.description)` for top-N contextually relevant observations
|
|
1533
|
+
- Deduplicate across tiers (domain summary may reference same entities as tier 2)
|
|
1534
|
+
- Respect `maxNotes` and `maxTokens` limits (estimate tokens from content length)
|
|
1535
|
+
- Return `KnowledgeMatch[]` sorted by relevance
|
|
1536
|
+
|
|
1537
|
+
#### Step 4.2 — Prompt formatting (`src/memory/knowledge-bank.ts`)
|
|
1538
|
+
|
|
1539
|
+
Implement `formatKnowledgeForPrompt()`.
|
|
1540
|
+
|
|
1541
|
+
**Output format:**
|
|
1542
|
+
```markdown
|
|
1543
|
+
## Relevant Knowledge
|
|
1544
|
+
|
|
1545
|
+
### About {entity} ({confidence}% confidence)
|
|
1546
|
+
- {observation summary} ({source info})
|
|
1547
|
+
- {observation summary}
|
|
1548
|
+
|
|
1549
|
+
### {domain} Overview
|
|
1550
|
+
{domain summary content}
|
|
1551
|
+
|
|
1552
|
+
### Additional Context
|
|
1553
|
+
- {contextual observation}
|
|
1554
|
+
```
|
|
1555
|
+
|
|
1556
|
+
**Options:**
|
|
1557
|
+
- `maxTokens` — truncate to fit budget (drop lowest-confidence notes first)
|
|
1558
|
+
- `includeEvidence` — append evidence citations (trajectory IDs, dates)
|
|
1559
|
+
- `includeLinks` — append "Related: ..." links
|
|
1560
|
+
|
|
1561
|
+
#### Step 4.3 — Wire into Atlas.solve() (`src/atlas.ts`)
|
|
1562
|
+
|
|
1563
|
+
Modify `solve()` to surface knowledge alongside skills.
|
|
1564
|
+
|
|
1565
|
+
**What to add:**
|
|
1566
|
+
```typescript
|
|
1567
|
+
// In solve(), after skill surfacing:
|
|
1568
|
+
let knowledgeContext = '';
|
|
1569
|
+
if (this.memory.knowledgeBank) {
|
|
1570
|
+
const knowledge = await this.memory.knowledgeBank.getRelevantKnowledge(task, {
|
|
1571
|
+
maxNotes: this.config.knowledgeBank.surfacing.maxNotesPerTask,
|
|
1572
|
+
maxTokens: this.config.knowledgeBank.surfacing.maxTokensForKnowledge,
|
|
1573
|
+
});
|
|
1574
|
+
knowledgeContext = this.memory.knowledgeBank.formatKnowledgeForPrompt(knowledge, {
|
|
1575
|
+
includeEvidence: this.config.knowledgeBank.surfacing.includeEvidence,
|
|
1576
|
+
includeLinks: this.config.knowledgeBank.surfacing.includeLinks,
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
// Combine skill context + knowledge context for agent
|
|
1581
|
+
const systemPromptAdditions = [skillContext, knowledgeContext].filter(Boolean).join('\n\n');
|
|
1582
|
+
```
|
|
1583
|
+
|
|
1584
|
+
**What to add to SolveResult:**
|
|
1585
|
+
- `injectedKnowledge?: KnowledgeMatch[]` — which knowledge notes were surfaced (for traceability)
|
|
1586
|
+
|
|
1587
|
+
#### Step 4.4 — Knowledge tracing in trajectories
|
|
1588
|
+
|
|
1589
|
+
**What to add to trajectory metadata** (in the `SolveResult` or trajectory's metadata field):
|
|
1590
|
+
- List of surfaced knowledge note IDs + their `updated` timestamps at time of surfacing
|
|
1591
|
+
- This enables the learning pipeline to assess: "was this knowledge helpful?" by comparing surfaced knowledge to trajectory outcome
|
|
1592
|
+
|
|
1593
|
+
This is the knowledge equivalent of `injectedPlaybooks` / `playbookUsage` in the existing flow.
|
|
1594
|
+
|
|
1595
|
+
#### Step 4.5 — Multi-layer graph query methods (`src/memory/knowledge-bank.ts`)
|
|
1596
|
+
|
|
1597
|
+
Implement the remaining graph delegation methods:
|
|
1598
|
+
|
|
1599
|
+
**`getCausalChain(noteId, direction)`:**
|
|
1600
|
+
- Requires causal layer enabled
|
|
1601
|
+
- Follow `caused-by` edges backward (direction: 'causes') or `led-to`/`broke`/`enabled` forward (direction: 'effects')
|
|
1602
|
+
- Return chain as ordered `KnowledgeMatch[]`
|
|
1603
|
+
|
|
1604
|
+
**`getTemporalNeighbors(noteId, window)`:**
|
|
1605
|
+
- Requires temporal layer enabled
|
|
1606
|
+
- Follow `co-occurred`, `observed-before`, `observed-after` edges
|
|
1607
|
+
- Optionally filter by time window
|
|
1608
|
+
|
|
1609
|
+
**`getKnowledgeForPlaybook(playbookId)`:**
|
|
1610
|
+
- Query cross-system edges where `crossSystem === 'playbook'` and target matches playbookId
|
|
1611
|
+
- Return all knowledge notes that reference this playbook
|
|
1612
|
+
|
|
1613
|
+
#### Step 4.6 — MCP server integration
|
|
1614
|
+
|
|
1615
|
+
**Option A (recommended):** Add knowledge tools to the existing `PlaybookMCPServer` (`src/mcp/playbook-server.ts`).
|
|
1616
|
+
|
|
1617
|
+
New tools:
|
|
1618
|
+
- `knowledge_search` — wraps `knowledgeBank.search()`
|
|
1619
|
+
- `knowledge_entity` — wraps `knowledgeBank.getEntity()`
|
|
1620
|
+
- `knowledge_domain` — wraps `knowledgeBank.getDomainSummary()`
|
|
1621
|
+
- `knowledge_related` — wraps `knowledgeBank.getRelated()`
|
|
1622
|
+
|
|
1623
|
+
**Option B:** Separate `KnowledgeMCPServer`. More modular but adds operational complexity (two servers to configure).
|
|
1624
|
+
|
|
1625
|
+
**Recommendation:** Option A — extend the existing server. Rename it to `CognitiveCoreMCPServer` if the scope warrants it.
|
|
1626
|
+
|
|
1627
|
+
#### Step 4.7 — Tests
|
|
1628
|
+
|
|
1629
|
+
New test files:
|
|
1630
|
+
- `tests/memory/knowledge-retrieval.test.ts` — search with various query types, relevance ranking, token budget enforcement, tier matching
|
|
1631
|
+
- `tests/memory/knowledge-surfacing.test.ts` — formatKnowledgeForPrompt output format, truncation, option variations
|
|
1632
|
+
- `tests/atlas-knowledge.test.ts` — integration: Atlas.solve() with knowledge bank enabled, verify knowledge context appears in agent spawn config, verify traceability in SolveResult
|
|
1633
|
+
|
|
1634
|
+
**Phase 4 deliverable:** Agents receive relevant knowledge context during task execution. Knowledge surfacing is fully independent from skill surfacing. Multi-layer graph queries enable causal and temporal reasoning. Knowledge notes are traceable through trajectory metadata.
|
|
1635
|
+
|
|
1636
|
+
---
|
|
1637
|
+
|
|
1638
|
+
### Phase 5: Bidirectional minimem Integration (Optional)
|
|
1639
|
+
|
|
1640
|
+
**Goal**: Make cognitive-core and minimem mutually aware — cognitive-core delegates search to minimem when available, and minimem gains the ability to parse, index, and query knowledge-structured notes.
|
|
1641
|
+
|
|
1642
|
+
**Depends on:** Phase 4 complete. This phase is entirely optional and does not gate any core functionality.
|
|
1643
|
+
|
|
1644
|
+
**Coupling approach:** File conventions only — minimem parses the YAML frontmatter format by convention. No cross-package imports. Both packages remain independently deployable.
|
|
1645
|
+
|
|
1646
|
+
#### Part A: cognitive-core → minimem
|
|
1647
|
+
|
|
1648
|
+
**Step A1 — SearchProvider interface** (`src/memory/search-provider.ts`)
|
|
1649
|
+
|
|
1650
|
+
Strategy pattern for swappable search backends:
|
|
1651
|
+
|
|
1652
|
+
```typescript
|
|
1653
|
+
interface SearchProvider {
|
|
1654
|
+
readonly name: string;
|
|
1655
|
+
search(query, candidates, options?): SearchProviderResult[] | Promise<SearchProviderResult[]>;
|
|
1656
|
+
}
|
|
1657
|
+
```
|
|
1658
|
+
|
|
1659
|
+
**Step A2 — TextSimilaritySearchProvider** (`src/memory/search-providers/text-similarity.ts`)
|
|
1660
|
+
|
|
1661
|
+
Extracted existing `findTopK` logic from `KnowledgeBank.search()` into a class implementing `SearchProvider`.
|
|
1662
|
+
|
|
1663
|
+
**Step A3 — MinimemSearchProvider** (`src/memory/search-providers/minimem.ts`)
|
|
1664
|
+
|
|
1665
|
+
Defines `MinimemSearchClient` interface (subset of minimem's API) to avoid hard dependency. Delegates search to minimem, maps result paths back to candidate note IDs.
|
|
1666
|
+
|
|
1667
|
+
**Step A4 — Directory layout** (`src/memory/knowledge-bank.ts`)
|
|
1668
|
+
|
|
1669
|
+
When `minimemAware: true`, knowledge files are placed under `memory/knowledge/` instead of `knowledge/`, aligning with minimem's indexed path (`memory/**/*.md`).
|
|
1670
|
+
|
|
1671
|
+
**Step A5 — Detection** (`src/memory/knowledge-bank.ts`)
|
|
1672
|
+
|
|
1673
|
+
On `init()`, if `minimemAware`, checks for `.minimem/` directory or `MEMORY.md`. If found, dynamically `import('minimem')` — optional dependency, no `package.json` change. Falls back to `TextSimilaritySearchProvider` if unavailable.
|
|
1674
|
+
|
|
1675
|
+
#### Part B: minimem → cognitive-core
|
|
1676
|
+
|
|
1677
|
+
All changes in `references/minimem/`.
|
|
1678
|
+
|
|
1679
|
+
**Step B1 — Enhanced frontmatter parsing** (`src/session.ts`)
|
|
1680
|
+
|
|
1681
|
+
Extended `MemoryFrontmatter` with knowledge fields (`id`, `type`, `domain[]`, `entities[]`, `confidence`, `source`, `links[]`, `supersedes`). Types defined locally — zero imports from cognitive-core. Enhanced YAML parser for nested objects and arrays of objects.
|
|
1682
|
+
|
|
1683
|
+
**Step B2 — Database schema v4** (`src/db/schema.ts`)
|
|
1684
|
+
|
|
1685
|
+
Added nullable columns to `chunks` table (`knowledge_type`, `knowledge_id`, `domains`, `entities`, `confidence`). Created `knowledge_links` table for graph edges with composite PK `(from_id, to_id, relation)`.
|
|
1686
|
+
|
|
1687
|
+
**Step B3 — Knowledge-aware indexing** (`src/minimem.ts`)
|
|
1688
|
+
|
|
1689
|
+
`indexFile()` extracts knowledge frontmatter and populates chunk metadata columns. Upserts `knowledge_links` from frontmatter `links` array. Deletes old links on re-index.
|
|
1690
|
+
|
|
1691
|
+
**Step B4 — Knowledge-filtered search** (`src/search/search.ts`)
|
|
1692
|
+
|
|
1693
|
+
`buildKnowledgeFilterSql()` generates WHERE clauses using `json_each()` for domain/entity array filtering. Supports `minConfidence` and `knowledgeType` filters.
|
|
1694
|
+
|
|
1695
|
+
**Step B5 — Graph traversal** (`src/search/graph.ts`)
|
|
1696
|
+
|
|
1697
|
+
`getLinksFrom()`, `getLinksTo()`, `getNeighbors()` (BFS), `getPathBetween()` (BFS shortest path).
|
|
1698
|
+
|
|
1699
|
+
**Step B6 — Minimem class methods** (`src/minimem.ts`)
|
|
1700
|
+
|
|
1701
|
+
Public methods: `knowledgeSearch()`, `getLinks()`, `getGraphNeighbors()`, `getGraphPath()`.
|
|
1702
|
+
|
|
1703
|
+
**Step B7 — MCP tools** (`src/server/tools.ts`)
|
|
1704
|
+
|
|
1705
|
+
Three new tools alongside existing `memory_search`:
|
|
1706
|
+
- `knowledge_search` — search with domain/entity/confidence/type filters
|
|
1707
|
+
- `knowledge_graph` — traverse graph relationships from a note
|
|
1708
|
+
- `knowledge_path` — find shortest path between two knowledge notes
|
|
1709
|
+
|
|
1710
|
+
#### Part C: Tests
|
|
1711
|
+
|
|
1712
|
+
- `tests/memory/knowledge-minimem.test.ts` — 11 tests: file layout (4), search delegation (5), SearchProvider abstraction (2)
|
|
1713
|
+
- `references/minimem/src/__tests__/knowledge.test.ts` — 13 tests: frontmatter parsing (5), graph traversal (8)
|
|
1714
|
+
|
|
1715
|
+
**Phase 5 deliverable:** cognitive-core's knowledge bank works seamlessly in minimem-backed environments, reusing minimem's search. minimem gains full knowledge awareness — indexing metadata, storing graph edges, exposing knowledge-specific MCP tools — all via file conventions with zero cross-package coupling.
|
|
1716
|
+
|
|
1717
|
+
---
|
|
1718
|
+
|
|
1719
|
+
### Implementation Order & Parallelism
|
|
1720
|
+
|
|
1721
|
+
```
|
|
1722
|
+
Phase 1 (Foundation)
|
|
1723
|
+
├── Steps 1.1-1.4 (types, config, frontmatter) — can be done in parallel
|
|
1724
|
+
├── Steps 1.5-1.8 (KnowledgeBank, graph, layers) — depend on types
|
|
1725
|
+
├── Steps 1.9-1.11 (wiring, exports) — depend on KnowledgeBank
|
|
1726
|
+
└── Step 1.12 (tests) — depend on implementation
|
|
1727
|
+
|
|
1728
|
+
Phase 2 (Extraction) Phase 4 (Surfacing)
|
|
1729
|
+
├── depends on Phase 1 ├── Steps 4.1-4.2 can start after Phase 1
|
|
1730
|
+
└── Steps 2.1-2.5 ├── Steps 4.3-4.4 need Phase 2 for full integration
|
|
1731
|
+
└── Steps 4.5-4.7
|
|
1732
|
+
|
|
1733
|
+
Phase 3 (Evolution)
|
|
1734
|
+
├── depends on Phase 2
|
|
1735
|
+
└── Steps 3.1-3.8
|
|
1736
|
+
|
|
1737
|
+
Phase 5 (minimem)
|
|
1738
|
+
└── depends on Phase 4 (optional)
|
|
1739
|
+
```
|
|
1740
|
+
|
|
1741
|
+
Phases 2 and 4 can be developed partially in parallel since Phase 4's retrieval/formatting code doesn't depend on extraction — it just needs notes to exist on disk (can be seeded manually for testing).
|
|
1742
|
+
|
|
1743
|
+
## 13. Open Questions
|
|
1744
|
+
|
|
1745
|
+
### Resolved
|
|
1746
|
+
1. **Where does the processing pipeline live?** → In cognitive-core. minimem provides filesystem + optional search.
|
|
1747
|
+
2. **Extraction granularity (atomic vs aggregate)?** → Both. Observations are atomic; entity notes aggregate. The natural domain drives this.
|
|
1748
|
+
3. **Who writes knowledge?** → Both agents (directly to files/inbox) and cognitive-core (via extraction pipeline). Different confidence levels.
|
|
1749
|
+
4. **Graph complexity** → Multi-graph (MAGMA-style) from the start, with a pluggable layer interface. Four orthogonal layers: semantic (default/always-on), temporal, causal, entity. Each layer can be independently enabled/disabled. Shared node set, separate edge sets per layer. See Section 5 for full design.
|
|
1750
|
+
5. **Knowledge surfacing alongside playbooks** → Independent. Knowledge and playbook surfacing are decoupled systems. Both produce separate context sections. The learning pipeline sees them colocated when analyzing trajectories (agents carry traced versions of skills + knowledge). No coupling between playbook selection and knowledge retrieval. See Section 9.2.
|
|
1751
|
+
6. **minimem's role?** → Bidirectional: (a) cognitive-core delegates search to minimem when available (SearchProvider strategy pattern), (b) minimem parses knowledge frontmatter, indexes metadata, stores graph edges, and exposes knowledge-specific MCP tools. Coupling is via file conventions only — no cross-package imports.
|
|
1752
|
+
7. **Knowledge extraction wiring?** → Knowledge extraction is decoupled from `LearningPipeline.processTrajectory()`. Callers invoke `KnowledgeBank.extractFromTrajectory()` directly. This differs from Section 6.5's design (which showed automatic wiring) but is intentional — it gives callers control over when extraction runs and avoids coupling the learning pipeline to the knowledge bank.
|
|
1753
|
+
|
|
1754
|
+
### Implementation Notes
|
|
1755
|
+
|
|
1756
|
+
All 5 phases are implemented. Key divergences from the original design:
|
|
1757
|
+
|
|
1758
|
+
- **Phase 2 (Section 6.5)**: Knowledge extraction is NOT auto-wired into `LearningPipeline.processTrajectory()`. Instead, extraction is invoked directly via `KnowledgeBank.extractFromTrajectory()` or `KnowledgeBank.extractFrom()`. This keeps the learning pipeline's contract unchanged and allows callers to control extraction timing.
|
|
1759
|
+
- **Phase 4 (Section 4.5)**: The specialized graph traversal convenience methods `getCausalChain()`, `getTemporalNeighbors()`, and `getKnowledgeForPlaybook()` are not implemented as named methods. The underlying graph traversal works via `getRelated()` with layer filtering. These can be added as thin wrappers if needed.
|
|
1760
|
+
- **Phase 4 (Section 4.6)**: MCP knowledge tools are not in cognitive-core's `playbook-server.ts`. Instead, they are implemented on the minimem side (`knowledge_search`, `knowledge_graph`, `knowledge_path`), which is the natural home since minimem is the MCP server.
|
|
1761
|
+
- **Phase 5**: Expanded from unidirectional (cognitive-core → minimem) to bidirectional. minimem now has full knowledge awareness: schema v4 with knowledge columns + graph table, knowledge-aware indexing, filtered search, graph traversal, and 3 new MCP tools.
|
|
1762
|
+
|
|
1763
|
+
### Test Coverage
|
|
1764
|
+
|
|
1765
|
+
973 tests passing across the full codebase. Knowledge-specific test files:
|
|
1766
|
+
|
|
1767
|
+
| File | Tests | Covers |
|
|
1768
|
+
|------|-------|--------|
|
|
1769
|
+
| `tests/memory/knowledge-bank.test.ts` | 36 | CRUD, directory structure, stats |
|
|
1770
|
+
| `tests/memory/knowledge-graph.test.ts` | 33 | Graph manager, multi-layer traversal, persistence |
|
|
1771
|
+
| `tests/memory/graph-layers/semantic.test.ts` | 17 | Semantic layer operations, BFS, rebuild |
|
|
1772
|
+
| `tests/utils/frontmatter.test.ts` | 11 | YAML parsing, serialization, round-trip |
|
|
1773
|
+
| `tests/learning/knowledge-extractor.test.ts` | 20 | All 4 extraction strategies |
|
|
1774
|
+
| `tests/memory/knowledge-bank-extraction.test.ts` | 14 | applyExtraction, extractFromTrajectory |
|
|
1775
|
+
| `tests/memory/knowledge-evolution.test.ts` | 19 | Reinforcement, contradiction, decay |
|
|
1776
|
+
| `tests/memory/knowledge-defrag.test.ts` | 12 | 7-step defragmentation cycle |
|
|
1777
|
+
| `tests/memory/knowledge-inbox.test.ts` | 11 | Inbox processing, classification |
|
|
1778
|
+
| `tests/atlas-knowledge.test.ts` | 4 | Atlas.solve() knowledge surfacing |
|
|
1779
|
+
| `tests/memory/knowledge-minimem.test.ts` | 11 | minimem integration, SearchProvider |
|
|
1780
|
+
|
|
1781
|
+
## 14. References
|
|
1782
|
+
|
|
1783
|
+
1. [Memory in the Age of AI Agents](https://arxiv.org/abs/2512.13564) — Comprehensive survey, taxonomy of factual/experiential/procedural memory
|
|
1784
|
+
2. [A-MEM: Agentic Memory for LLM Agents](https://arxiv.org/abs/2502.12110) — Zettelkasten-inspired structured notes with dynamic linking
|
|
1785
|
+
3. [MAGMA: Multi-Graph Agentic Memory](https://arxiv.org/abs/2601.03236) — Multi-graph decomposition (semantic, temporal, causal, entity)
|
|
1786
|
+
4. [Zep: Temporal Knowledge Graph](https://arxiv.org/pdf/2501.13956) — Entity extraction, community detection, temporal tracking
|
|
1787
|
+
5. [AriGraph](https://www.ijcai.org/proceedings/2025/0002.pdf) — Incremental KG learning from agent interaction (episodic → semantic)
|
|
1788
|
+
6. [CompassMem](https://arxiv.org/abs/2601.04726) — Event-centric memory as logic maps for reasoning
|
|
1789
|
+
7. [Agent Memory Paper List](https://github.com/Shichun-Liu/Agent-Memory-Paper-List) — Curated list of 100+ papers on agent memory
|