@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,125 @@
|
|
|
1
|
+
// Fixed current-conversation factory, separate from CLI top-level execution.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {fileURLToPath} from 'node:url';
|
|
5
|
+
import {createCodexDeveloperRun,readCodexDeveloperRequest} from './codex-developer-adapter.mjs';
|
|
6
|
+
import {createClaudeDeveloperRun,readClaudeDeveloperRequest} from './claude-developer-adapter.mjs';
|
|
7
|
+
import {createCodexReviewRun} from './codex-review-adapter.mjs';
|
|
8
|
+
import {createClaudeReviewRun} from './claude-review-adapter.mjs';
|
|
9
|
+
import {claudeWorker,claudePreflightMatches} from './worker-claude.mjs';
|
|
10
|
+
import {codexWorker,preflightMatches} from './worker-codex.mjs';
|
|
11
|
+
import {createHostReviewAuthority} from './host-review-authority.mjs';
|
|
12
|
+
import {createHostWorkflowCapabilities} from './host-workflow-capabilities.mjs';
|
|
13
|
+
import {resolveHostRole} from './host-role-routing.mjs';
|
|
14
|
+
import {specsPermissionArgs} from './codex-config.mjs';
|
|
15
|
+
import {createProjectExecution} from './host-project-execution.mjs';
|
|
16
|
+
import {codeProjectPaths,codeProjectInstructionPaths,resolveCodeProjects} from './code-projects.mjs';
|
|
17
|
+
import {readProjectInstructionContext} from './cm-ai-context-refresh.mjs';
|
|
18
|
+
import {validateDocumentationPaths} from './host-documentation.mjs';
|
|
19
|
+
import {isFinalCmAiTask} from './cm-ai-admission.mjs';
|
|
20
|
+
import {createHostBootstrap} from './host-bootstrap.mjs';
|
|
21
|
+
import {digest,id,json,need,shape,freeze} from './effect-contract.mjs';
|
|
22
|
+
const protectedConversations=new WeakMap();
|
|
23
|
+
export const conversationProtection=execution=>protectedConversations.get(execution)??null;
|
|
24
|
+
export function createConversationExecution(definition,hostContextId,bridge,review=null,allowedAttempt=null,workflow=null,allowQa=false,runtime='codex',options={}){
|
|
25
|
+
definition=json(definition);workflow=workflow===null?null:json(workflow);options=json(options);
|
|
26
|
+
shape(options,[...['protection','batchWorkflowsDigest','qaLogHome','bootstrap'].filter(key=>Object.hasOwn(options,key))]);
|
|
27
|
+
let bootstrap=null;
|
|
28
|
+
if(options.bootstrap){
|
|
29
|
+
shape(options.bootstrap,['selection','allowWrite']);
|
|
30
|
+
bootstrap=createHostBootstrap({definition,workflowRoot:path.resolve(fileURLToPath(new URL('../../..',import.meta.url))),
|
|
31
|
+
selection:options.bootstrap.selection,bridge,allowWrite:options.bootstrap.allowWrite});
|
|
32
|
+
}
|
|
33
|
+
const protection=options.protection??null;
|
|
34
|
+
if(protection){shape(protection,['checkCommands','timeoutMs']);specsPermissionArgs({cwd:definition.codeProject,specsRoot:definition.specsDir});}
|
|
35
|
+
need(!definition.codeProjects||protection,'multi_root_protection_required');
|
|
36
|
+
const projectExecution=protection?createProjectExecution({definition,protection}):null;
|
|
37
|
+
const check=projectExecution?.check??null;
|
|
38
|
+
const documentationPaths=workflow?validateDocumentationPaths(workflow.documentationPaths,definition.scope):[];
|
|
39
|
+
need(['codex','claude'].includes(runtime),'invalid_runtime');
|
|
40
|
+
const allowedAttempts=allowedAttempt===null?[]:Array.isArray(allowedAttempt)?json(allowedAttempt):[allowedAttempt];
|
|
41
|
+
need(allowedAttempts.length<=2&&new Set(allowedAttempts).size===allowedAttempts.length
|
|
42
|
+
&&allowedAttempts.every(value=>value===1||value===2),'invalid_review_attempt');
|
|
43
|
+
const author='cm-conversation-author',reviewContexts=['cm-conversation-review-1','cm-conversation-review-2'];
|
|
44
|
+
id(hostContextId);need(![author,...reviewContexts].includes(hostContextId),'not_independent');
|
|
45
|
+
// Keep the unverified native permissions boundary intact for this first host
|
|
46
|
+
// slice too. A transport is not physical protection of nested specs.
|
|
47
|
+
need(protection||!definition.specsDir.startsWith(definition.codeProject+path.sep),'nested_specs_protection_required');
|
|
48
|
+
const configuration={kind:'cm-current-conversation-v1',definitionDigest:digest(definition),hostContextId,
|
|
49
|
+
...(runtime==='claude'?{runtime}:{}),
|
|
50
|
+
...(protection?{protection}:{}),
|
|
51
|
+
...(bootstrap?{bootstrap:bootstrap.configuration}:{}),
|
|
52
|
+
...(options.batchWorkflowsDigest?{batchWorkflowsDigest:options.batchWorkflowsDigest}:{}),
|
|
53
|
+
...(review?{review:{version:1,model:review.model,disabledSkills:review.disabledSkills}}:{}),
|
|
54
|
+
...(workflow?{workflow}: {})};
|
|
55
|
+
const reviewOptions={cwd:definition.codeProject,model:review?.model??'unconfigured',preflight:review?.preflight??null,
|
|
56
|
+
disabledSkills:review?.disabledSkills??[],
|
|
57
|
+
promptTransport:'stdin',schemaPath:fileURLToPath(new URL('./review-result.schema.json',import.meta.url))};
|
|
58
|
+
need(!allowedAttempts.length||review!==null,'review_configuration_required');
|
|
59
|
+
if(allowedAttempts.length)need((runtime==='codex'?preflightMatches:claudePreflightMatches)(reviewOptions.preflight,reviewOptions),'tool_preflight_missing');
|
|
60
|
+
need(runtime!=='claude'||!review||review.disabledSkills.length===0,'invalid_review_config');
|
|
61
|
+
// Preserve P4a's unauthorizable placeholder bytes for existing unconfigured runs.
|
|
62
|
+
const reviewProvider=review?runtime:'codex', adapterId=`${reviewProvider}-review-adapter`;
|
|
63
|
+
const authority=review?createHostReviewAuthority({hostContextId,reviewerId:'reviewer',adapterId,
|
|
64
|
+
decide:async binding=>allowedAttempts.includes(binding.identity.attempt)?{status:'approved'}:null}):null;
|
|
65
|
+
const execution={configuration,timeoutMs:1800000,excludedContexts:[hostContextId],hostDecision:null,applicableAgentFiles:[],
|
|
66
|
+
...(bootstrap?{bootstrap}:{}),
|
|
67
|
+
...(workflow?createHostWorkflowCapabilities({definition,configuration:workflow,bridge,allowQa,runtime,protectedExecution:protection!==null,bootstrap}):{}),
|
|
68
|
+
...(options.qaLogHome?{qaLogHome:options.qaLogHome}:{}),
|
|
69
|
+
...(authority?{hostDecisionProvider:authority.hostDecisionProvider}:{}),
|
|
70
|
+
developer:{provider:runtime,requestedModel:'current-session',contextId:author,run:async(request,control)=>{
|
|
71
|
+
const bound=(runtime==='codex'?readCodexDeveloperRequest:readClaudeDeveloperRequest)(request);
|
|
72
|
+
const route=resolveHostRole({definition,identity:bound.identity,role:'coder',signal:control.signal,runtime});
|
|
73
|
+
const worker=async({prompt})=>{
|
|
74
|
+
const expected=projectExecution?projectExecution.expected(bound.payload.scope):null;
|
|
75
|
+
if(protection){
|
|
76
|
+
prompt+='\nProtected current-host mode: do not write files or run commands. Return {status,value,edits} on success; '
|
|
77
|
+
+'value retains the original implementation/Learning contract. edits is [{path,beforeSha256,content}], complete UTF-8 text or null for deletion. '
|
|
78
|
+
+'Only the supplied scope and expected hashes are allowed. The fixed sandbox applies these edits. On failure return {status,code} without edits.';
|
|
79
|
+
if(documentationPaths.length&&isFinalCmAiTask({specsDir:definition.specsDir,codeProject:definition.codeProject,
|
|
80
|
+
feature:definition.feature,taskId:bound.identity.taskId}))prompt+=' Include necessary documentation synchronization in the same edits: '+JSON.stringify(documentationPaths);
|
|
81
|
+
}
|
|
82
|
+
const response=json(await bridge.call('develop',{request:bound,prompt,codeProject:definition.codeProject,route,
|
|
83
|
+
...(definition.codeProjects?{codeProjects:resolveCodeProjects(definition.codeProject,definition.codeProjects),
|
|
84
|
+
projectInstructions:definition.codeProjects.map(root=>({codeProject:root,files:readProjectInstructionContext(root)}))}:{}),
|
|
85
|
+
...(protection?{editMode:'protected-text-v1',expected}: {})},control.signal));
|
|
86
|
+
if(response.status==='succeeded'){
|
|
87
|
+
shape(response,['status','value',...(protection?['edits']:[])]);
|
|
88
|
+
if(protection){
|
|
89
|
+
need(Array.isArray(response.edits),'protected_edit_invalid');
|
|
90
|
+
if(response.value?.outcome==='blocked')need(response.edits.length===0,'protected_edit_invalid');
|
|
91
|
+
else await projectExecution.commit({scope:bound.payload.scope,
|
|
92
|
+
edits:response.edits,expected,identity:bound.identity,signal:control.signal});
|
|
93
|
+
}
|
|
94
|
+
// This execution surface is the current trusted host, not a thread ID
|
|
95
|
+
// invented by a model response. Exclude it from independent Review.
|
|
96
|
+
return {status:response.status,value:response.value,providerThread:hostContextId};
|
|
97
|
+
}
|
|
98
|
+
shape(response,['status','code']);return response;
|
|
99
|
+
};
|
|
100
|
+
return (runtime==='codex'?createCodexDeveloperRun:createClaudeDeveloperRun)({worker,requestedModel:'current-session'})(bound,control);
|
|
101
|
+
}},
|
|
102
|
+
check:check??((request,control)=>{
|
|
103
|
+
const route=resolveHostRole({definition,identity:request.identity,role:'tester',signal:control.signal,runtime});
|
|
104
|
+
return bridge.call('check',{...request,codeProject:definition.codeProject,
|
|
105
|
+
scope:definition.scope,requirements:definition.requirements,route},control.signal);
|
|
106
|
+
}),
|
|
107
|
+
// The opt-in path uses the original process adapter and observed events.
|
|
108
|
+
// Diagnostic preflight alone never grants review dispatch.
|
|
109
|
+
reviewers:[{id:'reviewer',adapterId,provider:reviewProvider,requestedModel:reviewOptions.model,
|
|
110
|
+
allowed:true,available:true,contexts:reviewContexts,
|
|
111
|
+
run:(request,control)=>{
|
|
112
|
+
need(review!==null,'review_configuration_required');
|
|
113
|
+
return runtime==='codex'?createCodexReviewRun(codexWorker(reviewOptions))(request,control)
|
|
114
|
+
:createClaudeReviewRun(claudeWorker(reviewOptions))(request,control);
|
|
115
|
+
}}],
|
|
116
|
+
reviewInvocation:{developerThreadId:author,excludedThreadIds:[hostContextId],
|
|
117
|
+
authorize:authority?.authorize??(()=>({status:'denied',code:'permission_denied'}))},
|
|
118
|
+
};
|
|
119
|
+
if(definition.codeProjects)execution.applicableAgentFiles=[...new Set([...execution.applicableAgentFiles,
|
|
120
|
+
...codeProjectInstructionPaths(codeProjectPaths(definition.codeProject,definition.codeProjects))
|
|
121
|
+
.filter(file=>file!=='AGENTS.md'&&fs.existsSync(path.join(definition.codeProject,file)))])];
|
|
122
|
+
if(protection){freeze(execution);protectedConversations.set(execution,freeze({codeProject:definition.codeProject,
|
|
123
|
+
specsRoot:definition.specsDir,definitionDigest:digest(definition)}));}
|
|
124
|
+
return execution;
|
|
125
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Documentation is part of the existing durable developer invocation, before
|
|
2
|
+
// checks/Learning/handoff/review. This adapter grants no additional file scope.
|
|
3
|
+
import {isFinalCmAiTask} from './cm-ai-admission.mjs';
|
|
4
|
+
import {captureReviewBaseline} from './review-package.mjs';
|
|
5
|
+
import {digest,json,shape,need,terminalFor} from './effect-contract.mjs';
|
|
6
|
+
|
|
7
|
+
export function validateDocumentationPaths(raw,scope){
|
|
8
|
+
const paths=json(raw);
|
|
9
|
+
need(Array.isArray(paths)&&new Set(paths).size===paths.length);
|
|
10
|
+
for(const file of paths){
|
|
11
|
+
need(typeof file==='string'&&scope.includes(file),'documentation_scope_required');
|
|
12
|
+
need(/\.md$/i.test(file)&&!file.split('/').some(part=>
|
|
13
|
+
['.git','.claude','.codex','.reviews','agents.md','claude.md','tasks.md'].includes(part.toLowerCase())),
|
|
14
|
+
'protected_scope');
|
|
15
|
+
}
|
|
16
|
+
return paths;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function withHostDocumentation({developer,documentationSync,specsDir,codeProject,feature,scope}){
|
|
20
|
+
shape(documentationSync,['paths','run']);need(typeof documentationSync.run==='function');
|
|
21
|
+
const paths=validateDocumentationPaths(documentationSync.paths,scope),run=documentationSync.run;
|
|
22
|
+
need(paths.length>0);
|
|
23
|
+
return {...developer,run:async(request,control)=>{
|
|
24
|
+
const response=terminalFor(await developer.run(request,control),request);
|
|
25
|
+
if(response.status!=='succeeded')return response;
|
|
26
|
+
need(!control.signal.aborted,'cancelled');
|
|
27
|
+
if(!isFinalCmAiTask({specsDir,codeProject,feature,taskId:request.identity.taskId}))return response;
|
|
28
|
+
const baseline=captureReviewBaseline({root:codeProject,specsRoot:specsDir,identity:request.identity,
|
|
29
|
+
scope:paths,requirements:request.payload.requirements.map(file=>file.path)});
|
|
30
|
+
const result=json(await run(json({identity:request.identity,invocationId:request.invocationId,
|
|
31
|
+
specsDir,codeProject,feature,paths}),control.signal));
|
|
32
|
+
need(!control.signal.aborted,'cancelled');shape(result,['status']);
|
|
33
|
+
need(result.status==='completed','documentation_sync_blocked');
|
|
34
|
+
const after=captureReviewBaseline({root:codeProject,specsRoot:specsDir,identity:request.identity,
|
|
35
|
+
scope:paths,requirements:request.payload.requirements.map(file=>file.path)});
|
|
36
|
+
need(digest(baseline.files.filter(file=>!paths.includes(file.path)))===
|
|
37
|
+
digest(after.files.filter(file=>!paths.includes(file.path))),'out_of_scope');
|
|
38
|
+
return response;
|
|
39
|
+
}};
|
|
40
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Host-only initial handoff producer. It grants no review or completion authority.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {randomUUID,createHash} from 'node:crypto';
|
|
5
|
+
import {createReviewPackage,verifyReviewPackage} from './review-package.mjs';
|
|
6
|
+
import {implementationSha256,loadHandoff} from '../../../scripts/cm-task-gate.mjs';
|
|
7
|
+
import {digest,json,shape,text,need} from './effect-contract.mjs';
|
|
8
|
+
|
|
9
|
+
function prepareHostHandoff(raw){
|
|
10
|
+
const input=json(raw,16*1024*1024);
|
|
11
|
+
shape(input,['root','baseline','checks','handoffPath',...(Object.hasOwn(input,'evidence')?['evidence']:[])]);
|
|
12
|
+
const evidence=input.evidence??[];
|
|
13
|
+
need(Array.isArray(evidence)&&evidence.length<=32,'invalid_handoff_evidence');
|
|
14
|
+
for(const item of evidence)text(item);
|
|
15
|
+
const {root,baseline,checks,handoffPath}=input;
|
|
16
|
+
text(handoffPath);
|
|
17
|
+
need(path.isAbsolute(handoffPath)&&path.resolve(handoffPath)===handoffPath,'unsupported_path');
|
|
18
|
+
const parent=path.dirname(handoffPath);
|
|
19
|
+
need(fs.realpathSync(parent)===parent&&fs.lstatSync(parent).isDirectory(),'unsupported_path');
|
|
20
|
+
const reviewPackage=createReviewPackage({root,baseline,checks});
|
|
21
|
+
const changedFiles=reviewPackage.changes.map(change=>change.path);
|
|
22
|
+
const passed=checks.every(check=>check.outcome==='passed');
|
|
23
|
+
const payload={schema_version:1,task_id:baseline.identity.taskId,attempt:baseline.identity.attempt,
|
|
24
|
+
status:passed?'ready_for_review':'blocked',changed_files:changedFiles,
|
|
25
|
+
implementation_sha256:implementationSha256(root,changedFiles),
|
|
26
|
+
verification:checks.map(check=>({command:check.kind==='visual'
|
|
27
|
+
?`Visual inspection (not a shell command): ${check.before.kind} before/after comparison`
|
|
28
|
+
:JSON.stringify(check.command),
|
|
29
|
+
status:check.outcome==='passed'?'passed':'failed',evidence:check.evidence})),
|
|
30
|
+
evidence:[`host review package ${reviewPackage.packageDigest}`,...evidence],
|
|
31
|
+
blockers:passed?[]:checks.filter(check=>check.outcome!=='passed').map(check=>`check ${check.id}: ${check.outcome}`),
|
|
32
|
+
scope_deviation:[]};
|
|
33
|
+
const bytes=Buffer.from(JSON.stringify(payload,null,2)+'\n');
|
|
34
|
+
need(bytes.length<=256*1024,'limit_exceeded');
|
|
35
|
+
return {root,baseline,checks,handoffPath,parent,reviewPackage,changedFiles,payload,bytes};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Same serialization as publication, without creating files or registering work.
|
|
39
|
+
export function checkHostHandoffSize(raw){prepareHostHandoff(raw);}
|
|
40
|
+
|
|
41
|
+
export function verifyHostHandoff(raw){
|
|
42
|
+
const {root,baseline,checks,handoffPath,reviewPackage,payload}=prepareHostHandoff(raw);
|
|
43
|
+
const bound=createReviewPackage({root,baseline,checks,handoffPath});
|
|
44
|
+
const actual=loadHandoff(handoffPath,{task:baseline.identity.taskId,attempt:baseline.identity.attempt});
|
|
45
|
+
need(digest(actual)===digest(payload),'handoff_content_mismatch');
|
|
46
|
+
verifyReviewPackage({root,baseline,checks,reviewPackage:bound,expectedDigest:bound.packageDigest,handoffPath});
|
|
47
|
+
return {outcome:'matched',handoffSha256:bound.handoff.sha256,packageDigest:reviewPackage.packageDigest};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function createHostHandoff(raw){
|
|
51
|
+
const {root,baseline,checks,handoffPath,parent,reviewPackage,changedFiles,payload,bytes}=prepareHostHandoff(raw);
|
|
52
|
+
const temp=path.join(parent,`.cm-initial-handoff-${randomUUID()}`);
|
|
53
|
+
let fd;
|
|
54
|
+
try{
|
|
55
|
+
fd=fs.openSync(temp,fs.constants.O_WRONLY|fs.constants.O_CREAT|fs.constants.O_EXCL,0o600);
|
|
56
|
+
fs.writeFileSync(fd,bytes);fs.fsyncSync(fd);fs.closeSync(fd);fd=undefined;
|
|
57
|
+
loadHandoff(temp,{task:baseline.identity.taskId,attempt:baseline.identity.attempt});
|
|
58
|
+
verifyReviewPackage({root,baseline,checks,reviewPackage,expectedDigest:reviewPackage.packageDigest});
|
|
59
|
+
need(payload.implementation_sha256===implementationSha256(root,changedFiles),'snapshot_changed');
|
|
60
|
+
// Atomic no-replace publication, unlike rename which could overwrite approval.
|
|
61
|
+
fs.linkSync(temp,handoffPath);
|
|
62
|
+
fs.unlinkSync(temp);
|
|
63
|
+
const dir=fs.openSync(parent,fs.constants.O_RDONLY);
|
|
64
|
+
try{fs.fsyncSync(dir);}finally{fs.closeSync(dir);}
|
|
65
|
+
return {outcome:'created',status:payload.status,
|
|
66
|
+
handoffSha256:createHash('sha256').update(bytes).digest('hex')};
|
|
67
|
+
}finally{
|
|
68
|
+
if(fd!==undefined)fs.closeSync(fd);
|
|
69
|
+
try{fs.unlinkSync(temp);}catch(error){if(error.code!=='ENOENT')throw error;}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Execute declared root-local operations and aggregate into the original task.
|
|
2
|
+
// Root selection is data, not a second scheduler or a task completion authority.
|
|
3
|
+
import {captureProtectedEdits,commitProtectedEdits} from '../cm-fix/protected-edits.mjs';
|
|
4
|
+
import {groupCodeProjectPaths,resolveCodeProjects} from './code-projects.mjs';
|
|
5
|
+
import {createHostCheck} from './host-check.mjs';
|
|
6
|
+
import {specsPermissionArgs} from './codex-config.mjs';
|
|
7
|
+
import {digest,json,need,shape,id} from './effect-contract.mjs';
|
|
8
|
+
|
|
9
|
+
export function createProjectExecution({definition,protection}){
|
|
10
|
+
const data=json(definition),config=json(protection);
|
|
11
|
+
const roots=data.codeProjects?resolveCodeProjects(data.codeProject,data.codeProjects):[data.codeProject];
|
|
12
|
+
for(const root of roots)specsPermissionArgs({cwd:root,specsRoot:data.specsDir});
|
|
13
|
+
const groups=scope=>data.codeProjects?groupCodeProjectPaths(data.codeProject,roots,scope)
|
|
14
|
+
:[{codeProject:data.codeProject,prefix:'',paths:scope}];
|
|
15
|
+
const full=(group,file)=>group.prefix?group.prefix+'/'+file:file;
|
|
16
|
+
const commands=config.checkCommands;
|
|
17
|
+
need(Array.isArray(commands)&&commands.length>0&&commands.length<=32,'invalid_check_config');
|
|
18
|
+
const ids=new Set();
|
|
19
|
+
const checks=commands.map(command=>{
|
|
20
|
+
shape(command,['id','command',...(data.codeProjects?['codeProject']:[])]);id(command.id);
|
|
21
|
+
need(!ids.has(command.id),'invalid_check_config');ids.add(command.id);
|
|
22
|
+
const cwd=data.codeProjects?command.codeProject:data.codeProject;
|
|
23
|
+
need(roots.includes(cwd),'execution_root_mismatch');
|
|
24
|
+
const check=createHostCheck({cwd,specsRoot:data.specsDir,timeoutMs:config.timeoutMs,
|
|
25
|
+
commands:[{id:command.id,command:command.command}]});
|
|
26
|
+
return {cwd,check};
|
|
27
|
+
});
|
|
28
|
+
need(roots.every(root=>checks.some(item=>item.cwd===root)),'code_project_checks_required');
|
|
29
|
+
const recheck=()=>{if(data.codeProjects)need(digest(resolveCodeProjects(data.codeProject,roots))===digest(roots),'execution_root_mismatch');};
|
|
30
|
+
return Object.freeze({
|
|
31
|
+
expected(scope){recheck();return Object.fromEntries(groups(scope).flatMap(group=>
|
|
32
|
+
Object.entries(group.paths.length?captureProtectedEdits(group.codeProject,group.paths):{}).map(([file,hash])=>[full(group,file),hash])));},
|
|
33
|
+
async commit({scope,edits,expected,identity,signal}){
|
|
34
|
+
recheck();need(Array.isArray(edits),'protected_edit_invalid');
|
|
35
|
+
for(const edit of edits)need(scope.includes(edit.path),'out_of_scope');
|
|
36
|
+
// Precheck all roots before the first root writes; no claim of atomicity.
|
|
37
|
+
const selected=groups(scope);
|
|
38
|
+
for(const group of selected)for(const [file,hash] of Object.entries(group.paths.length?captureProtectedEdits(group.codeProject,group.paths):{}))
|
|
39
|
+
need(hash===expected[full(group,file)],'protected_edit_stale');
|
|
40
|
+
for(const group of selected){
|
|
41
|
+
const local=edits.filter(edit=>group.paths.some(file=>full(group,file)===edit.path))
|
|
42
|
+
.map(edit=>({...edit,path:group.prefix?edit.path.slice(group.prefix.length+1):edit.path}));
|
|
43
|
+
if(!local.length)continue;
|
|
44
|
+
await commitProtectedEdits({cwd:group.codeProject,specsRoot:data.specsDir,scope:group.paths,edits:local,
|
|
45
|
+
expected:Object.fromEntries(group.paths.map(file=>[file,expected[full(group,file)]])),identity,signal,timeoutMs:config.timeoutMs});
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
async check(request,control){
|
|
49
|
+
recheck();const result=[];
|
|
50
|
+
for(const item of checks){
|
|
51
|
+
const [row]=await item.check(request,control);
|
|
52
|
+
result.push(data.codeProjects?{...row,evidence:`cwd=${item.cwd}; ${row.evidence}`}:row);
|
|
53
|
+
if(row.outcome!=='passed')break;
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
// N6 execution over already-authorized host capabilities. No model dispatch,
|
|
2
|
+
// browser installation, task writes, auto-fix or second completion authority.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import {spawnSync} from 'node:child_process';
|
|
6
|
+
import {fileURLToPath} from 'node:url';
|
|
7
|
+
import {loadConfig,resolveRole} from '../../../scripts/cm-workflow-config.mjs';
|
|
8
|
+
import {validateTestCases} from '../../../scripts/validate-test-cases.mjs';
|
|
9
|
+
import {inspectCmAiAdmission} from './cm-ai-admission.mjs';
|
|
10
|
+
import {createHostCheck} from './host-check.mjs';
|
|
11
|
+
import {specsPermissionArgs} from './codex-config.mjs';
|
|
12
|
+
import {resolveCodeProjects,codeProjectPaths} from './code-projects.mjs';
|
|
13
|
+
import {findCmAiQaDecision,readCmAiQaRunRound,reportFile} from './cm-ai-qa-log.mjs';
|
|
14
|
+
import {captureReviewBaseline} from './review-package.mjs';
|
|
15
|
+
import {writeCmAiQaStatus} from './cm-ai-run-finalizer.mjs';
|
|
16
|
+
import {digest,freeze,hex,id,json,need,shape,text,validCallTimeout,validIdentity} from './effect-contract.mjs';
|
|
17
|
+
|
|
18
|
+
const writer=fileURLToPath(new URL('../../../scripts/cm-log-event.py',import.meta.url));
|
|
19
|
+
const order={ 'cm-default':['logic','commands','browser'],
|
|
20
|
+
'java-backend':['commands','logic','browser'],'web-frontend':['commands','browser','logic'] };
|
|
21
|
+
|
|
22
|
+
function readPlan(configuration) {
|
|
23
|
+
const {codeProject,specsDir,feature,commands}=configuration;
|
|
24
|
+
const admission=inspectCmAiAdmission({specsDir,codeProject});
|
|
25
|
+
need(['ready','complete'].includes(admission.state),admission.reason??'qa_admission_required');
|
|
26
|
+
const featureRoot=path.join(specsDir,feature);
|
|
27
|
+
need(fs.realpathSync(featureRoot)===featureRoot&&fs.lstatSync(featureRoot).isDirectory(),'qa_feature_invalid');
|
|
28
|
+
const config=loadConfig({projectRoot:codeProject});
|
|
29
|
+
const source=path.join(specsDir,feature,'test-cases.json');let cases=[];
|
|
30
|
+
// Admission validates approved references and containment; read only that
|
|
31
|
+
// feature's original test contract, not executable instructions from cases.
|
|
32
|
+
if(fs.existsSync(source)){
|
|
33
|
+
const bytes=fs.readFileSync(source);need(bytes.length<=1024*1024,'limit_exceeded');
|
|
34
|
+
const contract=json(JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(bytes)));
|
|
35
|
+
need(validateTestCases(contract).length===0&&contract.feature===feature.replace(/^\d+\./,''),'test_cases_invalid');
|
|
36
|
+
cases=contract.cases;
|
|
37
|
+
}
|
|
38
|
+
const selected=cases.filter(item=>item.blocking||config.policies.tests.includes(item.kind));
|
|
39
|
+
const wanted=new Set(selected.filter(item=>item.kind==='logic').map(item=>item.id));
|
|
40
|
+
const scheduled=commands.filter(item=>config.policies.tests.includes('commands')
|
|
41
|
+
||item.caseIds.some(caseId=>wanted.has(caseId)));
|
|
42
|
+
for(const item of commands)for(const caseId of item.caseIds)
|
|
43
|
+
need(cases.some(candidate=>candidate.id===caseId&&candidate.kind==='logic'),'qa_command_mapping_invalid');
|
|
44
|
+
const modes=order[config.project.workflow].filter(mode=>mode==='commands'
|
|
45
|
+
?scheduled.length>0||config.policies.tests.includes('commands'):selected.some(item=>item.kind===mode));
|
|
46
|
+
return json({config,cases:selected,commands:scheduled,modes});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function logStep(configuration,binding,event,phase,data,detail) {
|
|
50
|
+
const payload={node:'N6',feature:configuration.feature,task:binding.identity.taskId,
|
|
51
|
+
attempt:binding.identity.attempt,repository_id:binding.identity.repositoryId,
|
|
52
|
+
package_digest:binding.packageDigest,operation_id:binding.testRunId,...data};
|
|
53
|
+
if(event==='test_run'){
|
|
54
|
+
const decision=findCmAiQaDecision({specsDir:configuration.specsDir,feature:configuration.feature,
|
|
55
|
+
identity:binding.identity,packageDigest:binding.packageDigest});
|
|
56
|
+
need(decision?.status==='triggered','qa_not_triggered');
|
|
57
|
+
payload.qa_decision_id=decision.decisionId;payload.attempt=binding.qaRound;
|
|
58
|
+
}
|
|
59
|
+
const result=spawnSync('python3',[writer,'--workflow','cm-ai','--event',event,'--phase',phase,
|
|
60
|
+
'--runtime',configuration.runtime,'--project-root',configuration.codeProject,'--specs-dir',configuration.specsDir,
|
|
61
|
+
'--run-id',binding.identity.runId,'--detail',detail,'--data-json',JSON.stringify(payload)],
|
|
62
|
+
{env:{...process.env,CM_WORKFLOW_LOG_HOME:configuration.logHome},timeout:10000,maxBuffer:1024*1024});
|
|
63
|
+
need(!result.error&&result.status===0&&result.signal===null,'qa_log_failed');
|
|
64
|
+
const logged=JSON.parse(result.stdout.toString('utf8'));
|
|
65
|
+
need(logged.run_id===binding.identity.runId&&logged.project_log===path.join(configuration.specsDir,'运行日志.jsonl'),'qa_log_failed');
|
|
66
|
+
if(event==='test_run'&&phase.startsWith('case_'))writeCmAiQaStatus({specsDir:configuration.specsDir,
|
|
67
|
+
feature:configuration.feature,identity:binding.identity,caseId:data.case_id,phase});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function evidence(raw) {
|
|
71
|
+
const result=json(raw);need(Array.isArray(result)&&result.length>0&&result.length<=32,'qa_evidence_required');
|
|
72
|
+
for(const item of result){text(item);need(item.length<=2000&&!item.includes('\0'),'qa_evidence_required');}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function saveReport(configuration,binding,rows,summary) {
|
|
77
|
+
const reviews=path.join(configuration.specsDir,'.reviews'),stat=fs.lstatSync(reviews);
|
|
78
|
+
need(stat.isDirectory()&&!stat.isSymbolicLink()&&fs.realpathSync(reviews)===reviews,'qa_report_invalid');
|
|
79
|
+
const target=path.join(reviews,`${binding.testRunId}-execution.md`);
|
|
80
|
+
const body=Buffer.from(`# CM QA execution report\n\nOverall: ${summary.result}\n\n`
|
|
81
|
+
+'Counts are declared command checks plus selected cases, not framework test totals.\n'
|
|
82
|
+
+'Static verdicts are retained separately; only observed command/browser evidence counts as PASS.\n\n'
|
|
83
|
+
+rows.map(row=>`## ${row.id}\n\n${JSON.stringify(row,null,2)}\n`).join('\n'));
|
|
84
|
+
need(body.length<=1024*1024,'limit_exceeded');
|
|
85
|
+
const fd=fs.openSync(target,fs.constants.O_CREAT|fs.constants.O_EXCL|fs.constants.O_WRONLY|fs.constants.O_NOFOLLOW,0o600);
|
|
86
|
+
try{fs.writeFileSync(fd,body);fs.fsyncSync(fd);}finally{fs.closeSync(fd);}
|
|
87
|
+
return target;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function createHostQaExecutor(options) {
|
|
91
|
+
const keys=['specsDir','codeProject','feature','runtime','requirements','commands','environment','timeoutMs','logHome'];
|
|
92
|
+
shape(options,[...keys,...['logic','browser','specsRoot','codeProjects','bootstrap'].filter(key=>Object.hasOwn(options,key))]);
|
|
93
|
+
const {logic=null,browser=null,...raw}=options,configuration=json(raw);
|
|
94
|
+
for(const capability of [logic,browser])need(capability===null||typeof capability==='function');
|
|
95
|
+
for(const name of ['specsDir','codeProject','logHome'])need(path.isAbsolute(configuration[name]),'unsupported_path');
|
|
96
|
+
for(const name of ['specsDir','codeProject'])need(fs.realpathSync(configuration[name])===configuration[name],'unsupported_path');
|
|
97
|
+
const roots=configuration.codeProjects?resolveCodeProjects(configuration.codeProject,configuration.codeProjects):null;
|
|
98
|
+
if(configuration.bootstrap){
|
|
99
|
+
shape(configuration.bootstrap,['requirements','scope']);need(configuration.feature==='0.bootstrap','bootstrap_task_required');
|
|
100
|
+
}
|
|
101
|
+
if(Object.hasOwn(configuration,'specsRoot')){
|
|
102
|
+
need(configuration.specsRoot===configuration.specsDir,'execution_specs_mismatch');
|
|
103
|
+
specsPermissionArgs({cwd:configuration.codeProject,specsRoot:configuration.specsRoot});
|
|
104
|
+
}
|
|
105
|
+
need(/^\d+\.[A-Za-z0-9._-]+$/.test(configuration.feature),'feature_invalid');
|
|
106
|
+
need(['codex','claude'].includes(configuration.runtime));validCallTimeout(configuration.timeoutMs);
|
|
107
|
+
const ids=new Set();need(Array.isArray(configuration.commands)&&configuration.commands.length<=32);
|
|
108
|
+
for(const item of configuration.commands){
|
|
109
|
+
shape(item,['id','command','caseIds',...(roots?['codeProject']:[])]);id(item.id);need(!ids.has(item.id));ids.add(item.id);
|
|
110
|
+
if(roots)need(roots.includes(item.codeProject),'execution_root_mismatch');
|
|
111
|
+
need(Array.isArray(item.caseIds)&&new Set(item.caseIds).size===item.caseIds.length);
|
|
112
|
+
for(const caseId of item.caseIds)id(caseId);
|
|
113
|
+
// Reuse the actual host checker validator, without running a command.
|
|
114
|
+
createHostCheck({cwd:roots?item.codeProject:configuration.codeProject,commands:[{id:item.id,command:item.command}],timeoutMs:configuration.timeoutMs});
|
|
115
|
+
}
|
|
116
|
+
shape(configuration.environment,['kind','carrier','target','scope']);
|
|
117
|
+
const environment=configuration.environment;
|
|
118
|
+
need(['local','test'].includes(environment.scope),'qa_environment_required');text(environment.target);
|
|
119
|
+
const carriers={web:['browser'],app:['ios-simulator','android-emulator','device'],miniprogram:['wechat-devtools','device']};
|
|
120
|
+
need(carriers[environment.kind]?.includes(environment.carrier),'qa_environment_required');
|
|
121
|
+
const plan=readPlan(configuration);
|
|
122
|
+
need(!plan.cases.some(item=>ids.has(item.id)),'qa_id_conflict');
|
|
123
|
+
// One missing-command item keeps an empty invocation from passing as zero tests.
|
|
124
|
+
const commandCount=plan.modes.includes('commands')?Math.max(1,plan.commands.length):0;
|
|
125
|
+
const caseCount=Math.max(1,commandCount+plan.cases.length);
|
|
126
|
+
const mode=plan.modes.length===1&&['commands','browser'].includes(plan.modes[0])?plan.modes[0]:'all';
|
|
127
|
+
const metadata=json({kind:'cm-host-qa-executor-v1',...configuration,plan,
|
|
128
|
+
capabilities:{logic:logic!==null,browser:browser!==null}});
|
|
129
|
+
return Object.freeze({mode,caseCount,timeoutMs:configuration.timeoutMs,configuration:metadata,
|
|
130
|
+
async run(rawBinding,signal){
|
|
131
|
+
let binding=json(rawBinding);
|
|
132
|
+
shape(binding,['specsDir','codeProject','feature','identity','packageDigest','testRunId','mode','caseCount',
|
|
133
|
+
...(Object.hasOwn(binding,'qaRound')?['qaRound']:[])]);
|
|
134
|
+
validIdentity(binding.identity);hex(binding.packageDigest);id(binding.testRunId);
|
|
135
|
+
const qaRound=readCmAiQaRunRound({specsDir:binding.specsDir,feature:binding.feature,
|
|
136
|
+
identity:binding.identity,packageDigest:binding.packageDigest,testRunId:binding.testRunId});
|
|
137
|
+
need(!Object.hasOwn(binding,'qaRound')||binding.qaRound===qaRound,'qa_round_invalid');
|
|
138
|
+
binding=json({...binding,qaRound});
|
|
139
|
+
need(['specsDir','codeProject','feature'].every(key=>binding[key]===configuration[key])
|
|
140
|
+
&&binding.mode===mode&&binding.caseCount===caseCount,'qa_execution_mismatch');
|
|
141
|
+
const unchanged=()=>need(digest(readPlan(configuration))===digest(plan),'qa_plan_changed');
|
|
142
|
+
const notCancelled=()=>need(!signal.aborted,'cancelled');notCancelled();unchanged();
|
|
143
|
+
const snapshot=()=>captureReviewBaseline({root:configuration.codeProject,specsRoot:configuration.specsDir,
|
|
144
|
+
identity:binding.identity,scope:configuration.bootstrap?.scope??configuration.requirements,requirements:configuration.requirements,
|
|
145
|
+
...(configuration.bootstrap?{bootstrapRequirements:configuration.bootstrap.requirements}:{}),
|
|
146
|
+
...(roots?{codeProjectPaths:codeProjectPaths(configuration.codeProject,resolveCodeProjects(configuration.codeProject,roots))}:{})});
|
|
147
|
+
const before=snapshot(),rows=[],commandResults=new Map();
|
|
148
|
+
const route=role=>{
|
|
149
|
+
notCancelled();unchanged();
|
|
150
|
+
const result=resolveRole(loadConfig({projectRoot:configuration.codeProject}),role,configuration.runtime);
|
|
151
|
+
logStep(configuration,binding,'decision','route',{role,adapter:result.adapter,requested_model:result.model,
|
|
152
|
+
source:result.source,purpose:'qa',route_state:result.route_state},`QA role: ${role}`);
|
|
153
|
+
if(result.route_state==='declared-adapter')logStep(configuration,binding,'degrade','route',
|
|
154
|
+
{role,route_state:result.route_state,outcome:'local_qa_only'},'Requested QA adapter unobserved; local evidence only');
|
|
155
|
+
return result;
|
|
156
|
+
};
|
|
157
|
+
for(const stage of plan.modes){
|
|
158
|
+
const routed=route(stage==='browser'?'browser_qa':'tester');
|
|
159
|
+
if(stage==='commands'){
|
|
160
|
+
if(!plan.commands.length)rows.push({id:'commands-unavailable',kind:'commands',verdict:'BLOCKED',evidence:['No declared project test command']});
|
|
161
|
+
for(const command of plan.commands){
|
|
162
|
+
notCancelled();
|
|
163
|
+
const check=createHostCheck({cwd:roots?command.codeProject:configuration.codeProject,commands:[{id:command.id,command:command.command}],
|
|
164
|
+
timeoutMs:configuration.timeoutMs,specsRoot:configuration.specsRoot??null});
|
|
165
|
+
const resource={resource_id:`qa-command-${digest({testRunId:binding.testRunId,command:command.id}).slice(0,48)}`,
|
|
166
|
+
resource_kind:'qa_command'};
|
|
167
|
+
logStep(configuration,binding,'resource','acquired',{...resource,cleanup_required:true},'QA command resource acquired');
|
|
168
|
+
let observed;
|
|
169
|
+
try{
|
|
170
|
+
[observed]=await check({identity:binding.identity},{signal});
|
|
171
|
+
logStep(configuration,binding,'resource',observed.evidence==='host check: cleanup_failed'?'cleanup_failed':'released',
|
|
172
|
+
resource,'QA command resource finished');
|
|
173
|
+
}catch(error){
|
|
174
|
+
logStep(configuration,binding,'resource','cleanup_failed',resource,'QA command cleanup not confirmed');throw error;
|
|
175
|
+
}
|
|
176
|
+
notCancelled();
|
|
177
|
+
commandResults.set(command.id,observed);
|
|
178
|
+
rows.push({id:command.id,kind:'commands',verdict:observed.outcome==='passed'?'PASS':observed.outcome==='failed'?'FAIL':'BLOCKED',
|
|
179
|
+
exitCode:observed.exitCode,evidence:[...(roots?[`cwd=${command.codeProject}`]:[]),observed.evidence]});
|
|
180
|
+
}
|
|
181
|
+
}else for(const item of plan.cases.filter(candidate=>candidate.kind===stage)){
|
|
182
|
+
notCancelled();
|
|
183
|
+
const request=freeze({...binding,case:item,route:routed,environment,...(roots?{codeProjects:roots}:{})});
|
|
184
|
+
if(stage==='logic'){
|
|
185
|
+
const observed=logic===null?{verdict:'INSUFFICIENT_EVIDENCE',evidence:['Logic host unavailable']}:json(await logic(request,signal));
|
|
186
|
+
notCancelled();shape(observed,['verdict','evidence']);
|
|
187
|
+
need(['SUPPORTED','CONTRADICTED','INSUFFICIENT_EVIDENCE'].includes(observed.verdict),'qa_verdict_invalid');
|
|
188
|
+
rows.push({id:item.id,kind:'logic',origin:item.origin,blocking:item.blocking,
|
|
189
|
+
staticVerdict:observed.verdict,verdict:'BLOCKED',evidence:evidence(observed.evidence)});
|
|
190
|
+
}else{
|
|
191
|
+
logStep(configuration,binding,'test_run','case_start',{case_id:item.id},'QA browser case started');
|
|
192
|
+
let observed;
|
|
193
|
+
if(browser===null||item.expected.some(value=>value.includes('[需确认]')))
|
|
194
|
+
observed={verdict:'BLOCKED',evidence:[],environment,cleanup:'not_needed'};
|
|
195
|
+
else observed=json(await browser(request,signal));
|
|
196
|
+
notCancelled();shape(observed,['verdict','evidence','environment','cleanup']);
|
|
197
|
+
need(['PASS','FAIL','BLOCKED'].includes(observed.verdict),'qa_verdict_invalid');
|
|
198
|
+
need(['completed','not_needed','failed'].includes(observed.cleanup),'qa_cleanup_required');
|
|
199
|
+
let evidenceProblem=null;
|
|
200
|
+
if(observed.verdict!=='BLOCKED')try{
|
|
201
|
+
for(const file of evidence(observed.evidence)){
|
|
202
|
+
const target=reportFile(configuration.specsDir,file);
|
|
203
|
+
need(fs.statSync(target).size>0,'qa_evidence_required');
|
|
204
|
+
}
|
|
205
|
+
}catch{evidenceProblem='qa_evidence_required';}
|
|
206
|
+
const verdict=evidenceProblem!==null||digest(observed.environment)!==digest(environment)||observed.cleanup==='failed'
|
|
207
|
+
||(item.cleanup.length>0&&observed.cleanup!=='completed')?'BLOCKED':observed.verdict;
|
|
208
|
+
rows.push({id:item.id,kind:'browser',origin:item.origin,blocking:item.blocking,verdict,
|
|
209
|
+
evidence:observed.evidence,evidenceProblem,environment:observed.environment,cleanup:observed.cleanup});
|
|
210
|
+
logStep(configuration,binding,'test_run',verdict==='BLOCKED'?'case_blocked':'case_complete',
|
|
211
|
+
{case_id:item.id,result:verdict},'QA browser case finished');
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
notCancelled();unchanged();
|
|
216
|
+
// A single declared command can supply runtime evidence for several logic
|
|
217
|
+
// cases. The host declares that mapping; no additional tests are invented.
|
|
218
|
+
for(const row of rows.filter(item=>item.kind==='logic')){
|
|
219
|
+
const mappings=plan.commands.filter(item=>item.caseIds.includes(row.id));
|
|
220
|
+
const observed=mappings.map(item=>commandResults.get(item.id));
|
|
221
|
+
row.verdict=row.staticVerdict==='CONTRADICTED'?'FAIL':
|
|
222
|
+
observed.some(item=>item?.outcome==='failed')?'FAIL':
|
|
223
|
+
observed.length>0&&observed.every(item=>item?.outcome==='passed')?'PASS':'BLOCKED';
|
|
224
|
+
row.commandEvidence=mappings.map(item=>item.id);
|
|
225
|
+
const item=plan.cases.find(item=>item.id===row.id);
|
|
226
|
+
if(item.expected.some(value=>value.includes('[需确认]')))row.verdict='BLOCKED';
|
|
227
|
+
}
|
|
228
|
+
if(rows.length===0)rows.push({id:'qa-unavailable',kind:'commands',verdict:'BLOCKED',evidence:['No executable QA contract']});
|
|
229
|
+
const drift=digest(before.files)!==digest(snapshot().files);
|
|
230
|
+
if(drift)for(const row of rows){row.verdict='BLOCKED';row.sourceChanged=true;}
|
|
231
|
+
const passed=rows.filter(item=>item.verdict==='PASS').length,failed=rows.filter(item=>item.verdict==='FAIL').length,
|
|
232
|
+
blocked=rows.filter(item=>item.verdict==='BLOCKED').length;
|
|
233
|
+
need(passed+failed+blocked===caseCount,'qa_result_invalid');
|
|
234
|
+
const summary={result:failed>0?'FAIL':blocked>0?'BLOCKED':'PASS',passed,failed,blocked};
|
|
235
|
+
const report=saveReport(configuration,binding,rows,summary);
|
|
236
|
+
return json({...summary,report});
|
|
237
|
+
}});
|
|
238
|
+
}
|