@aibyzero/cm-workflow 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +27 -0
- package/CHANGELOG.md +230 -1
- package/CONTRIBUTING.md +47 -0
- package/README.md +21 -3
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/VERSION +1 -1
- package/compat/claude-commands/cm-challenge.md +3 -0
- package/docs/architecture.md +40 -13
- package/docs/cm-control-policy-v2.md +127 -9
- package/docs/fixes/20261013-claude-preinit-ui-invalidate.md +48 -0
- package/docs/installation.md +310 -4
- package/docs/js-workflow-control.md +153 -16
- package/docs/live-evidence-drivers.md +28 -4
- package/docs/out-of-scope/README.md +25 -0
- package/docs/out-of-scope/background-supervisor.md +32 -0
- package/docs/reviewed-integration.md +48 -0
- package/docs/user-guide.md +50 -21
- package/install-codex.sh +331 -18
- package/install.ps1 +28 -2
- package/install.sh +321 -17
- package/package.json +2 -1
- package/runtime/js/cm-ai/batch-location.mjs +55 -0
- package/runtime/js/cm-ai/batch-plan.mjs +242 -0
- package/runtime/js/cm-ai/checkpoint-package-material.mjs +162 -0
- package/runtime/js/cm-ai/claude-developer-proposal.schema.json +55 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +94 -21
- package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-admission.mjs +18 -12
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +91 -6
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +5 -1
- package/runtime/js/cm-ai/codex-config.mjs +6 -2
- package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +3 -2
- package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
- package/runtime/js/cm-ai/codex-reconnect-notice.mjs +6 -0
- package/runtime/js/cm-ai/codex-review-adapter.mjs +27 -7
- package/runtime/js/cm-ai/control-policy.mjs +24 -6
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +236 -34
- package/runtime/js/cm-ai/drive-rate-limit.mjs +105 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +234 -33
- package/runtime/js/cm-ai/effect-contract.mjs +11 -2
- package/runtime/js/cm-ai/execution-policy.mjs +3 -1
- package/runtime/js/cm-ai/execution-snapshot.mjs +4 -2
- package/runtime/js/cm-ai/execution-store-limits.mjs +14 -7
- package/runtime/js/cm-ai/execution-store.mjs +60 -17
- package/runtime/js/cm-ai/fix-code-association.mjs +73 -2
- package/runtime/js/cm-ai/host-check.mjs +14 -6
- package/runtime/js/cm-ai/host-conversation-execution.mjs +70 -28
- package/runtime/js/cm-ai/host-qa-executor.mjs +38 -5
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +19 -2
- package/runtime/js/cm-ai/host-replay.mjs +148 -0
- package/runtime/js/cm-ai/host-session.mjs +42 -9
- package/runtime/js/cm-ai/host-stage-observer.mjs +26 -0
- package/runtime/js/cm-ai/host-tool-bridge.mjs +22 -9
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +19 -2
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/implicit-qa-decision.mjs +5 -0
- package/runtime/js/cm-ai/integration-snapshots.mjs +50 -0
- package/runtime/js/cm-ai/live-evidence.mjs +28 -6
- package/runtime/js/cm-ai/operator-guidance.mjs +63 -30
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +27 -9
- package/runtime/js/cm-ai/process-group-exit.mjs +46 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +3 -2
- package/runtime/js/cm-ai/qa-attachment.mjs +22 -0
- package/runtime/js/cm-ai/qa-config-revision.mjs +7 -2
- package/runtime/js/cm-ai/requirement-evidence.mjs +102 -0
- package/runtime/js/cm-ai/review-package.mjs +79 -7
- package/runtime/js/cm-ai/review-presentation-delta.mjs +166 -0
- package/runtime/js/cm-ai/review-presentation.mjs +177 -8
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +70 -2
- package/runtime/js/cm-ai/reviewed-integration.mjs +260 -0
- package/runtime/js/cm-ai/scope-revision.mjs +38 -0
- package/runtime/js/cm-ai/specification-material.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +247 -41
- package/runtime/js/cm-ai/verification-auto.mjs +38 -0
- package/runtime/js/cm-ai/worker-claude-developer.mjs +39 -15
- package/runtime/js/cm-ai/worker-claude.mjs +35 -13
- package/runtime/js/cm-ai/worker-codex-developer.mjs +43 -17
- package/runtime/js/cm-ai/worker-codex.mjs +41 -7
- package/runtime/js/cm-fix/cause-invocation.mjs +16 -2
- package/runtime/js/cm-fix/cause-package.mjs +46 -1
- package/runtime/js/cm-fix/command-correction.mjs +37 -0
- package/runtime/js/cm-fix/cooperative.mjs +12 -0
- package/runtime/js/cm-fix/dossier.mjs +8 -2
- package/runtime/js/cm-fix/execution.mjs +578 -100
- package/runtime/js/cm-fix/final-review.mjs +39 -8
- package/runtime/js/cm-fix/finish.mjs +15 -11
- package/runtime/js/cm-fix/host-review.mjs +65 -10
- package/runtime/js/cm-fix/host.mjs +35 -12
- package/runtime/js/cm-fix/jest-command-correction.mjs +69 -0
- package/runtime/js/cm-fix/metrics.mjs +18 -5
- package/runtime/js/cm-fix/regression-evidence.mjs +3 -2
- package/runtime/js/cm-fix/regression.mjs +16 -7
- package/runtime/js/cm-fix/repair.mjs +29 -8
- package/runtime/js/cm-fix/review-verification-command.mjs +135 -0
- package/runtime/js/cm-fix/review-verification-contract.mjs +54 -0
- package/runtime/js/cm-fix/review-verification-diagnostic.mjs +75 -0
- package/runtime/js/cm-fix/review-verification-recovery.mjs +44 -0
- package/runtime/js/cm-fix/review-verification-server.mjs +38 -0
- package/runtime/js/cm-fix/review-verification.mjs +214 -0
- package/runtime/js/cm-fix/source-correction-recovery.mjs +65 -0
- package/runtime/js/cm-fix/start.mjs +6 -3
- package/runtime/js/cm-fix/test-type-correction.mjs +86 -0
- package/runtime/js/cm-fix/test-type-recovery.mjs +51 -0
- package/runtime/js/cm-fix/type-import-correction.mjs +89 -0
- package/runtime/js/cm-prd/accepted-design.mjs +8 -0
- package/runtime/js/cm-prd/analysis.mjs +13 -9
- package/runtime/js/cm-prd/change.mjs +37 -16
- package/runtime/js/cm-prd/draft-save.mjs +13 -6
- package/runtime/js/cm-prd/draft.mjs +31 -3
- package/runtime/js/cm-prd/failed-correction.mjs +19 -3
- package/runtime/js/cm-prd/inputs-replaced.mjs +3 -0
- package/runtime/js/cm-prd/review-correction.mjs +6 -4
- package/runtime/js/cm-prd/review-disposition.mjs +7 -1
- package/runtime/js/cm-prd/self-check-revision.mjs +2 -2
- package/runtime/js/cm-prd/self-check.mjs +125 -6
- package/runtime/js/cm-prd/session.mjs +30 -1
- package/runtime/js/cm-prd/summary.mjs +38 -17
- package/runtime/js/cm-prd/task-scope-record.mjs +97 -0
- package/runtime/js/cm-prd/tree-digest.mjs +34 -0
- package/runtime/js/cm-prd/validation-reason.mjs +8 -4
- package/runtime/js/cm-security/scan.mjs +1 -1
- package/runtime/js/commander/decision.mjs +44 -0
- package/runtime/js/commander/dispatch-registry.mjs +110 -0
- package/runtime/js/commander/ledger.mjs +265 -0
- package/runtime/js/commander/preflight.mjs +107 -0
- package/runtime/js/notify-later.mjs +13 -0
- package/runtime/js/notify-send.mjs +6 -2
- package/runtime/js/notify.mjs +570 -63
- package/runtime/js/review-findings.mjs +38 -0
- package/runtime/js/session-boundary.mjs +56 -0
- package/runtime/js/session-handoff.mjs +68 -0
- package/runtime/js/spec-task-line.mjs +27 -13
- package/runtime/js/specs-status.mjs +1 -1
- package/runtime/js/task-scope.mjs +197 -0
- package/runtime/logging.md +6 -1
- package/runtime/model-efficiency.md +69 -10
- package/runtime/orchestration.md +3 -1
- package/runtime/project-learning.md +2 -0
- package/runtime/review.md +12 -2
- package/runtime/test-contract.md +1 -0
- package/scripts/ci-test-weights.json +3 -0
- package/scripts/cm-ai-admission.mjs +11 -5
- package/scripts/cm-ai-admission.test.mjs +23 -2
- package/scripts/cm-ai-batch-drive.mjs +79 -18
- package/scripts/cm-ai-batch-drive.test.mjs +169 -3
- package/scripts/cm-ai-batch-host.mjs +38 -9
- package/scripts/cm-ai-batch-host.test.mjs +27 -14
- package/scripts/cm-ai-batch-learning-merge.test.mjs +36 -0
- package/scripts/cm-ai-batch-location.test.mjs +57 -0
- package/scripts/cm-ai-batch-plan.mjs +52 -0
- package/scripts/cm-ai-batch-plan.test.mjs +397 -0
- package/scripts/cm-ai-batch-run-fixture.mjs +446 -35
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +16 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +28 -1
- package/scripts/cm-ai-batch-run.mjs +483 -63
- package/scripts/cm-ai-batch-run.test.mjs +23 -4
- package/scripts/cm-ai-batch-session-e2e.test.mjs +235 -0
- package/scripts/cm-ai-batch-session-member.test.mjs +293 -0
- package/scripts/cm-ai-batch-session-recovery.test.mjs +423 -0
- package/scripts/cm-ai-check-recheck-cancellation.test.mjs +247 -0
- package/scripts/cm-ai-checklist-coverage.test.mjs +4 -2
- package/scripts/cm-ai-checkpoint-package-material.test.mjs +221 -0
- package/scripts/cm-ai-checkpoint-package-owner.test.mjs +193 -0
- package/scripts/cm-ai-control-launch.test.mjs +21 -0
- package/scripts/cm-ai-control-policy.test.mjs +82 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +398 -3
- package/scripts/cm-ai-control-v2-supersede-race.mjs +25 -0
- package/scripts/cm-ai-control-v2-supersede.test.mjs +318 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +163 -0
- package/scripts/cm-ai-development-rework.test.mjs +423 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +3 -2
- package/scripts/cm-ai-drive.mjs +73 -17
- package/scripts/cm-ai-drive.test.mjs +37 -5
- package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
- package/scripts/cm-ai-host-fixture.mjs +9 -6
- package/scripts/cm-ai-host-protected.test.mjs +1 -1
- package/scripts/cm-ai-host.mjs +60 -19
- package/scripts/cm-ai-host.test.mjs +15 -0
- package/scripts/cm-ai-integration-adoption.test.mjs +223 -0
- package/scripts/cm-ai-integration-independence.test.mjs +23 -0
- package/scripts/cm-ai-integration-launch.test.mjs +240 -0
- package/scripts/cm-ai-integration-preview.mjs +41 -0
- package/scripts/cm-ai-integration-snapshots.test.mjs +197 -0
- package/scripts/cm-ai-nested-execution.test.mjs +29 -1
- package/scripts/cm-ai-operator-guidance.test.mjs +71 -0
- package/scripts/cm-ai-prefinal-delivery.test.mjs +278 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +56 -0
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +28 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +36 -2
- package/scripts/cm-ai-requirement-evidence.test.mjs +65 -0
- package/scripts/cm-ai-review-failure.test.mjs +150 -5
- package/scripts/cm-ai-review-timeout.test.mjs +20 -0
- package/scripts/cm-ai-run.mjs +88 -21
- package/scripts/cm-ai-scope-revision.test.mjs +341 -0
- package/scripts/cm-ai-spec-rebind.test.mjs +13 -0
- package/scripts/cm-ai-supersede.test.mjs +28 -0
- package/scripts/cm-ai-verification-auto.test.mjs +99 -0
- package/scripts/cm-announce-hook.mjs +35 -8
- package/scripts/cm-announce-hook.test.mjs +25 -0
- package/scripts/cm-challenge.test.mjs +61 -0
- package/scripts/cm-check-drive-files.mjs +2 -2
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +58 -1
- package/scripts/cm-claude-developer-worker.test.mjs +56 -7
- package/scripts/cm-claude-install-layout.test.mjs +1 -1
- package/scripts/cm-claude-probe.test.mjs +26 -0
- package/scripts/cm-claude-review-diagnostics.test.mjs +235 -0
- package/scripts/cm-claude-review-stream.test.mjs +49 -0
- package/scripts/cm-claude-worker.test.mjs +16 -0
- package/scripts/cm-codex-developer-reconnect-notice.test.mjs +98 -0
- package/scripts/cm-codex-developer-worker.test.mjs +120 -0
- package/scripts/cm-codex-install-local-edit-guard.test.mjs +436 -0
- package/scripts/cm-codex-prompt-input.test.mjs +153 -0
- package/scripts/cm-codex-reconnect-notice.test.mjs +167 -0
- package/scripts/cm-commander-ledger.test.mjs +260 -0
- package/scripts/cm-commander-p2.test.mjs +295 -0
- package/scripts/cm-commander-preflight.mjs +84 -0
- package/scripts/cm-commander.mjs +116 -0
- package/scripts/cm-config-lock.mjs +35 -0
- package/scripts/cm-controlled-correction.test.mjs +10 -1
- package/scripts/cm-developer-failure-code.test.mjs +62 -0
- package/scripts/cm-display-task-id.test.mjs +41 -0
- package/scripts/cm-drive-liveness.test.mjs +83 -0
- package/scripts/cm-efficiency-presentation-delta.test.mjs +218 -0
- package/scripts/cm-execution-snapshot-reuse.test.mjs +115 -0
- package/scripts/cm-external-batch-host.test.mjs +12 -9
- package/scripts/cm-external-process-cleanup.test.mjs +128 -0
- package/scripts/cm-external-qa-fix.test.mjs +89 -7
- package/scripts/cm-external-review-reconciliation.test.mjs +11 -0
- package/scripts/cm-failover.mjs +48 -10
- package/scripts/cm-failover.test.mjs +46 -0
- package/scripts/cm-fix-cause-invocation.test.mjs +19 -4
- package/scripts/cm-fix-command-correction.mjs +17 -0
- package/scripts/cm-fix-command-correction.test.mjs +211 -0
- package/scripts/cm-fix-cooperative-closeout.test.mjs +87 -0
- package/scripts/cm-fix-diagnosis-module-correction.test.mjs +217 -0
- package/scripts/cm-fix-drive.mjs +33 -5
- package/scripts/cm-fix-drive.test.mjs +49 -0
- package/scripts/cm-fix-host-review-assembly.test.mjs +197 -1
- package/scripts/cm-fix-host-review.test.mjs +21 -9
- package/scripts/cm-fix-host.mjs +26 -8
- package/scripts/cm-fix-monorepo-map.test.mjs +92 -0
- package/scripts/cm-fix-observation-task-id.test.mjs +122 -0
- package/scripts/cm-fix-regression-input-budget.test.mjs +111 -0
- package/scripts/cm-fix-repair-input-budget.test.mjs +119 -0
- package/scripts/cm-fix-review-file-paging.test.mjs +91 -0
- package/scripts/cm-fix-review-preflight.mjs +24 -0
- package/scripts/cm-fix-review-storage.test.mjs +233 -0
- package/scripts/cm-fix-review-verification-command.test.mjs +242 -0
- package/scripts/cm-fix-review-verification-evidence.test.mjs +218 -0
- package/scripts/cm-fix-review-verification-integration.test.mjs +81 -0
- package/scripts/cm-fix-review-verification-recovery.test.mjs +198 -0
- package/scripts/cm-fix-review-verification.test.mjs +146 -0
- package/scripts/cm-fix-revision-transport.test.mjs +81 -0
- package/scripts/cm-fix-source-correction.test.mjs +296 -0
- package/scripts/cm-fix-test-type-correction.mjs +18 -0
- package/scripts/cm-fix-test-type-correction.test.mjs +123 -0
- package/scripts/cm-fix-test-type-owner.test.mjs +208 -0
- package/scripts/cm-fix-test-type-verification-cost.test.mjs +66 -0
- package/scripts/cm-fix-type-import-correction.test.mjs +95 -0
- package/scripts/cm-fix-verification-diagnostic.test.mjs +200 -0
- package/scripts/cm-fix-verification-recovery.mjs +33 -0
- package/scripts/cm-host-diagnostic.test.mjs +33 -0
- package/scripts/cm-host-liveness.test.mjs +150 -0
- package/scripts/cm-host-qa-executor.test.mjs +77 -0
- package/scripts/cm-host-replay.test.mjs +176 -0
- package/scripts/cm-host-stage-observer.test.mjs +41 -0
- package/scripts/cm-install-local-edit-guard.test.mjs +621 -0
- package/scripts/cm-install-manifest.sh +351 -0
- package/scripts/cm-live-evidence.test.mjs +59 -1
- package/scripts/cm-log-event.mjs +61 -10
- package/scripts/cm-log-event.test.mjs +121 -1
- package/scripts/cm-matt-skills.mjs +576 -0
- package/scripts/cm-matt-skills.test.mjs +550 -0
- package/scripts/cm-notify-command.test.mjs +42 -10
- package/scripts/cm-notify.mjs +14 -10
- package/scripts/cm-notify.test.mjs +625 -75
- package/scripts/cm-patrol.mjs +4 -1
- package/scripts/cm-patrol.test.mjs +23 -5
- package/scripts/cm-prd-answer-gaps.test.mjs +2 -2
- package/scripts/cm-prd-completion.test.mjs +56 -13
- package/scripts/cm-prd-design-phase.test.mjs +78 -8
- package/scripts/cm-prd-draft-save.test.mjs +12 -0
- package/scripts/cm-prd-draft.test.mjs +1 -1
- package/scripts/cm-prd-drive.mjs +13 -6
- package/scripts/cm-prd-drive.test.mjs +46 -2
- package/scripts/cm-prd-gate-diagnostic.test.mjs +2 -2
- package/scripts/cm-prd-host.mjs +10 -5
- package/scripts/cm-prd-host.test.mjs +4 -2
- package/scripts/cm-prd-inputs-replaced.test.mjs +1 -1
- package/scripts/cm-prd-review-disposition.test.mjs +124 -8
- package/scripts/cm-prd-revision.test.mjs +1 -1
- package/scripts/cm-prd-self-check-revision.test.mjs +16 -1
- package/scripts/cm-prd-self-check-rules.test.mjs +239 -0
- package/scripts/cm-prd-self-check.test.mjs +105 -5
- package/scripts/cm-prd-session-recovery.test.mjs +5 -3
- package/scripts/cm-prd-summary.test.mjs +55 -3
- package/scripts/cm-prd-task-grouping.test.mjs +6 -6
- package/scripts/cm-prd-tree-digest.test.mjs +74 -0
- package/scripts/cm-refactor-drive.mjs +2 -1
- package/scripts/cm-refactor-drive.test.mjs +9 -0
- package/scripts/cm-release-smoke.sh +3 -15
- package/scripts/cm-skill-hints-autowire.test.mjs +394 -0
- package/scripts/cm-skill-hints-exam.mjs +149 -0
- package/scripts/cm-skill-hints-install.test.mjs +168 -0
- package/scripts/cm-skill-hints.exam.json +706 -0
- package/scripts/cm-skill-hints.json +119 -0
- package/scripts/cm-skill-hints.mjs +669 -0
- package/scripts/cm-skill-hints.test.mjs +831 -0
- package/scripts/cm-skill-judge.mjs +181 -0
- package/scripts/cm-skill-judge.test.mjs +255 -0
- package/scripts/cm-specs-status.test.mjs +4 -2
- package/scripts/cm-start-check.mjs +208 -0
- package/scripts/cm-start-check.test.mjs +321 -0
- package/scripts/cm-task-gate.mjs +150 -29
- package/scripts/cm-task-gate.test.mjs +73 -1
- package/scripts/cm-task-id-grammar.test.mjs +66 -0
- package/scripts/cm-task-scope.test.mjs +308 -0
- package/scripts/cm-test-suite.mjs +109 -0
- package/scripts/cm-test-suite.test.mjs +162 -0
- package/scripts/cm-upgrade-compat-batch.test.mjs +172 -0
- package/scripts/cm-upgrade-compat.test.mjs +239 -0
- package/scripts/cm-workflow-config.mjs +12 -2
- package/scripts/fixtures/fix-verification-claude.mjs +44 -0
- package/scripts/fixtures/host-diagnostic.mjs +33 -0
- package/scripts/fixtures/reviewed-integration.mjs +202 -0
- package/scripts/scan-public-safety.py +1 -0
- package/scripts/session-boundary.test.mjs +170 -0
- package/scripts/test-npm-install.py +14 -3
- package/scripts/test-shell-compat.sh +2 -0
- package/scripts/validate-public-repo.py +1 -0
- package/scripts/validate-test-cases.mjs +3 -2
- package/skills/cm-ai/SKILL.md +5 -2
- package/skills/cm-ai/references/N4-review.md +2 -1
- package/skills/cm-ai/references/N6-qa-eval.md +3 -1
- package/skills/cm-ai/references/N8-finish.md +22 -0
- package/skills/cm-ai/references/js-host-qa-recovery.md +1 -1
- package/skills/cm-ai/references/js-host-recovery.md +79 -3
- package/skills/cm-ai/references/js-host.md +89 -17
- package/skills/cm-challenge/SKILL.md +65 -0
- package/skills/cm-challenge/evals/README.md +18 -0
- package/skills/cm-challenge/evals/trigger-cases.json +20 -0
- package/skills/cm-challenge/evals/trigger-config.json +28 -0
- package/skills/cm-challenge/references/examples.md +15 -0
- package/skills/cm-check/SKILL.md +5 -0
- package/skills/cm-check/references/js-host.md +2 -0
- package/skills/cm-fix/SKILL.md +12 -3
- package/skills/cm-fix/references/command-correction.md +67 -0
- package/skills/cm-fix/references/isolated-review.md +54 -0
- package/skills/cm-fix/references/js-host.md +62 -2
- package/skills/cm-fix/references/test-type-correction.md +72 -0
- package/skills/cm-fix/references/verification-recovery.md +114 -0
- package/skills/cm-idea/SKILL.md +2 -0
- package/skills/cm-idea/references/js-host.md +2 -0
- package/skills/cm-notify/SKILL.md +2 -0
- package/skills/cm-prd/SKILL.md +12 -8
- package/skills/cm-prd/references/brownfield.md +8 -1
- package/skills/cm-prd/references/change-mode.md +6 -0
- package/skills/cm-prd/references/greenfield.md +4 -0
- package/skills/cm-prd/references/js-host.md +4 -2
- package/skills/cm-prd/references/spec-self-check.md +5 -1
- package/skills/cm-refactor/SKILL.md +8 -0
- package/skills/cm-refactor/references/js-host.md +2 -0
- package/skills/cm-test/SKILL.md +4 -0
- package/templates/dashboard/dashboard.html +2 -2
- package/templates/pixel/cm-pixel.html +1 -1
- package/templates/pixel/cm-pixel.sh +1 -1
- package/templates/pixel/dev/template.html +1 -1
- package/templates/statusline/cm-statusline.sh +1 -1
|
@@ -8,6 +8,7 @@ import {EventEmitter} from 'node:events';
|
|
|
8
8
|
import {PassThrough} from 'node:stream';
|
|
9
9
|
import {codexWorker} from '../runtime/js/cm-ai/worker-codex.mjs';
|
|
10
10
|
import {claudeWorker,claudeReviewFingerprint} from '../runtime/js/cm-ai/worker-claude.mjs';
|
|
11
|
+
import {ownedProcessCleanup} from '../runtime/js/cm-ai/owned-process-cleanup.mjs';
|
|
11
12
|
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
12
13
|
import {readModelJson,writeModelJson} from '../runtime/js/cm-ai/model-configuration-file.mjs';
|
|
13
14
|
const fixture=t=>{const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-security-fix-')));t.after(()=>fs.rmSync(root,{recursive:true,force:true}));return root;};
|
|
@@ -69,3 +70,130 @@ test('Windows old reviewer keeps successful dispatch; termination uncertainty ca
|
|
|
69
70
|
assert.equal(kills,2);
|
|
70
71
|
}finally{Object.defineProperty(process,'platform',original);}
|
|
71
72
|
});
|
|
73
|
+
|
|
74
|
+
// Signal delivery is asynchronous. The last member can be exiting until the
|
|
75
|
+
// next event-loop turn; a probe must not run in the SIGKILL delivery turn.
|
|
76
|
+
test('owned cleanup waits for asynchronous exit before its first group probe',{skip:process.platform==='win32'},async()=>{
|
|
77
|
+
const calls=[];let reaped=false;
|
|
78
|
+
const cleanup=ownedProcessCleanup({pid:12345},{graceMs:0,killProcess:(pid,signal)=>{
|
|
79
|
+
assert.equal(pid,-12345);calls.push(signal);
|
|
80
|
+
if(signal==='SIGKILL'){setTimeout(()=>{reaped=true;},0);return;}
|
|
81
|
+
if(signal===0){
|
|
82
|
+
if(!reaped)throw Object.assign(new Error('synthetic exit still pending'),{code:'EPERM'});
|
|
83
|
+
throw Object.assign(new Error('synthetic group gone'),{code:'ESRCH'});
|
|
84
|
+
}
|
|
85
|
+
}});
|
|
86
|
+
await cleanup();assert.equal(reaped,true);assert.deepEqual(calls,['SIGTERM','SIGKILL',0]);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
for(const failureAt of ['SIGTERM','SIGKILL',0])test(`owned cleanup stops at permission refusal during ${failureAt}`,{skip:process.platform==='win32'},async()=>{
|
|
90
|
+
const calls=[];
|
|
91
|
+
const cleanup=ownedProcessCleanup({pid:12345},{graceMs:0,killProcess:(pid,signal)=>{
|
|
92
|
+
assert.equal(pid,-12345);calls.push(signal);
|
|
93
|
+
if(signal===failureAt)throw Object.assign(new Error('synthetic permission denied'),{code:'EPERM'});
|
|
94
|
+
}});
|
|
95
|
+
await assert.rejects(cleanup(),{code:'process_cleanup_unknown'});
|
|
96
|
+
assert.deepEqual(calls,['SIGTERM','SIGKILL',0].slice(0,['SIGTERM','SIGKILL',0].indexOf(failureAt)+1));
|
|
97
|
+
await assert.rejects(cleanup(),{code:'process_cleanup_unknown'});
|
|
98
|
+
assert.equal(calls.length,['SIGTERM','SIGKILL',0].indexOf(failureAt)+1);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('owned cleanup keeps a live group unknown at its original deadline',{skip:process.platform==='win32'},async()=>{
|
|
102
|
+
const calls=[];
|
|
103
|
+
const cleanup=ownedProcessCleanup({pid:12345},{graceMs:0,killWaitMs:0,killProcess:(pid,signal)=>{
|
|
104
|
+
assert.equal(pid,-12345);calls.push(signal);
|
|
105
|
+
}});
|
|
106
|
+
await assert.rejects(cleanup(),{code:'process_cleanup_unknown'});
|
|
107
|
+
assert.deepEqual(calls,['SIGTERM','SIGKILL',0]);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// 2026-10-27 (macOS 26 measured): a process group whose only member is our own child
|
|
111
|
+
// that already exited but is not reaped yet (a zombie) answers kill(-pgid, 0|SIGTERM)
|
|
112
|
+
// with EPERM; after the reap it is ESRCH. A provider CLI that exits right after its
|
|
113
|
+
// error used to end process_cleanup_unknown. A stop is proven only once our direct
|
|
114
|
+
// child's exit is observed and a re-probe answers ESRCH (no process table is read).
|
|
115
|
+
const exitedChild=(pid=12345)=>Object.assign(new EventEmitter(),{pid,exitCode:1,signalCode:null});
|
|
116
|
+
const denied=()=>{throw Object.assign(new Error('synthetic permission denied'),{code:'EPERM'});};
|
|
117
|
+
test('owned cleanup: a real child that exited at once (unreaped zombie group) is proven stopped',{skip:process.platform==='win32'},async()=>{
|
|
118
|
+
const child=spawn(process.execPath,['-e','process.exit(1)'],{detached:true,stdio:'ignore'});
|
|
119
|
+
const started=Date.now();while(Date.now()-started<400){} // the child exits; this loop keeps it unreaped
|
|
120
|
+
await ownedProcessCleanup(child,{graceMs:0})();
|
|
121
|
+
assert.notEqual(child.exitCode,null);
|
|
122
|
+
});
|
|
123
|
+
// EPERM is resolved only through our own child: after its exit is observed, a re-probe
|
|
124
|
+
// within the same budget must answer ESRCH (stopped) or deliver (a live member).
|
|
125
|
+
const waitingChild=(pid=12345)=>Object.assign(new EventEmitter(),{pid,exitCode:null,signalCode:null});
|
|
126
|
+
test('owned cleanup: EPERM until our child is reaped, then ESRCH, is a stop; the wait never blocks the event loop',{skip:process.platform==='win32'},async()=>{
|
|
127
|
+
const child=waitingChild(),calls=[];let reaped=false,ticked=false;
|
|
128
|
+
setTimeout(()=>{ticked=true;},10);
|
|
129
|
+
setTimeout(()=>{reaped=true;child.exitCode=1;child.emit('exit',1,null);},40);
|
|
130
|
+
await ownedProcessCleanup(child,{graceMs:0,killProcess:(pid,signal)=>{
|
|
131
|
+
assert.equal(pid,-12345);calls.push(signal);
|
|
132
|
+
throw Object.assign(new Error('synthetic'),{code:reaped?'ESRCH':'EPERM'});
|
|
133
|
+
}})();
|
|
134
|
+
assert.equal(ticked,true,'a 10 ms timer ran while waiting for the exit');
|
|
135
|
+
assert.deepEqual(calls,['SIGTERM','SIGTERM']);
|
|
136
|
+
});
|
|
137
|
+
test('owned cleanup: an EPERM that persists after our child exited stays unknown',{skip:process.platform==='win32'},async()=>{
|
|
138
|
+
const started=Date.now();
|
|
139
|
+
await assert.rejects(ownedProcessCleanup(exitedChild(),{graceMs:0,exitBudgetMs:200,killProcess:denied})(),{code:'process_cleanup_unknown'});
|
|
140
|
+
assert(Date.now()-started<1000,'bounded by the budget');
|
|
141
|
+
});
|
|
142
|
+
// Review 2026-10-27 round 2: every signal used to get the full exit budget again, so a
|
|
143
|
+
// probe that met EPERM at the kill deadline still waited the whole budget past it.
|
|
144
|
+
test('owned cleanup: an EPERM probe at the kill deadline does not wait past it',{skip:process.platform==='win32'},async()=>{
|
|
145
|
+
const started=Date.now();
|
|
146
|
+
await assert.rejects(ownedProcessCleanup(exitedChild(),{graceMs:0,killWaitMs:0,exitBudgetMs:200,killProcess:(pid,signal)=>{
|
|
147
|
+
if(signal===0)denied();
|
|
148
|
+
}})(),{code:'process_cleanup_unknown'});
|
|
149
|
+
assert(Date.now()-started<150,`ended at the kill deadline, not ${Date.now()-started} ms later`);
|
|
150
|
+
});
|
|
151
|
+
// Review 2026-10-27 round 3: SIGTERM and SIGKILL each met EPERM before delivering, then
|
|
152
|
+
// the group stayed alive; the poll after SIGKILL got a fresh killWaitMs (≈560 ms of 400).
|
|
153
|
+
test('owned cleanup: EPERM before SIGTERM and SIGKILL still ends at the overall deadline',{skip:process.platform==='win32'},async()=>{
|
|
154
|
+
const started=Date.now(),at=()=>Date.now()-started;
|
|
155
|
+
await assert.rejects(ownedProcessCleanup(exitedChild(),{graceMs:0,killWaitMs:200,exitBudgetMs:200,killProcess:(pid,signal)=>{
|
|
156
|
+
if(signal==='SIGTERM'&&at()<150)denied();
|
|
157
|
+
if(signal==='SIGKILL'&&at()<350)denied();
|
|
158
|
+
}})(),{code:'process_cleanup_unknown'});
|
|
159
|
+
assert(at()<480,`ended near the 400 ms overall deadline, not ${at()} ms`);
|
|
160
|
+
});
|
|
161
|
+
test('owned cleanup: a member that answers once our child exited is live, not stopped',{skip:process.platform==='win32'},async()=>{
|
|
162
|
+
const calls=[];let first=true;
|
|
163
|
+
await assert.rejects(ownedProcessCleanup(exitedChild(),{graceMs:0,killWaitMs:0,killProcess:(pid,signal)=>{
|
|
164
|
+
calls.push(signal);if(first){first=false;denied();}
|
|
165
|
+
}})(),{code:'process_cleanup_unknown'});
|
|
166
|
+
// It was treated as alive: escalated to SIGKILL and still probed alive at the deadline.
|
|
167
|
+
assert.deepEqual(calls,['SIGTERM','SIGTERM','SIGKILL',0]);
|
|
168
|
+
});
|
|
169
|
+
test('owned cleanup: EPERM without an observed exit of our child stays unknown, even if a later probe says ESRCH',{skip:process.platform==='win32'},async()=>{
|
|
170
|
+
await assert.rejects(ownedProcessCleanup(waitingChild(),{graceMs:0,exitBudgetMs:30,killProcess:denied})(),{code:'process_cleanup_unknown'});
|
|
171
|
+
let first=true;
|
|
172
|
+
await assert.rejects(ownedProcessCleanup(waitingChild(),{graceMs:0,exitBudgetMs:30,killProcess:()=>{
|
|
173
|
+
if(first){first=false;denied();}throw Object.assign(new Error('synthetic'),{code:'ESRCH'});
|
|
174
|
+
}})(),{code:'process_cleanup_unknown'});
|
|
175
|
+
});
|
|
176
|
+
test('owned cleanup: a zombie leader with a live descendant is killed, not taken for stopped',{skip:process.platform==='win32'},async t=>{
|
|
177
|
+
const root=fixture(t),pidFile=path.join(root,'grandchild.pid');
|
|
178
|
+
const child=spawn(process.execPath,['-e',`const c=require('child_process').spawn(process.execPath,['-e','process.on("SIGTERM",()=>{});setInterval(()=>{},1000)'],{stdio:'ignore'});
|
|
179
|
+
require('fs').writeFileSync(${JSON.stringify(pidFile)},String(c.pid));c.unref();process.exit(0);`],{detached:true,stdio:'ignore'});
|
|
180
|
+
t.after(()=>{try{process.kill(-child.pid,'SIGKILL');}catch{}});
|
|
181
|
+
while(!fs.existsSync(pidFile))await new Promise(resolve=>setTimeout(resolve,10));
|
|
182
|
+
const grandchild=Number(fs.readFileSync(pidFile,'utf8'));
|
|
183
|
+
await ownedProcessCleanup(child,{graceMs:50})();
|
|
184
|
+
assert.equal(alive(grandchild),false,'the TERM-ignoring descendant was killed');
|
|
185
|
+
});
|
|
186
|
+
test('Codex reviewer that exits right after its 429 ends reviewer_rate_limited, not process_cleanup_unknown',{skip:process.platform==='win32'},async t=>{
|
|
187
|
+
const root=fixture(t),script=path.join(root,'codex-429.mjs');
|
|
188
|
+
fs.writeFileSync(script,`let input='';for await(const part of process.stdin)input+=part;
|
|
189
|
+
const message='exceeded retry limit, last status: 429 Too Many Requests';
|
|
190
|
+
for(const value of [{type:'thread.started',thread_id:'t-429'},{type:'turn.started'},{type:'error',message},{type:'turn.failed',error:{message}}])
|
|
191
|
+
process.stdout.write(JSON.stringify(value)+'\\n');
|
|
192
|
+
process.exit(1);`);
|
|
193
|
+
for(let attempt=0;attempt<3;attempt++){
|
|
194
|
+
const result=await worker(root,{promptTransport:'stdin',timeoutMs:5000,spawnProcess:(_cli,_args,opts)=>spawn(process.execPath,[script],opts),
|
|
195
|
+
preflight:{passed:true,cli_model:'synthetic-reviewer',prompt_transport:'stdin',
|
|
196
|
+
config_fingerprint:configFingerprint({...options(root),promptTransport:'stdin'})}})({prompt:'p'},{signal:new AbortController().signal,onEvent:()=>{}});
|
|
197
|
+
assert.deepEqual(result,{status:'failed',code:'reviewer_rate_limited'},`attempt ${attempt}`);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
@@ -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();
|