@aibyzero/cm-workflow 0.17.0 → 0.18.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/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +27 -0
- package/CHANGELOG.md +230 -1
- package/CONTRIBUTING.md +47 -0
- package/README.md +21 -3
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/VERSION +1 -1
- package/compat/claude-commands/cm-challenge.md +3 -0
- package/docs/architecture.md +40 -13
- package/docs/cm-control-policy-v2.md +127 -9
- package/docs/fixes/20261013-claude-preinit-ui-invalidate.md +48 -0
- package/docs/installation.md +310 -4
- package/docs/js-workflow-control.md +153 -16
- package/docs/live-evidence-drivers.md +28 -4
- package/docs/out-of-scope/README.md +25 -0
- package/docs/out-of-scope/background-supervisor.md +32 -0
- package/docs/reviewed-integration.md +48 -0
- package/docs/user-guide.md +50 -21
- package/install-codex.sh +331 -18
- package/install.ps1 +28 -2
- package/install.sh +321 -17
- package/package.json +2 -1
- package/runtime/js/cm-ai/batch-location.mjs +55 -0
- package/runtime/js/cm-ai/batch-plan.mjs +242 -0
- package/runtime/js/cm-ai/checkpoint-package-material.mjs +162 -0
- package/runtime/js/cm-ai/claude-developer-proposal.schema.json +55 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +94 -21
- package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-admission.mjs +18 -12
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +91 -6
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +5 -1
- package/runtime/js/cm-ai/codex-config.mjs +6 -2
- package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +3 -2
- package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
- package/runtime/js/cm-ai/codex-reconnect-notice.mjs +6 -0
- package/runtime/js/cm-ai/codex-review-adapter.mjs +27 -7
- package/runtime/js/cm-ai/control-policy.mjs +24 -6
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +236 -34
- package/runtime/js/cm-ai/drive-rate-limit.mjs +105 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +234 -33
- package/runtime/js/cm-ai/effect-contract.mjs +11 -2
- package/runtime/js/cm-ai/execution-policy.mjs +3 -1
- package/runtime/js/cm-ai/execution-snapshot.mjs +4 -2
- package/runtime/js/cm-ai/execution-store-limits.mjs +14 -7
- package/runtime/js/cm-ai/execution-store.mjs +60 -17
- package/runtime/js/cm-ai/fix-code-association.mjs +73 -2
- package/runtime/js/cm-ai/host-check.mjs +14 -6
- package/runtime/js/cm-ai/host-conversation-execution.mjs +70 -28
- package/runtime/js/cm-ai/host-qa-executor.mjs +38 -5
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +19 -2
- package/runtime/js/cm-ai/host-replay.mjs +148 -0
- package/runtime/js/cm-ai/host-session.mjs +42 -9
- package/runtime/js/cm-ai/host-stage-observer.mjs +26 -0
- package/runtime/js/cm-ai/host-tool-bridge.mjs +22 -9
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +19 -2
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/implicit-qa-decision.mjs +5 -0
- package/runtime/js/cm-ai/integration-snapshots.mjs +50 -0
- package/runtime/js/cm-ai/live-evidence.mjs +28 -6
- package/runtime/js/cm-ai/operator-guidance.mjs +63 -30
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +27 -9
- package/runtime/js/cm-ai/process-group-exit.mjs +46 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +3 -2
- package/runtime/js/cm-ai/qa-attachment.mjs +22 -0
- package/runtime/js/cm-ai/qa-config-revision.mjs +7 -2
- package/runtime/js/cm-ai/requirement-evidence.mjs +102 -0
- package/runtime/js/cm-ai/review-package.mjs +79 -7
- package/runtime/js/cm-ai/review-presentation-delta.mjs +166 -0
- package/runtime/js/cm-ai/review-presentation.mjs +177 -8
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +70 -2
- package/runtime/js/cm-ai/reviewed-integration.mjs +260 -0
- package/runtime/js/cm-ai/scope-revision.mjs +38 -0
- package/runtime/js/cm-ai/specification-material.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +247 -41
- package/runtime/js/cm-ai/verification-auto.mjs +38 -0
- package/runtime/js/cm-ai/worker-claude-developer.mjs +39 -15
- package/runtime/js/cm-ai/worker-claude.mjs +35 -13
- package/runtime/js/cm-ai/worker-codex-developer.mjs +43 -17
- package/runtime/js/cm-ai/worker-codex.mjs +41 -7
- package/runtime/js/cm-fix/cause-invocation.mjs +16 -2
- package/runtime/js/cm-fix/cause-package.mjs +46 -1
- package/runtime/js/cm-fix/command-correction.mjs +37 -0
- package/runtime/js/cm-fix/cooperative.mjs +12 -0
- package/runtime/js/cm-fix/dossier.mjs +8 -2
- package/runtime/js/cm-fix/execution.mjs +578 -100
- package/runtime/js/cm-fix/final-review.mjs +39 -8
- package/runtime/js/cm-fix/finish.mjs +15 -11
- package/runtime/js/cm-fix/host-review.mjs +65 -10
- package/runtime/js/cm-fix/host.mjs +35 -12
- package/runtime/js/cm-fix/jest-command-correction.mjs +69 -0
- package/runtime/js/cm-fix/metrics.mjs +18 -5
- package/runtime/js/cm-fix/regression-evidence.mjs +3 -2
- package/runtime/js/cm-fix/regression.mjs +16 -7
- package/runtime/js/cm-fix/repair.mjs +29 -8
- package/runtime/js/cm-fix/review-verification-command.mjs +135 -0
- package/runtime/js/cm-fix/review-verification-contract.mjs +54 -0
- package/runtime/js/cm-fix/review-verification-diagnostic.mjs +75 -0
- package/runtime/js/cm-fix/review-verification-recovery.mjs +44 -0
- package/runtime/js/cm-fix/review-verification-server.mjs +38 -0
- package/runtime/js/cm-fix/review-verification.mjs +214 -0
- package/runtime/js/cm-fix/source-correction-recovery.mjs +65 -0
- package/runtime/js/cm-fix/start.mjs +6 -3
- package/runtime/js/cm-fix/test-type-correction.mjs +86 -0
- package/runtime/js/cm-fix/test-type-recovery.mjs +51 -0
- package/runtime/js/cm-fix/type-import-correction.mjs +89 -0
- package/runtime/js/cm-prd/accepted-design.mjs +8 -0
- package/runtime/js/cm-prd/analysis.mjs +13 -9
- package/runtime/js/cm-prd/change.mjs +37 -16
- package/runtime/js/cm-prd/draft-save.mjs +13 -6
- package/runtime/js/cm-prd/draft.mjs +31 -3
- package/runtime/js/cm-prd/failed-correction.mjs +19 -3
- package/runtime/js/cm-prd/inputs-replaced.mjs +3 -0
- package/runtime/js/cm-prd/review-correction.mjs +6 -4
- package/runtime/js/cm-prd/review-disposition.mjs +7 -1
- package/runtime/js/cm-prd/self-check-revision.mjs +2 -2
- package/runtime/js/cm-prd/self-check.mjs +125 -6
- package/runtime/js/cm-prd/session.mjs +30 -1
- package/runtime/js/cm-prd/summary.mjs +38 -17
- package/runtime/js/cm-prd/task-scope-record.mjs +97 -0
- package/runtime/js/cm-prd/tree-digest.mjs +34 -0
- package/runtime/js/cm-prd/validation-reason.mjs +8 -4
- package/runtime/js/cm-security/scan.mjs +1 -1
- package/runtime/js/commander/decision.mjs +44 -0
- package/runtime/js/commander/dispatch-registry.mjs +110 -0
- package/runtime/js/commander/ledger.mjs +265 -0
- package/runtime/js/commander/preflight.mjs +107 -0
- package/runtime/js/notify-later.mjs +13 -0
- package/runtime/js/notify-send.mjs +6 -2
- package/runtime/js/notify.mjs +570 -63
- package/runtime/js/review-findings.mjs +38 -0
- package/runtime/js/session-boundary.mjs +56 -0
- package/runtime/js/session-handoff.mjs +68 -0
- package/runtime/js/spec-task-line.mjs +27 -13
- package/runtime/js/specs-status.mjs +1 -1
- package/runtime/js/task-scope.mjs +197 -0
- package/runtime/logging.md +6 -1
- package/runtime/model-efficiency.md +69 -10
- package/runtime/orchestration.md +3 -1
- package/runtime/project-learning.md +2 -0
- package/runtime/review.md +12 -2
- package/runtime/test-contract.md +1 -0
- package/scripts/ci-test-weights.json +3 -0
- package/scripts/cm-ai-admission.mjs +11 -5
- package/scripts/cm-ai-admission.test.mjs +23 -2
- package/scripts/cm-ai-batch-drive.mjs +79 -18
- package/scripts/cm-ai-batch-drive.test.mjs +169 -3
- package/scripts/cm-ai-batch-host.mjs +38 -9
- package/scripts/cm-ai-batch-host.test.mjs +27 -14
- package/scripts/cm-ai-batch-learning-merge.test.mjs +36 -0
- package/scripts/cm-ai-batch-location.test.mjs +57 -0
- package/scripts/cm-ai-batch-plan.mjs +52 -0
- package/scripts/cm-ai-batch-plan.test.mjs +397 -0
- package/scripts/cm-ai-batch-run-fixture.mjs +446 -35
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +16 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +28 -1
- package/scripts/cm-ai-batch-run.mjs +483 -63
- package/scripts/cm-ai-batch-run.test.mjs +23 -4
- package/scripts/cm-ai-batch-session-e2e.test.mjs +235 -0
- package/scripts/cm-ai-batch-session-member.test.mjs +293 -0
- package/scripts/cm-ai-batch-session-recovery.test.mjs +423 -0
- package/scripts/cm-ai-check-recheck-cancellation.test.mjs +247 -0
- package/scripts/cm-ai-checklist-coverage.test.mjs +4 -2
- package/scripts/cm-ai-checkpoint-package-material.test.mjs +221 -0
- package/scripts/cm-ai-checkpoint-package-owner.test.mjs +193 -0
- package/scripts/cm-ai-control-launch.test.mjs +21 -0
- package/scripts/cm-ai-control-policy.test.mjs +82 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +398 -3
- package/scripts/cm-ai-control-v2-supersede-race.mjs +25 -0
- package/scripts/cm-ai-control-v2-supersede.test.mjs +318 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +163 -0
- package/scripts/cm-ai-development-rework.test.mjs +423 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +3 -2
- package/scripts/cm-ai-drive.mjs +73 -17
- package/scripts/cm-ai-drive.test.mjs +37 -5
- package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
- package/scripts/cm-ai-host-fixture.mjs +9 -6
- package/scripts/cm-ai-host-protected.test.mjs +1 -1
- package/scripts/cm-ai-host.mjs +60 -19
- package/scripts/cm-ai-host.test.mjs +15 -0
- package/scripts/cm-ai-integration-adoption.test.mjs +223 -0
- package/scripts/cm-ai-integration-independence.test.mjs +23 -0
- package/scripts/cm-ai-integration-launch.test.mjs +240 -0
- package/scripts/cm-ai-integration-preview.mjs +41 -0
- package/scripts/cm-ai-integration-snapshots.test.mjs +197 -0
- package/scripts/cm-ai-nested-execution.test.mjs +29 -1
- package/scripts/cm-ai-operator-guidance.test.mjs +71 -0
- package/scripts/cm-ai-prefinal-delivery.test.mjs +278 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +56 -0
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +28 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +36 -2
- package/scripts/cm-ai-requirement-evidence.test.mjs +65 -0
- package/scripts/cm-ai-review-failure.test.mjs +150 -5
- package/scripts/cm-ai-review-timeout.test.mjs +20 -0
- package/scripts/cm-ai-run.mjs +88 -21
- package/scripts/cm-ai-scope-revision.test.mjs +341 -0
- package/scripts/cm-ai-spec-rebind.test.mjs +13 -0
- package/scripts/cm-ai-supersede.test.mjs +28 -0
- package/scripts/cm-ai-verification-auto.test.mjs +99 -0
- package/scripts/cm-announce-hook.mjs +35 -8
- package/scripts/cm-announce-hook.test.mjs +25 -0
- package/scripts/cm-challenge.test.mjs +61 -0
- package/scripts/cm-check-drive-files.mjs +2 -2
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +58 -1
- package/scripts/cm-claude-developer-worker.test.mjs +56 -7
- package/scripts/cm-claude-install-layout.test.mjs +1 -1
- package/scripts/cm-claude-probe.test.mjs +26 -0
- package/scripts/cm-claude-review-diagnostics.test.mjs +235 -0
- package/scripts/cm-claude-review-stream.test.mjs +49 -0
- package/scripts/cm-claude-worker.test.mjs +16 -0
- package/scripts/cm-codex-developer-reconnect-notice.test.mjs +98 -0
- package/scripts/cm-codex-developer-worker.test.mjs +120 -0
- package/scripts/cm-codex-install-local-edit-guard.test.mjs +436 -0
- package/scripts/cm-codex-prompt-input.test.mjs +153 -0
- package/scripts/cm-codex-reconnect-notice.test.mjs +167 -0
- package/scripts/cm-commander-ledger.test.mjs +260 -0
- package/scripts/cm-commander-p2.test.mjs +295 -0
- package/scripts/cm-commander-preflight.mjs +84 -0
- package/scripts/cm-commander.mjs +116 -0
- package/scripts/cm-config-lock.mjs +35 -0
- package/scripts/cm-controlled-correction.test.mjs +10 -1
- package/scripts/cm-developer-failure-code.test.mjs +62 -0
- package/scripts/cm-display-task-id.test.mjs +41 -0
- package/scripts/cm-drive-liveness.test.mjs +83 -0
- package/scripts/cm-efficiency-presentation-delta.test.mjs +218 -0
- package/scripts/cm-execution-snapshot-reuse.test.mjs +115 -0
- package/scripts/cm-external-batch-host.test.mjs +12 -9
- package/scripts/cm-external-process-cleanup.test.mjs +128 -0
- package/scripts/cm-external-qa-fix.test.mjs +89 -7
- package/scripts/cm-external-review-reconciliation.test.mjs +11 -0
- package/scripts/cm-failover.mjs +48 -10
- package/scripts/cm-failover.test.mjs +46 -0
- package/scripts/cm-fix-cause-invocation.test.mjs +19 -4
- package/scripts/cm-fix-command-correction.mjs +17 -0
- package/scripts/cm-fix-command-correction.test.mjs +211 -0
- package/scripts/cm-fix-cooperative-closeout.test.mjs +87 -0
- package/scripts/cm-fix-diagnosis-module-correction.test.mjs +217 -0
- package/scripts/cm-fix-drive.mjs +33 -5
- package/scripts/cm-fix-drive.test.mjs +49 -0
- package/scripts/cm-fix-host-review-assembly.test.mjs +197 -1
- package/scripts/cm-fix-host-review.test.mjs +21 -9
- package/scripts/cm-fix-host.mjs +26 -8
- package/scripts/cm-fix-monorepo-map.test.mjs +92 -0
- package/scripts/cm-fix-observation-task-id.test.mjs +122 -0
- package/scripts/cm-fix-regression-input-budget.test.mjs +111 -0
- package/scripts/cm-fix-repair-input-budget.test.mjs +119 -0
- package/scripts/cm-fix-review-file-paging.test.mjs +91 -0
- package/scripts/cm-fix-review-preflight.mjs +24 -0
- package/scripts/cm-fix-review-storage.test.mjs +233 -0
- package/scripts/cm-fix-review-verification-command.test.mjs +242 -0
- package/scripts/cm-fix-review-verification-evidence.test.mjs +218 -0
- package/scripts/cm-fix-review-verification-integration.test.mjs +81 -0
- package/scripts/cm-fix-review-verification-recovery.test.mjs +198 -0
- package/scripts/cm-fix-review-verification.test.mjs +146 -0
- package/scripts/cm-fix-revision-transport.test.mjs +81 -0
- package/scripts/cm-fix-source-correction.test.mjs +296 -0
- package/scripts/cm-fix-test-type-correction.mjs +18 -0
- package/scripts/cm-fix-test-type-correction.test.mjs +123 -0
- package/scripts/cm-fix-test-type-owner.test.mjs +208 -0
- package/scripts/cm-fix-test-type-verification-cost.test.mjs +66 -0
- package/scripts/cm-fix-type-import-correction.test.mjs +95 -0
- package/scripts/cm-fix-verification-diagnostic.test.mjs +200 -0
- package/scripts/cm-fix-verification-recovery.mjs +33 -0
- package/scripts/cm-host-diagnostic.test.mjs +33 -0
- package/scripts/cm-host-liveness.test.mjs +150 -0
- package/scripts/cm-host-qa-executor.test.mjs +77 -0
- package/scripts/cm-host-replay.test.mjs +176 -0
- package/scripts/cm-host-stage-observer.test.mjs +41 -0
- package/scripts/cm-install-local-edit-guard.test.mjs +621 -0
- package/scripts/cm-install-manifest.sh +351 -0
- package/scripts/cm-live-evidence.test.mjs +59 -1
- package/scripts/cm-log-event.mjs +61 -10
- package/scripts/cm-log-event.test.mjs +121 -1
- package/scripts/cm-matt-skills.mjs +576 -0
- package/scripts/cm-matt-skills.test.mjs +550 -0
- package/scripts/cm-notify-command.test.mjs +42 -10
- package/scripts/cm-notify.mjs +14 -10
- package/scripts/cm-notify.test.mjs +625 -75
- package/scripts/cm-patrol.mjs +4 -1
- package/scripts/cm-patrol.test.mjs +23 -5
- package/scripts/cm-prd-answer-gaps.test.mjs +2 -2
- package/scripts/cm-prd-completion.test.mjs +56 -13
- package/scripts/cm-prd-design-phase.test.mjs +78 -8
- package/scripts/cm-prd-draft-save.test.mjs +12 -0
- package/scripts/cm-prd-draft.test.mjs +1 -1
- package/scripts/cm-prd-drive.mjs +13 -6
- package/scripts/cm-prd-drive.test.mjs +46 -2
- package/scripts/cm-prd-gate-diagnostic.test.mjs +2 -2
- package/scripts/cm-prd-host.mjs +10 -5
- package/scripts/cm-prd-host.test.mjs +4 -2
- package/scripts/cm-prd-inputs-replaced.test.mjs +1 -1
- package/scripts/cm-prd-review-disposition.test.mjs +124 -8
- package/scripts/cm-prd-revision.test.mjs +1 -1
- package/scripts/cm-prd-self-check-revision.test.mjs +16 -1
- package/scripts/cm-prd-self-check-rules.test.mjs +239 -0
- package/scripts/cm-prd-self-check.test.mjs +105 -5
- package/scripts/cm-prd-session-recovery.test.mjs +5 -3
- package/scripts/cm-prd-summary.test.mjs +55 -3
- package/scripts/cm-prd-task-grouping.test.mjs +6 -6
- package/scripts/cm-prd-tree-digest.test.mjs +74 -0
- package/scripts/cm-refactor-drive.mjs +2 -1
- package/scripts/cm-refactor-drive.test.mjs +9 -0
- package/scripts/cm-release-smoke.sh +3 -15
- package/scripts/cm-skill-hints-autowire.test.mjs +394 -0
- package/scripts/cm-skill-hints-exam.mjs +149 -0
- package/scripts/cm-skill-hints-install.test.mjs +168 -0
- package/scripts/cm-skill-hints.exam.json +706 -0
- package/scripts/cm-skill-hints.json +119 -0
- package/scripts/cm-skill-hints.mjs +669 -0
- package/scripts/cm-skill-hints.test.mjs +831 -0
- package/scripts/cm-skill-judge.mjs +181 -0
- package/scripts/cm-skill-judge.test.mjs +255 -0
- package/scripts/cm-specs-status.test.mjs +4 -2
- package/scripts/cm-start-check.mjs +208 -0
- package/scripts/cm-start-check.test.mjs +321 -0
- package/scripts/cm-task-gate.mjs +150 -29
- package/scripts/cm-task-gate.test.mjs +73 -1
- package/scripts/cm-task-id-grammar.test.mjs +66 -0
- package/scripts/cm-task-scope.test.mjs +308 -0
- package/scripts/cm-test-suite.mjs +109 -0
- package/scripts/cm-test-suite.test.mjs +162 -0
- package/scripts/cm-upgrade-compat-batch.test.mjs +172 -0
- package/scripts/cm-upgrade-compat.test.mjs +239 -0
- package/scripts/cm-workflow-config.mjs +12 -2
- package/scripts/fixtures/fix-verification-claude.mjs +44 -0
- package/scripts/fixtures/host-diagnostic.mjs +33 -0
- package/scripts/fixtures/reviewed-integration.mjs +202 -0
- package/scripts/scan-public-safety.py +1 -0
- package/scripts/session-boundary.test.mjs +170 -0
- package/scripts/test-npm-install.py +14 -3
- package/scripts/test-shell-compat.sh +2 -0
- package/scripts/validate-public-repo.py +1 -0
- package/scripts/validate-test-cases.mjs +3 -2
- package/skills/cm-ai/SKILL.md +5 -2
- package/skills/cm-ai/references/N4-review.md +2 -1
- package/skills/cm-ai/references/N6-qa-eval.md +3 -1
- package/skills/cm-ai/references/N8-finish.md +22 -0
- package/skills/cm-ai/references/js-host-qa-recovery.md +1 -1
- package/skills/cm-ai/references/js-host-recovery.md +79 -3
- package/skills/cm-ai/references/js-host.md +89 -17
- package/skills/cm-challenge/SKILL.md +65 -0
- package/skills/cm-challenge/evals/README.md +18 -0
- package/skills/cm-challenge/evals/trigger-cases.json +20 -0
- package/skills/cm-challenge/evals/trigger-config.json +28 -0
- package/skills/cm-challenge/references/examples.md +15 -0
- package/skills/cm-check/SKILL.md +5 -0
- package/skills/cm-check/references/js-host.md +2 -0
- package/skills/cm-fix/SKILL.md +12 -3
- package/skills/cm-fix/references/command-correction.md +67 -0
- package/skills/cm-fix/references/isolated-review.md +54 -0
- package/skills/cm-fix/references/js-host.md +62 -2
- package/skills/cm-fix/references/test-type-correction.md +72 -0
- package/skills/cm-fix/references/verification-recovery.md +114 -0
- package/skills/cm-idea/SKILL.md +2 -0
- package/skills/cm-idea/references/js-host.md +2 -0
- package/skills/cm-notify/SKILL.md +2 -0
- package/skills/cm-prd/SKILL.md +12 -8
- package/skills/cm-prd/references/brownfield.md +8 -1
- package/skills/cm-prd/references/change-mode.md +6 -0
- package/skills/cm-prd/references/greenfield.md +4 -0
- package/skills/cm-prd/references/js-host.md +4 -2
- package/skills/cm-prd/references/spec-self-check.md +5 -1
- package/skills/cm-refactor/SKILL.md +8 -0
- package/skills/cm-refactor/references/js-host.md +2 -0
- package/skills/cm-test/SKILL.md +4 -0
- package/templates/dashboard/dashboard.html +2 -2
- package/templates/pixel/cm-pixel.html +1 -1
- package/templates/pixel/cm-pixel.sh +1 -1
- package/templates/pixel/dev/template.html +1 -1
- package/templates/statusline/cm-statusline.sh +1 -1
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {packageMaterialEligible,checkpointStoragePlan,checkpointPackageBudget,packageMaterialReference} from './checkpoint-package-material.mjs';
|
|
2
|
+
import {taskDeclarations,approvedTaskGrammar} from '../spec-task-line.mjs';
|
|
3
|
+
import {readIntegrationEvidenceFile,validateIntegrationRecord,verifyReviewedIntegration} from './reviewed-integration.mjs';
|
|
4
|
+
import {beginHostStage} from './host-stage-observer.mjs';
|
|
1
5
|
import {readExecutionPolicy} from './execution-policy.mjs';
|
|
2
6
|
import {readExternalModels} from './external-models.mjs';
|
|
3
7
|
import {beforeFirstQaRound,readQaConfigRevision} from './qa-config-revision.mjs';
|
|
@@ -11,16 +15,16 @@ import path from 'node:path';
|
|
|
11
15
|
import {createRequire} from 'node:module';
|
|
12
16
|
import {verifySpecificationMaterial,boundSpecificationMaterial,inspectSpecificationDrift,describeSpecificationDrift,
|
|
13
17
|
readSpecificationRebind} from './specification-material.mjs';
|
|
14
|
-
import { captureReviewBaseline, captureReviewInventory, compareReviewBaseline, createReviewPackage, verifyReviewPackage, verifyCompletionReviewPackage, validChecks, readReviewSourceFiles } from './review-package.mjs';
|
|
18
|
+
import { captureReviewBaseline, captureScopeRevisionSources, captureReviewInventory, compareReviewBaseline, createReviewPackage, verifyReviewPackage, verifyCompletionReviewPackage, validChecks, readReviewSourceFiles } from './review-package.mjs';
|
|
15
19
|
import { digest,need,shape,id,text,json,freeze,arrayItems,validIdentity,validTaskLearningInput,validCallTimeout,requestFor,terminalFor,failureCode,
|
|
16
20
|
JOURNAL_PAYLOAD_LIMIT,developCheckpointReserve,taskReviewScope,boundedReason } from './effect-contract.mjs';
|
|
17
21
|
import { reviewResult,reviewReceipt,boundReviewText,reviewPaths } from './review-runner.mjs';
|
|
18
22
|
import { checkCompletion } from './gate-bridge.mjs';
|
|
19
23
|
import { runnerPayload,runnerPayloadV3,readRunnerHistory,attemptBaseline,boundRunnerRecord,
|
|
20
24
|
MAX_AI_JOINED_HOSTS,controlledState,stageAllowed,effectSlotFree,reviewTimeoutTransition,validateTaskLearningReviewPackage,
|
|
21
|
-
reviewRetrySpent,abandonableReviewResult,developBudget,developBudgetExhausted,
|
|
25
|
+
reviewRetrySpent,abandonableReviewResult,developBudget,developBudgetExhausted,verificationBlockCount,developmentReworkBinding,applyDevelopmentRework,
|
|
22
26
|
MAX_REVIEW_REDISPATCHES,REVIEW_RETRY_CODES,reviewRedispatchCount,reviewRedispatchable,reviewRedispatchExhausted,REVIEW_REDISPATCH_LIMIT_CODE,reviewRedispatchLimitReason,reviewRedispatchStopReason,reviewAbandonRefusal,
|
|
23
|
-
completionBlockCount,completionRetriesExhausted,supersededReviewPayload,bootstrapReviewRecoverable,protectedDevelopScope,protectedScopeBlockReason,
|
|
27
|
+
completionBlockCount,completionRetriesExhausted,completionReworkBinding,applyCompletionRework,supersededReviewPayload,bootstrapReviewRecoverable,protectedDevelopScope,protectedScopeBlockReason,
|
|
24
28
|
developTimeoutBasis,developTimeoutEffect,developTimeoutState,DEVELOP_CALL_TIMEOUT_REASON,
|
|
25
29
|
developAnswerInvalidEffect,developAnswerRetryable,developAnswerInvalidReason,
|
|
26
30
|
RECHECK_CODES,COMPLETE_RECHECK_CODE,developRecheckSource,developRecheckCode,developRecheckReason,
|
|
@@ -31,6 +35,9 @@ import { runnerPayload,runnerPayloadV3,readRunnerHistory,attemptBaseline,boundRu
|
|
|
31
35
|
DOCUMENTATION_SYNC_CODES,documentationSyncSource,documentationSyncRetryCode,documentationSyncStopReason } from './durable-runner-state.mjs';
|
|
32
36
|
import {splitDocumentationState} from './host-documentation.mjs';
|
|
33
37
|
import {readControlPolicy} from './control-policy.mjs';
|
|
38
|
+
import {encodeRequirementEvidence} from './requirement-evidence.mjs';
|
|
39
|
+
import {encodeHostReplayEvidence} from './host-replay.mjs';
|
|
40
|
+
import {scopeRevisionBinding,revisedScope,applyScopeRevision} from './scope-revision.mjs';
|
|
34
41
|
import {readProcessStartTime,inspectWorkerGroup} from './worker-process-identity.mjs';
|
|
35
42
|
import {recoverRunnerCommitImage} from './task-commit.mjs';
|
|
36
43
|
import {commitRunnerFixture} from './task-commit.mjs';
|
|
@@ -41,7 +48,7 @@ import {readCmAiProjectLearningWriteback,writeCmAiProjectLearning} from './cm-ai
|
|
|
41
48
|
import {verifyCmAiTaskLearningHandoff,writeCmAiTaskLearningHandoff} from './cm-ai-learning-handoff-writer.mjs';
|
|
42
49
|
import {implementationSha256,loadHandoff} from '../../../scripts/cm-task-gate.mjs';
|
|
43
50
|
import {createHostHandoff} from './host-handoff.mjs';
|
|
44
|
-
import {inspectFixCodeAssociation,explainCompletedDelivery} from './fix-code-association.mjs';
|
|
51
|
+
import {inspectFixCodeAssociation,explainCompletedDelivery,firstReviewAt} from './fix-code-association.mjs';
|
|
45
52
|
import {approvedReviewAt,completedReviewedDeliveries,fixReviewedAt,resolveDeliverySteps} from './reviewed-deliveries.mjs';
|
|
46
53
|
import {validateAcceptedFix} from './accepted-fix.mjs';
|
|
47
54
|
import {appendFits} from './execution-store-limits.mjs';
|
|
@@ -157,6 +164,7 @@ export function createTaskRunner(options) {
|
|
|
157
164
|
if(options && Object.hasOwn(options,'executionPolicy'))optionKeys.push('executionPolicy');
|
|
158
165
|
if(options && Object.hasOwn(options,'externalModels'))optionKeys.push('externalModels');
|
|
159
166
|
if(options && Object.hasOwn(options,'controlPolicy'))optionKeys.push('controlPolicy');
|
|
167
|
+
if(options && Object.hasOwn(options,'parallelSelection'))optionKeys.push('parallelSelection');
|
|
160
168
|
if(invocationMode)optionKeys.push('reviewInvocation');
|
|
161
169
|
shape(options,optionKeys);
|
|
162
170
|
need(options.providerDevelopment===undefined||typeof options.providerDevelopment==='boolean','invalid_input');
|
|
@@ -168,6 +176,8 @@ export function createTaskRunner(options) {
|
|
|
168
176
|
// Opt-in gate between the task's own checks and the independent review. It may
|
|
169
177
|
// only block: passing it grants nothing and never substitutes for that review.
|
|
170
178
|
const verificationGate=options.verificationGate??null;
|
|
179
|
+
// The latest satisfied gate's handoff entry; reset on every gate run.
|
|
180
|
+
let requirementEvidence=null,hostReplayEvidence=null;
|
|
171
181
|
need(verificationGate===null||typeof verificationGate==='function');
|
|
172
182
|
if(taskMode)need(Object.hasOwn(options,'persistence'),'runner_completion');
|
|
173
183
|
const config=json({root:options.root,identity:options.identity,scope:options.scope,requirements:options.requirements,
|
|
@@ -220,7 +230,10 @@ export function createTaskRunner(options) {
|
|
|
220
230
|
...(Object.hasOwn(options,'knowledgeCloseout')?{knowledgeCloseout:readCloseoutPolicy(options.knowledgeCloseout)}:{}),
|
|
221
231
|
...(Object.hasOwn(options,'executionPolicy')?{executionPolicy:readExecutionPolicy(options.executionPolicy)}:{}),
|
|
222
232
|
...(Object.hasOwn(options,'externalModels')?{externalModels:readExternalModels(options.externalModels)}:{}),
|
|
223
|
-
...(Object.hasOwn(options,'controlPolicy')?{controlPolicy:readControlPolicy(options.controlPolicy)}:{})
|
|
233
|
+
...(Object.hasOwn(options,'controlPolicy')?{controlPolicy:readControlPolicy(options.controlPolicy)}:{}),
|
|
234
|
+
...(Object.hasOwn(options,'parallelSelection')&&
|
|
235
|
+
(options.persistence?.mode==='create'||options.persistence?.store?.snapshot().records[0]?.payload.config.parallelSelection)
|
|
236
|
+
?{parallelSelection:json(options.parallelSelection)}:{})});
|
|
224
237
|
const taskLearning=metadata.taskLearning??null;
|
|
225
238
|
if(taskLearning!==null){need(taskMode,'runner_learning');
|
|
226
239
|
shape(taskLearning,['feature',...(Object.hasOwn(taskLearning,'hostHandoff')?['hostHandoff']:[])]);
|
|
@@ -271,10 +284,14 @@ export function createTaskRunner(options) {
|
|
|
271
284
|
need(completion&&specificationSelection.specsRoot===completion.owner.specsRoot
|
|
272
285
|
&&specificationSelection.feature===taskLearning?.feature,'spec_drift');
|
|
273
286
|
}
|
|
274
|
-
|
|
287
|
+
let effectiveScope=restored?.effectiveScope??config.scope;
|
|
288
|
+
let scopeRevisionPaths=restored?.original.scopeRevisionPaths??null;
|
|
289
|
+
const effectiveMetadata=()=>({...metadata,scope:effectiveScope,...(scopeRevisionPaths?{scopeRevisionPaths}: {})});
|
|
290
|
+
const baselineOptions=()=>({...configToBaseline(effectiveMetadata()),
|
|
275
291
|
...(specificationSelection===null?{}:{specification:specificationSelection})});
|
|
276
|
-
|
|
277
|
-
|
|
292
|
+
let original=restored?.original??captureReviewBaseline(baselineOptions());
|
|
293
|
+
let controller=new AbortController();
|
|
294
|
+
const calls=[],cache=new Map(),session=restored?.session??randomUUID(),registered=new Map(),receipts=[];
|
|
278
295
|
let state=reviewers.some(r=>r.allowed&&r.available)?'ready':'pending_review',code=null,attempt=1;
|
|
279
296
|
let busy=false,pending=null,sequence=0,base=original,reviewPackage=null,currentChecks=null,workflowRunning=false;
|
|
280
297
|
let reason=null,checkNewPaths=null;
|
|
@@ -283,6 +300,7 @@ export function createTaskRunner(options) {
|
|
|
283
300
|
// Journaled supersession context: shown, never counted as a review verdict.
|
|
284
301
|
let carriedReview=restored?.supersession?.carriedReview??null;
|
|
285
302
|
const acceptedFixes=structuredClone(restored?.acceptedFixes??[]);
|
|
303
|
+
let acceptedIntegration=restored?.acceptedIntegration??null;
|
|
286
304
|
let qaAttachment=restored?.qaAttachment??null;
|
|
287
305
|
// A fresh ready-state capture carries the current material; represent an
|
|
288
306
|
// accepted (identical or explicitly rebound) one by the bound material.
|
|
@@ -304,11 +322,7 @@ export function createTaskRunner(options) {
|
|
|
304
322
|
// so the next corrected delivery needs a new effect id or it would just read
|
|
305
323
|
// the blocked result back out of the cache. Counting them here keeps that
|
|
306
324
|
// derivation in one place, next to the cache it is derived from.
|
|
307
|
-
const verificationBlocks=()=>[...cache.values()]
|
|
308
|
-
&&entry.result?.state==='blocked'
|
|
309
|
-
&&['verification_precheck_failed','check_output_out_of_scope','develop_checks_not_passed','develop_unchanged_after_review','develop_empty_changes','develop_requirement_missing','develop_package_too_large','bootstrap_verification_failed','bootstrap_instruction_conflict','develop_call_timeout'].includes(entry.result?.code)
|
|
310
|
-
||developTimeoutEffect(entry)||developAnswerInvalidEffect(entry)||developRecheckSource(entry)||developRedoSource(entry)||developDispatchFailedEffect(entry)
|
|
311
|
-
||documentationSyncSource(entry)).length;
|
|
325
|
+
const verificationBlocks=()=>verificationBlockCount([...cache.values()],parsedHistory?.developRecheckEffects);
|
|
312
326
|
const completionBlocks=()=>[...cache.values()].filter(entry=>entry.effect.kind==='complete'
|
|
313
327
|
&&entry.result?.state==='blocked'&&['completion_checks_changed','completion_package_changed'].includes(entry.result?.code)
|
|
314
328
|
||completeRecheckSource(entry)).length;
|
|
@@ -390,7 +404,7 @@ export function createTaskRunner(options) {
|
|
|
390
404
|
const answerGapCount=type=>journal?.filter(row=>row.payload.type===type).length??0;
|
|
391
405
|
const gapsLive=()=>Boolean(store&&taskMode&&invocationMode&&!busy&&!poisoned&&!(restored?.pending&&!cache.has(restored.pending.id)));
|
|
392
406
|
const developRecheck=()=>gapsLive()?developRecheckCode({state,code,attempt,cache:[...cache.values()],learningResult,receipt},
|
|
393
|
-
metadata,answerGapCount('develop-recheck')):null;
|
|
407
|
+
metadata,answerGapCount('develop-recheck'),parsedHistory?.developRecheckRecovery):null;
|
|
394
408
|
const completeRecheck=()=>gapsLive()&&completeRecheckable({state,code,attempt,cache:[...cache.values()],taskCommit},
|
|
395
409
|
answerGapCount('complete-recheck'));
|
|
396
410
|
// V2 + R3: a stuck current-session develop that only an operator confirmation
|
|
@@ -444,7 +458,7 @@ export function createTaskRunner(options) {
|
|
|
444
458
|
// scope and the ignore policy bound at create, as the task baseline), split
|
|
445
459
|
// at the documentation paths. The adapter takes its start and end with it too.
|
|
446
460
|
function documentationSnapshot(paths){
|
|
447
|
-
const baseline=captureReviewBaseline({...configToBaseline(
|
|
461
|
+
const baseline=captureReviewBaseline({...configToBaseline(effectiveMetadata()),version:original.version,
|
|
448
462
|
...(Object.hasOwn(original,'specification')?{specification:{specsRoot:original.specificationRoot,feature:original.specification.feature}}:{})},
|
|
449
463
|
!Object.hasOwn(original,'ignorePolicy'),original.ignorePolicy?.version??2,
|
|
450
464
|
original.ignorePolicy?.version===2?original.ignorePolicy:null);
|
|
@@ -551,6 +565,7 @@ export function createTaskRunner(options) {
|
|
|
551
565
|
};
|
|
552
566
|
const status=()=>{
|
|
553
567
|
let current=store?publication:privateStatus();
|
|
568
|
+
if(parsedHistory?.scopeRevisions)current=freeze({...current,effectiveScope});
|
|
554
569
|
if(current.state==='unknown'&&commitRecoveryTransaction()!==null){
|
|
555
570
|
const {reason:discard,...rest}=current;
|
|
556
571
|
current=freeze({...rest,state:'blocked',code:COMMIT_INTERRUPTED_CODE,reason:COMMIT_INTERRUPTED_REASON});
|
|
@@ -595,7 +610,7 @@ export function createTaskRunner(options) {
|
|
|
595
610
|
if((current.state==='unknown'||current.state==='blocked'&&['failed','unavailable'].includes(current.code))&&gapsLive()
|
|
596
611
|
&&(options.providerDevelopment!==true||providerRun)){
|
|
597
612
|
const limit=answerGapLimit({state,code,attempt,cache:[...cache.values()],calls,receipt,learningResult,taskCommit,reviewPackage,priorReview},
|
|
598
|
-
metadata,{developRecheck:answerGapCount('develop-recheck'),completeRecheck:answerGapCount('complete-recheck'),
|
|
613
|
+
metadata,{developRecheck:answerGapCount('develop-recheck'),developRecheckRecovery:parsedHistory?.developRecheckRecovery,completeRecheck:answerGapCount('complete-recheck'),
|
|
599
614
|
developRedo:answerGapCount('develop-answer-redo'),developDispatch:answerGapCount('develop-dispatch-retry'),
|
|
600
615
|
documentationSync:documentationRetries(),
|
|
601
616
|
workers:parsedHistory?.workers??null});
|
|
@@ -659,6 +674,10 @@ export function createTaskRunner(options) {
|
|
|
659
674
|
}
|
|
660
675
|
if(current.state!=='fixture_completed')return current;
|
|
661
676
|
try {
|
|
677
|
+
if(acceptedIntegration){
|
|
678
|
+
inspectAcceptedIntegration(acceptedIntegration);
|
|
679
|
+
return freeze({...current,acceptedIntegrationDigest:acceptedIntegration.planDigest});
|
|
680
|
+
}
|
|
662
681
|
if(acceptedFixes.length){
|
|
663
682
|
for(const item of acceptedFixes){
|
|
664
683
|
const {handoffDigest,...binding}=item.evidence.qaSource;
|
|
@@ -682,7 +701,8 @@ export function createTaskRunner(options) {
|
|
|
682
701
|
const handoff=handoffBinding().handoffPath;
|
|
683
702
|
need(digest(readReviewSourceFiles(path.dirname(handoff),[path.basename(handoff)])[0])===digest(reviewPackage.handoff),'package_mismatch');
|
|
684
703
|
}
|
|
685
|
-
explainCompletedDelivery({root:config.root,baseline:base,parentPackage:reviewPackage,deliveries:laterDeliveries(),after:reviewedAt()
|
|
704
|
+
explainCompletedDelivery({root:config.root,baseline:base,parentPackage:reviewPackage,deliveries:laterDeliveries(),after:reviewedAt(),
|
|
705
|
+
since:firstReviewAt(journal,config.identity)});
|
|
686
706
|
}
|
|
687
707
|
return current;
|
|
688
708
|
} catch(error){
|
|
@@ -693,7 +713,7 @@ export function createTaskRunner(options) {
|
|
|
693
713
|
};
|
|
694
714
|
const halt=(next,why,detail=null)=>{state=next;code=why;reason=detail;};
|
|
695
715
|
function assertReadyBaseline(){
|
|
696
|
-
compareReviewBaseline(withBoundSpecification(captureReviewBaseline({...configToBaseline(
|
|
716
|
+
compareReviewBaseline(withBoundSpecification(captureReviewBaseline({...configToBaseline(effectiveMetadata()),version:original.version,
|
|
697
717
|
...(Object.hasOwn(original,'specification')?{specification:{specsRoot:original.specificationRoot,feature:original.specification.feature}}:{})},
|
|
698
718
|
!Object.hasOwn(original,'ignorePolicy'),original.ignorePolicy?.version??2,
|
|
699
719
|
original.ignorePolicy?.version===2?original.ignorePolicy:null)),original);
|
|
@@ -716,15 +736,29 @@ export function createTaskRunner(options) {
|
|
|
716
736
|
same(current.identity,storeIdentity,'identity_mismatch');same(current.fingerprints,completion.fingerprints,'identity_mismatch');
|
|
717
737
|
need(current.revision===storeRevision,'runner_store_changed');need(!poisoned,'store_failure');return current;
|
|
718
738
|
}
|
|
739
|
+
const packageMaterialEnabled=()=>packageMaterialEligible(metadata,version);
|
|
740
|
+
function checkpointReserve(checkpoint){
|
|
741
|
+
if(!checkpoint.reviewPackage)return 0;
|
|
742
|
+
const size=value=>Buffer.byteLength(JSON.stringify(value??null));
|
|
743
|
+
return developCheckpointReserve({examinedPathsBytes:size(reviewPaths(checkpoint.reviewPackage)),
|
|
744
|
+
receiptsBytes:size(checkpoint.receipts),callsBytes:size(checkpoint.calls),writebackBytes:size(checkpoint.learningResult?.writeback)});
|
|
745
|
+
}
|
|
719
746
|
function candidate(type,fields){
|
|
747
|
+
if(['effect-checkpoint','review-invocation-reconciled'].includes(type)&&packageMaterialEnabled()){
|
|
748
|
+
const plan=checkpointStoragePlan({records:journal,effectId:fields.effectId,checkpoint:fields.checkpoint,
|
|
749
|
+
identity:{...config.identity,attempt:fields.checkpoint.attempt},enabled:packageMaterialEnabled(),
|
|
750
|
+
reserve:checkpointReserve(fields.checkpoint),type,
|
|
751
|
+
binding:type==='effect-checkpoint'?{}:Object.fromEntries(['invocationId','registeredDigest','startedDigest','resultDigest','receiptDigest'].map(key=>[key,fields[key]]))});
|
|
752
|
+
fields={...fields,checkpoint:plan.checkpoint,...plan.payloadFields};
|
|
753
|
+
}
|
|
720
754
|
const basic={id:`runner.${String(journal.length+1).padStart(6,'0')}`,
|
|
721
755
|
kind:{init:'result','effect-intent':'intent','effect-checkpoint':'result',control:'cancel',
|
|
722
756
|
'task-commit-intent':'commit-intent','task-commit-result':'commit-result',
|
|
723
757
|
'review-invocation-registered':'intent','review-invocation-started':'result','review-invocation-result':'result',
|
|
724
758
|
'review-invocation-abandoned':'result','review-invocation-receipt':'result','review-invocation-reconciled':'result','effect-abandoned':'result',
|
|
725
|
-
'host-joined':'result','qa-fix-accepted':'result','qa-attached':'result','qa-config-revised':'result',
|
|
759
|
+
'host-joined':'result','qa-fix-accepted':'result','reviewed-integration-accepted':'result','qa-attached':'result','qa-config-revised':'result',
|
|
726
760
|
'evidence-superseded':'result','develop-retry-limit':'result','develop-worker':'result','effect-interrupted':'result','develop-timeout-retry':'result','develop-answer-retry':'result','develop-recheck':'result','complete-recheck':'result','develop-answer-redo':'result','develop-dispatch-retry':'result','review-redispatch':'result','review-dispatch-confirmed':'result','completion-retry-limit':'result','specification-rebound':'result','documentation-sync-started':'result','documentation-sync-retry':'result',
|
|
727
|
-
'bootstrap-review-recovered':'result'}[type],
|
|
761
|
+
'completion-rework-requested':'result','development-rework-authorized':'result','scope-revised':'result','bootstrap-review-recovered':'result'}[type],
|
|
728
762
|
payload:version===3?runnerPayloadV3(type,fields):runnerPayload(type,fields,version)};
|
|
729
763
|
const body={version:1,seq:journal.length+1,...basic,previousDigest:journal.at(-1)?.digest??null};
|
|
730
764
|
const record={...body,digest:digest(body)};boundRunnerRecord(record,body.seq);
|
|
@@ -840,6 +874,7 @@ export function createTaskRunner(options) {
|
|
|
840
874
|
function active(){need(!poisoned,'store_failure');need(state!=='cancelled','cancelled');}
|
|
841
875
|
async function bounded(fn,request,extraControl=null) {
|
|
842
876
|
active();let timer,abort;
|
|
877
|
+
const endStage=beginHostStage(request?.role==='developer'?'develop':request?.role==='reviewer'?'review':'check',config.timeoutMs);
|
|
843
878
|
try {
|
|
844
879
|
const boxed=await Promise.race([
|
|
845
880
|
new Promise((resolve,reject)=>{
|
|
@@ -865,7 +900,7 @@ export function createTaskRunner(options) {
|
|
|
865
900
|
})
|
|
866
901
|
]);
|
|
867
902
|
return boxed.value;
|
|
868
|
-
} finally {clearTimeout(timer);controller.signal.removeEventListener('abort',abort);}
|
|
903
|
+
} finally {endStage();clearTimeout(timer);controller.signal.removeEventListener('abort',abort);}
|
|
869
904
|
}
|
|
870
905
|
async function invoke(adapter,role,contextId,payload,extraControl=null) {
|
|
871
906
|
const request=requestFor({invocationId:`${session}.${++sequence}`,identity:{...config.identity,attempt},
|
|
@@ -878,6 +913,7 @@ export function createTaskRunner(options) {
|
|
|
878
913
|
call.terminal=response.status;call.effectiveModel=response.effectiveModel;call.resultDigest=digest(response.result);
|
|
879
914
|
if(role==='developer'&&response.status==='failed'&&response.result!==null)call.failureResult=response.result;
|
|
880
915
|
if(role==='developer'&&Object.hasOwn(response,'blockedReason'))call.blockedReason=response.blockedReason;
|
|
916
|
+
if(role==='developer'&&Object.hasOwn(response,'failureCode'))call.failureCode=response.failureCode;
|
|
881
917
|
if(Object.hasOwn(response,'providerThreadId'))call.providerThreadId=response.providerThreadId;
|
|
882
918
|
return {request,response,call};
|
|
883
919
|
} catch(error){call.terminal=state==='cancelled'?'cancelled':'unknown';throw error;}
|
|
@@ -981,6 +1017,7 @@ export function createTaskRunner(options) {
|
|
|
981
1017
|
}
|
|
982
1018
|
};
|
|
983
1019
|
let timer,timedOut=false,cancelReject;
|
|
1020
|
+
const endReviewStage=beginHostStage('review',reviewTimeoutMs??config.timeoutMs);
|
|
984
1021
|
try{
|
|
985
1022
|
let raw;
|
|
986
1023
|
try{
|
|
@@ -1090,7 +1127,7 @@ export function createTaskRunner(options) {
|
|
|
1090
1127
|
else if(retry)halt(retry.state,retry.code);
|
|
1091
1128
|
else halt('unknown',inspection.code??'reconciliation_required');
|
|
1092
1129
|
}finally{
|
|
1093
|
-
captureOpen=false;
|
|
1130
|
+
endReviewStage();captureOpen=false;
|
|
1094
1131
|
if((metadata.externalModels||metadata.executionPolicy)&&(state==='unknown'||state==='pending_review'&&code==='review_transport_timeout')
|
|
1095
1132
|
&&started!==null&&!invalid&&!receiptConflict&&capturedReceipt)
|
|
1096
1133
|
pendingReconciliation={effectId,invocationId:request.invocationId,receipt:capturedReceipt};
|
|
@@ -1099,7 +1136,8 @@ export function createTaskRunner(options) {
|
|
|
1099
1136
|
}
|
|
1100
1137
|
async function collectChecks(){
|
|
1101
1138
|
const before=new Map(captureReviewInventory(config.root,base).map(file=>[file.path,file.sha256]));
|
|
1102
|
-
const results=json(await bounded(check,json({identity:{...config.identity,attempt}
|
|
1139
|
+
const results=json(await bounded(check,json({identity:{...config.identity,attempt},
|
|
1140
|
+
...(parsedHistory?.scopeRevisions?{scope:effectiveScope}: {})})));
|
|
1103
1141
|
validChecks(results);
|
|
1104
1142
|
const after=captureReviewInventory(config.root,base);
|
|
1105
1143
|
checkNewPaths=new Set(after.filter(file=>!before.has(file.path)).map(file=>file.path));
|
|
@@ -1114,7 +1152,22 @@ export function createTaskRunner(options) {
|
|
|
1114
1152
|
// Runs on the checks just collected, before any handoff or review package is
|
|
1115
1153
|
// built, so a deliverable that does not satisfy the task's own written
|
|
1116
1154
|
// verification never spends an independent review round.
|
|
1155
|
+
// The scope as the task baseline recorded it when the run was created: durable,
|
|
1156
|
+
// so a resumed process still knows the state before any development. The host
|
|
1157
|
+
// replay restores it as "before development" (host-replay.mjs). A scope file
|
|
1158
|
+
// the baseline holds without content makes it unavailable, never partial.
|
|
1159
|
+
function baselineSnapshot(){
|
|
1160
|
+
const files=new Map();
|
|
1161
|
+
for(const file of effectiveScope){
|
|
1162
|
+
const record=base.files.find(item=>item.path===file);
|
|
1163
|
+
if(!record){files.set(file,null);continue;}
|
|
1164
|
+
if(record.type!=='file'||typeof record.contentBase64!=='string')return {unavailable:'baseline_without_content'};
|
|
1165
|
+
files.set(file,{bytes:Buffer.from(record.contentBase64,'base64'),mode:record.mode});
|
|
1166
|
+
}
|
|
1167
|
+
return {files};
|
|
1168
|
+
}
|
|
1117
1169
|
async function verificationSatisfied(checks) {
|
|
1170
|
+
requirementEvidence=null;hostReplayEvidence=null;
|
|
1118
1171
|
if(verificationGate===null)return true;
|
|
1119
1172
|
// The description carries hard requirements too ("also confirm X/Y/Z do not
|
|
1120
1173
|
// regress", "do not modify A"), and a gate that reads only the verification
|
|
@@ -1128,20 +1181,30 @@ export function createTaskRunner(options) {
|
|
|
1128
1181
|
const verdict=json(await bounded(verificationGate,
|
|
1129
1182
|
json({identity:{...config.identity,attempt},
|
|
1130
1183
|
...(written(description)?{description}:{}),
|
|
1131
|
-
...(written(verification)?{verification}:{}),checks
|
|
1132
|
-
|
|
1184
|
+
...(written(verification)?{verification}:{}),checks,
|
|
1185
|
+
...(parsedHistory?.scopeRevisions?{scope:effectiveScope}: {})}),{baselineSnapshot:baselineSnapshot()}));
|
|
1186
|
+
shape(verdict,['satisfied',...['items','hostRecord'].filter(key=>Object.hasOwn(verdict,key))]);
|
|
1187
|
+
need(typeof verdict.satisfied==='boolean','invalid_result');
|
|
1188
|
+
need(verdict.satisfied||!Object.hasOwn(verdict,'items')&&!Object.hasOwn(verdict,'hostRecord'),'invalid_result');
|
|
1189
|
+
// The host's own replay record (host-replay.mjs) is a separate handoff entry.
|
|
1190
|
+
hostReplayEvidence=Object.hasOwn(verdict,'hostRecord')
|
|
1191
|
+
?encodeHostReplayEvidence({identity:{...config.identity,attempt},facts:verdict.hostRecord}):null;
|
|
1192
|
+
// A satisfied gate may return its per-requirement answers; they become one
|
|
1193
|
+
// handoff evidence entry bound to this identity and attempt.
|
|
1194
|
+
requirementEvidence=Object.hasOwn(verdict,'items')
|
|
1195
|
+
?encodeRequirementEvidence({identity:{...config.identity,attempt},items:verdict.items}):null;
|
|
1133
1196
|
return verdict.satisfied;
|
|
1134
1197
|
}
|
|
1135
1198
|
// Attempt 2 exists to answer the findings that rejected attempt 1. Code
|
|
1136
1199
|
// byte-identical to that rejected artifact cannot, so it never spends the
|
|
1137
1200
|
// last review round; the same attempt may deliver again under a new effect id.
|
|
1138
1201
|
function unchangedSinceRejection(){
|
|
1139
|
-
if(attempt!==2
|
|
1140
|
-
const rejected=receipts.findLast(item=>item.identity.attempt===1&&item.result.verdict
|
|
1202
|
+
if(attempt!==2||!['changes_requested','approved'].includes(priorReview?.verdict))return null;
|
|
1203
|
+
const rejected=receipts.findLast(item=>item.identity.attempt===1&&['changes_requested','approved'].includes(item.result.verdict));
|
|
1141
1204
|
if(!rejected)return null;
|
|
1142
1205
|
const candidate=createReviewPackage({root:config.root,baseline:base,checks:currentChecks});
|
|
1143
1206
|
return candidate.artifactDigest===rejected.artifactDigest
|
|
1144
|
-
?`develop_unchanged_after_review: 第 2 轮交付与第 1
|
|
1207
|
+
?`develop_unchanged_after_review: 第 2 轮交付与第 1 轮已审代码逐字节相同(artifactDigest ${rejected.artifactDigest.slice(0,12)});按审查 findings 修改后重新交付`:null;
|
|
1145
1208
|
}
|
|
1146
1209
|
// A delivery that changes nothing in scope has no review package to build. It
|
|
1147
1210
|
// is the delivery that must be redone, exactly like failed checks, not an
|
|
@@ -1152,7 +1215,7 @@ export function createTaskRunner(options) {
|
|
|
1152
1215
|
// packaged (every requirement must exist), which is again a delivery to redo.
|
|
1153
1216
|
// Only in-scope requirements qualify: touching any other file stays out_of_scope,
|
|
1154
1217
|
// which the package builder reports before it ever reads the requirements.
|
|
1155
|
-
const missingScopeRequirements=()=>
|
|
1218
|
+
const missingScopeRequirements=()=>effectiveScope.filter(p=>config.requirements.includes(p)).filter(p=>{
|
|
1156
1219
|
try{const stat=fs.lstatSync(path.join(config.root,p));return !stat.isFile()||stat.isSymbolicLink();}
|
|
1157
1220
|
catch(error){if(error.code==='ENOENT'||error.code==='ENOTDIR')return true;throw error;}
|
|
1158
1221
|
});
|
|
@@ -1186,7 +1249,19 @@ export function createTaskRunner(options) {
|
|
|
1186
1249
|
try{unchanged=unchangedSinceRejection();}catch(error){emptyDelivery(error);return false;}
|
|
1187
1250
|
if(unchanged){halt('blocked','develop_unchanged_after_review',unchanged);return false;}
|
|
1188
1251
|
try{createHostHandoff({root:config.root,baseline:base,checks:currentChecks,
|
|
1189
|
-
handoffPath:completion.handoffs[attempt-1]
|
|
1252
|
+
handoffPath:completion.handoffs[attempt-1],evidence:[...journal.filter(row=>row.payload.type==='completion-rework-requested')
|
|
1253
|
+
.map(row=>'cm-completion-rework-v1: '+JSON.stringify({identity:{...config.identity,attempt:2},recordDigest:row.digest})),
|
|
1254
|
+
...(requirementEvidence===null?[]:[requirementEvidence]),...(hostReplayEvidence===null?[]:[hostReplayEvidence])]});}
|
|
1255
|
+
catch(error){emptyDelivery(error);return false;}
|
|
1256
|
+
return true;
|
|
1257
|
+
}
|
|
1258
|
+
// The Learning evidence is appended to the handoff hostDeliveryChecks just
|
|
1259
|
+
// published. A delivery whose handoff fit before the append and not after
|
|
1260
|
+
// (requirement evidence makes that reachable) is the same retryable package
|
|
1261
|
+
// block as an oversized initial handoff, never an unknown effect.
|
|
1262
|
+
function appendLearningHandoff(v,{application,retrospective,writeback}){
|
|
1263
|
+
try{writeCmAiTaskLearningHandoff({handoffPath:completion.handoffs[attempt-1],feature:taskLearning.feature,
|
|
1264
|
+
identity:{...config.identity,attempt},learningInput:v.learningInput,application,retrospective,writeback});}
|
|
1190
1265
|
catch(error){emptyDelivery(error);return false;}
|
|
1191
1266
|
return true;
|
|
1192
1267
|
}
|
|
@@ -1241,9 +1316,7 @@ export function createTaskRunner(options) {
|
|
|
1241
1316
|
// the checks, the precheck, the handoff and the package. No developer call.
|
|
1242
1317
|
if(recheck){
|
|
1243
1318
|
if(!await hostDeliveryChecks())return;
|
|
1244
|
-
|
|
1245
|
-
identity:{...config.identity,attempt},learningInput:v.learningInput,application:learningResult.application,
|
|
1246
|
-
retrospective:learningResult.retrospective,writeback:learningResult.writeback});
|
|
1319
|
+
if(!appendLearningHandoff(v,learningResult))return;
|
|
1247
1320
|
await packageDelivery(v);return;
|
|
1248
1321
|
}
|
|
1249
1322
|
const previousLearning=learningResult;
|
|
@@ -1263,7 +1336,7 @@ export function createTaskRunner(options) {
|
|
|
1263
1336
|
const adapter=bootstrap===null?developer:{...developer,run:(request,control)=>
|
|
1264
1337
|
bootstrap.run(request,control,developer.run,{previous:previousBootstrap,previousWriteback,baseline:original,
|
|
1265
1338
|
verificationFailed:detail=>{verificationReason=detail;}})};
|
|
1266
|
-
const result=await invoke(adapter,'developer',developer.contextId,{scope:
|
|
1339
|
+
const result=await invoke(adapter,'developer',developer.contextId,{scope:effectiveScope,
|
|
1267
1340
|
requirements:original.files.filter(f=>config.requirements.includes(f.path)),priorReview,
|
|
1268
1341
|
...supersededReviewPayload(carriedReview,attempt),
|
|
1269
1342
|
...(Object.hasOwn(original,'specification')?{specification:verifySpecificationMaterial(original)}:{}),
|
|
@@ -1304,8 +1377,7 @@ export function createTaskRunner(options) {
|
|
|
1304
1377
|
learningResult=freeze({application,retrospective,writeback,...(instructionEvidence?{bootstrap:instructionEvidence}:{})});
|
|
1305
1378
|
if(writeback.outcome==='writeback_pending'){halt('blocked','learning_writeback_pending');return;}
|
|
1306
1379
|
if(taskLearning.hostHandoff===true&&!await hostDeliveryChecks())return;
|
|
1307
|
-
|
|
1308
|
-
identity:{...config.identity,attempt},learningInput:v.learningInput,application,retrospective,writeback});
|
|
1380
|
+
if(!appendLearningHandoff(v,{application,retrospective,writeback}))return;
|
|
1309
1381
|
}
|
|
1310
1382
|
need(result.response.result.outcome==='implemented','invalid_result');
|
|
1311
1383
|
if(taskLearning?.hostHandoff!==true){
|
|
@@ -1375,9 +1447,9 @@ export function createTaskRunner(options) {
|
|
|
1375
1447
|
// No delivery can still be reviewed: journal the terminal limit instead of an
|
|
1376
1448
|
// intent, so no developer call runs (see developBudgetExhausted).
|
|
1377
1449
|
const retryLimitDue=()=>invocationMode&&store&&!poisoned
|
|
1378
|
-
&&developBudgetExhausted({state,code,priorReview,calls,cache:[...cache.values()]});
|
|
1450
|
+
&&developBudgetExhausted({state,code,attempt,priorReview,calls,cache:[...cache.values()]},parsedHistory?.developRecheckEffects,parsedHistory?.developmentRework);
|
|
1379
1451
|
function recordRetryLimit(){
|
|
1380
|
-
const used=developBudget({calls,cache:[...cache.values()]});
|
|
1452
|
+
const used=developBudget({calls,cache:[...cache.values()]},parsedHistory?.developRecheckEffects,parsedHistory?.developmentRework);
|
|
1381
1453
|
persist('develop-retry-limit',{fromState:state,fromCode:code,countedCalls:used.calls,countedEffects:used.effects});
|
|
1382
1454
|
const recovered=readRunnerHistory(journal,metadata,3).state;
|
|
1383
1455
|
({state,code}=recovered);reason=recovered.reason??null;publication=privateStatus();return publication;
|
|
@@ -1419,6 +1491,7 @@ export function createTaskRunner(options) {
|
|
|
1419
1491
|
if(v.kind==='develop'&&(recheck!==null||state==='blocked'&&RECHECK_CODES.includes(code)))
|
|
1420
1492
|
need(digest(v.learningInput)===digest([...cache.values()].at(-1).effect.learningInput),'runner_learning');
|
|
1421
1493
|
if(v.kind==='complete'&&state==='unknown'&&completeRecheck())completeSource=code;
|
|
1494
|
+
if(recheck!==null||completeSource!==null)need(!cancellationRequested&&!cancelAfterCommit&&!workflowError,'cancelled');
|
|
1422
1495
|
if(v.kind==='develop'&&state==='unknown'&&recheck===null)dispatchBasis=developDispatchRetry();
|
|
1423
1496
|
// Q16/Q17: re-ask only documentation_sync; refused (nothing journaled)
|
|
1424
1497
|
// while the code root outside the documentation paths changed, or while a
|
|
@@ -1441,7 +1514,8 @@ export function createTaskRunner(options) {
|
|
|
1441
1514
|
}
|
|
1442
1515
|
answerRetry=v.kind==='develop'&&state==='blocked'&&code==='failed'&&answerRetryable();
|
|
1443
1516
|
need(timeoutBasis!==null||answerRetry||recheck!==null||completeSource!==null||dispatchBasis!==null
|
|
1444
|
-
||stageAllowed(v.kind,state,code,priorReview?.verdict),'stage_mismatch');need(effectSlotFree(v.kind,[...cache.values()],calls),'limit_exceeded');
|
|
1517
|
+
||stageAllowed(v.kind,state,code,priorReview?.verdict),'stage_mismatch');need(effectSlotFree(v.kind,[...cache.values()],calls,parsedHistory?.developRecheckEffects,parsedHistory?.developmentRework,v.id,recheck!==null?{state:'blocked',code:recheck}:{state,code}),'limit_exceeded');
|
|
1518
|
+
if(v.kind==='develop'&&parsedHistory?.developmentRework&&!parsedHistory.developmentRework.developerConsumed)need(digest(captureReviewInventory(config.root,original,{withMode:true}))===parsedHistory.developmentRework.sourceDigest,'development_rework_source_changed');
|
|
1445
1519
|
if(Object.hasOwn(original,'specification'))verifySpecificationMaterial(original);
|
|
1446
1520
|
if(v.kind==='develop'&&bootstrap!==null)bootstrap.assertWriteAuthorized();
|
|
1447
1521
|
} catch(error){return Promise.resolve(freeze({outcome:'rejected',code:error.code??'invalid_input',
|
|
@@ -1470,6 +1544,9 @@ export function createTaskRunner(options) {
|
|
|
1470
1544
|
catch{return Promise.resolve(poison());}
|
|
1471
1545
|
halt('blocked',COMPLETE_RECHECK_CODE,completeRecheckReason(completeSource));publication=privateStatus();
|
|
1472
1546
|
}
|
|
1547
|
+
// A check timeout aborted its signal, not the accepted delivery or review.
|
|
1548
|
+
// Only these journaled check-only recoveries receive a fresh controller.
|
|
1549
|
+
if(recheck!==null||completeSource!==null)controller=new AbortController();
|
|
1473
1550
|
if(answerRetry){
|
|
1474
1551
|
try{persist('develop-answer-retry',{effectId:[...cache.values()].at(-1).effect.id,invocationId:calls.at(-1).invocationId});}
|
|
1475
1552
|
catch{return Promise.resolve(poison());}
|
|
@@ -1523,7 +1600,10 @@ export function createTaskRunner(options) {
|
|
|
1523
1600
|
const reserve=developCheckpointReserve({examinedPathsBytes:size(reviewPaths(reviewPackage)),
|
|
1524
1601
|
receiptsBytes:size(receipts),callsBytes:size(calls),writebackBytes:size(learningResult?.writeback)});
|
|
1525
1602
|
const budget=JOURNAL_PAYLOAD_LIMIT-reserve;
|
|
1526
|
-
|
|
1603
|
+
const enabled=packageMaterialEnabled();
|
|
1604
|
+
const capacity=enabled?checkpointPackageBudget({inlineBytes:bytes,packageBytes:size(reviewPackage),reserve,enabled,
|
|
1605
|
+
referenced:packageMaterialReference(journal,reviewPackage,{...config.identity,attempt})!==null}):{fits:bytes<=budget};
|
|
1606
|
+
if(!capacity.fits){
|
|
1527
1607
|
const changed=reviewPackage.changes.filter(change=>change.after).map(change=>change.after);
|
|
1528
1608
|
reviewPackage=packageBefore;
|
|
1529
1609
|
halt('blocked','develop_package_too_large',boundedReason(`develop_package_too_large: the review checkpoint would be ${bytes} bytes, `
|
|
@@ -1610,8 +1690,48 @@ export function createTaskRunner(options) {
|
|
|
1610
1690
|
}
|
|
1611
1691
|
return status();
|
|
1612
1692
|
}
|
|
1693
|
+
function inspectAcceptedIntegration(record){
|
|
1694
|
+
const {evidence,reference}=readIntegrationEvidenceFile(record.reviewFile.path);
|
|
1695
|
+
same(reference,record.reviewFile,'integration_evidence_changed');
|
|
1696
|
+
same(evidence.plan,record.plan,'integration_evidence_changed');
|
|
1697
|
+
if(reviewPackage.handoff){
|
|
1698
|
+
const handoff=handoffBinding().handoffPath;
|
|
1699
|
+
need(digest(readReviewSourceFiles(path.dirname(handoff),[path.basename(handoff)])[0])===digest(reviewPackage.handoff),'package_mismatch');
|
|
1700
|
+
}
|
|
1701
|
+
return verifyReviewedIntegration({root:config.root,specsRoot:completion.owner.specsRoot,
|
|
1702
|
+
baseline:base,parentPackage:reviewPackage,records:journal.slice(0,record.plan.target.recordCount),...evidence});
|
|
1703
|
+
}
|
|
1704
|
+
// Launch-only authority. The existing owner holds the store lock; evidence
|
|
1705
|
+
// never grants itself permission. No provider, QA, commit, or product write.
|
|
1706
|
+
const acceptReviewedIntegration=raw=>{
|
|
1707
|
+
try{
|
|
1708
|
+
shape(raw,['allowed','evidenceFile','expectedDigest']);
|
|
1709
|
+
need(raw.allowed===true,'integration_authorization_required');
|
|
1710
|
+
need(invocationMode&&store&&completion&&!busy&&!poisoned&&!restored?.pending
|
|
1711
|
+
&&state==='fixture_completed'&&acceptedFixes.length===0,'integration_parent_not_completed');
|
|
1712
|
+
currentStore();
|
|
1713
|
+
const {evidence,reference}=readIntegrationEvidenceFile(raw.evidenceFile);
|
|
1714
|
+
need(raw.expectedDigest===digest(evidence.plan),'integration_target_changed');
|
|
1715
|
+
if(acceptedIntegration){
|
|
1716
|
+
same(acceptedIntegration.plan,evidence.plan,'integration_target_changed');
|
|
1717
|
+
same(acceptedIntegration.reviewFile,reference,'integration_evidence_changed');
|
|
1718
|
+
inspectAcceptedIntegration(acceptedIntegration);return status();
|
|
1719
|
+
}
|
|
1720
|
+
const record=validateIntegrationRecord({record:{version:1,plan:evidence.plan,reviewFile:reference,
|
|
1721
|
+
reason:'Explicit reviewed integration',planDigest:raw.expectedDigest},
|
|
1722
|
+
baseline:base,parentPackage:reviewPackage,records:journal});
|
|
1723
|
+
inspectAcceptedIntegration(record);
|
|
1724
|
+
// Re-read exact evidence after all source, Git, and inventory checks.
|
|
1725
|
+
same(readIntegrationEvidenceFile(raw.evidenceFile).reference,reference,'integration_evidence_changed');
|
|
1726
|
+
assertJournalFits('reviewed-integration-accepted',{record},'integration_storage_limit');
|
|
1727
|
+
persist('reviewed-integration-accepted',{record});acceptedIntegration=record;
|
|
1728
|
+
return status();
|
|
1729
|
+
}catch(error){return freeze({outcome:'rejected',code:error?.code??'integration_evidence_invalid',
|
|
1730
|
+
...(Array.isArray(error.paths)?{reason:error.paths.join(', ').slice(0,8192)}:{})});}
|
|
1731
|
+
};
|
|
1613
1732
|
// Read-only content comparison, not completion authority or a JSON operation.
|
|
1614
1733
|
const inspectFixAssociation=(fixPackage,evidence=null)=>{
|
|
1734
|
+
need(acceptedIntegration===null,'integration_fix_unsupported');
|
|
1615
1735
|
need(!busy&&!poisoned,'host_busy');
|
|
1616
1736
|
const current=status();
|
|
1617
1737
|
need(current.state==='fixture_completed'&¤t.code!=='review_publication_required','qa_fix_parent_not_completed');
|
|
@@ -1902,6 +2022,82 @@ export function createTaskRunner(options) {
|
|
|
1902
2022
|
}catch(error){return freeze({outcome:'rejected',code:poisoned?'store_failure':error.code??'develop_redo_unavailable',
|
|
1903
2023
|
...(!poisoned&&error.reason?{reason:error.reason}:{})});}
|
|
1904
2024
|
};
|
|
2025
|
+
const reviseScope=raw=>{
|
|
2026
|
+
try{
|
|
2027
|
+
need(invocationMode&&store&&!busy&&!poisoned&&options.persistence.mode==='resume'
|
|
2028
|
+
&&options.providerDevelopment!==true&&options.protectedDevelopment!==true,'scope_revision_unavailable');
|
|
2029
|
+
const value=json(raw);shape(value,['allowed','reason','scope']);need(value.allowed===true,'scope_revision_authorization_required');
|
|
2030
|
+
const history=readRunnerHistory(journal,metadata,3);
|
|
2031
|
+
need(history.pending===null&&history.transaction===null,'scope_revision_unavailable');
|
|
2032
|
+
const binding=scopeRevisionBinding(history.state,effectiveMetadata(),history.scopeRevisions);
|
|
2033
|
+
need(!developBudgetExhausted(history.state,history.developRecheckEffects),'scope_revision_budget_exhausted');
|
|
2034
|
+
const rows=taskDeclarations(fs.readFileSync(completion.owner.tasksPath,'utf8'),
|
|
2035
|
+
{grammar:approvedTaskGrammar(completion.owner.specsRoot)}).filter(item=>item.id===config.identity.taskId);
|
|
2036
|
+
need(rows.length===1&&!rows[0].completed,'scope_revision_task_completed');
|
|
2037
|
+
if(Object.hasOwn(original,'specification'))verifySpecificationMaterial(original);
|
|
2038
|
+
const scope=revisedScope(value.scope,effectiveScope);
|
|
2039
|
+
const files=captureScopeRevisionSources(config.root,original,scope);
|
|
2040
|
+
const record={fromDigest:journal.at(-1).digest,...binding,baselineDigest:original.baselineDigest,
|
|
2041
|
+
scope,files,reason:value.reason,at:new Date().toISOString()};
|
|
2042
|
+
applyScopeRevision(history.state,effectiveMetadata(),original,record,history.scopeRevisions);
|
|
2043
|
+
assertJournalFits('scope-revised',record,'scope_revision_too_large');
|
|
2044
|
+
persist('scope-revised',record);
|
|
2045
|
+
original=parsedHistory.original;effectiveScope=parsedHistory.effectiveScope;scopeRevisionPaths=original.scopeRevisionPaths;
|
|
2046
|
+
base=attemptBaseline(original,attempt);publication=privateStatus();return status();
|
|
2047
|
+
}catch(error){return freeze({outcome:'rejected',code:poisoned?'store_failure':error.code??'scope_revision_unavailable'});}
|
|
2048
|
+
};
|
|
2049
|
+
const reworkDevelopment=raw=>{
|
|
2050
|
+
try{
|
|
2051
|
+
need(invocationMode&&store&&!busy&&!poisoned&&options.persistence.mode==='resume'
|
|
2052
|
+
&&options.providerDevelopment!==true&&options.protectedDevelopment!==true,'development_rework_unavailable');
|
|
2053
|
+
const value=json(raw);shape(value,['allowed','reason']);need(value.allowed===true,'development_rework_authorization_required');
|
|
2054
|
+
const history=readRunnerHistory(journal,metadata,3);
|
|
2055
|
+
need(history.pending===null&&history.transaction===null,'development_rework_unavailable');
|
|
2056
|
+
const effectiveConfig={...metadata,scope:effectiveScope};
|
|
2057
|
+
const binding=developmentReworkBinding(journal,history.state,effectiveConfig,original,
|
|
2058
|
+
history.developRecheckEffects,history.developmentRework);
|
|
2059
|
+
const rows=taskDeclarations(fs.readFileSync(completion.owner.tasksPath,'utf8'),
|
|
2060
|
+
{grammar:approvedTaskGrammar(completion.owner.specsRoot)}).filter(item=>item.id===config.identity.taskId);
|
|
2061
|
+
need(rows.length===1&&!rows[0].completed,'development_rework_task_completed');
|
|
2062
|
+
if(Object.hasOwn(original,'specification'))verifySpecificationMaterial(original);
|
|
2063
|
+
for(const file of [completion.handoffs[1],path.join(completion.reviewsDir,
|
|
2064
|
+
completion.owner.feature.replace(/^\d+\./,'')+'-'+config.identity.taskId+'-r2.md')]){
|
|
2065
|
+
try{fs.lstatSync(file);need(false,'development_rework_evidence_exists');}
|
|
2066
|
+
catch(error){if(error.code!=='ENOENT')throw error;}
|
|
2067
|
+
}
|
|
2068
|
+
const record={fromDigest:journal.at(-1).digest,...binding,effectCredit:1,
|
|
2069
|
+
sourceDigest:digest(captureReviewInventory(config.root,original,{withMode:true})),reason:value.reason,at:new Date().toISOString()};
|
|
2070
|
+
applyDevelopmentRework(journal,history.state,effectiveConfig,original,record,history.developRecheckEffects,history.developmentRework);
|
|
2071
|
+
persist('development-rework-authorized',record);
|
|
2072
|
+
({state,code,reason}=parsedHistory.state);publication=privateStatus();return status();
|
|
2073
|
+
}catch(error){return freeze({outcome:'rejected',code:poisoned?'store_failure':error.code??'development_rework_unavailable'});}
|
|
2074
|
+
};
|
|
2075
|
+
const reworkCompletion=raw=>{
|
|
2076
|
+
try{
|
|
2077
|
+
need(invocationMode&&store&&!busy&&!poisoned&&options.persistence.mode==='resume'
|
|
2078
|
+
&&(options.parallelSelection??null)===null&&options.providerDevelopment!==true&&options.protectedDevelopment!==true,'completion_rework_unavailable');
|
|
2079
|
+
const value=json(raw);shape(value,['allowed','reason']);need(value.allowed===true,'completion_rework_authorization_required');
|
|
2080
|
+
const binding=completionReworkBinding(frame(),metadata);
|
|
2081
|
+
need(!readRunnerHistory(journal,metadata,3).pending,'completion_rework_unavailable');
|
|
2082
|
+
publishRegisteredReview(true);
|
|
2083
|
+
verifyReviewPackage({root:config.root,baseline:base,checks:currentChecks,reviewPackage,
|
|
2084
|
+
expectedDigest:binding.packageDigest,...handoffBinding()});
|
|
2085
|
+
const rows=taskDeclarations(fs.readFileSync(completion.owner.tasksPath,'utf8'),
|
|
2086
|
+
{grammar:approvedTaskGrammar(completion.owner.specsRoot)}).filter(item=>item.id===config.identity.taskId);
|
|
2087
|
+
need(rows.length===1&&!rows[0].completed,'completion_rework_task_completed');
|
|
2088
|
+
for(const file of [completion.handoffs[1],path.join(completion.reviewsDir,
|
|
2089
|
+
completion.owner.feature.replace(/^\d+\./,'')+'-'+config.identity.taskId+'-r2.md')]){
|
|
2090
|
+
try{fs.lstatSync(file);need(false,'completion_rework_evidence_exists');}
|
|
2091
|
+
catch(error){if(error.code!=='ENOENT')throw error;}
|
|
2092
|
+
}
|
|
2093
|
+
const record={...binding,fromAttempt:1,toAttempt:2,reason:value.reason,at:new Date().toISOString()};
|
|
2094
|
+
applyCompletionRework(frame(),metadata,record);
|
|
2095
|
+
persist('completion-rework-requested',record);
|
|
2096
|
+
const next=readRunnerHistory(journal,metadata,3).state;
|
|
2097
|
+
({state,code,attempt,receipt,reviewInvocation,reason}=next);
|
|
2098
|
+
base=attemptBaseline(original,attempt);publication=privateStatus();return publication;
|
|
2099
|
+
}catch(error){return freeze({outcome:'rejected',code:error.code??'completion_rework_unavailable'});}
|
|
2100
|
+
};
|
|
1905
2101
|
const recoverBootstrapReview=raw=>{
|
|
1906
2102
|
try{
|
|
1907
2103
|
need(invocationMode&&store&&!busy&&!poisoned&&options.persistence.mode==='resume',
|
|
@@ -1944,7 +2140,16 @@ export function createTaskRunner(options) {
|
|
|
1944
2140
|
need(state==='fixture_completed'&&reviewPackage?.packageDigest===packageDigest,'stale_qa');
|
|
1945
2141
|
return freeze({paths:reviewPackage.changes.map(change=>change.path),source:'review_package'});
|
|
1946
2142
|
};
|
|
1947
|
-
|
|
2143
|
+
// Read-only: the reviewed package's task checks, only while the code root
|
|
2144
|
+
// still matches that package, so a QA command may reuse an identical passed
|
|
2145
|
+
// check instead of running it again (host-qa-executor reuseCheck).
|
|
2146
|
+
const qaCompletionChecks=packageDigest=>{
|
|
2147
|
+
need(state==='fixture_completed'&&reviewPackage?.packageDigest===packageDigest,'stale_qa');
|
|
2148
|
+
verifyReviewPackage({root:config.root,baseline:attemptBaseline(original,reviewPackage.identity.attempt),
|
|
2149
|
+
checks:reviewPackage.checks,reviewPackage,expectedDigest:reviewPackage.packageDigest,...handoffBinding()});
|
|
2150
|
+
return freeze(structuredClone(reviewPackage.checks));
|
|
2151
|
+
};
|
|
2152
|
+
const api={qaChangedFiles,qaCompletionChecks,reviseQa,supersedeEvidence,rebindSpecification,abandonReview,reconcileReview,abandonEffect,recoverBootstrapReview,reworkCompletion,reworkDevelopment,reviseScope,executeEffect,status,cancel,run,inspectFixAssociation,acceptCompletedFix,acceptReviewedIntegration,attachQa,verificationBlocks,completionBlocks,reviewEffectIds,recheckLearningInput,redoDevelop,recoverCommit,interruptions};
|
|
1948
2153
|
if(bootstrap!==null)api.inspectBootstrapAdmission=()=>bootstrap.inspectAdmission(original);
|
|
1949
2154
|
if(taskLearning!==null)api.attachLearningEvidence=attachLearningEvidence;
|
|
1950
2155
|
// A terminal reviewer observation is durable even if the host died before
|
|
@@ -1968,6 +2173,7 @@ export function createTaskRunner(options) {
|
|
|
1968
2173
|
function configToBaseline(c){
|
|
1969
2174
|
const scope=Object.hasOwn(c,'taskLearning')?taskReviewScope(c.scope):c.scope;
|
|
1970
2175
|
return {root:c.root,identity:c.identity,scope,requirements:c.requirements,
|
|
2176
|
+
...(c.scopeRevisionPaths?{scopeRevisionPaths:c.scopeRevisionPaths}:{}),
|
|
1971
2177
|
...(c.codeProjectPaths?{codeProjectPaths:c.codeProjectPaths}:{}),
|
|
1972
2178
|
...(c.bootstrap?{bootstrapRequirements:c.bootstrap.bootstrapRequirements}:{}),
|
|
1973
2179
|
...(c.completion?{specsRoot:c.completion.owner.specsRoot}:{})};
|