@aibyzero/cm-workflow 0.17.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +23 -0
- package/CHANGELOG.md +242 -0
- package/README.md +20 -3
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/VERSION +1 -1
- package/compat/claude-commands/cm-challenge.md +3 -0
- package/docs/architecture.md +11 -0
- package/docs/cm-control-policy-v2.md +127 -9
- package/docs/installation.md +310 -4
- package/docs/js-workflow-control.md +150 -15
- package/docs/live-evidence-drivers.md +28 -4
- package/docs/out-of-scope/README.md +25 -0
- package/docs/out-of-scope/background-supervisor.md +32 -0
- package/docs/reviewed-integration.md +48 -0
- package/docs/user-guide.md +50 -21
- package/install-codex.sh +331 -18
- package/install.ps1 +28 -2
- package/install.sh +321 -17
- package/package.json +2 -1
- package/runtime/js/autonomy.mjs +152 -0
- package/runtime/js/cm-ai/batch-location.mjs +55 -0
- package/runtime/js/cm-ai/batch-plan.mjs +242 -0
- package/runtime/js/cm-ai/checkpoint-package-material.mjs +162 -0
- package/runtime/js/cm-ai/claude-developer-proposal.schema.json +55 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +83 -14
- package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-admission.mjs +56 -17
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +91 -6
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +5 -1
- package/runtime/js/cm-ai/codex-config.mjs +6 -2
- package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +3 -2
- package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
- package/runtime/js/cm-ai/codex-reconnect-notice.mjs +6 -0
- package/runtime/js/cm-ai/codex-review-adapter.mjs +27 -7
- package/runtime/js/cm-ai/control-policy.mjs +21 -4
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +115 -11
- package/runtime/js/cm-ai/drive-rate-limit.mjs +105 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +234 -33
- package/runtime/js/cm-ai/effect-contract.mjs +11 -2
- package/runtime/js/cm-ai/execution-policy.mjs +3 -1
- package/runtime/js/cm-ai/execution-snapshot.mjs +4 -2
- package/runtime/js/cm-ai/execution-store-limits.mjs +14 -7
- package/runtime/js/cm-ai/execution-store.mjs +60 -17
- package/runtime/js/cm-ai/fix-code-association.mjs +73 -2
- package/runtime/js/cm-ai/host-check.mjs +11 -5
- package/runtime/js/cm-ai/host-conversation-execution.mjs +70 -28
- package/runtime/js/cm-ai/host-qa-executor.mjs +38 -5
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +19 -2
- package/runtime/js/cm-ai/host-replay.mjs +148 -0
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +19 -2
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/implicit-qa-decision.mjs +5 -0
- package/runtime/js/cm-ai/integration-snapshots.mjs +50 -0
- package/runtime/js/cm-ai/live-evidence.mjs +28 -6
- package/runtime/js/cm-ai/operator-guidance.mjs +9 -2
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +27 -9
- package/runtime/js/cm-ai/process-group-exit.mjs +46 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +3 -2
- package/runtime/js/cm-ai/qa-attachment.mjs +22 -0
- package/runtime/js/cm-ai/qa-config-revision.mjs +7 -2
- package/runtime/js/cm-ai/requirement-evidence.mjs +102 -0
- package/runtime/js/cm-ai/review-package.mjs +79 -7
- package/runtime/js/cm-ai/review-presentation-delta.mjs +166 -0
- package/runtime/js/cm-ai/review-presentation.mjs +177 -8
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +70 -2
- package/runtime/js/cm-ai/reviewed-integration.mjs +260 -0
- package/runtime/js/cm-ai/scope-revision.mjs +38 -0
- package/runtime/js/cm-ai/specification-material.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +242 -39
- package/runtime/js/cm-ai/verification-auto.mjs +38 -0
- package/runtime/js/cm-ai/worker-claude-developer.mjs +39 -15
- package/runtime/js/cm-ai/worker-claude.mjs +35 -13
- package/runtime/js/cm-ai/worker-codex-developer.mjs +43 -17
- package/runtime/js/cm-ai/worker-codex.mjs +41 -7
- package/runtime/js/cm-fix/cause-invocation.mjs +16 -2
- package/runtime/js/cm-fix/cause-package.mjs +46 -1
- package/runtime/js/cm-fix/command-correction.mjs +37 -0
- package/runtime/js/cm-fix/cooperative.mjs +12 -0
- package/runtime/js/cm-fix/dossier.mjs +8 -2
- package/runtime/js/cm-fix/execution.mjs +578 -100
- package/runtime/js/cm-fix/final-review.mjs +39 -8
- package/runtime/js/cm-fix/finish.mjs +15 -11
- package/runtime/js/cm-fix/host-review.mjs +65 -10
- package/runtime/js/cm-fix/host.mjs +35 -12
- package/runtime/js/cm-fix/jest-command-correction.mjs +69 -0
- package/runtime/js/cm-fix/metrics.mjs +18 -5
- package/runtime/js/cm-fix/regression-evidence.mjs +3 -2
- package/runtime/js/cm-fix/regression.mjs +16 -7
- package/runtime/js/cm-fix/repair.mjs +29 -8
- package/runtime/js/cm-fix/review-verification-command.mjs +135 -0
- package/runtime/js/cm-fix/review-verification-contract.mjs +54 -0
- package/runtime/js/cm-fix/review-verification-diagnostic.mjs +75 -0
- package/runtime/js/cm-fix/review-verification-recovery.mjs +44 -0
- package/runtime/js/cm-fix/review-verification-server.mjs +38 -0
- package/runtime/js/cm-fix/review-verification.mjs +214 -0
- package/runtime/js/cm-fix/source-correction-recovery.mjs +65 -0
- package/runtime/js/cm-fix/start.mjs +6 -3
- package/runtime/js/cm-fix/test-type-correction.mjs +86 -0
- package/runtime/js/cm-fix/test-type-recovery.mjs +51 -0
- package/runtime/js/cm-fix/type-import-correction.mjs +89 -0
- package/runtime/js/cm-prd/accepted-design.mjs +8 -0
- package/runtime/js/cm-prd/analysis.mjs +13 -9
- package/runtime/js/cm-prd/change.mjs +37 -16
- package/runtime/js/cm-prd/draft-save.mjs +13 -6
- package/runtime/js/cm-prd/draft.mjs +31 -3
- package/runtime/js/cm-prd/failed-correction.mjs +19 -3
- package/runtime/js/cm-prd/inputs-replaced.mjs +3 -0
- package/runtime/js/cm-prd/review-correction.mjs +6 -4
- package/runtime/js/cm-prd/review-disposition.mjs +7 -1
- package/runtime/js/cm-prd/self-check-revision.mjs +2 -2
- package/runtime/js/cm-prd/self-check.mjs +125 -6
- package/runtime/js/cm-prd/session.mjs +30 -1
- package/runtime/js/cm-prd/summary.mjs +11 -5
- package/runtime/js/cm-prd/task-scope-record.mjs +97 -0
- package/runtime/js/cm-prd/tree-digest.mjs +34 -0
- package/runtime/js/cm-prd/validation-reason.mjs +8 -4
- package/runtime/js/cm-security/scan.mjs +1 -1
- package/runtime/js/commander/decision.mjs +44 -0
- package/runtime/js/commander/dispatch-registry.mjs +110 -0
- package/runtime/js/commander/ledger.mjs +265 -0
- package/runtime/js/commander/preflight.mjs +107 -0
- package/runtime/js/notify-later.mjs +13 -0
- package/runtime/js/notify-send.mjs +6 -2
- package/runtime/js/notify.mjs +581 -65
- 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 +5 -4
- package/runtime/js/task-scope.mjs +197 -0
- package/runtime/logging.md +6 -1
- package/runtime/model-efficiency.md +69 -10
- package/runtime/orchestration.md +3 -1
- package/runtime/project-learning.md +2 -0
- package/runtime/review.md +3 -2
- package/runtime/test-contract.md +1 -0
- package/scripts/ci-test-weights.json +3 -0
- package/scripts/cm-ai-admission.mjs +21 -7
- package/scripts/cm-ai-admission.test.mjs +171 -3
- package/scripts/cm-ai-batch-drive.mjs +79 -18
- package/scripts/cm-ai-batch-drive.test.mjs +169 -3
- package/scripts/cm-ai-batch-host.mjs +38 -9
- package/scripts/cm-ai-batch-host.test.mjs +6 -5
- package/scripts/cm-ai-batch-learning-merge.test.mjs +36 -0
- package/scripts/cm-ai-batch-location.test.mjs +57 -0
- package/scripts/cm-ai-batch-plan.mjs +52 -0
- package/scripts/cm-ai-batch-plan.test.mjs +397 -0
- package/scripts/cm-ai-batch-run-fixture.mjs +446 -35
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +16 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +28 -1
- package/scripts/cm-ai-batch-run.mjs +471 -57
- package/scripts/cm-ai-batch-run.test.mjs +23 -4
- package/scripts/cm-ai-batch-session-e2e.test.mjs +235 -0
- package/scripts/cm-ai-batch-session-member.test.mjs +293 -0
- package/scripts/cm-ai-batch-session-recovery.test.mjs +423 -0
- package/scripts/cm-ai-check-recheck-cancellation.test.mjs +247 -0
- package/scripts/cm-ai-checklist-coverage.test.mjs +4 -2
- package/scripts/cm-ai-checkpoint-package-material.test.mjs +221 -0
- package/scripts/cm-ai-checkpoint-package-owner.test.mjs +193 -0
- package/scripts/cm-ai-control-launch.test.mjs +21 -0
- package/scripts/cm-ai-control-policy.test.mjs +14 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +398 -3
- package/scripts/cm-ai-control-v2-supersede-race.mjs +25 -0
- package/scripts/cm-ai-control-v2-supersede.test.mjs +318 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +163 -0
- package/scripts/cm-ai-development-rework.test.mjs +423 -0
- package/scripts/cm-ai-drive.mjs +73 -17
- package/scripts/cm-ai-drive.test.mjs +34 -2
- package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
- package/scripts/cm-ai-host.mjs +60 -19
- package/scripts/cm-ai-integration-adoption.test.mjs +223 -0
- package/scripts/cm-ai-integration-independence.test.mjs +23 -0
- package/scripts/cm-ai-integration-launch.test.mjs +240 -0
- package/scripts/cm-ai-integration-preview.mjs +41 -0
- package/scripts/cm-ai-integration-snapshots.test.mjs +197 -0
- package/scripts/cm-ai-nested-execution.test.mjs +29 -1
- package/scripts/cm-ai-operator-guidance.test.mjs +16 -1
- package/scripts/cm-ai-prefinal-delivery.test.mjs +278 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +56 -0
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +28 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +36 -2
- package/scripts/cm-ai-requirement-evidence.test.mjs +65 -0
- package/scripts/cm-ai-review-failure.test.mjs +150 -5
- package/scripts/cm-ai-run.mjs +88 -21
- package/scripts/cm-ai-scope-revision.test.mjs +341 -0
- package/scripts/cm-ai-spec-rebind.test.mjs +13 -0
- package/scripts/cm-ai-supersede.test.mjs +28 -0
- package/scripts/cm-ai-verification-auto.test.mjs +99 -0
- package/scripts/cm-announce-hook.mjs +35 -8
- package/scripts/cm-announce-hook.test.mjs +25 -0
- package/scripts/cm-autonomy.mjs +94 -0
- package/scripts/cm-autonomy.test.mjs +162 -0
- package/scripts/cm-challenge.test.mjs +61 -0
- package/scripts/cm-check-drive-files.mjs +1 -1
- package/scripts/cm-check-runtime.sh +60 -1
- package/scripts/cm-claude-developer-worker.test.mjs +56 -7
- package/scripts/cm-claude-install-layout.test.mjs +1 -1
- package/scripts/cm-claude-review-diagnostics.test.mjs +235 -0
- package/scripts/cm-claude-review-stream.test.mjs +13 -0
- package/scripts/cm-codex-developer-reconnect-notice.test.mjs +98 -0
- package/scripts/cm-codex-developer-worker.test.mjs +120 -0
- package/scripts/cm-codex-install-local-edit-guard.test.mjs +436 -0
- package/scripts/cm-codex-prompt-input.test.mjs +153 -0
- package/scripts/cm-codex-reconnect-notice.test.mjs +167 -0
- package/scripts/cm-commander-ledger.test.mjs +260 -0
- package/scripts/cm-commander-p2.test.mjs +295 -0
- package/scripts/cm-commander-preflight.mjs +84 -0
- package/scripts/cm-commander.mjs +116 -0
- package/scripts/cm-config-lock.mjs +35 -0
- package/scripts/cm-controlled-correction.test.mjs +10 -1
- package/scripts/cm-developer-failure-code.test.mjs +62 -0
- package/scripts/cm-display-task-id.test.mjs +41 -0
- package/scripts/cm-efficiency-presentation-delta.test.mjs +218 -0
- package/scripts/cm-execution-snapshot-reuse.test.mjs +115 -0
- package/scripts/cm-external-batch-host.test.mjs +4 -3
- package/scripts/cm-external-process-cleanup.test.mjs +128 -0
- package/scripts/cm-external-qa-fix.test.mjs +89 -7
- package/scripts/cm-external-review-reconciliation.test.mjs +11 -0
- package/scripts/cm-failover.mjs +48 -10
- package/scripts/cm-failover.test.mjs +46 -0
- package/scripts/cm-fix-cause-invocation.test.mjs +19 -4
- package/scripts/cm-fix-command-correction.mjs +17 -0
- package/scripts/cm-fix-command-correction.test.mjs +211 -0
- package/scripts/cm-fix-cooperative-closeout.test.mjs +87 -0
- package/scripts/cm-fix-diagnosis-module-correction.test.mjs +217 -0
- package/scripts/cm-fix-drive.mjs +33 -5
- package/scripts/cm-fix-drive.test.mjs +49 -0
- package/scripts/cm-fix-host-review-assembly.test.mjs +197 -1
- package/scripts/cm-fix-host-review.test.mjs +21 -9
- package/scripts/cm-fix-host.mjs +26 -8
- package/scripts/cm-fix-monorepo-map.test.mjs +92 -0
- package/scripts/cm-fix-observation-task-id.test.mjs +122 -0
- package/scripts/cm-fix-regression-input-budget.test.mjs +111 -0
- package/scripts/cm-fix-repair-input-budget.test.mjs +119 -0
- package/scripts/cm-fix-review-file-paging.test.mjs +91 -0
- package/scripts/cm-fix-review-preflight.mjs +24 -0
- package/scripts/cm-fix-review-storage.test.mjs +233 -0
- package/scripts/cm-fix-review-verification-command.test.mjs +242 -0
- package/scripts/cm-fix-review-verification-evidence.test.mjs +218 -0
- package/scripts/cm-fix-review-verification-integration.test.mjs +81 -0
- package/scripts/cm-fix-review-verification-recovery.test.mjs +198 -0
- package/scripts/cm-fix-review-verification.test.mjs +146 -0
- package/scripts/cm-fix-revision-transport.test.mjs +81 -0
- package/scripts/cm-fix-source-correction.test.mjs +296 -0
- package/scripts/cm-fix-test-type-correction.mjs +18 -0
- package/scripts/cm-fix-test-type-correction.test.mjs +123 -0
- package/scripts/cm-fix-test-type-owner.test.mjs +208 -0
- package/scripts/cm-fix-test-type-verification-cost.test.mjs +66 -0
- package/scripts/cm-fix-type-import-correction.test.mjs +95 -0
- package/scripts/cm-fix-verification-diagnostic.test.mjs +200 -0
- package/scripts/cm-fix-verification-recovery.mjs +33 -0
- package/scripts/cm-host-qa-executor.test.mjs +77 -0
- package/scripts/cm-host-replay.test.mjs +176 -0
- package/scripts/cm-install-local-edit-guard.test.mjs +621 -0
- package/scripts/cm-install-manifest.sh +351 -0
- package/scripts/cm-live-evidence.test.mjs +59 -1
- package/scripts/cm-log-event.mjs +61 -10
- package/scripts/cm-log-event.test.mjs +121 -1
- package/scripts/cm-matt-skills.mjs +576 -0
- package/scripts/cm-matt-skills.test.mjs +550 -0
- package/scripts/cm-notify-command.test.mjs +42 -10
- package/scripts/cm-notify.mjs +14 -10
- package/scripts/cm-notify.test.mjs +581 -59
- package/scripts/cm-patrol.mjs +4 -1
- package/scripts/cm-patrol.test.mjs +23 -5
- package/scripts/cm-prd-answer-gaps.test.mjs +2 -2
- package/scripts/cm-prd-completion.test.mjs +56 -13
- package/scripts/cm-prd-design-phase.test.mjs +78 -8
- package/scripts/cm-prd-draft-save.test.mjs +12 -0
- package/scripts/cm-prd-draft.test.mjs +1 -1
- package/scripts/cm-prd-drive.mjs +13 -6
- package/scripts/cm-prd-drive.test.mjs +45 -1
- package/scripts/cm-prd-gate-diagnostic.test.mjs +2 -2
- package/scripts/cm-prd-host.mjs +10 -5
- package/scripts/cm-prd-host.test.mjs +4 -2
- package/scripts/cm-prd-inputs-replaced.test.mjs +1 -1
- package/scripts/cm-prd-review-disposition.test.mjs +124 -8
- package/scripts/cm-prd-revision.test.mjs +1 -1
- package/scripts/cm-prd-self-check-revision.test.mjs +1 -1
- package/scripts/cm-prd-self-check-rules.test.mjs +239 -0
- package/scripts/cm-prd-self-check.test.mjs +105 -5
- package/scripts/cm-prd-summary.test.mjs +24 -3
- package/scripts/cm-prd-task-grouping.test.mjs +6 -6
- package/scripts/cm-prd-tree-digest.test.mjs +74 -0
- package/scripts/cm-refactor-drive.mjs +2 -1
- package/scripts/cm-refactor-drive.test.mjs +9 -0
- package/scripts/cm-release-smoke.sh +1 -1
- package/scripts/cm-skill-hints-autowire.test.mjs +394 -0
- package/scripts/cm-skill-hints-exam.mjs +149 -0
- package/scripts/cm-skill-hints-install.test.mjs +168 -0
- package/scripts/cm-skill-hints.exam.json +706 -0
- package/scripts/cm-skill-hints.json +119 -0
- package/scripts/cm-skill-hints.mjs +669 -0
- package/scripts/cm-skill-hints.test.mjs +831 -0
- package/scripts/cm-skill-judge.mjs +181 -0
- package/scripts/cm-skill-judge.test.mjs +255 -0
- package/scripts/cm-specs-status.test.mjs +4 -2
- package/scripts/cm-start-check.mjs +323 -0
- package/scripts/cm-start-check.test.mjs +406 -0
- package/scripts/cm-task-gate.mjs +150 -29
- package/scripts/cm-task-gate.test.mjs +73 -1
- package/scripts/cm-task-id-grammar.test.mjs +66 -0
- package/scripts/cm-task-scope.test.mjs +308 -0
- package/scripts/cm-upgrade-compat-batch.test.mjs +172 -0
- package/scripts/cm-upgrade-compat.test.mjs +239 -0
- package/scripts/cm-workflow-config.mjs +12 -2
- package/scripts/fixtures/fix-verification-claude.mjs +44 -0
- package/scripts/fixtures/reviewed-integration.mjs +202 -0
- package/scripts/scan-public-safety.py +1 -0
- package/scripts/session-boundary.test.mjs +170 -0
- package/scripts/test-npm-install.py +14 -3
- package/scripts/test-shell-compat.sh +2 -0
- package/scripts/validate-public-repo.py +4 -0
- package/scripts/validate-test-cases.mjs +3 -2
- package/skills/cm-ai/SKILL.md +5 -2
- package/skills/cm-ai/references/N3-execute-task.md +1 -1
- 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 +82 -16
- package/skills/cm-challenge/SKILL.md +65 -0
- package/skills/cm-challenge/evals/README.md +18 -0
- package/skills/cm-challenge/evals/trigger-cases.json +20 -0
- package/skills/cm-challenge/evals/trigger-config.json +28 -0
- package/skills/cm-challenge/references/examples.md +15 -0
- package/skills/cm-check/SKILL.md +5 -0
- package/skills/cm-check/references/js-host.md +2 -0
- package/skills/cm-fix/SKILL.md +12 -3
- package/skills/cm-fix/references/command-correction.md +67 -0
- package/skills/cm-fix/references/isolated-review.md +54 -0
- package/skills/cm-fix/references/js-host.md +62 -2
- package/skills/cm-fix/references/test-type-correction.md +72 -0
- package/skills/cm-fix/references/verification-recovery.md +114 -0
- package/skills/cm-idea/SKILL.md +2 -0
- package/skills/cm-idea/references/js-host.md +2 -0
- package/skills/cm-notify/SKILL.md +2 -0
- package/skills/cm-prd/SKILL.md +14 -9
- package/skills/cm-prd/references/brownfield.md +8 -1
- package/skills/cm-prd/references/change-mode.md +8 -1
- package/skills/cm-prd/references/greenfield.md +4 -0
- package/skills/cm-prd/references/js-change-recovery.md +14 -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
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// 升级兼容的完整生命周期(审查 R2-02):升级前(f73402d)创建、带在途操作的 PRD 会话,
|
|
2
|
+
// 用新代码恢复 → 开始新操作 → 发布 → 批准,全程穿过真实宿主与准入 CLI。
|
|
3
|
+
//
|
|
4
|
+
// 夹具格式依据:f73402d 的 runtime/js/cm-prd/session.mjs openPrdSession/begin/call
|
|
5
|
+
// (state.json 只有 version/identity/checkpoint/active/segments;active 为
|
|
6
|
+
// {request,before,calls,selfCheckRules?},规则字段在更早的宿主里不存在;未收到结果的
|
|
7
|
+
// 调用只有 {callId,requestDigest,kind,payload}),f73402d 的 cm-ai-admission.mjs
|
|
8
|
+
// approveCmAiSpecs(批准状态字段与顺序,taskGrammar:2;更早的批准没有该字段),
|
|
9
|
+
// task-scope-record.mjs recordPrdTaskScopes({version,enforced,exempt})。
|
|
10
|
+
// 外壳逐字段手写;检查点与生成请求负载由 analysis.mjs 产生,它在 f73402d 与本分支之间
|
|
11
|
+
// 逐字节未变。最后一条测试在 f73402d 可用时真实运行旧宿主,核对手写夹具与真实存档逐字节一致。
|
|
12
|
+
import test from 'node:test';
|
|
13
|
+
import assert from 'node:assert/strict';
|
|
14
|
+
import fs from 'node:fs';
|
|
15
|
+
import os from 'node:os';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import {spawn,spawnSync} from 'node:child_process';
|
|
18
|
+
import {once} from 'node:events';
|
|
19
|
+
import {createInterface} from 'node:readline';
|
|
20
|
+
import {fileURLToPath} from 'node:url';
|
|
21
|
+
import {createCmPrdAnalysis} from '../runtime/js/cm-prd/analysis.mjs';
|
|
22
|
+
import {checkPrdDraftMechanics,matchesPrdDraftMechanics} from '../runtime/js/cm-prd/self-check.mjs';
|
|
23
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
24
|
+
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
25
|
+
|
|
26
|
+
const TIMEOUT=Number(process.env.CM_TEST_FIXTURE_TIMEOUT_MS??120000);
|
|
27
|
+
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
|
|
28
|
+
const UPGRADE_BASE='f73402d';
|
|
29
|
+
const ANALYZED={status:'analyzed',summary:'Developer need',sourcePaths:['docs/input.md'],openQuestions:[]};
|
|
30
|
+
const PLAN={requestId:'plan',operation:'advance',text:'Generate specification draft'};
|
|
31
|
+
// 升级前宿主在第一次生成请求发出后被杀时留下的分段计数(真实旧宿主运行观察)。
|
|
32
|
+
const SEGMENTS={context_load:1,requirements_analysis:2,task_split:1,design_generation:1};
|
|
33
|
+
|
|
34
|
+
// 在途操作登记的回答:规则 1 跳过 T-002/a,规则 2 起拒绝它;规则 3 起要求每个任务写范围;
|
|
35
|
+
// 规则 4(语法 3)还会发现会话任务 T-001 不是最后一个。四条规则得到四份不同的报告。
|
|
36
|
+
const TASKS_V1=['- [ ] T-001: Update guide',' - 范围: `README.md`',' - 开发: 会话',
|
|
37
|
+
'- [ ] T-002: Walk guide',' - 范围: `docs/qa.md`','- [ ] T-003: Polish guide','- [ ] T-002/a: Hidden task',''].join('\n');
|
|
38
|
+
// 修正后的回答:规则 1-3 全部通过(`开发: 会话` 只是说明文字),规则 4 下仍报 session_task_not_final。
|
|
39
|
+
const TASKS_V2=['- [ ] T-001: Update guide',' - 范围: `README.md`',' - 开发: 会话',
|
|
40
|
+
'- [ ] T-002: Walk guide',' - 范围: `docs/qa.md`',''].join('\n');
|
|
41
|
+
const reply=tasks=>({status:'draft',summary:'Synthetic documentation draft',features:[{name:'guide',testCasesReason:'no_observable_behavior',
|
|
42
|
+
documents:[{path:'requirements.md',content:'## 功能需求\n1. [F-001] Guide\n- [ ] [AC-001] Document setup.'},
|
|
43
|
+
{path:'design.md',content:'## 方案摘要\nUnreviewed synthetic design'},{path:'tasks.md',content:tasks}]}]});
|
|
44
|
+
const EXPECTED_V1={1:[],2:['tasks_invalid'],3:['tasks_invalid','task_scope_missing'],
|
|
45
|
+
4:['tasks_invalid','task_scope_missing','session_task_not_final']};
|
|
46
|
+
|
|
47
|
+
function project(t,{prior}){
|
|
48
|
+
const dir=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-upgrade-prd-')));
|
|
49
|
+
t.after(()=>fs.rmSync(dir,{recursive:true,force:true}));
|
|
50
|
+
for(const name of ['docs','mirror'])fs.mkdirSync(path.join(dir,name));
|
|
51
|
+
fs.writeFileSync(path.join(dir,'docs/input.md'),'Synthetic requirement');
|
|
52
|
+
if(prior!=='none'){
|
|
53
|
+
// 升级前已批准并做完的一个 feature;状态按 f73402d approveCmAiSpecs 的字段顺序手写,
|
|
54
|
+
// 无字段版本是语法 2 出现前的批准。
|
|
55
|
+
fs.mkdirSync(path.join(dir,'1.history'));
|
|
56
|
+
for(const [file,content] of Object.entries({'requirements.md':'## 功能需求\n1. [F-001] History\n- [x] [AC-001] Kept.',
|
|
57
|
+
'design.md':'## 方案摘要\nHistory','tasks.md':'- [x] T-001: Old work\n'}))
|
|
58
|
+
fs.writeFileSync(path.join(dir,'1.history',file),content,{mode:0o600});
|
|
59
|
+
const at='2026-10-01T00:00:00.000Z',specFiles=buildManifest(dir);
|
|
60
|
+
fs.writeFileSync(path.join(dir,'.cm-specs-status'),JSON.stringify({status:'approved',summaryDigest:'a'.repeat(64),at,
|
|
61
|
+
features:['1.history'],specFiles,testCases:[],approval:{response:'开始',at},...(prior==='grammar2'?{taskGrammar:2}:{})})+'\n');
|
|
62
|
+
}
|
|
63
|
+
return dir;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 升级前会话存档:会话没有 taskGrammar/selfCheckRules,在途的 plan 操作已发出生成请求、
|
|
67
|
+
// 宿主随后中断(调用没有 result)。rules=null 是规则字段出现前的宿主写的。
|
|
68
|
+
async function legacySession(dir,{sessionId,rules,skillDir=path.join(root,'skills/cm-prd'),callId='0d2c7f5e-2b1a-4c3d-9e8f-7a6b5c4d3e2f'}){
|
|
69
|
+
const entry={skillDir,project:dir,specs:dir};let routeTurn=0,payload=null;
|
|
70
|
+
const analysis=createCmPrdAnalysis({input:entry,runtime:'codex',record:async({event})=>{if(event==='decision')routeTurn++;},
|
|
71
|
+
analyze:async()=>structuredClone(ANALYZED),
|
|
72
|
+
generate:async value=>{payload=JSON.parse(JSON.stringify(value));throw Object.assign(new Error('host stopped'),{code:'host_stopped'});}});
|
|
73
|
+
await analysis.advance('Analyze');
|
|
74
|
+
const checkpoint={analysis:analysis.checkpoint(),change:null,started:true,routeTurn,reviewState:null,summaryState:null,publishedSummary:false};
|
|
75
|
+
await assert.rejects(analysis.plan(PLAN.text),{code:'host_stopped'});
|
|
76
|
+
const call={callId,requestDigest:digest({kind:'prd_generate',payload}),kind:'prd_generate',payload};
|
|
77
|
+
const state={version:1,identity:{entry,runtime:'codex'},checkpoint,
|
|
78
|
+
active:{request:PLAN,before:checkpoint,calls:[call],...(rules===null?{}:{selfCheckRules:rules})},segments:SEGMENTS};
|
|
79
|
+
if(sessionId!==undefined){
|
|
80
|
+
for(const relative of ['.reviews','.reviews/prd-sessions',`.reviews/prd-sessions/${sessionId}`])
|
|
81
|
+
fs.mkdirSync(path.join(dir,relative),{mode:0o700,recursive:true});
|
|
82
|
+
fs.writeFileSync(path.join(dir,'.reviews/prd-sessions',sessionId,'state.json'),JSON.stringify(state),{mode:0o600});
|
|
83
|
+
}
|
|
84
|
+
return {state,call};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function host(dir,sessionId,onRequest){
|
|
88
|
+
const child=spawn(process.execPath,[path.join(root,'scripts/cm-prd-host.mjs'),'serve','--skill-dir',path.join(root,'skills/cm-prd'),
|
|
89
|
+
'--project',dir,'--specs',dir,'--runtime','codex','--allow-log-write','--allow-review-write','--allow-disposition-write',
|
|
90
|
+
'--allow-spec-write','--host-context','author-context','--session',sessionId],
|
|
91
|
+
{env:{...process.env,CM_WORKFLOW_LOG_HOME:path.join(dir,'mirror')},stdio:['pipe','pipe','pipe']});
|
|
92
|
+
let stderr='',bridge=null,readyResolve;const waiting=new Map(),ready=new Promise(resolve=>{readyResolve=resolve;});
|
|
93
|
+
child.stderr.on('data',chunk=>{stderr+=chunk;});
|
|
94
|
+
const closed=once(child,'close'),lines=createInterface({input:child.stdout});
|
|
95
|
+
const write=value=>child.stdin.write(JSON.stringify(value)+'\n');
|
|
96
|
+
const loop=(async()=>{for await(const line of lines){
|
|
97
|
+
const message=JSON.parse(line);
|
|
98
|
+
if(message.type==='host_ready'){bridge=message.sessionId;readyResolve();}
|
|
99
|
+
else if(message.type==='host_request')write({type:'host_result',sessionId:bridge,callId:message.callId,
|
|
100
|
+
requestDigest:message.requestDigest,result:await onRequest(message)});
|
|
101
|
+
else if(Object.hasOwn(message,'requestId')){const resolve=waiting.get(message.requestId);waiting.delete(message.requestId);resolve(message);}
|
|
102
|
+
}})();
|
|
103
|
+
return {
|
|
104
|
+
async send(request){await ready;const answer=new Promise(resolve=>waiting.set(request.requestId,resolve));write(request);
|
|
105
|
+
const message=await answer;assert.equal(message.error,undefined,`${request.requestId}: ${JSON.stringify(message.error)} ${stderr}`);return message.result;},
|
|
106
|
+
async close(){await ready;write({type:'host_close',sessionId:bridge});const [code]=await closed;await loop;assert.equal(code,0,stderr);},
|
|
107
|
+
kill(){child.kill();},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const sessionFile=(dir,sessionId)=>path.join(dir,'.reviews/prd-sessions',sessionId,'state.json');
|
|
112
|
+
const readState=(dir,sessionId)=>JSON.parse(fs.readFileSync(sessionFile(dir,sessionId),'utf8'));
|
|
113
|
+
const noBinding=state=>!Object.hasOwn(state,'taskGrammar')&&!Object.hasOwn(state,'selfCheckRules');
|
|
114
|
+
const codes=report=>report.findings.map(item=>item.code);
|
|
115
|
+
|
|
116
|
+
// rules:在途操作登记的规则(null=无字段,按规则 1);prior:发布前 .cm-specs-status 的样子。
|
|
117
|
+
for(const [rules,prior] of [[null,'none'],[1,'grammar2'],[2,'legacy'],[3,'none']])
|
|
118
|
+
test(`升级前会话(在途操作规则 ${rules??'无字段'},已有状态 ${prior})恢复→新操作→发布→批准`,{timeout:TIMEOUT},async t=>{
|
|
119
|
+
const dir=project(t,{prior}),sessionId=`prd-legacy-${rules??'none'}`,applied=rules??1;
|
|
120
|
+
const {call}=await legacySession(dir,{sessionId,rules});
|
|
121
|
+
const feature=prior==='none'?'1.guide':'2.guide';
|
|
122
|
+
// 新操作期间(请求已发出、结果未回)读存档:规则来自会话的旧字面量 3,会话本身不被改写。
|
|
123
|
+
const observed=[];
|
|
124
|
+
const watch=()=>{const state=readState(dir,sessionId);observed.push(state.active?.selfCheckRules);
|
|
125
|
+
assert.ok(noBinding(state),'升级前的会话不补写版本字段');};
|
|
126
|
+
let checks=0,v1Digest=null;
|
|
127
|
+
const session=host(dir,sessionId,async message=>{
|
|
128
|
+
const {kind,payload}=message;
|
|
129
|
+
if(kind==='prd_generate'){watch();return reply(TASKS_V2);}
|
|
130
|
+
if(kind==='prd_self_check'){watch();checks++;const draft=payload.draft;
|
|
131
|
+
// 第一次只为规则 1 的旧回答(它机械自检通过)报一个上下文失败,促成一次新的生成操作。
|
|
132
|
+
return {draftDigest:draft.draftDigest,features:draft.features.map(item=>({directory:item.directory,
|
|
133
|
+
checks:draft.mechanicalSelfCheck.pending.map((id,index)=>({id,status:draft.draftDigest===v1Digest&&index===0?'failed':'passed',
|
|
134
|
+
evidence:['Synthetic context check']}))}))};}
|
|
135
|
+
if(kind==='prd_review')return {reviewer:'codex-subagent',contextId:'reviewer-context',independent:true,at:'2026-10-27T00:00:00.000Z',
|
|
136
|
+
result:{verdict:'changes_requested',packageDigest:payload.package.packageDigest,examinedPaths:payload.examinedPaths,
|
|
137
|
+
findings:[{id:'R1',severity:'P2',path:`${feature}/design.md`,message:'Clarify design',evidence:'Synthetic finding'}],summary:'Synthetic review'}};
|
|
138
|
+
if(kind==='prd_correct')return {documents:payload.documents.map(item=>({path:item.path,
|
|
139
|
+
content:item.path===`${feature}/design.md`?'## 方案摘要\nCorrected synthetic design':item.content})),
|
|
140
|
+
decisions:[{id:'R1',status:'applied',evidence:['Synthetic clarification'],changedPaths:[`${feature}/design.md`]}]};
|
|
141
|
+
if(kind==='prd_summary')return {evidenceDigest:payload.evidenceDigest,deliveryForm:'Documentation',estimatedTime:'Human review required',
|
|
142
|
+
openQuestions:'None',risks:'Synthetic responses',contextScope:'Targeted',platformReadiness:'Not applicable',uiBaseline:'None',
|
|
143
|
+
designRisk:[{feature,signals:{greenfieldAdr:false,architectureOrDataFlow:false,newRuntimeDependencyOrToolchain:false,
|
|
144
|
+
publicContractDataOrSecurity:false,fiveOrMoreFunctions:false},evidence:['Synthetic documentation-only fixture']}]};
|
|
145
|
+
throw new Error(`unexpected host request ${kind}`);
|
|
146
|
+
});
|
|
147
|
+
try{
|
|
148
|
+
// 1. 恢复在途操作:消费原生成请求的结果,按它自己登记的规则重放。
|
|
149
|
+
let status=await session.send({requestId:'resume',operation:'resume',resolution:{callId:call.callId,requestDigest:call.requestDigest,
|
|
150
|
+
result:reply(TASKS_V1),evidence:'Planner reply delivered before the host stopped'}});
|
|
151
|
+
let state=readState(dir,sessionId);
|
|
152
|
+
assert.ok(noBinding(state));assert.equal(state.active,null);
|
|
153
|
+
const draft=state.checkpoint.analysis.draft,report=draft.mechanicalSelfCheck;
|
|
154
|
+
assert.deepEqual(codes(report),EXPECTED_V1[applied],`在途操作沿用规则 ${applied}`);
|
|
155
|
+
assert.deepEqual(report,checkPrdDraftMechanics(draft,{rules:applied}));
|
|
156
|
+
assert.ok(matchesPrdDraftMechanics(draft,report),'历史报告摘要仍匹配');
|
|
157
|
+
assert.equal(status.stage,applied===1?'draft_ready':'draft_self_check_failed');
|
|
158
|
+
v1Digest=draft.draftDigest;
|
|
159
|
+
// 2. 之后每个新操作都按会话固定的规则 3;修正稿在规则 4 下会失败,在这里通过。
|
|
160
|
+
for(let guard=0;status.stage!=='self_check_reported_passed';guard++){
|
|
161
|
+
assert.ok(guard<4,status.stage);
|
|
162
|
+
status=await session.send(status.stage==='draft_ready'?{requestId:`verify-${guard}`,operation:'advance',text:'Self-check'}
|
|
163
|
+
:{requestId:`fix-${guard}`,operation:'advance',text:'Fix reported findings'});
|
|
164
|
+
}
|
|
165
|
+
state=readState(dir,sessionId);
|
|
166
|
+
const fixed=state.checkpoint.analysis.draft;
|
|
167
|
+
assert.deepEqual(codes(fixed.mechanicalSelfCheck),[]);
|
|
168
|
+
assert.deepEqual(codes(checkPrdDraftMechanics(fixed,{rules:4})),['session_task_not_final'],'规则 4 会拒绝修正稿');
|
|
169
|
+
assert.ok(observed.length>=2&&observed.every(value=>value===3),`新操作登记规则 3:${observed}`);
|
|
170
|
+
// 3. 保存:规则 3 的保存写旧格式的范围记录,后续重查不按语法 3 读。
|
|
171
|
+
const saved=await session.send({requestId:'save',operation:'save_draft'});
|
|
172
|
+
assert.equal(saved.status,'draft_saved');
|
|
173
|
+
const slug=feature.replace(/^\d+\./,'');
|
|
174
|
+
assert.equal(fs.readFileSync(path.join(dir,`.reviews/prd-${slug}-task-scope.json`),'utf8'),
|
|
175
|
+
JSON.stringify({version:1,enforced:true,exempt:[]})+'\n');
|
|
176
|
+
assert.equal(fs.readFileSync(path.join(dir,feature,'tasks.md'),'utf8'),TASKS_V2);
|
|
177
|
+
// 4. 拆分审查、修正、处置、汇总(各处重查都在会话规则下通过)。
|
|
178
|
+
await session.send({requestId:'package',operation:'final_review_package',stage:'split',feature});
|
|
179
|
+
const reviewed=await session.send({requestId:'review',operation:'final_review',stage:'split',feature,mode:'independent'});
|
|
180
|
+
assert.equal(reviewed.reviewState.status,'review_recorded');
|
|
181
|
+
await session.send({requestId:'findings',operation:'review_findings',stage:'split',feature});
|
|
182
|
+
assert.equal((await session.send({requestId:'correct',operation:'correct_findings',stage:'split',feature})).status,'correction_saved');
|
|
183
|
+
const corrected=await session.send({requestId:'resume-correction',operation:'resume_correction',stage:'split',feature});
|
|
184
|
+
const disposed=await session.send({requestId:'disposition',operation:'review_disposition',stage:'split',feature,
|
|
185
|
+
packageDigest:corrected.packageDigest,decisions:corrected.decisions,artifacts:corrected.artifacts});
|
|
186
|
+
assert.equal(disposed.status,'disposition_recorded');
|
|
187
|
+
const summary=await session.send({requestId:'summary',operation:'prepare_summary'});
|
|
188
|
+
assert.equal(summary.readyForAwaitingReview,true,JSON.stringify(summary.blockers));
|
|
189
|
+
// 5. 发布:首次发布写会话绑定的语法 2;已有状态沿用它的语法(旧版无字段的保持无字段)。
|
|
190
|
+
const published=await session.send({requestId:'publish',operation:'publish_summary',summaryDigest:summary.summaryDigest});
|
|
191
|
+
assert.equal(published.status,'awaiting_review');
|
|
192
|
+
const awaiting=JSON.parse(fs.readFileSync(path.join(dir,'.cm-specs-status'),'utf8'));
|
|
193
|
+
assert.equal(awaiting.status,'awaiting_review');
|
|
194
|
+
if(prior==='legacy')assert.equal(Object.hasOwn(awaiting,'taskGrammar'),false,'无字段的旧状态保持无字段');
|
|
195
|
+
else assert.equal(awaiting.taskGrammar,2);
|
|
196
|
+
assert.ok(noBinding(readState(dir,sessionId)));
|
|
197
|
+
}finally{await session.close().catch(()=>session.kill());}
|
|
198
|
+
// 6. 批准:沿用待审状态携带的语法,没有携带的写 2,从不升成 3。
|
|
199
|
+
const approve=spawnSync(process.execPath,[path.join(root,'scripts/cm-ai-admission.mjs'),'--specs-dir',dir,'--code-project',dir,
|
|
200
|
+
'--approve','--approval-response','开始'],{encoding:'utf8',env:process.env});
|
|
201
|
+
const approved=JSON.parse(fs.readFileSync(path.join(dir,'.cm-specs-status'),'utf8'));
|
|
202
|
+
assert.equal(approved.status,'approved',approve.stdout+approve.stderr);
|
|
203
|
+
assert.equal(approved.taskGrammar,2);
|
|
204
|
+
assert.deepEqual(approved.features,prior==='none'?['1.guide']:['1.history','2.guide']);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// 手写夹具与升级前宿主真实写出的存档逐字节一致(只在本地有 f73402d 时可核对)。
|
|
208
|
+
const oldAvailable=spawnSync('git',['-C',root,'cat-file','-e',`${UPGRADE_BASE}^{commit}`]).status===0;
|
|
209
|
+
test('手写的升级前会话存档与 f73402d 宿主真实写出的逐字节一致',{timeout:TIMEOUT,
|
|
210
|
+
skip:oldAvailable?false:`本地没有 ${UPGRADE_BASE}(浅克隆),跳过真实旧宿主比对`},async t=>{
|
|
211
|
+
const old=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-upgrade-old-')));
|
|
212
|
+
t.after(()=>fs.rmSync(old,{recursive:true,force:true}));
|
|
213
|
+
const archive=spawnSync('git',['-C',root,'archive','--format=tar',UPGRADE_BASE],{maxBuffer:256*1024*1024});
|
|
214
|
+
assert.equal(archive.status,0,String(archive.stderr));
|
|
215
|
+
assert.equal(spawnSync('tar',['-x','-C',old],{input:archive.stdout}).status,0);
|
|
216
|
+
const dir=project(t,{prior:'none'}),skillDir=path.join(old,'skills/cm-prd');
|
|
217
|
+
const child=spawn(process.execPath,[path.join(old,'scripts/cm-prd-host.mjs'),'serve','--skill-dir',skillDir,'--project',dir,'--specs',dir,
|
|
218
|
+
'--runtime','codex','--allow-log-write'],{env:{...process.env,CM_WORKFLOW_LOG_HOME:path.join(dir,'mirror')},stdio:['pipe','pipe','pipe']});
|
|
219
|
+
const closed=once(child,'close'),lines=createInterface({input:child.stdout});let stderr='',bridge;
|
|
220
|
+
child.stderr.on('data',chunk=>{stderr+=chunk;});
|
|
221
|
+
const send=value=>child.stdin.write(JSON.stringify(value)+'\n');
|
|
222
|
+
for await(const line of lines){
|
|
223
|
+
const message=JSON.parse(line);
|
|
224
|
+
if(message.type==='host_ready'){bridge=message.sessionId;send({requestId:'turn',operation:'start',text:'Analyze'});}
|
|
225
|
+
else if(message.type==='host_request'&&message.kind==='prd_analyze')send({type:'host_result',sessionId:bridge,callId:message.callId,
|
|
226
|
+
requestDigest:message.requestDigest,result:ANALYZED});
|
|
227
|
+
else if(message.requestId==='turn'){assert.equal(message.result?.stage,'analysis_ready',stderr);send(PLAN);}
|
|
228
|
+
// 生成请求发出后宿主中断:升级前在途操作的真实样子。
|
|
229
|
+
else if(message.type==='host_request'&&message.kind==='prd_generate'){child.kill('SIGKILL');break;}
|
|
230
|
+
}
|
|
231
|
+
lines.close();await closed;
|
|
232
|
+
const [sessionId]=fs.readdirSync(path.join(dir,'.reviews/prd-sessions'));
|
|
233
|
+
const real=fs.readFileSync(sessionFile(dir,sessionId),'utf8');
|
|
234
|
+
const recorded=JSON.parse(real);
|
|
235
|
+
assert.equal(recorded.active.selfCheckRules,3,'f73402d 的宿主登记规则 3');
|
|
236
|
+
// 调用编号是会话自己随机生成的,只有它取自真实存档。
|
|
237
|
+
const {state}=await legacySession(dir,{rules:3,skillDir,callId:recorded.active.calls[0].callId});
|
|
238
|
+
assert.equal(JSON.stringify(state),real);
|
|
239
|
+
});
|
|
@@ -284,7 +284,7 @@ function requireString(value,location,choices=null){
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
function validateRaw(value){
|
|
287
|
-
const root=requireMapping(value,'config');rejectUnknown(root,new Set(['version','project','runtimes','roles','policies']),'config');
|
|
287
|
+
const root=requireMapping(value,'config');rejectUnknown(root,new Set(['version','project','runtimes','roles','policies','parallel']),'config');
|
|
288
288
|
if(typeof root.version!=='bigint'||root.version!==1n)throw new ConfigError('config.version must equal integer 1');
|
|
289
289
|
if(Object.hasOwn(root,'project')){
|
|
290
290
|
const project=requireMapping(root.project,'config.project');rejectUnknown(project,new Set(['type','workflow']),'config.project');
|
|
@@ -322,6 +322,15 @@ function validateRaw(value){
|
|
|
322
322
|
if(Object.hasOwn(policies,'auto_fix'))requireString(policies.auto_fix,'config.policies.auto_fix',AUTO_FIX_POLICIES);
|
|
323
323
|
if(Object.hasOwn(policies,'delivery'))requireString(policies.delivery,'config.policies.delivery',DELIVERY_MODES);
|
|
324
324
|
}
|
|
325
|
+
// /cm-ai worktree parallelism (runtime/js/cm-ai/batch-plan.mjs). Not in the
|
|
326
|
+
// defaults: a project that does not set it keeps its effective config unchanged.
|
|
327
|
+
if(Object.hasOwn(root,'parallel')){
|
|
328
|
+
const parallel=requireMapping(root.parallel,'config.parallel');rejectUnknown(parallel,new Set(['enabled','max','worktree_all']),'config.parallel');
|
|
329
|
+
if(Object.hasOwn(parallel,'enabled')&&typeof parallel.enabled!=='boolean')throw new ConfigError('config.parallel.enabled must be boolean');
|
|
330
|
+
if(Object.hasOwn(parallel,'worktree_all')&&typeof parallel.worktree_all!=='boolean')throw new ConfigError('config.parallel.worktree_all must be boolean');
|
|
331
|
+
if(Object.hasOwn(parallel,'max')&&!((typeof parallel.max==='bigint'&¶llel.max>=1n&¶llel.max<=4n)
|
|
332
|
+
||(Number.isInteger(parallel.max)&¶llel.max>=1&¶llel.max<=4)))throw new ConfigError('config.parallel.max must be an integer from 1 to 4');
|
|
333
|
+
}
|
|
325
334
|
}
|
|
326
335
|
|
|
327
336
|
function validateEffective(config){
|
|
@@ -493,7 +502,8 @@ function loadConfigUsing(input,userDefaults){
|
|
|
493
502
|
if(SECRET_VALUE.test(text))throw new ConfigError('configuration contains a secret-like value');
|
|
494
503
|
try{
|
|
495
504
|
const raw=parseDocument(configPath,text);walkForSecrets(raw);validateRaw(raw);
|
|
496
|
-
const normalizedRaw={...raw,version:Number(raw.version)
|
|
505
|
+
const normalizedRaw={...raw,version:Number(raw.version),
|
|
506
|
+
...(raw.parallel&&Object.hasOwn(raw.parallel,'max')?{parallel:{...raw.parallel,max:Number(raw.parallel.max)}}:{})};
|
|
497
507
|
const projectDeclared=raw.runtimes?.available!==undefined;
|
|
498
508
|
const user=projectDeclared?null:userDefaults();
|
|
499
509
|
const defaults=user?deepMerge(DEFAULT_CONFIG,runtimePreset(user.preset)):DEFAULT_CONFIG;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Synthetic CLI protocol fixture. Exercises the real MCP server, never a model.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import {spawn} from 'node:child_process';
|
|
4
|
+
import {createInterface} from 'node:readline';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
const args=process.argv.slice(2),pick=key=>args[args.indexOf(key)+1];
|
|
7
|
+
assert(args.includes('--restricted'));assert(!args.includes('--safe-mode'));assert.equal(pick('--tools'),'');
|
|
8
|
+
const config=JSON.parse(pick('--mcp-config')).mcpServers.cm_review;
|
|
9
|
+
let prompt='';for await(const chunk of process.stdin)prompt+=chunk;
|
|
10
|
+
assert(!prompt.includes('Use no tools and do not execute code.'));
|
|
11
|
+
const probe=process.env.ANTHROPIC_API_KEY==='cm-synthetic-local-probe';
|
|
12
|
+
const data=probe?null:JSON.parse(prompt.split('<cm-review-data-json>\n')[1].split('\n')[0]);
|
|
13
|
+
const server=spawn(config.command,config.args,{stdio:['pipe','pipe','pipe']});server.stderr.resume();
|
|
14
|
+
const pending=new Map();let seq=0;
|
|
15
|
+
createInterface({input:server.stdout}).on('line',line=>{const value=JSON.parse(line);pending.get(value.id)?.(value.result);pending.delete(value.id);});
|
|
16
|
+
const rpc=(method,params={})=>new Promise(resolve=>{const id=++seq;pending.set(id,resolve);server.stdin.write(JSON.stringify({jsonrpc:'2.0',id,method,params})+'\n');});
|
|
17
|
+
const session_id='synthetic-isolated-review',emit=value=>process.stdout.write(JSON.stringify({...value,session_id})+'\n');
|
|
18
|
+
try{
|
|
19
|
+
await rpc('initialize',{protocolVersion:'2024-11-05',capabilities:{},clientInfo:{name:'fixture',version:'1'}});
|
|
20
|
+
const catalog=await rpc('tools/list');assert.deepEqual(catalog.tools.map(t=>t.name),['read_file','run_check','mutate_check']);
|
|
21
|
+
assert.deepEqual(catalog.tools[1].inputSchema.properties.id.enum,['unit']);
|
|
22
|
+
assert.deepEqual(catalog.tools[2].inputSchema.properties.checkId.enum,['unit']);
|
|
23
|
+
emit({type:'system',subtype:'init'});
|
|
24
|
+
if(probe){
|
|
25
|
+
const http=await import('node:http');
|
|
26
|
+
await new Promise((resolve,reject)=>{
|
|
27
|
+
const req=http.request(new URL('/v1/messages',process.env.ANTHROPIC_BASE_URL),{method:'POST',headers:{'x-api-key':'cm-synthetic-local-probe','content-type':'application/json'}},res=>{res.resume();res.on('end',resolve);});req.on('error',reject);
|
|
28
|
+
req.end(JSON.stringify({model:pick('--model'),messages:[{role:'user',content:'Synthetic local probe'}],tools:[{name:'StructuredOutput'},...catalog.tools.map(t=>({name:'mcp__cm_review__'+t.name}))]}));
|
|
29
|
+
});
|
|
30
|
+
}else{
|
|
31
|
+
|
|
32
|
+
const call=async(name,input)=>{
|
|
33
|
+
const id='tool-'+seq;emit({type:'assistant',parent_tool_use_id:null,message:{role:'assistant',content:[{type:'tool_use',id,name:'mcp__cm_review__'+name,input}]}});
|
|
34
|
+
const result=await rpc('tools/call',{name,arguments:input});
|
|
35
|
+
emit({type:'user',message:{role:'user',content:[{type:'tool_result',tool_use_id:id,is_error:result.isError===true,content:JSON.stringify(result.content)}]}});
|
|
36
|
+
assert(!result.isError,JSON.stringify(result));return JSON.parse(result.content[0].text);
|
|
37
|
+
};
|
|
38
|
+
const file=await call('read_file',{path:'value.mjs'});assert(file.content.includes('value=1'));
|
|
39
|
+
const mode=process.env.CM_VERIFICATION_FIXTURE_MODE??'valid';
|
|
40
|
+
assert.equal((await call('run_check',{id:'unit'})).exitCode,mode==='failed-check'?1:0);
|
|
41
|
+
if(mode==='valid')assert.equal((await call('mutate_check',{path:'value.mjs',find:'value=1',replace:'value=2',checkId:'unit'})).killed,true);
|
|
42
|
+
emit({type:'result',subtype:'success',is_error:false,num_turns:4,structured_output:{verdict:'approved',packageDigest:data.reviewPackage.packageDigest,examinedPaths:data.examinedPaths,findings:[],summary:'Synthetic CLI transport and actual isolated commands; not a model review.'}});
|
|
43
|
+
}
|
|
44
|
+
}finally{server.stdin.end();await new Promise(resolve=>server.once('close',resolve));}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// Synthetic fixture support. Every provider response and verification receipt
|
|
2
|
+
// below is test data, never a real review or product completion claim.
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import {createHash} from 'node:crypto';
|
|
8
|
+
import {spawnSync} from 'node:child_process';
|
|
9
|
+
import {buildManifest} from '../cm-spec-manifest.mjs';
|
|
10
|
+
import {openControlRun} from '../cm-ai-run.mjs';
|
|
11
|
+
import {createDeveloperRun} from '../../runtime/js/cm-ai/developer-adapter.mjs';
|
|
12
|
+
import {createHostCheck} from '../../runtime/js/cm-ai/host-check.mjs';
|
|
13
|
+
import {createHostHandoff} from '../../runtime/js/cm-ai/host-handoff.mjs';
|
|
14
|
+
import {createHostReviewAuthority} from '../../runtime/js/cm-ai/host-review-authority.mjs';
|
|
15
|
+
import {captureReviewBaseline,createReviewPackage} from '../../runtime/js/cm-ai/review-package.mjs';
|
|
16
|
+
import {reviewPaths} from '../../runtime/js/cm-ai/review-runner.mjs';
|
|
17
|
+
import {readExecutionSnapshot} from '../../runtime/js/cm-ai/execution-snapshot.mjs';
|
|
18
|
+
import {readRunnerHistory} from '../../runtime/js/cm-ai/durable-runner-state.mjs';
|
|
19
|
+
import {digest} from '../../runtime/js/cm-ai/effect-contract.mjs';
|
|
20
|
+
import {createFixFinalReview,fixFinalReviewConfiguration} from '../../runtime/js/cm-fix/final-review.mjs';
|
|
21
|
+
|
|
22
|
+
export const canonical=value=>JSON.stringify(value)+'\n';
|
|
23
|
+
export const sha=value=>createHash('sha256').update(value).digest('hex');
|
|
24
|
+
export const fileRecord=(name,bytes,mode=0o644)=>({path:name,type:'file',mode,size:Buffer.byteLength(bytes),sha256:sha(bytes)});
|
|
25
|
+
export const syntheticEvents=(onEvent,thread)=>{
|
|
26
|
+
for(const event of [{event:'thread.started',provider_thread:thread},{event:'turn.started',item_type:null},
|
|
27
|
+
{event:'item.completed',item_type:'agent_message'},{event:'turn.completed',item_type:null},
|
|
28
|
+
{event:'process_closed',exit_code:0,signal:null,timed_out:false}])onEvent(event);
|
|
29
|
+
};
|
|
30
|
+
const checks=[{id:'synthetic',command:['synthetic-check'],outcome:'passed',exitCode:0,evidence:'Synthetic fixture only'}];
|
|
31
|
+
|
|
32
|
+
function git(cwd,...args){
|
|
33
|
+
const run=spawnSync('/usr/bin/git',['-c','core.fsmonitor=false','-c','core.hooksPath=/dev/null','-c','commit.gpgsign=false',...args],
|
|
34
|
+
{cwd,encoding:'utf8',timeout:10000});
|
|
35
|
+
assert.equal(run.status,0,run.stderr);return run.stdout.trim();
|
|
36
|
+
}
|
|
37
|
+
function put(root,file,bytes){fs.mkdirSync(path.dirname(path.join(root,file)),{recursive:true});fs.writeFileSync(path.join(root,file),bytes);}
|
|
38
|
+
|
|
39
|
+
export async function syntheticIntegrationReview(root,plan,documentBytes,{includeVerification=true,threadId='synthetic-integration-review-thread',snapshotEvidence=null}={}){
|
|
40
|
+
const proofRoot=fs.mkdtempSync(path.join(root,'proof-'));
|
|
41
|
+
const planPath='integration/plan.json',probe='integration/probe.mjs';
|
|
42
|
+
put(proofRoot,planPath,canonical(plan));put(proofRoot,probe,'export const probe=0;\n');
|
|
43
|
+
const requirements=[planPath];
|
|
44
|
+
if(snapshotEvidence!==null){
|
|
45
|
+
const provenancePath='integration/snapshot-provenance.json';
|
|
46
|
+
put(proofRoot,provenancePath,snapshotEvidence.provenance);requirements.push(provenancePath);
|
|
47
|
+
for(const [hash,bytes] of Object.entries(snapshotEvidence.contents)){
|
|
48
|
+
assert.match(hash,/^[a-f0-9]{64}$/);assert.equal(sha(bytes),hash);
|
|
49
|
+
const name=`integration/snapshots/${hash}.txt`;put(proofRoot,name,bytes);requirements.push(name);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
for(const [file,bytes] of Object.entries(documentBytes))put(proofRoot,`integration/documents/${file}`,bytes.before);
|
|
53
|
+
const identity={repositoryId:plan.target.identity.repositoryId,runId:'synthetic-integration-review',taskId:'T-FIX-integration',attempt:1};
|
|
54
|
+
const baseline=captureReviewBaseline({root:proofRoot,identity,
|
|
55
|
+
scope:[probe,...Object.keys(documentBytes).map(file=>`integration/documents/${file}`)],requirements});
|
|
56
|
+
put(proofRoot,probe,'export const probe=1;\n');
|
|
57
|
+
for(const [file,bytes] of Object.entries(documentBytes))put(proofRoot,`integration/documents/${file}`,bytes.after);
|
|
58
|
+
const handoffPath=path.join(root,`synthetic-handoff-${path.basename(proofRoot)}.json`);
|
|
59
|
+
createHostHandoff({root:proofRoot,baseline,checks,handoffPath,
|
|
60
|
+
evidence:['learning: no_relevant_lesson','learning: retrospective no_new_lesson','Synthetic integration test only']});
|
|
61
|
+
const pkg=createReviewPackage({root:proofRoot,baseline,checks,handoffPath});
|
|
62
|
+
const materials=[...pkg.changes.filter(c=>c.after).map(c=>({...c.after,path:c.path})),
|
|
63
|
+
...(pkg.unchangedScope??[]),...pkg.requirements,...(pkg.instructions??[])];
|
|
64
|
+
const files=[...new Map(materials.map(file=>[file.path,{path:file.path,sha256:file.sha256,mode:file.mode}])).values()]
|
|
65
|
+
.sort((a,b)=>a.path.localeCompare(b.path));
|
|
66
|
+
const verification={files:files.map(file=>file.path),checks:[{id:'unit',command:[process.execPath,'--check',probe]}],
|
|
67
|
+
mutationPaths:[probe],timeoutMs:1000};
|
|
68
|
+
const causeReview={reviewerId:'synthetic-cause-reviewer',adapterId:'claude-cause-review-adapter',provider:'claude',
|
|
69
|
+
requestedModel:'synthetic',contextId:'synthetic-cause-review',excludedThreadIds:[]};
|
|
70
|
+
const configuration=fixFinalReviewConfiguration({hostContextId:plan.author.contextId,causeReview,
|
|
71
|
+
...(includeVerification?{reviewVerification:verification}:{})});
|
|
72
|
+
const authority=createHostReviewAuthority({hostContextId:configuration.hostContextId,
|
|
73
|
+
reviewerId:configuration.reviewer.reviewerId,adapterId:configuration.reviewer.adapterId,
|
|
74
|
+
decide:async()=>({status:'approved'})});
|
|
75
|
+
await authority.hostDecisionProvider.decide({identity,packageDigest:pkg.packageDigest},new AbortController().signal);
|
|
76
|
+
let registration,started;
|
|
77
|
+
const review=createFixFinalReview({reviewPackage:pkg,configuration,timeoutMs:1000},{authorize:authority.authorize,
|
|
78
|
+
async run(request,{onEvent,onVerification}){
|
|
79
|
+
syntheticEvents(onEvent,threadId);
|
|
80
|
+
if(includeVerification){
|
|
81
|
+
const before=files.find(file=>file.path===probe).sha256;
|
|
82
|
+
onVerification({version:1,requestDigest:request.requestDigest,packageDigest:pkg.packageDigest,
|
|
83
|
+
profileDigest:digest(verification),providerThreadId:threadId,files,snapshotDigest:digest(files),
|
|
84
|
+
checks:[{id:'unit',commandDigest:digest(verification.checks[0].command),exitCode:0,outputSha256:sha('synthetic check'),startedAt:1,endedAt:2}],
|
|
85
|
+
mutations:[{path:probe,beforeSha256:before,afterSha256:sha('synthetic mutation'),checkId:'unit',
|
|
86
|
+
baselineExitCode:0,mutatedExitCode:1,restoredExitCode:0,restoredSha256:before,startedAt:3,endedAt:4}]});
|
|
87
|
+
}
|
|
88
|
+
return {status:'succeeded',value:{verdict:'approved',packageDigest:pkg.packageDigest,
|
|
89
|
+
examinedPaths:reviewPaths(pkg),findings:[],summary:'Synthetic integration test observation, not independent review'}};
|
|
90
|
+
}});
|
|
91
|
+
const result=await review({signal:new AbortController().signal,register(value){registration=value;},onStarted(value){started=value;}});
|
|
92
|
+
assert.equal(result.inspection?.review?.verdict,'approved',JSON.stringify(result));
|
|
93
|
+
return {configuration,registration,started,result:result.value};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export async function createReviewedIntegrationFixture(t,{unrelated=false,premature=false,controlPolicy=null,sourceBeforeRename=false,providerDevelopment=false,developerProvider='claude'}={}){
|
|
97
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-reviewed-integration-')));
|
|
98
|
+
const env={CM_WORKFLOW_HOME:process.env.CM_WORKFLOW_HOME,CM_WORKFLOW_LOG_HOME:process.env.CM_WORKFLOW_LOG_HOME};
|
|
99
|
+
process.env.CM_WORKFLOW_HOME=path.join(root,'home');process.env.CM_WORKFLOW_LOG_HOME=path.join(root,'logs');
|
|
100
|
+
t.after(()=>{
|
|
101
|
+
for(const [key,value] of Object.entries(env)){if(value===undefined)delete process.env[key];else process.env[key]=value;}
|
|
102
|
+
fs.rmSync(root,{recursive:true,force:true});
|
|
103
|
+
});
|
|
104
|
+
const codeProject=path.join(root,'code'),sourceRoot=path.join(root,'source'),specsDir=path.join(root,'specs');
|
|
105
|
+
fs.mkdirSync(codeProject);
|
|
106
|
+
const originalFiles={'parent.mjs':'export const parent=0;\n','source.mjs':'export const source=0;\n',
|
|
107
|
+
'next.mjs':'export const next=0;\n','docs/guide.md':'# Guide\n','req.md':'Synthetic requirements\n',
|
|
108
|
+
'package.json':canonical({name:'oldrepo'}),'.cm-workflow.json':canonical({version:1,policies:{delivery:'diff'}})};
|
|
109
|
+
for(const [file,bytes] of Object.entries(originalFiles))put(codeProject,file,bytes);
|
|
110
|
+
git(codeProject,'init','--quiet');git(codeProject,'add','.');
|
|
111
|
+
git(codeProject,'-c','user.name=Synthetic Fixture','-c','user.email=fixture@example.invalid','commit','--quiet','-m','Synthetic baseline');
|
|
112
|
+
git(codeProject,'worktree','add','--quiet','--detach',sourceRoot);
|
|
113
|
+
const names=['parent','cross','rename','renamed',...(premature?['premature']:[]),...(unrelated?['unrelated']:[])];
|
|
114
|
+
const features=names.map((name,index)=>`${index+1}.${name}`);
|
|
115
|
+
for(const [index,name] of names.entries()){
|
|
116
|
+
const feature=features[index],taskId=`T-${String(index+1).padStart(3,'0')}`;
|
|
117
|
+
for(const file of ['requirements.md','design.md'])put(specsDir,`${feature}/${file}`,'# Synthetic fixture\n');
|
|
118
|
+
put(specsDir,`${feature}/tasks.md`,`- [ ] ${taskId}: implement ${name}\n`);
|
|
119
|
+
}
|
|
120
|
+
put(specsDir,'.cm-specs-status',canonical({status:'approved',features,specFiles:buildManifest(specsDir)}));
|
|
121
|
+
let unrelatedRoot=null;
|
|
122
|
+
if(unrelated){
|
|
123
|
+
unrelatedRoot=path.join(root,'unrelated');fs.mkdirSync(unrelatedRoot);
|
|
124
|
+
for(const [file,bytes] of Object.entries(originalFiles))put(unrelatedRoot,file,bytes);
|
|
125
|
+
git(unrelatedRoot,'init','--quiet');git(unrelatedRoot,'add','.');
|
|
126
|
+
git(unrelatedRoot,'-c','user.name=Synthetic Fixture','-c','user.email=fixture@example.invalid','commit','--quiet','-m','Separate synthetic baseline');
|
|
127
|
+
}
|
|
128
|
+
const calls={develop:0,review:0,check:0},definitions={},executions={},approvedBytes={};let sealed=false;
|
|
129
|
+
const changes={parent:{'parent.mjs':'export const parent=1;\n','docs/guide.md':'# Guide\nParent reviewed paragraph.\n'},
|
|
130
|
+
cross:{'source.mjs':'export const source=1;\n'},rename:{'package.json':canonical({name:'newrepo'})},
|
|
131
|
+
renamed:{'next.mjs':'export const next=1;\n'},premature:{'next.mjs':'export const next=1;\n'},unrelated:{'source.mjs':'export const source=1;\n'}};
|
|
132
|
+
const statePath=name=>path.join(specsDir,'.reviews','.execution',definitions[name].identity.runId,'state.json');
|
|
133
|
+
const snapshot=name=>readExecutionSnapshot({specsRoot:specsDir,identity:{repositoryId:definitions[name].identity.repositoryId,
|
|
134
|
+
runId:definitions[name].identity.runId}});
|
|
135
|
+
const history=name=>{const saved=snapshot(name);return {saved,...readRunnerHistory(saved.records,saved.records[0].payload.config,3)};};
|
|
136
|
+
const request=(name,operation,extra={})=>({version:1,requestId:`synthetic-${name}-${operation}`,operation,identity:definitions[name].identity,...extra});
|
|
137
|
+
for(const [index,name] of names.entries()){
|
|
138
|
+
const targetRoot=name==='cross'?sourceRoot:name==='unrelated'?unrelatedRoot:codeProject;
|
|
139
|
+
const identity={repositoryId:['renamed','premature'].includes(name)?'newrepo':'oldrepo',runId:`integration-${name}`,taskId:`T-${String(index+1).padStart(3,'0')}`,attempt:1};
|
|
140
|
+
definitions[name]={version:1,specsDir,codeProject:targetRoot,feature:features[index],identity,
|
|
141
|
+
featureSelection:{version:1,feature:features[index]},scope:Object.keys(changes[name]),requirements:['req.md']};
|
|
142
|
+
const check=createHostCheck({cwd:targetRoot,commands:[{id:'syntax',command:[process.execPath,'--check','parent.mjs']}]});
|
|
143
|
+
executions[name]={configuration:{kind:'synthetic-integration-fixture',...(controlPolicy?{controlPolicy}:{}),
|
|
144
|
+
...(providerDevelopment?{providerDevelopment:true}:{})},timeoutMs:3000,excludedContexts:['synthetic-host'],
|
|
145
|
+
developer:{provider:developerProvider,requestedModel:'synthetic',contextId:`${name}-author`,
|
|
146
|
+
run:createDeveloperRun({provider:developerProvider,requestedModel:'synthetic',worker:async()=>{
|
|
147
|
+
assert.equal(sealed,false,'adoption must not call a developer');calls.develop++;
|
|
148
|
+
for(const [file,bytes] of Object.entries(changes[name]))put(targetRoot,file,bytes);
|
|
149
|
+
return {status:'succeeded',value:{outcome:'implemented',application:{status:'no_relevant_lesson',note:null},
|
|
150
|
+
retrospective:{status:'no_new_lesson',candidates:[],reason:null}}};
|
|
151
|
+
}})},
|
|
152
|
+
reviewers:[{id:'reviewer',adapterId:'codex-review-adapter',provider:'codex',requestedModel:'synthetic',allowed:true,available:true,
|
|
153
|
+
contexts:[`${name}-review-1`,`${name}-review-2`],run:async(reviewRequest,{onEvent})=>{
|
|
154
|
+
assert.equal(sealed,false,'adoption must not call a reviewer');calls.review++;
|
|
155
|
+
syntheticEvents(onEvent,`synthetic-${name}-review-thread`);
|
|
156
|
+
return {status:'succeeded',value:{verdict:'approved',packageDigest:reviewRequest.payload.reviewPackage.packageDigest,
|
|
157
|
+
examinedPaths:reviewPaths(reviewRequest.payload.reviewPackage),findings:[],summary:'Synthetic fixture review'}};
|
|
158
|
+
}}],reviewInvocation:{developerThreadId:`${name}-author`,excludedThreadIds:['synthetic-host']},
|
|
159
|
+
check:async(...args)=>{assert.equal(sealed,false,'adoption must not execute checks');calls.check++;return check(...args);},applicableAgentFiles:[]};
|
|
160
|
+
}
|
|
161
|
+
// All operations use real durable V3 owners. No journal is fabricated to make
|
|
162
|
+
// a source eligible, and no product provider is invoked.
|
|
163
|
+
const runOrder=sourceBeforeRename?names.filter(name=>name!=='rename').concat('rename'):
|
|
164
|
+
premature?['parent','cross','premature',...names.filter(name=>!['parent','cross','premature'].includes(name))]:names;
|
|
165
|
+
for(const name of runOrder){
|
|
166
|
+
const run=await openControlRun(definitions[name],'create',executions[name]);
|
|
167
|
+
try{
|
|
168
|
+
assert.ok(run.host,JSON.stringify(run.blocked));
|
|
169
|
+
const start=await run.host.handle(request(name,'start'));assert.equal(start.state,'awaiting_review',JSON.stringify(start));
|
|
170
|
+
const decision=await run.host.handle(request(name,'decision',{packageDigest:start.packageDigest}));
|
|
171
|
+
assert.equal(decision.state,'approved',JSON.stringify(decision));approvedBytes[name]=fs.readFileSync(statePath(name));
|
|
172
|
+
const complete=await run.host.handle(request(name,'complete',{packageDigest:start.packageDigest}));
|
|
173
|
+
assert.equal(complete.state,'fixture_completed',JSON.stringify(complete));
|
|
174
|
+
}finally{run.close();}
|
|
175
|
+
// Fixture-only shelving retains a valid historical package with an earlier
|
|
176
|
+
// new-name review. The later legitimate source starts from the same bytes.
|
|
177
|
+
if(name==='premature')put(codeProject,'next.mjs',originalFiles['next.mjs']);
|
|
178
|
+
}
|
|
179
|
+
sealed=true;
|
|
180
|
+
const parent=history('parent'),before=changes.parent['docs/guide.md'],after=before+'Reviewed integration paragraph.\n';
|
|
181
|
+
const documents={'docs/guide.md':{before,after}};
|
|
182
|
+
const makePlan=(targetName='parent',sourceNames=['cross','renamed'],withDocument=true)=>{
|
|
183
|
+
const target=history(targetName);
|
|
184
|
+
return {version:1,kind:'cm-reviewed-integration-v1',author:{provider:'codex',contextId:'synthetic-integration-author'},target:{identity:target.state.reviewPackage.identity,
|
|
185
|
+
rootDigest:target.original.rootDigest,baselineDigest:target.original.baselineDigest,packageDigest:target.state.reviewPackage.packageDigest,
|
|
186
|
+
recordCount:target.saved.records.length,lastDigest:target.saved.records.at(-1).digest},
|
|
187
|
+
sources:sourceNames.map(name=>{const source=history(name);return {identity:source.state.reviewPackage.identity,
|
|
188
|
+
root:definitions[name].codeProject,revision:source.saved.revision,packageDigest:source.state.reviewPackage.packageDigest};}),
|
|
189
|
+
documents:withDocument?[{path:'docs/guide.md',before:fileRecord('docs/guide.md',before),after:fileRecord('docs/guide.md',after)}]:[]};
|
|
190
|
+
};
|
|
191
|
+
const plan=makePlan(),review=await syntheticIntegrationReview(root,plan,documents);
|
|
192
|
+
put(codeProject,'source.mjs',changes.cross['source.mjs']);put(codeProject,'docs/guide.md',after);
|
|
193
|
+
const evidenceFile=path.join(root,'integration-evidence.json');fs.writeFileSync(evidenceFile,canonical({plan,review}),{mode:0o600});
|
|
194
|
+
const input={root:codeProject,specsRoot:specsDir,baseline:parent.original,parentPackage:parent.state.reviewPackage,
|
|
195
|
+
records:parent.saved.records,plan,review};
|
|
196
|
+
const record={version:1,plan,reviewFile:{path:evidenceFile,sha256:sha(fs.readFileSync(evidenceFile))},
|
|
197
|
+
reason:'Explicit reviewed integration',planDigest:digest(plan)};
|
|
198
|
+
return {root,codeProject,sourceRoot,unrelatedRoot,specsDir,definitions,executions,calls,approvedBytes,
|
|
199
|
+
statePath,snapshot,history,request,makePlan,plan,review,documents,evidenceFile,record,input,
|
|
200
|
+
write:(file,bytes)=>put(codeProject,file,bytes),
|
|
201
|
+
openParent:(options={})=>openControlRun(definitions.parent,'resume',executions.parent,options)};
|
|
202
|
+
}
|
|
@@ -43,6 +43,7 @@ ALLOW_LOOPBACK_ENDPOINT_FILES = {
|
|
|
43
43
|
Path("scripts/cm-ai-multi-root.test.mjs"),
|
|
44
44
|
Path("scripts/cm-ai-nested-execution.test.mjs"),
|
|
45
45
|
Path("scripts/cm-claude-probe.test.mjs"),
|
|
46
|
+
Path("scripts/cm-fix-review-verification-command.test.mjs"),
|
|
46
47
|
Path("scripts/cm-fix-visual-bare.test.mjs"),
|
|
47
48
|
Path("scripts/cm-fix-walkthrough.test.mjs"),
|
|
48
49
|
Path("scripts/cm-notify-command.test.mjs"),
|