@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
|
@@ -46,7 +46,7 @@ export function boundedReason(head,items,tail=''){
|
|
|
46
46
|
// Explicit host call budget, shared by live initialization and journal replay.
|
|
47
47
|
// This is not the short-lived authorization grant expiry.
|
|
48
48
|
export const validCallTimeout=value=>need(Number.isInteger(value)&&value>=1&&value<=3600000);
|
|
49
|
-
const failureCodes=new Set(['invalid_input','limit_exceeded','call_timeout','cancelled','terminal_mismatch','invalid_result',
|
|
49
|
+
const failureCodes=new Set(['checkpoint_package_material_invalid','invalid_input','limit_exceeded','call_timeout','cancelled','terminal_mismatch','invalid_result',
|
|
50
50
|
'review_package_mismatch','missing_material','contradictory_verdict','execution_mismatch','receipt_version',
|
|
51
51
|
'unregistered_receipt','invalid_receipt','receipt_identity','receipt_package_mismatch','review_not_approved',
|
|
52
52
|
'checks_not_passed','async_commit','commit_unknown','unsupported_path','unsupported_file','read_failed',
|
|
@@ -129,6 +129,7 @@ export const id=v=>need(typeof v==='string' && /^[A-Za-z0-9][A-Za-z0-9._-]{0,127
|
|
|
129
129
|
export const text=v=>need(typeof v==='string' && v.trim().length>0);
|
|
130
130
|
export const validBlockedReason=v=>need(typeof v==='string'&&v.trim().length>0
|
|
131
131
|
&&Buffer.byteLength(v,'utf8')<=1000&&!/[\x00-\x08\x0b-\x1f]/.test(v));
|
|
132
|
+
export const validFailureCode=v=>need(typeof v==='string'&&/^[a-z][a-z0-9_]{0,63}$/.test(v));
|
|
132
133
|
export const hex=v=>need(typeof v==='string' && /^[a-f0-9]{64}$/.test(v));
|
|
133
134
|
export const freeze=v=>{if(v && typeof v==='object'){Object.values(v).forEach(freeze);Object.freeze(v);}return v;};
|
|
134
135
|
export function arrayItems(value) {
|
|
@@ -184,7 +185,15 @@ export function terminalFor(raw,request) {
|
|
|
184
185
|
const v=json(raw);
|
|
185
186
|
shape(v,['version','invocationId','contextId','provider','effectiveModel','status','accepted','result',
|
|
186
187
|
...(Object.hasOwn(v,'providerThreadId')?['providerThreadId']:[]),
|
|
187
|
-
...(Object.hasOwn(v,'blockedReason')?['blockedReason']:[])
|
|
188
|
+
...(Object.hasOwn(v,'blockedReason')?['blockedReason']:[]),
|
|
189
|
+
...(Object.hasOwn(v,'failureCode')?['failureCode']:[])]);
|
|
190
|
+
// The worker's own code for a developer call that ended without a result
|
|
191
|
+
// (timeout, missing_init, provider_failed...). Diagnostic only: it never
|
|
192
|
+
// changes the terminal, its retry rules or any later decision.
|
|
193
|
+
if(Object.hasOwn(v,'failureCode')){
|
|
194
|
+
need(request.role==='developer'&&['failed','unknown'].includes(v.status)&&v.result===null
|
|
195
|
+
&&!Object.hasOwn(v,'blockedReason'));validFailureCode(v.failureCode);
|
|
196
|
+
}
|
|
188
197
|
if(Object.hasOwn(v,'blockedReason')){
|
|
189
198
|
need(request.role==='developer'&&v.status==='failed'&&v.result===null);
|
|
190
199
|
validBlockedReason(v.blockedReason);
|
|
@@ -8,8 +8,10 @@ import {readExecutionSnapshot} from './execution-snapshot.mjs';
|
|
|
8
8
|
import {scanRows} from './log-rows.mjs';
|
|
9
9
|
export const EXECUTION_POLICY_V1=Object.freeze({version:1,responseRecovery:'mechanical-v1',
|
|
10
10
|
checkReuse:'declared-adjacent-v1',reviewPresentation:'utf8-v1',usage:'provider-terminal-v1'});
|
|
11
|
+
export const EXECUTION_POLICY_V2=Object.freeze({...EXECUTION_POLICY_V1,version:2,reviewPresentation:'utf8-delta-v2'});
|
|
11
12
|
export function readExecutionPolicy(raw){
|
|
12
|
-
const value=json(raw)
|
|
13
|
+
const value=json(raw),key=digest(value);
|
|
14
|
+
need(key===digest(EXECUTION_POLICY_V1)||key===digest(EXECUTION_POLICY_V2),'execution_policy_invalid');return value;
|
|
13
15
|
}
|
|
14
16
|
export function readLaunchExecutionPolicy({definition,mode,enabled=false}){
|
|
15
17
|
need(['create','resume'].includes(mode),'invalid_mode');
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import {digest,need,shape,id,hex,json} from './effect-contract.mjs';
|
|
6
|
+
import {fixJournalWorkflow,packFixJournalPayload,unpackFixJournalState} from './review-presentation.mjs';
|
|
6
7
|
export function readExecutionSnapshot({specsRoot,identity}){
|
|
7
8
|
shape(identity,['repositoryId','runId']);Object.values(identity).forEach(id);
|
|
8
9
|
need(path.isAbsolute(specsRoot)&&fs.realpathSync(specsRoot)===specsRoot,'unsupported_path');
|
|
@@ -21,8 +22,9 @@ export function readExecutionSnapshot({specsRoot,identity}){
|
|
|
21
22
|
need([after,current].every(s=>['dev','ino','size','mtimeMs','ctimeMs'].every(k=>s[k]===before[k]))
|
|
22
23
|
&&bytes.length===before.size,'snapshot_changed');
|
|
23
24
|
}finally{fs.closeSync(fd);}
|
|
24
|
-
const raw=JSON.parse(bytes.toString('utf8'))
|
|
25
|
+
const raw=JSON.parse(bytes.toString('utf8'));
|
|
25
26
|
need(Buffer.from(JSON.stringify(raw)+'\n').equals(bytes),'store_corrupt');
|
|
27
|
+
const v=unpackFixJournalState(raw);
|
|
26
28
|
shape(v,['version','identity','fingerprints','records','revision']);
|
|
27
29
|
need(v.version===1&&digest(v.identity)===digest(identity),'identity_mismatch');
|
|
28
30
|
shape(v.fingerprints,['workflow','config','inputs']);Object.values(v.fingerprints).forEach(hex);
|
|
@@ -30,7 +32,7 @@ export function readExecutionSnapshot({specsRoot,identity}){
|
|
|
30
32
|
let previous=null;const ids=new Set();
|
|
31
33
|
for(const [index,r] of v.records.entries()){
|
|
32
34
|
shape(r,['version','seq','id','kind','payload','previousDigest','digest']);id(r.id);hex(r.digest);
|
|
33
|
-
|
|
35
|
+
need(Buffer.byteLength(JSON.stringify(packFixJournalPayload(r.payload,{workflow:fixJournalWorkflow(v)})))<=1024*1024,'limit_exceeded');
|
|
34
36
|
const {digest:checksum,...body}=r;
|
|
35
37
|
need(r.version===1&&r.seq===index+1&&r.previousDigest===previous&&!ids.has(r.id)
|
|
36
38
|
&&['intent','result','cancel','commit-intent','commit-result','finalized'].includes(r.kind)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Size and count limits of the local durable record store, without the store
|
|
2
2
|
// itself (no node:sqlite import), so owners can check an append before making it.
|
|
3
|
-
import { digest } from './effect-contract.mjs';
|
|
3
|
+
import { digest,json } from './effect-contract.mjs';
|
|
4
|
+
import {fixJournalWorkflow,packFixJournalPayload,packFixJournalState} from './review-presentation.mjs';
|
|
4
5
|
|
|
5
6
|
export const MiB=1024*1024,STATE_LIMIT=16*MiB,PHYSICAL_LIMIT=32*MiB,RECORD_LIMIT=1024;
|
|
6
7
|
|
|
@@ -9,10 +10,16 @@ export const MiB=1024*1024,STATE_LIMIT=16*MiB,PHYSICAL_LIMIT=32*MiB,RECORD_LIMIT
|
|
|
9
10
|
// before an append that would fail inside its writer. The directory's physical
|
|
10
11
|
// limit (state plus retained temporary files) is not checked here.
|
|
11
12
|
export function appendFits(current,input){
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
try{
|
|
14
|
+
const bytes=value=>Buffer.byteLength(JSON.stringify(value));
|
|
15
|
+
const entry=json(input,10*MiB),physicalPayload=packFixJournalPayload(entry.payload,{workflow:fixJournalWorkflow(current)});
|
|
16
|
+
if(bytes({...entry,payload:physicalPayload})>MiB+1024||current.records.length>=RECORD_LIMIT)return false;
|
|
17
|
+
const record={version:1,seq:current.records.length+1,id:entry.id,kind:entry.kind,payload:entry.payload,
|
|
18
|
+
previousDigest:current.records.at(-1)?.digest??null};
|
|
19
|
+
const {revision,...data}=current,next={...data,records:[...current.records,{...record,digest:digest(record)}]};
|
|
20
|
+
const logical={...next,revision:digest(next)};
|
|
21
|
+
// Both budgets remain unchanged. Encoded payloads cannot hide logical-state
|
|
22
|
+
// growth, and the writer also needs the physical trailing newline to fit.
|
|
23
|
+
return bytes(logical)<=STATE_LIMIT&&bytes(packFixJournalState(logical))+1<=STATE_LIMIT;
|
|
24
|
+
}catch{return false;}
|
|
18
25
|
}
|
|
@@ -8,6 +8,7 @@ const sqlite=()=>process.getBuiltinModule('node:sqlite');
|
|
|
8
8
|
import { need,shape,id,hex,json,digest,freeze,JOURNAL_PAYLOAD_LIMIT } from './effect-contract.mjs';
|
|
9
9
|
import { isSupportedExecutionPlatform } from './execution-platform.mjs';
|
|
10
10
|
import { MiB,STATE_LIMIT,PHYSICAL_LIMIT } from './execution-store-limits.mjs';
|
|
11
|
+
import {fixJournalWorkflow,packFixJournalPayload,packFixJournalState,unpackFixJournalState} from './review-presentation.mjs';
|
|
11
12
|
|
|
12
13
|
const APP_ID=0x434d5831;
|
|
13
14
|
const PROTOCOL_SQL='CREATE TABLE protocol(version INTEGER NOT NULL CHECK(version=1))';
|
|
@@ -33,7 +34,7 @@ function regular(p,limit) {
|
|
|
33
34
|
need(s.isFile() && !s.isSymbolicLink() && s.nlink===1,'unsupported_file');
|
|
34
35
|
need((s.mode&0o077)===0,'store_permissions');need(s.size<=limit,'limit_exceeded');return s;
|
|
35
36
|
}
|
|
36
|
-
function readState(p) {
|
|
37
|
+
function readState(p,{withBytes=false}={}) {
|
|
37
38
|
const before=regular(p,STATE_LIMIT),fd=fs.openSync(p,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW);
|
|
38
39
|
try {
|
|
39
40
|
need(sameInode(before,fs.fstatSync(fd)),'snapshot_changed');
|
|
@@ -43,7 +44,8 @@ function readState(p) {
|
|
|
43
44
|
&& before.ctimeMs===after.ctimeMs && bytes.length===after.size,'snapshot_changed');
|
|
44
45
|
const raw=bytes.toString('utf8'),value=JSON.parse(raw);
|
|
45
46
|
// Compare original bytes: replacement decoding must never repair corruption.
|
|
46
|
-
need(Buffer.from(JSON.stringify(value)+'\n').equals(bytes),'store_corrupt');
|
|
47
|
+
need(Buffer.from(JSON.stringify(value)+'\n').equals(bytes),'store_corrupt');
|
|
48
|
+
return withBytes?{value,bytes}:value;
|
|
47
49
|
}finally{fs.closeSync(fd);}
|
|
48
50
|
}
|
|
49
51
|
function validateState(raw,options) {
|
|
@@ -56,7 +58,8 @@ function validateState(raw,options) {
|
|
|
56
58
|
for(const [index,r] of v.records.entries()) {
|
|
57
59
|
shape(r,['version','seq','id','kind','payload','previousDigest','digest']);
|
|
58
60
|
need(r.version===1,'store_version');need(r.seq===index+1 && r.previousDigest===previous,'store_corrupt');
|
|
59
|
-
id(r.id);need(!ids.has(r.id) && kinds.has(r.kind),'store_corrupt');ids.add(r.id);
|
|
61
|
+
id(r.id);need(!ids.has(r.id) && kinds.has(r.kind),'store_corrupt');ids.add(r.id);
|
|
62
|
+
need(Buffer.byteLength(JSON.stringify(packFixJournalPayload(r.payload,{workflow:fixJournalWorkflow(v)})))<=JOURNAL_PAYLOAD_LIMIT,'limit_exceeded');
|
|
60
63
|
const {digest:checksum,...data}=r;hex(checksum);need(digest(data)===checksum,'store_corrupt');previous=checksum;
|
|
61
64
|
}
|
|
62
65
|
const {revision,...data}=v;hex(revision);need(digest(data)===revision,'store_corrupt');return v;
|
|
@@ -72,8 +75,10 @@ function runBytes(dir) {
|
|
|
72
75
|
}
|
|
73
76
|
need(total<=PHYSICAL_LIMIT,'limit_exceeded');return total;
|
|
74
77
|
}
|
|
75
|
-
function atomicState(dir,value) {
|
|
76
|
-
const
|
|
78
|
+
function atomicState(dir,value,physical=null) {
|
|
79
|
+
const encoded=physical??packFixJournalState(value);
|
|
80
|
+
if(physical!==null)need(digest(unpackFixJournalState(physical))===digest(value),'store_corrupt');
|
|
81
|
+
const bytes=Buffer.from(JSON.stringify(encoded)+'\n');need(bytes.length<=STATE_LIMIT,'limit_exceeded');
|
|
77
82
|
need(runBytes(dir)+bytes.length<=PHYSICAL_LIMIT,'limit_exceeded');
|
|
78
83
|
const tmp=path.join(dir,`.state.${randomUUID()}.tmp`);let fd,renamed=false;
|
|
79
84
|
try {
|
|
@@ -168,6 +173,28 @@ function acquireWriter(p,create) {
|
|
|
168
173
|
return {db,inode:regular(p,64*1024),certificate:current,inspectionFd,release};
|
|
169
174
|
}catch(error){release();if(error.errcode===5)need(false,'store_busy');throw error;}
|
|
170
175
|
}
|
|
176
|
+
// Every create probes the legacy shared writer. Another process creating a run
|
|
177
|
+
// in the same specs root holds that probe's write lock for a moment, so two
|
|
178
|
+
// creates started together used to fail one of them with store_busy (seen in a
|
|
179
|
+
// real two-task run). Only that transient contention is retried, briefly, and
|
|
180
|
+
// only here, before this create has written anything; any other failure, or a
|
|
181
|
+
// legacy writer that stays held, still refuses with store_busy as before.
|
|
182
|
+
export const LEGACY_PROBE_ATTEMPTS=20;
|
|
183
|
+
export const LEGACY_PROBE_DELAY_MS=50;
|
|
184
|
+
const pause=ms=>Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,ms);
|
|
185
|
+
function probeLegacyWriter(legacyPath){
|
|
186
|
+
for(let attempt=1;;attempt++){
|
|
187
|
+
// Probe with the full existing protocol; never create or migrate old files.
|
|
188
|
+
// release closes SQLite before its inspection fd and removes the inode key.
|
|
189
|
+
let probe;
|
|
190
|
+
try{probe=acquireWriter(legacyPath,false);}
|
|
191
|
+
catch(error){
|
|
192
|
+
if(error?.code==='store_busy'&&attempt<LEGACY_PROBE_ATTEMPTS){pause(LEGACY_PROBE_DELAY_MS);continue;}
|
|
193
|
+
need(false,'store_busy');
|
|
194
|
+
}
|
|
195
|
+
probe.release();return;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
171
198
|
export { appendFits } from './execution-store-limits.mjs';
|
|
172
199
|
export function openExecutionStore(input) {
|
|
173
200
|
const options=json(input);shape(options,['specsRoot','identity','fingerprints','create']);
|
|
@@ -184,13 +211,7 @@ export function openExecutionStore(input) {
|
|
|
184
211
|
if(options.create) {
|
|
185
212
|
const legacyPath=path.join(execution,'writer.sqlite');let legacy=false;
|
|
186
213
|
try{fs.lstatSync(legacyPath);legacy=true;}catch(error){if(error.code!=='ENOENT')throw error;}
|
|
187
|
-
if(legacy)
|
|
188
|
-
// Probe with the full existing protocol; never create or migrate old files.
|
|
189
|
-
// release closes SQLite before its inspection fd and removes the inode key.
|
|
190
|
-
let probe;
|
|
191
|
-
try{probe=acquireWriter(legacyPath,false);}catch{need(false,'store_busy');}
|
|
192
|
-
probe.release();
|
|
193
|
-
}
|
|
214
|
+
if(legacy)probeLegacyWriter(legacyPath);
|
|
194
215
|
}
|
|
195
216
|
const existed=fs.existsSync(dir);
|
|
196
217
|
directory(dir,options.create);
|
|
@@ -210,16 +231,29 @@ export function openExecutionStore(input) {
|
|
|
210
231
|
};
|
|
211
232
|
const statePath=path.join(dir,'state.json');
|
|
212
233
|
if(options.create)atomicState(dir,seal({version:1,identity:options.identity,fingerprints:options.fingerprints,records:[]}));
|
|
234
|
+
let physicalState=null,validatedBytes=null,validatedLogical=null;
|
|
213
235
|
const snapshot=()=>{
|
|
214
236
|
need(!closed,'store_closed');need(!poisoned,'store_poisoned');
|
|
215
|
-
try{
|
|
237
|
+
try{
|
|
238
|
+
guard();runBytes(dir);
|
|
239
|
+
const {value:physical,bytes}=readState(statePath,{withBytes:true});
|
|
240
|
+
// Reuse only after every fresh path/ownership/read/canonical check above.
|
|
241
|
+
// The buffer stays private; validateState returns a deeply frozen value.
|
|
242
|
+
if(validatedBytes!==null && validatedBytes.equals(bytes))return validatedLogical;
|
|
243
|
+
const logical=validateState(unpackFixJournalState(physical),options);
|
|
244
|
+
// Private physical rows never escape to the logical owner. Append keeps
|
|
245
|
+
// these validated old objects verbatim instead of encoding them again.
|
|
246
|
+
physicalState=physical;validatedBytes=bytes;validatedLogical=logical;return logical;
|
|
247
|
+
}catch(error){poisoned=true;throw error;}
|
|
216
248
|
};
|
|
217
249
|
snapshot();
|
|
218
250
|
const append=input=>{
|
|
219
251
|
need(!closed,'store_closed');need(!poisoned,'store_poisoned');
|
|
220
|
-
const v=json(input,MiB
|
|
221
|
-
id(v.id);hex(v.expectedRevision);need(kinds.has(v.kind));
|
|
222
|
-
const current=snapshot(),
|
|
252
|
+
const v=json(input,10*MiB);shape(v,['id','kind','payload','expectedRevision']);
|
|
253
|
+
id(v.id);hex(v.expectedRevision);need(kinds.has(v.kind));
|
|
254
|
+
const current=snapshot(),physicalPayload=packFixJournalPayload(v.payload,{workflow:fixJournalWorkflow(current)});
|
|
255
|
+
need(Buffer.byteLength(JSON.stringify({...v,payload:physicalPayload}))<=MiB+1024,'limit_exceeded');
|
|
256
|
+
const existing=current.records.find(r=>r.id===v.id);
|
|
223
257
|
if(existing){need(existing.kind===v.kind && digest(existing.payload)===digest(v.payload),'record_conflict');return current;}
|
|
224
258
|
need(v.expectedRevision===current.revision,'revision_mismatch');
|
|
225
259
|
need(current.records.length<1024,'limit_exceeded');
|
|
@@ -227,7 +261,16 @@ export function openExecutionStore(input) {
|
|
|
227
261
|
previousDigest:current.records.at(-1)?.digest??null};
|
|
228
262
|
const {revision:oldRevision,...data}=current;
|
|
229
263
|
const next=validateState(seal({...data,records:[...current.records,{...record,digest:digest(record)}]}),options);
|
|
230
|
-
|
|
264
|
+
const {storageEncoding,...physicalData}=physicalState;
|
|
265
|
+
const encodedSequences=[...(storageEncoding?.records??[]),
|
|
266
|
+
...(Buffer.byteLength(JSON.stringify(v.payload))>JOURNAL_PAYLOAD_LIMIT?[record.seq]:[])];
|
|
267
|
+
const physicalNext={...physicalData,records:[...physicalState.records,{...record,payload:physicalPayload,digest:digest(record)}],
|
|
268
|
+
revision:next.revision,...(encodedSequences.length?{storageEncoding:{version:1,kind:'cm-fix-review-payloads-v1',records:encodedSequences}}:{})};
|
|
269
|
+
try{
|
|
270
|
+
guard();atomicState(dir,next,physicalNext);
|
|
271
|
+
// A new physical state must take the full validation path on next read.
|
|
272
|
+
validatedBytes=null;validatedLogical=null;
|
|
273
|
+
}catch(error){poisoned=true;throw error;}
|
|
231
274
|
return next;
|
|
232
275
|
};
|
|
233
276
|
return Object.freeze({snapshot,append,close});
|
|
@@ -3,6 +3,7 @@ import {captureReviewBaseline,compareReviewInventoryToBaseline,readReviewBaselin
|
|
|
3
3
|
import {verifySpecificationMaterial} from './specification-material.mjs';
|
|
4
4
|
import {CONFIG_FILENAMES} from '../../../scripts/cm-workflow-config.mjs';
|
|
5
5
|
import {digest,hex,id,json,need,shape} from './effect-contract.mjs';
|
|
6
|
+
import {assertSnapshotBoundaries} from './integration-snapshots.mjs';
|
|
6
7
|
|
|
7
8
|
const inventoryFile=({contentBase64,...metadata})=>metadata;
|
|
8
9
|
const sameFile=(a,b)=>digest(a===null?null:inventoryFile(a))===digest(b===null?null:inventoryFile(b));
|
|
@@ -35,6 +36,16 @@ const compact=steps=>steps.map(({beforeFix,runId,packageDigest})=>({beforeFix,ru
|
|
|
35
36
|
// deliveries: [{runId,packages:[{pkg,reviewedAt}]}].
|
|
36
37
|
export const deliveredAfter=(item,after)=>Number.isSafeInteger(after)
|
|
37
38
|
&&Number.isSafeInteger(item.reviewedAt)&&item.reviewedAt>after;
|
|
39
|
+
// Only the runner's already-validated journal supplies this lower bound. Its
|
|
40
|
+
// first review registration is necessarily after its frozen baseline. Missing
|
|
41
|
+
// legacy evidence keeps the historical, final-review-only composition.
|
|
42
|
+
export function firstReviewAt(records,identity){
|
|
43
|
+
const row=records?.find(record=>record.payload?.type==='review-invocation-registered')?.payload;
|
|
44
|
+
const bound=(row?.binding??row?.grant)?.identity;
|
|
45
|
+
return row?.version===3&&row.protocol==='cm-task-runner'&&Number.isSafeInteger(row.registeredAt)
|
|
46
|
+
&&bound?.repositoryId===identity.repositoryId&&bound.runId===identity.runId&&bound.taskId===identity.taskId
|
|
47
|
+
&&Number.isInteger(bound.attempt)&&bound.attempt>=1?row.registeredAt:null;
|
|
48
|
+
}
|
|
38
49
|
const key=file=>file===null||file===undefined?null:`${file.sha256}:${file.mode}`;
|
|
39
50
|
const applyMeta=(state,pkg)=>{for(const change of pkg.changes){
|
|
40
51
|
if(change.after===null)state.delete(change.path);else state.set(change.path,inventoryFile(change.after));}};
|
|
@@ -130,7 +141,7 @@ export function explainReviewedDrift({root,baseline,composed,ownScope,deliveries
|
|
|
130
141
|
}
|
|
131
142
|
|
|
132
143
|
// Completed run without accepted fixes: its own reviewed composition, then drift.
|
|
133
|
-
export function explainCompletedDelivery({root,baseline,parentPackage,deliveries,after}){
|
|
144
|
+
export function explainCompletedDelivery({root,baseline,parentPackage,deliveries,after,since=null}){
|
|
134
145
|
const base=readReviewBaseline(baseline),parent=readReviewPackage(parentPackage);
|
|
135
146
|
need(parent.baseIdentity===base.baselineDigest&&parent.rootDigest===base.rootDigest
|
|
136
147
|
&&digest(parent.identity)===digest(base.identity),'fix_parent_binding_mismatch');
|
|
@@ -140,7 +151,67 @@ export function explainCompletedDelivery({root,baseline,parentPackage,deliveries
|
|
|
140
151
|
need(sameFile(expected.get(change.path)??null,change.before),'fix_before_mismatch');
|
|
141
152
|
if(change.after===null)expected.delete(change.path);else expected.set(change.path,inventoryFile(change.after));
|
|
142
153
|
}
|
|
143
|
-
|
|
154
|
+
try{
|
|
155
|
+
explainReviewedDrift({root,baseline:base,composed:[...expected.values()],ownScope:parent.scope,deliveries,after});
|
|
156
|
+
return;
|
|
157
|
+
}catch(error){
|
|
158
|
+
if(error.code!=='fix_current_code_unexplained'||base.version!==2||!Number.isSafeInteger(since)
|
|
159
|
+
||!Number.isSafeInteger(after)||since>=after)throw error;
|
|
160
|
+
// A sibling can finish while the parent is being revised. Prove the whole
|
|
161
|
+
// bounded interval from the unchanged baseline, in durable review order;
|
|
162
|
+
// never select packages or stop the chain to fit the current tree.
|
|
163
|
+
const earlier=laterSequence(deliveries,since,base.rootDigest).filter(entry=>entry.reviewedAt<after);
|
|
164
|
+
if(!earlier.length)throw error;
|
|
165
|
+
const interval=new Map(base.files.map(file=>[file.path,inventoryFile(file)]));
|
|
166
|
+
for(const entry of earlier){
|
|
167
|
+
need(entry.pkg.identity.repositoryId===parent.identity.repositoryId&&entry.pkg.identity.runId===entry.runId
|
|
168
|
+
&&entry.runId!==parent.identity.runId&&entry.pkg.identity.taskId!==parent.identity.taskId,'fix_association_unverified');
|
|
169
|
+
applyDelivery(interval,entry.pkg,strict);
|
|
170
|
+
}
|
|
171
|
+
// The parent's own reviewed scope remains authoritative, including paths
|
|
172
|
+
// that were unchanged or absent in its final package. Earlier deliveries
|
|
173
|
+
// can explain only the rest of the tree; they cannot undo a parent change.
|
|
174
|
+
const own=new Set(parent.scope);
|
|
175
|
+
for(const p of new Set([...expected.keys(),...interval.keys()]))if(!own.has(p)){
|
|
176
|
+
if(interval.has(p))expected.set(p,interval.get(p));else expected.delete(p);
|
|
177
|
+
}
|
|
178
|
+
explainReviewedDrift({root,baseline:base,composed:[...expected.values()],ownScope:parent.scope,deliveries,after});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Called only after the explicit integration evidence has authenticated each
|
|
183
|
+
// additional source in its original namespace. Never rewrite package identity
|
|
184
|
+
// or rootDigest to make it pass ordinary delivery discovery.
|
|
185
|
+
export function explainIntegratedDelivery({root,baseline,parentPackage,deliveries,after,since,sources,documents,snapshots}){
|
|
186
|
+
const base=readReviewBaseline(baseline),parent=readReviewPackage(parentPackage);
|
|
187
|
+
need(base.version===2&&parent.baseIdentity===base.baselineDigest&&parent.rootDigest===base.rootDigest
|
|
188
|
+
&&digest(parent.identity)===digest(base.identity),'fix_parent_binding_mismatch');
|
|
189
|
+
if(base.specification)verifySpecificationMaterial(base);
|
|
190
|
+
const expected=new Map(base.files.map(file=>[file.path,inventoryFile(file)]));
|
|
191
|
+
applyDelivery(expected,parent,strict);
|
|
192
|
+
const earlier=laterSequence(deliveries,since,base.rootDigest).filter(entry=>entry.reviewedAt<after);
|
|
193
|
+
if(earlier.length){
|
|
194
|
+
const interval=new Map(base.files.map(file=>[file.path,inventoryFile(file)]));
|
|
195
|
+
for(const entry of earlier)applyDelivery(interval,entry.pkg,strict);
|
|
196
|
+
const own=new Set(parent.scope);
|
|
197
|
+
for(const p of new Set([...expected.keys(),...interval.keys()]))if(!own.has(p)){
|
|
198
|
+
if(interval.has(p))expected.set(p,interval.get(p));else expected.delete(p);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// These exact transitions have their own new independent review; historical
|
|
202
|
+
// merge prose is never interpreted as approval. Parent scope is unchanged.
|
|
203
|
+
applyDelivery(expected,{changes:documents},strict);
|
|
204
|
+
const ordinary=laterSequence(deliveries,after,base.rootDigest);
|
|
205
|
+
const imported=sources.flatMap(delivery=>delivery.packages.map((item,index)=>({
|
|
206
|
+
runId:delivery.runId,index,reviewedAt:item.reviewedAt,pkg:readReviewPackage(item.pkg)})));
|
|
207
|
+
const later=[...ordinary,...imported].sort((a,b)=>a.reviewedAt-b.reviewedAt
|
|
208
|
+
||(a.runId<b.runId?-1:a.runId>b.runId?1:0)||a.index-b.index);
|
|
209
|
+
need(new Set(later.map(entry=>entry.runId+'\0'+entry.pkg.packageDigest)).size===later.length,'fix_association_unverified');
|
|
210
|
+
const tolerated=toleratedConfig(parent.scope);
|
|
211
|
+
for(const entry of later)applyDelivery(expected,entry.pkg,tolerated);
|
|
212
|
+
assertSnapshotBoundaries(snapshots,base,[parent,...earlier.map(entry=>entry.pkg),...later.map(entry=>entry.pkg)]);
|
|
213
|
+
if(snapshots)applyDelivery(expected,{changes:snapshots.files.map(file=>({path:file.path,before:null,after:file}))},strict);
|
|
214
|
+
compareCurrent({root,base,state:expected,tolerated});
|
|
144
215
|
}
|
|
145
216
|
|
|
146
217
|
// One deterministic order for a run with QA fixes, from facts fixed at
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Runs host-configured, already-authorized project checks. Commands may execute
|
|
2
2
|
// project code; specsRoot opts into Codex's native sandbox for that subprocess.
|
|
3
3
|
// Without specsRoot this preserves the existing direct host-check behavior.
|
|
4
|
+
import {signalOwnedGroup} from './process-group-exit.mjs';
|
|
5
|
+
import {beginHostStage} from './host-stage-observer.mjs';
|
|
4
6
|
import fs from 'node:fs';
|
|
5
7
|
import path from 'node:path';
|
|
6
8
|
import {spawn} from 'node:child_process';
|
|
@@ -55,6 +57,7 @@ export function createHostCheck({cwd,commands,timeoutMs=60000,specsRoot=null,out
|
|
|
55
57
|
...(signature?{signatureMatched:original.signatureMatched}:{})});continue;
|
|
56
58
|
}
|
|
57
59
|
notify({phase:'start',id:item.id});
|
|
60
|
+
const endStage=beginHostStage('check',timeoutMs);
|
|
58
61
|
const result=await new Promise(resolve=>{
|
|
59
62
|
let child;
|
|
60
63
|
try{
|
|
@@ -72,13 +75,18 @@ export function createHostCheck({cwd,commands,timeoutMs=60000,specsRoot=null,out
|
|
|
72
75
|
const match=line.trim().match(/^[^0-9A-Za-z]*(tests|suites|pass|passed|passing|fail|failed|failing|skipped|todo)\s*[:=]?\s*(\d+)\s*$/i);
|
|
73
76
|
if(match&&counts.size<8&&!counts.has(match[1].toLowerCase()))counts.set(match[1].toLowerCase(),match[2]);
|
|
74
77
|
};
|
|
75
|
-
|
|
78
|
+
// signalOwnedGroup (process-group-exit.mjs): an exited, not yet reaped command
|
|
79
|
+
// (EPERM on macOS) is stopped only once its exit is observed and a re-probe
|
|
80
|
+
// answers ESRCH; anything unproven is cleanup_failed, as before.
|
|
81
|
+
const kill=async name=>{
|
|
76
82
|
if(!Number.isInteger(child.pid)||child.pid<=0)return false;
|
|
77
|
-
try{
|
|
78
|
-
catch
|
|
83
|
+
try{return await signalOwnedGroup(child,name)==='sent';}
|
|
84
|
+
catch{failure??='cleanup_failed';return false;}
|
|
79
85
|
};
|
|
80
|
-
const clean=()=>cleanup??=(
|
|
81
|
-
|
|
86
|
+
const clean=()=>cleanup??=(async()=>{
|
|
87
|
+
if(!await kill('SIGTERM'))return;
|
|
88
|
+
await new Promise(done=>setTimeout(done,1000));await kill('SIGKILL');
|
|
89
|
+
})();
|
|
82
90
|
const stop=reason=>{failure??=reason;clean();};
|
|
83
91
|
const abort=()=>stop('cancelled');
|
|
84
92
|
signal.addEventListener('abort',abort,{once:true});
|
|
@@ -126,7 +134,7 @@ export function createHostCheck({cwd,commands,timeoutMs=60000,specsRoot=null,out
|
|
|
126
134
|
evidence:prefix+(summary.length?` (${summary.join(', ')})`:'')});
|
|
127
135
|
}
|
|
128
136
|
});
|
|
129
|
-
});
|
|
137
|
+
}).finally(endStage);
|
|
130
138
|
notify({phase:'complete',id:item.id,outcome:result.outcome,exitCode:result.exitCode});
|
|
131
139
|
need(!signal.aborted,'cancelled');
|
|
132
140
|
results.push({id:item.id,command:item.command,...result,...(signature?{signatureMatched}:{})});
|
|
@@ -18,9 +18,13 @@ import {createCodexReviewRun} from './codex-review-adapter.mjs';
|
|
|
18
18
|
import {createClaudeReviewRun} from './claude-review-adapter.mjs';
|
|
19
19
|
import {claudeWorker,claudePreflightMatches} from './worker-claude.mjs';
|
|
20
20
|
import {codexWorker,preflightMatches} from './worker-codex.mjs';
|
|
21
|
-
import {createHostWorkflowCapabilities} from './host-workflow-capabilities.mjs';
|
|
21
|
+
import {createHostWorkflowCapabilities,createImplicitQaDecision} from './host-workflow-capabilities.mjs';
|
|
22
22
|
import {resolveHostRole} from './host-role-routing.mjs';
|
|
23
23
|
import {checklistGaps} from './checklist-coverage.mjs';
|
|
24
|
+
import {readRequirementItems,splitRequirementReport} from './requirement-evidence.mjs';
|
|
25
|
+
import {replayDelivery,notReplayed} from './host-replay.mjs';
|
|
26
|
+
import {autoVerificationVerdict} from './verification-auto.mjs';
|
|
27
|
+
import {declaredTaskScope} from '../task-scope.mjs';
|
|
24
28
|
import {specsPermissionArgs} from './codex-config.mjs';
|
|
25
29
|
import {createProjectExecution} from './host-project-execution.mjs';
|
|
26
30
|
import {codeProjectPaths,codeProjectInstructionPaths,resolveCodeProjects} from './code-projects.mjs';
|
|
@@ -55,20 +59,10 @@ export const externalConversationDefinition=execution=>externalConversations.get
|
|
|
55
59
|
// requirement is satisfied. Mechanical shape is not semantic coverage.
|
|
56
60
|
export function readVerificationPrecheck(raw){
|
|
57
61
|
const value=json(raw,256*1024);shape(value,['items']);
|
|
58
|
-
const items=arrayItems(value.items);
|
|
59
|
-
need(items.length>0&&items.length<=64,'verification_precheck_invalid');
|
|
60
|
-
for(const item of items){
|
|
61
|
-
shape(item,['requirement','satisfied','evidence']);
|
|
62
|
-
need(typeof item.satisfied==='boolean','verification_precheck_invalid');
|
|
63
|
-
for(const field of ['requirement','evidence']){
|
|
64
|
-
const text=item[field];
|
|
65
|
-
need(typeof text==='string'&&text.trim().length>0&&Buffer.byteLength(text,'utf8')<=2000
|
|
66
|
-
&&!/[\x00-\x08\x0b-\x1f]/.test(text),'verification_precheck_invalid');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
62
|
+
const items=readRequirementItems(arrayItems(value.items));
|
|
69
63
|
return freeze({satisfied:items.every(item=>item.satisfied===true),
|
|
70
64
|
unsatisfied:items.filter(item=>item.satisfied!==true).map(item=>item.requirement),
|
|
71
|
-
evidence:items.map(item=>item.evidence).join('\n')});
|
|
65
|
+
evidence:items.map(item=>item.evidence).join('\n'),items});
|
|
72
66
|
}
|
|
73
67
|
|
|
74
68
|
// The delivered evidence usually lives in the scope files (a walkthrough
|
|
@@ -107,14 +101,25 @@ export const REVIEW_BOUND_MARGIN_MS=60000;
|
|
|
107
101
|
export const reviewRaceTimeout=(outerTimeoutMs,reviewTimeoutMs)=>Math.max(outerTimeoutMs,reviewTimeoutMs+REVIEW_BOUND_MARGIN_MS);
|
|
108
102
|
export function createConversationExecution(definition,hostContextId,bridge,review=null,reservedReviewAttempt=null,workflow=null,allowQa=false,runtime='codex',options={}){
|
|
109
103
|
definition=json(definition);workflow=workflow===null?null:json(workflow);options=json(options);
|
|
110
|
-
shape(options,[...['originalHostContextId','protection','batchWorkflowsDigest','qaLogHome','bootstrap','providerDevelopment','externalModels','reviewerRuntime','reviewRuntime','parallelMember','verificationPrecheck','executionPolicy','controlPolicy'].filter(key=>Object.hasOwn(options,key))]);
|
|
104
|
+
shape(options,[...['originalHostContextId','protection','batchWorkflowsDigest','qaLogHome','bootstrap','providerDevelopment','externalModels','reviewerRuntime','reviewRuntime','parallelMember','soloMember','verificationPrecheck','executionPolicy','controlPolicy','memberDevelopment'].filter(key=>Object.hasOwn(options,key))]);
|
|
111
105
|
const controlPolicy=options.controlPolicy?readControlPolicy(options.controlPolicy):null;
|
|
112
106
|
need(!Object.hasOwn(options,'verificationPrecheck')||typeof options.verificationPrecheck==='boolean','invalid_input');
|
|
113
107
|
const executionPolicy=options.executionPolicy?readExecutionPolicy(options.executionPolicy):null;
|
|
114
108
|
const parallelMember=options.parallelMember??false;need(typeof parallelMember==='boolean','invalid_input');
|
|
109
|
+
// soloMember: a worktree member alone in its group (batch-plan.mjs worktree_all). It
|
|
110
|
+
// keeps the worktree review and bridge of a member but not the deferred QA: only a
|
|
111
|
+
// member developed alongside others defers its N6 to the feature's final task.
|
|
112
|
+
const soloMember=options.soloMember??false;need(typeof soloMember==='boolean'&&(!soloMember||parallelMember),'invalid_input');
|
|
113
|
+
const deferMemberQa=parallelMember&&!soloMember;
|
|
115
114
|
const provider=options.providerDevelopment??null;
|
|
115
|
+
// memberDevelopment 'session': a batch execution table (batch-plan.mjs) has the
|
|
116
|
+
// current session develop this member, so it never carries providerDevelopment, even
|
|
117
|
+
// under a provider policy; every other member of such a policy carries it.
|
|
118
|
+
need(!Object.hasOwn(options,'memberDevelopment')||options.memberDevelopment==='session','invalid_input');
|
|
119
|
+
const sessionMember=options.memberDevelopment==='session';
|
|
120
|
+
need(!sessionMember||!provider,'invalid_arguments');
|
|
116
121
|
if(controlPolicy){
|
|
117
|
-
need((controlPolicy.development==='provider')===Boolean(provider),'invalid_arguments');
|
|
122
|
+
need((controlPolicy.development==='provider'&&!sessionMember)===Boolean(provider),'invalid_arguments');
|
|
118
123
|
need(controlPolicy.bootstrap!=='write'||Boolean(options.bootstrap),'invalid_arguments');
|
|
119
124
|
need(controlPolicy.qa!=='run'||workflow?.qa!=null,'invalid_arguments');
|
|
120
125
|
need(!options.bootstrap||controlPolicy.bootstrap==='write','invalid_arguments');
|
|
@@ -165,7 +170,7 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
165
170
|
// Keep the unverified native permissions boundary intact for this first host
|
|
166
171
|
// slice too. A transport is not physical protection of nested specs.
|
|
167
172
|
need(protection||!definition.specsDir.startsWith(definition.codeProject+path.sep),'nested_specs_protection_required');
|
|
168
|
-
const configuration={kind:'cm-current-conversation-v1',...(parallelMember?{parallelMember}:{}),definitionDigest:digest(definition),hostContextId:durableHostContextId,
|
|
173
|
+
const configuration={kind:'cm-current-conversation-v1',...(parallelMember?{parallelMember}:{}),...(soloMember?{soloMember}:{}),definitionDigest:digest(definition),hostContextId:durableHostContextId,
|
|
169
174
|
...(controlPolicy?{controlPolicy}:{}),
|
|
170
175
|
...(runtime==='claude'?{runtime}:{}),
|
|
171
176
|
...(options.reviewRuntime===undefined?{}:{reviewRuntime:options.reviewRuntime}),
|
|
@@ -186,6 +191,7 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
186
191
|
// Preserve P4a's unauthorizable placeholder bytes for existing unconfigured runs.
|
|
187
192
|
const reviewProvider=review?reviewerRuntime:'codex', adapterId=`${reviewProvider}-review-adapter`;
|
|
188
193
|
// Reread role declarations at each boundary; never switch a bound invocation.
|
|
194
|
+
// A session member's review (bound pair checked at construction) is rechecked too.
|
|
189
195
|
// onWorker (provider development, task-runner.mjs) journals the worker's
|
|
190
196
|
// identity right before and right after the spawn; a journal failure kills
|
|
191
197
|
// the new process group like a refused role route does.
|
|
@@ -206,17 +212,40 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
206
212
|
};
|
|
207
213
|
};
|
|
208
214
|
const used=new Set();
|
|
215
|
+
// Host replay (host-replay.mjs) restores the task baseline the runner hands the
|
|
216
|
+
// gate (control.baselineSnapshot). Each attempt's per-requirement report is split
|
|
217
|
+
// off the developer value before it is validated or journaled; it lives in memory
|
|
218
|
+
// only, so a resumed process without it reports the report as missing.
|
|
219
|
+
const requirementReports=new Map();
|
|
220
|
+
const reportKey=identity=>`${identity.taskId}:${identity.attempt}`;
|
|
221
|
+
const replayable=projectExecution!==null&&!definition.codeProjects;
|
|
222
|
+
const declaredTests=taskId=>{try{return declaredTaskScope(definition.specsDir,definition.feature,taskId)?.tests??[];}catch{return [];}};
|
|
223
|
+
// Only a protected single-root run has host checks to replay; any other run
|
|
224
|
+
// keeps its gate request and handoff exactly as before (facts null).
|
|
225
|
+
const hostRuns=(request,control)=>replayable?replayDelivery({codeProject:definition.codeProject,specsDir:definition.specsDir,
|
|
226
|
+
snapshot:control.baselineSnapshot??null,scope:request.scope??definition.scope,
|
|
227
|
+
tests:declaredTests(request.identity.taskId),checkCommands:protection.checkCommands,timeoutMs:protection.timeoutMs,
|
|
228
|
+
identity:request.identity,greenChecks:request.checks,signal:control.signal}):null;
|
|
209
229
|
// The gate is opt-in: without it the flow is byte-for-byte what it was.
|
|
210
230
|
// The runner contract is exactly {satisfied}. Which requirements failed is
|
|
211
231
|
// what the operator needs to act on, so it goes to this process's stderr the
|
|
212
232
|
// same way other host diagnostics do, not into the runner state.
|
|
213
|
-
|
|
214
|
-
|
|
233
|
+
// A v2 policy may enable the gate durably (it is part of the run fingerprint);
|
|
234
|
+
// the legacy launch flag keeps working for runs created without it.
|
|
235
|
+
// auto: the host answers from the developer's report and its own runs
|
|
236
|
+
// (verification-auto.mjs); precheck: the session answers, seeing the host runs.
|
|
237
|
+
const gateMode=controlPolicy?.verification==='auto'?'auto'
|
|
238
|
+
:options.verificationPrecheck===true||controlPolicy?.verification==='precheck'?'precheck':null;
|
|
239
|
+
const verificationGate=gateMode?async(request,control)=>{
|
|
240
|
+
const facts=await hostRuns(request,control);
|
|
241
|
+
const verdict=gateMode==='auto'?autoVerificationVerdict({report:requirementReports.get(reportKey(request.identity))??null,
|
|
242
|
+
facts:facts??notReplayed(definition.codeProjects?'multi_root':'no_host_checks',request.checks)})
|
|
243
|
+
:readVerificationPrecheck(await bridge.call('verification_precheck',
|
|
215
244
|
{...request,codeProject:definition.codeProject,feature:definition.feature,
|
|
216
|
-
scope:definition.scope},control.signal));
|
|
245
|
+
scope:request.scope??definition.scope,...(facts?{hostRuns:facts}:{})},control.signal));
|
|
217
246
|
if(!verdict.satisfied)try{
|
|
218
247
|
process.stderr.write(JSON.stringify({diagnostic:'verification_precheck_failed',
|
|
219
|
-
task:request.identity.taskId,attempt:request.identity.attempt,
|
|
248
|
+
task:request.identity.taskId,attempt:request.identity.attempt,mode:gateMode,
|
|
220
249
|
unsatisfied:verdict.unsatisfied})+'\n');
|
|
221
250
|
}catch{/* diagnostics never change the verdict */}
|
|
222
251
|
// Advisory only. An enumerated list in the task text whose entries are not
|
|
@@ -226,12 +255,16 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
226
255
|
try{
|
|
227
256
|
const gaps=checklistGaps([request.description,request.verification]
|
|
228
257
|
.filter(text=>typeof text==='string').join('\n'),
|
|
229
|
-
[verdict.evidence
|
|
258
|
+
[verdict.evidence??(verdict.items??[]).map(item=>item.evidence).join('\n'),
|
|
259
|
+
deliveredText(definition.codeProject,request.scope??definition.scope)].join('\n'));
|
|
230
260
|
if(gaps.length>0)process.stderr.write(JSON.stringify({diagnostic:'checklist_coverage',
|
|
231
261
|
task:request.identity.taskId,attempt:request.identity.attempt,advisory:true,
|
|
232
262
|
gaps:gaps.map(gap=>({total:gap.total,missing:gap.missing}))})+'\n');
|
|
233
263
|
}catch{/* diagnostics never change the verdict */}
|
|
234
|
-
|
|
264
|
+
// The answered items travel to the runner, which binds them into the host
|
|
265
|
+
// handoff the reviewer reads; a failed gate halts before any handoff exists.
|
|
266
|
+
// The host record travels as its own handoff entry (host-replay.mjs), never inside the items.
|
|
267
|
+
return verdict.satisfied?{satisfied:true,items:verdict.items,...(facts?{hostRecord:facts}:{})}:{satisfied:false};
|
|
235
268
|
}:null;
|
|
236
269
|
const outerTimeoutMs=provider?protection.timeoutMs:1800000;
|
|
237
270
|
const progress=(request,control,stage,run,selectedRuntime=runtime)=>withHostProgress({definition,
|
|
@@ -240,7 +273,8 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
240
273
|
...(verificationGate?{verificationGate:(request,control)=>progress(request,control,'verifying',()=>verificationGate(request,control))}:{}),
|
|
241
274
|
...(bootstrap?{bootstrap}:{}),
|
|
242
275
|
...(provider&&!controlPolicy?{developmentAttempt:provider.attempt}:{}),
|
|
243
|
-
...(workflow?createHostWorkflowCapabilities({definition,configuration:workflow,bridge,allowQa,runtime,protectedExecution:protection!==null,bootstrap,parallelMember,controlPolicy})
|
|
276
|
+
...(workflow?createHostWorkflowCapabilities({definition,configuration:workflow,bridge,allowQa,runtime,protectedExecution:protection!==null,bootstrap,parallelMember:deferMemberQa,controlPolicy})
|
|
277
|
+
:controlPolicy?createImplicitQaDecision({definition,bridge,parallelMember:deferMemberQa,controlPolicy}):{}),
|
|
244
278
|
...(options.qaLogHome?{qaLogHome:options.qaLogHome}:{}),
|
|
245
279
|
developer:{provider:coderRuntime,requestedModel:provider?.model??'current-session',contextId:author,run:async(request,control)=>{
|
|
246
280
|
const bound=(coderRuntime==='codex'?readCodexDeveloperRequest:readClaudeDeveloperRequest)(request);
|
|
@@ -256,10 +290,18 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
256
290
|
cwd:definition.codeProject,model:provider.model,...(externalModels?{effort:provider.effort}:{}),timeoutMs:protection.timeoutMs,
|
|
257
291
|
...(coderRuntime==='codex'?{specsRoot:definition.specsDir}:{}),
|
|
258
292
|
spawnProcess:dispatchSpawn('coder',bound.identity,control.signal,typeof control.onWorker==='function'?control.onWorker:null)}):null;
|
|
293
|
+
const splitReport=response=>{
|
|
294
|
+
if(response?.status!=='succeeded')return response;
|
|
295
|
+
const split=splitRequirementReport(response.value);
|
|
296
|
+
requirementReports.set(reportKey(bound.identity),split.items);
|
|
297
|
+
if(split.items==='invalid')try{process.stderr.write(JSON.stringify({diagnostic:'requirement_report_invalid',
|
|
298
|
+
task:bound.identity.taskId,attempt:bound.identity.attempt,problem:split.problem})+'\n');}catch{/* diagnostics never change the result */}
|
|
299
|
+
return {...response,value:split.value};
|
|
300
|
+
};
|
|
259
301
|
const worker=async({prompt})=>{
|
|
260
302
|
if(provider&&coderRuntime==='codex'){
|
|
261
303
|
if(documentationPaths.length)prompt='Synchronize approved documentation inside this invocation: '+JSON.stringify(documentationPaths)+'\n'+prompt;
|
|
262
|
-
const response=await processWorker({prompt},control);
|
|
304
|
+
const response=splitReport(await processWorker({prompt},control));
|
|
263
305
|
developerLog?.complete(developerUsage??{usage_state:'unavailable'},response.status==='succeeded'?'success':response.status==='cancelled'?'cancelled':'error');
|
|
264
306
|
return response;
|
|
265
307
|
}
|
|
@@ -269,10 +311,10 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
269
311
|
if(!parallelMember&&documentationPaths.length&&isFinalCmAiTask({specsDir:definition.specsDir,codeProject:definition.codeProject,
|
|
270
312
|
feature:definition.feature,taskId:bound.identity.taskId,featureSelection:definition.featureSelection?.feature}))prompt+=' Include necessary documentation synchronization in the same edits: '+JSON.stringify(documentationPaths);
|
|
271
313
|
}
|
|
272
|
-
const response=provider?await processWorker({prompt:prompt+'\n'+JSON.stringify({editMode:'protected-text-v1',expected})},control):json(await bridge.call('develop',{request:bound,prompt,codeProject:definition.codeProject,route,
|
|
314
|
+
const response=splitReport(provider?await processWorker({prompt:prompt+'\n'+JSON.stringify({editMode:'protected-text-v1',expected})},control):json(await bridge.call('develop',{request:bound,prompt,codeProject:definition.codeProject,route,
|
|
273
315
|
...(definition.codeProjects?{codeProjects:resolveCodeProjects(definition.codeProject,definition.codeProjects),
|
|
274
316
|
projectInstructions:definition.codeProjects.map(root=>({codeProject:root,files:readProjectInstructionContext(root)}))}:{}),
|
|
275
|
-
...(protection?{editMode:'protected-text-v1',expected}: {})},control.signal));
|
|
317
|
+
...(protection?{editMode:'protected-text-v1',expected}: {})},control.signal)));
|
|
276
318
|
if(provider)developerLog?.complete(developerUsage??{usage_state:'unavailable'},response.status==='succeeded'?'success':response.status==='cancelled'?'cancelled':'error');
|
|
277
319
|
if(response.status==='succeeded'){
|
|
278
320
|
const edits=[];
|
|
@@ -331,7 +373,7 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
331
373
|
if(check)return check(request,control);
|
|
332
374
|
const route=resolveHostRole({definition,identity:request.identity,role:'tester',signal:control.signal,runtime});
|
|
333
375
|
return bridge.call('check',{...request,codeProject:definition.codeProject,
|
|
334
|
-
scope:definition.scope,requirements:definition.requirements,route},control.signal);
|
|
376
|
+
scope:request.scope??definition.scope,requirements:definition.requirements,route},control.signal);
|
|
335
377
|
}),
|
|
336
378
|
// The process adapter records observed reviewer events. Preflight checks capability.
|
|
337
379
|
reviewers:[{id:'reviewer',adapterId,provider:reviewProvider,requestedModel:reviewOptions.model,
|
|
@@ -339,7 +381,7 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
339
381
|
run:(request,control)=>{
|
|
340
382
|
need(review!==null,'review_configuration_required');
|
|
341
383
|
let observedUsage=null;const usageLog=executionPolicy?createNativeUsageLog({definition,request,provider:reviewerRuntime,role:'reviewer'}):null;
|
|
342
|
-
const selectedOptions={...reviewOptions,...(usageLog?{onUsageClaim:()=>usageLog.claimed(),onUsage:value=>{observedUsage=value;}}:{}),...(provider?{spawnProcess:dispatchSpawn('reviewer',request.identity,control.signal)}:{})};
|
|
384
|
+
const selectedOptions={...reviewOptions,...(usageLog?{onUsageClaim:()=>usageLog.claimed(),onUsage:value=>{observedUsage=value;}}:{}),...(provider||sessionMember&&options.reviewRuntime!==undefined?{spawnProcess:dispatchSpawn('reviewer',request.identity,control.signal)}:{})};
|
|
343
385
|
return progress(request,control,'review_starting',async observation=>{
|
|
344
386
|
const observedControl={...control,onEvent:event=>{
|
|
345
387
|
control.onEvent(event);
|