@aibyzero/cm-workflow 0.17.1 → 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 +23 -0
- package/CHANGELOG.md +224 -0
- package/README.md +14 -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 +11 -0
- package/docs/cm-control-policy-v2.md +127 -9
- package/docs/installation.md +310 -4
- package/docs/js-workflow-control.md +150 -15
- 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 +83 -14
- 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 +21 -4
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +114 -11
- 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 +11 -5
- 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 +1 -1
- 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 +9 -2
- 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 +242 -39
- 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 +11 -5
- 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 +3 -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 +6 -5
- 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 +471 -57
- 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 +14 -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.mjs +73 -17
- package/scripts/cm-ai-drive.test.mjs +34 -2
- package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
- package/scripts/cm-ai-host.mjs +60 -19
- 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 +16 -1
- 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-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 +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-review-diagnostics.test.mjs +235 -0
- package/scripts/cm-claude-review-stream.test.mjs +13 -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-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 +4 -3
- 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-qa-executor.test.mjs +77 -0
- package/scripts/cm-host-replay.test.mjs +176 -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 +575 -59
- 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 +45 -1
- 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 +1 -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-summary.test.mjs +24 -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 +1 -1
- 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-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/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 +56 -16
- 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
|
@@ -158,3 +158,31 @@ test('N6 registered critical paths use existing workflow QA seam and fingerprint
|
|
|
158
158
|
await opens(f,'resume',conversation(f,syntax,registry));
|
|
159
159
|
await assert.rejects(opens(f,'resume',conversation(f,syntax,{payment:['src/billing/**']})),{code:'fingerprint_mismatch'});
|
|
160
160
|
});
|
|
161
|
+
|
|
162
|
+
test('N6 a one-member worktree group keeps the fixed checkpoints; only a member alongside others defers',async()=>{
|
|
163
|
+
const f=fixture();userRuntimes('codex-codes');
|
|
164
|
+
fs.writeFileSync(path.join(f.specsDir,f.feature,'tasks.md'),'- [x] T-002: fixture\n');
|
|
165
|
+
const member=options=>createConversationExecution(f.definition,'host-session-1',
|
|
166
|
+
{call:async name=>{assert.equal(name,'qa_assess');return {confirmed:true};}},null,null,
|
|
167
|
+
{qa:{commands:syntax,environment,criticalPaths:{authentication:['a.mjs']}},documentationPaths:[],applicableAgentFiles:[]},true,'claude',options);
|
|
168
|
+
const binding={specsDir:f.specsDir,codeProject:f.codeProject,feature:f.feature,identity,packageDigest:'a'.repeat(64),
|
|
169
|
+
changedFiles:{paths:['a.mjs'],source:'review_package'}};
|
|
170
|
+
const decide=execution=>execution.qaDecisionProvider.decide(binding,new AbortController().signal);
|
|
171
|
+
// Members developed together: unchanged configuration and the deferred decision.
|
|
172
|
+
const shared=member({parallelMember:true});
|
|
173
|
+
assert.equal(shared.configuration.parallelMember,true);assert.equal(Object.hasOwn(shared.configuration,'soloMember'),false);
|
|
174
|
+
assert.deepEqual([(await decide(shared)).status,(await decide(shared)).reason],['skipped','parallel_member_deferred']);
|
|
175
|
+
// Alone in its worktree: the ordinary decision, here a registered authentication path.
|
|
176
|
+
const solo=member({parallelMember:true,soloMember:true});
|
|
177
|
+
assert.equal(solo.configuration.soloMember,true);
|
|
178
|
+
const decision=await decide(solo);
|
|
179
|
+
assert.equal(decision.status,'triggered');assert.match(decision.reason,/authentication/);
|
|
180
|
+
assert.throws(()=>member({soloMember:true}),{code:'invalid_input'});
|
|
181
|
+
// The flag is part of the run fingerprint: a run cannot switch between the two on resume.
|
|
182
|
+
const g=fixture(),run=options=>createConversationExecution(g.definition,'host-session-1',{call:async()=>{throw new Error('not dispatched');}},
|
|
183
|
+
null,null,{qa:{commands:syntax,environment},documentationPaths:[],applicableAgentFiles:[]},true,'claude',options);
|
|
184
|
+
const selection={parallelSelection:{version:1,group:['T-002']}};
|
|
185
|
+
await opens(g,'create',run({parallelMember:true,soloMember:true}),selection);
|
|
186
|
+
await opens(g,'resume',run({parallelMember:true,soloMember:true}),selection);
|
|
187
|
+
await assert.rejects(opens(g,'resume',run({parallelMember:true}),selection),{code:'fingerprint_mismatch'});
|
|
188
|
+
});
|
|
@@ -41,7 +41,7 @@ if(mode==='exit65')process.exit(65);
|
|
|
41
41
|
if(mode!=='ready')process.exit(1);
|
|
42
42
|
`;
|
|
43
43
|
|
|
44
|
-
function fixture(t,{browser=false}={}){
|
|
44
|
+
function fixture(t,{browser=false,cleanup=[]}={}){
|
|
45
45
|
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-qa-rerun-')));
|
|
46
46
|
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
47
47
|
const codeProject=path.join(root,'code'),specsDir=path.join(root,'specs'),feature='1.work';
|
|
@@ -52,7 +52,7 @@ function fixture(t,{browser=false}={}){
|
|
|
52
52
|
if(browser)fs.writeFileSync(path.join(specsDir,feature,'test-cases.json'),JSON.stringify({schemaVersion:'1.0',feature:'work',
|
|
53
53
|
cases:Array.from({length:browser===true?1:browser},(_,index)=>({id:`TC-00${index+1}`,origin:'generated',kind:'browser',
|
|
54
54
|
blocking:true,acIds:['AC-001'],taskIds:['T-001'],title:'four tabs',
|
|
55
|
-
preconditions:['UI test'],steps:['launch on simulator'],expected:['four tabs visible'],cleanup
|
|
55
|
+
preconditions:['UI test'],steps:['launch on simulator'],expected:['four tabs visible'],cleanup}))}));
|
|
56
56
|
const manifest=buildManifest(specsDir);
|
|
57
57
|
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],specFiles:manifest,
|
|
58
58
|
...(browser?{testCases:manifest.filter(item=>item.path.endsWith('/test-cases.json'))}:{})}));
|
|
@@ -249,6 +249,40 @@ test('#13 a host-declared BLOCKED simulator case re-runs on unchanged code with
|
|
|
249
249
|
assert.deepEqual(testRuns(f,'complete').map(row=>row.result),['BLOCKED','PASS']);
|
|
250
250
|
});
|
|
251
251
|
|
|
252
|
+
// A case whose contract requires cleanup, answered PASS without completing it, is
|
|
253
|
+
// BLOCKED for cleanup by the host (blocked_reason in the durable case row). A
|
|
254
|
+
// completed round reruns it like a failed cleanup; a downgraded FAIL never does.
|
|
255
|
+
test('#13 a PASS that skipped the required cleanup re-runs on unchanged code with --rerun-blocked-qa',POSIX,async t=>{
|
|
256
|
+
const f=fixture(t,{browser:true,cleanup:['remove the seeded fixture']}),workflow=f.workflow('workflow',probeQa({environment:simulator}));
|
|
257
|
+
const evidence=path.join(f.specsDir,'.reviews','tc-001.png');
|
|
258
|
+
const answer=(verdict,cleanup)=>row=>{fs.writeFileSync(evidence,'png');
|
|
259
|
+
return {verdict,evidence:[evidence],environment:row.payload.environment,cleanup};};
|
|
260
|
+
const first=done(await launch(f,{mode:'create',workflow,extra:['--browser-qa','available'],answers:{qa_browser:answer('PASS','not_needed')}}));
|
|
261
|
+
assert.equal(first.code,'qa_result_blocked',JSON.stringify(first));
|
|
262
|
+
const blocked=testRuns(f,'case_blocked');
|
|
263
|
+
assert.equal(blocked.length,1);assert.equal(blocked[0].blocked_reason,'cleanup');assert.equal(blocked[0].answered_verdict,'PASS');
|
|
264
|
+
const rerun=done(await launch(f,{workflow,extra:['--browser-qa','available','--rerun-blocked-qa'],answers:{qa_browser:answer('PASS','completed')}}));
|
|
265
|
+
assert.equal(rerun.state,'run_done',JSON.stringify(rerun));
|
|
266
|
+
const superseded=testRuns(f,'superseded');
|
|
267
|
+
assert.equal(superseded.length,1);assert.equal(superseded[0].reason,'host_evidence_problem');
|
|
268
|
+
assert.deepEqual(superseded[0].blocked_cases,['TC-001']);
|
|
269
|
+
assert.deepEqual(testRuns(f,'complete').map(row=>row.result),['BLOCKED','PASS']);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
test('#13 a FAIL the host downgraded for a skipped cleanup still refuses --rerun-blocked-qa',POSIX,async t=>{
|
|
273
|
+
const f=fixture(t,{browser:true,cleanup:['remove the seeded fixture']}),workflow=f.workflow('workflow',probeQa({environment:simulator}));
|
|
274
|
+
const first=done(await launch(f,{mode:'create',workflow,extra:['--browser-qa','available'],
|
|
275
|
+
answers:{qa_browser:row=>{const evidence=path.join(f.specsDir,'.reviews','tc-001.png');fs.writeFileSync(evidence,'png');
|
|
276
|
+
return {verdict:'FAIL',evidence:[evidence],environment:row.payload.environment,cleanup:'not_needed'};}}}));
|
|
277
|
+
assert.equal(first.code,'qa_result_blocked',JSON.stringify(first));
|
|
278
|
+
const blocked=testRuns(f,'case_blocked');
|
|
279
|
+
assert.equal(blocked[0].blocked_reason,'cleanup');assert.equal(blocked[0].answered_verdict,'FAIL');
|
|
280
|
+
const before=f.rows().length;
|
|
281
|
+
const rerun=done(await launch(f,{workflow,extra:['--browser-qa','available','--rerun-blocked-qa'],answers:{qa_browser:'IGNORE'}}));
|
|
282
|
+
assert.equal(rerun.code,'qa_rerun_not_blocked_by_evidence',JSON.stringify(rerun));
|
|
283
|
+
assert.equal(f.rows().length,before);assert.equal(testRuns(f,'superseded').length,0);
|
|
284
|
+
});
|
|
285
|
+
|
|
252
286
|
// Q14: rounds ended by a host or environment gap (here a killed command) do not
|
|
253
287
|
// count toward the three-round budget, but at most two are given back per run.
|
|
254
288
|
test('#13 an unavailable QA command (killed, no exit code) re-runs; host-caused rounds give back at most two',POSIX,async t=>{
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
|
|
4
|
+
import {REQUIREMENT_EVIDENCE_PREFIX,REQUIREMENT_EVIDENCE_LIMIT,readRequirementItems,encodeRequirementEvidence,
|
|
5
|
+
readRequirementEvidence} from '../runtime/js/cm-ai/requirement-evidence.mjs';
|
|
6
|
+
import {readVerificationPrecheck} from '../runtime/js/cm-ai/host-conversation-execution.mjs';
|
|
7
|
+
import {buildReviewPrompt} from '../runtime/js/cm-ai/codex-review-adapter.mjs';
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
|
|
10
|
+
const identity={repositoryId:'evidence-fixture',runId:'evidence-run',taskId:'T-001',attempt:2};
|
|
11
|
+
const item=(requirement,satisfied,evidence)=>({requirement,satisfied,evidence});
|
|
12
|
+
|
|
13
|
+
test('satisfied answers encode to one handoff entry bound to the task attempt',()=>{
|
|
14
|
+
const entry=encodeRequirementEvidence({identity,items:[item('记录实现前基线',true,'tests 49 / pass 49'),
|
|
15
|
+
item('列出 undoSnapshot 全部出现位置',true,'src/app.js:12, 40, 88')]});
|
|
16
|
+
assert.ok(entry.startsWith(REQUIREMENT_EVIDENCE_PREFIX));
|
|
17
|
+
const record=readRequirementEvidence(entry);
|
|
18
|
+
assert.deepEqual(record.identity,identity);
|
|
19
|
+
assert.deepEqual(record.items,[{requirement:'记录实现前基线',evidence:'tests 49 / pass 49'},
|
|
20
|
+
{requirement:'列出 undoSnapshot 全部出现位置',evidence:'src/app.js:12, 40, 88'}]);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('an unsatisfied answer never becomes reviewable evidence',()=>{
|
|
24
|
+
assert.throws(()=>encodeRequirementEvidence({identity,items:[item('a',true,'b'),item('c',false,'d')]}),{code:'invalid_result'});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('the serialized answer set is bounded below the handoff limit',()=>{
|
|
28
|
+
const near=Math.floor(REQUIREMENT_EVIDENCE_LIMIT/2000)+2;
|
|
29
|
+
const big=Array.from({length:near},(_,index)=>item(`要求 ${index}`,true,'e'.repeat(1990)));
|
|
30
|
+
assert.throws(()=>readRequirementItems(big),{code:'verification_precheck_invalid'});
|
|
31
|
+
assert.throws(()=>readVerificationPrecheck({items:big}),{code:'verification_precheck_invalid'});
|
|
32
|
+
const fits=Array.from({length:20},(_,index)=>item(`要求 ${index}`,true,'e'.repeat(1990)));
|
|
33
|
+
assert.equal(readVerificationPrecheck({items:fits}).items.length,20);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('a tampered or malformed entry is rejected',()=>{
|
|
37
|
+
const entry=encodeRequirementEvidence({identity,items:[item('a',true,'b')]});
|
|
38
|
+
for(const bad of [entry.replace(REQUIREMENT_EVIDENCE_PREFIX,'cm-other: '),
|
|
39
|
+
entry.replace('"version":1','"version":2'),entry.replace('"evidence":"b"','"evidence":""'),
|
|
40
|
+
entry.replace('"attempt":2','"attempt":3'),REQUIREMENT_EVIDENCE_PREFIX+'{not json',
|
|
41
|
+
entry.replace('}]}',',"satisfied":true}]}')])
|
|
42
|
+
assert.throws(()=>readRequirementEvidence(bad),{code:'invalid_input'},bad);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('the precheck verdict returns the validated items for the runner',()=>{
|
|
46
|
+
const verdict=readVerificationPrecheck({items:[item('a',true,'b')]});
|
|
47
|
+
assert.deepEqual(verdict.items,[item('a',true,'b')]);
|
|
48
|
+
assert.ok(Object.isFrozen(verdict.items)&&Object.isFrozen(verdict.items[0]));
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('the reviewer is told how to treat developer-reported requirement evidence',()=>{
|
|
52
|
+
const source=fs.readFileSync(new URL('../runtime/js/cm-ai/codex-review-adapter.mjs',import.meta.url),'utf8');
|
|
53
|
+
const instructions=/const INSTRUCTIONS=`([\s\S]*?)`;/.exec(source)[1];
|
|
54
|
+
assert.match(instructions,/cm-requirement-evidence-v1:/);
|
|
55
|
+
assert.match(instructions,/developer's own record, not host-verified fact/);
|
|
56
|
+
assert.match(instructions,/do not request changes or block solely because such a record cannot be re-executed/);
|
|
57
|
+
assert.equal(typeof buildReviewPrompt,'function');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('the runner binds a satisfied gate into the host handoff and resets it per gate run',()=>{
|
|
61
|
+
const source=fs.readFileSync(new URL('../runtime/js/cm-ai/task-runner.mjs',import.meta.url),'utf8');
|
|
62
|
+
const body=/async function verificationSatisfied\(checks\) \{([\s\S]*?)\n \}/.exec(source)[1];
|
|
63
|
+
assert.match(body,/^\s*requirementEvidence=null;/);
|
|
64
|
+
assert.match(source,/\.\.\.\(requirementEvidence===null\?\[\]:\[requirementEvidence\]\)/);
|
|
65
|
+
});
|
|
@@ -8,7 +8,7 @@ import os from 'node:os';
|
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import {EventEmitter} from 'node:events';
|
|
10
10
|
import {PassThrough} from 'node:stream';
|
|
11
|
-
import {spawnSync} from 'node:child_process';
|
|
11
|
+
import {spawn,spawnSync} from 'node:child_process';
|
|
12
12
|
import {fileURLToPath} from 'node:url';
|
|
13
13
|
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
14
14
|
import {projectedRunnerStatus} from '../runtime/js/cm-ai/durable-runner-state.mjs';
|
|
@@ -22,6 +22,7 @@ import {inspectProviderReview,inspectProviderReviewFailure} from '../runtime/js/
|
|
|
22
22
|
import {buildReviewPrompt,VERDICT_RULES} from '../runtime/js/cm-ai/codex-review-adapter.mjs';
|
|
23
23
|
import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
24
24
|
import {isSupportedExecutionPlatform} from '../runtime/js/cm-ai/execution-platform.mjs';
|
|
25
|
+
import {rateLimitRetryEligible} from '../runtime/js/cm-ai/drive-rate-limit.mjs';
|
|
25
26
|
import {guardFixtureSource,killFixtureProcesses} from './fixtures/process-cleanup.mjs';
|
|
26
27
|
|
|
27
28
|
// Native V3 runner fixtures require Node 24.14+ on macOS/Linux. Preserve the
|
|
@@ -108,9 +109,9 @@ function fixture(t,{reviewTimeoutMs=null}={}){
|
|
|
108
109
|
fs.writeFileSync(file,JSON.stringify({config:'run.json',mode:'create',hostContext:'review-host-a',runtime:'claude',
|
|
109
110
|
permissions:['--review-config','review.json'],answers:'answers',
|
|
110
111
|
checks:[{id:'syntax',command:[process.execPath,'--check','target.mjs']}],...extra}));return file;};
|
|
111
|
-
const drive=(file,operation)=>{const run=spawnSync(process.execPath,[DRIVER,'--plan',file,operation],{encoding:'utf8',timeout:60000,
|
|
112
|
+
const drive=(file,operation,env={})=>{const run=spawnSync(process.execPath,[DRIVER,'--plan',file,operation],{encoding:'utf8',timeout:60000,
|
|
112
113
|
env:{...process.env,PATH:bin+path.delimiter+process.env.PATH,CM_WORKFLOW_HOME:path.join(root,'home'),
|
|
113
|
-
CM_WORKFLOW_LOG_HOME:path.join(root,'logs')}});
|
|
114
|
+
CM_WORKFLOW_LOG_HOME:path.join(root,'logs'),...env}});
|
|
114
115
|
let result=null;try{result=JSON.parse(run.stdout).result;}catch{}
|
|
115
116
|
return {status:run.status,stderr:run.stderr,result};};
|
|
116
117
|
const store=path.join(specsDir,'.reviews','.execution',identity.runId,'state.json');
|
|
@@ -122,10 +123,30 @@ function fixture(t,{reviewTimeoutMs=null}={}){
|
|
|
122
123
|
const first=drive(plan(),'start');assert.equal(first.status,0,first.stderr);
|
|
123
124
|
assert.equal(first.result.state,'awaiting_review');return first.result.packageDigest;
|
|
124
125
|
};
|
|
125
|
-
const decide=(packageDigest,attempt=1)=>drive(plan({mode:'resume',permissions:review(attempt),packageDigest,answers:undefined,checks:undefined}),'decision');
|
|
126
|
+
const decide=(packageDigest,attempt=1,env={})=>drive(plan({mode:'resume',permissions:review(attempt),packageDigest,answers:undefined,checks:undefined}),'decision',env);
|
|
126
127
|
const lastResult=()=>records().findLast(row=>row.payload.type==='review-invocation-result').payload;
|
|
127
128
|
const intents=()=>records().filter(row=>row.payload.type==='effect-intent').map(row=>row.payload.effect.id);
|
|
128
|
-
|
|
129
|
+
// Optional notices: notify.json in the fixture's CM_WORKFLOW_HOME runs a
|
|
130
|
+
// recorder; sent() lists what reached it (the launcher is detached).
|
|
131
|
+
const notices=()=>{
|
|
132
|
+
const home=path.join(root,'home'),sent=path.join(root,'sent.jsonl'),script=path.join(root,'fake-notify.mjs');
|
|
133
|
+
fs.mkdirSync(home,{recursive:true});
|
|
134
|
+
fs.writeFileSync(script,`import fs from 'node:fs';let input='';process.stdin.on('data',c=>input+=c);
|
|
135
|
+
process.stdin.on('end',()=>{fs.appendFileSync(${JSON.stringify(sent)},JSON.stringify({body:process.env.CM_NOTIFY_BODY,stdin:JSON.parse(input)})+'\\n');});`);
|
|
136
|
+
fs.writeFileSync(path.join(home,'notify.json'),JSON.stringify({version:1,command:[process.execPath,script],layout:'compact'}));
|
|
137
|
+
const rows=()=>fs.existsSync(sent)?fs.readFileSync(sent,'utf8').split('\n').filter(Boolean).map(line=>JSON.parse(line)):[];
|
|
138
|
+
const pending=()=>{const dir=path.join(home,'notify-pending');return fs.existsSync(dir)?fs.readdirSync(dir).filter(name=>name.endsWith('.json')):[];};
|
|
139
|
+
return {rows,pending};
|
|
140
|
+
};
|
|
141
|
+
// The same driver started without waiting for it (a timed retry in the background).
|
|
142
|
+
const driveAsync=(file,operation,env={})=>{
|
|
143
|
+
const child=spawn(process.execPath,[DRIVER,'--plan',file,operation],{env:{...process.env,PATH:bin+path.delimiter+process.env.PATH,
|
|
144
|
+
CM_WORKFLOW_HOME:path.join(root,'home'),CM_WORKFLOW_LOG_HOME:path.join(root,'logs'),...env}});
|
|
145
|
+
let stdout='',stderr='';child.stdout.on('data',chunk=>stdout+=chunk);child.stderr.on('data',chunk=>stderr+=chunk);
|
|
146
|
+
return {child,stderr:()=>stderr,done:new Promise(resolve=>child.on('close',status=>{
|
|
147
|
+
let result=null;try{result=JSON.parse(stdout).result;}catch{}resolve({status,stdout,stderr,result});}))};
|
|
148
|
+
};
|
|
149
|
+
return {root,specsDir,codeProject,answers,write,behave,plan,drive,driveAsync,store,records,replay,calls,review,awaitingReview,decide,lastResult,intents,notices};
|
|
129
150
|
}
|
|
130
151
|
|
|
131
152
|
const apiErrors=[
|
|
@@ -190,6 +211,8 @@ test(`#8 ${error==='authentication_failed'?'real Claude CLI':'in-process Claude
|
|
|
190
211
|
assert.equal(failed.status,0,failed.stderr);
|
|
191
212
|
assert.equal(failed.result.state,'pending_review');assert.equal(failed.result.code,'review_provider_failed');
|
|
192
213
|
assert.equal(failed.result.pendingAction,'resume');assert.match(failed.result.reason,new RegExp(`^${failure}: `));
|
|
214
|
+
// The class is also a structured field, so a driver never parses the reason text.
|
|
215
|
+
assert.equal(failed.result.reviewFailure,failure);
|
|
193
216
|
const result=f.lastResult();
|
|
194
217
|
assert.equal(result.outcome,'failed');assert.equal(result.reconciliationRequired,false);
|
|
195
218
|
assert.equal(result.inspection.kind,'cm-provider-review-failure');assert.equal(result.inspection.category,'provider');
|
|
@@ -210,6 +233,128 @@ test(`#8 ${error==='authentication_failed'?'real Claude CLI':'in-process Claude
|
|
|
210
233
|
assert.equal(f.replay().state.state,'approved');assert.equal(f.calls().length,2);
|
|
211
234
|
});
|
|
212
235
|
|
|
236
|
+
// 2026-10-26: a provider rate limit stopped the run although the quota recovered
|
|
237
|
+
// minutes later. The driver waits and re-runs the same command in resume mode,
|
|
238
|
+
// which is the runner's own one automatic redispatch of this round: no review
|
|
239
|
+
// round, no abandon_review, no extra permission, and no notice while it waits.
|
|
240
|
+
const rateLimited={mode:'api_error',error:'rate_limit',status:429,text:'API Error: 429 rate limited'};
|
|
241
|
+
const until=async(check,ms=8000)=>{const end=Date.now()+ms;while(!check()&&Date.now()<end)await new Promise(r=>setTimeout(r,25));return check();};
|
|
242
|
+
test('#8 a rate-limited review is redispatched by the driver after a wait, in the same run, without a notice',async t=>{
|
|
243
|
+
const f=fixture(t),packageDigest=f.awaitingReview(),notices=f.notices();
|
|
244
|
+
f.behave(rateLimited,{mode:'ok'});
|
|
245
|
+
const run=f.decide(packageDigest,1,{CM_DRIVE_RATE_LIMIT_DELAYS_MS:'300,300,300'});
|
|
246
|
+
assert.equal(run.status,0,run.stderr);
|
|
247
|
+
// stdout holds only the re-run's result: the interim rate-limited one is not printed.
|
|
248
|
+
assert.equal(run.result.state,'approved',run.stderr);
|
|
249
|
+
assert.match(run.stderr,/审查被限流(reviewer_rate_limited),1 秒后在原运行自动重派审查(第 1\/3 次);等待期间不推送/);
|
|
250
|
+
assert.deepEqual(f.intents(),['develop-1','review-1','review-1-retry-1']);assert.equal(f.calls().length,2);
|
|
251
|
+
// The review rounds are untouched: one round, its automatic redispatch spent.
|
|
252
|
+
assert.equal(f.replay().state.attempt,1);
|
|
253
|
+
await new Promise(resolve=>setTimeout(resolve,700));
|
|
254
|
+
assert.deepEqual(notices.rows(),[],'nothing is sent while waiting or after the retry succeeded');
|
|
255
|
+
assert.deepEqual(notices.pending(),[],'the backstop notice was cancelled by the re-run');
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// advance (not only decision) dispatches the pending review again: the retry
|
|
259
|
+
// must show a new review effect and a second reviewer call.
|
|
260
|
+
test('#8 advance on a rate-limited review is retried and the review is really redispatched',async t=>{
|
|
261
|
+
const f=fixture(t);f.awaitingReview();
|
|
262
|
+
f.behave(rateLimited,{mode:'ok'});
|
|
263
|
+
const run=f.drive(f.plan({mode:'resume'}),'advance',{CM_DRIVE_RATE_LIMIT_DELAYS_MS:'300,300,300'});
|
|
264
|
+
assert.match(run.stderr,/自动重派审查(第 1\/3 次)/);
|
|
265
|
+
assert.match(run.stderr,/按等待时那次限流重派这一次审查(第 1\/3 次)/);
|
|
266
|
+
// The retry is a bound decision: it redispatched that review and did not go on to complete.
|
|
267
|
+
assert.equal(run.result.operation,'decision');assert.equal(f.intents().some(id=>id.startsWith('complete-')),false);
|
|
268
|
+
assert.deepEqual(f.intents().slice(0,3),['develop-1','review-1','review-1-retry-1']);
|
|
269
|
+
assert.equal(f.calls().length,2);assert.notEqual(run.result?.state,'pending_review',run.stderr);
|
|
270
|
+
// resume only reports a pending_review state, so it is never retried; decision and advance are.
|
|
271
|
+
assert.deepEqual(['advance','decision','resume','status'].map(op=>rateLimitRetryEligible(op,{permissions:[]})),[true,true,false,false]);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// The timed re-run is bound to the stop it waited for: if another driver moved
|
|
275
|
+
// the run on, or the PLAN now names something else, nothing is dispatched.
|
|
276
|
+
// Codex round 2 reproduction: the waiting command is advance; while it waits,
|
|
277
|
+
// another driver's decision takes the review to approved. The timed retry is a
|
|
278
|
+
// decision carrying the frozen stop, checked by the host under the run's writer
|
|
279
|
+
// lock: it dispatches nothing (no complete, tasks.md untouched).
|
|
280
|
+
test('#8 a timed rate-limit retry does nothing when another driver moved the run on meanwhile',async t=>{
|
|
281
|
+
const f=fixture(t),packageDigest=f.awaitingReview();
|
|
282
|
+
f.behave(rateLimited,{mode:'ok'},{mode:'ok'});
|
|
283
|
+
const tasks=path.join(f.specsDir,'1.work','tasks.md'),before=fs.readFileSync(tasks);
|
|
284
|
+
const waiting=f.driveAsync(f.plan({mode:'resume'}),'advance',{CM_DRIVE_RATE_LIMIT_DELAYS_MS:'4000'});
|
|
285
|
+
assert(await until(()=>/秒后在原运行自动重派审查/.test(waiting.stderr()),20000),'the first driver is waiting');
|
|
286
|
+
const other=f.decide(packageDigest,1,{CM_DRIVE_RATE_LIMIT_DELAYS_MS:'1'});
|
|
287
|
+
assert.equal(other.result.state,'approved',other.stderr);assert.equal(f.calls().length,2);
|
|
288
|
+
const intents=f.intents();
|
|
289
|
+
const first=await waiting.done;
|
|
290
|
+
assert.match(first.stderr,/状态已变,未自动重试:宿主核对运行已不停在等待时那次审查限流,没有派发任何操作/);
|
|
291
|
+
assert.equal(first.result.staleRetry,true,first.stdout);assert.equal(first.result.outcome,'rejected');
|
|
292
|
+
assert.equal(first.result.state,'approved');
|
|
293
|
+
assert.deepEqual(f.intents(),intents,'no effect at all, complete-1 included');
|
|
294
|
+
assert.equal(f.intents().some(id=>id.startsWith('complete-')),false);
|
|
295
|
+
assert.deepEqual(fs.readFileSync(tasks),before,'tasks.md unchanged');
|
|
296
|
+
assert.equal(f.calls().length,2,'no third reviewer call');assert.equal(f.replay().state.state,'approved');
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// The host's own check of the frozen stop: another failed invocation is refused
|
|
300
|
+
// without any effect; the exact frozen one is redispatched once.
|
|
301
|
+
test('#8 the host redispatches a bound rate-limit retry only for the exact frozen review invocation',async t=>{
|
|
302
|
+
const f=fixture(t),packageDigest=f.awaitingReview();
|
|
303
|
+
f.behave(rateLimited,{mode:'ok'});
|
|
304
|
+
const file=f.plan({mode:'resume',permissions:f.review(1),packageDigest,answers:undefined,checks:undefined});
|
|
305
|
+
const waiting=f.driveAsync(file,'decision',{CM_DRIVE_RATE_LIMIT_DELAYS_MS:'600000'});
|
|
306
|
+
t.after(()=>{try{waiting.child.kill('SIGKILL');}catch{}});
|
|
307
|
+
assert(await until(()=>/分钟后在原运行自动重派审查/.test(waiting.stderr()),20000),'the first driver is waiting');
|
|
308
|
+
waiting.child.kill('SIGKILL');await waiting.done;
|
|
309
|
+
const invocationId=f.lastResult().invocationId,identity={repositoryId:'review-failure',runId:'review-failure-run',taskId:'T-001',attempt:1};
|
|
310
|
+
assert.equal(typeof invocationId,'string');
|
|
311
|
+
const bound=id=>f.drive(file,'decision',{CM_DRIVE_RATE_LIMIT_RETRY:'1',CM_DRIVE_RATE_LIMIT_EXPECTED:JSON.stringify({identity,packageDigest,invocationId:id})});
|
|
312
|
+
const intents=f.intents();
|
|
313
|
+
const stale=bound('another-invocation');
|
|
314
|
+
assert.equal(stale.result?.staleRetry,true,`${stale.status} ${stale.stderr}`);assert.equal(stale.result.state,'pending_review');
|
|
315
|
+
assert.deepEqual(f.intents(),intents);assert.equal(f.calls().length,1);
|
|
316
|
+
const exact=bound(invocationId);
|
|
317
|
+
assert.equal(exact.result.state,'approved',exact.stderr);assert.equal(f.calls().length,2);
|
|
318
|
+
assert.deepEqual(f.intents(),[...intents,'review-1-retry-1']);
|
|
319
|
+
// A retry without its frozen stop never falls back to a plain command.
|
|
320
|
+
const missing=f.drive(file,'decision',{CM_DRIVE_RATE_LIMIT_RETRY:'1'});
|
|
321
|
+
assert.equal(missing.status,2);assert.match(missing.stderr,/缺少等待时冻结的审查限流前置条件/);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
test('#8 a timed rate-limit retry does nothing when the PLAN was changed to name another run',async t=>{
|
|
325
|
+
const f=fixture(t),packageDigest=f.awaitingReview();
|
|
326
|
+
f.behave(rateLimited,{mode:'ok'});
|
|
327
|
+
const file=f.plan({mode:'resume',permissions:f.review(1),packageDigest,answers:undefined,checks:undefined});
|
|
328
|
+
const waiting=f.driveAsync(file,'decision',{CM_DRIVE_RATE_LIMIT_DELAYS_MS:'2000'});
|
|
329
|
+
assert(await until(()=>/秒后在原运行自动重派审查/.test(waiting.stderr()),20000),'the first driver is waiting');
|
|
330
|
+
const definition=JSON.parse(fs.readFileSync(path.join(f.root,'run.json'),'utf8'));
|
|
331
|
+
fs.writeFileSync(path.join(f.root,'run-other.json'),JSON.stringify({...definition,identity:{...definition.identity,runId:'review-failure-other'}}));
|
|
332
|
+
fs.writeFileSync(file,JSON.stringify({...JSON.parse(fs.readFileSync(file,'utf8')),config:'run-other.json'}));
|
|
333
|
+
const first=await waiting.done;
|
|
334
|
+
assert.match(first.stderr,/状态已变,未自动重试:PLAN 文件在等待期间被改过/);
|
|
335
|
+
assert.equal(first.result.state,'pending_review');assert.equal(f.calls().length,1,'nothing was dispatched');
|
|
336
|
+
assert.equal(fs.existsSync(path.join(f.specsDir,'.reviews','.execution','review-failure-other')),false);
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
test('#8 a review still rate limited after the automatic retry is returned and notified at once with what to do',async t=>{
|
|
340
|
+
const f=fixture(t),packageDigest=f.awaitingReview(),notices=f.notices();
|
|
341
|
+
f.behave(rateLimited,rateLimited,{mode:'ok'});
|
|
342
|
+
const run=f.decide(packageDigest,1,{CM_DRIVE_RATE_LIMIT_DELAYS_MS:'200,200,200'});
|
|
343
|
+
// The second rate limit of the round is the runner's blocked stop: no third dispatch, no abandon_review sent.
|
|
344
|
+
assert.equal(run.result.state,'blocked',run.stderr);assert.equal(run.result.code,'review_provider_failed');
|
|
345
|
+
assert.equal(run.result.reviewFailure,'reviewer_rate_limited');assert.equal(run.result.pendingAction,'abandon_review');
|
|
346
|
+
assert.equal(f.calls().length,2);assert.equal(f.records().filter(row=>row.payload.type==='review-redispatch').length,0);
|
|
347
|
+
assert.equal((run.stderr.match(/自动重派审查(第 /g)??[]).length,1);
|
|
348
|
+
assert(await until(()=>notices.rows().length===1),'notified at once');
|
|
349
|
+
const [sent]=notices.rows();
|
|
350
|
+
// The real exit is the round's stop confirmation, not "继续": the notice says so.
|
|
351
|
+
assert.equal(sent.body.split('\n')[1],'你要做:需要你确认旧审查进程已停后,回到会话「review-host-a」授权放弃这次审查再重派');
|
|
352
|
+
assert.equal(sent.stdin.code,'review_provider_failed');
|
|
353
|
+
// Without the automatic retry budget (no eligible operation), status never retries.
|
|
354
|
+
const status=f.drive(f.plan({mode:'resume',answers:undefined,checks:undefined}),'status',{CM_DRIVE_RATE_LIMIT_DELAYS_MS:'200'});
|
|
355
|
+
assert.equal(status.result.state,'blocked');assert.equal(f.calls().length,2);
|
|
356
|
+
});
|
|
357
|
+
|
|
213
358
|
test('#8 a reviewer with no init line is redispatched twice per round; the third failure is a limit and abandon is refused',t=>{
|
|
214
359
|
const f=fixture(t),packageDigest=f.awaitingReview();
|
|
215
360
|
f.behave({mode:'no_init'});
|
package/scripts/cm-ai-run.mjs
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Fixed, no-provider control entry. Executing adapters are a subsequent slice.
|
|
3
3
|
import fs from 'node:fs';
|
|
4
|
+
import {assertDeclaredScope} from '../runtime/js/task-scope.mjs';
|
|
4
5
|
import {spawn as spawnChild} from 'node:child_process';
|
|
5
6
|
import path from 'node:path';
|
|
6
7
|
import {fileURLToPath} from 'node:url';
|
|
7
8
|
import {serveCmAiHost} from '../runtime/js/cm-ai/host-session.mjs';
|
|
8
9
|
import {digest as sha} from '../runtime/js/cm-ai/contracts.mjs';
|
|
9
10
|
import {resolveCodeProjects,codeProjectPaths,assertCodeProjectSelections} from '../runtime/js/cm-ai/code-projects.mjs';
|
|
10
|
-
import {preQaConfigurations,readQaAttachment} from '../runtime/js/cm-ai/qa-attachment.mjs';
|
|
11
|
+
import {preQaConfigurations,preQaUpgradeConfigurations,readQaAttachment} from '../runtime/js/cm-ai/qa-attachment.mjs';
|
|
12
|
+
import {isImplicitQaDecision} from '../runtime/js/cm-ai/implicit-qa-decision.mjs';
|
|
11
13
|
import {recordCmAiQaAttachment} from '../runtime/js/cm-ai/cm-ai-qa-log.mjs';
|
|
12
14
|
import {writeCmAiQaStatus} from '../runtime/js/cm-ai/cm-ai-run-finalizer.mjs';
|
|
13
15
|
import {isSupportedExecutionPlatform} from '../runtime/js/cm-ai/execution-platform.mjs';
|
|
@@ -22,7 +24,7 @@ import {recordReviewAbandonment} from '../runtime/js/cm-ai/review-abandon-log.mj
|
|
|
22
24
|
import {recordEffectAbandonment} from '../runtime/js/cm-ai/effect-abandon-log.mjs';
|
|
23
25
|
import {reviewConsumedHandoff,reviewedHandoffConflict} from '../runtime/js/cm-ai/host-handoff.mjs';
|
|
24
26
|
import {RUN_ID_RULE,validRunId} from './cm-log-event.mjs';
|
|
25
|
-
import {JOURNAL_PAYLOAD_LIMIT,boundedReason} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
27
|
+
import {JOURNAL_PAYLOAD_LIMIT,boundedReason,shape,hex} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
26
28
|
import {protectedScopePaths} from '../runtime/js/cm-ai/developer-adapter.mjs';
|
|
27
29
|
import {closeoutPolicyCandidates} from '../runtime/js/cm-ai/knowledge-closeout.mjs';
|
|
28
30
|
|
|
@@ -244,7 +246,11 @@ export function runConfigMaterial(definition,execution,{parallelSelection=null,b
|
|
|
244
246
|
export function inspectRunHistory(definition){
|
|
245
247
|
const snapshot=readExecutionSnapshot({specsRoot:definition.specsDir,
|
|
246
248
|
identity:{repositoryId:definition.identity.repositoryId,runId:definition.identity.runId}});
|
|
247
|
-
|
|
249
|
+
// The restart target is the same launch projection a v2 supersede compares;
|
|
250
|
+
// histories this runtime cannot project report null rather than a guess.
|
|
251
|
+
let supersedeTarget=null;
|
|
252
|
+
try{supersedeTarget=controlLaunchTarget(snapshot);}catch{supersedeTarget=null;}
|
|
253
|
+
return {identity:snapshot.identity,revision:snapshot.revision,fingerprints:snapshot.fingerprints,supersedeTarget,
|
|
248
254
|
records:snapshot.records.map(record=>({seq:record.seq,id:record.id,kind:record.kind,type:record.payload.type??null,
|
|
249
255
|
legacyReviewGrant:record.payload.type==='review-invocation-registered'
|
|
250
256
|
&&(Object.hasOwn(record.payload,'grant')||Object.hasOwn(record.payload,'authorizationAt'))}))};
|
|
@@ -268,6 +274,8 @@ export async function openControlRun(definition,mode,execution=null,options={}){
|
|
|
268
274
|
if(!isSupportedExecutionPlatform())fail('unsupported_runner_platform');
|
|
269
275
|
if(!['create','resume'].includes(mode))fail('invalid_mode');
|
|
270
276
|
let guard;
|
|
277
|
+
const holds=[];
|
|
278
|
+
const releaseHolds=()=>{for(const held of holds.splice(0)){try{held.close();}catch{}}};
|
|
271
279
|
try{
|
|
272
280
|
const acquire=async()=>{
|
|
273
281
|
const {acquireExternalRunGuard,externalRunGuardExists}=await import('../runtime/js/cm-ai/external-run-guard.mjs');
|
|
@@ -275,12 +283,15 @@ export async function openControlRun(definition,mode,execution=null,options={}){
|
|
|
275
283
|
// Switching this binary to a legacy launch must not bypass an existing strict attempt.
|
|
276
284
|
if(strict||externalRunGuardExists(definition.specsDir,definition.codeProject))guard=acquireExternalRunGuard(definition,{strictOnly:!strict});
|
|
277
285
|
};
|
|
278
|
-
|
|
286
|
+
// A v2 restart holds the predecessor's writer lock from the target check until
|
|
287
|
+
// the new run has journaled and archived the supersession (or failed).
|
|
288
|
+
const result=await openControlRunOwned(definition,mode,execution,{...options,supersedeHolds:holds},acquire);
|
|
289
|
+
releaseHolds();
|
|
279
290
|
const close=result.close;
|
|
280
291
|
return {...result,close:()=>{try{close();}finally{guard?.close();}}};
|
|
281
|
-
}catch(error){guard?.close();throw error;}
|
|
292
|
+
}catch(error){releaseHolds();guard?.close();throw error;}
|
|
282
293
|
}
|
|
283
|
-
async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQa=false,rerunBlockedQa=false,qaEnvironmentFailure=null,parallelSelection=null,qaConfigRevision=null,supersedeReason=null,acceptSupersededCodeDrift=false,allowAbandonReview=false,allowAbandonEffect=false,allowBootstrapReviewRecovery=false,allowDevelopRedo=false,holdRevision=false,specRebindReason=null,expectedControl=null}={},acquireGuard=async()=>{}){
|
|
294
|
+
async function openControlRunOwned(definition,mode,execution=null,{supersedeHolds=null,supersedeTarget=null,rerunUnknownQa=false,rerunBlockedQa=false,qaEnvironmentFailure=null,parallelSelection=null,qaConfigRevision=null,supersedeReason=null,acceptSupersededCodeDrift=false,allowAbandonReview=false,allowAbandonEffect=false,allowBootstrapReviewRecovery=false,allowDevelopRedo=false,holdRevision=false,specRebindReason=null,expectedControl=null,scopeRevision=null,developmentReworkReason=null,reviewedIntegration=null}={},acquireGuard=async()=>{}){
|
|
284
295
|
// Check before importing node:sqlite: legacy Node users get a useful error.
|
|
285
296
|
if(!isSupportedExecutionPlatform())fail('unsupported_runner_platform');
|
|
286
297
|
const {conversationProtection,externalConversationDefinition}=await import('../runtime/js/cm-ai/host-conversation-execution.mjs');
|
|
@@ -290,8 +301,9 @@ async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQ
|
|
|
290
301
|
// run here, before any journal, intent or execution directory exists, so it
|
|
291
302
|
// cannot strand its first develop effect. A bootstrap run's own instruction
|
|
292
303
|
// paths are checked by createHostBootstrap against its business scope.
|
|
293
|
-
if(mode==='create'&&!execution?.bootstrap)assertCreatableScope(definition?.scope);
|
|
304
|
+
if(mode==='create'&&!execution?.bootstrap){assertCreatableScope(definition?.scope);assertDeclaredScope(definition);}
|
|
294
305
|
if(supersedeReason!==null&&mode!=='create')fail('supersede_unavailable');
|
|
306
|
+
if(supersedeTarget!==null&&!execution?.configuration?.controlPolicy)fail('invalid_arguments');
|
|
295
307
|
if(allowAbandonEffect&&mode!=='resume')fail('effect_abandon_unavailable');
|
|
296
308
|
if(allowBootstrapReviewRecovery&&mode!=='resume')fail('bootstrap_review_recovery_unavailable');
|
|
297
309
|
if(allowDevelopRedo&&mode!=='resume')fail('develop_redo_unavailable');
|
|
@@ -307,18 +319,49 @@ async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQ
|
|
|
307
319
|
||(rerunUnknownQa||rerunBlockedQa)&&(mode!=='resume'||!execution?.qaExecutor))fail('qa_recovery_authorization_required');
|
|
308
320
|
const {openTaskExecutionStore}=await import('../runtime/js/cm-ai/task-owner.mjs');
|
|
309
321
|
const controlPolicy=execution?.configuration?.controlPolicy??null;
|
|
310
|
-
const
|
|
322
|
+
const elevatedRecovery=scopeRevision!==null||developmentReworkReason!==null;
|
|
323
|
+
const launchRecovery=qaConfigRevision!==null||rerunUnknownQa||rerunBlockedQa||specRebindReason!==null||elevatedRecovery||reviewedIntegration!==null;
|
|
324
|
+
if(elevatedRecovery){
|
|
325
|
+
if(!controlPolicy||mode!=='resume'||parallelSelection!==null||conversationProtection(execution)!==null
|
|
326
|
+
||protectedExecutions.has(execution)||execution.configuration.providerDevelopment)fail('recovery_launch_unavailable');
|
|
327
|
+
if([scopeRevision!==null,developmentReworkReason!==null,qaConfigRevision!==null,rerunUnknownQa,rerunBlockedQa,specRebindReason!==null].filter(Boolean).length!==1)fail('invalid_input');
|
|
328
|
+
const reason=scopeRevision?.reason??developmentReworkReason;
|
|
329
|
+
if(typeof reason!=='string'||!reason.trim()||Buffer.byteLength(reason,'utf8')>500||/[\r\n\0]/.test(reason))fail('invalid_input');
|
|
330
|
+
}
|
|
331
|
+
if(reviewedIntegration!==null){
|
|
332
|
+
shape(reviewedIntegration,['evidenceFile','expectedDigest']);hex(reviewedIntegration.expectedDigest);
|
|
333
|
+
if(typeof reviewedIntegration.evidenceFile!=='string'||!path.isAbsolute(reviewedIntegration.evidenceFile)
|
|
334
|
+
||reviewedIntegration.evidenceFile.includes('\0'))fail('invalid_input');
|
|
335
|
+
if(!controlPolicy||mode!=='resume'||parallelSelection!==null)fail('recovery_launch_unavailable');
|
|
336
|
+
// Integration adoption is its own launch: never together with another recovery.
|
|
337
|
+
if(qaConfigRevision!==null||rerunUnknownQa||rerunBlockedQa||qaEnvironmentFailure!==null
|
|
338
|
+
||specRebindReason!==null||supersedeReason!==null||holdRevision||elevatedRecovery||supersedeTarget!==null)fail('invalid_input');
|
|
339
|
+
}
|
|
311
340
|
if(controlPolicy){
|
|
312
|
-
|
|
341
|
+
// V2 restart: only create, only with the previewed predecessor launch target.
|
|
342
|
+
if(supersedeReason!==null){
|
|
343
|
+
if(mode!=='create')fail('supersede_unavailable');
|
|
344
|
+
if(supersedeTarget===null)fail('invalid_input');
|
|
345
|
+
supersedeTarget=readControlTarget(supersedeTarget);
|
|
346
|
+
}else if(supersedeTarget!==null)fail('invalid_input');
|
|
313
347
|
if(launchRecovery){
|
|
314
348
|
if(mode!=='resume')fail('supersede_unavailable');
|
|
315
349
|
if(expectedControl===null)fail('invalid_input');
|
|
316
350
|
expectedControl=readControlTarget(expectedControl);
|
|
317
351
|
}else if(expectedControl!==null)fail('invalid_input');
|
|
318
352
|
}
|
|
353
|
+
// savedPolicy: set only when a completed qa:"disabled" run is resumed with
|
|
354
|
+
// qa:"run" and a QA workflow (control-policy.mjs isControlQaUpgrade). The
|
|
355
|
+
// runner keeps the saved policy; only the host's QA wiring uses the new one.
|
|
356
|
+
let savedPolicy=null;
|
|
319
357
|
if(mode==='resume'){
|
|
320
358
|
const snapshot=assertSupportedResumeHistory(definition);
|
|
321
|
-
if(snapshot?.records.length)
|
|
359
|
+
if(snapshot?.records.length){
|
|
360
|
+
savedPolicy=assertControlEntry(snapshot,controlPolicy,{allowQaUpgrade:Boolean(execution?.qaExecutor)});
|
|
361
|
+
// The first upgrade is its own launch; recoveries come after it, on the attached run.
|
|
362
|
+
if(savedPolicy&&!snapshot.records.some(row=>row.payload.type==='qa-attached')
|
|
363
|
+
&&(launchRecovery||supersedeTarget!==null||holdRevision))fail('invalid_input');
|
|
364
|
+
}
|
|
322
365
|
}
|
|
323
366
|
const {createCmAiHost}=await import('../runtime/js/cm-ai/host.mjs');
|
|
324
367
|
const {inspectCmAiAdmission,matchesCmAiTaskSelection,explainCmAiTaskSelection,selectedFeature}=await import('../runtime/js/cm-ai/cm-ai-admission.mjs');
|
|
@@ -357,7 +400,7 @@ async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQ
|
|
|
357
400
|
const reviewsDir=path.join(specsDir,'.reviews');
|
|
358
401
|
const supersession=mode==='create'&&supersedeReason!==null
|
|
359
402
|
?prepareReviewedEvidenceSupersession({specsDir,codeProject,feature,identity,reason:supersedeReason,tasksPath,
|
|
360
|
-
acceptSupersededCodeDrift}):null;
|
|
403
|
+
acceptSupersededCodeDrift,...(supersedeTarget?{expectedPredecessor:supersedeTarget,predecessorTarget:controlLaunchTarget,holds:supersedeHolds}:{})}):null;
|
|
361
404
|
let bootstrapConfig=null;
|
|
362
405
|
if(execution?.bootstrap){
|
|
363
406
|
const {bootstrapConfiguration}=await import('../runtime/js/cm-ai/host-bootstrap.mjs');
|
|
@@ -436,7 +479,7 @@ async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQ
|
|
|
436
479
|
store=openTaskExecutionStore({...storeOptions,fingerprints:{...fingerprints,config:snapshot.fingerprints.config}});
|
|
437
480
|
}
|
|
438
481
|
if(!store){
|
|
439
|
-
for(const previous of preQaConfigurations(material)){
|
|
482
|
+
for(const previous of [...preQaConfigurations(material),...(savedPolicy?preQaUpgradeConfigurations(material):[])]){
|
|
440
483
|
try{store=openTaskExecutionStore({...storeOptions,fingerprints:{...fingerprints,config:sha(previous)}});break;}
|
|
441
484
|
catch(cause){if(cause.code!=='fingerprint_mismatch')throw cause;}
|
|
442
485
|
}
|
|
@@ -457,6 +500,7 @@ async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQ
|
|
|
457
500
|
throw Object.assign(new Error('fingerprint_mismatch'),{code:'fingerprint_mismatch',
|
|
458
501
|
reason:'启动配置与事后附加 QA 时绑定的配置不同;请用附加 QA 时的 --workflow-config 与参数恢复'});
|
|
459
502
|
if(attaching&&store.snapshot().records.length===0)fail('qa_attach_not_completed');
|
|
503
|
+
if(savedPolicy&&!attaching&&!attached)fail('fingerprint_mismatch');
|
|
460
504
|
return {material,fingerprints,store,attaching,priorMaterial,chain,attached};
|
|
461
505
|
}catch(error){store.close();throw error;}
|
|
462
506
|
};
|
|
@@ -478,6 +522,16 @@ async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQ
|
|
|
478
522
|
}
|
|
479
523
|
}
|
|
480
524
|
}
|
|
525
|
+
// 修复前创建、没有 workflow 配置的 v2 运行:指纹里没有隐式 QA 判定,按原样打开,行为不变。
|
|
526
|
+
// 只用去掉判定的副本算指纹;execution 本身不换,受保护会话等按对象身份登记的状态保持原样。
|
|
527
|
+
let implicitQaSuppressed=false;
|
|
528
|
+
if(!opened&&mode==='resume'&&isImplicitQaDecision(execution?.qaDecisionProvider)){
|
|
529
|
+
const {qaDecisionProvider,...original}=execution;
|
|
530
|
+
for(const knowledgeCloseout of closeoutPolicyCandidates(original,mode,snapshot)){
|
|
531
|
+
try{opened=openFor(runConfigMaterial(definition,original,{parallelSelection,bootstrapConfig,knowledgeCloseout}));implicitQaSuppressed=true;break;}
|
|
532
|
+
catch(error){if(error.code!=='fingerprint_mismatch')throw error;}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
481
535
|
if(!opened)throw lastMismatch;
|
|
482
536
|
const {material:configMaterial,fingerprints,store,attaching,priorMaterial,chain,attached}=opened;
|
|
483
537
|
const knowledgeCloseout=configMaterial.knowledgeCloseout??null;
|
|
@@ -491,6 +545,8 @@ async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQ
|
|
|
491
545
|
throw error;
|
|
492
546
|
}
|
|
493
547
|
}
|
|
548
|
+
// Integration acceptance never attaches QA or repairs unrelated audit mirrors.
|
|
549
|
+
if(reviewedIntegration!==null&&attaching)fail('integration_launch_qa_attachment_unavailable');
|
|
494
550
|
let runnerMode=mode;
|
|
495
551
|
if(mode==='resume'&&store.snapshot().records.length===0){
|
|
496
552
|
// Only the genuine, fingerprint-matching empty initializer can be finished.
|
|
@@ -506,7 +562,8 @@ async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQ
|
|
|
506
562
|
...(knowledgeCloseout===null?{}:{knowledgeCloseout}),
|
|
507
563
|
...(execution?.configuration.executionPolicy?{executionPolicy:execution.configuration.executionPolicy}:{}),
|
|
508
564
|
...(execution?.configuration.externalModels?{externalModels:execution.configuration.externalModels}:{}),excludedContexts:['control-host'],
|
|
509
|
-
...(controlPolicy?{controlPolicy}:{}),
|
|
565
|
+
...(controlPolicy?{controlPolicy:savedPolicy??controlPolicy}:{}),
|
|
566
|
+
...(parallelSelection===null?{}:{parallelSelection}),
|
|
510
567
|
developer:{provider:'codex',requestedModel:'unconfigured',contextId:'control-developer',run:unavailable},
|
|
511
568
|
reviewers:[],check:unavailable,taskCompletion:{reviewsDir,handoffs},taskLearning:{feature},
|
|
512
569
|
persistence:{store,mode:runnerMode,version:execution===null?2:3},
|
|
@@ -522,9 +579,17 @@ async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQ
|
|
|
522
579
|
entry:{specsDir,codeProject,feature,identity,rerunUnknownQa,rerunBlockedQa,
|
|
523
580
|
...(definition.featureSelection?{featureSelection:definition.featureSelection.feature}:{}),
|
|
524
581
|
...(knowledgeCloseout===null?{}:{knowledgeCloseout,...(definition.codeProjects?{codeProjects:definition.codeProjects}:{})}),
|
|
525
|
-
...(qaEnvironmentFailure===null?{}:{qaEnvironmentFailure}),allowAbandonReview,allowAbandonEffect,allowBootstrapReviewRecovery,allowDevelopRedo
|
|
526
|
-
|
|
582
|
+
...(qaEnvironmentFailure===null?{}:{qaEnvironmentFailure}),allowAbandonReview,allowAbandonEffect,allowBootstrapReviewRecovery,allowDevelopRedo,allowCompletionRework:Boolean(controlPolicy)&&mode==='resume'&¶llelSelection===null&&conversationProtection(execution)===null
|
|
583
|
+
&&!protectedExecutions.has(execution)&&!execution.configuration.providerDevelopment,...(holdRevision?{holdRevision}:{}),...(selection===null?{}:{parallelSelection:selection}),...(execution===null?{}:{
|
|
584
|
+
...Object.fromEntries(['developmentAttempt','qaDecisionProvider','qaLogHome','qaExecutor','applicableAgentFiles','documentationProvider','documentationResult'].filter(key=>Object.hasOwn(execution,key)
|
|
585
|
+
&&!(implicitQaSuppressed&&key==='qaDecisionProvider')).map(key=>[key,execution[key]]))})},
|
|
527
586
|
});
|
|
587
|
+
if(elevatedRecovery||reviewedIntegration!==null){
|
|
588
|
+
const result=reviewedIntegration!==null?host.acceptReviewedIntegration({allowed:true,...reviewedIntegration})
|
|
589
|
+
:scopeRevision!==null?host.reviseScope({allowed:true,...scopeRevision})
|
|
590
|
+
:host.reworkDevelopment({allowed:true,reason:developmentReworkReason});
|
|
591
|
+
if(result.outcome==='rejected')fail(result.code);
|
|
592
|
+
}
|
|
528
593
|
const logAbandonments=()=>{
|
|
529
594
|
for(const record of store.snapshot().records.filter(row=>row.payload.type==='review-invocation-abandoned'))
|
|
530
595
|
recordReviewAbandonment({specsDir,codeProject,feature,identity,record,
|
|
@@ -535,15 +600,15 @@ async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQ
|
|
|
535
600
|
runtime:execution?.developer?.provider??'codex',
|
|
536
601
|
...(execution?.qaLogHome?{logHome:execution.qaLogHome}:{})});
|
|
537
602
|
};
|
|
538
|
-
if(mode==='resume')logAbandonments();
|
|
603
|
+
if(mode==='resume'&&reviewedIntegration===null)logAbandonments();
|
|
539
604
|
const recorded=store.snapshot().records.find(row=>row.payload.type==='evidence-superseded')?.payload.record??null;
|
|
540
|
-
if(supersession!==null||recorded!==null){
|
|
605
|
+
if(reviewedIntegration===null&&(supersession!==null||recorded!==null)){
|
|
541
606
|
const record=host.supersedeEvidence(supersession??recorded);
|
|
542
607
|
archiveReviewedEvidence(reviewsDir,record);
|
|
543
608
|
recordEvidenceSupersession({specsDir,codeProject,identity,record,
|
|
544
609
|
...(execution?.qaLogHome?{logHome:execution.qaLogHome}:{})});
|
|
545
610
|
}
|
|
546
|
-
if(attaching||attached){
|
|
611
|
+
if(reviewedIntegration===null&&(attaching||attached)){
|
|
547
612
|
const record=host.attachQa(attached??{version:1,qaFingerprint:fingerprints.config,
|
|
548
613
|
attachedAt:new Date().toISOString().replace(/\.\d{3}Z$/,'Z'),hostContextId:execution.configuration.hostContextId});
|
|
549
614
|
// Repeating this deterministic log write also repairs a crash after the
|
|
@@ -554,7 +619,7 @@ async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQ
|
|
|
554
619
|
const qaBinding={specsDir,codeProject,feature,identity,
|
|
555
620
|
...(execution?.qaLogHome?{logHome:execution.qaLogHome}:{})};
|
|
556
621
|
// Repair a crash after the journal append, before the log supersession.
|
|
557
|
-
for(const record of chain.revisions)recordCmAiQaConfigurationRevision({...qaBinding,identity:{...identity,attempt:record.taskAttempt},packageDigest:record.packageDigest},record);
|
|
622
|
+
for(const record of reviewedIntegration===null?chain.revisions:[])recordCmAiQaConfigurationRevision({...qaBinding,identity:{...identity,attempt:record.taskAttempt},packageDigest:record.packageDigest},record);
|
|
558
623
|
if(specRebindReason!==null){
|
|
559
624
|
// Consumed once on this launch; the journal record is the audit trail.
|
|
560
625
|
host.rebindSpecification({version:1,reason:specRebindReason,at:new Date().toISOString()});
|
|
@@ -578,7 +643,9 @@ async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQ
|
|
|
578
643
|
// Replaying or repairing its audit mirror above is not new execution.
|
|
579
644
|
if(!beforeQa)writeCmAiQaStatus({specsDir,feature,identity:current.identity,phase:'configuration_revised'});
|
|
580
645
|
}
|
|
581
|
-
const legacyHost={async handle(request){
|
|
646
|
+
const legacyHost={acceptReviewedIntegration:host.acceptReviewedIntegration,async handle(request){
|
|
647
|
+
if(reviewedIntegration!==null&&request.operation!=='status')
|
|
648
|
+
return {outcome:'rejected',code:'integration_launch_status_only'};
|
|
582
649
|
if(execution===null&&!['status','cancel'].includes(request.operation)){
|
|
583
650
|
// Do not imply an unavailable execution adapter was dispatched.
|
|
584
651
|
return {outcome:'blocked',code:'execution_adapter_required',providerCalls:0};
|
|
@@ -588,7 +655,7 @@ async function openControlRunOwned(definition,mode,execution=null,{rerunUnknownQ
|
|
|
588
655
|
return result;
|
|
589
656
|
}};
|
|
590
657
|
const controlHost=controlPolicy?withControlPolicyHost(legacyHost,{identity,snapshot:()=>store.snapshot(),launchTarget:controlLaunchTarget}):null;
|
|
591
|
-
return {host:legacyHost,...(controlHost?{controlHost}:{}),inspectFixAssociation:host.inspectFixAssociation,acceptCompletedFix:host.acceptCompletedFix,
|
|
658
|
+
return {host:legacyHost,...(controlHost?{controlHost}:{}),inspectFixAssociation:host.inspectFixAssociation,acceptCompletedFix:host.acceptCompletedFix,acceptReviewedIntegration:host.acceptReviewedIntegration,
|
|
592
659
|
checkpoint:()=>store.snapshot().revision,close:()=>store.close()};
|
|
593
660
|
}catch(error){store.close();throw error;}
|
|
594
661
|
}
|