@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
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {readDecision,recordCmAiQaDecision,findCmAiQaDecision} from '../runtime/js/cm-ai/cm-ai-qa-log.mjs';
|
|
7
|
+
const identity={repositoryId:'fixture',runId:'fixed-log',taskId:'T-001',attempt:1},packageDigest='a'.repeat(64);
|
|
8
|
+
const decision=(status,score,reason)=>({decisionId:'qa-fixed',identity,packageDigest,status,score,reason,at:'2026-10-12T00:00:00Z'});
|
|
9
|
+
test('N6 decision accepts null scores for every status and preserves legacy thresholds',()=>{
|
|
10
|
+
for(const [status,reason] of [['skipped','no_fixed_trigger'],['skipped','merged_to_feature_qa'],['triggered','payment,api'],['blocked','host_request_timeout']])
|
|
11
|
+
assert.equal(readDecision(decision(status,null,reason),identity,packageDigest).score,null);
|
|
12
|
+
for(const [status,score] of [['skipped',4],['skipped',7],['triggered',8],['triggered',20],['blocked',4],['blocked',20]])
|
|
13
|
+
assert.equal(readDecision(decision(status,score,'historical'),identity,packageDigest).score,score);
|
|
14
|
+
});
|
|
15
|
+
test('N6 legacy decision rejects illegal non-null scores including coercible values',()=>{
|
|
16
|
+
for(const status of ['skipped','triggered','blocked'])for(const score of [undefined,'4','8',false,true,{},[],3,21,4.5])
|
|
17
|
+
assert.throws(()=>readDecision(decision(status,score,'historical'),identity,packageDigest),`${status}/${JSON.stringify(score)}`);
|
|
18
|
+
for(const [status,score] of [['skipped',8],['triggered',7]])
|
|
19
|
+
assert.throws(()=>readDecision(decision(status,score,'historical'),identity,packageDigest));
|
|
20
|
+
});
|
|
21
|
+
test('N6 null skip logs reason and changed file source, keeps old bytes and merge event',()=>{
|
|
22
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-fixed-log-')));
|
|
23
|
+
try{
|
|
24
|
+
const specsDir=path.join(root,'specs'),codeProject=path.join(root,'code');fs.mkdirSync(specsDir);fs.mkdirSync(codeProject);
|
|
25
|
+
const log=path.join(specsDir,'运行日志.jsonl'),old='{"historical":"byte exact"}\n';fs.writeFileSync(log,old);
|
|
26
|
+
const binding={specsDir,codeProject,feature:'1.work',identity,packageDigest,logHome:path.join(root,'logs')};
|
|
27
|
+
const value={...decision('skipped',null,'no_fixed_trigger'),changedFilesSource:'handoff_only'};
|
|
28
|
+
recordCmAiQaDecision({...binding,decision:value});
|
|
29
|
+
recordCmAiQaDecision({...binding,decision:value});
|
|
30
|
+
assert(fs.readFileSync(log,'utf8').startsWith(old));
|
|
31
|
+
const row=fs.readFileSync(log,'utf8').trim().split('\n').map(JSON.parse).at(-1);
|
|
32
|
+
assert.equal(row.detail,'跳过:no_fixed_trigger');assert.equal(row.changed_files_source,'handoff_only');assert.equal(row.score,null);
|
|
33
|
+
const {codeProject:_,logHome:__,...query}=binding;
|
|
34
|
+
assert.equal(findCmAiQaDecision(query).changedFilesSource,'handoff_only');
|
|
35
|
+
const merged={...binding,identity:{...identity,runId:'fixed-merge'},decision:{...decision('skipped',null,'merged_to_feature_qa'),identity:{...identity,runId:'fixed-merge'}}};
|
|
36
|
+
recordCmAiQaDecision(merged);
|
|
37
|
+
const rows=fs.readFileSync(log,'utf8').trim().split('\n').map(JSON.parse);
|
|
38
|
+
assert.equal(rows.filter(row=>row.phase==='qa_merge').length,1);
|
|
39
|
+
assert.equal(rows.at(-1).reason,'merged_to_feature_qa');
|
|
40
|
+
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
41
|
+
});
|
|
@@ -78,3 +78,10 @@ test('a single recovery flag with --allow-qa passes the launch guards', () => ba
|
|
|
78
78
|
assert.equal(line(withFlag),line(without));
|
|
79
79
|
assert.equal(withFlag.status,without.status);
|
|
80
80
|
}));
|
|
81
|
+
|
|
82
|
+
test('N6 QA critical paths accept grouped relative globs and reject malformed registration',()=>{
|
|
83
|
+
const criticalPaths={migration:['db/migrations/**'],authentication:['src/login.mjs'],authorization:['src/access/*.mjs'],payment:['src/payment?.mjs'],api:['src/api/**']};
|
|
84
|
+
assert.deepEqual(validateHostWorkflowConfiguration({...workflow(undefined),qa:{...qa(undefined),criticalPaths}}).qa.criticalPaths,criticalPaths);
|
|
85
|
+
for(const value of [null,[],{unknown:['src/**']},{api:'src/**'},{api:['../src/**']},{api:['src/{a,b}.mjs']}])
|
|
86
|
+
assert.throws(()=>validateHostWorkflowConfiguration({...workflow(undefined),qa:{...qa(undefined),criticalPaths:value}}));
|
|
87
|
+
});
|
|
@@ -29,8 +29,7 @@ const POSIX={skip:process.platform==='win32'?'host-check QA commands and the fix
|
|
|
29
29
|
const identity={repositoryId:'qa-rerun-fixture',runId:'qa-rerun-run',taskId:'T-001',attempt:1};
|
|
30
30
|
const simulator={kind:'app',carrier:'ios-simulator',target:'Fixture-iPhone',scope:'local'};
|
|
31
31
|
const service={kind:'service',carrier:'cli',target:'node',scope:'local'};
|
|
32
|
-
const lowRisk={
|
|
33
|
-
changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}};
|
|
32
|
+
const lowRisk={confirmed:true};
|
|
34
33
|
|
|
35
34
|
// The QA command stands in for xcodebuild/simulator scripts. It reads a mode
|
|
36
35
|
// file outside both roots, so switching the "environment" never touches the
|
|
@@ -115,7 +114,7 @@ function failingStartShim(f){
|
|
|
115
114
|
function launch(f,{mode='resume',operation='advance',workflow=null,extra=[],answers={},review=true,pathPrefix=null}={}){
|
|
116
115
|
return new Promise((resolve,reject)=>{
|
|
117
116
|
const args=['serve','--config',f.config,'--mode',mode,'--host-context','session-A','--allow-development',
|
|
118
|
-
'--review-config',f.reviewFile,...(review?[
|
|
117
|
+
'--review-config',f.reviewFile,...(review?[]:[]),
|
|
119
118
|
...(workflow?['--workflow-config',workflow,'--allow-qa']:[]),...extra];
|
|
120
119
|
const env=pathPrefix?{...f.env,PATH:pathPrefix+path.delimiter+f.env.PATH}:f.env;
|
|
121
120
|
const child=spawn(process.execPath,[cli,...args],{env,stdio:['pipe','pipe','pipe']});
|
|
@@ -305,7 +304,7 @@ test('#26 a wrong QA workflow config is revised before any QA round, without con
|
|
|
305
304
|
const f=fixture(t);
|
|
306
305
|
const wrong=f.workflow('workflow-old',{commands:[{id:'probe',command:[process.execPath,'-e','process.exit(3)'],caseIds:[]}],environment:service});
|
|
307
306
|
const fixed=f.workflow('workflow-new',probeQa());
|
|
308
|
-
const waiting=done(await launch(f,{mode:'create',workflow:wrong,
|
|
307
|
+
const waiting=done(await launch(f,{mode:'create',workflow:wrong,operation:'start'}));
|
|
309
308
|
assert.equal(waiting.state,'awaiting_review',JSON.stringify(waiting));
|
|
310
309
|
const before=f.journal();
|
|
311
310
|
const drift=await launch(f,{workflow:fixed,review:false});
|
|
@@ -9,7 +9,7 @@ import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
|
9
9
|
import {openTaskExecutionStore} from '../runtime/js/cm-ai/task-owner.mjs';
|
|
10
10
|
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
11
11
|
import {createCmAiTaskLearningApplication,createCmAiTaskLearningRetrospective} from '../runtime/js/cm-ai/cm-ai-context-refresh.mjs';
|
|
12
|
-
import {writeHandoff} from '
|
|
12
|
+
import {writeHandoff} from './fixtures/native-gate-fixture.mjs';
|
|
13
13
|
|
|
14
14
|
const identity={repositoryId:'fixture',runId:'review-drift',taskId:'T-001',attempt:1};
|
|
15
15
|
const terminal=(request,result)=>({version:1,invocationId:request.invocationId,
|
|
@@ -117,9 +117,9 @@ function fixture(t,{reviewTimeoutMs=null}={}){
|
|
|
117
117
|
const records=()=>JSON.parse(fs.readFileSync(store,'utf8')).records;
|
|
118
118
|
const replay=()=>{const rows=records();return readRunnerHistory(rows,rows[0].payload.config,3);};
|
|
119
119
|
const calls=()=>fs.existsSync(callsFile)?fs.readFileSync(callsFile,'utf8').trim().split('\n').map(line=>JSON.parse(line)):[];
|
|
120
|
-
const review=(attempt=1)=>['--review-config','review.json'
|
|
120
|
+
const review=(attempt=1)=>['--review-config','review.json'];
|
|
121
121
|
const awaitingReview=()=>{
|
|
122
|
-
const first=drive(plan(),'
|
|
122
|
+
const first=drive(plan(),'start');assert.equal(first.status,0,first.stderr);
|
|
123
123
|
assert.equal(first.result.state,'awaiting_review');return first.result.packageDigest;
|
|
124
124
|
};
|
|
125
125
|
const decide=(packageDigest,attempt=1)=>drive(plan({mode:'resume',permissions:review(attempt),packageDigest,answers:undefined,checks:undefined}),'decision');
|
|
@@ -198,15 +198,15 @@ test(`#8 ${error==='authentication_failed'?'real Claude CLI':'in-process Claude
|
|
|
198
198
|
assert.deepEqual(result.observation.events.map(event=>event.event),['thread.started','turn.started','process_closed']);
|
|
199
199
|
const history=f.replay();assert.equal(history.state.state,'pending_review');assert.equal(history.state.code,'review_provider_failed');
|
|
200
200
|
if(error!=='authentication_failed')return;
|
|
201
|
-
// After logging in, the same attempt is reviewed once more with a
|
|
201
|
+
// After logging in, the same attempt is reviewed once more with a fresh invocation binding.
|
|
202
202
|
f.behave({mode:'ok'});
|
|
203
203
|
const approved=f.decide(packageDigest);
|
|
204
204
|
assert.equal(approved.status,0,approved.stderr);assert.equal(approved.result.state,'approved');
|
|
205
205
|
assert.deepEqual(f.intents(),['develop-1','review-1','review-1-retry-1']);
|
|
206
206
|
const registrations=f.records().filter(row=>row.payload.type==='review-invocation-registered');
|
|
207
207
|
assert.equal(registrations.length,2);
|
|
208
|
-
assert.notEqual(registrations[0].payload.
|
|
209
|
-
assert.notEqual(registrations[0].payload.
|
|
208
|
+
assert.notEqual(registrations[0].payload.binding.invocationId,registrations[1].payload.binding.invocationId);
|
|
209
|
+
assert.notEqual(registrations[0].payload.binding.requestDigest,registrations[1].payload.binding.requestDigest);
|
|
210
210
|
assert.equal(f.replay().state.state,'approved');assert.equal(f.calls().length,2);
|
|
211
211
|
});
|
|
212
212
|
|
|
@@ -409,13 +409,7 @@ test('#8 legacy unknown results replay unchanged and forged failed results are r
|
|
|
409
409
|
// Runner-level fixture: the real V3 task runner and execution store with
|
|
410
410
|
// synthetic developer/reviewer adapters, for bounds the driver cannot reach fast.
|
|
411
411
|
const checksPassed=[{id:'check',command:['synthetic'],outcome:'passed',exitCode:0,evidence:'fixture'}];
|
|
412
|
-
|
|
413
|
-
const body={version:1,kind:'cm-review-dispatch-grant',grantId:`grant-${request.invocationId}`,adapterId:`${request.provider}-review-adapter`,
|
|
414
|
-
invocationId:request.invocationId,requestDigest:request.requestDigest,identity:request.identity,
|
|
415
|
-
reviewerId:'reviewer',logicalContextId:request.contextId,packageDigest:request.payload.reviewPackage.packageDigest,
|
|
416
|
-
hostContextId:'actual-main',decisionId:'decision-1',decision:'approved',issuedAt:authorizationAt,expiresAt:authorizationAt+60000};
|
|
417
|
-
return {...body,grantDigest:digest(body)};
|
|
418
|
-
};
|
|
412
|
+
|
|
419
413
|
const reviewEvents=(onEvent,request,{result=true,close=true}={})=>{
|
|
420
414
|
onEvent({event:'thread.started',provider_thread:`thread-${request.invocationId}`});
|
|
421
415
|
onEvent({event:'turn.started',item_type:null});
|
|
@@ -448,7 +442,6 @@ async function runnerFixture(t,fn,{timeoutMs=1000,reviewTimeoutMs,reviewerProvid
|
|
|
448
442
|
check:request=>checks(request),
|
|
449
443
|
taskCompletion:{reviewsDir,handoffs:[path.join(reviewsDir,'a1.json'),path.join(reviewsDir,'a2.json')]},
|
|
450
444
|
reviewInvocation:{developerThreadId:'actual-developer',excludedThreadIds:['actual-main'],
|
|
451
|
-
authorize:(request,{authorizationAt})=>grantFor(request,authorizationAt),
|
|
452
445
|
...(reviewTimeoutMs===undefined?{}:{timeoutMs:reviewTimeoutMs})}};
|
|
453
446
|
const make=(mode,extra={})=>createTaskRunner({...options,reviewInvocation:{...options.reviewInvocation,...extra},persistence:{store,mode,version:3}});
|
|
454
447
|
const reopen=(extra={})=>{store.close();store=openTaskExecutionStore({...owner,create:false});return make('resume',extra);};
|
|
@@ -499,7 +492,8 @@ test('#20 the conversation factory sizes the review race above the reviewer budg
|
|
|
499
492
|
const codeProject=path.join(root,'code'),specsDir=path.join(root,'specs');fs.mkdirSync(codeProject);fs.mkdirSync(specsDir);
|
|
500
493
|
const definition={codeProject,specsDir,feature:'1.work',identity,scope:['code.js'],requirements:[]};
|
|
501
494
|
const bridge={call:()=>assert.fail('no host call expected')};
|
|
502
|
-
const preflight={passed:true,provider:'claude',prompt_transport:'stdin',
|
|
495
|
+
const preflight={passed:true,provider:'claude',prompt_transport:'stdin',
|
|
496
|
+
config_fingerprint:claudeReviewFingerprint({cwd:codeProject,model:'fixture'})};
|
|
503
497
|
return import('../runtime/js/cm-ai/host-conversation-execution.mjs').then(({createConversationExecution,REVIEW_BOUND_MARGIN_MS})=>{
|
|
504
498
|
for(const [reviewTimeout,expected] of [[3000000,3000000+REVIEW_BOUND_MARGIN_MS],[3600000,3660000],[null,1800000],[60000,1800000]]){
|
|
505
499
|
const review={model:'fixture',disabledSkills:[],preflight,...(reviewTimeout===null?{}:{timeoutMs:reviewTimeout})};
|
|
@@ -522,7 +516,7 @@ test('#20 the real host passes the raised review bound from review-config into t
|
|
|
522
516
|
const definition=readRunDefinition(path.join(f.root,'run.json'));
|
|
523
517
|
const review=readConversationReviewConfiguration(path.join(f.root,'review.json'));
|
|
524
518
|
const execution=createConversationExecution(definition,'review-host-a',{call:()=>assert.fail('no host call expected')},
|
|
525
|
-
review,
|
|
519
|
+
review,null,null,false,'claude');
|
|
526
520
|
const run=await openControlRun(definition,'resume',execution);
|
|
527
521
|
t.after(()=>run.close());
|
|
528
522
|
const delays=[],originalTimer=globalThis.setTimeout;
|
|
@@ -899,7 +893,7 @@ test('an approved run already holding all six effects (old grammar) completes (r
|
|
|
899
893
|
for(let round=1;round<=4;round++)
|
|
900
894
|
assert.equal(run('advance',round===1?{mode:'create',originalHostContext:undefined}:{}).result.code,'develop_checks_not_passed');
|
|
901
895
|
fs.writeFileSync(marker,'pass\n');
|
|
902
|
-
const delivered=run('
|
|
896
|
+
const delivered=run('start');assert.equal(delivered.result.state,'awaiting_review',JSON.stringify(delivered.result));
|
|
903
897
|
const packageDigest=delivered.result.packageDigest;
|
|
904
898
|
assert.equal(run('decision',{permissions:f.review(1),packageDigest}).result.state,'approved');
|
|
905
899
|
const {completedEffectCount,effectSlotFree}=await import('../runtime/js/cm-ai/durable-runner-state.mjs');
|
|
@@ -947,7 +941,7 @@ function completionFixture(t){
|
|
|
947
941
|
}
|
|
948
942
|
test('repeated completion re-check blocks stop at completion_retry_limit instead of an uncompletable approval (real host)',t=>{
|
|
949
943
|
const f=completionFixture(t);f.pass(true);
|
|
950
|
-
const delivered=f.run('
|
|
944
|
+
const delivered=f.run('start',{mode:'create'});
|
|
951
945
|
assert.equal(delivered.status,0,delivered.stderr);assert.equal(delivered.result.state,'awaiting_review');
|
|
952
946
|
const packageDigest=delivered.result.packageDigest;
|
|
953
947
|
assert.equal(f.run('decision',{review:true,packageDigest}).result.state,'approved');
|
|
@@ -980,7 +974,7 @@ test('completion re-checks no longer eat the six effects: develop blocks plus re
|
|
|
980
974
|
const f=completionFixture(t);f.pass(false);
|
|
981
975
|
for(const mode of ['create','resume'])assert.equal(f.run('advance',{mode}).result.code,'develop_checks_not_passed');
|
|
982
976
|
f.pass(true);
|
|
983
|
-
const delivered=f.run('
|
|
977
|
+
const delivered=f.run('start');assert.equal(delivered.result.state,'awaiting_review');
|
|
984
978
|
const packageDigest=delivered.result.packageDigest;
|
|
985
979
|
assert.equal(f.run('decision',{review:true,packageDigest}).result.state,'approved');
|
|
986
980
|
// Four effects held; three re-check blocks would previously have used the rest.
|
|
@@ -994,7 +988,7 @@ test('completion re-checks no longer eat the six effects: develop blocks plus re
|
|
|
994
988
|
|
|
995
989
|
test('#retry-limit replay accepts the completion limit only once the re-check bound is spent',t=>{
|
|
996
990
|
const f=completionFixture(t);f.pass(true);
|
|
997
|
-
const packageDigest=f.run('
|
|
991
|
+
const packageDigest=f.run('start',{mode:'create'}).result.packageDigest;
|
|
998
992
|
f.run('decision',{review:true,packageDigest});f.pass(false);
|
|
999
993
|
for(let block=1;block<=4;block++)f.run('complete',{packageDigest});
|
|
1000
994
|
const records=f.records(),configuration=records[0].payload.config;
|
|
@@ -5,6 +5,7 @@ import path from 'node:path';
|
|
|
5
5
|
import test from 'node:test';
|
|
6
6
|
|
|
7
7
|
import {readConversationReviewConfiguration,formatClaudeModelHint} from './cm-ai-host.mjs';
|
|
8
|
+
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
8
9
|
import {createConversationExecution,resolveReviewTimeout} from '../runtime/js/cm-ai/host-conversation-execution.mjs';
|
|
9
10
|
|
|
10
11
|
const preflight={passed:true,provider:'claude',prompt_transport:'stdin',config_fingerprint:'x'};
|
|
@@ -68,7 +69,8 @@ test('review timeout changes do not alter the authorized execution configuration
|
|
|
68
69
|
const definition={codeProject,specsDir,feature:'1.work',identity:{repositoryId:'fixture',runId:'run',taskId:'T-001',attempt:1},
|
|
69
70
|
scope:['code.js'],requirements:[]};
|
|
70
71
|
const bridge={call:()=>assert.fail('no host call expected')};
|
|
71
|
-
const review={model:'fixture',disabledSkills:[],preflight
|
|
72
|
+
const review={model:'fixture',disabledSkills:[],preflight:{passed:true,cli_model:'fixture',prompt_transport:'stdin',
|
|
73
|
+
config_fingerprint:configFingerprint({cwd:codeProject,model:'fixture'})}};
|
|
72
74
|
const earlier=createConversationExecution(definition,'host-fixture',bridge,{...review,timeoutMs:60000});
|
|
73
75
|
const later=createConversationExecution(definition,'host-fixture',bridge,{...review,timeoutMs:900000});
|
|
74
76
|
assert.deepEqual(earlier.configuration,later.configuration);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {withHostStageObserver} from '../runtime/js/cm-ai/host-stage-observer.mjs';
|
|
1
2
|
import test from 'node:test';
|
|
2
3
|
import assert from 'node:assert/strict';
|
|
3
4
|
import fs from 'node:fs';
|
|
@@ -17,13 +18,6 @@ import {recordReviewAbandonment} from '../runtime/js/cm-ai/review-abandon-log.mj
|
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
const checks=[{id:'check',command:['synthetic'],outcome:'passed',exitCode:0,evidence:'fixture'}];
|
|
20
|
-
const grantFor=(request,authorizationAt,change=grant=>grant)=>{
|
|
21
|
-
const body={version:1,kind:'cm-review-dispatch-grant',grantId:`grant-${request.invocationId}`,adapterId:`${request.provider}-review-adapter`,
|
|
22
|
-
invocationId:request.invocationId,requestDigest:request.requestDigest,identity:request.identity,
|
|
23
|
-
reviewerId:'reviewer',logicalContextId:request.contextId,packageDigest:request.payload.reviewPackage.packageDigest,
|
|
24
|
-
hostContextId:'actual-main',decisionId:'decision-1',decision:'approved',issuedAt:authorizationAt,expiresAt:authorizationAt+60000};
|
|
25
|
-
change(body);return {...body,grantDigest:digest(body)};
|
|
26
|
-
};
|
|
27
21
|
const events=(onEvent,thread='actual-review')=>{
|
|
28
22
|
onEvent({event:'thread.started',provider_thread:thread});
|
|
29
23
|
onEvent({event:'turn.started',item_type:null});
|
|
@@ -32,7 +26,7 @@ const events=(onEvent,thread='actual-review')=>{
|
|
|
32
26
|
onEvent({event:'process_closed',exit_code:0,signal:null,timed_out:false});
|
|
33
27
|
};
|
|
34
28
|
|
|
35
|
-
async function fixture(fn,{reviewRun,
|
|
29
|
+
async function fixture(fn,{reviewRun,times,timeoutMs=1000,provider='codex'}={}) {
|
|
36
30
|
const temp=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-review-v3-')));
|
|
37
31
|
const root=path.join(temp,'code'),specsRoot=path.join(temp,'specs'),reviewsDir=path.join(specsRoot,'.reviews');
|
|
38
32
|
fs.mkdirSync(root);fs.mkdirSync(reviewsDir,{recursive:true});
|
|
@@ -56,8 +50,7 @@ async function fixture(fn,{reviewRun,authorize,times,timeoutMs=1000,provider='co
|
|
|
56
50
|
dispatches++;lateEvent=control.onEvent;return (reviewRun??defaultRun)(request,control);
|
|
57
51
|
}}],check:()=>checks,
|
|
58
52
|
taskCompletion:{reviewsDir,handoffs:[path.join(reviewsDir,'a1.json'),path.join(reviewsDir,'a2.json')]},
|
|
59
|
-
reviewInvocation:{developerThreadId:'actual-developer',excludedThreadIds:['actual-main']
|
|
60
|
-
authorize:authorize??((request,{authorizationAt})=>grantFor(request,authorizationAt))}};
|
|
53
|
+
reviewInvocation:{developerThreadId:'actual-developer',excludedThreadIds:['actual-main']}};
|
|
61
54
|
const make=mode=>{
|
|
62
55
|
const old=Date.now,values=times?[...times]:null;if(values)Date.now=()=>values.length>1?values.shift():values[0];
|
|
63
56
|
try{return createTaskRunner({...options,persistence:{store,mode,version:3}});}finally{Date.now=old;}
|
|
@@ -85,106 +78,6 @@ const timeoutRun=(request,{onEvent})=>{
|
|
|
85
78
|
};
|
|
86
79
|
const retryEffect=(f,attempt=1)=>({...f.effect('review',attempt),id:`review-${attempt}-retry-1`});
|
|
87
80
|
|
|
88
|
-
test('V3 expired dispatch grant is journaled as grant_expired without adapter dispatch',()=>fixture(async f=>{
|
|
89
|
-
const runner=f.make();await runner.executeEffect(f.effect('develop'));
|
|
90
|
-
const end=await runner.executeEffect(f.effect('review'));
|
|
91
|
-
assert.equal(end.state,'pending_review');assert.equal(end.code,'grant_expired');assert.equal(f.dispatches(),0);
|
|
92
|
-
assert.equal(end.reviewInvocation.result.outcome,'not_dispatched');
|
|
93
|
-
assert.equal(end.reviewInvocation.result.reason,'grant_expired');
|
|
94
|
-
assert.equal(end.reviewInvocation.result.dispatchAt,200);
|
|
95
|
-
assert.equal(end.reviewInvocation.registration.grant.expiresAt,150);
|
|
96
|
-
assert.equal(end.calls.at(-1).terminal,'not_dispatched');assert.equal(end.receipt,null);
|
|
97
|
-
const saved=f.getStore().snapshot();
|
|
98
|
-
assert.equal(readRunnerHistory(saved.records,saved.records[0].payload.config,3).state.code,'grant_expired');
|
|
99
|
-
assert.deepEqual(saved.records.slice(-3).map(record=>record.payload.type),
|
|
100
|
-
['review-invocation-registered','review-invocation-result','effect-checkpoint']);
|
|
101
|
-
assert.deepEqual(f.reopen().status(),end);
|
|
102
|
-
},{times:[100,101,200],authorize:(request,{authorizationAt})=>grantFor(request,authorizationAt,grant=>{grant.expiresAt=150;})}));
|
|
103
|
-
|
|
104
|
-
// Batch 4 review round 1: a registered review that was never dispatched (expired
|
|
105
|
-
// grant) left the run at pending_review/grant_expired with no usable exit. No
|
|
106
|
-
// reviewer ran, so the round redispatches under a fresh grant (new effect id), the
|
|
107
|
-
// not-dispatched effect holds no call or effect slot, and the journal replays.
|
|
108
|
-
test('a never-dispatched review (grant_expired) redispatches in its own run under a fresh grant and replays',()=>{
|
|
109
|
-
let expired=true;
|
|
110
|
-
return fixture(async f=>{
|
|
111
|
-
const runner=f.make();await runner.executeEffect(f.effect('develop'));
|
|
112
|
-
const end=await runner.executeEffect(f.effect('review'));
|
|
113
|
-
assert.deepEqual([end.state,end.code,f.dispatches()],['pending_review','grant_expired',0]);
|
|
114
|
-
assert.equal(end.calls.at(-1).terminal,'not_dispatched');assert.equal(end.calls.at(-1).started,false);
|
|
115
|
-
const saved=f.getStore().snapshot(),history=readRunnerHistory(saved.records,saved.records[0].payload.config,3);
|
|
116
|
-
assert.equal(completedEffectCount(history.state.cache,history.state.calls),1,'the never-dispatched review holds no effect slot');
|
|
117
|
-
// The cached effect id still replays the not-dispatched result unchanged.
|
|
118
|
-
const resumed=f.reopen();assert.deepEqual(await resumed.executeEffect(f.effect('review')),end);assert.equal(f.dispatches(),0);
|
|
119
|
-
expired=false;
|
|
120
|
-
const approved=await resumed.executeEffect({...f.effect('review'),id:'review-1-retry-1'});
|
|
121
|
-
assert.equal(approved.state,'approved',JSON.stringify(approved));assert.equal(f.dispatches(),1);
|
|
122
|
-
assert.equal(approved.calls.filter(call=>call.terminal==='not_dispatched').length,1);
|
|
123
|
-
assert.deepEqual(f.reopen().status(),approved);
|
|
124
|
-
},{times:[100,101,200],authorize:(request,{authorizationAt})=>grantFor(request,authorizationAt,grant=>{if(expired)grant.expiresAt=150;})});
|
|
125
|
-
});
|
|
126
|
-
// Batch 4 review round 2: never-dispatched redispatches hold no call or effect slot
|
|
127
|
-
// but have their own bound, two per review round. The third not-dispatched end is an
|
|
128
|
-
// explicit limit block; live status and the replayed projection read the same count.
|
|
129
|
-
test('never-dispatched review redispatches stop at review_not_dispatched_limit after two, identically live and replayed',()=>{
|
|
130
|
-
let expiring=3;
|
|
131
|
-
return fixture(async f=>{
|
|
132
|
-
const runner=f.make();await runner.executeEffect(f.effect('develop'));
|
|
133
|
-
let end=await runner.executeEffect(f.effect('review'));expiring--;
|
|
134
|
-
assert.deepEqual([end.state,end.code],['pending_review','grant_expired']);
|
|
135
|
-
for(const retry of [1,2]){
|
|
136
|
-
const next=f.reopen();
|
|
137
|
-
// Still redispatchable: same review round, no call or effect slot spent.
|
|
138
|
-
end=await next.executeEffect({...f.effect('review'),id:`review-1-retry-${retry}`});expiring--;
|
|
139
|
-
if(retry===1)assert.deepEqual([end.state,end.code],['pending_review','grant_expired']);
|
|
140
|
-
}
|
|
141
|
-
assert.equal(f.dispatches(),0);
|
|
142
|
-
assert.equal(end.state,'blocked');assert.equal(end.code,'review_not_dispatched_limit');
|
|
143
|
-
assert.match(end.reason,/^review_not_dispatched_limit: .*3 次.*派发前作废/);
|
|
144
|
-
const saved=f.getStore().snapshot(),config=saved.records[0].payload.config,history=readRunnerHistory(saved.records,config,3);
|
|
145
|
-
assert.deepEqual([history.state.state,history.state.code],['pending_review','grant_expired']);
|
|
146
|
-
assert.equal(completedEffectCount(history.state.cache,history.state.calls),1);
|
|
147
|
-
const projected=projectedRunnerStatus(history,config);
|
|
148
|
-
assert.deepEqual([projected.state,projected.code,projected.reason],[end.state,end.code,end.reason]);
|
|
149
|
-
// Replay applies the same stop: a journal carrying a fourth review intent is refused.
|
|
150
|
-
const intent=saved.records.findLast(record=>record.kind==='intent'&&record.payload.effect?.id==='review-1-retry-2');
|
|
151
|
-
assert(intent,'retry-2 intent');
|
|
152
|
-
const {digest:ignored,...body}=JSON.parse(JSON.stringify(intent).replaceAll('review-1-retry-2','review-1-retry-3'));
|
|
153
|
-
const last=saved.records.at(-1),forged={...body,seq:last.seq+1,id:`runner.${String(saved.records.length+1).padStart(6,'0')}`,previousDigest:last.digest};
|
|
154
|
-
assert.throws(()=>readRunnerHistory([...saved.records,{...forged,digest:digest(forged)}],config,3),{code:'runner_stage'});
|
|
155
|
-
const reopened=f.reopen();assert.deepEqual(reopened.status(),end);
|
|
156
|
-
// No fourth registration, even with a grant that would dispatch.
|
|
157
|
-
const refused=await reopened.executeEffect({...f.effect('review'),id:'review-1-retry-3'});
|
|
158
|
-
assert.deepEqual([refused.outcome,refused.code],['rejected','review_not_dispatched_limit']);
|
|
159
|
-
assert.equal(f.getStore().snapshot().records.length,saved.records.length);assert.equal(f.dispatches(),0);
|
|
160
|
-
},{times:[100,101,200],authorize:(request,{authorizationAt})=>grantFor(request,authorizationAt,grant=>{if(expiring>0)grant.expiresAt=150;})});
|
|
161
|
-
});
|
|
162
|
-
// The bound counts not-dispatched ends only: two of them, then a dispatched review, is approved.
|
|
163
|
-
test('a review dispatched on the second never-dispatched redispatch is accepted',()=>{
|
|
164
|
-
let expiring=2;
|
|
165
|
-
return fixture(async f=>{
|
|
166
|
-
const runner=f.make();await runner.executeEffect(f.effect('develop'));
|
|
167
|
-
await runner.executeEffect(f.effect('review'));expiring--;
|
|
168
|
-
await f.reopen().executeEffect({...f.effect('review'),id:'review-1-retry-1'});expiring--;
|
|
169
|
-
const approved=await f.reopen().executeEffect({...f.effect('review'),id:'review-1-retry-2'});
|
|
170
|
-
assert.equal(approved.state,'approved',JSON.stringify(approved));assert.equal(f.dispatches(),1);
|
|
171
|
-
assert.deepEqual(f.reopen().status(),approved);
|
|
172
|
-
},{times:[100,101,200],authorize:(request,{authorizationAt})=>grantFor(request,authorizationAt,grant=>{if(expiring>0)grant.expiresAt=150;})});
|
|
173
|
-
});
|
|
174
|
-
test('V3 non-monotonic dispatch clock is journaled as clock_invalid without adapter dispatch',()=>fixture(async f=>{
|
|
175
|
-
const runner=f.make();await runner.executeEffect(f.effect('develop'));
|
|
176
|
-
const end=await runner.executeEffect(f.effect('review'));
|
|
177
|
-
assert.equal(end.state,'pending_review');assert.equal(end.code,'clock_invalid');assert.equal(f.dispatches(),0);
|
|
178
|
-
assert.equal(end.reviewInvocation.result.outcome,'not_dispatched');
|
|
179
|
-
assert.equal(end.reviewInvocation.result.reason,'clock_invalid');
|
|
180
|
-
assert.equal(end.reviewInvocation.result.dispatchAt,99);
|
|
181
|
-
assert.equal(end.reviewInvocation.registration.registeredAt,101);
|
|
182
|
-
assert.equal(end.calls.at(-1).terminal,'not_dispatched');assert.equal(end.receipt,null);
|
|
183
|
-
const saved=f.getStore().snapshot();
|
|
184
|
-
assert.equal(readRunnerHistory(saved.records,saved.records[0].payload.config,3).state.code,'clock_invalid');
|
|
185
|
-
assert.deepEqual(f.reopen().status(),end);
|
|
186
|
-
},{times:[100,101,99]}));
|
|
187
|
-
|
|
188
81
|
test('runner timer without a result shares pending/blocked timeout transitions and replay',()=>fixture(async f=>{
|
|
189
82
|
const runner=f.make();await runner.executeEffect(f.effect('develop'));
|
|
190
83
|
const end=await runner.executeEffect(f.effect('review'));
|
|
@@ -221,7 +114,7 @@ test('runner timer without a result shares pending/blocked timeout transitions a
|
|
|
221
114
|
onEvent({event:'thread.started',provider_thread:`thread-${request.invocationId}`});return new Promise(()=>{});
|
|
222
115
|
}}));
|
|
223
116
|
|
|
224
|
-
test('each attempt gets one retry without consuming the six-effect budget or reusing
|
|
117
|
+
test('each attempt gets one retry without consuming the six-effect budget or reusing bindings',()=>fixture(async f=>{
|
|
225
118
|
const attempts=new Map();
|
|
226
119
|
f.options.reviewers[0].run=(request,control)=>{
|
|
227
120
|
const attempt=request.identity.attempt,count=(attempts.get(attempt)??0)+1;attempts.set(attempt,count);
|
|
@@ -238,8 +131,8 @@ test('each attempt gets one retry without consuming the six-effect budget or reu
|
|
|
238
131
|
runner=f.reopen();assert.deepEqual(runner.status(),first);
|
|
239
132
|
const second=await runner.executeEffect(retryEffect(f,attempt));
|
|
240
133
|
assert.equal(second.state,attempt===1?'changes_requested':'approved');
|
|
241
|
-
assert.notEqual(first.reviewInvocation.registration.
|
|
242
|
-
assert.notEqual(first.reviewInvocation.registration.
|
|
134
|
+
assert.notEqual(first.reviewInvocation.registration.binding.invocationId,second.reviewInvocation.registration.binding.invocationId);
|
|
135
|
+
assert.notEqual(first.reviewInvocation.registration.binding.requestDigest,second.reviewInvocation.registration.binding.requestDigest);
|
|
243
136
|
runner=f.reopen();assert.deepEqual(runner.status(),second);
|
|
244
137
|
}
|
|
245
138
|
const records=f.getStore().snapshot().records,history=readRunnerHistory(records,records[0].payload.config,3);
|
|
@@ -271,10 +164,10 @@ test('interrupted V3 review needs explicit abandonment and replays the audited e
|
|
|
271
164
|
const next=f.reopen();
|
|
272
165
|
const result=await next.executeEffect(retryEffect(f));
|
|
273
166
|
assert.equal(result.state,'approved');
|
|
274
|
-
assert.notEqual(result.reviewInvocation.registration.
|
|
275
|
-
abandoned.reviewInvocation.registration.
|
|
276
|
-
assert.notEqual(result.reviewInvocation.registration.
|
|
277
|
-
abandoned.reviewInvocation.registration.
|
|
167
|
+
assert.notEqual(result.reviewInvocation.registration.binding.invocationId,
|
|
168
|
+
abandoned.reviewInvocation.registration.binding.invocationId);
|
|
169
|
+
assert.notEqual(result.reviewInvocation.registration.binding.requestDigest,
|
|
170
|
+
abandoned.reviewInvocation.registration.binding.requestDigest);
|
|
278
171
|
}));
|
|
279
172
|
|
|
280
173
|
test('registered review without a started record can also be abandoned',()=>fixture(async f=>{
|
|
@@ -342,7 +235,7 @@ test('conversation reports unknown cancel truthfully, then consumes abandonment
|
|
|
342
235
|
assert.equal((await noFlag.handle(request('abandon_review',{reason:'old process exited'}))).outcome,'rejected');
|
|
343
236
|
assert.deepEqual(f.getStore().snapshot(),before);
|
|
344
237
|
const entry=createCmAiConversationEntry({specsDir:path.dirname(f.tasksPath),codeProject:f.root,
|
|
345
|
-
feature:'feature',identity:f.options.identity,runner,allowAbandonReview:true
|
|
238
|
+
feature:'feature',identity:f.options.identity,runner,allowAbandonReview:true});
|
|
346
239
|
const cancelled=await entry.handle(request('cancel'));
|
|
347
240
|
assert.equal(cancelled.outcome,'reported');assert.equal(cancelled.state,'unknown');
|
|
348
241
|
assert.equal(cancelled.pendingAction,'abandon_review');
|
|
@@ -502,7 +395,7 @@ test(`factory passes exact configured timeout to ${runtime} reviewer, provider m
|
|
|
502
395
|
const review={model:'fixture',disabledSkills:[],preflight:{passed:true,provider:runtime,cli_model:'fixture',
|
|
503
396
|
prompt_transport:'stdin',config_fingerprint:(runtime==='codex'?configFingerprint:claudeReviewFingerprint)(workerOptions)}};
|
|
504
397
|
const timeoutMs=providerMode?6789:5123;
|
|
505
|
-
const execution=createConversationExecution(definition,'host-test',{call:()=>assert.fail('unexpected host call')},review,
|
|
398
|
+
const execution=createConversationExecution(definition,'host-test',{call:()=>assert.fail('unexpected host call')},review,null,null,false,runtime,
|
|
506
399
|
{protection:{checkCommands:[{id:'syntax',command:[process.execPath,'--version']}],timeoutMs},
|
|
507
400
|
...(providerMode?{providerDevelopment:{model:'fixture',attempt:1,coderRuntime:runtime,reviewerRuntime:runtime}}:{})});
|
|
508
401
|
const timers=[],originalTimer=globalThis.setTimeout;
|
|
@@ -526,21 +419,16 @@ test(`factory passes exact configured timeout to ${runtime} reviewer, provider m
|
|
|
526
419
|
}finally{t.mock.restoreAll();syncBuiltinESMExports();}
|
|
527
420
|
}));
|
|
528
421
|
|
|
529
|
-
for(const boundary of ['
|
|
422
|
+
for(const boundary of ['package-drift','cancelled'])
|
|
530
423
|
test(`retry preserves original authorization/package/cancellation boundary: ${boundary}`,()=>fixture(async f=>{
|
|
531
|
-
if(boundary==='stale-grant'){
|
|
532
|
-
let firstGrant;
|
|
533
|
-
f.options.reviewInvocation.authorize=(request,{authorizationAt})=>firstGrant??=grantFor(request,authorizationAt);
|
|
534
|
-
}
|
|
535
424
|
let runner=f.make();await runner.executeEffect(f.effect('develop'));
|
|
536
425
|
const pending=await runner.executeEffect(f.effect('review'));assert.equal(pending.state,'pending_review');
|
|
537
426
|
if(boundary==='package-drift')fs.writeFileSync(path.join(f.root,'code.js'),'outside drift\n');
|
|
538
427
|
if(boundary==='cancelled')runner.cancel();
|
|
539
|
-
|
|
428
|
+
runner=f.reopen();
|
|
540
429
|
const result=await runner.executeEffect(retryEffect(f));
|
|
541
|
-
assert.equal(result.code,boundary==='
|
|
430
|
+
assert.equal(result.code,boundary==='package-drift'?'package_mismatch':'stage_mismatch');
|
|
542
431
|
assert.equal(f.dispatches(),1);
|
|
543
|
-
if(boundary==='stale-grant')assert.equal(f.reopen().status().state,'unknown');
|
|
544
432
|
},{reviewRun:timeoutRun}));
|
|
545
433
|
|
|
546
434
|
// V5 (A33): a reviewer whose worker proved its process gone without a final
|
|
@@ -619,7 +507,7 @@ test('review-redispatch replay refuses forged, duplicate and over-limit records'
|
|
|
619
507
|
const duplicate=structuredClone(records.slice(0,at+1));duplicate.push(structuredClone(records[at]));
|
|
620
508
|
assert.throws(()=>readRunnerHistory(resequence(duplicate),config,3),{code:'runner_review_redispatch'});
|
|
621
509
|
const third=structuredClone(records);third.push({...structuredClone(records[at]),payload:{...records[at].payload,
|
|
622
|
-
effectId:'review-1-retry-2',invocationId:readRunnerHistory(records,config,3).state.reviewInvocation.registration.
|
|
510
|
+
effectId:'review-1-retry-2',invocationId:readRunnerHistory(records,config,3).state.reviewInvocation.registration.binding.invocationId}});
|
|
623
511
|
assert.throws(()=>readRunnerHistory(resequence(third),config,3),{code:'runner_review_redispatch'});
|
|
624
512
|
// A journal without the record (older version) replays the spent block unchanged;
|
|
625
513
|
// drivers read it through the same projection the host shows.
|
|
@@ -627,3 +515,22 @@ test('review-redispatch replay refuses forged, duplicate and over-limit records'
|
|
|
627
515
|
assert.equal(projectedRunnerStatus(older,config).state,'blocked');assert.equal(projectedRunnerStatus(older,config).reviewRedispatchStopRequired,true);
|
|
628
516
|
assert.equal(projectedRunnerStatus(readRunnerHistory(records,config,3),config).code,'review_redispatch_limit');
|
|
629
517
|
},{timeoutMs:20,reviewRun:timeoutRun}));
|
|
518
|
+
|
|
519
|
+
// Transport telemetry must use the existing budgets without entering durable history.
|
|
520
|
+
test('native review telemetry reports its configured deadline and leaves original replay unchanged',()=>fixture(async f=>{
|
|
521
|
+
f.options.reviewInvocation.timeoutMs=2500;
|
|
522
|
+
const runner=f.make(),rows=[];
|
|
523
|
+
await withHostStageObserver(row=>rows.push(row),async()=>{
|
|
524
|
+
await runner.executeEffect(f.effect('develop'));
|
|
525
|
+
const result=await runner.executeEffect(f.effect('review'));
|
|
526
|
+
assert.equal(result.state,'approved');
|
|
527
|
+
});
|
|
528
|
+
const review=rows.find(row=>row?.kind==='review');assert.ok(review);
|
|
529
|
+
assert.equal(review.deadlineMs-Date.parse(review.startedAt),2500);
|
|
530
|
+
assert.ok(rows.some(row=>row?.kind==='develop'));
|
|
531
|
+
assert.ok(rows.some(row=>row?.kind==='check'));
|
|
532
|
+
const before=JSON.stringify(f.getStore().snapshot());
|
|
533
|
+
assert.doesNotMatch(before,/nativeStage|host_heartbeat|lastProgressAt|deadlineMs/);
|
|
534
|
+
const resumed=f.reopen();assert.equal(resumed.status().state,'approved');
|
|
535
|
+
assert.equal(JSON.stringify(f.getStore().snapshot()),before);
|
|
536
|
+
},{timeoutMs:5000}));
|