@aibyzero/cm-workflow 0.10.5
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 +30 -0
- package/AGENTS.md +74 -0
- package/CONTRIBUTING.md +62 -0
- package/LICENSE +21 -0
- package/README.md +263 -0
- package/SECURITY.md +49 -0
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/VERSION +1 -0
- package/agents/cm-backend-agent.md +34 -0
- package/agents/cm-contract-agent.md +34 -0
- package/agents/cm-database-agent.md +34 -0
- package/agents/cm-frontend-agent.md +33 -0
- package/agents/cm-miniprogram-agent.md +33 -0
- package/agents/cm-ui-agent.md +34 -0
- package/assets/docs/command-picker-mobile.svg +56 -0
- package/assets/docs/command-picker.svg +56 -0
- package/assets/docs/user-guide-hero-mobile.svg +35 -0
- package/assets/docs/user-guide-hero.svg +36 -0
- package/assets/readme/delivery-flow.svg +86 -0
- package/assets/readme/hero.svg +77 -0
- package/assets/readme/recovery-record.svg +73 -0
- package/assets/readme/test-evidence.svg +64 -0
- package/compat/claude-commands/cm-ai.md +3 -0
- package/compat/claude-commands/cm-check.md +3 -0
- package/compat/claude-commands/cm-fix.md +3 -0
- package/compat/claude-commands/cm-idea.md +3 -0
- package/compat/claude-commands/cm-init.md +3 -0
- package/compat/claude-commands/cm-prd.md +3 -0
- package/compat/claude-commands/cm-refactor.md +3 -0
- package/compat/claude-commands/cm-test.md +3 -0
- package/docs/architecture.md +155 -0
- package/docs/fixes/.reviews/fix-cancel-throw-T-FIX-cancel-throw-a1-handoff.json +57 -0
- package/docs/fixes/.reviews/fix-cancel-throw-T-FIX-cancel-throw-a2-handoff.json +58 -0
- package/docs/fixes/.reviews/fix-cancel-throw-T-FIX-cancel-throw-r1.md +121 -0
- package/docs/fixes/.reviews/fix-cancel-throw-v2-T-FIX-cancel-throw-v2-a1-handoff.json +56 -0
- package/docs/fixes/.reviews/fix-cancel-throw-v2-T-FIX-cancel-throw-v2-r1.md +100 -0
- package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-a1-handoff.json +61 -0
- package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-a2-handoff.json +63 -0
- package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-r1.md +58 -0
- package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-r2.md +55 -0
- package/docs/fixes/.reviews/fix-f01-dual-failure-terminal-T-FIX-f01-dual-failure-terminal-a1-handoff.json +65 -0
- package/docs/fixes/.reviews/fix-f01-dual-failure-terminal-T-FIX-f01-dual-failure-terminal-r1.md +88 -0
- package/docs/fixes/.reviews/fix-manifest-runtime-checkbox-drift-r1.md +33 -0
- package/docs/fixes/.reviews/fix-manifest-runtime-checkbox-drift-r2.md +31 -0
- package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-a1-handoff.json +56 -0
- package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-a2-handoff.json +85 -0
- package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-r1.md +53 -0
- package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-r2.md +80 -0
- package/docs/fixes/.reviews/fix-review-evidence-scope-honesty-T-FIX-review-evidence-scope-honesty-a1-handoff.json +35 -0
- package/docs/fixes/.reviews/fix-review-evidence-scope-honesty-T-FIX-review-evidence-scope-honesty-r1.md +33 -0
- package/docs/fixes/.reviews/fix-windows-cp1252-log-output-r1.md +30 -0
- package/docs/fixes/.reviews/fix-windows-cp1252-log-output-r2.md +16 -0
- package/docs/fixes/.reviews/openai-compatible-depth-fixture-T-FIX-openai-compatible-depth-fixture-a1-handoff.json +40 -0
- package/docs/fixes/.reviews/openai-compatible-depth-fixture-T-FIX-openai-compatible-depth-fixture-r1.md +30 -0
- package/docs/fixes/20260729-windows-cp1252-log-output.md +65 -0
- package/docs/fixes/20260804-manifest-runtime-checkbox-drift.md +67 -0
- package/docs/fixes/20260806-model-call-boundary-identity.md +80 -0
- package/docs/fixes/20260807-prelanding-integrity.md +58 -0
- package/docs/fixes/20260826-openai-compatible-depth-fixture.md +39 -0
- package/docs/fixes/20260903-cm-js-n1n2-admission-r1.md +64 -0
- package/docs/fixes/20260903-cm-js-n1n2-admission-successor.md +83 -0
- package/docs/fixes/20260903-s4c1b-v3-cancel-throw.md +89 -0
- package/docs/fixes/20260904-f01-codex-dual-failure-terminal.md +89 -0
- package/docs/fixes/20260907-wip-triage-log.md +44 -0
- package/docs/installation.md +202 -0
- package/docs/js-workflow-control.md +1010 -0
- package/docs/sample-prd/prd-funding-rate-alert.md +42 -0
- package/docs/sample-specs/docs//351/234/200/346/261/202/347/244/272/344/276/213.md +24 -0
- package/docs/user-guide.md +526 -0
- package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/README.md +19 -0
- package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.excalidraw +3650 -0
- package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.mp4 +0 -0
- package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.png +0 -0
- package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.spec.json +223 -0
- package/install-codex.sh +184 -0
- package/install.ps1 +206 -0
- package/install.sh +244 -0
- package/package.json +58 -0
- package/runtime/external-expert.md +302 -0
- package/runtime/js/cm-ai/accepted-fix.mjs +28 -0
- package/runtime/js/cm-ai/claude-developer-adapter.mjs +6 -0
- package/runtime/js/cm-ai/claude-review-adapter.mjs +16 -0
- package/runtime/js/cm-ai/claude-review-stream.mjs +53 -0
- package/runtime/js/cm-ai/claude-tool-preview.mjs +107 -0
- package/runtime/js/cm-ai/cm-ai-admission.mjs +353 -0
- package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +217 -0
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +538 -0
- package/runtime/js/cm-ai/cm-ai-learning-handoff-writer.mjs +119 -0
- package/runtime/js/cm-ai/cm-ai-learning-writer.mjs +172 -0
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +320 -0
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +107 -0
- package/runtime/js/cm-ai/code-projects.mjs +85 -0
- package/runtime/js/cm-ai/codex-config.mjs +48 -0
- package/runtime/js/cm-ai/codex-developer-adapter.mjs +5 -0
- package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +6 -0
- package/runtime/js/cm-ai/codex-developer-output.schema.json +37 -0
- package/runtime/js/cm-ai/codex-review-adapter.mjs +73 -0
- package/runtime/js/cm-ai/contracts.mjs +156 -0
- package/runtime/js/cm-ai/developer-adapter.mjs +93 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +504 -0
- package/runtime/js/cm-ai/effect-contract.mjs +102 -0
- package/runtime/js/cm-ai/execution-platform.mjs +7 -0
- package/runtime/js/cm-ai/execution-store.mjs +211 -0
- package/runtime/js/cm-ai/fix-code-association.mjs +40 -0
- package/runtime/js/cm-ai/gate-bridge.mjs +25 -0
- package/runtime/js/cm-ai/host-bootstrap.mjs +170 -0
- package/runtime/js/cm-ai/host-check.mjs +89 -0
- package/runtime/js/cm-ai/host-conversation-execution.mjs +125 -0
- package/runtime/js/cm-ai/host-documentation.mjs +40 -0
- package/runtime/js/cm-ai/host-handoff.mjs +71 -0
- package/runtime/js/cm-ai/host-project-execution.mjs +58 -0
- package/runtime/js/cm-ai/host-qa-executor.mjs +238 -0
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +131 -0
- package/runtime/js/cm-ai/host-qa-fix.mjs +30 -0
- package/runtime/js/cm-ai/host-qa-policy.mjs +70 -0
- package/runtime/js/cm-ai/host-review-authority.mjs +36 -0
- package/runtime/js/cm-ai/host-review-file.mjs +56 -0
- package/runtime/js/cm-ai/host-role-routing.mjs +41 -0
- package/runtime/js/cm-ai/host-session.mjs +96 -0
- package/runtime/js/cm-ai/host-tool-bridge.mjs +53 -0
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +45 -0
- package/runtime/js/cm-ai/host.mjs +20 -0
- package/runtime/js/cm-ai/index.mjs +7 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +86 -0
- package/runtime/js/cm-ai/qa-fix-definition.mjs +21 -0
- package/runtime/js/cm-ai/review-evidence-file.mjs +38 -0
- package/runtime/js/cm-ai/review-package.mjs +426 -0
- package/runtime/js/cm-ai/review-result.schema.json +40 -0
- package/runtime/js/cm-ai/review-runner.mjs +35 -0
- package/runtime/js/cm-ai/task-commit-codec.mjs +54 -0
- package/runtime/js/cm-ai/task-commit.mjs +201 -0
- package/runtime/js/cm-ai/task-owner.mjs +97 -0
- package/runtime/js/cm-ai/task-runner.mjs +766 -0
- package/runtime/js/cm-ai/tool-preview.mjs +205 -0
- package/runtime/js/cm-ai/worker-claude.mjs +104 -0
- package/runtime/js/cm-ai/worker-codex-developer.mjs +124 -0
- package/runtime/js/cm-ai/worker-codex.mjs +143 -0
- package/runtime/js/cm-check/host.mjs +101 -0
- package/runtime/js/cm-fix/baseline.mjs +70 -0
- package/runtime/js/cm-fix/cause-evidence.mjs +24 -0
- package/runtime/js/cm-fix/cause-invocation.mjs +40 -0
- package/runtime/js/cm-fix/cause-package.mjs +68 -0
- package/runtime/js/cm-fix/dossier.mjs +140 -0
- package/runtime/js/cm-fix/execution.mjs +1549 -0
- package/runtime/js/cm-fix/final-review-evidence.mjs +20 -0
- package/runtime/js/cm-fix/final-review.mjs +156 -0
- package/runtime/js/cm-fix/finish.mjs +124 -0
- package/runtime/js/cm-fix/handoff.mjs +64 -0
- package/runtime/js/cm-fix/host-review.mjs +38 -0
- package/runtime/js/cm-fix/host.mjs +96 -0
- package/runtime/js/cm-fix/investigation.mjs +25 -0
- package/runtime/js/cm-fix/layout.mjs +17 -0
- package/runtime/js/cm-fix/learning-writeback.mjs +86 -0
- package/runtime/js/cm-fix/learning.mjs +31 -0
- package/runtime/js/cm-fix/metrics.mjs +75 -0
- package/runtime/js/cm-fix/progress.mjs +64 -0
- package/runtime/js/cm-fix/protected-edits.mjs +95 -0
- package/runtime/js/cm-fix/qa-source.mjs +58 -0
- package/runtime/js/cm-fix/red-test.mjs +92 -0
- package/runtime/js/cm-fix/regression-evidence.mjs +64 -0
- package/runtime/js/cm-fix/regression.mjs +41 -0
- package/runtime/js/cm-fix/repair.mjs +95 -0
- package/runtime/js/cm-fix/reproduce.mjs +54 -0
- package/runtime/js/cm-fix/retrospective.mjs +41 -0
- package/runtime/js/cm-fix/review-baseline.mjs +47 -0
- package/runtime/js/cm-fix/start.mjs +49 -0
- package/runtime/js/cm-fix/test-author.mjs +63 -0
- package/runtime/js/cm-fix/visual.mjs +72 -0
- package/runtime/js/cm-fix/walkthrough.mjs +126 -0
- package/runtime/js/cm-idea/session.mjs +79 -0
- package/runtime/js/cm-init/draft-generation.mjs +66 -0
- package/runtime/js/cm-init/draft-inspection.mjs +70 -0
- package/runtime/js/cm-init/project-analysis.mjs +60 -0
- package/runtime/js/cm-init/project-scan.mjs +55 -0
- package/runtime/js/cm-init/review-evidence.mjs +80 -0
- package/runtime/js/cm-prd/accepted-design.mjs +46 -0
- package/runtime/js/cm-prd/analysis.mjs +260 -0
- package/runtime/js/cm-prd/change.mjs +268 -0
- package/runtime/js/cm-prd/correction-check.mjs +49 -0
- package/runtime/js/cm-prd/design-risk.mjs +30 -0
- package/runtime/js/cm-prd/disposition-plan.mjs +33 -0
- package/runtime/js/cm-prd/draft-save.mjs +122 -0
- package/runtime/js/cm-prd/draft.mjs +70 -0
- package/runtime/js/cm-prd/materials.mjs +48 -0
- package/runtime/js/cm-prd/review-correction.mjs +158 -0
- package/runtime/js/cm-prd/review-disposition.mjs +96 -0
- package/runtime/js/cm-prd/review-findings.mjs +36 -0
- package/runtime/js/cm-prd/review-host.mjs +48 -0
- package/runtime/js/cm-prd/review-preparation.mjs +49 -0
- package/runtime/js/cm-prd/review-publication.mjs +56 -0
- package/runtime/js/cm-prd/self-check.mjs +75 -0
- package/runtime/js/cm-prd/session.mjs +74 -0
- package/runtime/js/cm-prd/summary.mjs +133 -0
- package/runtime/js/cm-refactor/host.mjs +2 -0
- package/runtime/js/cm-refactor/records.mjs +86 -0
- package/runtime/js/cm-refactor/workflow.mjs +478 -0
- package/runtime/js/cm-test/declared-command.mjs +32 -0
- package/runtime/js/cm-test/host.mjs +319 -0
- package/runtime/js/cm-test/logic-results.mjs +39 -0
- package/runtime/js/cm-test/recovery.mjs +58 -0
- package/runtime/js/cm-test/session.mjs +56 -0
- package/runtime/js/cm-test/source-snapshot.mjs +136 -0
- package/runtime/logging.md +207 -0
- package/runtime/model-efficiency.md +201 -0
- package/runtime/orchestration.md +113 -0
- package/runtime/project-context.md +43 -0
- package/runtime/project-learning.md +49 -0
- package/runtime/review.md +140 -0
- package/runtime/steelman-review.md +111 -0
- package/runtime/task-gates.md +283 -0
- package/runtime/task-handoff.schema.json +103 -0
- package/runtime/test-contract.md +212 -0
- package/runtime/workflow-config.md +118 -0
- package/runtime/workflow-routing.md +82 -0
- package/scripts/cm-ai-admission.mjs +50 -0
- package/scripts/cm-ai-admission.test.mjs +38 -0
- package/scripts/cm-ai-batch-host.mjs +77 -0
- package/scripts/cm-ai-batch-host.test.mjs +155 -0
- package/scripts/cm-ai-batch-run.mjs +136 -0
- package/scripts/cm-ai-batch-run.test.mjs +128 -0
- package/scripts/cm-ai-bootstrap.test.mjs +228 -0
- package/scripts/cm-ai-fix-integration.test.mjs +233 -0
- package/scripts/cm-ai-host.mjs +175 -0
- package/scripts/cm-ai-host.test.mjs +368 -0
- package/scripts/cm-ai-multi-root.test.mjs +289 -0
- package/scripts/cm-ai-nested-execution.test.mjs +313 -0
- package/scripts/cm-ai-run.mjs +293 -0
- package/scripts/cm-ai-run.test.mjs +336 -0
- package/scripts/cm-check-entry.mjs +120 -0
- package/scripts/cm-check-host.mjs +29 -0
- package/scripts/cm-check-host.test.mjs +71 -0
- package/scripts/cm-check-runtime.ps1 +69 -0
- package/scripts/cm-check-runtime.sh +910 -0
- package/scripts/cm-claude-probe.test.mjs +54 -0
- package/scripts/cm-claude-review-stream.test.mjs +45 -0
- package/scripts/cm-claude-worker.test.mjs +92 -0
- package/scripts/cm-codex-developer-adapter.test.mjs +85 -0
- package/scripts/cm-codex-developer-worker.test.mjs +128 -0
- package/scripts/cm-codex-review-progress.test.mjs +96 -0
- package/scripts/cm-execution-platform.test.mjs +47 -0
- package/scripts/cm-fix-cause-invocation.test.mjs +72 -0
- package/scripts/cm-fix-cause-package.test.mjs +68 -0
- package/scripts/cm-fix-code-association.test.mjs +55 -0
- package/scripts/cm-fix-entry.mjs +132 -0
- package/scripts/cm-fix-execution.test.mjs +63 -0
- package/scripts/cm-fix-final-review.test.mjs +124 -0
- package/scripts/cm-fix-host-review-assembly.test.mjs +34 -0
- package/scripts/cm-fix-host-review.test.mjs +261 -0
- package/scripts/cm-fix-host-sequence.test.mjs +26 -0
- package/scripts/cm-fix-host.mjs +89 -0
- package/scripts/cm-fix-host.test.mjs +105 -0
- package/scripts/cm-fix-learning-writeback.test.mjs +73 -0
- package/scripts/cm-fix-learning.test.mjs +66 -0
- package/scripts/cm-fix-metrics.test.mjs +58 -0
- package/scripts/cm-fix-no-existing-tests.test.mjs +92 -0
- package/scripts/cm-fix-observation-dossier.test.mjs +452 -0
- package/scripts/cm-fix-progress.test.mjs +45 -0
- package/scripts/cm-fix-protected-edits.test.mjs +54 -0
- package/scripts/cm-fix-qa-source.test.mjs +206 -0
- package/scripts/cm-fix-red-owner.test.mjs +143 -0
- package/scripts/cm-fix-red-test.test.mjs +38 -0
- package/scripts/cm-fix-regression.test.mjs +57 -0
- package/scripts/cm-fix-repair-owner.test.mjs +370 -0
- package/scripts/cm-fix-repair.test.mjs +68 -0
- package/scripts/cm-fix-reproduce.test.mjs +31 -0
- package/scripts/cm-fix-retrospective.test.mjs +46 -0
- package/scripts/cm-fix-review-baseline.test.mjs +54 -0
- package/scripts/cm-fix-review-recovery.test.mjs +197 -0
- package/scripts/cm-fix-test-author.test.mjs +105 -0
- package/scripts/cm-fix-visual-bare.test.mjs +171 -0
- package/scripts/cm-fix-walkthrough.test.mjs +45 -0
- package/scripts/cm-host-check.test.mjs +113 -0
- package/scripts/cm-host-documentation.test.mjs +45 -0
- package/scripts/cm-host-handoff.test.mjs +58 -0
- package/scripts/cm-host-qa-executor.test.mjs +156 -0
- package/scripts/cm-host-qa-policy.test.mjs +59 -0
- package/scripts/cm-host-review-authority.test.mjs +60 -0
- package/scripts/cm-host-role-routing.test.mjs +33 -0
- package/scripts/cm-idea-entry.mjs +104 -0
- package/scripts/cm-idea-host.mjs +144 -0
- package/scripts/cm-idea-host.test.mjs +75 -0
- package/scripts/cm-idea-recovery.test.mjs +90 -0
- package/scripts/cm-init-analysis-host.test.mjs +50 -0
- package/scripts/cm-init-draft-generation.test.mjs +52 -0
- package/scripts/cm-init-draft-inspection.test.mjs +41 -0
- package/scripts/cm-init-entry.mjs +170 -0
- package/scripts/cm-init-host.mjs +284 -0
- package/scripts/cm-init-host.test.mjs +231 -0
- package/scripts/cm-init-project-analysis.test.mjs +47 -0
- package/scripts/cm-init-project-scan.test.mjs +41 -0
- package/scripts/cm-init-revision-host.test.mjs +61 -0
- package/scripts/cm-init-session.test.mjs +122 -0
- package/scripts/cm-log-event.mjs +538 -0
- package/scripts/cm-log-event.py +133 -0
- package/scripts/cm-log-event.test.mjs +70 -0
- package/scripts/cm-openai-compatible-call.py +661 -0
- package/scripts/cm-prd-analysis.test.mjs +67 -0
- package/scripts/cm-prd-completion.test.mjs +190 -0
- package/scripts/cm-prd-design-phase.test.mjs +296 -0
- package/scripts/cm-prd-draft-save.test.mjs +63 -0
- package/scripts/cm-prd-draft.test.mjs +39 -0
- package/scripts/cm-prd-entry.mjs +245 -0
- package/scripts/cm-prd-host.mjs +273 -0
- package/scripts/cm-prd-host.test.mjs +169 -0
- package/scripts/cm-prd-materials.test.mjs +41 -0
- package/scripts/cm-prd-review-claim.test.mjs +42 -0
- package/scripts/cm-prd-review-disposition.test.mjs +196 -0
- package/scripts/cm-prd-review-gate.mjs +194 -0
- package/scripts/cm-prd-review-gate.py +26 -0
- package/scripts/cm-prd-review-host.test.mjs +30 -0
- package/scripts/cm-prd-review-preparation.test.mjs +69 -0
- package/scripts/cm-prd-review-publication.test.mjs +95 -0
- package/scripts/cm-prd-revision.test.mjs +32 -0
- package/scripts/cm-prd-self-check.test.mjs +23 -0
- package/scripts/cm-prd-sources.test.mjs +76 -0
- package/scripts/cm-prd-timing.py +272 -0
- package/scripts/cm-refactor-entry.mjs +145 -0
- package/scripts/cm-refactor-host.mjs +26 -0
- package/scripts/cm-refactor-host.test.mjs +201 -0
- package/scripts/cm-review-dependency-snapshot.test.mjs +67 -0
- package/scripts/cm-review-inventory.test.mjs +109 -0
- package/scripts/cm-spec-manifest.mjs +104 -0
- package/scripts/cm-spec-manifest.py +26 -0
- package/scripts/cm-task-gate.mjs +879 -0
- package/scripts/cm-task-gate.py +312 -0
- package/scripts/cm-task-gate.test.mjs +202 -0
- package/scripts/cm-test-declared-command.test.mjs +18 -0
- package/scripts/cm-test-entry.mjs +231 -0
- package/scripts/cm-test-host.mjs +40 -0
- package/scripts/cm-test-host.test.mjs +169 -0
- package/scripts/cm-test-logic-results.test.mjs +26 -0
- package/scripts/cm-test-session.test.mjs +138 -0
- package/scripts/cm-usage-report.py +516 -0
- package/scripts/cm-workflow-config.mjs +463 -0
- package/scripts/cm-workflow-config.test.mjs +181 -0
- package/scripts/cm-workflow.mjs +36 -0
- package/scripts/cm-workflow.test.mjs +51 -0
- package/scripts/cm_workflow_config.py +52 -0
- package/scripts/fixtures/claude-review-process.mjs +35 -0
- package/scripts/fixtures/codex-review-process.mjs +22 -0
- package/scripts/fixtures/prd-review-gate-python-oracle.py +320 -0
- package/scripts/fixtures/spec-manifest-python-oracle.py +172 -0
- package/scripts/scan-public-safety.py +117 -0
- package/scripts/test-cm-log-event.py +1213 -0
- package/scripts/test-cm-openai-compatible-call.py +1185 -0
- package/scripts/test-cm-prd-review-gate.py +272 -0
- package/scripts/test-cm-prd-timing.py +168 -0
- package/scripts/test-cm-usage-report.py +584 -0
- package/scripts/test-npm-install.py +171 -0
- package/scripts/test-scan-public-safety.py +76 -0
- package/scripts/test-shell-compat.sh +365 -0
- package/scripts/test-spec-manifest.py +263 -0
- package/scripts/test-task-gate.py +46 -0
- package/scripts/test-workflow-config.py +30 -0
- package/scripts/validate-public-repo.py +245 -0
- package/scripts/validate-test-cases.mjs +71 -0
- package/scripts/validate-test-cases.py +27 -0
- package/scripts/validate-test-cases.test.mjs +36 -0
- package/skills/cm-ai/SKILL.md +137 -0
- package/skills/cm-ai/references/N1-init.md +108 -0
- package/skills/cm-ai/references/N2-enter-feature.md +38 -0
- package/skills/cm-ai/references/N3-execute-task.md +123 -0
- package/skills/cm-ai/references/N4-review.md +103 -0
- package/skills/cm-ai/references/N5-mark-done.md +117 -0
- package/skills/cm-ai/references/N6-qa-eval.md +102 -0
- package/skills/cm-ai/references/N7-context.md +23 -0
- package/skills/cm-ai/references/N8-finish.md +103 -0
- package/skills/cm-ai/references/js-host.md +126 -0
- package/skills/cm-backend-engineer/SKILL.md +100 -0
- package/skills/cm-check/SKILL.md +52 -0
- package/skills/cm-check/references/js-host.md +44 -0
- package/skills/cm-contract-engineer/SKILL.md +136 -0
- package/skills/cm-database-engineer/SKILL.md +89 -0
- package/skills/cm-devops-engineer/SKILL.md +137 -0
- package/skills/cm-doc-syncer/SKILL.md +150 -0
- package/skills/cm-finance-expert/SKILL.md +85 -0
- package/skills/cm-fix/SKILL.md +199 -0
- package/skills/cm-fix/references/cross-boundary-debugging.md +44 -0
- package/skills/cm-fix/references/js-host.md +135 -0
- package/skills/cm-frontend-engineer/SKILL.md +127 -0
- package/skills/cm-idea/SKILL.md +55 -0
- package/skills/cm-idea/references/domains/trading.md +97 -0
- package/skills/cm-idea/references/example-prd.md +92 -0
- package/skills/cm-idea/references/idea-to-prd.md +282 -0
- package/skills/cm-idea/references/js-host.md +63 -0
- package/skills/cm-init/SKILL.md +191 -0
- package/skills/cm-init/references/js-host.md +123 -0
- package/skills/cm-miniprogram-engineer/SKILL.md +141 -0
- package/skills/cm-miniprogram-engineer/references/platform-readiness.md +58 -0
- package/skills/cm-miniprogram-engineer/references/release-checklist.md +59 -0
- package/skills/cm-prd/SKILL.md +548 -0
- package/skills/cm-prd/references/brownfield.md +13 -0
- package/skills/cm-prd/references/change-mode.md +145 -0
- package/skills/cm-prd/references/context-scope.md +62 -0
- package/skills/cm-prd/references/greenfield.md +80 -0
- package/skills/cm-prd/references/js-change-recovery.md +57 -0
- package/skills/cm-prd/references/js-host.md +98 -0
- package/skills/cm-prd/references/phase-timing.md +68 -0
- package/skills/cm-prd/references/spec-self-check.md +22 -0
- package/skills/cm-product-manager/SKILL.md +83 -0
- package/skills/cm-qa-engineer/SKILL.md +142 -0
- package/skills/cm-refactor/SKILL.md +236 -0
- package/skills/cm-refactor/references/js-batch.md +75 -0
- package/skills/cm-refactor/references/js-host.md +78 -0
- package/skills/cm-test/SKILL.md +288 -0
- package/skills/cm-test/references/js-host.md +118 -0
- package/skills/cm-ui-engineer/SKILL.md +105 -0
- package/skills/codebase-context/SKILL.md +489 -0
- package/skills/darwin-skill/NOTICE.md +26 -0
- package/skills/darwin-skill/README.md +272 -0
- package/skills/darwin-skill/SKILL.md +492 -0
- package/skills/darwin-skill/references/runtime-neutrality.md +68 -0
- package/skills/darwin-skill/references/skilllens-evidence.md +142 -0
- package/skills/darwin-skill/scripts/screenshot.mjs +71 -0
- package/skills/darwin-skill/templates/result-card-dark.html +698 -0
- package/skills/darwin-skill/templates/result-card-white.html +444 -0
- package/skills/darwin-skill/templates/result-card.html +616 -0
- package/skills/external-expert/SKILL.md +250 -0
- package/templates/arch-reference.md +68 -0
- package/templates/auto-update/cm-announce.sh +19 -0
- package/templates/auto-update/cm-update.sh +274 -0
- package/templates/cm-workflow.yml +52 -0
- package/templates/dashboard/dashboard.html +153 -0
- package/templates/dashboard/serve.sh +10 -0
- package/templates/hooks/pre-commit-cm-task-check +67 -0
- package/templates/pixel/cm-pixel.html +388 -0
- package/templates/pixel/cm-pixel.sh +212 -0
- package/templates/pixel/dev/README.md +20 -0
- package/templates/pixel/dev/atlas-preview.png +0 -0
- package/templates/pixel/dev/build.py +55 -0
- package/templates/pixel/dev/sheets/roguelikeChar_transparent.png +0 -0
- package/templates/pixel/dev/sheets/roguelikeCity_tilemap.png +0 -0
- package/templates/pixel/dev/sheets/roguelikeIndoor_transparent.png +0 -0
- package/templates/pixel/dev/template.html +388 -0
- package/templates/pixel/serve.sh +12 -0
- package/templates/refactor/cm-refactor-denies.json +14 -0
- package/templates/rules/backend-api.md +36 -0
- package/templates/rules/coding-style.md +44 -0
- package/templates/rules/database.md +27 -0
- package/templates/rules/finance.md +32 -0
- package/templates/rules/frontend.md +32 -0
- package/templates/rules/git-workflow.md +25 -0
- package/templates/rules/miniprogram.md +31 -0
- package/templates/rules/security.md +31 -0
- package/templates/rules/smart-contract.md +28 -0
- package/templates/rules/testing.md +36 -0
- package/templates/statusline/cm-statusline.sh +73 -0
- package/templates/ui-lens/cm-ui-lens-extract.mjs +55 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {PassThrough,Writable} from 'node:stream';
|
|
7
|
+
import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
|
|
8
|
+
import {createFixHost} from '../runtime/js/cm-fix/host.mjs';
|
|
9
|
+
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
10
|
+
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
11
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
12
|
+
import {main} from './cm-fix-host.mjs';
|
|
13
|
+
|
|
14
|
+
// Real temporary files/commands/owner/CLI; model responses and diagnostics are
|
|
15
|
+
// synthetic. No live provider, XBrief writes, installation or Git operations.
|
|
16
|
+
async function fixture(t,mode){
|
|
17
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-fix-review-recovery-')));
|
|
18
|
+
const cwd=path.join(root,'code');fs.mkdirSync(cwd);
|
|
19
|
+
const logHome=process.env.CM_WORKFLOW_LOG_HOME;process.env.CM_WORKFLOW_LOG_HOME=path.join(root,'mirror');
|
|
20
|
+
t.after(()=>{if(logHome===undefined)delete process.env.CM_WORKFLOW_LOG_HOME;else process.env.CM_WORKFLOW_LOG_HOME=logHome;fs.rmSync(root,{recursive:true,force:true});});
|
|
21
|
+
fs.writeFileSync(path.join(cwd,'value.mjs'),'export const value=1;');
|
|
22
|
+
fs.writeFileSync(path.join(cwd,'red.mjs'),"import {value} from './value.mjs';if(value!==2){console.error('BUG');process.exit(1)}");
|
|
23
|
+
fs.writeFileSync(path.join(cwd,'existing.mjs'),"import {value} from './value.mjs';if(typeof value!=='number')process.exit(1)");
|
|
24
|
+
fs.writeFileSync(path.join(cwd,'.cm-workflow.json'),JSON.stringify({version:1,policies:{delivery:'diff'}}));
|
|
25
|
+
const config={identity:{repositoryId:'fixture',runId:'recovery',taskId:'T-FIX-one',attempt:1},defect:'Wrong value',
|
|
26
|
+
reproduction:{cwd,command:[process.execPath,'red.mjs'],expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000},
|
|
27
|
+
redTest:{cwd,testFiles:['red.mjs'],command:[process.execPath,'red.mjs'],expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000},
|
|
28
|
+
baseline:{cwd,testFiles:['existing.mjs'],commands:[{id:'existing',command:[process.execPath,'existing.mjs']}],timeoutMs:2000},
|
|
29
|
+
repair:{scope:['value.mjs'],requirements:['value.mjs']},
|
|
30
|
+
walkthrough:{timeoutMs:2000,flows:[{id:'value',modules:['value'],steps:['Read value'],expected:['value is 2'],kind:'commands',command:[process.execPath,'red.mjs']}]}};
|
|
31
|
+
const permissions=['--allow-reproduction','--allow-red-test','--allow-baseline','--allow-repair','--allow-regression','--allow-final-review','--allow-walkthrough','--allow-finish'];
|
|
32
|
+
const model='synthetic',review={model,disabledSkills:[],preflight:{passed:true,cli_model:model,prompt_transport:'stdin',config_fingerprint:configFingerprint({cwd,model,disabledSkills:[]})}};
|
|
33
|
+
let calls=0,repairs=0;
|
|
34
|
+
const workerFactory=()=>async({prompt},{onEvent})=>{
|
|
35
|
+
calls++;const data=JSON.parse(prompt.split('<cm-review-data-json>\n')[1]);
|
|
36
|
+
const thread=calls===1||mode==='reuse-thread'||['reuse-first-thread','revision-reuses-lost-thread'].includes(mode)&&calls===3?'old-thread':`new-thread-${calls}`;
|
|
37
|
+
onEvent({event:'thread.started',provider_thread:thread});
|
|
38
|
+
if(calls===1&&!['approved','changes_requested'].includes(mode)||mode==='loss-again'
|
|
39
|
+
||['twice-then-success','reuse-first-thread'].includes(mode)&&calls<=2)throw Error('Synthetic lost result');
|
|
40
|
+
const verdict=mode==='changes_requested'||mode==='revision-reuses-lost-thread'&&calls===2?'changes_requested':'approved';
|
|
41
|
+
for(const event of [{event:'turn.started',item_type:null},{event:'item.completed',item_type:'agent_message'},
|
|
42
|
+
{event:'turn.completed',item_type:null},{event:'process_closed',exit_code:0,signal:null,timed_out:false}])onEvent(event);
|
|
43
|
+
return {status:'succeeded',value:{verdict,packageDigest:data.reviewPackage.packageDigest,examinedPaths:data.examinedPaths,
|
|
44
|
+
findings:verdict==='changes_requested'?[{id:'F1',severity:'P2',path:'value.mjs',message:'Synthetic issue',evidence:'Fixture'}]:[],summary:'Synthetic'}};
|
|
45
|
+
};
|
|
46
|
+
const reviewHost=createFixReviewHost({codeProject:cwd,hostContextId:'fixture-host',review,permissions,workerFactory});
|
|
47
|
+
const configuration={hostContextId:'fixture-host',...config,causeReview:reviewHost.reviewer};delete configuration.identity;
|
|
48
|
+
const learning={contextDigest:digest([]),files:[],application:{contextDigest:digest([]),status:'no_relevant_lesson',summary:'No fixture instructions'}};
|
|
49
|
+
const bridge={async call(kind){
|
|
50
|
+
if(kind==='fix_diagnose')return {status:'diagnosed',rootCause:'Wrong value',plan:'Correct value',affectedPaths:['value.mjs'],affectedModules:['value'],crossLayer:false,investigation:{discardedAlternatives:[],boundaryAnalysis:null}};
|
|
51
|
+
if(kind==='fix_repair'){repairs++;fs.writeFileSync(path.join(cwd,'value.mjs'),'export const value=2;'+(repairs>1?' // revised':''));return {outcome:'repaired'};}
|
|
52
|
+
if(kind==='fix_retrospective')return {status:'no_new_lesson',candidates:[],reason:null};
|
|
53
|
+
throw Error(kind);
|
|
54
|
+
}};
|
|
55
|
+
const options={identity:config.identity,configuration,create:true};
|
|
56
|
+
let owner=openFixExecution(options,{...reviewHost.execution,bridge,prepare:async()=>learning});
|
|
57
|
+
t.after(()=>owner.close());
|
|
58
|
+
const host=createFixHost({owner,config,permissions,authority:reviewHost.authority,finalAuthority:reviewHost.finalAuthority});
|
|
59
|
+
for(const operation of ['advance','red_test','baseline','repair','regression','retrospective','handoff','final_review'])
|
|
60
|
+
await host.handle({requestId:operation,operation});
|
|
61
|
+
const specsRoot=path.join(cwd,'docs/fixes'),statePath=path.join(specsRoot,'.reviews/.execution/recovery/state.json');
|
|
62
|
+
const bytes=fs.readFileSync(statePath),state=JSON.parse(bytes),registered=state.records.find(r=>r.id==='fix-final-registered').payload;
|
|
63
|
+
const request={requestId:'recover',operation:'recover_final_review',invocationId:registered.request.invocationId,
|
|
64
|
+
packageDigest:registered.request.payload.reviewPackage.packageDigest,previousInvocationStopped:true,reason:'Human authorized one continuation; previous process stopped'};
|
|
65
|
+
const configPath=path.join(root,'config.json'),reviewPath=path.join(root,'review.json');
|
|
66
|
+
fs.writeFileSync(configPath,JSON.stringify(config));fs.writeFileSync(reviewPath,JSON.stringify(review));
|
|
67
|
+
async function cli(requests,flags=[]){
|
|
68
|
+
owner.close();const input=new PassThrough(),rows=[];let index=0;
|
|
69
|
+
const next=()=>index<requests.length?input.write(JSON.stringify(requests[index++])+'\n'):input.end();
|
|
70
|
+
const output=new Writable({write(chunk,enc,done){const row=JSON.parse(chunk.toString());rows.push(row);
|
|
71
|
+
if(row.type==='host_ready'||Object.hasOwn(row,'requestId'))setImmediate(next);
|
|
72
|
+
if(row.type==='host_request'){
|
|
73
|
+
assert.equal(row.kind,'fix_learning');input.write(JSON.stringify({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,result:learning.application})+'\n');
|
|
74
|
+
}done();}});
|
|
75
|
+
const args=['serve','--config',configPath,'--mode','resume','--host-context','fixture-host','--allow-reproduction','--review-config',reviewPath,...flags];
|
|
76
|
+
assert.equal(await main(args,{input,output,error:output,reviewWorkerFactory:workerFactory}),0);
|
|
77
|
+
return rows.filter(r=>r.requestId);
|
|
78
|
+
}
|
|
79
|
+
const reopen=()=>{owner.close();owner=openFixExecution({...options,create:false},{...reviewHost.execution,bridge,prepare:async()=>learning});return owner;};
|
|
80
|
+
return {cwd,statePath,bytes,state,request,cli,reopen,owner:()=>owner,calls:()=>calls,repairs:()=>repairs};
|
|
81
|
+
}
|
|
82
|
+
const op=operation=>({requestId:operation,operation});
|
|
83
|
+
|
|
84
|
+
test('revision refuses lost earlier thread before persisting started, keeping replay valid',{timeout:15000},async t=>{
|
|
85
|
+
const f=await fixture(t,'revision-reuses-lost-thread');
|
|
86
|
+
const recovered=await f.cli([f.request,op('final_review'),op('publish_review')],['--allow-final-review-recovery','--allow-final-review']);
|
|
87
|
+
assert.equal(recovered.at(-1).result.stage,'final_review_changes_requested');
|
|
88
|
+
const owner=f.reopen();
|
|
89
|
+
await owner.prepareRevision({authorized:true});await owner.repair({authorized:true});
|
|
90
|
+
await owner.runRegression({authorized:true});await owner.retrospect();owner.createHandoff();
|
|
91
|
+
assert.equal(owner.status().stage,'revision_final_review_required');
|
|
92
|
+
const rows=await f.cli([op('final_review')],['--allow-final-review']);
|
|
93
|
+
assert(!rows[0].error,JSON.stringify(rows[0]));assert.equal(rows[0].result.stage,'unknown');
|
|
94
|
+
const records=JSON.parse(fs.readFileSync(f.statePath)).records;
|
|
95
|
+
assert(records.some(r=>r.id==='fix-revision-final-registered'));
|
|
96
|
+
assert(!records.some(r=>r.id==='fix-revision-final-started'));
|
|
97
|
+
assert.equal(f.reopen().status().stage,'unknown');assert.equal(f.calls(),3);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
for(const mode of ['twice-then-success','reuse-first-thread','loss-again'])test(`fresh invocation-bound continuation: ${mode}`,{timeout:15000},async t=>{
|
|
101
|
+
const f=await fixture(t,mode);
|
|
102
|
+
await f.cli([f.request,op('final_review')],['--allow-final-review','--allow-final-review-recovery']);
|
|
103
|
+
assert.equal(f.calls(),2);
|
|
104
|
+
const before=fs.readFileSync(f.statePath),beforeRecords=JSON.parse(before).records;
|
|
105
|
+
const status=(await f.cli([op('status')]))[0].result;
|
|
106
|
+
assert.equal(status.stage,'unknown');assert.equal(status.progress.finished,false);
|
|
107
|
+
assert.equal(status.progress.recovery.needsFreshInvocationBinding,true);
|
|
108
|
+
assert.equal(status.progress.recovery.authorizationGranted,false);
|
|
109
|
+
assert.deepEqual(fs.readFileSync(f.statePath),before);
|
|
110
|
+
const latest=status.finalReviewInvocation;
|
|
111
|
+
const request={...f.request,invocationId:latest.invocationId,packageDigest:latest.packageDigest};
|
|
112
|
+
const flags=['--allow-final-review-recovery','--final-review-recovery-invocation',latest.invocationId];
|
|
113
|
+
for(const denied of [['--allow-final-review-recovery'],['--allow-final-review-recovery','--final-review-recovery-invocation',f.request.invocationId]]){
|
|
114
|
+
const rows=await f.cli([request],denied);assert(rows[0].error);assert.deepEqual(fs.readFileSync(f.statePath),before);
|
|
115
|
+
}
|
|
116
|
+
const stale=await f.cli([f.request],flags);assert(stale[0].error);assert.deepEqual(fs.readFileSync(f.statePath),before);
|
|
117
|
+
const prepared=await f.cli([request,request],flags);
|
|
118
|
+
assert.equal(prepared[0].result.stage,'final_review_required');assert(prepared[1].error);assert.equal(f.calls(),2);
|
|
119
|
+
const deniedDispatch=await f.cli([op('final_review')],['--allow-final-review-recovery','--allow-final-review']);
|
|
120
|
+
assert(deniedDispatch[0].error);assert.equal(f.calls(),2);
|
|
121
|
+
const reviewed=await f.cli([op('final_review'),op('final_review')],[...flags,'--allow-final-review']);
|
|
122
|
+
assert.equal(f.calls(),3);assert.equal(f.repairs(),1);
|
|
123
|
+
assert.deepEqual(JSON.parse(fs.readFileSync(f.statePath)).records.slice(0,beforeRecords.length),beforeRecords);
|
|
124
|
+
if(mode==='loss-again'){
|
|
125
|
+
assert.equal(reviewed[0].result.stage,'unknown');
|
|
126
|
+
const newest=f.reopen().status().finalReviewInvocation;
|
|
127
|
+
const bytes=fs.readFileSync(f.statePath);
|
|
128
|
+
const staleBudget=await f.cli([{...request,invocationId:newest.invocationId}],flags);
|
|
129
|
+
assert(staleBudget[0].error);assert.deepEqual(fs.readFileSync(f.statePath),bytes);
|
|
130
|
+
assert.equal(f.calls(),3);return;
|
|
131
|
+
}
|
|
132
|
+
if(mode==='reuse-first-thread'){
|
|
133
|
+
assert.equal(reviewed[0].result.stage,'unknown');assert.equal(reviewed[0].result.diagnostic.code,'final_context_mismatch');
|
|
134
|
+
assert.equal(f.reopen().status().stage,'unknown');return;
|
|
135
|
+
}
|
|
136
|
+
assert.equal(reviewed[0].result.stage,'final_review_evidence_required');
|
|
137
|
+
const rows=await f.cli(['publish_review','check_n5','post_review_regression','walkthrough','finish','completion_evidence','status'].map(op),
|
|
138
|
+
['--allow-regression','--allow-walkthrough','--allow-finish']);
|
|
139
|
+
for(const row of rows)assert(!row.error,JSON.stringify(row));
|
|
140
|
+
assert.equal(rows.at(-1).result.progress.finished,true);
|
|
141
|
+
const state=JSON.parse(fs.readFileSync(f.statePath));
|
|
142
|
+
const registration=state.records.find(r=>r.id==='fix-final-recovery-2-registered').payload;
|
|
143
|
+
assert.equal(rows.find(r=>r.requestId==='completion_evidence').result.reviewRegistrationDigest,digest(registration));
|
|
144
|
+
assert.equal(f.reopen().status().stage,'completed');assert.equal(f.calls(),3);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('one authorized CLI continuation preserves old history and reaches the original finish',{timeout:15000},async t=>{
|
|
148
|
+
const f=await fixture(t,'success');assert.equal(f.owner().status().stage,'unknown');
|
|
149
|
+
assert.equal((await f.owner().reviewFinal()).stage,'unknown');assert.equal(f.calls(),1);
|
|
150
|
+
const denied=await f.cli([f.request]);assert.equal(denied[0].error.code,'host_request_failed');
|
|
151
|
+
assert.deepEqual(fs.readFileSync(f.statePath),f.bytes);
|
|
152
|
+
const owner=f.reopen();
|
|
153
|
+
assert.throws(()=>owner.recoverFinalReview(f.request),{code:'fix_review_recovery_authorization_required'});
|
|
154
|
+
for(const change of [{invocationId:'wrong'},{packageDigest:'0'.repeat(64)},{previousInvocationStopped:false}])
|
|
155
|
+
assert.throws(()=>owner.recoverFinalReview({...f.request,...change,authorized:true}),{code:'fix_review_recovery_mismatch'});
|
|
156
|
+
fs.appendFileSync(path.join(f.cwd,'value.mjs'),' // drift');
|
|
157
|
+
assert.throws(()=>owner.recoverFinalReview({...f.request,authorized:true}));
|
|
158
|
+
fs.writeFileSync(path.join(f.cwd,'value.mjs'),'export const value=2;');
|
|
159
|
+
assert.deepEqual(fs.readFileSync(f.statePath),f.bytes);
|
|
160
|
+
const prepared=await f.cli([f.request],['--allow-final-review-recovery']);
|
|
161
|
+
assert.equal(prepared[0].result.stage,'final_review_required');assert.equal(f.calls(),1);
|
|
162
|
+
const noPermission=await f.cli([op('final_review')],['--allow-final-review']);
|
|
163
|
+
assert.equal(noPermission[0].error.code,'host_request_failed');assert.equal(f.calls(),1);
|
|
164
|
+
const noDispatchGrant=await f.cli([op('final_review')],['--allow-final-review-recovery']);
|
|
165
|
+
assert.equal(noDispatchGrant[0].result.stage,'final_review_required');assert.equal(f.calls(),1);
|
|
166
|
+
const rejectedAgain=await f.cli([f.request],['--allow-final-review-recovery']);
|
|
167
|
+
assert.equal(rejectedAgain[0].error.code,'host_request_failed');
|
|
168
|
+
const reviewed=await f.cli([op('final_review')],['--allow-final-review','--allow-final-review-recovery']);
|
|
169
|
+
assert.equal(reviewed[0].result.stage,'final_review_evidence_required');assert.equal(f.calls(),2);
|
|
170
|
+
const final=await f.cli(['publish_review','check_n5','post_review_regression','walkthrough','finish','completion_evidence'].map(op),['--allow-regression','--allow-walkthrough','--allow-finish']);
|
|
171
|
+
for(const row of final)assert(!row.error,JSON.stringify(row));
|
|
172
|
+
assert.equal(final.find(r=>r.requestId==='finish').result.stage,'completed');
|
|
173
|
+
const state=JSON.parse(fs.readFileSync(f.statePath));assert.deepEqual(state.records.slice(0,f.state.records.length),f.state.records);
|
|
174
|
+
const fresh=state.records.find(r=>r.id==='fix-final-recovery-registered').payload;
|
|
175
|
+
assert.notEqual(fresh.request.invocationId,f.request.invocationId);assert.equal(fresh.request.identity.attempt,1);
|
|
176
|
+
assert.equal(final.at(-1).result.reviewRegistrationDigest,digest(fresh));
|
|
177
|
+
const resumed=f.reopen();assert.equal(resumed.status().stage,'completed');
|
|
178
|
+
await resumed.reviewFinal();assert.equal(f.calls(),2);assert.equal(f.repairs(),1);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
for(const mode of ['loss-again','reuse-thread','approved','changes_requested'])test(`continuation refuses unsafe reuse: ${mode}`,{timeout:10000},async t=>{
|
|
182
|
+
const f=await fixture(t,mode);
|
|
183
|
+
if(['approved','changes_requested'].includes(mode)){
|
|
184
|
+
await f.cli([f.request],['--allow-final-review-recovery']).then(rows=>assert.equal(rows[0].error.code,'host_request_failed'));
|
|
185
|
+
assert.deepEqual(fs.readFileSync(f.statePath),f.bytes);assert.equal(f.calls(),1);return;
|
|
186
|
+
}
|
|
187
|
+
const rows=await f.cli([f.request,op('final_review'),op('final_review'),f.request],['--allow-final-review','--allow-final-review-recovery']);
|
|
188
|
+
assert.equal(rows[1].result.stage,'unknown');assert.equal(rows[2].result.stage,'unknown');
|
|
189
|
+
assert.equal(rows[1].result.reason,'transport_incomplete');
|
|
190
|
+
assert.deepEqual(rows[1].result.diagnostic,mode==='loss-again'?{phase:'transport',code:'execution_error'}:
|
|
191
|
+
{phase:'registration',code:'final_context_mismatch'});
|
|
192
|
+
// Immediate response only: replay neither invents diagnostics nor dispatches.
|
|
193
|
+
assert.equal(rows[2].result.diagnostic,undefined);
|
|
194
|
+
assert.equal(rows[3].error.code,'host_request_failed');assert.equal(f.calls(),2);
|
|
195
|
+
assert.equal(f.reopen().status().stage,'unknown');assert.equal((await f.owner().reviewFinal()).stage,'unknown');
|
|
196
|
+
assert.equal(f.calls(),2);assert.equal(f.repairs(),1);
|
|
197
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {prepareFixTestAuthor} from '../runtime/js/cm-fix/test-author.mjs';
|
|
7
|
+
import {createHostToolBridge} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
8
|
+
import {createFixRedTest} from '../runtime/js/cm-fix/red-test.mjs';
|
|
9
|
+
import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
|
|
10
|
+
import {openExecutionStore} from '../runtime/js/cm-ai/execution-store.mjs';
|
|
11
|
+
import {captureReviewBaseline} from '../runtime/js/cm-ai/review-package.mjs';
|
|
12
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
13
|
+
|
|
14
|
+
test('current host writes only regression scope after readiness/registration; real test subsequently goes red',async()=>{
|
|
15
|
+
for(const mode of ['authored','out-of-scope','no-op','review-unavailable']){
|
|
16
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-author-')));
|
|
17
|
+
const cwd=path.join(root,'code'),specsRoot=path.join(root,'specs');fs.mkdirSync(cwd);fs.mkdirSync(specsRoot);fs.mkdirSync(path.join(specsRoot,'.reviews'));
|
|
18
|
+
fs.writeFileSync(path.join(cwd,'value.mjs'),'export const value=1;');
|
|
19
|
+
const identity={repositoryId:'fixture',runId:'author-run',taskId:'T-FIX-author',attempt:1};
|
|
20
|
+
let ready=0,registered=0,calls=0;const bridge=createHostToolBridge();
|
|
21
|
+
bridge.attach(row=>{
|
|
22
|
+
if(row.type!=='host_request')return;
|
|
23
|
+
calls++;assert.equal(row.kind,'fix_test_author');assert.equal(ready,1);assert.equal(registered,1);
|
|
24
|
+
if(mode!=='no-op')fs.writeFileSync(path.join(cwd,'regression.mjs'),"import {value} from './value.mjs';if(value!==2){console.error('EXPECTED VALUE 2');process.exit(1)}");
|
|
25
|
+
if(mode==='out-of-scope')fs.writeFileSync(path.join(cwd,'value.mjs'),'export const value=2;');
|
|
26
|
+
bridge.accept({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,result:{outcome:'authored'}});
|
|
27
|
+
});
|
|
28
|
+
const options={codeProject:cwd,specsRoot,identity,testFiles:['regression.mjs'],requirements:['value.mjs'],
|
|
29
|
+
defect:'Wrong constant',diagnosis:{rootCause:'constant mismatch'},reproduction:{status:'reproduced'}};
|
|
30
|
+
const capabilities={bridge,assertReviewReady(){ready++;if(mode==='review-unavailable')throw Object.assign(new Error('unavailable'),{code:'review_unavailable'});}};
|
|
31
|
+
try{
|
|
32
|
+
assert.throws(()=>prepareFixTestAuthor({...options,testFiles:['AGENTS.md']},capabilities),{code:'protected_scope'});
|
|
33
|
+
const author=prepareFixTestAuthor(options,capabilities);
|
|
34
|
+
const control={authorized:true,signal:new AbortController().signal,register(baseline){registered++;assert.equal(baseline.baselineDigest,author.baseline.baselineDigest);}};
|
|
35
|
+
await assert.rejects(author.execute({...control,authorized:false}),{code:'test_author_authorization_required'});
|
|
36
|
+
if(mode==='authored'){
|
|
37
|
+
const result=await author.execute(control);assert.deepEqual(result.changedFiles,['regression.mjs']);assert.equal(result.completionEligible,false);
|
|
38
|
+
const red=await createFixRedTest({cwd,testFiles:['regression.mjs'],command:[process.execPath,'regression.mjs'],
|
|
39
|
+
expectedFailure:{exitCode:1,outputIncludes:'EXPECTED VALUE 2'},timeoutMs:2000},{specsRoot,identity})({identity},control);
|
|
40
|
+
assert.equal(red.status,'red_confirmed');await assert.rejects(author.execute(control),{code:'test_author_already_attempted'});
|
|
41
|
+
}else{
|
|
42
|
+
await assert.rejects(author.execute(control),{code:mode==='out-of-scope'?'out_of_scope':mode==='no-op'?'test_author_no_test':'review_unavailable'});
|
|
43
|
+
if(mode==='review-unavailable'){assert.equal(calls,0);assert.equal(registered,0);assert(!fs.existsSync(path.join(cwd,'regression.mjs')));}
|
|
44
|
+
}
|
|
45
|
+
}finally{bridge.close();fs.rmSync(root,{recursive:true,force:true});}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('fix owner registers test writing before bridge, resumes without redispatch, and keeps lost results unknown',async()=>{
|
|
50
|
+
for(const mode of ['authored','lost','unavailable','wrong-root','wrong-specs']){
|
|
51
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-author-owner-')));
|
|
52
|
+
const cwd=path.join(root,'code'),specsRoot=path.join(root,'specs');fs.mkdirSync(cwd);fs.mkdirSync(specsRoot);
|
|
53
|
+
fs.writeFileSync(path.join(cwd,'value.mjs'),'export const value=1;');
|
|
54
|
+
const identity={repositoryId:'fixture',runId:'owner-author',taskId:'T-FIX-author',attempt:1};
|
|
55
|
+
const options={specsRoot,identity,create:true,configuration:{hostContextId:'fixture-host',defect:'Constant bug',
|
|
56
|
+
reproduction:{cwd,command:[process.execPath,'-e',"console.error('BUG');process.exit(1)"],expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000},
|
|
57
|
+
redTest:{cwd,testFiles:['regression.mjs'],command:[process.execPath,'regression.mjs'],expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000},
|
|
58
|
+
testAuthor:{requirements:['value.mjs']}}};
|
|
59
|
+
let writes=0;const bridge=createHostToolBridge();
|
|
60
|
+
bridge.attach(row=>{
|
|
61
|
+
if(row.type!=='host_request')return;
|
|
62
|
+
let result={status:'diagnosed',rootCause:'Wrong constant',affectedPaths:['value.mjs'],affectedModules:['one'],plan:'Correct after test',crossLayer:false};
|
|
63
|
+
if(row.kind==='fix_test_author'){
|
|
64
|
+
const state=JSON.parse(fs.readFileSync(path.join(specsRoot,'.reviews','.execution',identity.runId,'state.json')));
|
|
65
|
+
assert(state.records.some(record=>record.id==='fix-test-author-intent'));
|
|
66
|
+
writes++;fs.writeFileSync(path.join(cwd,'regression.mjs'),"import {value} from './value.mjs';if(value!==2){console.error('BUG');process.exit(1)}");
|
|
67
|
+
if(mode==='lost'){bridge.close();return;}result={outcome:'authored'};
|
|
68
|
+
}
|
|
69
|
+
bridge.accept({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,result});
|
|
70
|
+
});
|
|
71
|
+
let owner=openFixExecution(options,{bridge,assertReviewReady(){if(mode==='unavailable')throw new Error('not ready');}});
|
|
72
|
+
try{
|
|
73
|
+
assert.equal((await owner.advance({authorized:true})).stage,'test_author_required');
|
|
74
|
+
if(mode.startsWith('wrong-')){
|
|
75
|
+
const other=path.join(root,'other');fs.mkdirSync(other);fs.writeFileSync(path.join(other,'value.mjs'),'export const value=1;');
|
|
76
|
+
let baseline=captureReviewBaseline({root:mode==='wrong-root'?other:cwd,specsRoot,identity,
|
|
77
|
+
scope:['regression.mjs'],requirements:['value.mjs']});
|
|
78
|
+
if(mode==='wrong-specs'){
|
|
79
|
+
const {baselineDigest,...body}=baseline;body.specsPath='different-specs';baseline={...body,baselineDigest:digest(body)};
|
|
80
|
+
}
|
|
81
|
+
owner.close();owner=null;
|
|
82
|
+
const state=JSON.parse(fs.readFileSync(path.join(specsRoot,'.reviews','.execution',identity.runId,'state.json')));
|
|
83
|
+
const store=openExecutionStore({specsRoot,identity:state.identity,fingerprints:state.fingerprints,create:false});
|
|
84
|
+
store.append({id:'fix-test-author-intent',kind:'intent',payload:baseline,expectedRevision:store.snapshot().revision});store.close();
|
|
85
|
+
assert.throws(()=>openFixExecution({...options,create:false}),{code:'test_author_binding_mismatch'});
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
assert.equal((await owner.runRedTest({authorized:true})).stage,'test_author_required');
|
|
89
|
+
await assert.rejects(owner.authorTests(),{code:'test_author_authorization_required'});
|
|
90
|
+
if(mode==='unavailable'){
|
|
91
|
+
await assert.rejects(owner.authorTests({authorized:true}),{code:'test_author_preparation_failed'});
|
|
92
|
+
assert.equal(writes,0);assert.equal(owner.status().pending,null);
|
|
93
|
+
}else{
|
|
94
|
+
assert.equal((await owner.authorTests({authorized:true})).stage,mode==='lost'?'unknown':'red_test_required');
|
|
95
|
+
const before=owner.status();owner.close();owner=openFixExecution({...options,create:false});
|
|
96
|
+
assert.deepEqual(await owner.authorTests({authorized:true}),before);assert.equal(writes,1);
|
|
97
|
+
if(mode==='authored'){
|
|
98
|
+
fs.appendFileSync(path.join(cwd,'regression.mjs'),'\n// drift');
|
|
99
|
+
assert.equal(owner.status().stage,'test_author_evidence_required');
|
|
100
|
+
assert.equal((await owner.runRedTest({authorized:true})).stage,'test_author_evidence_required');
|
|
101
|
+
}else assert.equal(owner.status().pending,'test_author');
|
|
102
|
+
}
|
|
103
|
+
}finally{owner?.close();bridge.close();fs.rmSync(root,{recursive:true,force:true});}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {createHash} from 'node:crypto';
|
|
7
|
+
import {PassThrough,Writable} from 'node:stream';
|
|
8
|
+
import {main} from './cm-fix-host.mjs';
|
|
9
|
+
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
10
|
+
import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
|
|
11
|
+
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
12
|
+
import {createFixHost} from '../runtime/js/cm-fix/host.mjs';
|
|
13
|
+
import {eventsAt} from '../runtime/js/cm-fix/finish.mjs';
|
|
14
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
15
|
+
import {verifyVisualCarrier,observeVisualAfter} from '../runtime/js/cm-fix/visual.mjs';
|
|
16
|
+
|
|
17
|
+
const png=Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+a7l8AAAAASUVORK5CYII=','base64');
|
|
18
|
+
function carrier(file,caption){const bytes=Buffer.concat([png,Buffer.from(caption)]);fs.writeFileSync(file,bytes);
|
|
19
|
+
return {path:file,kind:'screenshot',sha256:createHash('sha256').update(bytes).digest('hex'),description:`Synthetic fixture: ${caption}`};}
|
|
20
|
+
function fixture(t){
|
|
21
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-visual-bare-'))),cwd=path.join(root,'code');fs.mkdirSync(cwd);
|
|
22
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
23
|
+
fs.writeFileSync(path.join(cwd,'style.css'),'button { color:red; }');
|
|
24
|
+
fs.writeFileSync(path.join(cwd,'.cm-workflow.json'),JSON.stringify({version:1,policies:{delivery:'diff'}}));
|
|
25
|
+
const environment={scope:'local',kind:'web',carrier:'browser',target:'http://127.0.0.1:3000'};
|
|
26
|
+
const visual={kind:'visual',cwd,timeoutMs:2000,before:carrier(path.join(root,'before.png'),'before'),
|
|
27
|
+
reason:'Pure visual fixture: automated red assertion unavailable',environment,steps:['Inspect button'],expected:['Button has the intended color']};
|
|
28
|
+
const config={identity:{repositoryId:'fixture',runId:'visual-bare',taskId:'T-FIX-color',attempt:1},defect:'Button color is incorrect',
|
|
29
|
+
reproduction:visual,redTest:{...visual,testFiles:[]},
|
|
30
|
+
baseline:{cwd,testFiles:[],commands:[],timeoutMs:2000,noExistingTests:'Fixture has no existing automated suites'},
|
|
31
|
+
repair:{scope:['style.css'],requirements:['style.css']},walkthrough:{timeoutMs:2000,environment,
|
|
32
|
+
flows:[{id:'button',kind:'browser',modules:['button'],steps:['Inspect button'],expected:['Color is correct']}]} };
|
|
33
|
+
return {root,cwd,config,archive:path.join(cwd,'docs','fixes')};
|
|
34
|
+
}
|
|
35
|
+
const diagnosed={status:'diagnosed',rootCause:'Wrong color',affectedPaths:['style.css'],plan:'Correct the color',crossLayer:false,
|
|
36
|
+
affectedModules:['button'],investigation:{discardedAlternatives:[],boundaryAnalysis:null}};
|
|
37
|
+
const control={authorized:true,signal:new AbortController().signal};
|
|
38
|
+
const prepare=async()=>({contextDigest:digest([]),files:[],application:{contextDigest:digest([]),status:'no_relevant_lesson',summary:'Synthetic fixture'}});
|
|
39
|
+
|
|
40
|
+
for(const mode of ['visual','command'])test(`bare ${mode} CLI uses original review/finalizer, no metrics or fabricated commands; restart is read-only`,async t=>{
|
|
41
|
+
const f=fixture(t),configPath=path.join(f.root,'config.json'),reviewPath=path.join(f.root,'review.json');
|
|
42
|
+
if(mode==='command'){
|
|
43
|
+
fs.writeFileSync(path.join(f.cwd,'regression.mjs'),"import fs from 'node:fs';if(!fs.readFileSync('style.css','utf8').includes('blue')){console.error('WRONG_COLOR');process.exit(1)}");
|
|
44
|
+
const command=[process.execPath,'regression.mjs'];
|
|
45
|
+
f.config.reproduction={cwd:f.cwd,command,timeoutMs:2000,expectedFailure:{exitCode:1,outputIncludes:'WRONG_COLOR'}};
|
|
46
|
+
f.config.redTest={...f.config.reproduction,testFiles:['regression.mjs']};
|
|
47
|
+
f.config.walkthrough={timeoutMs:2000,flows:[{id:'button',kind:'commands',command,modules:['button'],steps:['Read color'],expected:['Blue']}]};
|
|
48
|
+
}
|
|
49
|
+
fs.writeFileSync(configPath,JSON.stringify(f.config));
|
|
50
|
+
fs.writeFileSync(reviewPath,JSON.stringify({model:'synthetic',disabledSkills:[],preflight:{passed:true,cli_model:'synthetic',prompt_transport:'stdin',
|
|
51
|
+
config_fingerprint:configFingerprint({cwd:f.cwd,model:'synthetic',disabledSkills:[],promptTransport:'stdin'})}}));
|
|
52
|
+
const args=['serve','--config',configPath,'--mode','create','--host-context','fixture-host','--allow-reproduction','--review-config',reviewPath,
|
|
53
|
+
'--allow-red-test','--allow-baseline','--allow-repair','--allow-regression','--allow-final-review','--allow-walkthrough','--allow-finish'];
|
|
54
|
+
let reviews=0,repairs=0,visualCalls=0,hostCalls=0,after;
|
|
55
|
+
const reviewWorkerFactory=()=>async({prompt},{onEvent})=>{
|
|
56
|
+
reviews++;const data=JSON.parse(prompt.split('<cm-review-data-json>\n')[1]);
|
|
57
|
+
if(mode==='visual'){
|
|
58
|
+
assert.equal(data.reviewPackage.checks[0].kind,'visual');assert.equal(Object.hasOwn(data.reviewPackage.checks[0],'command'),false);
|
|
59
|
+
assert.equal(Object.hasOwn(data.reviewPackage.checks[0],'exitCode'),false);
|
|
60
|
+
const handoff=JSON.parse(Buffer.from(data.reviewPackage.handoff.contentBase64,'base64'));
|
|
61
|
+
assert.match(handoff.verification[0].command,/visual/i);
|
|
62
|
+
assert.ok(handoff.evidence.some(row=>row.includes(f.config.reproduction.before.sha256)));
|
|
63
|
+
}else{assert.equal(data.reviewPackage.checks[0].outcome,'passed');assert.deepEqual(data.reviewPackage.checks[0].command,f.config.redTest.command);}
|
|
64
|
+
for(const event of [{event:'thread.started',provider_thread:'fixture-independent-review'},{event:'turn.started',item_type:null},
|
|
65
|
+
{event:'item.completed',item_type:'agent_message'},{event:'turn.completed',item_type:null},{event:'process_closed',exit_code:0,signal:null,timed_out:false}])onEvent(event);
|
|
66
|
+
return {status:'succeeded',value:{verdict:'approved',packageDigest:data.reviewPackage.packageDigest,examinedPaths:data.examinedPaths,findings:[],summary:'Synthetic independent review'}};
|
|
67
|
+
};
|
|
68
|
+
const operations=['advance','red_test','baseline','repair','regression','retrospective','handoff','final_review','publish_review','check_n5','post_review_regression','walkthrough','publish_dossier','finish'];
|
|
69
|
+
async function launch(mode,ops){
|
|
70
|
+
const input=new PassThrough(),rows=[];let index=0,stderr='';
|
|
71
|
+
const next=()=>index<ops.length?input.write(JSON.stringify({requestId:ops[index],operation:ops[index++]})+'\n'):input.end();
|
|
72
|
+
const output=new Writable({write(bytes,encoding,done){
|
|
73
|
+
try{const row=JSON.parse(bytes);rows.push(row);if(row.type==='host_ready')setImmediate(next);
|
|
74
|
+
if(row.type==='host_request'){
|
|
75
|
+
hostCalls++;let result;
|
|
76
|
+
if(row.kind==='fix_learning')result={contextDigest:row.payload.contextDigest,status:'no_relevant_lesson',summary:'Synthetic fixture'};
|
|
77
|
+
else if(row.kind==='fix_diagnose')result=diagnosed;
|
|
78
|
+
else if(row.kind==='fix_repair'){repairs++;fs.writeFileSync(path.join(f.cwd,'style.css'),'button { color:blue; }');result={outcome:'repaired'};}
|
|
79
|
+
else if(row.kind==='fix_retrospective')result={status:'no_new_lesson',candidates:[],reason:null};
|
|
80
|
+
else if(row.kind==='qa_browser'&&row.payload.before){visualCalls++;
|
|
81
|
+
after=carrier(path.join(f.archive,'.reviews',`after-${visualCalls}.png`),`after ${visualCalls}`);
|
|
82
|
+
result={verdict:'PASS',after,environment:f.config.reproduction.environment,cleanup:'completed',explanation:'Synthetic observed comparison'};
|
|
83
|
+
}else if(row.kind==='qa_browser')result={verdict:'PASS',evidence:[path.relative(f.archive,after.path)],environment:f.config.reproduction.environment,cleanup:'completed'};
|
|
84
|
+
else assert.fail(row.kind);
|
|
85
|
+
input.write(JSON.stringify({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,result})+'\n');
|
|
86
|
+
}
|
|
87
|
+
if(Object.hasOwn(row,'requestId'))setImmediate(next);done();
|
|
88
|
+
}catch(error){done(error);input.end();}
|
|
89
|
+
}});
|
|
90
|
+
const current=[...args];current[4]=mode;
|
|
91
|
+
assert.equal(await main(current,{input,output,error:new Writable({write(c,e,done){stderr+=c;done();}}),reviewWorkerFactory}),0,stderr);
|
|
92
|
+
assert.ok(rows.every(row=>!row.error),JSON.stringify(rows.filter(row=>row.error)));
|
|
93
|
+
return rows.filter(row=>row.requestId);
|
|
94
|
+
}
|
|
95
|
+
const rows=await launch('create',operations);assert.equal(rows.at(-1).result.stage,'completed',JSON.stringify(rows.map(r=>[r.requestId,r.result.stage])));
|
|
96
|
+
assert.equal(repairs,1);assert.equal(reviews,1);assert.equal(visualCalls,mode==='visual'?2:0);
|
|
97
|
+
assert.equal(fs.existsSync(path.join(f.cwd,'specs')),false);assert.equal(fs.existsSync(path.join(f.archive,'fixes')),false);
|
|
98
|
+
assert.equal(fs.existsSync(path.join(f.archive,'METRICS.md')),false);
|
|
99
|
+
const logs=eventsAt(f.archive,{archiveMode:'bare'});assert.equal(logs.filter(row=>row.event==='task_done').length,1);
|
|
100
|
+
assert.equal(logs.find(row=>row.event==='run_done').metrics_skipped,'no_specs');assert.ok(logs.every(row=>!row.specs_path));
|
|
101
|
+
const done=logs.find(row=>row.event==='task_done');assert.equal(path.dirname(done.dossier_file),'.');
|
|
102
|
+
assert.match(fs.readFileSync(path.join(f.archive,done.dossier_file),'utf8'),/跳过 METRICS/);
|
|
103
|
+
const calls=hostCalls;const resumed=await launch('resume',['status','finish']);assert.equal(resumed.at(-1).result.stage,'completed');assert.equal(hostCalls,calls);
|
|
104
|
+
assert.deepEqual(eventsAt(f.archive,{archiveMode:'bare'}),logs);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('visual missing/drifted carrier refuses admission; lost after observation stays unknown without redispatch',async t=>{
|
|
108
|
+
const f=fixture(t);let owner,calls=0;
|
|
109
|
+
const {identity,...config}=f.config,options={identity,configuration:{hostContextId:'fixture-host',...config},create:true};
|
|
110
|
+
const dependencies={prepare,assertReviewReady(){},bridge:{async call(kind){
|
|
111
|
+
if(kind==='fix_diagnose')return diagnosed;
|
|
112
|
+
if(kind==='fix_repair'){fs.writeFileSync(path.join(f.cwd,'style.css'),'button { color:blue; }');return {outcome:'repaired'};}
|
|
113
|
+
if(kind==='qa_browser'){calls++;throw Error('synthetic lost original visual result');}assert.fail(kind);
|
|
114
|
+
}}};
|
|
115
|
+
const before=f.config.reproduction.before;
|
|
116
|
+
assert.throws(()=>verifyVisualCarrier({...before,path:path.join(f.root,'missing.png')}));
|
|
117
|
+
assert.throws(()=>verifyVisualCarrier({...before,sha256:'0'.repeat(64)}),{code:'fix_visual_carrier_changed'});
|
|
118
|
+
let observedSignal;
|
|
119
|
+
await assert.rejects(observeVisualAfter({...f.config.redTest,timeoutMs:20},{identity,signal:control.signal,specsRoot:f.archive,
|
|
120
|
+
bridge:{call:async(kind,payload,signal)=>{observedSignal=signal;return new Promise(()=>{});}}}),{code:'fix_visual_timeout'});
|
|
121
|
+
assert.equal(observedSignal.aborted,true);
|
|
122
|
+
try{
|
|
123
|
+
owner=openFixExecution(options,dependencies);assert.equal((await owner.advance(control)).stage,'red_test_required');
|
|
124
|
+
assert.equal((await owner.runRedTest(control)).stage,'baseline_required');assert.equal((await owner.captureBaseline(control)).stage,'repair_required');
|
|
125
|
+
assert.equal((await owner.repair(control)).stage,'regression_required');assert.equal((await owner.runRegression(control)).stage,'unknown');
|
|
126
|
+
owner.close();owner=openFixExecution({...options,create:false},dependencies);
|
|
127
|
+
assert.equal((await owner.runRegression(control)).stage,'unknown');assert.equal(calls,1);assert.equal(owner.status().completionEligible,false);
|
|
128
|
+
owner.cancel();owner.close();owner=openFixExecution({...options,create:false},dependencies);assert.equal(owner.status().stage,'cancelled');
|
|
129
|
+
}finally{owner?.close();}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('identical-byte visual FAIL persists defect_remaining and permits original reviewed retry after reopen',async t=>{
|
|
133
|
+
const f=fixture(t);let owner,observations=0,reviews=0;
|
|
134
|
+
const {identity,...config}=f.config,permissions=['--allow-reproduction','--allow-red-test','--allow-baseline','--allow-repair','--allow-regression','--allow-final-review'];
|
|
135
|
+
const review={model:'synthetic',disabledSkills:[],preflight:{passed:true,cli_model:'synthetic',prompt_transport:'stdin',
|
|
136
|
+
config_fingerprint:configFingerprint({cwd:f.cwd,model:'synthetic',disabledSkills:[],promptTransport:'stdin'})}};
|
|
137
|
+
const assembly=createFixReviewHost({codeProject:f.cwd,hostContextId:'fixture-host',review,permissions,workerFactory:()=>async({prompt},{onEvent})=>{
|
|
138
|
+
reviews++;const data=JSON.parse(prompt.split('<cm-review-data-json>\n')[1]);
|
|
139
|
+
for(const event of [{event:'thread.started',provider_thread:'identical-fail-review'},{event:'turn.started',item_type:null},
|
|
140
|
+
{event:'item.completed',item_type:'agent_message'},{event:'turn.completed',item_type:null},{event:'process_closed',exit_code:0,signal:null,timed_out:false}])onEvent(event);
|
|
141
|
+
return {status:'succeeded',value:{verdict:'approved',packageDigest:data.reviewPackage.packageDigest,examinedPaths:data.examinedPaths,findings:[],summary:'Synthetic review'}};
|
|
142
|
+
}});
|
|
143
|
+
const options={identity,configuration:{hostContextId:'fixture-host',...config,causeReview:assembly.reviewer},create:true};
|
|
144
|
+
const dependencies={prepare,...assembly.execution,bridge:{async call(kind){
|
|
145
|
+
if(kind==='fix_diagnose')return diagnosed;
|
|
146
|
+
if(kind==='fix_repair'){fs.writeFileSync(path.join(f.cwd,'style.css'),'button { color:blue; }');return {outcome:'repaired'};}
|
|
147
|
+
if(kind==='fix_retrospective')return {status:'no_new_lesson',candidates:[],reason:null};
|
|
148
|
+
if(kind==='qa_browser'){
|
|
149
|
+
observations++;const failed=observations===2;
|
|
150
|
+
const after=carrier(path.join(f.archive,'.reviews',`observation-${observations}.png`),failed?'before':'corrected');
|
|
151
|
+
if(failed){assert.equal(after.sha256,f.config.reproduction.before.sha256);assert.notEqual(after.path,f.config.reproduction.before.path);}
|
|
152
|
+
return {verdict:failed?'FAIL':'PASS',after,environment:f.config.reproduction.environment,cleanup:'completed',explanation:'Synthetic visual observation'};
|
|
153
|
+
}
|
|
154
|
+
assert.fail(kind);
|
|
155
|
+
}}};
|
|
156
|
+
try{
|
|
157
|
+
owner=openFixExecution(options,dependencies);
|
|
158
|
+
const host=createFixHost({owner,config:f.config,permissions,finalAuthority:assembly.finalAuthority});
|
|
159
|
+
for(const operation of ['advance','red_test','baseline','repair','regression','retrospective','handoff','final_review','publish_review','check_n5'])
|
|
160
|
+
await host.handle({requestId:operation,operation});
|
|
161
|
+
assert.equal(owner.status().stage,'post_review_regression_required');
|
|
162
|
+
const failed=await owner.runRegression({...control,postReview:true});
|
|
163
|
+
assert.equal(failed.stage,'post_review_regression_blocked');assert.equal(failed.postReviewRegression.status,'defect_remaining');
|
|
164
|
+
assert.equal(failed.pending,null);assert.equal(failed.postReviewRegression.red.verdict,'FAIL');
|
|
165
|
+
owner.close();owner=openFixExecution({...options,create:false},dependencies);
|
|
166
|
+
assert.deepEqual(owner.status().postReviewRegression,failed.postReviewRegression);
|
|
167
|
+
assert.equal((await owner.runRegression({...control,postReview:true})).stage,'post_review_regression_blocked');
|
|
168
|
+
assert.equal(observations,2);assert.equal(reviews,1);
|
|
169
|
+
assert.equal((await owner.prepareRevision(control)).stage,'revision_prepared');
|
|
170
|
+
}finally{owner?.close();}
|
|
171
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {createFixWalkthrough,verifyFixWalkthroughEvidence} from '../runtime/js/cm-fix/walkthrough.mjs';
|
|
7
|
+
|
|
8
|
+
test('impact walkthrough requires coverage and authority; preserves observed, static and missing evidence separately',async()=>{
|
|
9
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-walkthrough-')));
|
|
10
|
+
try{
|
|
11
|
+
fs.writeFileSync(path.join(root,'observed.md'),'Synthetic host observation, not a real browser run.');
|
|
12
|
+
const environment={kind:'web',carrier:'browser',target:'http://127.0.0.1:3000',scope:'local'};
|
|
13
|
+
const flow={id:'flow',modules:['value'],steps:['Read value'],expected:['value is 2'],kind:'browser'};
|
|
14
|
+
const options={cwd:root,specsRoot:root,identity:{repositoryId:'fixture',runId:'walk',taskId:'T-FIX-walk',attempt:1},
|
|
15
|
+
packageDigest:'a'.repeat(64),diagnosis:{affectedModules:['value']},configuration:{flows:[flow],environment,timeoutMs:2000}};
|
|
16
|
+
assert.throws(()=>createFixWalkthrough({...options,diagnosis:{affectedModules:['value','other']}}),{code:'walkthrough_module_mismatch'});
|
|
17
|
+
let calls=0;
|
|
18
|
+
const approved=createFixWalkthrough(options,{browser:async()=>{calls++;return {verdict:'PASS',evidence:['observed.md'],environment,cleanup:'completed'};}});
|
|
19
|
+
await assert.rejects(()=>approved.run({signal:new AbortController().signal}),{code:'walkthrough_authorization_required'});assert.equal(calls,0);
|
|
20
|
+
const passed=await approved.run({authorized:true,signal:new AbortController().signal});assert.equal(passed.status,'passed');assert.equal(passed.completionEligible,false);
|
|
21
|
+
verifyFixWalkthroughEvidence(passed,root);
|
|
22
|
+
await assert.rejects(()=>approved.run({authorized:true,signal:new AbortController().signal}),{code:'walkthrough_already_attempted'});assert.equal(calls,1);
|
|
23
|
+
fs.appendFileSync(path.join(root,'observed.md'),' changed');assert.throws(()=>verifyFixWalkthroughEvidence(passed,root),{code:'walkthrough_evidence_changed'});
|
|
24
|
+
for(const mode of ['missing-host','missing-file','cleanup','fail','logic','command']){
|
|
25
|
+
const configuration={...options.configuration,flows:[mode==='logic'?{...flow,kind:'logic'}:mode==='command'?{...flow,kind:'commands',command:[process.execPath,'-e','process.exit(0)']}:flow]};
|
|
26
|
+
const capabilities=mode==='missing-host'?{}:{browser:async()=>({verdict:mode==='fail'?'FAIL':'PASS',evidence:[mode==='missing-file'?'missing.md':'observed.md'],environment,cleanup:mode==='cleanup'?'failed':'completed'}),
|
|
27
|
+
logic:async()=>({verdict:'SUPPORTED',evidence:['Synthetic static reading only']})};
|
|
28
|
+
const result=await createFixWalkthrough({...options,configuration},capabilities).run({authorized:true,signal:new AbortController().signal});
|
|
29
|
+
assert.equal(result.status,mode==='fail'?'failed':mode==='command'?'passed':'blocked',mode);
|
|
30
|
+
if(mode==='logic')assert.equal(result.rows[0].observation.verdict,'SUPPORTED');
|
|
31
|
+
if(mode==='missing-file')assert.equal(result.rows[0].evidenceProblem,'walkthrough_evidence_required');
|
|
32
|
+
}
|
|
33
|
+
for(const kind of ['browser','logic'])for(const reason of ['timeout','cancel']){
|
|
34
|
+
const configuration={...options.configuration,timeoutMs:reason==='timeout'?25:1000,flows:[{...flow,kind}]};
|
|
35
|
+
let rejectLate,observedSignal;const controller=new AbortController();
|
|
36
|
+
const run=createFixWalkthrough({...options,configuration},{[kind]:(request,signal)=>{
|
|
37
|
+
observedSignal=signal;
|
|
38
|
+
if(reason==='cancel')setImmediate(()=>controller.abort());
|
|
39
|
+
return new Promise((resolve,reject)=>{rejectLate=reject;});
|
|
40
|
+
}});
|
|
41
|
+
await assert.rejects(()=>run.run({authorized:true,signal:controller.signal}),{code:reason==='timeout'?'walkthrough_timeout':'cancelled'});
|
|
42
|
+
assert(observedSignal.aborted);rejectLate(new Error('late callback rejection'));await new Promise(resolve=>setImmediate(resolve));
|
|
43
|
+
}
|
|
44
|
+
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
45
|
+
});
|