cognitive-core 0.1.2 → 0.2.0
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.md +233 -0
- package/README.md +370 -54
- package/dist/atlas.d.ts +10 -10
- package/dist/atlas.d.ts.map +1 -1
- package/dist/atlas.js +79 -48
- package/dist/atlas.js.map +1 -1
- package/dist/bin/cli-utils.d.ts +37 -0
- package/dist/bin/cli-utils.d.ts.map +1 -0
- package/dist/bin/cli-utils.js +176 -0
- package/dist/bin/cli-utils.js.map +1 -0
- package/dist/bin/cognitive-core.d.ts +2 -12
- package/dist/bin/cognitive-core.d.ts.map +1 -1
- package/dist/bin/cognitive-core.js +76 -351
- package/dist/bin/cognitive-core.js.map +1 -1
- package/dist/bin/commands/kb.d.ts +6 -0
- package/dist/bin/commands/kb.d.ts.map +1 -0
- package/dist/bin/commands/kb.js +240 -0
- package/dist/bin/commands/kb.js.map +1 -0
- package/dist/bin/commands/learn.d.ts +6 -0
- package/dist/bin/commands/learn.d.ts.map +1 -0
- package/dist/bin/commands/learn.js +91 -0
- package/dist/bin/commands/learn.js.map +1 -0
- package/dist/bin/commands/legacy.d.ts +12 -0
- package/dist/bin/commands/legacy.d.ts.map +1 -0
- package/dist/bin/commands/legacy.js +142 -0
- package/dist/bin/commands/legacy.js.map +1 -0
- package/dist/bin/commands/run.d.ts +3 -0
- package/dist/bin/commands/run.d.ts.map +1 -0
- package/dist/bin/commands/run.js +99 -0
- package/dist/bin/commands/run.js.map +1 -0
- package/dist/bin/commands/sessions.d.ts +9 -0
- package/dist/bin/commands/sessions.d.ts.map +1 -0
- package/dist/bin/commands/sessions.js +183 -0
- package/dist/bin/commands/sessions.js.map +1 -0
- package/dist/bin/commands/skills.d.ts +6 -0
- package/dist/bin/commands/skills.d.ts.map +1 -0
- package/dist/bin/commands/skills.js +135 -0
- package/dist/bin/commands/skills.js.map +1 -0
- package/dist/embeddings/index.d.ts +1 -0
- package/dist/embeddings/index.d.ts.map +1 -1
- package/dist/embeddings/index.js +2 -0
- package/dist/embeddings/index.js.map +1 -1
- package/dist/embeddings/inverted-index.d.ts +47 -0
- package/dist/embeddings/inverted-index.d.ts.map +1 -0
- package/dist/embeddings/inverted-index.js +122 -0
- package/dist/embeddings/inverted-index.js.map +1 -0
- package/dist/embeddings/manager.d.ts +3 -1
- package/dist/embeddings/manager.d.ts.map +1 -1
- package/dist/embeddings/manager.js +12 -7
- package/dist/embeddings/manager.js.map +1 -1
- package/dist/embeddings/vector-store.d.ts +7 -3
- package/dist/embeddings/vector-store.d.ts.map +1 -1
- package/dist/embeddings/vector-store.js +22 -6
- package/dist/embeddings/vector-store.js.map +1 -1
- package/dist/factory.d.ts +11 -12
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +20 -7
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -5
- package/dist/index.js.map +1 -1
- package/dist/learning/analyzer.d.ts.map +1 -1
- package/dist/learning/analyzer.js +17 -35
- package/dist/learning/analyzer.js.map +1 -1
- package/dist/learning/energy-evaluator.d.ts +128 -0
- package/dist/learning/energy-evaluator.d.ts.map +1 -0
- package/dist/learning/energy-evaluator.js +175 -0
- package/dist/learning/energy-evaluator.js.map +1 -0
- package/dist/learning/healing-orchestrator.d.ts +182 -0
- package/dist/learning/healing-orchestrator.d.ts.map +1 -0
- package/dist/learning/healing-orchestrator.js +250 -0
- package/dist/learning/healing-orchestrator.js.map +1 -0
- package/dist/learning/index.d.ts +7 -2
- package/dist/learning/index.d.ts.map +1 -1
- package/dist/learning/index.js +13 -2
- package/dist/learning/index.js.map +1 -1
- package/dist/learning/instant-loop.d.ts +87 -0
- package/dist/learning/instant-loop.d.ts.map +1 -0
- package/dist/learning/instant-loop.js +264 -0
- package/dist/learning/instant-loop.js.map +1 -0
- package/dist/learning/loop-coordinator.d.ts +61 -0
- package/dist/learning/loop-coordinator.d.ts.map +1 -0
- package/dist/learning/loop-coordinator.js +96 -0
- package/dist/learning/loop-coordinator.js.map +1 -0
- package/dist/learning/maintenance-scheduler.d.ts +141 -0
- package/dist/learning/maintenance-scheduler.d.ts.map +1 -0
- package/dist/learning/maintenance-scheduler.js +186 -0
- package/dist/learning/maintenance-scheduler.js.map +1 -0
- package/dist/learning/meta-learner.d.ts.map +1 -1
- package/dist/learning/meta-learner.js +4 -21
- package/dist/learning/meta-learner.js.map +1 -1
- package/dist/learning/pipeline.d.ts +31 -4
- package/dist/learning/pipeline.d.ts.map +1 -1
- package/dist/learning/pipeline.js +64 -12
- package/dist/learning/pipeline.js.map +1 -1
- package/dist/learning/reflexion-generator.d.ts +64 -0
- package/dist/learning/reflexion-generator.d.ts.map +1 -0
- package/dist/learning/reflexion-generator.js +194 -0
- package/dist/learning/reflexion-generator.js.map +1 -0
- package/dist/learning/trajectory-sources/entire.d.ts +8 -5
- package/dist/learning/trajectory-sources/entire.d.ts.map +1 -1
- package/dist/learning/trajectory-sources/entire.js +13 -6
- package/dist/learning/trajectory-sources/entire.js.map +1 -1
- package/dist/learning/trajectory-sources/index.d.ts +1 -1
- package/dist/learning/trajectory-sources/index.d.ts.map +1 -1
- package/dist/learning/trajectory-sources/index.js +1 -1
- package/dist/learning/trajectory-sources/index.js.map +1 -1
- package/dist/learning/trajectory-sources/pipeline.d.ts +4 -4
- package/dist/learning/trajectory-sources/pipeline.d.ts.map +1 -1
- package/dist/learning/trajectory-sources/pipeline.js +2 -2
- package/dist/learning/trajectory-sources/pipeline.js.map +1 -1
- package/dist/learning/unified-pipeline.d.ts +281 -0
- package/dist/learning/unified-pipeline.d.ts.map +1 -0
- package/dist/learning/unified-pipeline.js +637 -0
- package/dist/learning/unified-pipeline.js.map +1 -0
- package/dist/memory/candidate-retrieval.d.ts +43 -0
- package/dist/memory/candidate-retrieval.d.ts.map +1 -0
- package/dist/memory/candidate-retrieval.js +41 -0
- package/dist/memory/candidate-retrieval.js.map +1 -0
- package/dist/memory/causal-store.d.ts +97 -0
- package/dist/memory/causal-store.d.ts.map +1 -0
- package/dist/memory/causal-store.js +209 -0
- package/dist/memory/causal-store.js.map +1 -0
- package/dist/memory/coherence.d.ts +71 -0
- package/dist/memory/coherence.d.ts.map +1 -0
- package/dist/memory/coherence.js +176 -0
- package/dist/memory/coherence.js.map +1 -0
- package/dist/memory/experience.d.ts +39 -6
- package/dist/memory/experience.d.ts.map +1 -1
- package/dist/memory/experience.js +193 -49
- package/dist/memory/experience.js.map +1 -1
- package/dist/memory/index.d.ts +7 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +12 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/knowledge-bank.d.ts +14 -0
- package/dist/memory/knowledge-bank.d.ts.map +1 -1
- package/dist/memory/knowledge-bank.js +45 -0
- package/dist/memory/knowledge-bank.js.map +1 -1
- package/dist/memory/meta.d.ts +7 -8
- package/dist/memory/meta.d.ts.map +1 -1
- package/dist/memory/meta.js +73 -79
- package/dist/memory/meta.js.map +1 -1
- package/dist/memory/playbook.d.ts +26 -9
- package/dist/memory/playbook.d.ts.map +1 -1
- package/dist/memory/playbook.js +198 -74
- package/dist/memory/playbook.js.map +1 -1
- package/dist/memory/reasoning-bank.d.ts +130 -0
- package/dist/memory/reasoning-bank.d.ts.map +1 -0
- package/dist/memory/reasoning-bank.js +342 -0
- package/dist/memory/reasoning-bank.js.map +1 -0
- package/dist/memory/reflexion.d.ts +59 -0
- package/dist/memory/reflexion.d.ts.map +1 -0
- package/dist/memory/reflexion.js +96 -0
- package/dist/memory/reflexion.js.map +1 -0
- package/dist/memory/system.d.ts +7 -2
- package/dist/memory/system.d.ts.map +1 -1
- package/dist/memory/system.js +19 -7
- package/dist/memory/system.js.map +1 -1
- package/dist/memory/temporal-compressor.d.ts +126 -0
- package/dist/memory/temporal-compressor.d.ts.map +1 -0
- package/dist/memory/temporal-compressor.js +335 -0
- package/dist/memory/temporal-compressor.js.map +1 -0
- package/dist/persistence/index.d.ts +11 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +11 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/migrator.d.ts +40 -0
- package/dist/persistence/migrator.d.ts.map +1 -0
- package/dist/persistence/migrator.js +238 -0
- package/dist/persistence/migrator.js.map +1 -0
- package/dist/persistence/serializers.d.ts +45 -0
- package/dist/persistence/serializers.d.ts.map +1 -0
- package/dist/persistence/serializers.js +80 -0
- package/dist/persistence/serializers.js.map +1 -0
- package/dist/persistence/sqlite-persistence.d.ts +228 -0
- package/dist/persistence/sqlite-persistence.d.ts.map +1 -0
- package/dist/persistence/sqlite-persistence.js +588 -0
- package/dist/persistence/sqlite-persistence.js.map +1 -0
- package/dist/runtime/flows/learning.d.ts +10 -12
- package/dist/runtime/flows/learning.d.ts.map +1 -1
- package/dist/runtime/flows/learning.js +10 -23
- package/dist/runtime/flows/learning.js.map +1 -1
- package/dist/search/index.d.ts +1 -0
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +2 -0
- package/dist/search/index.js.map +1 -1
- package/dist/search/moe-gate.d.ts +124 -0
- package/dist/search/moe-gate.d.ts.map +1 -0
- package/dist/search/moe-gate.js +234 -0
- package/dist/search/moe-gate.js.map +1 -0
- package/dist/search/router.d.ts +32 -2
- package/dist/search/router.d.ts.map +1 -1
- package/dist/search/router.js +87 -4
- package/dist/search/router.js.map +1 -1
- package/dist/session-bank/git-reader.d.ts +9 -4
- package/dist/session-bank/git-reader.d.ts.map +1 -1
- package/dist/session-bank/git-reader.js +22 -15
- package/dist/session-bank/git-reader.js.map +1 -1
- package/dist/session-bank/index.d.ts +2 -2
- package/dist/session-bank/index.d.ts.map +1 -1
- package/dist/session-bank/index.js +2 -2
- package/dist/session-bank/index.js.map +1 -1
- package/dist/session-bank/parser.d.ts +16 -5
- package/dist/session-bank/parser.d.ts.map +1 -1
- package/dist/session-bank/parser.js +187 -80
- package/dist/session-bank/parser.js.map +1 -1
- package/dist/session-bank/session-bank.d.ts +5 -0
- package/dist/session-bank/session-bank.d.ts.map +1 -1
- package/dist/session-bank/session-bank.js +30 -9
- package/dist/session-bank/session-bank.js.map +1 -1
- package/dist/session-bank/types.d.ts +4 -1
- package/dist/session-bank/types.d.ts.map +1 -1
- package/dist/session-bank/types.js +3 -3
- package/dist/session-bank/types.js.map +1 -1
- package/dist/surfacing/skill-publisher.d.ts.map +1 -1
- package/dist/surfacing/skill-publisher.js +15 -43
- package/dist/surfacing/skill-publisher.js.map +1 -1
- package/dist/surfacing/sqlite-storage-adapter.d.ts.map +1 -1
- package/dist/surfacing/sqlite-storage-adapter.js +13 -21
- package/dist/surfacing/sqlite-storage-adapter.js.map +1 -1
- package/dist/types/config.d.ts +100 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +27 -0
- package/dist/types/config.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/memory.d.ts +52 -0
- package/dist/types/memory.d.ts.map +1 -1
- package/dist/types/memory.js +13 -0
- package/dist/types/memory.js.map +1 -1
- package/dist/types/playbook.d.ts +4 -0
- package/dist/types/playbook.d.ts.map +1 -1
- package/dist/types/playbook.js.map +1 -1
- package/dist/utils/error-classifier.d.ts +30 -0
- package/dist/utils/error-classifier.d.ts.map +1 -0
- package/dist/utils/error-classifier.js +85 -0
- package/dist/utils/error-classifier.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/partitioned-store.d.ts +93 -0
- package/dist/utils/partitioned-store.d.ts.map +1 -0
- package/dist/utils/partitioned-store.js +251 -0
- package/dist/utils/partitioned-store.js.map +1 -0
- package/dist/utils/trajectory-helpers.d.ts +39 -0
- package/dist/utils/trajectory-helpers.d.ts.map +1 -0
- package/dist/utils/trajectory-helpers.js +57 -0
- package/dist/utils/trajectory-helpers.js.map +1 -0
- package/dist/workspace/runner.d.ts +3 -4
- package/dist/workspace/runner.d.ts.map +1 -1
- package/dist/workspace/runner.js.map +1 -1
- package/dist/workspace/types.d.ts +9 -2
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/types.js.map +1 -1
- package/package.json +6 -4
- package/references/sessionlog/.husky/pre-commit +1 -0
- package/references/sessionlog/.lintstagedrc.json +4 -0
- package/references/sessionlog/.prettierignore +4 -0
- package/references/sessionlog/.prettierrc.json +11 -0
- package/references/sessionlog/LICENSE +21 -0
- package/references/sessionlog/README.md +453 -0
- package/references/sessionlog/eslint.config.js +58 -0
- package/references/sessionlog/package-lock.json +3672 -0
- package/references/sessionlog/package.json +65 -0
- package/references/sessionlog/src/__tests__/agent-hooks.test.ts +570 -0
- package/references/sessionlog/src/__tests__/agent-registry.test.ts +127 -0
- package/references/sessionlog/src/__tests__/claude-code-hooks.test.ts +225 -0
- package/references/sessionlog/src/__tests__/claude-generator.test.ts +46 -0
- package/references/sessionlog/src/__tests__/commit-msg.test.ts +86 -0
- package/references/sessionlog/src/__tests__/cursor-agent.test.ts +224 -0
- package/references/sessionlog/src/__tests__/e2e-live.test.ts +890 -0
- package/references/sessionlog/src/__tests__/event-log.test.ts +183 -0
- package/references/sessionlog/src/__tests__/flush-sentinel.test.ts +105 -0
- package/references/sessionlog/src/__tests__/gemini-agent.test.ts +375 -0
- package/references/sessionlog/src/__tests__/git-hooks.test.ts +78 -0
- package/references/sessionlog/src/__tests__/hook-managers.test.ts +121 -0
- package/references/sessionlog/src/__tests__/lifecycle-tasks.test.ts +759 -0
- package/references/sessionlog/src/__tests__/opencode-agent.test.ts +338 -0
- package/references/sessionlog/src/__tests__/redaction.test.ts +136 -0
- package/references/sessionlog/src/__tests__/session-repo.test.ts +353 -0
- package/references/sessionlog/src/__tests__/session-store.test.ts +166 -0
- package/references/sessionlog/src/__tests__/setup-ccweb.test.ts +466 -0
- package/references/sessionlog/src/__tests__/skill-live.test.ts +461 -0
- package/references/sessionlog/src/__tests__/summarize.test.ts +348 -0
- package/references/sessionlog/src/__tests__/task-plan-e2e.test.ts +610 -0
- package/references/sessionlog/src/__tests__/task-plan-live.test.ts +632 -0
- package/references/sessionlog/src/__tests__/transcript-timestamp.test.ts +121 -0
- package/references/sessionlog/src/__tests__/types.test.ts +166 -0
- package/references/sessionlog/src/__tests__/utils.test.ts +333 -0
- package/references/sessionlog/src/__tests__/validation.test.ts +103 -0
- package/references/sessionlog/src/__tests__/worktree.test.ts +57 -0
- package/references/sessionlog/src/agent/agents/claude-code.ts +1089 -0
- package/references/sessionlog/src/agent/agents/cursor.ts +361 -0
- package/references/sessionlog/src/agent/agents/gemini-cli.ts +632 -0
- package/references/sessionlog/src/agent/agents/opencode.ts +540 -0
- package/references/sessionlog/src/agent/registry.ts +143 -0
- package/references/sessionlog/src/agent/session-types.ts +113 -0
- package/references/sessionlog/src/agent/types.ts +220 -0
- package/references/sessionlog/src/cli.ts +597 -0
- package/references/sessionlog/src/commands/clean.ts +133 -0
- package/references/sessionlog/src/commands/disable.ts +84 -0
- package/references/sessionlog/src/commands/doctor.ts +145 -0
- package/references/sessionlog/src/commands/enable.ts +202 -0
- package/references/sessionlog/src/commands/explain.ts +261 -0
- package/references/sessionlog/src/commands/reset.ts +105 -0
- package/references/sessionlog/src/commands/resume.ts +180 -0
- package/references/sessionlog/src/commands/rewind.ts +195 -0
- package/references/sessionlog/src/commands/setup-ccweb.ts +275 -0
- package/references/sessionlog/src/commands/status.ts +172 -0
- package/references/sessionlog/src/config.ts +165 -0
- package/references/sessionlog/src/events/event-log.ts +126 -0
- package/references/sessionlog/src/git-operations.ts +558 -0
- package/references/sessionlog/src/hooks/git-hooks.ts +165 -0
- package/references/sessionlog/src/hooks/lifecycle.ts +391 -0
- package/references/sessionlog/src/index.ts +650 -0
- package/references/sessionlog/src/security/redaction.ts +283 -0
- package/references/sessionlog/src/session/state-machine.ts +452 -0
- package/references/sessionlog/src/store/checkpoint-store.ts +509 -0
- package/references/sessionlog/src/store/native-store.ts +173 -0
- package/references/sessionlog/src/store/provider-types.ts +99 -0
- package/references/sessionlog/src/store/session-store.ts +266 -0
- package/references/sessionlog/src/strategy/attribution.ts +296 -0
- package/references/sessionlog/src/strategy/common.ts +207 -0
- package/references/sessionlog/src/strategy/content-overlap.ts +228 -0
- package/references/sessionlog/src/strategy/manual-commit.ts +988 -0
- package/references/sessionlog/src/strategy/types.ts +279 -0
- package/references/sessionlog/src/summarize/claude-generator.ts +115 -0
- package/references/sessionlog/src/summarize/summarize.ts +432 -0
- package/references/sessionlog/src/types.ts +508 -0
- package/references/sessionlog/src/utils/chunk-files.ts +49 -0
- package/references/sessionlog/src/utils/commit-message.ts +65 -0
- package/references/sessionlog/src/utils/detect-agent.ts +36 -0
- package/references/sessionlog/src/utils/hook-managers.ts +125 -0
- package/references/sessionlog/src/utils/ide-tags.ts +32 -0
- package/references/sessionlog/src/utils/paths.ts +79 -0
- package/references/sessionlog/src/utils/preview-rewind.ts +80 -0
- package/references/sessionlog/src/utils/rewind-conflict.ts +121 -0
- package/references/sessionlog/src/utils/shadow-branch.ts +109 -0
- package/references/sessionlog/src/utils/string-utils.ts +46 -0
- package/references/sessionlog/src/utils/todo-extract.ts +188 -0
- package/references/sessionlog/src/utils/trailers.ts +187 -0
- package/references/sessionlog/src/utils/transcript-parse.ts +177 -0
- package/references/sessionlog/src/utils/transcript-timestamp.ts +59 -0
- package/references/sessionlog/src/utils/tree-ops.ts +219 -0
- package/references/sessionlog/src/utils/tty.ts +72 -0
- package/references/sessionlog/src/utils/validation.ts +65 -0
- package/references/sessionlog/src/utils/worktree.ts +58 -0
- package/references/sessionlog/src/wire-types.ts +59 -0
- package/references/sessionlog/templates/setup-env.sh +153 -0
- package/references/sessionlog/tsconfig.json +18 -0
- package/references/sessionlog/vitest.config.ts +12 -0
- package/references/skill-tree/.sudocode/issues.jsonl +8 -0
- package/references/skill-tree/.sudocode/specs.jsonl +2 -0
- package/references/skill-tree/CLAUDE.md +56 -80
- package/references/skill-tree/README.md +188 -140
- package/references/skill-tree/examples/basic-usage.ts +95 -121
- package/references/skill-tree/package-lock.json +369 -26
- package/references/skill-tree/package.json +1 -1
- package/src/atlas.ts +97 -67
- package/src/bin/cli-utils.ts +220 -0
- package/src/bin/cognitive-core.ts +84 -392
- package/src/bin/commands/kb.ts +266 -0
- package/src/bin/commands/learn.ts +100 -0
- package/src/bin/commands/legacy.ts +182 -0
- package/src/bin/commands/run.ts +113 -0
- package/src/bin/commands/sessions.ts +221 -0
- package/src/bin/commands/skills.ts +146 -0
- package/src/embeddings/index.ts +3 -0
- package/src/embeddings/inverted-index.ts +134 -0
- package/src/embeddings/manager.ts +13 -8
- package/src/embeddings/vector-store.ts +21 -9
- package/src/factory.ts +33 -16
- package/src/index.ts +109 -9
- package/src/learning/analyzer.ts +21 -37
- package/src/learning/energy-evaluator.ts +282 -0
- package/src/learning/healing-orchestrator.ts +383 -0
- package/src/learning/index.ts +65 -9
- package/src/learning/instant-loop.ts +357 -0
- package/src/learning/maintenance-scheduler.ts +271 -0
- package/src/learning/meta-learner.ts +5 -23
- package/src/learning/reflexion-generator.ts +273 -0
- package/src/learning/trajectory-sources/entire.ts +24 -13
- package/src/learning/trajectory-sources/index.ts +2 -2
- package/src/learning/trajectory-sources/pipeline.ts +5 -5
- package/src/learning/unified-pipeline.ts +921 -0
- package/src/memory/candidate-retrieval.ts +71 -0
- package/src/memory/causal-store.ts +273 -0
- package/src/memory/coherence.ts +252 -0
- package/src/memory/experience.ts +217 -50
- package/src/memory/index.ts +43 -0
- package/src/memory/knowledge-bank.ts +57 -0
- package/src/memory/meta.ts +78 -96
- package/src/memory/playbook.ts +239 -75
- package/src/memory/reasoning-bank.ts +458 -0
- package/src/memory/reflexion.ts +122 -0
- package/src/memory/system.ts +21 -5
- package/src/memory/temporal-compressor.ts +409 -0
- package/src/persistence/index.ts +37 -0
- package/src/persistence/migrator.ts +298 -0
- package/src/persistence/serializers.ts +79 -0
- package/src/persistence/sqlite-persistence.ts +925 -0
- package/src/runtime/flows/learning.ts +25 -42
- package/src/search/index.ts +10 -0
- package/src/search/moe-gate.ts +304 -0
- package/src/search/router.ts +111 -4
- package/src/session-bank/git-reader.ts +29 -19
- package/src/session-bank/index.ts +4 -2
- package/src/session-bank/parser.ts +280 -98
- package/src/session-bank/session-bank.ts +33 -12
- package/src/session-bank/types.ts +8 -5
- package/src/surfacing/skill-publisher.ts +17 -49
- package/src/surfacing/sqlite-storage-adapter.ts +16 -32
- package/src/types/config.ts +30 -0
- package/src/types/index.ts +3 -0
- package/src/types/memory.ts +30 -0
- package/src/types/playbook.ts +4 -0
- package/src/utils/error-classifier.ts +113 -0
- package/src/utils/index.ts +18 -0
- package/src/utils/partitioned-store.ts +299 -0
- package/src/utils/trajectory-helpers.ts +79 -0
- package/src/workspace/runner.ts +3 -3
- package/src/workspace/types.ts +10 -2
- package/tests/embeddings/inverted-index.test.ts +138 -0
- package/tests/feature-toggles.test.ts +275 -0
- package/tests/gap-fixes.test.ts +17 -4
- package/tests/integration/cli-e2e.test.ts +621 -0
- package/tests/integration/e2e.test.ts +6 -5
- package/tests/integration/entire-e2e.test.ts +314 -125
- package/tests/integration/persistence-e2e.test.ts +741 -0
- package/tests/integration/phase-e2e.test.ts +1143 -0
- package/tests/integration/session-bank.test.ts +20 -14
- package/tests/integration/sessionlog-e2e.test.ts +329 -0
- package/tests/integration/unified-pipeline-e2e.test.ts +634 -0
- package/tests/learning/analyzer.test.ts +1 -1
- package/tests/learning/energy-evaluator.test.ts +180 -0
- package/tests/learning/entire-trajectory-source.test.ts +25 -25
- package/tests/learning/healing-orchestrator.test.ts +269 -0
- package/tests/learning/instant-loop.test.ts +243 -0
- package/tests/learning/maintenance-scheduler.test.ts +191 -0
- package/tests/learning/reflexion-generator.test.ts +411 -0
- package/tests/learning/trajectory-sources.test.ts +12 -4
- package/tests/learning/unified-pipeline.test.ts +322 -0
- package/tests/mcp/playbook-server.test.ts +6 -1
- package/tests/memory/causal-store.test.ts +276 -0
- package/tests/memory/coherence.test.ts +232 -0
- package/tests/memory/experience.test.ts +8 -3
- package/tests/memory/playbook.test.ts +307 -1
- package/tests/memory/provenance.test.ts +11 -2
- package/tests/memory/reasoning-bank.test.ts +239 -0
- package/tests/memory/reflexion.test.ts +166 -0
- package/tests/memory/skill-exporter.test.ts +6 -1
- package/tests/memory/system.test.ts +6 -1
- package/tests/memory/temporal-compressor.test.ts +318 -0
- package/tests/persistence/migrator.test.ts +1009 -0
- package/tests/persistence/sqlite-persistence.test.ts +635 -0
- package/tests/runtime/agent-manager.test.ts +6 -1
- package/tests/runtime/delegate.test.ts +6 -1
- package/tests/search/moe-gate.test.ts +250 -0
- package/tests/search/refinement-loop.test.ts +11 -2
- package/tests/search/router.test.ts +81 -2
- package/tests/session-bank/fixtures/sessionlog-root-metadata.json +16 -0
- package/tests/session-bank/fixtures/sessionlog-session/full.jsonl +6 -0
- package/tests/session-bank/fixtures/sessionlog-session/metadata.json +55 -0
- package/tests/session-bank/git-reader.test.ts +13 -13
- package/tests/session-bank/parser.test.ts +135 -3
- package/tests/session-bank/session-bank.test.ts +1 -1
- package/tests/surfacing/skill-library.test.ts +6 -1
- package/tests/surfacing/skill-publisher.test.ts +24 -58
- package/tests/surfacing/sqlite-storage-adapter.test.ts +11 -23
- package/tests/utils/partitioned-store.test.ts +230 -0
- package/tests/workspace/full-flow.test.ts +10 -4
- package/tests/workspace/runner.test.ts +10 -4
- package/docs/DESIGN-workspace-migration.md +0 -1079
- package/docs/PLAN-agentic-workspace-implementation.md +0 -717
- package/docs/PLAN-graph-migration.md +0 -299
- package/docs/PLAN-session-bank-implementation.md +0 -474
- package/src/learning/pipeline.ts +0 -323
- package/tests/learning/pipeline.test.ts +0 -176
|
@@ -1,717 +0,0 @@
|
|
|
1
|
-
# Implementation Plan: Agentic Workspace
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
This plan implements the agentic workspace infrastructure described in `DESIGN-agentic-workspace.md`. The system standardizes how cognitive-core spawns analysis agents with filesystem-based workspaces, structured I/O, and meta-learning capture.
|
|
6
|
-
|
|
7
|
-
**Goal**: Replace ad-hoc heuristic analyzers with a reusable workspace pattern that routes complex inputs to full agentic analysis while keeping simple cases on fast heuristic paths.
|
|
8
|
-
|
|
9
|
-
**Key constraint**: All existing heuristics are preserved as `heuristicFallback` — no functionality is lost, and simple cases stay fast.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Phase 1: Core Infrastructure
|
|
14
|
-
|
|
15
|
-
**Objective**: Implement the three foundational components — types, `WorkspaceManager`, and `AgenticTaskRunner` — and wire them into `Atlas`.
|
|
16
|
-
|
|
17
|
-
### 1.1 — Types & Interfaces
|
|
18
|
-
|
|
19
|
-
**File**: `src/workspace/types.ts` (new)
|
|
20
|
-
|
|
21
|
-
Define all workspace-related types and interfaces:
|
|
22
|
-
|
|
23
|
-
- `AgenticTaskTemplate<TInput, TOutput>` — the declarative recipe interface
|
|
24
|
-
- `OutputConfig`, `OutputFileSpec` — output shape definition
|
|
25
|
-
- `AgentSkillSpec` — skill to load into workspace
|
|
26
|
-
- `ResourceSpec` — supplementary resource definition
|
|
27
|
-
- `AnalysisComplexity` — complexity assessment enum (`'heuristic' | 'lightweight' | 'standard' | 'thorough'`)
|
|
28
|
-
- `ProcessingContext` — context passed to `processOutput`
|
|
29
|
-
- `WorkspaceHandle` — handle to a created workspace directory
|
|
30
|
-
- `AgenticTaskResult<TOutput>` — result from running a task
|
|
31
|
-
- `AgenticTaskRunnerConfig` — runner configuration
|
|
32
|
-
- `AgenticTaskOutputError` — custom error class for output validation failures
|
|
33
|
-
|
|
34
|
-
All types are directly derived from the design doc (lines 107-283 of `DESIGN-agentic-workspace.md`).
|
|
35
|
-
|
|
36
|
-
**Zod schemas**: Add `AgenticTaskRunnerConfigSchema` to `src/types/config.ts` as a new section in `AtlasConfigSchema`:
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
export const AgenticTaskRunnerConfigSchema = z.object({
|
|
40
|
-
cleanupWorkspaces: z.boolean().default(true),
|
|
41
|
-
keepFailedWorkspaces: z.boolean().default(true),
|
|
42
|
-
maxConcurrentAgents: z.number().default(3),
|
|
43
|
-
staleWorkspaceMaxAgeMs: z.number().default(3600_000),
|
|
44
|
-
workspaceBaseDir: z.string().optional(), // defaults to os.tmpdir()
|
|
45
|
-
});
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Add `agenticTasks: AgenticTaskRunnerConfigSchema.default({})` to `AtlasConfigSchema`.
|
|
49
|
-
|
|
50
|
-
**Dependencies**: None — pure type definitions.
|
|
51
|
-
|
|
52
|
-
### 1.2 — WorkspaceManager
|
|
53
|
-
|
|
54
|
-
**File**: `src/workspace/manager.ts` (new)
|
|
55
|
-
|
|
56
|
-
Implement the `WorkspaceManager` class with all methods from the design doc (lines 291-596):
|
|
57
|
-
|
|
58
|
-
- **Creation**: `create(taskType)` — creates `{baseDir}/atlas-workspaces/{taskType}-{timestamp}-{randomId}/` with subdirectories `input/`, `resources/`, `skills/`, `workspace/`, `output/`
|
|
59
|
-
- **Input writers**:
|
|
60
|
-
- `writeInputJson(handle, filename, data)` — JSON files
|
|
61
|
-
- `writeInputJsonl(handle, filename, items)` — JSONL files (one item per line)
|
|
62
|
-
- `writeInputMarkdown(handle, filename, frontmatter, body)` — Markdown with YAML frontmatter
|
|
63
|
-
- `writeInputRaw(handle, filename, content)` — arbitrary files
|
|
64
|
-
- **Skill writers**:
|
|
65
|
-
- `writeSkill(handle, skill)` — writes `skills/{name}/SKILL.md`
|
|
66
|
-
- `writeSkills(handle, skills)` — writes multiple skills in parallel
|
|
67
|
-
- **Resource writers**:
|
|
68
|
-
- `writeResource(handle, resource)` — handles `file`, `symlink`, and `directory` resource types
|
|
69
|
-
- `writeResources(handle, resources)` — writes multiple resources in parallel
|
|
70
|
-
- **Output readers**:
|
|
71
|
-
- `readOutputJson<T>(handle, filename, schema?)` — reads and optionally validates JSON
|
|
72
|
-
- `readOutputJsonl<T>(handle, filename, schema?)` — reads JSONL as array
|
|
73
|
-
- `readOutputMarkdown(handle, filename)` — reads raw markdown
|
|
74
|
-
- `readOutputDir<T>(handle, dirName, schema?)` — reads all JSON files in a directory
|
|
75
|
-
- **Validation**: `validateOutput(handle, config)` — checks required output files exist
|
|
76
|
-
- **Lifecycle**:
|
|
77
|
-
- `cleanup(handle)` — removes workspace directory
|
|
78
|
-
- `listActive()` — scans for active workspaces
|
|
79
|
-
- `pruneStale(maxAgeMs)` — removes old workspaces
|
|
80
|
-
- **Helpers**: `toYamlFrontmatter(data)` — simple YAML serializer for frontmatter
|
|
81
|
-
|
|
82
|
-
**Implementation notes**:
|
|
83
|
-
- Uses `node:fs/promises` (`mkdir`, `writeFile`, `readFile`, `readdir`, `rm`, `symlink`, `cp`, `access`)
|
|
84
|
-
- Uses `node:path` (`join`, `dirname`)
|
|
85
|
-
- Uses `node:crypto` (`randomUUID`) for workspace IDs
|
|
86
|
-
- `baseDir` defaults to `os.tmpdir()`
|
|
87
|
-
|
|
88
|
-
**Tests**: `tests/workspace/manager.test.ts`
|
|
89
|
-
- Test workspace creation and directory structure
|
|
90
|
-
- Test each input writer (JSON, JSONL, markdown, raw)
|
|
91
|
-
- Test skill writing
|
|
92
|
-
- Test resource writing (file, symlink, directory)
|
|
93
|
-
- Test output reading with and without schema validation
|
|
94
|
-
- Test output validation (required vs optional files)
|
|
95
|
-
- Test cleanup and stale pruning
|
|
96
|
-
- Test YAML frontmatter generation with different data types
|
|
97
|
-
|
|
98
|
-
### 1.3 — Playbook-Skill Converter
|
|
99
|
-
|
|
100
|
-
**File**: `src/workspace/skill-converter.ts` (new)
|
|
101
|
-
|
|
102
|
-
Implement bidirectional conversion between Playbooks and Agent Skills (SKILL.md format):
|
|
103
|
-
|
|
104
|
-
- `convertPlaybooksToSkills(playbooks: Playbook[]): AgentSkillSpec[]`
|
|
105
|
-
- `generateSkillMd(playbook: Playbook): string` — renders Playbook as SKILL.md with sections: When to Use, Triggers, Strategy, Tactics, Steps, Example, Verification
|
|
106
|
-
- `parseSkillMdToPlaybook(skillMd: string, skillName: string): Playbook` — parses SKILL.md sections back into Playbook fields
|
|
107
|
-
|
|
108
|
-
This is directly from the design doc (lines 1792-1849).
|
|
109
|
-
|
|
110
|
-
**Tests**: `tests/workspace/skill-converter.test.ts`
|
|
111
|
-
- Test round-trip conversion (Playbook → SKILL.md → Playbook)
|
|
112
|
-
- Test that generated SKILL.md is valid markdown with expected sections
|
|
113
|
-
- Test parsing handles optional sections gracefully
|
|
114
|
-
- Test edge cases: empty tactics, no steps, no code example
|
|
115
|
-
|
|
116
|
-
### 1.4 — AgenticTaskRunner
|
|
117
|
-
|
|
118
|
-
**File**: `src/workspace/runner.ts` (new)
|
|
119
|
-
|
|
120
|
-
Implement the `AgenticTaskRunner` class (design doc lines 604-821):
|
|
121
|
-
|
|
122
|
-
- **Constructor**: Takes `WorkspaceManager`, `AgentManager`, `MemorySystem`, `LearningPipeline`, `AgenticTaskRunnerConfig`
|
|
123
|
-
- **Main method** `run<TInput, TOutput>(template, input)`:
|
|
124
|
-
1. `assessComplexity()` — check if heuristic suffices
|
|
125
|
-
2. If `'heuristic'` + `heuristicFallback` exists → run fallback, return immediately
|
|
126
|
-
3. `workspaceManager.create()` — create workspace
|
|
127
|
-
4. `template.prepareWorkspace()` — populate input files
|
|
128
|
-
5. `workspaceManager.writeSkills()` — load skills
|
|
129
|
-
6. `workspaceManager.writeResources()` — load resources
|
|
130
|
-
7. `getKnowledge()` — query memory for domain + additional knowledge
|
|
131
|
-
8. `agentManager.spawn()` — spawn agent with workspace as cwd
|
|
132
|
-
9. `workspaceManager.validateOutput()` — check required files exist
|
|
133
|
-
10. `collectWithRetry()` — read and validate output
|
|
134
|
-
11. `template.processOutput()` — store/accumulate results
|
|
135
|
-
12. `learningPipeline.processTrajectory()` — meta-learning on analysis agent
|
|
136
|
-
13. Cleanup workspace (in `finally` block)
|
|
137
|
-
- **Private helpers**:
|
|
138
|
-
- `getKnowledge()` — combines domain-scoped query + template-specific additional knowledge via `mergeKnowledge`
|
|
139
|
-
- `collectWithRetry()` — retries output collection on validation failure
|
|
140
|
-
- `getTimeout()` — adjusts timeout based on complexity level
|
|
141
|
-
|
|
142
|
-
**Implementation notes**:
|
|
143
|
-
- The `mergeKnowledge` helper deduplicates playbooks by ID when merging domain + additional knowledge results
|
|
144
|
-
- When `config.keepFailedWorkspaces` is true and the task fails, skip cleanup
|
|
145
|
-
- The runner does NOT manage concurrency in Phase 1 (single-threaded execution). Concurrency limiting (`maxConcurrentAgents`) is deferred to Phase 4.
|
|
146
|
-
|
|
147
|
-
**Tests**: `tests/workspace/runner.test.ts`
|
|
148
|
-
- Test heuristic fallback path (complexity = 'heuristic')
|
|
149
|
-
- Test full agentic path with mock backend and mock template
|
|
150
|
-
- Test workspace lifecycle (created, populated, cleaned up)
|
|
151
|
-
- Test output validation failure handling
|
|
152
|
-
- Test meta-learning (analysis agent trajectory processed)
|
|
153
|
-
- Test knowledge injection (domain + additional merged)
|
|
154
|
-
- Test timeout adjustment by complexity
|
|
155
|
-
- Test failed workspace preservation when `keepFailedWorkspaces` is true
|
|
156
|
-
|
|
157
|
-
### 1.5 — Module Exports & Index
|
|
158
|
-
|
|
159
|
-
**File**: `src/workspace/index.ts` (new)
|
|
160
|
-
|
|
161
|
-
Export all workspace types, classes, and factory functions:
|
|
162
|
-
- `WorkspaceManager`, `createWorkspaceManager`
|
|
163
|
-
- `AgenticTaskRunner`, `createAgenticTaskRunner`
|
|
164
|
-
- `convertPlaybooksToSkills`, `generateSkillMd`, `parseSkillMdToPlaybook`
|
|
165
|
-
- All type exports
|
|
166
|
-
|
|
167
|
-
**File**: `src/index.ts` (modified)
|
|
168
|
-
|
|
169
|
-
Add workspace exports section.
|
|
170
|
-
|
|
171
|
-
### 1.6 — Atlas Integration
|
|
172
|
-
|
|
173
|
-
**File**: `src/atlas.ts` (modified)
|
|
174
|
-
|
|
175
|
-
- Add `private taskRunner: AgenticTaskRunner | null = null` field
|
|
176
|
-
- In constructor or `init()`: if `agentManager` is set, create `AgenticTaskRunner` with workspace manager, agent manager, memory, and learning pipeline
|
|
177
|
-
- Add `getTaskRunner(): AgenticTaskRunner | null` accessor
|
|
178
|
-
- Wire into `AtlasConfig` via the new `agenticTasks` config section
|
|
179
|
-
|
|
180
|
-
**File**: `src/types/config.ts` (modified)
|
|
181
|
-
|
|
182
|
-
- Add `AgenticTaskRunnerConfigSchema` as defined in 1.1
|
|
183
|
-
- Add to `AtlasConfigSchema`
|
|
184
|
-
|
|
185
|
-
No changes to existing `solve()` flow in Phase 1 — the runner is available but not yet used by any templates.
|
|
186
|
-
|
|
187
|
-
### Phase 1 Deliverables
|
|
188
|
-
|
|
189
|
-
| File | Action | Description |
|
|
190
|
-
|------|--------|-------------|
|
|
191
|
-
| `src/workspace/types.ts` | NEW | All workspace type definitions |
|
|
192
|
-
| `src/workspace/manager.ts` | NEW | WorkspaceManager implementation |
|
|
193
|
-
| `src/workspace/skill-converter.ts` | NEW | Playbook ↔ SKILL.md converter |
|
|
194
|
-
| `src/workspace/runner.ts` | NEW | AgenticTaskRunner implementation |
|
|
195
|
-
| `src/workspace/index.ts` | NEW | Module exports |
|
|
196
|
-
| `src/types/config.ts` | MODIFY | Add AgenticTaskRunnerConfig |
|
|
197
|
-
| `src/atlas.ts` | MODIFY | Wire in AgenticTaskRunner |
|
|
198
|
-
| `src/index.ts` | MODIFY | Export workspace module |
|
|
199
|
-
| `tests/workspace/manager.test.ts` | NEW | WorkspaceManager tests |
|
|
200
|
-
| `tests/workspace/skill-converter.test.ts` | NEW | Converter tests |
|
|
201
|
-
| `tests/workspace/runner.test.ts` | NEW | AgenticTaskRunner tests |
|
|
202
|
-
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
## Phase 2: First Templates (Team Analysis)
|
|
206
|
-
|
|
207
|
-
**Objective**: Implement the team analysis and team playbook extraction templates as the first concrete uses of the workspace infrastructure. These are new functionality (no existing code to replace), which makes them ideal for validating the infrastructure end-to-end.
|
|
208
|
-
|
|
209
|
-
### 2.1 — Team Types
|
|
210
|
-
|
|
211
|
-
**File**: `src/types/team-trajectory.ts` (new)
|
|
212
|
-
|
|
213
|
-
Define team trajectory types from `PROPOSAL-team-aware-learning.md`:
|
|
214
|
-
- `TeamEvent`, `TeamEventType`
|
|
215
|
-
- `InteractionEdge`
|
|
216
|
-
- `CoordinationMetrics`
|
|
217
|
-
- `MemberOutcome`
|
|
218
|
-
- `TeamTrajectory`
|
|
219
|
-
- `TeamOutcome`
|
|
220
|
-
|
|
221
|
-
**File**: `src/types/team-playbook.ts` (new)
|
|
222
|
-
|
|
223
|
-
Define team playbook types:
|
|
224
|
-
- `TeamPlaybook`, `TeamPlaybookApplicability`
|
|
225
|
-
- `TeamCompositionGuidance`, `TeamRoleSpec`
|
|
226
|
-
- `TeamCoordinationGuidance`, `TeamChannelSpec`, `InteractionPattern`
|
|
227
|
-
- `TeamPlaybookVerification`, `TeamPlaybookEvolution`, `TeamRefinement`
|
|
228
|
-
- `RolePlaybook`, `RoleInteractionGuidance` (from `DESIGN-team-extraction-pipeline.md`)
|
|
229
|
-
|
|
230
|
-
**File**: `src/types/team-meta.ts` (new)
|
|
231
|
-
|
|
232
|
-
Define team meta-learning types:
|
|
233
|
-
- `TeamMetaObservation`, `FormationObservation`
|
|
234
|
-
- `CompositionObservation`, `CoordinationObservation`
|
|
235
|
-
- `TeamOutcomeObservation`, `TeamLessonsLearned`
|
|
236
|
-
- `TeamMetaStrategy`, `TeamMetaCondition`, `TeamMetaAdjustment`
|
|
237
|
-
|
|
238
|
-
**File**: `src/types/index.ts` (modified)
|
|
239
|
-
|
|
240
|
-
Export all new team types.
|
|
241
|
-
|
|
242
|
-
**File**: `src/types/config.ts` (modified)
|
|
243
|
-
|
|
244
|
-
Add `TeamLearningConfigSchema` from the proposal:
|
|
245
|
-
```typescript
|
|
246
|
-
export const TeamLearningConfigSchema = z.object({
|
|
247
|
-
enabled: z.boolean().default(false),
|
|
248
|
-
minTrajectories: z.number().default(5),
|
|
249
|
-
deduplicationThreshold: z.number().min(0).max(1).default(0.85),
|
|
250
|
-
metricsWeight: z.number().min(0).max(1).default(0.3),
|
|
251
|
-
maxExperiences: z.number().default(200),
|
|
252
|
-
maxPlaybooks: z.number().default(50),
|
|
253
|
-
maxRolePlaybooks: z.number().default(100),
|
|
254
|
-
analysisTimeout: z.number().default(300_000),
|
|
255
|
-
extractionTimeout: z.number().default(600_000),
|
|
256
|
-
});
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
Add `teamLearning: TeamLearningConfigSchema.default({})` to `AtlasConfigSchema`.
|
|
260
|
-
|
|
261
|
-
### 2.2 — Team Analysis Output Schemas
|
|
262
|
-
|
|
263
|
-
**File**: `src/workspace/templates/team-analysis-schemas.ts` (new)
|
|
264
|
-
|
|
265
|
-
Zod schemas for the team analysis agent's output files (from `DESIGN-team-extraction-pipeline.md` lines 518-667):
|
|
266
|
-
- `AgentCreditOutputSchema` — `output/agent-credits.json`
|
|
267
|
-
- `InteractionCreditOutputSchema` — `output/interaction-credits.json`
|
|
268
|
-
- `CoordinationAssessmentOutputSchema` — `output/coordination-assessment.json`
|
|
269
|
-
- `RoleLessonOutputSchema` — `output/role-lessons/{role}.json`
|
|
270
|
-
- `TeamLessonsOutputSchema` — `output/team-lessons.json`
|
|
271
|
-
- `TeamMetaObservationOutputSchema` — `output/meta-observations.json`
|
|
272
|
-
|
|
273
|
-
These schemas validate that the analysis agent produced correctly shaped output.
|
|
274
|
-
|
|
275
|
-
### 2.3 — Team Trajectory Ingester
|
|
276
|
-
|
|
277
|
-
**File**: `src/workspace/templates/team-ingester.ts` (new)
|
|
278
|
-
|
|
279
|
-
Implement `TeamTrajectoryIngester` — the computational preprocessing step (no LLM calls) from `DESIGN-team-extraction-pipeline.md`:
|
|
280
|
-
|
|
281
|
-
```typescript
|
|
282
|
-
class TeamTrajectoryIngester {
|
|
283
|
-
async ingest(input: TeamTrajectoryInput): Promise<IngestResult>
|
|
284
|
-
}
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
The `ingest()` method:
|
|
288
|
-
1. **Build interaction graph** — extract interaction tags from step metadata, group by `interactionId`, link source→target, validate edges, flag expected vs emergent
|
|
289
|
-
2. **Compute structural metrics** — per-agent stats, per-interaction stats, graph-level metrics (density, degree, bottlenecks, parallelism)
|
|
290
|
-
3. **Compress trajectories** — preserve interaction boundary steps at full fidelity, fold internal steps between boundaries, strip verbose output
|
|
291
|
-
4. **Score steps and interactions** — promise + progress + interaction bonus scoring, mark top ~20% as critical
|
|
292
|
-
5. Return `IngestResult` with `TeamTrajectory`, `compressionStats`, `criticalMoments`
|
|
293
|
-
|
|
294
|
-
This is purely computational — no workspace or agent involved yet.
|
|
295
|
-
|
|
296
|
-
**Configuration**: `CompressionConfig` with defaults:
|
|
297
|
-
- `maxTokensPerAgent`: 5000
|
|
298
|
-
- `preserveInteractionBoundaries`: true
|
|
299
|
-
- `foldThreshold`: 5
|
|
300
|
-
- `maxCriticalRatio`: 0.25
|
|
301
|
-
- `criticalStepThreshold`: 0.3
|
|
302
|
-
- `criticalInteractionThreshold`: 0.3
|
|
303
|
-
|
|
304
|
-
**Tests**: `tests/workspace/templates/team-ingester.test.ts`
|
|
305
|
-
- Test interaction graph building from tagged steps
|
|
306
|
-
- Test structural metrics computation
|
|
307
|
-
- Test compression preserves boundary steps
|
|
308
|
-
- Test critical step/interaction scoring
|
|
309
|
-
- Test with minimal (2-agent) and larger (5+ agent) teams
|
|
310
|
-
|
|
311
|
-
### 2.4 — Team Analysis Template
|
|
312
|
-
|
|
313
|
-
**File**: `src/workspace/templates/team-analysis.ts` (new)
|
|
314
|
-
|
|
315
|
-
Implement `teamAnalysisTemplate: AgenticTaskTemplate<TeamAnalysisInput, TeamAnalysisResult>` (design doc lines 1475-1619):
|
|
316
|
-
|
|
317
|
-
- `taskType`: `'team-analysis'`
|
|
318
|
-
- `domain`: `'team-analysis'`
|
|
319
|
-
- `assessComplexity()`: ≤2 members → lightweight, >5 or failed → thorough, else standard
|
|
320
|
-
- No `heuristicFallback` — team analysis always needs semantic understanding
|
|
321
|
-
- `prepareWorkspace()`:
|
|
322
|
-
- Uses the ingester (2.3) to preprocess, then writes compressed trajectories, interaction graph, metrics, context
|
|
323
|
-
- Writes JSONL for per-agent trajectories
|
|
324
|
-
- Writes JSON for interaction graph, timeline, structural metrics
|
|
325
|
-
- Writes markdown context doc with YAML frontmatter
|
|
326
|
-
- `buildTaskPrompt()`: natural language instructions for the analysis agent
|
|
327
|
-
- `getSkills()`: converts team analysis playbooks to SKILL.md
|
|
328
|
-
- `getResources()`: optional codebase snapshot symlink
|
|
329
|
-
- `outputConfig`: defines required output files (agent-credits.json, interaction-credits.json, coordination-assessment.md, lessons.json)
|
|
330
|
-
- `collectOutput()`: reads and validates all output files against Zod schemas
|
|
331
|
-
- `processOutput()`: stores results in team memory (deferred to Phase 2.6), accumulates for batch extraction
|
|
332
|
-
|
|
333
|
-
**Tests**: `tests/workspace/templates/team-analysis.test.ts`
|
|
334
|
-
- Test complexity assessment for different team sizes/outcomes
|
|
335
|
-
- Test workspace preparation produces expected file structure
|
|
336
|
-
- Test task prompt includes workspace file paths
|
|
337
|
-
- Test output collection with valid and invalid outputs
|
|
338
|
-
|
|
339
|
-
### 2.5 — Team Playbook Extraction Template
|
|
340
|
-
|
|
341
|
-
**File**: `src/workspace/templates/team-playbook-extraction.ts` (new)
|
|
342
|
-
|
|
343
|
-
Implement `teamPlaybookExtractionTemplate: AgenticTaskTemplate<TeamPlaybookExtractionInput, ExtractedTeamPlaybooks>` (design doc lines 1625-1783):
|
|
344
|
-
|
|
345
|
-
- `taskType`: `'team-playbook-extraction'`
|
|
346
|
-
- `domain`: `'team-playbook-extraction'`
|
|
347
|
-
- `timeout`: 600_000 (10 minutes)
|
|
348
|
-
- `assessComplexity()`: always agentic, >10 batches → thorough, else standard
|
|
349
|
-
- `prepareWorkspace()`:
|
|
350
|
-
- Writes batch summary markdown with frontmatter
|
|
351
|
-
- Writes each lesson batch as markdown
|
|
352
|
-
- Writes existing team/role playbooks for deduplication
|
|
353
|
-
- `buildTaskPrompt()`: instructions for extracting role, team coordination, and meta-strategy playbooks
|
|
354
|
-
- `outputConfig`: team-playbooks/, role-playbooks/, team-skills/, role-skills/, updates/, meta-strategies/, extraction-summary.json
|
|
355
|
-
- `collectOutput()`: reads all output directories
|
|
356
|
-
- `processOutput()`: stores new playbooks and meta-strategies
|
|
357
|
-
|
|
358
|
-
**Tests**: `tests/workspace/templates/team-playbook-extraction.test.ts`
|
|
359
|
-
- Test complexity assessment
|
|
360
|
-
- Test workspace preparation
|
|
361
|
-
- Test output collection from multiple output directories
|
|
362
|
-
|
|
363
|
-
### 2.6 — Team Memory System
|
|
364
|
-
|
|
365
|
-
**File**: `src/memory/team-experience.ts` (new)
|
|
366
|
-
|
|
367
|
-
Implement `TeamExperienceMemory` — stores team trajectories and analysis results. Mirrors `ExperienceMemory` but for team data.
|
|
368
|
-
|
|
369
|
-
- JSON file-based persistence under `{baseDir}/team-experiences/`
|
|
370
|
-
- `store(teamTrajectory, analysis)` — save team experience
|
|
371
|
-
- `findSimilar(query, options)` — BM25 search over team experiences
|
|
372
|
-
- `getByDomain(domain)` — domain-scoped retrieval
|
|
373
|
-
- `count()`, `getAll()`, `prune()` — standard memory operations
|
|
374
|
-
|
|
375
|
-
**File**: `src/memory/team-playbook.ts` (new)
|
|
376
|
-
|
|
377
|
-
Implement `TeamPlaybookLibrary` and `RolePlaybookLibrary`:
|
|
378
|
-
|
|
379
|
-
- `TeamPlaybookLibrary` — stores/retrieves `TeamPlaybook` objects
|
|
380
|
-
- JSON file-based persistence under `{baseDir}/team-playbooks/`
|
|
381
|
-
- `findMatching(query)` — find team playbooks matching a task
|
|
382
|
-
- `add()`, `get()`, `getAll()`, `delete()`, `count()`
|
|
383
|
-
- `recordSuccess()`, `recordFailure()` — evolution tracking
|
|
384
|
-
|
|
385
|
-
- `RolePlaybookLibrary` — stores/retrieves `RolePlaybook` objects
|
|
386
|
-
- JSON file-based persistence under `{baseDir}/role-playbooks/`
|
|
387
|
-
- `findForRole(role, topology, domain)` — find role guidance
|
|
388
|
-
- `add()`, `get()`, `getAll()`, `delete()`, `count()`
|
|
389
|
-
|
|
390
|
-
**File**: `src/memory/team-meta.ts` (new)
|
|
391
|
-
|
|
392
|
-
Implement `TeamMetaMemory`:
|
|
393
|
-
- Stores `TeamMetaObservation` and `TeamMetaStrategy`
|
|
394
|
-
- JSON file-based persistence under `{baseDir}/team-meta-observations/` and `{baseDir}/team-meta-strategies/`
|
|
395
|
-
- `recordObservation()`, `getObservations()`
|
|
396
|
-
- `storeMetaStrategy()`, `getStrategies()`
|
|
397
|
-
|
|
398
|
-
**File**: `src/memory/system.ts` (modified)
|
|
399
|
-
|
|
400
|
-
Extend `MemorySystem` with optional team memory fields:
|
|
401
|
-
```typescript
|
|
402
|
-
public readonly teamExperiences?: TeamExperienceMemory;
|
|
403
|
-
public readonly teamPlaybooks?: TeamPlaybookLibrary;
|
|
404
|
-
public readonly rolePlaybooks?: RolePlaybookLibrary;
|
|
405
|
-
public readonly teamMeta?: TeamMetaMemory;
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
Initialize these when `teamLearning.enabled` is true in config.
|
|
409
|
-
|
|
410
|
-
**Tests**: `tests/memory/team-experience.test.ts`, `tests/memory/team-playbook.test.ts`, `tests/memory/team-meta.test.ts`
|
|
411
|
-
|
|
412
|
-
### 2.7 — Team Learning Pipeline
|
|
413
|
-
|
|
414
|
-
**File**: `src/learning/team-pipeline.ts` (new)
|
|
415
|
-
|
|
416
|
-
Implement `TeamLearningPipeline` (from `DESIGN-team-extraction-pipeline.md` lines 1144-1213):
|
|
417
|
-
|
|
418
|
-
```typescript
|
|
419
|
-
class TeamLearningPipeline {
|
|
420
|
-
async processTeamTrajectory(input: TeamTrajectoryInput): Promise<TeamProcessResult>
|
|
421
|
-
async runBatchLearning(): Promise<TeamBatchResult>
|
|
422
|
-
isBatchReady(): boolean
|
|
423
|
-
getAccumulatedCount(): number
|
|
424
|
-
}
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
- `processTeamTrajectory()`:
|
|
428
|
-
1. Ingest via `TeamTrajectoryIngester` (preprocess + compress)
|
|
429
|
-
2. Run `teamAnalysisTemplate` through `AgenticTaskRunner`
|
|
430
|
-
3. Store results, accumulate for batch extraction
|
|
431
|
-
4. Analysis agent's trajectory is automatically processed for meta-learning (done by the runner)
|
|
432
|
-
|
|
433
|
-
- `runBatchLearning()`:
|
|
434
|
-
1. Check `accumulated.length >= config.minTeamTrajectories`
|
|
435
|
-
2. Run `teamPlaybookExtractionTemplate` through `AgenticTaskRunner`
|
|
436
|
-
3. Store extracted team/role playbooks
|
|
437
|
-
4. Clear accumulated
|
|
438
|
-
|
|
439
|
-
**Tests**: `tests/learning/team-pipeline.test.ts`
|
|
440
|
-
|
|
441
|
-
### 2.8 — Atlas Team Methods
|
|
442
|
-
|
|
443
|
-
**File**: `src/atlas.ts` (modified)
|
|
444
|
-
|
|
445
|
-
Add team-aware methods:
|
|
446
|
-
- `processTeamTrajectory(input)` — delegates to `TeamLearningPipeline`
|
|
447
|
-
- `runTeamBatchLearning()` — delegates to pipeline
|
|
448
|
-
- Wire `TeamLearningPipeline` into constructor when team learning is enabled
|
|
449
|
-
- Update `getStats()` to include team memory stats
|
|
450
|
-
|
|
451
|
-
**File**: `src/index.ts` (modified)
|
|
452
|
-
|
|
453
|
-
Export team types and pipeline.
|
|
454
|
-
|
|
455
|
-
### Phase 2 Deliverables
|
|
456
|
-
|
|
457
|
-
| File | Action | Description |
|
|
458
|
-
|------|--------|-------------|
|
|
459
|
-
| `src/types/team-trajectory.ts` | NEW | Team trajectory types |
|
|
460
|
-
| `src/types/team-playbook.ts` | NEW | Team/role playbook types |
|
|
461
|
-
| `src/types/team-meta.ts` | NEW | Team meta-learning types |
|
|
462
|
-
| `src/types/config.ts` | MODIFY | Add TeamLearningConfig |
|
|
463
|
-
| `src/types/index.ts` | MODIFY | Export team types |
|
|
464
|
-
| `src/workspace/templates/team-analysis-schemas.ts` | NEW | Output Zod schemas |
|
|
465
|
-
| `src/workspace/templates/team-ingester.ts` | NEW | Computational preprocessor |
|
|
466
|
-
| `src/workspace/templates/team-analysis.ts` | NEW | Team analysis template |
|
|
467
|
-
| `src/workspace/templates/team-playbook-extraction.ts` | NEW | Team playbook extraction template |
|
|
468
|
-
| `src/memory/team-experience.ts` | NEW | Team experience memory |
|
|
469
|
-
| `src/memory/team-playbook.ts` | NEW | Team/role playbook libraries |
|
|
470
|
-
| `src/memory/team-meta.ts` | NEW | Team meta-observation memory |
|
|
471
|
-
| `src/memory/system.ts` | MODIFY | Add optional team fields |
|
|
472
|
-
| `src/learning/team-pipeline.ts` | NEW | Team learning pipeline |
|
|
473
|
-
| `src/atlas.ts` | MODIFY | Add team methods |
|
|
474
|
-
| `src/index.ts` | MODIFY | Export team modules |
|
|
475
|
-
| `tests/workspace/templates/team-ingester.test.ts` | NEW | Ingester tests |
|
|
476
|
-
| `tests/workspace/templates/team-analysis.test.ts` | NEW | Analysis template tests |
|
|
477
|
-
| `tests/workspace/templates/team-playbook-extraction.test.ts` | NEW | Extraction template tests |
|
|
478
|
-
| `tests/memory/team-experience.test.ts` | NEW | Team memory tests |
|
|
479
|
-
| `tests/memory/team-playbook.test.ts` | NEW | Team playbook tests |
|
|
480
|
-
| `tests/memory/team-meta.test.ts` | NEW | Team meta tests |
|
|
481
|
-
| `tests/learning/team-pipeline.test.ts` | NEW | Pipeline tests |
|
|
482
|
-
|
|
483
|
-
---
|
|
484
|
-
|
|
485
|
-
## Phase 3: Migrate Existing Analysis
|
|
486
|
-
|
|
487
|
-
**Objective**: Create templates for existing analysis points, preserving current heuristics as fallbacks. Each migration follows the same pattern: wrap the existing analyzer as `heuristicFallback`, implement `prepareWorkspace` + `buildTaskPrompt` + `collectOutput` for the agentic path.
|
|
488
|
-
|
|
489
|
-
### 3.1 — Trajectory Analysis Template
|
|
490
|
-
|
|
491
|
-
**File**: `src/workspace/templates/trajectory-analysis.ts` (new)
|
|
492
|
-
|
|
493
|
-
Wraps existing `TrajectoryAnalyzer` (from `src/learning/analyzer.ts`):
|
|
494
|
-
|
|
495
|
-
- `heuristicFallback`: delegates to existing `TrajectoryAnalyzer.analyze()`
|
|
496
|
-
- `assessComplexity`: ≤5 steps + success → heuristic; failed or >20 steps → standard; else lightweight
|
|
497
|
-
- `prepareWorkspace`: writes trajectory as JSONL, context as markdown with frontmatter
|
|
498
|
-
- `outputConfig`: `analysis.json` (required)
|
|
499
|
-
- `collectOutput`: reads and validates against `AnalysisResultSchema`
|
|
500
|
-
|
|
501
|
-
**File**: `src/learning/pipeline.ts` (modified)
|
|
502
|
-
|
|
503
|
-
Update `processTrajectory()` to optionally route through `AgenticTaskRunner` when available:
|
|
504
|
-
```typescript
|
|
505
|
-
if (this.taskRunner) {
|
|
506
|
-
const { output: analysis } = await this.taskRunner.run(
|
|
507
|
-
trajectoryAnalysisTemplate, { trajectory, creditStrategy }
|
|
508
|
-
);
|
|
509
|
-
} else {
|
|
510
|
-
const analysis = await this.analyzer.analyze(trajectory);
|
|
511
|
-
}
|
|
512
|
-
```
|
|
513
|
-
|
|
514
|
-
Add `setTaskRunner(runner)` method to accept the runner reference.
|
|
515
|
-
|
|
516
|
-
### 3.2 — Playbook Extraction Template
|
|
517
|
-
|
|
518
|
-
**File**: `src/workspace/templates/playbook-extraction.ts` (new)
|
|
519
|
-
|
|
520
|
-
Wraps existing `PlaybookExtractor` + `LLMPlaybookExtractor`:
|
|
521
|
-
|
|
522
|
-
- `heuristicFallback`: delegates to existing `PlaybookExtractor.extract()`
|
|
523
|
-
- `assessComplexity`: ≤3 trajectories → heuristic; >10 → thorough; else standard
|
|
524
|
-
- `prepareWorkspace`: writes batch summary, trajectories as JSONL, analyses as JSON, existing playbooks for dedup
|
|
525
|
-
- `timeout`: 300_000 (5 min)
|
|
526
|
-
- `outputConfig`: playbooks/ (optional), skills/ (optional), updates/ (optional), extraction-summary.json (required)
|
|
527
|
-
- `collectOutput`: reads playbooks, skills, updates directories
|
|
528
|
-
|
|
529
|
-
**File**: `src/learning/pipeline.ts` (modified)
|
|
530
|
-
|
|
531
|
-
Update `runBatchLearning()` to optionally route through runner.
|
|
532
|
-
|
|
533
|
-
### 3.3 — Meta-Learning Reflection Template
|
|
534
|
-
|
|
535
|
-
**File**: `src/workspace/templates/meta-reflection.ts` (new)
|
|
536
|
-
|
|
537
|
-
Wraps existing `MetaLearner.generateReflection()`:
|
|
538
|
-
|
|
539
|
-
- `heuristicFallback`: existing `MetaLearner` logic
|
|
540
|
-
- `assessComplexity`: success + high confidence → heuristic; else lightweight
|
|
541
|
-
- `prepareWorkspace`: trajectory as JSONL, context with routing decision + injected playbooks as markdown
|
|
542
|
-
- `outputConfig`: `meta-observation.json` (required)
|
|
543
|
-
|
|
544
|
-
### 3.4 — Usage Inference Template
|
|
545
|
-
|
|
546
|
-
**File**: `src/workspace/templates/usage-inference.ts` (new)
|
|
547
|
-
|
|
548
|
-
Wraps existing `PlaybookUsageInference`:
|
|
549
|
-
|
|
550
|
-
- `heuristicFallback`: existing word-overlap matching
|
|
551
|
-
- `assessComplexity`: no playbooks → heuristic; ≤2 playbooks + short trajectory → heuristic; else lightweight
|
|
552
|
-
- `prepareWorkspace`: trajectory as JSONL, each playbook as markdown
|
|
553
|
-
- `outputConfig`: `usage-results.json` (required)
|
|
554
|
-
|
|
555
|
-
### 3.5 — Solution Evaluation Template
|
|
556
|
-
|
|
557
|
-
**File**: `src/workspace/templates/solution-evaluation.ts` (new)
|
|
558
|
-
|
|
559
|
-
Enhances existing `SolutionEvaluator` Tier 2:
|
|
560
|
-
|
|
561
|
-
- `heuristicFallback`: existing Tier 1 (verification) + Tier 3 (heuristic) logic
|
|
562
|
-
- `assessComplexity`: has programmatic verification → heuristic; short success → lightweight; else standard
|
|
563
|
-
- `getResources`: optional codebase symlink for verification
|
|
564
|
-
- `outputConfig`: `evaluation.json` (required)
|
|
565
|
-
|
|
566
|
-
### Phase 3 Deliverables
|
|
567
|
-
|
|
568
|
-
| File | Action | Description |
|
|
569
|
-
|------|--------|-------------|
|
|
570
|
-
| `src/workspace/templates/trajectory-analysis.ts` | NEW | Trajectory analysis template |
|
|
571
|
-
| `src/workspace/templates/playbook-extraction.ts` | NEW | Playbook extraction template |
|
|
572
|
-
| `src/workspace/templates/meta-reflection.ts` | NEW | Meta-reflection template |
|
|
573
|
-
| `src/workspace/templates/usage-inference.ts` | NEW | Usage inference template |
|
|
574
|
-
| `src/workspace/templates/solution-evaluation.ts` | NEW | Solution evaluation template |
|
|
575
|
-
| `src/learning/pipeline.ts` | MODIFY | Route through runner when available |
|
|
576
|
-
| `tests/workspace/templates/trajectory-analysis.test.ts` | NEW | Tests |
|
|
577
|
-
| `tests/workspace/templates/playbook-extraction.test.ts` | NEW | Tests |
|
|
578
|
-
| `tests/workspace/templates/meta-reflection.test.ts` | NEW | Tests |
|
|
579
|
-
| `tests/workspace/templates/usage-inference.test.ts` | NEW | Tests |
|
|
580
|
-
| `tests/workspace/templates/solution-evaluation.test.ts` | NEW | Tests |
|
|
581
|
-
|
|
582
|
-
---
|
|
583
|
-
|
|
584
|
-
## Phase 4: Tuning & Robustness
|
|
585
|
-
|
|
586
|
-
**Objective**: Add production-readiness features — concurrency control, monitoring, and cost optimization.
|
|
587
|
-
|
|
588
|
-
### 4.1 — Concurrency Limiting
|
|
589
|
-
|
|
590
|
-
Add a semaphore to `AgenticTaskRunner` that limits concurrent agent spawns to `config.maxConcurrentAgents`. Use a simple queue-based approach:
|
|
591
|
-
|
|
592
|
-
```typescript
|
|
593
|
-
class AgenticTaskRunner {
|
|
594
|
-
private activeCount = 0;
|
|
595
|
-
private queue: Array<() => void> = [];
|
|
596
|
-
|
|
597
|
-
private async acquireSlot(): Promise<void> { ... }
|
|
598
|
-
private releaseSlot(): void { ... }
|
|
599
|
-
}
|
|
600
|
-
```
|
|
601
|
-
|
|
602
|
-
### 4.2 — Workspace Monitoring
|
|
603
|
-
|
|
604
|
-
Add `AgenticTaskRunner.getActiveWorkspaces()` for debugging/monitoring. Include metrics: task type, start time, elapsed time, agent status.
|
|
605
|
-
|
|
606
|
-
Add periodic stale workspace cleanup (driven by the runner config `staleWorkspaceMaxAgeMs`).
|
|
607
|
-
|
|
608
|
-
### 4.3 — Cost Tracking
|
|
609
|
-
|
|
610
|
-
Add per-template cost tracking to `AgenticTaskResult`:
|
|
611
|
-
- Estimated token usage (from agent metrics)
|
|
612
|
-
- Whether heuristic or agentic path was used
|
|
613
|
-
- Complexity assessment
|
|
614
|
-
|
|
615
|
-
Aggregate statistics available via `Atlas.getStats()`.
|
|
616
|
-
|
|
617
|
-
### 4.4 — Complexity Threshold Calibration
|
|
618
|
-
|
|
619
|
-
After accumulating real usage data, refine `assessComplexity` thresholds:
|
|
620
|
-
- Track quality difference between heuristic and agentic paths
|
|
621
|
-
- Identify cases where heuristic is sufficient (save cost)
|
|
622
|
-
- Identify cases where agentic adds clear value (justify cost)
|
|
623
|
-
|
|
624
|
-
This is data-driven tuning, not code changes per se.
|
|
625
|
-
|
|
626
|
-
---
|
|
627
|
-
|
|
628
|
-
## Implementation Order & Dependencies
|
|
629
|
-
|
|
630
|
-
```
|
|
631
|
-
Phase 1.1 (types) ──────────────────────────────────────────┐
|
|
632
|
-
Phase 1.2 (WorkspaceManager) ──────┐ │
|
|
633
|
-
Phase 1.3 (skill converter) ───────┤ │
|
|
634
|
-
▼ ▼
|
|
635
|
-
Phase 1.4 (AgenticTaskRunner) ──── needs 1.1, 1.2, 1.3 ───►│
|
|
636
|
-
Phase 1.5 (exports) ──────────────────────────────────────── │
|
|
637
|
-
Phase 1.6 (Atlas integration) ──── needs 1.4 ──────────────►│
|
|
638
|
-
│
|
|
639
|
-
Phase 2.1 (team types) ────────────────────────────────────┐ │
|
|
640
|
-
Phase 2.2 (output schemas) ───────────────────────────────┐│ │
|
|
641
|
-
Phase 2.3 (ingester) ──────────── needs 2.1 ─────────────►││ │
|
|
642
|
-
Phase 2.4 (team analysis template) needs 1.4, 2.1-2.3 ───►│└►│
|
|
643
|
-
Phase 2.5 (team extraction template) needs 1.4, 2.1-2.2 ──┘ │
|
|
644
|
-
Phase 2.6 (team memory) ──────── needs 2.1 ──────────────────►│
|
|
645
|
-
Phase 2.7 (team pipeline) ────── needs 2.3-2.6 ──────────────►│
|
|
646
|
-
Phase 2.8 (Atlas team methods) ── needs 2.7 ──────────────────►│
|
|
647
|
-
│
|
|
648
|
-
Phase 3.1-3.5 (existing templates) needs Phase 1 ─────────────►
|
|
649
|
-
Phase 4 (tuning) ──────────────── needs Phase 1-3 ─────────────►
|
|
650
|
-
```
|
|
651
|
-
|
|
652
|
-
**Recommended implementation sequence within each phase**:
|
|
653
|
-
- Phase 1: 1.1 → 1.2 + 1.3 (parallel) → 1.4 → 1.5 + 1.6 (parallel)
|
|
654
|
-
- Phase 2: 2.1 + 2.2 (parallel) → 2.3 + 2.6 (parallel) → 2.4 + 2.5 (parallel) → 2.7 → 2.8
|
|
655
|
-
- Phase 3: 3.1 → 3.2 → 3.3 + 3.4 + 3.5 (parallel, independent)
|
|
656
|
-
- Phase 4: 4.1 → 4.2 + 4.3 (parallel) → 4.4
|
|
657
|
-
|
|
658
|
-
---
|
|
659
|
-
|
|
660
|
-
## Testing Strategy
|
|
661
|
-
|
|
662
|
-
### Unit Tests
|
|
663
|
-
|
|
664
|
-
Each new file gets a corresponding test file. Tests use:
|
|
665
|
-
- **Vitest** (existing test framework)
|
|
666
|
-
- **MockBackend** (existing `src/runtime/backends/mock.ts`) for agent spawning
|
|
667
|
-
- **In-memory filesystem** or temp directories for workspace tests
|
|
668
|
-
- **Zod schemas** for output validation
|
|
669
|
-
|
|
670
|
-
### Integration Tests
|
|
671
|
-
|
|
672
|
-
**File**: `tests/integration/workspace-e2e.test.ts` (new)
|
|
673
|
-
|
|
674
|
-
End-to-end test that:
|
|
675
|
-
1. Creates an `Atlas` instance with mock backend
|
|
676
|
-
2. Runs a template through `AgenticTaskRunner`
|
|
677
|
-
3. Verifies workspace was created, populated, and cleaned up
|
|
678
|
-
4. Verifies output was collected and processed
|
|
679
|
-
5. Verifies meta-learning captured the analysis agent's trajectory
|
|
680
|
-
|
|
681
|
-
**File**: `tests/integration/team-learning-e2e.test.ts` (new)
|
|
682
|
-
|
|
683
|
-
End-to-end test for team learning:
|
|
684
|
-
1. Creates team trajectory input with multiple members
|
|
685
|
-
2. Processes through `TeamLearningPipeline`
|
|
686
|
-
3. Verifies team experience stored
|
|
687
|
-
4. Accumulates multiple executions
|
|
688
|
-
5. Triggers batch extraction
|
|
689
|
-
6. Verifies team playbooks created
|
|
690
|
-
|
|
691
|
-
### Test Approach
|
|
692
|
-
|
|
693
|
-
- Tests for templates use mock templates with simple input/output types to test the runner independently from any specific analysis logic
|
|
694
|
-
- Tests for the ingester use synthetic team trajectory data with known patterns
|
|
695
|
-
- All tests are designed to run without network access or LLM calls
|
|
696
|
-
|
|
697
|
-
---
|
|
698
|
-
|
|
699
|
-
## Risk Mitigation
|
|
700
|
-
|
|
701
|
-
| Risk | Mitigation |
|
|
702
|
-
|------|-----------|
|
|
703
|
-
| Agent doesn't produce valid output | `collectWithRetry` + `outputConfig` validation + graceful fallback to heuristic |
|
|
704
|
-
| Workspace cleanup fails | `finally` block + periodic stale pruning |
|
|
705
|
-
| Cost explosion from excessive agentic analysis | `assessComplexity` gates most inputs to heuristic path |
|
|
706
|
-
| Team types conflict with existing types | Team types are in separate files, no naming conflicts |
|
|
707
|
-
| `AgentManager.spawn()` API mismatch | Runner wraps spawn, adapter layer isolates changes |
|
|
708
|
-
| Circular dependency (runner → pipeline → runner) | Pipeline receives runner via `setTaskRunner()` setter, not constructor |
|
|
709
|
-
|
|
710
|
-
---
|
|
711
|
-
|
|
712
|
-
## Open Questions for Later
|
|
713
|
-
|
|
714
|
-
1. **Concurrency model**: Should the runner use a work-stealing queue or simple semaphore? (Start simple in Phase 4.1)
|
|
715
|
-
2. **Workspace persistence**: Should successful analysis workspaces be archived for debugging? (Default: no, but `keepFailedWorkspaces` covers failure cases)
|
|
716
|
-
3. **Cross-template knowledge**: Should playbooks from one analysis domain inform another? (The domain-scoped memory query handles this automatically)
|
|
717
|
-
4. **Streaming output**: Should the runner support streaming partial results from long-running analysis agents? (Not in scope for initial implementation)
|