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,1103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the 5 gap fixes:
|
|
3
|
+
* Gap 1: LLMPlaybookExtractor deletion
|
|
4
|
+
* Gap 2: Atlas.solve() template delegation with fallback
|
|
5
|
+
* Gap 3: solution-evaluation template codebasePath / getResources
|
|
6
|
+
* Gap 4: MetaLearner.recordFromReflection bridge
|
|
7
|
+
* Gap 5: SolutionEvaluator & RefinementLoop setTaskRunner delegation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
11
|
+
import { mkdtemp, rm } from 'node:fs/promises';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
import { tmpdir } from 'node:os';
|
|
14
|
+
|
|
15
|
+
// Types
|
|
16
|
+
import { createTask } from '../src/types/task.js';
|
|
17
|
+
import { createTrajectory } from '../src/types/trajectory.js';
|
|
18
|
+
import { createStep } from '../src/types/step.js';
|
|
19
|
+
import { successOutcome, failureOutcome } from '../src/types/outcome.js';
|
|
20
|
+
import type { Trajectory } from '../src/types/trajectory.js';
|
|
21
|
+
import type { Task } from '../src/types/task.js';
|
|
22
|
+
import type { Playbook } from '../src/types/index.js';
|
|
23
|
+
|
|
24
|
+
// Memory
|
|
25
|
+
import { createMemorySystem, type MemorySystem } from '../src/memory/system.js';
|
|
26
|
+
import { MetaMemory } from '../src/memory/meta.js';
|
|
27
|
+
|
|
28
|
+
// Learning
|
|
29
|
+
import { MetaLearner, createMetaLearner } from '../src/learning/meta-learner.js';
|
|
30
|
+
import type { MetaReflectionOutput } from '../src/workspace/templates/meta-reflection.js';
|
|
31
|
+
import type { RoutingDecision } from '../src/learning/meta-learner.js';
|
|
32
|
+
|
|
33
|
+
// Search
|
|
34
|
+
import { SolutionEvaluator, createSolutionEvaluator } from '../src/search/evaluator.js';
|
|
35
|
+
import { RefinementLoop, createRefinementLoop } from '../src/search/refinement-loop.js';
|
|
36
|
+
import { createEvaluationResult, type EvaluationResult } from '../src/search/refinement-types.js';
|
|
37
|
+
|
|
38
|
+
// Runtime
|
|
39
|
+
import { AgentManager, createAgentManager } from '../src/runtime/manager.js';
|
|
40
|
+
import { MockBackend, createMockBackend } from '../src/runtime/backends/mock.js';
|
|
41
|
+
|
|
42
|
+
// Workspace / templates
|
|
43
|
+
import type { AgenticTaskRunner } from '../src/workspace/runner.js';
|
|
44
|
+
import { solutionEvaluationTemplate } from '../src/workspace/templates/solution-evaluation.js';
|
|
45
|
+
import type { SolutionEvaluationInput } from '../src/workspace/templates/solution-evaluation.js';
|
|
46
|
+
import { refinementAnalysisTemplate, type RefinementPlan } from '../src/workspace/templates/refinement-analysis.js';
|
|
47
|
+
import { metaReflectionTemplate } from '../src/workspace/templates/meta-reflection.js';
|
|
48
|
+
import { usageInferenceTemplate } from '../src/workspace/templates/usage-inference.js';
|
|
49
|
+
|
|
50
|
+
// Atlas
|
|
51
|
+
import { Atlas, createAtlasWithAgents } from '../src/atlas.js';
|
|
52
|
+
|
|
53
|
+
// ============================================================
|
|
54
|
+
// Helpers
|
|
55
|
+
// ============================================================
|
|
56
|
+
|
|
57
|
+
const makeTask = (overrides: Partial<Task> = {}) =>
|
|
58
|
+
createTask({
|
|
59
|
+
domain: 'code',
|
|
60
|
+
description: 'Fix the authentication bug',
|
|
61
|
+
...overrides,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const makeSuccessTrajectory = (overrides: Partial<Trajectory> = {}): Trajectory =>
|
|
65
|
+
createTrajectory({
|
|
66
|
+
task: makeTask(),
|
|
67
|
+
steps: [
|
|
68
|
+
createStep({ thought: 'analyze', action: 'read_file', observation: 'found code' }),
|
|
69
|
+
createStep({ thought: 'fix', action: 'write_file', observation: 'written' }),
|
|
70
|
+
createStep({ action: 'run_tests', observation: 'all tests pass' }),
|
|
71
|
+
],
|
|
72
|
+
outcome: successOutcome('Bug fixed'),
|
|
73
|
+
agentId: 'test-agent',
|
|
74
|
+
wallTimeSeconds: 30,
|
|
75
|
+
llmCalls: 5,
|
|
76
|
+
...overrides,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const makeFailTrajectory = (overrides: Partial<Trajectory> = {}): Trajectory =>
|
|
80
|
+
createTrajectory({
|
|
81
|
+
task: makeTask(),
|
|
82
|
+
steps: [
|
|
83
|
+
createStep({ action: 'attempt', observation: 'error occurred' }),
|
|
84
|
+
],
|
|
85
|
+
outcome: failureOutcome('Could not fix bug'),
|
|
86
|
+
agentId: 'test-agent',
|
|
87
|
+
wallTimeSeconds: 10,
|
|
88
|
+
llmCalls: 2,
|
|
89
|
+
...overrides,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const makeRouting = (overrides: Partial<RoutingDecision> = {}): RoutingDecision => ({
|
|
93
|
+
strategy: 'direct',
|
|
94
|
+
confidence: 0.8,
|
|
95
|
+
estimatedBudget: 10,
|
|
96
|
+
reasoning: 'High similarity to known patterns',
|
|
97
|
+
...overrides,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const makePlaybook = (id: string, name: string): Playbook => ({
|
|
101
|
+
id,
|
|
102
|
+
name,
|
|
103
|
+
applicability: {
|
|
104
|
+
situations: ['Fix a bug'],
|
|
105
|
+
triggers: ['authentication'],
|
|
106
|
+
antiPatterns: [],
|
|
107
|
+
domains: ['code'],
|
|
108
|
+
},
|
|
109
|
+
guidance: {
|
|
110
|
+
strategy: 'Check token validation',
|
|
111
|
+
tactics: ['Verify token expiry', 'Check session storage'],
|
|
112
|
+
steps: ['Read code', 'Find bug', 'Fix', 'Test'],
|
|
113
|
+
},
|
|
114
|
+
verification: {
|
|
115
|
+
successIndicators: ['Tests pass'],
|
|
116
|
+
failureIndicators: ['Auth still fails'],
|
|
117
|
+
},
|
|
118
|
+
evolution: {
|
|
119
|
+
version: '1.0.0',
|
|
120
|
+
createdFrom: [],
|
|
121
|
+
failures: [],
|
|
122
|
+
refinements: [],
|
|
123
|
+
successCount: 5,
|
|
124
|
+
failureCount: 0,
|
|
125
|
+
},
|
|
126
|
+
confidence: 0.85,
|
|
127
|
+
complexity: 'moderate',
|
|
128
|
+
domain: 'code',
|
|
129
|
+
createdAt: new Date(),
|
|
130
|
+
updatedAt: new Date(),
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Wraps an array of values as a sequence for createMockTaskRunner.
|
|
135
|
+
* Successive calls consume values in order; the last one repeats.
|
|
136
|
+
*/
|
|
137
|
+
function seq(...values: unknown[]): { __seq: true; values: unknown[] } {
|
|
138
|
+
return { __seq: true, values };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function isSeq(v: unknown): v is { __seq: true; values: unknown[] } {
|
|
142
|
+
return typeof v === 'object' && v !== null && '__seq' in v && (v as Record<string, unknown>).__seq === true;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Creates a mock AgenticTaskRunner that records calls and returns
|
|
147
|
+
* configurable outputs per template taskType.
|
|
148
|
+
*
|
|
149
|
+
* Outputs can be:
|
|
150
|
+
* - A single value → returned every time
|
|
151
|
+
* - An Error → thrown every time
|
|
152
|
+
* - seq(v1, v2, ...) → values are consumed in order (last one repeats)
|
|
153
|
+
*/
|
|
154
|
+
function createMockTaskRunner(
|
|
155
|
+
outputs: Record<string, unknown> = {}
|
|
156
|
+
): AgenticTaskRunner & { calls: Array<{ taskType: string; input: unknown }> } {
|
|
157
|
+
const calls: Array<{ taskType: string; input: unknown }> = [];
|
|
158
|
+
const callCounts: Record<string, number> = {};
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
calls,
|
|
162
|
+
run: vi.fn(async (template: { taskType: string }, input: unknown) => {
|
|
163
|
+
calls.push({ taskType: template.taskType, input });
|
|
164
|
+
|
|
165
|
+
const raw = outputs[template.taskType];
|
|
166
|
+
if (raw === undefined) {
|
|
167
|
+
throw new Error(`No mock output for template ${template.taskType}`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
let output: unknown;
|
|
171
|
+
if (isSeq(raw)) {
|
|
172
|
+
const idx = callCounts[template.taskType] ?? 0;
|
|
173
|
+
callCounts[template.taskType] = idx + 1;
|
|
174
|
+
output = raw.values[Math.min(idx, raw.values.length - 1)];
|
|
175
|
+
} else {
|
|
176
|
+
output = raw;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (output instanceof Error) throw output;
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
output,
|
|
183
|
+
trajectory: makeSuccessTrajectory(),
|
|
184
|
+
workspace: { id: 'mock-ws', path: '/tmp/mock-ws' },
|
|
185
|
+
};
|
|
186
|
+
}),
|
|
187
|
+
} as unknown as AgenticTaskRunner & { calls: Array<{ taskType: string; input: unknown }> };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// ============================================================
|
|
191
|
+
// Gap 1: LLMPlaybookExtractor deletion
|
|
192
|
+
// ============================================================
|
|
193
|
+
|
|
194
|
+
describe('Gap 1: LLMPlaybookExtractor deletion', () => {
|
|
195
|
+
it('should not export LLMPlaybookExtractor from learning/index', async () => {
|
|
196
|
+
const learningExports = await import('../src/learning/index.js');
|
|
197
|
+
expect('LLMPlaybookExtractor' in learningExports).toBe(false);
|
|
198
|
+
expect('createLLMExtractor' in learningExports).toBe(false);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('should not export LLMPlaybookExtractor from root index', async () => {
|
|
202
|
+
const rootExports = await import('../src/index.js');
|
|
203
|
+
expect('LLMPlaybookExtractor' in rootExports).toBe(false);
|
|
204
|
+
expect('createLLMExtractor' in rootExports).toBe(false);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('should still export other learning components', async () => {
|
|
208
|
+
const learningExports = await import('../src/learning/index.js');
|
|
209
|
+
expect('PlaybookExtractor' in learningExports).toBe(true);
|
|
210
|
+
expect('MetaLearner' in learningExports).toBe(true);
|
|
211
|
+
expect('PlaybookUsageInference' in learningExports).toBe(true);
|
|
212
|
+
expect('LearningPipeline' in learningExports).toBe(true);
|
|
213
|
+
expect('LearningEffectivenessTracker' in learningExports).toBe(true);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// ============================================================
|
|
218
|
+
// Gap 3: solution-evaluation template codebasePath / getResources
|
|
219
|
+
// ============================================================
|
|
220
|
+
|
|
221
|
+
describe('Gap 3: solution-evaluation template codebasePath', () => {
|
|
222
|
+
const trajectory = makeSuccessTrajectory();
|
|
223
|
+
const task = makeTask();
|
|
224
|
+
|
|
225
|
+
it('should return empty resources when codebasePath is not set', () => {
|
|
226
|
+
const resources = solutionEvaluationTemplate.getResources({ trajectory, task });
|
|
227
|
+
expect(resources).toEqual([]);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('should return a symlink resource when codebasePath is set', () => {
|
|
231
|
+
const resources = solutionEvaluationTemplate.getResources({
|
|
232
|
+
trajectory,
|
|
233
|
+
task,
|
|
234
|
+
codebasePath: '/home/user/my-project',
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
expect(resources).toHaveLength(1);
|
|
238
|
+
expect(resources[0]).toEqual({
|
|
239
|
+
path: 'codebase',
|
|
240
|
+
type: 'symlink',
|
|
241
|
+
source: '/home/user/my-project',
|
|
242
|
+
description: 'Codebase for solution verification',
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('should include codebase instruction in prompt when codebasePath is set', () => {
|
|
247
|
+
const prompt = solutionEvaluationTemplate.buildTaskPrompt({
|
|
248
|
+
trajectory,
|
|
249
|
+
task,
|
|
250
|
+
codebasePath: '/home/user/my-project',
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
expect(prompt).toContain('resources/codebase/');
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('should NOT include codebase instruction in prompt when codebasePath is absent', () => {
|
|
257
|
+
const prompt = solutionEvaluationTemplate.buildTaskPrompt({
|
|
258
|
+
trajectory,
|
|
259
|
+
task,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
expect(prompt).not.toContain('resources/codebase/');
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it('should still use heuristic complexity when task has verification', () => {
|
|
266
|
+
const taskWithVerification = makeTask({
|
|
267
|
+
verification: { type: 'exact_match', expected: 'pass' },
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
const complexity = solutionEvaluationTemplate.assessComplexity({
|
|
271
|
+
trajectory,
|
|
272
|
+
task: taskWithVerification,
|
|
273
|
+
});
|
|
274
|
+
expect(complexity).toBe('heuristic');
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// ============================================================
|
|
279
|
+
// Gap 4: MetaLearner.recordFromReflection
|
|
280
|
+
// ============================================================
|
|
281
|
+
|
|
282
|
+
describe('Gap 4: MetaLearner.recordFromReflection', () => {
|
|
283
|
+
let tempDir: string;
|
|
284
|
+
let metaMemory: MetaMemory;
|
|
285
|
+
let metaLearner: MetaLearner;
|
|
286
|
+
|
|
287
|
+
beforeEach(async () => {
|
|
288
|
+
tempDir = await mkdtemp(join(tmpdir(), 'meta-learner-test-'));
|
|
289
|
+
metaMemory = new MetaMemory(tempDir);
|
|
290
|
+
await metaMemory.init();
|
|
291
|
+
metaLearner = createMetaLearner(metaMemory);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
afterEach(async () => {
|
|
295
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('should create a MetaObservation from MetaReflectionOutput', async () => {
|
|
299
|
+
const reflection: MetaReflectionOutput = {
|
|
300
|
+
retrievalQuality: 'helpful',
|
|
301
|
+
outcomeQuality: 'good',
|
|
302
|
+
whatWorked: ['Direct routing was effective'],
|
|
303
|
+
whatFailed: [],
|
|
304
|
+
suggestions: ['Consider caching results'],
|
|
305
|
+
decompositionUsed: true,
|
|
306
|
+
backtrackingOccurred: false,
|
|
307
|
+
refinementIterations: 1,
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
const routing = makeRouting();
|
|
311
|
+
const observation = await metaLearner.recordFromReflection(
|
|
312
|
+
reflection,
|
|
313
|
+
'traj-123',
|
|
314
|
+
routing,
|
|
315
|
+
['playbook-1', 'playbook-2'],
|
|
316
|
+
5,
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
expect(observation.trajectoryId).toBe('traj-123');
|
|
320
|
+
expect(observation.id).toBeDefined();
|
|
321
|
+
expect(observation.timestamp).toBeInstanceOf(Date);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('should map routing fields correctly', async () => {
|
|
325
|
+
const routing = makeRouting({
|
|
326
|
+
strategy: 'explore',
|
|
327
|
+
confidence: 0.6,
|
|
328
|
+
reasoning: 'Unfamiliar task',
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
const observation = await metaLearner.recordFromReflection(
|
|
332
|
+
{
|
|
333
|
+
retrievalQuality: 'neutral',
|
|
334
|
+
outcomeQuality: 'acceptable',
|
|
335
|
+
whatWorked: [],
|
|
336
|
+
whatFailed: ['Exploration was slow'],
|
|
337
|
+
suggestions: [],
|
|
338
|
+
decompositionUsed: false,
|
|
339
|
+
backtrackingOccurred: true,
|
|
340
|
+
refinementIterations: 2,
|
|
341
|
+
},
|
|
342
|
+
'traj-456',
|
|
343
|
+
routing,
|
|
344
|
+
[],
|
|
345
|
+
8,
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
expect(observation.routing.decision).toBe('explore');
|
|
349
|
+
expect(observation.routing.confidence).toBe(0.6);
|
|
350
|
+
expect(observation.routing.reasoning).toBe('Unfamiliar task');
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it('should map memory usage fields correctly', async () => {
|
|
354
|
+
const observation = await metaLearner.recordFromReflection(
|
|
355
|
+
{
|
|
356
|
+
retrievalQuality: 'misleading',
|
|
357
|
+
outcomeQuality: 'poor',
|
|
358
|
+
whatWorked: [],
|
|
359
|
+
whatFailed: ['Playbook was wrong'],
|
|
360
|
+
suggestions: ['Update playbook'],
|
|
361
|
+
decompositionUsed: false,
|
|
362
|
+
backtrackingOccurred: false,
|
|
363
|
+
refinementIterations: 0,
|
|
364
|
+
},
|
|
365
|
+
'traj-789',
|
|
366
|
+
makeRouting(),
|
|
367
|
+
['pb-1'],
|
|
368
|
+
3,
|
|
369
|
+
);
|
|
370
|
+
|
|
371
|
+
expect(observation.memoryUsage.retrievalQuality).toBe('misleading');
|
|
372
|
+
expect(observation.memoryUsage.playbooksApplied).toEqual(['pb-1']);
|
|
373
|
+
expect(observation.memoryUsage.experiencesRetrieved).toBe(0);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it('should map execution fields correctly', async () => {
|
|
377
|
+
const observation = await metaLearner.recordFromReflection(
|
|
378
|
+
{
|
|
379
|
+
retrievalQuality: 'helpful',
|
|
380
|
+
outcomeQuality: 'excellent',
|
|
381
|
+
whatWorked: ['Decomposition was key'],
|
|
382
|
+
whatFailed: [],
|
|
383
|
+
suggestions: [],
|
|
384
|
+
decompositionUsed: true,
|
|
385
|
+
backtrackingOccurred: true,
|
|
386
|
+
refinementIterations: 3,
|
|
387
|
+
},
|
|
388
|
+
'traj-exec',
|
|
389
|
+
makeRouting(),
|
|
390
|
+
[],
|
|
391
|
+
4,
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
expect(observation.execution.decompositionUsed).toBe(true);
|
|
395
|
+
expect(observation.execution.backtrackingOccurred).toBe(true);
|
|
396
|
+
expect(observation.execution.refinementIterations).toBe(3);
|
|
397
|
+
expect(observation.execution.toolsUsed).toEqual([]);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
it('should map outcome fields correctly', async () => {
|
|
401
|
+
const routing = makeRouting({ estimatedBudget: 10 });
|
|
402
|
+
|
|
403
|
+
const observation = await metaLearner.recordFromReflection(
|
|
404
|
+
{
|
|
405
|
+
retrievalQuality: 'neutral',
|
|
406
|
+
outcomeQuality: 'good',
|
|
407
|
+
whatWorked: ['Worked'],
|
|
408
|
+
whatFailed: [],
|
|
409
|
+
suggestions: [],
|
|
410
|
+
decompositionUsed: false,
|
|
411
|
+
backtrackingOccurred: false,
|
|
412
|
+
refinementIterations: 0,
|
|
413
|
+
},
|
|
414
|
+
'traj-outcome',
|
|
415
|
+
routing,
|
|
416
|
+
[],
|
|
417
|
+
7,
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
expect(observation.outcome.success).toBe(true); // outcomeQuality != 'poor'
|
|
421
|
+
expect(observation.outcome.quality).toBe('good');
|
|
422
|
+
expect(observation.outcome.effortActual).toBe(7);
|
|
423
|
+
expect(observation.outcome.effortEstimate).toBe(10);
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
it('should set success=false when outcomeQuality is poor', async () => {
|
|
427
|
+
const observation = await metaLearner.recordFromReflection(
|
|
428
|
+
{
|
|
429
|
+
retrievalQuality: 'neutral',
|
|
430
|
+
outcomeQuality: 'poor',
|
|
431
|
+
whatWorked: [],
|
|
432
|
+
whatFailed: ['Everything'],
|
|
433
|
+
suggestions: ['Retry'],
|
|
434
|
+
decompositionUsed: false,
|
|
435
|
+
backtrackingOccurred: false,
|
|
436
|
+
refinementIterations: 0,
|
|
437
|
+
},
|
|
438
|
+
'traj-poor',
|
|
439
|
+
makeRouting(),
|
|
440
|
+
[],
|
|
441
|
+
2,
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
expect(observation.outcome.success).toBe(false);
|
|
445
|
+
expect(observation.outcome.quality).toBe('poor');
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
it('should map lessons correctly', async () => {
|
|
449
|
+
const observation = await metaLearner.recordFromReflection(
|
|
450
|
+
{
|
|
451
|
+
retrievalQuality: 'neutral',
|
|
452
|
+
outcomeQuality: 'acceptable',
|
|
453
|
+
whatWorked: ['Step-by-step approach', 'Error handling'],
|
|
454
|
+
whatFailed: ['Initial attempt was too broad'],
|
|
455
|
+
suggestions: ['Start with narrower scope', 'Read docs first'],
|
|
456
|
+
decompositionUsed: false,
|
|
457
|
+
backtrackingOccurred: false,
|
|
458
|
+
refinementIterations: 0,
|
|
459
|
+
},
|
|
460
|
+
'traj-lessons',
|
|
461
|
+
makeRouting(),
|
|
462
|
+
[],
|
|
463
|
+
5,
|
|
464
|
+
);
|
|
465
|
+
|
|
466
|
+
expect(observation.lessons.whatWorked).toEqual([
|
|
467
|
+
'Step-by-step approach',
|
|
468
|
+
'Error handling',
|
|
469
|
+
]);
|
|
470
|
+
expect(observation.lessons.whatFailed).toEqual([
|
|
471
|
+
'Initial attempt was too broad',
|
|
472
|
+
]);
|
|
473
|
+
expect(observation.lessons.suggestions).toEqual([
|
|
474
|
+
'Start with narrower scope',
|
|
475
|
+
'Read docs first',
|
|
476
|
+
]);
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
it('should persist the observation to MetaMemory', async () => {
|
|
480
|
+
await metaLearner.recordFromReflection(
|
|
481
|
+
{
|
|
482
|
+
retrievalQuality: 'helpful',
|
|
483
|
+
outcomeQuality: 'good',
|
|
484
|
+
whatWorked: ['Worked'],
|
|
485
|
+
whatFailed: [],
|
|
486
|
+
suggestions: [],
|
|
487
|
+
decompositionUsed: false,
|
|
488
|
+
backtrackingOccurred: false,
|
|
489
|
+
refinementIterations: 0,
|
|
490
|
+
},
|
|
491
|
+
'traj-persist',
|
|
492
|
+
makeRouting(),
|
|
493
|
+
[],
|
|
494
|
+
4,
|
|
495
|
+
);
|
|
496
|
+
|
|
497
|
+
const stats = await metaMemory.getStats();
|
|
498
|
+
expect(stats.totalObservations).toBeGreaterThanOrEqual(1);
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
it('should trigger learn() at strategyGenerationInterval', async () => {
|
|
502
|
+
const learnSpy = vi.spyOn(metaLearner, 'learn');
|
|
503
|
+
|
|
504
|
+
// Default interval is 10; create learner with interval=2 for testing
|
|
505
|
+
const fastLearner = createMetaLearner(metaMemory, {
|
|
506
|
+
strategyGenerationInterval: 2,
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
const reflection: MetaReflectionOutput = {
|
|
510
|
+
retrievalQuality: 'neutral',
|
|
511
|
+
outcomeQuality: 'good',
|
|
512
|
+
whatWorked: [],
|
|
513
|
+
whatFailed: [],
|
|
514
|
+
suggestions: [],
|
|
515
|
+
decompositionUsed: false,
|
|
516
|
+
backtrackingOccurred: false,
|
|
517
|
+
refinementIterations: 0,
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
const fastLearnSpy = vi.spyOn(fastLearner, 'learn');
|
|
521
|
+
|
|
522
|
+
await fastLearner.recordFromReflection(reflection, 't1', makeRouting(), [], 1);
|
|
523
|
+
expect(fastLearnSpy).not.toHaveBeenCalled();
|
|
524
|
+
|
|
525
|
+
await fastLearner.recordFromReflection(reflection, 't2', makeRouting(), [], 1);
|
|
526
|
+
expect(fastLearnSpy).toHaveBeenCalledTimes(1);
|
|
527
|
+
|
|
528
|
+
learnSpy.mockRestore();
|
|
529
|
+
fastLearnSpy.mockRestore();
|
|
530
|
+
});
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
// ============================================================
|
|
534
|
+
// Gap 5a: SolutionEvaluator.setTaskRunner delegation
|
|
535
|
+
// ============================================================
|
|
536
|
+
|
|
537
|
+
describe('Gap 5a: SolutionEvaluator.setTaskRunner', () => {
|
|
538
|
+
let tempDir: string;
|
|
539
|
+
let memory: MemorySystem;
|
|
540
|
+
let agentManager: AgentManager;
|
|
541
|
+
|
|
542
|
+
beforeEach(async () => {
|
|
543
|
+
tempDir = await mkdtemp(join(tmpdir(), 'evaluator-test-'));
|
|
544
|
+
memory = createMemorySystem(tempDir);
|
|
545
|
+
await memory.init();
|
|
546
|
+
agentManager = createAgentManager(memory);
|
|
547
|
+
const mockBackend = createMockBackend({ success: true, result: 'ok', durationMs: 10 });
|
|
548
|
+
agentManager.registerBackend(mockBackend);
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
afterEach(async () => {
|
|
552
|
+
await memory.close();
|
|
553
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
it('should use heuristic when no taskRunner is set', async () => {
|
|
557
|
+
const evaluator = createSolutionEvaluator(null);
|
|
558
|
+
const result = await evaluator.evaluate(makeSuccessTrajectory(), makeTask());
|
|
559
|
+
|
|
560
|
+
expect(result.method).toBe('heuristic');
|
|
561
|
+
expect(result.score).toBeGreaterThan(0);
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
it('should delegate to workspace template when taskRunner is set', async () => {
|
|
565
|
+
const mockEvalResult = createEvaluationResult({
|
|
566
|
+
quality: 'excellent',
|
|
567
|
+
score: 0.95,
|
|
568
|
+
acceptable: true,
|
|
569
|
+
issues: [],
|
|
570
|
+
method: 'agent',
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
const runner = createMockTaskRunner({
|
|
574
|
+
'solution-evaluation': mockEvalResult,
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
const evaluator = createSolutionEvaluator(null);
|
|
578
|
+
evaluator.setTaskRunner(runner);
|
|
579
|
+
|
|
580
|
+
const result = await evaluator.evaluate(makeSuccessTrajectory(), makeTask());
|
|
581
|
+
|
|
582
|
+
expect(result.quality).toBe('excellent');
|
|
583
|
+
expect(result.score).toBe(0.95);
|
|
584
|
+
expect(runner.calls).toHaveLength(1);
|
|
585
|
+
expect(runner.calls[0].taskType).toBe('solution-evaluation');
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
it('should pass trajectory and task to the template', async () => {
|
|
589
|
+
const trajectory = makeSuccessTrajectory();
|
|
590
|
+
const task = makeTask({ description: 'Specific task desc' });
|
|
591
|
+
|
|
592
|
+
const runner = createMockTaskRunner({
|
|
593
|
+
'solution-evaluation': createEvaluationResult({
|
|
594
|
+
quality: 'good',
|
|
595
|
+
score: 0.8,
|
|
596
|
+
acceptable: true,
|
|
597
|
+
issues: [],
|
|
598
|
+
method: 'agent',
|
|
599
|
+
}),
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
const evaluator = createSolutionEvaluator(null);
|
|
603
|
+
evaluator.setTaskRunner(runner);
|
|
604
|
+
await evaluator.evaluate(trajectory, task);
|
|
605
|
+
|
|
606
|
+
const input = runner.calls[0].input as SolutionEvaluationInput;
|
|
607
|
+
expect(input.trajectory).toBe(trajectory);
|
|
608
|
+
expect(input.task).toBe(task);
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
it('should fall back to heuristic when taskRunner.run throws', async () => {
|
|
612
|
+
const runner = createMockTaskRunner({
|
|
613
|
+
'solution-evaluation': new Error('Workspace failed'),
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
const evaluator = createSolutionEvaluator(null);
|
|
617
|
+
evaluator.setTaskRunner(runner);
|
|
618
|
+
|
|
619
|
+
// suppress console.warn from fallback
|
|
620
|
+
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
621
|
+
|
|
622
|
+
const result = await evaluator.evaluate(makeSuccessTrajectory(), makeTask());
|
|
623
|
+
|
|
624
|
+
expect(result.method).toBe('heuristic');
|
|
625
|
+
expect(runner.calls).toHaveLength(1);
|
|
626
|
+
|
|
627
|
+
warnSpy.mockRestore();
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
it('should prefer verification over workspace template', async () => {
|
|
631
|
+
const runner = createMockTaskRunner({
|
|
632
|
+
'solution-evaluation': createEvaluationResult({
|
|
633
|
+
quality: 'good', score: 0.8, acceptable: true, issues: [], method: 'agent',
|
|
634
|
+
}),
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
const evaluator = createSolutionEvaluator(null);
|
|
638
|
+
evaluator.setTaskRunner(runner);
|
|
639
|
+
evaluator.registerVerifier('code', async () => ({
|
|
640
|
+
passed: true,
|
|
641
|
+
confidence: 0.95,
|
|
642
|
+
details: 'All good',
|
|
643
|
+
}));
|
|
644
|
+
|
|
645
|
+
const result = await evaluator.evaluate(
|
|
646
|
+
makeSuccessTrajectory(),
|
|
647
|
+
makeTask({ domain: 'code' }),
|
|
648
|
+
);
|
|
649
|
+
|
|
650
|
+
// Verification took precedence — template never called
|
|
651
|
+
expect(result.method).toBe('verification');
|
|
652
|
+
expect(runner.calls).toHaveLength(0);
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
it('should fall through to workspace when verification confidence is low', async () => {
|
|
656
|
+
const runner = createMockTaskRunner({
|
|
657
|
+
'solution-evaluation': createEvaluationResult({
|
|
658
|
+
quality: 'good', score: 0.8, acceptable: true, issues: [], method: 'agent',
|
|
659
|
+
}),
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
const evaluator = createSolutionEvaluator(null);
|
|
663
|
+
evaluator.setTaskRunner(runner);
|
|
664
|
+
evaluator.registerVerifier('code', async () => ({
|
|
665
|
+
passed: true,
|
|
666
|
+
confidence: 0.3, // Below default 0.8 threshold
|
|
667
|
+
}));
|
|
668
|
+
|
|
669
|
+
const result = await evaluator.evaluate(
|
|
670
|
+
makeSuccessTrajectory(),
|
|
671
|
+
makeTask({ domain: 'code' }),
|
|
672
|
+
);
|
|
673
|
+
|
|
674
|
+
// Low-confidence verification → fell through to workspace
|
|
675
|
+
expect(result.method).toBe('agent');
|
|
676
|
+
expect(runner.calls).toHaveLength(1);
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
// ============================================================
|
|
681
|
+
// Gap 5b: RefinementLoop.setTaskRunner delegation
|
|
682
|
+
// ============================================================
|
|
683
|
+
|
|
684
|
+
describe('Gap 5b: RefinementLoop.setTaskRunner', () => {
|
|
685
|
+
let tempDir: string;
|
|
686
|
+
let memory: MemorySystem;
|
|
687
|
+
let agentManager: AgentManager;
|
|
688
|
+
let mockBackend: MockBackend;
|
|
689
|
+
|
|
690
|
+
beforeEach(async () => {
|
|
691
|
+
tempDir = await mkdtemp(join(tmpdir(), 'refine-runner-test-'));
|
|
692
|
+
memory = createMemorySystem(tempDir);
|
|
693
|
+
await memory.init();
|
|
694
|
+
agentManager = createAgentManager(memory);
|
|
695
|
+
mockBackend = createMockBackend({
|
|
696
|
+
success: true,
|
|
697
|
+
result: 'Refined',
|
|
698
|
+
durationMs: 50,
|
|
699
|
+
});
|
|
700
|
+
agentManager.registerBackend(mockBackend);
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
afterEach(async () => {
|
|
704
|
+
await memory.close();
|
|
705
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
it('should propagate taskRunner to evaluator', () => {
|
|
709
|
+
const loop = createRefinementLoop(agentManager, memory);
|
|
710
|
+
const runner = createMockTaskRunner({});
|
|
711
|
+
|
|
712
|
+
loop.setTaskRunner(runner);
|
|
713
|
+
|
|
714
|
+
// The evaluator should also have the runner — verify indirectly:
|
|
715
|
+
// evaluator.setTaskRunner was called by RefinementLoop.setTaskRunner
|
|
716
|
+
const evaluator = loop.getEvaluator();
|
|
717
|
+
expect(evaluator).toBeDefined();
|
|
718
|
+
// We can verify the runner is set by checking that evaluator.evaluate
|
|
719
|
+
// tries the template path (which will throw since we gave no output)
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
it('should use refinement plan from template when runner is set', async () => {
|
|
723
|
+
const plan: RefinementPlan = {
|
|
724
|
+
rootCauses: ['Token not refreshed', 'Session timeout ignored'],
|
|
725
|
+
strategy: 'Implement token refresh with retry logic',
|
|
726
|
+
steps: ['Add refresh interceptor', 'Handle timeout gracefully'],
|
|
727
|
+
avoidPatterns: ['Hardcoded token values'],
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
// First solution-evaluation call (initial) → poor → triggers refinement
|
|
731
|
+
// Second call (after retry) → excellent → stops loop
|
|
732
|
+
const poorEval = createEvaluationResult({
|
|
733
|
+
quality: 'poor', score: 0.2, acceptable: false,
|
|
734
|
+
issues: [{ type: 'error', description: 'Auth failed', severity: 'critical' }],
|
|
735
|
+
method: 'agent',
|
|
736
|
+
});
|
|
737
|
+
const goodEval = createEvaluationResult({
|
|
738
|
+
quality: 'excellent', score: 0.95, acceptable: true, issues: [], method: 'agent',
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
const runner = createMockTaskRunner({
|
|
742
|
+
'refinement-analysis': plan,
|
|
743
|
+
'solution-evaluation': seq(poorEval, goodEval),
|
|
744
|
+
});
|
|
745
|
+
|
|
746
|
+
const loop = createRefinementLoop(agentManager, memory, {
|
|
747
|
+
maxIterations: 2,
|
|
748
|
+
minAcceptableScore: 0.7,
|
|
749
|
+
});
|
|
750
|
+
loop.setTaskRunner(runner);
|
|
751
|
+
|
|
752
|
+
const failTraj = makeFailTrajectory();
|
|
753
|
+
const spawnConfig = {
|
|
754
|
+
agentType: 'mock',
|
|
755
|
+
task: makeTask(),
|
|
756
|
+
timeout: 60000,
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
const result = await loop.refine(failTraj, spawnConfig);
|
|
760
|
+
|
|
761
|
+
// refinement-analysis should have been called for the retry
|
|
762
|
+
const refinementCalls = runner.calls.filter(c => c.taskType === 'refinement-analysis');
|
|
763
|
+
expect(refinementCalls.length).toBeGreaterThanOrEqual(1);
|
|
764
|
+
expect(result.iterations).toBeGreaterThanOrEqual(1);
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
it('should fall back to heuristic refinement when template fails', async () => {
|
|
768
|
+
const poorEval = createEvaluationResult({
|
|
769
|
+
quality: 'poor', score: 0.2, acceptable: false,
|
|
770
|
+
issues: [{ type: 'error', description: 'Failed', severity: 'critical' }],
|
|
771
|
+
method: 'agent',
|
|
772
|
+
});
|
|
773
|
+
const goodEval = createEvaluationResult({
|
|
774
|
+
quality: 'excellent', score: 0.95, acceptable: true, issues: [], method: 'agent',
|
|
775
|
+
});
|
|
776
|
+
|
|
777
|
+
const runner = createMockTaskRunner({
|
|
778
|
+
'refinement-analysis': new Error('Template failure'),
|
|
779
|
+
'solution-evaluation': seq(poorEval, goodEval),
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
783
|
+
|
|
784
|
+
const loop = createRefinementLoop(agentManager, memory, {
|
|
785
|
+
maxIterations: 2,
|
|
786
|
+
minAcceptableScore: 0.7,
|
|
787
|
+
});
|
|
788
|
+
loop.setTaskRunner(runner);
|
|
789
|
+
|
|
790
|
+
const failTraj = makeFailTrajectory();
|
|
791
|
+
const spawnConfig = {
|
|
792
|
+
agentType: 'mock',
|
|
793
|
+
task: makeTask(),
|
|
794
|
+
timeout: 60000,
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
// Should not throw — falls back to heuristic prompt
|
|
798
|
+
const result = await loop.refine(failTraj, spawnConfig);
|
|
799
|
+
expect(result).toBeDefined();
|
|
800
|
+
expect(result.iterations).toBeGreaterThanOrEqual(1);
|
|
801
|
+
|
|
802
|
+
warnSpy.mockRestore();
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
it('should format RefinementPlan into prompt additions for the retry agent', async () => {
|
|
806
|
+
const plan: RefinementPlan = {
|
|
807
|
+
rootCauses: ['Stale cache', 'Race condition'],
|
|
808
|
+
strategy: 'Use lock-based approach with cache invalidation',
|
|
809
|
+
steps: ['Acquire lock', 'Invalidate cache', 'Retry operation'],
|
|
810
|
+
avoidPatterns: ['Polling without backoff'],
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
const poorEval = createEvaluationResult({
|
|
814
|
+
quality: 'poor', score: 0.2, acceptable: false,
|
|
815
|
+
issues: [{ type: 'error', description: 'Cache stale', severity: 'critical' }],
|
|
816
|
+
method: 'agent',
|
|
817
|
+
});
|
|
818
|
+
const goodEval = createEvaluationResult({
|
|
819
|
+
quality: 'excellent', score: 0.95, acceptable: true, issues: [], method: 'agent',
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
const runner = createMockTaskRunner({
|
|
823
|
+
'refinement-analysis': plan,
|
|
824
|
+
'solution-evaluation': seq(poorEval, goodEval),
|
|
825
|
+
});
|
|
826
|
+
|
|
827
|
+
const loop = createRefinementLoop(agentManager, memory, {
|
|
828
|
+
maxIterations: 2,
|
|
829
|
+
minAcceptableScore: 0.7,
|
|
830
|
+
});
|
|
831
|
+
loop.setTaskRunner(runner);
|
|
832
|
+
|
|
833
|
+
// Spy on AgentManager.spawn to capture the refined prompt
|
|
834
|
+
const spawnSpy = vi.spyOn(agentManager, 'spawn');
|
|
835
|
+
|
|
836
|
+
const failTraj = makeFailTrajectory();
|
|
837
|
+
await loop.refine(failTraj, {
|
|
838
|
+
agentType: 'mock',
|
|
839
|
+
task: makeTask(),
|
|
840
|
+
timeout: 60000,
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
// Find a spawn call that includes refinement content
|
|
844
|
+
const spawnCalls = spawnSpy.mock.calls;
|
|
845
|
+
const refinementCall = spawnCalls.find(call => {
|
|
846
|
+
const config = call[0];
|
|
847
|
+
return config.systemPromptAdditions?.includes('Root Cause Analysis');
|
|
848
|
+
});
|
|
849
|
+
|
|
850
|
+
expect(refinementCall).toBeDefined();
|
|
851
|
+
const additions = refinementCall![0].systemPromptAdditions!;
|
|
852
|
+
expect(additions).toContain('Stale cache');
|
|
853
|
+
expect(additions).toContain('Race condition');
|
|
854
|
+
expect(additions).toContain('Use lock-based approach');
|
|
855
|
+
expect(additions).toContain('Acquire lock');
|
|
856
|
+
expect(additions).toContain('DO NOT: Polling without backoff');
|
|
857
|
+
|
|
858
|
+
spawnSpy.mockRestore();
|
|
859
|
+
});
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
// ============================================================
|
|
863
|
+
// Gap 2: Atlas.solve() template delegation and fallback
|
|
864
|
+
// ============================================================
|
|
865
|
+
|
|
866
|
+
describe('Gap 2: Atlas.solve() template delegation', () => {
|
|
867
|
+
let tempDir: string;
|
|
868
|
+
let atlas: Atlas;
|
|
869
|
+
let mockBackend: MockBackend;
|
|
870
|
+
|
|
871
|
+
beforeEach(async () => {
|
|
872
|
+
tempDir = await mkdtemp(join(tmpdir(), 'atlas-delegation-test-'));
|
|
873
|
+
mockBackend = createMockBackend({
|
|
874
|
+
success: true,
|
|
875
|
+
result: 'Task completed',
|
|
876
|
+
durationMs: 50,
|
|
877
|
+
toolCalls: [
|
|
878
|
+
{ name: 'read_file', input: { path: 'src/main.ts' }, output: 'code' },
|
|
879
|
+
],
|
|
880
|
+
});
|
|
881
|
+
|
|
882
|
+
atlas = createAtlasWithAgents([mockBackend], {
|
|
883
|
+
storage: { baseDir: tempDir },
|
|
884
|
+
learning: { minTrajectories: 100 }, // high threshold to avoid batch triggers
|
|
885
|
+
execution: { defaultAgentType: 'mock', maxExecutionTime: 60 },
|
|
886
|
+
});
|
|
887
|
+
await atlas.init();
|
|
888
|
+
});
|
|
889
|
+
|
|
890
|
+
afterEach(async () => {
|
|
891
|
+
await atlas.close();
|
|
892
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
893
|
+
});
|
|
894
|
+
|
|
895
|
+
it('should call reflectOnExecution after solve', async () => {
|
|
896
|
+
// The metaLearner should have an observation after solve
|
|
897
|
+
const task = makeTask();
|
|
898
|
+
const result = await atlas.solve(task);
|
|
899
|
+
|
|
900
|
+
expect(result.trajectory).toBeDefined();
|
|
901
|
+
expect(result.trajectory.outcome.success).toBe(true);
|
|
902
|
+
|
|
903
|
+
// Meta learner should have been invoked (either via template fallback or heuristic)
|
|
904
|
+
const metaLearner = atlas.getMetaLearner();
|
|
905
|
+
expect(metaLearner).toBeDefined();
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
it('should handle solve when no playbooks exist (no usage inference needed)', async () => {
|
|
909
|
+
const task = makeTask({ description: 'A unique task with no playbooks' });
|
|
910
|
+
const result = await atlas.solve(task);
|
|
911
|
+
|
|
912
|
+
expect(result.trajectory).toBeDefined();
|
|
913
|
+
// No injected playbooks → no usage inference
|
|
914
|
+
expect(result.injectedPlaybooks).toEqual([]);
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
it('should infer playbook usage via template when playbooks are injected', async () => {
|
|
918
|
+
// Add a playbook to memory so it gets injected
|
|
919
|
+
const mem = atlas.getMemory();
|
|
920
|
+
await mem.playbooks.add(makePlaybook('pb-auth', 'Auth Bug Fix'));
|
|
921
|
+
|
|
922
|
+
// Solve a matching task
|
|
923
|
+
const task = makeTask({
|
|
924
|
+
description: 'Fix the authentication bug in login',
|
|
925
|
+
domain: 'code',
|
|
926
|
+
});
|
|
927
|
+
const result = await atlas.solve(task);
|
|
928
|
+
|
|
929
|
+
// Playbook was injected (may or may not get usage depending on heuristic)
|
|
930
|
+
// The key check: solve completes without error when playbooks are present
|
|
931
|
+
expect(result.trajectory).toBeDefined();
|
|
932
|
+
expect(result.trajectory.outcome.success).toBe(true);
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
it('should handle failed agent execution gracefully', async () => {
|
|
936
|
+
const failBackend = createMockBackend({
|
|
937
|
+
success: false,
|
|
938
|
+
result: undefined,
|
|
939
|
+
durationMs: 50,
|
|
940
|
+
error: 'Agent crashed',
|
|
941
|
+
});
|
|
942
|
+
|
|
943
|
+
const failAtlas = createAtlasWithAgents([failBackend], {
|
|
944
|
+
storage: { baseDir: tempDir + '-fail' },
|
|
945
|
+
learning: { minTrajectories: 100 },
|
|
946
|
+
execution: { defaultAgentType: 'mock', maxExecutionTime: 60 },
|
|
947
|
+
});
|
|
948
|
+
await failAtlas.init();
|
|
949
|
+
|
|
950
|
+
// Suppress warnings from template fallbacks in failed execution
|
|
951
|
+
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
952
|
+
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
953
|
+
|
|
954
|
+
const task = makeTask();
|
|
955
|
+
const result = await failAtlas.solve(task);
|
|
956
|
+
|
|
957
|
+
expect(result.trajectory).toBeDefined();
|
|
958
|
+
expect(result.trajectory.outcome.success).toBe(false);
|
|
959
|
+
|
|
960
|
+
await failAtlas.close();
|
|
961
|
+
await rm(tempDir + '-fail', { recursive: true, force: true });
|
|
962
|
+
|
|
963
|
+
warnSpy.mockRestore();
|
|
964
|
+
errorSpy.mockRestore();
|
|
965
|
+
});
|
|
966
|
+
});
|
|
967
|
+
|
|
968
|
+
// ============================================================
|
|
969
|
+
// Template-level tests: meta-reflection heuristic correctness
|
|
970
|
+
// ============================================================
|
|
971
|
+
|
|
972
|
+
describe('Meta-reflection template heuristic', () => {
|
|
973
|
+
it('should return heuristic complexity for successful high-confidence tasks', () => {
|
|
974
|
+
const complexity = metaReflectionTemplate.assessComplexity({
|
|
975
|
+
trajectory: makeSuccessTrajectory(),
|
|
976
|
+
routingDecision: { strategy: 'direct', confidence: 0.9, estimatedBudget: 5, reasoning: 'ok' },
|
|
977
|
+
playbooksUsed: [],
|
|
978
|
+
});
|
|
979
|
+
expect(complexity).toBe('heuristic');
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
it('should return lightweight for failed tasks', () => {
|
|
983
|
+
const complexity = metaReflectionTemplate.assessComplexity({
|
|
984
|
+
trajectory: makeFailTrajectory(),
|
|
985
|
+
routingDecision: { strategy: 'explore', confidence: 0.4, estimatedBudget: 10, reasoning: 'uncertain' },
|
|
986
|
+
playbooksUsed: [],
|
|
987
|
+
});
|
|
988
|
+
expect(complexity).toBe('lightweight');
|
|
989
|
+
});
|
|
990
|
+
|
|
991
|
+
it('should compute correct heuristic outcomeQuality based on effort ratio', async () => {
|
|
992
|
+
const heuristic = metaReflectionTemplate.heuristicFallback!;
|
|
993
|
+
|
|
994
|
+
// effortRatio = 5/10 = 0.5 → 'excellent'
|
|
995
|
+
const excellent = await heuristic({
|
|
996
|
+
trajectory: makeSuccessTrajectory({ llmCalls: 5 }),
|
|
997
|
+
routingDecision: { strategy: 'direct', confidence: 0.9, estimatedBudget: 10, reasoning: 'ok' },
|
|
998
|
+
playbooksUsed: [],
|
|
999
|
+
});
|
|
1000
|
+
expect(excellent.outcomeQuality).toBe('excellent');
|
|
1001
|
+
|
|
1002
|
+
// effortRatio = 10/10 = 1.0 → 'good'
|
|
1003
|
+
const good = await heuristic({
|
|
1004
|
+
trajectory: makeSuccessTrajectory({ llmCalls: 10 }),
|
|
1005
|
+
routingDecision: { strategy: 'direct', confidence: 0.9, estimatedBudget: 10, reasoning: 'ok' },
|
|
1006
|
+
playbooksUsed: [],
|
|
1007
|
+
});
|
|
1008
|
+
expect(good.outcomeQuality).toBe('good');
|
|
1009
|
+
|
|
1010
|
+
// effortRatio = 15/10 = 1.5 → 'acceptable'
|
|
1011
|
+
const acceptable = await heuristic({
|
|
1012
|
+
trajectory: makeSuccessTrajectory({ llmCalls: 15 }),
|
|
1013
|
+
routingDecision: { strategy: 'direct', confidence: 0.9, estimatedBudget: 10, reasoning: 'ok' },
|
|
1014
|
+
playbooksUsed: [],
|
|
1015
|
+
});
|
|
1016
|
+
expect(acceptable.outcomeQuality).toBe('acceptable');
|
|
1017
|
+
|
|
1018
|
+
// Failed trajectory → 'poor'
|
|
1019
|
+
const poor = await heuristic({
|
|
1020
|
+
trajectory: makeFailTrajectory(),
|
|
1021
|
+
routingDecision: { strategy: 'explore', confidence: 0.5, estimatedBudget: 10, reasoning: 'guess' },
|
|
1022
|
+
playbooksUsed: [],
|
|
1023
|
+
});
|
|
1024
|
+
expect(poor.outcomeQuality).toBe('poor');
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1027
|
+
it('should report helpful retrieval when playbooks used and successful', async () => {
|
|
1028
|
+
const heuristic = metaReflectionTemplate.heuristicFallback!;
|
|
1029
|
+
const result = await heuristic({
|
|
1030
|
+
trajectory: makeSuccessTrajectory(),
|
|
1031
|
+
routingDecision: { strategy: 'direct', confidence: 0.9, estimatedBudget: 10, reasoning: 'ok' },
|
|
1032
|
+
playbooksUsed: [{
|
|
1033
|
+
playbook: makePlaybook('pb-1', 'Auth Fix'),
|
|
1034
|
+
score: 0.9,
|
|
1035
|
+
matchType: 'situation',
|
|
1036
|
+
}],
|
|
1037
|
+
});
|
|
1038
|
+
|
|
1039
|
+
expect(result.retrievalQuality).toBe('helpful');
|
|
1040
|
+
});
|
|
1041
|
+
|
|
1042
|
+
it('should report neutral retrieval when no playbooks used', async () => {
|
|
1043
|
+
const heuristic = metaReflectionTemplate.heuristicFallback!;
|
|
1044
|
+
const result = await heuristic({
|
|
1045
|
+
trajectory: makeSuccessTrajectory(),
|
|
1046
|
+
routingDecision: { strategy: 'direct', confidence: 0.9, estimatedBudget: 10, reasoning: 'ok' },
|
|
1047
|
+
playbooksUsed: [],
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
expect(result.retrievalQuality).toBe('neutral');
|
|
1051
|
+
});
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
// ============================================================
|
|
1055
|
+
// Template-level tests: refinement-analysis
|
|
1056
|
+
// ============================================================
|
|
1057
|
+
|
|
1058
|
+
describe('Refinement-analysis template complexity', () => {
|
|
1059
|
+
const baseInput = {
|
|
1060
|
+
trajectory: makeFailTrajectory(),
|
|
1061
|
+
task: makeTask(),
|
|
1062
|
+
evaluation: createEvaluationResult({
|
|
1063
|
+
quality: 'poor', score: 0.3, acceptable: false, issues: [], method: 'heuristic',
|
|
1064
|
+
}),
|
|
1065
|
+
previousAttempts: 1,
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
it('should return lightweight for first failure', () => {
|
|
1069
|
+
expect(refinementAnalysisTemplate.assessComplexity(baseInput)).toBe('lightweight');
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
it('should return standard for repeated failures', () => {
|
|
1073
|
+
expect(
|
|
1074
|
+
refinementAnalysisTemplate.assessComplexity({ ...baseInput, previousAttempts: 2 })
|
|
1075
|
+
).toBe('standard');
|
|
1076
|
+
});
|
|
1077
|
+
|
|
1078
|
+
it('should have no heuristic fallback', () => {
|
|
1079
|
+
expect(refinementAnalysisTemplate.heuristicFallback).toBeUndefined();
|
|
1080
|
+
});
|
|
1081
|
+
});
|
|
1082
|
+
|
|
1083
|
+
// ============================================================
|
|
1084
|
+
// Template-level tests: usage-inference complexity
|
|
1085
|
+
// ============================================================
|
|
1086
|
+
|
|
1087
|
+
describe('Usage-inference template complexity', () => {
|
|
1088
|
+
it('should return heuristic when no playbooks injected', () => {
|
|
1089
|
+
const complexity = usageInferenceTemplate.assessComplexity({
|
|
1090
|
+
trajectory: makeSuccessTrajectory(),
|
|
1091
|
+
injectedPlaybooks: [],
|
|
1092
|
+
});
|
|
1093
|
+
expect(complexity).toBe('heuristic');
|
|
1094
|
+
});
|
|
1095
|
+
|
|
1096
|
+
it('should return heuristic for few playbooks and short trajectory', () => {
|
|
1097
|
+
const complexity = usageInferenceTemplate.assessComplexity({
|
|
1098
|
+
trajectory: makeSuccessTrajectory(), // 3 steps
|
|
1099
|
+
injectedPlaybooks: [makePlaybook('p1', 'P1')],
|
|
1100
|
+
});
|
|
1101
|
+
expect(complexity).toBe('heuristic');
|
|
1102
|
+
});
|
|
1103
|
+
});
|