@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,35 @@
|
|
|
1
|
+
// Pure review data functions. Only task-runner owns invocation/registration.
|
|
2
|
+
import { digest,need,shape,id,text,json,freeze } from './effect-contract.mjs';
|
|
3
|
+
export function reviewPaths(pkg) {
|
|
4
|
+
return [...new Set([...pkg.changes.map(c=>c.path),...pkg.requirements.map(f=>f.path),
|
|
5
|
+
...(pkg.instructions??[]).map(file=>file.path),
|
|
6
|
+
...(pkg.bootstrapRequirements?.files??[]).map(file=>'specs:'+file.path)])].sort();
|
|
7
|
+
}
|
|
8
|
+
export function reviewResult(raw,pkg) {
|
|
9
|
+
return reviewResultForPaths(raw,pkg,reviewPaths(pkg));
|
|
10
|
+
}
|
|
11
|
+
export function reviewResultForPaths(raw,pkg,paths) {
|
|
12
|
+
const r=json(raw);shape(r,['verdict','packageDigest','examinedPaths','findings','summary']);
|
|
13
|
+
need(['approved','changes_requested','blocked'].includes(r.verdict));text(r.summary);
|
|
14
|
+
need(r.packageDigest===pkg.packageDigest,'review_package_mismatch');
|
|
15
|
+
need(digest(r.examinedPaths)===digest(paths),'missing_material');
|
|
16
|
+
need(Array.isArray(r.findings) && r.findings.length<=100);const ids=new Set();
|
|
17
|
+
for(const f of r.findings) {
|
|
18
|
+
shape(f,['id','severity','path','message','evidence']);id(f.id);need(!ids.has(f.id));ids.add(f.id);
|
|
19
|
+
need(['P0','P1','P2','P3'].includes(f.severity) && paths.includes(f.path));text(f.message);text(f.evidence);
|
|
20
|
+
}
|
|
21
|
+
const blocking=r.findings.filter(f=>f.severity!=='P3').length;
|
|
22
|
+
need(r.verdict!=='approved'||blocking===0,'contradictory_verdict');
|
|
23
|
+
need(r.verdict!=='changes_requested'||blocking>0,'contradictory_verdict');return r;
|
|
24
|
+
}
|
|
25
|
+
export function reviewReceipt({request,call,result,reviewPackage,developerProvider,fallbackReasons}) {
|
|
26
|
+
const checked=reviewResult(result,reviewPackage);
|
|
27
|
+
need(call.started===true && call.terminal==='succeeded' && call.requestDigest===request.requestDigest
|
|
28
|
+
&& call.resultDigest===digest(checked),'execution_mismatch');
|
|
29
|
+
const data={version:1,kind:'cm-review-receipt',id:call.invocationId,identity:request.identity,
|
|
30
|
+
packageDigest:reviewPackage.packageDigest,baseIdentity:reviewPackage.baseIdentity,
|
|
31
|
+
artifactDigest:reviewPackage.artifactDigest,requirementsDigest:reviewPackage.requirementsDigest,
|
|
32
|
+
checksDigest:reviewPackage.checksDigest,execution:json(call),
|
|
33
|
+
route:{mode:call.provider===developerProvider?'same-provider':'cross-provider',fallbackReasons},result:checked};
|
|
34
|
+
return json({...data,receiptDigest:digest(data)});
|
|
35
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Internal pure C2b payload validation. No filesystem or approval authority.
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {createHash} from 'node:crypto';
|
|
4
|
+
import {need,shape,hex,json,digest,validIdentity} from './effect-contract.mjs';
|
|
5
|
+
import {reviewSpecsPath} from './review-package.mjs';
|
|
6
|
+
const FILE_LIMIT=256*1024,sha=b=>createHash('sha256').update(b).digest('hex');
|
|
7
|
+
const same=(a,b)=>need(digest(a)===digest(b),'commit_history_invalid');
|
|
8
|
+
const absolute=p=>need(typeof p==='string'&&!p.includes('\0')&&path.isAbsolute(p)&&path.resolve(p)===p,'unsupported_path');
|
|
9
|
+
function base64(s){
|
|
10
|
+
need(typeof s==='string'&&s.length<=Math.ceil(FILE_LIMIT/3)*4,'limit_exceeded');
|
|
11
|
+
const b=Buffer.from(s,'base64');need(b.length<=FILE_LIMIT&&b.toString('base64')===s,'invalid_plan');return b;
|
|
12
|
+
}
|
|
13
|
+
export function planBytes(raw){
|
|
14
|
+
const p=json(raw);
|
|
15
|
+
shape(p,['version','protocol','feature','taskId','attempt','tasksPath','mode','beforeBase64','afterBase64',
|
|
16
|
+
'beforeDigest','afterDigest','taskRevision','evidence','planDigest']);
|
|
17
|
+
need(p.version===1&&p.protocol==='cm-mark-done-plan'&&typeof p.feature==='string'&&p.feature.length>0,'invalid_plan');
|
|
18
|
+
validIdentity({repositoryId:'plan',runId:'plan',taskId:p.taskId,attempt:p.attempt});absolute(p.tasksPath);
|
|
19
|
+
need(Number.isInteger(p.mode)&&p.mode>=0&&p.mode<=0o7777,'invalid_plan');
|
|
20
|
+
for(const k of ['beforeDigest','afterDigest','taskRevision','planDigest'])hex(p[k]);
|
|
21
|
+
need(Array.isArray(p.evidence)&&p.evidence.length>0&&p.evidence.length<=4,'invalid_plan');
|
|
22
|
+
let previous;
|
|
23
|
+
for(const e of p.evidence){shape(e,['path','revision']);absolute(e.path);hex(e.revision);
|
|
24
|
+
need(previous===undefined||Buffer.compare(Buffer.from(previous),Buffer.from(e.path))<0,'invalid_plan');previous=e.path;}
|
|
25
|
+
const {planDigest,...body}=p;need(digest(body)===planDigest,'invalid_plan');
|
|
26
|
+
const before=base64(p.beforeBase64),after=base64(p.afterBase64);
|
|
27
|
+
need(sha(before)===p.beforeDigest&&sha(after)===p.afterDigest,'invalid_plan');
|
|
28
|
+
need(!before.equals(after),'task_already_marked');need(before.length===after.length,'invalid_plan');
|
|
29
|
+
let changes=0;for(let n=0;n<before.length;n++)if(before[n]!==after[n]){
|
|
30
|
+
need(before[n]===32&&after[n]===120,'invalid_plan');changes++;}
|
|
31
|
+
need(changes===1,'invalid_plan');return {before,after};
|
|
32
|
+
}
|
|
33
|
+
export function readCommitIntent(raw,{owner,identity,fingerprints}){
|
|
34
|
+
const p=json(raw);
|
|
35
|
+
shape(p,['version','protocol','type','identity','owner','fingerprints','plan','proof','parent','temporaryName']);
|
|
36
|
+
need(p.version===1&&p.protocol==='cm-task-commit'&&p.type==='intent','commit_history_invalid');
|
|
37
|
+
validIdentity(p.identity);same(p.identity,identity);same(p.owner,owner);same(p.fingerprints,fingerprints);
|
|
38
|
+
planBytes(p.plan);need(p.plan.feature===owner.feature&&p.plan.tasksPath===owner.tasksPath
|
|
39
|
+
&&p.plan.taskId===p.identity.taskId&&p.plan.attempt===p.identity.attempt,'commit_history_invalid');
|
|
40
|
+
shape(p.proof,['root','baselineDigest','packageDigest','receiptDigest','checksDigest']);absolute(p.proof.root);
|
|
41
|
+
for(const k of ['baselineDigest','packageDigest','receiptDigest','checksDigest'])hex(p.proof[k]);
|
|
42
|
+
reviewSpecsPath(p.proof.root,owner.specsRoot);
|
|
43
|
+
shape(p.parent,['path','dev','ino','mode']);need(p.parent.path===path.dirname(owner.tasksPath)
|
|
44
|
+
&&[p.parent.dev,p.parent.ino].every(n=>typeof n==='string'&&/^(0|[1-9][0-9]*)$/.test(n))
|
|
45
|
+
&&Number.isInteger(p.parent.mode)&&p.parent.mode>=0&&p.parent.mode<=0o7777,'commit_history_invalid');
|
|
46
|
+
need(typeof p.temporaryName==='string'&&/^\.cm-task\.[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}\.tmp$/.test(p.temporaryName),'commit_history_invalid');
|
|
47
|
+
return p;
|
|
48
|
+
}
|
|
49
|
+
export function readCommitResult(raw,{intentDigest,planDigest}){
|
|
50
|
+
const p=json(raw);shape(p,['version','protocol','type','intentDigest','planDigest','outcome']);
|
|
51
|
+
need(p.version===1&&p.protocol==='cm-task-commit'&&p.type==='result'&&p.intentDigest===intentDigest
|
|
52
|
+
&&p.planDigest===planDigest&&p.outcome==='fixture_committed','commit_history_invalid');
|
|
53
|
+
hex(p.intentDigest);hex(p.planDigest);return p;
|
|
54
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// Fixture-only transaction primitive. Not a provider bridge or runner-v1 adapter.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { createHash,randomUUID } from 'node:crypto';
|
|
5
|
+
import { types } from 'node:util';
|
|
6
|
+
import {createRequire} from 'node:module';
|
|
7
|
+
import { verifyReviewPackage,reviewSpecsPath } from './review-package.mjs';
|
|
8
|
+
import { checkCompletion } from './gate-bridge.mjs';
|
|
9
|
+
import { need,shape,json,digest,validIdentity } from './effect-contract.mjs';
|
|
10
|
+
import {planBytes,readCommitIntent,readCommitResult} from './task-commit-codec.mjs';
|
|
11
|
+
import {resolveFixtureCommit} from './task-runner.mjs';
|
|
12
|
+
import {readRunnerHistory} from './durable-runner-state.mjs';
|
|
13
|
+
import {prepareMarkDone,verifyMarkDonePlan} from '../../../scripts/cm-task-gate.mjs';
|
|
14
|
+
|
|
15
|
+
const requireNative=createRequire(import.meta.url);
|
|
16
|
+
const taskOwnerTarget=store=>requireNative('./task-owner.mjs').taskOwnerTarget(store);
|
|
17
|
+
|
|
18
|
+
const MiB=1024*1024,FILE_LIMIT=256*1024;
|
|
19
|
+
const aborted=Object.getOwnPropertyDescriptor(AbortSignal.prototype,'aborted').get;
|
|
20
|
+
const signalPrototype=AbortSignal.prototype;
|
|
21
|
+
const signalSlots=Object.getOwnPropertySymbols(new AbortController().signal);
|
|
22
|
+
const sha=b=>createHash('sha256').update(b).digest('hex');
|
|
23
|
+
const equal=(a,b)=>digest(a)===digest(b);
|
|
24
|
+
const mode=s=>Number(s.mode&0o7777n);
|
|
25
|
+
const statFields=s=>[s.dev,s.ino,s.mode,s.nlink,s.size,s.mtimeNs,s.ctimeNs].map(String);
|
|
26
|
+
const sameStat=(a,b)=>statFields(a).join(':')===statFields(b).join(':');
|
|
27
|
+
const sameInode=(a,b)=>a.dev===b.dev && a.ino===b.ino;
|
|
28
|
+
function pathString(p) {need(typeof p==='string' && !p.includes('\0') && path.isAbsolute(p) && path.resolve(p)===p,'unsupported_path');}
|
|
29
|
+
function canonicalPath(p) {pathString(p);need(fs.realpathSync(p)===p,'unsupported_path');return p;}
|
|
30
|
+
function cancellation(signal) {
|
|
31
|
+
let value=false;
|
|
32
|
+
if(signal!==undefined)try{
|
|
33
|
+
// Node's native getter reads symbol properties; it is not a callback-free
|
|
34
|
+
// brand check. Reject proxies before reflection, and require own data slots
|
|
35
|
+
// on every read so neither accessors nor prototype lookup can run caller code.
|
|
36
|
+
need(signal!==null && typeof signal==='object' && !types.isProxy(signal)
|
|
37
|
+
&& Object.getPrototypeOf(signal)===signalPrototype,'invalid_input');
|
|
38
|
+
const keys=Reflect.ownKeys(signal);need(keys.length<=64,'invalid_input');
|
|
39
|
+
for(const key of keys)need(Object.hasOwn(Object.getOwnPropertyDescriptor(signal,key),'value'),'invalid_input');
|
|
40
|
+
for(const key of signalSlots)need(Object.hasOwn(signal,key),'invalid_input');
|
|
41
|
+
value=aborted.call(signal);
|
|
42
|
+
}catch{need(false,'invalid_input');}
|
|
43
|
+
need(!value,'cancelled');
|
|
44
|
+
}
|
|
45
|
+
function parentRevision(p) {
|
|
46
|
+
canonicalPath(p);const s=fs.lstatSync(p,{bigint:true});need(s.isDirectory() && !s.isSymbolicLink(),'unsupported_path');
|
|
47
|
+
return {path:p,dev:String(s.dev),ino:String(s.ino),mode:mode(s)};
|
|
48
|
+
}
|
|
49
|
+
function readFile(p) {
|
|
50
|
+
let fd;
|
|
51
|
+
try {
|
|
52
|
+
const before=fs.lstatSync(p,{bigint:true});
|
|
53
|
+
need(before.isFile() && !before.isSymbolicLink() && before.nlink===1n,'unsupported_file');
|
|
54
|
+
need(before.size<=BigInt(FILE_LIMIT),'limit_exceeded');
|
|
55
|
+
fd=fs.openSync(p,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW);
|
|
56
|
+
need(sameStat(before,fs.fstatSync(fd,{bigint:true})),'snapshot_changed');
|
|
57
|
+
const data=Buffer.alloc(Number(before.size)+1);let size=0;
|
|
58
|
+
while(size<data.length){const n=fs.readSync(fd,data,size,data.length-size,size);if(!n)break;size+=n;}
|
|
59
|
+
need(size===Number(before.size) && sameStat(before,fs.fstatSync(fd,{bigint:true}))
|
|
60
|
+
&& sameStat(before,fs.lstatSync(p,{bigint:true})),'snapshot_changed');
|
|
61
|
+
return {bytes:data.subarray(0,size),stat:before};
|
|
62
|
+
}finally{if(fd!==undefined)fs.closeSync(fd);}
|
|
63
|
+
}
|
|
64
|
+
function nativeRevision(p,f) {return digest({path:p,stat:statFields(f.stat),sha256:sha(f.bytes)});}
|
|
65
|
+
function completionSelectors(selectors,identity,projectRoot){return {...selectors,task:identity.taskId,projectRoot};}
|
|
66
|
+
function verifyProof(v) {
|
|
67
|
+
verifyReviewPackage({root:v.root,baseline:v.baseline,checks:v.checks,reviewPackage:v.reviewPackage,expectedDigest:v.reviewPackage.packageDigest,
|
|
68
|
+
...(Object.hasOwn(v.reviewPackage,'handoff')?{handoffPath:v.selectors.handoff}:{})});
|
|
69
|
+
checkCompletion({receipt:v.receipt,registered:v.registered,execution:v.execution,reviewPackage:v.reviewPackage,identity:v.identity});
|
|
70
|
+
}
|
|
71
|
+
function ownerMatch(store,owner,initial,revision) {
|
|
72
|
+
need(equal(taskOwnerTarget(store),owner),'task_owner_mismatch');const s=store.snapshot();
|
|
73
|
+
need(equal(s.identity,initial.identity) && equal(s.fingerprints,initial.fingerprints),'identity_mismatch');
|
|
74
|
+
need(s.revision===revision,'commit_store_changed');return s;
|
|
75
|
+
}
|
|
76
|
+
function boundedRecord(record) {need(Buffer.byteLength(JSON.stringify(record))<=MiB,'limit_exceeded');}
|
|
77
|
+
function append(store,current,id,kind,payload) {
|
|
78
|
+
const data={version:1,seq:current.records.length+1,id,kind,payload,previousDigest:current.records.at(-1)?.digest??null};
|
|
79
|
+
const record={...data,digest:digest(data)};boundedRecord(record);
|
|
80
|
+
store.append({id,kind,payload,expectedRevision:current.revision});const saved=store.snapshot();
|
|
81
|
+
need(saved.records.length===current.records.length+1 && equal(saved.records.at(-1),record),'commit_store_changed');return saved;
|
|
82
|
+
}
|
|
83
|
+
function history(store,owner) {
|
|
84
|
+
const s=store.snapshot();need(s.records.length>0,'commit_missing');need(s.records.length<=2,'commit_history_invalid');
|
|
85
|
+
for(const r of s.records)boundedRecord(r);
|
|
86
|
+
const r=s.records[0],p=r.payload;
|
|
87
|
+
need(r.id==='task-commit.intent' && r.kind==='commit-intent','commit_history_invalid');
|
|
88
|
+
readCommitIntent(p,{owner,identity:{...s.identity,taskId:p.identity?.taskId,attempt:p.identity?.attempt},fingerprints:s.fingerprints});
|
|
89
|
+
if(s.records.length===2){const last=s.records[1];
|
|
90
|
+
need(last.id==='task-commit.result' && last.kind==='commit-result','commit_history_invalid');
|
|
91
|
+
readCommitResult(last.payload,{intentDigest:r.digest,planDigest:p.plan.planDigest});}
|
|
92
|
+
return {s,p,intentDigest:r.digest};
|
|
93
|
+
}
|
|
94
|
+
export function commitFixtureTask(store,input,signal) {
|
|
95
|
+
const owner=taskOwnerTarget(store),initial=store.snapshot();need(initial.records.length===0,'commit_records_present');
|
|
96
|
+
let current=initial;
|
|
97
|
+
return commitCore(input,signal,owner,initial,
|
|
98
|
+
()=>ownerMatch(store,owner,initial,current.revision),
|
|
99
|
+
payload=>{current=append(store,current,'task-commit.intent','commit-intent',payload);return current.records.at(-1).digest;},
|
|
100
|
+
payload=>{current=append(store,current,'task-commit.result','commit-result',payload);});
|
|
101
|
+
}
|
|
102
|
+
// Internal native entry. Only the live runner can issue the opaque capability.
|
|
103
|
+
export function commitRunnerFixture(token,store,input,signal) {
|
|
104
|
+
const binding=resolveFixtureCommit(token,store,'guard');
|
|
105
|
+
need(arguments.length===4 && binding.phase==='prepared','commit_phase_invalid');
|
|
106
|
+
const v=json(input,16*MiB);need(digest(v)===binding.inputDigest,'commit_input_mismatch');
|
|
107
|
+
const initial={identity:{repositoryId:binding.identity.repositoryId,runId:binding.identity.runId},fingerprints:binding.fingerprints};
|
|
108
|
+
return commitCore(v,signal,binding.owner,initial,
|
|
109
|
+
()=>resolveFixtureCommit(token,store,'guard'),
|
|
110
|
+
payload=>resolveFixtureCommit(token,store,'append-intent',payload).intentDigest,
|
|
111
|
+
payload=>resolveFixtureCommit(token,store,'append-result',payload));
|
|
112
|
+
}
|
|
113
|
+
// Closures below are constructed only by the two fixed wrappers, never supplied
|
|
114
|
+
// by a public host option. The composed wrapper owns no second mutable revision.
|
|
115
|
+
function commitCore(input,signal,owner,initial,guard,appendIntent,appendResult) {
|
|
116
|
+
cancellation(signal);const v=json(input,16*MiB);
|
|
117
|
+
shape(v,['selectors','root','identity','baseline','reviewPackage','checks','receipt','registered','execution']);
|
|
118
|
+
shape(v.selectors,['handoff','reviewsDir','tasksPath','feature']);validIdentity(v.identity);
|
|
119
|
+
need(equal(initial.identity,{repositoryId:v.identity.repositoryId,runId:v.identity.runId}),'identity_mismatch');
|
|
120
|
+
const selectors=v.selectors;
|
|
121
|
+
need(selectors.tasksPath===owner.tasksPath && selectors.feature===owner.feature,'task_owner_mismatch');
|
|
122
|
+
for(const p of [v.root,selectors.tasksPath,selectors.reviewsDir,selectors.handoff])canonicalPath(p);
|
|
123
|
+
need([path.join(owner.specsRoot,'.reviews'),path.join(path.dirname(owner.tasksPath),'.reviews')].includes(selectors.reviewsDir)
|
|
124
|
+
&& path.dirname(selectors.handoff)===selectors.reviewsDir,'unsupported_path');
|
|
125
|
+
need((v.baseline.specsPath??null)===reviewSpecsPath(v.root,owner.specsRoot),'overlapping_roots');
|
|
126
|
+
const parent=parentRevision(path.dirname(owner.tasksPath));
|
|
127
|
+
let plan;
|
|
128
|
+
try{plan=json(prepareMarkDone(completionSelectors(selectors,v.identity,v.root)),MiB);}
|
|
129
|
+
catch{need(false,'preparation_failed');}
|
|
130
|
+
const {after}=planBytes(plan);
|
|
131
|
+
need(plan.tasksPath===owner.tasksPath && plan.feature===owner.feature && plan.taskId===v.identity.taskId
|
|
132
|
+
&& plan.attempt===v.identity.attempt,'identity_mismatch');verifyProof(v);cancellation(signal);
|
|
133
|
+
guard();need(equal(parentRevision(parent.path),parent),'snapshot_changed');
|
|
134
|
+
const payload={version:1,protocol:'cm-task-commit',type:'intent',identity:v.identity,owner,
|
|
135
|
+
fingerprints:initial.fingerprints,plan,proof:{root:v.root,baselineDigest:v.baseline.baselineDigest,
|
|
136
|
+
packageDigest:v.reviewPackage.packageDigest,receiptDigest:v.receipt.receiptDigest,checksDigest:v.reviewPackage.checksDigest},
|
|
137
|
+
parent,temporaryName:`.cm-task.${randomUUID()}.tmp`};
|
|
138
|
+
const temporary=path.join(parent.path,payload.temporaryName);let fd;
|
|
139
|
+
try {
|
|
140
|
+
const intentDigest=appendIntent(payload);
|
|
141
|
+
guard();need(equal(parentRevision(parent.path),parent),'snapshot_changed');cancellation(signal);
|
|
142
|
+
fd=fs.openSync(temporary,fs.constants.O_WRONLY|fs.constants.O_CREAT|fs.constants.O_EXCL|fs.constants.O_NOFOLLOW,0o600);
|
|
143
|
+
const created=fs.fstatSync(fd,{bigint:true});
|
|
144
|
+
const checkTemp=()=>{const f=readFile(temporary);need(sameInode(f.stat,created) && mode(f.stat)===plan.mode
|
|
145
|
+
&& f.bytes.equals(after) && sha(f.bytes)===plan.afterDigest,'temporary_changed');return f;};
|
|
146
|
+
fs.writeFileSync(fd,after);fs.fchmodSync(fd,plan.mode);fs.fsyncSync(fd);
|
|
147
|
+
const synced=checkTemp();need(sameStat(synced.stat,fs.fstatSync(fd,{bigint:true})),'temporary_changed');
|
|
148
|
+
fs.closeSync(fd);fd=undefined;
|
|
149
|
+
let verified;
|
|
150
|
+
try{verified=verifyMarkDonePlan(completionSelectors(selectors,v.identity,v.root),plan.planDigest);}
|
|
151
|
+
catch{need(false,'preparation_failed');}
|
|
152
|
+
shape(verified,['outcome','planDigest']);need(verified.outcome==='matched' && verified.planDigest===plan.planDigest,'invalid_plan');
|
|
153
|
+
verifyProof(v);guard();
|
|
154
|
+
need(equal(parentRevision(parent.path),parent),'snapshot_changed');
|
|
155
|
+
for(const e of plan.evidence)need(nativeRevision(e.path,readFile(e.path))===e.revision,'snapshot_changed');
|
|
156
|
+
need(nativeRevision(owner.tasksPath,readFile(owner.tasksPath))===plan.taskRevision,'snapshot_changed');
|
|
157
|
+
checkTemp();cancellation(signal);fs.renameSync(temporary,owner.tasksPath);
|
|
158
|
+
const dir=fs.openSync(parent.path,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW);
|
|
159
|
+
try{const opened=fs.fstatSync(dir,{bigint:true});
|
|
160
|
+
need(equal({path:parent.path,dev:String(opened.dev),ino:String(opened.ino),mode:mode(opened)},parent)
|
|
161
|
+
&& equal(parentRevision(parent.path),parent),'snapshot_changed');fs.fsyncSync(dir);
|
|
162
|
+
}finally{fs.closeSync(dir);}
|
|
163
|
+
guard();
|
|
164
|
+
appendResult({version:1,protocol:'cm-task-commit',type:'result',
|
|
165
|
+
intentDigest,planDigest:plan.planDigest,outcome:'fixture_committed'});
|
|
166
|
+
return json({outcome:'fixture_committed',intentDigest,planDigest:plan.planDigest});
|
|
167
|
+
}catch{need(false,'commit_unknown');}
|
|
168
|
+
finally{if(fd!==undefined)try{fs.closeSync(fd);}catch{/* Retain unknown; never compensate task bytes. */}}
|
|
169
|
+
}
|
|
170
|
+
function observeImage(owner,p) {
|
|
171
|
+
const {before,after}=planBytes(p.plan);let observation='conflict';
|
|
172
|
+
try {
|
|
173
|
+
need(equal(parentRevision(p.parent.path),p.parent),'snapshot_changed');const f=readFile(owner.tasksPath);
|
|
174
|
+
need(equal(parentRevision(p.parent.path),p.parent),'snapshot_changed');
|
|
175
|
+
if(mode(f.stat)===p.plan.mode){if(f.bytes.equals(before))observation='observed_before';else if(f.bytes.equals(after))observation='observed_after';}
|
|
176
|
+
}catch{/* Unsafe/missing/changed target is observation conflict, not write authority. */}
|
|
177
|
+
return observation;
|
|
178
|
+
}
|
|
179
|
+
export function observeFixtureCommit(store) {
|
|
180
|
+
const owner=taskOwnerTarget(store);let h;
|
|
181
|
+
try{h=history(store,owner);}catch(error){if(error.code==='commit_missing')throw error;need(false,'commit_history_invalid');}
|
|
182
|
+
const {s,p,intentDigest}=h,observation=observeImage(owner,p);
|
|
183
|
+
ownerMatch(store,owner,s,s.revision);
|
|
184
|
+
return json({observation,recordedOutcome:s.records.length===2?'fixture_committed':null,intentDigest,planDigest:p.plan.planDigest});
|
|
185
|
+
}
|
|
186
|
+
export function observeRunnerFixture(store) {
|
|
187
|
+
const owner=taskOwnerTarget(store);need(arguments.length===1);
|
|
188
|
+
const s=store.snapshot();need(s.records.length>0,'runner_missing');let config,parsed;
|
|
189
|
+
try{
|
|
190
|
+
config=json(s.records[0].payload.config,16*MiB);
|
|
191
|
+
need(equal({repositoryId:config.identity.repositoryId,runId:config.identity.runId},s.identity)
|
|
192
|
+
&&equal(config.completion.owner,owner)&&equal(config.completion.fingerprints,s.fingerprints),'identity_mismatch');
|
|
193
|
+
parsed=readRunnerHistory(s.records,config,2);
|
|
194
|
+
}catch{need(false,'runner_history_invalid');}
|
|
195
|
+
const transaction=parsed.transaction;
|
|
196
|
+
const observedImage=transaction?observeImage(owner,transaction.intentRecord.payload.commit):'not_observed';
|
|
197
|
+
ownerMatch(store,owner,s,s.revision);
|
|
198
|
+
return json({version:1,protocol:'cm-runner-observation',identity:{...config.identity,attempt:parsed.state.attempt},
|
|
199
|
+
observedImage,recordedNativeOutcome:transaction?.resultRecord?'fixture_committed':null,
|
|
200
|
+
recordedRunnerState:parsed.state.state,recordedRunnerCode:parsed.state.code,taskCommit:parsed.state.taskCommit});
|
|
201
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Synthetic task-enabled entry; raw S3a is only a storage primitive.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { need,shape,id,hex,json } from './effect-contract.mjs';
|
|
5
|
+
import { openExecutionStore } from './execution-store.mjs';
|
|
6
|
+
import { isSupportedExecutionPlatform } from './execution-platform.mjs';
|
|
7
|
+
|
|
8
|
+
const same=(a,b)=>a.dev===b.dev && a.ino===b.ino;
|
|
9
|
+
const taskOwners=new WeakMap();
|
|
10
|
+
export function taskOwnerTarget(store) {
|
|
11
|
+
const owner=taskOwners.get(store);
|
|
12
|
+
need(owner!==undefined,'task_owner_required');
|
|
13
|
+
owner.validate();return owner.target;
|
|
14
|
+
}
|
|
15
|
+
function sync(p) {
|
|
16
|
+
const fd=fs.openSync(p,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW);
|
|
17
|
+
try{fs.fsyncSync(fd);}finally{fs.closeSync(fd);}
|
|
18
|
+
}
|
|
19
|
+
function directory(p,create=false) {
|
|
20
|
+
if(create)try{fs.mkdirSync(p,{mode:0o700});}catch(error){if(error.code!=='EEXIST')throw error;}
|
|
21
|
+
const stat=fs.lstatSync(p);need(stat.isDirectory() && !stat.isSymbolicLink(),'unsupported_path');return stat;
|
|
22
|
+
}
|
|
23
|
+
function validate(input) {
|
|
24
|
+
const v={...json(input)};shape(v,['tasksPath','feature','specsRoot','identity','fingerprints','create']);
|
|
25
|
+
shape(v.identity,['repositoryId','runId']);Object.values(v.identity).forEach(id);
|
|
26
|
+
shape(v.fingerprints,['workflow','config','inputs']);Object.values(v.fingerprints).forEach(hex);
|
|
27
|
+
need(typeof v.create==='boolean');
|
|
28
|
+
need(isSupportedExecutionPlatform(),'unsupported_platform');
|
|
29
|
+
for(const p of [v.tasksPath,v.specsRoot])need(typeof p==='string' && path.isAbsolute(p)
|
|
30
|
+
&& path.resolve(p)===p,'unsupported_path');
|
|
31
|
+
need(typeof v.feature==='string' && v.feature.length>0 && !['.','..'].includes(v.feature)
|
|
32
|
+
&& !/[ .]$|[\x00-\x1f<>:"/\\|?*]/u.test(v.feature),'unsupported_feature');
|
|
33
|
+
directory(v.specsRoot);
|
|
34
|
+
const task=fs.lstatSync(v.tasksPath);
|
|
35
|
+
need(task.isFile() && !task.isSymbolicLink() && task.nlink===1,'unsupported_file');
|
|
36
|
+
v.tasksPath=fs.realpathSync(v.tasksPath);v.specsRoot=fs.realpathSync(v.specsRoot);
|
|
37
|
+
need(path.basename(v.tasksPath)==='tasks.md','unsupported_path');
|
|
38
|
+
const parent=path.dirname(v.tasksPath),name=path.basename(parent),suffix='.'+v.feature;
|
|
39
|
+
const numbered=name.endsWith(suffix) && /^[0-9]+$/.test(name.slice(0,-suffix.length));
|
|
40
|
+
need(parent===v.specsRoot || (path.dirname(parent)===v.specsRoot && (name===v.feature || numbered)),
|
|
41
|
+
'unsupported_layout');
|
|
42
|
+
const reviews=path.join(v.specsRoot,'.reviews');
|
|
43
|
+
try{directory(reviews);}catch(error){if(error.code!=='ENOENT')throw error;}
|
|
44
|
+
return v;
|
|
45
|
+
}
|
|
46
|
+
function bind(v) {
|
|
47
|
+
const parent=path.dirname(v.tasksPath),reviews=path.join(parent,'.reviews');directory(reviews,true);
|
|
48
|
+
const p=path.join(reviews,'.cm-task-owner.json');
|
|
49
|
+
const bytes=Buffer.from(JSON.stringify({version:1,tasksPath:v.tasksPath,specsRoot:v.specsRoot})+'\n');
|
|
50
|
+
need(bytes.length<=16384,'limit_exceeded');
|
|
51
|
+
try {
|
|
52
|
+
const fd=fs.openSync(p,fs.constants.O_CREAT|fs.constants.O_EXCL|fs.constants.O_WRONLY|fs.constants.O_NOFOLLOW,0o600);
|
|
53
|
+
try{fs.writeFileSync(fd,bytes);fs.fsyncSync(fd);}finally{fs.closeSync(fd);}
|
|
54
|
+
}catch(error){if(error.code!=='EEXIST')throw error;}
|
|
55
|
+
const stat=fs.lstatSync(p);
|
|
56
|
+
need(stat.isFile() && !stat.isSymbolicLink() && stat.nlink===1 && (stat.mode&0o077)===0,'unsupported_binding');
|
|
57
|
+
need(stat.size<=16384,'limit_exceeded');
|
|
58
|
+
const fd=fs.openSync(p,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW);
|
|
59
|
+
try {
|
|
60
|
+
need(same(stat,fs.fstatSync(fd)),'task_owner_changed');
|
|
61
|
+
need(fs.readFileSync(fd).equals(bytes),'task_owner_mismatch');
|
|
62
|
+
fs.fsyncSync(fd);
|
|
63
|
+
need(same(stat,fs.lstatSync(p)),'task_owner_changed');
|
|
64
|
+
}finally{fs.closeSync(fd);}
|
|
65
|
+
// Includes a prior initializer's possibly unsynced directory entry.
|
|
66
|
+
sync(reviews);sync(parent);
|
|
67
|
+
return {p,stat,bytes};
|
|
68
|
+
}
|
|
69
|
+
export function openTaskExecutionStore(input) {
|
|
70
|
+
const v=validate(input),binding=bind(v),{tasksPath,feature,...options}=v;
|
|
71
|
+
const execution=path.join(v.specsRoot,'.reviews','.execution');
|
|
72
|
+
try {
|
|
73
|
+
directory(execution);
|
|
74
|
+
// Never let native SQLite recovery consume retained initialization evidence.
|
|
75
|
+
// Resolve the same pathname SQLite uses, including case-insensitive aliases
|
|
76
|
+
// and dangling symlinks. A directory-name string comparison is insufficient.
|
|
77
|
+
fs.lstatSync(path.join(execution,'writer.sqlite-journal'));
|
|
78
|
+
need(false,'retained_journal');
|
|
79
|
+
}catch(error){if(error.code!=='ENOENT')throw error;}
|
|
80
|
+
const store=openExecutionStore(options);
|
|
81
|
+
let poisoned=false;
|
|
82
|
+
const guard=()=>{
|
|
83
|
+
need(!poisoned,'store_poisoned');
|
|
84
|
+
try {
|
|
85
|
+
directory(path.dirname(binding.p));
|
|
86
|
+
const stat=fs.lstatSync(binding.p);
|
|
87
|
+
need(same(stat,binding.stat) && stat.isFile() && stat.nlink===1 && (stat.mode&0o077)===0
|
|
88
|
+
&& stat.size<=16384 && fs.readFileSync(binding.p).equals(binding.bytes),'task_owner_changed');
|
|
89
|
+
}catch(error){poisoned=true;throw error;}
|
|
90
|
+
};
|
|
91
|
+
try{guard();}catch(error){store.close();throw error;}
|
|
92
|
+
const handle=Object.freeze({snapshot:()=>{guard();return store.snapshot();},
|
|
93
|
+
append:entry=>{guard();return store.append(entry);},close:()=>store.close()});
|
|
94
|
+
taskOwners.set(handle,{target:Object.freeze({tasksPath,feature,specsRoot:v.specsRoot}),
|
|
95
|
+
validate:()=>{guard();store.snapshot();}});
|
|
96
|
+
return handle;
|
|
97
|
+
}
|