@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,261 @@
|
|
|
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 {main} from './cm-fix-host.mjs';
|
|
8
|
+
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
9
|
+
import {claudeReviewFingerprint} from '../runtime/js/cm-ai/worker-claude.mjs';
|
|
10
|
+
import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
|
|
11
|
+
import {checkN4} from './cm-task-gate.mjs';
|
|
12
|
+
import {fixCompletionProjection} from '../runtime/js/cm-fix/finish.mjs';
|
|
13
|
+
import {loadConfig,resolveRole} from './cm-workflow-config.mjs';
|
|
14
|
+
|
|
15
|
+
for(const runtime of ['codex','claude']){
|
|
16
|
+
test(`${runtime} CLI cause review requires opt-in and matching diagnostic, then resumes without dispatch`,async()=>{
|
|
17
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-host-review-')));
|
|
18
|
+
const cwd=path.join(root,'code'),specsRoot=path.join(root,'specs');fs.mkdirSync(cwd);fs.mkdirSync(specsRoot);
|
|
19
|
+
fs.writeFileSync(path.join(cwd,'value.mjs'),'export const value=1;');
|
|
20
|
+
const config=path.join(root,'config.json'),reviewConfig=path.join(root,'review.json');
|
|
21
|
+
fs.writeFileSync(config,JSON.stringify({specsRoot,identity:{repositoryId:'fixture',runId:'fix-host-review',taskId:'T-FIX-demo',attempt:1},
|
|
22
|
+
defect:'Synthetic constant',reproduction:{cwd,command:[process.execPath,'-e',"process.stderr.write('BUG');process.exit(3)"],
|
|
23
|
+
expectedFailure:{exitCode:3,outputIncludes:'BUG'},timeoutMs:1000}}));
|
|
24
|
+
const review={model:'synthetic-model',disabledSkills:[],preflight:{passed:true,cli_model:'synthetic-model',prompt_transport:'stdin',
|
|
25
|
+
config_fingerprint:configFingerprint({cwd,model:'synthetic-model',disabledSkills:[],promptTransport:'stdin'})}};
|
|
26
|
+
if(runtime==='claude')review.preflight={passed:true,provider:'claude',prompt_transport:'stdin',config_fingerprint:claudeReviewFingerprint({cwd,model:review.model})};
|
|
27
|
+
fs.writeFileSync(reviewConfig,JSON.stringify({...review,preflight:{...review.preflight,passed:false}}));
|
|
28
|
+
const args=['serve','--config',config,'--mode','create','--host-context','fixture-host','--allow-reproduction','--review-config',reviewConfig];
|
|
29
|
+
if(runtime==='claude')args.push('--runtime','claude');
|
|
30
|
+
let calls=0;
|
|
31
|
+
const reviewWorkerFactory=()=>async({prompt},{onEvent})=>{
|
|
32
|
+
calls++;const data=JSON.parse(prompt.split('<cm-review-data-json>\n')[1]);
|
|
33
|
+
for(const event of [{event:'thread.started',provider_thread:'fresh-cause-review'},{event:'turn.started',item_type:null},
|
|
34
|
+
{event:'item.completed',item_type:'agent_message'},{event:'turn.completed',item_type:null},
|
|
35
|
+
{event:'process_closed',exit_code:0,signal:null,timed_out:false}])onEvent(event);
|
|
36
|
+
return {status:'succeeded',value:{verdict:'approved',packageDigest:data.reviewPackage.packageDigest,
|
|
37
|
+
examinedPaths:['value.mjs'],findings:[],summary:'Synthetic review no findings'}};
|
|
38
|
+
};
|
|
39
|
+
try{
|
|
40
|
+
const discard=new Writable({write(c,e,cb){cb();}});
|
|
41
|
+
assert.equal(await main([...args,'--allow-cause-review'],{error:discard,reviewWorkerFactory}),1);
|
|
42
|
+
assert.equal(fs.existsSync(path.join(specsRoot,'.reviews')),false);assert.equal(calls,0);
|
|
43
|
+
if(runtime==='claude'){
|
|
44
|
+
const wrong={passed:true,cli_model:review.model,prompt_transport:'stdin',
|
|
45
|
+
config_fingerprint:configFingerprint({cwd,model:review.model,disabledSkills:[],promptTransport:'stdin'})};
|
|
46
|
+
fs.writeFileSync(reviewConfig,JSON.stringify({...review,preflight:wrong}));
|
|
47
|
+
assert.equal(await main([...args,'--allow-cause-review'],{error:discard,reviewWorkerFactory}),1);
|
|
48
|
+
fs.writeFileSync(reviewConfig,JSON.stringify({...review,disabledSkills:['/synthetic/unsupported-skill']}));
|
|
49
|
+
assert.equal(await main([...args,'--allow-cause-review'],{error:discard,reviewWorkerFactory}),1);
|
|
50
|
+
assert.equal(fs.existsSync(path.join(specsRoot,'.reviews')),false);assert.equal(calls,0);
|
|
51
|
+
}
|
|
52
|
+
fs.writeFileSync(reviewConfig,JSON.stringify(review));
|
|
53
|
+
for(const pass of ['denied','allowed','resume']){
|
|
54
|
+
args[4]=pass==='denied'?'create':'resume';
|
|
55
|
+
const input=new PassThrough(),rows=[];
|
|
56
|
+
const send=operation=>input.write(JSON.stringify({requestId:operation,operation})+'\n');
|
|
57
|
+
const output=new Writable({write(chunk,enc,done){
|
|
58
|
+
const row=JSON.parse(chunk.toString());rows.push(row);
|
|
59
|
+
if(row.type==='host_ready')send(pass==='denied'?'advance':'cause_review');
|
|
60
|
+
if(row.type==='host_request'){
|
|
61
|
+
const result=row.kind==='fix_learning'?{contextDigest:row.payload.contextDigest,status:'no_relevant_lesson',summary:'No project instructions'}:
|
|
62
|
+
{status:'diagnosed',rootCause:'Cross-layer constant',plan:'Correct after red test',affectedPaths:['value.mjs'],affectedModules:['value'],crossLayer:true};
|
|
63
|
+
input.write(JSON.stringify({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,result})+'\n');
|
|
64
|
+
}
|
|
65
|
+
if(row.requestId==='advance')setImmediate(()=>send('cause_review'));
|
|
66
|
+
if(row.requestId==='cause_review')input.end();
|
|
67
|
+
done();
|
|
68
|
+
}});
|
|
69
|
+
assert.equal(await main(pass==='denied'?args:[...args,'--allow-cause-review'],{input,output,error:output,reviewWorkerFactory}),0);
|
|
70
|
+
const result=rows.find(row=>row.requestId==='cause_review').result;
|
|
71
|
+
assert.equal(result.stage,pass==='denied'?'cause_review_required':'red_test_required');
|
|
72
|
+
if(pass==='denied')assert.equal(result.reason,'permission_denied');
|
|
73
|
+
assert.equal(result.completionEligible,false);assert.equal(calls,pass==='denied'?0:1);
|
|
74
|
+
}
|
|
75
|
+
if(runtime==='claude'){
|
|
76
|
+
const statePath=path.join(specsRoot,'.reviews','.execution','fix-host-review','state.json'),bytes=fs.readFileSync(statePath);
|
|
77
|
+
const changed=args.map((value,index)=>index===args.indexOf('--runtime')+1?'codex':value);
|
|
78
|
+
assert.equal(await main(changed,{error:discard,reviewWorkerFactory}),1);
|
|
79
|
+
assert.deepEqual(fs.readFileSync(statePath),bytes);assert.equal(calls,1);
|
|
80
|
+
}
|
|
81
|
+
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test(`${runtime} CLI stages independently authorize writes and synthetic final review, then resume without redispatch`,{timeout:15000},async()=>{
|
|
85
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-host-author-')));
|
|
86
|
+
const cwd=path.join(root,'code'),specsRoot=path.join(root,'specs');fs.mkdirSync(cwd);fs.mkdirSync(specsRoot);
|
|
87
|
+
fs.writeFileSync(path.join(cwd,'value.mjs'),'export const value=1;');
|
|
88
|
+
const config=path.join(root,'config.json'),reviewConfig=path.join(root,'review.json');
|
|
89
|
+
fs.writeFileSync(path.join(cwd,'existing.mjs'),"import {value} from './value.mjs';if(typeof value!=='number')process.exit(1)");
|
|
90
|
+
fs.writeFileSync(path.join(cwd,'.cm-workflow.json'),JSON.stringify({version:1,policies:{delivery:'diff'}}));
|
|
91
|
+
fs.writeFileSync(config,JSON.stringify({specsRoot,identity:{repositoryId:'fixture',runId:'fix-author-cli',taskId:'T-FIX-author',attempt:1},
|
|
92
|
+
defect:'Synthetic',reproduction:{cwd,command:[process.execPath,'-e',"console.error('BUG');process.exit(1)"],expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000},
|
|
93
|
+
redTest:{cwd,testFiles:['regression.mjs'],command:[process.execPath,'regression.mjs'],expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000},
|
|
94
|
+
testAuthor:{requirements:['value.mjs']},repair:{scope:['value.mjs'],requirements:['value.mjs']},
|
|
95
|
+
walkthrough:{timeoutMs:2000,flows:[{id:'value-flow',modules:['value'],steps:['Read the corrected value'],expected:['value is 2'],kind:'commands',command:[process.execPath,'regression.mjs']}]},
|
|
96
|
+
baseline:{cwd,testFiles:['existing.mjs'],commands:[{id:'existing',command:[process.execPath,'existing.mjs']}],timeoutMs:2000}}));
|
|
97
|
+
const review={model:'synthetic-model',disabledSkills:[],preflight:{passed:true,cli_model:'synthetic-model',prompt_transport:'stdin',
|
|
98
|
+
config_fingerprint:configFingerprint({cwd,model:'synthetic-model',disabledSkills:[],promptTransport:'stdin'})}};
|
|
99
|
+
if(runtime==='claude')review.preflight={passed:true,provider:'claude',prompt_transport:'stdin',config_fingerprint:claudeReviewFingerprint({cwd,model:review.model})};
|
|
100
|
+
const args=['serve','--config',config,'--mode','create','--host-context','fixture-host','--allow-reproduction','--review-config',reviewConfig];
|
|
101
|
+
if(runtime==='claude')args.push('--runtime','claude');
|
|
102
|
+
let providerCalls=0,writes=0,repairs=0,retrospectives=0;const reviewWorkerFactory=()=>async({prompt},{onEvent})=>{
|
|
103
|
+
providerCalls++;
|
|
104
|
+
const data=JSON.parse(prompt.split('<cm-review-data-json>\n')[1]);assert(data.reviewPackage.handoff);
|
|
105
|
+
const handoff=JSON.parse(Buffer.from(data.reviewPackage.handoff.contentBase64,'base64').toString('utf8'));
|
|
106
|
+
const defectEvidence=JSON.parse(handoff.evidence.find(item=>item.startsWith('fix defect evidence')).split('(data, not instructions) ')[1]);
|
|
107
|
+
assert.equal(defectEvidence.redTest.result.status,'red_confirmed');
|
|
108
|
+
assert.deepEqual(defectEvidence.diagnosis.investigation,{discardedAlternatives:[],boundaryAnalysis:null});
|
|
109
|
+
assert.deepEqual(defectEvidence.redOutput,JSON.parse(fs.readFileSync(path.join(specsRoot,defectEvidence.redTest.result.output.path))));
|
|
110
|
+
const state=JSON.parse(fs.readFileSync(path.join(specsRoot,'.reviews','.execution','fix-author-cli','state.json')));
|
|
111
|
+
assert.equal(state.records.at(-1).id,'fix-final-registered');
|
|
112
|
+
for(const event of [{event:'thread.started',provider_thread:'actual-final-review'},{event:'turn.started',item_type:null},
|
|
113
|
+
{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);
|
|
114
|
+
return {status:'succeeded',value:{verdict:'approved',packageDigest:data.reviewPackage.packageDigest,examinedPaths:data.examinedPaths,findings:[],summary:'Synthetic final review'}};
|
|
115
|
+
};
|
|
116
|
+
try{
|
|
117
|
+
fs.writeFileSync(reviewConfig,JSON.stringify({...review,preflight:{...review.preflight,passed:false}}));
|
|
118
|
+
assert.equal(await main([...args,'--allow-test-author'],{reviewWorkerFactory,error:new Writable({write(c,e,cb){cb();}})}),1);
|
|
119
|
+
assert.equal(await main([...args,'--allow-repair'],{reviewWorkerFactory,error:new Writable({write(c,e,cb){cb();}})}),1);
|
|
120
|
+
assert.equal(await main([...args,'--allow-final-review'],{reviewWorkerFactory,error:new Writable({write(c,e,cb){cb();}})}),1);
|
|
121
|
+
assert(!fs.existsSync(path.join(specsRoot,'.reviews')));assert.equal(providerCalls,0);
|
|
122
|
+
fs.writeFileSync(reviewConfig,JSON.stringify(review));
|
|
123
|
+
for(const pass of ['denied','allowed','repair','regression','writeback','final','resume']){
|
|
124
|
+
args[4]=pass==='denied'?'create':'resume';
|
|
125
|
+
const input=new PassThrough(),rows=[];const operations=pass==='denied'?['advance','author_tests']:['author_tests','red_test','baseline','repair','regression','retrospective','learning_writeback','handoff','final_review','publish_review','check_n5','post_review_regression'];let index=0;
|
|
126
|
+
const next=()=>index<operations.length?input.write(JSON.stringify({requestId:operations[index],operation:operations[index++]})+'\n'):input.end();
|
|
127
|
+
const output=new Writable({write(chunk,enc,done){
|
|
128
|
+
const row=JSON.parse(chunk.toString());rows.push(row);if(row.type==='host_ready')setImmediate(next);
|
|
129
|
+
if(row.type==='host_request'){
|
|
130
|
+
let result=row.kind==='fix_learning'?{contextDigest:row.payload.contextDigest,status:'no_relevant_lesson',summary:'No instructions'}:
|
|
131
|
+
{status:'diagnosed',rootCause:'Wrong constant',plan:'Correct after test',affectedPaths:['value.mjs'],affectedModules:['value'],crossLayer:false,
|
|
132
|
+
investigation:{discardedAlternatives:[],boundaryAnalysis:null}};
|
|
133
|
+
if(row.kind==='fix_test_author'){
|
|
134
|
+
writes++;fs.writeFileSync(path.join(cwd,'regression.mjs'),"import {value} from './value.mjs';if(value!==2){console.error('BUG');process.exit(1)}");result={outcome:'authored'};
|
|
135
|
+
}
|
|
136
|
+
if(row.kind==='fix_repair'){repairs++;fs.writeFileSync(path.join(cwd,'value.mjs'),'export const value=2;');result={outcome:'repaired'};}
|
|
137
|
+
if(row.kind==='fix_retrospective'){retrospectives++;result={status:'lesson_candidate',candidates:[{classification:'structured',trigger:'Wrong constant',action:'Keep regression assertion',evidence:['regression.mjs']}],reason:null};}
|
|
138
|
+
input.write(JSON.stringify({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,result})+'\n');
|
|
139
|
+
}
|
|
140
|
+
if(Object.hasOwn(row,'requestId'))setImmediate(next);done();
|
|
141
|
+
}});
|
|
142
|
+
const flags=pass==='denied'?[]:pass==='repair'?['--allow-repair']:pass==='regression'?['--allow-regression']:pass==='writeback'?['--allow-learning-writeback']:pass==='final'?['--allow-final-review']:['--allow-test-author','--allow-red-test','--allow-baseline',...(pass==='resume'?['--allow-repair','--allow-regression','--allow-learning-writeback','--allow-final-review']:[])];
|
|
143
|
+
assert.equal(await main([...args,...flags],{input,output,error:output,reviewWorkerFactory}),0);
|
|
144
|
+
if(pass==='denied'){assert(rows.find(row=>row.requestId==='author_tests').error);assert.equal(writes,0);}
|
|
145
|
+
else{
|
|
146
|
+
assert.equal(writes,1);
|
|
147
|
+
if(pass==='allowed'){assert.equal(rows.find(row=>row.requestId==='baseline').result.stage,'repair_required');assert(rows.find(row=>row.requestId==='repair').error);assert.equal(repairs,0);}
|
|
148
|
+
else{
|
|
149
|
+
assert.equal(repairs,1);
|
|
150
|
+
if(pass==='repair'){assert.equal(rows.find(row=>row.requestId==='repair').result.stage,'regression_required');assert(rows.find(row=>row.requestId==='regression').error);}
|
|
151
|
+
else{
|
|
152
|
+
const resumedStage=pass==='resume'?'post_review_regression_required':pass==='final'?'final_review_required':null;
|
|
153
|
+
assert.equal(rows.find(row=>row.requestId==='regression').result.stage,resumedStage??(pass==='writeback'?'learning_writeback_required':'handoff_required'));
|
|
154
|
+
assert.equal(rows.find(row=>row.requestId==='retrospective').result.stage,resumedStage??'learning_writeback_required');assert.equal(retrospectives,1);
|
|
155
|
+
if(pass==='regression'){assert(rows.find(row=>row.requestId==='learning_writeback').error);assert(!fs.existsSync(path.join(cwd,'AGENTS.md')));}
|
|
156
|
+
else{
|
|
157
|
+
assert.equal(rows.find(row=>row.requestId==='learning_writeback').result.stage,resumedStage??'handoff_ready');
|
|
158
|
+
assert.equal(rows.find(row=>row.requestId==='handoff').result.stage,pass==='resume'?'post_review_regression_required':'final_review_required');assert(fs.existsSync(path.join(cwd,'AGENTS.md')));
|
|
159
|
+
if(pass==='writeback')assert.equal(rows.find(row=>row.requestId==='final_review').result.reason,'permission_denied');
|
|
160
|
+
if(pass==='final'||pass==='resume'){
|
|
161
|
+
assert.equal(rows.find(row=>row.requestId==='final_review').result.stage,pass==='resume'?'post_review_regression_required':'final_review_evidence_required');
|
|
162
|
+
assert.equal(rows.find(row=>row.requestId==='publish_review').result.stage,pass==='resume'?'post_review_regression_required':'completion_gate_required');
|
|
163
|
+
assert.equal(rows.find(row=>row.requestId==='publish_review').result.completionEligible,false);
|
|
164
|
+
assert.equal(rows.find(row=>row.requestId==='check_n5').result.stage,'post_review_regression_required');
|
|
165
|
+
if(pass==='final'){
|
|
166
|
+
assert.equal(rows.find(row=>row.requestId==='post_review_regression').error.code,'host_request_failed');
|
|
167
|
+
const state=JSON.parse(fs.readFileSync(path.join(specsRoot,'.reviews','.execution','fix-author-cli','state.json')));
|
|
168
|
+
assert(!state.records.some(record=>record.id==='fix-post-regression-intent'));
|
|
169
|
+
}
|
|
170
|
+
else{
|
|
171
|
+
assert.equal(rows.find(row=>row.requestId==='post_review_regression').result.stage,'closeout_required');
|
|
172
|
+
assert.equal(rows.find(row=>row.requestId==='post_review_regression').result.completionEligible,false);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
assert.equal(rows.find(row=>row.requestId==='regression').result.completionEligible,false);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
assert.equal(providerCalls,pass==='final'||pass==='resume'?1:0);
|
|
181
|
+
}
|
|
182
|
+
const reviewsDir=path.join(specsRoot,'.reviews'),reviewPath=path.join(reviewsDir,'fix-author-T-FIX-author-r1.md');
|
|
183
|
+
const gateOptions={reviewsDir,handoff:path.join(reviewsDir,'fix-author-T-FIX-author-a1-handoff.json'),feature:'fix-author',task:'T-FIX-author',projectRoot:cwd,requireLearning:true};
|
|
184
|
+
assert.doesNotThrow(()=>checkN4(gateOptions));
|
|
185
|
+
const bytes=fs.readFileSync(reviewPath),state=JSON.parse(fs.readFileSync(path.join(reviewsDir,'.execution','fix-author-cli','state.json')));
|
|
186
|
+
const saved=state.records[0].payload;
|
|
187
|
+
let owner=openFixExecution({specsRoot,identity:saved.identity,configuration:saved.configuration,create:false});
|
|
188
|
+
try{
|
|
189
|
+
const closed=owner.status();assert.equal(closed.stage,'closeout_required');assert.equal(closed.n5.gate.outcome,'approved');
|
|
190
|
+
assert.deepEqual(await owner.runRegression({authorized:true,postReview:true}),closed);
|
|
191
|
+
assert.throws(()=>owner.publishDossier(),{code:'walkthrough_required'});
|
|
192
|
+
await assert.rejects(()=>owner.runWalkthrough(),{code:'walkthrough_authorization_required'});
|
|
193
|
+
owner.close();const walkInput=new PassThrough(),walkRows=[];
|
|
194
|
+
const walkOutput=new Writable({write(chunk,encoding,done){
|
|
195
|
+
const row=JSON.parse(chunk.toString());walkRows.push(row);
|
|
196
|
+
if(row.type==='host_ready')walkInput.write(JSON.stringify({requestId:'walk',operation:'walkthrough'})+'\n');
|
|
197
|
+
if(row.requestId==='walk')walkInput.end();done();
|
|
198
|
+
}});
|
|
199
|
+
assert.equal(await main([...args,'--allow-walkthrough'],{input:walkInput,output:walkOutput,error:walkOutput,reviewWorkerFactory}),0);
|
|
200
|
+
const walked=walkRows.find(row=>row.requestId==='walk').result;assert.equal(walked.walkthrough.status,'passed');assert.equal(walked.completionEligible,false);
|
|
201
|
+
owner=openFixExecution({specsRoot,identity:saved.identity,configuration:saved.configuration,create:false});
|
|
202
|
+
// executionActive is host-local, not persisted with the completed walk.
|
|
203
|
+
assert.equal(owner.status().executionActive,false);
|
|
204
|
+
assert.deepEqual(await owner.runWalkthrough({authorized:true}),{...walked,executionActive:false});
|
|
205
|
+
const archived=owner.publishDossier();assert.equal(archived.stage,'closeout_required');assert.equal(archived.completionEligible,false);
|
|
206
|
+
const dossierBytes=fs.readFileSync(archived.dossier.path);
|
|
207
|
+
assert.equal(fs.statSync(archived.dossier.path).mode&0o777,0o600);
|
|
208
|
+
assert.match(dossierBytes.toString(),/关键流程走查/);assert.match(dossierBytes.toString(),/stdoutBase64/);
|
|
209
|
+
assert.match(dossierBytes.toString(),/诊断记录明确未放弃其他方案/);assert(!dossierBytes.toString().includes('放弃方案:当前宿主记录未提供'));
|
|
210
|
+
assert.deepEqual(owner.publishDossier(),archived);
|
|
211
|
+
fs.renameSync(archived.dossier.path,path.join(root,'saved-dossier.md'));
|
|
212
|
+
assert.deepEqual(owner.publishDossier(),archived);assert.deepEqual(fs.readFileSync(archived.dossier.path),dossierBytes);
|
|
213
|
+
fs.appendFileSync(archived.dossier.path,'conflict');assert.throws(()=>owner.publishDossier(),{code:'review_file_conflict'});
|
|
214
|
+
fs.renameSync(reviewPath,path.join(root,'saved-review.md'));assert.equal(owner.status().stage,'final_review_evidence_required');
|
|
215
|
+
assert.throws(()=>owner.publishDossier(),{code:'fix_closeout_unavailable'});
|
|
216
|
+
assert.equal(owner.publishReview().stage,'closeout_required');assert.deepEqual(fs.readFileSync(reviewPath),bytes);assert.equal(providerCalls,1);
|
|
217
|
+
const logs=fs.readFileSync(path.join(specsRoot,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
218
|
+
assert(logs.every(row=>row.runtime===runtime));
|
|
219
|
+
const routes=logs.filter(row=>row.event==='decision'&&row.phase==='route');
|
|
220
|
+
assert.equal(routes.length,3);
|
|
221
|
+
for(const row of routes){
|
|
222
|
+
const expected=resolveRole(loadConfig({projectRoot:cwd}),row.role,runtime);
|
|
223
|
+
assert.equal(row.adapter,expected.adapter);assert.equal(row.route_state,expected.route_state);
|
|
224
|
+
}
|
|
225
|
+
const reviews=logs.filter(row=>row.event==='review');assert.equal(reviews.length,1);
|
|
226
|
+
assert.equal(reviews[0].node,'FIX');assert.equal(reviews[0].result,'approved');assert.equal(reviews[0].package_digest,walked.n5.packageDigest);
|
|
227
|
+
assert.equal(reviews[0].provider,runtime);
|
|
228
|
+
assert(bytes.toString().includes(`reviewer: ${runtime}-cli`));
|
|
229
|
+
assert.equal(logs.filter(row=>row.event==='task_start').length,1);
|
|
230
|
+
assert(!logs.some(row=>['task_done','run_done'].includes(row.event)));
|
|
231
|
+
fs.appendFileSync(reviewPath,'conflicting bytes');assert.equal(owner.status().stage,'final_review_evidence_required');
|
|
232
|
+
assert.throws(()=>owner.publishReview(),{code:'review_file_conflict'});assert.equal(owner.status().finalReview.review.verdict,'approved');
|
|
233
|
+
fs.writeFileSync(reviewPath,bytes);fs.writeFileSync(archived.dossier.path,dossierBytes);
|
|
234
|
+
assert.throws(()=>owner.finish(),{code:'fix_finish_authorization_required'});
|
|
235
|
+
fs.writeFileSync(path.join(specsRoot,'METRICS.md'),'User custom table, not recognized.\n');
|
|
236
|
+
assert.throws(()=>owner.finish({authorized:true}),{code:'metrics_table_invalid'});
|
|
237
|
+
assert.equal(owner.status().stage,'closeout_incomplete');assert.equal(owner.status().completionHistory.taskDoneEventIds.length,1);
|
|
238
|
+
owner.close();owner=openFixExecution({specsRoot,identity:saved.identity,configuration:saved.configuration,create:false});
|
|
239
|
+
assert.equal(owner.status().stage,'closeout_incomplete');
|
|
240
|
+
fs.renameSync(path.join(specsRoot,'METRICS.md'),path.join(root,'user-metrics.md'));
|
|
241
|
+
owner.close();const finishInput=new PassThrough(),finishRows=[];
|
|
242
|
+
const finishOutput=new Writable({write(chunk,encoding,done){
|
|
243
|
+
const row=JSON.parse(chunk.toString());finishRows.push(row);
|
|
244
|
+
if(row.type==='host_ready')finishInput.write(JSON.stringify({requestId:'finish',operation:'finish'})+'\n');
|
|
245
|
+
if(row.requestId==='finish')finishInput.end();done();
|
|
246
|
+
}});
|
|
247
|
+
assert.equal(await main([...args,'--allow-finish'],{input:finishInput,output:finishOutput,error:finishOutput,reviewWorkerFactory}),0);
|
|
248
|
+
const completed=finishRows.find(row=>row.requestId==='finish').result;assert.equal(completed.stage,'completed');assert.equal(completed.completionEligible,true);
|
|
249
|
+
owner=openFixExecution({specsRoot,identity:saved.identity,configuration:saved.configuration,create:false});
|
|
250
|
+
assert.deepEqual(owner.status(),completed);assert.deepEqual(owner.finish({authorized:true}),completed);
|
|
251
|
+
assert.equal(fixCompletionProjection({specsRoot,identity:saved.identity,status:{...completed,stage:'closeout_required',completionEligible:false,walkthrough:null}}).stage,'closeout_incomplete');
|
|
252
|
+
const finalLogs=fs.readFileSync(path.join(specsRoot,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
253
|
+
assert(finalLogs.every(row=>row.runtime===runtime));
|
|
254
|
+
assert.equal(finalLogs.filter(row=>row.event==='task_done').length,1);assert.equal(finalLogs.filter(row=>row.event==='run_done').length,1);
|
|
255
|
+
assert.match(fs.readFileSync(archived.dossier.path,'utf8'),/验证收口/);assert.equal(providerCalls,1);
|
|
256
|
+
fs.appendFileSync(path.join(cwd,'value.mjs'),' ');assert.equal(owner.status().stage,'learning_writeback_evidence_required');
|
|
257
|
+
assert.deepEqual(owner.status().completionHistory,completed.completionHistory);assert.equal(owner.status().completionEligible,false);
|
|
258
|
+
}finally{owner.close();}
|
|
259
|
+
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import {createFixHost} from '../runtime/js/cm-fix/host.mjs';
|
|
4
|
+
|
|
5
|
+
test('continuous fix keeps individual action authorization',async()=>{
|
|
6
|
+
let repairs=0;
|
|
7
|
+
const owner={status:()=>({stage:'repair_required'}),repair:({authorized})=>{
|
|
8
|
+
repairs++;assert.equal(authorized,false);throw Object.assign(Error('No repair grant'),{code:'fix_repair_authorization_required'});
|
|
9
|
+
}};
|
|
10
|
+
const host=createFixHost({owner,config:{},permissions:['--allow-reproduction']});
|
|
11
|
+
await assert.rejects(host.run('sequence'),{code:'fix_repair_authorization_required'});
|
|
12
|
+
assert.equal(repairs,1);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('continuous fix stops at unchanged or blocked stage',async()=>{
|
|
16
|
+
let redTests=0;
|
|
17
|
+
const status={stage:'red_test_required'};
|
|
18
|
+
const host=createFixHost({owner:{status:()=>status,runRedTest:({authorized})=>{
|
|
19
|
+
assert.equal(authorized,true);redTests++;return status;
|
|
20
|
+
}},config:{},permissions:['--allow-reproduction','--allow-red-test']});
|
|
21
|
+
assert.deepEqual(await host.run('sequence'),status);assert.equal(redTests,1);
|
|
22
|
+
for(const stage of ['unknown','cancelled','observation','final_review_changes_requested','revision_prepared']){
|
|
23
|
+
const blocked=createFixHost({owner:{status:()=>({stage})},config:{},permissions:['--allow-reproduction']});
|
|
24
|
+
assert.deepEqual(await blocked.run('sequence'),{stage});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Opt-in fix stages; cause review dispatch needs explicit launch authority and matching diagnostics.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import {fileURLToPath} from 'node:url';
|
|
5
|
+
import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
|
|
6
|
+
import {createFixHost} from '../runtime/js/cm-fix/host.mjs';
|
|
7
|
+
import {createFixLearningPreparation} from '../runtime/js/cm-fix/learning.mjs';
|
|
8
|
+
import {createHostToolBridge} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
9
|
+
import {serveCmAiHost} from '../runtime/js/cm-ai/host-session.mjs';
|
|
10
|
+
import {id,json,need,shape,digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
11
|
+
import {readConversationReviewConfiguration} from './cm-ai-host.mjs';
|
|
12
|
+
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
13
|
+
|
|
14
|
+
const usage='cm-fix-host.mjs serve --config PATH --mode create|resume --host-context ID --allow-reproduction [--runtime codex|claude] [--review-config PATH] [--allow-cause-review] [--allow-final-review] [--allow-test-author] [--allow-red-test] [--allow-baseline] [--allow-repair] [--allow-regression] [--allow-learning-writeback]\nCodex or Claude current-host operations: advance, cause_review_package, cause_review, author_tests, red_test, baseline, repair, regression, retrospective, learning_writeback, handoff, final_review_package, final_review, publish_review, check_n5, post_review_regression, status, cancel. Runtime defaults to codex; claude uses its own matching diagnostic receipt and cannot reuse Codex preflight or disabledSkills settings. Runtime selection is bound to recovery; switching providers requires a separate run. This selects existing adapters, not permission to call them. Each write/check needs its respective launch flag and configuration. Test authoring, repair, cause and final review dispatch require matching existing stdin diagnostics; diagnostic alone is not authorization. Passing regression stops at handoff_required. The read-only retrospective operation yields handoff_ready or learning_writeback_required. learning_writeback requires its own flag, preserves project instructions and includes AGENTS.md in the review scope; it does not authorize provider calls. handoff publishes the fixed specs-local handoff with Learning evidence and moves to final_review_required; no provider is called and no task is completed. final_review_package is read-only and returns the final content-bound review package. final_review requires its own flag and matching diagnostics; observations do not complete the task. publish_review projects the registered result into the existing review file; it does not dispatch or complete tasks. check_n5 runs the original Learning-aware gate; post_review_regression requires --allow-regression and reaches closeout_required, not completion.';
|
|
15
|
+
|
|
16
|
+
export async function main(argv=process.argv.slice(2),{input=process.stdin,output=process.stdout,error=process.stderr,reviewWorkerFactory=null}={}){
|
|
17
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Omit specsRoot or use null for a bare project: the same owner stores archives in docs/fixes and reviews in docs/fixes/.reviews, uses the original no-specs log mode, and skips METRICS. No specs skeleton is created. Visual-only reproduction/redTest may use kind:visual with cwd, timeoutMs, before:{path,sha256,kind:screenshot|video,description}, reason explaining why automated red cannot be written, environment, steps and expected; redTest also has testFiles:[]. No testAuthor or fake red/green command. Repair/regression/review/finish permissions remain mandatory. qa_browser returns actual after carrier metadata; missing evidence blocks.\n');
|
|
18
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Optional startup configuration protectSpecs:true uses the existing Codex native sandbox for reproduction, red/baseline/regression/walkthrough commands and fixed text edits, without a model call. Requires the local sandbox executable; it does not change the current Codex/Claude host or reviewer identity. Original action permissions remain required. fix_test_author/fix_repair with editMode=protected-text-v1 require {outcome,edits:[{path,beforeSha256,content}]} using the supplied scope/expected hashes; never write directly. Content is full UTF-8 text or null for deletion, blocked requires edits:[]. Original 64KiB response limit applies. Drift or failed writes retain the original unknown boundary; no automatic retry/rollback or protection-mode switching on resume.\n');
|
|
19
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('completion_evidence is read-only and available only after the original finish has completed and current evidence still validates. It returns the selected attempt, original reviewed package, handoff/review digests, completion event IDs and optional qaSource from the original owner. It does not complete or resume a parent task; JSON evidence alone is not authority.\n');
|
|
20
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('recover_final_review requires --allow-final-review-recovery and exact latest invocationId/packageDigest, previousInvocationStopped:true, and a nonempty reason. The legacy first continuation remains once-only. A further continuation additionally requires a fresh startup --final-review-recovery-invocation ID matching the latest unknown invocation, authorizing exactly one new call. Confirm the previous process stopped; this is a trusted host acknowledgment, not an automatic liveness check. Preparation dispatches nothing. Later final_review requires recovery permission and --allow-final-review; additional cycles require the same invocation binding after restart. Old records, task attempt, reviewed package and the original Review/N5/finish remain unchanged. No automatic retry, cancelled/complete-verdict recovery, missing-thread recovery, business-revision recovery or source-drift bypass. status adds a read-only progress projection, not authorization or current-source verification.\n');
|
|
21
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('N6 child configuration may include qaSource {feature, identity, packageDigest, testRunId, handoffDigest}; derive the separate fixed child identity with qaFixIdentity. It requires --allow-qa-fix in addition to existing action flags. Close the parent host first: the original specs-wide owner lock is shared. Creation/resume rechecks the current failed round, project, report and policy; the source is bound to the original fix configuration. This does not resume the parent or automatically rerun QA, and does not authorize provider calls, installation or Git.\n');
|
|
22
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Second-round retrospective uses the cumulative original baseline, including previously authored tests and Learning scope. It persists the current round reflection and reaches revision_handoff_ready or revision_learning_writeback_required; neither state completes the task or publishes a new handoff. From revision_handoff_ready, handoff publishes a separate a2 handoff containing cumulative changes, current reflection, original red evidence and prior review/Learning history; final_review_package then reads that bound package. Pending Learning blocks publication. final_review requires --allow-final-review, uses fresh-thread exclusions and carries prior findings; publish_review writes the original r2 evidence and review log, and check_n5 runs the original Learning-aware gate. Approval reaches revision_post_review_regression_required, not completion.\n');
|
|
23
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('prepare_revision requires --allow-repair and either a published first-round changes_requested review or an approved first-round review followed by a package-bound walkthrough result of failed. The latter preserves the approved verdict and carries separate walkthrough failure evidence; passed, blocked, unknown, or drifted evidence cannot authorize this repair. An approved first-round review followed by package-bound post-review regression defect_remaining or regressed can also prepare the second repair when all baseline commands produced complete results. The regression commands must match the first reviewed handoff; passed, inconclusive, unavailable or partial evidence is refused. Regression and walkthrough failure feedback are mutually exclusive and neither replaces the next independent review. It rereads project Learning and persists the second-round preparation in the original store, preserving first-round evidence. repair then uses the original business scope and findings with separate second-round records. regression requires --allow-regression and reruns the original test commands against the second repair, preserving the original red evidence. Success reaches revision_handoff_required, not completion; handoff and final_review use the second-round package; review evidence publication and N5 are connected; post_review_regression requires --allow-regression and reaches revision_closeout_required after the original checks; walkthrough requires --allow-walkthrough and binds the second-round package and identity; finish reuses the original closeout with --allow-finish and delivery:diff, preserving first-round history and recording completion for attempt 2. Second-round learning_writeback requires --allow-learning-writeback, includes the resulting AGENTS.md in the cumulative review package and preserves prior Learning history; pending or unknown writeback cannot advance to handoff. A lost repair or regression result stays unknown and is not redispatched.\n');
|
|
24
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\nAdditional operation: publish_dossier writes a private immutable fixes/YYYYMMDD-slug.md closeout snapshot; missing evidence is explicit and the task remains incomplete. In observation it writes the recorded reproduction summary and expected evidence to the same fixes archive, preserving its date across restart and refusing user-content conflicts; it does not repair or complete the task. In observation, finish with --allow-finish records run_done as observing and releases the owner lock without task_done or metrics; end the existing transport with host_close or EOF. resume accepts evidenceFiles (1-3 explicit specs-local files) and binds them to the prior observing exit and dossier without resetting task attempt. It reaches observation_resume_prepared; evidence drift blocks continuation. advance from prepared rereads Learning and reruns the original reproduction command, then passes selected evidence references to the original diagnosis capability. Recovery uses separate records without resetting attempt; unknown outcomes are not redispatched. Unreproduced, blocked or still-insufficient evidence stays incomplete. Before resumed execution, the original resume log binds the observation exit and selected evidence digests, restoring the same run to running without a new task start. Recovered handoffs bind exact selected evidence bytes and pre-observation history under the original size and review gates; legacy recovered handoffs lacking that material remain readable but cannot claim current review coverage. Recovered closeout preserves the exact observation archive prefix and original filename, appends the recovery results, and uses the existing finish gate; user-modified continuations are refused. If recovery still cannot reproduce the defect or diagnosis still needs evidence, publish_dossier appends the latest observation and authorized finish records a second bound observing exit without task completion or metrics. After a recorded observing exit, resume can bind another explicit evidence selection to the latest exit and archive. Observation cycles retain prior records and archive bytes, do not reset task attempts or review rounds, and require separately authorized advance; unknown outcomes are not retried. Multi-cycle handoffs include the exact prior archive under the original size limit. walkthrough requires configured module-mapped flows and --allow-walkthrough; it runs declared commands or uses existing qa_browser/qa_logic host capabilities. Static support cannot pass a walkthrough. Browser execution remains limited to the authorized current-host environment; no install or provider authority is implied.\nRepair completion via finish requires --allow-finish, existing delivery:diff, reviewed diagnosis, modern handoff and passed walkthrough. It rechecks the original N5 gate, finalizes the generated dossier, records reviewed lessons, task_done, metrics and run_done. It resumes partial closeout without redispatch and refuses user-modified dossier conflicts. Branch/MR delivery still requires separate authorization; this command does not execute Git.\n');return 0;}
|
|
25
|
+
let owner,bridge;
|
|
26
|
+
try{
|
|
27
|
+
need(argv.length>=8&&argv[0]==='serve'&&argv[1]==='--config'&&argv[3]==='--mode'
|
|
28
|
+
&&argv[5]==='--host-context'&&argv[7]==='--allow-reproduction','host_launch_authorization_required');
|
|
29
|
+
need(['create','resume'].includes(argv[4]),'invalid_arguments');id(argv[6]);
|
|
30
|
+
const extra=new Map();
|
|
31
|
+
for(let index=8;index<argv.length;index++){
|
|
32
|
+
const flag=argv[index];need(!extra.has(flag)&&['--runtime','--review-config','--final-review-recovery-invocation','--allow-qa-fix','--allow-cause-review','--allow-final-review','--allow-final-review-recovery','--allow-red-test','--allow-baseline','--allow-test-author','--allow-repair','--allow-regression','--allow-learning-writeback','--allow-walkthrough','--allow-finish'].includes(flag),'invalid_arguments');
|
|
33
|
+
if(flag.startsWith('--allow-'))extra.set(flag,true);
|
|
34
|
+
else{need(typeof argv[index+1]==='string'&&!argv[index+1].startsWith('--'),'invalid_arguments');extra.set(flag,argv[++index]);}
|
|
35
|
+
}
|
|
36
|
+
const recoveryInvocationId=extra.get('--final-review-recovery-invocation')??null;
|
|
37
|
+
if(recoveryInvocationId!==null){id(recoveryInvocationId);need(extra.has('--allow-final-review-recovery'),'fix_review_recovery_authorization_required');}
|
|
38
|
+
const runtime=extra.get('--runtime')??'codex';need(['codex','claude'].includes(runtime),'invalid_runtime');
|
|
39
|
+
const review=extra.has('--review-config')?readConversationReviewConfiguration(extra.get('--review-config')):null;
|
|
40
|
+
need(runtime!=='claude'||!review||review.disabledSkills.length===0,'invalid_review_config');
|
|
41
|
+
need(!extra.has('--allow-cause-review')||review!==null,'review_configuration_required');
|
|
42
|
+
need(!extra.has('--allow-final-review')||review!==null,'review_configuration_required');
|
|
43
|
+
const stat=fs.lstatSync(argv[2]);
|
|
44
|
+
need(stat.isFile()&&!stat.isSymbolicLink()&&stat.size<=64*1024,'invalid_fix_config');
|
|
45
|
+
const config=json(JSON.parse(fs.readFileSync(argv[2],'utf8')),64*1024);
|
|
46
|
+
shape(config,['identity','defect','reproduction',...(Object.hasOwn(config,'specsRoot')?['specsRoot']:[]),...(Object.hasOwn(config,'applicableAgentFiles')?['applicableAgentFiles']:[]),
|
|
47
|
+
...(Object.hasOwn(config,'protectSpecs')?['protectSpecs']:[]),
|
|
48
|
+
...(Object.hasOwn(config,'qaSource')?['qaSource']:[]),
|
|
49
|
+
...(Object.hasOwn(config,'redTest')?['redTest']:[]),...(Object.hasOwn(config,'baseline')?['baseline']:[]),
|
|
50
|
+
...(Object.hasOwn(config,'testAuthor')?['testAuthor']:[]),...(Object.hasOwn(config,'repair')?['repair']:[]),...(Object.hasOwn(config,'walkthrough')?['walkthrough']:[])]);
|
|
51
|
+
need(!extra.has('--allow-walkthrough')||config.walkthrough,'walkthrough_configuration_required');
|
|
52
|
+
need(!Object.hasOwn(config,'qaSource')||extra.has('--allow-qa-fix'),'qa_fix_authorization_required');
|
|
53
|
+
need(!extra.has('--allow-qa-fix')||Object.hasOwn(config,'qaSource'),'qa_fix_source_required');
|
|
54
|
+
need(!extra.has('--allow-red-test')||config.redTest,'red_test_configuration_required');
|
|
55
|
+
need(!extra.has('--allow-baseline')||config.baseline,'baseline_configuration_required');
|
|
56
|
+
need(!extra.has('--allow-test-author')||(config.testAuthor&&review),'test_author_configuration_required');
|
|
57
|
+
need(!extra.has('--allow-repair')||(config.repair&&review),'repair_configuration_required');
|
|
58
|
+
need(!extra.has('--allow-regression')||(config.repair&&config.redTest&&config.baseline),'regression_configuration_required');
|
|
59
|
+
const {reviewer,authority,finalAuthority,execution:reviewExecution}=createFixReviewHost({
|
|
60
|
+
codeProject:config.reproduction.cwd,hostContextId:argv[6],runtime,review,
|
|
61
|
+
permissions:[...extra.keys()],workerFactory:reviewWorkerFactory});
|
|
62
|
+
bridge=createHostToolBridge();
|
|
63
|
+
owner=openFixExecution({specsRoot:config.specsRoot??null,identity:config.identity,create:argv[4]==='create',
|
|
64
|
+
configuration:{hostContextId:argv[6],defect:config.defect,reproduction:config.reproduction,
|
|
65
|
+
...(Object.hasOwn(config,'protectSpecs')?{protectSpecs:config.protectSpecs}:{}),
|
|
66
|
+
...(Object.hasOwn(config,'qaSource')?{qaSource:config.qaSource}:{}),
|
|
67
|
+
...(runtime==='claude'?{runtime}:{}),
|
|
68
|
+
...(reviewer?{causeReview:reviewer}:{}),
|
|
69
|
+
...(Object.hasOwn(config,'redTest')?{redTest:config.redTest}:{}),
|
|
70
|
+
...(Object.hasOwn(config,'baseline')?{baseline:config.baseline}:{}),
|
|
71
|
+
...(Object.hasOwn(config,'testAuthor')?{testAuthor:config.testAuthor}:{}),
|
|
72
|
+
...(Object.hasOwn(config,'repair')?{repair:config.repair}:{}),
|
|
73
|
+
...(Object.hasOwn(config,'walkthrough')?{walkthrough:config.walkthrough}:{}),
|
|
74
|
+
...(Object.hasOwn(config,'applicableAgentFiles')?{applicableAgentFiles:config.applicableAgentFiles}:{})}},{bridge,
|
|
75
|
+
...reviewExecution,
|
|
76
|
+
prepare:createFixLearningPreparation({bridge,codeProject:config.reproduction.cwd,
|
|
77
|
+
applicableAgentFiles:config.applicableAgentFiles??[]})});
|
|
78
|
+
const host=createFixHost({owner,config,runtime,permissions:[...extra.keys(),'--allow-reproduction'],authority,finalAuthority,recoveryInvocationId});
|
|
79
|
+
const rawMode=input.isTTY&&typeof input.setRawMode==='function';
|
|
80
|
+
if(rawMode)input.setRawMode(true);
|
|
81
|
+
try{await serveCmAiHost({host,input,output,toolBridge:bridge});}
|
|
82
|
+
finally{if(rawMode)input.setRawMode(false);}
|
|
83
|
+
return 0;
|
|
84
|
+
}catch(cause){
|
|
85
|
+
const code=typeof cause?.code==='string'&&/^[a-z][a-z0-9_]{0,63}$/.test(cause.code)?cause.code:'fix_host_failed';
|
|
86
|
+
error.write(JSON.stringify({error:{code}})+'\n');return 1;
|
|
87
|
+
}finally{bridge?.close();owner?.close();}
|
|
88
|
+
}
|
|
89
|
+
if(process.argv[1]&&fs.realpathSync(process.argv[1])===fileURLToPath(import.meta.url))process.exitCode=await main();
|
|
@@ -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 {PassThrough,Writable} from 'node:stream';
|
|
7
|
+
import {main} from './cm-fix-host.mjs';
|
|
8
|
+
import {startFixRun} from '../runtime/js/cm-fix/start.mjs';
|
|
9
|
+
|
|
10
|
+
test('fix CLI requires launch authorization and uses duplex diagnosis, resume and original store',async()=>{
|
|
11
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-fix-cli-')));
|
|
12
|
+
const specsRoot=path.join(root,'specs'),cwd=path.join(root,'code');fs.mkdirSync(specsRoot);fs.mkdirSync(cwd);
|
|
13
|
+
fs.writeFileSync(path.join(cwd,'AGENTS.md'),'Verify exact failure before modifying code.');
|
|
14
|
+
const config=path.join(root,'config.json');
|
|
15
|
+
fs.writeFileSync(config,JSON.stringify({specsRoot,identity:{repositoryId:'fixture',runId:'fix-cli-run',taskId:'T-FIX-cli',attempt:1},
|
|
16
|
+
defect:'Synthetic defect',reproduction:{cwd,command:[process.execPath,'-e',
|
|
17
|
+
"require('node:fs').appendFileSync('visits','1');process.stderr.write('BUG');process.exit(3)"],
|
|
18
|
+
expectedFailure:{exitCode:3,outputIncludes:'BUG'},timeoutMs:2000}}));
|
|
19
|
+
try{
|
|
20
|
+
const args=['serve','--config',config,'--mode','create','--host-context','fixture-host','--allow-reproduction'];
|
|
21
|
+
assert.equal(await main(args.slice(0,-1),{error:new Writable({write(c,e,cb){cb();}})}),1);
|
|
22
|
+
assert.equal(fs.existsSync(path.join(specsRoot,'.reviews')),false);
|
|
23
|
+
const definition=JSON.parse(fs.readFileSync(config,'utf8'));
|
|
24
|
+
const startOptions={specsRoot,identity:definition.identity,configuration:{reproduction:definition.reproduction}};
|
|
25
|
+
const badConfig=path.join(cwd,'.cm-workflow.json');fs.writeFileSync(badConfig,'{');
|
|
26
|
+
assert.throws(()=>startFixRun(startOptions),{code:'invalid_workflow_config'});
|
|
27
|
+
assert.equal(fs.existsSync(path.join(specsRoot,'运行日志.jsonl')),false);
|
|
28
|
+
assert.equal(fs.existsSync(path.join(cwd,'visits')),false);fs.unlinkSync(badConfig);
|
|
29
|
+
for(const mode of ['create','resume']){
|
|
30
|
+
args[4]=mode;const input=new PassThrough();let calls=0;const replies=[];
|
|
31
|
+
const output=new Writable({write(chunk,encoding,callback){
|
|
32
|
+
const row=JSON.parse(chunk.toString());replies.push(row);
|
|
33
|
+
if(row.type==='host_ready')input.write(JSON.stringify({requestId:'advance',operation:'advance'})+'\n');
|
|
34
|
+
if(row.type==='host_request'){
|
|
35
|
+
if(row.kind==='fix_learning'){
|
|
36
|
+
assert.equal(row.payload.context[0].content,'Verify exact failure before modifying code.');
|
|
37
|
+
input.write(JSON.stringify({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,
|
|
38
|
+
result:{contextDigest:row.payload.contextDigest,status:'applied',summary:'AGENTS.md: verify exact exit and signature before repair'}})+'\n');
|
|
39
|
+
callback();return;
|
|
40
|
+
}
|
|
41
|
+
calls++;assert.equal(row.kind,'fix_diagnose');
|
|
42
|
+
input.write(JSON.stringify({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,
|
|
43
|
+
result:{status:'diagnosed',rootCause:'Fixture constant',affectedPaths:['value.mjs'],affectedModules:['value'],
|
|
44
|
+
plan:'Correct after red test',crossLayer:false}})+'\n');
|
|
45
|
+
}
|
|
46
|
+
if(row.requestId==='advance')setImmediate(()=>input.write(JSON.stringify({requestId:'complete',operation:'complete'})+'\n'));
|
|
47
|
+
if(row.requestId==='complete')input.end();
|
|
48
|
+
callback();
|
|
49
|
+
}});
|
|
50
|
+
assert.equal(await main(args,{input,output,error:output}),0);
|
|
51
|
+
assert.equal(calls,mode==='create'?1:0);
|
|
52
|
+
assert.equal(replies.find(row=>row.requestId==='advance').result.stage,'red_test_required');
|
|
53
|
+
assert.equal(replies.find(row=>row.requestId==='advance').result.completionEligible,false);
|
|
54
|
+
assert.equal(replies.find(row=>row.requestId==='advance').result.learning.application.status,'applied');
|
|
55
|
+
assert.equal(replies.find(row=>row.requestId==='complete').error.code,'host_request_failed');
|
|
56
|
+
assert.equal(fs.readFileSync(path.join(cwd,'visits'),'utf8'),'1');
|
|
57
|
+
startFixRun(startOptions); // Interrupted startup replay deduplicates original events.
|
|
58
|
+
const events=fs.readFileSync(path.join(specsRoot,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
59
|
+
assert.equal(events.filter(row=>row.event==='run_start').length,1);
|
|
60
|
+
assert.equal(events.filter(row=>row.event==='task_start'&&row.node==='FIX').length,1);
|
|
61
|
+
assert.equal(events.filter(row=>row.event==='decision'&&row.phase==='route').length,3);
|
|
62
|
+
assert.equal(events.some(row=>row.event==='run_done'),false);
|
|
63
|
+
}
|
|
64
|
+
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('fix CLI red and baseline flags authorize separate real commands across resume',{timeout:15000},async()=>{
|
|
68
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-cli-checks-')));
|
|
69
|
+
const cwd=path.join(root,'code'),specsRoot=path.join(root,'specs');fs.mkdirSync(cwd);fs.mkdirSync(specsRoot);
|
|
70
|
+
fs.writeFileSync(path.join(cwd,'red.mjs'),"import fs from 'node:fs';fs.appendFileSync('red-calls','1');console.error('BUG');process.exit(1)");
|
|
71
|
+
fs.writeFileSync(path.join(cwd,'existing.mjs'),"import fs from 'node:fs';fs.appendFileSync('baseline-calls','1')");
|
|
72
|
+
const config=path.join(root,'config.json');
|
|
73
|
+
fs.writeFileSync(config,JSON.stringify({specsRoot,identity:{repositoryId:'fixture',runId:'cli-checks',taskId:'T-FIX-checks',attempt:1},defect:'Synthetic',
|
|
74
|
+
reproduction:{cwd,command:[process.execPath,'-e',"console.error('BUG');process.exit(1)"],expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000},
|
|
75
|
+
redTest:{cwd,testFiles:['red.mjs'],command:[process.execPath,'red.mjs'],expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000},
|
|
76
|
+
baseline:{cwd,testFiles:['existing.mjs'],commands:[{id:'existing',command:[process.execPath,'existing.mjs']}],timeoutMs:2000}}));
|
|
77
|
+
try{
|
|
78
|
+
for(const [index,flags] of [[],['--allow-red-test'],['--allow-baseline'],['--allow-red-test','--allow-baseline']].entries()){
|
|
79
|
+
const input=new PassThrough(),rows=[],errors=[];let cursor=0;
|
|
80
|
+
const ops=index===0?['advance','red_test','baseline']:['red_test','baseline'];
|
|
81
|
+
const next=()=>cursor<ops.length?input.write(JSON.stringify({requestId:ops[cursor],operation:ops[cursor++]})+'\n'):input.end();
|
|
82
|
+
const output=new Writable({write(chunk,encoding,callback){
|
|
83
|
+
const row=JSON.parse(chunk.toString());rows.push(row);
|
|
84
|
+
if(row.type==='host_ready')setImmediate(next);
|
|
85
|
+
if(row.type==='host_request'){
|
|
86
|
+
const result=row.kind==='fix_learning'?{contextDigest:row.payload.contextDigest,status:'no_relevant_lesson',summary:'No relevant lesson'}:
|
|
87
|
+
{status:'diagnosed',rootCause:'Wrong constant',affectedPaths:['red.mjs'],affectedModules:['one'],plan:'Correct constant',crossLayer:false};
|
|
88
|
+
input.write(JSON.stringify({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,result})+'\n');
|
|
89
|
+
}
|
|
90
|
+
if(Object.hasOwn(row,'requestId'))setImmediate(next);callback();
|
|
91
|
+
}});
|
|
92
|
+
const code=await main(['serve','--config',config,'--mode',index===0?'create':'resume','--host-context','fixture-host','--allow-reproduction',...flags],
|
|
93
|
+
{input,output,error:new Writable({write(chunk,encoding,cb){errors.push(chunk.toString());cb();}})});
|
|
94
|
+
assert.equal(code,0,errors.join(''));
|
|
95
|
+
const red=rows.find(row=>row.requestId==='red_test'),baseline=rows.find(row=>row.requestId==='baseline');
|
|
96
|
+
if(index===0){assert(red.error);assert.equal(baseline.result.stage,'red_test_required');}
|
|
97
|
+
if(index===1){assert.equal(red.result.stage,'baseline_required');assert(baseline.error);}
|
|
98
|
+
if(index>=2){assert.equal(baseline.result.stage,'repair_required');assert.equal(baseline.result.completionEligible,false);}
|
|
99
|
+
assert.equal(fs.existsSync(path.join(cwd,'red-calls')),index>0);
|
|
100
|
+
assert.equal(fs.existsSync(path.join(cwd,'baseline-calls')),index>1);
|
|
101
|
+
}
|
|
102
|
+
assert.equal(fs.readFileSync(path.join(cwd,'red-calls'),'utf8'),'1');
|
|
103
|
+
assert.equal(fs.readFileSync(path.join(cwd,'baseline-calls'),'utf8'),'1');
|
|
104
|
+
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
105
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
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 {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
8
|
+
import {captureReviewBaseline,createReviewPackage} from '../runtime/js/cm-ai/review-package.mjs';
|
|
9
|
+
import {prepareFixLearningWriteback,fixLearningReviewBaseline,inspectFixLearningReviewPackage} from '../runtime/js/cm-fix/learning-writeback.mjs';
|
|
10
|
+
|
|
11
|
+
test('fix writeback reuses the existing merge, requires registration and preserves pending versus written',()=>{
|
|
12
|
+
for(const status of ['no_new_lesson','lesson_candidate','writeback_pending']){
|
|
13
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-learning-writeback-')));
|
|
14
|
+
try{
|
|
15
|
+
const original='# Project\n\nKeep this instruction.\n';fs.writeFileSync(path.join(root,'AGENTS.md'),original);
|
|
16
|
+
fs.writeFileSync(path.join(root,'value.mjs'),'export const value=1;');
|
|
17
|
+
const identity={repositoryId:'fixture',runId:'writeback',taskId:'T-FIX-demo',attempt:1};
|
|
18
|
+
const files=[{scope:'project',path:'AGENTS.md',sha256:createHash('sha256').update(original).digest('hex')}];
|
|
19
|
+
const learning={files,contextDigest:digest(files),application:{contextDigest:digest(files),status:'no_relevant_lesson',summary:'Fixture'}};
|
|
20
|
+
const baseline=captureReviewBaseline({root,identity,scope:['value.mjs'],requirements:['value.mjs']});
|
|
21
|
+
fs.writeFileSync(path.join(root,'value.mjs'),'export const value=2;');
|
|
22
|
+
const reviewPackage=createReviewPackage({root,baseline,checks:[{id:'fixture',command:['synthetic'],outcome:'passed',exitCode:0,evidence:'Synthetic package only'}]});
|
|
23
|
+
const content={status,candidates:status==='no_new_lesson'?[]:[{classification:'memory_only',trigger:'Wrong constant',action:'Inspect expected value',evidence:['value.mjs']}],reason:status==='writeback_pending'?'Evidence needs human assessment':null};
|
|
24
|
+
const retrospective={identity,learningDigest:digest(learning),packageDigest:reviewPackage.packageDigest,content,completionEligible:false};
|
|
25
|
+
const options={identity,codeProject:root,learning,retrospective,baseline,reviewPackage};
|
|
26
|
+
const writer=prepareFixLearningWriteback(options);let registered=0;
|
|
27
|
+
assert.throws(()=>writer.execute({register(){}}),{code:'learning_writeback_authorization_required'});
|
|
28
|
+
const result=writer.execute({authorized:true,register(binding){assert.equal(binding.retrospectiveDigest,digest(retrospective));assert.equal(fs.readFileSync(path.join(root,'AGENTS.md'),'utf8'),original);registered++;}});
|
|
29
|
+
assert.equal(registered,1);assert.equal(result.completionEligible,false);
|
|
30
|
+
assert.equal(result.outcome,status==='lesson_candidate'?'written':status);
|
|
31
|
+
const after=fs.readFileSync(path.join(root,'AGENTS.md'),'utf8');assert(after.startsWith(original));
|
|
32
|
+
if(status==='lesson_candidate'){assert(after.includes('## 项目教训'));assert(after.includes('[仅记忆]'));}
|
|
33
|
+
else assert.equal(after,original);
|
|
34
|
+
assert.throws(()=>writer.execute({authorized:true,register(){}}),{code:'learning_writeback_already_attempted'});
|
|
35
|
+
fs.writeFileSync(path.join(root,'value.mjs'),'export const value=3;');
|
|
36
|
+
assert.throws(()=>prepareFixLearningWriteback(options));
|
|
37
|
+
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('cumulative Learning packages retain prior lessons for append and deduplicated writeback',()=>{
|
|
42
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-learning-cumulative-')));
|
|
43
|
+
try{
|
|
44
|
+
const original='# Project\n\nKeep this instruction.\n';
|
|
45
|
+
fs.writeFileSync(path.join(root,'AGENTS.md'),original);fs.writeFileSync(path.join(root,'value.mjs'),'export const value=1;');
|
|
46
|
+
const identity={repositoryId:'fixture',runId:'cumulative',taskId:'T-FIX-demo',attempt:2};
|
|
47
|
+
const baseline=fixLearningReviewBaseline(captureReviewBaseline({root,identity,scope:['value.mjs'],requirements:['value.mjs']}));
|
|
48
|
+
fs.writeFileSync(path.join(root,'value.mjs'),'export const value=2;');
|
|
49
|
+
const checks=[{id:'fixture',command:['synthetic'],outcome:'passed',exitCode:0,evidence:'Synthetic package only'}];
|
|
50
|
+
const content={status:'lesson_candidate',candidates:[{classification:'memory_only',trigger:'Wrong constant',action:'Inspect expected value',evidence:['value.mjs']}],reason:null};
|
|
51
|
+
const write=content=>{
|
|
52
|
+
const reviewPackage=createReviewPackage({root,baseline,checks});
|
|
53
|
+
const files=[{scope:'project',path:'AGENTS.md',sha256:createHash('sha256').update(fs.readFileSync(path.join(root,'AGENTS.md'))).digest('hex')}];
|
|
54
|
+
const learning={files,contextDigest:digest(files),application:{contextDigest:digest(files),status:'no_relevant_lesson',summary:'Fixture'}};
|
|
55
|
+
const retrospective={identity,learningDigest:digest(learning),packageDigest:reviewPackage.packageDigest,content,completionEligible:false};
|
|
56
|
+
const writer=prepareFixLearningWriteback({identity,codeProject:root,learning,retrospective,baseline,reviewPackage});
|
|
57
|
+
const writeback=writer.execute({authorized:true,register(){}});
|
|
58
|
+
const pkg=createReviewPackage({root,baseline,checks});
|
|
59
|
+
inspectFixLearningReviewPackage(pkg,{baseline,previous:reviewPackage,writeback});
|
|
60
|
+
return {pkg,writeback,previous:reviewPackage};
|
|
61
|
+
};
|
|
62
|
+
const first=write(content);assert.equal(first.writeback.outcome,'written');
|
|
63
|
+
const repeated=write(content);assert.equal(repeated.writeback.outcome,'deduplicated');assert.deepEqual(repeated.pkg,first.pkg);
|
|
64
|
+
const next=write({...content,candidates:[{...content.candidates[0],trigger:'Second boundary',action:'Preserve earlier lessons'}]});
|
|
65
|
+
assert.equal(next.writeback.outcome,'written');
|
|
66
|
+
const changed=next.pkg.changes.find(file=>file.path==='AGENTS.md');
|
|
67
|
+
assert.equal(Buffer.from(changed.before.contentBase64,'base64').toString(),original);
|
|
68
|
+
const after=Buffer.from(changed.after.contentBase64,'base64').toString();assert(after.includes('Wrong constant'));assert(after.includes('Second boundary'));
|
|
69
|
+
fs.chmodSync(path.join(root,'value.mjs'),0o755);
|
|
70
|
+
const forged=createReviewPackage({root,baseline,checks});
|
|
71
|
+
assert.throws(()=>inspectFixLearningReviewPackage(forged,{baseline,previous:next.previous,writeback:next.writeback}),{code:'writeback_package_mismatch'});
|
|
72
|
+
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
73
|
+
});
|