@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
|
@@ -24,15 +24,14 @@ async function fixture(value,provider,fn){
|
|
|
24
24
|
const adapter=createDeveloperRun({provider,requestedModel:'fixture',worker:async()=>{
|
|
25
25
|
dispatched++;return {status:'succeeded',value};
|
|
26
26
|
}});
|
|
27
|
-
const execution={configuration:{kind:'blocked-fixture-v1'},timeoutMs:3000,excludedContexts:['host'],
|
|
28
|
-
hostDecision:{status:'approved'},applicableAgentFiles:[],qaLogHome:path.join(root,'logs'),
|
|
27
|
+
const execution={configuration:{kind:'blocked-fixture-v1'},timeoutMs:3000,excludedContexts:['host'],applicableAgentFiles:[],qaLogHome:path.join(root,'logs'),
|
|
29
28
|
developer:{provider,requestedModel:'fixture',contextId:'author',run:async(r,c)=>{
|
|
30
29
|
request=r;terminal=await adapter(r,c);return terminal;
|
|
31
30
|
}},
|
|
32
31
|
check:()=>assert.fail('blocked must not run checks'),
|
|
33
32
|
reviewers:[{id:'reviewer',adapterId:'codex-review-adapter',provider:'codex',requestedModel:'fixture',
|
|
34
33
|
allowed:true,available:true,contexts:['review-1','review-2'],run:()=>assert.fail('blocked must not run review')}],
|
|
35
|
-
reviewInvocation:{developerThreadId:'author',excludedThreadIds:['host']
|
|
34
|
+
reviewInvocation:{developerThreadId:'author',excludedThreadIds:['host']},
|
|
36
35
|
};
|
|
37
36
|
const statePath=path.join(specsDir,'.reviews','.execution',identity.runId,'state.json');
|
|
38
37
|
const read=()=>JSON.parse(fs.readFileSync(statePath,'utf8'));
|
|
@@ -10,6 +10,7 @@ import {spawnSync} from 'node:child_process';
|
|
|
10
10
|
import {fileURLToPath} from 'node:url';
|
|
11
11
|
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
12
12
|
import {loadConfig} from './cm-workflow-config.mjs';
|
|
13
|
+
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
13
14
|
|
|
14
15
|
const isolatedHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-capability-home-'));
|
|
15
16
|
process.env.CM_WORKFLOW_HOME=path.join(isolatedHome,'user');
|
|
@@ -42,7 +43,8 @@ function fixture(browserCase,{blocking=true,tests=['logic','commands','browser']
|
|
|
42
43
|
qa:{commands:[{id:'unit',command:[process.execPath,'--version'],caseIds:browserCase?[]:['TC-001']}],
|
|
43
44
|
environment:{kind:'web',carrier:'browser',target:'https://example.invalid/fixture',scope:'local'}}}));
|
|
44
45
|
// create requires a bound review configuration; this one grants no review attempt.
|
|
45
|
-
const review=path.join(root,'placeholder-review.json');fs.writeFileSync(review,JSON.stringify({model:'fixture',preflight:{
|
|
46
|
+
const review=path.join(root,'placeholder-review.json');fs.writeFileSync(review,JSON.stringify({model:'fixture',preflight:{passed:true,cli_model:'fixture',prompt_transport:'stdin',
|
|
47
|
+
config_fingerprint:configFingerprint({cwd:codeProject,model:'fixture'})}}));
|
|
46
48
|
return {root,specsDir,codeProject,config,workflow,
|
|
47
49
|
args:['serve','--config',config,'--mode','create','--host-context','gate-fixture','--allow-development',
|
|
48
50
|
'--workflow-config',workflow,'--allow-qa','--review-config',review]};
|
|
@@ -196,3 +198,33 @@ test('declaring browser tests requires the role that serves them',()=>{
|
|
|
196
198
|
assert.deepEqual(loadConfig({projectRoot:root}).policies.tests,['logic']);
|
|
197
199
|
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
198
200
|
});
|
|
201
|
+
|
|
202
|
+
for(const batch of [false,true])test(`v2 ${batch?'batch':'single'} inactive QA does not require browser capability`,()=>{
|
|
203
|
+
for(const qa of ['disabled','run'])for(const declaration of [null,'unavailable']){
|
|
204
|
+
const f=batch?batchFixture({}):fixture(true);
|
|
205
|
+
try{
|
|
206
|
+
const control=path.join(f.root,'control.json');
|
|
207
|
+
fs.writeFileSync(control,JSON.stringify({version:2,development:'conversation',bootstrap:'disabled',qa,qaFix:'disabled'}));
|
|
208
|
+
const review=path.join(f.root,'placeholder-review.json');
|
|
209
|
+
fs.writeFileSync(review,JSON.stringify({model:'fixture',preflight:{passed:true,cli_model:'fixture',
|
|
210
|
+
prompt_transport:'stdin',config_fingerprint:configFingerprint({cwd:f.codeProject,model:'fixture'})}}));
|
|
211
|
+
if(batch)for(const args of [['init','-b','main'],['config','user.name','Fixture'],['config','user.email','fixture@example.invalid'],['add','-A'],['commit','-m','baseline']]){
|
|
212
|
+
const result=spawnSync('git',['-C',f.codeProject,...args],{encoding:'utf8'});assert.equal(result.status,0,result.stderr);
|
|
213
|
+
}
|
|
214
|
+
const args=['serve','--config',f.config,...(batch?[]:['--mode','create']),'--host-context','gate-v2',
|
|
215
|
+
'--control-config',control,'--review-config',review,...(batch?[]:['--workflow-config',f.workflow]),
|
|
216
|
+
...(declaration?['--browser-qa',declaration]:[])];
|
|
217
|
+
const request={version:2,operation:'status',requestId:'v2-status',...(batch?{}:{identity})};
|
|
218
|
+
const result=spawnSync(process.execPath,[batch?batchCli:cli,...args],{encoding:'utf8',timeout:20000,
|
|
219
|
+
input:JSON.stringify(request)+'\n',env:{...process.env,NODE_NO_WARNINGS:'1'}});
|
|
220
|
+
if(qa==='run')rejected(result,declaration?'browser_capability_unavailable':'browser_capability_required');
|
|
221
|
+
else if(declaration)rejected(result,'invalid_arguments');
|
|
222
|
+
else{
|
|
223
|
+
assert.equal(result.error,undefined);assert.equal(result.status,0,result.stderr);
|
|
224
|
+
const rows=result.stdout.trim().split('\n').map(JSON.parse);assert.equal(rows[0].type,'host_ready');
|
|
225
|
+
const response=rows.find(row=>row.requestId==='v2-status');assert.ok(response,result.stdout);
|
|
226
|
+
assert.notEqual(response.result.outcome,'rejected',result.stdout);assert.ok(response.result.state,result.stdout);
|
|
227
|
+
}
|
|
228
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
export const CHECK_DRIVE_COPIED_FILES=Object.freeze([
|
|
4
4
|
'scripts/cm-check-entry.mjs','scripts/cm-check-host.mjs','scripts/cm-check-drive.mjs',
|
|
5
5
|
'scripts/cm-workflow-config.mjs','runtime/js/cm-check/host.mjs','runtime/js/cm-ai/drive-core.mjs',
|
|
6
|
-
'runtime/js/cm-ai/operator-guidance.mjs','runtime/js/cm-ai/
|
|
6
|
+
'runtime/js/cm-ai/operator-guidance.mjs','runtime/js/cm-ai/host-stage-observer.mjs',
|
|
7
7
|
'runtime/js/cm-ai/host-tool-bridge.mjs','runtime/js/cm-ai/host-session.mjs','runtime/js/cm-ai/diagnostic-reason.mjs','runtime/js/cm-ai/effect-contract.mjs',
|
|
8
8
|
'runtime/js/cm-ai/contracts.mjs','runtime/js/cm-init/draft-inspection.mjs','skills/cm-check/SKILL.md']);
|
|
@@ -19,7 +19,7 @@ function fixture(t,exitCode=0){
|
|
|
19
19
|
const dir=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-check-host-'))),project=path.join(dir,'project');fs.mkdirSync(project);
|
|
20
20
|
t.after(()=>fs.rmSync(dir,{recursive:true,force:true}));
|
|
21
21
|
for(const file of ['scripts/cm-check-entry.mjs','scripts/cm-check-host.mjs','scripts/cm-workflow-config.mjs','runtime/js/cm-check/host.mjs',
|
|
22
|
-
'runtime/js/cm-ai/host-tool-bridge.mjs','runtime/js/cm-ai/host-session.mjs','runtime/js/cm-ai/diagnostic-reason.mjs','runtime/js/cm-ai/effect-contract.mjs',
|
|
22
|
+
'runtime/js/cm-ai/host-stage-observer.mjs','runtime/js/cm-ai/host-tool-bridge.mjs','runtime/js/cm-ai/host-session.mjs','runtime/js/cm-ai/diagnostic-reason.mjs','runtime/js/cm-ai/effect-contract.mjs',
|
|
23
23
|
'runtime/js/cm-ai/contracts.mjs','runtime/js/cm-init/draft-inspection.mjs','skills/cm-check/SKILL.md']){
|
|
24
24
|
fs.mkdirSync(path.dirname(path.join(dir,file)),{recursive:true});fs.copyFileSync(path.join(root,file),path.join(dir,file));
|
|
25
25
|
}
|
|
@@ -284,7 +284,7 @@ for module in \
|
|
|
284
284
|
durable-runner-state.mjs effect-contract.mjs execution-store.mjs gate-bridge.mjs \
|
|
285
285
|
host.mjs host-session.mjs diagnostic-reason.mjs index.mjs provider-review-observation.mjs review-package.mjs \
|
|
286
286
|
review-result.schema.json review-runner.mjs task-commit-codec.mjs task-commit.mjs \
|
|
287
|
-
task-owner.mjs task-runner.mjs worker-codex.mjs operator-guidance.mjs
|
|
287
|
+
task-owner.mjs task-runner.mjs worker-codex.mjs operator-guidance.mjs; do
|
|
288
288
|
require_file "runtime/js/cm-ai/$module"
|
|
289
289
|
done
|
|
290
290
|
require_file "scripts/cm-check-runtime.ps1"
|
|
@@ -12,6 +12,32 @@ import {ownerGuardSource} from './fixtures/process-cleanup.mjs';
|
|
|
12
12
|
import {previewClaudeTools,claudeProbeSandbox,createClaudeModelMarkerDetector} from '../runtime/js/cm-ai/claude-tool-preview.mjs';
|
|
13
13
|
import {previewPromptTransport,writePreviewPrompt} from '../runtime/js/cm-ai/tool-preview.mjs';
|
|
14
14
|
|
|
15
|
+
for(const sendMessage of [true,false])test(`UI invalidation before init ${sendMessage?'permits a validated POST':'cannot make startup-only preflight pass'}`,
|
|
16
|
+
{skip:process.platform!=='darwin'},async()=>{
|
|
17
|
+
// Emit the real CLI ordering before POST. Existing HTTP-first fixtures cannot
|
|
18
|
+
// detect a worker that kills the child while decoding its startup notice.
|
|
19
|
+
const source=`let input='';process.stdin.on('data',s=>input+=s);process.stdin.on('end',async()=>{
|
|
20
|
+
await fetch(process.env.ANTHROPIC_BASE_URL+'/api/hello',{method:'HEAD'});
|
|
21
|
+
console.log(JSON.stringify({type:'system',subtype:'ui_invalidate',session_id:'probe-ui'}));
|
|
22
|
+
console.log(JSON.stringify({type:'system',subtype:'init',session_id:'probe-ui'}));
|
|
23
|
+
await new Promise(resolve=>setTimeout(resolve,100));
|
|
24
|
+
if(${sendMessage}){
|
|
25
|
+
await fetch(process.env.ANTHROPIC_BASE_URL+'/v1/messages',{method:'POST',
|
|
26
|
+
headers:{'x-api-key':'cm-synthetic-local-probe'},
|
|
27
|
+
body:JSON.stringify({model:'fixture',messages:[{role:'user',content:input}],tools:[]})});
|
|
28
|
+
}
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});`;
|
|
31
|
+
const {preflight}=await previewClaudeTools({cwd:process.cwd(),model:'fixture',
|
|
32
|
+
spawnProcess:(command,args,options)=>spawn(command,[...args.slice(0,2),process.execPath,'-e',source],options)});
|
|
33
|
+
assert.equal(preflight.passed,sendMessage);
|
|
34
|
+
assert.equal(preflight.message_requests,sendMessage?1:0);
|
|
35
|
+
assert.equal(preflight.local_requests,sendMessage?2:1);
|
|
36
|
+
assert.equal(preflight.stopped_by_probe,sendMessage);
|
|
37
|
+
assert.equal(preflight.listener_closed,true);
|
|
38
|
+
if(sendMessage)assert.equal(preflight.request_checks[1].synthetic_auth,true);
|
|
39
|
+
});
|
|
40
|
+
|
|
15
41
|
test('tool preview argument transport preserves a long Unicode argv prompt without stdin',()=>{
|
|
16
42
|
const prompt='参数\n🚀'+'界'.repeat(10000);
|
|
17
43
|
const transport=previewPromptTransport('argument',prompt);
|
|
@@ -9,6 +9,42 @@ const transcript = () => [
|
|
|
9
9
|
{type:'result', subtype:'success', session_id:'fresh-review', is_error:false,
|
|
10
10
|
num_turns:1, structured_output:{verdict:'approved'}},
|
|
11
11
|
];
|
|
12
|
+
const uiInvalidate = (over={}) => ({type:'system',subtype:'ui_invalidate',session_id:'fresh-review',...over});
|
|
13
|
+
test('UI invalidation before and after init is body-free and leaves review events unchanged',()=>{
|
|
14
|
+
const baseline=observe(transcript()),[init,...tail]=transcript();
|
|
15
|
+
for(const messages of [[uiInvalidate(),init,...tail],[init,uiInvalidate(),...tail],
|
|
16
|
+
[uiInvalidate({payload:{text:'do not forward'},structured_output:{verdict:'approved'}}),init,...tail]]){
|
|
17
|
+
const actual=observe(messages);
|
|
18
|
+
assert.deepEqual(actual.result,baseline.result);assert.deepEqual(actual.events,baseline.events);
|
|
19
|
+
assert.deepEqual(actual.notices,[{kind:'claude_system_notice',subtype:'ui_invalidate'}]);
|
|
20
|
+
}
|
|
21
|
+
const events=[],stream=createClaudeReviewStream(e=>events.push(e));stream.accept(uiInvalidate());
|
|
22
|
+
assert.deepEqual(events,[]);assert.throws(()=>stream.finish(),{code:'incomplete_result'});
|
|
23
|
+
});
|
|
24
|
+
test('UI invalidation preserves session, initialization and terminal boundaries',()=>{
|
|
25
|
+
const [init,text,result]=transcript();
|
|
26
|
+
for(const notice of [uiInvalidate({session_id:''}),uiInvalidate({session_id:null}),uiInvalidate({session_id:'x'.repeat(257)})])
|
|
27
|
+
assert.throws(()=>decode([notice,init,text,result]),{code:'invalid_session'});
|
|
28
|
+
assert.throws(()=>decode([uiInvalidate(),{...init,session_id:'other'}]),{code:'session_mismatch'});
|
|
29
|
+
assert.throws(()=>decode([init,uiInvalidate({session_id:'other'}),text,result]),{code:'session_mismatch'});
|
|
30
|
+
assert.throws(()=>decode([uiInvalidate(),text,result]),{code:'missing_init'});
|
|
31
|
+
assert.throws(()=>decode([init,uiInvalidate(),result]),{code:'unexpected_result'});
|
|
32
|
+
assert.throws(()=>decode([init,text,result,uiInvalidate()]),{code:'unexpected_event'});
|
|
33
|
+
assert.throws(()=>decode([uiInvalidate({subtype:'future_ui'}),init,text,result]),{code:'missing_init'});
|
|
34
|
+
});
|
|
35
|
+
test('UI invalidation shares the existing 32 notice slots across init',()=>{
|
|
36
|
+
const [init,...tail]=transcript(),dev={type:'system',subtype:'dev_intent',session_id:'fresh-review'};
|
|
37
|
+
const before=Array.from({length:16},(_,i)=>i%2?dev:uiInvalidate());
|
|
38
|
+
const after=Array.from({length:16},()=>uiInvalidate());
|
|
39
|
+
const actual=observe([...before,init,...after,...tail]);assert.equal(actual.notices.length,32);
|
|
40
|
+
assert.deepEqual(actual.events,observe(transcript()).events);
|
|
41
|
+
for(const callback of [null,()=>{throw Error('notice callback');}]){
|
|
42
|
+
const stream=createClaudeReviewStream(()=>{},callback);
|
|
43
|
+
[...before,init,...after].forEach(m=>stream.accept(m));
|
|
44
|
+
assert.throws(()=>stream.accept(uiInvalidate()),{code:'unexpected_event'});
|
|
45
|
+
assert.throws(()=>stream.finish(),{code:'incomplete_result'});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
12
48
|
test('Claude result maps to original observer syntax, never invents process close', () => {
|
|
13
49
|
const events=[], stream=createClaudeReviewStream(event=>events.push(event));
|
|
14
50
|
transcript().forEach(message=>stream.accept(message));
|
|
@@ -75,6 +75,22 @@ async function runMessages(wireMessages,onNotice){
|
|
|
75
75
|
{signal:new AbortController().signal,onEvent:e=>events.push(e)});
|
|
76
76
|
return {result,events};
|
|
77
77
|
}
|
|
78
|
+
test('UI invalidation prefix does not stop the Claude reviewer before init',async()=>{
|
|
79
|
+
const notices=[],notice={type:'system',subtype:'ui_invalidate',session_id:'fresh-review',payload:{text:'not forwarded'}};
|
|
80
|
+
const actual=await runMessages([notice,...messages],n=>notices.push(n));
|
|
81
|
+
assert.deepEqual(actual,await runMessages(messages));
|
|
82
|
+
assert.deepEqual(notices,[{kind:'claude_system_notice',subtype:'ui_invalidate'}]);
|
|
83
|
+
});
|
|
84
|
+
test('UI invalidation without init or with a different session never produces review success',async()=>{
|
|
85
|
+
const notice={type:'system',subtype:'ui_invalidate',session_id:'fresh-review'};
|
|
86
|
+
for(const [wire,code] of [[[notice],'incomplete_result'],[[notice,{...messages[0],session_id:'other'}],'session_mismatch'],
|
|
87
|
+
[[notice,...messages.slice(1)],'missing_init']]){
|
|
88
|
+
const actual=await runMessages(wire);
|
|
89
|
+
assert.deepEqual(actual.result,{status:'failed',code});
|
|
90
|
+
assert(!actual.events.some(e=>e.event==='turn.completed'));
|
|
91
|
+
assert.equal(actual.events.at(-1).event,'process_closed');
|
|
92
|
+
}
|
|
93
|
+
});
|
|
78
94
|
test('worker accepts 88 and 4096 thinking heartbeats but rejects 4097 without completion',async()=>{
|
|
79
95
|
const baseline=await runMessages(messages);
|
|
80
96
|
for(const count of [88,4096,4097]){
|
|
@@ -169,7 +185,9 @@ test('timeout kills inherited-pipe descendants, including TERM-ignoring children
|
|
|
169
185
|
let descendant,leader;
|
|
170
186
|
// Both guards watch this test process, never the leader, so a missed group kill still shows.
|
|
171
187
|
const hung=ownerGuardSource()+"process.on('SIGTERM',()=>{});setInterval(()=>{},1000)";
|
|
172
|
-
|
|
188
|
+
// 1.5 s leaves a loaded CI runner time to start the leader and report the
|
|
189
|
+
// descendant pid before the timeout fires; the assertions below scale with it.
|
|
190
|
+
const worker=claudeWorker({...config,preflight:receipt,timeoutMs:1500,
|
|
173
191
|
spawnProcess:(_cli,_args,options)=>{
|
|
174
192
|
const child=spawn(process.execPath,['-e',
|
|
175
193
|
`${ownerGuardSource()}const {spawn}=require('node:child_process');const c=spawn(process.execPath,['-e',
|
|
@@ -181,8 +199,8 @@ test('timeout kills inherited-pipe descendants, including TERM-ignoring children
|
|
|
181
199
|
try {
|
|
182
200
|
const started=Date.now();
|
|
183
201
|
const result=await worker({prompt:'synthetic'}, {signal:new AbortController().signal,onEvent:()=>{}});
|
|
184
|
-
assert.equal(result.code,'timeout');assert.ok(Date.now()-started<
|
|
185
|
-
assert.ok(Date.now()-started>=
|
|
202
|
+
assert.equal(result.code,'timeout');assert.ok(Date.now()-started<8000);
|
|
203
|
+
assert.ok(Date.now()-started>=2400,'leader close must not cancel group escalation');
|
|
186
204
|
assert.ok(Number.isInteger(descendant));
|
|
187
205
|
const gone=()=>{try{process.kill(descendant,0);return false;}catch(error){return error.code==='ESRCH';}};
|
|
188
206
|
for(const deadline=Date.now()+3000;!gone()&&Date.now()<deadline;)await new Promise(resolve=>setTimeout(resolve,25));
|