@cleocode/core 2026.9.8 → 2026.9.10
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/audit/reconstruct.d.ts +13 -43
- package/dist/audit/reconstruct.d.ts.map +1 -1
- package/dist/audit/reconstruct.js +295 -290
- package/dist/audit/reconstruct.js.map +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +8 -2
- package/dist/bootstrap.js.map +1 -1
- package/dist/compliance/protocol-rules.d.ts.map +1 -1
- package/dist/compliance/protocol-rules.js +3 -1
- package/dist/compliance/protocol-rules.js.map +1 -1
- package/dist/dispatch/mutate-projection.d.ts.map +1 -1
- package/dist/dispatch/mutate-projection.js +12 -0
- package/dist/dispatch/mutate-projection.js.map +1 -1
- package/dist/dispatch/mvi-projection.d.ts +29 -6
- package/dist/dispatch/mvi-projection.d.ts.map +1 -1
- package/dist/dispatch/mvi-projection.js +109 -139
- package/dist/dispatch/mvi-projection.js.map +1 -1
- package/dist/docs/docs-read-model.d.ts +3 -2
- package/dist/docs/docs-read-model.d.ts.map +1 -1
- package/dist/docs/docs-read-model.js +4 -3
- package/dist/docs/docs-read-model.js.map +1 -1
- package/dist/docs/export-document.js +5129 -2297
- package/dist/docs/export-document.js.map +3 -3
- package/dist/docs/projection.d.ts +67 -0
- package/dist/docs/projection.d.ts.map +1 -0
- package/dist/docs/projection.js +370 -0
- package/dist/docs/projection.js.map +1 -0
- package/dist/doctor/acceptance-drift.d.ts +6 -2
- package/dist/doctor/acceptance-drift.d.ts.map +1 -1
- package/dist/doctor/acceptance-drift.js +43 -5
- package/dist/doctor/acceptance-drift.js.map +1 -1
- package/dist/doctor/knowledge-summary.d.ts +41 -0
- package/dist/doctor/knowledge-summary.d.ts.map +1 -0
- package/dist/doctor/knowledge-summary.js +81 -0
- package/dist/doctor/knowledge-summary.js.map +1 -0
- package/dist/doctor/knowledge.d.ts +192 -0
- package/dist/doctor/knowledge.d.ts.map +1 -0
- package/dist/doctor/knowledge.js +1864 -0
- package/dist/doctor/knowledge.js.map +1 -0
- package/dist/git/work-tree.d.ts +169 -0
- package/dist/git/work-tree.d.ts.map +1 -0
- package/dist/git/work-tree.js +341 -0
- package/dist/git/work-tree.js.map +1 -0
- package/dist/hooks/handlers/task-hooks.d.ts +8 -5
- package/dist/hooks/handlers/task-hooks.d.ts.map +1 -1
- package/dist/hooks/handlers/task-hooks.js +15 -60
- package/dist/hooks/handlers/task-hooks.js.map +1 -1
- package/dist/identity/cleo-identity.d.ts +13 -0
- package/dist/identity/cleo-identity.d.ts.map +1 -1
- package/dist/identity/cleo-identity.js +20 -6
- package/dist/identity/cleo-identity.js.map +1 -1
- package/dist/injection.d.ts.map +1 -1
- package/dist/injection.js +29 -13
- package/dist/injection.js.map +1 -1
- package/dist/internal.d.ts +3 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +4 -0
- package/dist/internal.js.map +1 -1
- package/dist/lifecycle/verification/satisfies-validator.d.ts.map +1 -1
- package/dist/lifecycle/verification/satisfies-validator.js +124 -120
- package/dist/lifecycle/verification/satisfies-validator.js.map +1 -1
- package/dist/llm/plugin-facade.js +4047 -1726
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/memory/brain-backfill.d.ts +27 -12
- package/dist/memory/brain-backfill.d.ts.map +1 -1
- package/dist/memory/brain-backfill.js +325 -134
- package/dist/memory/brain-backfill.js.map +1 -1
- package/dist/memory/brain-doctor.d.ts +21 -0
- package/dist/memory/brain-doctor.d.ts.map +1 -1
- package/dist/memory/brain-doctor.js +111 -53
- package/dist/memory/brain-doctor.js.map +1 -1
- package/dist/memory/brain-links.d.ts.map +1 -1
- package/dist/memory/brain-links.js +31 -4
- package/dist/memory/brain-links.js.map +1 -1
- package/dist/memory/brain-reasoning.d.ts.map +1 -1
- package/dist/memory/brain-reasoning.js +28 -2
- package/dist/memory/brain-reasoning.js.map +1 -1
- package/dist/memory/brain-reconciler.d.ts +14 -19
- package/dist/memory/brain-reconciler.d.ts.map +1 -1
- package/dist/memory/brain-reconciler.js +70 -97
- package/dist/memory/brain-reconciler.js.map +1 -1
- package/dist/memory/brain-search.d.ts +2 -0
- package/dist/memory/brain-search.d.ts.map +1 -1
- package/dist/memory/brain-search.js +59 -29
- package/dist/memory/brain-search.js.map +1 -1
- package/dist/memory/brain-similarity.d.ts.map +1 -1
- package/dist/memory/brain-similarity.js +5 -4
- package/dist/memory/brain-similarity.js.map +1 -1
- package/dist/memory/brain-stub-prune.d.ts +31 -9
- package/dist/memory/brain-stub-prune.d.ts.map +1 -1
- package/dist/memory/brain-stub-prune.js +65 -18
- package/dist/memory/brain-stub-prune.js.map +1 -1
- package/dist/memory/brain-writer-handlers.d.ts +10 -1
- package/dist/memory/brain-writer-handlers.d.ts.map +1 -1
- package/dist/memory/brain-writer-handlers.js +23 -3
- package/dist/memory/brain-writer-handlers.js.map +1 -1
- package/dist/memory/brain-writer-thread.d.ts +11 -1
- package/dist/memory/brain-writer-thread.d.ts.map +1 -1
- package/dist/memory/brain-writer-thread.js +87 -20
- package/dist/memory/brain-writer-thread.js.map +1 -1
- package/dist/memory/brain-writer-worker.js +8 -1
- package/dist/memory/brain-writer-worker.js.map +1 -1
- package/dist/memory/decision-cross-link.d.ts +39 -0
- package/dist/memory/decision-cross-link.d.ts.map +1 -1
- package/dist/memory/decision-cross-link.js +316 -0
- package/dist/memory/decision-cross-link.js.map +1 -1
- package/dist/memory/decisions.d.ts +4 -1
- package/dist/memory/decisions.d.ts.map +1 -1
- package/dist/memory/decisions.js +7 -24
- package/dist/memory/decisions.js.map +1 -1
- package/dist/memory/dispatch-trace.d.ts +12 -5
- package/dist/memory/dispatch-trace.d.ts.map +1 -1
- package/dist/memory/dispatch-trace.js +17 -7
- package/dist/memory/dispatch-trace.js.map +1 -1
- package/dist/memory/eligibility.d.ts +51 -0
- package/dist/memory/eligibility.d.ts.map +1 -0
- package/dist/memory/eligibility.js +77 -0
- package/dist/memory/eligibility.js.map +1 -0
- package/dist/memory/engine-compat.d.ts +2 -0
- package/dist/memory/engine-compat.d.ts.map +1 -1
- package/dist/memory/engine-compat.js +10 -0
- package/dist/memory/engine-compat.js.map +1 -1
- package/dist/memory/extraction-gate.d.ts +21 -7
- package/dist/memory/extraction-gate.d.ts.map +1 -1
- package/dist/memory/extraction-gate.js +178 -216
- package/dist/memory/extraction-gate.js.map +1 -1
- package/dist/memory/graph-auto-populate.d.ts +38 -5
- package/dist/memory/graph-auto-populate.d.ts.map +1 -1
- package/dist/memory/graph-auto-populate.js +182 -60
- package/dist/memory/graph-auto-populate.js.map +1 -1
- package/dist/memory/graph-memory-bridge.d.ts +14 -1
- package/dist/memory/graph-memory-bridge.d.ts.map +1 -1
- package/dist/memory/graph-memory-bridge.js +66 -28
- package/dist/memory/graph-memory-bridge.js.map +1 -1
- package/dist/memory/index.d.ts +1 -19
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +1 -50
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/learnings.d.ts.map +1 -1
- package/dist/memory/learnings.js +2 -23
- package/dist/memory/learnings.js.map +1 -1
- package/dist/memory/manifest-filter.d.ts +21 -0
- package/dist/memory/manifest-filter.d.ts.map +1 -0
- package/dist/memory/manifest-filter.js +51 -0
- package/dist/memory/manifest-filter.js.map +1 -0
- package/dist/memory/manifest-ingestion.d.ts +28 -30
- package/dist/memory/manifest-ingestion.d.ts.map +1 -1
- package/dist/memory/manifest-ingestion.js +104 -235
- package/dist/memory/manifest-ingestion.js.map +1 -1
- package/dist/memory/observer-reflector.d.ts +2 -0
- package/dist/memory/observer-reflector.d.ts.map +1 -1
- package/dist/memory/observer-reflector.js +6 -49
- package/dist/memory/observer-reflector.js.map +1 -1
- package/dist/memory/patterns.d.ts +10 -0
- package/dist/memory/patterns.d.ts.map +1 -1
- package/dist/memory/patterns.js +25 -33
- package/dist/memory/patterns.js.map +1 -1
- package/dist/memory/pipeline-manifest-sqlite.d.ts +72 -9
- package/dist/memory/pipeline-manifest-sqlite.d.ts.map +1 -1
- package/dist/memory/pipeline-manifest-sqlite.js +508 -412
- package/dist/memory/pipeline-manifest-sqlite.js.map +1 -1
- package/dist/memory/retrieval/build-retrieval-bundle.d.ts.map +1 -1
- package/dist/memory/retrieval/build-retrieval-bundle.js +16 -15
- package/dist/memory/retrieval/build-retrieval-bundle.js.map +1 -1
- package/dist/memory/retrieval/fetch.d.ts +7 -0
- package/dist/memory/retrieval/fetch.d.ts.map +1 -1
- package/dist/memory/retrieval/fetch.js +14 -11
- package/dist/memory/retrieval/fetch.js.map +1 -1
- package/dist/memory/retrieval/observe.d.ts +7 -1
- package/dist/memory/retrieval/observe.d.ts.map +1 -1
- package/dist/memory/retrieval/observe.js +58 -4
- package/dist/memory/retrieval/observe.js.map +1 -1
- package/dist/memory/retrieval/search.d.ts +14 -1
- package/dist/memory/retrieval/search.d.ts.map +1 -1
- package/dist/memory/retrieval/search.js +133 -69
- package/dist/memory/retrieval/search.js.map +1 -1
- package/dist/memory/retrieval/telemetry.d.ts +31 -0
- package/dist/memory/retrieval/telemetry.d.ts.map +1 -0
- package/dist/memory/retrieval/telemetry.js +53 -0
- package/dist/memory/retrieval/telemetry.js.map +1 -0
- package/dist/nexus/analyze-orchestrator.d.ts +41 -9
- package/dist/nexus/analyze-orchestrator.d.ts.map +1 -1
- package/dist/nexus/analyze-orchestrator.js +257 -58
- package/dist/nexus/analyze-orchestrator.js.map +1 -1
- package/dist/nexus/api-contracts.d.ts +2 -6
- package/dist/nexus/api-contracts.d.ts.map +1 -1
- package/dist/nexus/api-contracts.js +11 -2
- package/dist/nexus/api-contracts.js.map +1 -1
- package/dist/nexus/context.d.ts.map +1 -1
- package/dist/nexus/context.js +14 -37
- package/dist/nexus/context.js.map +1 -1
- package/dist/nexus/diff.d.ts.map +1 -1
- package/dist/nexus/diff.js +2 -1
- package/dist/nexus/diff.js.map +1 -1
- package/dist/nexus/identity.d.ts +29 -3
- package/dist/nexus/identity.d.ts.map +1 -1
- package/dist/nexus/identity.js +63 -12
- package/dist/nexus/identity.js.map +1 -1
- package/dist/nexus/impact.d.ts +21 -19
- package/dist/nexus/impact.d.ts.map +1 -1
- package/dist/nexus/impact.js +96 -192
- package/dist/nexus/impact.js.map +1 -1
- package/dist/nexus/knowledge.d.ts +80 -0
- package/dist/nexus/knowledge.d.ts.map +1 -0
- package/dist/nexus/knowledge.js +786 -0
- package/dist/nexus/knowledge.js.map +1 -0
- package/dist/nexus/living-brain.d.ts +8 -5
- package/dist/nexus/living-brain.d.ts.map +1 -1
- package/dist/nexus/living-brain.js +252 -188
- package/dist/nexus/living-brain.js.map +1 -1
- package/dist/nexus/registry.d.ts +11 -2
- package/dist/nexus/registry.d.ts.map +1 -1
- package/dist/nexus/registry.js +144 -128
- package/dist/nexus/registry.js.map +1 -1
- package/dist/nexus/source-roots.d.ts +16 -0
- package/dist/nexus/source-roots.d.ts.map +1 -0
- package/dist/nexus/source-roots.js +174 -0
- package/dist/nexus/source-roots.js.map +1 -0
- package/dist/nexus/task-evidence.d.ts +22 -0
- package/dist/nexus/task-evidence.d.ts.map +1 -0
- package/dist/nexus/task-evidence.js +210 -0
- package/dist/nexus/task-evidence.js.map +1 -0
- package/dist/nexus/tasks-bridge.d.ts +14 -7
- package/dist/nexus/tasks-bridge.d.ts.map +1 -1
- package/dist/nexus/tasks-bridge.js +81 -40
- package/dist/nexus/tasks-bridge.js.map +1 -1
- package/dist/orchestrate/lifecycle-ops.d.ts.map +1 -1
- package/dist/orchestrate/lifecycle-ops.js +170 -120
- package/dist/orchestrate/lifecycle-ops.js.map +1 -1
- package/dist/orchestrate/query-ops.d.ts +6 -7
- package/dist/orchestrate/query-ops.d.ts.map +1 -1
- package/dist/orchestrate/query-ops.js +509 -532
- package/dist/orchestrate/query-ops.js.map +1 -1
- package/dist/orchestration/bootstrap.d.ts +15 -1
- package/dist/orchestration/bootstrap.d.ts.map +1 -1
- package/dist/orchestration/bootstrap.js +21 -10
- package/dist/orchestration/bootstrap.js.map +1 -1
- package/dist/orchestration/index.d.ts +35 -3
- package/dist/orchestration/index.d.ts.map +1 -1
- package/dist/orchestration/index.js +64 -35
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/lead-rollup.d.ts +24 -1
- package/dist/orchestration/lead-rollup.d.ts.map +1 -1
- package/dist/orchestration/lead-rollup.js +31 -11
- package/dist/orchestration/lead-rollup.js.map +1 -1
- package/dist/orchestration/spawn-prompt.d.ts.map +1 -1
- package/dist/orchestration/spawn-prompt.js +25 -45
- package/dist/orchestration/spawn-prompt.js.map +1 -1
- package/dist/orchestration/unblock.d.ts +15 -1
- package/dist/orchestration/unblock.d.ts.map +1 -1
- package/dist/orchestration/unblock.js +23 -12
- package/dist/orchestration/unblock.js.map +1 -1
- package/dist/orchestration/validate-spawn.d.ts.map +1 -1
- package/dist/orchestration/validate-spawn.js +3 -3
- package/dist/orchestration/validate-spawn.js.map +1 -1
- package/dist/orchestration/waves.d.ts +29 -13
- package/dist/orchestration/waves.d.ts.map +1 -1
- package/dist/orchestration/waves.js +43 -55
- package/dist/orchestration/waves.js.map +1 -1
- package/dist/paths.d.ts +17 -163
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +145 -496
- package/dist/paths.js.map +1 -1
- package/dist/project-info.d.ts +2 -11
- package/dist/project-info.d.ts.map +1 -1
- package/dist/project-info.js +3 -31
- package/dist/project-info.js.map +1 -1
- package/dist/project-scope.d.ts +239 -0
- package/dist/project-scope.d.ts.map +1 -0
- package/dist/project-scope.js +473 -0
- package/dist/project-scope.js.map +1 -0
- package/dist/release/pr-evidence.d.ts +23 -4
- package/dist/release/pr-evidence.d.ts.map +1 -1
- package/dist/release/pr-evidence.js +65 -9
- package/dist/release/pr-evidence.js.map +1 -1
- package/dist/render/nexus/graph/index.d.ts.map +1 -1
- package/dist/render/nexus/graph/index.js +4 -2
- package/dist/render/nexus/graph/index.js.map +1 -1
- package/dist/render/orchestration/audit-reconstruct.d.ts +11 -0
- package/dist/render/orchestration/audit-reconstruct.d.ts.map +1 -1
- package/dist/render/orchestration/audit-reconstruct.js +21 -6
- package/dist/render/orchestration/audit-reconstruct.js.map +1 -1
- package/dist/render/tasks/show.js +2 -1
- package/dist/render/tasks/show.js.map +1 -1
- package/dist/resources/spawn-wrapper.d.ts +82 -14
- package/dist/resources/spawn-wrapper.d.ts.map +1 -1
- package/dist/resources/spawn-wrapper.js +585 -27
- package/dist/resources/spawn-wrapper.js.map +1 -1
- package/dist/selfimprove/fix-gen.js +4055 -1734
- package/dist/selfimprove/fix-gen.js.map +3 -3
- package/dist/sequence/index.d.ts.map +1 -1
- package/dist/sequence/index.js +76 -68
- package/dist/sequence/index.js.map +1 -1
- package/dist/session/canon-lint.d.ts +24 -3
- package/dist/session/canon-lint.d.ts.map +1 -1
- package/dist/session/canon-lint.js +72 -31
- package/dist/session/canon-lint.js.map +1 -1
- package/dist/session/engine-ops.d.ts +1 -4
- package/dist/session/engine-ops.d.ts.map +1 -1
- package/dist/session/engine-ops.js +42 -6
- package/dist/session/engine-ops.js.map +1 -1
- package/dist/sessions/briefing.d.ts +11 -1
- package/dist/sessions/briefing.d.ts.map +1 -1
- package/dist/sessions/briefing.js +76 -8
- package/dist/sessions/briefing.js.map +1 -1
- package/dist/sessions/handoff.d.ts +3 -1
- package/dist/sessions/handoff.d.ts.map +1 -1
- package/dist/sessions/handoff.js +2 -0
- package/dist/sessions/handoff.js.map +1 -1
- package/dist/shutdown-deadline.d.ts +24 -33
- package/dist/shutdown-deadline.d.ts.map +1 -1
- package/dist/shutdown-deadline.js +71 -14
- package/dist/shutdown-deadline.js.map +1 -1
- package/dist/shutdown.d.ts +21 -10
- package/dist/shutdown.d.ts.map +1 -1
- package/dist/shutdown.js +89 -42
- package/dist/shutdown.js.map +1 -1
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/orchestrator/validator.d.ts +87 -20
- package/dist/skills/orchestrator/validator.d.ts.map +1 -1
- package/dist/skills/orchestrator/validator.js +330 -241
- package/dist/skills/orchestrator/validator.js.map +1 -1
- package/dist/store/agent-resolver.d.ts.map +1 -1
- package/dist/store/agent-resolver.js +16 -9
- package/dist/store/agent-resolver.js.map +1 -1
- package/dist/store/attachment-store.d.ts +4 -1
- package/dist/store/attachment-store.d.ts.map +1 -1
- package/dist/store/attachment-store.js +20 -3
- package/dist/store/attachment-store.js.map +1 -1
- package/dist/store/background-jobs.d.ts +426 -105
- package/dist/store/background-jobs.d.ts.map +1 -1
- package/dist/store/background-jobs.js +1208 -252
- package/dist/store/background-jobs.js.map +1 -1
- package/dist/store/background-ops.d.ts +145 -8
- package/dist/store/background-ops.d.ts.map +1 -1
- package/dist/store/background-ops.js +459 -15
- package/dist/store/background-ops.js.map +1 -1
- package/dist/store/backup-inspect.d.ts +48 -4
- package/dist/store/backup-inspect.d.ts.map +1 -1
- package/dist/store/backup-inspect.js +384 -4
- package/dist/store/backup-inspect.js.map +1 -1
- package/dist/store/converters.d.ts.map +1 -1
- package/dist/store/converters.js +19 -2
- package/dist/store/converters.js.map +1 -1
- package/dist/store/data-accessor.d.ts +9 -1
- package/dist/store/data-accessor.d.ts.map +1 -1
- package/dist/store/data-accessor.js +22 -5
- package/dist/store/data-accessor.js.map +1 -1
- package/dist/store/data-safety-central.d.ts.map +1 -1
- package/dist/store/data-safety-central.js +272 -232
- package/dist/store/data-safety-central.js.map +1 -1
- package/dist/store/db-helpers.d.ts +19 -3
- package/dist/store/db-helpers.d.ts.map +1 -1
- package/dist/store/db-helpers.js +42 -58
- package/dist/store/db-helpers.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts +63 -4
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +166 -19
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/exodus/archive.d.ts +21 -7
- package/dist/store/exodus/archive.d.ts.map +1 -1
- package/dist/store/exodus/archive.js +60 -18
- package/dist/store/exodus/archive.js.map +1 -1
- package/dist/store/exodus/migrate.d.ts.map +1 -1
- package/dist/store/exodus/migrate.js +27 -23
- package/dist/store/exodus/migrate.js.map +1 -1
- package/dist/store/exodus/on-open.d.ts +16 -27
- package/dist/store/exodus/on-open.d.ts.map +1 -1
- package/dist/store/exodus/on-open.js +121 -169
- package/dist/store/exodus/on-open.js.map +1 -1
- package/dist/store/exodus/recovery.d.ts +90 -0
- package/dist/store/exodus/recovery.d.ts.map +1 -0
- package/dist/store/exodus/recovery.js +434 -0
- package/dist/store/exodus/recovery.js.map +1 -0
- package/dist/store/exodus/types.d.ts +15 -0
- package/dist/store/exodus/types.d.ts.map +1 -1
- package/dist/store/memory-accessor.d.ts +52 -3
- package/dist/store/memory-accessor.d.ts.map +1 -1
- package/dist/store/memory-accessor.js +122 -7
- package/dist/store/memory-accessor.js.map +1 -1
- package/dist/store/nexus-sqlite.d.ts +24 -6
- package/dist/store/nexus-sqlite.d.ts.map +1 -1
- package/dist/store/nexus-sqlite.js +39 -20
- package/dist/store/nexus-sqlite.js.map +1 -1
- package/dist/store/ports/domain-binding.d.ts.map +1 -1
- package/dist/store/ports/domain-binding.js +27 -5
- package/dist/store/ports/domain-binding.js.map +1 -1
- package/dist/store/schema/background-jobs.d.ts +181 -2
- package/dist/store/schema/background-jobs.d.ts.map +1 -1
- package/dist/store/schema/background-jobs.js +27 -3
- package/dist/store/schema/background-jobs.js.map +1 -1
- package/dist/store/schema/cleo-global/skills.d.ts +2 -2
- package/dist/store/schema/cleo-project/lifecycle.d.ts +2 -2
- package/dist/store/schema/cleo-project/runtime.d.ts +1 -1
- package/dist/store/schema/cleo-project/tasks-core.d.ts +1 -1
- package/dist/store/schema/lifecycle.d.ts +2 -2
- package/dist/store/schema/skills-schema.d.ts +2 -2
- package/dist/store/schema/tasks.d.ts +1 -1
- package/dist/store/session-store.d.ts +3 -1
- package/dist/store/session-store.d.ts.map +1 -1
- package/dist/store/session-store.js +252 -207
- package/dist/store/session-store.js.map +1 -1
- package/dist/store/sqlite-data-accessor.d.ts +39 -4
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +689 -527
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/tasks-sqlite.d.ts +3 -1
- package/dist/store/tasks-sqlite.d.ts.map +1 -1
- package/dist/store/tasks-sqlite.js +309 -279
- package/dist/store/tasks-sqlite.js.map +1 -1
- package/dist/store/validation-schemas.d.ts +8 -8
- package/dist/store/writer-lease.d.ts +80 -8
- package/dist/store/writer-lease.d.ts.map +1 -1
- package/dist/store/writer-lease.js +503 -134
- package/dist/store/writer-lease.js.map +1 -1
- package/dist/system/audit.d.ts +2 -1
- package/dist/system/audit.d.ts.map +1 -1
- package/dist/system/audit.js +118 -71
- package/dist/system/audit.js.map +1 -1
- package/dist/system/backup.d.ts.map +1 -1
- package/dist/system/backup.js +5 -5
- package/dist/system/backup.js.map +1 -1
- package/dist/system/inject-generate.js +1 -1
- package/dist/task-work/index.d.ts +3 -0
- package/dist/task-work/index.d.ts.map +1 -1
- package/dist/task-work/index.js +34 -37
- package/dist/task-work/index.js.map +1 -1
- package/dist/tasks/ac-coverage-gate.d.ts.map +1 -1
- package/dist/tasks/ac-coverage-gate.js +4 -0
- package/dist/tasks/ac-coverage-gate.js.map +1 -1
- package/dist/tasks/ac-immutability.d.ts +7 -4
- package/dist/tasks/ac-immutability.d.ts.map +1 -1
- package/dist/tasks/ac-immutability.js +19 -17
- package/dist/tasks/ac-immutability.js.map +1 -1
- package/dist/tasks/ac-table.d.ts +5 -5
- package/dist/tasks/ac-table.d.ts.map +1 -1
- package/dist/tasks/ac-table.js +26 -12
- package/dist/tasks/ac-table.js.map +1 -1
- package/dist/tasks/acceptance-input.d.ts +52 -0
- package/dist/tasks/acceptance-input.d.ts.map +1 -0
- package/dist/tasks/acceptance-input.js +259 -0
- package/dist/tasks/acceptance-input.js.map +1 -0
- package/dist/tasks/add.d.ts +67 -29
- package/dist/tasks/add.d.ts.map +1 -1
- package/dist/tasks/add.js +255 -97
- package/dist/tasks/add.js.map +1 -1
- package/dist/tasks/complete.d.ts +16 -1
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +152 -55
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/decompose.d.ts +103 -0
- package/dist/tasks/decompose.d.ts.map +1 -0
- package/dist/tasks/decompose.js +224 -0
- package/dist/tasks/decompose.js.map +1 -0
- package/dist/tasks/delete.d.ts +5 -8
- package/dist/tasks/delete.d.ts.map +1 -1
- package/dist/tasks/delete.js +4 -3
- package/dist/tasks/delete.js.map +1 -1
- package/dist/tasks/dependency-check.d.ts +59 -0
- package/dist/tasks/dependency-check.d.ts.map +1 -1
- package/dist/tasks/dependency-check.js +73 -0
- package/dist/tasks/dependency-check.js.map +1 -1
- package/dist/tasks/deps-ready.d.ts +13 -1
- package/dist/tasks/deps-ready.d.ts.map +1 -1
- package/dist/tasks/deps-ready.js +16 -5
- package/dist/tasks/deps-ready.js.map +1 -1
- package/dist/tasks/engine-converters.d.ts +7 -0
- package/dist/tasks/engine-converters.d.ts.map +1 -1
- package/dist/tasks/engine-converters.js +8 -1
- package/dist/tasks/engine-converters.js.map +1 -1
- package/dist/tasks/evidence.d.ts +88 -27
- package/dist/tasks/evidence.d.ts.map +1 -1
- package/dist/tasks/evidence.js +344 -43
- package/dist/tasks/evidence.js.map +1 -1
- package/dist/tasks/find.d.ts +16 -12
- package/dist/tasks/find.d.ts.map +1 -1
- package/dist/tasks/find.js +107 -93
- package/dist/tasks/find.js.map +1 -1
- package/dist/tasks/gate-preview.d.ts +73 -0
- package/dist/tasks/gate-preview.d.ts.map +1 -0
- package/dist/tasks/gate-preview.js +119 -0
- package/dist/tasks/gate-preview.js.map +1 -0
- package/dist/tasks/gate-runner.d.ts +88 -14
- package/dist/tasks/gate-runner.d.ts.map +1 -1
- package/dist/tasks/gate-runner.js +719 -250
- package/dist/tasks/gate-runner.js.map +1 -1
- package/dist/tasks/hierarchy-policy.d.ts +8 -0
- package/dist/tasks/hierarchy-policy.d.ts.map +1 -1
- package/dist/tasks/hierarchy-policy.js +9 -2
- package/dist/tasks/hierarchy-policy.js.map +1 -1
- package/dist/tasks/hierarchy.d.ts +67 -1
- package/dist/tasks/hierarchy.d.ts.map +1 -1
- package/dist/tasks/hierarchy.js +81 -1
- package/dist/tasks/hierarchy.js.map +1 -1
- package/dist/tasks/index.d.ts +3 -0
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/index.js +3 -0
- package/dist/tasks/index.js.map +1 -1
- package/dist/tasks/infer-add-params.d.ts +1 -20
- package/dist/tasks/infer-add-params.d.ts.map +1 -1
- package/dist/tasks/infer-add-params.js +2 -203
- package/dist/tasks/infer-add-params.js.map +1 -1
- package/dist/tasks/list.d.ts +7 -2
- package/dist/tasks/list.d.ts.map +1 -1
- package/dist/tasks/list.js +24 -36
- package/dist/tasks/list.js.map +1 -1
- package/dist/tasks/ops.d.ts +6 -61
- package/dist/tasks/ops.d.ts.map +1 -1
- package/dist/tasks/ops.js +5 -53
- package/dist/tasks/ops.js.map +1 -1
- package/dist/tasks/plan.d.ts +15 -1
- package/dist/tasks/plan.d.ts.map +1 -1
- package/dist/tasks/plan.js +23 -25
- package/dist/tasks/plan.js.map +1 -1
- package/dist/tasks/population.d.ts +46 -0
- package/dist/tasks/population.d.ts.map +1 -0
- package/dist/tasks/population.js +88 -0
- package/dist/tasks/population.js.map +1 -0
- package/dist/tasks/reconcile-scope.d.ts +157 -0
- package/dist/tasks/reconcile-scope.d.ts.map +1 -0
- package/dist/tasks/reconcile-scope.js +242 -0
- package/dist/tasks/reconcile-scope.js.map +1 -0
- package/dist/tasks/req.d.ts +51 -12
- package/dist/tasks/req.d.ts.map +1 -1
- package/dist/tasks/req.js +125 -69
- package/dist/tasks/req.js.map +1 -1
- package/dist/tasks/session-scope.d.ts +6 -31
- package/dist/tasks/session-scope.d.ts.map +1 -1
- package/dist/tasks/session-scope.js +3 -17
- package/dist/tasks/session-scope.js.map +1 -1
- package/dist/tasks/severity-attestation.d.ts +39 -10
- package/dist/tasks/severity-attestation.d.ts.map +1 -1
- package/dist/tasks/severity-attestation.js +75 -36
- package/dist/tasks/severity-attestation.js.map +1 -1
- package/dist/tasks/task-next.d.ts +5 -0
- package/dist/tasks/task-next.d.ts.map +1 -1
- package/dist/tasks/task-next.js +10 -9
- package/dist/tasks/task-next.js.map +1 -1
- package/dist/tasks/task-reparent.d.ts.map +1 -1
- package/dist/tasks/task-reparent.js +3 -13
- package/dist/tasks/task-reparent.js.map +1 -1
- package/dist/tasks/update.d.ts +20 -43
- package/dist/tasks/update.d.ts.map +1 -1
- package/dist/tasks/update.js +64 -49
- package/dist/tasks/update.js.map +1 -1
- package/dist/validation/engine-ops.d.ts +17 -1
- package/dist/validation/engine-ops.d.ts.map +1 -1
- package/dist/validation/engine-ops.js +149 -11
- package/dist/validation/engine-ops.js.map +1 -1
- package/dist/workgraph/reparent-preflight.d.ts +1 -1
- package/dist/workgraph/reparent-preflight.d.ts.map +1 -1
- package/dist/workgraph/reparent-preflight.js +6 -1
- package/dist/workgraph/reparent-preflight.js.map +1 -1
- package/dist/workgraph/scaffold-apply.d.ts.map +1 -1
- package/dist/workgraph/scaffold-apply.js +81 -76
- package/dist/workgraph/scaffold-apply.js.map +1 -1
- package/dist/workgraph/structure-validation.d.ts +1 -1
- package/dist/workgraph/structure-validation.d.ts.map +1 -1
- package/dist/workgraph/structure-validation.js +6 -1
- package/dist/workgraph/structure-validation.js.map +1 -1
- package/migrations/drizzle-tasks/20260919180000_t12263-job-ownership-fences/migration.sql +34 -0
- package/migrations/drizzle-tasks/20260919184500_t12265-durable-pending-proposals/migration.sql +4 -0
- package/package.json +18 -13
- package/schemas/config.schema.json +2 -2
- package/schemas/project-context.schema.json +12 -0
- package/templates/CLEO-INJECTION.md +114 -101
|
@@ -1,296 +1,385 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Orchestrator protocol
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* manifest integrity, and pre-spawn compliance checks.
|
|
7
|
-
*
|
|
8
|
-
* @epic T4454
|
|
9
|
-
* @task T4519
|
|
2
|
+
* Orchestrator protocol validation against canonical current evidence or an
|
|
3
|
+
* explicitly selected historical JSONL file. Historical validation is never
|
|
4
|
+
* presented as verification of the current authoritative store.
|
|
5
|
+
* @task T12282
|
|
10
6
|
*/
|
|
11
|
-
import {
|
|
12
|
-
import { join } from 'node:path';
|
|
7
|
+
import { readFileSync } from 'node:fs';
|
|
8
|
+
import { join, resolve } from 'node:path';
|
|
13
9
|
import { MANIFEST_STATUSES } from '@cleocode/contracts';
|
|
14
|
-
import {
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { EngineResultError } from '../../engine-result.js';
|
|
12
|
+
import { pipelineManifestShow, readManifestEntries, } from '../../memory/pipeline-manifest-sqlite.js';
|
|
13
|
+
import { getAgentOutputsAbsolute, getProjectRoot, resolveOrCwd } from '../../paths.js';
|
|
14
|
+
import { captureProjectScope, worktreeScope } from '../../project-scope.js';
|
|
15
15
|
import { getTaskAccessor } from '../../store/data-accessor.js';
|
|
16
|
-
// ============================================================================
|
|
17
|
-
// Constants
|
|
18
|
-
// ============================================================================
|
|
19
16
|
const KEY_FINDINGS_MIN = 3;
|
|
20
17
|
const KEY_FINDINGS_MAX = 7;
|
|
21
|
-
const MANIFEST_REQUIRED_FIELDS = [
|
|
22
|
-
'id',
|
|
23
|
-
'file',
|
|
24
|
-
'title',
|
|
25
|
-
'date',
|
|
26
|
-
'status',
|
|
27
|
-
'topics',
|
|
28
|
-
'key_findings',
|
|
29
|
-
'actionable',
|
|
30
|
-
];
|
|
31
18
|
const VALID_STATUSES_SET = new Set(MANIFEST_STATUSES);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
const CHECKED_RULES = [
|
|
20
|
+
'MANIFEST_ENTRY_EXISTS',
|
|
21
|
+
'REQUIRED_FIELDS_PRESENT',
|
|
22
|
+
'STATUS_VALID_ENUM',
|
|
23
|
+
'KEY_FINDINGS_COUNT_3_7',
|
|
24
|
+
'DATE_ISO_8601',
|
|
25
|
+
'TOPICS_ARRAY_NON_EMPTY',
|
|
26
|
+
'NEEDS_FOLLOWUP_ARRAY',
|
|
27
|
+
'ACTIONABLE_BOOLEAN',
|
|
28
|
+
'OUTPUT_FILE_EXISTS',
|
|
29
|
+
];
|
|
30
|
+
const historicalEntrySchema = z.looseObject({
|
|
31
|
+
id: z.string().min(1),
|
|
32
|
+
file: z.string().min(1),
|
|
33
|
+
title: z.string().min(1),
|
|
34
|
+
date: z.string().min(1),
|
|
35
|
+
status: z.enum(MANIFEST_STATUSES),
|
|
36
|
+
agent_type: z.string().optional(),
|
|
37
|
+
topics: z.array(z.string()),
|
|
38
|
+
key_findings: z.array(z.string()),
|
|
39
|
+
actionable: z.boolean(),
|
|
40
|
+
needs_followup: z.array(z.string()),
|
|
41
|
+
linked_tasks: z.array(z.string()).optional(),
|
|
42
|
+
});
|
|
43
|
+
function currentSourceIssue(method) {
|
|
44
|
+
return `CURRENT_MANIFEST_REQUIRES_ASYNC: Use ${method} for the authoritative store, or explicitly select a historicalManifestPath.`;
|
|
38
45
|
}
|
|
39
|
-
|
|
40
|
-
* Read all manifest entries from the legacy agent-outputs flat-file.
|
|
41
|
-
*/
|
|
42
|
-
function readManifestEntries(cwd) {
|
|
43
|
-
const manifestPath = getManifestPath(cwd);
|
|
44
|
-
if (!existsSync(manifestPath))
|
|
45
|
-
return [];
|
|
46
|
-
const content = readFileSync(manifestPath, 'utf-8');
|
|
46
|
+
function readHistoricalEntries(cwd, manifestPath) {
|
|
47
47
|
const entries = [];
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
const issues = [];
|
|
49
|
+
let content;
|
|
50
|
+
try {
|
|
51
|
+
content = readFileSync(resolve(resolveOrCwd(cwd), manifestPath), 'utf8');
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
issues.push(`HISTORICAL_MANIFEST_READ_FAILED: ${error instanceof Error ? error.message : String(error)}`);
|
|
55
|
+
return { exists: false, entries, issues, totalLines: 0, invalidEntries: 0 };
|
|
56
|
+
}
|
|
57
|
+
let totalLines = 0;
|
|
58
|
+
let invalidEntries = 0;
|
|
59
|
+
const seen = new Set();
|
|
60
|
+
for (const [index, line] of content.split('\n').entries()) {
|
|
61
|
+
if (!line.trim())
|
|
51
62
|
continue;
|
|
63
|
+
totalLines++;
|
|
52
64
|
try {
|
|
53
|
-
|
|
65
|
+
const parsed = historicalEntrySchema.safeParse(JSON.parse(line));
|
|
66
|
+
if (!parsed.success) {
|
|
67
|
+
issues.push(`LINE_${index + 1}_INVALID_ENTRY: ${parsed.error.message}`);
|
|
68
|
+
invalidEntries++;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (seen.has(parsed.data.id)) {
|
|
72
|
+
issues.push(`LINE_${index + 1}_DUPLICATE_ID: ${parsed.data.id}`);
|
|
73
|
+
invalidEntries++;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
seen.add(parsed.data.id);
|
|
77
|
+
entries.push(parsed.data);
|
|
54
78
|
}
|
|
55
|
-
catch {
|
|
56
|
-
|
|
79
|
+
catch (error) {
|
|
80
|
+
issues.push(`LINE_${index + 1}_INVALID_JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
81
|
+
invalidEntries++;
|
|
57
82
|
}
|
|
58
83
|
}
|
|
59
|
-
|
|
84
|
+
if (totalLines === 0)
|
|
85
|
+
issues.push('MANIFEST_EMPTY: Selected historical file has no evidence');
|
|
86
|
+
return { exists: true, entries, issues, totalLines, invalidEntries };
|
|
60
87
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Validate a subagent's manifest entry for protocol compliance.
|
|
66
|
-
* @task T4519
|
|
67
|
-
*/
|
|
68
|
-
export function validateSubagentOutput(researchId, cwd) {
|
|
88
|
+
function entryIssues(entry, researchId) {
|
|
89
|
+
if (!entry)
|
|
90
|
+
return [`MANIFEST_ENTRY_MISSING: No manifest entry found for id=${researchId}`];
|
|
69
91
|
const issues = [];
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
'REQUIRED_FIELDS_PRESENT',
|
|
73
|
-
'STATUS_VALID_ENUM',
|
|
74
|
-
'KEY_FINDINGS_COUNT_3_7',
|
|
75
|
-
'DATE_ISO_8601',
|
|
76
|
-
'TOPICS_ARRAY_NON_EMPTY',
|
|
77
|
-
'NEEDS_FOLLOWUP_ARRAY',
|
|
78
|
-
'ACTIONABLE_BOOLEAN',
|
|
79
|
-
'OUTPUT_FILE_EXISTS',
|
|
80
|
-
];
|
|
81
|
-
const entries = readManifestEntries(cwd);
|
|
82
|
-
const entry = entries.find((e) => e.id === researchId);
|
|
83
|
-
if (!entry) {
|
|
84
|
-
issues.push(`MANIFEST_ENTRY_MISSING: No manifest entry found for id=${researchId}`);
|
|
85
|
-
return { passed: false, issues, checkedRules };
|
|
86
|
-
}
|
|
87
|
-
// Check required fields
|
|
88
|
-
for (const field of MANIFEST_REQUIRED_FIELDS) {
|
|
89
|
-
if (!(field in entry)) {
|
|
92
|
+
for (const field of ['id', 'file', 'title', 'date']) {
|
|
93
|
+
if (!entry[field])
|
|
90
94
|
issues.push(`MISSING_FIELD: ${field}`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
// Validate status
|
|
94
|
-
if (entry.status && !VALID_STATUSES_SET.has(entry.status)) {
|
|
95
|
-
issues.push(`INVALID_STATUS: ${entry.status} (must be completed|partial|blocked|archived)`);
|
|
96
|
-
}
|
|
97
|
-
// Validate key_findings count
|
|
98
|
-
if (!Array.isArray(entry.key_findings)) {
|
|
99
|
-
issues.push('KEY_FINDINGS_NOT_ARRAY');
|
|
100
95
|
}
|
|
101
|
-
|
|
102
|
-
issues.push(`
|
|
96
|
+
if (!VALID_STATUSES_SET.has(entry.status))
|
|
97
|
+
issues.push(`INVALID_STATUS: ${entry.status}`);
|
|
98
|
+
if (entry.key_findings.length < KEY_FINDINGS_MIN ||
|
|
99
|
+
entry.key_findings.length > KEY_FINDINGS_MAX) {
|
|
100
|
+
issues.push(`KEY_FINDINGS_COUNT: count=${entry.key_findings.length} (must be ${KEY_FINDINGS_MIN}-${KEY_FINDINGS_MAX})`);
|
|
103
101
|
}
|
|
104
|
-
|
|
105
|
-
issues.push(`
|
|
106
|
-
|
|
107
|
-
// Validate date format
|
|
108
|
-
if (entry.date && !/^\d{4}-\d{2}-\d{2}$/.test(entry.date)) {
|
|
109
|
-
issues.push(`INVALID_DATE: ${entry.date} (must be YYYY-MM-DD)`);
|
|
110
|
-
}
|
|
111
|
-
// Validate topics
|
|
112
|
-
if (!Array.isArray(entry.topics) || entry.topics.length === 0) {
|
|
102
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(entry.date))
|
|
103
|
+
issues.push(`INVALID_DATE: ${entry.date}`);
|
|
104
|
+
if (entry.topics.length === 0)
|
|
113
105
|
issues.push('TOPICS_EMPTY: topics must be a non-empty array');
|
|
106
|
+
return issues;
|
|
107
|
+
}
|
|
108
|
+
function historicalOutputIssue(entry, cwd) {
|
|
109
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(entry.file)) {
|
|
110
|
+
return `HISTORICAL_OUTPUT_REQUIRES_ASYNC: Cannot resolve ${entry.file} as an explicit historical file`;
|
|
114
111
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
try {
|
|
113
|
+
const scope = captureProjectScope(cwd ?? getProjectRoot(), worktreeScope.getStore());
|
|
114
|
+
const outputRoot = worktreeScope.run(scope, () => getAgentOutputsAbsolute(scope.worktreeRoot));
|
|
115
|
+
readFileSync(join(outputRoot, entry.file));
|
|
116
|
+
return null;
|
|
118
117
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
118
|
+
catch (error) {
|
|
119
|
+
return `OUTPUT_FILE_READ_FAILED: ${entry.file}: ${error instanceof Error ? error.message : String(error)}`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function selectedEntry(entries, taskId, researchId) {
|
|
123
|
+
return researchId
|
|
124
|
+
? entries.find((entry) => entry.id === researchId)
|
|
125
|
+
: entries.find((entry) => entry.linked_tasks?.includes(taskId));
|
|
126
|
+
}
|
|
127
|
+
function complianceResult(taskId, entry, issues) {
|
|
128
|
+
const violations = [...issues];
|
|
129
|
+
const researchLinkedToTask = entry?.linked_tasks?.includes(taskId) ?? false;
|
|
130
|
+
if (entry && !researchLinkedToTask)
|
|
131
|
+
violations.push(`RESEARCH_NOT_LINKED: ${entry.id} is not linked to ${taskId}`);
|
|
132
|
+
const returnStatusValid = entry ? VALID_STATUSES_SET.has(entry.status) : null;
|
|
133
|
+
if (returnStatusValid === false)
|
|
134
|
+
violations.push(`INVALID_MANIFEST_STATUS: ${entry?.status}`);
|
|
135
|
+
return {
|
|
136
|
+
previousTaskId: taskId,
|
|
137
|
+
researchId: entry?.id ?? null,
|
|
138
|
+
checks: { manifestEntryExists: !!entry, researchLinkedToTask, returnStatusValid },
|
|
139
|
+
canSpawnNext: violations.length === 0,
|
|
140
|
+
violations,
|
|
141
|
+
warnings: [],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function currentRoot(cwd) {
|
|
145
|
+
return captureProjectScope(cwd ?? getProjectRoot(), worktreeScope.getStore()).worktreeRoot;
|
|
146
|
+
}
|
|
147
|
+
async function currentOutputIssue(entry, root) {
|
|
148
|
+
const result = await pipelineManifestShow(entry.id, root);
|
|
149
|
+
if (!result.success)
|
|
150
|
+
throw new EngineResultError(result.error);
|
|
151
|
+
const data = result.data;
|
|
152
|
+
if (!data ||
|
|
153
|
+
typeof data !== 'object' ||
|
|
154
|
+
!('fileExists' in data) ||
|
|
155
|
+
typeof data.fileExists !== 'boolean') {
|
|
156
|
+
throw new EngineResultError({
|
|
157
|
+
code: 'E_MANIFEST_RESULT_INVALID',
|
|
158
|
+
message: 'Canonical manifest show did not disclose output availability',
|
|
159
|
+
details: { entryId: entry.id },
|
|
160
|
+
});
|
|
126
161
|
}
|
|
127
|
-
return
|
|
162
|
+
return data.fileExists ? null : `OUTPUT_FILE_MISSING: ${entry.file}`;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Validate one entry in an explicitly selected historical JSONL file synchronously.
|
|
166
|
+
* @remarks Bare calls cannot validate the authoritative current store and return
|
|
167
|
+
* an unavailable-current-source issue. Use validateCurrentSubagentOutput for that store.
|
|
168
|
+
* @param researchId - Exact historical entry identity.
|
|
169
|
+
* @param cwd - Root used for relative historical paths and output files.
|
|
170
|
+
* @param historicalManifestPath - Explicit historical file; never inferred from cwd.
|
|
171
|
+
* @returns Synchronous compliance result with all historical read/parse issues.
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* const result = validateSubagentOutput('entry', '/project', 'history.jsonl');
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
export function validateSubagentOutput(researchId, cwd, historicalManifestPath) {
|
|
178
|
+
if (!historicalManifestPath)
|
|
179
|
+
return {
|
|
180
|
+
passed: false,
|
|
181
|
+
issues: [currentSourceIssue('validateCurrentSubagentOutput')],
|
|
182
|
+
checkedRules: [...CHECKED_RULES],
|
|
183
|
+
};
|
|
184
|
+
const history = readHistoricalEntries(cwd, historicalManifestPath);
|
|
185
|
+
const entry = history.entries.find((candidate) => candidate.id === researchId);
|
|
186
|
+
const issues = [...history.issues, ...entryIssues(entry, researchId)];
|
|
187
|
+
const outputIssue = entry && historicalOutputIssue(entry, cwd);
|
|
188
|
+
if (outputIssue)
|
|
189
|
+
issues.push(outputIssue);
|
|
190
|
+
return { passed: issues.length === 0, issues, checkedRules: [...CHECKED_RULES] };
|
|
128
191
|
}
|
|
129
|
-
// ============================================================================
|
|
130
|
-
// Manifest Integrity
|
|
131
|
-
// ============================================================================
|
|
132
192
|
/**
|
|
133
|
-
* Validate
|
|
134
|
-
* @
|
|
193
|
+
* Validate an explicitly selected historical manifest synchronously.
|
|
194
|
+
* @remarks This preserves the synchronous return shape without equating a retired
|
|
195
|
+
* or missing JSONL file with a valid current database. Every malformed row fails.
|
|
196
|
+
* @param cwd - Root for relative historical and output paths.
|
|
197
|
+
* @param historicalManifestPath - Explicit historical JSONL file.
|
|
198
|
+
* @returns Historical validation result; absent explicit source fails.
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const result = validateManifestIntegrity('/project', 'history.jsonl');
|
|
202
|
+
* ```
|
|
135
203
|
*/
|
|
136
|
-
export function validateManifestIntegrity(cwd) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
204
|
+
export function validateManifestIntegrity(cwd, historicalManifestPath) {
|
|
205
|
+
if (!historicalManifestPath)
|
|
206
|
+
return {
|
|
207
|
+
exists: false,
|
|
208
|
+
passed: false,
|
|
209
|
+
issues: [currentSourceIssue('validateCurrentManifestIntegrity')],
|
|
210
|
+
};
|
|
211
|
+
const history = readHistoricalEntries(cwd, historicalManifestPath);
|
|
212
|
+
const issues = [...history.issues];
|
|
213
|
+
for (const entry of history.entries) {
|
|
214
|
+
issues.push(...entryIssues(entry, entry.id));
|
|
215
|
+
const outputIssue = historicalOutputIssue(entry, cwd);
|
|
216
|
+
if (outputIssue)
|
|
217
|
+
issues.push(outputIssue);
|
|
140
218
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
219
|
+
return {
|
|
220
|
+
exists: history.exists,
|
|
221
|
+
passed: issues.length === 0,
|
|
222
|
+
issues,
|
|
223
|
+
stats: {
|
|
224
|
+
totalLines: history.totalLines,
|
|
225
|
+
validEntries: history.entries.length,
|
|
226
|
+
invalidEntries: history.invalidEntries,
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Check exact task linkage and output validity in explicitly selected history.
|
|
232
|
+
* @remarks Entry names and follow-up requests do not establish task evidence.
|
|
233
|
+
* Bare synchronous calls fail with current-store async guidance.
|
|
234
|
+
* @param previousTaskId - Exact task whose evidence is required.
|
|
235
|
+
* @param researchId - Optional exact historical entry identity.
|
|
236
|
+
* @param cwd - Root for relative historical and output paths.
|
|
237
|
+
* @param historicalManifestPath - Explicit historical JSONL file.
|
|
238
|
+
* @returns Synchronous compliance result, never successful after read/parse failure.
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* const result = verifyCompliance('T1', undefined, '/project', 'history.jsonl');
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
export function verifyCompliance(previousTaskId, researchId, cwd, historicalManifestPath) {
|
|
245
|
+
if (!historicalManifestPath)
|
|
246
|
+
return complianceResult(previousTaskId, undefined, [
|
|
247
|
+
currentSourceIssue('verifyCurrentCompliance'),
|
|
248
|
+
]);
|
|
249
|
+
const history = readHistoricalEntries(cwd, historicalManifestPath);
|
|
250
|
+
const entry = selectedEntry(history.entries, previousTaskId, researchId);
|
|
251
|
+
const issues = [...history.issues, ...entryIssues(entry, researchId ?? previousTaskId)];
|
|
252
|
+
const outputIssue = entry && historicalOutputIssue(entry, cwd);
|
|
253
|
+
if (outputIssue)
|
|
254
|
+
issues.push(outputIssue);
|
|
255
|
+
return complianceResult(previousTaskId, entry, issues);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Validate an exact entry from canonical modern and retained historical rows.
|
|
259
|
+
* @remarks Captures project ownership before awaiting and verifies real output
|
|
260
|
+
* availability through the same canonical resolver as manifest show.
|
|
261
|
+
* @param researchId - Exact canonical entry identity.
|
|
262
|
+
* @param cwd - Optional explicit project root.
|
|
263
|
+
* @returns Field and output validation result.
|
|
264
|
+
* @throws If canonical storage, history, metadata or output resolution fails.
|
|
265
|
+
* @example
|
|
266
|
+
* ```ts
|
|
267
|
+
* const result = await validateCurrentSubagentOutput('entry', '/project');
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
export async function validateCurrentSubagentOutput(researchId, cwd) {
|
|
271
|
+
const root = currentRoot(cwd);
|
|
272
|
+
const entries = await readManifestEntries(root);
|
|
273
|
+
const entry = entries.find((candidate) => candidate.id === researchId);
|
|
274
|
+
const issues = entryIssues(entry, researchId);
|
|
275
|
+
const outputIssue = entry && (await currentOutputIssue(entry, root));
|
|
276
|
+
if (outputIssue)
|
|
277
|
+
issues.push(outputIssue);
|
|
278
|
+
return { passed: issues.length === 0, issues, checkedRules: [...CHECKED_RULES] };
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Validate eligible canonical manifest rows and their actual output availability.
|
|
282
|
+
* @remarks The existing totalLines counter denotes records for the database
|
|
283
|
+
* source. Empty evidence fails; archived rows remain outside current eligibility.
|
|
284
|
+
* @param cwd - Optional explicit project root.
|
|
285
|
+
* @returns Integrity result for current eligible evidence.
|
|
286
|
+
* @throws If canonical reads, history comparison or output resolution fail.
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* const result = await validateCurrentManifestIntegrity('/project');
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
export async function validateCurrentManifestIntegrity(cwd) {
|
|
293
|
+
const root = currentRoot(cwd);
|
|
294
|
+
const entries = await readManifestEntries(root);
|
|
295
|
+
const issues = entries.length
|
|
296
|
+
? []
|
|
297
|
+
: ['MANIFEST_EMPTY: Current store has no eligible evidence'];
|
|
145
298
|
let invalidEntries = 0;
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// Check valid JSON
|
|
153
|
-
let entry;
|
|
154
|
-
try {
|
|
155
|
-
entry = JSON.parse(line);
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
issues.push(`LINE_${lineNum}_INVALID_JSON: Parse error`);
|
|
159
|
-
invalidEntries++;
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
// Check id field
|
|
163
|
-
if (!entry.id) {
|
|
164
|
-
issues.push(`LINE_${lineNum}_MISSING_ID: No id field`);
|
|
165
|
-
invalidEntries++;
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
// Check duplicate ID
|
|
169
|
-
if (seenIds.has(entry.id)) {
|
|
170
|
-
issues.push(`LINE_${lineNum}_DUPLICATE_ID: ${entry.id} already exists`);
|
|
299
|
+
for (const entry of entries) {
|
|
300
|
+
const entryProblems = entryIssues(entry, entry.id);
|
|
301
|
+
const outputIssue = await currentOutputIssue(entry, root);
|
|
302
|
+
if (outputIssue)
|
|
303
|
+
entryProblems.push(outputIssue);
|
|
304
|
+
if (entryProblems.length)
|
|
171
305
|
invalidEntries++;
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
seenIds.add(entry.id);
|
|
175
|
-
// Check file exists
|
|
176
|
-
if (entry.file) {
|
|
177
|
-
const absOutputDir = getAgentOutputsAbsolute(cwd);
|
|
178
|
-
const filePath = join(absOutputDir, entry.file);
|
|
179
|
-
if (!existsSync(filePath)) {
|
|
180
|
-
issues.push(`LINE_${lineNum}_FILE_MISSING: ${entry.file} does not exist`);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
validEntries++;
|
|
306
|
+
issues.push(...entryProblems.map((issue) => `${entry.id}: ${issue}`));
|
|
184
307
|
}
|
|
185
308
|
return {
|
|
186
309
|
exists: true,
|
|
187
310
|
passed: issues.length === 0,
|
|
311
|
+
issues,
|
|
188
312
|
stats: {
|
|
189
|
-
totalLines:
|
|
190
|
-
validEntries,
|
|
313
|
+
totalLines: entries.length,
|
|
314
|
+
validEntries: entries.length - invalidEntries,
|
|
191
315
|
invalidEntries,
|
|
192
316
|
},
|
|
193
|
-
issues,
|
|
194
317
|
};
|
|
195
318
|
}
|
|
196
|
-
// ============================================================================
|
|
197
|
-
// Pre-Spawn Compliance Verification
|
|
198
|
-
// ============================================================================
|
|
199
319
|
/**
|
|
200
|
-
*
|
|
201
|
-
* @task
|
|
320
|
+
* Check current canonical evidence for an exact task before another spawn.
|
|
321
|
+
* @remarks Requires explicit task linkage and valid fields/output; identifier
|
|
322
|
+
* substrings and follow-up requests cannot authorize the next action.
|
|
323
|
+
* @param previousTaskId - Exact task whose evidence is required.
|
|
324
|
+
* @param researchId - Optional exact canonical entry identity.
|
|
325
|
+
* @param cwd - Optional explicit project root.
|
|
326
|
+
* @returns Compliance result with current canonical evidence checks.
|
|
327
|
+
* @throws If canonical reads, history comparison or output resolution fail.
|
|
328
|
+
* @example
|
|
329
|
+
* ```ts
|
|
330
|
+
* const result = await verifyCurrentCompliance('T1', undefined, '/project');
|
|
331
|
+
* ```
|
|
202
332
|
*/
|
|
203
|
-
export function
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
else {
|
|
213
|
-
// Search by linked_tasks
|
|
214
|
-
entry = entries.find((e) => e.linked_tasks?.includes(previousTaskId) || e.needs_followup?.includes(previousTaskId));
|
|
215
|
-
// Try ID pattern match
|
|
216
|
-
if (!entry) {
|
|
217
|
-
const taskNum = previousTaskId.replace(/^T/, '');
|
|
218
|
-
entry = entries.find((e) => e.id.includes(taskNum));
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
const manifestEntryExists = !!entry;
|
|
222
|
-
if (!manifestEntryExists) {
|
|
223
|
-
violations.push(`MANIFEST_ENTRY_MISSING: No manifest entry found for task ${previousTaskId}`);
|
|
224
|
-
}
|
|
225
|
-
// Check research linked to task
|
|
226
|
-
let researchLinkedToTask = false;
|
|
227
|
-
if (entry) {
|
|
228
|
-
researchLinkedToTask = entry.linked_tasks?.includes(previousTaskId) ?? false;
|
|
229
|
-
if (!researchLinkedToTask) {
|
|
230
|
-
warnings.push(`RESEARCH_NOT_LINKED: Research entry exists but not linked to task ${previousTaskId}`);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
// Check return status
|
|
234
|
-
let returnStatusValid = null;
|
|
235
|
-
if (entry) {
|
|
236
|
-
returnStatusValid = VALID_STATUSES_SET.has(entry.status);
|
|
237
|
-
if (!returnStatusValid) {
|
|
238
|
-
violations.push(`INVALID_MANIFEST_STATUS: ${entry.status}`);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return {
|
|
242
|
-
previousTaskId,
|
|
243
|
-
researchId: entry?.id ?? null,
|
|
244
|
-
checks: {
|
|
245
|
-
manifestEntryExists,
|
|
246
|
-
researchLinkedToTask,
|
|
247
|
-
returnStatusValid,
|
|
248
|
-
},
|
|
249
|
-
canSpawnNext: violations.length === 0,
|
|
250
|
-
violations,
|
|
251
|
-
warnings,
|
|
252
|
-
};
|
|
333
|
+
export async function verifyCurrentCompliance(previousTaskId, researchId, cwd) {
|
|
334
|
+
const root = currentRoot(cwd);
|
|
335
|
+
const entries = await readManifestEntries(root);
|
|
336
|
+
const entry = selectedEntry(entries, previousTaskId, researchId);
|
|
337
|
+
const issues = entryIssues(entry, researchId ?? previousTaskId);
|
|
338
|
+
const outputIssue = entry && (await currentOutputIssue(entry, root));
|
|
339
|
+
if (outputIssue)
|
|
340
|
+
issues.push(outputIssue);
|
|
341
|
+
return complianceResult(previousTaskId, entry, issues);
|
|
253
342
|
}
|
|
254
343
|
/**
|
|
255
344
|
* Validate orchestrator compliance (post-hoc behavioral checks).
|
|
256
|
-
* @task
|
|
345
|
+
* @remarks Uses canonical manifest evidence and propagates failed task reads.
|
|
346
|
+
* @param epicId - Optional epic for dependency completion-order checks.
|
|
347
|
+
* @param cwd - Optional explicit project root.
|
|
348
|
+
* @returns Compliance result and observed protocol violations.
|
|
349
|
+
* @throws If canonical evidence or task storage reads fail.
|
|
350
|
+
* @example
|
|
351
|
+
* ```ts
|
|
352
|
+
* const result = await validateOrchestratorCompliance('T0', '/project');
|
|
353
|
+
* ```
|
|
257
354
|
*/
|
|
258
355
|
export async function validateOrchestratorCompliance(epicId, cwd) {
|
|
259
356
|
const violations = [];
|
|
260
357
|
const warnings = [];
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
if (!
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
const content = readFileSync(manifestPath, 'utf-8').trim();
|
|
268
|
-
if (!content) {
|
|
269
|
-
warnings.push('ORC-005_EMPTY_MANIFEST: Manifest exists but has no entries');
|
|
270
|
-
}
|
|
271
|
-
}
|
|
358
|
+
const root = currentRoot(cwd);
|
|
359
|
+
const manifest = await validateCurrentManifestIntegrity(root);
|
|
360
|
+
if (!manifest.passed)
|
|
361
|
+
violations.push(...manifest.issues);
|
|
272
362
|
// Check dependency order (ORC-004) for completed tasks via DataAccessor
|
|
273
363
|
if (epicId) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
364
|
+
const acc = await getTaskAccessor(root);
|
|
365
|
+
if (!(await acc.loadSingleTask(epicId))) {
|
|
366
|
+
violations.push(`ORC_EPIC_NOT_FOUND: Cannot assess dependency order for ${epicId}`);
|
|
367
|
+
return { compliant: false, violations, warnings };
|
|
368
|
+
}
|
|
369
|
+
const children = await acc.getChildren(epicId);
|
|
370
|
+
const tasks = children.filter((t) => t.status === 'done');
|
|
371
|
+
// Sort by updatedAt and check for dependency violations
|
|
372
|
+
const sorted = tasks.sort((a, b) => new Date(a.updatedAt ?? '').getTime() - new Date(b.updatedAt ?? '').getTime());
|
|
373
|
+
const completionOrder = sorted.map((t) => t.id);
|
|
374
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
375
|
+
const deps = sorted[i].depends ?? [];
|
|
376
|
+
for (const dep of deps) {
|
|
377
|
+
const depIdx = completionOrder.indexOf(dep);
|
|
378
|
+
if (depIdx >= 0 && depIdx >= i) {
|
|
379
|
+
violations.push(`ORC-004_DEPENDENCY_ORDER: Task ${sorted[i].id} completed before dependency ${dep}`);
|
|
288
380
|
}
|
|
289
381
|
}
|
|
290
382
|
}
|
|
291
|
-
catch {
|
|
292
|
-
// Skip on DB error
|
|
293
|
-
}
|
|
294
383
|
}
|
|
295
384
|
return {
|
|
296
385
|
compliant: violations.length === 0,
|