@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,538 @@
|
|
|
1
|
+
// Fixed Codex-host entry for the existing cm-ai admission and V3 task runner.
|
|
2
|
+
import {inspectCmAiAdmission} from './cm-ai-admission.mjs';
|
|
3
|
+
import {inspectCmAiContextRefresh,inspectCmAiTaskLearningInput} from './cm-ai-context-refresh.mjs';
|
|
4
|
+
import {findCmAiQaDecision,inspectCmAiQaDecision,inspectCmAiQaResult,recordCmAiQaDecision,
|
|
5
|
+
latestCmAiQaRun,recordCmAiQaRun} from './cm-ai-qa-log.mjs';
|
|
6
|
+
import {recordCmAiRunDone} from './cm-ai-run-finalizer.mjs';
|
|
7
|
+
import {readHostQaFixHandoff} from './host-qa-fix.mjs';
|
|
8
|
+
import {digest,freeze,hex,id,json,need,shape,text,validIdentity} from './effect-contract.mjs';
|
|
9
|
+
|
|
10
|
+
const sameIdentity=(left,right)=>['repositoryId','runId','taskId','attempt'].every(key=>left[key]===right[key]);
|
|
11
|
+
const sameTask=(left,right)=>['repositoryId','runId','taskId'].every(key=>left[key]===right[key]);
|
|
12
|
+
const boundStatus=(status,identity)=>{validIdentity(status?.identity);
|
|
13
|
+
need(sameIdentity(status.identity,identity),'identity_mismatch');return status;};
|
|
14
|
+
const pendingAction=status=>status.state==='awaiting_spec_approval'?'spec_approval':
|
|
15
|
+
status.state==='changes_requested'?'resume':
|
|
16
|
+
status.state==='awaiting_review'?'decision':status.state==='unknown'?'reconcile':
|
|
17
|
+
status.state==='pending_review'&&status.code==='provider_review_observed'?'review_evidence':
|
|
18
|
+
status.state==='pending_review'?'decision':status.state==='approved'?'complete':
|
|
19
|
+
status.state==='fixture_completed'&&status.code==='qa_triggered'?'qa_execution':
|
|
20
|
+
status.state==='fixture_completed'&&status.code==='qa_skipped'?'context_refresh':
|
|
21
|
+
status.state==='fixture_completed'&&status.code==='qa_passed'?'context_refresh':
|
|
22
|
+
status.state==='fixture_completed'&&status.code==='correction_review_required'?'none':
|
|
23
|
+
status.state==='fixture_completed'&&status.code==='documentation_sync_required'?'documentation_sync':
|
|
24
|
+
status.state==='fixture_completed'&&status.code==='documentation_synced'?'run_finalize':
|
|
25
|
+
status.state==='fixture_completed'&&status.code==='documentation_sync_blocked'?'none':
|
|
26
|
+
status.state==='fixture_completed'&&status.code==='qa_blocked'?'none':
|
|
27
|
+
status.state==='fixture_completed'&&status.code==='qa_execution_unknown'?'reconcile':
|
|
28
|
+
status.state==='fixture_completed'&&['qa_failed','qa_result_blocked'].includes(status.code)?'none':
|
|
29
|
+
status.state==='fixture_completed'?'qa':'none';
|
|
30
|
+
const summary=(operation,status,outcome)=>freeze({version:1,workflow:'cm-ai',operation:operation.operation,
|
|
31
|
+
requestDigest:digest(operation),identity:status.identity,outcome,state:status.state,code:status.code??null,
|
|
32
|
+
packageDigest:status.packageDigest??null,pendingAction:pendingAction(status)});
|
|
33
|
+
const correctionSummary=(operation,status)=>status.code==='correction_review_required'
|
|
34
|
+
?summary(operation,status,'blocked'):null;
|
|
35
|
+
|
|
36
|
+
function readOperation(raw) {
|
|
37
|
+
const operation=json(raw),keys=['version','operation','requestId','identity'];
|
|
38
|
+
if(['decision','complete','qa','qa_result','context_refresh','finish','run_finalize'].includes(operation?.operation))keys.push('packageDigest');
|
|
39
|
+
if(['qa_result','context_refresh','finish','run_finalize'].includes(operation?.operation))keys.push('testRunId');
|
|
40
|
+
shape(operation,keys);
|
|
41
|
+
need(operation.version===1&&['advance','start','status','decision','complete','qa','qa_result','context_refresh','finish','run_finalize','cancel','resume']
|
|
42
|
+
.includes(operation.operation));
|
|
43
|
+
id(operation.requestId);validIdentity(operation.identity);
|
|
44
|
+
if(['decision','complete','qa','qa_result','context_refresh','finish','run_finalize'].includes(operation.operation))hex(operation.packageDigest);
|
|
45
|
+
if(operation.operation==='qa_result')id(operation.testRunId);
|
|
46
|
+
if(['context_refresh','finish','run_finalize'].includes(operation.operation)){
|
|
47
|
+
need(operation.testRunId===null||typeof operation.testRunId==='string');
|
|
48
|
+
if(operation.testRunId!==null)id(operation.testRunId);
|
|
49
|
+
}
|
|
50
|
+
return operation;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const rejected=(identity,error)=>{
|
|
54
|
+
let code='invalid_input';
|
|
55
|
+
try{const descriptor=Object.getOwnPropertyDescriptor(error,'code');
|
|
56
|
+
if(descriptor&&Object.hasOwn(descriptor,'value')&&typeof descriptor.value==='string'
|
|
57
|
+
&&/^[a-z][a-z0-9_]{0,63}$/.test(descriptor.value))code=descriptor.value;
|
|
58
|
+
}catch{}
|
|
59
|
+
return freeze({version:1,workflow:'cm-ai',operation:null,requestDigest:null,identity,
|
|
60
|
+
outcome:'rejected',state:null,code,packageDigest:null,pendingAction:'none'});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
function validateHostDecision(decision,status) {
|
|
64
|
+
if(decision?.status==='denied'){
|
|
65
|
+
shape(decision,['status','code']);need(decision.code==='permission_denied','invalid_host_decision');return 'denied';
|
|
66
|
+
}
|
|
67
|
+
shape(decision,['status']);need(decision.status==='approved','invalid_host_decision');
|
|
68
|
+
need(status.packageDigest!==null,'stale_decision');return 'approved';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function effectSummary(operation,result,runner,identity) {
|
|
72
|
+
if(result?.outcome==='rejected'){
|
|
73
|
+
const rejection=json(result);shape(rejection,['outcome','code']);id(rejection.code);
|
|
74
|
+
const current=boundStatus(runner.status(),identity);
|
|
75
|
+
return summary(operation,{...current,code:rejection.code},'rejected');
|
|
76
|
+
}
|
|
77
|
+
if(operation.operation==='decision'&&identity.attempt===1&&result?.state==='changes_requested'){
|
|
78
|
+
const next={...identity,attempt:2};
|
|
79
|
+
boundStatus(runner.status(),next);
|
|
80
|
+
return summary(operation,boundStatus(result,next),'advanced');
|
|
81
|
+
}
|
|
82
|
+
return summary(operation,boundStatus(result,identity),'advanced');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function contextEvidence(options,identity,operation) {
|
|
86
|
+
try {
|
|
87
|
+
const decision=inspectCmAiQaDecision({specsDir:options.specsDir,feature:options.feature,identity,
|
|
88
|
+
packageDigest:operation.packageDigest});
|
|
89
|
+
if(operation.testRunId===null)need(decision.status==='skipped','context_not_ready');
|
|
90
|
+
else {
|
|
91
|
+
need(decision.status==='triggered','context_not_ready');
|
|
92
|
+
const result=inspectCmAiQaResult({specsDir:options.specsDir,feature:options.feature,identity,
|
|
93
|
+
packageDigest:operation.packageDigest,testRunId:operation.testRunId});
|
|
94
|
+
need(result.status==='passed','context_not_ready');
|
|
95
|
+
}
|
|
96
|
+
} catch {need(false,'context_not_ready');}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const contextSummary=(operation,status,refresh)=>freeze({version:1,workflow:'cm-ai',operation:operation.operation,
|
|
100
|
+
requestDigest:digest(operation),identity:status.identity,outcome:'refreshed',state:status.state,
|
|
101
|
+
code:refresh.state==='complete'?'context_complete':'context_refreshed',packageDigest:status.packageDigest,
|
|
102
|
+
pendingAction:refresh.state==='complete'?'finish':'start_next_task',nextTask:refresh.nextTask,
|
|
103
|
+
contextDigest:refresh.contextDigest,contextFiles:refresh.contextFiles});
|
|
104
|
+
|
|
105
|
+
function validateDocumentationResult(result,status,refresh) {
|
|
106
|
+
shape(result,['syncId','identity','packageDigest','contextDigest','status','reason','at']);
|
|
107
|
+
id(result.syncId);validIdentity(result.identity);hex(result.packageDigest);hex(result.contextDigest);
|
|
108
|
+
need(sameIdentity(result.identity,status.identity),'identity_mismatch');
|
|
109
|
+
need(result.packageDigest===status.packageDigest&&result.contextDigest===refresh.contextDigest,'stale_documentation');
|
|
110
|
+
need(['completed','blocked'].includes(result.status),'invalid_documentation_result');
|
|
111
|
+
text(result.reason);need(result.reason.length<=200&&!/[\n\r\0]/.test(result.reason),'invalid_documentation_result');
|
|
112
|
+
need(typeof result.at==='string'
|
|
113
|
+
&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:Z|[+-]\d{2}:\d{2})$/.test(result.at)
|
|
114
|
+
&&Number.isFinite(Date.parse(result.at)),'invalid_documentation_result');
|
|
115
|
+
return result.status;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function createCmAiConversationEntry(options) {
|
|
119
|
+
const optionKeys=['specsDir','codeProject','feature','identity','runner'];
|
|
120
|
+
if(options&&Object.hasOwn(options,'hostDecision'))optionKeys.push('hostDecision');
|
|
121
|
+
if(options&&Object.hasOwn(options,'hostDecisionProvider'))optionKeys.push('hostDecisionProvider');
|
|
122
|
+
if(options&&Object.hasOwn(options,'developmentAttempt'))optionKeys.push('developmentAttempt');
|
|
123
|
+
if(options&&Object.hasOwn(options,'qaDecision'))optionKeys.push('qaDecision');
|
|
124
|
+
if(options&&Object.hasOwn(options,'qaDecisionProvider'))optionKeys.push('qaDecisionProvider');
|
|
125
|
+
if(options&&Object.hasOwn(options,'qaExecutor'))optionKeys.push('qaExecutor');
|
|
126
|
+
if(options&&Object.hasOwn(options,'qaLogHome'))optionKeys.push('qaLogHome');
|
|
127
|
+
if(options&&Object.hasOwn(options,'applicableAgentFiles'))optionKeys.push('applicableAgentFiles');
|
|
128
|
+
if(options&&Object.hasOwn(options,'documentationResult'))optionKeys.push('documentationResult');
|
|
129
|
+
if(options&&Object.hasOwn(options,'documentationProvider'))optionKeys.push('documentationProvider');
|
|
130
|
+
shape(options,optionKeys);
|
|
131
|
+
if(Object.hasOwn(options,'developmentAttempt'))need([1,2].includes(options.developmentAttempt),'invalid_development_attempt');
|
|
132
|
+
text(options.specsDir);text(options.codeProject);text(options.feature);
|
|
133
|
+
const ownerIdentity=json(options.identity);validIdentity(ownerIdentity);
|
|
134
|
+
const runner=options.runner;
|
|
135
|
+
const runnerKeys=['executeEffect','status','cancel','run'];
|
|
136
|
+
if(runner&&Object.hasOwn(runner,'attachLearningEvidence'))runnerKeys.push('attachLearningEvidence');
|
|
137
|
+
if(runner&&Object.hasOwn(runner,'inspectFixAssociation'))runnerKeys.push('inspectFixAssociation');
|
|
138
|
+
if(runner&&Object.hasOwn(runner,'acceptCompletedFix'))runnerKeys.push('acceptCompletedFix');
|
|
139
|
+
if(runner&&Object.hasOwn(runner,'inspectBootstrapAdmission'))runnerKeys.push('inspectBootstrapAdmission');
|
|
140
|
+
shape(runner,runnerKeys);
|
|
141
|
+
for(const name of ['executeEffect','status','cancel','run'])need(typeof runner[name]==='function');
|
|
142
|
+
if(Object.hasOwn(runner,'attachLearningEvidence'))need(typeof runner.attachLearningEvidence==='function');
|
|
143
|
+
if(Object.hasOwn(runner,'inspectFixAssociation'))need(typeof runner.inspectFixAssociation==='function');
|
|
144
|
+
if(Object.hasOwn(runner,'acceptCompletedFix'))need(typeof runner.acceptCompletedFix==='function');
|
|
145
|
+
if(Object.hasOwn(runner,'inspectBootstrapAdmission'))need(typeof runner.inspectBootstrapAdmission==='function');
|
|
146
|
+
|
|
147
|
+
const hostDecision=Object.hasOwn(options,'hostDecision')?json(options.hostDecision):null;
|
|
148
|
+
let hostDecisionProvider=null,pendingReviewDecision=null;
|
|
149
|
+
if(Object.hasOwn(options,'hostDecisionProvider')){
|
|
150
|
+
shape(options.hostDecisionProvider,['decide','timeoutMs']);
|
|
151
|
+
const {decide,timeoutMs}=options.hostDecisionProvider;
|
|
152
|
+
need(typeof decide==='function'&&Number.isInteger(timeoutMs)&&timeoutMs>=1&&timeoutMs<=60000);
|
|
153
|
+
need(hostDecision===null);hostDecisionProvider={decide,timeoutMs};
|
|
154
|
+
}
|
|
155
|
+
const qaDecision=Object.hasOwn(options,'qaDecision')?json(options.qaDecision):null;
|
|
156
|
+
const qaProvider=options.qaDecisionProvider??null;
|
|
157
|
+
if(qaProvider!==null){
|
|
158
|
+
shape(qaProvider,['decide','timeoutMs']);
|
|
159
|
+
need(typeof qaProvider.decide==='function'&&Number.isInteger(qaProvider.timeoutMs)
|
|
160
|
+
&&qaProvider.timeoutMs>=1&&qaProvider.timeoutMs<=60000);
|
|
161
|
+
need(qaDecision===null);
|
|
162
|
+
}
|
|
163
|
+
const decideQa=qaProvider?.decide,qaTimeout=qaProvider?.timeoutMs;
|
|
164
|
+
let pendingQa=null;
|
|
165
|
+
let qaExecutor=null,pendingExecution=null,cancellationEpoch=0;
|
|
166
|
+
if(Object.hasOwn(options,'qaExecutor')){
|
|
167
|
+
shape(options.qaExecutor,['mode','caseCount','timeoutMs','run',
|
|
168
|
+
...(Object.hasOwn(options.qaExecutor,'configuration')?['configuration']:[])]);
|
|
169
|
+
const {run,...config}=options.qaExecutor;
|
|
170
|
+
need(typeof run==='function');qaExecutor={...json(config),run};
|
|
171
|
+
need(['commands','browser','all'].includes(config.mode)&&Number.isSafeInteger(config.caseCount)&&config.caseCount>0);
|
|
172
|
+
need(Number.isInteger(config.timeoutMs)&&config.timeoutMs>=1&&config.timeoutMs<=3600000);
|
|
173
|
+
}
|
|
174
|
+
const applicableAgentFiles=Object.hasOwn(options,'applicableAgentFiles')?json(options.applicableAgentFiles):null;
|
|
175
|
+
const documentationResult=Object.hasOwn(options,'documentationResult')?json(options.documentationResult):null;
|
|
176
|
+
let documentationProvider=null,pendingDocumentation=null,inspectedDocumentation=null;
|
|
177
|
+
if(Object.hasOwn(options,'documentationProvider')){
|
|
178
|
+
shape(options.documentationProvider,['inspect','timeoutMs']);
|
|
179
|
+
const {inspect,timeoutMs}=options.documentationProvider;
|
|
180
|
+
need(typeof inspect==='function'&&Number.isInteger(timeoutMs)&&timeoutMs>=1&&timeoutMs<=60000);
|
|
181
|
+
need(documentationResult===null);documentationProvider={inspect,timeoutMs};
|
|
182
|
+
}
|
|
183
|
+
if(Object.hasOwn(options,'qaLogHome'))text(options.qaLogHome);
|
|
184
|
+
|
|
185
|
+
async function documentationFor(status,refresh){
|
|
186
|
+
if(documentationProvider===null)return documentationResult;
|
|
187
|
+
const binding=json({specsDir:options.specsDir,codeProject:options.codeProject,feature:options.feature,
|
|
188
|
+
identity:status.identity,packageDigest:status.packageDigest,contextDigest:refresh.contextDigest});
|
|
189
|
+
const syncId=`docs-${digest(binding).slice(0,48)}`;
|
|
190
|
+
if(inspectedDocumentation?.syncId===syncId)return inspectedDocumentation;
|
|
191
|
+
need(pendingDocumentation===null,'documentation_pending');
|
|
192
|
+
need(!status.cancellationRequested&&!status.cancelAfterCommit,'cancelled');
|
|
193
|
+
const controller=new AbortController();pendingDocumentation=controller;
|
|
194
|
+
let timer,timedOut=false;
|
|
195
|
+
try{
|
|
196
|
+
const interrupted=new Promise((_,reject)=>{
|
|
197
|
+
controller.signal.addEventListener('abort',()=>reject(Object.assign(new Error('Documentation interrupted'),
|
|
198
|
+
{code:timedOut?'documentation_timeout':'cancelled'})),{once:true});
|
|
199
|
+
timer=setTimeout(()=>{timedOut=true;controller.abort();},documentationProvider.timeoutMs);
|
|
200
|
+
});
|
|
201
|
+
const result=json(await Promise.race([Promise.resolve().then(()=>{
|
|
202
|
+
need(!controller.signal.aborted,'cancelled');
|
|
203
|
+
return documentationProvider.inspect(freeze({...binding,syncId}),controller.signal);
|
|
204
|
+
}),interrupted]));
|
|
205
|
+
need(!controller.signal.aborted,'cancelled');need(result.syncId===syncId,'stale_documentation');
|
|
206
|
+
const current=boundStatus(runner.status(),status.identity);
|
|
207
|
+
need(current.state==='fixture_completed'&¤t.code==null&¤t.packageDigest===status.packageDigest,'stale_documentation');
|
|
208
|
+
const reread=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,
|
|
209
|
+
feature:options.feature,applicableAgentFiles});
|
|
210
|
+
need(reread.state==='complete'&&reread.contextDigest===refresh.contextDigest,'stale_documentation');
|
|
211
|
+
validateDocumentationResult(result,current,reread);
|
|
212
|
+
if(result.status==='completed')inspectedDocumentation=result;
|
|
213
|
+
return result;
|
|
214
|
+
}finally{clearTimeout(timer);pendingDocumentation=null;}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async function route(raw) {
|
|
218
|
+
const operation=readOperation(raw);
|
|
219
|
+
need(sameTask(operation.identity,ownerIdentity),'identity_mismatch');
|
|
220
|
+
need(operation.identity.attempt>=ownerIdentity.attempt,'identity_mismatch');
|
|
221
|
+
const admission=['start','resume'].includes(operation.operation)
|
|
222
|
+
?runner.inspectBootstrapAdmission?.()??inspectCmAiAdmission({specsDir:options.specsDir,codeProject:options.codeProject}):null;
|
|
223
|
+
if(admission&&admission.state!=='ready'){
|
|
224
|
+
// Original callers still stop before reading runner state. A caller using
|
|
225
|
+
// a newer attempt must bind it to the runner before we report its block.
|
|
226
|
+
const blockedIdentity=sameIdentity(operation.identity,ownerIdentity)?ownerIdentity:
|
|
227
|
+
boundStatus(runner.status(),operation.identity).identity;
|
|
228
|
+
return summary(operation,{state:admission.state,code:admission.reason,
|
|
229
|
+
identity:blockedIdentity,packageDigest:null},'awaiting');
|
|
230
|
+
}
|
|
231
|
+
const initialStatus=runner.status();
|
|
232
|
+
const identity=json(initialStatus.identity);validIdentity(identity);
|
|
233
|
+
need(sameTask(identity,ownerIdentity)&&identity.attempt>=ownerIdentity.attempt,'identity_mismatch');
|
|
234
|
+
// Stable run-definition identity can query/control or resume the current
|
|
235
|
+
// attempt. Package-bound mutations must name the current attempt exactly.
|
|
236
|
+
const stableControl=['status','cancel','advance','resume'].includes(operation.operation)
|
|
237
|
+
&&sameIdentity(operation.identity,ownerIdentity);
|
|
238
|
+
need(sameIdentity(operation.identity,identity)||stableControl,'identity_mismatch');
|
|
239
|
+
if(operation.operation==='advance'){
|
|
240
|
+
const startedEpoch=cancellationEpoch;
|
|
241
|
+
const notCancelled=()=>{const current=runner.status();
|
|
242
|
+
need(startedEpoch===cancellationEpoch&&!current.cancellationRequested&&!current.cancelAfterCommit,'cancelled');};
|
|
243
|
+
// Reuse the runner's two-attempt lifecycle, including its fresh review
|
|
244
|
+
// identity and review_limit. Never retry unknown/provider failures.
|
|
245
|
+
const call=(name,packageDigest,extra={})=>route({version:1,operation:name,
|
|
246
|
+
requestId:operation.requestId,identity:runner.status().identity,...(packageDigest===undefined?{}:{packageDigest}),...extra});
|
|
247
|
+
let result=await call('status');
|
|
248
|
+
for(let round=identity.attempt;round<=2;round++){
|
|
249
|
+
if(result.code===null&&['ready','changes_requested'].includes(result.state))result=await call('start');
|
|
250
|
+
if(['reported','advanced'].includes(result.outcome)&&result.code===null&&result.state==='awaiting_review')
|
|
251
|
+
result=await call('decision',result.packageDigest);
|
|
252
|
+
if(result.outcome==='advanced'&&result.code===null&&result.state==='changes_requested'
|
|
253
|
+
&&result.identity.attempt===round+1)continue;
|
|
254
|
+
if(['reported','advanced'].includes(result.outcome)&&result.code===null&&result.state==='approved')
|
|
255
|
+
result=await call('complete',result.packageDigest);
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
if(['reported','advanced'].includes(result.outcome)&&result.code===null&&result.state==='fixture_completed'){
|
|
259
|
+
let qaTestRunId=null;
|
|
260
|
+
notCancelled();
|
|
261
|
+
result=await call('qa',result.packageDigest);
|
|
262
|
+
if(result.outcome==='recorded'&&result.code==='qa_triggered'&&qaExecutor!==null){
|
|
263
|
+
notCancelled();
|
|
264
|
+
need(pendingExecution===null,'qa_execution_pending');
|
|
265
|
+
const binding={specsDir:options.specsDir,feature:options.feature,identity:result.identity,packageDigest:result.packageDigest};
|
|
266
|
+
let previous;
|
|
267
|
+
try{previous=latestCmAiQaRun(binding);}
|
|
268
|
+
catch(error){
|
|
269
|
+
if(error.code==='qa_result_incomplete')return summary(operation,{...runner.status(),code:'qa_execution_unknown'},'blocked');
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
let testRunId=previous?.testRunId;
|
|
273
|
+
const accepted=runner.status().acceptedQaFix;
|
|
274
|
+
const repaired=previous?.status==='failed'&&accepted?.testRunId===previous.testRunId;
|
|
275
|
+
if(previous===null||repaired){
|
|
276
|
+
// Later rounds require an original completed child accepted by the
|
|
277
|
+
// parent journal. Unknown executions and unrepaired failures stop.
|
|
278
|
+
const qaRound=repaired?accepted.qaRound+1:1;
|
|
279
|
+
need(qaRound>=1&&qaRound<=3,'qa_round_invalid');
|
|
280
|
+
testRunId=`qa-${digest(repaired?{...binding,qaRound,repair:accepted.evidenceDigest}:binding).slice(0,48)}`;
|
|
281
|
+
const invocation={...binding,codeProject:options.codeProject,testRunId,mode:qaExecutor.mode,caseCount:qaExecutor.caseCount,
|
|
282
|
+
...(repaired?{qaRound}: {})};
|
|
283
|
+
const logInput={...invocation,...(Object.hasOwn(options,'qaLogHome')?{logHome:options.qaLogHome}:{})};
|
|
284
|
+
notCancelled();
|
|
285
|
+
recordCmAiQaRun({...logInput,phase:'start'});
|
|
286
|
+
const controller=new AbortController();pendingExecution=controller;
|
|
287
|
+
let timer,timedOut=false;
|
|
288
|
+
try{
|
|
289
|
+
const interrupted=new Promise((_,reject)=>{
|
|
290
|
+
controller.signal.addEventListener('abort',()=>reject(Object.assign(new Error('QA interrupted'),
|
|
291
|
+
{code:timedOut?'qa_execution_timeout':'cancelled'})),{once:true});
|
|
292
|
+
timer=setTimeout(()=>{timedOut=true;controller.abort();},qaExecutor.timeoutMs);
|
|
293
|
+
});
|
|
294
|
+
const executed=await Promise.race([Promise.resolve().then(()=>{
|
|
295
|
+
notCancelled();
|
|
296
|
+
need(!controller.signal.aborted,'cancelled');
|
|
297
|
+
return qaExecutor.run(freeze(invocation),controller.signal);
|
|
298
|
+
}),interrupted]);
|
|
299
|
+
need(!controller.signal.aborted,'cancelled');
|
|
300
|
+
const current=boundStatus(runner.status(),result.identity);
|
|
301
|
+
need(current.state==='fixture_completed'&¤t.code==null&¤t.packageDigest===result.packageDigest,'stale_qa');
|
|
302
|
+
recordCmAiQaRun({...logInput,phase:'complete',result:executed});
|
|
303
|
+
}finally{clearTimeout(timer);pendingExecution=null;}
|
|
304
|
+
}
|
|
305
|
+
result=await call('qa_result',result.packageDigest,{testRunId});
|
|
306
|
+
qaTestRunId=testRunId;
|
|
307
|
+
if(result.code==='qa_passed'&&applicableAgentFiles!==null)
|
|
308
|
+
result=await call('context_refresh',result.packageDigest,{testRunId});
|
|
309
|
+
}
|
|
310
|
+
// Only the already-bound host decision can skip execution. A triggered
|
|
311
|
+
// QA stops at qa_execution until the actual executor supplies evidence.
|
|
312
|
+
if(result.outcome==='recorded'&&result.code==='qa_skipped'&&applicableAgentFiles!==null)
|
|
313
|
+
result=await call('context_refresh',result.packageDigest,{testRunId:null});
|
|
314
|
+
if(result.code==='context_complete'){
|
|
315
|
+
notCancelled();
|
|
316
|
+
result=await call('finish',result.packageDigest,{testRunId:qaTestRunId});
|
|
317
|
+
if(result.code==='documentation_synced'){
|
|
318
|
+
notCancelled();
|
|
319
|
+
result=await call('run_finalize',result.packageDigest,{testRunId:qaTestRunId});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
// Next-task execution and QA execution still need their host adapters;
|
|
324
|
+
// a refreshed nextTask is not permission to dispatch it or claim run_done.
|
|
325
|
+
return freeze({...result,operation:'advance',requestDigest:digest(operation)});
|
|
326
|
+
}
|
|
327
|
+
if(operation.operation==='status'){
|
|
328
|
+
const status=boundStatus(initialStatus,identity);
|
|
329
|
+
return summary(operation,status,'reported');
|
|
330
|
+
}
|
|
331
|
+
if(operation.operation==='cancel'){
|
|
332
|
+
cancellationEpoch++;
|
|
333
|
+
pendingReviewDecision?.abort();
|
|
334
|
+
pendingQa?.abort();
|
|
335
|
+
pendingExecution?.abort();
|
|
336
|
+
pendingDocumentation?.abort();
|
|
337
|
+
const status=boundStatus(runner.cancel(),identity);
|
|
338
|
+
return summary(operation,status,'cancelled');
|
|
339
|
+
}
|
|
340
|
+
if(operation.operation==='decision'){
|
|
341
|
+
const status=boundStatus(runner.status(),identity);
|
|
342
|
+
need(status.packageDigest===operation.packageDigest,'stale_decision');
|
|
343
|
+
let decision=hostDecision;
|
|
344
|
+
if(hostDecisionProvider!==null){
|
|
345
|
+
// A historical terminal or outstanding invocation is owned by the runner;
|
|
346
|
+
// never ask for fresh authorization to replay or reopen it.
|
|
347
|
+
if(status.state!=='awaiting_review'||status.code!==null)return summary(operation,status,'reported');
|
|
348
|
+
need(pendingReviewDecision===null,'review_decision_pending');
|
|
349
|
+
need(!status.cancellationRequested&&!status.cancelAfterCommit,'cancelled');
|
|
350
|
+
const controller=new AbortController();pendingReviewDecision=controller;
|
|
351
|
+
let timer,timedOut=false;
|
|
352
|
+
try{
|
|
353
|
+
const interrupted=new Promise((_,reject)=>{
|
|
354
|
+
controller.signal.addEventListener('abort',()=>reject(Object.assign(new Error('Review decision interrupted'),
|
|
355
|
+
{code:timedOut?'review_decision_timeout':'cancelled'})),{once:true});
|
|
356
|
+
timer=setTimeout(()=>{timedOut=true;controller.abort();},hostDecisionProvider.timeoutMs);
|
|
357
|
+
});
|
|
358
|
+
const binding=freeze(json({specsDir:options.specsDir,codeProject:options.codeProject,feature:options.feature,
|
|
359
|
+
identity,packageDigest:operation.packageDigest}));
|
|
360
|
+
decision=json(await Promise.race([Promise.resolve().then(()=>{
|
|
361
|
+
need(!controller.signal.aborted,'cancelled');return hostDecisionProvider.decide(binding,controller.signal);
|
|
362
|
+
}),interrupted]));
|
|
363
|
+
need(!controller.signal.aborted,'cancelled');
|
|
364
|
+
const current=boundStatus(runner.status(),identity);
|
|
365
|
+
need(current.state===status.state&¤t.code===status.code
|
|
366
|
+
&¤t.packageDigest===operation.packageDigest,'stale_decision');
|
|
367
|
+
need(!current.cancellationRequested&&!current.cancelAfterCommit,'cancelled');
|
|
368
|
+
}finally{clearTimeout(timer);pendingReviewDecision=null;}
|
|
369
|
+
}
|
|
370
|
+
if(decision===null)return summary(operation,{...status,code:'decision_required'},'awaiting');
|
|
371
|
+
if(validateHostDecision(decision,status)==='denied')
|
|
372
|
+
return summary(operation,{...status,code:'permission_denied'},'denied');
|
|
373
|
+
const result=await runner.executeEffect({version:1,id:`review-${identity.attempt}`,identity,kind:'review'});
|
|
374
|
+
return effectSummary(operation,result,runner,identity);
|
|
375
|
+
}
|
|
376
|
+
if(operation.operation==='complete'){
|
|
377
|
+
const status=boundStatus(runner.status(),identity);
|
|
378
|
+
need(status.packageDigest===operation.packageDigest,'stale_completion');
|
|
379
|
+
const correction=correctionSummary(operation,status);if(correction)return correction;
|
|
380
|
+
need(['approved','fixture_completed'].includes(status.state),'completion_not_ready');
|
|
381
|
+
const result=await runner.executeEffect({version:1,id:`complete-${identity.attempt}`,identity,kind:'complete'});
|
|
382
|
+
return effectSummary(operation,result,runner,identity);
|
|
383
|
+
}
|
|
384
|
+
if(operation.operation==='qa'){
|
|
385
|
+
const status=boundStatus(runner.status(),identity);
|
|
386
|
+
need(status.packageDigest===operation.packageDigest,'stale_qa');
|
|
387
|
+
const correction=correctionSummary(operation,status);if(correction)return correction;
|
|
388
|
+
need(status.state==='fixture_completed','qa_not_ready');
|
|
389
|
+
let decision=qaDecision;
|
|
390
|
+
if(qaProvider!==null){
|
|
391
|
+
need(pendingQa===null,'qa_decision_pending');
|
|
392
|
+
const binding={specsDir:options.specsDir,feature:options.feature,identity,packageDigest:operation.packageDigest};
|
|
393
|
+
decision=findCmAiQaDecision(binding);
|
|
394
|
+
// A bound historical decision is evidence, not a fresh proposal. Keep
|
|
395
|
+
// the existing downstream compatibility path; do not rewrite its log.
|
|
396
|
+
if(decision!==null)return summary(operation,{...status,code:`qa_${decision.status}`},'recorded');
|
|
397
|
+
if(decision===null){
|
|
398
|
+
const controller=new AbortController();pendingQa=controller;
|
|
399
|
+
let timer,timedOut=false;
|
|
400
|
+
try{
|
|
401
|
+
const interrupted=new Promise((_,reject)=>{
|
|
402
|
+
controller.signal.addEventListener('abort',()=>reject(Object.assign(new Error('QA decision interrupted'),
|
|
403
|
+
{code:timedOut?'qa_decision_timeout':'cancelled'})),{once:true});
|
|
404
|
+
timer=setTimeout(()=>{timedOut=true;controller.abort();},qaTimeout);
|
|
405
|
+
});
|
|
406
|
+
decision=json(await Promise.race([
|
|
407
|
+
Promise.resolve().then(()=>{need(!controller.signal.aborted,'cancelled');
|
|
408
|
+
return decideQa(freeze({...binding,codeProject:options.codeProject}),controller.signal);}),interrupted]));
|
|
409
|
+
need(!controller.signal.aborted,'cancelled');
|
|
410
|
+
const current=boundStatus(runner.status(),identity);
|
|
411
|
+
need(current.state==='fixture_completed'&¤t.code==null&¤t.packageDigest===operation.packageDigest,'stale_qa');
|
|
412
|
+
}finally{clearTimeout(timer);pendingQa=null;}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if(decision===null)return summary(operation,{...status,code:'qa_decision_required'},'awaiting');
|
|
416
|
+
if(decision.status==='skipped'){
|
|
417
|
+
const admission=inspectCmAiAdmission({specsDir:options.specsDir,codeProject:options.codeProject});
|
|
418
|
+
if(!['ready','complete'].includes(admission.state))
|
|
419
|
+
return summary(operation,{...status,code:admission.reason},'awaiting');
|
|
420
|
+
const feature=admission.features.find(item=>item.name===options.feature);
|
|
421
|
+
need(feature,'qa_policy_unavailable');
|
|
422
|
+
// N6 feature completion is a mandatory trigger, regardless of score.
|
|
423
|
+
// Ask for the proper bound decision; do not synthesize authorization.
|
|
424
|
+
if(feature.pending===0)return summary(operation,{...status,code:'qa_mandatory_required'},'awaiting');
|
|
425
|
+
}
|
|
426
|
+
const input={specsDir:options.specsDir,codeProject:options.codeProject,feature:options.feature,identity,
|
|
427
|
+
packageDigest:operation.packageDigest,decision};
|
|
428
|
+
if(Object.hasOwn(options,'qaLogHome'))input.logHome=options.qaLogHome;
|
|
429
|
+
recordCmAiQaDecision(input);
|
|
430
|
+
return summary(operation,{...status,code:`qa_${decision.status}`},'recorded');
|
|
431
|
+
}
|
|
432
|
+
if(operation.operation==='qa_result'){
|
|
433
|
+
const status=boundStatus(runner.status(),identity);
|
|
434
|
+
need(status.packageDigest===operation.packageDigest,'stale_qa');
|
|
435
|
+
const correction=correctionSummary(operation,status);if(correction)return correction;
|
|
436
|
+
need(status.state==='fixture_completed','qa_not_ready');
|
|
437
|
+
const result=inspectCmAiQaResult({specsDir:options.specsDir,feature:options.feature,identity,
|
|
438
|
+
packageDigest:operation.packageDigest,testRunId:operation.testRunId});
|
|
439
|
+
const code=result.status==='blocked'?'qa_result_blocked':`qa_${result.status}`;
|
|
440
|
+
if(result.status==='failed'){
|
|
441
|
+
const fixHandoff=readHostQaFixHandoff({specsDir:options.specsDir,codeProject:options.codeProject,
|
|
442
|
+
feature:options.feature,identity,packageDigest:operation.packageDigest,testRunId:operation.testRunId});
|
|
443
|
+
return freeze({...summary(operation,{...status,code},'verified'),fixHandoff,
|
|
444
|
+
pendingAction:fixHandoff.status==='authorization_required'?'fix_authorization':
|
|
445
|
+
fixHandoff.status==='dispatch_required'?'fix_dispatch':'none'});
|
|
446
|
+
}
|
|
447
|
+
return summary(operation,{...status,code},'verified');
|
|
448
|
+
}
|
|
449
|
+
if(operation.operation==='context_refresh'){
|
|
450
|
+
const status=boundStatus(runner.status(),identity);
|
|
451
|
+
need(status.packageDigest===operation.packageDigest,'stale_qa');
|
|
452
|
+
const correction=correctionSummary(operation,status);if(correction)return correction;
|
|
453
|
+
need(status.state==='fixture_completed','context_not_ready');
|
|
454
|
+
contextEvidence(options,identity,operation);
|
|
455
|
+
need(applicableAgentFiles!==null,'context_invalid');
|
|
456
|
+
const refresh=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,
|
|
457
|
+
feature:options.feature,applicableAgentFiles});
|
|
458
|
+
if(!['ready','complete'].includes(refresh.state))return summary(operation,{state:refresh.state,
|
|
459
|
+
code:refresh.reason,identity,packageDigest:status.packageDigest},'awaiting');
|
|
460
|
+
return contextSummary(operation,status,refresh);
|
|
461
|
+
}
|
|
462
|
+
if(operation.operation==='finish'){
|
|
463
|
+
const status=boundStatus(runner.status(),identity);
|
|
464
|
+
need(status.packageDigest===operation.packageDigest,'stale_qa');
|
|
465
|
+
const correction=correctionSummary(operation,status);if(correction)return correction;
|
|
466
|
+
need(status.state==='fixture_completed','run_not_ready');
|
|
467
|
+
contextEvidence(options,identity,operation);
|
|
468
|
+
need(applicableAgentFiles!==null,'context_invalid');
|
|
469
|
+
const refresh=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,
|
|
470
|
+
feature:options.feature,applicableAgentFiles});
|
|
471
|
+
need(refresh.state==='complete','run_not_ready');
|
|
472
|
+
const documentationEpoch=cancellationEpoch;
|
|
473
|
+
const documentation=await documentationFor(status,refresh);
|
|
474
|
+
need(documentationEpoch===cancellationEpoch,'cancelled');
|
|
475
|
+
contextEvidence(options,identity,operation);
|
|
476
|
+
const current=boundStatus(runner.status(),identity);
|
|
477
|
+
need(current.state==='fixture_completed'&¤t.code==null&¤t.packageDigest===status.packageDigest,'stale_documentation');
|
|
478
|
+
if(documentation===null)
|
|
479
|
+
return summary(operation,{...status,code:'documentation_sync_required'},'awaiting');
|
|
480
|
+
const result=validateDocumentationResult(documentation,status,refresh);
|
|
481
|
+
if(result==='blocked')return summary(operation,{...status,code:'documentation_sync_blocked'},'blocked');
|
|
482
|
+
return freeze({...summary(operation,{...status,code:'documentation_synced'},'verified'),
|
|
483
|
+
contextDigest:refresh.contextDigest});
|
|
484
|
+
}
|
|
485
|
+
if(operation.operation==='run_finalize'){
|
|
486
|
+
const status=boundStatus(runner.status(),identity);
|
|
487
|
+
need(status.packageDigest===operation.packageDigest,'stale_qa');
|
|
488
|
+
const correction=correctionSummary(operation,status);if(correction)return correction;
|
|
489
|
+
need(status.state==='fixture_completed','run_not_ready');
|
|
490
|
+
contextEvidence(options,identity,operation);
|
|
491
|
+
need(applicableAgentFiles!==null,'context_invalid');
|
|
492
|
+
const refresh=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,
|
|
493
|
+
feature:options.feature,applicableAgentFiles});
|
|
494
|
+
need(refresh.state==='complete','run_not_ready');
|
|
495
|
+
const documentationEpoch=cancellationEpoch;
|
|
496
|
+
const documentation=await documentationFor(status,refresh);need(documentation!==null,'run_not_ready');
|
|
497
|
+
need(documentationEpoch===cancellationEpoch,'cancelled');
|
|
498
|
+
contextEvidence(options,identity,operation);
|
|
499
|
+
const current=boundStatus(runner.status(),identity);
|
|
500
|
+
need(!current.cancellationRequested&&!current.cancelAfterCommit,'cancelled');
|
|
501
|
+
need(current.state==='fixture_completed'&¤t.code==null&¤t.packageDigest===status.packageDigest,'stale_documentation');
|
|
502
|
+
const finalContext=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,
|
|
503
|
+
feature:options.feature,applicableAgentFiles});
|
|
504
|
+
need(finalContext.state==='complete'&&finalContext.contextDigest===refresh.contextDigest,'stale_documentation');
|
|
505
|
+
const documentationStatus=validateDocumentationResult(documentation,status,refresh);
|
|
506
|
+
if(documentationStatus==='blocked')
|
|
507
|
+
return summary(operation,{...status,code:'documentation_sync_blocked'},'blocked');
|
|
508
|
+
const input={specsDir:options.specsDir,codeProject:options.codeProject,feature:options.feature,identity,
|
|
509
|
+
packageDigest:operation.packageDigest,contextDigest:refresh.contextDigest,
|
|
510
|
+
documentationSyncId:documentation.syncId};
|
|
511
|
+
if(Object.hasOwn(options,'qaLogHome'))input.logHome=options.qaLogHome;
|
|
512
|
+
const result=recordCmAiRunDone(input);
|
|
513
|
+
return freeze({version:1,workflow:'cm-ai',operation:operation.operation,requestDigest:digest(operation),identity,
|
|
514
|
+
outcome:'finalized',state:'run_done',code:result.degraded?'run_done_degraded':'run_done',
|
|
515
|
+
packageDigest:operation.packageDigest,pendingAction:'none',contextDigest:refresh.contextDigest,
|
|
516
|
+
deduplicated:result.deduplicated,degraded:result.degraded});
|
|
517
|
+
}
|
|
518
|
+
need(['start','resume'].includes(operation.operation),'invalid_input');
|
|
519
|
+
need(admission.state==='ready'&&admission.nextTask?.feature===options.feature
|
|
520
|
+
&&admission.nextTask.id===identity.taskId,'task_mismatch');
|
|
521
|
+
const status=boundStatus(runner.status(),identity);
|
|
522
|
+
const developable=['ready','changes_requested'].includes(status.state);
|
|
523
|
+
const repeatable=operation.operation==='start'&&status.state==='awaiting_review';
|
|
524
|
+
if(!developable&&!repeatable)
|
|
525
|
+
return summary(operation,status,'reported');
|
|
526
|
+
// Launch authority is checked before any develop intent or Learning work.
|
|
527
|
+
// An unapproved next attempt is waiting, not a dispatched effect of unknown outcome.
|
|
528
|
+
if(developable&&Object.hasOwn(options,'developmentAttempt')&&options.developmentAttempt!==identity.attempt)
|
|
529
|
+
return summary(operation,{...status,code:'provider_development_authorization_required'},'awaiting');
|
|
530
|
+
const learningInput=inspectCmAiTaskLearningInput({specsDir:options.specsDir,codeProject:options.codeProject,
|
|
531
|
+
feature:options.feature,identity,applicableAgentFiles:applicableAgentFiles??[]},
|
|
532
|
+
{admission:runner.inspectBootstrapAdmission?.()??null});
|
|
533
|
+
const result=await runner.executeEffect({version:1,id:`develop-${identity.attempt}`,identity,kind:'develop',learningInput});
|
|
534
|
+
return effectSummary(operation,result,runner,identity);
|
|
535
|
+
}
|
|
536
|
+
const handle=async raw=>{try{return await route(raw);}catch(error){return rejected(ownerIdentity,error);}};
|
|
537
|
+
return Object.freeze({handle});
|
|
538
|
+
}
|