@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,584 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Dependency-free behavior fixture for CM model-usage observability."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
import tempfile
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Dict, List
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
16
|
+
WRITER = ROOT / "scripts" / "cm-log-event.py"
|
|
17
|
+
REPORTER = ROOT / "scripts" / "cm-usage-report.py"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def write_jsonl(path: Path, rows: List[Dict[str, object]]) -> None:
|
|
21
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
22
|
+
path.write_text(
|
|
23
|
+
"".join(json.dumps(row, ensure_ascii=False) + "\n" for row in rows),
|
|
24
|
+
encoding="utf-8",
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def invoke_writer(log_home: Path, data: Dict[str, object], expected_exit: int = 0) -> subprocess.CompletedProcess[str]:
|
|
29
|
+
payload = {
|
|
30
|
+
"stage": "design_generation",
|
|
31
|
+
"adapter": "company-api",
|
|
32
|
+
"requested_model": "planner-default",
|
|
33
|
+
"source": "api",
|
|
34
|
+
"purpose": "cm-prd:design_generation",
|
|
35
|
+
**data,
|
|
36
|
+
}
|
|
37
|
+
env = os.environ.copy()
|
|
38
|
+
env["CM_WORKFLOW_LOG_HOME"] = str(log_home)
|
|
39
|
+
result = subprocess.run(
|
|
40
|
+
[
|
|
41
|
+
sys.executable,
|
|
42
|
+
str(WRITER),
|
|
43
|
+
"--workflow",
|
|
44
|
+
"cm-prd",
|
|
45
|
+
"--event",
|
|
46
|
+
"model_usage",
|
|
47
|
+
"--phase",
|
|
48
|
+
"complete",
|
|
49
|
+
"--runtime",
|
|
50
|
+
"codex",
|
|
51
|
+
"--run-id",
|
|
52
|
+
"usage-fixture-0001",
|
|
53
|
+
"--detail",
|
|
54
|
+
"planner model call completed",
|
|
55
|
+
"--data-json",
|
|
56
|
+
json.dumps(payload),
|
|
57
|
+
],
|
|
58
|
+
cwd=ROOT,
|
|
59
|
+
env=env,
|
|
60
|
+
text=True,
|
|
61
|
+
encoding="utf-8",
|
|
62
|
+
capture_output=True,
|
|
63
|
+
check=False,
|
|
64
|
+
)
|
|
65
|
+
if result.returncode != expected_exit:
|
|
66
|
+
raise AssertionError(
|
|
67
|
+
f"expected exit {expected_exit}, got {result.returncode}\n"
|
|
68
|
+
f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}"
|
|
69
|
+
)
|
|
70
|
+
return result
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def invoke_claim(
|
|
74
|
+
log_home: Path,
|
|
75
|
+
data: Dict[str, object],
|
|
76
|
+
expected_exit: int = 0,
|
|
77
|
+
) -> subprocess.CompletedProcess[str]:
|
|
78
|
+
env = os.environ.copy()
|
|
79
|
+
env["CM_WORKFLOW_LOG_HOME"] = str(log_home)
|
|
80
|
+
result = subprocess.run(
|
|
81
|
+
[
|
|
82
|
+
sys.executable,
|
|
83
|
+
str(WRITER),
|
|
84
|
+
"--workflow",
|
|
85
|
+
"cm-prd",
|
|
86
|
+
"--event",
|
|
87
|
+
"model_call",
|
|
88
|
+
"--phase",
|
|
89
|
+
"claimed",
|
|
90
|
+
"--runtime",
|
|
91
|
+
"codex",
|
|
92
|
+
"--run-id",
|
|
93
|
+
"usage-fixture-0001",
|
|
94
|
+
"--detail",
|
|
95
|
+
"planner model call claimed",
|
|
96
|
+
"--data-json",
|
|
97
|
+
json.dumps(data),
|
|
98
|
+
],
|
|
99
|
+
cwd=ROOT,
|
|
100
|
+
env=env,
|
|
101
|
+
text=True,
|
|
102
|
+
encoding="utf-8",
|
|
103
|
+
capture_output=True,
|
|
104
|
+
check=False,
|
|
105
|
+
)
|
|
106
|
+
if result.returncode != expected_exit:
|
|
107
|
+
raise AssertionError(
|
|
108
|
+
f"expected exit {expected_exit}, got {result.returncode}\n"
|
|
109
|
+
f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}"
|
|
110
|
+
)
|
|
111
|
+
return result
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def invoke_report(log_home: Path, *args: str) -> subprocess.CompletedProcess[str]:
|
|
115
|
+
result = subprocess.run(
|
|
116
|
+
[sys.executable, str(REPORTER), "--log-home", str(log_home), *args],
|
|
117
|
+
cwd=ROOT,
|
|
118
|
+
text=True,
|
|
119
|
+
encoding="utf-8",
|
|
120
|
+
capture_output=True,
|
|
121
|
+
check=False,
|
|
122
|
+
)
|
|
123
|
+
if result.returncode != 0:
|
|
124
|
+
raise AssertionError(
|
|
125
|
+
f"report failed with {result.returncode}\n"
|
|
126
|
+
f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}"
|
|
127
|
+
)
|
|
128
|
+
return result
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def main() -> int:
|
|
132
|
+
with tempfile.TemporaryDirectory(prefix="cm-usage-") as tmp:
|
|
133
|
+
home = Path(tmp).resolve()
|
|
134
|
+
|
|
135
|
+
accepted = invoke_writer(
|
|
136
|
+
home,
|
|
137
|
+
{
|
|
138
|
+
"call_id": "planner-call-0001",
|
|
139
|
+
"role": "planner",
|
|
140
|
+
"adapter": "company-api",
|
|
141
|
+
"requested_model": "planner-default",
|
|
142
|
+
"effective_model": "provider-model-v2",
|
|
143
|
+
"usage_state": "observed",
|
|
144
|
+
"input_tokens": 1200,
|
|
145
|
+
"output_tokens": 300,
|
|
146
|
+
"cache_read_tokens": 800,
|
|
147
|
+
"cache_write_tokens": 100,
|
|
148
|
+
"duration_ms": 2500,
|
|
149
|
+
"outcome": "success",
|
|
150
|
+
},
|
|
151
|
+
)
|
|
152
|
+
payload = json.loads(accepted.stdout)
|
|
153
|
+
run_log = Path(payload["global_log"])
|
|
154
|
+
event = json.loads(run_log.read_text(encoding="utf-8").splitlines()[0])
|
|
155
|
+
assert event["input_tokens"] == 1200
|
|
156
|
+
assert event["cache_read_tokens"] == 800
|
|
157
|
+
|
|
158
|
+
second_call_data = {
|
|
159
|
+
"call_id": "planner-call-0002",
|
|
160
|
+
"role": "planner",
|
|
161
|
+
"adapter": "company-api",
|
|
162
|
+
"requested_model": "planner-default",
|
|
163
|
+
"effective_model": "provider-model-v2",
|
|
164
|
+
"usage_state": "observed",
|
|
165
|
+
"input_tokens": 1200,
|
|
166
|
+
"output_tokens": 300,
|
|
167
|
+
"cache_read_tokens": 800,
|
|
168
|
+
"cache_write_tokens": 100,
|
|
169
|
+
"duration_ms": 2500,
|
|
170
|
+
"outcome": "success",
|
|
171
|
+
}
|
|
172
|
+
second_call = invoke_writer(home, second_call_data)
|
|
173
|
+
second_payload = json.loads(second_call.stdout)
|
|
174
|
+
assert second_payload["deduplicated"] is False
|
|
175
|
+
assert len(run_log.read_text(encoding="utf-8").splitlines()) == 2
|
|
176
|
+
retry = invoke_writer(home, second_call_data)
|
|
177
|
+
retry_payload = json.loads(retry.stdout)
|
|
178
|
+
assert retry_payload["deduplicated"] is True
|
|
179
|
+
assert len(run_log.read_text(encoding="utf-8").splitlines()) == 2
|
|
180
|
+
changed_retry_data = dict(second_call_data)
|
|
181
|
+
changed_retry_data["output_tokens"] = 301
|
|
182
|
+
changed_retry = invoke_writer(home, changed_retry_data, expected_exit=2)
|
|
183
|
+
assert "call_id already used with different payload" in changed_retry.stderr
|
|
184
|
+
|
|
185
|
+
late_claim = invoke_claim(
|
|
186
|
+
home,
|
|
187
|
+
{
|
|
188
|
+
"call_id": "planner-call-0001",
|
|
189
|
+
"stage": "design_generation",
|
|
190
|
+
"role": "planner",
|
|
191
|
+
"adapter": "company-api",
|
|
192
|
+
"requested_model": "planner-default",
|
|
193
|
+
"source": "api",
|
|
194
|
+
"purpose": "cm-prd:design_generation",
|
|
195
|
+
},
|
|
196
|
+
expected_exit=2,
|
|
197
|
+
)
|
|
198
|
+
assert "call_id already completed" in late_claim.stderr
|
|
199
|
+
|
|
200
|
+
incomplete_claim = invoke_claim(
|
|
201
|
+
home,
|
|
202
|
+
{
|
|
203
|
+
"call_id": "planner-incomplete-claim",
|
|
204
|
+
"role": "planner",
|
|
205
|
+
},
|
|
206
|
+
expected_exit=2,
|
|
207
|
+
)
|
|
208
|
+
assert "requires a non-empty stage" in incomplete_claim.stderr
|
|
209
|
+
|
|
210
|
+
identity_claim = invoke_claim(
|
|
211
|
+
home,
|
|
212
|
+
{
|
|
213
|
+
"call_id": "planner-identity-mismatch",
|
|
214
|
+
"stage": "design_generation",
|
|
215
|
+
"role": "planner",
|
|
216
|
+
"adapter": "company-api",
|
|
217
|
+
"requested_model": "planner-default",
|
|
218
|
+
"source": "api",
|
|
219
|
+
"purpose": "cm-prd:design_generation",
|
|
220
|
+
},
|
|
221
|
+
)
|
|
222
|
+
assert json.loads(identity_claim.stdout)["global_written"] is True
|
|
223
|
+
identity_mismatch = invoke_writer(
|
|
224
|
+
home,
|
|
225
|
+
{
|
|
226
|
+
"call_id": "planner-identity-mismatch",
|
|
227
|
+
"stage": "other_stage",
|
|
228
|
+
"role": "analyst",
|
|
229
|
+
"adapter": "other-api",
|
|
230
|
+
"requested_model": "analyst-default",
|
|
231
|
+
"source": "api",
|
|
232
|
+
"purpose": "cm-prd:other_stage",
|
|
233
|
+
"usage_state": "observed",
|
|
234
|
+
"input_tokens": 1,
|
|
235
|
+
"output_tokens": 1,
|
|
236
|
+
"outcome": "success",
|
|
237
|
+
},
|
|
238
|
+
expected_exit=2,
|
|
239
|
+
)
|
|
240
|
+
assert "identity does not match model_call claim" in identity_mismatch.stderr
|
|
241
|
+
|
|
242
|
+
managed_without_claim = invoke_writer(
|
|
243
|
+
home,
|
|
244
|
+
{
|
|
245
|
+
"call_id": "managed-without-claim",
|
|
246
|
+
"role": "planner",
|
|
247
|
+
"adapter": "openai-compatible",
|
|
248
|
+
"usage_state": "observed",
|
|
249
|
+
"input_tokens": 999,
|
|
250
|
+
"output_tokens": 111,
|
|
251
|
+
"outcome": "success",
|
|
252
|
+
},
|
|
253
|
+
expected_exit=2,
|
|
254
|
+
)
|
|
255
|
+
assert "requires a prior model_call claim" in managed_without_claim.stderr
|
|
256
|
+
|
|
257
|
+
rejected = invoke_writer(
|
|
258
|
+
home,
|
|
259
|
+
{
|
|
260
|
+
"call_id": "planner-negative-0001",
|
|
261
|
+
"role": "planner",
|
|
262
|
+
"usage_state": "observed",
|
|
263
|
+
"input_tokens": -1,
|
|
264
|
+
"output_tokens": 1,
|
|
265
|
+
"outcome": "success",
|
|
266
|
+
},
|
|
267
|
+
expected_exit=2,
|
|
268
|
+
)
|
|
269
|
+
assert "non-negative integer" in rejected.stderr
|
|
270
|
+
|
|
271
|
+
secret = invoke_writer(
|
|
272
|
+
home,
|
|
273
|
+
{
|
|
274
|
+
"call_id": "planner-secret-0001",
|
|
275
|
+
"role": "planner",
|
|
276
|
+
"usage_state": "observed",
|
|
277
|
+
"input_tokens": 1,
|
|
278
|
+
"output_tokens": 1,
|
|
279
|
+
"access_token": "must-not-log",
|
|
280
|
+
"outcome": "success",
|
|
281
|
+
},
|
|
282
|
+
expected_exit=2,
|
|
283
|
+
)
|
|
284
|
+
assert "sensitive log field" in secret.stderr
|
|
285
|
+
|
|
286
|
+
prompt = invoke_writer(
|
|
287
|
+
home,
|
|
288
|
+
{
|
|
289
|
+
"call_id": "planner-prompt-0001",
|
|
290
|
+
"role": "planner",
|
|
291
|
+
"usage_state": "observed",
|
|
292
|
+
"input_tokens": 1,
|
|
293
|
+
"output_tokens": 1,
|
|
294
|
+
"prompt": "must-not-log",
|
|
295
|
+
"outcome": "success",
|
|
296
|
+
},
|
|
297
|
+
expected_exit=2,
|
|
298
|
+
)
|
|
299
|
+
assert "unsupported fields" in prompt.stderr
|
|
300
|
+
|
|
301
|
+
unavailable_with_counts = invoke_writer(
|
|
302
|
+
home,
|
|
303
|
+
{
|
|
304
|
+
"call_id": "planner-unavailable-counts-0001",
|
|
305
|
+
"role": "planner",
|
|
306
|
+
"usage_state": "unavailable",
|
|
307
|
+
"input_tokens": 0,
|
|
308
|
+
"output_tokens": 0,
|
|
309
|
+
"outcome": "success",
|
|
310
|
+
},
|
|
311
|
+
expected_exit=2,
|
|
312
|
+
)
|
|
313
|
+
assert "cannot contain token counts" in unavailable_with_counts.stderr
|
|
314
|
+
|
|
315
|
+
unavailable_duration = invoke_writer(
|
|
316
|
+
home,
|
|
317
|
+
{
|
|
318
|
+
"call_id": "planner-unavailable-duration-0001",
|
|
319
|
+
"role": "planner",
|
|
320
|
+
"usage_state": "unavailable",
|
|
321
|
+
"duration_ms": 700,
|
|
322
|
+
"outcome": "success",
|
|
323
|
+
},
|
|
324
|
+
)
|
|
325
|
+
assert json.loads(unavailable_duration.stdout)["global_written"] is True
|
|
326
|
+
|
|
327
|
+
unavailable_run = "usage-fixture-0002"
|
|
328
|
+
duplicate_row = dict(event)
|
|
329
|
+
conflicting_duplicate = dict(event)
|
|
330
|
+
conflicting_duplicate["event_id"] = "conflicting-call-event"
|
|
331
|
+
conflicting_duplicate["output_tokens"] = 301
|
|
332
|
+
unavailable_row: Dict[str, object] = {
|
|
333
|
+
"schema_version": 1,
|
|
334
|
+
"event_id": "unavailable-event",
|
|
335
|
+
"run_id": unavailable_run,
|
|
336
|
+
"at": "2026-08-06T11:00:00+00:00",
|
|
337
|
+
"workflow": "cm-ai",
|
|
338
|
+
"event": "model_usage",
|
|
339
|
+
"phase": "complete",
|
|
340
|
+
"runtime": "codex",
|
|
341
|
+
"project": "fixture",
|
|
342
|
+
"detail": "usage unavailable",
|
|
343
|
+
"call_id": "coder-call-0001",
|
|
344
|
+
"stage": "task_execution",
|
|
345
|
+
"role": "coder",
|
|
346
|
+
"adapter": "subscription-runtime",
|
|
347
|
+
"requested_model": "coder-default",
|
|
348
|
+
"source": "subscription",
|
|
349
|
+
"purpose": "cm-ai:task_execution",
|
|
350
|
+
"usage_state": "unavailable",
|
|
351
|
+
"duration_ms": 700,
|
|
352
|
+
"outcome": "success",
|
|
353
|
+
}
|
|
354
|
+
failed_unavailable_row: Dict[str, object] = {
|
|
355
|
+
**unavailable_row,
|
|
356
|
+
"event_id": "unavailable-error-event",
|
|
357
|
+
"call_id": "coder-call-0002",
|
|
358
|
+
"at": "2026-08-06T11:00:30+00:00",
|
|
359
|
+
"duration_ms": 400,
|
|
360
|
+
"outcome": "error",
|
|
361
|
+
}
|
|
362
|
+
unresolved_claim: Dict[str, object] = {
|
|
363
|
+
"schema_version": 1,
|
|
364
|
+
"event_id": "unresolved-claim-event",
|
|
365
|
+
"run_id": unavailable_run,
|
|
366
|
+
"at": "2026-08-06T11:00:45+00:00",
|
|
367
|
+
"workflow": "cm-ai",
|
|
368
|
+
"event": "model_call",
|
|
369
|
+
"phase": "claimed",
|
|
370
|
+
"runtime": "codex",
|
|
371
|
+
"project": "fixture",
|
|
372
|
+
"detail": "reviewer call claimed",
|
|
373
|
+
"call_id": "reviewer-call-unresolved",
|
|
374
|
+
"stage": "task_review",
|
|
375
|
+
"role": "reviewer",
|
|
376
|
+
"adapter": "openai-compatible",
|
|
377
|
+
"requested_model": "reviewer-default",
|
|
378
|
+
"source": "api",
|
|
379
|
+
"purpose": "cm-ai:task_review",
|
|
380
|
+
}
|
|
381
|
+
malformed_base: Dict[str, object] = {
|
|
382
|
+
"schema_version": 1,
|
|
383
|
+
"run_id": unavailable_run,
|
|
384
|
+
"at": "2026-08-06T11:01:00+00:00",
|
|
385
|
+
"workflow": "cm-ai",
|
|
386
|
+
"event": "model_usage",
|
|
387
|
+
"phase": "complete",
|
|
388
|
+
"runtime": "codex",
|
|
389
|
+
"project": "fixture",
|
|
390
|
+
"detail": "malformed fixture",
|
|
391
|
+
"stage": "task_execution",
|
|
392
|
+
"role": "coder",
|
|
393
|
+
"adapter": "company-api",
|
|
394
|
+
"requested_model": "coder-default",
|
|
395
|
+
"source": "api",
|
|
396
|
+
"purpose": "cm-ai:task_execution",
|
|
397
|
+
"usage_state": "observed",
|
|
398
|
+
"outcome": "success",
|
|
399
|
+
}
|
|
400
|
+
malformed_rows = [
|
|
401
|
+
{
|
|
402
|
+
**malformed_base,
|
|
403
|
+
"event_id": "malformed-missing-input",
|
|
404
|
+
"call_id": "malformed-call-0001",
|
|
405
|
+
"output_tokens": 4,
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
**malformed_base,
|
|
409
|
+
"event_id": "malformed-bool-input",
|
|
410
|
+
"call_id": "malformed-call-0002",
|
|
411
|
+
"input_tokens": True,
|
|
412
|
+
"output_tokens": 4,
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
**malformed_base,
|
|
416
|
+
"event_id": "malformed-negative-output",
|
|
417
|
+
"call_id": "malformed-call-0003",
|
|
418
|
+
"input_tokens": 4,
|
|
419
|
+
"output_tokens": -1,
|
|
420
|
+
},
|
|
421
|
+
]
|
|
422
|
+
mismatched_claim: Dict[str, object] = {
|
|
423
|
+
**unresolved_claim,
|
|
424
|
+
"event_id": "mismatched-claim-event",
|
|
425
|
+
"call_id": "mismatched-call-0001",
|
|
426
|
+
}
|
|
427
|
+
mismatched_usage: Dict[str, object] = {
|
|
428
|
+
**malformed_base,
|
|
429
|
+
"event_id": "mismatched-usage-event",
|
|
430
|
+
"call_id": "mismatched-call-0001",
|
|
431
|
+
"workflow": "cm-prd",
|
|
432
|
+
"stage": "design_generation",
|
|
433
|
+
"role": "planner",
|
|
434
|
+
"adapter": "other-api",
|
|
435
|
+
"requested_model": "planner-default",
|
|
436
|
+
"purpose": "cm-prd:design_generation",
|
|
437
|
+
"input_tokens": 10,
|
|
438
|
+
"output_tokens": 2,
|
|
439
|
+
}
|
|
440
|
+
conflicting_claim_one: Dict[str, object] = {
|
|
441
|
+
**unresolved_claim,
|
|
442
|
+
"event_id": "conflicting-claim-one",
|
|
443
|
+
"call_id": "conflicting-call-0001",
|
|
444
|
+
}
|
|
445
|
+
conflicting_claim_two: Dict[str, object] = {
|
|
446
|
+
**conflicting_claim_one,
|
|
447
|
+
"event_id": "conflicting-claim-two",
|
|
448
|
+
"stage": "design_generation",
|
|
449
|
+
"role": "planner",
|
|
450
|
+
"requested_model": "planner-default",
|
|
451
|
+
"purpose": "cm-ai:design_generation",
|
|
452
|
+
}
|
|
453
|
+
conflicting_usage: Dict[str, object] = {
|
|
454
|
+
**malformed_base,
|
|
455
|
+
"event_id": "conflicting-usage-event",
|
|
456
|
+
"call_id": "conflicting-call-0001",
|
|
457
|
+
"stage": "task_review",
|
|
458
|
+
"role": "reviewer",
|
|
459
|
+
"adapter": "openai-compatible",
|
|
460
|
+
"requested_model": "reviewer-default",
|
|
461
|
+
"source": "api",
|
|
462
|
+
"purpose": "cm-ai:task_review",
|
|
463
|
+
"input_tokens": 10,
|
|
464
|
+
"output_tokens": 2,
|
|
465
|
+
}
|
|
466
|
+
usage_before_claim: Dict[str, object] = {
|
|
467
|
+
**conflicting_usage,
|
|
468
|
+
"event_id": "usage-before-claim-event",
|
|
469
|
+
"call_id": "usage-before-claim-0001",
|
|
470
|
+
}
|
|
471
|
+
claim_after_usage: Dict[str, object] = {
|
|
472
|
+
**conflicting_claim_one,
|
|
473
|
+
"event_id": "claim-after-usage-event",
|
|
474
|
+
"call_id": "usage-before-claim-0001",
|
|
475
|
+
}
|
|
476
|
+
managed_without_claim_row: Dict[str, object] = {
|
|
477
|
+
**conflicting_usage,
|
|
478
|
+
"event_id": "managed-without-claim-event",
|
|
479
|
+
"call_id": "managed-without-claim-0002",
|
|
480
|
+
}
|
|
481
|
+
write_jsonl(
|
|
482
|
+
home / "index.jsonl",
|
|
483
|
+
[
|
|
484
|
+
{
|
|
485
|
+
"schema_version": 1,
|
|
486
|
+
"at": "2026-08-06T10:00:00+00:00",
|
|
487
|
+
"run_id": "usage-fixture-0001",
|
|
488
|
+
"status": "done",
|
|
489
|
+
"workflow": "cm-prd",
|
|
490
|
+
"runtime": "codex",
|
|
491
|
+
"project": "fixture",
|
|
492
|
+
"log_file": str(run_log.relative_to(home)),
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
"schema_version": 1,
|
|
496
|
+
"at": "2026-08-06T11:00:00+00:00",
|
|
497
|
+
"run_id": unavailable_run,
|
|
498
|
+
"status": "done",
|
|
499
|
+
"workflow": "cm-ai",
|
|
500
|
+
"runtime": "codex",
|
|
501
|
+
"project": "fixture",
|
|
502
|
+
"log_file": f"runs/2026-08/{unavailable_run}.jsonl",
|
|
503
|
+
},
|
|
504
|
+
],
|
|
505
|
+
)
|
|
506
|
+
write_jsonl(run_log, [event, duplicate_row, conflicting_duplicate])
|
|
507
|
+
write_jsonl(
|
|
508
|
+
home / f"runs/2026-08/{unavailable_run}.jsonl",
|
|
509
|
+
[
|
|
510
|
+
unavailable_row,
|
|
511
|
+
failed_unavailable_row,
|
|
512
|
+
unresolved_claim,
|
|
513
|
+
mismatched_claim,
|
|
514
|
+
mismatched_usage,
|
|
515
|
+
conflicting_claim_one,
|
|
516
|
+
conflicting_claim_two,
|
|
517
|
+
conflicting_usage,
|
|
518
|
+
usage_before_claim,
|
|
519
|
+
claim_after_usage,
|
|
520
|
+
managed_without_claim_row,
|
|
521
|
+
*malformed_rows,
|
|
522
|
+
],
|
|
523
|
+
)
|
|
524
|
+
|
|
525
|
+
machine = invoke_report(home, "--last", "2", "--json")
|
|
526
|
+
report = json.loads(machine.stdout)
|
|
527
|
+
assert report["unresolved_claim_policy"] == "reported-not-counted"
|
|
528
|
+
assert report["summary"]["observed_calls"] == 1
|
|
529
|
+
assert report["summary"]["unavailable_calls"] == 2
|
|
530
|
+
assert report["summary"]["unresolved_claims"] == 4
|
|
531
|
+
assert report["summary"]["invalid_calls"] == 8
|
|
532
|
+
assert report["summary"]["outcomes"] == {
|
|
533
|
+
"success": 2,
|
|
534
|
+
"error": 1,
|
|
535
|
+
"blocked": 0,
|
|
536
|
+
"cancelled": 0,
|
|
537
|
+
}
|
|
538
|
+
assert report["summary"]["input_tokens"] == 1200
|
|
539
|
+
assert report["summary"]["output_tokens"] == 300
|
|
540
|
+
assert report["summary"]["cache_read_tokens"] == 800
|
|
541
|
+
assert report["summary"]["cache_write_tokens"] == 100
|
|
542
|
+
assert report["summary"]["duration_ms"] == 3600
|
|
543
|
+
assert report["summary"]["duration_observed_calls"] == 3
|
|
544
|
+
assert len(report["groups"]) == 1
|
|
545
|
+
assert report["groups"][0]["model_source"] == "effective"
|
|
546
|
+
assert report["groups"][0]["model"] == "provider-model-v2"
|
|
547
|
+
assert report["groups"][0]["outcome"] == "success"
|
|
548
|
+
assert {group["outcome"] for group in report["unavailable_groups"]} == {
|
|
549
|
+
"success",
|
|
550
|
+
"error",
|
|
551
|
+
}
|
|
552
|
+
assert sum(group["duration_ms"] for group in report["unavailable_groups"]) == 1100
|
|
553
|
+
assert report["unresolved_groups"] == [
|
|
554
|
+
{
|
|
555
|
+
"workflow": "cm-ai",
|
|
556
|
+
"stage": "task_review",
|
|
557
|
+
"role": "reviewer",
|
|
558
|
+
"adapter": "openai-compatible",
|
|
559
|
+
"requested_model": "reviewer-default",
|
|
560
|
+
"source": "api",
|
|
561
|
+
"claims": 4,
|
|
562
|
+
}
|
|
563
|
+
]
|
|
564
|
+
assert "ignored malformed model_usage" in machine.stderr
|
|
565
|
+
assert "conflicting model_call identity" in machine.stderr
|
|
566
|
+
assert "mismatched claim identity" in machine.stderr
|
|
567
|
+
|
|
568
|
+
human = invoke_report(home, "--last", "2")
|
|
569
|
+
assert "observed 1" in human.stdout
|
|
570
|
+
assert "unavailable 2" in human.stdout
|
|
571
|
+
assert "unresolved claims 4" in human.stdout
|
|
572
|
+
assert "cm-ai/task_review | reviewer | openai-compatible | reviewer-default" in (
|
|
573
|
+
human.stdout
|
|
574
|
+
)
|
|
575
|
+
assert "outcomes: success 2 | error 1 | blocked 0 | cancelled 0" in human.stdout
|
|
576
|
+
assert "cache read 800" in human.stdout
|
|
577
|
+
assert "未推测缺失用量" in human.stdout
|
|
578
|
+
|
|
579
|
+
print("cm usage report fixture: PASS")
|
|
580
|
+
return 0
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
if __name__ == "__main__":
|
|
584
|
+
raise SystemExit(main())
|