@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
|
@@ -14,6 +14,7 @@ import {createQaFixOwnerHost} from '../runtime/js/cm-ai/host-qa-fix-owner.mjs';
|
|
|
14
14
|
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
15
15
|
import {qaFixIdentity} from '../runtime/js/cm-fix/qa-source.mjs';
|
|
16
16
|
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
17
|
+
import {claudeReviewFingerprint} from '../runtime/js/cm-ai/worker-claude.mjs';
|
|
17
18
|
import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
|
|
18
19
|
import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
19
20
|
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
@@ -34,7 +35,7 @@ function events(onEvent,thread){
|
|
|
34
35
|
{event:'item.completed',item_type:'agent_message'},{event:'turn.completed',item_type:null},
|
|
35
36
|
{event:'process_closed',exit_code:0,signal:null,timed_out:false}])onEvent(event);
|
|
36
37
|
}
|
|
37
|
-
async function fixture(t,{childHost=A,causeContext=null,lostCauseReviews=0,external=false,lateCause=false,optimized=false}={}){
|
|
38
|
+
async function fixture(t,{childHost=A,causeContext=null,lostCauseReviews=0,external=false,lateCause=false,optimized=false,reviewRuntime,reviewVerification=null}={}){
|
|
38
39
|
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'qa-fix-session-')));
|
|
39
40
|
const codeProject=path.join(root,'code'),specsDir=path.join(root,'specs'),feature='1.value';
|
|
40
41
|
fs.mkdirSync(codeProject);fs.mkdirSync(path.join(specsDir,feature),{recursive:true});
|
|
@@ -42,7 +43,7 @@ async function fixture(t,{childHost=A,causeContext=null,lostCauseReviews=0,exter
|
|
|
42
43
|
fs.writeFileSync(path.join(codeProject,'requirements.md'),'Value must be 2.');
|
|
43
44
|
fs.writeFileSync(path.join(codeProject,'red.mjs'),"import {value} from './value.mjs';if(value!==2){console.error('BUG');process.exit(1)}");
|
|
44
45
|
fs.writeFileSync(path.join(codeProject,'existing.mjs'),"import {value} from './value.mjs';if(typeof value!=='number')process.exit(1)");
|
|
45
|
-
fs.writeFileSync(path.join(codeProject,'.cm-workflow.json'),JSON.stringify({version:1,policies:{delivery:'diff'}}));
|
|
46
|
+
fs.writeFileSync(path.join(codeProject,'.cm-workflow.json'),JSON.stringify({version:1,policies:{delivery:'diff'},...(reviewRuntime?{roles:{coder:{adapter:'codex-cli'},reviewer:{adapter:`${reviewRuntime}-cli`}},runtimes:{available:'both'}}:{})}));
|
|
46
47
|
for(const name of ['requirements','design'])fs.writeFileSync(path.join(specsDir,feature,`${name}.md`),'# Fixture');
|
|
47
48
|
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),'- [ ] T-001: implement value\n');
|
|
48
49
|
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],specFiles:buildManifest(specsDir)}));
|
|
@@ -84,9 +85,10 @@ async function fixture(t,{childHost=A,causeContext=null,lostCauseReviews=0,exter
|
|
|
84
85
|
handoffDigest:failed.fixHandoff.handoffDigest};
|
|
85
86
|
const permissions=['--allow-cause-review'];
|
|
86
87
|
let causeReviews=0;
|
|
87
|
-
const models={schemaVersion:1,providers:{codex:{model:'fixture',effort:'low'}}};
|
|
88
|
-
const
|
|
89
|
-
const
|
|
88
|
+
const models={schemaVersion:1,providers:{codex:{model:'fixture',effort:'low'},...(reviewRuntime==='claude'?{claude:{model:'claude-fixture',effort:'high'}}:{})}};
|
|
89
|
+
const childModels=reviewRuntime?{schemaVersion:1,providers:{[reviewRuntime]:models.providers[reviewRuntime]}}:models;
|
|
90
|
+
const childReview=reviewRuntime==='claude'?{model:'claude-fixture',disabledSkills:[],...(external?{effort:'high'}:{}),preflight:{passed:true,provider:'claude',prompt_transport:'stdin',config_fingerprint:claudeReviewFingerprint({cwd:codeProject,model:'claude-fixture',...(external?{effort:'high'}:{}),verification:reviewVerification})}}:external?{...review,...(lateCause?{timeoutMs:20}:{}),effort:'low',preflight:{...review.preflight,config_fingerprint:configFingerprint({cwd:codeProject,model:'fixture',effort:'low'})}}:review;
|
|
91
|
+
const reviewHost=live=>createFixReviewHost({codeProject,hostContextId:live,runtime:'codex',reviewRuntime,verification:reviewVerification,review:childReview,permissions,...(optimized?{executionPolicy:EXECUTION_POLICY_V1,specsDir}:{}),...(external?{externalModels:models}:{}),workerFactory:()=>async({prompt},{onEvent,signal,onTerminal})=>{
|
|
90
92
|
const parsed=JSON.parse(prompt.split('<cm-review-data-json>\n')[1]),data=parsed.presentation?expandReviewData(parsed):parsed;
|
|
91
93
|
if(lateCause){causeReviews++;onEvent({event:'thread.started',provider_thread:'synthetic-child-review'});onEvent({event:'turn.started',item_type:null});
|
|
92
94
|
return new Promise(resolve=>signal.addEventListener('abort',()=>setTimeout(()=>{
|
|
@@ -100,7 +102,7 @@ async function fixture(t,{childHost=A,causeContext=null,lostCauseReviews=0,exter
|
|
|
100
102
|
return {status:'succeeded',value:{verdict:'approved',packageDigest:data.reviewPackage.packageDigest,
|
|
101
103
|
examinedPaths:['value.mjs'],findings:[],summary:'Synthetic cause review'}};
|
|
102
104
|
}});
|
|
103
|
-
const configuration={...(optimized?{executionPolicy:EXECUTION_POLICY_V1}:{}),...(external?{externalModels:
|
|
105
|
+
const configuration={...(reviewRuntime?{reviewRuntime}:{}),...(reviewVerification?{reviewVerification}:{}),...(optimized?{executionPolicy:EXECUTION_POLICY_V1}:{}),...(external?{externalModels:childModels}:{}),hostContextId:childHost,defect:'Value must be 2',qaSource,
|
|
104
106
|
causeReview:{...reviewHost(A).reviewer,...(causeContext?{contextId:causeContext}:{})},
|
|
105
107
|
reproduction:{cwd:codeProject,command:[process.execPath,'red.mjs'],expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000}};
|
|
106
108
|
const fix={specsRoot:specsDir,identity:qaFixIdentity(qaSource),configuration};
|
|
@@ -124,7 +126,7 @@ async function fixture(t,{childHost=A,causeContext=null,lostCauseReviews=0,exter
|
|
|
124
126
|
const records=()=>JSON.parse(fs.readFileSync(statePath)).records;
|
|
125
127
|
const bin=path.join(root,'bin');fs.mkdirSync(bin);
|
|
126
128
|
const fake=path.join(bin,'codex');fs.copyFileSync(fileURLToPath(new URL('./fixtures/codex-review-process.mjs',import.meta.url)),fake);fs.chmodSync(fake,0o700);
|
|
127
|
-
for(const [name,value] of Object.entries({run:definition,review,workflow,fix}))fs.writeFileSync(path.join(root,`${name}.json`),JSON.stringify(value));
|
|
129
|
+
for(const [name,value] of Object.entries({run:definition,review,workflow,fix,'child-review':childReview}))fs.writeFileSync(path.join(root,`${name}.json`),JSON.stringify(value));
|
|
128
130
|
return {causeReviews:()=>causeReviews,models,open,close,bound,fix,childDir,statePath,records,reviewHost,root,bin,request};
|
|
129
131
|
}
|
|
130
132
|
|
|
@@ -168,3 +170,83 @@ test('QA optimization refuses retrofitting a legacy child before opening a store
|
|
|
168
170
|
const f=await fixture(t,{optimized:true});delete f.fix.configuration.executionPolicy;
|
|
169
171
|
await assert.rejects(f.open(A),{code:'execution_policy_legacy_child_inheritance_forbidden'});assert(!fs.existsSync(f.statePath));
|
|
170
172
|
});
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
test('Codex QA parent keeps its host while Claude child reviewer inherits only its frozen pair across resume',async t=>{
|
|
176
|
+
const f=await fixture(t,{external:true,reviewRuntime:'claude'});
|
|
177
|
+
let owner=await f.open(A,{template:true});
|
|
178
|
+
assert.equal((await owner.handle(f.bound('fix_advance'))).fixStage,'cause_review_required');
|
|
179
|
+
const saved=f.records()[0].payload.configuration;
|
|
180
|
+
assert.equal(saved.runtime??'codex','codex');assert.equal(saved.reviewRuntime,'claude');
|
|
181
|
+
assert.equal(saved.hostContextId,A);assert.equal(saved.causeReview.provider,'claude');
|
|
182
|
+
assert.equal(saved.causeReview.requestedModel,'claude-fixture');
|
|
183
|
+
assert.deepEqual(saved.externalModels,{schemaVersion:1,providers:{claude:f.models.providers.claude}});
|
|
184
|
+
assert.equal((await owner.handle({...f.bound('fix_action'),fixOperation:'cause_review'})).fixStage,'red_test_required');
|
|
185
|
+
const registration=f.records().find(record=>record.id==='fix-cause-registered').payload;
|
|
186
|
+
assert.equal(registration.request.provider,'claude');assert.equal(registration.request.requestedModel,'claude-fixture');
|
|
187
|
+
assert.equal(registration.grant.hostContextId,A);assert.equal(registration.grant.adapterId,'claude-cause-review-adapter');
|
|
188
|
+
assert.equal(f.causeReviews(),1);
|
|
189
|
+
f.close();const before=f.records();owner=await f.open(B);
|
|
190
|
+
assert.equal((await owner.handle(f.bound('fix_status'))).fixStage,'red_test_required');
|
|
191
|
+
assert.deepEqual(f.records(),before);assert.equal(f.causeReviews(),1);
|
|
192
|
+
const logs=fs.readFileSync(path.join(f.fix.specsRoot,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
193
|
+
for(const runId of ['qa-parent',f.fix.identity.runId]){
|
|
194
|
+
const rows=logs.filter(row=>row.run_id===runId);assert(rows.length>0);
|
|
195
|
+
assert(rows.every(row=>row.runtime==='codex'),'reviewer selection must not relabel either execution host');
|
|
196
|
+
}
|
|
197
|
+
f.close();f.fix.configuration.externalModels={schemaVersion:1,providers:{claude:{model:'changed-model',effort:'high'}}};
|
|
198
|
+
await assert.rejects(f.open(C),{code:'external_model_pair_conflict'});
|
|
199
|
+
assert.deepEqual(f.records(),before);assert.equal(f.causeReviews(),1);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// Spawn the public CLI, so accidentally dropping either child field at the
|
|
203
|
+
// cm-ai-host -> createFixReviewHost boundary cannot hide behind direct fixtures.
|
|
204
|
+
async function childCli(f,operation){
|
|
205
|
+
f.close();fs.writeFileSync(path.join(f.root,'fix.json'),JSON.stringify(f.fix));
|
|
206
|
+
const args=['serve','--config',path.join(f.root,'run.json'),'--mode','resume','--host-context',A,'--allow-development',
|
|
207
|
+
'--review-config',path.join(f.root,'review.json'),'--workflow-config',path.join(f.root,'workflow.json'),'--allow-qa',
|
|
208
|
+
'--qa-fix-owner-config',path.join(f.root,'fix.json'),'--allow-qa-fix-start','--runtime','codex',
|
|
209
|
+
'--qa-fix-review-config',path.join(f.root,'child-review.json'),'--allow-qa-fix-cause-review'];
|
|
210
|
+
return new Promise((resolve,reject)=>{
|
|
211
|
+
const child=spawn(process.execPath,[fileURLToPath(new URL('./cm-ai-host.mjs',import.meta.url)),...args],
|
|
212
|
+
{env:{...process.env,PATH:f.bin+path.delimiter+process.env.PATH},stdio:['pipe','pipe','pipe']});
|
|
213
|
+
let buffer='',stderr='',sessionId;const rows=[];
|
|
214
|
+
const timer=setTimeout(()=>{child.kill();reject(Error('QA child routing CLI timed out'));},15000);
|
|
215
|
+
child.on('error',error=>{clearTimeout(timer);reject(error);});
|
|
216
|
+
child.stderr.on('data',chunk=>{stderr+=chunk;});
|
|
217
|
+
child.stdout.on('data',chunk=>{
|
|
218
|
+
buffer+=chunk;
|
|
219
|
+
while(buffer.includes('\n')){
|
|
220
|
+
const end=buffer.indexOf('\n'),line=buffer.slice(0,end);buffer=buffer.slice(end+1);if(!line)continue;
|
|
221
|
+
try{
|
|
222
|
+
const row=JSON.parse(line);rows.push(row);
|
|
223
|
+
if(row.type==='host_ready')sessionId=row.sessionId;
|
|
224
|
+
if(row.type==='host_request'){
|
|
225
|
+
assert(['fix_learning','fix_diagnose'].includes(row.kind),row.kind);
|
|
226
|
+
const result=row.kind==='fix_learning'?{contextDigest:row.payload.contextDigest,status:'no_relevant_lesson',summary:'Synthetic fixture'}:diagnosis;
|
|
227
|
+
child.stdin.write(JSON.stringify({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,result})+'\n');
|
|
228
|
+
}
|
|
229
|
+
if(row.requestId===operation.requestId)child.stdin.write(JSON.stringify({type:'host_close',sessionId})+'\n');
|
|
230
|
+
}catch(error){child.kill();clearTimeout(timer);reject(error);}
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
child.on('close',code=>{clearTimeout(timer);resolve({code,stderr,rows,result:rows.find(row=>row.requestId===operation.requestId)?.result});});
|
|
234
|
+
child.stdin.write(JSON.stringify(operation)+'\n');
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
for(const verified of [false,true])test(`public QA CLI preserves ${verified?'Codex host Claude verified reviewer':'legacy absent reviewer fields'}`,
|
|
238
|
+
{skip:verified&&process.platform!=='darwin'},async t=>{
|
|
239
|
+
const reviewVerification=verified?{files:['value.mjs','red.mjs','existing.mjs'],checks:[{id:'unit',command:[process.execPath,'existing.mjs']}],mutationPaths:['value.mjs'],timeoutMs:2000}:null;
|
|
240
|
+
const f=await fixture(t,{...(verified?{reviewRuntime:'claude',reviewVerification}:{})});
|
|
241
|
+
const first=await childCli(f,f.bound('fix_advance'));
|
|
242
|
+
assert.equal(first.code,0,JSON.stringify(first));assert.equal(first.result?.fixStage,'cause_review_required',JSON.stringify(first));
|
|
243
|
+
const saved=f.records()[0].payload.configuration;
|
|
244
|
+
assert.equal(saved.runtime??'codex','codex');assert.equal(saved.hostContextId,A);
|
|
245
|
+
assert.equal(saved.causeReview.provider,verified?'claude':'codex');
|
|
246
|
+
if(verified){assert.equal(saved.reviewRuntime,'claude');assert.deepEqual(saved.reviewVerification,reviewVerification);}
|
|
247
|
+
else{assert.equal(Object.hasOwn(saved,'reviewRuntime'),false);assert.equal(Object.hasOwn(saved,'reviewVerification'),false);}
|
|
248
|
+
const before=fs.readFileSync(f.statePath),resumed=await childCli(f,f.bound('fix_status'));
|
|
249
|
+
assert.equal(resumed.code,0,JSON.stringify(resumed));assert.equal(resumed.result?.fixStage,'cause_review_required');
|
|
250
|
+
assert.deepEqual(fs.readFileSync(f.statePath),before);assert.equal(f.causeReviews(),0);
|
|
251
|
+
assert.equal(f.records().filter(r=>r.id.endsWith('-registered')).length,0,'routing readiness does not claim provider execution');
|
|
252
|
+
});
|
|
@@ -132,6 +132,17 @@ test('reconciled provider failure spends the original one-retry budget and requi
|
|
|
132
132
|
assert.equal(f.dispatches(),2);assert.deepEqual(f.reopen().status(),final);
|
|
133
133
|
},{timeoutMs:20,reviewRun:lateReceiptRun({failed:true})}));
|
|
134
134
|
|
|
135
|
+
// A Codex 429 receipt keeps its class through reconciliation (2026-10-26).
|
|
136
|
+
test('reconciled Codex rate limit keeps the reviewer_rate_limited class',()=>fixture(async f=>{
|
|
137
|
+
const runner=f.make();await runner.executeEffect(f.effect('develop'));
|
|
138
|
+
const first=await runner.executeEffect(f.effect('review'));
|
|
139
|
+
const after=runner.reconcileReview({invocationId:first.reviewReconciliation.invocationId});
|
|
140
|
+
assert.equal(after.state,'pending_review',JSON.stringify(after));assert.equal(after.code,'review_provider_failed');
|
|
141
|
+
assert.match(after.reason,/^reviewer_rate_limited: /);
|
|
142
|
+
assert.equal(after.reviewInvocation.result.inspection.failure,'reviewer_rate_limited');
|
|
143
|
+
assert.deepEqual(f.reopen().status(),after);
|
|
144
|
+
},{timeoutMs:20,reviewRun:lateReceiptRun({failed:true,change:receipt=>{receipt.result.code='reviewer_rate_limited';}})}));
|
|
145
|
+
|
|
135
146
|
test('replay rejects receipt or reconciliation bindings even when an attacker recomputes the journal hash chain',()=>fixture(async f=>{
|
|
136
147
|
const runner=f.make();await runner.executeEffect(f.effect('develop'));
|
|
137
148
|
const end=await runner.executeEffect(f.effect('review'));
|
package/scripts/cm-failover.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import childProcess from 'node:child_process';
|
|
|
8
8
|
// Single source of truth for role primary/standby; shared with the cm-ai host.
|
|
9
9
|
import {ROLE_ROUTING} from '../runtime/js/cm-ai/runtime-failover.mjs';
|
|
10
10
|
import {taskDeclarations,approvedTaskGrammar,TASK_GRAMMAR} from '../runtime/js/spec-task-line.mjs';
|
|
11
|
+
import {parseFeatureTaskText,validDependencies} from '../runtime/js/cm-ai/cm-ai-admission.mjs';
|
|
11
12
|
|
|
12
13
|
export {ROLE_ROUTING};
|
|
13
14
|
|
|
@@ -135,31 +136,68 @@ export function classifyBreakpoint(task,attempts){
|
|
|
135
136
|
summary:`第 ${last.attempt} 次审查结论无法识别,需人工确认`};
|
|
136
137
|
}
|
|
137
138
|
|
|
139
|
+
function reviewEntries(reviewsDir){
|
|
140
|
+
if(!fs.existsSync(reviewsDir))return new Set();
|
|
141
|
+
return new Set(readDirectory(reviewsDir,'reviews directory').filter(e=>e.isFile()).map(e=>e.name));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// The current task follows the cm-ai admission rule: DROPPED tasks are skipped,
|
|
145
|
+
// and a task is ready only once each prerequisite is completed or DROPPED.
|
|
146
|
+
// Evidence of JS runs lives in <specs>/.reviews under the feature name without
|
|
147
|
+
// its number prefix; legacy runs keep <feature>/.reviews. The JS location wins.
|
|
138
148
|
function inspectFeature(featureDir,feature){
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
const grammar=approvedTaskGrammar(path.dirname(featureDir));
|
|
150
|
+
const text=readTextFile(path.join(featureDir,'tasks.md'),'tasks.md');
|
|
151
|
+
const tasks=parseTasks(text,grammar);
|
|
152
|
+
const parsed=parseFeatureTaskText(text,{allowDependencyPunctuation:true,grammar});
|
|
153
|
+
if(parsed.error)throw new FailoverError(`tasks.md is not readable by the cm-ai task rule: ${parsed.error}`);
|
|
154
|
+
if(!validDependencies(parsed.tasks,parsed.dependencies))throw new FailoverError('tasks.md dependencies are invalid by the cm-ai task rule: dependencies_invalid');
|
|
155
|
+
const dropped=new Set(parsed.tasks.filter(task=>task.dropped).map(task=>task.id));
|
|
156
|
+
const settled=id=>dropped.has(id)||tasks.some(task=>task.id===id&&task.done);
|
|
157
|
+
const ready=task=>(parsed.dependencies.get(task.id)??[]).every(settled);
|
|
158
|
+
const pending=tasks.filter(task=>!task.done&&!dropped.has(task.id));
|
|
159
|
+
const current=pending.find(ready)??null;
|
|
160
|
+
const specsReviews=path.join(path.dirname(featureDir),'.reviews'),slug=feature.replace(/^\d+\./,'');
|
|
161
|
+
const evidence=task=>{
|
|
162
|
+
const js=attemptEvidence(specsReviews,reviewEntries(specsReviews),slug,task.id);
|
|
163
|
+
if(js.length)return js;
|
|
164
|
+
const legacy=path.join(featureDir,'.reviews');
|
|
165
|
+
return attemptEvidence(legacy,reviewEntries(legacy),feature,task.id);
|
|
166
|
+
};
|
|
167
|
+
const breakpoint=pending.length===0
|
|
168
|
+
? {node:'N6',state:'all_tasks_done',summary:'全部任务已标记完成或作废,进入 QA 评估'}
|
|
169
|
+
: current===null
|
|
170
|
+
? {node:'N2',state:'dependencies_not_ready',summary:`剩余 ${pending.length} 个任务的依赖都未满足,需先处理依赖`}
|
|
171
|
+
: classifyBreakpoint(current,evidence(current));
|
|
149
172
|
return {feature,featureDir,tasks,
|
|
150
173
|
done:tasks.filter(task=>task.done).length,
|
|
174
|
+
dropped:dropped.size,
|
|
151
175
|
total:tasks.length,
|
|
152
176
|
currentTask:current,
|
|
153
177
|
breakpoint};
|
|
154
178
|
}
|
|
155
179
|
|
|
180
|
+
// Shared .reviews evidence is keyed by the feature name without its number, so
|
|
181
|
+
// two features that collide on either form cannot be told apart. Refuse them,
|
|
182
|
+
// as cm-ai admission does (feature_contract_invalid), before reading evidence.
|
|
183
|
+
function assertDistinctFeatureKeys(specsRoot){
|
|
184
|
+
const names=readDirectory(specsRoot,'specs directory')
|
|
185
|
+
.filter(entry=>entry.isDirectory()&&FEATURE_RE.test(entry.name)&&fs.existsSync(path.join(specsRoot,entry.name,'tasks.md')))
|
|
186
|
+
.map(entry=>entry.name);
|
|
187
|
+
const keys=names.flatMap(name=>[...new Set([name,name.replace(/^\d+\./,'')])]);
|
|
188
|
+
if(new Set(keys).size!==keys.length)
|
|
189
|
+
throw new FailoverError('feature names collide once their number is removed (feature_contract_invalid); shared review evidence would be ambiguous');
|
|
190
|
+
}
|
|
191
|
+
|
|
156
192
|
export function inspectSpecs(specsDir){
|
|
157
193
|
const resolved=path.resolve(specsDir);
|
|
158
194
|
if(fs.existsSync(path.join(resolved,'tasks.md'))){
|
|
159
195
|
const feature=path.basename(resolved);
|
|
160
196
|
if(!FEATURE_RE.test(feature))throw new FailoverError(`unsupported feature directory name: ${feature}`);
|
|
197
|
+
assertDistinctFeatureKeys(path.dirname(resolved));
|
|
161
198
|
return {specsDir:resolved,features:[inspectFeature(resolved,feature)]};
|
|
162
199
|
}
|
|
200
|
+
assertDistinctFeatureKeys(resolved);
|
|
163
201
|
const features=[];
|
|
164
202
|
for(const entry of readDirectory(resolved,'specs directory')){
|
|
165
203
|
if(!entry.isDirectory()||!FEATURE_RE.test(entry.name))continue;
|
|
@@ -96,6 +96,52 @@ test('全部完成后断点推进到 QA',()=>{
|
|
|
96
96
|
assert.equal(inspectSpecs(root).features[0].breakpoint.node,'N6');
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
+
// 总指挥第 0 期:接手脚本的「当前任务」与 cm-ai admission 同一规则。
|
|
100
|
+
test('当前任务跳过 DROPPED,并等依赖完成或作废',()=>{
|
|
101
|
+
const root=sandbox();
|
|
102
|
+
const dir=feature(root,'1.demo',[{id:'T-001',title:'a',done:false},{id:'T-002',title:'b',done:false},{id:'T-003',title:'c',done:false}]);
|
|
103
|
+
const text=fs.readFileSync(path.join(dir,'tasks.md'),'utf8')
|
|
104
|
+
.replace('T-001: a','T-001: ~~a~~ [DROPPED 不再需要]')+'\n- T-002 依赖 T-003\n';
|
|
105
|
+
fs.writeFileSync(path.join(dir,'tasks.md'),text);
|
|
106
|
+
const only=inspectSpecs(root).features[0];
|
|
107
|
+
assert.equal(only.currentTask.id,'T-003','T-001 作废被跳过,T-002 依赖未满足');
|
|
108
|
+
assert.equal(only.dropped,1);
|
|
109
|
+
fs.writeFileSync(path.join(dir,'tasks.md'),text.replace('- [ ] T-003','- [x] T-003'));
|
|
110
|
+
assert.equal(inspectSpecs(root).features[0].currentTask.id,'T-002','依赖完成后才轮到 T-002');
|
|
111
|
+
fs.writeFileSync(path.join(dir,'tasks.md'),text.replace('- [ ] T-002','- [x] T-002').replace('- [ ] T-003','- [x] T-003'));
|
|
112
|
+
assert.equal(inspectSpecs(root).features[0].breakpoint.state,'all_tasks_done','只剩作废任务算全部完成');
|
|
113
|
+
fs.writeFileSync(path.join(dir,'tasks.md'),'# d\n\n- [ ] T-001: ~~a~~ [DROPPED 不再需要]\n- [ ] T-002: b\n\n- T-002 依赖 T-001\n');
|
|
114
|
+
assert.equal(inspectSpecs(root).features[0].currentTask.id,'T-002','依赖的任务作废也算满足');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('feature 去编号后重名时拒绝读取共享证据,不把别的 feature 的批准算进来',()=>{
|
|
118
|
+
const root=sandbox();
|
|
119
|
+
feature(root,'1.demo',[{id:'T-001',title:'a',done:false}]);
|
|
120
|
+
const second=feature(root,'2.demo',[{id:'T-001',title:'b',done:false}]);
|
|
121
|
+
fs.mkdirSync(path.join(root,'.reviews'),{recursive:true});
|
|
122
|
+
handoff(root,'demo','T-001',1,{});review(root,'demo','T-001',1,'approved');
|
|
123
|
+
assert.throws(()=>inspectSpecs(root),/feature_contract_invalid/);
|
|
124
|
+
assert.throws(()=>inspectSpecs(second),/feature_contract_invalid/,'直接指向单个 feature 也核对同根冲突');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('依赖成环或指向未知任务时按 admission 规则拒绝,不乱选',()=>{
|
|
128
|
+
const root=sandbox();
|
|
129
|
+
const dir=feature(root,'1.demo',[{id:'T-001',title:'a',done:false},{id:'T-002',title:'b',done:false}]);
|
|
130
|
+
fs.appendFileSync(path.join(dir,'tasks.md'),'\n- T-001 依赖 T-002\n- T-002 依赖 T-001\n');
|
|
131
|
+
assert.throws(()=>inspectSpecs(root),FailoverError,'成环依赖按 admission 规则拒绝');
|
|
132
|
+
fs.writeFileSync(path.join(dir,'tasks.md'),'# d\n\n- [ ] T-001: a\n\n- T-001 依赖 T-009\n');
|
|
133
|
+
assert.throws(()=>inspectSpecs(root),FailoverError,'未知依赖按 admission 规则拒绝');
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('JS 运行的交接证据在 specs 根 .reviews 下按去编号的 feature 名读取',()=>{
|
|
137
|
+
const root=sandbox();
|
|
138
|
+
feature(root,'1.demo',[{id:'T-001',title:'a',done:false}]);
|
|
139
|
+
fs.mkdirSync(path.join(root,'.reviews'),{recursive:true});
|
|
140
|
+
handoff(root,'demo','T-001',1,{});review(root,'demo','T-001',1,'approved');
|
|
141
|
+
const point=inspectSpecs(root).features[0].breakpoint;
|
|
142
|
+
assert.equal(point.state,'approved');assert.equal(point.node,'N5');
|
|
143
|
+
});
|
|
144
|
+
|
|
99
145
|
test('blocked 交接把阻塞项带进简报',()=>{
|
|
100
146
|
const root=sandbox();
|
|
101
147
|
const dir=feature(root,'1.demo',[{id:'T-001',title:'a',done:false}]);
|
|
@@ -6,16 +6,19 @@ import path from 'node:path';
|
|
|
6
6
|
import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
|
|
7
7
|
import {createHostReviewAuthority} from '../runtime/js/cm-ai/host-review-authority.mjs';
|
|
8
8
|
import {createCauseReviewRun} from '../runtime/js/cm-ai/codex-review-adapter.mjs';
|
|
9
|
+
import {inspectCauseRegistration} from '../runtime/js/cm-fix/cause-invocation.mjs';
|
|
9
10
|
|
|
10
|
-
for(const
|
|
11
|
+
for(const [runtime,reviewRuntime] of [['codex',null],['claude',null],['codex','claude'],['claude','codex']])
|
|
12
|
+
for(const outcome of ['approved','incomplete','denied','timeout','cancelled'])test(`${runtime}/${reviewRuntime??runtime} cause invocation ${outcome} uses original grant and durable registration`,async()=>{
|
|
13
|
+
const provider=reviewRuntime??runtime;
|
|
11
14
|
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-cause-call-')));
|
|
12
15
|
const cwd=path.join(root,'code'),specsRoot=path.join(root,'specs');fs.mkdirSync(cwd);fs.mkdirSync(specsRoot);
|
|
13
16
|
fs.writeFileSync(path.join(cwd,'value.mjs'),'export const value=1;');
|
|
14
17
|
const identity={repositoryId:'fixture',runId:'cause-review-run',taskId:'T-FIX-cause',attempt:1};
|
|
15
|
-
const reviewer={reviewerId:'cause-reviewer',adapterId
|
|
18
|
+
const reviewer={reviewerId:'cause-reviewer',adapterId:`${provider}-review-adapter`,provider,requestedModel:'synthetic',
|
|
16
19
|
contextId:'logical-review',excludedThreadIds:['other-author']};
|
|
17
20
|
fs.symlinkSync(root,path.join(root,'parent-alias'));
|
|
18
|
-
const options={specsRoot:outcome==='approved'?path.join(root,'parent-alias','specs'):specsRoot,identity,create:true,configuration:{hostContextId:'fixture-host',defect:'Synthetic value mismatch',causeReview:reviewer,
|
|
21
|
+
const options={specsRoot:outcome==='approved'?path.join(root,'parent-alias','specs'):specsRoot,identity,create:true,configuration:{hostContextId:'fixture-host',...(runtime==='claude'?{runtime}:{}),...(reviewRuntime?{reviewRuntime}:{}),defect:'Synthetic value mismatch',causeReview:reviewer,
|
|
19
22
|
reproduction:{cwd,command:[process.execPath,'-e',"process.stderr.write('BUG');process.exit(3)"],
|
|
20
23
|
expectedFailure:{exitCode:3,outputIncludes:'BUG'},timeoutMs:1000}}};
|
|
21
24
|
const authority=createHostReviewAuthority({hostContextId:'fixture-host',reviewerId:reviewer.reviewerId,adapterId:reviewer.adapterId,
|
|
@@ -37,7 +40,7 @@ for(const outcome of ['approved','incomplete','denied','timeout','cancelled'])te
|
|
|
37
40
|
{event:'turn.completed',item_type:null},{event:'process_closed',exit_code:0,signal:null,timed_out:false}])assert.equal(onEvent(event),true);
|
|
38
41
|
return {status:'succeeded',value:{verdict:'approved',packageDigest:data.reviewPackage.packageDigest,
|
|
39
42
|
examinedPaths:['value.mjs'],findings:[],summary:'No finding in synthetic package'}};
|
|
40
|
-
},
|
|
43
|
+
},provider)};
|
|
41
44
|
try{
|
|
42
45
|
owner=openFixExecution(options,{causeReview,bridge:{async call(){return {status:'diagnosed',rootCause:'Cross-layer constant',
|
|
43
46
|
plan:'Correct source after red test',affectedPaths:['value.mjs'],affectedModules:['value'],crossLayer:true};}}});
|
|
@@ -51,6 +54,18 @@ for(const outcome of ['approved','incomplete','denied','timeout','cancelled'])te
|
|
|
51
54
|
if(lateEvent)assert.equal(lateEvent({event:'turn.started',item_type:null}),false);
|
|
52
55
|
assert.equal((await owner.reviewCause()).stage,result.stage);assert.equal(calls,outcome==='denied'?0:1);
|
|
53
56
|
if(outcome==='approved'){
|
|
57
|
+
const records=JSON.parse(fs.readFileSync(path.join(specsRoot,'.reviews','.execution',identity.runId,'state.json'))).records;
|
|
58
|
+
const registered=records.find(record=>record.id==='fix-cause-registered').payload;
|
|
59
|
+
assert.equal(registered.request.provider,provider);
|
|
60
|
+
assert.equal(registered.grant.adapterId,reviewer.adapterId);
|
|
61
|
+
assert.equal(registered.grant.hostContextId,'fixture-host');
|
|
62
|
+
assert.deepEqual(inspectCauseRegistration(registered,options.configuration),registered);
|
|
63
|
+
const wrongProvider=structuredClone(registered);wrongProvider.request.provider=provider==='codex'?'claude':'codex';
|
|
64
|
+
assert.throws(()=>inspectCauseRegistration(wrongProvider,options.configuration),{code:'cause_registration_mismatch'});
|
|
65
|
+
const wrongModel=structuredClone(registered);wrongModel.request.requestedModel='different-model';
|
|
66
|
+
assert.throws(()=>inspectCauseRegistration(wrongModel,options.configuration),{code:'cause_registration_mismatch'});
|
|
67
|
+
const expired=structuredClone(registered);expired.registeredAt=expired.grant.expiresAt;
|
|
68
|
+
assert.throws(()=>inspectCauseRegistration(expired,options.configuration),{code:'runner_grant'});
|
|
54
69
|
const evidence=path.join(specsRoot,'.reviews','fix-cause-cause-r1.md');
|
|
55
70
|
const bytes=fs.readFileSync(evidence);
|
|
56
71
|
assert.match(bytes.toString(),/phase: cause\nround: 1\nverdict: approved/);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Qualification only: no writer, source edits, command execution or provider.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import {fileURLToPath} from 'node:url';
|
|
6
|
+
import {inspectFixCommandCorrection} from '../runtime/js/cm-fix/execution.mjs';
|
|
7
|
+
import {need} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
8
|
+
export function main(argv=process.argv.slice(2),{output=process.stdout,error=process.stderr}={}){
|
|
9
|
+
try{
|
|
10
|
+
need(argv.length===4&&argv[0]==='--config'&&argv[2]==='--jest-config','invalid_arguments');
|
|
11
|
+
const stat=fs.lstatSync(argv[1]);need(stat.isFile()&&!stat.isSymbolicLink()&&stat.size<=64*1024,'invalid_fix_config');
|
|
12
|
+
const c=JSON.parse(fs.readFileSync(argv[1],'utf8')),specsRoot=fs.realpathSync(c.specsRoot??path.join(c.reproduction.cwd,'docs/fixes'));
|
|
13
|
+
const expected=inspectFixCommandCorrection({specsRoot,identity:{repositoryId:c.identity.repositoryId,runId:c.identity.runId},declaration:{kind:'jest-config-path',path:argv[3]}});
|
|
14
|
+
output.write(JSON.stringify({eligible:true,expected})+'\n');return 0;
|
|
15
|
+
}catch(e){const code=/^[a-z_]{1,64}$/.test(e?.code??'')?e.code:'fix_command_correction_unavailable';error.write(JSON.stringify({eligible:false,code})+'\n');return 1;}
|
|
16
|
+
}
|
|
17
|
+
if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url))process.exitCode=main();
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {spawnSync} from 'node:child_process';
|
|
7
|
+
import {fileURLToPath} from 'node:url';
|
|
8
|
+
import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
|
|
9
|
+
import {openExecutionStore} from '../runtime/js/cm-ai/execution-store.mjs';
|
|
10
|
+
import * as execution from '../runtime/js/cm-fix/execution.mjs';
|
|
11
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
12
|
+
import {assertJestConfigurationDiscovery} from '../runtime/js/cm-fix/jest-command-correction.mjs';
|
|
13
|
+
import {startFixRun} from '../runtime/js/cm-fix/start.mjs';
|
|
14
|
+
import {createHostReviewAuthority} from '../runtime/js/cm-ai/host-review-authority.mjs';
|
|
15
|
+
import {fixFinalReviewConfiguration} from '../runtime/js/cm-fix/final-review.mjs';
|
|
16
|
+
import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
17
|
+
|
|
18
|
+
const DRIVER=fileURLToPath(new URL('./cm-fix-drive.mjs',import.meta.url));
|
|
19
|
+
const INSPECT=fileURLToPath(new URL('./cm-fix-command-correction.mjs',import.meta.url));
|
|
20
|
+
|
|
21
|
+
async function fixture(t,{green=false,unrelated=false,closeout=false,summaryFailure=false,configRepairScope=false,commandSuffix=[]}={}){
|
|
22
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-jest-correction-'))),cwd=path.join(root,'code'),specsRoot=path.join(root,'specs');
|
|
23
|
+
fs.mkdirSync(path.join(cwd,'app/node_modules/jest/bin'),{recursive:true});fs.mkdirSync(specsRoot);
|
|
24
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
25
|
+
fs.writeFileSync(path.join(cwd,'app/package.json'),JSON.stringify({jest:{}}));
|
|
26
|
+
if(closeout)fs.writeFileSync(path.join(cwd,'.cm-workflow.json'),JSON.stringify({version:1,policies:{delivery:'diff'}}));
|
|
27
|
+
fs.writeFileSync(path.join(cwd,'value.mjs'),'export const value=1;');
|
|
28
|
+
fs.writeFileSync(path.join(cwd,'test.mjs'),"import {value} from './value.mjs';if(value!==2){console.error('TARGET BUG');process.exit(1)}");
|
|
29
|
+
const cli='app/node_modules/jest/bin/jest.js',callsPath=path.join(root,'check-calls');
|
|
30
|
+
fs.writeFileSync(path.join(cwd,cli),`const fs=require('node:fs');fs.appendFileSync(${JSON.stringify(callsPath)},'1');if(!process.argv.includes('--config')){console.error('Error: Could not find a config file based on provided values:\\ncwd: "'+process.cwd()+'"');process.exit(1)}if(process.argv.includes('--baseline'))process.exit(0);import(process.cwd()+'/test.mjs');`);
|
|
31
|
+
if(summaryFailure){const file=path.join(cwd,cli);fs.writeFileSync(file,fs.readFileSync(file,'utf8').replace('process.exit(1)',"console.error('Test Suites: 1 failed, 1 total');process.exit(1)"));}
|
|
32
|
+
const command=[process.execPath,cli,'--rootDir','app',...commandSuffix];
|
|
33
|
+
const options={specsRoot,identity:{repositoryId:'fixture',runId:'jest-command',taskId:'T-FIX-command',attempt:1},create:true,configuration:{hostContextId:'fixture-host',defect:'Wrong constant',
|
|
34
|
+
reproduction:{cwd,command:[process.execPath,'test.mjs'],expectedFailure:{exitCode:1,outputIncludes:'TARGET BUG'},timeoutMs:3000},
|
|
35
|
+
redTest:{cwd,command:green?[process.execPath,'-e','process.exit(0)']:unrelated?[process.execPath,'-e',"console.error('OTHER');process.exit(1)"]:command,testFiles:['test.mjs'],expectedFailure:{exitCode:1,outputIncludes:'TARGET BUG'},timeoutMs:3000},
|
|
36
|
+
baseline:{cwd,testFiles:['test.mjs'],commands:[{id:'existing',command:[...command,'--baseline']}],timeoutMs:3000},
|
|
37
|
+
repair:{scope:configRepairScope?['value.mjs','app/package.json']:['value.mjs'],requirements:['value.mjs']},walkthrough:{flows:[{id:'flow',modules:['one'],kind:'commands',steps:['Run constant'],expected:['No error'],command}],timeoutMs:3000}}};
|
|
38
|
+
if(closeout){options.configuration.reviewRuntime='claude';options.configuration.causeReview={reviewerId:'fixture-cause',adapterId:'claude-review-adapter',provider:'claude',requestedModel:'synthetic',contextId:'fixture-cause-context',excludedThreadIds:[]};}
|
|
39
|
+
const learning={files:[],contextDigest:digest([]),application:{contextDigest:digest([]),status:'no_relevant_lesson',summary:'Fixture'}};
|
|
40
|
+
const bridge={call:async(kind)=>{
|
|
41
|
+
if(kind==='fix_diagnose')return {status:'diagnosed',rootCause:'Wrong constant',affectedPaths:['value.mjs'],plan:'Set value to 2',crossLayer:false,affectedModules:['one'],investigation:{discardedAlternatives:[],boundaryAnalysis:null}};
|
|
42
|
+
if(kind==='fix_retrospective')return {status:'no_new_lesson',candidates:[],reason:null};
|
|
43
|
+
assert.equal(kind,'fix_repair');fs.writeFileSync(path.join(cwd,'value.mjs'),'export const value=2;');return {outcome:'repaired'};
|
|
44
|
+
}};
|
|
45
|
+
const capabilities={bridge,assertReviewReady(){},...(closeout?{prepare:async()=>learning}:{})};
|
|
46
|
+
let owner=openFixExecution(options,capabilities);t.after(()=>owner.close());
|
|
47
|
+
if(closeout)startFixRun({specsRoot,identity:options.identity,configuration:options.configuration});
|
|
48
|
+
await owner.advance({authorized:true});assert.equal((await owner.runRedTest({authorized:true})).stage,'red_test_not_confirmed');
|
|
49
|
+
const statePath=path.join(specsRoot,'.reviews/.execution/jest-command/state.json'),state=()=>JSON.parse(fs.readFileSync(statePath));
|
|
50
|
+
const reopen=(extra={})=>{owner.close();owner=openFixExecution({...options,create:false},{...capabilities,...extra});return owner;};
|
|
51
|
+
return {root,cwd,specsRoot,options,statePath,state,reopen,checkCalls:()=>fs.readFileSync(callsPath,'utf8'),get owner(){return owner;},declaration:{kind:'jest-config-path',path:'app/package.json'}};
|
|
52
|
+
}
|
|
53
|
+
test('original not-red run gains one explicit correction; all later command phases and replay use corrected argv',async t=>{
|
|
54
|
+
const f=await fixture(t),before=f.state(),output=f.owner.status().redTest.output,old=fs.readFileSync(path.join(f.specsRoot,output.path));
|
|
55
|
+
const expected=f.owner.inspectCommandCorrection({declaration:f.declaration});
|
|
56
|
+
assert.deepEqual(f.state(),before);assert.equal(expected.commands.length,3);
|
|
57
|
+
assert.throws(()=>f.owner.prepareCommandCorrection({expected,declaration:f.declaration,previousInvocationStopped:true,reason:'explicit config'}),{code:'fix_command_correction_authorization_required'});
|
|
58
|
+
const input={authorized:true,expected,declaration:f.declaration,previousInvocationStopped:true,reason:'Explicitly add config discovery only'};
|
|
59
|
+
assert.equal(f.owner.prepareCommandCorrection(input).stage,'red_test_required');
|
|
60
|
+
assert.deepEqual(f.state().records.slice(0,before.records.length),before.records);assert.deepEqual(f.state().fingerprints,before.fingerprints);
|
|
61
|
+
assert.equal((await f.reopen().runRedTest({authorized:true})).stage,'baseline_required');
|
|
62
|
+
assert.match(f.owner.status().redTest.output.path,/-retry-1\.md$/);assert.deepEqual(fs.readFileSync(path.join(f.specsRoot,output.path)),old);
|
|
63
|
+
assert.equal((await f.owner.captureBaseline({authorized:true})).stage,'repair_required');
|
|
64
|
+
assert.equal(f.owner.status().baseline.observations[0].outcome,'passed');
|
|
65
|
+
assert.equal((await f.owner.repair({authorized:true})).stage,'regression_required');
|
|
66
|
+
assert.equal((await f.owner.runRegression({authorized:true})).stage,'handoff_required');
|
|
67
|
+
assert.equal(f.reopen().status().stage,'handoff_required');
|
|
68
|
+
assert.equal(f.owner.status().regression.red.outcome,'passed');assert.equal(f.owner.status().regression.baseline.observations[0].outcome,'passed');
|
|
69
|
+
assert.throws(()=>f.owner.prepareCommandCorrection(input),{code:'fix_command_correction_used'});
|
|
70
|
+
});
|
|
71
|
+
test('qualification rejects real green/unrelated failure, stale history, changed tests/config and arbitrary corrections',async t=>{
|
|
72
|
+
for(const mode of ['green','unrelated']){
|
|
73
|
+
const f=await fixture(t,{[mode]:true});assert.throws(()=>f.owner.inspectCommandCorrection({declaration:f.declaration}),{code:'fix_command_correction_unavailable'});f.owner.close();
|
|
74
|
+
}
|
|
75
|
+
const f=await fixture(t),expected=f.owner.inspectCommandCorrection({declaration:f.declaration});
|
|
76
|
+
for(const override of [{previousInvocationStopped:false},{reason:''},{expected:{...expected,historyDigest:digest('stale')}}]){
|
|
77
|
+
assert.throws(()=>f.owner.prepareCommandCorrection({authorized:true,expected,declaration:f.declaration,previousInvocationStopped:true,reason:'fixed',...override}));
|
|
78
|
+
}
|
|
79
|
+
const old=fs.readFileSync(path.join(f.cwd,'test.mjs'));fs.appendFileSync(path.join(f.cwd,'test.mjs'),'\n// drift');
|
|
80
|
+
assert.throws(()=>f.owner.prepareCommandCorrection({authorized:true,expected,declaration:f.declaration,previousInvocationStopped:true,reason:'fixed'}));
|
|
81
|
+
fs.writeFileSync(path.join(f.cwd,'test.mjs'),old);
|
|
82
|
+
assert.throws(()=>f.owner.inspectCommandCorrection({declaration:{...f.declaration,command:['anything']}}));
|
|
83
|
+
fs.appendFileSync(path.join(f.cwd,'app/package.json'),' ');
|
|
84
|
+
assert.throws(()=>f.owner.prepareCommandCorrection({authorized:true,expected,declaration:f.declaration,previousInvocationStopped:true,reason:'fixed'}),{code:'fix_command_correction_stale'});
|
|
85
|
+
});
|
|
86
|
+
test('read-only inspection API exists and new-run launch preflight rejects every missing Jest configuration',()=>{
|
|
87
|
+
assert.equal(typeof execution.inspectFixCommandCorrection,'function');
|
|
88
|
+
const config={reproduction:{cwd:'/no-such-fixture'},redTest:{cwd:'/no-such-fixture',command:['node','app/node_modules/jest/bin/jest.js','--rootDir','app']}};
|
|
89
|
+
assert.throws(()=>assertJestConfigurationDiscovery(config),{code:'fix_jest_config_path_required'});
|
|
90
|
+
assert.doesNotThrow(()=>assertJestConfigurationDiscovery({...config,redTest:{...config.redTest,command:[...config.redTest.command,'--config','app/package.json']}}));
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('real inspector and driver prepare one correction without running checks or altering old records',async t=>{
|
|
94
|
+
const f=await fixture(t),before=f.state(),checkCalls=f.checkCalls();f.owner.close();
|
|
95
|
+
const config=path.join(f.root,'config.json'),plan=path.join(f.root,'plan.json');
|
|
96
|
+
const {hostContextId,...configuration}=f.options.configuration;
|
|
97
|
+
fs.writeFileSync(config,JSON.stringify({...configuration,specsRoot:f.specsRoot,identity:f.options.identity}));
|
|
98
|
+
const cli=args=>spawnSync(process.execPath,args,{encoding:'utf8',timeout:30000,env:{...process.env,CM_WORKFLOW_HOME:path.join(f.root,'home'),CM_WORKFLOW_LOG_HOME:path.join(f.root,'logs')}});
|
|
99
|
+
const preview=cli([INSPECT,'--config',config,'--jest-config',f.declaration.path]);
|
|
100
|
+
assert.equal(preview.status,0,preview.stdout+preview.stderr);
|
|
101
|
+
const expected=JSON.parse(preview.stdout).expected;assert.equal(expected.commands.length,3);assert.deepEqual(f.state(),before);
|
|
102
|
+
const base={config,cwd:f.cwd,mode:'resume',hostContext:hostContextId,runtime:'codex',expected,commandCorrection:f.declaration,previousInvocationStopped:true,reason:'Explicit Jest discovery correction'};
|
|
103
|
+
const drive=(permissions,extra={})=>{fs.writeFileSync(plan,JSON.stringify({...base,permissions,...extra}));return cli([DRIVER,'--plan',plan,'prepare_command_correction']);};
|
|
104
|
+
for(const [permissions,extra]of [[[],{}],[['--allow-command-correction'],{previousInvocationStopped:false}],[['--allow-command-correction'],{mode:'create'}]]){
|
|
105
|
+
const rejected=drive(permissions,extra);assert.notEqual(rejected.status,0);assert.deepEqual(f.state(),before);
|
|
106
|
+
}
|
|
107
|
+
const prepared=drive(['--allow-command-correction']);assert.equal(prepared.status,0,prepared.stdout+prepared.stderr);
|
|
108
|
+
assert.match(prepared.stdout,/red_test_required/);
|
|
109
|
+
const after=f.state();assert.deepEqual(after.records.slice(0,before.records.length),before.records);assert.deepEqual(after.fingerprints,before.fingerprints);
|
|
110
|
+
assert.equal(after.records.length,before.records.length+1);
|
|
111
|
+
const again=drive(['--allow-command-correction']);assert.notEqual(again.status,0);assert.deepEqual(f.state(),after);
|
|
112
|
+
const used=cli([INSPECT,'--config',config,'--jest-config',f.declaration.path]);assert.notEqual(used.status,0);assert.match(used.stderr,/fix_command_correction_used/);
|
|
113
|
+
assert.equal(f.checkCalls(),checkCalls);
|
|
114
|
+
assert.equal((await f.reopen().runRedTest({authorized:true})).stage,'baseline_required');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('corrected original run completes fixture review, N5, post-review regression, walkthrough and finish',async t=>{
|
|
118
|
+
const f=await fixture(t,{closeout:true}),before=f.state(),expected=f.owner.inspectCommandCorrection({declaration:f.declaration});
|
|
119
|
+
f.owner.prepareCommandCorrection({authorized:true,expected,declaration:f.declaration,previousInvocationStopped:true,reason:'Explicit Jest discovery correction'});
|
|
120
|
+
assert.equal((await f.reopen().runRedTest({authorized:true})).stage,'baseline_required');
|
|
121
|
+
assert.equal((await f.owner.captureBaseline({authorized:true})).stage,'repair_required');
|
|
122
|
+
assert.equal((await f.owner.repair({authorized:true})).stage,'regression_required');
|
|
123
|
+
assert.equal((await f.owner.runRegression({authorized:true})).stage,'handoff_required');
|
|
124
|
+
assert.equal((await f.owner.retrospect()).stage,'handoff_ready');
|
|
125
|
+
assert.equal(f.owner.createHandoff().stage,'final_review_required');
|
|
126
|
+
const pkg=f.owner.finalReviewPackage();assert(pkg.checks.every(c=>c.outcome==='passed'));
|
|
127
|
+
const settings=fixFinalReviewConfiguration(f.options.configuration),authority=createHostReviewAuthority({hostContextId:settings.hostContextId,reviewerId:settings.reviewer.reviewerId,adapterId:settings.reviewer.adapterId,decide:async()=>({status:'approved'})});
|
|
128
|
+
await authority.hostDecisionProvider.decide({identity:pkg.identity,packageDigest:pkg.packageDigest},new AbortController().signal);
|
|
129
|
+
let calls=0;
|
|
130
|
+
f.reopen({finalReview:{authorize:authority.authorize,run:async(request,{onEvent})=>{
|
|
131
|
+
assert.equal(request.provider,'claude');assert.equal(request.requestedModel,'synthetic');
|
|
132
|
+
calls++;for(const event of [{event:'thread.started',provider_thread:'synthetic-command-correction-reviewer'},{event:'turn.started',item_type:null},{event:'item.completed',item_type:'agent_message'},{event:'turn.completed',item_type:null},{event:'process_closed',exit_code:0,signal:null,timed_out:false}])assert.equal(onEvent(event),true);
|
|
133
|
+
return {status:'succeeded',value:{verdict:'approved',packageDigest:request.payload.reviewPackage.packageDigest,examinedPaths:reviewPaths(request.payload.reviewPackage),findings:[],summary:'Synthetic fixture only; no Claude call'}};
|
|
134
|
+
}}});
|
|
135
|
+
assert.equal((await f.owner.reviewFinal()).stage,'final_review_evidence_required');assert.equal(calls,1);
|
|
136
|
+
assert.equal(f.owner.publishReview().stage,'completion_gate_required');
|
|
137
|
+
assert.equal(f.owner.checkCompletionGate().stage,'post_review_regression_required');
|
|
138
|
+
assert.equal((await f.owner.runRegression({authorized:true,postReview:true})).stage,'closeout_required');
|
|
139
|
+
assert.equal((await f.reopen().runWalkthrough({authorized:true})).stage,'closeout_required');
|
|
140
|
+
assert.equal(f.owner.status().walkthrough.status,'passed');
|
|
141
|
+
assert.equal(f.owner.status().walkthrough.rows[0].observation.command.at(-1),'app/package.json');
|
|
142
|
+
f.owner.publishDossier();
|
|
143
|
+
const finished=f.owner.finish({authorized:true});assert.equal(finished.stage,'completed');assert.equal(finished.completionEligible,true);
|
|
144
|
+
assert.equal(f.reopen().status().stage,'completed');assert.equal(f.owner.completionEvidence().identity.runId,f.options.identity.runId);
|
|
145
|
+
assert.deepEqual(f.state().records.slice(0,before.records.length),before.records);assert.deepEqual(f.state().fingerprints,before.fingerprints);
|
|
146
|
+
assert.equal(calls,1);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('prepared correction refuses source drift before corrected red without losing history or executing another check',async t=>{
|
|
150
|
+
const f=await fixture(t),expected=f.owner.inspectCommandCorrection({declaration:f.declaration});
|
|
151
|
+
f.owner.prepareCommandCorrection({authorized:true,expected,declaration:f.declaration,previousInvocationStopped:true,reason:'Explicit Jest discovery correction'});
|
|
152
|
+
const prepared=f.state(),checkCalls=f.checkCalls(),source=path.join(f.cwd,'value.mjs'),original=fs.readFileSync(source);
|
|
153
|
+
fs.appendFileSync(source,'\n// unrelated drift after qualification');
|
|
154
|
+
assert.equal(f.owner.status().stage,'command_correction_drift');
|
|
155
|
+
assert.equal((await f.owner.runRedTest({authorized:true})).stage,'command_correction_drift');
|
|
156
|
+
assert.deepEqual(f.state(),prepared);
|
|
157
|
+
f.reopen();assert.equal(f.owner.status().stage,'command_correction_drift');assert.deepEqual(f.state(),prepared);
|
|
158
|
+
assert.equal(f.checkCalls(),checkCalls);
|
|
159
|
+
fs.writeFileSync(source,original);
|
|
160
|
+
assert.equal(f.owner.status().stage,'red_test_required');
|
|
161
|
+
assert.equal((await f.owner.runRedTest({authorized:true})).stage,'baseline_required');
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Startup correction must not become a retry for tests that actually ran, or
|
|
165
|
+
// freeze a configuration file which the declared repair itself must change.
|
|
166
|
+
test('qualification rejects Jest test summaries and repair-owned configuration',async t=>{
|
|
167
|
+
for(const option of ['summaryFailure','configRepairScope']){
|
|
168
|
+
const f=await fixture(t,{[option]:true}),before=f.state();
|
|
169
|
+
assert.throws(()=>f.owner.inspectCommandCorrection({declaration:f.declaration}),{code:option==='summaryFailure'?'fix_command_correction_unavailable':'fix_command_correction_config'});
|
|
170
|
+
assert.deepEqual(f.state(),before);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test('corrected red retry budget refuses an eighth abandon before poisoning replay',async t=>{
|
|
175
|
+
const f=await fixture(t),expected=f.owner.inspectCommandCorrection({declaration:f.declaration});
|
|
176
|
+
f.owner.prepareCommandCorrection({authorized:true,expected,declaration:f.declaration,previousInvocationStopped:true,reason:'Explicit Jest discovery correction'});
|
|
177
|
+
for(let retry=1;retry<=8;retry++){
|
|
178
|
+
// An occupied private result path makes this isolated command's publication
|
|
179
|
+
// unknown, without fabricating or editing a journal record.
|
|
180
|
+
const output=path.join(f.specsRoot,`.reviews/fix-command-a1-red-output-retry-${retry}.md`);
|
|
181
|
+
fs.writeFileSync(output,'existing evidence must survive',{mode:0o600});
|
|
182
|
+
assert.equal((await f.owner.runRedTest({authorized:true})).stage,'unknown');
|
|
183
|
+
if(retry<8){assert.equal(f.owner.abandonStep({authorized:true,reason:'Stopped fixture command; preserve lost result'}).stage,'red_test_required');f.reopen();}
|
|
184
|
+
}
|
|
185
|
+
const before=f.state();
|
|
186
|
+
assert.throws(()=>f.owner.abandonStep({authorized:true,reason:'Must not create retry nine'}),{code:'fix_abandon_limit'});
|
|
187
|
+
assert.deepEqual(f.state(),before);assert.equal(f.reopen().status().stage,'unknown');
|
|
188
|
+
assert.equal((await f.owner.runRedTest({authorized:true})).stage,'unknown');assert.deepEqual(f.state(),before);
|
|
189
|
+
assert.equal(f.state().records.some(r=>r.id.includes('retry-9')),false);
|
|
190
|
+
// Upgrade fixture: the old runtime could already have appended abandon #8.
|
|
191
|
+
// Preserve that legal prefix and refuse the next intent before any append.
|
|
192
|
+
f.owner.close();
|
|
193
|
+
const history=f.state(),store=openExecutionStore({specsRoot:f.specsRoot,identity:history.identity,fingerprints:history.fingerprints,create:false});
|
|
194
|
+
try{store.append({id:'fix-abandoned-8',kind:'result',expectedRevision:history.revision,payload:{pending:'red_test',reason:'Old-runtime legal abandon',abandonedAt:Date.now(),intentDigest:digest(history.records.at(-1))}});}finally{store.close();}
|
|
195
|
+
const legacy=f.state();assert.equal(f.reopen().status().stage,'red_test_required');
|
|
196
|
+
await assert.rejects(()=>f.owner.runRedTest({authorized:true}),{code:'fix_abandon_limit'});
|
|
197
|
+
assert.deepEqual(f.state(),legacy);assert.equal(f.reopen().status().stage,'red_test_required');
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('new-run configuration discovery accepts Jest default package.json without jest field',t=>{
|
|
201
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'jest-default-config-')));t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
202
|
+
fs.writeFileSync(path.join(root,'package.json'),'{}');
|
|
203
|
+
assert.doesNotThrow(()=>assertJestConfigurationDiscovery({reproduction:{cwd:root},redTest:{cwd:root,command:['node','node_modules/jest/bin/jest.js','--rootDir','.']}}));
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test('qualification refuses Jest option separators and existing short config alias',async t=>{
|
|
207
|
+
for(const commandSuffix of [['--'],['-c','app/package.json']]){
|
|
208
|
+
const f=await fixture(t,{commandSuffix}),before=f.state();
|
|
209
|
+
assert.throws(()=>f.owner.inspectCommandCorrection({declaration:f.declaration}),{code:'fix_command_correction_config'});assert.deepEqual(f.state(),before);
|
|
210
|
+
}
|
|
211
|
+
});
|