@soleri/core 9.0.3 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/brain/intelligence.d.ts +27 -0
- package/dist/brain/intelligence.d.ts.map +1 -1
- package/dist/brain/intelligence.js +160 -14
- package/dist/brain/intelligence.js.map +1 -1
- package/dist/brain/learning-radar.d.ts +4 -0
- package/dist/brain/learning-radar.d.ts.map +1 -1
- package/dist/brain/learning-radar.js +20 -1
- package/dist/brain/learning-radar.js.map +1 -1
- package/dist/brain/strength-scorer.d.ts +31 -0
- package/dist/brain/strength-scorer.d.ts.map +1 -0
- package/dist/brain/strength-scorer.js +264 -0
- package/dist/brain/strength-scorer.js.map +1 -0
- package/dist/chat/agent-loop.d.ts.map +1 -1
- package/dist/chat/agent-loop.js +2 -0
- package/dist/chat/agent-loop.js.map +1 -1
- package/dist/chat/notifications.d.ts.map +1 -1
- package/dist/chat/notifications.js +2 -0
- package/dist/chat/notifications.js.map +1 -1
- package/dist/claudemd/compose.js +1 -1
- package/dist/claudemd/compose.js.map +1 -1
- package/dist/control/intent-router.d.ts.map +1 -1
- package/dist/control/intent-router.js +12 -4
- package/dist/control/intent-router.js.map +1 -1
- package/dist/curator/contradiction-detector.d.ts +27 -0
- package/dist/curator/contradiction-detector.d.ts.map +1 -0
- package/dist/curator/contradiction-detector.js +62 -0
- package/dist/curator/contradiction-detector.js.map +1 -0
- package/dist/curator/curator.d.ts +3 -4
- package/dist/curator/curator.d.ts.map +1 -1
- package/dist/curator/curator.js +90 -525
- package/dist/curator/curator.js.map +1 -1
- package/dist/curator/duplicate-detector.d.ts +14 -0
- package/dist/curator/duplicate-detector.d.ts.map +1 -0
- package/dist/curator/duplicate-detector.js +77 -0
- package/dist/curator/duplicate-detector.js.map +1 -0
- package/dist/curator/health-audit.d.ts +15 -0
- package/dist/curator/health-audit.d.ts.map +1 -0
- package/dist/curator/health-audit.js +97 -0
- package/dist/curator/health-audit.js.map +1 -0
- package/dist/curator/metadata-enricher.d.ts +17 -0
- package/dist/curator/metadata-enricher.d.ts.map +1 -0
- package/dist/curator/metadata-enricher.js +60 -0
- package/dist/curator/metadata-enricher.js.map +1 -0
- package/dist/curator/schema.d.ts +7 -0
- package/dist/curator/schema.d.ts.map +1 -0
- package/dist/curator/schema.js +62 -0
- package/dist/curator/schema.js.map +1 -0
- package/dist/curator/tag-manager.d.ts +36 -0
- package/dist/curator/tag-manager.d.ts.map +1 -0
- package/dist/curator/tag-manager.js +78 -0
- package/dist/curator/tag-manager.js.map +1 -0
- package/dist/engine/bin/soleri-engine.js +55 -3
- package/dist/engine/bin/soleri-engine.js.map +1 -1
- package/dist/engine/core-ops.d.ts.map +1 -1
- package/dist/engine/core-ops.js +33 -10
- package/dist/engine/core-ops.js.map +1 -1
- package/dist/engine/module-manifest.d.ts.map +1 -1
- package/dist/engine/module-manifest.js +22 -2
- package/dist/engine/module-manifest.js.map +1 -1
- package/dist/engine/register-engine.d.ts.map +1 -1
- package/dist/engine/register-engine.js +26 -2
- package/dist/engine/register-engine.js.map +1 -1
- package/dist/errors/retry.d.ts.map +1 -1
- package/dist/errors/retry.js +2 -0
- package/dist/errors/retry.js.map +1 -1
- package/dist/facades/types.d.ts +1 -1
- package/dist/flows/chain-types.d.ts +18 -18
- package/dist/flows/gate-evaluator.d.ts.map +1 -1
- package/dist/flows/gate-evaluator.js +22 -0
- package/dist/flows/gate-evaluator.js.map +1 -1
- package/dist/flows/types.d.ts +157 -28
- package/dist/flows/types.d.ts.map +1 -1
- package/dist/flows/types.js +4 -0
- package/dist/flows/types.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/intake/intake-pipeline.d.ts.map +1 -1
- package/dist/intake/intake-pipeline.js +1 -0
- package/dist/intake/intake-pipeline.js.map +1 -1
- package/dist/intake/text-ingester.d.ts.map +1 -1
- package/dist/intake/text-ingester.js +2 -0
- package/dist/intake/text-ingester.js.map +1 -1
- package/dist/llm/key-pool.d.ts +1 -1
- package/dist/llm/key-pool.d.ts.map +1 -1
- package/dist/llm/key-pool.js +3 -4
- package/dist/llm/key-pool.js.map +1 -1
- package/dist/llm/utils.d.ts.map +1 -1
- package/dist/llm/utils.js +2 -0
- package/dist/llm/utils.js.map +1 -1
- package/dist/migrations/migration-runner.test-helpers.d.ts +13 -0
- package/dist/migrations/migration-runner.test-helpers.d.ts.map +1 -0
- package/dist/migrations/migration-runner.test-helpers.js +47 -0
- package/dist/migrations/migration-runner.test-helpers.js.map +1 -0
- package/dist/operator/operator-profile.d.ts +44 -0
- package/dist/operator/operator-profile.d.ts.map +1 -0
- package/dist/operator/operator-profile.js +377 -0
- package/dist/operator/operator-profile.js.map +1 -0
- package/dist/operator/operator-signals.d.ts +45 -0
- package/dist/operator/operator-signals.d.ts.map +1 -0
- package/dist/operator/operator-signals.js +228 -0
- package/dist/operator/operator-signals.js.map +1 -0
- package/dist/operator/operator-types.d.ts +360 -0
- package/dist/operator/operator-types.d.ts.map +1 -0
- package/dist/operator/operator-types.js +24 -0
- package/dist/operator/operator-types.js.map +1 -0
- package/dist/packs/types.d.ts +27 -27
- package/dist/paths.d.ts +40 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +98 -0
- package/dist/paths.js.map +1 -0
- package/dist/persistence/index.d.ts +1 -1
- 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/sqlite-provider.d.ts +2 -0
- package/dist/persistence/sqlite-provider.d.ts.map +1 -1
- package/dist/persistence/sqlite-provider.js +8 -5
- package/dist/persistence/sqlite-provider.js.map +1 -1
- package/dist/planning/evidence-collector.d.ts +13 -1
- package/dist/planning/evidence-collector.d.ts.map +1 -1
- package/dist/planning/evidence-collector.js +33 -0
- package/dist/planning/evidence-collector.js.map +1 -1
- package/dist/planning/gap-analysis.d.ts +5 -4
- package/dist/planning/gap-analysis.d.ts.map +1 -1
- package/dist/planning/gap-analysis.js +7 -341
- package/dist/planning/gap-analysis.js.map +1 -1
- package/dist/planning/gap-passes.d.ts +19 -0
- package/dist/planning/gap-passes.d.ts.map +1 -0
- package/dist/planning/gap-passes.js +157 -0
- package/dist/planning/gap-passes.js.map +1 -0
- package/dist/planning/gap-patterns.d.ts +29 -0
- package/dist/planning/gap-patterns.d.ts.map +1 -0
- package/dist/planning/gap-patterns.js +129 -0
- package/dist/planning/gap-patterns.js.map +1 -0
- package/dist/planning/gap-types.d.ts +1 -1
- package/dist/planning/gap-types.d.ts.map +1 -1
- package/dist/planning/gap-types.js +1 -0
- package/dist/planning/gap-types.js.map +1 -1
- package/dist/planning/github-projection.d.ts +122 -0
- package/dist/planning/github-projection.d.ts.map +1 -0
- package/dist/planning/github-projection.js +294 -0
- package/dist/planning/github-projection.js.map +1 -0
- package/dist/planning/impact-analyzer.d.ts +26 -0
- package/dist/planning/impact-analyzer.d.ts.map +1 -0
- package/dist/planning/impact-analyzer.js +199 -0
- package/dist/planning/impact-analyzer.js.map +1 -0
- package/dist/planning/plan-lifecycle.d.ts +136 -0
- package/dist/planning/plan-lifecycle.d.ts.map +1 -0
- package/dist/planning/plan-lifecycle.js +296 -0
- package/dist/planning/plan-lifecycle.js.map +1 -0
- package/dist/planning/planner-types.d.ts +202 -0
- package/dist/planning/planner-types.d.ts.map +1 -0
- package/dist/planning/planner-types.js +6 -0
- package/dist/planning/planner-types.js.map +1 -0
- package/dist/planning/planner.d.ts +31 -383
- package/dist/planning/planner.d.ts.map +1 -1
- package/dist/planning/planner.js +154 -878
- package/dist/planning/planner.js.map +1 -1
- package/dist/planning/rationalization-detector.d.ts +32 -0
- package/dist/planning/rationalization-detector.d.ts.map +1 -0
- package/dist/planning/rationalization-detector.js +89 -0
- package/dist/planning/rationalization-detector.js.map +1 -0
- package/dist/planning/reconciliation-engine.d.ts +47 -0
- package/dist/planning/reconciliation-engine.d.ts.map +1 -0
- package/dist/planning/reconciliation-engine.js +128 -0
- package/dist/planning/reconciliation-engine.js.map +1 -0
- package/dist/planning/task-verifier.d.ts +85 -0
- package/dist/planning/task-verifier.d.ts.map +1 -0
- package/dist/planning/task-verifier.js +227 -0
- package/dist/planning/task-verifier.js.map +1 -0
- package/dist/plugins/types.d.ts +4 -4
- package/dist/runtime/admin-ops.d.ts +2 -2
- package/dist/runtime/admin-ops.d.ts.map +1 -1
- package/dist/runtime/admin-ops.js +44 -17
- package/dist/runtime/admin-ops.js.map +1 -1
- package/dist/runtime/admin-setup-ops.d.ts.map +1 -1
- package/dist/runtime/admin-setup-ops.js +21 -46
- package/dist/runtime/admin-setup-ops.js.map +1 -1
- package/dist/runtime/archive-ops.d.ts +10 -0
- package/dist/runtime/archive-ops.d.ts.map +1 -0
- package/dist/runtime/archive-ops.js +310 -0
- package/dist/runtime/archive-ops.js.map +1 -0
- package/dist/runtime/capture-ops.d.ts.map +1 -1
- package/dist/runtime/capture-ops.js +42 -7
- package/dist/runtime/capture-ops.js.map +1 -1
- package/dist/runtime/claude-md-helpers.js +1 -1
- package/dist/runtime/claude-md-helpers.js.map +1 -1
- package/dist/runtime/context-health.d.ts +31 -0
- package/dist/runtime/context-health.d.ts.map +1 -0
- package/dist/runtime/context-health.js +57 -0
- package/dist/runtime/context-health.js.map +1 -0
- package/dist/runtime/facades/archive-facade.d.ts +10 -0
- package/dist/runtime/facades/archive-facade.d.ts.map +1 -0
- package/dist/runtime/facades/archive-facade.js +11 -0
- package/dist/runtime/facades/archive-facade.js.map +1 -0
- package/dist/runtime/facades/brain-facade.d.ts.map +1 -1
- package/dist/runtime/facades/brain-facade.js +2 -0
- package/dist/runtime/facades/brain-facade.js.map +1 -1
- package/dist/runtime/facades/chat-facade.d.ts +7 -0
- package/dist/runtime/facades/chat-facade.d.ts.map +1 -1
- package/dist/runtime/facades/chat-facade.js +15 -800
- package/dist/runtime/facades/chat-facade.js.map +1 -1
- package/dist/runtime/facades/chat-service-ops.d.ts +9 -0
- package/dist/runtime/facades/chat-service-ops.d.ts.map +1 -0
- package/dist/runtime/facades/chat-service-ops.js +330 -0
- package/dist/runtime/facades/chat-service-ops.js.map +1 -0
- package/dist/runtime/facades/chat-session-ops.d.ts +8 -0
- package/dist/runtime/facades/chat-session-ops.d.ts.map +1 -0
- package/dist/runtime/facades/chat-session-ops.js +136 -0
- package/dist/runtime/facades/chat-session-ops.js.map +1 -0
- package/dist/runtime/facades/chat-state.d.ts +31 -0
- package/dist/runtime/facades/chat-state.d.ts.map +1 -0
- package/dist/runtime/facades/chat-state.js +32 -0
- package/dist/runtime/facades/chat-state.js.map +1 -0
- package/dist/runtime/facades/chat-transport-ops.d.ts +9 -0
- package/dist/runtime/facades/chat-transport-ops.d.ts.map +1 -0
- package/dist/runtime/facades/chat-transport-ops.js +337 -0
- package/dist/runtime/facades/chat-transport-ops.js.map +1 -0
- package/dist/runtime/facades/control-facade.d.ts.map +1 -1
- package/dist/runtime/facades/control-facade.js +4 -1
- package/dist/runtime/facades/control-facade.js.map +1 -1
- package/dist/runtime/facades/index.d.ts.map +1 -1
- package/dist/runtime/facades/index.js +6 -0
- package/dist/runtime/facades/index.js.map +1 -1
- package/dist/runtime/facades/memory-facade.d.ts.map +1 -1
- package/dist/runtime/facades/memory-facade.js +75 -6
- package/dist/runtime/facades/memory-facade.js.map +1 -1
- package/dist/runtime/facades/operator-facade.d.ts +8 -0
- package/dist/runtime/facades/operator-facade.d.ts.map +1 -0
- package/dist/runtime/facades/operator-facade.js +220 -0
- package/dist/runtime/facades/operator-facade.js.map +1 -0
- package/dist/runtime/facades/orchestrate-facade.js +3 -3
- package/dist/runtime/facades/orchestrate-facade.js.map +1 -1
- package/dist/runtime/facades/plan-facade.d.ts.map +1 -1
- package/dist/runtime/facades/plan-facade.js +39 -6
- package/dist/runtime/facades/plan-facade.js.map +1 -1
- package/dist/runtime/facades/review-facade.d.ts +7 -0
- package/dist/runtime/facades/review-facade.d.ts.map +1 -0
- package/dist/runtime/facades/review-facade.js +8 -0
- package/dist/runtime/facades/review-facade.js.map +1 -0
- package/dist/runtime/facades/sync-facade.d.ts +7 -0
- package/dist/runtime/facades/sync-facade.d.ts.map +1 -0
- package/dist/runtime/facades/sync-facade.js +8 -0
- package/dist/runtime/facades/sync-facade.js.map +1 -0
- package/dist/runtime/facades/vault-facade.d.ts +4 -1
- package/dist/runtime/facades/vault-facade.d.ts.map +1 -1
- package/dist/runtime/facades/vault-facade.js +13 -66
- package/dist/runtime/facades/vault-facade.js.map +1 -1
- package/dist/runtime/github-integration.d.ts +49 -0
- package/dist/runtime/github-integration.d.ts.map +1 -0
- package/dist/runtime/github-integration.js +113 -0
- package/dist/runtime/github-integration.js.map +1 -0
- package/dist/runtime/grading-ops.js +1 -1
- package/dist/runtime/grading-ops.js.map +1 -1
- package/dist/runtime/memory-extra-ops.d.ts.map +1 -1
- package/dist/runtime/memory-extra-ops.js +6 -2
- package/dist/runtime/memory-extra-ops.js.map +1 -1
- package/dist/runtime/orchestrate-ops.d.ts.map +1 -1
- package/dist/runtime/orchestrate-ops.js +367 -40
- package/dist/runtime/orchestrate-ops.js.map +1 -1
- package/dist/runtime/planning-extra-ops.d.ts.map +1 -1
- package/dist/runtime/planning-extra-ops.js +69 -4
- package/dist/runtime/planning-extra-ops.js.map +1 -1
- package/dist/runtime/review-ops.d.ts +10 -0
- package/dist/runtime/review-ops.d.ts.map +1 -0
- package/dist/runtime/review-ops.js +97 -0
- package/dist/runtime/review-ops.js.map +1 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +27 -12
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/session-briefing.d.ts +3 -0
- package/dist/runtime/session-briefing.d.ts.map +1 -1
- package/dist/runtime/session-briefing.js +68 -1
- package/dist/runtime/session-briefing.js.map +1 -1
- package/dist/runtime/sync-ops.d.ts +12 -0
- package/dist/runtime/sync-ops.d.ts.map +1 -0
- package/dist/runtime/sync-ops.js +288 -0
- package/dist/runtime/sync-ops.js.map +1 -0
- package/dist/runtime/types.d.ts +10 -4
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/vault-extra-ops.d.ts +5 -4
- package/dist/runtime/vault-extra-ops.d.ts.map +1 -1
- package/dist/runtime/vault-extra-ops.js +5 -300
- package/dist/runtime/vault-extra-ops.js.map +1 -1
- package/dist/runtime/vault-sharing-ops.d.ts +4 -4
- package/dist/runtime/vault-sharing-ops.d.ts.map +1 -1
- package/dist/runtime/vault-sharing-ops.js +5 -300
- package/dist/runtime/vault-sharing-ops.js.map +1 -1
- package/dist/skills/sync-skills.d.ts +27 -0
- package/dist/skills/sync-skills.d.ts.map +1 -0
- package/dist/skills/sync-skills.js +81 -0
- package/dist/skills/sync-skills.js.map +1 -0
- package/dist/update-check.d.ts +14 -0
- package/dist/update-check.d.ts.map +1 -0
- package/dist/update-check.js +96 -0
- package/dist/update-check.js.map +1 -0
- package/dist/vault/linking.d.ts +10 -12
- package/dist/vault/linking.d.ts.map +1 -1
- package/dist/vault/linking.js +104 -161
- package/dist/vault/linking.js.map +1 -1
- package/dist/vault/vault-entries.d.ts +69 -0
- package/dist/vault/vault-entries.d.ts.map +1 -0
- package/dist/vault/vault-entries.js +257 -0
- package/dist/vault/vault-entries.js.map +1 -0
- package/dist/vault/vault-interfaces.d.ts +153 -0
- package/dist/vault/vault-interfaces.d.ts.map +1 -0
- package/dist/vault/vault-interfaces.js +2 -0
- package/dist/vault/vault-interfaces.js.map +1 -0
- package/dist/vault/vault-maintenance.d.ts +40 -0
- package/dist/vault/vault-maintenance.d.ts.map +1 -0
- package/dist/vault/vault-maintenance.js +142 -0
- package/dist/vault/vault-maintenance.js.map +1 -0
- package/dist/vault/vault-markdown-sync.d.ts +22 -0
- package/dist/vault/vault-markdown-sync.d.ts.map +1 -0
- package/dist/vault/vault-markdown-sync.js +143 -0
- package/dist/vault/vault-markdown-sync.js.map +1 -0
- package/dist/vault/vault-memories.d.ts +61 -0
- package/dist/vault/vault-memories.d.ts.map +1 -0
- package/dist/vault/vault-memories.js +240 -0
- package/dist/vault/vault-memories.js.map +1 -0
- package/dist/vault/vault-schema.d.ts +9 -0
- package/dist/vault/vault-schema.d.ts.map +1 -0
- package/dist/vault/vault-schema.js +179 -0
- package/dist/vault/vault-schema.js.map +1 -0
- package/dist/vault/vault.d.ts +29 -81
- package/dist/vault/vault.d.ts.map +1 -1
- package/dist/vault/vault.js +78 -931
- package/dist/vault/vault.js.map +1 -1
- package/package.json +1 -1
- package/src/agency/agency-manager.test.ts +600 -0
- package/src/agency/default-rules.test.ts +228 -0
- package/src/{__tests__ → brain}/brain-intelligence.test.ts +37 -14
- package/src/{__tests__ → brain}/brain.test.ts +1 -1
- package/src/brain/intelligence.ts +196 -15
- package/src/brain/learning-radar.ts +22 -1
- package/src/{__tests__ → brain}/second-brain-features.test.ts +4 -4
- package/src/{__tests__ → brain}/session-lifecycle.test.ts +2 -2
- package/src/brain/strength-scorer.ts +404 -0
- package/src/capabilities/chain-mapping.test.ts +66 -0
- package/src/capabilities/registry.test.ts +369 -0
- package/src/chat/agent-loop.test.ts +394 -0
- package/src/chat/agent-loop.ts +2 -0
- package/src/{__tests__ → chat}/chat-differentiators.test.ts +3 -3
- package/src/{__tests__ → chat}/chat-enhanced.test.ts +4 -4
- package/src/{__tests__ → chat}/chat-transport.test.ts +6 -6
- package/src/chat/mcp-bridge.test.ts +173 -0
- package/src/chat/notifications.ts +2 -0
- package/src/chat/output-compressor.test.ts +164 -0
- package/src/claudemd/compose.test.ts +178 -0
- package/src/claudemd/compose.ts +1 -1
- package/src/claudemd/inject.test.ts +211 -0
- package/src/context/context-engine.test.ts +461 -0
- package/src/control/identity-manager.test.ts +305 -0
- package/src/control/intent-router.test.ts +360 -0
- package/src/control/intent-router.ts +13 -4
- package/src/curator/classifier.test.ts +104 -0
- package/src/curator/contradiction-detector.test.ts +180 -0
- package/src/curator/contradiction-detector.ts +87 -0
- package/src/{__tests__ → curator}/curator-pipeline-e2e.test.ts +10 -10
- package/src/{__tests__ → curator}/curator.test.ts +77 -1
- package/src/curator/curator.ts +115 -777
- package/src/curator/duplicate-detector.test.ts +183 -0
- package/src/curator/duplicate-detector.ts +103 -0
- package/src/curator/health-audit.ts +126 -0
- package/src/curator/metadata-enricher.ts +84 -0
- package/src/curator/quality-gate.test.ts +135 -0
- package/src/curator/schema.ts +65 -0
- package/src/curator/tag-manager.test.ts +165 -0
- package/src/curator/tag-manager.ts +109 -0
- package/src/domain-packs/inject-rules.test.ts +117 -0
- package/src/domain-packs/knowledge-installer.test.ts +171 -0
- package/src/domain-packs/loader.test.ts +86 -0
- package/src/domain-packs/pack-runtime.test.ts +140 -0
- package/src/domain-packs/skills-installer.test.ts +135 -0
- package/src/domain-packs/token-resolver.test.ts +150 -0
- package/src/domain-packs/types.test.ts +130 -0
- package/src/enforcement/adapters/claude-code.test.ts +216 -0
- package/src/enforcement/registry.test.ts +264 -0
- package/src/engine/bin/soleri-engine.ts +59 -3
- package/src/engine/core-ops.test.ts +254 -0
- package/src/engine/core-ops.ts +35 -10
- package/src/engine/module-manifest.test.ts +124 -0
- package/src/engine/module-manifest.ts +22 -2
- package/src/engine/register-engine.test.ts +230 -0
- package/src/engine/register-engine.ts +26 -2
- package/src/errors/classify.test.ts +199 -0
- package/src/errors/retry.test.ts +156 -0
- package/src/errors/retry.ts +2 -0
- package/src/errors/types.test.ts +108 -0
- package/src/events/event-bus.test.ts +149 -0
- package/src/extensions/middleware.test.ts +234 -0
- package/src/facades/facade-factory.test.ts +424 -0
- package/src/flows/chain-runner.test.ts +273 -0
- package/src/flows/context-router.test.ts +52 -0
- package/src/flows/dispatch-registry.test.ts +128 -0
- package/src/flows/epilogue.test.ts +107 -0
- package/src/flows/executor.test.ts +263 -0
- package/src/flows/gate-evaluator.test.ts +194 -0
- package/src/flows/gate-evaluator.ts +25 -0
- package/src/flows/types.ts +4 -0
- package/src/governance/governance.test.ts +726 -0
- package/src/health/health-registry.test.ts +186 -0
- package/src/health/vault-integrity.test.ts +110 -0
- package/src/index.ts +92 -0
- package/src/intake/content-classifier.test.ts +209 -0
- package/src/intake/dedup-gate.test.ts +131 -0
- package/src/intake/intake-pipeline.test.ts +506 -0
- package/src/intake/intake-pipeline.ts +1 -0
- package/src/intake/text-ingester.test.ts +194 -0
- package/src/intake/text-ingester.ts +2 -0
- package/src/llm/key-pool.test.ts +236 -0
- package/src/llm/key-pool.ts +3 -4
- package/src/llm/llm-client.test.ts +345 -0
- package/src/llm/oauth-discovery.test.ts +180 -0
- package/src/llm/utils.test.ts +327 -0
- package/src/llm/utils.ts +2 -0
- package/src/{__tests__ → logging}/logger.test.ts +41 -62
- package/src/loop/loop-manager.test.ts +519 -0
- package/src/migrations/migration-runner.edge-cases.test.ts +319 -0
- package/src/migrations/migration-runner.test-helpers.ts +64 -0
- package/src/migrations/migration-runner.test.ts +385 -0
- package/src/operator/auto-signal-pipeline.test.ts +207 -0
- package/src/operator/operator-profile-extended.test.ts +320 -0
- package/src/operator/operator-profile.test.ts +314 -0
- package/src/operator/operator-profile.ts +469 -0
- package/src/operator/operator-signals-extended.test.ts +245 -0
- package/src/operator/operator-signals.test.ts +281 -0
- package/src/operator/operator-signals.ts +261 -0
- package/src/operator/operator-types.ts +444 -0
- package/src/operator/prompts/hook-precompact-operator-dispatch.md +94 -0
- package/src/operator/prompts/subagent-soft-signal-extractor.md +125 -0
- package/src/operator/prompts/subagent-synthesis-cognition.md +181 -0
- package/src/operator/prompts/subagent-synthesis-communication.md +140 -0
- package/src/operator/prompts/subagent-synthesis-technical.md +160 -0
- package/src/operator/prompts/subagent-synthesis-trust.md +143 -0
- package/src/{__tests__ → packs}/pack-lockfile.test.ts +3 -3
- package/src/{__tests__ → packs}/pack-system.test.ts +2 -2
- package/src/paths.ts +115 -0
- package/src/persistence/index.ts +1 -1
- package/src/persistence/sqlite-provider.test.ts +540 -0
- package/src/persistence/sqlite-provider.ts +8 -5
- package/src/persona/defaults.test.ts +59 -0
- package/src/persona/loader.test.ts +67 -0
- package/src/persona/prompt-generator.test.ts +127 -0
- package/src/planning/evidence-collector.test.ts +406 -0
- package/src/planning/evidence-collector.ts +50 -0
- package/src/planning/gap-analysis-alternatives.test.ts +169 -0
- package/src/planning/gap-analysis.ts +21 -636
- package/src/planning/gap-passes.test.ts +372 -0
- package/src/planning/gap-passes.ts +298 -0
- package/src/planning/gap-patterns.test.ts +320 -0
- package/src/planning/gap-patterns.ts +234 -0
- package/src/planning/gap-types.ts +4 -1
- package/src/planning/github-projection.test.ts +177 -0
- package/src/planning/github-projection.ts +425 -0
- package/src/planning/impact-analyzer.test.ts +180 -0
- package/src/planning/impact-analyzer.ts +264 -0
- package/src/planning/plan-lifecycle.test.ts +312 -0
- package/src/planning/plan-lifecycle.ts +346 -0
- package/src/planning/planner-types.ts +215 -0
- package/src/{__tests__ → planning}/planner.test.ts +169 -15
- package/src/planning/planner.ts +197 -1228
- package/src/planning/rationalization-detector.test.ts +171 -0
- package/src/planning/rationalization-detector.ts +138 -0
- package/src/planning/reconciliation-engine.test.ts +141 -0
- package/src/planning/reconciliation-engine.ts +162 -0
- package/src/planning/task-verifier.test.ts +235 -0
- package/src/planning/task-verifier.ts +303 -0
- package/src/planning/verification-protocol.test.ts +201 -0
- package/src/playbooks/generic/generic-playbooks.test.ts +438 -0
- package/src/playbooks/index.test.ts +77 -0
- package/src/playbooks/playbook-executor.test.ts +255 -0
- package/src/playbooks/playbook-registry.test.ts +232 -0
- package/src/playbooks/playbook-seeder.test.ts +153 -0
- package/src/plugins/plugin-loader.test.ts +212 -0
- package/src/plugins/plugin-registry.test.ts +272 -0
- package/src/project/project-registry.test.ts +428 -0
- package/src/prompts/parser.test.ts +100 -0
- package/src/prompts/template-manager.test.ts +109 -0
- package/src/{__tests__ → queue}/async-infrastructure.test.ts +3 -3
- package/src/queue/job-queue.test.ts +331 -0
- package/src/queue/pipeline-runner.test.ts +209 -0
- package/src/runtime/admin-extra-ops.test.ts +527 -0
- package/src/runtime/admin-ops.test.ts +257 -0
- package/src/runtime/admin-ops.ts +45 -17
- package/src/runtime/admin-setup-ops.test.ts +328 -0
- package/src/runtime/admin-setup-ops.ts +20 -43
- package/src/runtime/archive-ops.test.ts +269 -0
- package/src/runtime/archive-ops.ts +347 -0
- package/src/runtime/capture-ops.test.ts +433 -0
- package/src/runtime/capture-ops.ts +50 -8
- package/src/runtime/chain-ops.test.ts +149 -0
- package/src/runtime/claude-md-helpers.test.ts +191 -0
- package/src/runtime/claude-md-helpers.ts +1 -1
- package/src/runtime/context-health.test.ts +78 -0
- package/src/runtime/context-health.ts +85 -0
- package/src/runtime/curator-extra-ops.test.ts +202 -0
- package/src/runtime/deprecation.test.ts +98 -0
- package/src/runtime/domain-ops.test.ts +268 -0
- package/src/runtime/facades/admin-facade.test.ts +333 -0
- package/src/runtime/facades/agency-facade.test.ts +278 -0
- package/src/runtime/facades/archive-facade.test.ts +294 -0
- package/src/runtime/facades/archive-facade.ts +14 -0
- package/src/runtime/facades/brain-facade.test.ts +714 -0
- package/src/runtime/facades/brain-facade.ts +2 -0
- package/src/runtime/facades/chat-facade.test.ts +166 -0
- package/src/runtime/facades/chat-facade.ts +15 -906
- package/src/runtime/facades/chat-service-ops.test.ts +276 -0
- package/src/runtime/facades/chat-service-ops.ts +374 -0
- package/src/runtime/facades/chat-session-ops.test.ts +197 -0
- package/src/runtime/facades/chat-session-ops.ts +146 -0
- package/src/runtime/facades/chat-state.ts +60 -0
- package/src/runtime/facades/chat-transport-ops.test.ts +269 -0
- package/src/runtime/facades/chat-transport-ops.ts +380 -0
- package/src/runtime/facades/context-facade.test.ts +108 -0
- package/src/runtime/facades/control-facade.test.ts +436 -0
- package/src/runtime/facades/control-facade.ts +6 -1
- package/src/runtime/facades/curator-facade.test.ts +303 -0
- package/src/runtime/facades/index.ts +6 -0
- package/src/runtime/facades/loop-facade.test.ts +245 -0
- package/src/runtime/facades/memory-facade.test.ts +269 -0
- package/src/runtime/facades/memory-facade.ts +78 -6
- package/src/runtime/facades/operator-facade.test.ts +208 -0
- package/src/runtime/facades/operator-facade.ts +236 -0
- package/src/runtime/facades/orchestrate-facade.test.ts +185 -0
- package/src/runtime/facades/orchestrate-facade.ts +3 -3
- package/src/runtime/facades/plan-facade.test.ts +266 -0
- package/src/runtime/facades/plan-facade.ts +42 -6
- package/src/runtime/facades/review-facade.test.ts +82 -0
- package/src/runtime/facades/review-facade.ts +11 -0
- package/src/runtime/facades/sync-facade.test.ts +113 -0
- package/src/runtime/facades/sync-facade.ts +11 -0
- package/src/runtime/facades/vault-facade.test.ts +631 -0
- package/src/runtime/facades/vault-facade.ts +15 -70
- package/src/runtime/feature-flags.test.ts +140 -0
- package/src/runtime/github-integration.test.ts +89 -0
- package/src/runtime/github-integration.ts +159 -0
- package/src/runtime/grading-ops.test.ts +141 -0
- package/src/runtime/grading-ops.ts +1 -1
- package/src/runtime/intake-ops.test.ts +208 -0
- package/src/runtime/loop-ops.test.ts +238 -0
- package/src/runtime/memory-cross-project-ops.test.ts +177 -0
- package/src/runtime/memory-extra-ops.test.ts +453 -0
- package/src/runtime/memory-extra-ops.ts +6 -2
- package/src/runtime/orchestrate-ops.test.ts +302 -0
- package/src/runtime/orchestrate-ops.ts +435 -46
- package/src/runtime/pack-ops.test.ts +158 -0
- package/src/runtime/planning-extra-ops.test.ts +583 -0
- package/src/runtime/planning-extra-ops.ts +72 -4
- package/src/{__tests__ → runtime}/playbook-ops-execution.test.ts +3 -3
- package/src/runtime/playbook-ops.test.ts +262 -0
- package/src/runtime/plugin-ops.test.ts +201 -0
- package/src/runtime/project-ops.test.ts +235 -0
- package/src/runtime/review-ops.test.ts +142 -0
- package/src/runtime/review-ops.ts +99 -0
- package/src/runtime/runtime.test.ts +363 -0
- package/src/runtime/runtime.ts +39 -12
- package/src/runtime/session-briefing.test.ts +302 -0
- package/src/runtime/session-briefing.ts +80 -1
- package/src/runtime/sync-ops.test.ts +221 -0
- package/src/runtime/sync-ops.ts +325 -0
- package/src/runtime/telemetry-ops.test.ts +132 -0
- package/src/runtime/types.ts +10 -4
- package/src/runtime/vault-extra-ops.test.ts +246 -0
- package/src/runtime/vault-extra-ops.ts +5 -332
- package/src/runtime/vault-linking-ops.test.ts +237 -0
- package/src/runtime/vault-sharing-ops.test.ts +130 -0
- package/src/runtime/vault-sharing-ops.ts +5 -329
- package/src/skills/sync-skills.ts +108 -0
- package/src/streams/normalize.test.ts +95 -0
- package/src/streams/replayable-stream.test.ts +166 -0
- package/src/telemetry/telemetry.test.ts +143 -0
- package/src/transport/http-server.test.ts +394 -0
- package/src/transport/lsp-server.test.ts +458 -0
- package/src/transport/rate-limiter.test.ts +126 -0
- package/src/transport/session-manager.test.ts +133 -0
- package/src/transport/token-auth.test.ts +136 -0
- package/src/transport/ws-server.test.ts +294 -0
- package/src/update-check.ts +111 -0
- package/src/vault/__tests__/vault-characterization.test.ts +168 -0
- package/src/vault/content-hash.test.ts +78 -0
- package/src/vault/git-vault-sync.test.ts +234 -0
- package/src/vault/knowledge-review.test.ts +269 -0
- package/src/vault/linking.test.ts +358 -0
- package/src/vault/linking.ts +149 -183
- package/src/vault/obsidian-sync.test.ts +342 -0
- package/src/vault/playbook.test.ts +152 -0
- package/src/vault/scope-detector.test.ts +187 -0
- package/src/vault/vault-branching.test.ts +250 -0
- package/src/{__tests__ → vault}/vault-connect.test.ts +1 -1
- package/src/vault/vault-entries.ts +282 -0
- package/src/vault/vault-interfaces.ts +56 -0
- package/src/vault/vault-maintenance.ts +205 -0
- package/src/vault/vault-manager.test.ts +206 -0
- package/src/vault/vault-markdown-sync.test.ts +203 -0
- package/src/vault/vault-markdown-sync.ts +160 -0
- package/src/vault/vault-memories.ts +339 -0
- package/src/{__tests__ → vault}/vault-scaling.test.ts +1 -1
- package/src/vault/vault-schema.ts +181 -0
- package/src/{__tests__ → vault}/vault-sharing.test.ts +4 -4
- package/src/{__tests__ → vault}/vault.test.ts +2 -2
- package/src/vault/vault.ts +89 -1171
- package/dist/cognee/client.d.ts +0 -43
- package/dist/cognee/client.d.ts.map +0 -1
- package/dist/cognee/client.js +0 -375
- package/dist/cognee/client.js.map +0 -1
- package/dist/cognee/sync-manager.d.ts +0 -153
- package/dist/cognee/sync-manager.d.ts.map +0 -1
- package/dist/cognee/sync-manager.js +0 -390
- package/dist/cognee/sync-manager.js.map +0 -1
- package/dist/cognee/types.d.ts +0 -62
- package/dist/cognee/types.d.ts.map +0 -1
- package/dist/cognee/types.js +0 -3
- package/dist/cognee/types.js.map +0 -1
- package/dist/governance/index.d.ts +0 -3
- package/dist/governance/index.d.ts.map +0 -1
- package/dist/governance/index.js +0 -2
- package/dist/governance/index.js.map +0 -1
- package/dist/health/doctor-checks.d.ts +0 -15
- package/dist/health/doctor-checks.d.ts.map +0 -1
- package/dist/health/doctor-checks.js +0 -98
- package/dist/health/doctor-checks.js.map +0 -1
- package/dist/persistence/postgres-provider.d.ts +0 -81
- package/dist/persistence/postgres-provider.d.ts.map +0 -1
- package/dist/persistence/postgres-provider.js +0 -256
- package/dist/persistence/postgres-provider.js.map +0 -1
- package/dist/runtime/cognee-sync-ops.d.ts +0 -12
- package/dist/runtime/cognee-sync-ops.d.ts.map +0 -1
- package/dist/runtime/cognee-sync-ops.js +0 -93
- package/dist/runtime/cognee-sync-ops.js.map +0 -1
- package/dist/runtime/core-ops.d.ts +0 -23
- package/dist/runtime/core-ops.d.ts.map +0 -1
- package/dist/runtime/core-ops.js +0 -1296
- package/dist/runtime/core-ops.js.map +0 -1
- package/dist/runtime/facades/cognee-facade.d.ts +0 -8
- package/dist/runtime/facades/cognee-facade.d.ts.map +0 -1
- package/dist/runtime/facades/cognee-facade.js +0 -156
- package/dist/runtime/facades/cognee-facade.js.map +0 -1
- package/src/__tests__/admin-extra-ops.test.ts +0 -484
- package/src/__tests__/admin-ops.test.ts +0 -268
- package/src/__tests__/admin-setup-ops.test.ts +0 -355
- package/src/__tests__/agency-manager.test.ts +0 -374
- package/src/__tests__/agent-loop.test.ts +0 -256
- package/src/__tests__/capture-ops.test.ts +0 -784
- package/src/__tests__/claudemd.test.ts +0 -282
- package/src/__tests__/content-hash.test.ts +0 -60
- package/src/__tests__/context-engine.test.ts +0 -251
- package/src/__tests__/core-ops.test.ts +0 -550
- package/src/__tests__/curator-extra-ops.test.ts +0 -383
- package/src/__tests__/deprecation.test.ts +0 -78
- package/src/__tests__/domain-ops.test.ts +0 -226
- package/src/__tests__/domain-packs.test.ts +0 -421
- package/src/__tests__/enforcement.test.ts +0 -153
- package/src/__tests__/errors.test.ts +0 -388
- package/src/__tests__/extensions.test.ts +0 -233
- package/src/__tests__/facade-factory.test.ts +0 -271
- package/src/__tests__/feature-flags.test.ts +0 -137
- package/src/__tests__/flows.test.ts +0 -604
- package/src/__tests__/git-vault-sync.test.ts +0 -230
- package/src/__tests__/governance.test.ts +0 -522
- package/src/__tests__/grading-ops.test.ts +0 -361
- package/src/__tests__/health-registry.test.ts +0 -173
- package/src/__tests__/identity-manager.test.ts +0 -243
- package/src/__tests__/intake-pipeline.test.ts +0 -162
- package/src/__tests__/intent-router.test.ts +0 -222
- package/src/__tests__/knowledge-review.test.ts +0 -104
- package/src/__tests__/llm-client.test.ts +0 -69
- package/src/__tests__/llm.test.ts +0 -556
- package/src/__tests__/loader.test.ts +0 -176
- package/src/__tests__/loop-ops.test.ts +0 -469
- package/src/__tests__/lsp-transport.test.ts +0 -442
- package/src/__tests__/memory-cross-project-ops.test.ts +0 -248
- package/src/__tests__/memory-extra-ops.test.ts +0 -352
- package/src/__tests__/migration-runner.test.ts +0 -170
- package/src/__tests__/module-manifest-drift.test.ts +0 -59
- package/src/__tests__/normalize.test.ts +0 -85
- package/src/__tests__/obsidian-sync.test.ts +0 -354
- package/src/__tests__/orchestrate-ops.test.ts +0 -289
- package/src/__tests__/pack-ops.test.ts +0 -146
- package/src/__tests__/persistence.test.ts +0 -291
- package/src/__tests__/planning-extra-ops.test.ts +0 -706
- package/src/__tests__/playbook-executor.test.ts +0 -249
- package/src/__tests__/playbook-registry.test.ts +0 -326
- package/src/__tests__/playbook-seeder.test.ts +0 -163
- package/src/__tests__/playbook.test.ts +0 -389
- package/src/__tests__/plugin-ops.test.ts +0 -411
- package/src/__tests__/plugin-system.test.ts +0 -509
- package/src/__tests__/project-ops.test.ts +0 -381
- package/src/__tests__/replayable-stream.test.ts +0 -177
- package/src/__tests__/runtime.test.ts +0 -95
- package/src/__tests__/scope-detector.test.ts +0 -121
- package/src/__tests__/template-manager.test.ts +0 -222
- package/src/__tests__/token-resolver.test.ts +0 -79
- package/src/__tests__/transport.test.ts +0 -758
- package/src/__tests__/vault-branching.test.ts +0 -274
- package/src/__tests__/vault-extra-ops.test.ts +0 -482
- package/src/__tests__/vault-integrity.test.ts +0 -71
- package/src/__tests__/vault-manager.test.ts +0 -238
- package/src/__tests__/ws-transport.test.ts +0 -479
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { detectRationalizations } from './rationalization-detector.js';
|
|
3
|
+
|
|
4
|
+
const CRITERIA = [
|
|
5
|
+
'All API endpoints return proper error codes',
|
|
6
|
+
'Unit test coverage above 80%',
|
|
7
|
+
'Database migrations are reversible',
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
describe('detectRationalizations', () => {
|
|
11
|
+
// ─── Positive cases: each pattern detected ──────────────────
|
|
12
|
+
|
|
13
|
+
it('detects "out of scope" pattern', () => {
|
|
14
|
+
const report = detectRationalizations(
|
|
15
|
+
CRITERIA,
|
|
16
|
+
'Database migrations are out of scope for this task.',
|
|
17
|
+
);
|
|
18
|
+
expect(report.detected).toBe(true);
|
|
19
|
+
expect(report.items).toHaveLength(1);
|
|
20
|
+
expect(report.items[0].pattern).toBe('out-of-scope');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('detects "follow-up ticket" pattern', () => {
|
|
24
|
+
const report = detectRationalizations(
|
|
25
|
+
CRITERIA,
|
|
26
|
+
'Error codes will be addressed in a follow-up issue.',
|
|
27
|
+
);
|
|
28
|
+
expect(report.detected).toBe(true);
|
|
29
|
+
expect(report.items).toHaveLength(1);
|
|
30
|
+
expect(report.items[0].pattern).toBe('follow-up-ticket');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('detects "follow-up PR" pattern', () => {
|
|
34
|
+
const report = detectRationalizations(
|
|
35
|
+
CRITERIA,
|
|
36
|
+
'Test coverage bump deferred to follow-up PR.',
|
|
37
|
+
);
|
|
38
|
+
expect(report.detected).toBe(true);
|
|
39
|
+
expect(report.items[0].pattern).toBe('follow-up-ticket');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('detects "pre-existing issue" pattern', () => {
|
|
43
|
+
const report = detectRationalizations(
|
|
44
|
+
CRITERIA,
|
|
45
|
+
'The missing error codes are a pre-existing bug in the codebase.',
|
|
46
|
+
);
|
|
47
|
+
expect(report.detected).toBe(true);
|
|
48
|
+
expect(report.items[0].pattern).toBe('pre-existing-issue');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('detects "over-engineering" pattern', () => {
|
|
52
|
+
const report = detectRationalizations(
|
|
53
|
+
CRITERIA,
|
|
54
|
+
'Making migrations reversible would be over-engineering at this stage.',
|
|
55
|
+
);
|
|
56
|
+
expect(report.detected).toBe(true);
|
|
57
|
+
expect(report.items[0].pattern).toBe('over-engineering');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('detects "separate PR" pattern', () => {
|
|
61
|
+
const report = detectRationalizations(
|
|
62
|
+
CRITERIA,
|
|
63
|
+
'Test coverage improvements will go in a separate PR.',
|
|
64
|
+
);
|
|
65
|
+
expect(report.detected).toBe(true);
|
|
66
|
+
expect(report.items[0].pattern).toBe('separate-pr');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('detects "too complex for this task" pattern', () => {
|
|
70
|
+
const report = detectRationalizations(
|
|
71
|
+
CRITERIA,
|
|
72
|
+
'Reversible migrations are too complex for this task, deferring.',
|
|
73
|
+
);
|
|
74
|
+
expect(report.detected).toBe(true);
|
|
75
|
+
expect(report.items[0].pattern).toBe('too-complex');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// ─── Negative cases: clean completion ───────────────────────
|
|
79
|
+
|
|
80
|
+
it('returns no detection for clean completion claim', () => {
|
|
81
|
+
const report = detectRationalizations(
|
|
82
|
+
CRITERIA,
|
|
83
|
+
'All endpoints return proper error codes. Test coverage is at 85%. Migrations are reversible.',
|
|
84
|
+
);
|
|
85
|
+
expect(report.detected).toBe(false);
|
|
86
|
+
expect(report.items).toHaveLength(0);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('returns no detection for unrelated text', () => {
|
|
90
|
+
const report = detectRationalizations(
|
|
91
|
+
CRITERIA,
|
|
92
|
+
'Implemented the feature, ran all tests, everything passes.',
|
|
93
|
+
);
|
|
94
|
+
expect(report.detected).toBe(false);
|
|
95
|
+
expect(report.items).toHaveLength(0);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// ─── Case-insensitive matching ──────────────────────────────
|
|
99
|
+
|
|
100
|
+
it('matches case-insensitively (uppercase)', () => {
|
|
101
|
+
const report = detectRationalizations(
|
|
102
|
+
CRITERIA,
|
|
103
|
+
'This is OUT OF SCOPE for the current work.',
|
|
104
|
+
);
|
|
105
|
+
expect(report.detected).toBe(true);
|
|
106
|
+
expect(report.items[0].pattern).toBe('out-of-scope');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('matches case-insensitively (mixed case)', () => {
|
|
110
|
+
const report = detectRationalizations(
|
|
111
|
+
CRITERIA,
|
|
112
|
+
'That is a Pre-Existing Issue we inherited.',
|
|
113
|
+
);
|
|
114
|
+
expect(report.detected).toBe(true);
|
|
115
|
+
expect(report.items[0].pattern).toBe('pre-existing-issue');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// ─── Empty/skip cases ──────────────────────────────────────
|
|
119
|
+
|
|
120
|
+
it('skips detection when acceptance criteria are empty', () => {
|
|
121
|
+
const report = detectRationalizations(
|
|
122
|
+
[],
|
|
123
|
+
'This is out of scope and a pre-existing issue.',
|
|
124
|
+
);
|
|
125
|
+
expect(report.detected).toBe(false);
|
|
126
|
+
expect(report.items).toHaveLength(0);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('skips detection when completion claim is empty', () => {
|
|
130
|
+
const report = detectRationalizations(CRITERIA, '');
|
|
131
|
+
expect(report.detected).toBe(false);
|
|
132
|
+
expect(report.items).toHaveLength(0);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('skips detection when completion claim is whitespace only', () => {
|
|
136
|
+
const report = detectRationalizations(CRITERIA, ' ');
|
|
137
|
+
expect(report.detected).toBe(false);
|
|
138
|
+
expect(report.items).toHaveLength(0);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// ─── Multiple rationalizations ─────────────────────────────
|
|
142
|
+
|
|
143
|
+
it('detects multiple rationalizations in one claim', () => {
|
|
144
|
+
const report = detectRationalizations(
|
|
145
|
+
CRITERIA,
|
|
146
|
+
'Error codes are out of scope. Test coverage will go in a separate PR. ' +
|
|
147
|
+
'Reversible migrations are too complex for this task.',
|
|
148
|
+
);
|
|
149
|
+
expect(report.detected).toBe(true);
|
|
150
|
+
expect(report.items.length).toBeGreaterThanOrEqual(3);
|
|
151
|
+
|
|
152
|
+
const patterns = report.items.map((i) => i.pattern);
|
|
153
|
+
expect(patterns).toContain('out-of-scope');
|
|
154
|
+
expect(patterns).toContain('separate-pr');
|
|
155
|
+
expect(patterns).toContain('too-complex');
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// ─── Suggestion is always present ──────────────────────────
|
|
159
|
+
|
|
160
|
+
it('provides actionable suggestions for each item', () => {
|
|
161
|
+
const report = detectRationalizations(
|
|
162
|
+
CRITERIA,
|
|
163
|
+
'This is out of scope and over-engineering.',
|
|
164
|
+
);
|
|
165
|
+
expect(report.detected).toBe(true);
|
|
166
|
+
for (const item of report.items) {
|
|
167
|
+
expect(item.suggestion).toBeTruthy();
|
|
168
|
+
expect(item.suggestion.length).toBeGreaterThan(10);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rationalization detector — identifies completion claims that rationalize
|
|
3
|
+
* away unmet acceptance criteria instead of genuinely completing them.
|
|
4
|
+
*
|
|
5
|
+
* Used by orchestrate_complete to gate auto-completion.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ─── Types ──────────────────────────────────────────────────────
|
|
9
|
+
|
|
10
|
+
export interface RationalizationItem {
|
|
11
|
+
/** The acceptance criterion being rationalized away. */
|
|
12
|
+
criterion: string;
|
|
13
|
+
/** The phrase in the completion claim that triggered detection. */
|
|
14
|
+
phrase: string;
|
|
15
|
+
/** The pattern name that matched. */
|
|
16
|
+
pattern: string;
|
|
17
|
+
/** Actionable suggestion for the user. */
|
|
18
|
+
suggestion: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface RationalizationReport {
|
|
22
|
+
/** Whether any rationalizations were detected. */
|
|
23
|
+
detected: boolean;
|
|
24
|
+
/** Individual rationalization items found. */
|
|
25
|
+
items: RationalizationItem[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ─── Patterns ───────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
interface RationalizationPattern {
|
|
31
|
+
name: string;
|
|
32
|
+
regex: RegExp;
|
|
33
|
+
suggestion: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const PATTERNS: RationalizationPattern[] = [
|
|
37
|
+
{
|
|
38
|
+
name: 'out-of-scope',
|
|
39
|
+
regex: /out\s+of\s+scope/i,
|
|
40
|
+
suggestion: 'If it was in the acceptance criteria, it is in scope. Remove from criteria or complete it.',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'follow-up-ticket',
|
|
44
|
+
regex: /follow[- ]?up\s+(ticket|issue|pr|task)/i,
|
|
45
|
+
suggestion: 'Deferring to a follow-up means the criterion is unmet. Complete it now or revise the plan.',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'pre-existing-issue',
|
|
49
|
+
regex: /pre[- ]?existing\s+(issue|bug|problem)/i,
|
|
50
|
+
suggestion: 'Pre-existing or not, the criterion expects it resolved. Fix it or remove the criterion.',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'over-engineering',
|
|
54
|
+
regex: /over[- ]?engineering/i,
|
|
55
|
+
suggestion: 'Meeting acceptance criteria is not over-engineering. Implement what was agreed upon.',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'separate-pr',
|
|
59
|
+
regex: /separate\s+(pr|task|ticket|issue)/i,
|
|
60
|
+
suggestion: 'Splitting into a separate PR defers the work. Complete the criterion or update the plan.',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'too-complex',
|
|
64
|
+
regex: /too\s+complex\s+for\s+this\s+(task|pr|ticket|issue|scope)/i,
|
|
65
|
+
suggestion: 'Complexity was known at planning time. Revisit the plan or complete the criterion.',
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
// ─── Detector ───────────────────────────────────────────────────
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Scan a completion claim against acceptance criteria for rationalization
|
|
73
|
+
* language — phrases that excuse unmet criteria rather than completing them.
|
|
74
|
+
*
|
|
75
|
+
* @param acceptanceCriteria - The plan/task acceptance criteria
|
|
76
|
+
* @param completionClaim - The completion summary to scan
|
|
77
|
+
* @returns A report with detected rationalization items
|
|
78
|
+
*/
|
|
79
|
+
export function detectRationalizations(
|
|
80
|
+
acceptanceCriteria: string[],
|
|
81
|
+
completionClaim: string,
|
|
82
|
+
): RationalizationReport {
|
|
83
|
+
if (!acceptanceCriteria.length || !completionClaim.trim()) {
|
|
84
|
+
return { detected: false, items: [] };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const items: RationalizationItem[] = [];
|
|
88
|
+
|
|
89
|
+
for (const pattern of PATTERNS) {
|
|
90
|
+
const match = pattern.regex.exec(completionClaim);
|
|
91
|
+
if (!match) continue;
|
|
92
|
+
|
|
93
|
+
// Find which criterion is being rationalized (nearest mention)
|
|
94
|
+
const criterion = findRelatedCriterion(
|
|
95
|
+
acceptanceCriteria,
|
|
96
|
+
completionClaim,
|
|
97
|
+
match.index,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
items.push({
|
|
101
|
+
criterion,
|
|
102
|
+
phrase: match[0],
|
|
103
|
+
pattern: pattern.name,
|
|
104
|
+
suggestion: pattern.suggestion,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return { detected: items.length > 0, items };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ─── Helpers ────────────────────────────────────────────────────
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Find the acceptance criterion most related to the rationalization phrase
|
|
115
|
+
* by checking which criterion text appears closest to the match position.
|
|
116
|
+
*/
|
|
117
|
+
function findRelatedCriterion(
|
|
118
|
+
criteria: string[],
|
|
119
|
+
claim: string,
|
|
120
|
+
matchIndex: number,
|
|
121
|
+
): string {
|
|
122
|
+
const claimLower = claim.toLowerCase();
|
|
123
|
+
let bestCriterion = criteria[0];
|
|
124
|
+
let bestDistance = Infinity;
|
|
125
|
+
|
|
126
|
+
for (const c of criteria) {
|
|
127
|
+
const idx = claimLower.indexOf(c.toLowerCase());
|
|
128
|
+
if (idx !== -1) {
|
|
129
|
+
const dist = Math.abs(idx - matchIndex);
|
|
130
|
+
if (dist < bestDistance) {
|
|
131
|
+
bestDistance = dist;
|
|
132
|
+
bestCriterion = c;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return bestCriterion;
|
|
138
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
DRIFT_WEIGHTS,
|
|
4
|
+
calculateDriftScore,
|
|
5
|
+
computeExecutionSummary,
|
|
6
|
+
buildReconciliationReport,
|
|
7
|
+
buildAutoReconcileInput,
|
|
8
|
+
} from './reconciliation-engine.js';
|
|
9
|
+
import type { DriftItem, PlanTask } from './planner-types.js';
|
|
10
|
+
|
|
11
|
+
describe('reconciliation-engine', () => {
|
|
12
|
+
describe('DRIFT_WEIGHTS', () => {
|
|
13
|
+
it('has correct weights', () => {
|
|
14
|
+
expect(DRIFT_WEIGHTS.high).toBe(20);
|
|
15
|
+
expect(DRIFT_WEIGHTS.medium).toBe(10);
|
|
16
|
+
expect(DRIFT_WEIGHTS.low).toBe(5);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('calculateDriftScore', () => {
|
|
21
|
+
it('returns 100 for no drift items', () => {
|
|
22
|
+
expect(calculateDriftScore([])).toBe(100);
|
|
23
|
+
});
|
|
24
|
+
it('deducts by impact weight', () => {
|
|
25
|
+
const items: DriftItem[] = [
|
|
26
|
+
{ type: 'skipped', description: 'x', impact: 'medium', rationale: 'r' },
|
|
27
|
+
];
|
|
28
|
+
expect(calculateDriftScore(items)).toBe(90);
|
|
29
|
+
});
|
|
30
|
+
it('accumulates multiple items', () => {
|
|
31
|
+
const items: DriftItem[] = [
|
|
32
|
+
{ type: 'skipped', description: 'x', impact: 'high', rationale: 'r' },
|
|
33
|
+
{ type: 'modified', description: 'y', impact: 'low', rationale: 'r' },
|
|
34
|
+
];
|
|
35
|
+
expect(calculateDriftScore(items)).toBe(75);
|
|
36
|
+
});
|
|
37
|
+
it('floors at 0', () => {
|
|
38
|
+
const items: DriftItem[] = Array.from({ length: 10 }, () => ({
|
|
39
|
+
type: 'skipped' as const, description: 'x', impact: 'high' as const, rationale: 'r',
|
|
40
|
+
}));
|
|
41
|
+
expect(calculateDriftScore(items)).toBe(0);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('computeExecutionSummary', () => {
|
|
46
|
+
it('returns zeros for empty tasks', () => {
|
|
47
|
+
const summary = computeExecutionSummary([]);
|
|
48
|
+
expect(summary.totalDurationMs).toBe(0);
|
|
49
|
+
expect(summary.tasksCompleted).toBe(0);
|
|
50
|
+
expect(summary.avgTaskDurationMs).toBe(0);
|
|
51
|
+
});
|
|
52
|
+
it('counts task statuses correctly', () => {
|
|
53
|
+
const tasks: PlanTask[] = [
|
|
54
|
+
{ id: 't1', title: '', description: '', status: 'completed', updatedAt: 0 },
|
|
55
|
+
{ id: 't2', title: '', description: '', status: 'skipped', updatedAt: 0 },
|
|
56
|
+
{ id: 't3', title: '', description: '', status: 'failed', updatedAt: 0 },
|
|
57
|
+
{ id: 't4', title: '', description: '', status: 'pending', updatedAt: 0 },
|
|
58
|
+
];
|
|
59
|
+
const summary = computeExecutionSummary(tasks);
|
|
60
|
+
expect(summary.tasksCompleted).toBe(1);
|
|
61
|
+
expect(summary.tasksSkipped).toBe(1);
|
|
62
|
+
expect(summary.tasksFailed).toBe(1);
|
|
63
|
+
});
|
|
64
|
+
it('computes average duration from tasks with metrics', () => {
|
|
65
|
+
const tasks: PlanTask[] = [
|
|
66
|
+
{ id: 't1', title: '', description: '', status: 'completed', updatedAt: 0, metrics: { durationMs: 100 } },
|
|
67
|
+
{ id: 't2', title: '', description: '', status: 'completed', updatedAt: 0, metrics: { durationMs: 200 } },
|
|
68
|
+
{ id: 't3', title: '', description: '', status: 'completed', updatedAt: 0 }, // no metrics
|
|
69
|
+
];
|
|
70
|
+
const summary = computeExecutionSummary(tasks);
|
|
71
|
+
expect(summary.totalDurationMs).toBe(300);
|
|
72
|
+
expect(summary.avgTaskDurationMs).toBe(150);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('buildReconciliationReport', () => {
|
|
77
|
+
it('builds a report with accuracy score', () => {
|
|
78
|
+
const report = buildReconciliationReport('plan-1', {
|
|
79
|
+
actualOutcome: 'Done',
|
|
80
|
+
driftItems: [{ type: 'skipped', description: 'x', impact: 'low', rationale: 'r' }],
|
|
81
|
+
});
|
|
82
|
+
expect(report.planId).toBe('plan-1');
|
|
83
|
+
expect(report.accuracy).toBe(95);
|
|
84
|
+
expect(report.driftItems).toHaveLength(1);
|
|
85
|
+
expect(report.summary).toBe('Done');
|
|
86
|
+
expect(report.reconciledAt).toBeGreaterThan(0);
|
|
87
|
+
});
|
|
88
|
+
it('defaults to empty drift items', () => {
|
|
89
|
+
const report = buildReconciliationReport('plan-2', { actualOutcome: 'OK' });
|
|
90
|
+
expect(report.accuracy).toBe(100);
|
|
91
|
+
expect(report.driftItems).toEqual([]);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe('buildAutoReconcileInput', () => {
|
|
96
|
+
it('allows auto-reconcile when all tasks completed', () => {
|
|
97
|
+
const tasks: PlanTask[] = [
|
|
98
|
+
{ id: 't1', title: 'A', description: '', status: 'completed', updatedAt: 0 },
|
|
99
|
+
{ id: 't2', title: 'B', description: '', status: 'completed', updatedAt: 0 },
|
|
100
|
+
];
|
|
101
|
+
const result = buildAutoReconcileInput(tasks);
|
|
102
|
+
expect(result.canAutoReconcile).toBe(true);
|
|
103
|
+
expect(result.input?.actualOutcome).toContain('2/2 tasks completed');
|
|
104
|
+
});
|
|
105
|
+
it('rejects when tasks are in progress', () => {
|
|
106
|
+
const tasks: PlanTask[] = [
|
|
107
|
+
{ id: 't1', title: 'A', description: '', status: 'in_progress', updatedAt: 0 },
|
|
108
|
+
];
|
|
109
|
+
expect(buildAutoReconcileInput(tasks).canAutoReconcile).toBe(false);
|
|
110
|
+
});
|
|
111
|
+
it('rejects when too many pending/failed tasks', () => {
|
|
112
|
+
const tasks: PlanTask[] = [
|
|
113
|
+
{ id: 't1', title: 'A', description: '', status: 'failed', updatedAt: 0 },
|
|
114
|
+
{ id: 't2', title: 'B', description: '', status: 'failed', updatedAt: 0 },
|
|
115
|
+
{ id: 't3', title: 'C', description: '', status: 'pending', updatedAt: 0 },
|
|
116
|
+
];
|
|
117
|
+
expect(buildAutoReconcileInput(tasks).canAutoReconcile).toBe(false);
|
|
118
|
+
});
|
|
119
|
+
it('generates drift items for skipped and failed tasks', () => {
|
|
120
|
+
const tasks: PlanTask[] = [
|
|
121
|
+
{ id: 't1', title: 'A', description: '', status: 'completed', updatedAt: 0 },
|
|
122
|
+
{ id: 't2', title: 'B', description: '', status: 'skipped', updatedAt: 0 },
|
|
123
|
+
{ id: 't3', title: 'C', description: '', status: 'failed', updatedAt: 0 },
|
|
124
|
+
];
|
|
125
|
+
const result = buildAutoReconcileInput(tasks);
|
|
126
|
+
expect(result.canAutoReconcile).toBe(true);
|
|
127
|
+
expect(result.input?.driftItems).toHaveLength(2);
|
|
128
|
+
expect(result.input?.driftItems?.[0].type).toBe('skipped');
|
|
129
|
+
expect(result.input?.driftItems?.[1].type).toBe('modified');
|
|
130
|
+
});
|
|
131
|
+
it('generates drift items for pending tasks', () => {
|
|
132
|
+
const tasks: PlanTask[] = [
|
|
133
|
+
{ id: 't1', title: 'Done', description: '', status: 'completed', updatedAt: 0 },
|
|
134
|
+
{ id: 't2', title: 'Not started', description: '', status: 'pending', updatedAt: 0 },
|
|
135
|
+
];
|
|
136
|
+
const result = buildAutoReconcileInput(tasks);
|
|
137
|
+
expect(result.canAutoReconcile).toBe(true);
|
|
138
|
+
expect(result.input?.driftItems?.[0].impact).toBe('low');
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
});
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reconciliation engine — drift detection, accuracy scoring, and auto-reconciliation.
|
|
3
|
+
* Extracted from planner.ts. All functions are pure (no persistence side-effects).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
DriftItem,
|
|
8
|
+
ReconciliationReport,
|
|
9
|
+
ExecutionSummary,
|
|
10
|
+
PlanTask,
|
|
11
|
+
} from './planner-types.js';
|
|
12
|
+
|
|
13
|
+
// ─── Drift Scoring ───────────────────────────────────────────────
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Severity weights for drift accuracy score calculation.
|
|
17
|
+
* Score = 100 - sum(drift_items * weight_per_impact)
|
|
18
|
+
* Ported from Salvador's plan-lifecycle-types.ts.
|
|
19
|
+
*/
|
|
20
|
+
export const DRIFT_WEIGHTS: Record<DriftItem['impact'], number> = {
|
|
21
|
+
high: 20,
|
|
22
|
+
medium: 10,
|
|
23
|
+
low: 5,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Calculate drift accuracy score from drift items.
|
|
28
|
+
* Score = max(0, 100 - sum(weight_per_impact))
|
|
29
|
+
* Ported from Salvador's calculateDriftScore.
|
|
30
|
+
*/
|
|
31
|
+
export function calculateDriftScore(items: ReadonlyArray<DriftItem>): number {
|
|
32
|
+
let deductions = 0;
|
|
33
|
+
for (const item of items) {
|
|
34
|
+
deductions += DRIFT_WEIGHTS[item.impact];
|
|
35
|
+
}
|
|
36
|
+
return Math.max(0, 100 - deductions);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ─── Execution Summary ───────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Compute aggregate execution summary from per-task metrics.
|
|
43
|
+
* Pure function — does not mutate state.
|
|
44
|
+
*/
|
|
45
|
+
export function computeExecutionSummary(tasks: ReadonlyArray<PlanTask>): ExecutionSummary {
|
|
46
|
+
let totalDurationMs = 0;
|
|
47
|
+
let tasksCompleted = 0;
|
|
48
|
+
let tasksSkipped = 0;
|
|
49
|
+
let tasksFailed = 0;
|
|
50
|
+
let tasksWithDuration = 0;
|
|
51
|
+
|
|
52
|
+
for (const task of tasks) {
|
|
53
|
+
if (task.status === 'completed') tasksCompleted++;
|
|
54
|
+
else if (task.status === 'skipped') tasksSkipped++;
|
|
55
|
+
else if (task.status === 'failed') tasksFailed++;
|
|
56
|
+
|
|
57
|
+
if (task.metrics?.durationMs) {
|
|
58
|
+
totalDurationMs += task.metrics.durationMs;
|
|
59
|
+
tasksWithDuration++;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
totalDurationMs,
|
|
65
|
+
tasksCompleted,
|
|
66
|
+
tasksSkipped,
|
|
67
|
+
tasksFailed,
|
|
68
|
+
avgTaskDurationMs:
|
|
69
|
+
tasksWithDuration > 0 ? Math.round(totalDurationMs / tasksWithDuration) : 0,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ─── Reconciliation ──────────────────────────────────────────────
|
|
74
|
+
|
|
75
|
+
export interface ReconcileInput {
|
|
76
|
+
actualOutcome: string;
|
|
77
|
+
driftItems?: DriftItem[];
|
|
78
|
+
/** Who initiated the reconciliation. */
|
|
79
|
+
reconciledBy?: 'human' | 'auto';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Build a reconciliation report from drift items and outcome.
|
|
84
|
+
* Pure function — returns report without mutating state.
|
|
85
|
+
*/
|
|
86
|
+
export function buildReconciliationReport(
|
|
87
|
+
planId: string,
|
|
88
|
+
input: ReconcileInput,
|
|
89
|
+
): ReconciliationReport {
|
|
90
|
+
const driftItems = input.driftItems ?? [];
|
|
91
|
+
const accuracy = calculateDriftScore(driftItems);
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
planId,
|
|
95
|
+
accuracy,
|
|
96
|
+
driftItems,
|
|
97
|
+
summary: input.actualOutcome,
|
|
98
|
+
reconciledAt: Date.now(),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ─── Auto-Reconciliation ────────────────────────────────────────
|
|
103
|
+
|
|
104
|
+
export interface AutoReconcileResult {
|
|
105
|
+
canAutoReconcile: boolean;
|
|
106
|
+
input?: ReconcileInput;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Determine if a plan can be auto-reconciled and build the reconciliation input.
|
|
111
|
+
* Returns null input if auto-reconciliation is not possible.
|
|
112
|
+
*
|
|
113
|
+
* Rules:
|
|
114
|
+
* - Can't auto-reconcile if tasks are still in progress
|
|
115
|
+
* - Can't auto-reconcile if too many non-completed tasks (>2 pending + failed)
|
|
116
|
+
*/
|
|
117
|
+
export function buildAutoReconcileInput(tasks: ReadonlyArray<PlanTask>): AutoReconcileResult {
|
|
118
|
+
const completed = tasks.filter((t) => t.status === 'completed').length;
|
|
119
|
+
const skipped = tasks.filter((t) => t.status === 'skipped').length;
|
|
120
|
+
const failed = tasks.filter((t) => t.status === 'failed').length;
|
|
121
|
+
const pending = tasks.filter((t) => t.status === 'pending').length;
|
|
122
|
+
const inProgress = tasks.filter((t) => t.status === 'in_progress').length;
|
|
123
|
+
|
|
124
|
+
if (inProgress > 0) return { canAutoReconcile: false };
|
|
125
|
+
if (pending + failed > 2) return { canAutoReconcile: false };
|
|
126
|
+
|
|
127
|
+
const driftItems: DriftItem[] = [];
|
|
128
|
+
|
|
129
|
+
for (const task of tasks) {
|
|
130
|
+
if (task.status === 'skipped') {
|
|
131
|
+
driftItems.push({
|
|
132
|
+
type: 'skipped',
|
|
133
|
+
description: `Task '${task.title}' was skipped`,
|
|
134
|
+
impact: 'medium',
|
|
135
|
+
rationale: 'Task not executed during plan implementation',
|
|
136
|
+
});
|
|
137
|
+
} else if (task.status === 'failed') {
|
|
138
|
+
driftItems.push({
|
|
139
|
+
type: 'modified',
|
|
140
|
+
description: `Task '${task.title}' failed`,
|
|
141
|
+
impact: 'high',
|
|
142
|
+
rationale: 'Task execution failed',
|
|
143
|
+
});
|
|
144
|
+
} else if (task.status === 'pending') {
|
|
145
|
+
driftItems.push({
|
|
146
|
+
type: 'skipped',
|
|
147
|
+
description: `Task '${task.title}' was never started`,
|
|
148
|
+
impact: 'low',
|
|
149
|
+
rationale: 'Task left in pending state',
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
canAutoReconcile: true,
|
|
156
|
+
input: {
|
|
157
|
+
actualOutcome: `Auto-reconciled: ${completed}/${tasks.length} tasks completed, ${skipped} skipped, ${failed} failed`,
|
|
158
|
+
driftItems,
|
|
159
|
+
reconciledBy: 'auto',
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|