@aibyzero/cm-workflow 0.16.4 → 0.16.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +8 -0
- package/CHANGELOG.md +50 -0
- package/README.md +12 -1
- package/VERSION +1 -1
- package/docs/installation.md +21 -1
- package/docs/js-workflow-control.md +245 -33
- package/docs/runtime-failover.md +1 -1
- 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-stream.mjs +12 -0
- 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 +137 -22
- 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 +180 -53
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +2 -1
- package/runtime/js/cm-ai/codex-review-adapter.mjs +24 -4
- 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 +305 -0
- package/runtime/js/cm-ai/drive-core.mjs +39 -7
- package/runtime/js/cm-ai/durable-runner-state.mjs +307 -53
- 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-store-limits.mjs +18 -0
- package/runtime/js/cm-ai/execution-store.mjs +6 -4
- package/runtime/js/cm-ai/fix-code-association.mjs +171 -18
- package/runtime/js/cm-ai/host-bootstrap.mjs +68 -21
- package/runtime/js/cm-ai/host-conversation-execution.mjs +16 -4
- package/runtime/js/cm-ai/host-handoff.mjs +13 -6
- package/runtime/js/cm-ai/host-qa-executor.mjs +21 -7
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +4 -4
- 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 +13 -4
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/launch-mismatch.mjs +42 -0
- package/runtime/js/cm-ai/log-rows.mjs +21 -0
- package/runtime/js/cm-ai/project-qa-gate.mjs +84 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +53 -9
- 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 +427 -31
- 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/task-commit.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +502 -65
- package/runtime/js/cm-fix/execution.mjs +109 -25
- package/runtime/js/cm-fix/host-review.mjs +7 -3
- package/runtime/js/cm-fix/host.mjs +3 -1
- package/runtime/js/cm-fix/progress.mjs +1 -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-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/review-preparation.mjs +10 -3
- package/runtime/js/cm-prd/review-publication.mjs +4 -2
- package/runtime/js/cm-prd/self-check.mjs +6 -3
- package/runtime/js/cm-prd/summary.mjs +3 -1
- package/runtime/js/cm-prd/validation-reason.mjs +20 -0
- package/runtime/js/spec-task-line.mjs +117 -0
- package/runtime/js/specs-status.mjs +10 -3
- 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 +92 -20
- package/scripts/cm-ai-batch-drive.test.mjs +164 -3
- package/scripts/cm-ai-batch-host.mjs +27 -11
- package/scripts/cm-ai-batch-host.test.mjs +2 -1
- package/scripts/cm-ai-batch-run.mjs +33 -10
- 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 +158 -0
- package/scripts/cm-ai-bootstrap-merge.test.mjs +45 -0
- package/scripts/cm-ai-bootstrap.test.mjs +99 -7
- package/scripts/cm-ai-conversation-entry-ops.test.mjs +82 -2
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +822 -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 +479 -47
- package/scripts/cm-ai-drive.test.mjs +240 -10
- package/scripts/cm-ai-fix-later-delivery.test.mjs +383 -0
- package/scripts/cm-ai-host.mjs +84 -25
- 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-project-qa-gate.test.mjs +308 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +166 -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 +917 -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 +160 -60
- package/scripts/cm-ai-run.test.mjs +4 -3
- 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-capability-gate.test.mjs +21 -2
- package/scripts/cm-check-drive.test.mjs +1 -1
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +1 -1
- package/scripts/cm-claude-developer-worker.test.mjs +3 -1
- package/scripts/cm-claude-probe.test.mjs +9 -1
- 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-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 +45 -13
- package/scripts/cm-fix-drive.test.mjs +36 -1
- package/scripts/cm-fix-host.mjs +9 -6
- package/scripts/cm-fix-review-budget.test.mjs +141 -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 +192 -17
- package/scripts/cm-host-session-diagnostic.test.mjs +10 -0
- package/scripts/cm-interactive-qa-diagnostic.test.mjs +53 -0
- package/scripts/cm-log-event.mjs +17 -0
- package/scripts/cm-log-event.test.mjs +31 -0
- package/scripts/cm-prd-completion.test.mjs +75 -0
- package/scripts/cm-prd-draft.test.mjs +14 -0
- package/scripts/cm-prd-gate-diagnostic.test.mjs +100 -0
- 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-review-dependency-snapshot.test.mjs +15 -0
- package/scripts/cm-review-inventory.test.mjs +253 -1
- 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.mjs +18 -10
- package/scripts/cm-task-gate.py +1 -1
- package/scripts/cm-test-branch-impact.test.mjs +6 -3
- package/scripts/fixtures/claude-review-process.mjs +1 -0
- package/scripts/fixtures/process-cleanup.mjs +99 -0
- package/scripts/test-cm-log-event.py +2 -0
- package/scripts/test-cm-prd-review-gate.py +2 -1
- package/scripts/test-npm-install.py +1 -1
- 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/references/N1-init.md +1 -1
- package/skills/cm-ai/references/js-host.md +261 -42
- package/skills/cm-fix/references/js-host.md +22 -1
- package/skills/cm-prd/references/js-change-recovery.md +1 -1
- package/skills/cm-prd/references/js-host.md +6 -0
|
@@ -14,6 +14,7 @@ import {createDeveloperRun,validateDeveloperScope} from '../runtime/js/cm-ai/dev
|
|
|
14
14
|
import {inspectCmAiAdmission} from '../runtime/js/cm-ai/cm-ai-admission.mjs';
|
|
15
15
|
import {inspectCmAiContextRefresh,inspectCmAiTaskLearningInput} from '../runtime/js/cm-ai/cm-ai-context-refresh.mjs';
|
|
16
16
|
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
17
|
+
import {readRunnerHistory,runnerStatus,developBudgetExhausted} from '../runtime/js/cm-ai/durable-runner-state.mjs';
|
|
17
18
|
import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
|
|
18
19
|
import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
19
20
|
const FIXTURE_TIMEOUT_MS=Number(process.env.CM_TEST_FIXTURE_TIMEOUT_MS??60000);
|
|
@@ -49,7 +50,9 @@ function reply(f,kind,payload){
|
|
|
49
50
|
if(kind==='init_generate')return {status:'generated',documents:payload.targets.map(file=>({path:file,
|
|
50
51
|
content:file==='AGENTS.md'&&fs.existsSync(path.join(f.codeProject,file))?fs.readFileSync(path.join(f.codeProject,file),'utf8'):
|
|
51
52
|
file==='.claude/CLAUDE.md'?'# Fixture instructions\n'+payload.targets.filter(p=>p.startsWith('.claude/rules/'))
|
|
52
|
-
.map(p=>'@rules/'+path.basename(p)).join('\n')+'\n':'# Fixture instructions\nUse approved scope.\n'
|
|
53
|
+
.map(p=>'@rules/'+path.basename(p)).join('\n')+'\n':'# Fixture instructions\nUse approved scope.\n'
|
|
54
|
+
// A revision must change the rejected bytes (develop_unchanged_after_review).
|
|
55
|
+
+(payload.bootstrap?.priorReview?'Revised for the review findings.\n':'')}))};
|
|
53
56
|
if(kind==='init_verify')return {checks:checks(),constraintChanges:[],application:{status:'no_relevant_lesson',note:null},
|
|
54
57
|
retrospective:f.lesson&&f.calls.filter(kind=>kind==='init_verify').length===1
|
|
55
58
|
?{status:'lesson_candidate',candidates:[{classification:'structured',trigger:'Bootstrap recovery',
|
|
@@ -93,9 +96,9 @@ function open(f,taskId,mode='create',overrides={}){
|
|
|
93
96
|
check:createHostCheck({cwd:f.codeProject,timeoutMs:1000,commands:[{id:'syntax',command:[process.execPath,'--check','app.mjs']}]}),
|
|
94
97
|
taskCompletion:{reviewsDir:path.join(f.specsDir,'.reviews'),handoffs:[1,2].map(a=>path.join(f.specsDir,'.reviews',`bootstrap-${taskId}-a${a}-handoff.json`))},
|
|
95
98
|
persistence:{store,mode,version:3}});
|
|
96
|
-
return {runner,store,definition:d,close:()=>store.close(),effect:kind=>{
|
|
99
|
+
return {runner,store,definition:d,close:()=>store.close(),effect:(kind,suffix='')=>{
|
|
97
100
|
const identity=runner.status().identity;
|
|
98
|
-
return runner.executeEffect({version:1,id:kind+'-'+identity.attempt,kind,identity,...(kind==='develop'?{
|
|
101
|
+
return runner.executeEffect({version:1,id:kind+'-'+identity.attempt+suffix,kind,identity,...(kind==='develop'?{
|
|
99
102
|
learningInput:inspectCmAiTaskLearningInput({specsDir:f.specsDir,codeProject:f.codeProject,feature:'0.bootstrap',identity,
|
|
100
103
|
applicableAgentFiles:[]},{admission:runner.inspectBootstrapAdmission()})}:{})});
|
|
101
104
|
}};
|
|
@@ -143,7 +146,9 @@ function runCli(f,config,mode,operation){
|
|
|
143
146
|
if(row.type==='host_ready')sessionId=row.sessionId;
|
|
144
147
|
if(row.type==='host_request'){
|
|
145
148
|
calls.push(row.kind);let response;
|
|
146
|
-
if(['init_generate','init_verify'].includes(row.kind)){assert
|
|
149
|
+
if(['init_generate','init_verify'].includes(row.kind)){assert(mode==='create'||f.resumeInit);
|
|
150
|
+
response=reply(f,row.kind,row.payload);
|
|
151
|
+
if(row.kind==='init_verify'&&f.failVerify>0){f.failVerify--;response.checks.commands={status:'failed',evidence:'npm test exited 1'};}}
|
|
147
152
|
else if(row.kind==='qa_assess')response={scores:{scope:5,risk:5,accumulation:5,boundary:5},
|
|
148
153
|
changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}};
|
|
149
154
|
else if(row.kind==='documentation_inspect'){
|
|
@@ -211,7 +216,7 @@ test('bootstrap denies missing authority before intent and a newly authorized la
|
|
|
211
216
|
assert.equal((await run.effect('complete')).state,'fixture_completed');run.close();
|
|
212
217
|
});
|
|
213
218
|
|
|
214
|
-
for(const scenario of ['existing-instructions','
|
|
219
|
+
for(const scenario of ['existing-instructions','target-drift'])
|
|
215
220
|
test('rules task preserves files and original unknown outcome: '+scenario,{timeout:5000},async t=>{
|
|
216
221
|
const f=fixture(t),tasks=path.join(f.specsDir,'0.bootstrap','tasks.md');
|
|
217
222
|
// A previously accepted scaffold is test setup, not a second execution path.
|
|
@@ -229,8 +234,95 @@ test('rules task preserves files and original unknown outcome: '+scenario,{timeo
|
|
|
229
234
|
}});
|
|
230
235
|
const result=await run.effect('develop');assert.equal(result.state,'unknown');run.close();
|
|
231
236
|
assert.equal(fs.existsSync(path.join(f.codeProject,'.claude')),false);
|
|
232
|
-
|
|
233
|
-
else assert.match(fs.readFileSync(agents,'utf8'),/user|User/);
|
|
237
|
+
assert.match(fs.readFileSync(agents,'utf8'),/user|User/);
|
|
234
238
|
const before=[...f.calls],resumed=open(f,'T-002','resume');
|
|
235
239
|
assert.equal(resumed.runner.status().state,'unknown');resumed.close();assert.deepEqual(f.calls,before);
|
|
236
240
|
});
|
|
241
|
+
|
|
242
|
+
const ruleHashes=f=>Object.fromEntries(cmInitRuleTargets(selection).map(file=>{
|
|
243
|
+
const target=path.join(f.codeProject,file);return [file,fs.existsSync(target)?digest(fs.readFileSync(target,'utf8')):null];}));
|
|
244
|
+
const journal=f=>JSON.parse(fs.readFileSync(path.join(f.specsDir,'.reviews','.execution','run-T-002','state.json'),'utf8')).records;
|
|
245
|
+
function rechain(records){
|
|
246
|
+
let previousDigest=null;
|
|
247
|
+
for(const row of records){row.previousDigest=previousDigest;const {digest:old,...body}=row;row.digest=digest(body);previousDigest=row.digest;}
|
|
248
|
+
return records;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
test('round-2 live init_verify that fails blocks retryably and the same attempt redoes it against its recorded rules',{timeout:FIXTURE_TIMEOUT_MS},async t=>{
|
|
252
|
+
const f=fixture(t),tasks=path.join(f.specsDir,'0.bootstrap','tasks.md');
|
|
253
|
+
fs.writeFileSync(tasks,fs.readFileSync(tasks,'utf8').replace('[ ] T-001','[x] T-001'));
|
|
254
|
+
fs.writeFileSync(path.join(f.codeProject,'app.mjs'),'export const fixture = true;\n');
|
|
255
|
+
f.requestRevision=true;f.lesson=true;
|
|
256
|
+
let failNext=false;const reply2=(kind,payload)=>{
|
|
257
|
+
const response=reply(f,kind,payload);
|
|
258
|
+
if(kind==='init_verify'&&failNext){failNext=false;response.checks.commands={status:'failed',evidence:'npm test exited 1'};
|
|
259
|
+
response.checks.globs={status:'verified',evidence:' '};}
|
|
260
|
+
return response;
|
|
261
|
+
};
|
|
262
|
+
let run=open(f,'T-002','create',{reply:reply2});
|
|
263
|
+
assert.equal((await run.effect('develop')).state,'awaiting_review');
|
|
264
|
+
assert.equal((await run.effect('review')).state,'changes_requested');
|
|
265
|
+
const recorded=ruleHashes(f);assert(Object.values(recorded).every(Boolean));
|
|
266
|
+
failNext=true;
|
|
267
|
+
const blocked=await run.effect('develop');
|
|
268
|
+
assert.equal(blocked.state,'blocked');assert.equal(blocked.code,'bootstrap_verification_failed');
|
|
269
|
+
const status=run.runner.status();
|
|
270
|
+
assert.equal(status.identity.attempt,2);assert.equal(status.state,'blocked');
|
|
271
|
+
assert.match(status.reason,/^bootstrap_verification_failed: .*commands: failed; npm test exited 1.*globs: verified; \(no evidence\)/);
|
|
272
|
+
assert.equal(status.calls.at(-1).failureResult.code,'bootstrap_verification_failed');
|
|
273
|
+
// Nothing was written and the round-1 evidence the retry binds to is kept.
|
|
274
|
+
assert.deepEqual(ruleHashes(f),recorded);assert.equal(f.reviews.length,1);run.close();
|
|
275
|
+
// A resumed process replays the blocked journal and redoes the same attempt.
|
|
276
|
+
run=open(f,'T-002','resume',{reply:reply2});
|
|
277
|
+
assert.equal(run.runner.status().code,'bootstrap_verification_failed');
|
|
278
|
+
const calls=f.calls.length,retried=await run.effect('develop','-retry-1');
|
|
279
|
+
assert.equal(retried.state,'awaiting_review',JSON.stringify(run.runner.status()));
|
|
280
|
+
assert.deepEqual(f.calls.slice(calls),['init_generate','init_verify']);
|
|
281
|
+
assert.equal(run.runner.status().identity.attempt,2);
|
|
282
|
+
assert.equal((await run.effect('review')).state,'approved');
|
|
283
|
+
assert.equal((await run.effect('complete')).state,'fixture_completed');run.close();
|
|
284
|
+
assert.equal(f.reviews.length,2);assert.match(fs.readFileSync(path.join(f.codeProject,'.claude','rules','frontend.md'),'utf8'),/Revised for the review findings/);
|
|
285
|
+
const replay=open(f,'T-002','resume');assert.equal(replay.runner.status().state,'fixture_completed');replay.close();
|
|
286
|
+
|
|
287
|
+
// Replay accepts the blocked checkpoint strictly; forged or legacy shapes are judged as before.
|
|
288
|
+
const rows=journal(f),config=rows[0].payload.config;
|
|
289
|
+
const index=rows.findIndex(row=>row.payload.checkpoint?.code==='bootstrap_verification_failed');assert(index>0);
|
|
290
|
+
const blockedState=readRunnerHistory(rechain(structuredClone(rows.slice(0,index+1))),config,3).state;
|
|
291
|
+
assert.equal(blockedState.code,'bootstrap_verification_failed');
|
|
292
|
+
// The retry is admitted through the shared develop budget guard, like every other retryable block.
|
|
293
|
+
assert.equal(developBudgetExhausted(blockedState),false);
|
|
294
|
+
const spent=structuredClone(blockedState.calls.at(-1));
|
|
295
|
+
assert.equal(developBudgetExhausted({...blockedState,calls:[...blockedState.calls,spent,spent]}),true);
|
|
296
|
+
const forged=(change,expected)=>{const records=structuredClone(rows.slice(0,index+1)),checkpoint=records.at(-1).payload.checkpoint;
|
|
297
|
+
change(checkpoint);checkpoint.cache.at(-1).result=runnerStatus(checkpoint,config);
|
|
298
|
+
const replayed=()=>readRunnerHistory(rechain(records),config,3);
|
|
299
|
+
if(expected===null)return replayed();assert.throws(replayed,{code:expected});};
|
|
300
|
+
forged(checkpoint=>{checkpoint.learningResult=null;},'runner_history_mismatch');
|
|
301
|
+
forged(checkpoint=>{checkpoint.code='develop_checks_not_passed';},'runner_transition');
|
|
302
|
+
forged(checkpoint=>{checkpoint.state='awaiting_review';checkpoint.code=null;checkpoint.reason=null;},'runner_learning');
|
|
303
|
+
// The shape an older version wrote for the same answer: an unknown developer call.
|
|
304
|
+
const legacy=forged(checkpoint=>{const call=checkpoint.calls.at(-1);delete call.failureResult;call.terminal='unknown';call.resultDigest=null;
|
|
305
|
+
checkpoint.state='unknown';checkpoint.code='bootstrap_verification_blocked';checkpoint.reason=null;checkpoint.learningResult=null;},null);
|
|
306
|
+
assert.equal(legacy.state.state,'unknown');
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
test('current-session host: round-1 init_verify that fails blocks and a resumed advance redoes it in the same run',{timeout:FIXTURE_TIMEOUT_MS},async t=>{
|
|
310
|
+
const f=fixture(t);
|
|
311
|
+
const run=open(f,'T-001');await run.effect('develop');await run.effect('review');await run.effect('complete');run.close();
|
|
312
|
+
const cli=prepareCli(f);f.failVerify=1;
|
|
313
|
+
const blocked=await runCli(f,cli,'create','advance');
|
|
314
|
+
assert.equal(blocked.code,0,blocked.stderr);
|
|
315
|
+
assert.equal(blocked.result.state,'blocked',JSON.stringify(blocked.result));assert.equal(blocked.result.code,'bootstrap_verification_failed');
|
|
316
|
+
assert.equal(blocked.result.pendingAction,'resume');
|
|
317
|
+
assert.deepEqual(f.calls,['init_generate','init_verify']);
|
|
318
|
+
assert.equal(fs.existsSync(path.join(f.codeProject,'AGENTS.md')),false);assert.equal(fs.existsSync(path.join(f.codeProject,'.claude')),false);
|
|
319
|
+
f.resumeInit=true;
|
|
320
|
+
const completed=await runCli(f,cli,'resume','advance');
|
|
321
|
+
assert.equal(completed.code,0,completed.stderr);assert.equal(completed.result.state,'run_done',JSON.stringify(completed.result));
|
|
322
|
+
assert.deepEqual(f.calls,['init_generate','init_verify','init_generate','init_verify']);
|
|
323
|
+
// One run: the blocked develop and the redone one share its journal.
|
|
324
|
+
assert.deepEqual(fs.readdirSync(path.join(f.specsDir,'.reviews','.execution')).filter(name=>name.startsWith('run-')),['run-T-001','run-T-002']);
|
|
325
|
+
assert(journal(f).some(row=>row.payload.checkpoint?.code==='bootstrap_verification_failed'));
|
|
326
|
+
const status=await runCli(f,cli,'resume','status');assert.equal(status.code,0,status.stderr);
|
|
327
|
+
assert.equal(status.result.state,'fixture_completed');assert.deepEqual(status.calls,[]);
|
|
328
|
+
});
|
|
@@ -10,6 +10,7 @@ import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
|
10
10
|
const identity={repositoryId:'fixture',runId:'conversation-ops',taskId:'T-001',attempt:1};
|
|
11
11
|
const packageDigest='8'.repeat(64);
|
|
12
12
|
const operation=(name,requestId=name)=>({version:1,operation:name,requestId,identity,packageDigest,testRunId:null});
|
|
13
|
+
const control=name=>({version:1,operation:name,requestId:name,identity});
|
|
13
14
|
|
|
14
15
|
async function fixture(run){
|
|
15
16
|
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-ai-conversation-ops-')));
|
|
@@ -21,18 +22,79 @@ async function fixture(run){
|
|
|
21
22
|
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature]}));
|
|
22
23
|
fs.writeFileSync(path.join(codeProject,'README.md'),'existing project\n');
|
|
23
24
|
let current={state:'ready',code:null,identity,packageDigest},effects=0;
|
|
24
|
-
|
|
25
|
+
let execute=async()=>{throw Error('unexpected runner effect');};
|
|
26
|
+
const runner={status:()=>current,executeEffect:async effect=>{effects++;return execute(effect);},
|
|
25
27
|
cancel:()=>current,run:async()=>current};
|
|
26
28
|
const entry=extra=>createCmAiConversationEntry({specsDir,codeProject,feature,identity,runner,
|
|
27
29
|
applicableAgentFiles:[],...extra});
|
|
28
30
|
const complete=()=>{current={...current,state:'fixture_completed'};};
|
|
31
|
+
const setStatus=(state,code,reason)=>{current={...current,state,code,...(reason?{reason}:{})};};
|
|
29
32
|
const seedQa=()=>recordCmAiQaDecision({specsDir,codeProject,feature,identity,packageDigest,
|
|
30
33
|
logHome:path.join(root,'logs'),decision:{decisionId:'qa-skipped',identity,packageDigest,
|
|
31
34
|
status:'skipped',reason:'fixture',score:4,at:'2026-09-04T15:10:00-07:00'}});
|
|
32
|
-
try{return await run({root,specsDir,codeProject,entry,complete,seedQa,effects:()=>effects
|
|
35
|
+
try{return await run({root,specsDir,codeProject,entry,complete,setStatus,seedQa,effects:()=>effects,
|
|
36
|
+
setExecutor:fn=>{execute=fn;},setCompletionBlocks:fn=>{runner.completionBlocks=fn;},status:()=>current});}
|
|
33
37
|
finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
test('A4 completion retry routes a new effect id through the same run',()=>fixture(async f=>{
|
|
41
|
+
f.setStatus('blocked','completion_checks_changed');f.setCompletionBlocks(()=>1);
|
|
42
|
+
let expectedId='complete-1-retry-1';
|
|
43
|
+
f.setExecutor(effect=>{
|
|
44
|
+
assert.equal(effect.kind,'complete');assert.equal(effect.id,expectedId);
|
|
45
|
+
f.setStatus('fixture_completed',null);return f.status();
|
|
46
|
+
});
|
|
47
|
+
const entry=f.entry(),before=await entry.handle(control('status'));
|
|
48
|
+
assert.equal(before.pendingAction,'complete');
|
|
49
|
+
const result=await entry.handle({version:1,operation:'complete',requestId:'complete',identity,packageDigest});
|
|
50
|
+
assert.equal(result.state,'fixture_completed',JSON.stringify(result));assert.equal(f.effects(),1);
|
|
51
|
+
f.setStatus('blocked','completion_checks_changed');f.setCompletionBlocks(()=>2);
|
|
52
|
+
expectedId='complete-1-retry-2';
|
|
53
|
+
await entry.handle(control('advance'));
|
|
54
|
+
assert.equal(f.effects(),2);
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
test('check output block reaches operator status with paths and resume action',()=>fixture(async f=>{
|
|
58
|
+
f.setStatus('blocked','check_output_out_of_scope','out_of_scope: build/product');
|
|
59
|
+
const result=await f.entry().handle(control('status'));
|
|
60
|
+
assert.equal(result.code,'check_output_out_of_scope');
|
|
61
|
+
assert.equal(result.pendingAction,'resume');
|
|
62
|
+
assert.equal(result.reason,'out_of_scope: build/product');
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
test('review package drift reports paths and suppresses refused decision and completion actions',()=>fixture(async f=>{
|
|
66
|
+
f.setStatus('blocked','review_package_changed','out_of_scope: App.xcodeproj/user.xcuserstate');
|
|
67
|
+
const entry=f.entry();const status=await entry.handle(control('status'));
|
|
68
|
+
assert.equal(status.pendingAction,'none');assert.match(status.reason,/xcuserstate/);
|
|
69
|
+
for(const operation of ['decision','complete']){
|
|
70
|
+
const result=await entry.handle({version:1,operation,requestId:operation,identity,packageDigest});
|
|
71
|
+
assert.equal(result.outcome,'rejected');assert.equal(result.code,'review_package_changed');
|
|
72
|
+
assert.match(result.reason,/xcuserstate/);
|
|
73
|
+
}
|
|
74
|
+
assert.equal(f.effects(),0);
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
test('completion package drift advertises complete retry and uses a fresh effect id',()=>fixture(async f=>{
|
|
78
|
+
f.setStatus('blocked','completion_package_changed','out_of_scope: unexpected.txt');
|
|
79
|
+
f.setCompletionBlocks(()=>1);
|
|
80
|
+
f.setExecutor(effect=>{
|
|
81
|
+
assert.equal(effect.id,'complete-1-retry-1');f.setStatus('fixture_completed',null);return f.status();
|
|
82
|
+
});
|
|
83
|
+
const entry=f.entry();assert.equal((await entry.handle(control('status'))).pendingAction,'complete');
|
|
84
|
+
assert.equal((await entry.handle({version:1,operation:'complete',requestId:'complete',identity,packageDigest})).state,'fixture_completed');
|
|
85
|
+
}));
|
|
86
|
+
|
|
87
|
+
test('completion package drift keeps complete unavailable until cleanup',()=>fixture(async f=>{
|
|
88
|
+
f.setStatus('blocked','completion_package_changed','out_of_scope: unexpected.txt');
|
|
89
|
+
const entry=f.entry({});
|
|
90
|
+
const current=f.status();current.retryReady=false;
|
|
91
|
+
const status=await entry.handle(control('status'));
|
|
92
|
+
assert.equal(status.pendingAction,'none');
|
|
93
|
+
const refused=await entry.handle({version:1,operation:'complete',requestId:'complete',identity,packageDigest});
|
|
94
|
+
assert.equal(refused.outcome,'rejected');assert.equal(refused.code,'completion_package_changed');
|
|
95
|
+
assert.match(refused.reason,/unexpected.txt/);assert.equal(f.effects(),0);
|
|
96
|
+
}));
|
|
97
|
+
|
|
36
98
|
test('context_refresh requires a completed task and returns its bound context summary',()=>fixture(async f=>{
|
|
37
99
|
const request=operation('context_refresh');
|
|
38
100
|
assert.equal((await f.entry().handle(request)).code,'context_not_ready');
|
|
@@ -47,6 +109,24 @@ test('context_refresh requires a completed task and returns its bound context su
|
|
|
47
109
|
assert.equal(f.effects(),0);
|
|
48
110
|
}));
|
|
49
111
|
|
|
112
|
+
test('idle unknown cancel reports unchanged durable state',()=>fixture(async f=>{
|
|
113
|
+
f.setStatus('unknown','reconciliation_required');
|
|
114
|
+
const entry=f.entry(),result=await entry.handle(control('cancel'));
|
|
115
|
+
assert.equal(result.outcome,'reported');
|
|
116
|
+
assert.equal(result.state,'unknown');
|
|
117
|
+
assert.equal(result.code,'reconciliation_required');
|
|
118
|
+
assert.equal(result.pendingAction,'reconcile');
|
|
119
|
+
}));
|
|
120
|
+
|
|
121
|
+
test('cancel stops an in-flight advance on a completed runner',()=>fixture(async f=>{
|
|
122
|
+
f.complete();
|
|
123
|
+
const entry=f.entry(),advance=entry.handle(control('advance'));
|
|
124
|
+
const cancelled=await entry.handle(control('cancel'));
|
|
125
|
+
assert.equal(cancelled.outcome,'cancelled');
|
|
126
|
+
assert.equal(cancelled.state,'fixture_completed');
|
|
127
|
+
assert.equal((await advance).code,'cancelled');
|
|
128
|
+
}));
|
|
129
|
+
|
|
50
130
|
test('run_finalize requires documentation sync and returns the final outcome without runner effects',()=>fixture(async f=>{
|
|
51
131
|
f.complete();f.seedQa();
|
|
52
132
|
const refresh=await f.entry().handle(operation('context_refresh'));
|