@aibyzero/cm-workflow 0.19.0 → 0.20.0
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 +8 -0
- package/CHANGELOG.md +8 -0
- package/README.md +8 -1
- package/VERSION +1 -1
- package/docs/architecture.md +3 -0
- package/docs/cm-acceptance-completion.md +185 -0
- package/docs/installation.md +1 -1
- package/package.json +1 -1
- package/runtime/js/autonomy.mjs +159 -3
- package/runtime/js/check-coverage.mjs +130 -0
- package/runtime/js/cm-ai/acceptance-contract.mjs +252 -0
- package/runtime/js/cm-ai/claude-developer-proposal.schema.json +18 -0
- package/runtime/js/cm-ai/cm-ai-admission.mjs +14 -6
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +10 -6
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +8 -3
- package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +1 -1
- package/runtime/js/cm-ai/codex-developer-output.schema.json +1 -1
- package/runtime/js/cm-ai/completion-summary.mjs +187 -0
- package/runtime/js/cm-ai/control-policy.mjs +3 -1
- package/runtime/js/cm-ai/delivery-evidence.mjs +173 -0
- package/runtime/js/cm-ai/developer-adapter.mjs +4 -0
- package/runtime/js/cm-ai/drive-core.mjs +6 -2
- package/runtime/js/cm-ai/durable-runner-state.mjs +2 -2
- package/runtime/js/cm-ai/gate-bridge.mjs +13 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +26 -14
- package/runtime/js/cm-ai/host-progress.mjs +2 -1
- package/runtime/js/cm-ai/log-rows.mjs +3 -2
- package/runtime/js/cm-ai/operator-guidance.mjs +110 -4
- package/runtime/js/cm-ai/requirement-evidence.mjs +4 -2
- package/runtime/js/cm-ai/review-package.mjs +2 -2
- package/runtime/js/cm-ai/specification-material.mjs +57 -12
- package/runtime/js/cm-ai/task-runner.mjs +38 -13
- package/runtime/js/cm-ai/verification-auto.mjs +6 -4
- package/runtime/js/cm-prd/acceptance-preview.mjs +203 -0
- package/runtime/js/cm-prd/change.mjs +17 -1
- package/runtime/js/cm-prd/summary.mjs +5 -0
- package/runtime/js/node-test-selection.mjs +38 -0
- package/runtime/js/run-analysis.mjs +153 -0
- package/runtime/js/session-boundary.mjs +17 -5
- package/runtime/js/session-handoff.mjs +5 -2
- package/scripts/cm-acceptance-preview.mjs +26 -0
- package/scripts/cm-acceptance-preview.test.mjs +156 -0
- package/scripts/cm-ai-acceptance-contract.test.mjs +185 -0
- package/scripts/cm-ai-admission.test.mjs +5 -2
- package/scripts/cm-ai-blockage.test.mjs +120 -0
- package/scripts/cm-ai-checklist-coverage.test.mjs +5 -2
- package/scripts/cm-ai-completion-summary.test.mjs +154 -0
- package/scripts/cm-ai-conversation-entry-ops.test.mjs +8 -2
- package/scripts/cm-ai-progress.test.mjs +7 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +55 -4
- package/scripts/cm-ai-run.test.mjs +23 -1
- package/scripts/cm-ai-spec-rebind.test.mjs +51 -15
- package/scripts/cm-ai-verification-auto.test.mjs +33 -8
- package/scripts/cm-ai-verification-gate.test.mjs +1 -1
- package/scripts/cm-autonomy-acceptance.test.mjs +212 -0
- package/scripts/cm-autonomy-review-r1.test.mjs +93 -0
- package/scripts/cm-autonomy.mjs +3 -1
- package/scripts/cm-autonomy.test.mjs +10 -9
- package/scripts/cm-check-runtime.sh +1 -1
- package/scripts/cm-delivery-evidence.mjs +59 -0
- package/scripts/cm-delivery-evidence.test.mjs +177 -0
- package/scripts/cm-drive-liveness.test.mjs +6 -0
- package/scripts/cm-driver-light-import.test.mjs +32 -0
- package/scripts/cm-mandatory-check-coverage.test.mjs +82 -0
- package/scripts/cm-node-test-selection.test.mjs +108 -0
- package/scripts/cm-notify-read-drift.test.mjs +6 -3
- package/scripts/cm-prd-completion.test.mjs +12 -0
- package/scripts/cm-prd-host.mjs +3 -1
- package/scripts/cm-prd-host.test.mjs +18 -1
- package/scripts/cm-prd-summary.test.mjs +19 -4
- package/scripts/cm-review-inventory.test.mjs +21 -6
- package/scripts/cm-run-analysis.mjs +21 -0
- package/scripts/cm-run-analysis.test.mjs +120 -0
- package/scripts/cm-start-check.mjs +60 -53
- package/scripts/cm-start-check.test.mjs +76 -1
- package/scripts/cm-usage-report.py +8 -3
- package/scripts/cm019-r1-contract.test.mjs +137 -0
- package/scripts/cm019-review-gates.test.mjs +97 -0
- package/skills/cm-ai/references/js-host.md +5 -1
- package/skills/cm-prd/references/js-change-recovery.md +1 -1
- package/skills/cm-prd/references/js-host.md +1 -0
|
@@ -0,0 +1,120 @@
|
|
|
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 {operatorGuidance,guidanceText,projectOperatorGuidance} from '../runtime/js/cm-ai/operator-guidance.mjs';
|
|
7
|
+
import {createCmAiConversationEntry} from '../runtime/js/cm-ai/cm-ai-conversation-entry.mjs';
|
|
8
|
+
import {batchMemberResult} from './cm-ai-batch-run.mjs';
|
|
9
|
+
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
10
|
+
|
|
11
|
+
const identity={repositoryId:'fixture',runId:'blockage-fixture',taskId:'T-001',attempt:1};
|
|
12
|
+
const packageDigest='a'.repeat(64);
|
|
13
|
+
const input=(code='verification_precheck_failed',extra={})=>({workflow:'cm-ai',identity,packageDigest,
|
|
14
|
+
state:'blocked',code,pendingAction:'resume',outcome:'reported',...extra});
|
|
15
|
+
const guided=(value,options)=>({...value,guidance:operatorGuidance(value,options)});
|
|
16
|
+
|
|
17
|
+
test('verification detail reports the actual current reason but cannot add a recovery operation',()=>{
|
|
18
|
+
const reason='verification_precheck_failed: task:T-001:abc:1: missing acceptance obligation, mandatory tests missing: tests/b.test.mjs';
|
|
19
|
+
const value=input(undefined,{reason}),before=JSON.stringify(value),result=guided(value),b=result.guidance.blockage;
|
|
20
|
+
assert.equal(b.phase.code,'verification');assert.equal(b.detail.status,'recorded');assert.equal(b.detail.text,reason);
|
|
21
|
+
assert.equal(b.recovery.operation,'advance');assert.equal(b.recovery.authorizationGranted,false);
|
|
22
|
+
assert.equal(b.validEvidence.status,'unknown');assert.equal(b.inspection.dispatchedCalls,0);
|
|
23
|
+
assert.match(guidanceText(result),/tests\/b.test.mjs/);assert.match(guidanceText(result),/当前可复用证据:UNKNOWN/);
|
|
24
|
+
assert.equal(JSON.stringify(value),before);
|
|
25
|
+
const noPath=guided({...value,pendingAction:'none'});
|
|
26
|
+
assert.equal(noPath.guidance.recoveryOperation,null);assert.equal(noPath.guidance.blockage.recovery.operation,null);
|
|
27
|
+
assert.equal(noPath.guidance.blockage.recovery.decision,'not_available');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('old, arbitrary and control-character reasons remain unknown instead of invented detail',()=>{
|
|
31
|
+
for(const reason of [undefined,'private raw provider message','verification_precheck_failed:',
|
|
32
|
+
'verification_precheck_failed: private\u001b[31m message','verification_precheck_failed: false\u202e message',
|
|
33
|
+
'verification_precheck_failed: '+ 'x'.repeat(8192)]){
|
|
34
|
+
const result=guided(input(undefined,{reason}));
|
|
35
|
+
assert.equal(result.guidance.blockage.detail.status,'unknown');
|
|
36
|
+
assert.doesNotMatch(guidanceText(result),/private|\u001b|\u202e/);
|
|
37
|
+
}
|
|
38
|
+
const result=guided(input(undefined,{reason:'verification_precheck_failed: '+ '义务'.repeat(2000)}));
|
|
39
|
+
assert.equal(result.guidance.blockage.detail.truncated,true);
|
|
40
|
+
assert(Buffer.byteLength(result.guidance.blockage.detail.text)<2000);
|
|
41
|
+
assert.match(guidanceText(result),/完整原因见 result.reason/);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('check, spec drift and review-no-verdict phases use their existing recovery paths and costs',()=>{
|
|
45
|
+
const checks=guided(input('develop_checks_not_passed',{reason:'develop_checks_not_passed: unit-b: failed; assertion'}));
|
|
46
|
+
assert.equal(checks.guidance.blockage.phase.code,'checks');assert.equal(checks.guidance.blockage.detail.status,'recorded');
|
|
47
|
+
assert.equal(checks.guidance.blockage.recovery.checks,'may_run');
|
|
48
|
+
const complete=guided(input('completion_checks_changed',{pendingAction:'complete',reason:'completion_checks_changed: test-b: failed'}));
|
|
49
|
+
assert.equal(complete.guidance.blockage.phase.code,'completion');assert.equal(complete.guidance.blockage.recovery.reviewCalls,'not_dispatched');
|
|
50
|
+
const review=guided(input('review_transport_timeout',{state:'pending_review'}));
|
|
51
|
+
assert.equal(review.guidance.blockage.phase.code,'review');assert.equal(review.guidance.blockage.detail.status,'unknown');
|
|
52
|
+
assert.equal(review.guidance.blockage.recovery.checks,'may_run','advance may continue through completion/QA or next-attempt development');
|
|
53
|
+
assert.equal(review.guidance.blockage.recovery.reviewCalls,'may_dispatch');
|
|
54
|
+
const abandon=guided(input('review_transport_timeout',{state:'unknown',pendingAction:'abandon_review'}));
|
|
55
|
+
assert.equal(abandon.guidance.blockage.recovery.decision,'required');assert.equal(abandon.guidance.blockage.recovery.reviewCalls,'not_dispatched');
|
|
56
|
+
const busy=guided(input('review_transport_timeout',{state:'unknown',pendingAction:'abandon_review'}),{executionActive:true});
|
|
57
|
+
assert.equal(busy.guidance.blockage.recovery.operation,null);assert.equal(busy.guidance.blockage.recovery.decision,'wait');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('only the matching validated completion snapshot supplies currently reusable evidence',()=>{
|
|
61
|
+
const completion={snapshotDigest:'b'.repeat(64),binding:{identity,packageDigest,runnerRevision:'revision'},
|
|
62
|
+
task:{status:'completed',review:{status:'passed',evidence:['receipt:'+'c'.repeat(64)]}},
|
|
63
|
+
feature:{status:'passed',qa:{status:'passed'}}};
|
|
64
|
+
const value=input('documentation_sync_blocked',{state:'fixture_completed',pendingAction:'none',completion});
|
|
65
|
+
assert.equal(guided(value).guidance.blockage.validEvidence.status,'confirmed');
|
|
66
|
+
assert.equal(guided(value).guidance.blockage.validEvidence.items.length,2);
|
|
67
|
+
for(const changed of [{...completion,snapshotDigest:null},{...completion,binding:{...completion.binding,identity:{...identity,attempt:2}}},
|
|
68
|
+
{...completion,binding:{...completion.binding,packageDigest:'d'.repeat(64)}},
|
|
69
|
+
{...completion,task:{...completion.task,status:'unknown'}},{...completion,task:{...completion.task,status:'blocked'}}])
|
|
70
|
+
assert.equal(guided({...value,completion:changed}).guidance.blockage.validEvidence.status,'unknown');
|
|
71
|
+
assert.equal(guided({...value,code:'spec_drift'}).guidance.blockage.validEvidence.status,'unknown');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('protocol and batch reprojections preserve explanations without leaking a single-run launch instruction',()=>{
|
|
75
|
+
const value=input('spec_drift',{pendingAction:'spec_rebind',
|
|
76
|
+
reason:'规格已重新批准,变更文件:1.sample/tasks.md;用 --supersede-reviewed-evidence 新建运行'});
|
|
77
|
+
const single=projectOperatorGuidance(guided(value),{protocol:'v2'});
|
|
78
|
+
assert.equal(single.guidance.blockage.phase.code,'specification');
|
|
79
|
+
assert.match(single.guidance.blockage.detail.text,/1.sample\/tasks.md/);
|
|
80
|
+
assert.doesNotMatch(guidanceText(single),/--supersede-reviewed-evidence/);
|
|
81
|
+
const batch=batchMemberResult(single,{protocol:'v2',taskKey:'1.sample/T-001'});
|
|
82
|
+
assert.equal(batch.pendingAction,'none');assert.equal(batch.guidance.blockage.recovery.operation,null);
|
|
83
|
+
assert.equal(batch.guidance.blockage.recovery.decision,'not_available');
|
|
84
|
+
assert.doesNotMatch(guidanceText(batch),/--expected-control|--rebind-spec-material|--supersede-reviewed-evidence/);
|
|
85
|
+
const retry=batchMemberResult(guided(input('develop_checks_not_passed')),{protocol:'v2'});
|
|
86
|
+
assert.equal(retry.guidance.blockage.recovery.operation,'advance');
|
|
87
|
+
assert.match(guidanceText(retry),/原批次入口/);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('malformed explanation decoration cannot break the existing human guidance renderer',()=>{
|
|
91
|
+
const result=guided(input());
|
|
92
|
+
for(const validEvidence of [null,{message:'safe',status:'confirmed',items:null},{message:'safe',items:[null]}]){
|
|
93
|
+
const output=guidanceText({...result,guidance:{...result.guidance,blockage:{...result.guidance.blockage,validEvidence}}});
|
|
94
|
+
assert.match(output,/交付未满足/);
|
|
95
|
+
}
|
|
96
|
+
const injected=guidanceText({...result,guidance:{...result.guidance,blockage:{...result.guidance.blockage,
|
|
97
|
+
detail:{text:'fake\u001b[31m message'}}}});
|
|
98
|
+
assert.doesNotMatch(injected,/fake|\u001b/);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('real status entry reads runner once and preserves files and dispatch counters',async t=>{
|
|
102
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-blockage-')));t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
103
|
+
const specsDir=path.join(root,'specs'),codeProject=path.join(root,'code'),feature='1.sample';
|
|
104
|
+
fs.mkdirSync(path.join(specsDir,feature),{recursive:true});fs.mkdirSync(codeProject);
|
|
105
|
+
for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(specsDir,feature,name),'# Fixture\n');
|
|
106
|
+
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),'- [ ] T-001: fixture\n');
|
|
107
|
+
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],specFiles:buildManifest(specsDir)}));
|
|
108
|
+
fs.writeFileSync(path.join(specsDir,'.cm-status.json'),'original display');
|
|
109
|
+
const files=['.cm-status.json','.cm-specs-status',feature+'/requirements.md',feature+'/design.md',feature+'/tasks.md'];
|
|
110
|
+
const before=files.map(file=>[file,fs.readFileSync(path.join(specsDir,file)),fs.statSync(path.join(specsDir,file)).mtimeMs]);
|
|
111
|
+
let reads=0;const unexpected=()=>{throw Error('must not dispatch or mutate');};
|
|
112
|
+
const status={...input(undefined,{reason:'verification_precheck_failed: task:T-001:missing',calls:[]}),state:'blocked'};
|
|
113
|
+
const entry=createCmAiConversationEntry({specsDir,codeProject,feature,identity,
|
|
114
|
+
runner:{status:()=>{reads++;return status;},executeEffect:unexpected,cancel:unexpected,run:unexpected}});
|
|
115
|
+
const output=await entry.handle({version:1,operation:'status',requestId:'status',identity});
|
|
116
|
+
assert.equal(reads,1);assert.equal(output.guidance.blockage.detail.status,'recorded');
|
|
117
|
+
assert.equal(output.guidance.blockage.validEvidence.status,'unknown');assert.equal(output.guidance.blockage.inspection.dispatchedCalls,0);
|
|
118
|
+
for(const [file,bytes,mtime] of before){assert.deepEqual(fs.readFileSync(path.join(specsDir,file)),bytes);assert.equal(fs.statSync(path.join(specsDir,file)).mtimeMs,mtime);}
|
|
119
|
+
assert.equal(fs.existsSync(path.join(specsDir,'运行日志.jsonl')),false);assert.equal(fs.existsSync(path.join(specsDir,'.reviews')),false);
|
|
120
|
+
});
|
|
@@ -101,18 +101,21 @@ test('scope files are read, and unreadable entries contribute nothing rather tha
|
|
|
101
101
|
test('the gate emits the reminder without letting it change the verdict', async () => {
|
|
102
102
|
const source = fs.readFileSync(new URL('../runtime/js/cm-ai/host-conversation-execution.mjs',
|
|
103
103
|
import.meta.url), 'utf8');
|
|
104
|
-
const gate = /const verificationGate=
|
|
104
|
+
const gate = /const verificationGate=async\(request,control\)=>\{([\s\S]*?)\n \};\n const outerTimeoutMs=/.exec(source);
|
|
105
105
|
assert.notEqual(gate, null, 'verificationGate not found');
|
|
106
|
+
assert.match(gate[1], /if\(!gateMode&&!contract\)return \{satisfied:true\};/);
|
|
106
107
|
assert.match(gate[1], /checklistGaps\(/);
|
|
107
108
|
assert.match(gate[1], /diagnostic:'checklist_coverage'/);
|
|
108
109
|
assert.match(gate[1], /advisory:true/);
|
|
109
110
|
// The returned verdict must still be the gate's own, unqualified by coverage.
|
|
110
111
|
// Satisfied answers carry their items to the handoff; a failed gate carries nothing.
|
|
111
112
|
// The host replay record is appended as one more item, never folded into the verdict.
|
|
112
|
-
assert.match(gate[1], /return verdict\.satisfied\?\{satisfied:true,items:verdict\.items,\.\.\.\(facts\?\{hostRecord:facts\}:\{\}\)\}:\{satisfied:false\};/);
|
|
113
|
+
assert.match(gate[1], /return verdict\.satisfied\?\{satisfied:true,items:verdict\.items,\.\.\.\(facts\?\{hostRecord:facts\}:\{\}\),\.\.\.\(coverage\?\{coverage\}:\{\}\)\}\s*:\{satisfied:false,reason:boundedReason\('verification_precheck_failed: ',verdict\.unsatisfied\?\?\['门禁未记录具体缺项'\]\)\};/);
|
|
113
114
|
assert.equal(/satisfied:verdict\.satisfied&&/.test(gate[1]), false,
|
|
114
115
|
'coverage was folded into the verdict; it must stay advisory');
|
|
115
116
|
// Any throw inside the reminder must not reach the caller.
|
|
116
117
|
const reminder = /\/\/ Advisory only\.[\s\S]*?\}catch\{[^}]*\}/.exec(gate[1]);
|
|
117
118
|
assert.notEqual(reminder, null, 'the reminder is not wrapped in its own try/catch');
|
|
119
|
+
assert.equal(/\b(?:return|throw)\b|verdict\.satisfied\s*=(?!=)/.test(reminder[0]), false,
|
|
120
|
+
'the advisory reminder must not override or throw away the gate verdict');
|
|
118
121
|
});
|
|
@@ -0,0 +1,154 @@
|
|
|
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 {buildManifest} from './cm-spec-manifest.mjs';
|
|
7
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
8
|
+
import {completionSummary,completionLines,taskCompletion} from '../runtime/js/cm-ai/completion-summary.mjs';
|
|
9
|
+
import {cmAiSessionBoundary} from '../runtime/js/session-boundary.mjs';
|
|
10
|
+
import {handoffText} from '../runtime/js/session-handoff.mjs';
|
|
11
|
+
|
|
12
|
+
const identity={repositoryId:'completion-fixture',runId:'current',taskId:'T-001',attempt:1},packageDigest='a'.repeat(64);
|
|
13
|
+
function project(t){
|
|
14
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-completion-')));
|
|
15
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
16
|
+
for(const [feature,tasks] of [['1.first','- [x] T-001: done\n- [ ] T-002: open\n'],['2.next','- [ ] T-003: open\n']]){
|
|
17
|
+
fs.mkdirSync(path.join(root,feature));
|
|
18
|
+
for(const [name,body] of [['tasks.md',tasks],['requirements.md','# R\n'],['design.md','# D\n']])
|
|
19
|
+
fs.writeFileSync(path.join(root,feature,name),body);
|
|
20
|
+
}
|
|
21
|
+
const approve=()=>fs.writeFileSync(path.join(root,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.first','2.next'],
|
|
22
|
+
taskGrammar:2,specFiles:buildManifest(root)}));
|
|
23
|
+
approve();
|
|
24
|
+
const receipt={kind:'cm-review-receipt',identity,packageDigest,result:{verdict:'approved'}};
|
|
25
|
+
const source={identity,packageDigest,state:'fixture_completed',code:null,receipt:{...receipt,receiptDigest:digest(receipt)}};
|
|
26
|
+
const result={workflow:'cm-ai',...source,completion:{task:taskCompletion(source)}};
|
|
27
|
+
const log=path.join(root,'运行日志.jsonl');
|
|
28
|
+
const qa=(status,more={})=>({schema_version:1,workflow:'cm-ai',event:'qa',node:'N6',event_id:'qa-event',feature:'1.first',
|
|
29
|
+
repository_id:identity.repositoryId,run_id:identity.runId,task:identity.taskId,attempt:1,package_digest:packageDigest,
|
|
30
|
+
decision_id:'qa-current',status,reason:'feature_complete',score:null,at:'2026-11-01T00:00:00Z',...more});
|
|
31
|
+
const writeRows=rows=>fs.writeFileSync(log,rows.map(row=>JSON.stringify(row)+'\n').join(''));
|
|
32
|
+
const summary=()=>completionSummary({specsDir:root,feature:'1.first',result});
|
|
33
|
+
return {root,approve,source,result,log,qa,writeRows,summary};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
test('a reported task completion without durable owner evidence cannot complete its feature or project',t=>{
|
|
37
|
+
const p=project(t);fs.writeFileSync(path.join(p.root,'.cm-status.json'),JSON.stringify({state:'run_done'}));
|
|
38
|
+
const value=p.summary();
|
|
39
|
+
assert.equal(taskCompletion(p.source).status,'completed');
|
|
40
|
+
assert.equal(value.task.status,'unknown');assert.equal(value.task.historicalCompleted,true);assert.equal(value.task.review.status,'passed');
|
|
41
|
+
assert.deepEqual(value.project.scope,['1.first','2.next']);assert.equal(value.project.pendingTasks,2);
|
|
42
|
+
assert.equal(value.feature.tasks.completed,1);assert.equal(value.feature.tasks.total,2);
|
|
43
|
+
assert.equal(value.feature.status,'unknown');assert.equal(value.feature.qa.status,'unknown');
|
|
44
|
+
assert.equal(value.project.status,'unknown');assert.equal(value.run.status,'unknown');
|
|
45
|
+
assert.equal(value.productAcceptance.status,'unknown');assert.equal(value.deployment.status,'unknown');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
for(const [decision,expected] of [['skipped','skipped'],['blocked','blocked'],['triggered','unknown']]){
|
|
49
|
+
test(`terminal task list keeps QA ${decision} distinct from PASS`,t=>{
|
|
50
|
+
const p=project(t);fs.writeFileSync(path.join(p.root,'1.first','tasks.md'),'- [x] T-001: done\n');p.approve();
|
|
51
|
+
p.writeRows([p.qa(decision)]);const value=p.summary();
|
|
52
|
+
assert.equal(value.feature.qa.status,expected);assert.notEqual(value.feature.status,'passed');
|
|
53
|
+
assert.notEqual(value.project.status,'completed');
|
|
54
|
+
if(decision==='skipped')assert.equal(value.feature.qa.reason,'terminal_feature_qa_required');
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
test('a row claiming old QA PASS is not accepted without the strict owner evidence, and a different current candidate is blocked',t=>{
|
|
59
|
+
const p=project(t);p.writeRows([p.qa('triggered'),{...p.qa('triggered'),event:'test_run',phase:'start',operation_id:'qa-1'},
|
|
60
|
+
{...p.qa('triggered'),event:'test_run',phase:'complete',operation_id:'qa-1',result:'PASS'}]);
|
|
61
|
+
assert.notEqual(p.summary().feature.qa.status,'passed');
|
|
62
|
+
p.writeRows([p.qa('triggered',{package_digest:'b'.repeat(64)})]);
|
|
63
|
+
const value=p.summary();assert.equal(value.feature.qa.status,'blocked');assert.equal(value.feature.qa.reason,'qa_candidate_changed');
|
|
64
|
+
p.writeRows([p.qa('triggered',{run_id:'older-run'})]);
|
|
65
|
+
const older=p.summary();assert.equal(older.feature.qa.status,'blocked');assert.equal(older.feature.qa.reason,'qa_candidate_changed');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('historical task completion survives correction while current eligibility remains blocked',t=>{
|
|
69
|
+
const p=project(t);const source={...p.source,code:'correction_review_required'};
|
|
70
|
+
const value=completionSummary({specsDir:p.root,feature:'1.first',result:{...p.result,code:source.code,completion:{task:taskCompletion(source)}}});
|
|
71
|
+
assert.equal(value.task.historicalCompleted,true);assert.equal(value.task.status,'blocked');
|
|
72
|
+
assert.equal(value.task.review.status,'passed');assert.equal(value.project.status,'blocked');
|
|
73
|
+
assert.equal(value.feature.status,'blocked');assert.equal(value.run.status,'blocked');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('a wider QA or closeout block does not undo the task completion gate',t=>{
|
|
77
|
+
const p=project(t),source={...p.source,code:'project_qa_not_passed'};
|
|
78
|
+
const value=completionSummary({specsDir:p.root,feature:'1.first',result:{...p.result,code:source.code,completion:{task:taskCompletion(source)}}});
|
|
79
|
+
assert.equal(taskCompletion(source).status,'completed');assert.equal(value.task.historicalCompleted,true);
|
|
80
|
+
assert.equal(value.task.status,'unknown','this fixture has no durable completion owner');assert.equal(value.run.status,'blocked');
|
|
81
|
+
assert.equal(value.project.status,'unknown');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('old durable baselines are explicitly reported as unprotected and are never rewritten',t=>{
|
|
85
|
+
const p=project(t),directory=path.join(p.root,'.reviews','.execution',identity.runId);
|
|
86
|
+
fs.mkdirSync(directory,{recursive:true,mode:0o700});
|
|
87
|
+
const body={version:1,seq:1,id:'runner.000001',kind:'result',payload:{type:'init',baseline:{}},previousDigest:null};
|
|
88
|
+
const state={version:1,identity:{repositoryId:identity.repositoryId,runId:identity.runId},
|
|
89
|
+
fingerprints:{workflow:'1'.repeat(64),config:'2'.repeat(64),inputs:'3'.repeat(64)},records:[{...body,digest:digest(body)}]};
|
|
90
|
+
const file=path.join(directory,'state.json'),bytes=JSON.stringify({...state,revision:digest(state)})+'\n';
|
|
91
|
+
fs.writeFileSync(file,bytes,{mode:0o600});const before=fs.statSync(file).mtimeMs;
|
|
92
|
+
const value=p.summary();assert.equal(value.task.acceptanceProtection,'legacy_unprotected');
|
|
93
|
+
assert(completionLines(value)[0].includes('未受新合同保护'));
|
|
94
|
+
assert.equal(fs.readFileSync(file,'utf8'),bytes);assert.equal(fs.statSync(file).mtimeMs,before);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('run_done proves only its recorded scope, without completing pending project tasks or proving external acceptance',t=>{
|
|
98
|
+
const p=project(t);p.writeRows([{schema_version:1,workflow:'cm-ai',event:'run_done',node:'N8',event_id:'done-current',
|
|
99
|
+
repository_id:identity.repositoryId,run_id:identity.runId,task:identity.taskId,feature:'1.first',package_digest:packageDigest,
|
|
100
|
+
context_digest:'c'.repeat(64),documentation_sync_id:'docs-current',scope_features:['1.first']}]);
|
|
101
|
+
const value=p.summary();assert.equal(value.run.historicalFinalized,true);assert.equal(value.run.status,'unknown');
|
|
102
|
+
assert.deepEqual(value.run.scope,['1.first']);
|
|
103
|
+
assert.equal(value.project.status,'unknown');assert.equal(value.project.historicalFinalized,false);
|
|
104
|
+
assert.equal(value.productAcceptance.status,'unknown');assert.equal(value.deployment.status,'unknown');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('legacy run_done without repository binding remains historical evidence with UNKNOWN current eligibility',t=>{
|
|
108
|
+
const p=project(t);p.writeRows([{schema_version:1,workflow:'cm-ai',event:'run_done',node:'N8',event_id:'legacy-done',
|
|
109
|
+
run_id:identity.runId,task:identity.taskId,feature:'1.first',package_digest:packageDigest,
|
|
110
|
+
context_digest:'c'.repeat(64),documentation_sync_id:'legacy-docs'}]);
|
|
111
|
+
const value=p.summary();assert.equal(value.run.status,'unknown');assert.equal(value.run.historicalFinalized,true);
|
|
112
|
+
assert.equal(value.run.reason,'legacy_closeout_binding_unknown');assert(value.run.evidence.includes('运行日志.jsonl#legacy-done'));
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test('missing approval or source drift stays UNKNOWN instead of synthesizing completion',t=>{
|
|
116
|
+
const p=project(t);fs.writeFileSync(path.join(p.root,'2.next','tasks.md'),'- [x] T-003: silently weakened\n');
|
|
117
|
+
const value=p.summary();assert.equal(value.project.status,'unknown');assert.equal(value.feature.status,'unknown');
|
|
118
|
+
fs.writeFileSync(path.join(p.root,'.cm-specs-status'),'{}');assert.equal(p.summary().project.status,'unknown');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('a change during QA inspection invalidates the composed snapshot',t=>{
|
|
122
|
+
const p=project(t);p.writeRows([p.qa('skipped')]);
|
|
123
|
+
const original=fs.existsSync;let changed=false;
|
|
124
|
+
fs.existsSync=function(file){
|
|
125
|
+
if(file===p.log&&!changed){changed=true;fs.appendFileSync(path.join(p.root,'1.first','tasks.md'),'- [ ] T-004: new\n');}
|
|
126
|
+
return original.apply(this,arguments);
|
|
127
|
+
};
|
|
128
|
+
let value;try{value=p.summary();}finally{fs.existsSync=original;}
|
|
129
|
+
assert(changed);assert.equal(value.project.status,'unknown');assert.equal(value.feature.status,'unknown');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('summary reads write no files; the same structured result supplies boundary and handoff text',t=>{
|
|
133
|
+
const p=project(t),snapshot=()=>{
|
|
134
|
+
const files=[...fs.readdirSync(p.root,{recursive:true})].filter(name=>fs.statSync(path.join(p.root,name)).isFile()).sort();
|
|
135
|
+
return files.map(name=>{const file=path.join(p.root,name);return [name,fs.readFileSync(file,'utf8'),fs.statSync(file).mtimeMs];});
|
|
136
|
+
};
|
|
137
|
+
const before=snapshot(),completion=p.summary();assert.deepEqual(snapshot(),before);
|
|
138
|
+
const boundary=cmAiSessionBoundary({workflow:'cm-ai',state:'run_done',completion},{specsDir:p.root,feature:'1.first'});
|
|
139
|
+
const handoff=handoffText({workflow:'cm-ai',at:'2026-11-01T00:00:00Z',runId:'current',done:[],todo:[],next:'next',completion});
|
|
140
|
+
for(const line of completionLines(completion)){assert(boundary.includes(line));assert(handoff.includes(line));}
|
|
141
|
+
assert.deepEqual(snapshot(),before,'formatting without an explicit handoff writer stays read-only');
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('R1 G7 admission without a current identity leaves prior QA unknown rather than candidate-blocked',t=>{
|
|
145
|
+
const p=project(t);p.writeRows([p.qa('triggered')]);
|
|
146
|
+
const value=completionSummary({specsDir:p.root,feature:'1.first',result:{state:'blocked',code:'specs_unapproved'}});
|
|
147
|
+
assert.equal(value.feature.qa.status,'unknown');assert.equal(value.feature.qa.reason,'current_candidate_unavailable');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test('R1 G10 completion refuses oversized logs before scanning them',t=>{
|
|
151
|
+
const p=project(t),row=JSON.stringify({workflow:'other',padding:'x'.repeat(2048)})+'\n';
|
|
152
|
+
fs.writeFileSync(p.log,row.repeat(Math.ceil(33*1024*1024/Buffer.byteLength(row))));
|
|
153
|
+
const value=p.summary();assert.equal(value.project.status,'unknown');assert.equal(value.project.reason,'completion_log_invalid');
|
|
154
|
+
});
|
|
@@ -115,7 +115,9 @@ test('context_refresh requires a completed task and returns its bound context su
|
|
|
115
115
|
assert.equal((await f.entry().handle(request)).code,'context_not_ready');
|
|
116
116
|
f.complete();f.seedQa();
|
|
117
117
|
const result=await f.entry().handle(request);
|
|
118
|
-
|
|
118
|
+
const {completion,...operationResult}=result;
|
|
119
|
+
assert.equal(completion.project.status,'unknown');assert.equal(completion.task.review.status,'unknown');
|
|
120
|
+
assert.deepEqual(operationResult,{version:1,workflow:'cm-ai',operation:'context_refresh',requestDigest:digest(request),
|
|
119
121
|
identity,outcome:'refreshed',state:'fixture_completed',code:'context_complete',packageDigest,
|
|
120
122
|
pendingAction:'finish',nextTask:null,contextDigest:result.contextDigest,contextFiles:result.contextFiles});
|
|
121
123
|
assert.match(result.contextDigest,/^[a-f0-9]{64}$/);
|
|
@@ -150,7 +152,11 @@ test('run_finalize requires documentation sync and returns the final outcome wit
|
|
|
150
152
|
const documentationResult={syncId:'docs-completed',identity,packageDigest,contextDigest:refresh.contextDigest,
|
|
151
153
|
status:'completed',reason:'documentation synced',at:'2026-09-04T15:20:00-07:00'};
|
|
152
154
|
const result=await f.entry({documentationResult,qaLogHome:path.join(f.root,'logs')}).handle(request);
|
|
153
|
-
|
|
155
|
+
const {completion,...operationResult}=result;
|
|
156
|
+
assert.equal(completion.task.status,'unknown','a synthetic runner without a registered receipt does not prove task acceptance');
|
|
157
|
+
assert.equal(completion.project.status,'unknown','a legacy approval without a manifest does not prove project completion');
|
|
158
|
+
assert.equal(completion.productAcceptance.status,'unknown');assert.equal(completion.deployment.status,'unknown');
|
|
159
|
+
assert.deepEqual(operationResult,{version:1,workflow:'cm-ai',operation:'run_finalize',requestDigest:digest(request),
|
|
154
160
|
identity,outcome:'finalized',state:'run_done',code:'run_done',packageDigest,pendingAction:'none',
|
|
155
161
|
contextDigest:refresh.contextDigest,deduplicated:false,degraded:false});
|
|
156
162
|
assert.equal(f.effects(),0);
|
|
@@ -11,6 +11,7 @@ import {installSyntheticReview,syntheticReviewConfig} from './cm-ai-host-fixture
|
|
|
11
11
|
import {createConversationExecution} from './cm-ai-host.mjs';
|
|
12
12
|
import {createCmAiConversationEntry} from '../runtime/js/cm-ai/cm-ai-conversation-entry.mjs';
|
|
13
13
|
import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs';
|
|
14
|
+
import {captureSpecificationMaterial} from '../runtime/js/cm-ai/specification-material.mjs';
|
|
14
15
|
|
|
15
16
|
const driver=fileURLToPath(new URL('./cm-ai-drive.mjs',import.meta.url));
|
|
16
17
|
const home=fs.mkdtempSync(path.join(os.tmpdir(),'cm-progress-home-'));
|
|
@@ -35,6 +36,9 @@ function fixture(t){
|
|
|
35
36
|
const answers=path.join(root,'answers');fs.mkdirSync(answers);
|
|
36
37
|
fs.writeFileSync(path.join(answers,'target.txt'),'export const value=42;\n');
|
|
37
38
|
fs.writeFileSync(path.join(answers,'develop.json'),JSON.stringify({status:'succeeded',value:{outcome:'implemented',
|
|
39
|
+
...(captureSpecificationMaterial({specsRoot:specsDir,feature,taskId:identity.taskId}).acceptanceContract?{requirements:
|
|
40
|
+
captureSpecificationMaterial({specsRoot:specsDir,feature,taskId:identity.taskId}).acceptanceContract.obligations
|
|
41
|
+
.map(item=>({...item,satisfied:true,evidence:'Synthetic progress fixture implementation and check evidence'}))}:{}),
|
|
38
42
|
application:{status:'no_relevant_lesson',note:null},retrospective:{status:'no_new_lesson',candidates:[],reason:null}},edits:{'target.mjs':'target.txt'}}));
|
|
39
43
|
fs.writeFileSync(path.join(root,'review.json'),JSON.stringify(syntheticReviewConfig(codeProject)));
|
|
40
44
|
const plan=(checks,extra={})=>{
|
|
@@ -76,6 +80,8 @@ test('failed checks project blocked and do not start later commands or independe
|
|
|
76
80
|
assert.equal(run.status,0,run.stderr);const result=JSON.parse(run.stdout).result;
|
|
77
81
|
assert.equal(result.code,'develop_checks_not_passed');assert.equal(result.pendingAction,'resume');
|
|
78
82
|
assert.equal(result.guidance.recoveryOperation,'advance');assert.equal(result.guidance.authorizationGranted,false);
|
|
83
|
+
assert.equal(result.guidance.blockage.phase.code,'checks');assert.equal(result.guidance.blockage.detail.status,'recorded');
|
|
84
|
+
assert.match(result.guidance.blockage.detail.text,/broken: failed/);assert.match(run.stderr,/缺项\/原因:develop_checks_not_passed: broken: failed/);
|
|
79
85
|
assert.match(f.status().detail,/开发检查未通过/);assert.match(run.stderr,/恢复原运行并发送 advance/);
|
|
80
86
|
assert.equal(f.status().state,'blocked');assert.equal(f.status().code,'develop_checks_not_passed');
|
|
81
87
|
assert.equal(f.status().task,identity.taskId);assert.equal(fs.existsSync(marker),false);
|
|
@@ -103,6 +109,7 @@ test('guidance survives original-run status and recovery without writing it into
|
|
|
103
109
|
assert.equal(result.identity.attempt,1);assert.equal(result.guidance,undefined);
|
|
104
110
|
const after=snapshot();assert.deepEqual(after.records.slice(0,before.records.length),before.records);
|
|
105
111
|
assert.equal(JSON.stringify(after.records).includes('recoveryOperation'),false);
|
|
112
|
+
assert.equal(JSON.stringify(after.records).includes('"blockage"'),false);
|
|
106
113
|
assert(fs.readFileSync(path.join(f.specsDir,f.feature,'tasks.md'),'utf8').includes('- [ ] T-001'));
|
|
107
114
|
assert(!f.events().some(row=>row.phase_name==='reviewing'),'start recovery preserves the development stage');
|
|
108
115
|
});
|
|
@@ -17,6 +17,7 @@ import {explainReviewedDrift} from '../runtime/js/cm-ai/fix-code-association.mjs
|
|
|
17
17
|
import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
18
18
|
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
19
19
|
import {createTaskRunner} from '../runtime/js/cm-ai/task-runner.mjs';
|
|
20
|
+
import {completionSummary} from '../runtime/js/cm-ai/completion-summary.mjs';
|
|
20
21
|
|
|
21
22
|
const isolated=fs.mkdtempSync(path.join(os.tmpdir(),'cm-project-qa-gate-'));
|
|
22
23
|
const saved={CM_WORKFLOW_HOME:process.env.CM_WORKFLOW_HOME,CM_WORKFLOW_LOG_HOME:process.env.CM_WORKFLOW_LOG_HOME};
|
|
@@ -30,14 +31,14 @@ const lesson={status:'lesson_candidate',reason:null,candidates:[{classification:
|
|
|
30
31
|
const noLesson={status:'no_new_lesson',candidates:[],reason:null};
|
|
31
32
|
|
|
32
33
|
// Two approved features: 1.work/T-002 carries one blocking browser case, 2.next/T-003 is the project's last task.
|
|
33
|
-
function project(){
|
|
34
|
+
function project({mandatory=false}={}){
|
|
34
35
|
const root=fs.realpathSync(fs.mkdtempSync(path.join(isolated,'project-')));
|
|
35
36
|
const codeProject=path.join(root,'code'),specsDir=path.join(root,'specs');fs.mkdirSync(codeProject);
|
|
36
37
|
for(const [feature,task] of [['1.work','T-002'],['2.next','T-003']]){
|
|
37
38
|
fs.mkdirSync(path.join(specsDir,feature),{recursive:true});
|
|
38
39
|
fs.writeFileSync(path.join(specsDir,feature,'design.md'),'# D\n');
|
|
39
40
|
fs.writeFileSync(path.join(specsDir,feature,'requirements.md'),feature==='1.work'?'# R\n\n- AC-001: page renders\n':'# R\n');
|
|
40
|
-
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),`- [ ] ${task}: fixture\n`);
|
|
41
|
+
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),`- [ ] ${task}: ${mandatory?'必验: ':''}fixture\n`);
|
|
41
42
|
}
|
|
42
43
|
fs.writeFileSync(path.join(specsDir,'1.work','test-cases.json'),JSON.stringify({schemaVersion:'1.0',feature:'work',cases:[
|
|
43
44
|
{id:'TC-001',origin:'generated',kind:'browser',blocking:true,acIds:['AC-001'],taskIds:['T-002'],title:'renders',
|
|
@@ -65,6 +66,8 @@ function project(){
|
|
|
65
66
|
examinedPaths:reviewPaths(review.payload.reviewPackage),findings:result==='approved'?[]:
|
|
66
67
|
[{id:'F1',severity:'P2',path:'b.mjs',message:'Again',evidence:'Synthetic'}],summary:'Synthetic review'}};}}],
|
|
67
68
|
reviewInvocation:{developerThreadId:'author-thread',excludedThreadIds:['control']},check:createHostCheck({cwd:codeProject,commands:[{id:'syntax',command:[process.execPath,'--check','a.mjs']}]}),
|
|
69
|
+
verificationGate:async request=>({satisfied:true,...(request.acceptanceContract?{items:request.acceptanceContract.obligations.map(item=>({...item,
|
|
70
|
+
satisfied:true,evidence:'Synthetic implementation fixture evidence; separate QA result is exercised below'}))}:{})}),
|
|
68
71
|
qaLogHome:logHome,applicableAgentFiles:[],
|
|
69
72
|
documentationProvider:{timeoutMs:5000,inspect:async binding=>{state.documentation++;
|
|
70
73
|
return {syncId:binding.syncId,identity:binding.identity,packageDigest:binding.packageDigest,contextDigest:binding.contextDigest,
|
|
@@ -95,6 +98,41 @@ function project(){
|
|
|
95
98
|
}
|
|
96
99
|
const status=p=>JSON.parse(fs.readFileSync(path.join(p.specsDir,'.cm-status.json'),'utf8'));
|
|
97
100
|
|
|
101
|
+
test('completion layers keep feature PASS separate from pending project work; later QA cannot reuse an old PASS',async()=>{
|
|
102
|
+
const p=project();p.state.browserUp=true;
|
|
103
|
+
const selected={...p.first,featureSelection:{version:1,feature:'1.work'}};
|
|
104
|
+
const done=await p.advance(selected,p.firstExecution(),'create');
|
|
105
|
+
assert.equal(done.code,'context_refreshed',JSON.stringify(done));
|
|
106
|
+
assert.equal(done.completion.feature.status,'passed',JSON.stringify(done.completion));
|
|
107
|
+
assert.equal(done.completion.run.status,'pending');assert.equal(done.completion.task.status,'completed');
|
|
108
|
+
assert.equal(done.completion.project.status,'pending');assert.equal(done.completion.project.pendingTasks,1);
|
|
109
|
+
assert.equal(done.completion.project.totalFeatures,2);assert.equal(done.completion.productAcceptance.status,'unknown');
|
|
110
|
+
const journal=path.join(p.specsDir,'.reviews','.execution',p.first.identity.runId,'state.json');
|
|
111
|
+
const originalJournal=fs.readFileSync(journal,'utf8'),saved=JSON.parse(originalJournal);
|
|
112
|
+
const {revision,...initialOnly}=saved;initialOnly.records=saved.records.slice(0,1);
|
|
113
|
+
fs.writeFileSync(journal,JSON.stringify({...initialOnly,revision:digest(initialOnly)})+'\n');
|
|
114
|
+
const stale=completionSummary({specsDir:p.specsDir,feature:'1.work',result:done});
|
|
115
|
+
assert.equal(stale.task.status,'unknown');assert.equal(stale.task.historicalCompleted,true);
|
|
116
|
+
assert.equal(stale.task.reason,'completion_owner_changed');assert.equal(stale.feature.qa.status,'unknown');
|
|
117
|
+
assert.notEqual(stale.binding.runnerRevision,done.completion.binding.runnerRevision);
|
|
118
|
+
fs.writeFileSync(journal,originalJournal);
|
|
119
|
+
const design=path.join(p.specsDir,'1.work','design.md'),original=fs.readFileSync(design,'utf8');
|
|
120
|
+
fs.appendFileSync(design,'\nAdditional mandatory acceptance condition\n');p.reapprove();
|
|
121
|
+
const drift=completionSummary({specsDir:p.specsDir,feature:'1.work',result:done});
|
|
122
|
+
assert.equal(drift.feature.qa.status,'blocked');assert.equal(drift.feature.qa.reason,'qa_specification_changed');
|
|
123
|
+
assert.equal(drift.task.status,'blocked');assert.equal(drift.task.historicalCompleted,true);
|
|
124
|
+
fs.writeFileSync(design,original);p.reapprove();
|
|
125
|
+
const log=path.join(p.specsDir,'运行日志.jsonl');
|
|
126
|
+
const rows=fs.readFileSync(log,'utf8').trim().split('\n').map(JSON.parse);
|
|
127
|
+
const start=rows.filter(row=>row.event==='test_run'&&row.phase==='start').at(-1);
|
|
128
|
+
// Adversarial newer in-flight evidence: even an illegal new round must block,
|
|
129
|
+
// never let a display fall back to the previous completed PASS.
|
|
130
|
+
fs.appendFileSync(log,JSON.stringify({...start,event_id:'later-start',operation_id:'later-qa',attempt:start.attempt+1})+'\n');
|
|
131
|
+
const current=completionSummary({specsDir:p.specsDir,feature:'1.work',result:done});
|
|
132
|
+
assert.notEqual(current.feature.qa.status,'passed');assert.notEqual(current.feature.status,'passed');
|
|
133
|
+
assert.equal(current.run.historicalFinalized,false);assert.notEqual(current.run.status,'finalized');
|
|
134
|
+
});
|
|
135
|
+
|
|
98
136
|
test('qaChangedFiles rejects stale_qa before completion and for a mismatched digest after completion',async()=>{
|
|
99
137
|
const p=project(),identity=p.first.identity;
|
|
100
138
|
const terminal=(request,result)=>({version:1,invocationId:request.invocationId,
|
|
@@ -126,9 +164,11 @@ test('qaChangedFiles rejects stale_qa before completion and for a mismatched dig
|
|
|
126
164
|
});
|
|
127
165
|
|
|
128
166
|
test('#17 an earlier feature whose QA is BLOCKED keeps the project from run_done until it is recovered; #18 its recovery survives a later reviewed task',async()=>{
|
|
129
|
-
const p=project();
|
|
167
|
+
const p=project({mandatory:true});
|
|
130
168
|
const blocked=await p.advance(p.first,p.firstExecution(),'create');
|
|
131
169
|
assert.equal(blocked.code,'qa_result_blocked');
|
|
170
|
+
assert.equal(blocked.completion.task.status,'completed');assert.equal(blocked.completion.task.review.status,'passed');
|
|
171
|
+
assert.equal(blocked.completion.feature.qa.status,'blocked');assert.equal(blocked.completion.project.pendingTasks,1);
|
|
132
172
|
const admission=inspectCmAiAdmission({specsDir:p.specsDir,codeProject:p.codeProject});
|
|
133
173
|
assert.equal(admission.nextTask.id,'T-003');
|
|
134
174
|
assert.deepEqual(admission.warnings.filter(line=>line.includes('QA 未通过')).length,1);
|
|
@@ -160,8 +200,19 @@ test('#17 an earlier feature whose QA is BLOCKED keeps the project from run_done
|
|
|
160
200
|
const recovered=await p.advance(p.first,p.firstExecution(),'resume',{rerunBlockedQa:true});
|
|
161
201
|
assert.notEqual(recovered.code,'correction_review_required',JSON.stringify(recovered));
|
|
162
202
|
assert.equal(recovered.code,'run_done',JSON.stringify(recovered));
|
|
203
|
+
const readyRun=await openControlRun(last,'resume',lastExecution());
|
|
204
|
+
try{
|
|
205
|
+
const ready=await readyRun.host.handle({version:1,operation:'finish',requestId:'finish-only',identity:last.identity,
|
|
206
|
+
packageDigest:refused.packageDigest,testRunId});
|
|
207
|
+
assert.equal(ready.code,'documentation_synced',JSON.stringify(ready));
|
|
208
|
+
assert.equal(ready.completion.run.status,'ready_to_finalize');assert.equal(ready.completion.run.historicalFinalized,false);
|
|
209
|
+
assert.equal(ready.completion.project.status,'ready_to_finalize');
|
|
210
|
+
}finally{readyRun.close();}
|
|
163
211
|
const finished=await p.advance(last,lastExecution(),'resume');
|
|
164
212
|
assert.equal(finished.code,'run_done',JSON.stringify(finished));
|
|
213
|
+
assert.equal(finished.completion.project.status,'completed',JSON.stringify(finished.completion));
|
|
214
|
+
assert.equal(finished.completion.run.status,'finalized');assert.equal(finished.completion.task.acceptanceProtection,'contract_v1');
|
|
215
|
+
assert.equal(finished.completion.productAcceptance.status,'unknown');assert.equal(finished.completion.deployment.status,'unknown');
|
|
165
216
|
assert.equal(status(p).state,'run_done');
|
|
166
217
|
});
|
|
167
218
|
|
|
@@ -386,7 +437,7 @@ test('#17 a feature completed outside N6 has no completion QA and blocks run_don
|
|
|
386
437
|
test('#17 a skip is fine while tasks remain, but a terminal feature whose latest decision is a skip blocks run_done',async()=>{
|
|
387
438
|
const p=project();
|
|
388
439
|
const tasks=path.join(p.specsDir,'1.work','tasks.md');
|
|
389
|
-
fs.writeFileSync(tasks,'- [ ] T-001: first\n- [ ] T-002: fixture\n');p.reapprove();
|
|
440
|
+
fs.writeFileSync(tasks,'- [ ] T-001: first (AC-001)\n- [ ] T-002: fixture\n');p.reapprove();
|
|
390
441
|
const first=p.definition('1.work','T-001',['a.mjs']);
|
|
391
442
|
const skipped=await p.advance(first,p.execution('1.work',{write:()=>fs.writeFileSync(path.join(p.codeProject,'a.mjs'),'export const a=1;\n'),
|
|
392
443
|
decision:{status:'skipped',reason:'no_fixed_trigger',score:null}}),'create');
|
|
@@ -77,7 +77,20 @@ test(`trusted host execution uses the same entry and sole gate: ${mode} nested=$
|
|
|
77
77
|
// include/follow its external metadata in the provider review package.
|
|
78
78
|
fs.writeFileSync(path.join(f.codeProject,'.git'),'gitdir: /nonexistent/cm-synthetic-worktree-metadata\n');
|
|
79
79
|
let stdout='',stderr='',calls=0,reviews=0;output.on('data',x=>stdout+=x);error.on('data',x=>stderr+=x);
|
|
80
|
+
fs.writeFileSync(path.join(f.specsDir,'1.login','tasks.md'),'- [ ] T-001: implement\n - 必验: preserve implementation\n');
|
|
81
|
+
fs.writeFileSync(path.join(f.specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.login'],specFiles:buildManifest(f.specsDir)}));
|
|
80
82
|
const execution={configuration:{kind:'synthetic-host-v1'},timeoutMs:2000,excludedContexts:['main'],
|
|
83
|
+
verificationGate:async request=>{
|
|
84
|
+
// These fixtures deliberately vary Review, not the implemented task's
|
|
85
|
+
// acceptance. Bind the evidence to the fixed fixture and real check.
|
|
86
|
+
assert.equal(request.description,'implement');
|
|
87
|
+
assert.deepEqual(request.acceptanceContract.obligations.map(item=>item.requirement),['- [ ] T-001: implement','- 必验: preserve implementation']);
|
|
88
|
+
assert.equal(request.checks.length,1);assert.equal(request.checks[0].id,'content');
|
|
89
|
+
assert.equal(request.checks[0].outcome,'passed');
|
|
90
|
+
assert.match(fs.readFileSync(path.join(f.codeProject,'a.js'),'utf8'),/^new( 2)?\n$/);
|
|
91
|
+
return {satisfied:true,items:request.acceptanceContract.obligations.map(item=>({...item,satisfied:true,
|
|
92
|
+
evidence:'Synthetic fixture a.js matches the implemented value; the real content subprocess passed'}))};
|
|
93
|
+
},
|
|
81
94
|
developer:{provider:'codex',requestedModel:'fixture',contextId:'dev',run:createCodexDeveloperRun({requestedModel:'fixture',worker:async({prompt})=>{
|
|
82
95
|
// Attempt 2 must change the rejected bytes (develop_unchanged_after_review).
|
|
83
96
|
calls++;fs.writeFileSync(path.join(f.codeProject,'a.js'),JSON.parse(prompt.split('<cm-developer-data-json>\n')[1]).identity.attempt===1?'new\n':'new 2\n');
|
|
@@ -367,13 +380,22 @@ test('trusted parallel selection binds admission, Learning, start and resume fin
|
|
|
367
380
|
const {inspectCmAiTaskLearningInput}=await import('../runtime/js/cm-ai/cm-ai-context-refresh.mjs');
|
|
368
381
|
const {createCodexDeveloperRun}=await import('../runtime/js/cm-ai/codex-developer-adapter.mjs');
|
|
369
382
|
const {createCmAiHost}=await import('../runtime/js/cm-ai/host.mjs');
|
|
370
|
-
fs.writeFileSync(path.join(f.specsDir,'1.login','tasks.md'),'- [ ] T-001: first\n- [ ] T-002: second\n- [ ] T-003: final\n\n- T-003 依赖 T-001, T-002\n');
|
|
383
|
+
fs.writeFileSync(path.join(f.specsDir,'1.login','tasks.md'),'- [ ] T-001: first\n- [ ] T-002: second\n - 必验: preserve second\n- [ ] T-003: final\n\n- T-003 依赖 T-001, T-002\n');
|
|
371
384
|
fs.writeFileSync(path.join(f.specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.login'],specFiles:buildManifest(f.specsDir)}));
|
|
372
385
|
const definition={...f.definition,identity:{...identity,taskId:'T-002'}},parallelSelection={version:1,group:['T-001','T-002']};
|
|
373
386
|
const learning={specsDir:f.specsDir,codeProject:f.codeProject,feature:'1.login',identity:definition.identity,applicableAgentFiles:[]};
|
|
374
387
|
assert.throws(()=>inspectCmAiTaskLearningInput(learning),{code:'learning_context_invalid'});
|
|
375
388
|
assert.equal(inspectCmAiTaskLearningInput(learning,{parallelSelection}).identity.taskId,'T-002');
|
|
376
389
|
const execution={configuration:{kind:'selection-fixture'},timeoutMs:2000,excludedContexts:['host'],
|
|
390
|
+
verificationGate:async request=>{
|
|
391
|
+
assert.equal(request.description,'second');
|
|
392
|
+
assert.deepEqual(request.acceptanceContract.obligations.map(item=>item.requirement),
|
|
393
|
+
['- [ ] T-002: second','- 必验: preserve second']);
|
|
394
|
+
assert.equal(fs.readFileSync(path.join(f.codeProject,'a.js'),'utf8'),'selected implementation\n');
|
|
395
|
+
assert.equal(request.checks[0].outcome,'passed');
|
|
396
|
+
return {satisfied:true,items:request.acceptanceContract.obligations.map(item=>({...item,satisfied:true,
|
|
397
|
+
evidence:'Synthetic selected implementation bytes and T-002 dependency references match this fixed fixture'}))};
|
|
398
|
+
},
|
|
377
399
|
developer:{provider:'codex',requestedModel:'fixture',contextId:'author',run:createCodexDeveloperRun({requestedModel:'fixture',worker:async()=>{fs.writeFileSync(path.join(f.codeProject,'a.js'),'selected implementation\n');return {status:'succeeded',value:{outcome:'implemented',
|
|
378
400
|
application:{status:'no_relevant_lesson',note:null},retrospective:{status:'no_new_lesson',candidates:[],reason:null}}};}})},
|
|
379
401
|
check:async()=>[{id:'check',command:['fixture'],outcome:'passed',exitCode:0,evidence:'fixture'}],reviewers:[{id:'reviewer',adapterId:'codex-review-adapter',provider:'codex',
|