@aibyzero/cm-workflow 0.16.9 → 0.17.1
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 +4 -0
- package/CHANGELOG.md +18 -1
- package/CONTRIBUTING.md +47 -0
- package/README.md +16 -1
- package/VERSION +1 -1
- package/docs/architecture.md +29 -13
- package/docs/cm-control-policy-v2.md +331 -0
- package/docs/execution-optimizations.md +1 -1
- package/docs/external-models.md +3 -3
- package/docs/fixes/20261013-claude-preinit-ui-invalidate.md +48 -0
- package/docs/human-correction.md +5 -5
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +104 -85
- package/docs/next-steps.md +11 -0
- package/docs/untested-branches.md +2 -3
- package/docs/user-guide.md +3 -3
- package/package.json +1 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +12 -8
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +13 -69
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +10 -5
- package/runtime/js/cm-ai/control-policy.mjs +112 -0
- package/runtime/js/cm-ai/drive-bootstrap.mjs +11 -8
- package/runtime/js/cm-ai/drive-core.mjs +124 -25
- package/runtime/js/cm-ai/durable-runner-state.mjs +32 -126
- package/runtime/js/cm-ai/gate-bridge.mjs +4 -4
- package/runtime/js/cm-ai/host-check.mjs +3 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +22 -20
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +11 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +63 -21
- package/runtime/js/cm-ai/host-review-authority.mjs +2 -2
- package/runtime/js/cm-ai/host-review-file.mjs +1 -1
- package/runtime/js/cm-ai/host-session.mjs +41 -8
- package/runtime/js/cm-ai/host-stage-observer.mjs +26 -0
- package/runtime/js/cm-ai/host-tool-bridge.mjs +25 -9
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +21 -10
- package/runtime/js/cm-ai/host.mjs +1 -2
- package/runtime/js/cm-ai/operator-guidance.mjs +57 -54
- package/runtime/js/cm-ai/review-package.mjs +16 -4
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +1 -1
- package/runtime/js/cm-ai/task-runner.mjs +41 -101
- package/runtime/js/cm-init/review-evidence.mjs +3 -1
- package/runtime/js/cm-prd/review-host.mjs +1 -1
- package/runtime/js/cm-prd/review-publication.mjs +5 -3
- package/runtime/js/cm-prd/summary.mjs +27 -12
- package/runtime/js/cm-refactor/workflow.mjs +1 -1
- package/runtime/js/notify-send.mjs +15 -14
- package/runtime/js/notify.mjs +27 -4
- package/runtime/js/policy-binding-compat.mjs +2 -1
- package/runtime/review.md +61 -7
- package/runtime/task-gates.md +107 -9
- package/scripts/cm-ai-abandon-effect-position.test.mjs +1 -8
- package/scripts/cm-ai-answer-gap-driver.test.mjs +12 -12
- package/scripts/cm-ai-answer-gap-fixture.mjs +1 -8
- package/scripts/cm-ai-batch-drive.mjs +50 -31
- package/scripts/cm-ai-batch-drive.test.mjs +62 -19
- package/scripts/cm-ai-batch-host.mjs +39 -20
- package/scripts/cm-ai-batch-host.test.mjs +83 -47
- package/scripts/cm-ai-batch-run-fixture.mjs +6 -53
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +0 -12
- package/scripts/cm-ai-batch-run.mjs +46 -14
- package/scripts/cm-ai-bootstrap-flow.test.mjs +1 -7
- package/scripts/cm-ai-bootstrap.test.mjs +2 -3
- package/scripts/cm-ai-control-launch.test.mjs +219 -0
- package/scripts/cm-ai-control-policy.test.mjs +192 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +270 -0
- package/scripts/cm-ai-develop-answer-invalid.test.mjs +1 -8
- package/scripts/cm-ai-develop-call-timeout.test.mjs +1 -8
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +33 -20
- package/scripts/cm-ai-direct-review.test.mjs +348 -0
- package/scripts/cm-ai-documentation-sync-gap.test.mjs +3 -3
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +57 -27
- package/scripts/cm-ai-drive.mjs +96 -54
- package/scripts/cm-ai-drive.test.mjs +46 -87
- package/scripts/cm-ai-fix-integration.test.mjs +3 -5
- package/scripts/cm-ai-fix-later-delivery.test.mjs +3 -6
- package/scripts/cm-ai-fix-run-delivery.test.mjs +3 -6
- package/scripts/cm-ai-host-cli-workflow.test.mjs +6 -10
- package/scripts/cm-ai-host-fixture.mjs +47 -16
- package/scripts/cm-ai-host-protected.test.mjs +35 -33
- package/scripts/cm-ai-host.mjs +103 -93
- package/scripts/cm-ai-host.test.mjs +34 -18
- package/scripts/cm-ai-launch-diagnostics.test.mjs +5 -3
- package/scripts/cm-ai-legacy-history.test.mjs +53 -0
- package/scripts/cm-ai-light-modules.test.mjs +4 -7
- package/scripts/cm-ai-multi-root.test.mjs +4 -4
- package/scripts/cm-ai-nested-execution.test.mjs +16 -19
- package/scripts/cm-ai-operator-guidance.test.mjs +56 -0
- package/scripts/cm-ai-progress.test.mjs +10 -8
- package/scripts/cm-ai-project-qa-gate.test.mjs +37 -10
- package/scripts/cm-ai-protected-scope.test.mjs +1 -2
- package/scripts/cm-ai-qa-config-revision.test.mjs +1 -9
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +12 -9
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +18 -3
- package/scripts/cm-ai-qa-fixed-log.test.mjs +41 -0
- package/scripts/cm-ai-qa-recovery-args.test.mjs +7 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +3 -4
- package/scripts/cm-ai-review-drift-precedence.test.mjs +1 -1
- package/scripts/cm-ai-review-failure.test.mjs +13 -19
- package/scripts/cm-ai-review-timeout-config.test.mjs +3 -1
- package/scripts/cm-ai-review-timeout.test.mjs +35 -128
- package/scripts/cm-ai-run.mjs +78 -24
- package/scripts/cm-ai-run.test.mjs +11 -38
- package/scripts/cm-ai-selection-guard.test.mjs +2 -2
- package/scripts/cm-ai-session-chain.test.mjs +18 -15
- package/scripts/cm-ai-spec-rebind.test.mjs +14 -18
- package/scripts/cm-ai-supersede.test.mjs +3 -10
- package/scripts/cm-blocked-reason.test.mjs +2 -3
- package/scripts/cm-capability-gate.test.mjs +33 -1
- package/scripts/cm-check-drive-files.mjs +1 -1
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +1 -1
- package/scripts/cm-claude-probe.test.mjs +26 -0
- package/scripts/cm-claude-review-stream.test.mjs +36 -0
- package/scripts/cm-claude-worker.test.mjs +21 -3
- package/scripts/cm-controlled-correction.test.mjs +469 -0
- package/scripts/cm-drive-liveness.test.mjs +83 -0
- package/scripts/cm-external-batch-host.test.mjs +38 -17
- package/scripts/cm-external-model-host.test.mjs +1 -1
- package/scripts/cm-external-model-recovery.test.mjs +3 -9
- package/scripts/cm-external-qa-fix.test.mjs +1 -1
- package/scripts/cm-external-review-reconciliation.test.mjs +6 -24
- package/scripts/cm-fix-review-recovery.test.mjs +1 -1
- package/scripts/cm-host-diagnostic.test.mjs +33 -0
- package/scripts/cm-host-liveness.test.mjs +150 -0
- package/scripts/cm-host-qa-executor.test.mjs +1 -2
- package/scripts/cm-host-qa-policy.test.mjs +43 -16
- package/scripts/cm-host-review-authority.test.mjs +0 -31
- package/scripts/cm-host-stage-observer.test.mjs +41 -0
- package/scripts/cm-knowledge-closeout.test.mjs +3 -3
- package/scripts/cm-notify-command.test.mjs +54 -18
- package/scripts/cm-notify-read-drift.test.mjs +69 -4
- package/scripts/cm-notify.mjs +16 -4
- package/scripts/cm-notify.test.mjs +135 -29
- package/scripts/cm-patrol.test.mjs +3 -2
- package/scripts/cm-prd-drive.test.mjs +1 -1
- package/scripts/cm-prd-self-check-revision.test.mjs +15 -0
- package/scripts/cm-prd-session-recovery.test.mjs +5 -3
- package/scripts/cm-prd-summary.test.mjs +31 -0
- package/scripts/cm-release-smoke.sh +2 -14
- package/scripts/cm-task-gate-correction.test.mjs +69 -16
- package/scripts/cm-task-gate.mjs +368 -34
- package/scripts/cm-task-gate.py +2 -0
- package/scripts/cm-task-gate.test.mjs +252 -4
- package/scripts/cm-test-suite.mjs +109 -0
- package/scripts/cm-test-suite.test.mjs +162 -0
- package/scripts/fixtures/bootstrap-review-runner.mjs +1 -7
- package/scripts/fixtures/host-diagnostic.mjs +33 -0
- package/scripts/fixtures/native-gate-fixture.mjs +18 -0
- package/scripts/policy-binding-compat.test.mjs +4 -0
- package/skills/cm-ai/SKILL.md +8 -6
- package/skills/cm-ai/references/N3-execute-task.md +17 -2
- package/skills/cm-ai/references/N4-review.md +11 -21
- package/skills/cm-ai/references/N5-mark-done.md +1 -1
- package/skills/cm-ai/references/N6-qa-eval.md +49 -21
- package/skills/cm-ai/references/js-host-modes.md +35 -14
- package/skills/cm-ai/references/js-host-qa-recovery.md +60 -12
- package/skills/cm-ai/references/js-host-recovery.md +95 -47
- package/skills/cm-ai/references/js-host.md +98 -29
- package/skills/cm-fix/SKILL.md +12 -0
- package/skills/cm-init/references/js-host.md +1 -1
- package/skills/cm-prd/references/js-host.md +1 -1
- package/skills/cm-refactor/SKILL.md +12 -0
- package/runtime/js/cm-ai/review-dispatch-limits.mjs +0 -18
- package/scripts/cm-ai-review-dispatch-exit.test.mjs +0 -475
|
@@ -7,7 +7,6 @@ import path from 'node:path';
|
|
|
7
7
|
import {openControlRun} from './cm-ai-run.mjs';
|
|
8
8
|
import {createCodexDeveloperRun} from '../runtime/js/cm-ai/codex-developer-adapter.mjs';
|
|
9
9
|
import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
|
|
10
|
-
import {createHostReviewAuthority} from '../runtime/js/cm-ai/host-review-authority.mjs';
|
|
11
10
|
import {createQaFixOwnerHost} from '../runtime/js/cm-ai/host-qa-fix-owner.mjs';
|
|
12
11
|
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
13
12
|
import {qaFixIdentity} from '../runtime/js/cm-fix/qa-source.mjs';
|
|
@@ -42,9 +41,8 @@ for(const mode of ['history','retest','unknown','failed-retest','double-pass','d
|
|
|
42
41
|
{event:'item.completed',item_type:'agent_message'},{event:'turn.completed',item_type:null},
|
|
43
42
|
{event:'process_closed',exit_code:0,signal:null,timed_out:false}])onEvent(event);
|
|
44
43
|
};
|
|
45
|
-
|
|
46
|
-
const execution={configuration:{kind:'synthetic-parent-fix'},timeoutMs:2000,excludedContexts:['parent-host'],
|
|
47
|
-
hostDecisionProvider:authority.hostDecisionProvider,
|
|
44
|
+
|
|
45
|
+
const execution={configuration:{kind:'synthetic-parent-fix'},timeoutMs:2000,excludedContexts:['parent-host'],
|
|
48
46
|
developer:{provider:'codex',requestedModel:'synthetic',contextId:'author',run:createCodexDeveloperRun({requestedModel:'synthetic',worker:async()=>{
|
|
49
47
|
developers++;fs.writeFileSync(path.join(codeProject,'value.mjs'),'export const value=1;');
|
|
50
48
|
return {status:'succeeded',value:{outcome:'implemented',application:{status:'no_relevant_lesson',note:null},
|
|
@@ -56,7 +54,7 @@ for(const mode of ['history','retest','unknown','failed-retest','double-pass','d
|
|
|
56
54
|
return {status:'succeeded',value:{verdict:'approved',packageDigest:request.payload.reviewPackage.packageDigest,
|
|
57
55
|
examinedPaths:reviewPaths(request.payload.reviewPackage),findings:[],summary:'Synthetic parent review; QA exposes remaining defect'}};
|
|
58
56
|
}}],
|
|
59
|
-
reviewInvocation:{developerThreadId:'author',excludedThreadIds:['parent-host']
|
|
57
|
+
reviewInvocation:{developerThreadId:'author',excludedThreadIds:['parent-host']},
|
|
60
58
|
check:createHostCheck({cwd:codeProject,commands:[{id:'existing',command:[process.execPath,'existing.mjs']}]}),
|
|
61
59
|
qaLogHome:path.join(root,'logs'),qaDecisionProvider:{timeoutMs:1000,decide:async binding=>({decisionId:'qa-parent',identity:binding.identity,packageDigest:binding.packageDigest,
|
|
62
60
|
status:'triggered',reason:'feature_complete',score:null,at:'2026-09-08T01:00:00Z'})},
|
|
@@ -9,7 +9,6 @@ import {buildManifest} from './cm-spec-manifest.mjs';
|
|
|
9
9
|
import {openControlRun} from './cm-ai-run.mjs';
|
|
10
10
|
import {createCodexDeveloperRun} from '../runtime/js/cm-ai/codex-developer-adapter.mjs';
|
|
11
11
|
import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
|
|
12
|
-
import {createHostReviewAuthority} from '../runtime/js/cm-ai/host-review-authority.mjs';
|
|
13
12
|
import {createQaFixOwnerHost} from '../runtime/js/cm-ai/host-qa-fix-owner.mjs';
|
|
14
13
|
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
15
14
|
import {qaFixIdentity} from '../runtime/js/cm-fix/qa-source.mjs';
|
|
@@ -56,10 +55,8 @@ for(const variant of ['separate','shared'])test(`#18 a QA fix for an earlier fea
|
|
|
56
55
|
fs.writeFileSync(path.join(codeProject,'.cm-workflow.json'),JSON.stringify({version:1,policies:{delivery:'diff'}}));
|
|
57
56
|
let qaRuns=0,childReviews=0,documentation=0;
|
|
58
57
|
const execution=({feature,write,retrospective={status:'no_new_lesson',candidates:[],reason:null},qa})=>{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return {configuration:{kind:'synthetic-parent-fix'},timeoutMs:2000,excludedContexts:['parent-host'],hostDecision:null,
|
|
62
|
-
hostDecisionProvider:authority.hostDecisionProvider,
|
|
58
|
+
|
|
59
|
+
return {configuration:{kind:'synthetic-parent-fix'},timeoutMs:2000,excludedContexts:['parent-host'],
|
|
63
60
|
developer:{provider:'codex',requestedModel:'synthetic',contextId:'author',run:createCodexDeveloperRun({requestedModel:'synthetic',worker:async()=>{
|
|
64
61
|
write();return {status:'succeeded',value:{outcome:'implemented',application:{status:'no_relevant_lesson',note:null},retrospective}};}})},
|
|
65
62
|
reviewers:[{id:'reviewer',adapterId:'codex-review-adapter',provider:'codex',requestedModel:'synthetic',allowed:true,available:true,
|
|
@@ -67,7 +64,7 @@ for(const variant of ['separate','shared'])test(`#18 a QA fix for an earlier fea
|
|
|
67
64
|
events(onEvent,`synthetic-review-${request.identity.runId}`);
|
|
68
65
|
return {status:'succeeded',value:{verdict:'approved',packageDigest:request.payload.reviewPackage.packageDigest,
|
|
69
66
|
examinedPaths:reviewPaths(request.payload.reviewPackage),findings:[],summary:'Synthetic review'}};}}],
|
|
70
|
-
reviewInvocation:{developerThreadId:'author',excludedThreadIds:['parent-host']
|
|
67
|
+
reviewInvocation:{developerThreadId:'author',excludedThreadIds:['parent-host']},
|
|
71
68
|
check:createHostCheck({cwd:codeProject,commands:[{id:'existing',command:[process.execPath,'existing.mjs']}]}),
|
|
72
69
|
qaLogHome:path.join(root,'logs'),qaDecisionProvider:{timeoutMs:1000,decide:async binding=>({decisionId:`qa-${binding.identity.runId}`,
|
|
73
70
|
identity:binding.identity,packageDigest:binding.packageDigest,status:'triggered',reason:'feature_complete',score:null,at:'2026-09-28T01:00:00Z'})},
|
|
@@ -12,7 +12,6 @@ import {buildManifest} from './cm-spec-manifest.mjs';
|
|
|
12
12
|
import {openControlRun} from './cm-ai-run.mjs';
|
|
13
13
|
import {createCodexDeveloperRun} from '../runtime/js/cm-ai/codex-developer-adapter.mjs';
|
|
14
14
|
import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
|
|
15
|
-
import {createHostReviewAuthority} from '../runtime/js/cm-ai/host-review-authority.mjs';
|
|
16
15
|
import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
17
16
|
import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
|
|
18
17
|
import {createFixHost} from '../runtime/js/cm-fix/host.mjs';
|
|
@@ -49,10 +48,8 @@ async function completedTaskThenFix({finish}){
|
|
|
49
48
|
fs.writeFileSync(path.join(codeProject,'red.mjs'),"import {value} from './value.mjs';if(value!==2){console.error('BUG');process.exit(1)}");
|
|
50
49
|
fs.writeFileSync(path.join(codeProject,'existing.mjs'),"import {value} from './value.mjs';if(typeof value!=='number')process.exit(1)");
|
|
51
50
|
fs.writeFileSync(path.join(codeProject,'.cm-workflow.json'),JSON.stringify({version:1,policies:{delivery:'diff'}}));
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const execution={configuration:{kind:'synthetic-parent'},timeoutMs:2000,excludedContexts:['parent-host'],hostDecision:null,
|
|
55
|
-
hostDecisionProvider:authority.hostDecisionProvider,
|
|
51
|
+
|
|
52
|
+
const execution={configuration:{kind:'synthetic-parent'},timeoutMs:2000,excludedContexts:['parent-host'],
|
|
56
53
|
developer:{provider:'codex',requestedModel:'synthetic',contextId:'author',run:createCodexDeveloperRun({requestedModel:'synthetic',worker:async()=>{
|
|
57
54
|
fs.writeFileSync(path.join(codeProject,'value.mjs'),'export const value=1;');
|
|
58
55
|
return {status:'succeeded',value:{outcome:'implemented',application:{status:'no_relevant_lesson',note:null},
|
|
@@ -62,7 +59,7 @@ async function completedTaskThenFix({finish}){
|
|
|
62
59
|
events(onEvent,`synthetic-review-${request.identity.runId}`);
|
|
63
60
|
return {status:'succeeded',value:{verdict:'approved',packageDigest:request.payload.reviewPackage.packageDigest,
|
|
64
61
|
examinedPaths:reviewPaths(request.payload.reviewPackage),findings:[],summary:'Synthetic review'}};}}],
|
|
65
|
-
reviewInvocation:{developerThreadId:'author',excludedThreadIds:['parent-host']
|
|
62
|
+
reviewInvocation:{developerThreadId:'author',excludedThreadIds:['parent-host']},
|
|
66
63
|
check:createHostCheck({cwd:codeProject,commands:[{id:'existing',command:[process.execPath,'existing.mjs']}]}),
|
|
67
64
|
qaLogHome:path.join(root,'logs'),qaDecisionProvider:{timeoutMs:1000,decide:async binding=>({decisionId:`qa-${binding.identity.runId}`,
|
|
68
65
|
identity:binding.identity,packageDigest:binding.packageDigest,status:'triggered',reason:'feature_complete',score:null,at:'2026-10-08T01:00:00Z'})},
|
|
@@ -67,7 +67,7 @@ let input='';process.stdin.on('data',s=>input+=s);process.stdin.on('end',()=>{
|
|
|
67
67
|
repair:{scope:['target.mjs','README.md'],requirements:['requirements.md']},
|
|
68
68
|
walkthrough:{timeoutMs:2000,flows:[{id:'value',modules:['value'],steps:['Read exported value'],expected:['43'],kind:'commands',command}]}};
|
|
69
69
|
const template=path.join(f.root,'template.json');fs.writeFileSync(template,JSON.stringify({specsRoot:f.specsDir,feature:'1.work',identity,configuration}));
|
|
70
|
-
f.args.push('--runtime',runtime,'--review-config',reviewFile,'--
|
|
70
|
+
f.args.push('--runtime',runtime,'--review-config',reviewFile,'--workflow-config',workflowFile,'--allow-qa',
|
|
71
71
|
'--qa-fix-template-config',template,'--qa-fix-review-config',reviewFile,'--allow-qa-fix-start','--auto-qa-fix',
|
|
72
72
|
...permissions.map(name=>`--allow-qa-fix-${name}`));
|
|
73
73
|
if(f.protected){
|
|
@@ -94,7 +94,7 @@ let input='';process.stdin.on('data',s=>input+=s);process.stdin.on('end',()=>{
|
|
|
94
94
|
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
for(const runtime of ['codex','claude'])for(const initialWorkflow of ['absent','qa-null','qa'])test(`configured ${runtime} CLI
|
|
97
|
+
for(const runtime of ['codex','claude'])for(const initialWorkflow of ['absent','qa-null','qa'])test(`configured ${runtime} CLI starts development and resumes through direct review and resumes via the original review worker/gate workflow=${initialWorkflow}`,async()=>{
|
|
98
98
|
const workflow=initialWorkflow==='qa';
|
|
99
99
|
const f=fixture();
|
|
100
100
|
try{
|
|
@@ -121,7 +121,7 @@ for(const runtime of ['codex','claude'])for(const initialWorkflow of ['absent','
|
|
|
121
121
|
f.args.push('--review-config',config);
|
|
122
122
|
if(runtime==='claude'){
|
|
123
123
|
fs.writeFileSync(config,JSON.stringify({...review,preflight:{...review.preflight,provider:'codex'}}));
|
|
124
|
-
const denied=spawnSync(process.execPath,[cli,...f.args
|
|
124
|
+
const denied=spawnSync(process.execPath,[cli,...f.args],{encoding:'utf8',env:f.env,timeout:3000});
|
|
125
125
|
assert.equal(denied.status,1);assert(denied.stderr.includes('tool_preflight_missing'));
|
|
126
126
|
assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));
|
|
127
127
|
fs.writeFileSync(config,JSON.stringify(review));
|
|
@@ -146,8 +146,8 @@ for(const runtime of ['codex','claude'])for(const initialWorkflow of ['absent','
|
|
|
146
146
|
fs.writeFileSync(attachmentFile,JSON.stringify({...attachmentConfig,qa:null}));
|
|
147
147
|
f.args.push('--workflow-config',attachmentFile);
|
|
148
148
|
}
|
|
149
|
-
const first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
|
|
150
|
-
assert.equal(first.rows.find(row=>row.requestId==='advance').result.code,
|
|
149
|
+
f.operation='start';const first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
|
|
150
|
+
assert.equal(first.rows.find(row=>row.requestId==='advance').result.code,null);
|
|
151
151
|
const initialArgs=[...f.args];
|
|
152
152
|
const attemptAttachment=()=>{
|
|
153
153
|
fs.writeFileSync(attachmentFile,JSON.stringify(attachmentConfig));
|
|
@@ -163,11 +163,7 @@ for(const runtime of ['codex','claude'])for(const initialWorkflow of ['absent','
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[ ] T-001'));
|
|
166
|
-
|
|
167
|
-
f.args.push('--allow-review-attempt','2');
|
|
168
|
-
const wrong=await runCli(f,'normal','resume');assert.equal(wrong.code,0,wrong.stderr);
|
|
169
|
-
assert.deepEqual(wrong.calls,[]);assert.equal(wrong.rows.find(row=>row.requestId==='advance').result.code,'decision_required');
|
|
170
|
-
f.args[f.args.length-1]='1';
|
|
166
|
+
f.operation='advance';
|
|
171
167
|
const completed=await runCli(f,'authorized-review','resume');assert.equal(completed.code,0,completed.stderr);
|
|
172
168
|
assert.deepEqual(completed.calls,workflow?['check','qa_assess','documentation_inspect']:['check']);
|
|
173
169
|
const result=completed.rows.find(row=>row.requestId==='advance').result;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {hostDiagnostic} from './fixtures/host-diagnostic.mjs';
|
|
1
2
|
// Shared real-host fixture for the cm-ai-host*.test.mjs files (the Codex-sandbox
|
|
2
3
|
// set that CI cannot host). Importing it isolates CM_WORKFLOW_HOME/LOG_HOME for the
|
|
3
4
|
// importing test file and sweeps every fixture root for leaked processes when that
|
|
@@ -11,6 +12,8 @@ import os from 'node:os';
|
|
|
11
12
|
import path from 'node:path';
|
|
12
13
|
import {spawn,spawnSync} from 'node:child_process';
|
|
13
14
|
import {fileURLToPath} from 'node:url';
|
|
15
|
+
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
16
|
+
import {claudeReviewFingerprint} from '../runtime/js/cm-ai/worker-claude.mjs';
|
|
14
17
|
import {guardFixtureSource,killFixtureProcesses} from './fixtures/process-cleanup.mjs';
|
|
15
18
|
|
|
16
19
|
// Keep runtime declarations and log mirrors independent of the invoking user's home.
|
|
@@ -39,19 +42,48 @@ export function fixture(){
|
|
|
39
42
|
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],specFiles:buildManifest(specsDir)}));
|
|
40
43
|
fs.writeFileSync(path.join(codeProject,'requirements.md'),'# Fixture\n');
|
|
41
44
|
fs.writeFileSync(config,JSON.stringify({version:1,specsDir,codeProject,feature,identity,scope:['target.mjs'],requirements:['requirements.md']}));
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
return
|
|
45
|
+
const reviewFile=path.join(root,'synthetic-review.json');
|
|
46
|
+
const f={root,specsDir,codeProject,config,reviewFile,args:['serve','--config',config,'--mode','create','--host-context','native-host-fixture','--allow-development']};
|
|
47
|
+
installSyntheticReview(f);
|
|
48
|
+
return f;
|
|
49
|
+
}
|
|
50
|
+
export function syntheticReviewConfig(codeProject,runtime='codex',model='fixture'){
|
|
51
|
+
return {model,disabledSkills:[],preflight:{passed:true,provider:runtime,cli_model:model,prompt_transport:'stdin',
|
|
52
|
+
config_fingerprint:(runtime==='claude'?claudeReviewFingerprint:configFingerprint)({cwd:codeProject,model,disabledSkills:[]})}};
|
|
53
|
+
}
|
|
54
|
+
// Only review output is synthetic. Any sandbox request delegates to the actual
|
|
55
|
+
// installed Codex, preserving native write-protection and command checks.
|
|
56
|
+
export function installSyntheticReview(f){
|
|
57
|
+
const bin=path.join(f.root,'synthetic-review-bin');fs.mkdirSync(bin,{recursive:true});
|
|
58
|
+
const real=spawnSync('/usr/bin/which',['codex'],{encoding:'utf8'}).stdout.trim();
|
|
59
|
+
for(const runtime of ['codex','claude']){
|
|
60
|
+
const source=fileURLToPath(new URL(`./fixtures/${runtime}-review-process.mjs`,import.meta.url));
|
|
61
|
+
fs.writeFileSync(path.join(bin,runtime),`#!${process.execPath}\n`
|
|
62
|
+
+`const {spawnSync}=await import('node:child_process');\n`
|
|
63
|
+
+`if(process.argv[2]==='sandbox'){const r=spawnSync(${JSON.stringify(real)},process.argv.slice(2),{stdio:'inherit'});process.exitCode=r.status??1;}\n`
|
|
64
|
+
+`else await import(${JSON.stringify(new URL('file://'+source).href)});\n`,{mode:0o700});
|
|
65
|
+
}
|
|
66
|
+
f.env={...(f.env??process.env),PATH:bin+path.delimiter+(f.env?.PATH??process.env.PATH),
|
|
67
|
+
CM_WORKFLOW_HOME:path.join(f.root,'home'),CM_WORKFLOW_LOG_HOME:path.join(f.root,'logs')};
|
|
68
|
+
if(f.reviewFile)fs.writeFileSync(f.reviewFile,JSON.stringify(syntheticReviewConfig(f.codeProject,f.runtime)));
|
|
69
|
+
return f;
|
|
46
70
|
}
|
|
47
|
-
//
|
|
48
|
-
export const launchArgs=f=>
|
|
71
|
+
// Explicit review configs retain the case's intended missing/stale preflight.
|
|
72
|
+
export const launchArgs=f=>{
|
|
73
|
+
if(f.args.includes('--review-config'))return f.args;
|
|
74
|
+
const index=f.args.indexOf('--review-runtime'),hostIndex=f.args.indexOf('--runtime');
|
|
75
|
+
const runtime=index>=0?f.args[index+1]:hostIndex>=0?f.args[hostIndex+1]:'codex';
|
|
76
|
+
fs.writeFileSync(f.reviewFile,JSON.stringify(syntheticReviewConfig(f.codeProject,runtime)));
|
|
77
|
+
return [...f.args,'--review-config',f.reviewFile];
|
|
78
|
+
};
|
|
49
79
|
|
|
50
80
|
export function runCli(f,mode,action='create'){
|
|
51
81
|
return new Promise((resolve,reject)=>{
|
|
52
82
|
const args=[...launchArgs(f)];args[4]=action;
|
|
53
83
|
const child=spawn(process.execPath,[cli,...args],{stdio:['pipe','pipe','pipe'],env:f.env??process.env});
|
|
54
84
|
let buffer='',stderr='',closed=false,sessionId;const rows=[],calls=[];
|
|
85
|
+
const timeoutMs=Number(process.env.CM_TEST_FIXTURE_TIMEOUT_MS??60000);
|
|
86
|
+
const trace=hostDiagnostic(child,{timeoutMs:f.watchdog?null:timeoutMs});
|
|
55
87
|
// Provider children run in their own process groups: stopping only the host
|
|
56
88
|
// would orphan a hung fake reviewer, so failure and watchdog paths stop the
|
|
57
89
|
// whole fixture tree. f.watchdog(expire) may replace the timer; it returns a disarm function.
|
|
@@ -59,13 +91,13 @@ export function runCli(f,mode,action='create'){
|
|
|
59
91
|
const fail=error=>{
|
|
60
92
|
disarm();child.kill('SIGKILL');
|
|
61
93
|
try{killFixtureProcesses(f.root);}catch(cleanup){error=new AggregateError([error,cleanup],String(error?.message??error));}
|
|
62
|
-
reject(error);
|
|
94
|
+
reject(trace.attach(error));
|
|
63
95
|
};
|
|
64
|
-
disarm=(f.watchdog??(expire=>{const timer=setTimeout(expire,
|
|
96
|
+
disarm=(f.watchdog??(expire=>{const timer=setTimeout(expire,timeoutMs);
|
|
65
97
|
return ()=>clearTimeout(timer);}))(()=>fail(new Error('host fixture timed out')));
|
|
66
98
|
child.stderr.on('data',chunk=>{stderr+=chunk;});
|
|
67
|
-
child.once('error',reject);
|
|
68
|
-
const send=value=>child.stdin.write(JSON.stringify(value)+'\n');
|
|
99
|
+
child.once('error',error=>reject(trace.attach(error)));
|
|
100
|
+
const send=value=>{trace.send(value);child.stdin.write(JSON.stringify(value)+'\n');};
|
|
69
101
|
const response=(row,result)=>({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,result});
|
|
70
102
|
child.stdout.on('data',chunk=>{
|
|
71
103
|
buffer+=chunk;
|
|
@@ -74,7 +106,7 @@ export function runCli(f,mode,action='create'){
|
|
|
74
106
|
const line=buffer.slice(0,newline);buffer=buffer.slice(newline+1);
|
|
75
107
|
if(!line)continue;
|
|
76
108
|
try{
|
|
77
|
-
const row=JSON.parse(line);rows.push(row);
|
|
109
|
+
const row=JSON.parse(line);rows.push(row);trace.receive(row);
|
|
78
110
|
if(row.type==='host_ready')sessionId=row.sessionId;
|
|
79
111
|
if(row.type==='host_request'){
|
|
80
112
|
calls.push(row.kind);
|
|
@@ -128,8 +160,7 @@ export function runCli(f,mode,action='create'){
|
|
|
128
160
|
send(response(row,{status:'completed'}));
|
|
129
161
|
}else if(row.kind==='qa_assess'){
|
|
130
162
|
assert(f.workflow);assert.equal(row.payload.pending,0);
|
|
131
|
-
send(response(row,{
|
|
132
|
-
changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}}));
|
|
163
|
+
send(response(row,{confirmed:true}));
|
|
133
164
|
}else if(row.kind==='qa_browser'&&f.qaBrowser){
|
|
134
165
|
send(response(row,f.qaBrowser(row.payload)));
|
|
135
166
|
}else if(row.kind==='documentation_inspect'){
|
|
@@ -153,8 +184,8 @@ export function runCli(f,mode,action='create'){
|
|
|
153
184
|
}catch(error){fail(error);return;}
|
|
154
185
|
}
|
|
155
186
|
});
|
|
156
|
-
child.once('close',code=>{disarm();resolve({code,stderr,rows,calls});});
|
|
157
|
-
send(f.request??request('advance'));
|
|
187
|
+
child.once('close',code=>{disarm();resolve({code,stderr,rows,calls,diagnostic:trace.snapshot()});});
|
|
188
|
+
send(f.request??{...request(f.operation??'advance'),requestId:'advance'});
|
|
158
189
|
});
|
|
159
190
|
}
|
|
160
191
|
|
|
@@ -220,7 +251,7 @@ export function protectedResultFixture(){
|
|
|
220
251
|
fs.writeFileSync(config,JSON.stringify({timeoutMs:5000,
|
|
221
252
|
checkCommands:[{id:'syntax',command:[process.execPath,'--check','target.mjs']}]}));
|
|
222
253
|
f.args.push('--protected-conversation-config',config);
|
|
223
|
-
f.env={...
|
|
254
|
+
f.env={...f.env,CM_WORKFLOW_LOG_HOME:path.join(f.root,'logs')};
|
|
224
255
|
return f;
|
|
225
256
|
}
|
|
226
257
|
export const implementedValue=()=>({outcome:'implemented',application:{status:'no_relevant_lesson',note:null},
|
|
@@ -3,15 +3,15 @@ import assert from 'node:assert/strict';
|
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import {spawnSync} from 'node:child_process';
|
|
6
|
-
import {fileURLToPath} from 'node:url';
|
|
7
6
|
import {readRunDefinition,openControlRun} from './cm-ai-run.mjs';
|
|
8
|
-
import {
|
|
7
|
+
import {checkN4} from './cm-task-gate.mjs';
|
|
8
|
+
import {cli,identity,request,fixture,runCli,installDispatchFakes,protectedResultFixture,implementedValue,lastCheckpoint,installTimeoutReviewer,syntheticReviewConfig} from './cm-ai-host-fixture.mjs';
|
|
9
9
|
|
|
10
10
|
for(const [available,coder,reviewer,runtime] of [
|
|
11
11
|
['codex','codex','codex','codex'],['codex','codex','codex','claude'],['claude','claude','claude','codex'],
|
|
12
12
|
['both','codex','claude','claude'],['both','claude','codex','codex'],
|
|
13
13
|
])test(`protected dispatch ${available}: ${runtime} host -> ${coder} coder -> ${reviewer} reviewer`,async()=>{
|
|
14
|
-
const f=fixture();
|
|
14
|
+
const f=fixture();f.operation='start';
|
|
15
15
|
try{
|
|
16
16
|
installDispatchFakes(f);
|
|
17
17
|
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.json'),JSON.stringify({version:1,runtimes:{available},
|
|
@@ -27,31 +27,27 @@ for(const [available,coder,reviewer,runtime] of [
|
|
|
27
27
|
assert(!fs.existsSync(path.join(f.codeProject,'target.mjs')));assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));
|
|
28
28
|
f.args.push('--allow-provider-development-attempt','1');
|
|
29
29
|
const first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
|
|
30
|
-
assert.equal(first.rows.find(row=>row.requestId==='advance').result.code,
|
|
30
|
+
assert.equal(first.rows.find(row=>row.requestId==='advance').result.code,null,JSON.stringify(first.diagnostic));assert.deepEqual(first.calls,[]);
|
|
31
31
|
assert.equal(fs.readFileSync(path.join(f.codeProject,'target.mjs'),'utf8'),'export const value = 42;\n');
|
|
32
32
|
const readRoutes=()=>fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse)
|
|
33
33
|
.filter(row=>row.phase==='route'&&row.event==='decision');
|
|
34
34
|
assert.equal(readRoutes().filter(row=>row.role==='coder'&&row.route_state===(coder===runtime?'current-runtime':'cli-dispatch')).length,1);
|
|
35
35
|
assert.equal(readRoutes().filter(row=>row.role==='reviewer').length,0);
|
|
36
|
-
f.
|
|
37
|
-
const wrong=await runCli(f,'normal','resume');assert.equal(wrong.rows.find(row=>row.requestId==='advance').result.code,'decision_required');
|
|
38
|
-
assert.equal(readRoutes().filter(row=>row.role==='reviewer').length,0);
|
|
39
|
-
f.args[f.args.length-1]='1';
|
|
36
|
+
f.operation='advance';
|
|
40
37
|
const reviewed=await runCli(f,'normal','resume');assert.equal(reviewed.code,0,reviewed.stderr);
|
|
41
38
|
assert.equal(reviewed.rows.find(row=>row.requestId==='advance').result.state,'fixture_completed',JSON.stringify(reviewed.rows));
|
|
42
39
|
const route=readRoutes().find(row=>row.role==='reviewer');assert(route);
|
|
43
40
|
assert.equal(route.adapter,`${reviewer}-cli`);assert.equal(route.route_state,reviewer===runtime?'current-runtime':'cli-dispatch');
|
|
44
41
|
const receipt=fs.readFileSync(path.join(f.specsDir,'.reviews','work-T-001-r1.md'),'utf8');
|
|
45
42
|
assert.match(receipt,new RegExp(`reviewer: ${reviewer}-cli`));assert.match(receipt,/independent: true/);
|
|
46
|
-
const gate=
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
assert.equal(gate.status,0,gate.stderr);assert.equal(JSON.parse(gate.stdout).content_bound,true);
|
|
43
|
+
const gate=checkN4({handoff:path.join(f.specsDir,'.reviews','work-T-001-a1-handoff.json'),
|
|
44
|
+
reviewsDir:path.join(f.specsDir,'.reviews'),feature:'work',task:'T-001',projectRoot:f.codeProject});
|
|
45
|
+
assert.equal(gate.content_bound,true);
|
|
50
46
|
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
51
47
|
});
|
|
52
48
|
|
|
53
|
-
for(const available of ['unknown','codex'])test(`legacy protected ${available} run
|
|
54
|
-
const f=fixture();
|
|
49
|
+
for(const available of ['unknown','codex'])test(`legacy protected ${available} run refuses the retired CLI assembly without changing its recorded contexts`,async()=>{
|
|
50
|
+
const f=fixture();f.operation='start';
|
|
55
51
|
try{
|
|
56
52
|
installDispatchFakes(f);
|
|
57
53
|
const projectConfig=path.join(f.codeProject,'.cm-workflow.json');
|
|
@@ -69,39 +65,45 @@ for(const available of ['unknown','codex'])test(`legacy protected ${available} r
|
|
|
69
65
|
fs.writeFileSync(initializer,`
|
|
70
66
|
import fs from 'node:fs';
|
|
71
67
|
import {readRunDefinition,createCodexExecution,openControlRun} from ${JSON.stringify(new URL('./cm-ai-run.mjs',import.meta.url).href)};
|
|
72
|
-
import {createHostReviewAuthority} from ${JSON.stringify(new URL('../runtime/js/cm-ai/host-review-authority.mjs',import.meta.url).href)};
|
|
73
68
|
const definition=readRunDefinition(${JSON.stringify(f.config)}),review=JSON.parse(fs.readFileSync(${JSON.stringify(reviewFile)}));
|
|
74
69
|
const config=JSON.parse(fs.readFileSync(${JSON.stringify(protectedFile)}));
|
|
75
|
-
|
|
70
|
+
|
|
76
71
|
const execution=await createCodexExecution({codeProject:definition.codeProject,specsRoot:definition.specsDir,
|
|
77
72
|
developerModel:config.model,checkCommands:config.checkCommands,timeoutMs:config.timeoutMs,
|
|
78
73
|
hostContextId:'native-host-fixture',developerContextId:'cm-protected-author',reviewerModel:review.model,
|
|
79
74
|
reviewerPreflight:review.preflight,disabledSkills:review.disabledSkills},
|
|
80
|
-
{
|
|
75
|
+
{developmentAttempt:1,
|
|
81
76
|
authorizeDevelopment:()=>({status:'approved'})});
|
|
82
77
|
const run=await openControlRun(definition,'create',execution);
|
|
83
|
-
try{console.log(JSON.stringify(await run.host.handle(${JSON.stringify(request('
|
|
78
|
+
try{console.log(JSON.stringify(await run.host.handle(${JSON.stringify(request('start'))})));}finally{run.close();}
|
|
84
79
|
`);
|
|
85
80
|
const old=spawnSync(process.execPath,[initializer],{encoding:'utf8',env:f.env,timeout:10000});
|
|
86
|
-
assert.equal(old.status,0,old.stderr);assert.equal(JSON.parse(old.stdout).code,
|
|
87
|
-
f.args.push('--protected-config',protectedFile,'--allow-provider-development-attempt','1','--review-config',reviewFile
|
|
81
|
+
assert.equal(old.status,0,old.stderr);assert.equal(JSON.parse(old.stdout).code,null);
|
|
82
|
+
f.args.push('--protected-config',protectedFile,'--allow-provider-development-attempt','1','--review-config',reviewFile);
|
|
88
83
|
// A changed two-provider declaration cannot recover through Codex-only compatibility.
|
|
89
84
|
fs.writeFileSync(projectConfig,JSON.stringify({version:1,runtimes:{available:'both'},
|
|
90
85
|
roles:{coder:{adapter:'claude-cli'},reviewer:{adapter:'codex-cli'}}}));
|
|
91
86
|
const mismatch=await runCli(f,'normal','resume');assert.equal(mismatch.code,1);assert.match(mismatch.stderr,/fingerprint_mismatch/);
|
|
92
87
|
assert(!fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[x]'));
|
|
93
88
|
fs.writeFileSync(projectConfig,JSON.stringify(declaration));
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
89
|
+
// Runtime routing now determines the reviewer before the exact old assembly
|
|
90
|
+
// fingerprint is checked; the diagnostic preflight must match that route.
|
|
91
|
+
fs.writeFileSync(reviewFile,JSON.stringify(syntheticReviewConfig(f.codeProject,available==='unknown'?'claude':'codex')));
|
|
92
|
+
const stateFile=path.join(f.specsDir,'.reviews','.execution',identity.runId,'state.json');
|
|
93
|
+
const before=fs.readFileSync(stateFile);
|
|
94
|
+
const resumed=await runCli(f,'normal','resume');assert.equal(resumed.code,1,resumed.stderr);
|
|
95
|
+
assert.match(resumed.stderr,/fingerprint_mismatch/);
|
|
96
|
+
assert.match(resumed.stderr,/旧 createCodexExecution.*停用/);
|
|
97
|
+
assert.match(resumed.stderr,/inspect-history --config/);
|
|
98
|
+
assert.deepEqual(resumed.calls,[]);assert.equal(resumed.rows.some(row=>row.type==='host_ready'),false);
|
|
99
|
+
assert.deepEqual(fs.readFileSync(stateFile),before);
|
|
100
|
+
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[ ] T-001'));
|
|
99
101
|
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
100
102
|
});
|
|
101
103
|
|
|
102
104
|
|
|
103
105
|
test('protected local invalid_result writes nothing and corrected CLI resume keeps run and attempt',async()=>{
|
|
104
|
-
const f=protectedResultFixture()
|
|
106
|
+
const f=protectedResultFixture();f.operation='start';const target=path.join(f.codeProject,'target.mjs');
|
|
105
107
|
try{
|
|
106
108
|
f.develop=payload=>{
|
|
107
109
|
assert.equal(payload.editMode,'protected-text-v1');assert.equal(payload.expected['target.mjs'],null);
|
|
@@ -122,16 +124,16 @@ test('protected local invalid_result writes nothing and corrected CLI resume kee
|
|
|
122
124
|
edits:[{path:'target.mjs',beforeSha256:payload.expected['target.mjs'],content:'export const value = 42;\n'}]});
|
|
123
125
|
const resumed=await runCli(f,'normal','resume');assert.equal(resumed.code,0,resumed.stderr);
|
|
124
126
|
const result=resumed.rows.find(row=>row.requestId==='advance').result;
|
|
125
|
-
assert.equal(result.state,'awaiting_review');assert.equal(result.code,
|
|
127
|
+
assert.equal(result.state,'awaiting_review');assert.equal(result.code,null);
|
|
126
128
|
assert.deepEqual(result.identity,identity);assert.equal(fs.readFileSync(target,'utf8'),'export const value = 42;\n');
|
|
127
129
|
assert.deepEqual(lastCheckpoint(f).calls.map(call=>call.terminal),[...Array(7).fill('failed'),'succeeded']);
|
|
128
130
|
const reopened=await runCli(f,'normal','resume');assert.equal(reopened.code,0,reopened.stderr);
|
|
129
|
-
assert.deepEqual(reopened.calls,[]);assert.equal(reopened.rows.find(row=>row.requestId==='advance').result.code,
|
|
131
|
+
assert.deepEqual(reopened.calls,[]);assert.equal(reopened.rows.find(row=>row.requestId==='advance').result.code,null);
|
|
130
132
|
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
131
133
|
});
|
|
132
134
|
|
|
133
135
|
for(const matches of [true,false])test(`protected old proposal compares exact output with expected disk hashes: matches=${matches}`,async()=>{
|
|
134
|
-
const f=protectedResultFixture()
|
|
136
|
+
const f=protectedResultFixture();f.operation='start';const target=path.join(f.codeProject,'target.mjs');
|
|
135
137
|
try{
|
|
136
138
|
// Simulate a proposal already applied before this invocation was rejected.
|
|
137
139
|
const content='export const value = 42;\n';
|
|
@@ -146,7 +148,7 @@ for(const matches of [true,false])test(`protected old proposal compares exact ou
|
|
|
146
148
|
const run=await runCli(f,'normal','resume');assert.equal(run.code,0,run.stderr);
|
|
147
149
|
const result=run.rows.find(row=>row.requestId==='advance').result;
|
|
148
150
|
assert.equal(result.state,matches?'awaiting_review':'blocked');
|
|
149
|
-
assert.equal(result.code,matches?
|
|
151
|
+
assert.equal(result.code,matches?null:'protected_edit_stale');
|
|
150
152
|
assert.deepEqual(fs.readFileSync(target),before);
|
|
151
153
|
const resumed=await runCli(f,'normal','resume');assert.equal(resumed.code,0,resumed.stderr);
|
|
152
154
|
assert.deepEqual(resumed.calls,[]);
|
|
@@ -196,7 +198,7 @@ test(`protected conversation review timeout ${runtime} -> ${second}`,async()=>{
|
|
|
196
198
|
const review=JSON.parse(preview.stdout);assert.equal(review.timeoutMs,900000);
|
|
197
199
|
delete review.timeoutMs;
|
|
198
200
|
const config=path.join(f.root,'review.json');fs.writeFileSync(config,JSON.stringify(review));
|
|
199
|
-
f.args.push('--review-config',config
|
|
201
|
+
f.args.push('--review-config',config);f.operation='advance';
|
|
200
202
|
f.develop=payload=>({status:'succeeded',value:implementedValue(),
|
|
201
203
|
edits:[{path:'target.mjs',beforeSha256:payload.expected['target.mjs'],content:'export const value = 42;\n'}]});
|
|
202
204
|
setMode(second==='result'?'result':'timeout');
|
|
@@ -236,8 +238,8 @@ test(`protected conversation review timeout ${runtime} -> ${second}`,async()=>{
|
|
|
236
238
|
assert.equal(end.state,second==='approved'?'fixture_completed':'blocked');
|
|
237
239
|
assert.equal(end.code,second==='approved'?'qa_decision_required':'review_transport_timeout');
|
|
238
240
|
assert.equal(after.cache.find(entry=>entry.effect.id==='review-1-retry-1').effect.identity.attempt,1);
|
|
239
|
-
assert.notEqual(after.reviewInvocation.registration.
|
|
240
|
-
assert.notEqual(after.reviewInvocation.registration.
|
|
241
|
+
assert.notEqual(after.reviewInvocation.registration.binding.invocationId,original.registration.binding.invocationId);
|
|
242
|
+
assert.notEqual(after.reviewInvocation.registration.binding.requestDigest,original.registration.binding.requestDigest);
|
|
241
243
|
assert.notEqual(after.reviewInvocation.started,original.started);
|
|
242
244
|
assert.deepEqual(after.calls.slice(0,before.calls.length),before.calls);
|
|
243
245
|
assert.deepEqual(after.cache.slice(0,before.cache.length),before.cache);
|