cognitive-core 0.2.4 → 0.3.1
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/LICENSE +21 -0
- package/README.md +88 -143
- package/dist/agents/mock-provider.d.ts.map +1 -1
- package/dist/agents/mock-provider.js.map +1 -1
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/types.js +5 -4
- package/dist/agents/types.js.map +1 -1
- package/dist/atlas.d.ts +309 -97
- package/dist/atlas.d.ts.map +1 -1
- package/dist/atlas.js +743 -277
- package/dist/atlas.js.map +1 -1
- package/dist/bin/cli-utils.d.ts +25 -2
- package/dist/bin/cli-utils.d.ts.map +1 -1
- package/dist/bin/cli-utils.js +79 -9
- package/dist/bin/cli-utils.js.map +1 -1
- package/dist/bin/cognitive-core.js +32 -0
- package/dist/bin/cognitive-core.js.map +1 -1
- package/dist/bin/commands/dream.d.ts +17 -0
- package/dist/bin/commands/dream.d.ts.map +1 -0
- package/dist/bin/commands/dream.js +168 -0
- package/dist/bin/commands/dream.js.map +1 -0
- package/dist/bin/commands/eval.d.ts +181 -0
- package/dist/bin/commands/eval.d.ts.map +1 -0
- package/dist/bin/commands/eval.js +1582 -0
- package/dist/bin/commands/eval.js.map +1 -0
- package/dist/bin/commands/kb.js +0 -8
- package/dist/bin/commands/kb.js.map +1 -1
- package/dist/bin/commands/learn.js +12 -4
- package/dist/bin/commands/learn.js.map +1 -1
- package/dist/bin/commands/legacy.d.ts.map +1 -1
- package/dist/bin/commands/legacy.js +1 -1
- package/dist/bin/commands/legacy.js.map +1 -1
- package/dist/bin/commands/run.d.ts.map +1 -1
- package/dist/bin/commands/run.js +10 -9
- package/dist/bin/commands/run.js.map +1 -1
- package/dist/bin/commands/sessions.d.ts.map +1 -1
- package/dist/bin/commands/sessions.js.map +1 -1
- package/dist/bin/commands/skills.d.ts.map +1 -1
- package/dist/bin/commands/skills.js +283 -1
- package/dist/bin/commands/skills.js.map +1 -1
- package/dist/embeddings/bm25.d.ts.map +1 -1
- package/dist/embeddings/bm25.js +1 -2
- package/dist/embeddings/bm25.js.map +1 -1
- package/dist/embeddings/index.d.ts +3 -3
- package/dist/embeddings/index.d.ts.map +1 -1
- package/dist/embeddings/index.js +3 -3
- package/dist/embeddings/index.js.map +1 -1
- package/dist/embeddings/inverted-index.js +62 -7
- package/dist/embeddings/inverted-index.js.map +1 -1
- package/dist/embeddings/manager.d.ts.map +1 -1
- package/dist/embeddings/manager.js +6 -5
- package/dist/embeddings/manager.js.map +1 -1
- package/dist/embeddings/provider.d.ts +96 -5
- package/dist/embeddings/provider.d.ts.map +1 -1
- package/dist/embeddings/provider.js +171 -48
- package/dist/embeddings/provider.js.map +1 -1
- package/dist/embeddings/vector-store.d.ts.map +1 -1
- package/dist/embeddings/vector-store.js +3 -1
- package/dist/embeddings/vector-store.js.map +1 -1
- package/dist/eval/ablation-validate.d.ts +12 -0
- package/dist/eval/ablation-validate.d.ts.map +1 -0
- package/dist/eval/ablation-validate.js +78 -0
- package/dist/eval/ablation-validate.js.map +1 -0
- package/dist/eval/ablation.d.ts +94 -0
- package/dist/eval/ablation.d.ts.map +1 -0
- package/dist/eval/ablation.js +161 -0
- package/dist/eval/ablation.js.map +1 -0
- package/dist/eval/ci-smoke.d.ts +11 -0
- package/dist/eval/ci-smoke.d.ts.map +1 -0
- package/dist/eval/ci-smoke.js +49 -0
- package/dist/eval/ci-smoke.js.map +1 -0
- package/dist/eval/diagnostics.d.ts +214 -0
- package/dist/eval/diagnostics.d.ts.map +1 -0
- package/dist/eval/diagnostics.js +107 -0
- package/dist/eval/diagnostics.js.map +1 -0
- package/dist/eval/index.d.ts +27 -0
- package/dist/eval/index.d.ts.map +1 -0
- package/dist/eval/index.js +27 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/eval/live/alfworld.d.ts +248 -0
- package/dist/eval/live/alfworld.d.ts.map +1 -0
- package/dist/eval/live/alfworld.js +637 -0
- package/dist/eval/live/alfworld.js.map +1 -0
- package/dist/eval/live/alfworld_h1.d.ts +16 -0
- package/dist/eval/live/alfworld_h1.d.ts.map +1 -0
- package/dist/eval/live/alfworld_h1.js +75 -0
- package/dist/eval/live/alfworld_h1.js.map +1 -0
- package/dist/eval/live/alfworld_memory.d.ts +38 -0
- package/dist/eval/live/alfworld_memory.d.ts.map +1 -0
- package/dist/eval/live/alfworld_memory.js +184 -0
- package/dist/eval/live/alfworld_memory.js.map +1 -0
- package/dist/eval/live/alfworld_strategy.d.ts +65 -0
- package/dist/eval/live/alfworld_strategy.d.ts.map +1 -0
- package/dist/eval/live/alfworld_strategy.js +89 -0
- package/dist/eval/live/alfworld_strategy.js.map +1 -0
- package/dist/eval/live/azure-openai-llm-provider.d.ts +41 -0
- package/dist/eval/live/azure-openai-llm-provider.d.ts.map +1 -0
- package/dist/eval/live/azure-openai-llm-provider.js +92 -0
- package/dist/eval/live/azure-openai-llm-provider.js.map +1 -0
- package/dist/eval/live/bridges/skillflow_e2b_bridge.d.ts +3 -0
- package/dist/eval/live/bridges/skillflow_e2b_bridge.d.ts.map +1 -0
- package/dist/eval/live/bridges/skillflow_e2b_bridge.js +12 -0
- package/dist/eval/live/bridges/skillflow_e2b_bridge.js.map +1 -0
- package/dist/eval/live/claude-cli-llm-provider.d.ts +53 -0
- package/dist/eval/live/claude-cli-llm-provider.d.ts.map +1 -0
- package/dist/eval/live/claude-cli-llm-provider.js +71 -0
- package/dist/eval/live/claude-cli-llm-provider.js.map +1 -0
- package/dist/eval/live/claude-cli.d.ts +96 -0
- package/dist/eval/live/claude-cli.d.ts.map +1 -0
- package/dist/eval/live/claude-cli.js +314 -0
- package/dist/eval/live/claude-cli.js.map +1 -0
- package/dist/eval/live/claude-delegate.d.ts +41 -0
- package/dist/eval/live/claude-delegate.d.ts.map +1 -0
- package/dist/eval/live/claude-delegate.js +59 -0
- package/dist/eval/live/claude-delegate.js.map +1 -0
- package/dist/eval/live/claude-workspace-backend.d.ts +24 -0
- package/dist/eval/live/claude-workspace-backend.d.ts.map +1 -0
- package/dist/eval/live/claude-workspace-backend.js +76 -0
- package/dist/eval/live/claude-workspace-backend.js.map +1 -0
- package/dist/eval/live/clbench.d.ts +64 -0
- package/dist/eval/live/clbench.d.ts.map +1 -0
- package/dist/eval/live/clbench.js +291 -0
- package/dist/eval/live/clbench.js.map +1 -0
- package/dist/eval/live/cold-reuse.d.ts +21 -0
- package/dist/eval/live/cold-reuse.d.ts.map +1 -0
- package/dist/eval/live/cold-reuse.js +102 -0
- package/dist/eval/live/cold-reuse.js.map +1 -0
- package/dist/eval/live/difficulty-registry.d.ts +68 -0
- package/dist/eval/live/difficulty-registry.d.ts.map +1 -0
- package/dist/eval/live/difficulty-registry.js +169 -0
- package/dist/eval/live/difficulty-registry.js.map +1 -0
- package/dist/eval/live/docker.d.ts +52 -0
- package/dist/eval/live/docker.d.ts.map +1 -0
- package/dist/eval/live/docker.js +164 -0
- package/dist/eval/live/docker.js.map +1 -0
- package/dist/eval/live/env-bridge.d.ts +68 -0
- package/dist/eval/live/env-bridge.d.ts.map +1 -0
- package/dist/eval/live/env-bridge.js +188 -0
- package/dist/eval/live/env-bridge.js.map +1 -0
- package/dist/eval/live/gsm8k.d.ts +44 -0
- package/dist/eval/live/gsm8k.d.ts.map +1 -0
- package/dist/eval/live/gsm8k.js +142 -0
- package/dist/eval/live/gsm8k.js.map +1 -0
- package/dist/eval/live/index.d.ts +38 -0
- package/dist/eval/live/index.d.ts.map +1 -0
- package/dist/eval/live/index.js +38 -0
- package/dist/eval/live/index.js.map +1 -0
- package/dist/eval/live/lifelongagent.d.ts +64 -0
- package/dist/eval/live/lifelongagent.d.ts.map +1 -0
- package/dist/eval/live/lifelongagent.js +216 -0
- package/dist/eval/live/lifelongagent.js.map +1 -0
- package/dist/eval/live/lift-registry.d.ts +128 -0
- package/dist/eval/live/lift-registry.d.ts.map +1 -0
- package/dist/eval/live/lift-registry.js +147 -0
- package/dist/eval/live/lift-registry.js.map +1 -0
- package/dist/eval/live/live-benchmark.d.ts +84 -0
- package/dist/eval/live/live-benchmark.d.ts.map +1 -0
- package/dist/eval/live/live-benchmark.js +2 -0
- package/dist/eval/live/live-benchmark.js.map +1 -0
- package/dist/eval/live/live-runner.d.ts +609 -0
- package/dist/eval/live/live-runner.d.ts.map +1 -0
- package/dist/eval/live/live-runner.js +1409 -0
- package/dist/eval/live/live-runner.js.map +1 -0
- package/dist/eval/live/refine.d.ts +88 -0
- package/dist/eval/live/refine.d.ts.map +1 -0
- package/dist/eval/live/refine.js +135 -0
- package/dist/eval/live/refine.js.map +1 -0
- package/dist/eval/live/registry-store.d.ts +109 -0
- package/dist/eval/live/registry-store.d.ts.map +1 -0
- package/dist/eval/live/registry-store.js +272 -0
- package/dist/eval/live/registry-store.js.map +1 -0
- package/dist/eval/live/run-checkpoint.d.ts +55 -0
- package/dist/eval/live/run-checkpoint.d.ts.map +1 -0
- package/dist/eval/live/run-checkpoint.js +86 -0
- package/dist/eval/live/run-checkpoint.js.map +1 -0
- package/dist/eval/live/run-resume.d.ts +22 -0
- package/dist/eval/live/run-resume.d.ts.map +1 -0
- package/dist/eval/live/run-resume.js +70 -0
- package/dist/eval/live/run-resume.js.map +1 -0
- package/dist/eval/live/skill-injector.d.ts +36 -0
- package/dist/eval/live/skill-injector.d.ts.map +1 -0
- package/dist/eval/live/skill-injector.js +81 -0
- package/dist/eval/live/skill-injector.js.map +1 -0
- package/dist/eval/live/skillflow-embedded-workbook-bundle.d.ts +3 -0
- package/dist/eval/live/skillflow-embedded-workbook-bundle.d.ts.map +1 -0
- package/dist/eval/live/skillflow-embedded-workbook-bundle.js +391 -0
- package/dist/eval/live/skillflow-embedded-workbook-bundle.js.map +1 -0
- package/dist/eval/live/skillflow.d.ts +154 -0
- package/dist/eval/live/skillflow.d.ts.map +1 -0
- package/dist/eval/live/skillflow.js +612 -0
- package/dist/eval/live/skillflow.js.map +1 -0
- package/dist/eval/live/skilllearnbench.d.ts +43 -0
- package/dist/eval/live/skilllearnbench.d.ts.map +1 -0
- package/dist/eval/live/skilllearnbench.js +154 -0
- package/dist/eval/live/skilllearnbench.js.map +1 -0
- package/dist/eval/live/skillopt_v1.d.ts +96 -0
- package/dist/eval/live/skillopt_v1.d.ts.map +1 -0
- package/dist/eval/live/skillopt_v1.js +0 -0
- package/dist/eval/live/skillopt_v1.js.map +1 -0
- package/dist/eval/live/skillopt_v1_causal.d.ts +26 -0
- package/dist/eval/live/skillopt_v1_causal.d.ts.map +1 -0
- package/dist/eval/live/skillopt_v1_causal.js +106 -0
- package/dist/eval/live/skillopt_v1_causal.js.map +1 -0
- package/dist/eval/live/skillopt_v1_memory.d.ts +53 -0
- package/dist/eval/live/skillopt_v1_memory.d.ts.map +1 -0
- package/dist/eval/live/skillopt_v1_memory.js +147 -0
- package/dist/eval/live/skillopt_v1_memory.js.map +1 -0
- package/dist/eval/live/skillopt_v1_rules.d.ts +39 -0
- package/dist/eval/live/skillopt_v1_rules.d.ts.map +1 -0
- package/dist/eval/live/skillopt_v1_rules.js +91 -0
- package/dist/eval/live/skillopt_v1_rules.js.map +1 -0
- package/dist/eval/live/skillsbench.d.ts +138 -0
- package/dist/eval/live/skillsbench.d.ts.map +1 -0
- package/dist/eval/live/skillsbench.js +626 -0
- package/dist/eval/live/skillsbench.js.map +1 -0
- package/dist/eval/live/stopping.d.ts +69 -0
- package/dist/eval/live/stopping.d.ts.map +1 -0
- package/dist/eval/live/stopping.js +213 -0
- package/dist/eval/live/stopping.js.map +1 -0
- package/dist/eval/live/trace.d.ts +20 -0
- package/dist/eval/live/trace.d.ts.map +1 -0
- package/dist/eval/live/trace.js +41 -0
- package/dist/eval/live/trace.js.map +1 -0
- package/dist/eval/mechanism-trace-adapter.d.ts +8 -0
- package/dist/eval/mechanism-trace-adapter.d.ts.map +1 -0
- package/dist/eval/mechanism-trace-adapter.js +118 -0
- package/dist/eval/mechanism-trace-adapter.js.map +1 -0
- package/dist/eval/memory-ab.d.ts +61 -0
- package/dist/eval/memory-ab.d.ts.map +1 -0
- package/dist/eval/memory-ab.js +161 -0
- package/dist/eval/memory-ab.js.map +1 -0
- package/dist/eval/memory-mock.d.ts +54 -0
- package/dist/eval/memory-mock.d.ts.map +1 -0
- package/dist/eval/memory-mock.js +129 -0
- package/dist/eval/memory-mock.js.map +1 -0
- package/dist/eval/memory-qa/index.d.ts +13 -0
- package/dist/eval/memory-qa/index.d.ts.map +1 -0
- package/dist/eval/memory-qa/index.js +13 -0
- package/dist/eval/memory-qa/index.js.map +1 -0
- package/dist/eval/memory-qa/iterative.d.ts +80 -0
- package/dist/eval/memory-qa/iterative.d.ts.map +1 -0
- package/dist/eval/memory-qa/iterative.js +107 -0
- package/dist/eval/memory-qa/iterative.js.map +1 -0
- package/dist/eval/memory-qa/loaders.d.ts +11 -0
- package/dist/eval/memory-qa/loaders.d.ts.map +1 -0
- package/dist/eval/memory-qa/loaders.js +21 -0
- package/dist/eval/memory-qa/loaders.js.map +1 -0
- package/dist/eval/memory-qa/metrics.d.ts +3 -0
- package/dist/eval/memory-qa/metrics.d.ts.map +1 -0
- package/dist/eval/memory-qa/metrics.js +2 -0
- package/dist/eval/memory-qa/metrics.js.map +1 -0
- package/dist/eval/memory-qa/qa.d.ts +186 -0
- package/dist/eval/memory-qa/qa.d.ts.map +1 -0
- package/dist/eval/memory-qa/qa.js +424 -0
- package/dist/eval/memory-qa/qa.js.map +1 -0
- package/dist/eval/memory-qa/retrieval.d.ts +33 -0
- package/dist/eval/memory-qa/retrieval.d.ts.map +1 -0
- package/dist/eval/memory-qa/retrieval.js +44 -0
- package/dist/eval/memory-qa/retrieval.js.map +1 -0
- package/dist/eval/memory-qa/serving.d.ts +60 -0
- package/dist/eval/memory-qa/serving.d.ts.map +1 -0
- package/dist/eval/memory-qa/serving.js +267 -0
- package/dist/eval/memory-qa/serving.js.map +1 -0
- package/dist/eval/memory-qa/types.d.ts +2 -0
- package/dist/eval/memory-qa/types.d.ts.map +1 -0
- package/dist/eval/memory-qa/types.js +2 -0
- package/dist/eval/memory-qa/types.js.map +1 -0
- package/dist/eval/metrics.d.ts +120 -0
- package/dist/eval/metrics.d.ts.map +1 -0
- package/dist/eval/metrics.js +361 -0
- package/dist/eval/metrics.js.map +1 -0
- package/dist/eval/oracle-smoke.d.ts +75 -0
- package/dist/eval/oracle-smoke.d.ts.map +1 -0
- package/dist/eval/oracle-smoke.js +143 -0
- package/dist/eval/oracle-smoke.js.map +1 -0
- package/dist/eval/playbook-calibration-report.d.ts +40 -0
- package/dist/eval/playbook-calibration-report.d.ts.map +1 -0
- package/dist/eval/playbook-calibration-report.js +246 -0
- package/dist/eval/playbook-calibration-report.js.map +1 -0
- package/dist/eval/playbook-candidate-decisions-report.d.ts +36 -0
- package/dist/eval/playbook-candidate-decisions-report.d.ts.map +1 -0
- package/dist/eval/playbook-candidate-decisions-report.js +201 -0
- package/dist/eval/playbook-candidate-decisions-report.js.map +1 -0
- package/dist/eval/playbook-usage-report.d.ts +7 -0
- package/dist/eval/playbook-usage-report.d.ts.map +1 -0
- package/dist/eval/playbook-usage-report.js +222 -0
- package/dist/eval/playbook-usage-report.js.map +1 -0
- package/dist/eval/report.d.ts +28 -0
- package/dist/eval/report.d.ts.map +1 -0
- package/dist/eval/report.js +567 -0
- package/dist/eval/report.js.map +1 -0
- package/dist/eval/retrieval/corpus.d.ts +41 -0
- package/dist/eval/retrieval/corpus.d.ts.map +1 -0
- package/dist/eval/retrieval/corpus.js +158 -0
- package/dist/eval/retrieval/corpus.js.map +1 -0
- package/dist/eval/retrieval/index.d.ts +12 -0
- package/dist/eval/retrieval/index.d.ts.map +1 -0
- package/dist/eval/retrieval/index.js +14 -0
- package/dist/eval/retrieval/index.js.map +1 -0
- package/dist/eval/retrieval/knowledge-corpus.d.ts +91 -0
- package/dist/eval/retrieval/knowledge-corpus.d.ts.map +1 -0
- package/dist/eval/retrieval/knowledge-corpus.js +268 -0
- package/dist/eval/retrieval/knowledge-corpus.js.map +1 -0
- package/dist/eval/retrieval/knowledge-quality.d.ts +91 -0
- package/dist/eval/retrieval/knowledge-quality.d.ts.map +1 -0
- package/dist/eval/retrieval/knowledge-quality.js +247 -0
- package/dist/eval/retrieval/knowledge-quality.js.map +1 -0
- package/dist/eval/retrieval/ladder.d.ts +69 -0
- package/dist/eval/retrieval/ladder.d.ts.map +1 -0
- package/dist/eval/retrieval/ladder.js +80 -0
- package/dist/eval/retrieval/ladder.js.map +1 -0
- package/dist/eval/retrieval/quality.d.ts +39 -0
- package/dist/eval/retrieval/quality.d.ts.map +1 -0
- package/dist/eval/retrieval/quality.js +75 -0
- package/dist/eval/retrieval/quality.js.map +1 -0
- package/dist/eval/rng.d.ts +25 -0
- package/dist/eval/rng.d.ts.map +1 -0
- package/dist/eval/rng.js +43 -0
- package/dist/eval/rng.js.map +1 -0
- package/dist/eval/runner.d.ts +65 -0
- package/dist/eval/runner.d.ts.map +1 -0
- package/dist/eval/runner.js +216 -0
- package/dist/eval/runner.js.map +1 -0
- package/dist/eval/skill-bundle.d.ts +18 -0
- package/dist/eval/skill-bundle.d.ts.map +1 -0
- package/dist/eval/skill-bundle.js +38 -0
- package/dist/eval/skill-bundle.js.map +1 -0
- package/dist/eval/swarmkit-report.d.ts +21 -0
- package/dist/eval/swarmkit-report.d.ts.map +1 -0
- package/dist/eval/swarmkit-report.js +93 -0
- package/dist/eval/swarmkit-report.js.map +1 -0
- package/dist/eval/task-stream.d.ts +22 -0
- package/dist/eval/task-stream.d.ts.map +1 -0
- package/dist/eval/task-stream.js +99 -0
- package/dist/eval/task-stream.js.map +1 -0
- package/dist/eval/types.d.ts +173 -0
- package/dist/eval/types.d.ts.map +1 -0
- package/dist/eval/types.js +11 -0
- package/dist/eval/types.js.map +1 -0
- package/dist/experimental/causal-store.d.ts +97 -0
- package/dist/experimental/causal-store.d.ts.map +1 -0
- package/dist/experimental/causal-store.js +213 -0
- package/dist/experimental/causal-store.js.map +1 -0
- package/dist/experimental/graph-layers/base.d.ts +29 -0
- package/dist/experimental/graph-layers/base.d.ts.map +1 -0
- package/dist/experimental/graph-layers/base.js +143 -0
- package/dist/experimental/graph-layers/base.js.map +1 -0
- package/dist/experimental/graph-layers/causal.d.ts +14 -0
- package/dist/experimental/graph-layers/causal.d.ts.map +1 -0
- package/dist/experimental/graph-layers/causal.js +14 -0
- package/dist/experimental/graph-layers/causal.js.map +1 -0
- package/dist/experimental/graph-layers/entity.d.ts +14 -0
- package/dist/experimental/graph-layers/entity.d.ts.map +1 -0
- package/dist/experimental/graph-layers/entity.js +14 -0
- package/dist/experimental/graph-layers/entity.js.map +1 -0
- package/dist/experimental/graph-layers/index.d.ts +6 -0
- package/dist/experimental/graph-layers/index.d.ts.map +1 -0
- package/dist/experimental/graph-layers/index.js +6 -0
- package/dist/experimental/graph-layers/index.js.map +1 -0
- package/dist/experimental/graph-layers/semantic.d.ts +14 -0
- package/dist/experimental/graph-layers/semantic.d.ts.map +1 -0
- package/dist/experimental/graph-layers/semantic.js +14 -0
- package/dist/experimental/graph-layers/semantic.js.map +1 -0
- package/dist/experimental/graph-layers/temporal.d.ts +14 -0
- package/dist/experimental/graph-layers/temporal.d.ts.map +1 -0
- package/dist/experimental/graph-layers/temporal.js +14 -0
- package/dist/experimental/graph-layers/temporal.js.map +1 -0
- package/dist/experimental/healing-orchestrator.d.ts +182 -0
- package/dist/experimental/healing-orchestrator.d.ts.map +1 -0
- package/dist/experimental/healing-orchestrator.js +250 -0
- package/dist/experimental/healing-orchestrator.js.map +1 -0
- package/dist/experimental/knowledge-graph-types.d.ts +148 -0
- package/dist/experimental/knowledge-graph-types.d.ts.map +1 -0
- package/dist/experimental/knowledge-graph-types.js +40 -0
- package/dist/experimental/knowledge-graph-types.js.map +1 -0
- package/dist/experimental/knowledge-graph.d.ts +41 -0
- package/dist/experimental/knowledge-graph.d.ts.map +1 -0
- package/dist/experimental/knowledge-graph.js +270 -0
- package/dist/experimental/knowledge-graph.js.map +1 -0
- package/dist/experimental/meta-reflection.d.ts +47 -0
- package/dist/experimental/meta-reflection.d.ts.map +1 -0
- package/dist/experimental/meta-reflection.js +143 -0
- package/dist/experimental/meta-reflection.js.map +1 -0
- package/dist/experimental/moe-gate.d.ts +134 -0
- package/dist/experimental/moe-gate.d.ts.map +1 -0
- package/dist/experimental/moe-gate.js +240 -0
- package/dist/experimental/moe-gate.js.map +1 -0
- package/dist/experimental/reasoning-bank.d.ts +130 -0
- package/dist/experimental/reasoning-bank.d.ts.map +1 -0
- package/dist/experimental/reasoning-bank.js +427 -0
- package/dist/experimental/reasoning-bank.js.map +1 -0
- package/dist/experimental/team/team-config.d.ts +127 -0
- package/dist/experimental/team/team-config.d.ts.map +1 -0
- package/dist/experimental/team/team-config.js +48 -0
- package/dist/experimental/team/team-config.js.map +1 -0
- package/dist/experimental/team/team-experience.d.ts +300 -0
- package/dist/experimental/team/team-experience.d.ts.map +1 -0
- package/dist/experimental/team/team-experience.js +355 -0
- package/dist/experimental/team/team-experience.js.map +1 -0
- package/dist/experimental/team/team-ingester.d.ts +152 -0
- package/dist/experimental/team/team-ingester.d.ts.map +1 -0
- package/dist/experimental/team/team-ingester.js +330 -0
- package/dist/experimental/team/team-ingester.js.map +1 -0
- package/dist/experimental/team/team-meta-learner.d.ts +51 -0
- package/dist/experimental/team/team-meta-learner.d.ts.map +1 -0
- package/dist/experimental/team/team-meta-learner.js +404 -0
- package/dist/experimental/team/team-meta-learner.js.map +1 -0
- package/dist/experimental/team/team-meta.d.ts +160 -0
- package/dist/experimental/team/team-meta.d.ts.map +1 -0
- package/dist/experimental/team/team-meta.js +42 -0
- package/dist/experimental/team/team-meta.js.map +1 -0
- package/dist/experimental/team/team-pipeline.d.ts +77 -0
- package/dist/experimental/team/team-pipeline.d.ts.map +1 -0
- package/dist/experimental/team/team-pipeline.js +262 -0
- package/dist/experimental/team/team-pipeline.js.map +1 -0
- package/dist/experimental/team/team-playbook-extraction.d.ts +45 -0
- package/dist/experimental/team/team-playbook-extraction.d.ts.map +1 -0
- package/dist/experimental/team/team-playbook-extraction.js +526 -0
- package/dist/experimental/team/team-playbook-extraction.js.map +1 -0
- package/dist/experimental/team/team-playbook.d.ts +276 -0
- package/dist/experimental/team/team-playbook.d.ts.map +1 -0
- package/dist/experimental/team/team-playbook.js +85 -0
- package/dist/experimental/team/team-playbook.js.map +1 -0
- package/dist/experimental/team/team-router.d.ts +98 -0
- package/dist/experimental/team/team-router.d.ts.map +1 -0
- package/dist/experimental/team/team-router.js +312 -0
- package/dist/experimental/team/team-router.js.map +1 -0
- package/dist/experimental/team/team-skill-library.d.ts +180 -0
- package/dist/experimental/team/team-skill-library.d.ts.map +1 -0
- package/dist/experimental/team/team-skill-library.js +385 -0
- package/dist/experimental/team/team-skill-library.js.map +1 -0
- package/dist/experimental/team/team-trajectory-analysis.d.ts +19 -0
- package/dist/experimental/team/team-trajectory-analysis.d.ts.map +1 -0
- package/dist/experimental/team/team-trajectory-analysis.js +442 -0
- package/dist/experimental/team/team-trajectory-analysis.js.map +1 -0
- package/dist/experimental/team/team-trajectory.d.ts +305 -0
- package/dist/experimental/team/team-trajectory.d.ts.map +1 -0
- package/dist/experimental/team/team-trajectory.js +315 -0
- package/dist/experimental/team/team-trajectory.js.map +1 -0
- package/dist/factory.d.ts +2 -3
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +12 -11
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +9 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -32
- package/dist/index.js.map +1 -1
- package/dist/learning/analyzer.d.ts +26 -36
- package/dist/learning/analyzer.d.ts.map +1 -1
- package/dist/learning/analyzer.js +50 -11
- package/dist/learning/analyzer.js.map +1 -1
- package/dist/learning/compound-bootstrap/external-acquisition.d.ts +63 -0
- package/dist/learning/compound-bootstrap/external-acquisition.d.ts.map +1 -0
- package/dist/learning/compound-bootstrap/external-acquisition.js +255 -0
- package/dist/learning/compound-bootstrap/external-acquisition.js.map +1 -0
- package/dist/learning/compound-bootstrap/index.d.ts +3 -0
- package/dist/learning/compound-bootstrap/index.d.ts.map +1 -0
- package/dist/learning/compound-bootstrap/index.js +3 -0
- package/dist/learning/compound-bootstrap/index.js.map +1 -0
- package/dist/learning/compound-bootstrap/workspace-analyzer.d.ts +33 -0
- package/dist/learning/compound-bootstrap/workspace-analyzer.d.ts.map +1 -0
- package/dist/learning/compound-bootstrap/workspace-analyzer.js +379 -0
- package/dist/learning/compound-bootstrap/workspace-analyzer.js.map +1 -0
- package/dist/learning/consolidation-coordinator.d.ts +49 -0
- package/dist/learning/consolidation-coordinator.d.ts.map +1 -0
- package/dist/learning/consolidation-coordinator.js +75 -0
- package/dist/learning/consolidation-coordinator.js.map +1 -0
- package/dist/learning/convention-distiller.d.ts +84 -0
- package/dist/learning/convention-distiller.d.ts.map +1 -0
- package/dist/learning/convention-distiller.js +268 -0
- package/dist/learning/convention-distiller.js.map +1 -0
- package/dist/learning/distiller.d.ts +82 -0
- package/dist/learning/distiller.d.ts.map +1 -0
- package/dist/learning/distiller.js +353 -0
- package/dist/learning/distiller.js.map +1 -0
- package/dist/learning/effectiveness.d.ts +12 -2
- package/dist/learning/effectiveness.d.ts.map +1 -1
- package/dist/learning/effectiveness.js +18 -14
- package/dist/learning/effectiveness.js.map +1 -1
- package/dist/learning/escalation.d.ts +89 -0
- package/dist/learning/escalation.d.ts.map +1 -0
- package/dist/learning/escalation.js +168 -0
- package/dist/learning/escalation.js.map +1 -0
- package/dist/learning/external-exposure.d.ts +57 -0
- package/dist/learning/external-exposure.d.ts.map +1 -0
- package/dist/learning/external-exposure.js +95 -0
- package/dist/learning/external-exposure.js.map +1 -0
- package/dist/learning/gepa-proposer.d.ts +116 -0
- package/dist/learning/gepa-proposer.d.ts.map +1 -0
- package/dist/learning/gepa-proposer.js +258 -0
- package/dist/learning/gepa-proposer.js.map +1 -0
- package/dist/learning/index.d.ts +21 -8
- package/dist/learning/index.d.ts.map +1 -1
- package/dist/learning/index.js +28 -10
- package/dist/learning/index.js.map +1 -1
- package/dist/learning/instant-loop.d.ts +46 -16
- package/dist/learning/instant-loop.d.ts.map +1 -1
- package/dist/learning/instant-loop.js +114 -111
- package/dist/learning/instant-loop.js.map +1 -1
- package/dist/learning/knowledge-extractor.d.ts.map +1 -1
- package/dist/learning/knowledge-extractor.js +1 -2
- package/dist/learning/knowledge-extractor.js.map +1 -1
- 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/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 +15 -4
- package/dist/learning/maintenance-scheduler.d.ts.map +1 -1
- package/dist/learning/maintenance-scheduler.js +19 -16
- package/dist/learning/maintenance-scheduler.js.map +1 -1
- package/dist/learning/mechanism-trace.d.ts +196 -0
- package/dist/learning/mechanism-trace.d.ts.map +1 -0
- package/dist/learning/mechanism-trace.js +81 -0
- package/dist/learning/mechanism-trace.js.map +1 -0
- package/dist/learning/merge-proposer.d.ts +102 -0
- package/dist/learning/merge-proposer.d.ts.map +1 -0
- package/dist/learning/merge-proposer.js +253 -0
- package/dist/learning/merge-proposer.js.map +1 -0
- package/dist/learning/meta-learner.d.ts +9 -7
- package/dist/learning/meta-learner.d.ts.map +1 -1
- package/dist/learning/meta-learner.js +16 -45
- package/dist/learning/meta-learner.js.map +1 -1
- package/dist/learning/mutation-gate.d.ts +218 -0
- package/dist/learning/mutation-gate.d.ts.map +1 -0
- package/dist/learning/mutation-gate.js +390 -0
- package/dist/learning/mutation-gate.js.map +1 -0
- package/dist/learning/oracle-signal.d.ts +67 -0
- package/dist/learning/oracle-signal.d.ts.map +1 -0
- package/dist/learning/oracle-signal.js +94 -0
- package/dist/learning/oracle-signal.js.map +1 -0
- 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/playbook-extractor.d.ts +8 -0
- package/dist/learning/playbook-extractor.d.ts.map +1 -1
- package/dist/learning/playbook-extractor.js +119 -34
- package/dist/learning/playbook-extractor.js.map +1 -1
- package/dist/learning/playbook-optimizer.d.ts +37 -0
- package/dist/learning/playbook-optimizer.d.ts.map +1 -0
- package/dist/learning/playbook-optimizer.js +125 -0
- package/dist/learning/playbook-optimizer.js.map +1 -0
- package/dist/learning/reflective-proposer.d.ts +173 -0
- package/dist/learning/reflective-proposer.d.ts.map +1 -0
- package/dist/learning/reflective-proposer.js +354 -0
- package/dist/learning/reflective-proposer.js.map +1 -0
- package/dist/learning/reflexion-generator.d.ts.map +1 -1
- package/dist/learning/reflexion-generator.js +4 -3
- package/dist/learning/reflexion-generator.js.map +1 -1
- package/dist/learning/replay-executor.d.ts +64 -0
- package/dist/learning/replay-executor.d.ts.map +1 -0
- package/dist/learning/replay-executor.js +92 -0
- package/dist/learning/replay-executor.js.map +1 -0
- package/dist/learning/replay-types.d.ts +150 -0
- package/dist/learning/replay-types.d.ts.map +1 -0
- package/dist/learning/replay-types.js +207 -0
- package/dist/learning/replay-types.js.map +1 -0
- package/dist/learning/replay.d.ts +166 -0
- package/dist/learning/replay.d.ts.map +1 -0
- package/dist/learning/replay.js +228 -0
- package/dist/learning/replay.js.map +1 -0
- package/dist/learning/seed-report.d.ts +88 -0
- package/dist/learning/seed-report.d.ts.map +1 -0
- package/dist/learning/seed-report.js +120 -0
- package/dist/learning/seed-report.js.map +1 -0
- package/dist/learning/trajectory-sources/dataclaw.d.ts.map +1 -1
- package/dist/learning/trajectory-sources/dataclaw.js +6 -18
- package/dist/learning/trajectory-sources/dataclaw.js.map +1 -1
- package/dist/learning/trajectory-sources/entire.d.ts.map +1 -1
- package/dist/learning/trajectory-sources/entire.js +30 -9
- package/dist/learning/trajectory-sources/entire.js.map +1 -1
- package/dist/learning/trajectory-sources/file.d.ts.map +1 -1
- package/dist/learning/trajectory-sources/file.js.map +1 -1
- package/dist/learning/trajectory-sources/huggingface.d.ts.map +1 -1
- package/dist/learning/trajectory-sources/huggingface.js +7 -7
- package/dist/learning/trajectory-sources/huggingface.js.map +1 -1
- package/dist/learning/trajectory-sources/in-memory.d.ts.map +1 -1
- package/dist/learning/trajectory-sources/in-memory.js.map +1 -1
- package/dist/learning/trajectory-sources/index.d.ts +3 -4
- package/dist/learning/trajectory-sources/index.d.ts.map +1 -1
- package/dist/learning/trajectory-sources/index.js +3 -4
- package/dist/learning/trajectory-sources/index.js.map +1 -1
- package/dist/learning/trajectory-sources/pipeline.d.ts +4 -3
- package/dist/learning/trajectory-sources/pipeline.d.ts.map +1 -1
- package/dist/learning/trajectory-sources/pipeline.js +4 -3
- package/dist/learning/trajectory-sources/pipeline.js.map +1 -1
- package/dist/learning/unified-pipeline.d.ts +486 -61
- package/dist/learning/unified-pipeline.d.ts.map +1 -1
- package/dist/learning/unified-pipeline.js +1501 -232
- package/dist/learning/unified-pipeline.js.map +1 -1
- package/dist/learning/usage-inference.d.ts.map +1 -1
- package/dist/learning/usage-inference.js +4 -9
- package/dist/learning/usage-inference.js.map +1 -1
- package/dist/learning/workspace-snapshot.d.ts +146 -0
- package/dist/learning/workspace-snapshot.d.ts.map +1 -0
- package/dist/learning/workspace-snapshot.js +269 -0
- package/dist/learning/workspace-snapshot.js.map +1 -0
- package/dist/mcp/playbook-server.d.ts +61 -2
- package/dist/mcp/playbook-server.d.ts.map +1 -1
- package/dist/mcp/playbook-server.js +179 -9
- package/dist/mcp/playbook-server.js.map +1 -1
- package/dist/memory/coherence.d.ts.map +1 -1
- package/dist/memory/coherence.js +5 -7
- package/dist/memory/coherence.js.map +1 -1
- package/dist/memory/curated-loader.d.ts +24 -0
- package/dist/memory/curated-loader.d.ts.map +1 -1
- package/dist/memory/curated-loader.js +22 -5
- package/dist/memory/curated-loader.js.map +1 -1
- package/dist/memory/evolution/llm-evolver.d.ts +36 -0
- package/dist/memory/evolution/llm-evolver.d.ts.map +1 -0
- package/dist/memory/evolution/llm-evolver.js +106 -0
- package/dist/memory/evolution/llm-evolver.js.map +1 -0
- package/dist/memory/experience.d.ts +34 -13
- package/dist/memory/experience.d.ts.map +1 -1
- package/dist/memory/experience.js +59 -48
- package/dist/memory/experience.js.map +1 -1
- package/dist/memory/extraction/conversation-extractor.d.ts +62 -0
- package/dist/memory/extraction/conversation-extractor.d.ts.map +1 -0
- package/dist/memory/extraction/conversation-extractor.js +169 -0
- package/dist/memory/extraction/conversation-extractor.js.map +1 -0
- package/dist/memory/filesystem-cascade.d.ts +116 -0
- package/dist/memory/filesystem-cascade.d.ts.map +1 -0
- package/dist/memory/filesystem-cascade.js +221 -0
- package/dist/memory/filesystem-cascade.js.map +1 -0
- package/dist/memory/index.d.ts +14 -10
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +15 -12
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/knowledge-bank.d.ts +145 -29
- package/dist/memory/knowledge-bank.d.ts.map +1 -1
- package/dist/memory/knowledge-bank.js +511 -200
- package/dist/memory/knowledge-bank.js.map +1 -1
- package/dist/memory/knowledge-defrag.d.ts +32 -9
- package/dist/memory/knowledge-defrag.d.ts.map +1 -1
- package/dist/memory/knowledge-defrag.js +57 -49
- package/dist/memory/knowledge-defrag.js.map +1 -1
- package/dist/memory/meta-playbook-bank.d.ts +24 -0
- package/dist/memory/meta-playbook-bank.d.ts.map +1 -0
- package/dist/memory/meta-playbook-bank.js +135 -0
- package/dist/memory/meta-playbook-bank.js.map +1 -0
- package/dist/memory/meta.d.ts.map +1 -1
- package/dist/memory/meta.js +33 -14
- package/dist/memory/meta.js.map +1 -1
- package/dist/memory/playbook-applicability.d.ts +43 -0
- package/dist/memory/playbook-applicability.d.ts.map +1 -0
- package/dist/memory/playbook-applicability.js +155 -0
- package/dist/memory/playbook-applicability.js.map +1 -0
- package/dist/memory/playbook-incorporation.d.ts +24 -0
- package/dist/memory/playbook-incorporation.d.ts.map +1 -0
- package/dist/memory/playbook-incorporation.js +41 -0
- package/dist/memory/playbook-incorporation.js.map +1 -0
- package/dist/memory/playbook.d.ts +444 -7
- package/dist/memory/playbook.d.ts.map +1 -1
- package/dist/memory/playbook.js +1231 -50
- package/dist/memory/playbook.js.map +1 -1
- package/dist/memory/procedural-skill.d.ts +142 -0
- package/dist/memory/procedural-skill.d.ts.map +1 -0
- package/dist/memory/procedural-skill.js +846 -0
- package/dist/memory/procedural-skill.js.map +1 -0
- package/dist/memory/search-provider.d.ts +8 -3
- package/dist/memory/search-provider.d.ts.map +1 -1
- package/dist/memory/search-providers/embedding.d.ts +64 -0
- package/dist/memory/search-providers/embedding.d.ts.map +1 -0
- package/dist/memory/search-providers/embedding.js +96 -0
- package/dist/memory/search-providers/embedding.js.map +1 -0
- package/dist/memory/search-providers/hybrid.d.ts +74 -0
- package/dist/memory/search-providers/hybrid.d.ts.map +1 -0
- package/dist/memory/search-providers/hybrid.js +94 -0
- package/dist/memory/search-providers/hybrid.js.map +1 -0
- package/dist/memory/search-providers/index.d.ts +3 -0
- package/dist/memory/search-providers/index.d.ts.map +1 -1
- package/dist/memory/search-providers/index.js +3 -0
- package/dist/memory/search-providers/index.js.map +1 -1
- package/dist/memory/search-providers/keyword-expanding.d.ts +22 -0
- package/dist/memory/search-providers/keyword-expanding.d.ts.map +1 -0
- package/dist/memory/search-providers/keyword-expanding.js +35 -0
- package/dist/memory/search-providers/keyword-expanding.js.map +1 -0
- package/dist/memory/search-providers/minimem.d.ts +16 -4
- package/dist/memory/search-providers/minimem.d.ts.map +1 -1
- package/dist/memory/search-providers/minimem.js +14 -3
- package/dist/memory/search-providers/minimem.js.map +1 -1
- package/dist/memory/search-providers/text-similarity.d.ts +2 -4
- package/dist/memory/search-providers/text-similarity.d.ts.map +1 -1
- package/dist/memory/search-providers/text-similarity.js.map +1 -1
- package/dist/memory/seeds/meta-playbook-seeds.d.ts +27 -0
- package/dist/memory/seeds/meta-playbook-seeds.d.ts.map +1 -0
- package/dist/memory/seeds/meta-playbook-seeds.js +560 -0
- package/dist/memory/seeds/meta-playbook-seeds.js.map +1 -0
- package/dist/memory/seeds/meta-strategy-seeds.d.ts +23 -0
- package/dist/memory/seeds/meta-strategy-seeds.d.ts.map +1 -0
- package/dist/memory/seeds/meta-strategy-seeds.js +82 -0
- package/dist/memory/seeds/meta-strategy-seeds.js.map +1 -0
- package/dist/memory/seeds/seed-loader.d.ts +34 -0
- package/dist/memory/seeds/seed-loader.d.ts.map +1 -0
- package/dist/memory/seeds/seed-loader.js +60 -0
- package/dist/memory/seeds/seed-loader.js.map +1 -0
- package/dist/memory/skill-exporter.d.ts.map +1 -1
- package/dist/memory/skill-exporter.js +1 -2
- package/dist/memory/skill-exporter.js.map +1 -1
- package/dist/memory/source-resolver.d.ts.map +1 -1
- package/dist/memory/source-resolver.js +7 -8
- package/dist/memory/source-resolver.js.map +1 -1
- package/dist/memory/system.d.ts +119 -14
- package/dist/memory/system.d.ts.map +1 -1
- package/dist/memory/system.js +416 -60
- package/dist/memory/system.js.map +1 -1
- package/dist/memory/temporal-compressor.d.ts +1 -1
- package/dist/memory/temporal-compressor.d.ts.map +1 -1
- package/dist/memory/temporal-compressor.js +26 -16
- package/dist/memory/temporal-compressor.js.map +1 -1
- package/dist/persistence/index.d.ts +2 -2
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +1 -1
- package/dist/persistence/index.js.map +1 -1
- package/dist/persistence/migrator.d.ts +34 -1
- package/dist/persistence/migrator.d.ts.map +1 -1
- package/dist/persistence/migrator.js +163 -33
- package/dist/persistence/migrator.js.map +1 -1
- package/dist/persistence/sqlite-persistence.d.ts +412 -1
- package/dist/persistence/sqlite-persistence.d.ts.map +1 -1
- package/dist/persistence/sqlite-persistence.js +1038 -47
- package/dist/persistence/sqlite-persistence.js.map +1 -1
- package/dist/runtime/backends/acp-protocol.d.ts.map +1 -1
- package/dist/runtime/backends/acp-protocol.js +2 -1
- package/dist/runtime/backends/acp-protocol.js.map +1 -1
- package/dist/runtime/backends/acp.d.ts.map +1 -1
- package/dist/runtime/backends/acp.js +5 -4
- package/dist/runtime/backends/acp.js.map +1 -1
- package/dist/runtime/backends/index.d.ts +2 -2
- package/dist/runtime/backends/index.d.ts.map +1 -1
- package/dist/runtime/backends/index.js +2 -2
- package/dist/runtime/backends/index.js.map +1 -1
- package/dist/runtime/backends/macro-agent.d.ts +17 -1
- package/dist/runtime/backends/macro-agent.d.ts.map +1 -1
- package/dist/runtime/backends/macro-agent.js +1 -1
- package/dist/runtime/backends/macro-agent.js.map +1 -1
- package/dist/runtime/backends/mock.d.ts.map +1 -1
- package/dist/runtime/backends/mock.js.map +1 -1
- package/dist/runtime/backends/subprocess.d.ts.map +1 -1
- package/dist/runtime/backends/subprocess.js +5 -4
- package/dist/runtime/backends/subprocess.js.map +1 -1
- package/dist/runtime/compute-provider.d.ts +2 -18
- package/dist/runtime/compute-provider.d.ts.map +1 -1
- package/dist/runtime/compute-provider.js +8 -8
- package/dist/runtime/compute-provider.js.map +1 -1
- package/dist/runtime/flows/learning.d.ts +2 -1
- package/dist/runtime/flows/learning.d.ts.map +1 -1
- package/dist/runtime/flows/learning.js +4 -5
- package/dist/runtime/flows/learning.js.map +1 -1
- package/dist/runtime/flows/validation.d.ts.map +1 -1
- package/dist/runtime/flows/validation.js +2 -5
- package/dist/runtime/flows/validation.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/manager.d.ts +128 -0
- package/dist/runtime/manager.d.ts.map +1 -1
- package/dist/runtime/manager.js +375 -64
- package/dist/runtime/manager.js.map +1 -1
- package/dist/runtime/types.d.ts +92 -1
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/search/evaluator.d.ts +71 -0
- package/dist/search/evaluator.d.ts.map +1 -1
- package/dist/search/evaluator.js +40 -5
- package/dist/search/evaluator.js.map +1 -1
- package/dist/search/index.d.ts +3 -5
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +4 -7
- package/dist/search/index.js.map +1 -1
- package/dist/search/moe-gate.d.ts +48 -2
- package/dist/search/moe-gate.d.ts.map +1 -1
- package/dist/search/moe-gate.js +117 -4
- package/dist/search/moe-gate.js.map +1 -1
- package/dist/search/refinement-loop.d.ts +63 -3
- package/dist/search/refinement-loop.d.ts.map +1 -1
- package/dist/search/refinement-loop.js +278 -23
- package/dist/search/refinement-loop.js.map +1 -1
- package/dist/search/refinement-types.d.ts +4 -2
- package/dist/search/refinement-types.d.ts.map +1 -1
- package/dist/search/refinement-types.js +2 -11
- package/dist/search/refinement-types.js.map +1 -1
- package/dist/search/router.d.ts +41 -34
- package/dist/search/router.d.ts.map +1 -1
- package/dist/search/router.js +156 -90
- package/dist/search/router.js.map +1 -1
- package/dist/search/solver.js +1 -1
- package/dist/search/solver.js.map +1 -1
- package/dist/search/task-difficulty.d.ts +54 -0
- package/dist/search/task-difficulty.d.ts.map +1 -0
- package/dist/search/task-difficulty.js +116 -0
- package/dist/search/task-difficulty.js.map +1 -0
- package/dist/search/tau-bench-verifier.d.ts +74 -0
- package/dist/search/tau-bench-verifier.d.ts.map +1 -0
- package/dist/search/tau-bench-verifier.js +96 -0
- package/dist/search/tau-bench-verifier.js.map +1 -0
- package/dist/search/verification-runner.d.ts.map +1 -1
- package/dist/search/verification-runner.js +6 -5
- package/dist/search/verification-runner.js.map +1 -1
- package/dist/session-bank/git-reader.d.ts.map +1 -1
- package/dist/session-bank/git-reader.js +5 -19
- package/dist/session-bank/git-reader.js.map +1 -1
- package/dist/session-bank/parser.d.ts.map +1 -1
- package/dist/session-bank/parser.js +26 -0
- package/dist/session-bank/parser.js.map +1 -1
- package/dist/session-bank/session-bank.d.ts.map +1 -1
- package/dist/session-bank/session-bank.js +2 -5
- package/dist/session-bank/session-bank.js.map +1 -1
- package/dist/session-bank/types.d.ts +24 -0
- package/dist/session-bank/types.d.ts.map +1 -1
- package/dist/surfacing/index.d.ts +3 -3
- package/dist/surfacing/index.d.ts.map +1 -1
- package/dist/surfacing/index.js +2 -2
- package/dist/surfacing/index.js.map +1 -1
- package/dist/surfacing/shared-bank.d.ts +43 -0
- package/dist/surfacing/shared-bank.d.ts.map +1 -0
- package/dist/surfacing/shared-bank.js +104 -0
- package/dist/surfacing/shared-bank.js.map +1 -0
- package/dist/surfacing/skill-library.d.ts +98 -2
- package/dist/surfacing/skill-library.d.ts.map +1 -1
- package/dist/surfacing/skill-library.js +192 -17
- package/dist/surfacing/skill-library.js.map +1 -1
- package/dist/surfacing/skill-publisher.d.ts +3 -1
- package/dist/surfacing/skill-publisher.d.ts.map +1 -1
- package/dist/surfacing/skill-publisher.js +28 -28
- package/dist/surfacing/skill-publisher.js.map +1 -1
- package/dist/surfacing/sqlite-storage-adapter.d.ts +2 -2
- package/dist/surfacing/sqlite-storage-adapter.d.ts.map +1 -1
- package/dist/surfacing/sqlite-storage-adapter.js +27 -18
- package/dist/surfacing/sqlite-storage-adapter.js.map +1 -1
- package/dist/types/analysis.d.ts +43 -0
- package/dist/types/analysis.d.ts.map +1 -0
- package/dist/types/analysis.js +10 -0
- package/dist/types/analysis.js.map +1 -0
- package/dist/types/config.d.ts +2178 -425
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +600 -88
- package/dist/types/config.js.map +1 -1
- package/dist/types/dataclaw.d.ts +3 -3
- package/dist/types/index.d.ts +4 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -10
- package/dist/types/index.js.map +1 -1
- package/dist/types/knowledge-graph.d.ts +1 -1
- package/dist/types/knowledge-graph.d.ts.map +1 -1
- package/dist/types/knowledge.d.ts +219 -11
- package/dist/types/knowledge.d.ts.map +1 -1
- package/dist/types/knowledge.js +90 -30
- package/dist/types/knowledge.js.map +1 -1
- package/dist/types/memory.d.ts +8 -0
- package/dist/types/memory.d.ts.map +1 -1
- package/dist/types/memory.js +12 -4
- package/dist/types/memory.js.map +1 -1
- package/dist/types/outcome.d.ts +11 -0
- package/dist/types/outcome.d.ts.map +1 -1
- package/dist/types/outcome.js +9 -0
- package/dist/types/outcome.js.map +1 -1
- package/dist/types/playbook.d.ts +63 -0
- package/dist/types/playbook.d.ts.map +1 -1
- package/dist/types/playbook.js +51 -0
- package/dist/types/playbook.js.map +1 -1
- package/dist/types/trajectory-source.d.ts +1 -1
- package/dist/types/trajectory-source.d.ts.map +1 -1
- package/dist/types/trajectory.d.ts +61 -0
- package/dist/types/trajectory.d.ts.map +1 -1
- package/dist/types/trajectory.js +25 -0
- package/dist/types/trajectory.js.map +1 -1
- package/dist/utils/clock.d.ts +36 -0
- package/dist/utils/clock.d.ts.map +1 -0
- package/dist/utils/clock.js +48 -0
- package/dist/utils/clock.js.map +1 -0
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +10 -2
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.d.ts +31 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +50 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/objectives.d.ts +45 -0
- package/dist/utils/objectives.d.ts.map +1 -0
- package/dist/utils/objectives.js +74 -0
- package/dist/utils/objectives.js.map +1 -0
- package/dist/utils/partitioned-store.d.ts.map +1 -1
- package/dist/utils/partitioned-store.js.map +1 -1
- package/dist/utils/playbook-hash.d.ts +19 -0
- package/dist/utils/playbook-hash.d.ts.map +1 -0
- package/dist/utils/playbook-hash.js +51 -0
- package/dist/utils/playbook-hash.js.map +1 -0
- package/dist/utils/similarity.d.ts.map +1 -1
- package/dist/utils/similarity.js.map +1 -1
- package/dist/utils/solver-canonicalizer.d.ts +22 -0
- package/dist/utils/solver-canonicalizer.d.ts.map +1 -0
- package/dist/utils/solver-canonicalizer.js +41 -0
- package/dist/utils/solver-canonicalizer.js.map +1 -0
- package/dist/utils/storage.d.ts.map +1 -1
- package/dist/utils/storage.js +1 -3
- package/dist/utils/storage.js.map +1 -1
- package/dist/utils/task-signature.d.ts +34 -0
- package/dist/utils/task-signature.d.ts.map +1 -0
- package/dist/utils/task-signature.js +112 -0
- package/dist/utils/task-signature.js.map +1 -0
- package/dist/utils/trajectory-helpers.d.ts.map +1 -1
- package/dist/utils/trajectory-helpers.js.map +1 -1
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js.map +1 -1
- package/dist/workspace/efficacy-toolkit.d.ts.map +1 -1
- package/dist/workspace/efficacy-toolkit.js +18 -26
- package/dist/workspace/efficacy-toolkit.js.map +1 -1
- package/dist/workspace/index.d.ts +4 -3
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +5 -3
- package/dist/workspace/index.js.map +1 -1
- package/dist/workspace/runner.d.ts.map +1 -1
- package/dist/workspace/runner.js +95 -21
- package/dist/workspace/runner.js.map +1 -1
- package/dist/workspace/skill-converter.d.ts +66 -1
- package/dist/workspace/skill-converter.d.ts.map +1 -1
- package/dist/workspace/skill-converter.js +238 -19
- package/dist/workspace/skill-converter.js.map +1 -1
- package/dist/workspace/skill-import.d.ts +43 -0
- package/dist/workspace/skill-import.d.ts.map +1 -0
- package/dist/workspace/skill-import.js +40 -0
- package/dist/workspace/skill-import.js.map +1 -0
- package/dist/workspace/templates/index.d.ts +6 -8
- package/dist/workspace/templates/index.d.ts.map +1 -1
- package/dist/workspace/templates/index.js +7 -11
- package/dist/workspace/templates/index.js.map +1 -1
- package/dist/workspace/templates/knowledge-defrag.d.ts.map +1 -1
- package/dist/workspace/templates/knowledge-defrag.js +0 -2
- package/dist/workspace/templates/knowledge-defrag.js.map +1 -1
- package/dist/workspace/templates/knowledge-extraction.d.ts +11 -0
- package/dist/workspace/templates/knowledge-extraction.d.ts.map +1 -1
- package/dist/workspace/templates/knowledge-extraction.js +11 -6
- package/dist/workspace/templates/knowledge-extraction.js.map +1 -1
- package/dist/workspace/templates/playbook-conditioning.d.ts +38 -0
- package/dist/workspace/templates/playbook-conditioning.d.ts.map +1 -0
- package/dist/workspace/templates/playbook-conditioning.js +147 -0
- package/dist/workspace/templates/playbook-conditioning.js.map +1 -0
- package/dist/workspace/templates/playbook-decay-detection.d.ts.map +1 -1
- package/dist/workspace/templates/playbook-decay-detection.js +24 -18
- package/dist/workspace/templates/playbook-decay-detection.js.map +1 -1
- package/dist/workspace/templates/playbook-efficacy-audit.d.ts.map +1 -1
- package/dist/workspace/templates/playbook-efficacy-audit.js +26 -11
- package/dist/workspace/templates/playbook-efficacy-audit.js.map +1 -1
- package/dist/workspace/templates/playbook-extraction.d.ts.map +1 -1
- package/dist/workspace/templates/playbook-extraction.js +75 -15
- package/dist/workspace/templates/playbook-extraction.js.map +1 -1
- package/dist/workspace/templates/playbook-lifecycle-review.d.ts.map +1 -1
- package/dist/workspace/templates/playbook-lifecycle-review.js +12 -8
- package/dist/workspace/templates/playbook-lifecycle-review.js.map +1 -1
- package/dist/workspace/templates/refinement-analysis.d.ts.map +1 -1
- package/dist/workspace/templates/refinement-analysis.js +11 -5
- package/dist/workspace/templates/refinement-analysis.js.map +1 -1
- package/dist/workspace/templates/skill-enrichment.d.ts.map +1 -1
- package/dist/workspace/templates/skill-enrichment.js +7 -11
- package/dist/workspace/templates/skill-enrichment.js.map +1 -1
- package/dist/workspace/templates/solution-evaluation.d.ts.map +1 -1
- package/dist/workspace/templates/solution-evaluation.js +15 -8
- package/dist/workspace/templates/solution-evaluation.js.map +1 -1
- package/dist/workspace/templates/trajectory-analysis.d.ts.map +1 -1
- package/dist/workspace/templates/trajectory-analysis.js +1 -3
- package/dist/workspace/templates/trajectory-analysis.js.map +1 -1
- package/dist/workspace/templates/usage-inference.d.ts.map +1 -1
- package/dist/workspace/templates/usage-inference.js +9 -7
- package/dist/workspace/templates/usage-inference.js.map +1 -1
- package/dist/workspace/types.d.ts +32 -2
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/types.js +29 -0
- package/dist/workspace/types.js.map +1 -1
- package/package.json +43 -19
- package/playbooks/agent-ops/long-task-checkpointing.json +54 -0
- package/playbooks/agent-ops/progressive-context-gathering.json +56 -0
- package/playbooks/agent-ops/safe-destructive-operations.json +59 -0
- package/playbooks/agent-ops/scope-discipline.json +56 -0
- package/playbooks/agent-ops/stall-detection-strategy-switch.json +55 -0
- package/playbooks/agent-ops/verification-before-completion.json +54 -0
- package/playbooks/alfworld/clean-and-place.json +35 -0
- package/playbooks/alfworld/cool-and-place.json +35 -0
- package/playbooks/alfworld/examine-in-light.json +32 -0
- package/playbooks/alfworld/heat-and-place.json +35 -0
- package/playbooks/alfworld/pick-and-place.json +37 -0
- package/playbooks/alfworld/pick-two-and-place.json +35 -0
- package/.claude/settings.json +0 -197
- package/.entire/settings.json +0 -4
- package/.sessionlog/settings.json +0 -4
- package/CLAUDE.md +0 -233
- package/SKILL.md +0 -193
- package/docs/DESIGN-agentic-workspace.md +0 -2057
- package/docs/DESIGN-semantic-memory-knowledge-bank.md +0 -1789
- package/docs/DESIGN-session-bank.md +0 -1134
- package/docs/DESIGN-team-extraction-pipeline.md +0 -1369
- package/docs/PROPOSAL-team-aware-learning.md +0 -1080
- package/docs/RESEARCH-semantic-memory-knowledge-structures.md +0 -517
- package/docs/RESEARCH-team-trajectory-learning.md +0 -553
- package/gaps.md +0 -204
- package/scripts/migrate-to-playbooks.ts +0 -307
- package/src/agents/index.ts +0 -14
- package/src/agents/mock-provider.ts +0 -93
- package/src/agents/types.ts +0 -137
- package/src/atlas.ts +0 -1198
- package/src/bin/cli-utils.ts +0 -220
- package/src/bin/cognitive-core.ts +0 -162
- package/src/bin/commands/kb.ts +0 -266
- package/src/bin/commands/learn.ts +0 -100
- package/src/bin/commands/legacy.ts +0 -182
- package/src/bin/commands/run.ts +0 -113
- package/src/bin/commands/sessions.ts +0 -221
- package/src/bin/commands/skills.ts +0 -146
- package/src/embeddings/bm25.ts +0 -337
- package/src/embeddings/index.ts +0 -42
- package/src/embeddings/inverted-index.ts +0 -134
- package/src/embeddings/manager.ts +0 -293
- package/src/embeddings/provider.ts +0 -318
- package/src/embeddings/vector-store.ts +0 -365
- package/src/factory.ts +0 -280
- package/src/index.ts +0 -495
- package/src/learning/analyzer.ts +0 -319
- package/src/learning/effectiveness.ts +0 -428
- package/src/learning/energy-evaluator.ts +0 -282
- package/src/learning/healing-orchestrator.ts +0 -383
- package/src/learning/index.ts +0 -150
- package/src/learning/instant-loop.ts +0 -357
- package/src/learning/knowledge-extractor.ts +0 -470
- package/src/learning/maintenance-scheduler.ts +0 -271
- package/src/learning/meta-learner.ts +0 -552
- package/src/learning/playbook-extractor.ts +0 -702
- package/src/learning/reflexion-generator.ts +0 -273
- package/src/learning/team-ingester.ts +0 -499
- package/src/learning/team-meta-learner.ts +0 -558
- package/src/learning/team-pipeline.ts +0 -364
- package/src/learning/trajectory-sources/dataclaw.ts +0 -403
- package/src/learning/trajectory-sources/entire.ts +0 -251
- package/src/learning/trajectory-sources/file.ts +0 -136
- package/src/learning/trajectory-sources/huggingface.ts +0 -248
- package/src/learning/trajectory-sources/in-memory.ts +0 -61
- package/src/learning/trajectory-sources/index.ts +0 -15
- package/src/learning/trajectory-sources/pipeline.ts +0 -69
- package/src/learning/unified-pipeline.ts +0 -1191
- package/src/learning/usage-inference.ts +0 -372
- package/src/mcp/index.ts +0 -12
- package/src/mcp/playbook-server.ts +0 -565
- package/src/memory/candidate-retrieval.ts +0 -72
- package/src/memory/causal-store.ts +0 -273
- package/src/memory/coherence.ts +0 -252
- package/src/memory/curated-loader.ts +0 -213
- package/src/memory/experience.ts +0 -682
- package/src/memory/graph-layers/base.ts +0 -184
- package/src/memory/graph-layers/causal.ts +0 -16
- package/src/memory/graph-layers/entity.ts +0 -16
- package/src/memory/graph-layers/index.ts +0 -5
- package/src/memory/graph-layers/semantic.ts +0 -16
- package/src/memory/graph-layers/temporal.ts +0 -16
- package/src/memory/index.ts +0 -131
- package/src/memory/knowledge-bank.ts +0 -1317
- package/src/memory/knowledge-defrag.ts +0 -329
- package/src/memory/knowledge-graph.ts +0 -361
- package/src/memory/meta.ts +0 -488
- package/src/memory/playbook.ts +0 -676
- package/src/memory/reasoning-bank.ts +0 -458
- package/src/memory/reflexion.ts +0 -122
- package/src/memory/search-provider.ts +0 -35
- package/src/memory/search-providers/index.ts +0 -3
- package/src/memory/search-providers/minimem.ts +0 -84
- package/src/memory/search-providers/text-similarity.ts +0 -35
- package/src/memory/skill-exporter.ts +0 -357
- package/src/memory/source-resolver.ts +0 -422
- package/src/memory/system.ts +0 -620
- package/src/memory/team-experience.ts +0 -604
- package/src/memory/temporal-compressor.ts +0 -409
- package/src/persistence/index.ts +0 -37
- package/src/persistence/migrator.ts +0 -298
- package/src/persistence/serializers.ts +0 -79
- package/src/persistence/sqlite-persistence.ts +0 -925
- package/src/runtime/backends/acp-protocol.ts +0 -231
- package/src/runtime/backends/acp.ts +0 -239
- package/src/runtime/backends/index.ts +0 -38
- package/src/runtime/backends/macro-agent.ts +0 -177
- package/src/runtime/backends/mock.ts +0 -218
- package/src/runtime/backends/subprocess.ts +0 -356
- package/src/runtime/compute-provider.ts +0 -206
- package/src/runtime/flows/learning.ts +0 -166
- package/src/runtime/flows/validation.ts +0 -381
- package/src/runtime/index.ts +0 -75
- package/src/runtime/manager.ts +0 -685
- package/src/runtime/types.ts +0 -198
- package/src/search/evaluator.ts +0 -499
- package/src/search/index.ts +0 -78
- package/src/search/moe-gate.ts +0 -304
- package/src/search/refinement-loop.ts +0 -457
- package/src/search/refinement-types.ts +0 -159
- package/src/search/router.ts +0 -368
- package/src/search/solver.ts +0 -303
- package/src/search/team-router.ts +0 -459
- package/src/search/verification-runner.ts +0 -570
- package/src/session-bank/git-reader.ts +0 -200
- package/src/session-bank/index.ts +0 -26
- package/src/session-bank/parser.ts +0 -548
- package/src/session-bank/session-bank.ts +0 -485
- package/src/session-bank/types.ts +0 -176
- package/src/surfacing/index.ts +0 -29
- package/src/surfacing/publisher.ts +0 -23
- package/src/surfacing/skill-library.ts +0 -625
- package/src/surfacing/skill-publisher.ts +0 -257
- package/src/surfacing/sqlite-storage-adapter.ts +0 -285
- package/src/surfacing/team-skill-library.ts +0 -610
- package/src/types/config.ts +0 -661
- package/src/types/dataclaw.ts +0 -99
- package/src/types/huggingface-transformers.d.ts +0 -12
- package/src/types/index.ts +0 -293
- package/src/types/knowledge-graph.ts +0 -246
- package/src/types/knowledge.ts +0 -388
- package/src/types/memory.ts +0 -300
- package/src/types/meta.ts +0 -218
- package/src/types/outcome.ts +0 -66
- package/src/types/playbook.ts +0 -215
- package/src/types/step.ts +0 -40
- package/src/types/task.ts +0 -52
- package/src/types/team-meta.ts +0 -212
- package/src/types/team-playbook.ts +0 -384
- package/src/types/team-trajectory.ts +0 -673
- package/src/types/trajectory-source.ts +0 -47
- package/src/types/trajectory.ts +0 -80
- package/src/utils/error-classifier.ts +0 -113
- package/src/utils/frontmatter.ts +0 -118
- package/src/utils/index.ts +0 -63
- package/src/utils/partitioned-store.ts +0 -299
- package/src/utils/similarity.ts +0 -139
- package/src/utils/storage.ts +0 -249
- package/src/utils/trajectory-helpers.ts +0 -79
- package/src/utils/validation.ts +0 -286
- package/src/workspace/efficacy-toolkit.ts +0 -496
- package/src/workspace/index.ts +0 -77
- package/src/workspace/runner.ts +0 -281
- package/src/workspace/skill-converter.ts +0 -288
- package/src/workspace/templates/index.ts +0 -95
- package/src/workspace/templates/knowledge-defrag.ts +0 -223
- package/src/workspace/templates/knowledge-extraction.ts +0 -337
- package/src/workspace/templates/meta-reflection.ts +0 -208
- package/src/workspace/templates/playbook-decay-detection.ts +0 -272
- package/src/workspace/templates/playbook-efficacy-audit.ts +0 -246
- package/src/workspace/templates/playbook-extraction.ts +0 -240
- package/src/workspace/templates/playbook-lifecycle-review.ts +0 -274
- package/src/workspace/templates/refinement-analysis.ts +0 -162
- package/src/workspace/templates/skill-enrichment.ts +0 -275
- package/src/workspace/templates/solution-evaluation.ts +0 -199
- package/src/workspace/templates/team-playbook-extraction.ts +0 -631
- package/src/workspace/templates/team-trajectory-analysis.ts +0 -564
- package/src/workspace/templates/trajectory-analysis.ts +0 -234
- package/src/workspace/templates/usage-inference.ts +0 -163
- package/src/workspace/types.ts +0 -185
- package/tests/atlas-knowledge.test.ts +0 -165
- package/tests/embeddings/bm25.test.ts +0 -130
- package/tests/embeddings/inverted-index.test.ts +0 -138
- package/tests/embeddings/manager.test.ts +0 -205
- package/tests/feature-toggles.test.ts +0 -275
- package/tests/fixtures/behavioral-trajectories.ts +0 -210
- package/tests/gap-fixes.test.ts +0 -1116
- package/tests/integration/atlas.test.ts +0 -266
- package/tests/integration/cli-e2e.test.ts +0 -621
- package/tests/integration/curated-sources-e2e.test.ts +0 -502
- package/tests/integration/dataclaw-e2e.test.ts +0 -559
- package/tests/integration/e2e.test.ts +0 -1337
- package/tests/integration/entire-e2e.test.ts +0 -376
- package/tests/integration/huggingface-e2e.test.ts +0 -627
- package/tests/integration/persistence-e2e.test.ts +0 -741
- package/tests/integration/phase-e2e.test.ts +0 -1143
- package/tests/integration/pipeline-data-correctness.test.ts +0 -794
- package/tests/integration/session-bank.test.ts +0 -231
- package/tests/integration/sessionlog-e2e.test.ts +0 -329
- package/tests/integration/skill-tree-wiring.test.ts +0 -152
- package/tests/integration/unified-pipeline-e2e.test.ts +0 -634
- package/tests/learning/analyzer.test.ts +0 -426
- package/tests/learning/dataclaw-trajectory-source.test.ts +0 -642
- package/tests/learning/effectiveness.test.ts +0 -542
- package/tests/learning/energy-evaluator.test.ts +0 -180
- package/tests/learning/entire-trajectory-source.test.ts +0 -380
- package/tests/learning/healing-orchestrator.test.ts +0 -269
- package/tests/learning/huggingface-trajectory-source.test.ts +0 -817
- package/tests/learning/instant-loop.test.ts +0 -243
- package/tests/learning/knowledge-extractor.test.ts +0 -491
- package/tests/learning/maintenance-scheduler.test.ts +0 -191
- package/tests/learning/meta-learner.test.ts +0 -418
- package/tests/learning/pipeline-memory-updates.test.ts +0 -721
- package/tests/learning/playbook-extractor-provenance.test.ts +0 -114
- package/tests/learning/reflexion-generator.test.ts +0 -411
- package/tests/learning/team-ingester.test.ts +0 -349
- package/tests/learning/team-meta-learner.test.ts +0 -618
- package/tests/learning/team-pipeline.test.ts +0 -334
- package/tests/learning/trajectory-sources.test.ts +0 -320
- package/tests/learning/unified-pipeline-efficacy.test.ts +0 -232
- package/tests/learning/unified-pipeline.test.ts +0 -322
- package/tests/learning/usage-inference.test.ts +0 -254
- package/tests/mcp/playbook-server.test.ts +0 -257
- package/tests/memory/candidate-retrieval.test.ts +0 -167
- package/tests/memory/causal-store.test.ts +0 -276
- package/tests/memory/coherence.test.ts +0 -232
- package/tests/memory/compound-engineering-seed.test.ts +0 -338
- package/tests/memory/curated-loader-extended.test.ts +0 -225
- package/tests/memory/experience.test.ts +0 -203
- package/tests/memory/graph-layers/semantic.test.ts +0 -219
- package/tests/memory/knowledge-bank-extraction.test.ts +0 -558
- package/tests/memory/knowledge-bank.test.ts +0 -705
- package/tests/memory/knowledge-defrag.test.ts +0 -366
- package/tests/memory/knowledge-evolution.test.ts +0 -563
- package/tests/memory/knowledge-graph.test.ts +0 -492
- package/tests/memory/knowledge-inbox.test.ts +0 -258
- package/tests/memory/knowledge-minimem.test.ts +0 -251
- package/tests/memory/meta.test.ts +0 -399
- package/tests/memory/playbook-quality-validation.test.ts +0 -430
- package/tests/memory/playbook.test.ts +0 -644
- package/tests/memory/provenance.test.ts +0 -648
- package/tests/memory/reasoning-bank.test.ts +0 -239
- package/tests/memory/reflexion.test.ts +0 -166
- package/tests/memory/skill-exporter.test.ts +0 -475
- package/tests/memory/source-resolver.test.ts +0 -700
- package/tests/memory/system.test.ts +0 -330
- package/tests/memory/team-experience.test.ts +0 -411
- package/tests/memory/temporal-compressor.test.ts +0 -318
- package/tests/persistence/migrator.test.ts +0 -1009
- package/tests/persistence/sqlite-persistence.test.ts +0 -635
- package/tests/runtime/agent-manager.test.ts +0 -517
- package/tests/runtime/compute-provider.test.ts +0 -288
- package/tests/runtime/delegate.test.ts +0 -354
- package/tests/runtime/macro-agent-backend.test.ts +0 -266
- package/tests/runtime/mock-backend.test.ts +0 -248
- package/tests/search/evaluator.test.ts +0 -257
- package/tests/search/moe-gate.test.ts +0 -250
- package/tests/search/refinement-loop.test.ts +0 -477
- package/tests/search/refinement.test.ts +0 -267
- package/tests/search/router.test.ts +0 -506
- package/tests/search/team-router.test.ts +0 -376
- package/tests/search/verification-runner.test.ts +0 -357
- package/tests/session-bank/fixtures/multi-tool-session/full.jsonl +0 -12
- package/tests/session-bank/fixtures/multi-tool-session/metadata.json +0 -28
- package/tests/session-bank/fixtures/root-metadata.json +0 -18
- package/tests/session-bank/fixtures/sessionlog-root-metadata.json +0 -16
- package/tests/session-bank/fixtures/sessionlog-session/full.jsonl +0 -6
- package/tests/session-bank/fixtures/sessionlog-session/metadata.json +0 -55
- package/tests/session-bank/fixtures/simple-session/full.jsonl +0 -6
- package/tests/session-bank/fixtures/simple-session/metadata.json +0 -38
- package/tests/session-bank/git-reader.test.ts +0 -232
- package/tests/session-bank/parser.test.ts +0 -453
- package/tests/session-bank/session-bank.test.ts +0 -546
- package/tests/surfacing/skill-library.test.ts +0 -297
- package/tests/surfacing/skill-publisher.test.ts +0 -437
- package/tests/surfacing/sqlite-storage-adapter.test.ts +0 -206
- package/tests/surfacing/team-skill-library.test.ts +0 -444
- package/tests/types/outcome.test.ts +0 -147
- package/tests/types/step.test.ts +0 -133
- package/tests/types/task.test.ts +0 -158
- package/tests/types/team-meta.test.ts +0 -147
- package/tests/types/team-playbook.test.ts +0 -246
- package/tests/types/team-trajectory.test.ts +0 -557
- package/tests/types/trajectory.test.ts +0 -253
- package/tests/utils/error-classifier.test.ts +0 -149
- package/tests/utils/frontmatter.test.ts +0 -208
- package/tests/utils/partitioned-store.test.ts +0 -230
- package/tests/utils/similarity.test.ts +0 -188
- package/tests/utils/trajectory-helpers.test.ts +0 -163
- package/tests/utils/validation.test.ts +0 -252
- package/tests/workspace/efficacy-toolkit.test.ts +0 -404
- package/tests/workspace/full-flow.test.ts +0 -845
- package/tests/workspace/manager.test.ts +0 -215
- package/tests/workspace/runner.test.ts +0 -336
- package/tests/workspace/skill-converter.test.ts +0 -205
- package/tests/workspace/templates/knowledge-extraction.test.ts +0 -235
- package/tests/workspace/templates/playbook-efficacy.test.ts +0 -377
- package/tests/workspace/templates/team-playbook-extraction.test.ts +0 -341
- package/tests/workspace/templates/team-trajectory-analysis.test.ts +0 -417
- package/tsconfig.json +0 -25
- package/vitest.config.ts +0 -22
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
import Database from 'better-sqlite3';
|
|
12
12
|
import { join } from 'node:path';
|
|
13
13
|
import { mkdirSync, existsSync } from 'node:fs';
|
|
14
|
-
import {
|
|
14
|
+
import { randomUUID } from 'node:crypto';
|
|
15
|
+
import { toISO, toJSON, fromJSON, toInt, fromInt, embeddingToBlob, blobToEmbedding, fromISO, } from './serializers.js';
|
|
16
|
+
import { signatureFor, SIGNATURE_SCHEME_VERSION } from '../utils/task-signature.js';
|
|
15
17
|
// Re-export serializers for use by consumers
|
|
16
18
|
export { toISO, toJSON, fromJSON, toInt, fromInt, embeddingToBlob, blobToEmbedding, fromISO };
|
|
17
19
|
const DEFAULT_CONFIG = {
|
|
@@ -20,6 +22,20 @@ const DEFAULT_CONFIG = {
|
|
|
20
22
|
enableWAL: true,
|
|
21
23
|
vectorDimension: 0,
|
|
22
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Sort two parent ids into canonical (lo, hi) order so the merge_attempts
|
|
27
|
+
* table records (A, B, ancestor) and (B, A, ancestor) as the same row.
|
|
28
|
+
* Lexicographic string comparison.
|
|
29
|
+
*/
|
|
30
|
+
export function canonicalizeParentPair(a, b) {
|
|
31
|
+
return a < b ? [a, b] : [b, a];
|
|
32
|
+
}
|
|
33
|
+
/** Eval cache priority: live observations supersede LLM judgments. */
|
|
34
|
+
const JUDGED_BY_PRIORITY = {
|
|
35
|
+
live: 3,
|
|
36
|
+
verifier: 2,
|
|
37
|
+
'llm-judge': 1,
|
|
38
|
+
};
|
|
23
39
|
// ============================================================================
|
|
24
40
|
// SqlitePersistence class
|
|
25
41
|
// ============================================================================
|
|
@@ -62,34 +78,47 @@ export class SqlitePersistence {
|
|
|
62
78
|
return this.db;
|
|
63
79
|
}
|
|
64
80
|
/**
|
|
65
|
-
* Run a function inside a transaction
|
|
81
|
+
* Run a function inside a transaction (default DEFERRED — read snapshot taken
|
|
82
|
+
* at first read; write lock at first write).
|
|
66
83
|
*/
|
|
67
84
|
transaction(fn) {
|
|
68
85
|
const tx = this.db.transaction(fn);
|
|
69
86
|
return tx();
|
|
70
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Run a function inside an IMMEDIATE transaction (`BEGIN IMMEDIATE` — takes
|
|
90
|
+
* the write lock up front). Required for read-then-write compare-and-set logic
|
|
91
|
+
* that must serialize across processes under WAL (queue claiming, the dream
|
|
92
|
+
* lock); DEFERRED's snapshot isolation would let two processes both pass the
|
|
93
|
+
* pre-check.
|
|
94
|
+
*/
|
|
95
|
+
transactionImmediate(fn) {
|
|
96
|
+
return this.db.transaction(fn).immediate();
|
|
97
|
+
}
|
|
71
98
|
// ==========================================================================
|
|
72
99
|
// Schema DDL
|
|
73
100
|
// ==========================================================================
|
|
74
101
|
createSchema() {
|
|
75
102
|
this.db.exec(`
|
|
76
103
|
CREATE TABLE IF NOT EXISTS experiences (
|
|
77
|
-
id
|
|
78
|
-
task_input
|
|
79
|
-
solution_output
|
|
80
|
-
feedback
|
|
81
|
-
success
|
|
82
|
-
domain
|
|
83
|
-
embedding
|
|
84
|
-
trajectory_id
|
|
85
|
-
usage_count
|
|
86
|
-
access_score
|
|
87
|
-
retrieval_count
|
|
88
|
-
tier
|
|
89
|
-
compressed
|
|
90
|
-
metadata
|
|
91
|
-
created_at
|
|
92
|
-
last_accessed_at
|
|
104
|
+
id TEXT PRIMARY KEY,
|
|
105
|
+
task_input TEXT NOT NULL,
|
|
106
|
+
solution_output TEXT NOT NULL,
|
|
107
|
+
feedback TEXT NOT NULL,
|
|
108
|
+
success INTEGER NOT NULL,
|
|
109
|
+
domain TEXT NOT NULL,
|
|
110
|
+
embedding BLOB,
|
|
111
|
+
trajectory_id TEXT NOT NULL,
|
|
112
|
+
usage_count INTEGER NOT NULL DEFAULT 0,
|
|
113
|
+
access_score REAL NOT NULL DEFAULT 0,
|
|
114
|
+
retrieval_count INTEGER NOT NULL DEFAULT 0,
|
|
115
|
+
tier TEXT NOT NULL DEFAULT 'hot',
|
|
116
|
+
compressed TEXT,
|
|
117
|
+
metadata TEXT NOT NULL DEFAULT '{}',
|
|
118
|
+
created_at TEXT NOT NULL,
|
|
119
|
+
last_accessed_at TEXT,
|
|
120
|
+
task_signature TEXT,
|
|
121
|
+
signature_scheme_version INTEGER
|
|
93
122
|
);
|
|
94
123
|
|
|
95
124
|
CREATE INDEX IF NOT EXISTS idx_experiences_domain ON experiences(domain);
|
|
@@ -98,32 +127,156 @@ export class SqlitePersistence {
|
|
|
98
127
|
CREATE INDEX IF NOT EXISTS idx_experiences_tier ON experiences(tier);
|
|
99
128
|
CREATE INDEX IF NOT EXISTS idx_experiences_access_score ON experiences(access_score);
|
|
100
129
|
CREATE INDEX IF NOT EXISTS idx_experiences_created_at ON experiences(created_at);
|
|
130
|
+
CREATE INDEX IF NOT EXISTS idx_experiences_task_signature ON experiences(task_signature);
|
|
101
131
|
|
|
102
132
|
CREATE TABLE IF NOT EXISTS playbooks (
|
|
103
|
-
id
|
|
104
|
-
name
|
|
105
|
-
confidence
|
|
106
|
-
complexity
|
|
107
|
-
estimated_effort
|
|
108
|
-
primary_domain
|
|
109
|
-
success_count
|
|
110
|
-
failure_count
|
|
111
|
-
version
|
|
112
|
-
origin
|
|
113
|
-
applicability
|
|
114
|
-
guidance
|
|
115
|
-
verification
|
|
116
|
-
evolution
|
|
117
|
-
provenance
|
|
118
|
-
embedding
|
|
119
|
-
created_at
|
|
120
|
-
updated_at
|
|
133
|
+
id TEXT PRIMARY KEY,
|
|
134
|
+
name TEXT NOT NULL,
|
|
135
|
+
confidence REAL NOT NULL DEFAULT 0.3,
|
|
136
|
+
complexity TEXT NOT NULL DEFAULT 'moderate',
|
|
137
|
+
estimated_effort INTEGER NOT NULL DEFAULT 3,
|
|
138
|
+
primary_domain TEXT,
|
|
139
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
140
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
141
|
+
version TEXT NOT NULL DEFAULT '1.0.0',
|
|
142
|
+
origin TEXT,
|
|
143
|
+
applicability TEXT NOT NULL,
|
|
144
|
+
guidance TEXT NOT NULL,
|
|
145
|
+
verification TEXT NOT NULL DEFAULT '{}',
|
|
146
|
+
evolution TEXT NOT NULL DEFAULT '{}',
|
|
147
|
+
provenance TEXT,
|
|
148
|
+
embedding BLOB,
|
|
149
|
+
created_at TEXT NOT NULL,
|
|
150
|
+
updated_at TEXT NOT NULL,
|
|
151
|
+
parent_playbook_id TEXT,
|
|
152
|
+
FOREIGN KEY (parent_playbook_id) REFERENCES playbooks(id) ON DELETE SET NULL
|
|
121
153
|
);
|
|
122
154
|
|
|
123
155
|
CREATE INDEX IF NOT EXISTS idx_playbooks_name ON playbooks(name);
|
|
124
156
|
CREATE INDEX IF NOT EXISTS idx_playbooks_confidence ON playbooks(confidence);
|
|
125
157
|
CREATE INDEX IF NOT EXISTS idx_playbooks_primary_domain ON playbooks(primary_domain);
|
|
126
158
|
CREATE INDEX IF NOT EXISTS idx_playbooks_origin ON playbooks(origin);
|
|
159
|
+
CREATE INDEX IF NOT EXISTS idx_playbooks_parent ON playbooks(parent_playbook_id);
|
|
160
|
+
|
|
161
|
+
CREATE TABLE IF NOT EXISTS playbook_frontier (
|
|
162
|
+
task_signature TEXT NOT NULL,
|
|
163
|
+
experience_id TEXT NOT NULL,
|
|
164
|
+
playbook_id TEXT NOT NULL,
|
|
165
|
+
score REAL NOT NULL,
|
|
166
|
+
recorded_at TEXT NOT NULL,
|
|
167
|
+
PRIMARY KEY (task_signature, experience_id, playbook_id),
|
|
168
|
+
FOREIGN KEY (playbook_id) REFERENCES playbooks(id) ON DELETE CASCADE,
|
|
169
|
+
FOREIGN KEY (experience_id) REFERENCES experiences(id) ON DELETE CASCADE
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
CREATE INDEX IF NOT EXISTS idx_frontier_sig_exp_score
|
|
173
|
+
ON playbook_frontier(task_signature, experience_id, score DESC);
|
|
174
|
+
CREATE INDEX IF NOT EXISTS idx_frontier_playbook
|
|
175
|
+
ON playbook_frontier(playbook_id);
|
|
176
|
+
|
|
177
|
+
CREATE TABLE IF NOT EXISTS playbook_eval_cache (
|
|
178
|
+
playbook_hash TEXT NOT NULL,
|
|
179
|
+
experience_id TEXT NOT NULL,
|
|
180
|
+
score REAL NOT NULL,
|
|
181
|
+
judged_by TEXT NOT NULL,
|
|
182
|
+
details TEXT,
|
|
183
|
+
created_at TEXT NOT NULL,
|
|
184
|
+
PRIMARY KEY (playbook_hash, experience_id),
|
|
185
|
+
FOREIGN KEY (experience_id) REFERENCES experiences(id) ON DELETE CASCADE
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
CREATE INDEX IF NOT EXISTS idx_eval_cache_judged
|
|
189
|
+
ON playbook_eval_cache(playbook_hash, judged_by);
|
|
190
|
+
|
|
191
|
+
-- Merge attempt dedup: records (canonical_pair, ancestor) -> result so the
|
|
192
|
+
-- maintenance loop doesn't re-judge the same triplet every cycle. Only
|
|
193
|
+
-- "real" gate decisions ('accepted' | 'regression') are recorded —
|
|
194
|
+
-- sparse/empty-minibatch outcomes get retried because more data may
|
|
195
|
+
-- accumulate by the next cycle.
|
|
196
|
+
CREATE TABLE IF NOT EXISTS merge_attempts (
|
|
197
|
+
parent_lo_id TEXT NOT NULL,
|
|
198
|
+
parent_hi_id TEXT NOT NULL,
|
|
199
|
+
ancestor_id TEXT NOT NULL,
|
|
200
|
+
result TEXT NOT NULL,
|
|
201
|
+
attempted_at TEXT NOT NULL,
|
|
202
|
+
PRIMARY KEY (parent_lo_id, parent_hi_id, ancestor_id),
|
|
203
|
+
FOREIGN KEY (parent_lo_id) REFERENCES playbooks(id) ON DELETE CASCADE,
|
|
204
|
+
FOREIGN KEY (parent_hi_id) REFERENCES playbooks(id) ON DELETE CASCADE,
|
|
205
|
+
FOREIGN KEY (ancestor_id) REFERENCES playbooks(id) ON DELETE CASCADE
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
CREATE INDEX IF NOT EXISTS idx_merge_attempts_attempted
|
|
209
|
+
ON merge_attempts(attempted_at);
|
|
210
|
+
|
|
211
|
+
-- Reflective-mutation attempt dedup: records (parent, failure_fingerprint)
|
|
212
|
+
-- -> result so the maintenance loop doesn't re-reflect the same playbook
|
|
213
|
+
-- on the same set of failing experiences every cycle. The fingerprint is
|
|
214
|
+
-- a hash of the failing experience IDs the proposer reflected on, so a
|
|
215
|
+
-- new attempt is only triggered once new failures accumulate. As with
|
|
216
|
+
-- merges, only definitive gate decisions ('accepted' | 'regression') are
|
|
217
|
+
-- recorded — sparse outcomes get retried.
|
|
218
|
+
CREATE TABLE IF NOT EXISTS reflection_attempts (
|
|
219
|
+
parent_id TEXT NOT NULL,
|
|
220
|
+
failure_fingerprint TEXT NOT NULL,
|
|
221
|
+
result TEXT NOT NULL,
|
|
222
|
+
attempted_at TEXT NOT NULL,
|
|
223
|
+
PRIMARY KEY (parent_id, failure_fingerprint),
|
|
224
|
+
FOREIGN KEY (parent_id) REFERENCES playbooks(id) ON DELETE CASCADE
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
CREATE INDEX IF NOT EXISTS idx_reflection_attempts_attempted
|
|
228
|
+
ON reflection_attempts(attempted_at);
|
|
229
|
+
|
|
230
|
+
-- Mutation optimization journal: unlike reflection_attempts (a hash+result
|
|
231
|
+
-- dedup guard that carries no learning content), this records the LEARNING
|
|
232
|
+
-- CONTENT of every mutation the gate considered — the candidate direction,
|
|
233
|
+
-- the gate's decision reason, the score delta (child_sum - parent_sum), and
|
|
234
|
+
-- a short rationale. The ReflectiveMutationProposer reads a parent's recent
|
|
235
|
+
-- entries back into its prompt so it proposes a MEANINGFULLY DIFFERENT edit
|
|
236
|
+
-- rather than re-treading rejected directions (GEPA-style "reflect on the
|
|
237
|
+
-- trajectory of prior attempts"). Append-only; keyed by autoincrement id so
|
|
238
|
+
-- the same parent accumulates a history rather than overwriting.
|
|
239
|
+
CREATE TABLE IF NOT EXISTS mutation_journal (
|
|
240
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
241
|
+
parent_id TEXT NOT NULL,
|
|
242
|
+
task_signature TEXT,
|
|
243
|
+
mutation_type TEXT NOT NULL,
|
|
244
|
+
candidate_id TEXT,
|
|
245
|
+
candidate_name TEXT,
|
|
246
|
+
guidance_after TEXT,
|
|
247
|
+
reason TEXT NOT NULL,
|
|
248
|
+
accepted INTEGER NOT NULL,
|
|
249
|
+
parent_sum REAL NOT NULL,
|
|
250
|
+
child_sum REAL NOT NULL,
|
|
251
|
+
score_delta REAL NOT NULL,
|
|
252
|
+
rationale TEXT,
|
|
253
|
+
attempted_at TEXT NOT NULL,
|
|
254
|
+
FOREIGN KEY (parent_id) REFERENCES playbooks(id) ON DELETE CASCADE
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
CREATE INDEX IF NOT EXISTS idx_mutation_journal_parent
|
|
258
|
+
ON mutation_journal(parent_id, attempted_at DESC);
|
|
259
|
+
|
|
260
|
+
-- Cartesian frontier: per-(signature, experience, objective, playbook)
|
|
261
|
+
-- Used for multi-objective Pareto routing. Coexists with playbook_frontier
|
|
262
|
+
-- which tracks the single-objective (quality) frontier — same data shape,
|
|
263
|
+
-- just one row per objective instead of one total.
|
|
264
|
+
CREATE TABLE IF NOT EXISTS playbook_frontier_cartesian (
|
|
265
|
+
task_signature TEXT NOT NULL,
|
|
266
|
+
experience_id TEXT NOT NULL,
|
|
267
|
+
objective TEXT NOT NULL,
|
|
268
|
+
playbook_id TEXT NOT NULL,
|
|
269
|
+
score REAL NOT NULL,
|
|
270
|
+
recorded_at TEXT NOT NULL,
|
|
271
|
+
PRIMARY KEY (task_signature, experience_id, objective, playbook_id),
|
|
272
|
+
FOREIGN KEY (playbook_id) REFERENCES playbooks(id) ON DELETE CASCADE,
|
|
273
|
+
FOREIGN KEY (experience_id) REFERENCES experiences(id) ON DELETE CASCADE
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
CREATE INDEX IF NOT EXISTS idx_frontier_cart_sig_obj_score
|
|
277
|
+
ON playbook_frontier_cartesian(task_signature, objective, score DESC);
|
|
278
|
+
CREATE INDEX IF NOT EXISTS idx_frontier_cart_playbook
|
|
279
|
+
ON playbook_frontier_cartesian(playbook_id);
|
|
127
280
|
|
|
128
281
|
CREATE TABLE IF NOT EXISTS playbook_versions (
|
|
129
282
|
playbook_id TEXT NOT NULL,
|
|
@@ -208,6 +361,96 @@ export class SqlitePersistence {
|
|
|
208
361
|
version INTEGER NOT NULL,
|
|
209
362
|
applied_at TEXT NOT NULL
|
|
210
363
|
);
|
|
364
|
+
|
|
365
|
+
-- Dream queue (Phase A of the dreaming refactor): durable, source-agnostic
|
|
366
|
+
-- backlog of trajectories awaiting offline consolidation. Replaces the
|
|
367
|
+
-- in-memory, per-process accumulator so a separate process can drain it.
|
|
368
|
+
-- Phase A is write-only (dual-write alongside the inline path); the
|
|
369
|
+
-- claim/lease/reclaim consumer arrives in later phases. The lease columns
|
|
370
|
+
-- exist now so those phases need no migration. trajectory_id is UNIQUE
|
|
371
|
+
-- so enqueue is idempotent (INSERT OR IGNORE).
|
|
372
|
+
CREATE TABLE IF NOT EXISTS dream_queue (
|
|
373
|
+
id TEXT PRIMARY KEY,
|
|
374
|
+
trajectory_id TEXT NOT NULL UNIQUE,
|
|
375
|
+
trajectory_json TEXT NOT NULL,
|
|
376
|
+
routing_json TEXT,
|
|
377
|
+
source TEXT NOT NULL DEFAULT 'pipeline',
|
|
378
|
+
status TEXT NOT NULL DEFAULT 'pending',
|
|
379
|
+
enqueued_at TEXT NOT NULL,
|
|
380
|
+
lease_owner TEXT,
|
|
381
|
+
lease_expires_at TEXT,
|
|
382
|
+
attempts INTEGER NOT NULL DEFAULT 0
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
CREATE INDEX IF NOT EXISTS idx_dream_queue_status ON dream_queue(status);
|
|
386
|
+
CREATE INDEX IF NOT EXISTS idx_dream_queue_enqueued ON dream_queue(enqueued_at);
|
|
387
|
+
|
|
388
|
+
-- Distillation cache (PR-D1): keyed by sha256(canonical-trajectory-form +
|
|
389
|
+
-- PROMPT_VERSION). Cache hits skip the LLM call entirely so re-runs are
|
|
390
|
+
-- fully reproducible and cost-free after the first distillation.
|
|
391
|
+
CREATE TABLE IF NOT EXISTS distillation_cache (
|
|
392
|
+
cache_key TEXT PRIMARY KEY,
|
|
393
|
+
playbook_json TEXT NOT NULL,
|
|
394
|
+
created_at TEXT NOT NULL
|
|
395
|
+
);
|
|
396
|
+
|
|
397
|
+
CREATE INDEX IF NOT EXISTS idx_distillation_cache_created
|
|
398
|
+
ON distillation_cache(created_at);
|
|
399
|
+
|
|
400
|
+
-- Filesystem cascade (section 6.2): durable change queue + content-hash
|
|
401
|
+
-- index. The watcher enqueues canonical-file edits here; a worker drains
|
|
402
|
+
-- them to reindex derived rows. Durable so a change detected mid-session
|
|
403
|
+
-- survives a crash (startup full-reindex is the backstop). path is UNIQUE
|
|
404
|
+
-- so re-enqueuing the same file coalesces to a single pending row (last op
|
|
405
|
+
-- wins). This is part of the rebuildable cache: deleting cognitive-core.db
|
|
406
|
+
-- drops the queue + hashes and a cold boot full-reindexes from files.
|
|
407
|
+
CREATE TABLE IF NOT EXISTS md_change_queue (
|
|
408
|
+
id TEXT PRIMARY KEY,
|
|
409
|
+
path TEXT NOT NULL UNIQUE,
|
|
410
|
+
kind TEXT NOT NULL, -- 'playbook'
|
|
411
|
+
op TEXT NOT NULL, -- 'upsert' | 'delete'
|
|
412
|
+
status TEXT NOT NULL DEFAULT 'pending', -- 'pending' | 'error'
|
|
413
|
+
enqueued_at TEXT NOT NULL,
|
|
414
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
415
|
+
last_error TEXT
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
CREATE INDEX IF NOT EXISTS idx_md_change_queue_status ON md_change_queue(status);
|
|
419
|
+
|
|
420
|
+
-- Content-hash index: what each canonical file looked like the last time
|
|
421
|
+
-- its derived rows were written. The drain (and, later, startup) skip files
|
|
422
|
+
-- whose hash is unchanged, so an unchanged file never re-embeds/re-indexes.
|
|
423
|
+
CREATE TABLE IF NOT EXISTS md_file_index (
|
|
424
|
+
path TEXT PRIMARY KEY,
|
|
425
|
+
content_hash TEXT NOT NULL,
|
|
426
|
+
entity_id TEXT, -- indexed playbook id
|
|
427
|
+
indexed_at TEXT NOT NULL
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
-- Lift registry (production side): per-(scope, family, solver) treatment
|
|
431
|
+
-- effect of memory injection, rolled up at dream time from effectiveness
|
|
432
|
+
-- annotations. scope is always 'production' here; eval-side cells live in
|
|
433
|
+
-- the standalone eval registry DB (src/eval/live/registry-store.ts —
|
|
434
|
+
-- SCHEMA MUST STAY IN SYNC with LIFT_CELLS_DDL there). The difficulty
|
|
435
|
+
-- registry answers "how hard is family X" (base rate); this table answers
|
|
436
|
+
-- "does memory injection change outcomes on family X with solver Y"
|
|
437
|
+
-- (treatment effect). Cells never pool across solvers or across
|
|
438
|
+
-- eval/production populations. Write-only from the pipeline (no core
|
|
439
|
+
-- consumers); read by "cogcore eval lift-report".
|
|
440
|
+
-- TODO(recency): runs is a raw counter; EMA/window decay is deferred —
|
|
441
|
+
-- see DESIGN-meta-learning-validation.md §10 (lift registry).
|
|
442
|
+
CREATE TABLE IF NOT EXISTS lift_cells (
|
|
443
|
+
scope TEXT NOT NULL,
|
|
444
|
+
family TEXT NOT NULL,
|
|
445
|
+
solver TEXT NOT NULL,
|
|
446
|
+
guided_attempts INTEGER NOT NULL DEFAULT 0,
|
|
447
|
+
guided_successes INTEGER NOT NULL DEFAULT 0,
|
|
448
|
+
unguided_attempts INTEGER NOT NULL DEFAULT 0,
|
|
449
|
+
unguided_successes INTEGER NOT NULL DEFAULT 0,
|
|
450
|
+
runs INTEGER NOT NULL DEFAULT 0,
|
|
451
|
+
updated_at TEXT NOT NULL,
|
|
452
|
+
PRIMARY KEY (scope, family, solver)
|
|
453
|
+
);
|
|
211
454
|
`);
|
|
212
455
|
}
|
|
213
456
|
// ==========================================================================
|
|
@@ -233,13 +476,52 @@ export class SqlitePersistence {
|
|
|
233
476
|
// Experiences CRUD
|
|
234
477
|
// ==========================================================================
|
|
235
478
|
insertExperience(exp) {
|
|
479
|
+
// Auto-stamp signature if caller didn't provide one. The signature is
|
|
480
|
+
// derived from (domain, taskInput) so it's always recomputable, but
|
|
481
|
+
// stamping at write time avoids per-query recompute and lets the
|
|
482
|
+
// index serve grouping/lookup directly.
|
|
483
|
+
let signature = exp.taskSignature;
|
|
484
|
+
let schemeVersion = exp.signatureSchemeVersion;
|
|
485
|
+
if (!signature) {
|
|
486
|
+
signature = signatureFor(exp.domain, exp.taskInput);
|
|
487
|
+
schemeVersion = SIGNATURE_SCHEME_VERSION;
|
|
488
|
+
}
|
|
489
|
+
else if (schemeVersion === undefined) {
|
|
490
|
+
schemeVersion = SIGNATURE_SCHEME_VERSION;
|
|
491
|
+
}
|
|
492
|
+
// UPSERT (not REPLACE): preserves row identity so cascade-delete-dependent
|
|
493
|
+
// rows (playbook_frontier, playbook_eval_cache via experience_id) survive
|
|
494
|
+
// experience metadata updates (access counter bumps, tier changes, etc).
|
|
236
495
|
this.stmt('insert_experience', `
|
|
237
|
-
INSERT
|
|
496
|
+
INSERT INTO experiences
|
|
238
497
|
(id, task_input, solution_output, feedback, success, domain, embedding,
|
|
239
498
|
trajectory_id, usage_count, access_score, retrieval_count, tier,
|
|
240
|
-
compressed, metadata, created_at, last_accessed_at
|
|
241
|
-
|
|
242
|
-
|
|
499
|
+
compressed, metadata, created_at, last_accessed_at,
|
|
500
|
+
task_signature, signature_scheme_version)
|
|
501
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
502
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
503
|
+
task_input = excluded.task_input,
|
|
504
|
+
solution_output = excluded.solution_output,
|
|
505
|
+
feedback = excluded.feedback,
|
|
506
|
+
success = excluded.success,
|
|
507
|
+
domain = excluded.domain,
|
|
508
|
+
embedding = excluded.embedding,
|
|
509
|
+
trajectory_id = excluded.trajectory_id,
|
|
510
|
+
usage_count = excluded.usage_count,
|
|
511
|
+
access_score = excluded.access_score,
|
|
512
|
+
retrieval_count = excluded.retrieval_count,
|
|
513
|
+
tier = excluded.tier,
|
|
514
|
+
compressed = excluded.compressed,
|
|
515
|
+
metadata = excluded.metadata,
|
|
516
|
+
last_accessed_at = excluded.last_accessed_at,
|
|
517
|
+
task_signature = excluded.task_signature,
|
|
518
|
+
signature_scheme_version = excluded.signature_scheme_version
|
|
519
|
+
`).run(exp.id, exp.taskInput, exp.solutionOutput, exp.feedback, toInt(exp.success), exp.domain, embeddingToBlob(exp.embedding), exp.trajectoryId,
|
|
520
|
+
// Coalesce defaulted columns. UPSERT (unlike INSERT OR REPLACE) does
|
|
521
|
+
// NOT substitute column DEFAULTs for NULL binds, so callers passing
|
|
522
|
+
// undefined would hit NOT NULL constraints. Mirror the Zod schema
|
|
523
|
+
// defaults from src/types/memory.ts.
|
|
524
|
+
exp.usageCount ?? 0, exp.accessScore ?? 0, exp.retrievalCount ?? 0, exp.tier ?? 'hot', toJSON(exp.compressed), toJSON(exp.metadata ?? {}), toISO(exp.createdAt ?? new Date()), toISO(exp.lastAccessedAt), signature, schemeVersion);
|
|
243
525
|
}
|
|
244
526
|
getExperience(id) {
|
|
245
527
|
return this.stmt('get_experience', 'SELECT * FROM experiences WHERE id = ?').get(id);
|
|
@@ -300,14 +582,38 @@ export class SqlitePersistence {
|
|
|
300
582
|
// Playbooks CRUD
|
|
301
583
|
// ==========================================================================
|
|
302
584
|
insertPlaybook(pb) {
|
|
585
|
+
// UPSERT (not REPLACE): preserves the row's identity on conflict, so
|
|
586
|
+
// cascade-delete-dependent rows (playbook_frontier, playbook_eval_cache
|
|
587
|
+
// via experience_id, playbook_versions) are not wiped on every
|
|
588
|
+
// confidence bump or evolution edit.
|
|
303
589
|
this.stmt('insert_playbook', `
|
|
304
|
-
INSERT
|
|
590
|
+
INSERT INTO playbooks
|
|
305
591
|
(id, name, confidence, complexity, estimated_effort, primary_domain,
|
|
306
592
|
success_count, failure_count, version, origin,
|
|
307
593
|
applicability, guidance, verification, evolution, provenance,
|
|
308
|
-
embedding, created_at, updated_at)
|
|
309
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
310
|
-
|
|
594
|
+
embedding, created_at, updated_at, parent_playbook_id)
|
|
595
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
596
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
597
|
+
name = excluded.name,
|
|
598
|
+
confidence = excluded.confidence,
|
|
599
|
+
complexity = excluded.complexity,
|
|
600
|
+
estimated_effort = excluded.estimated_effort,
|
|
601
|
+
primary_domain = excluded.primary_domain,
|
|
602
|
+
success_count = excluded.success_count,
|
|
603
|
+
failure_count = excluded.failure_count,
|
|
604
|
+
version = excluded.version,
|
|
605
|
+
origin = excluded.origin,
|
|
606
|
+
applicability = excluded.applicability,
|
|
607
|
+
guidance = excluded.guidance,
|
|
608
|
+
verification = excluded.verification,
|
|
609
|
+
evolution = excluded.evolution,
|
|
610
|
+
provenance = excluded.provenance,
|
|
611
|
+
embedding = excluded.embedding,
|
|
612
|
+
updated_at = excluded.updated_at,
|
|
613
|
+
parent_playbook_id = excluded.parent_playbook_id
|
|
614
|
+
`).run(pb.id, pb.name,
|
|
615
|
+
// Coalesce defaulted columns — see insertExperience for rationale.
|
|
616
|
+
pb.confidence ?? 0.3, pb.complexity ?? 'moderate', pb.estimatedEffort ?? 3, pb.applicability.domains?.[0] ?? null, pb.evolution.successCount ?? 0, pb.evolution.failureCount ?? 0, pb.evolution.version ?? '1.0.0', pb.provenance?.origin ?? null, toJSON(pb.applicability), toJSON(pb.guidance), toJSON(pb.verification ?? {}), toJSON(pb.evolution ?? {}), pb.provenance ? toJSON(pb.provenance) : null, embeddingToBlob(pb.embedding), toISO(pb.createdAt ?? new Date()), toISO(pb.updatedAt ?? new Date()), pb.parentPlaybookId ?? null);
|
|
311
617
|
}
|
|
312
618
|
getPlaybook(id) {
|
|
313
619
|
return this.stmt('get_playbook', 'SELECT * FROM playbooks WHERE id = ?').get(id);
|
|
@@ -353,6 +659,30 @@ export class SqlitePersistence {
|
|
|
353
659
|
const row = this.stmt('count_playbooks', 'SELECT COUNT(*) as count FROM playbooks').get();
|
|
354
660
|
return row.count;
|
|
355
661
|
}
|
|
662
|
+
/**
|
|
663
|
+
* Get the playbook id chain from this playbook up to its root ancestor.
|
|
664
|
+
* Result includes the starting id and walks `parent_playbook_id` until
|
|
665
|
+
* null. Used by the merge proposer to find common ancestors. Returns
|
|
666
|
+
* an empty array if the playbook doesn't exist.
|
|
667
|
+
*
|
|
668
|
+
* Safety: caps walk at 64 to avoid pathological cycles.
|
|
669
|
+
*/
|
|
670
|
+
getAncestryChain(playbookId) {
|
|
671
|
+
const chain = [];
|
|
672
|
+
const seen = new Set();
|
|
673
|
+
let current = playbookId;
|
|
674
|
+
let depth = 0;
|
|
675
|
+
while (current && !seen.has(current) && depth < 64) {
|
|
676
|
+
const row = this.getPlaybook(current);
|
|
677
|
+
if (!row)
|
|
678
|
+
break;
|
|
679
|
+
chain.push(current);
|
|
680
|
+
seen.add(current);
|
|
681
|
+
current = row.parent_playbook_id;
|
|
682
|
+
depth++;
|
|
683
|
+
}
|
|
684
|
+
return chain;
|
|
685
|
+
}
|
|
356
686
|
/** Snapshot current playbook state for version history. */
|
|
357
687
|
snapshotPlaybookVersion(playbookId, version, changelog = '') {
|
|
358
688
|
const pb = this.getPlaybook(playbookId);
|
|
@@ -368,6 +698,292 @@ export class SqlitePersistence {
|
|
|
368
698
|
return this.stmt('get_playbook_versions', 'SELECT * FROM playbook_versions WHERE playbook_id = ? ORDER BY created_at ASC').all(playbookId);
|
|
369
699
|
}
|
|
370
700
|
// ==========================================================================
|
|
701
|
+
// Playbook frontier CRUD
|
|
702
|
+
//
|
|
703
|
+
// One row per (task_signature, experience_id, playbook_id). The best score
|
|
704
|
+
// for a (signature, experience) pair across all playbooks defines the
|
|
705
|
+
// per-example Pareto frontier — used for specialist preservation.
|
|
706
|
+
// ==========================================================================
|
|
707
|
+
/**
|
|
708
|
+
* Upsert a frontier row. If a row already exists for
|
|
709
|
+
* (task_signature, experience_id, playbook_id), keep the higher score
|
|
710
|
+
* (frontier records each playbook's *best* score on each example).
|
|
711
|
+
*/
|
|
712
|
+
upsertFrontierRow(taskSignature, experienceId, playbookId, score, recordedAt = new Date()) {
|
|
713
|
+
this.stmt('upsert_frontier', `
|
|
714
|
+
INSERT INTO playbook_frontier
|
|
715
|
+
(task_signature, experience_id, playbook_id, score, recorded_at)
|
|
716
|
+
VALUES (?, ?, ?, ?, ?)
|
|
717
|
+
ON CONFLICT(task_signature, experience_id, playbook_id) DO UPDATE SET
|
|
718
|
+
score = MAX(playbook_frontier.score, excluded.score),
|
|
719
|
+
recorded_at = excluded.recorded_at
|
|
720
|
+
`).run(taskSignature, experienceId, playbookId, score, toISO(recordedAt));
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Get all frontier rows for a signature. Sorted by experience then score.
|
|
724
|
+
*/
|
|
725
|
+
getFrontierBySignature(taskSignature) {
|
|
726
|
+
return this.stmt('get_frontier_by_signature', `
|
|
727
|
+
SELECT * FROM playbook_frontier
|
|
728
|
+
WHERE task_signature = ?
|
|
729
|
+
ORDER BY experience_id, score DESC
|
|
730
|
+
`).all(taskSignature);
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Get all frontier rows for a playbook (across all signatures).
|
|
734
|
+
* Used by `getFrontierContribution` to gate deletion of specialists.
|
|
735
|
+
*/
|
|
736
|
+
getFrontierByPlaybook(playbookId) {
|
|
737
|
+
return this.stmt('get_frontier_by_playbook', `
|
|
738
|
+
SELECT * FROM playbook_frontier
|
|
739
|
+
WHERE playbook_id = ?
|
|
740
|
+
`).all(playbookId);
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Compute the frontier contribution of a playbook: how many
|
|
744
|
+
* (sig, experience) pairs it is at the top of (totalWins), and how many
|
|
745
|
+
* of those are *uniquely* held by it (uniqueWins, no other playbook ties).
|
|
746
|
+
*
|
|
747
|
+
* Deletion paths (consolidation, GC, pruning) should refuse to delete
|
|
748
|
+
* a playbook with `uniqueWins > 0` without an explicit replay-replace.
|
|
749
|
+
*/
|
|
750
|
+
getFrontierContribution(playbookId) {
|
|
751
|
+
// total wins: this playbook's score is the max for its (sig, exp)
|
|
752
|
+
const total = this.stmt('frontier_total_wins', `
|
|
753
|
+
SELECT COUNT(*) AS n FROM playbook_frontier pf
|
|
754
|
+
WHERE pf.playbook_id = ?
|
|
755
|
+
AND pf.score = (
|
|
756
|
+
SELECT MAX(score) FROM playbook_frontier
|
|
757
|
+
WHERE task_signature = pf.task_signature
|
|
758
|
+
AND experience_id = pf.experience_id
|
|
759
|
+
)
|
|
760
|
+
`).get(playbookId);
|
|
761
|
+
// unique wins: this playbook is the only one with the max score for its (sig, exp)
|
|
762
|
+
const unique = this.stmt('frontier_unique_wins', `
|
|
763
|
+
SELECT COUNT(*) AS n FROM playbook_frontier pf
|
|
764
|
+
WHERE pf.playbook_id = ?
|
|
765
|
+
AND pf.score = (
|
|
766
|
+
SELECT MAX(score) FROM playbook_frontier
|
|
767
|
+
WHERE task_signature = pf.task_signature
|
|
768
|
+
AND experience_id = pf.experience_id
|
|
769
|
+
)
|
|
770
|
+
AND NOT EXISTS (
|
|
771
|
+
SELECT 1 FROM playbook_frontier other
|
|
772
|
+
WHERE other.task_signature = pf.task_signature
|
|
773
|
+
AND other.experience_id = pf.experience_id
|
|
774
|
+
AND other.playbook_id != pf.playbook_id
|
|
775
|
+
AND other.score = pf.score
|
|
776
|
+
)
|
|
777
|
+
`).get(playbookId);
|
|
778
|
+
return { uniqueWins: unique.n, totalWins: total.n };
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Distinct task signatures present in the frontier, ordered by most
|
|
782
|
+
* recent activity. Used by the maintenance loop to pick signatures
|
|
783
|
+
* that have actually accumulated evidence and are worth re-scanning
|
|
784
|
+
* for merge candidates.
|
|
785
|
+
*/
|
|
786
|
+
getActiveSignatures(limit = 20) {
|
|
787
|
+
return this.stmt('active_signatures', `
|
|
788
|
+
SELECT task_signature, MAX(recorded_at) AS latest
|
|
789
|
+
FROM playbook_frontier
|
|
790
|
+
GROUP BY task_signature
|
|
791
|
+
ORDER BY latest DESC
|
|
792
|
+
LIMIT ?
|
|
793
|
+
`).all(limit).map((r) => r.task_signature);
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Delete all frontier rows for a playbook. Idempotent.
|
|
797
|
+
* Normally not called directly — cascades from `DELETE FROM playbooks`.
|
|
798
|
+
*/
|
|
799
|
+
deleteFrontierForPlaybook(playbookId) {
|
|
800
|
+
const r = this.stmt('delete_frontier_for_playbook', 'DELETE FROM playbook_frontier WHERE playbook_id = ?').run(playbookId);
|
|
801
|
+
return r.changes;
|
|
802
|
+
}
|
|
803
|
+
// ==========================================================================
|
|
804
|
+
// Playbook cartesian frontier CRUD
|
|
805
|
+
//
|
|
806
|
+
// One row per (sig, exp, objective, playbook). The best score for a
|
|
807
|
+
// (sig, exp, objective) tuple across all playbooks defines the
|
|
808
|
+
// per-(example, objective) Pareto frontier.
|
|
809
|
+
// ==========================================================================
|
|
810
|
+
/**
|
|
811
|
+
* Upsert a cartesian frontier row, keeping the higher score on conflict.
|
|
812
|
+
* For an outcome with multiple objectives, call once per objective.
|
|
813
|
+
*/
|
|
814
|
+
upsertFrontierCartesianRow(taskSignature, experienceId, objective, playbookId, score, recordedAt = new Date()) {
|
|
815
|
+
this.stmt('upsert_frontier_cartesian', `
|
|
816
|
+
INSERT INTO playbook_frontier_cartesian
|
|
817
|
+
(task_signature, experience_id, objective, playbook_id, score, recorded_at)
|
|
818
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
819
|
+
ON CONFLICT(task_signature, experience_id, objective, playbook_id) DO UPDATE SET
|
|
820
|
+
score = MAX(playbook_frontier_cartesian.score, excluded.score),
|
|
821
|
+
recorded_at = excluded.recorded_at
|
|
822
|
+
`).run(taskSignature, experienceId, objective, playbookId, score, toISO(recordedAt));
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Get all cartesian frontier rows for a signature. Sorted by
|
|
826
|
+
* (experience, objective, score DESC).
|
|
827
|
+
*/
|
|
828
|
+
getFrontierCartesianBySignature(taskSignature) {
|
|
829
|
+
return this.stmt('get_frontier_cart_by_signature', `
|
|
830
|
+
SELECT * FROM playbook_frontier_cartesian
|
|
831
|
+
WHERE task_signature = ?
|
|
832
|
+
ORDER BY experience_id, objective, score DESC
|
|
833
|
+
`).all(taskSignature);
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Get all cartesian frontier rows for a signature filtered to a
|
|
837
|
+
* specific objective. Useful when the router wants a single-objective
|
|
838
|
+
* frontier (e.g., "best by cost only").
|
|
839
|
+
*/
|
|
840
|
+
getFrontierCartesianBySignatureAndObjective(taskSignature, objective) {
|
|
841
|
+
return this.stmt('get_frontier_cart_by_sig_obj', `
|
|
842
|
+
SELECT * FROM playbook_frontier_cartesian
|
|
843
|
+
WHERE task_signature = ? AND objective = ?
|
|
844
|
+
ORDER BY experience_id, score DESC
|
|
845
|
+
`).all(taskSignature, objective);
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Distinct objective keys currently recorded in the cartesian frontier.
|
|
849
|
+
* Lets callers introspect what objectives have been observed.
|
|
850
|
+
*/
|
|
851
|
+
getCartesianObjectives() {
|
|
852
|
+
return this.stmt('cart_distinct_objectives', `
|
|
853
|
+
SELECT DISTINCT objective FROM playbook_frontier_cartesian ORDER BY objective
|
|
854
|
+
`).all().map((r) => r.objective);
|
|
855
|
+
}
|
|
856
|
+
// ==========================================================================
|
|
857
|
+
// Merge attempts dedup
|
|
858
|
+
//
|
|
859
|
+
// Records (canonicalized parent pair, ancestor) -> result so the
|
|
860
|
+
// maintenance loop doesn't re-judge the same triplet every cycle.
|
|
861
|
+
// ==========================================================================
|
|
862
|
+
/**
|
|
863
|
+
* Record a merge attempt outcome. The parent ids are sorted into
|
|
864
|
+
* lo/hi canonical form so (A, B) and (B, A) hash to the same row.
|
|
865
|
+
*/
|
|
866
|
+
recordMergeAttempt(parentAId, parentBId, ancestorId, result, attemptedAt = new Date()) {
|
|
867
|
+
const [lo, hi] = canonicalizeParentPair(parentAId, parentBId);
|
|
868
|
+
this.stmt('record_merge_attempt', `
|
|
869
|
+
INSERT INTO merge_attempts
|
|
870
|
+
(parent_lo_id, parent_hi_id, ancestor_id, result, attempted_at)
|
|
871
|
+
VALUES (?, ?, ?, ?, ?)
|
|
872
|
+
ON CONFLICT(parent_lo_id, parent_hi_id, ancestor_id) DO UPDATE SET
|
|
873
|
+
result = excluded.result,
|
|
874
|
+
attempted_at = excluded.attempted_at
|
|
875
|
+
`).run(lo, hi, ancestorId, result, toISO(attemptedAt));
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Look up the most recent merge attempt for a (parent pair, ancestor)
|
|
879
|
+
* triplet. Parent IDs are canonicalized before lookup.
|
|
880
|
+
*/
|
|
881
|
+
getMergeAttempt(parentAId, parentBId, ancestorId) {
|
|
882
|
+
const [lo, hi] = canonicalizeParentPair(parentAId, parentBId);
|
|
883
|
+
return this.stmt('get_merge_attempt', `
|
|
884
|
+
SELECT * FROM merge_attempts
|
|
885
|
+
WHERE parent_lo_id = ? AND parent_hi_id = ? AND ancestor_id = ?
|
|
886
|
+
`).get(lo, hi, ancestorId);
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Record a reflective-mutation attempt outcome, keyed on the parent
|
|
890
|
+
* playbook and a fingerprint of the failing experiences reflected on.
|
|
891
|
+
*/
|
|
892
|
+
recordReflectionAttempt(parentId, failureFingerprint, result, attemptedAt = new Date()) {
|
|
893
|
+
this.stmt('record_reflection_attempt', `
|
|
894
|
+
INSERT INTO reflection_attempts
|
|
895
|
+
(parent_id, failure_fingerprint, result, attempted_at)
|
|
896
|
+
VALUES (?, ?, ?, ?)
|
|
897
|
+
ON CONFLICT(parent_id, failure_fingerprint) DO UPDATE SET
|
|
898
|
+
result = excluded.result,
|
|
899
|
+
attempted_at = excluded.attempted_at
|
|
900
|
+
`).run(parentId, failureFingerprint, result, toISO(attemptedAt));
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Look up the most recent reflective-mutation attempt for a
|
|
904
|
+
* (parent, failure_fingerprint) pair.
|
|
905
|
+
*/
|
|
906
|
+
getReflectionAttempt(parentId, failureFingerprint) {
|
|
907
|
+
return this.stmt('get_reflection_attempt', `
|
|
908
|
+
SELECT * FROM reflection_attempts
|
|
909
|
+
WHERE parent_id = ? AND failure_fingerprint = ?
|
|
910
|
+
`).get(parentId, failureFingerprint);
|
|
911
|
+
}
|
|
912
|
+
// ==========================================================================
|
|
913
|
+
// Mutation journal CRUD
|
|
914
|
+
//
|
|
915
|
+
// Append-only log of the learning content of every mutation the gate
|
|
916
|
+
// considered. Read back by the ReflectiveMutationProposer to reflect on the
|
|
917
|
+
// trajectory of prior attempts (see the `mutation_journal` DDL).
|
|
918
|
+
// ==========================================================================
|
|
919
|
+
/**
|
|
920
|
+
* Append a mutation-decision entry to the journal for `parentId`. Never
|
|
921
|
+
* overwrites — each considered proposal adds a row, so a parent accumulates
|
|
922
|
+
* its optimization history.
|
|
923
|
+
*/
|
|
924
|
+
recordMutationJournalEntry(entry, attemptedAt = new Date()) {
|
|
925
|
+
this.stmt('record_mutation_journal_entry', `
|
|
926
|
+
INSERT INTO mutation_journal
|
|
927
|
+
(parent_id, task_signature, mutation_type, candidate_id, candidate_name,
|
|
928
|
+
guidance_after, reason, accepted, parent_sum, child_sum, score_delta,
|
|
929
|
+
rationale, attempted_at)
|
|
930
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
931
|
+
`).run(entry.parentId, entry.taskSignature ?? null, entry.mutationType, entry.candidateId ?? null, entry.candidateName ?? null, entry.guidanceAfter ?? null, entry.reason, entry.accepted ? 1 : 0, entry.parentSum, entry.childSum, entry.scoreDelta, entry.rationale ?? null, toISO(attemptedAt));
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* Most recent journal entries for a parent playbook, newest first, capped
|
|
935
|
+
* at `limit` (default 5). Empty when the parent has no recorded attempts.
|
|
936
|
+
*/
|
|
937
|
+
getMutationJournal(parentId, limit = 5) {
|
|
938
|
+
return this.stmt('get_mutation_journal', `
|
|
939
|
+
SELECT * FROM mutation_journal
|
|
940
|
+
WHERE parent_id = ?
|
|
941
|
+
ORDER BY attempted_at DESC, id DESC
|
|
942
|
+
LIMIT ?
|
|
943
|
+
`).all(parentId, limit);
|
|
944
|
+
}
|
|
945
|
+
// ==========================================================================
|
|
946
|
+
// Playbook eval cache CRUD
|
|
947
|
+
//
|
|
948
|
+
// Caches (playbook_hash, experience_id) -> score for replay-based
|
|
949
|
+
// acceptance gates. Live scores supersede LLM-judge scores via the
|
|
950
|
+
// `judged_by` priority ordering in `getCachedEval`.
|
|
951
|
+
// ==========================================================================
|
|
952
|
+
/**
|
|
953
|
+
* Upsert a cache entry, respecting priority: a write only succeeds if
|
|
954
|
+
* the incoming `judgedBy` has equal or higher priority than the existing
|
|
955
|
+
* row's `judgedBy`. Priority order: live > verifier > llm-judge.
|
|
956
|
+
*
|
|
957
|
+
* Returns true if the row was written, false if it was rejected because
|
|
958
|
+
* a higher-priority entry already exists.
|
|
959
|
+
*/
|
|
960
|
+
upsertEvalCache(playbookHash, experienceId, score, judgedBy, details, createdAt = new Date()) {
|
|
961
|
+
const newPri = JUDGED_BY_PRIORITY[judgedBy];
|
|
962
|
+
const existing = this.getCachedEval(playbookHash, experienceId);
|
|
963
|
+
if (existing) {
|
|
964
|
+
const existingPri = JUDGED_BY_PRIORITY[existing.judged_by] ?? 0;
|
|
965
|
+
if (newPri < existingPri) {
|
|
966
|
+
return false;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
this.stmt('upsert_eval_cache', `
|
|
970
|
+
INSERT OR REPLACE INTO playbook_eval_cache
|
|
971
|
+
(playbook_hash, experience_id, score, judged_by, details, created_at)
|
|
972
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
973
|
+
`).run(playbookHash, experienceId, score, judgedBy, details ?? null, toISO(createdAt));
|
|
974
|
+
return true;
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Get the highest-priority cached eval for a (hash, experience) pair.
|
|
978
|
+
* Priority: live > verifier > llm-judge.
|
|
979
|
+
*/
|
|
980
|
+
getCachedEval(playbookHash, experienceId) {
|
|
981
|
+
return this.stmt('get_cached_eval', `
|
|
982
|
+
SELECT * FROM playbook_eval_cache
|
|
983
|
+
WHERE playbook_hash = ? AND experience_id = ?
|
|
984
|
+
`).get(playbookHash, experienceId);
|
|
985
|
+
}
|
|
986
|
+
// ==========================================================================
|
|
371
987
|
// Reflexion Episodes CRUD
|
|
372
988
|
// ==========================================================================
|
|
373
989
|
insertReflexionEpisode(ep) {
|
|
@@ -481,11 +1097,13 @@ export class SqlitePersistence {
|
|
|
481
1097
|
}
|
|
482
1098
|
/** Aggregate routing effectiveness: { decision: { total, successful } } */
|
|
483
1099
|
aggregateRoutingEffectiveness() {
|
|
484
|
-
const rows = this.db
|
|
1100
|
+
const rows = this.db
|
|
1101
|
+
.prepare(`
|
|
485
1102
|
SELECT routing_decision, COUNT(*) as total, SUM(outcome_success) as successful
|
|
486
1103
|
FROM meta_observations
|
|
487
1104
|
GROUP BY routing_decision
|
|
488
|
-
`)
|
|
1105
|
+
`)
|
|
1106
|
+
.all();
|
|
489
1107
|
const result = {};
|
|
490
1108
|
for (const row of rows) {
|
|
491
1109
|
result[row.routing_decision] = { total: row.total, successful: row.successful };
|
|
@@ -531,13 +1149,386 @@ export class SqlitePersistence {
|
|
|
531
1149
|
if (setClauses.length === 0)
|
|
532
1150
|
return;
|
|
533
1151
|
values.push(id);
|
|
534
|
-
this.db
|
|
1152
|
+
this.db
|
|
1153
|
+
.prepare(`UPDATE meta_strategies SET ${setClauses.join(', ')} WHERE id = ?`)
|
|
1154
|
+
.run(...values);
|
|
535
1155
|
}
|
|
536
1156
|
deleteMetaStrategy(id) {
|
|
537
1157
|
const result = this.stmt('delete_meta_strategy', 'DELETE FROM meta_strategies WHERE id = ?').run(id);
|
|
538
1158
|
return result.changes > 0;
|
|
539
1159
|
}
|
|
540
1160
|
// ==========================================================================
|
|
1161
|
+
// Dream queue (Phase A: durable backlog for offline consolidation)
|
|
1162
|
+
//
|
|
1163
|
+
// Write + inspect only. The claim/lease/reclaim consumer is added in a later
|
|
1164
|
+
// phase; for now this dual-writes alongside the in-memory accumulator.
|
|
1165
|
+
// ==========================================================================
|
|
1166
|
+
/**
|
|
1167
|
+
* Enqueue a trajectory for offline consolidation. Idempotent by
|
|
1168
|
+
* `trajectory_id` (INSERT OR IGNORE against the UNIQUE constraint), so
|
|
1169
|
+
* enqueuing the same trajectory twice is a no-op. Returns the generated
|
|
1170
|
+
* row id (a fresh uuid even when the insert is ignored).
|
|
1171
|
+
*/
|
|
1172
|
+
enqueueDreamRow(entry) {
|
|
1173
|
+
const id = randomUUID();
|
|
1174
|
+
const res = this.stmt('enqueue_dream_row', `
|
|
1175
|
+
INSERT OR IGNORE INTO dream_queue
|
|
1176
|
+
(id, trajectory_id, trajectory_json, routing_json, source, status, enqueued_at)
|
|
1177
|
+
VALUES (?, ?, ?, ?, ?, 'pending', ?)
|
|
1178
|
+
`).run(id, entry.trajectoryId, entry.trajectoryJson, entry.routingJson ?? null, entry.source ?? 'pipeline', new Date().toISOString());
|
|
1179
|
+
// On a dedup conflict (existing trajectory_id) nothing is inserted — return
|
|
1180
|
+
// the EXISTING row's id, not the unused one we generated, so the returned id
|
|
1181
|
+
// always names a real row.
|
|
1182
|
+
if (res.changes === 1)
|
|
1183
|
+
return id;
|
|
1184
|
+
const existing = this.stmt('dream_row_id_by_trajectory', `SELECT id FROM dream_queue WHERE trajectory_id = ?`).get(entry.trajectoryId);
|
|
1185
|
+
return existing?.id ?? id;
|
|
1186
|
+
}
|
|
1187
|
+
/** Count rows still awaiting consolidation. */
|
|
1188
|
+
countPendingDreamRows() {
|
|
1189
|
+
const row = this.stmt('count_pending_dream_rows', `SELECT COUNT(*) AS n FROM dream_queue WHERE status = 'pending'`).get();
|
|
1190
|
+
return row.n;
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Enqueue time of the oldest pending row — the staleness signal a cadence
|
|
1194
|
+
* policy uses to decide when a dream is overdue. Undefined when empty.
|
|
1195
|
+
*/
|
|
1196
|
+
getOldestPendingDreamEnqueuedAt() {
|
|
1197
|
+
const row = this.stmt('oldest_pending_dream', `SELECT MIN(enqueued_at) AS oldest FROM dream_queue WHERE status = 'pending'`).get();
|
|
1198
|
+
return fromISO(row.oldest);
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Pending rows in enqueue order (oldest first). Ties on `enqueued_at`
|
|
1202
|
+
* (same-millisecond inserts) break on `rowid`, which SQLite increments in
|
|
1203
|
+
* insertion order — so the order is the true chronological enqueue order
|
|
1204
|
+
* the drain consumer needs, not uuid-random.
|
|
1205
|
+
*/
|
|
1206
|
+
peekPendingDreamRows(limit = 100) {
|
|
1207
|
+
return this.stmt('peek_pending_dream_rows', `
|
|
1208
|
+
SELECT * FROM dream_queue
|
|
1209
|
+
WHERE status = 'pending'
|
|
1210
|
+
ORDER BY rowid ASC
|
|
1211
|
+
LIMIT ?
|
|
1212
|
+
`).all(limit);
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Atomically claim up to `limit` pending rows for consolidation: flip them
|
|
1216
|
+
* `pending → processing`, stamp the lease (owner + expiry), and bump
|
|
1217
|
+
* `attempts`. Runs in a transaction so a concurrent claimer can't hand out
|
|
1218
|
+
* the same row twice. Rows are claimed oldest-first (chronological drain).
|
|
1219
|
+
*/
|
|
1220
|
+
claimDreamRows(limit, leaseOwner, leaseTtlMs) {
|
|
1221
|
+
return this.transactionImmediate(() => {
|
|
1222
|
+
const rows = this.stmt('claim_select', `
|
|
1223
|
+
SELECT * FROM dream_queue
|
|
1224
|
+
WHERE status = 'pending'
|
|
1225
|
+
ORDER BY rowid ASC
|
|
1226
|
+
LIMIT ?
|
|
1227
|
+
`).all(limit);
|
|
1228
|
+
if (rows.length === 0)
|
|
1229
|
+
return [];
|
|
1230
|
+
const expiresAt = new Date(Date.now() + leaseTtlMs).toISOString();
|
|
1231
|
+
const upd = this.stmt('claim_update', `
|
|
1232
|
+
UPDATE dream_queue
|
|
1233
|
+
SET status = 'processing', lease_owner = ?, lease_expires_at = ?, attempts = attempts + 1
|
|
1234
|
+
WHERE id = ? AND status = 'pending'
|
|
1235
|
+
`);
|
|
1236
|
+
const claimed = [];
|
|
1237
|
+
for (const r of rows) {
|
|
1238
|
+
if (upd.run(leaseOwner, expiresAt, r.id).changes === 1) {
|
|
1239
|
+
claimed.push({
|
|
1240
|
+
...r,
|
|
1241
|
+
status: 'processing',
|
|
1242
|
+
lease_owner: leaseOwner,
|
|
1243
|
+
lease_expires_at: expiresAt,
|
|
1244
|
+
attempts: r.attempts + 1,
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
return claimed;
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
/** Delete claimed rows after a successful dream. Returns rows removed. */
|
|
1252
|
+
completeDreamRows(ids) {
|
|
1253
|
+
if (ids.length === 0)
|
|
1254
|
+
return 0;
|
|
1255
|
+
const del = this.stmt('complete_dream_row', 'DELETE FROM dream_queue WHERE id = ?');
|
|
1256
|
+
return this.transaction(() => {
|
|
1257
|
+
let n = 0;
|
|
1258
|
+
for (const id of ids)
|
|
1259
|
+
n += del.run(id).changes;
|
|
1260
|
+
return n;
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Park rows as `failed` directly (e.g. corrupt/unparseable payloads that will
|
|
1265
|
+
* never succeed on retry). Observable via getDreamQueueStats and excluded from
|
|
1266
|
+
* future claims. Unlike releaseDreamRows, does NOT requeue.
|
|
1267
|
+
*/
|
|
1268
|
+
failDreamRows(ids) {
|
|
1269
|
+
if (ids.length === 0)
|
|
1270
|
+
return 0;
|
|
1271
|
+
const upd = this.stmt('fail_dream_row', `
|
|
1272
|
+
UPDATE dream_queue
|
|
1273
|
+
SET status = 'failed', lease_owner = NULL, lease_expires_at = NULL
|
|
1274
|
+
WHERE id = ?
|
|
1275
|
+
`);
|
|
1276
|
+
return this.transaction(() => {
|
|
1277
|
+
let n = 0;
|
|
1278
|
+
for (const id of ids)
|
|
1279
|
+
n += upd.run(id).changes;
|
|
1280
|
+
return n;
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
/** Return claimed rows to `pending` after a recoverable error. */
|
|
1284
|
+
releaseDreamRows(ids) {
|
|
1285
|
+
if (ids.length === 0)
|
|
1286
|
+
return 0;
|
|
1287
|
+
const upd = this.stmt('release_dream_row', `
|
|
1288
|
+
UPDATE dream_queue
|
|
1289
|
+
SET status = 'pending', lease_owner = NULL, lease_expires_at = NULL
|
|
1290
|
+
WHERE id = ?
|
|
1291
|
+
`);
|
|
1292
|
+
return this.transaction(() => {
|
|
1293
|
+
let n = 0;
|
|
1294
|
+
for (const id of ids)
|
|
1295
|
+
n += upd.run(id).changes;
|
|
1296
|
+
return n;
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Recover rows orphaned by a crashed dreamer: `processing` rows whose lease
|
|
1301
|
+
* has expired go back to `pending`, unless they have already been attempted
|
|
1302
|
+
* `maxAttempts` times — those move to `failed` (poison-row guard). Returns
|
|
1303
|
+
* counts of each.
|
|
1304
|
+
*/
|
|
1305
|
+
reclaimExpiredDreamRows(maxAttempts = 3, now = new Date()) {
|
|
1306
|
+
const iso = now.toISOString();
|
|
1307
|
+
// Both updates in one IMMEDIATE transaction so a concurrent claimer can't
|
|
1308
|
+
// slip a row in between the fail and reclaim passes.
|
|
1309
|
+
return this.transactionImmediate(() => {
|
|
1310
|
+
const failed = this.stmt('reclaim_fail', `
|
|
1311
|
+
UPDATE dream_queue
|
|
1312
|
+
SET status = 'failed', lease_owner = NULL, lease_expires_at = NULL
|
|
1313
|
+
WHERE status = 'processing' AND lease_expires_at < ? AND attempts >= ?
|
|
1314
|
+
`).run(iso, maxAttempts).changes;
|
|
1315
|
+
const reclaimed = this.stmt('reclaim_pending', `
|
|
1316
|
+
UPDATE dream_queue
|
|
1317
|
+
SET status = 'pending', lease_owner = NULL, lease_expires_at = NULL
|
|
1318
|
+
WHERE status = 'processing' AND lease_expires_at < ? AND attempts < ?
|
|
1319
|
+
`).run(iso, maxAttempts).changes;
|
|
1320
|
+
return { reclaimed, failed };
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
// ==========================================================================
|
|
1324
|
+
// Filesystem cascade (§6.2): md change queue + content-hash index
|
|
1325
|
+
//
|
|
1326
|
+
// Durable backlog for reindex-on-edit. The watcher enqueues; FilesystemCascade
|
|
1327
|
+
// drains. Single-process/single-drainer, so no lease/claim dance — pending
|
|
1328
|
+
// rows are read, processed, then deleted (success) or parked 'error'.
|
|
1329
|
+
// ==========================================================================
|
|
1330
|
+
/**
|
|
1331
|
+
* Enqueue a canonical-file change. Idempotent per `path`: re-enqueuing the
|
|
1332
|
+
* same file overwrites the pending row (last op wins) and re-arms it to
|
|
1333
|
+
* `pending`, so a burst of editor writes coalesces to one drain unit.
|
|
1334
|
+
*/
|
|
1335
|
+
enqueueMdChange(entry) {
|
|
1336
|
+
const id = randomUUID();
|
|
1337
|
+
this.stmt('enqueue_md_change', `
|
|
1338
|
+
INSERT INTO md_change_queue (id, path, kind, op, status, enqueued_at, attempts)
|
|
1339
|
+
VALUES (?, ?, ?, ?, 'pending', ?, 0)
|
|
1340
|
+
ON CONFLICT(path) DO UPDATE SET
|
|
1341
|
+
op = excluded.op,
|
|
1342
|
+
kind = excluded.kind,
|
|
1343
|
+
status = 'pending',
|
|
1344
|
+
enqueued_at = excluded.enqueued_at
|
|
1345
|
+
`).run(id, entry.path, entry.kind, entry.op, new Date().toISOString());
|
|
1346
|
+
const row = this.stmt('md_change_id_by_path', `SELECT id FROM md_change_queue WHERE path = ?`).get(entry.path);
|
|
1347
|
+
return row?.id ?? id;
|
|
1348
|
+
}
|
|
1349
|
+
/** Pending change rows in enqueue order (oldest first). */
|
|
1350
|
+
peekPendingMdChanges(limit = 500) {
|
|
1351
|
+
return this.stmt('peek_pending_md_changes', `
|
|
1352
|
+
SELECT * FROM md_change_queue
|
|
1353
|
+
WHERE status = 'pending'
|
|
1354
|
+
ORDER BY rowid ASC
|
|
1355
|
+
LIMIT ?
|
|
1356
|
+
`).all(limit);
|
|
1357
|
+
}
|
|
1358
|
+
countPendingMdChanges() {
|
|
1359
|
+
const row = this.stmt('count_pending_md_changes', `SELECT COUNT(*) AS n FROM md_change_queue WHERE status = 'pending'`).get();
|
|
1360
|
+
return row.n;
|
|
1361
|
+
}
|
|
1362
|
+
/** Delete a change row after it drains successfully (or is a no-op). */
|
|
1363
|
+
completeMdChange(id) {
|
|
1364
|
+
this.stmt('complete_md_change', 'DELETE FROM md_change_queue WHERE id = ?').run(id);
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Record a drain failure. Increments `attempts`; parks the row as terminal
|
|
1368
|
+
* `error` once it has been tried `maxAttempts` times (poison-file guard),
|
|
1369
|
+
* otherwise leaves it `pending` for the next event-triggered drain.
|
|
1370
|
+
*/
|
|
1371
|
+
failMdChange(id, error, maxAttempts = 5) {
|
|
1372
|
+
this.stmt('fail_md_change', `
|
|
1373
|
+
UPDATE md_change_queue
|
|
1374
|
+
SET attempts = attempts + 1,
|
|
1375
|
+
last_error = ?,
|
|
1376
|
+
status = CASE WHEN attempts + 1 >= ? THEN 'error' ELSE 'pending' END
|
|
1377
|
+
WHERE id = ?
|
|
1378
|
+
`).run(error, maxAttempts, id);
|
|
1379
|
+
}
|
|
1380
|
+
getMdFileIndex(path) {
|
|
1381
|
+
return this.stmt('get_md_file_index', `SELECT * FROM md_file_index WHERE path = ?`).get(path);
|
|
1382
|
+
}
|
|
1383
|
+
setMdFileIndex(entry) {
|
|
1384
|
+
this.stmt('set_md_file_index', `
|
|
1385
|
+
INSERT INTO md_file_index (path, content_hash, entity_id, indexed_at)
|
|
1386
|
+
VALUES (?, ?, ?, ?)
|
|
1387
|
+
ON CONFLICT(path) DO UPDATE SET
|
|
1388
|
+
content_hash = excluded.content_hash,
|
|
1389
|
+
entity_id = excluded.entity_id,
|
|
1390
|
+
indexed_at = excluded.indexed_at
|
|
1391
|
+
`).run(entry.path, entry.contentHash, entry.entityId ?? null, new Date().toISOString());
|
|
1392
|
+
}
|
|
1393
|
+
deleteMdFileIndex(path) {
|
|
1394
|
+
this.stmt('delete_md_file_index', 'DELETE FROM md_file_index WHERE path = ?').run(path);
|
|
1395
|
+
}
|
|
1396
|
+
/** Row counts by status, for observability. */
|
|
1397
|
+
getDreamQueueStats() {
|
|
1398
|
+
const row = this.stmt('dream_queue_stats', `
|
|
1399
|
+
SELECT
|
|
1400
|
+
SUM(CASE WHEN status = 'pending' THEN 1 ELSE 0 END) AS pending,
|
|
1401
|
+
SUM(CASE WHEN status = 'processing' THEN 1 ELSE 0 END) AS processing,
|
|
1402
|
+
SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) AS failed
|
|
1403
|
+
FROM dream_queue
|
|
1404
|
+
`).get();
|
|
1405
|
+
return {
|
|
1406
|
+
pending: row.pending ?? 0,
|
|
1407
|
+
processing: row.processing ?? 0,
|
|
1408
|
+
failed: row.failed ?? 0,
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
// ── Dead-letter: inspect / requeue / purge `failed` rows ──────────────────
|
|
1412
|
+
/** List parked (`failed`) rows for inspection, oldest first. */
|
|
1413
|
+
getFailedDreamRows(limit = 100) {
|
|
1414
|
+
return this.stmt('failed_dream_rows', `
|
|
1415
|
+
SELECT * FROM dream_queue
|
|
1416
|
+
WHERE status = 'failed'
|
|
1417
|
+
ORDER BY rowid ASC
|
|
1418
|
+
LIMIT ?
|
|
1419
|
+
`).all(limit);
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Requeue all `failed` rows back to `pending` with a fresh attempts counter —
|
|
1423
|
+
* for retrying transient failures after the underlying cause is fixed. (Rows
|
|
1424
|
+
* that fail deterministically, e.g. corrupt JSON, will simply re-park on the
|
|
1425
|
+
* next dream; use `purgeFailedDreamRows` for those.) Returns rows requeued.
|
|
1426
|
+
*/
|
|
1427
|
+
requeueFailedDreamRows() {
|
|
1428
|
+
return this.stmt('requeue_failed_dream', `
|
|
1429
|
+
UPDATE dream_queue
|
|
1430
|
+
SET status = 'pending', attempts = 0, lease_owner = NULL, lease_expires_at = NULL
|
|
1431
|
+
WHERE status = 'failed'
|
|
1432
|
+
`).run().changes;
|
|
1433
|
+
}
|
|
1434
|
+
/** Permanently delete all `failed` rows (corrupt/unrecoverable). Returns count. */
|
|
1435
|
+
purgeFailedDreamRows() {
|
|
1436
|
+
return this.stmt('purge_failed_dream', `
|
|
1437
|
+
DELETE FROM dream_queue WHERE status = 'failed'
|
|
1438
|
+
`).run().changes;
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* Try to acquire the singleton cross-process dream lock. Returns true if the
|
|
1442
|
+
* caller now holds it (no current holder, or the prior lease expired). Lets an
|
|
1443
|
+
* in-process scheduler and a separate `dream` process avoid dreaming at once.
|
|
1444
|
+
* The row-claim transaction already prevents two dreamers from claiming the
|
|
1445
|
+
* same rows; this additionally avoids wasteful concurrent dreams and
|
|
1446
|
+
* maintenance races. Compare-and-set runs in a transaction for atomicity.
|
|
1447
|
+
*/
|
|
1448
|
+
acquireDreamLock(owner, ttlMs, now = new Date()) {
|
|
1449
|
+
return this.transactionImmediate(() => {
|
|
1450
|
+
const cur = this.getSystemState('dream_lock');
|
|
1451
|
+
// Blocked only by a *different* owner whose lease is still live; the
|
|
1452
|
+
// current holder may re-acquire to refresh its lease (heartbeat).
|
|
1453
|
+
if (cur && cur.owner !== owner && new Date(cur.expiresAt).getTime() > now.getTime()) {
|
|
1454
|
+
return false;
|
|
1455
|
+
}
|
|
1456
|
+
this.setSystemState('dream_lock', {
|
|
1457
|
+
owner,
|
|
1458
|
+
expiresAt: new Date(now.getTime() + ttlMs).toISOString(),
|
|
1459
|
+
});
|
|
1460
|
+
return true;
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* Release the dream lock if held by `owner` (no-op otherwise). Single atomic
|
|
1465
|
+
* conditional DELETE so a late releaser can't stomp a successor's lock that
|
|
1466
|
+
* was acquired after this owner's lease expired.
|
|
1467
|
+
*/
|
|
1468
|
+
releaseDreamLock(owner) {
|
|
1469
|
+
this.stmt('release_dream_lock', `
|
|
1470
|
+
DELETE FROM system_state
|
|
1471
|
+
WHERE key = 'dream_lock' AND json_extract(value, '$.owner') = ?
|
|
1472
|
+
`).run(owner);
|
|
1473
|
+
}
|
|
1474
|
+
// ==========================================================================
|
|
1475
|
+
// Distillation Cache (PR-D1)
|
|
1476
|
+
// ==========================================================================
|
|
1477
|
+
/**
|
|
1478
|
+
* Look up a cached distillation result by cache_key.
|
|
1479
|
+
* Returns undefined on miss or when persistence is not initialized.
|
|
1480
|
+
*/
|
|
1481
|
+
getDistillationCache(cacheKey) {
|
|
1482
|
+
const row = this.stmt('get_distillation_cache', 'SELECT cache_key, playbook_json, created_at FROM distillation_cache WHERE cache_key = ?').get(cacheKey);
|
|
1483
|
+
return row ?? undefined;
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* Store a distillation result. INSERT OR REPLACE so a re-distillation
|
|
1487
|
+
* (e.g. after a prompt-version bump invalidating a stale entry) wins.
|
|
1488
|
+
*/
|
|
1489
|
+
setDistillationCache(entry) {
|
|
1490
|
+
this.stmt('set_distillation_cache', `INSERT OR REPLACE INTO distillation_cache (cache_key, playbook_json, created_at)
|
|
1491
|
+
VALUES (?, ?, ?)`).run(entry.cache_key, entry.playbook_json, entry.created_at);
|
|
1492
|
+
}
|
|
1493
|
+
// ==========================================================================
|
|
1494
|
+
// Lift registry (production rollup — dream-time, write-only)
|
|
1495
|
+
// ==========================================================================
|
|
1496
|
+
/**
|
|
1497
|
+
* Fold one trajectory's outcome into its lift cell. One call = one
|
|
1498
|
+
* observation, so counters (and `runs`) increment by 1 — in the production
|
|
1499
|
+
* scope `runs` therefore equals total observations, unlike eval scopes
|
|
1500
|
+
* where a run is an ingested artifact. Cheap single upsert: safe for the
|
|
1501
|
+
* dream path.
|
|
1502
|
+
*/
|
|
1503
|
+
recordLiftOutcome(input) {
|
|
1504
|
+
this.stmt('record_lift_outcome', `
|
|
1505
|
+
INSERT INTO lift_cells
|
|
1506
|
+
(scope, family, solver, guided_attempts, guided_successes,
|
|
1507
|
+
unguided_attempts, unguided_successes, runs, updated_at)
|
|
1508
|
+
VALUES (@scope, @family, @solver, @ga, @gs, @ua, @us, 1, @now)
|
|
1509
|
+
ON CONFLICT(scope, family, solver) DO UPDATE SET
|
|
1510
|
+
guided_attempts = guided_attempts + @ga,
|
|
1511
|
+
guided_successes = guided_successes + @gs,
|
|
1512
|
+
unguided_attempts = unguided_attempts + @ua,
|
|
1513
|
+
unguided_successes = unguided_successes + @us,
|
|
1514
|
+
runs = runs + 1,
|
|
1515
|
+
updated_at = @now
|
|
1516
|
+
`).run({
|
|
1517
|
+
scope: input.scope,
|
|
1518
|
+
family: input.family,
|
|
1519
|
+
solver: input.solver,
|
|
1520
|
+
ga: input.guided ? 1 : 0,
|
|
1521
|
+
gs: input.guided && input.success ? 1 : 0,
|
|
1522
|
+
ua: input.guided ? 0 : 1,
|
|
1523
|
+
us: !input.guided && input.success ? 1 : 0,
|
|
1524
|
+
now: new Date().toISOString(),
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
/** All lift cells (for the lift report / tests). */
|
|
1528
|
+
getLiftCells() {
|
|
1529
|
+
return this.stmt('get_lift_cells', 'SELECT * FROM lift_cells ORDER BY scope, family, solver').all();
|
|
1530
|
+
}
|
|
1531
|
+
// ==========================================================================
|
|
541
1532
|
// System State (key-value store for singleton blobs)
|
|
542
1533
|
// ==========================================================================
|
|
543
1534
|
getSystemState(key) {
|