@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
package/scripts/cm-ai-host.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {readLaunchExecutionPolicy} from '../runtime/js/cm-ai/execution-policy.mjs';
|
|
3
|
+
import {assertDeclaredScope} from '../runtime/js/task-scope.mjs';
|
|
3
4
|
import {readLaunchExternalModels} from '../runtime/js/cm-ai/external-model-launch.mjs';
|
|
4
5
|
import {loadExternalModels,externalPair} from '../runtime/js/cm-ai/external-models.mjs';
|
|
5
6
|
// Current-conversation host. Legacy keeps explicit attempt choices; v2 uses
|
|
@@ -24,6 +25,18 @@ import {readControlPolicyFile,withControlPolicyHost,readControlTarget} from '../
|
|
|
24
25
|
import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs';
|
|
25
26
|
import {parseModelJson} from '../runtime/js/cm-ai/model-configuration-file.mjs';
|
|
26
27
|
export {executionFor as createConversationExecution,reviewConfiguration as readConversationReviewConfiguration,reviewConfigurationValue as readConversationReviewConfigurationValue};
|
|
28
|
+
export function readScopeRevisionFile(file){
|
|
29
|
+
const before=fs.lstatSync(file);
|
|
30
|
+
need(before.isFile()&&!before.isSymbolicLink()&&before.nlink===1&&before.size<=65536,'invalid_input');
|
|
31
|
+
const descriptor=fs.openSync(file,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW);
|
|
32
|
+
try{
|
|
33
|
+
const bytes=fs.readFileSync(descriptor),after=fs.fstatSync(descriptor),current=fs.lstatSync(file);
|
|
34
|
+
need([after,current].every(info=>['dev','ino','size','mtimeMs','ctimeMs'].every(key=>info[key]===before[key]))
|
|
35
|
+
&&bytes.length===before.size,'snapshot_changed');
|
|
36
|
+
return parseModelJson(new TextDecoder('utf-8',{fatal:true}).decode(bytes));
|
|
37
|
+
}finally{fs.closeSync(descriptor);}
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
export function readLaunchControlFile(file){
|
|
28
41
|
const before=fs.lstatSync(file);
|
|
29
42
|
need(before.isFile()&&!before.isSymbolicLink()&&before.nlink===1&&before.size<=65536,'invalid_input');
|
|
@@ -32,7 +45,9 @@ export function readLaunchControlFile(file){
|
|
|
32
45
|
const bytes=fs.readFileSync(descriptor),after=fs.fstatSync(descriptor),current=fs.lstatSync(file);
|
|
33
46
|
need([after,current].every(info=>['dev','ino','size','mtimeMs','ctimeMs'].every(key=>info[key]===before[key]))
|
|
34
47
|
&&bytes.length===before.size,'snapshot_changed');
|
|
35
|
-
|
|
48
|
+
const target=parseModelJson(new TextDecoder('utf-8',{fatal:true}).decode(bytes));
|
|
49
|
+
need(target!==null&&typeof target==='object'&&!Array.isArray(target),'invalid_input');
|
|
50
|
+
return readControlTarget(target);
|
|
36
51
|
}finally{fs.closeSync(descriptor);}
|
|
37
52
|
}
|
|
38
53
|
export function withHandoffDiagnostic(host,error){
|
|
@@ -179,10 +194,11 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
179
194
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--hold-revision: 本次启动在第 1 轮审查要求修改后停在 changes_requested(revision_answer_required),不发起第 2 轮开发意图;只缩小本次启动,不写入配置,下次不带它即继续修订。\n');
|
|
180
195
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--allow-develop-redo: resume 原 run 后发送 develop_redo,request.reason 必须是单行且不超过 500 UTF-8 字节。当前会话开发(非受保护)的应答没拿到,或 provider 开发结果不明且存档记有 worker 进程身份(宿主先核对进程组已退出),pendingAction=develop_redo 时可用;操作员先确认会话已停止修改代码,宿主写入 develop-answer-redo 记录,之后 advance 重发本轮开发。旗标只消费一次,不写入配置。\n');
|
|
181
196
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--allow-bootstrap-review-recovery: resume 原 run 后发送 bootstrap_review_recover;只在 bootstrap develop 已完成且审查包构建失败时核对现有文件、handoff 与原始证据,并追加恢复记录,不重新派发开发。\n');
|
|
182
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--supersede-reviewed-evidence --supersede-reason REASON:仅新建同任务运行;旧运行都已终止且 tasks.md 未勾选时,先在新 journal 记授权,再归档旧审查证据。若保留直接前驱运行留下的代码漂移,可额外使用 --accept-superseded-code-drift;漂移文件会作为新运行的已有代码并记录当前 SHA-256
|
|
197
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--supersede-reviewed-evidence --supersede-reason REASON:仅新建同任务运行;旧运行都已终止且 tasks.md 未勾选时,先在新 journal 记授权,再归档旧审查证据。若保留直接前驱运行留下的代码漂移,可额外使用 --accept-superseded-code-drift;漂移文件会作为新运行的已有代码并记录当前 SHA-256。新版 --control-config 运行另须 --supersede-target FILE:文件保存旧运行 cm-ai-run.mjs inspect-history 返回的 supersedeTarget;旧运行在预览后变化则拒绝为 snapshot_changed,不自动替换目标。\n');
|
|
183
198
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--rebind-spec-material --spec-rebind-reason REASON:仅 resume。规格经 cm-prd --change 重新批准后,若本任务的描述、验证要求、验收标准、设计摘录与测试用例都未变,只换绑批准哈希并写 specification-rebound 记录,已有开发与审查结论保留;内容有变则拒绝并列出变化。status 的 spec_drift 会说明是否可换绑。\n');
|
|
184
199
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('当前会话手动驱动请用 scripts/cm-ai-drive.mjs(批次 cm-ai-batch-drive.mjs;修复 cm-fix-drive.mjs;规格 cm-prd-drive.mjs);详情见 skills/cm-ai/references/js-host.md。\n');
|
|
185
200
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('External-model mode freezes one model/effort pair per provider. Unknown or invalid external results require reconciliation; automatic retries and abandonment are disabled. See docs/external-models.md.\n');
|
|
201
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--integration-evidence FILE --accept-integration-digest HEX:新版 resume 启动时接纳已审集成计划;须提供原 --expected-control FILE。本连接仅允许 status,不执行开发、审查或 QA。\n');
|
|
186
202
|
if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\nV2: replace --allow-development with --control-config FILE. Explicit resume QA reruns, QA configuration revisions and specification rebinds require --expected-control FILE containing the original status.launchControlTarget; ordinary host recovery uses status.controlTarget.\n');return 0;}
|
|
187
203
|
let run,bridge;
|
|
188
204
|
try{
|
|
@@ -216,8 +232,8 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
216
232
|
const extra=new Map();
|
|
217
233
|
for(let index=controlPolicy?9:8;index<argv.length;index++){
|
|
218
234
|
const name=argv[index];refuse(!extra.has(name),'invalid_arguments',`参数重复:${name}`);
|
|
219
|
-
refuse(['--expected-control','--execution-optimizations','--external-models','--external-models-config','--verification-precheck','--revise-qa-config','--qa-config-revision-reason','--qa-environment-failure','--supersede-reviewed-evidence','--supersede-reason','--accept-superseded-code-drift','--rebind-spec-material','--spec-rebind-reason','--original-host-context','--bootstrap-config','--allow-bootstrap-write','--protected-conversation-config','--protected-config','--allow-provider-development-attempt','--review-config','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--allow-develop-redo','--hold-revision','--workflow-config','--allow-qa','--browser-qa','--rerun-unknown-qa','--rerun-blocked-qa','--runtime','--review-runtime','--feature','--input-limit','--failover','--qa-fix-owner-config','--qa-fix-template-config','--qa-fix-review-config','--qa-fix-final-review-recovery-invocation','--allow-qa-fix-start','--auto-qa-fix',...fixLocalPermissions.keys()].includes(name),'invalid_arguments',`未知参数:${name}`);
|
|
220
|
-
if(['--execution-optimizations','--external-models','--verification-precheck','--supersede-reviewed-evidence','--accept-superseded-code-drift','--rebind-spec-material','--allow-bootstrap-write','--allow-qa','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--allow-develop-redo','--hold-revision','--rerun-unknown-qa','--rerun-blocked-qa','--failover','--allow-qa-fix-start','--auto-qa-fix',...fixLocalPermissions.keys()].includes(name))extra.set(name,true);
|
|
235
|
+
refuse(['--integration-evidence','--accept-integration-digest','--revise-scope','--scope-revision-reason','--development-rework','--development-rework-reason','--expected-control','--execution-optimizations','--external-models','--external-models-config','--verification-precheck','--revise-qa-config','--qa-config-revision-reason','--qa-environment-failure','--supersede-reviewed-evidence','--supersede-reason','--supersede-target','--accept-superseded-code-drift','--rebind-spec-material','--spec-rebind-reason','--original-host-context','--bootstrap-config','--allow-bootstrap-write','--protected-conversation-config','--protected-config','--allow-provider-development-attempt','--review-config','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--allow-develop-redo','--hold-revision','--workflow-config','--allow-qa','--browser-qa','--rerun-unknown-qa','--rerun-blocked-qa','--runtime','--review-runtime','--feature','--input-limit','--failover','--qa-fix-owner-config','--qa-fix-template-config','--qa-fix-review-config','--qa-fix-final-review-recovery-invocation','--allow-qa-fix-start','--auto-qa-fix',...fixLocalPermissions.keys()].includes(name),'invalid_arguments',`未知参数:${name}`);
|
|
236
|
+
if(['--development-rework','--execution-optimizations','--external-models','--verification-precheck','--supersede-reviewed-evidence','--accept-superseded-code-drift','--rebind-spec-material','--allow-bootstrap-write','--allow-qa','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--allow-develop-redo','--hold-revision','--rerun-unknown-qa','--rerun-blocked-qa','--failover','--allow-qa-fix-start','--auto-qa-fix',...fixLocalPermissions.keys()].includes(name))extra.set(name,true);
|
|
221
237
|
else{refuse(typeof argv[index+1]==='string'&&!argv[index+1].startsWith('--'),'invalid_arguments',`${name} 需要一个值`);extra.set(name,argv[++index]);}
|
|
222
238
|
}
|
|
223
239
|
if(controlPolicy){
|
|
@@ -229,21 +245,42 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
229
245
|
refuse(controlPolicy.qaFix!=='disabled'||!['--qa-fix-owner-config','--qa-fix-template-config'].some(flag=>extra.has(flag)),
|
|
230
246
|
'invalid_arguments','加载 QA 修复配置必须选择 manual 或 auto 模式。');
|
|
231
247
|
refuse(!extra.has('--auto-qa-fix')||controlPolicy.qaFix==='auto','invalid_input','自动 QA 修复需要 qaFix:auto。');
|
|
248
|
+
// V2 supersede binds the predecessor state the operator previewed; it never
|
|
249
|
+
// refreshes the target or archives a run whose state moved after approval.
|
|
232
250
|
refuse(!['--supersede-reviewed-evidence','--supersede-reason','--accept-superseded-code-drift']
|
|
233
|
-
.some(flag=>extra.has(flag)),'supersede_unavailable',
|
|
234
|
-
'
|
|
235
|
-
|
|
251
|
+
.some(flag=>extra.has(flag))||argv[4]==='create'&&extra.has('--supersede-target'),'supersede_unavailable',
|
|
252
|
+
'新版重开需要 --mode create 与 --supersede-target FILE(保存旧运行 inspect-history 返回的 supersedeTarget);目标变化时先核对,不自动替换。');
|
|
253
|
+
refuse(!extra.has('--supersede-target')||extra.has('--supersede-reviewed-evidence'),'invalid_input',
|
|
254
|
+
'--supersede-target 只与 --supersede-reviewed-evidence、--supersede-reason 一起用于新版 create 重开。');
|
|
255
|
+
}else refuse(!extra.has('--supersede-target'),'invalid_arguments','--supersede-target 只用于新版 --control-config 的 create 重开。');
|
|
236
256
|
const qaEnabled=controlPolicy?controlPolicy.qa==='run':extra.has('--allow-qa');
|
|
237
257
|
const fixEnabled=controlPolicy?controlPolicy.qaFix!=='disabled':extra.has('--allow-qa-fix-start');
|
|
238
258
|
const autoFix=controlPolicy?controlPolicy.qaFix==='auto':extra.has('--auto-qa-fix');
|
|
239
259
|
const recoveryEnabled=flag=>controlPolicy?argv[4]==='resume':extra.has(flag);
|
|
240
|
-
const launchRecovery=['--revise-qa-config','--qa-config-revision-reason','--rerun-unknown-qa','--rerun-blocked-qa',
|
|
241
|
-
'--rebind-spec-material','--spec-rebind-reason'].some(flag=>extra.has(flag));
|
|
260
|
+
const launchRecovery=['--integration-evidence','--accept-integration-digest','--revise-qa-config','--qa-config-revision-reason','--rerun-unknown-qa','--rerun-blocked-qa',
|
|
261
|
+
'--rebind-spec-material','--spec-rebind-reason','--revise-scope','--scope-revision-reason','--development-rework','--development-rework-reason'].some(flag=>extra.has(flag));
|
|
242
262
|
refuse(!extra.has('--expected-control')||(controlPolicy&&launchRecovery&&argv[4]==='resume'),'invalid_input',
|
|
243
|
-
'--expected-control 仅用于新版 --mode resume
|
|
263
|
+
'--expected-control 仅用于新版 --mode resume 的显式启动恢复。');
|
|
244
264
|
if(controlPolicy&&launchRecovery)refuse(argv[4]==='resume'&&extra.has('--expected-control'),'invalid_input',
|
|
245
265
|
'启动恢复需要 --mode resume 与 --expected-control FILE,文件须保存原 status 的 launchControlTarget;目标变化时先核对,不能自动替换。');
|
|
246
266
|
const expectedControl=extra.has('--expected-control')?readLaunchControlFile(extra.get('--expected-control')):null;
|
|
267
|
+
const scopeRequested=extra.has('--revise-scope')||extra.has('--scope-revision-reason');
|
|
268
|
+
const reworkRequested=extra.has('--development-rework')||extra.has('--development-rework-reason');
|
|
269
|
+
refuse(!scopeRequested&&!reworkRequested||controlPolicy&&argv[4]==='resume'
|
|
270
|
+
&&(!scopeRequested||extra.has('--revise-scope')&&extra.has('--scope-revision-reason'))
|
|
271
|
+
&&(!reworkRequested||extra.has('--development-rework')&&extra.has('--development-rework-reason')),'invalid_input');
|
|
272
|
+
const scopeRevision=scopeRequested?{scope:readScopeRevisionFile(extra.get('--revise-scope')),reason:extra.get('--scope-revision-reason')}:null;
|
|
273
|
+
const supersedeTarget=extra.has('--supersede-target')?readLaunchControlFile(extra.get('--supersede-target')):null;
|
|
274
|
+
const integrationRequested=extra.has('--integration-evidence')||extra.has('--accept-integration-digest');
|
|
275
|
+
refuse(!integrationRequested||controlPolicy&&argv[4]==='resume'&&extra.has('--integration-evidence')
|
|
276
|
+
&&extra.has('--accept-integration-digest')&&/^[a-f0-9]{64}$/.test(extra.get('--accept-integration-digest'))
|
|
277
|
+
&&!['--revise-scope','--scope-revision-reason','--development-rework','--development-rework-reason',
|
|
278
|
+
'--revise-qa-config','--qa-config-revision-reason','--rerun-unknown-qa','--rerun-blocked-qa','--qa-environment-failure',
|
|
279
|
+
'--rebind-spec-material','--spec-rebind-reason','--supersede-reviewed-evidence','--supersede-reason',
|
|
280
|
+
'--supersede-target','--accept-superseded-code-drift','--hold-revision'].some(flag=>extra.has(flag)),
|
|
281
|
+
'invalid_input','受控集成接纳需要新版 resume、成对证据与批准摘要及原 launchControlTarget;不得并用其他恢复。');
|
|
282
|
+
const reviewedIntegration=integrationRequested?{evidenceFile:path.resolve(extra.get('--integration-evidence')),
|
|
283
|
+
expectedDigest:extra.get('--accept-integration-digest')}:null;
|
|
247
284
|
let inputLimit;
|
|
248
285
|
try{inputLimit=parseHostInputLimit(extra.get('--input-limit'));}
|
|
249
286
|
catch(error){refuse(error.code!=='invalid_arguments','invalid_arguments','--input-limit 须为 65536–4194304 的整数字节数');throw error;}
|
|
@@ -303,7 +340,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
303
340
|
definition={...definition,featureSelection:{version:1,feature:definition.feature}};
|
|
304
341
|
}
|
|
305
342
|
// Before any frozen model/policy configuration, execution or journal write.
|
|
306
|
-
if(argv[4]==='create'&&bootstrap===null)assertCreatableScope(definition.scope);
|
|
343
|
+
if(argv[4]==='create'&&bootstrap===null){assertCreatableScope(definition.scope);assertDeclaredScope(definition);}
|
|
307
344
|
const boundRuntime=extra.get('--runtime')??'codex';
|
|
308
345
|
const routes=extra.has('--protected-config')?resolveProtectedRuntimes(loadConfig({projectRoot:definition.codeProject}),boundRuntime):{reviewerRuntime:boundRuntime};
|
|
309
346
|
const executionPolicy=readLaunchExecutionPolicy({definition,mode:argv[4],enabled:extra.has('--execution-optimizations')});
|
|
@@ -352,10 +389,10 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
352
389
|
?await protectedExecutionFor(definition,argv[6],extra,review,argv[4],workflow,bridge,bootstrap,externalModels,executionPolicy,controlPolicy)
|
|
353
390
|
:executionFor(definition,argv[6],bridge,review,null,workflow,qaEnabled,runtime,
|
|
354
391
|
{...(controlPolicy?{controlPolicy}:{}),...(extra.has('--review-runtime')?{reviewRuntime:extra.get('--review-runtime')}:{}),...(executionPolicy?{executionPolicy}:{}),...(externalModels?{externalModels}:{}),...(extra.has('--verification-precheck')?{verificationPrecheck:true}:{}),...(extra.has('--original-host-context')?{originalHostContextId:extra.get('--original-host-context')}:{}),...(protection?{protection}:{}),...(bootstrap?{bootstrap:{...bootstrap,allowWrite:(controlPolicy?controlPolicy.bootstrap==='write':extra.has('--allow-bootstrap-write'))}}:{})});
|
|
355
|
-
run=await openControlRun(definition,argv[4],execution,{qaConfigRevision,rerunUnknownQa:extra.has('--rerun-unknown-qa'),rerunBlockedQa:extra.has('--rerun-blocked-qa'),qaEnvironmentFailure:extra.get('--qa-environment-failure')??null,supersedeReason:extra.get('--supersede-reason')??null,acceptSupersededCodeDrift:extra.has('--accept-superseded-code-drift'),allowAbandonReview:recoveryEnabled('--allow-abandon-review'),allowAbandonEffect:recoveryEnabled('--allow-abandon-effect'),allowBootstrapReviewRecovery:recoveryEnabled('--allow-bootstrap-review-recovery'),allowDevelopRedo:recoveryEnabled('--allow-develop-redo'),...(extra.has('--hold-revision')?{holdRevision:true}:{}),specRebindReason:extra.get('--spec-rebind-reason')??null,expectedControl});
|
|
392
|
+
run=await openControlRun(definition,argv[4],execution,{reviewedIntegration,qaConfigRevision,rerunUnknownQa:extra.has('--rerun-unknown-qa'),rerunBlockedQa:extra.has('--rerun-blocked-qa'),qaEnvironmentFailure:extra.get('--qa-environment-failure')??null,supersedeReason:extra.get('--supersede-reason')??null,acceptSupersededCodeDrift:extra.has('--accept-superseded-code-drift'),allowAbandonReview:recoveryEnabled('--allow-abandon-review'),allowAbandonEffect:recoveryEnabled('--allow-abandon-effect'),allowBootstrapReviewRecovery:recoveryEnabled('--allow-bootstrap-review-recovery'),allowDevelopRedo:recoveryEnabled('--allow-develop-redo'),...(extra.has('--hold-revision')?{holdRevision:true}:{}),scopeRevision,developmentReworkReason:extra.get('--development-rework-reason')??null,specRebindReason:extra.get('--spec-rebind-reason')??null,expectedControl,supersedeTarget});
|
|
356
393
|
}
|
|
357
394
|
if(run.blocked){output.write(JSON.stringify({outcome:'blocked',admission:run.blocked})+'\n');return 1;}
|
|
358
|
-
if(hasFix){
|
|
395
|
+
if(hasFix&&reviewedIntegration===null){
|
|
359
396
|
need(fs.realpathSync(fix.specsRoot)===fs.realpathSync(definition.specsDir)
|
|
360
397
|
&&fs.realpathSync(fix.configuration.reproduction.cwd)===fs.realpathSync(definition.codeProject)
|
|
361
398
|
&&(templated?fix.feature:fix.configuration.qaSource.feature)===definition.feature,'qa_fix_source_mismatch');
|
|
@@ -364,9 +401,9 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
364
401
|
let fixPermissions=[...fixLocalPermissions].filter(([flag])=>controlPolicy
|
|
365
402
|
?!['test-author','repair','cause-review','final-review'].some(name=>flag.endsWith('-'+name))
|
|
366
403
|
:extra.has(flag)).map(([,permission])=>permission);
|
|
367
|
-
const fixRuntime=fix.configuration.runtime??'codex';
|
|
368
|
-
const fixModels=externalModels?selectExternalModels(externalModels,[
|
|
369
|
-
const fixReview=extra.has('--qa-fix-review-config')?reviewConfiguration(extra.get('--qa-fix-review-config'),fixModels?.providers[
|
|
404
|
+
const fixRuntime=fix.configuration.runtime??'codex',fixReviewRuntime=fix.configuration.reviewRuntime??fixRuntime;
|
|
405
|
+
const fixModels=externalModels?selectExternalModels(externalModels,[fixReviewRuntime]):null;
|
|
406
|
+
const fixReview=extra.has('--qa-fix-review-config')?reviewConfiguration(extra.get('--qa-fix-review-config'),fixModels?.providers[fixReviewRuntime]??null):null;
|
|
370
407
|
if(controlPolicy&&fixReview)fixPermissions.push(...[...fixLocalPermissions]
|
|
371
408
|
.filter(([flag])=>flag.endsWith('-cause-review')||flag.endsWith('-final-review')
|
|
372
409
|
||fix.configuration.testAuthor&&flag.endsWith('-test-author')||fix.configuration.repair&&flag.endsWith('-repair'))
|
|
@@ -374,10 +411,10 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
374
411
|
need(!fixPermissions.includes('--allow-test-author')||(fix.configuration.testAuthor&&fixReview),'test_author_configuration_required');
|
|
375
412
|
need(!fixPermissions.includes('--allow-repair')||(fix.configuration.repair&&fixReview),'repair_configuration_required');
|
|
376
413
|
const fixReviewHost=createFixReviewHost({codeProject:definition.codeProject,
|
|
377
|
-
hostContextId:argv[6],runtime:fix.configuration.
|
|
414
|
+
hostContextId:argv[6],runtime:fixRuntime,reviewRuntime:fix.configuration.reviewRuntime,verification:fix.configuration.reviewVerification??null,
|
|
378
415
|
review:fixReview,permissions:fixPermissions,externalModels:fixModels,executionPolicy,specsDir:definition.specsDir});
|
|
379
416
|
if(fixModels||executionPolicy){
|
|
380
|
-
if(fixModels&&fix.configuration.causeReview)need(fix.configuration.causeReview.requestedModel===fixModels.providers[
|
|
417
|
+
if(fixModels&&fix.configuration.causeReview)need(fix.configuration.causeReview.requestedModel===fixModels.providers[fixReviewRuntime].model&&fix.configuration.causeReview.provider===fixReviewRuntime,'external_model_pair_conflict');
|
|
381
418
|
if(fixReview){
|
|
382
419
|
// Preserve explicit reviewer contexts/exclusions; changing them changes the durable run.
|
|
383
420
|
need(!fix.configuration.causeReview||digest(fix.configuration.causeReview)===digest(fixReviewHost.reviewer),'qa_fix_review_configuration_mismatch');
|
|
@@ -397,7 +434,11 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
397
434
|
const rawMode=input.isTTY&&typeof input.setRawMode==='function';if(rawMode)input.setRawMode(true);
|
|
398
435
|
const controlled=controlPolicy?withControlPolicyHost(run.host,{identity:definition.identity,
|
|
399
436
|
snapshot:()=>readExecutionSnapshot({specsRoot:definition.specsDir,identity:{repositoryId:definition.identity.repositoryId,runId:definition.identity.runId}}),launchTarget:controlLaunchTarget}):run.host;
|
|
400
|
-
const
|
|
437
|
+
const launchHost=reviewedIntegration===null?controlled:{...controlled,async handle(request){
|
|
438
|
+
if(request.operation!=='status')return {outcome:'rejected',code:'integration_launch_status_only'};
|
|
439
|
+
return controlled.handle(request);
|
|
440
|
+
}};
|
|
441
|
+
const diagnosticHost=withHandoffDiagnostic(launchHost,error);
|
|
401
442
|
try{await serveHostTransport({host:diagnosticHost,input,output,toolBridge:bridge,errorOutput:error},extra.get('--input-limit'));}
|
|
402
443
|
finally{if(rawMode)input.setRawMode(false);}
|
|
403
444
|
return 0;
|
|
@@ -597,3 +597,18 @@ test('ordinary CLI accepts --review-runtime claude under a Codex host and refuse
|
|
|
597
597
|
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
598
598
|
}
|
|
599
599
|
});
|
|
600
|
+
|
|
601
|
+
// Diagnostics must survive a real child startup failure without printing its inputs.
|
|
602
|
+
test('host fixture startup failure retains bounded process diagnostics',async()=>{
|
|
603
|
+
const f=fixture();
|
|
604
|
+
try{
|
|
605
|
+
f.args.push('--synthetic-unknown-option');
|
|
606
|
+
const result=await runCli(f,'normal');
|
|
607
|
+
assert.equal(result.code,1);
|
|
608
|
+
assert.equal(result.diagnostic.exitCode,1);
|
|
609
|
+
assert.equal(result.diagnostic.lastOperation,'advance');
|
|
610
|
+
assert.equal(result.diagnostic.timeoutMs,Number(process.env.CM_TEST_FIXTURE_TIMEOUT_MS??60000));
|
|
611
|
+
assert(result.diagnostic.stderrBytes>0);
|
|
612
|
+
assert(!JSON.stringify(result.diagnostic).includes(f.root));
|
|
613
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
614
|
+
});
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// Synthetic protocol fixtures only: these observations are not an independent
|
|
2
|
+
// review of this change and must never be used as product approval evidence.
|
|
3
|
+
import test,{after} from 'node:test';
|
|
4
|
+
import assert from 'node:assert/strict';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
9
|
+
import {readRunnerHistory} from '../runtime/js/cm-ai/durable-runner-state.mjs';
|
|
10
|
+
import {readIntegrationPlan,validateIntegrationRecord,previewReviewedIntegration,readIntegrationEvidence,verifyReviewedIntegration}
|
|
11
|
+
from '../runtime/js/cm-ai/reviewed-integration.mjs';
|
|
12
|
+
import {canonical,sha,createReviewedIntegrationFixture,syntheticIntegrationReview} from './fixtures/reviewed-integration.mjs';
|
|
13
|
+
|
|
14
|
+
let shared;
|
|
15
|
+
const cleanup=[];
|
|
16
|
+
const sharedFixture=()=>shared??=(async()=>{
|
|
17
|
+
let timer;
|
|
18
|
+
const deadline=new Promise((_,reject)=>{timer=setTimeout(()=>reject(new Error('Shared fixture preparation exceeded 90000 ms')),90000);});
|
|
19
|
+
try{return await Promise.race([createReviewedIntegrationFixture({after:fn=>cleanup.push(fn)},{unrelated:true,premature:true}),deadline]);}
|
|
20
|
+
finally{clearTimeout(timer);}
|
|
21
|
+
})();
|
|
22
|
+
after(()=>{for(const fn of cleanup.reverse())fn();});
|
|
23
|
+
|
|
24
|
+
const rejectPreview=(input,message)=>{
|
|
25
|
+
const result=previewReviewedIntegration(input);
|
|
26
|
+
assert.equal(result.eligibleForAdoption,false,message??JSON.stringify(result));
|
|
27
|
+
assert.notEqual(result.code,'integration_review_required',message??JSON.stringify(result));
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
const rejectOwner=action=>{
|
|
31
|
+
let result;
|
|
32
|
+
try{result=action();}catch(error){assert.equal(typeof error.code,'string');return;}
|
|
33
|
+
assert.equal(result?.outcome,'rejected',JSON.stringify(result));
|
|
34
|
+
};
|
|
35
|
+
function reseal(records){
|
|
36
|
+
let previous=null;
|
|
37
|
+
return structuredClone(records).map(row=>{
|
|
38
|
+
const {digest:old,...body}=row;body.previousDigest=previous;
|
|
39
|
+
const result={...body,digest:digest(body)};previous=result.digest;return result;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
test('a reviewed integration plan retains exact source identities without an alias field',()=>{
|
|
44
|
+
const plan={version:1,kind:'cm-reviewed-integration-v1',author:{provider:'codex',contextId:'synthetic-integration-author'},
|
|
45
|
+
target:{identity:{repositoryId:'oldrepo',runId:'parent-run',taskId:'T-001',attempt:1},
|
|
46
|
+
rootDigest:'a'.repeat(64),baselineDigest:'b'.repeat(64),packageDigest:'c'.repeat(64),recordCount:1,lastDigest:'d'.repeat(64)},
|
|
47
|
+
sources:[{identity:{repositoryId:'oldrepo',runId:'source-run',taskId:'T-002',attempt:1},
|
|
48
|
+
root:fs.realpathSync(os.tmpdir()),revision:'e'.repeat(64),packageDigest:'f'.repeat(64)}],documents:[]};
|
|
49
|
+
assert.deepEqual(readIntegrationPlan(plan),plan);
|
|
50
|
+
assert.throws(()=>readIntegrationPlan({...plan,alias:{oldrepo:'newrepo'}}));
|
|
51
|
+
assert.throws(()=>readIntegrationPlan({...plan,sources:[plan.sources[0],plan.sources[0]]}));
|
|
52
|
+
assert.throws(()=>readIntegrationPlan({...plan,sources:[{...plan.sources[0],identity:plan.target.identity}]}));
|
|
53
|
+
assert.throws(()=>readIntegrationPlan({...plan,sources:[{...plan.sources[0],identity:{...plan.sources[0].identity,attempt:0}}]}));
|
|
54
|
+
assert.throws(()=>readIntegrationPlan({...plan,sources:Array.from({length:65},(_,i)=>({...plan.sources[0],
|
|
55
|
+
identity:{...plan.sources[0].identity,runId:`source-${i}`}}))}));
|
|
56
|
+
for(const name of ['../docs/guide.md','src/guide.md','docs/guide.js','/docs/guide.md']){
|
|
57
|
+
const descriptor={path:name,type:'file',mode:0o644,size:1,sha256:'a'.repeat(64)};
|
|
58
|
+
assert.throws(()=>readIntegrationPlan({...plan,documents:[{path:name,before:descriptor,after:descriptor}]}));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// The first fixture user owns the existing 90 s preparation budget plus its
|
|
63
|
+
// original 30 s test-body allowance; product invocation budgets are unchanged.
|
|
64
|
+
test('pure acceptance binds the original prefix and preserves original baseline and package',{timeout:120000},async t=>{
|
|
65
|
+
const f=await sharedFixture(),before=structuredClone(f.input.records);
|
|
66
|
+
const validate=record=>validateIntegrationRecord({record,baseline:f.input.baseline,parentPackage:f.input.parentPackage,records:before});
|
|
67
|
+
assert.doesNotThrow(()=>validate(f.record));assert.deepEqual(f.input.records,before);
|
|
68
|
+
for(const change of [record=>record.plan.target.recordCount++,record=>record.plan.target.lastDigest='0'.repeat(64),
|
|
69
|
+
record=>record.plan.target.baselineDigest='0'.repeat(64),record=>record.plan.target.packageDigest='0'.repeat(64),
|
|
70
|
+
record=>record.plan.target.rootDigest='0'.repeat(64),record=>record.plan.target.identity.attempt++,
|
|
71
|
+
record=>record.reason='',record=>record.reviewFile.sha256='invalid']){
|
|
72
|
+
const record=structuredClone(f.record);change(record);record.planDigest=digest(record.plan);assert.throws(()=>validate(record));
|
|
73
|
+
}
|
|
74
|
+
assert.throws(()=>validate({...f.record,planDigest:'0'.repeat(64)}));
|
|
75
|
+
assert.throws(()=>validateIntegrationRecord({record:f.record,baseline:f.input.baseline,
|
|
76
|
+
parentPackage:f.input.parentPackage,records:before.slice(0,-1)}));
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('preview requires review only after the whole mapped tree matches and never changes the run',{timeout:30000},async t=>{
|
|
80
|
+
const f=await sharedFixture(),bytes=fs.readFileSync(f.statePath('parent')),calls={...f.calls};
|
|
81
|
+
const before=previewReviewedIntegration({...f.input,review:null});
|
|
82
|
+
assert.equal(before.eligibleForAdoption,false);assert.equal(before.code,'integration_review_required');
|
|
83
|
+
const ready=previewReviewedIntegration(f.input);
|
|
84
|
+
assert.equal(ready.eligibleForAdoption,true,JSON.stringify(ready));assert.equal(ready.planDigest,digest(f.plan));assert.equal(ready.sourceCount,2);
|
|
85
|
+
assert.doesNotThrow(()=>verifyReviewedIntegration(f.input));
|
|
86
|
+
assert.equal(f.history('parent').saved.records[0].payload.config.developer.provider,'claude');
|
|
87
|
+
assert.equal(f.plan.author.provider,'codex');assert.equal(f.review.registration.request.provider,'claude');
|
|
88
|
+
for(let n=0;n<48;n++)f.write(`extra-${String(n).padStart(2,'0')}.mjs`,'// unreviewed\n');
|
|
89
|
+
const extras=rejectPreview(f.input);assert(extras.paths.includes('extra-47.mjs'),JSON.stringify(extras));
|
|
90
|
+
for(let n=0;n<48;n++)fs.unlinkSync(path.join(f.codeProject,`extra-${String(n).padStart(2,'0')}.mjs`));
|
|
91
|
+
f.write('docs/guide.md',f.documents['docs/guide.md'].after+' ');
|
|
92
|
+
assert(rejectPreview(f.input).paths.includes('docs/guide.md'));
|
|
93
|
+
f.write('docs/guide.md',f.documents['docs/guide.md'].after);
|
|
94
|
+
if(process.platform!=='win32'){
|
|
95
|
+
fs.chmodSync(path.join(f.codeProject,'source.mjs'),0o755);rejectPreview(f.input);fs.chmodSync(path.join(f.codeProject,'source.mjs'),0o644);
|
|
96
|
+
}
|
|
97
|
+
assert.equal(previewReviewedIntegration(f.input).eligibleForAdoption,true);
|
|
98
|
+
assert.deepEqual(fs.readFileSync(f.statePath('parent')),bytes);assert.deepEqual(f.calls,calls);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('sources stay fixed to completed snapshots, exact identity and the original Git repository',{timeout:30000},async t=>{
|
|
102
|
+
const f=await sharedFixture(),base={...f.input,review:null};
|
|
103
|
+
const withSource=source=>({...base,plan:{...f.plan,sources:[source,f.plan.sources[1]]}});
|
|
104
|
+
const source=f.plan.sources[0];
|
|
105
|
+
for(const altered of [{...source,revision:'0'.repeat(64)},{...source,packageDigest:'0'.repeat(64)},
|
|
106
|
+
{...source,identity:{...source.identity,repositoryId:'arbitrary-alias'}},
|
|
107
|
+
{...source,identity:{...source.identity,taskId:'T-other'}},{...source,root:f.codeProject}])rejectPreview(withSource(altered));
|
|
108
|
+
const alias=path.join(f.root,'source-alias');fs.symlinkSync(f.sourceRoot,alias);
|
|
109
|
+
rejectPreview(withSource({...source,root:alias}));
|
|
110
|
+
// Keep the same source path and its real completed snapshot. Remove only its
|
|
111
|
+
// worktree registration, then point .git directly at the target common dir.
|
|
112
|
+
// Root/package/snapshot bindings still match; commonDir equality alone would
|
|
113
|
+
// incorrectly accept this unregistered directory.
|
|
114
|
+
const gitFile=path.join(f.sourceRoot,'.git'),gitBytes=fs.readFileSync(gitFile);
|
|
115
|
+
const admin=fs.realpathSync(path.resolve(f.sourceRoot,gitBytes.toString('utf8').trim().slice('gitdir: '.length)));
|
|
116
|
+
const heldAdmin=path.join(f.root,'held-worktree-admin');fs.renameSync(admin,heldAdmin);
|
|
117
|
+
fs.writeFileSync(gitFile,`gitdir: ${path.join(f.codeProject,'.git')}\n`);
|
|
118
|
+
try{rejectPreview(base,'sharing commonDir without a registered worktree is insufficient');}
|
|
119
|
+
finally{fs.writeFileSync(gitFile,gitBytes);fs.renameSync(heldAdmin,admin);}
|
|
120
|
+
const unrelated=f.makePlan('parent',['unrelated','renamed']);
|
|
121
|
+
rejectPreview({...base,plan:unrelated},'a separately initialized Git repository cannot be mapped by file equality');
|
|
122
|
+
const complete=fs.readFileSync(f.statePath('cross'));
|
|
123
|
+
fs.writeFileSync(f.statePath('cross'),f.approvedBytes.cross);
|
|
124
|
+
const approved=JSON.parse(f.approvedBytes.cross);
|
|
125
|
+
rejectPreview(withSource({...source,revision:approved.revision}),'approved but incomplete is not a delivered source');
|
|
126
|
+
fs.writeFileSync(f.statePath('cross'),complete);
|
|
127
|
+
const renameFile=f.statePath('rename'),held=renameFile+'.held';
|
|
128
|
+
fs.renameSync(renameFile,held);
|
|
129
|
+
try{rejectPreview(base,'new repository identity needs the completed old-name to new-name package');}
|
|
130
|
+
finally{fs.renameSync(held,renameFile);}
|
|
131
|
+
assert.equal(previewReviewedIntegration(f.input).eligibleForAdoption,true);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('a later rename cannot retroactively authorize a source using the new repository identity',{timeout:30000},async t=>{
|
|
135
|
+
const f=await sharedFixture();
|
|
136
|
+
rejectPreview({...f.input,plan:f.makePlan('parent',['cross','premature']),review:null});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('evidence reader rejects links, duplicate keys and noncanonical bytes',{timeout:30000},async t=>{
|
|
140
|
+
const f=await sharedFixture(),original=fs.readFileSync(f.evidenceFile);
|
|
141
|
+
assert.deepEqual(readIntegrationEvidence(f.evidenceFile),{plan:f.plan,review:f.review});
|
|
142
|
+
for(const bytes of [JSON.stringify({plan:f.plan,review:f.review}),JSON.stringify({plan:f.plan,review:f.review},null,2)+'\n',
|
|
143
|
+
canonical({plan:f.plan,review:f.review}).replace('{"plan":','{"plan":null,"plan":')]){
|
|
144
|
+
fs.writeFileSync(f.evidenceFile,bytes);assert.throws(()=>readIntegrationEvidence(f.evidenceFile));
|
|
145
|
+
}
|
|
146
|
+
fs.writeFileSync(f.evidenceFile,original);
|
|
147
|
+
const hardlink=path.join(f.root,'evidence-hardlink.json');fs.linkSync(f.evidenceFile,hardlink);
|
|
148
|
+
assert.throws(()=>readIntegrationEvidence(f.evidenceFile));fs.unlinkSync(hardlink);
|
|
149
|
+
const symlink=path.join(f.root,'evidence-symlink.json');fs.symlinkSync(f.evidenceFile,symlink);
|
|
150
|
+
assert.throws(()=>readIntegrationEvidence(symlink));
|
|
151
|
+
assert.deepEqual(readIntegrationEvidence(f.evidenceFile),{plan:f.plan,review:f.review});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test('review binds current author, exact plan bytes, document transforms and mechanical verification',{timeout:30000},async t=>{
|
|
155
|
+
const f=await sharedFixture();
|
|
156
|
+
const stalePlan={...f.plan,target:{...f.plan.target,recordCount:f.plan.target.recordCount+1}};
|
|
157
|
+
const staleReview=await syntheticIntegrationReview(f.root,stalePlan,f.documents);
|
|
158
|
+
rejectPreview({...f.input,review:staleReview},'a valid review of another target cannot authorize this plan');
|
|
159
|
+
const wrongDocuments={'docs/guide.md':{...f.documents['docs/guide.md'],after:'Different reviewed bytes\n'}};
|
|
160
|
+
const wrongReview=await syntheticIntegrationReview(f.root,f.plan,wrongDocuments);
|
|
161
|
+
rejectPreview({...f.input,review:wrongReview},'a separately reviewed document cannot supply different after bytes');
|
|
162
|
+
const legacy=await syntheticIntegrationReview(f.root,f.plan,f.documents,{includeVerification:false});
|
|
163
|
+
rejectPreview({...f.input,review:legacy},'approved without the required isolated verification evidence is insufficient');
|
|
164
|
+
const reused=await syntheticIntegrationReview(f.root,f.plan,f.documents,{threadId:'synthetic-parent-review-thread'});
|
|
165
|
+
rejectPreview({...f.input,review:reused},'a valid observation cannot reuse the historical parent provider thread');
|
|
166
|
+
for(const change of [review=>delete review.result.verification,review=>review.result.verification.packageDigest='0'.repeat(64),
|
|
167
|
+
review=>review.configuration.hostContextId='another-author',review=>review.started='synthetic-parent-review-thread']){
|
|
168
|
+
const review=structuredClone(f.review);change(review);rejectPreview({...f.input,review});
|
|
169
|
+
}
|
|
170
|
+
const sameProviderPlan={...f.plan,author:{...f.plan.author,provider:'claude'}};
|
|
171
|
+
assert.throws(()=>readIntegrationPlan(sameProviderPlan));
|
|
172
|
+
assert.equal(previewReviewedIntegration(f.input).eligibleForAdoption,true);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test('original owner accepts once, replay retains all history and live drift blocks without refunding calls',{timeout:30000},async t=>{
|
|
176
|
+
const f=await sharedFixture(),before=f.history('parent'),bytes=fs.readFileSync(f.statePath('parent')),
|
|
177
|
+
tasks=fs.readFileSync(path.join(f.specsDir,f.definitions.parent.feature,'tasks.md')),calls={...f.calls};
|
|
178
|
+
let run=await f.openParent();
|
|
179
|
+
try{
|
|
180
|
+
assert.equal(typeof run.host.acceptReviewedIntegration,'function');
|
|
181
|
+
const args={allowed:true,evidenceFile:f.evidenceFile,expectedDigest:digest(f.plan)};
|
|
182
|
+
rejectOwner(()=>run.host.acceptReviewedIntegration({...args,allowed:false}));
|
|
183
|
+
rejectOwner(()=>run.host.acceptReviewedIntegration({...args,expectedDigest:'0'.repeat(64)}));
|
|
184
|
+
assert.deepEqual(fs.readFileSync(f.statePath('parent')),bytes);
|
|
185
|
+
const accepted=run.host.acceptReviewedIntegration(args);assert.equal(accepted.state,'fixture_completed',JSON.stringify(accepted));
|
|
186
|
+
const after=f.history('parent');
|
|
187
|
+
assert.equal(after.saved.records.length,before.saved.records.length+1);
|
|
188
|
+
assert.deepEqual(after.saved.records.slice(0,-1),before.saved.records);
|
|
189
|
+
assert.deepEqual(after.state,before.state);assert.deepEqual(after.original,before.original);
|
|
190
|
+
assert.deepEqual(after.saved.identity,before.saved.identity);assert.deepEqual(after.saved.fingerprints,before.saved.fingerprints);
|
|
191
|
+
const added=after.saved.records.at(-1);assert.equal(added.payload.type,'reviewed-integration-accepted');
|
|
192
|
+
assert.equal(added.payload.record.reviewFile.sha256,sha(fs.readFileSync(f.evidenceFile)));
|
|
193
|
+
const adopted=fs.readFileSync(f.statePath('parent'));
|
|
194
|
+
assert.equal(run.host.acceptReviewedIntegration(args).state,'fixture_completed');
|
|
195
|
+
assert.deepEqual(fs.readFileSync(f.statePath('parent')),adopted);
|
|
196
|
+
for(const change of [record=>record.plan.target.recordCount++,record=>record.plan.target.lastDigest='0'.repeat(64),
|
|
197
|
+
record=>record.reason='',record=>record.planDigest='0'.repeat(64)]){
|
|
198
|
+
const records=structuredClone(after.saved.records);change(records.at(-1).payload.record);
|
|
199
|
+
assert.throws(()=>readRunnerHistory(reseal(records),records[0].payload.config,3));
|
|
200
|
+
}
|
|
201
|
+
run.close();run=null;
|
|
202
|
+
run=await f.openParent();
|
|
203
|
+
const status=await run.host.handle(f.request('parent','status'));
|
|
204
|
+
assert.equal(status.state,'fixture_completed');assert.equal(status.code,null,JSON.stringify(status));
|
|
205
|
+
assert.deepEqual(fs.readFileSync(f.statePath('parent')),adopted);
|
|
206
|
+
const proof=fs.readFileSync(f.evidenceFile);fs.writeFileSync(f.evidenceFile,Buffer.concat([proof,Buffer.from(' ')]));
|
|
207
|
+
const drift=await run.host.handle(f.request('parent','status'));assert.equal(drift.code,'correction_review_required',JSON.stringify(drift));
|
|
208
|
+
assert.deepEqual(f.history('parent').state,before.state);assert.deepEqual(fs.readFileSync(f.statePath('parent')),adopted);
|
|
209
|
+
fs.writeFileSync(f.evidenceFile,proof);
|
|
210
|
+
const sourceBytes=fs.readFileSync(f.statePath('cross'));fs.writeFileSync(f.statePath('cross'),f.approvedBytes.cross);
|
|
211
|
+
const stale=await run.host.handle(f.request('parent','status'));assert.equal(stale.code,'correction_review_required',JSON.stringify(stale));
|
|
212
|
+
fs.writeFileSync(f.statePath('cross'),sourceBytes);
|
|
213
|
+
assert.deepEqual(fs.readFileSync(f.statePath('parent')),adopted);
|
|
214
|
+
assert.deepEqual(f.calls,calls);assert.deepEqual(fs.readFileSync(path.join(f.specsDir,f.definitions.parent.feature,'tasks.md')),tasks);
|
|
215
|
+
// The accepted parent is not a recursively acceptable source. Without this
|
|
216
|
+
// guard its original parent package would exactly explain these two edits.
|
|
217
|
+
const cross=f.history('cross'),inverse=f.makePlan('cross',['parent'],false);
|
|
218
|
+
fs.writeFileSync(path.join(f.sourceRoot,'parent.mjs'),'export const parent=1;\n');
|
|
219
|
+
fs.writeFileSync(path.join(f.sourceRoot,'docs/guide.md'),f.documents['docs/guide.md'].before);
|
|
220
|
+
rejectPreview({root:f.sourceRoot,specsRoot:f.specsDir,baseline:cross.original,parentPackage:cross.state.reviewPackage,
|
|
221
|
+
records:cross.saved.records,plan:inverse,review:null},'accepted integration sources cannot be recursively adopted');
|
|
222
|
+
}finally{run?.close();}
|
|
223
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import {integrationReviewIndependent} from '../runtime/js/cm-ai/reviewed-integration.mjs';
|
|
4
|
+
|
|
5
|
+
const base={reviewRunId:'run-review',targetRunId:'run-target',hostContextId:'ctx-1',authorContextId:'ctx-1',
|
|
6
|
+
reviewerProvider:'claude',authorProvider:'codex',reviewerThreadId:'thread-r',
|
|
7
|
+
previousThreads:['thread-old'],developerThreadId:'thread-dev'};
|
|
8
|
+
|
|
9
|
+
test('integration review independence: different tool passes', ()=>{
|
|
10
|
+
assert.equal(integrationReviewIndependent(base),true);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('integration review independence: same tool as author is rejected', ()=>{
|
|
14
|
+
assert.equal(integrationReviewIndependent({...base,reviewerProvider:'codex'}),false);
|
|
15
|
+
assert.equal(integrationReviewIndependent({...base,reviewerProvider:'claude',authorProvider:'claude'}),false);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('integration review independence: reused run, context or threads are rejected', ()=>{
|
|
19
|
+
assert.equal(integrationReviewIndependent({...base,reviewRunId:'run-target'}),false);
|
|
20
|
+
assert.equal(integrationReviewIndependent({...base,hostContextId:'ctx-2'}),false);
|
|
21
|
+
assert.equal(integrationReviewIndependent({...base,reviewerThreadId:'thread-old'}),false);
|
|
22
|
+
assert.equal(integrationReviewIndependent({...base,reviewerThreadId:'thread-dev'}),false);
|
|
23
|
+
});
|