@aibyzero/cm-workflow 0.16.4 → 0.16.6
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 +1 -1
- package/AGENTS.md +22 -0
- package/CHANGELOG.md +57 -0
- package/README.md +22 -4
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/VERSION +1 -1
- package/docs/architecture.md +43 -0
- package/docs/execution-optimizations.md +33 -0
- package/docs/external-models.md +114 -0
- package/docs/fixes/.reviews/20260929-bootstrap-unchanged-review-r1.md +7 -0
- package/docs/fixes/.reviews/20260930-develop-package-limit-recovery-r4.md +9 -0
- package/docs/fixes/20260929-bootstrap-rule-refresh-conflict.md +22 -0
- package/docs/fixes/20260929-bootstrap-unchanged-review.md +26 -0
- package/docs/fixes/20260930-develop-package-limit-recovery.md +65 -0
- package/docs/human-correction.md +31 -0
- package/docs/installation.md +48 -7
- package/docs/js-workflow-control.md +293 -33
- package/docs/live-evidence-drivers.md +62 -0
- package/docs/next-steps.md +15 -10
- package/docs/runtime-failover.md +1 -1
- package/docs/untested-branches.md +27 -4
- package/docs/user-guide.md +23 -8
- package/install-codex.sh +28 -11
- package/package.json +1 -1
- package/runtime/js/cm-ai/accepted-fix.mjs +23 -5
- package/runtime/js/cm-ai/bootstrap-feature.mjs +15 -0
- package/runtime/js/cm-ai/claude-review-adapter.mjs +7 -4
- package/runtime/js/cm-ai/claude-review-stream.mjs +12 -0
- package/runtime/js/cm-ai/claude-tool-preview.mjs +4 -4
- package/runtime/js/cm-ai/cm-ai-admission.mjs +115 -41
- package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +3 -2
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +208 -34
- package/runtime/js/cm-ai/cm-ai-learning-handoff-writer.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-learning-writer.mjs +22 -5
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +181 -57
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +15 -58
- package/runtime/js/cm-ai/codex-config.mjs +3 -2
- package/runtime/js/cm-ai/codex-review-adapter.mjs +56 -17
- package/runtime/js/cm-ai/committed-rule-basis.mjs +76 -0
- package/runtime/js/cm-ai/developer-adapter.mjs +6 -2
- package/runtime/js/cm-ai/diagnostic-reason.mjs +10 -0
- package/runtime/js/cm-ai/drive-bootstrap.mjs +315 -0
- package/runtime/js/cm-ai/drive-core.mjs +47 -9
- package/runtime/js/cm-ai/durable-runner-state.mjs +413 -56
- package/runtime/js/cm-ai/effect-abandon-log.mjs +19 -0
- package/runtime/js/cm-ai/effect-contract.mjs +44 -2
- package/runtime/js/cm-ai/execution-policy.mjs +58 -0
- package/runtime/js/cm-ai/execution-store-limits.mjs +18 -0
- package/runtime/js/cm-ai/execution-store.mjs +6 -4
- package/runtime/js/cm-ai/external-group-models.mjs +53 -0
- package/runtime/js/cm-ai/external-model-launch.mjs +23 -0
- package/runtime/js/cm-ai/external-models.mjs +52 -0
- package/runtime/js/cm-ai/external-run-guard.mjs +96 -0
- package/runtime/js/cm-ai/fix-code-association.mjs +171 -18
- package/runtime/js/cm-ai/host-bootstrap.mjs +126 -29
- package/runtime/js/cm-ai/host-check.mjs +30 -4
- package/runtime/js/cm-ai/host-conversation-execution.mjs +66 -20
- package/runtime/js/cm-ai/host-handoff.mjs +13 -6
- package/runtime/js/cm-ai/host-progress.mjs +80 -0
- package/runtime/js/cm-ai/host-project-execution.mjs +16 -11
- package/runtime/js/cm-ai/host-qa-executor.mjs +23 -9
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +23 -6
- package/runtime/js/cm-ai/host-qa-policy.mjs +16 -7
- package/runtime/js/cm-ai/host-session.mjs +12 -4
- package/runtime/js/cm-ai/host-tool-bridge.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +16 -5
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/knowledge-closeout.mjs +56 -0
- package/runtime/js/cm-ai/launch-mismatch.mjs +42 -0
- package/runtime/js/cm-ai/legacy-model-run-preview.mjs +24 -0
- package/runtime/js/cm-ai/legacy-model-settings.mjs +59 -0
- package/runtime/js/cm-ai/live-evidence.mjs +96 -0
- package/runtime/js/cm-ai/log-rows.mjs +21 -0
- package/runtime/js/cm-ai/model-configuration-file.mjs +63 -0
- package/runtime/js/cm-ai/model_configuration_write.py +214 -0
- package/runtime/js/cm-ai/native-usage-log.mjs +26 -0
- package/runtime/js/cm-ai/operator-guidance.mjs +86 -0
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +22 -0
- package/runtime/js/cm-ai/project-qa-gate.mjs +84 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +68 -9
- package/runtime/js/cm-ai/provider-usage.mjs +39 -0
- package/runtime/js/cm-ai/qa-config-revision.mjs +44 -10
- package/runtime/js/cm-ai/review-abandon-log.mjs +21 -0
- package/runtime/js/cm-ai/review-package.mjs +438 -31
- package/runtime/js/cm-ai/review-presentation.mjs +45 -0
- package/runtime/js/cm-ai/review-reconciliation.mjs +20 -0
- package/runtime/js/cm-ai/review-runner.mjs +47 -1
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +97 -0
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +104 -10
- package/runtime/js/cm-ai/reviewed-evidence-supersession-record.mjs +42 -3
- package/runtime/js/cm-ai/specification-material.mjs +154 -12
- package/runtime/js/cm-ai/status-projection.mjs +93 -0
- package/runtime/js/cm-ai/task-commit.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +658 -75
- package/runtime/js/cm-ai/tool-preview.mjs +8 -4
- package/runtime/js/cm-ai/worker-claude-developer.mjs +16 -7
- package/runtime/js/cm-ai/worker-claude.mjs +63 -19
- package/runtime/js/cm-ai/worker-codex-developer.mjs +15 -9
- package/runtime/js/cm-ai/worker-codex.mjs +45 -19
- package/runtime/js/cm-fix/cause-evidence.mjs +5 -3
- package/runtime/js/cm-fix/cause-invocation.mjs +6 -3
- package/runtime/js/cm-fix/cause-package.mjs +10 -1
- package/runtime/js/cm-fix/execution.mjs +279 -52
- package/runtime/js/cm-fix/final-review.mjs +18 -10
- package/runtime/js/cm-fix/host-review.mjs +32 -9
- package/runtime/js/cm-fix/host.mjs +6 -1
- package/runtime/js/cm-fix/layout.mjs +1 -1
- package/runtime/js/cm-fix/progress.mjs +5 -0
- package/runtime/js/cm-fix/protected-edits.mjs +15 -4
- package/runtime/js/cm-fix/qa-source.mjs +6 -4
- package/runtime/js/cm-fix/review-reconciliation.mjs +64 -0
- package/runtime/js/cm-prd/analysis.mjs +2 -1
- package/runtime/js/cm-prd/change.mjs +28 -10
- package/runtime/js/cm-prd/draft.mjs +5 -2
- package/runtime/js/cm-prd/response-recovery.mjs +23 -0
- package/runtime/js/cm-prd/review-preparation.mjs +10 -3
- package/runtime/js/cm-prd/review-publication.mjs +27 -15
- package/runtime/js/cm-prd/review-time.mjs +29 -0
- package/runtime/js/cm-prd/self-check.mjs +6 -3
- package/runtime/js/cm-prd/session.mjs +53 -6
- package/runtime/js/cm-prd/summary.mjs +3 -1
- package/runtime/js/cm-prd/validation-reason.mjs +20 -0
- package/runtime/js/cm-security/finalize.mjs +32 -0
- package/runtime/js/spec-task-line.mjs +117 -0
- package/runtime/js/specs-status.mjs +10 -3
- package/runtime/review.md +5 -0
- package/runtime/task-gates.md +6 -0
- package/runtime/workflow-config.md +10 -1
- package/scripts/cm-ai-abandon-effect-position.test.mjs +201 -0
- package/scripts/cm-ai-admission.mjs +18 -11
- package/scripts/cm-ai-admission.test.mjs +65 -1
- package/scripts/cm-ai-batch-drive.mjs +135 -34
- package/scripts/cm-ai-batch-drive.test.mjs +209 -3
- package/scripts/cm-ai-batch-host.mjs +63 -24
- package/scripts/cm-ai-batch-host.test.mjs +2 -1
- package/scripts/cm-ai-batch-run.mjs +101 -34
- package/scripts/cm-ai-batch-run.test.mjs +56 -5
- package/scripts/cm-ai-bootstrap-driver-preflight.test.mjs +45 -0
- package/scripts/cm-ai-bootstrap-flow.test.mjs +159 -0
- package/scripts/cm-ai-bootstrap-merge.test.mjs +162 -0
- package/scripts/cm-ai-bootstrap.test.mjs +174 -89
- package/scripts/cm-ai-conversation-entry-ops.test.mjs +97 -2
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +924 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +468 -0
- package/scripts/cm-ai-drive-timeout.test.mjs +17 -0
- package/scripts/cm-ai-drive.mjs +526 -60
- package/scripts/cm-ai-drive.test.mjs +336 -10
- package/scripts/cm-ai-fix-later-delivery.test.mjs +383 -0
- package/scripts/cm-ai-host.mjs +142 -43
- package/scripts/cm-ai-host.test.mjs +232 -12
- package/scripts/cm-ai-launch-diagnostics.test.mjs +142 -0
- package/scripts/cm-ai-multi-root.test.mjs +9 -3
- package/scripts/cm-ai-operator-guidance.test.mjs +94 -0
- package/scripts/cm-ai-progress.test.mjs +521 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +308 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +187 -15
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +157 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +27 -2
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +400 -0
- package/scripts/cm-ai-review-drift-precedence.test.mjs +90 -0
- package/scripts/cm-ai-review-failure.test.mjs +977 -0
- package/scripts/cm-ai-review-timeout-config.test.mjs +29 -7
- package/scripts/cm-ai-review-timeout.test.mjs +199 -4
- package/scripts/cm-ai-run.mjs +206 -62
- package/scripts/cm-ai-run.test.mjs +6 -4
- package/scripts/cm-ai-runner-error-code-regression.test.mjs +219 -0
- package/scripts/cm-ai-selection-guard.test.mjs +100 -0
- package/scripts/cm-ai-session-chain.test.mjs +7 -3
- package/scripts/cm-ai-spec-rebind.test.mjs +481 -0
- package/scripts/cm-ai-supersede.test.mjs +571 -17
- package/scripts/cm-ai-verification-gate.test.mjs +2 -1
- package/scripts/cm-bootstrap-review-recovery.test.mjs +70 -0
- package/scripts/cm-capability-gate.test.mjs +21 -2
- package/scripts/cm-check-drive.test.mjs +2 -1
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +12 -1
- package/scripts/cm-claude-developer-worker.test.mjs +3 -1
- package/scripts/cm-claude-install-layout.test.mjs +26 -0
- package/scripts/cm-claude-probe.test.mjs +10 -2
- package/scripts/cm-claude-review-stream.test.mjs +25 -0
- package/scripts/cm-claude-worker.test.mjs +11 -4
- package/scripts/cm-codex-developer-worker.test.mjs +4 -2
- package/scripts/cm-codex-plugin-metadata.py +83 -0
- package/scripts/cm-codex-plugin-metadata.test.mjs +55 -0
- package/scripts/cm-efficiency-checks.test.mjs +37 -0
- package/scripts/cm-efficiency-diagnostics.test.mjs +74 -0
- package/scripts/cm-efficiency-offline.mjs +35 -0
- package/scripts/cm-efficiency-policy.test.mjs +48 -0
- package/scripts/cm-efficiency-presentation.test.mjs +35 -0
- package/scripts/cm-efficiency-response.test.mjs +117 -0
- package/scripts/cm-efficiency-usage.test.mjs +148 -0
- package/scripts/cm-external-batch-host.test.mjs +157 -0
- package/scripts/cm-external-fix-host.test.mjs +281 -0
- package/scripts/cm-external-fix-reconciliation.test.mjs +105 -0
- package/scripts/cm-external-group-models.test.mjs +60 -0
- package/scripts/cm-external-model-host.test.mjs +180 -0
- package/scripts/cm-external-model-recovery.test.mjs +108 -0
- package/scripts/cm-external-models.test.mjs +89 -0
- package/scripts/cm-external-process-cleanup.test.mjs +71 -0
- package/scripts/cm-external-qa-fix.test.mjs +170 -0
- package/scripts/cm-external-review-reconciliation.test.mjs +314 -0
- package/scripts/cm-failover.mjs +8 -8
- package/scripts/cm-fix-abandon.test.mjs +123 -5
- package/scripts/cm-fix-cause-package.test.mjs +2 -0
- package/scripts/cm-fix-drive.mjs +70 -23
- package/scripts/cm-fix-drive.test.mjs +36 -1
- package/scripts/cm-fix-final-review.test.mjs +11 -6
- package/scripts/cm-fix-host.mjs +24 -14
- package/scripts/cm-fix-protected-edits.test.mjs +12 -0
- package/scripts/cm-fix-rediagnosis.test.mjs +168 -0
- package/scripts/cm-fix-review-budget.test.mjs +147 -0
- package/scripts/cm-fixture-process-cleanup.test.mjs +95 -0
- package/scripts/cm-host-check.test.mjs +6 -3
- package/scripts/cm-host-qa-executor.test.mjs +213 -17
- package/scripts/cm-host-session-diagnostic.test.mjs +10 -0
- package/scripts/cm-interactive-qa-diagnostic.test.mjs +53 -0
- package/scripts/cm-knowledge-closeout.test.mjs +160 -0
- package/scripts/cm-live-evidence.test.mjs +64 -0
- package/scripts/cm-log-event.mjs +25 -2
- package/scripts/cm-log-event.py +15 -0
- package/scripts/cm-log-event.test.mjs +31 -0
- package/scripts/cm-model-setup.mjs +79 -0
- package/scripts/cm-prd-completion.test.mjs +75 -0
- package/scripts/cm-prd-draft.test.mjs +14 -0
- package/scripts/cm-prd-drive.mjs +32 -11
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-gate-diagnostic.test.mjs +100 -0
- package/scripts/cm-prd-host.mjs +13 -4
- package/scripts/cm-prd-review-gate.mjs +126 -81
- package/scripts/cm-prd-review-gate.test.mjs +105 -1
- package/scripts/cm-prd-review-preparation.test.mjs +15 -0
- package/scripts/cm-prd-review-publication.test.mjs +6 -0
- package/scripts/cm-prd-self-check.test.mjs +6 -0
- package/scripts/cm-prd-summary.test.mjs +9 -0
- package/scripts/cm-release-smoke.sh +5 -1
- package/scripts/cm-review-dependency-snapshot.test.mjs +15 -0
- package/scripts/cm-review-inventory.test.mjs +253 -1
- package/scripts/cm-runtime-i18n.mjs +15 -4
- package/scripts/cm-runtime-install.mjs +8 -4
- package/scripts/cm-runtime.mjs +116 -23
- package/scripts/cm-runtime.test.mjs +121 -12
- package/scripts/cm-security.test.mjs +32 -0
- package/scripts/cm-spec-manifest.mjs +28 -10
- package/scripts/cm-spec-manifest.test.mjs +8 -4
- package/scripts/cm-spec-task-line.test.mjs +138 -0
- package/scripts/cm-specs-status.test.mjs +12 -1
- package/scripts/cm-task-gate-correction.test.mjs +117 -0
- package/scripts/cm-task-gate.mjs +164 -20
- package/scripts/cm-task-gate.py +2 -1
- package/scripts/cm-test-branch-impact.test.mjs +6 -3
- package/scripts/cm-test-drive.mjs +10 -4
- package/scripts/cm-test-drive.test.mjs +14 -1
- package/scripts/cm-tool-preview-context.test.mjs +12 -0
- package/scripts/cm-usage-report.py +22 -3
- package/scripts/cm-workflow-config.mjs +10 -1
- package/scripts/fixtures/bootstrap-review-runner.mjs +102 -0
- package/scripts/fixtures/claude-review-process.mjs +1 -0
- package/scripts/fixtures/live-evidence-driver.mjs +35 -0
- package/scripts/fixtures/process-cleanup.mjs +101 -0
- package/scripts/test-cm-log-event.py +2 -0
- package/scripts/test-cm-native-usage.py +62 -0
- package/scripts/test-cm-prd-review-gate.py +2 -1
- package/scripts/test-external-model-setup.py +91 -0
- package/scripts/test-model-configuration-write.py +201 -0
- package/scripts/test-npm-install.py +11 -2
- package/scripts/test-scan-public-safety.py +1 -1
- package/scripts/test-spec-manifest.py +16 -8
- package/scripts/test-task-gate.py +2 -2
- package/scripts/test-workflow-config.py +1 -0
- package/scripts/validate-public-repo.py +1 -0
- package/skills/cm-ai/SKILL.md +2 -2
- package/skills/cm-ai/references/N1-init.md +1 -1
- package/skills/cm-ai/references/N8-finish.md +5 -0
- package/skills/cm-ai/references/js-host.md +270 -43
- package/skills/cm-ai/references/knowledge-closeout.md +90 -0
- package/skills/cm-fix/SKILL.md +1 -1
- package/skills/cm-fix/references/js-host.md +52 -3
- package/skills/cm-prd/references/js-change-recovery.md +1 -1
- package/skills/cm-prd/references/js-host.md +6 -0
- package/skills/cm-runtime/SKILL.md +29 -6
- package/skills/cm-security/SKILL.md +4 -2
- package/skills/cm-security/references/scan-contract.md +1 -0
- package/templates/cm-workflow.yml +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {createLiveEvidence} from '../runtime/js/cm-ai/live-evidence.mjs';
|
|
7
|
+
|
|
8
|
+
function fixture(t){
|
|
9
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-live-evidence-')));
|
|
10
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
11
|
+
const project=path.join(root,'project');fs.mkdirSync(project);
|
|
12
|
+
return {root,project,directory:path.join(root,'exchange')};
|
|
13
|
+
}
|
|
14
|
+
const row={type:'host_request',sessionId:'session-a',callId:'call-a',requestDigest:'a'.repeat(64),kind:'qa_logic',payload:{case:{id:'TC-001'}}};
|
|
15
|
+
test('fresh live request accepts only its session/call/digest and leaves request evidence',async t=>{
|
|
16
|
+
const f=fixture(t);let requestPath;
|
|
17
|
+
const live=createLiveEvidence({directory:f.directory,kinds:['qa_logic'],timeoutMs:1000},{base:f.root,protectedRoots:[f.project],
|
|
18
|
+
notify:p=>{requestPath=p;const request=JSON.parse(fs.readFileSync(p));
|
|
19
|
+
fs.writeFileSync(p.replace('.request.json','.result.json'),JSON.stringify({type:'host_result',sessionId:request.sessionId,
|
|
20
|
+
callId:request.callId,requestDigest:request.requestDigest,result:{verdict:'SUPPORTED',evidence:['observed']}}));}});
|
|
21
|
+
const result=await live.answer(row);
|
|
22
|
+
assert.equal(result.verdict,'SUPPORTED');assert.ok(fs.existsSync(requestPath));
|
|
23
|
+
assert.equal(fs.statSync(path.dirname(requestPath)).mode&0o777,0o700);
|
|
24
|
+
assert.equal(await live.answer({...row,kind:'check'}),null);
|
|
25
|
+
});
|
|
26
|
+
test('stale reply is refused rather than rebound to the current request',async t=>{
|
|
27
|
+
const f=fixture(t);const live=createLiveEvidence({directory:f.directory,kinds:['qa_logic'],timeoutMs:1000},
|
|
28
|
+
{base:f.root,protectedRoots:[f.project],notify:p=>fs.writeFileSync(p.replace('.request.json','.result.json'),
|
|
29
|
+
JSON.stringify({type:'host_result',sessionId:'old-session',callId:row.callId,requestDigest:row.requestDigest,result:{verdict:'PASS'}}))});
|
|
30
|
+
await assert.rejects(live.answer(row),/live_evidence_binding_mismatch/);
|
|
31
|
+
});
|
|
32
|
+
test('no response times out and cancellation interrupts the wait',async t=>{
|
|
33
|
+
const f=fixture(t);const live=createLiveEvidence({directory:f.directory,kinds:['qa_logic'],timeoutMs:30},
|
|
34
|
+
{base:f.root,protectedRoots:[f.project],notify:()=>{}});
|
|
35
|
+
await assert.rejects(live.answer(row),/live_evidence_timeout/);
|
|
36
|
+
const controller=new AbortController();controller.abort();
|
|
37
|
+
await assert.rejects(live.answer({...row,callId:'call-b'},{signal:controller.signal}),/live_evidence_cancelled/);
|
|
38
|
+
});
|
|
39
|
+
test('preflight refuses protected trees, symlinks, unknown kinds and malformed settings',t=>{
|
|
40
|
+
const f=fixture(t),options={base:f.root,protectedRoots:[f.project]};
|
|
41
|
+
fs.symlinkSync(f.project,path.join(f.root,'linked'));
|
|
42
|
+
for(const config of [{directory:f.project,kinds:['qa_logic']},{directory:path.join(f.project,'exchange'),kinds:['qa_logic']},
|
|
43
|
+
{directory:path.join(f.root,'linked','exchange'),kinds:['qa_logic']},{directory:f.directory,kinds:['develop']},
|
|
44
|
+
{directory:f.directory,kinds:['qa_logic'],timeoutMs:0},{directory:f.directory,kinds:['qa_logic'],extra:true}])
|
|
45
|
+
assert.throws(()=>createLiveEvidence(config,options),/live_evidence_/);
|
|
46
|
+
});
|
|
47
|
+
for(const bad of ['symlink','oversize','malformed'])test(`live result refuses ${bad} rather than claiming execution`,async t=>{
|
|
48
|
+
const f=fixture(t);const live=createLiveEvidence({directory:f.directory,kinds:['qa_logic'],timeoutMs:1000},
|
|
49
|
+
{base:f.root,protectedRoots:[f.project],maxBytes:100,notify:file=>{
|
|
50
|
+
const target=file.replace('.request.json','.result.json');
|
|
51
|
+
if(bad==='symlink')fs.symlinkSync(file,target);
|
|
52
|
+
else fs.writeFileSync(target,bad==='oversize'?'x'.repeat(101):'{');
|
|
53
|
+
}});
|
|
54
|
+
await assert.rejects(live.answer(row),bad==='malformed'?/live_evidence_invalid_json/:/live_evidence_unsafe_result|ELOOP/);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('future parallel worktree roots are protected before they exist, including an aliased parent',t=>{
|
|
58
|
+
const f=fixture(t),future=path.join(f.root,'.cm-worktrees');
|
|
59
|
+
assert.throws(()=>createLiveEvidence({directory:path.join(future,'run','exchange'),kinds:['qa_logic']},
|
|
60
|
+
{protectedRoots:[future]}),/live_evidence_protected_directory/);
|
|
61
|
+
const alias=path.join(f.root,'alias');fs.symlinkSync(f.root,alias);
|
|
62
|
+
assert.throws(()=>createLiveEvidence({directory:path.join(future,'run','exchange'),kinds:['qa_logic']},
|
|
63
|
+
{protectedRoots:[path.join(alias,'.cm-worktrees')]}),/live_evidence_protected_directory/);
|
|
64
|
+
});
|
package/scripts/cm-log-event.mjs
CHANGED
|
@@ -5,10 +5,15 @@ import fs from 'node:fs';
|
|
|
5
5
|
import os from 'node:os';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import {fileURLToPath} from 'node:url';
|
|
8
|
+
import {statusProjectionCommand} from '../runtime/js/cm-ai/status-projection.mjs';
|
|
8
9
|
|
|
9
10
|
const IDENTIFIER=/^[A-Za-z][A-Za-z0-9._-]{0,63}$/;
|
|
10
11
|
const RESOURCE_ID=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
11
12
|
const RUN_ID=/^[A-Za-z0-9][A-Za-z0-9._-]{7,127}$/;
|
|
13
|
+
// The single run ID rule. Workflow run definitions must satisfy it before they
|
|
14
|
+
// create durable state, otherwise the first log write fails inside an effect.
|
|
15
|
+
export const RUN_ID_RULE='8-128 characters of A-Z a-z 0-9 . _ -, starting with a letter or digit';
|
|
16
|
+
export const validRunId=value=>typeof value==='string'&&RUN_ID.test(value);
|
|
12
17
|
const SENSITIVE_KEY=/(api[_-]?key|authorization|cookie|password|passwd|private[_-]?key|recovery[_-]?code|secret|token)/i;
|
|
13
18
|
const RESERVED_FIELDS=new Set(['schema_version','event_id','run_id','at','workflow','event','phase','runtime','project','project_path','specs_path','detail']);
|
|
14
19
|
export const TERMINAL_EVENTS=new Set(['done','run_done']);
|
|
@@ -16,7 +21,7 @@ export const RESOURCE_GUARDED_EVENTS=new Set([...TERMINAL_EVENTS,'task_done']);
|
|
|
16
21
|
const RESOURCE_PHASES=new Set(['acquired','released','cleanup_failed']);
|
|
17
22
|
const TEST_RUN_GUARDED_EVENTS=new Set([...TERMINAL_EVENTS,'task_done']);
|
|
18
23
|
const TEST_RUN_PHASES=new Set(['start','case_start','case_complete','case_blocked','complete','abandoned','superseded']);
|
|
19
|
-
const MODEL_USAGE_TOKEN_FIELDS=new Set(['input_tokens','output_tokens','cache_read_tokens','cache_write_tokens']);
|
|
24
|
+
const MODEL_USAGE_TOKEN_FIELDS=new Set(['input_tokens','output_tokens','cache_read_tokens','cache_write_tokens','reasoning_tokens']);
|
|
20
25
|
const MODEL_USAGE_STATES=new Set(['observed','unavailable']);
|
|
21
26
|
const MODEL_USAGE_OUTCOMES=new Set(['success','error','blocked','cancelled']);
|
|
22
27
|
const MODEL_USAGE_ALLOWED_FIELDS=new Set([...MODEL_USAGE_TOKEN_FIELDS,'call_id','role','adapter','requested_model',
|
|
@@ -86,6 +91,7 @@ function validateModelUsageEvent(event,phase,data){
|
|
|
86
91
|
throw new UsageError('unavailable model_usage cannot contain token counts');
|
|
87
92
|
if(data.usage_state==='observed')for(const field of ['input_tokens','output_tokens'])
|
|
88
93
|
if(!Object.hasOwn(data,field))throw new UsageError(`observed model_usage requires ${field}`);
|
|
94
|
+
if(Object.hasOwn(data,'reasoning_tokens')&&data.reasoning_tokens>data.output_tokens)throw new UsageError('reasoning_tokens must be an output subset');
|
|
89
95
|
for(const field of [...MODEL_USAGE_TOKEN_FIELDS,'duration_ms'])if(Object.hasOwn(data,field)){
|
|
90
96
|
const value=data[field];
|
|
91
97
|
if(!Number.isInteger(value)||value<0)throw new UsageError(`model_usage ${field} must be a non-negative integer`);
|
|
@@ -345,6 +351,19 @@ function validateQaSupersession(state,event){
|
|
|
345
351
|
throw new UsageError('QA configuration supersession requires the matching completed invocation and revision digest');
|
|
346
352
|
return;
|
|
347
353
|
}
|
|
354
|
+
const caseList=(value,count)=>Array.isArray(value)&&value.length===count&&new Set(value).size===value.length
|
|
355
|
+
&&value.every(item=>typeof item==='string'&&RESOURCE_ID.test(item));
|
|
356
|
+
if(event.reason==='declared_environment_failure'){
|
|
357
|
+
const reason=event.environment_failure_reason;
|
|
358
|
+
if(state.active||state.superseded||!start||!complete||complete.result!=='FAIL'||!(complete.failed>0)
|
|
359
|
+
||start.attempt>=3||event.workflow!=='cm-ai'||event.node!=='N6'||event.previous_test_run_id!==start.operation_id
|
|
360
|
+
||!caseList(event.failed_cases,complete.failed)||!caseList(event.blocked_cases,complete.blocked)
|
|
361
|
+
||typeof reason!=='string'||!reason.trim()||Buffer.byteLength(reason,'utf8')>500||/[\r\n\0]/.test(reason)
|
|
362
|
+
||!['repository_id','run_id','feature','task','package_digest','qa_decision_id','operation_id','attempt','mode','case_count']
|
|
363
|
+
.every(key=>event[key]!==undefined&&event[key]===start[key]&&event[key]===complete[key]))
|
|
364
|
+
throw new UsageError('QA environment-failure supersession requires the matching completed FAIL invocation, case lists and reason');
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
348
367
|
if(state.active||state.superseded||!start||!complete||complete.result!=='BLOCKED'||complete.failed!==0
|
|
349
368
|
||complete.blocked<=0||start.attempt>=3||event.workflow!=='cm-ai'||event.node!=='N6'
|
|
350
369
|
||event.reason!=='host_evidence_problem'||event.previous_test_run_id!==start.operation_id
|
|
@@ -476,7 +495,7 @@ export function writeLogEvent(rawInput,{environment=process.env,now=new Date(),u
|
|
|
476
495
|
if(existingUsage!==null&&existingUsage.event_id!==event.event_id)
|
|
477
496
|
throw new UsageError('model_usage call_id already used with different payload');
|
|
478
497
|
const existingClaim=findModelEvent(authoritativeLog,built.runId,'model_call',event.call_id);
|
|
479
|
-
if(event.adapter==='openai-compatible'&&existingClaim===null)
|
|
498
|
+
if((event.adapter==='openai-compatible'||event.source==='native-cli-terminal')&&existingClaim===null)
|
|
480
499
|
throw new UsageError('managed model_usage requires a prior model_call claim');
|
|
481
500
|
if(existingClaim!==null&&modelCallIdentity(existingClaim).some((value,index)=>value!==modelCallIdentity(event)[index]))
|
|
482
501
|
throw new UsageError('model_usage identity does not match model_call claim');
|
|
@@ -584,6 +603,10 @@ function usage(){return 'usage: cm-log-event.py --workflow NAME --event NAME --r
|
|
|
584
603
|
|
|
585
604
|
export function main(argv=process.argv.slice(2),environment=process.env){
|
|
586
605
|
try{
|
|
606
|
+
if(argv[0]==='--status-only'){
|
|
607
|
+
const result=statusProjectionCommand(argv,environment);
|
|
608
|
+
if(result!==null)process.stdout.write(`${asciiJson(result)}\n`);return 0;
|
|
609
|
+
}
|
|
587
610
|
const input=parseCli(argv);if(input.help){process.stdout.write(`${usage()}\n`);return 0;}
|
|
588
611
|
if(environment.CM_LOG_PREFLIGHT==='1'){prepareInput(input);return 0;}
|
|
589
612
|
const result=writeLogEvent(input,{environment});process.stdout.write(`${asciiJson(result)}\n`);return 0;
|
package/scripts/cm-log-event.py
CHANGED
|
@@ -73,6 +73,7 @@ def run_node(entry: Path, arguments: List[str], environment: dict) -> int:
|
|
|
73
73
|
|
|
74
74
|
def main() -> int:
|
|
75
75
|
arguments = sys.argv[1:]
|
|
76
|
+
status_only = arguments[:1] == ["--status-only"]
|
|
76
77
|
entry = Path(__file__).resolve().with_name("cm-log-event.mjs")
|
|
77
78
|
|
|
78
79
|
if "--help" in arguments or "-h" in arguments:
|
|
@@ -92,6 +93,10 @@ def main() -> int:
|
|
|
92
93
|
)
|
|
93
94
|
if specs_dir is not None:
|
|
94
95
|
try:
|
|
96
|
+
if status_only:
|
|
97
|
+
lock = specs_dir / ".cm-run.lock"
|
|
98
|
+
if lock.is_symlink() or (lock.exists() and (not lock.is_file() or lock.stat().st_nlink != 1)):
|
|
99
|
+
raise OSError("invalid status lock")
|
|
95
100
|
acquire_file_lock(specs_dir / ".cm-run.lock", private=False)
|
|
96
101
|
except OSError as error:
|
|
97
102
|
print(
|
|
@@ -100,6 +105,16 @@ def main() -> int:
|
|
|
100
105
|
)
|
|
101
106
|
return 1
|
|
102
107
|
|
|
108
|
+
# Status is a projection, not a log event. Reuse the project lock, including
|
|
109
|
+
# its automatic release on process exit; do not touch the global mirror or
|
|
110
|
+
# active-run pointer for a display-only write.
|
|
111
|
+
if status_only:
|
|
112
|
+
environment = os.environ.copy()
|
|
113
|
+
environment["CM_LOG_LOCK_ADAPTER"] = "1"
|
|
114
|
+
environment["CM_LOG_LOCK_PARENT_PID"] = str(os.getpid())
|
|
115
|
+
environment["CM_LOG_PROJECT_LOCK"] = str(specs_dir / ".cm-run.lock")
|
|
116
|
+
return run_node(entry, arguments, environment)
|
|
117
|
+
|
|
103
118
|
global_home = Path(
|
|
104
119
|
os.environ.get("CM_WORKFLOW_LOG_HOME", "~/.cm-workflow/logs")
|
|
105
120
|
).expanduser().resolve(strict=False)
|
|
@@ -68,3 +68,34 @@ test('JS log persistence writes project authority, mirrors globally, and dedupli
|
|
|
68
68
|
assert.equal(fs.readFileSync(result.project_log,'utf8').trim().split('\n').length,1);
|
|
69
69
|
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
70
70
|
});
|
|
71
|
+
|
|
72
|
+
test('QA environment-failure supersession needs the matching completed FAIL, both case lists and a single-line reason',()=>{
|
|
73
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-log-env-failure-')));
|
|
74
|
+
try{
|
|
75
|
+
const project=path.join(root,'project'),specs=path.join(root,'specs'),runId='env-failure-run';
|
|
76
|
+
fs.mkdirSync(project);fs.mkdirSync(specs);
|
|
77
|
+
const env={...process.env,CM_WORKFLOW_LOG_HOME:path.join(root,'logs')};
|
|
78
|
+
const bound={node:'N6',repository_id:'fixture',feature:'1.work',task:'T-001',package_digest:'a'.repeat(64),
|
|
79
|
+
qa_decision_id:'qa-decision',operation_id:'qa-round-1',attempt:1,mode:'commands',case_count:2};
|
|
80
|
+
const write=(phase,data)=>spawnSync(process.env.CM_PYTHON_BIN||'python3',[pythonWriter,'--workflow','cm-ai','--event','test_run',
|
|
81
|
+
'--phase',phase,'--runtime','codex','--project-root',project,'--specs-dir',specs,'--run-id',runId,'--detail',`QA ${phase}`,
|
|
82
|
+
'--data-json',JSON.stringify({...bound,...data})],{encoding:'utf8',env});
|
|
83
|
+
assert.equal(write('start',{}).status,0);
|
|
84
|
+
assert.equal(write('complete',{result:'FAIL',passed:0,failed:1,blocked:1,report:'r.md'}).status,0);
|
|
85
|
+
const valid={previous_test_run_id:'qa-round-1',reason:'declared_environment_failure',failed_cases:['probe'],
|
|
86
|
+
blocked_cases:['TC-001'],expected_environment:null,environment_failure_reason:'simulator runtime was missing'};
|
|
87
|
+
for(const invalid of [{failed_cases:[]},{blocked_cases:[]},{failed_cases:['probe','probe']},{environment_failure_reason:' '},
|
|
88
|
+
{environment_failure_reason:'two\nlines'},{previous_test_run_id:'other'},{reason:'host_evidence_problem'}]){
|
|
89
|
+
const result=write('superseded',{...valid,...invalid});
|
|
90
|
+
assert.notEqual(result.status,0,JSON.stringify(invalid));
|
|
91
|
+
}
|
|
92
|
+
const accepted=write('superseded',valid);assert.equal(accepted.status,0,accepted.stderr);
|
|
93
|
+
// A BLOCKED invocation (no failures) cannot carry an environment-failure declaration.
|
|
94
|
+
const blockedRun={...bound,operation_id:'qa-round-2',attempt:2};
|
|
95
|
+
assert.equal(write('start',{...blockedRun,previous_test_run_id:'qa-round-1'}).status,0);
|
|
96
|
+
assert.equal(write('complete',{...blockedRun,result:'BLOCKED',passed:1,failed:0,blocked:1,report:'r.md'}).status,0);
|
|
97
|
+
assert.notEqual(write('superseded',{...blockedRun,...valid,previous_test_run_id:'qa-round-2',failed_cases:[]}).status,0);
|
|
98
|
+
assert.equal(write('superseded',{...blockedRun,previous_test_run_id:'qa-round-2',reason:'host_evidence_problem',
|
|
99
|
+
blocked_cases:['TC-001'],expected_environment:null}).status,0);
|
|
100
|
+
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
101
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// External providers only. No role picker, model catalog or background discovery.
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {fileURLToPath} from 'node:url';
|
|
5
|
+
import readline from 'node:readline/promises';
|
|
6
|
+
import {externalModelsPath,externalSettingsRecord,externalPair,readExternalModels,saveExternalModels,describeExternalModels} from '../runtime/js/cm-ai/external-models.mjs';
|
|
7
|
+
import {readModelJsonRecord} from '../runtime/js/cm-ai/model-configuration-file.mjs';
|
|
8
|
+
import {previewLegacyExternalModels} from '../runtime/js/cm-ai/legacy-model-settings.mjs';
|
|
9
|
+
import {need} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
10
|
+
import {previewLegacyModelRun} from '../runtime/js/cm-ai/legacy-model-run-preview.mjs';
|
|
11
|
+
import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs';
|
|
12
|
+
import {readRunnerHistory} from '../runtime/js/cm-ai/durable-runner-state.mjs';
|
|
13
|
+
const usage=`cm-model-setup.mjs show
|
|
14
|
+
cm-model-setup.mjs configure --provider codex|claude [--model ID] [--effort VALUE|default] [--yes]
|
|
15
|
+
cm-model-setup.mjs legacy-preview --input OLD_SETTINGS [--task OLD_TASK] [--project OLD_PROJECT] [--global OLD_GLOBAL]
|
|
16
|
+
cm-model-setup.mjs inspect-run --input RUN_JSON
|
|
17
|
+
cm-model-setup.mjs legacy-run-preview --input OLD_SNAPSHOT
|
|
18
|
+
cm-model-setup.mjs adopt-legacy --provider codex|claude --input OLD_SETTINGS [--task OLD_TASK] [--project OLD_PROJECT] [--global OLD_GLOBAL] [--yes]
|
|
19
|
+
Only external CLI requests are configured. Host work keeps the current session model.
|
|
20
|
+
No model is selected by default; optional effort keeps Codex high / Claude unsent.
|
|
21
|
+
Old choices and runs are never rewritten. Conflicting effective old tuples require configure.`;
|
|
22
|
+
export async function main(argv,{input=process.stdin,output=process.stdout,error=process.stderr}={}){
|
|
23
|
+
let rl;
|
|
24
|
+
try{
|
|
25
|
+
if(argv.length===0||argv[0]==='--help'){output.write(usage+'\n');return 0;}
|
|
26
|
+
const [action,...rest]=argv,flags=new Map();
|
|
27
|
+
for(let i=0;i<rest.length;i++){
|
|
28
|
+
const flag=rest[i];need(!flags.has(flag),'invalid_arguments');
|
|
29
|
+
need(['--provider','--model','--effort','--yes','--input','--task','--project','--global'].includes(flag),'invalid_arguments');
|
|
30
|
+
if(flag==='--yes')flags.set(flag,true);
|
|
31
|
+
else{need(typeof rest[i+1]==='string'&&!rest[i+1].startsWith('--'),'invalid_arguments');flags.set(flag,rest[++i]);}
|
|
32
|
+
}
|
|
33
|
+
if(['inspect-run','legacy-run-preview'].includes(action)){
|
|
34
|
+
need(flags.size===1&&flags.has('--input'),'invalid_arguments');
|
|
35
|
+
const raw=readModelJsonRecord(path.resolve(flags.get('--input'))).value;
|
|
36
|
+
if(action==='legacy-run-preview'){output.write(JSON.stringify(previewLegacyModelRun(raw))+'\n');return 0;}
|
|
37
|
+
const {readRunDefinition}=await import('./cm-ai-run.mjs');
|
|
38
|
+
// Definition validation is the same as the runner, without acquiring a writer.
|
|
39
|
+
const definition=readRunDefinition(path.resolve(flags.get('--input')));
|
|
40
|
+
const snapshot=readExecutionSnapshot({specsRoot:definition.specsDir,identity:{repositoryId:definition.identity.repositoryId,runId:definition.identity.runId}});
|
|
41
|
+
const init=snapshot.records[0].payload,history=readRunnerHistory(snapshot.records,init.config,init.version);
|
|
42
|
+
output.write(JSON.stringify({readOnly:true,identity:{...init.config.identity,attempt:history.state.attempt},state:history.state.state,
|
|
43
|
+
externalModels:init.config.externalModels??null,revision:snapshot.revision,
|
|
44
|
+
attempts:snapshot.records.filter(row=>row.payload.type.startsWith('review-invocation-')).map(row=>row.payload),
|
|
45
|
+
effectiveModel:'unknown',providerConfirmed:false})+'\n');return 0;
|
|
46
|
+
}
|
|
47
|
+
const file=externalModelsPath(),record=externalSettingsRecord(file);
|
|
48
|
+
const value=record?readExternalModels(record.value):{schemaVersion:1,providers:{}};
|
|
49
|
+
if(action==='show'){need(flags.size===0,'invalid_arguments');output.write(JSON.stringify(describeExternalModels(value))+'\n');return 0;}
|
|
50
|
+
let legacy=null,guards=[];
|
|
51
|
+
if(['legacy-preview','adopt-legacy'].includes(action)){
|
|
52
|
+
need(flags.has('--input')&&!flags.has('--model')&&!flags.has('--effort'),'invalid_arguments');
|
|
53
|
+
const read=flag=>{if(!flags.has(flag))return null;const name=path.resolve(flags.get(flag)),old=readModelJsonRecord(name);guards.push({file:name,sha256:old.sha256});return old.value;};
|
|
54
|
+
legacy=previewLegacyExternalModels({settings:read('--input'),task:read('--task'),project:read('--project'),global:read('--global')});
|
|
55
|
+
if(action==='legacy-preview'){need(!flags.has('--provider')&&!flags.has('--yes'),'invalid_arguments');output.write(JSON.stringify({readOnly:true,providers:legacy})+'\n');return 0;}
|
|
56
|
+
}else need(action==='configure'&&![...flags.keys()].some(flag=>['--input','--task','--project','--global'].includes(flag)),'invalid_arguments');
|
|
57
|
+
const provider=flags.get('--provider');need(['codex','claude'].includes(provider),'invalid_external_provider');
|
|
58
|
+
const ask=async text=>{need(input.isTTY===true&&output.isTTY===true,'external_model_setup_required');rl??=readline.createInterface({input,output});return rl.question(text);};
|
|
59
|
+
let pair;
|
|
60
|
+
if(legacy){need(!legacy[provider].conflict,'legacy_external_model_conflict');
|
|
61
|
+
need(guards.length===1&&path.dirname(guards[0].file)===path.dirname(file),'legacy_adoption_requires_explicit_choice');pair=legacy[provider].pair;}
|
|
62
|
+
else{
|
|
63
|
+
const model=flags.get('--model')??(await ask(`${provider} external model ID: `)).trim();
|
|
64
|
+
let effort=flags.get('--effort');
|
|
65
|
+
if(!flags.has('--model')&&effort===undefined)effort=(await ask('Effort (Enter = adapter default): ')).trim()||'default';
|
|
66
|
+
pair=externalPair(provider,{model,...(effort===undefined||effort==='default'?{}:{effort})});
|
|
67
|
+
}
|
|
68
|
+
const next=readExternalModels({...value,providers:{...value.providers,[provider]:pair}});
|
|
69
|
+
output.write(JSON.stringify({provider,pair,affects:'new external runs only',host:'current-session',file})+'\n');
|
|
70
|
+
if(!flags.has('--yes')&&!/^(y|yes)$/i.test((await ask('Save this provider pair? [y/N] ')).trim())){output.write('cancelled; no write\n');return 0;}
|
|
71
|
+
// Bind both target and each legacy source to the bytes shown before waiting.
|
|
72
|
+
for(const guard of guards)need(readModelJsonRecord(guard.file).sha256===guard.sha256,'model_configuration_changed');
|
|
73
|
+
saveExternalModels(next,{file,expectedSha256:record?.sha256??null,
|
|
74
|
+
sourceGuard:guards.length===1?guards[0]:null});
|
|
75
|
+
output.write('saved\n');return 0;
|
|
76
|
+
}catch(cause){error.write(JSON.stringify({error:{code:cause.code??cause.message}})+'\n');return 1;}
|
|
77
|
+
finally{if(rl){rl.close();input.pause();input.unref?.();}}
|
|
78
|
+
}
|
|
79
|
+
if(process.argv[1]===fileURLToPath(import.meta.url))process.exitCode=await main(process.argv.slice(2));
|
|
@@ -155,6 +155,81 @@ test('change cannot invent completion or erase completed lines; user case change
|
|
|
155
155
|
const synthetic={...before,files:{...before.files,'1.guide/test-cases.json':JSON.stringify({cases:[{id:'TC-001',origin:'user',expected:'Original user intent'}]})}};
|
|
156
156
|
const proposal=inspectPrdChangeProposal(synthetic,raw,['1.guide'],config);assert.equal(proposal.changedUserCases.length,1);
|
|
157
157
|
});
|
|
158
|
+
// Same declaration grammar as admission/N5: a completed task without a colon is still guarded.
|
|
159
|
+
test('change guards completed tasks written without a colon or with a full-width colon',t=>{
|
|
160
|
+
const dir=fixture(t),config=loadConfig({projectRoot:dir});
|
|
161
|
+
// Approved under the shared grammar (taskGrammar 2), where both spellings are declarations.
|
|
162
|
+
fs.writeFileSync(path.join(dir,'.cm-specs-status'),JSON.stringify({status:'approved',taskGrammar:2}),{mode:0o600});
|
|
163
|
+
for(const spelling of ['- [x] T-001 Existing guide','- [x] T-001:Existing guide']){
|
|
164
|
+
fs.writeFileSync(path.join(dir,'1.guide/tasks.md'),docs()[2].content.replace('- [x] T-001: Existing guide',spelling),{mode:0o600});
|
|
165
|
+
const before=inspectPrdChangeSnapshot(dir),task=revised().find(doc=>doc.path==='tasks.md');
|
|
166
|
+
const erased={status:'draft',summary:'Change',removed:[],features:[{directory:'1.guide',
|
|
167
|
+
documents:revised().map(doc=>doc.path==='tasks.md'?{...doc,content:task.content.replace('- [x] T-001: Existing guide',spelling.replace('[x]','[ ]'))}:doc),
|
|
168
|
+
testCasesReason:'no_observable_behavior'}]};
|
|
169
|
+
assert.throws(()=>inspectPrdChangeProposal(before,erased,['1.guide'],config),/prd_completed_task_changed/,spelling);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
// The approved original is read with its approval's grammar: under a legacy
|
|
173
|
+
// approval an unfenced full-width example is prose, not the completed task.
|
|
174
|
+
test('change guard reads the approved original with the legacy grammar',t=>{
|
|
175
|
+
const dir=fixture(t),config=loadConfig({projectRoot:dir}),example='- [ ] T-001:旧写法示例';
|
|
176
|
+
fs.writeFileSync(path.join(dir,'1.guide/tasks.md'),docs()[2].content.replace('- [x] T-001: Existing guide\n',
|
|
177
|
+
`- [x] T-001: Existing guide\n${example}\n`),{mode:0o600});
|
|
178
|
+
const before=inspectPrdChangeSnapshot(dir),task=revised().find(doc=>doc.path==='tasks.md');
|
|
179
|
+
const fenced={status:'draft',summary:'Fence the old example',removed:[],features:[{directory:'1.guide',
|
|
180
|
+
documents:revised().map(doc=>doc.path==='tasks.md'?{...doc,content:task.content.replace('- [x] T-001: Existing guide\n',
|
|
181
|
+
`- [x] T-001: Existing guide\n\`\`\`md\n${example}\n\`\`\`\n`)}:doc),testCasesReason:'no_observable_behavior'}]};
|
|
182
|
+
const proposal=inspectPrdChangeProposal(before,fenced,['1.guide'],config);
|
|
183
|
+
assert.equal(proposal.proposalDigest.length,64);
|
|
184
|
+
});
|
|
185
|
+
// Fifth review: two cm-prd --change runs before re-approval keep the grammar the
|
|
186
|
+
// last approval bound, carried through the awaiting_review status of the first.
|
|
187
|
+
function sharedGrammarFixture(t){
|
|
188
|
+
const dir=fixture(t),tasks=path.join(dir,'1.guide/tasks.md');
|
|
189
|
+
fs.writeFileSync(tasks,fs.readFileSync(tasks,'utf8').replace('- [ ] T-002: Draft appendix','- [ ] T-002:Draft appendix'),{mode:0o600});
|
|
190
|
+
fs.writeFileSync(path.join(dir,'.cm-specs-status'),JSON.stringify({status:'approved',taskGrammar:2}),{mode:0o600});
|
|
191
|
+
return dir;
|
|
192
|
+
}
|
|
193
|
+
const fullWidth=docs=>docs.map(doc=>doc.path==='tasks.md'?{...doc,content:doc.content.replace('- [ ] T-002: Draft appendix','- [ ] T-002:Draft appendix')}:doc);
|
|
194
|
+
const status=dir=>JSON.parse(fs.readFileSync(path.join(dir,'.cm-specs-status'),'utf8'));
|
|
195
|
+
test('a second change of the same feature before re-approval keeps the approved grammar',t=>{
|
|
196
|
+
const dir=sharedGrammarFixture(t),config=loadConfig({projectRoot:dir}),selected=['1.guide'];
|
|
197
|
+
const first=fullWidth(revised());
|
|
198
|
+
let before=inspectPrdChangeSnapshot(dir);
|
|
199
|
+
let proposal=inspectPrdChangeProposal(before,{status:'draft',summary:'First',removed:[],features:[{directory:'1.guide',
|
|
200
|
+
documents:first,testCasesReason:'no_observable_behavior'}]},selected,config);
|
|
201
|
+
applyPrdChange({specs:dir,before,proposal,selected});
|
|
202
|
+
assert.equal(status(dir).status,'awaiting_review');assert.equal(status(dir).taskGrammar,2);
|
|
203
|
+
const second=first.map(doc=>({...doc,content:doc.content+'\n| 2026-09-08 | v3 | again |\n'
|
|
204
|
+
+(doc.path==='tasks.md'?'- [ ] T-004: [NEW] Another example\n':'Again\n')}));
|
|
205
|
+
before=inspectPrdChangeSnapshot(dir);
|
|
206
|
+
proposal=inspectPrdChangeProposal(before,{status:'draft',summary:'Second',removed:[],features:[{directory:'1.guide',
|
|
207
|
+
documents:second,testCasesReason:'no_observable_behavior'}]},selected,config);
|
|
208
|
+
applyPrdChange({specs:dir,before,proposal,selected});
|
|
209
|
+
assert.equal(status(dir).taskGrammar,2);
|
|
210
|
+
});
|
|
211
|
+
test('a second change of another feature before re-approval still carries the approved grammar',t=>{
|
|
212
|
+
const dir=sharedGrammarFixture(t),config=loadConfig({projectRoot:dir});
|
|
213
|
+
let before=inspectPrdChangeSnapshot(dir);
|
|
214
|
+
let proposal=inspectPrdChangeProposal(before,{status:'draft',summary:'First',removed:[],features:[{directory:'1.guide',
|
|
215
|
+
documents:fullWidth(revised()),testCasesReason:'no_observable_behavior'}]},['1.guide'],config);
|
|
216
|
+
applyPrdChange({specs:dir,before,proposal,selected:['1.guide']});
|
|
217
|
+
before=inspectPrdChangeSnapshot(dir);
|
|
218
|
+
proposal=inspectPrdChangeProposal(before,{status:'draft',summary:'Second',removed:[],features:[{directory:'2.extra',
|
|
219
|
+
documents:docs().map(doc=>({...doc,content:doc.content.replace('[x]','[ ]')})),testCasesReason:'no_observable_behavior'}]},[],config);
|
|
220
|
+
applyPrdChange({specs:dir,before,proposal,selected:[]});
|
|
221
|
+
assert.equal(status(dir).status,'awaiting_review');assert.equal(status(dir).taskGrammar,2);
|
|
222
|
+
});
|
|
223
|
+
test('an unapproved legacy status never switches the change guard to the shared grammar',t=>{
|
|
224
|
+
const dir=fixture(t),config=loadConfig({projectRoot:dir}),tasks=path.join(dir,'1.guide/tasks.md');
|
|
225
|
+
fs.writeFileSync(tasks,fs.readFileSync(tasks,'utf8').replace('- [ ] T-002: Draft appendix','- [ ] T-002:Draft appendix'),{mode:0o600});
|
|
226
|
+
fs.writeFileSync(path.join(dir,'.cm-specs-status'),JSON.stringify({status:'awaiting_review'}),{mode:0o600});
|
|
227
|
+
const before=inspectPrdChangeSnapshot(dir);
|
|
228
|
+
// Under the old grammar the full-width line is prose, so rewriting it as a
|
|
229
|
+
// task in the proposal is a new task and needs its [NEW] mark.
|
|
230
|
+
assert.throws(()=>inspectPrdChangeProposal(before,{status:'draft',summary:'Change',removed:[],features:[{directory:'1.guide',
|
|
231
|
+
documents:revised(),testCasesReason:'no_observable_behavior'}]},['1.guide'],config),/prd_change_new_task_invalid/);
|
|
232
|
+
});
|
|
158
233
|
test('generate_cases false retains unchanged existing generated cases, forbids new generation',t=>{
|
|
159
234
|
const dir=fixture(t),before=inspectPrdChangeSnapshot(dir),config=loadConfig({projectRoot:dir});
|
|
160
235
|
const contract={schemaVersion:'1.0',feature:'guide',cases:[{id:'TC-001',origin:'generated',kind:'logic',blocking:true,
|
|
@@ -18,6 +18,20 @@ test('draft structure refuses missing triad, unsafe path and dropped user cases'
|
|
|
18
18
|
const unsafe=draft();unsafe.features[0].documents[0].path='../AGENTS.md';assert.throws(()=>inspectPrdDraft(unsafe,options));
|
|
19
19
|
assert.throws(()=>inspectPrdDraft(draft(),{...options,userCasesProvided:true}));
|
|
20
20
|
});
|
|
21
|
+
test('draft case reason identifies the feature field without accepting non-null values',()=>{
|
|
22
|
+
const value=draft(),feature=value.features[0];
|
|
23
|
+
feature.documents.push({path:'test-cases.json',content:JSON.stringify({schemaVersion:'1.0',feature:'guide',cases:[]})});
|
|
24
|
+
assert.throws(()=>inspectPrdDraft(value,{nextIndex:1,generateCases:true,userCasesProvided:false}),error=>
|
|
25
|
+
error.code==='prd_draft_cases_invalid'&&error.reason?.field==='features[0].testCasesReason'
|
|
26
|
+
&&/must be null when test cases are present/.test(error.reason.expected));
|
|
27
|
+
});
|
|
28
|
+
test('oversize draft reports the 64 KiB limit and actual serialized bytes',()=>{
|
|
29
|
+
const value=draft();value.summary='a'.repeat(65536);
|
|
30
|
+
const actual=Buffer.byteLength(JSON.stringify(value));
|
|
31
|
+
assert.throws(()=>inspectPrdDraft(value,{nextIndex:1,generateCases:true,userCasesProvided:false}),error=>
|
|
32
|
+
error.code==='limit_exceeded'&&error.reason?.field==='draft'
|
|
33
|
+
&&error.reason.limitBytes===65536&&error.reason.actualBytes===actual);
|
|
34
|
+
});
|
|
21
35
|
test('analysis -> planner clarification -> draft preserves scope and does not write',async t=>{
|
|
22
36
|
const dir=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-prd-draft-')));
|
|
23
37
|
t.after(()=>fs.rmSync(dir,{recursive:true,force:true}));
|
package/scripts/cm-prd-drive.mjs
CHANGED
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
// prd_materials needs PDF/browser observation; this driver has no such runner and refuses it.
|
|
25
25
|
// prd_self_check evidence comes from actual PLAN.contextChecks commands, never a static evidence file.
|
|
26
26
|
import fs from 'node:fs';
|
|
27
|
+
import {readPrdRepairBinding,recoverPrdResponse} from '../runtime/js/cm-prd/response-recovery.mjs';
|
|
28
|
+
import {inspectPrdReviewResponse} from '../runtime/js/cm-prd/review-publication.mjs';
|
|
27
29
|
import path from 'node:path';
|
|
28
30
|
import {fileURLToPath} from 'node:url';
|
|
29
31
|
import {createHash} from 'node:crypto';
|
|
@@ -42,10 +44,12 @@ import {inspectPrdSummaryEvidence} from '../runtime/js/cm-prd/summary.mjs';
|
|
|
42
44
|
import {prdDesignRiskSignals} from '../runtime/js/cm-prd/design-risk.mjs';
|
|
43
45
|
import {reviewResultForPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
44
46
|
import {stderr,stop,readJson,loadPlanFile,requireFields,preflightAnswers,driveHost} from '../runtime/js/cm-ai/drive-core.mjs';
|
|
47
|
+
import {driverLiveEvidence} from '../runtime/js/cm-ai/live-evidence.mjs';
|
|
45
48
|
|
|
49
|
+
// PLAN.liveEvidence: fresh current-session evidence; see docs/live-evidence-drivers.md.
|
|
46
50
|
const HOST=fileURLToPath(new URL('./cm-prd-host.mjs',import.meta.url));
|
|
47
51
|
const SKILL=fileURLToPath(new URL('../skills/cm-prd',import.meta.url));
|
|
48
|
-
const KNOWN=new Set(['start','advance','plan_design','promote_design','select_design_reviews','status','cancel',
|
|
52
|
+
const KNOWN=new Set(['repair_review_response','start','advance','plan_design','promote_design','select_design_reviews','status','cancel',
|
|
49
53
|
'final_review_package','final_review','review_findings','review_disposition','save_draft','save_design',
|
|
50
54
|
'correct_findings','prepare_summary','publish_summary','inspect_correction','resume_correction',
|
|
51
55
|
'prepare_revision','decision','resume','read_batch','replace_inputs']);
|
|
@@ -75,14 +79,14 @@ function load(){
|
|
|
75
79
|
catch(e){fail('准入或配置无效',e.code??e.message);}
|
|
76
80
|
if(admission.status!=='ready'&&!(plan.session&&admission.mode==='change'&&admission.reason==='feature_missing'))
|
|
77
81
|
fail('准入失败',admission.reason??admission.status);
|
|
78
|
-
if(!Array.isArray(plan.permissions??[])||!(plan.permissions??[]).every(p=>['--allow-spec-write','--allow-review-write','--allow-disposition-write'].includes(p)))
|
|
82
|
+
if(!Array.isArray(plan.permissions??[])||!(plan.permissions??[]).every(p=>['--execution-optimizations','--allow-spec-write','--allow-review-write','--allow-disposition-write'].includes(p)))
|
|
79
83
|
stop(2,'permissions 只能包含宿主支持的写入开关');
|
|
80
84
|
if(new Set(plan.permissions??[]).size!==(plan.permissions??[]).length)stop(2,'permissions 不可重复');
|
|
81
85
|
if(plan.predecessor&&!fs.existsSync(resolve(plan.predecessor)))stop(2,`predecessor 文件不存在: ${resolve(plan.predecessor)}`);
|
|
82
86
|
if(plan.permissions?.includes('--allow-review-write')&&!nonempty(plan.hostContext))stop(2,'--allow-review-write 需要 hostContext');
|
|
83
87
|
if(['save_draft','save_design','publish_summary','resume_correction','correct_findings'].includes(operation)
|
|
84
88
|
&&!plan.permissions?.includes('--allow-spec-write'))stop(2,`${operation} 需要 --allow-spec-write`);
|
|
85
|
-
if(
|
|
89
|
+
if(['final_review','repair_review_response'].includes(operation)&&!plan.permissions?.includes('--allow-review-write'))stop(2,'final_review 需要 --allow-review-write');
|
|
86
90
|
if(operation==='review_disposition'&&!plan.permissions?.includes('--allow-disposition-write'))stop(2,'review_disposition 需要 --allow-disposition-write');
|
|
87
91
|
if(['correct_findings','resume_correction'].includes(operation)&&!plan.permissions?.includes('--allow-review-write'))
|
|
88
92
|
stop(2,`${operation} 需要 --allow-review-write`);
|
|
@@ -96,20 +100,32 @@ function load(){
|
|
|
96
100
|
if(identity?.entry?.project!==project||identity.entry.specs!==specs||identity.entry.skillDir!==SKILL
|
|
97
101
|
||identity.entry.change!==entry.change||identity.entry.cases!==entry.cases||identity.runtime!==runtime)
|
|
98
102
|
stop(2,'恢复身份不匹配:project/specs/skillDir/change/cases/runtime');
|
|
99
|
-
if(state.active
|
|
103
|
+
if(state.active&&!['resume','repair_review_response'].includes(operation)&&!['status','read_batch','replace_inputs','cancel'].includes(operation))
|
|
100
104
|
stop(2,`待恢复操作 ${state.active.request.operation}:先用 resume`);
|
|
101
105
|
if(operation==='resume'&&!state.active)stop(2,'恢复存档没有待定操作');
|
|
102
106
|
}
|
|
103
107
|
const request=plan.request??{};
|
|
104
108
|
exact(request,['text','stage','feature','mode','packageDigest','decisions','artifacts','summaryDigest','draftDigest',
|
|
105
|
-
'risks','reason','proposalDigest','approved','allowUserCaseChanges','resolution','successorSpecs','successorSessionId'], 'PLAN.request');
|
|
106
|
-
const needed={start:['text'],advance:['text'],plan_design:['text'],promote_design:['draftDigest','reason'],
|
|
109
|
+
'risks','reason','proposalDigest','approved','allowUserCaseChanges','resolution','successorSpecs','successorSessionId','binding'], 'PLAN.request');
|
|
110
|
+
const needed={repair_review_response:['binding'],start:['text'],advance:['text'],plan_design:['text'],promote_design:['draftDigest','reason'],
|
|
107
111
|
select_design_reviews:['draftDigest','risks'],final_review_package:['stage','feature'],final_review:['stage','feature','mode'],
|
|
108
112
|
review_findings:['stage','feature'],review_disposition:['stage','feature','packageDigest','decisions','artifacts'],
|
|
109
113
|
correct_findings:['stage','feature'],inspect_correction:['stage','feature'],resume_correction:['stage','feature'],
|
|
110
114
|
publish_summary:['summaryDigest'],prepare_revision:['reason'],decision:['proposalDigest','approved','allowUserCaseChanges'],
|
|
111
115
|
replace_inputs:['approved','reason','successorSpecs','successorSessionId']};
|
|
112
116
|
for(const key of needed[operation]??[])if(!Object.hasOwn(request,key))stop(2,`${operation} 缺少 PLAN.request.${key}`);
|
|
117
|
+
if(operation==='repair_review_response'){
|
|
118
|
+
try{
|
|
119
|
+
const binding=readPrdRepairBinding(request.binding);
|
|
120
|
+
const call=state?.active?.calls?.find(item=>item.callId===binding.callId)
|
|
121
|
+
??state?.responseRepairs?.find(item=>item.originalCall.callId===binding.callId)?.originalCall;
|
|
122
|
+
check(state?.version===2&&call?.kind==='prd_review'&&Object.hasOwn(call,'result')
|
|
123
|
+
&&call.requestDigest===binding.requestDigest&&digest(call.result)===binding.resultDigest
|
|
124
|
+
&&call.payload.package.packageDigest===binding.packageDigest,'prd_recovery_binding');
|
|
125
|
+
const {packageDigest,...reviewPackage}=call.payload.package;
|
|
126
|
+
recoverPrdResponse({original:call.result,reviewPackage,packageDigest,authorContextId:call.payload.authorContextId});
|
|
127
|
+
}catch(error){fail('原响应修复预检失败',error.code??error.message);}
|
|
128
|
+
}
|
|
113
129
|
if(['review_disposition','correct_findings'].includes(operation)){
|
|
114
130
|
let review;try{review=inspectPrdFindings({specs,stage:request.stage,feature:request.feature});}
|
|
115
131
|
catch(e){fail('原审查记录无效',e.code??e.message);}
|
|
@@ -161,7 +177,10 @@ function load(){
|
|
|
161
177
|
const pending=state.active.calls.find(c=>!Object.hasOwn(c,'result'));
|
|
162
178
|
if(pending)stop(2,`resume 尚缺原调用结果:${pending.kind} ${pending.callId} ${pending.requestDigest}`);
|
|
163
179
|
}
|
|
164
|
-
|
|
180
|
+
let live;
|
|
181
|
+
try{live=driverLiveEvidence(plan,{base,protectedRoots:[project,specs],allowedKinds:['prd_materials']});}
|
|
182
|
+
catch(error){stop(2,error.message);}
|
|
183
|
+
if(asks.includes('prd_materials')&&!live.has('prd_materials'))stop(2,'缺少真实执行 runner: prd_materials(PDF/HTML 读取或浏览器交互);不能从静态答案文件应答');
|
|
165
184
|
const answersRoot=plan.answers?resolve(plan.answers):null;
|
|
166
185
|
if(answersRoot&&fs.existsSync(path.join(answersRoot,'materials.json')))
|
|
167
186
|
stop(2,'materials.json 是执行证据;不能从静态答案文件应答 prd_materials');
|
|
@@ -195,7 +214,7 @@ function load(){
|
|
|
195
214
|
if(answersRoot&&fs.existsSync(path.join(answersRoot,'self-check.json')))
|
|
196
215
|
stop(2,'self-check.json 是执行证据;不能从静态答案文件应答 prd_self_check');
|
|
197
216
|
}
|
|
198
|
-
return {operation,plan,base,project,specs,runtime,entry,admission,config,sources,state,request,asks,answers,answersRoot};
|
|
217
|
+
return {operation,plan,base,project,specs,runtime,entry,admission,config,sources,state,request,asks,answers,answersRoot,live};
|
|
199
218
|
}
|
|
200
219
|
function validate(kind,value,ctx){
|
|
201
220
|
if(kind==='prd_analyze'){
|
|
@@ -246,7 +265,7 @@ function validate(kind,value,ctx){
|
|
|
246
265
|
const prepared=preparePrdReview({specs:ctx.specs,draft,stage:ctx.request.stage,feature:ctx.request.feature});
|
|
247
266
|
const paths=(ctx.request.stage==='design'?['requirements.md','design.md']:['requirements.md','design.md','tasks.md'])
|
|
248
267
|
.map(name=>`${ctx.request.feature}/${name}`).sort();
|
|
249
|
-
|
|
268
|
+
inspectPrdReviewResponse({reviewPackage:prepared.reviewPackage,packageDigest:prepared.packageDigest,authorContextId:ctx.hostContext,response:value});}
|
|
250
269
|
catch(e){fail('review.json 与当前原审查包不匹配',e.code??e.message);}
|
|
251
270
|
}else if(kind==='prd_correct'){
|
|
252
271
|
exact(value,['decisions','documents'],'correct.json');
|
|
@@ -286,7 +305,8 @@ export async function runPrdContextChecks(cwd,commands){
|
|
|
286
305
|
}
|
|
287
306
|
return results;
|
|
288
307
|
}
|
|
289
|
-
async function answerFor(row,answers){
|
|
308
|
+
async function answerFor(row,answers,paths,control){
|
|
309
|
+
if(loaded.live.has(row.kind))return loaded.live.answer(row,control);
|
|
290
310
|
const v=answers[row.kind];
|
|
291
311
|
if(row.kind==='prd_materials')return null;
|
|
292
312
|
if(row.kind==='prd_self_check'){
|
|
@@ -297,7 +317,8 @@ async function answerFor(row,answers){
|
|
|
297
317
|
loaded.plan.contextJudgements[f.directory][id]:'failed',evidence}))}))};
|
|
298
318
|
}
|
|
299
319
|
if(row.kind==='prd_review'){
|
|
300
|
-
|
|
320
|
+
const {packageDigest,...reviewPackage}=row.payload.package;
|
|
321
|
+
inspectPrdReviewResponse({reviewPackage,packageDigest,authorContextId:row.payload.authorContextId,response:v});
|
|
301
322
|
return v;
|
|
302
323
|
}
|
|
303
324
|
if(row.kind==='prd_summary')return {...v,evidenceDigest:row.payload.evidenceDigest};
|
|
@@ -7,6 +7,7 @@ import {spawn,spawnSync} from 'node:child_process';
|
|
|
7
7
|
import {createInterface} from 'node:readline';
|
|
8
8
|
import {fileURLToPath} from 'node:url';
|
|
9
9
|
import {runPrdContextChecks} from './cm-prd-drive.mjs';
|
|
10
|
+
import {runLiveDriver} from './fixtures/live-evidence-driver.mjs';
|
|
10
11
|
|
|
11
12
|
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
|
|
12
13
|
const driver=path.join(root,'scripts/cm-prd-drive.mjs');
|
|
@@ -30,6 +31,20 @@ function fixture(t,{pdf=false}={}){
|
|
|
30
31
|
return {dir,project,answers,plan,write,drive,store:id=>path.join(project,'.reviews/prd-sessions',id,'state.json')};
|
|
31
32
|
}
|
|
32
33
|
const analyzed={status:'analyzed',summary:'Developer need',sourcePaths:['docs/input.md'],openQuestions:[]};
|
|
34
|
+
for(const format of ['pdf','html'])test(`${format} live material request is hash-bound and an unavailable reader stops honestly`,async t=>{
|
|
35
|
+
const f=fixture(t,{pdf:format==='pdf'});
|
|
36
|
+
if(format==='html')fs.writeFileSync(path.join(f.project,'docs/input.html'),'<button>Fixture</button>');
|
|
37
|
+
f.write('analyze.json',{status:'blocked',reason:'No material reader'});
|
|
38
|
+
const plan=path.join(f.dir,'live-plan.json');fs.writeFileSync(plan,JSON.stringify({...f.plan,
|
|
39
|
+
liveEvidence:{directory:'exchange',kinds:['prd_materials'],timeoutMs:1000}}));
|
|
40
|
+
const out=await runLiveDriver(driver,plan,'start',row=>{
|
|
41
|
+
assert.equal(row.kind,'prd_materials');assert.equal(row.payload.sources[0].format,format);
|
|
42
|
+
assert.match(row.payload.sources[0].sha256,/^[a-f0-9]{64}$/);
|
|
43
|
+
return {status:'blocked',reason:'Fixture intentionally has no reader; no processing claimed'};
|
|
44
|
+
},{env:{...process.env,CM_WORKFLOW_LOG_HOME:path.join(f.dir,'mirror')}});
|
|
45
|
+
assert.equal(out.status,0,out.stderr);assert.equal(out.requests.length,1);
|
|
46
|
+
assert.equal(JSON.parse(out.stdout).result.stage,'blocked');
|
|
47
|
+
});
|
|
33
48
|
const draft={status:'draft',summary:'Synthetic documentation draft',features:[{name:'guide',testCasesReason:'no_observable_behavior',
|
|
34
49
|
documents:[{path:'requirements.md',content:'## 功能需求\n1. [F-001] Guide\n- [ ] [AC-001] Document setup.'},
|
|
35
50
|
{path:'design.md',content:'## 方案摘要\nSynthetic design'},
|