@aibyzero/cm-workflow 0.21.7 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +52 -0
- package/README.md +10 -1
- package/VERSION +1 -1
- package/docs/architecture.md +9 -0
- package/docs/cm-acceptance-completion.md +3 -1
- package/docs/cm-control-policy-v2.md +35 -3
- package/docs/execution-optimizations.md +1 -1
- package/docs/external-models.md +1 -0
- package/docs/human-correction.md +1 -1
- package/docs/installation.md +36 -10
- package/docs/js-workflow-control.md +65 -30
- package/docs/next-steps.md +10 -0
- package/docs/runtime-failover.md +2 -2
- package/docs/user-guide.md +1 -1
- package/package.json +1 -1
- package/runtime/js/cm-ai/batch-location.mjs +14 -0
- package/runtime/js/cm-ai/batch-plan.mjs +6 -2
- package/runtime/js/cm-ai/cm-ai-admission.mjs +9 -3
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +51 -8
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +30 -4
- package/runtime/js/cm-ai/codex-review-adapter.mjs +2 -4
- package/runtime/js/cm-ai/delivery-evidence.mjs +3 -1
- package/runtime/js/cm-ai/developer-adapter.mjs +15 -1
- package/runtime/js/cm-ai/drive-core.mjs +50 -6
- package/runtime/js/cm-ai/drive-next-step.mjs +61 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +85 -23
- package/runtime/js/cm-ai/execution-snapshot.mjs +5 -2
- package/runtime/js/cm-ai/execution-store.mjs +21 -3
- package/runtime/js/cm-ai/external-run-guard.mjs +9 -1
- package/runtime/js/cm-ai/host-check.mjs +4 -2
- package/runtime/js/cm-ai/host-conversation-execution.mjs +23 -2
- package/runtime/js/cm-ai/host-handoff.mjs +7 -0
- package/runtime/js/cm-ai/host-progress.mjs +18 -0
- package/runtime/js/cm-ai/host-qa-executor.mjs +47 -15
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +11 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +24 -14
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +1 -1
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/operator-guidance.mjs +126 -2
- package/runtime/js/cm-ai/project-qa-gate.mjs +13 -2
- package/runtime/js/cm-ai/provider-review-observation.mjs +7 -3
- package/runtime/js/cm-ai/qa-plan-notes.mjs +106 -0
- package/runtime/js/cm-ai/review-continuation.mjs +102 -0
- package/runtime/js/cm-ai/review-evidence-file.mjs +11 -0
- package/runtime/js/cm-ai/review-package.mjs +25 -4
- package/runtime/js/cm-ai/review-presentation.mjs +31 -14
- package/runtime/js/cm-ai/review-runner.mjs +5 -4
- package/runtime/js/cm-ai/review-verdict-rules.mjs +7 -0
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +30 -1
- package/runtime/js/cm-ai/task-commit-codec.mjs +11 -1
- package/runtime/js/cm-ai/task-commit.mjs +7 -4
- package/runtime/js/cm-ai/task-owner.mjs +5 -2
- package/runtime/js/cm-ai/task-runner.mjs +343 -52
- package/runtime/js/cm-fix/diagnosis.mjs +16 -3
- package/runtime/js/cm-fix/execution.mjs +47 -9
- package/runtime/js/cm-fix/finish.mjs +9 -1
- package/runtime/js/cm-fix/step-timing.mjs +222 -0
- package/runtime/js/cm-idea/session.mjs +22 -3
- package/runtime/js/cm-init/review-evidence.mjs +20 -7
- package/runtime/js/cm-prd/ai-draft.mjs +260 -0
- package/runtime/js/cm-prd/analysis.mjs +27 -9
- package/runtime/js/cm-prd/change.mjs +29 -8
- package/runtime/js/cm-prd/failed-correction.mjs +24 -4
- package/runtime/js/cm-prd/narrow-review.mjs +63 -3
- package/runtime/js/cm-prd/review-correction.mjs +65 -5
- package/runtime/js/cm-prd/review-disposition.mjs +10 -1
- package/runtime/js/cm-prd/self-check.mjs +121 -9
- package/runtime/js/cm-prd/session.mjs +55 -13
- package/runtime/js/cm-prd/summary.mjs +34 -6
- package/runtime/js/cm-prd/task-scope-record.mjs +40 -15
- package/runtime/js/cm-refactor/records.mjs +82 -11
- package/runtime/js/cm-refactor/workflow.mjs +3 -1
- package/runtime/js/executor-version.mjs +81 -0
- package/runtime/js/python-log-writer.mjs +15 -0
- package/runtime/js/run-analysis.mjs +136 -11
- package/runtime/logging.md +6 -0
- package/runtime/review.md +2 -1
- package/scripts/ci-test-weights.json +1 -0
- package/scripts/cm-ai-admission.mjs +27 -1
- package/scripts/cm-ai-admission.test.mjs +34 -2
- package/scripts/cm-ai-answer-gap-recheck.test.mjs +3 -2
- package/scripts/cm-ai-batch-drive.mjs +54 -17
- package/scripts/cm-ai-batch-drive.test.mjs +123 -6
- package/scripts/cm-ai-batch-host.mjs +55 -9
- package/scripts/cm-ai-batch-host.test.mjs +22 -3
- package/scripts/cm-ai-batch-location.test.mjs +22 -1
- package/scripts/cm-ai-batch-merge.mjs +102 -0
- package/scripts/cm-ai-batch-plan.mjs +55 -2
- package/scripts/cm-ai-batch-plan.test.mjs +228 -6
- package/scripts/cm-ai-batch-run-fixture.mjs +239 -15
- package/scripts/cm-ai-batch-run-parallel.test.mjs +23 -1
- package/scripts/cm-ai-batch-run.mjs +435 -33
- package/scripts/cm-ai-batch-session-member.test.mjs +85 -0
- package/scripts/cm-ai-check-recheck-cancellation.test.mjs +23 -2
- package/scripts/cm-ai-completion-summary.test.mjs +2 -1
- package/scripts/cm-ai-control-v2-drive.test.mjs +39 -9
- package/scripts/cm-ai-direct-review.test.mjs +1 -1
- package/scripts/cm-ai-disk-edits.test.mjs +229 -0
- package/scripts/cm-ai-drive-next-step.test.mjs +191 -0
- package/scripts/cm-ai-drive.mjs +66 -14
- package/scripts/cm-ai-drive.test.mjs +13 -3
- package/scripts/cm-ai-host-cli-workflow.test.mjs +4 -2
- package/scripts/cm-ai-host.mjs +16 -8
- package/scripts/cm-ai-host.test.mjs +12 -0
- package/scripts/cm-ai-operator-guidance.test.mjs +132 -1
- package/scripts/cm-ai-project-qa-gate.test.mjs +26 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +18 -0
- package/scripts/cm-ai-review-continuation.test.mjs +335 -0
- package/scripts/cm-ai-review-failure.test.mjs +13 -10
- package/scripts/cm-ai-review-timeout.test.mjs +1 -1
- package/scripts/cm-ai-run.mjs +42 -11
- package/scripts/cm-ai-run.test.mjs +26 -0
- package/scripts/cm-ai-supersede.test.mjs +10 -2
- package/scripts/cm-capability-gate.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +9 -0
- package/scripts/cm-codex-prompt-input.test.mjs +2 -1
- package/scripts/cm-developer-self-review.test.mjs +27 -0
- package/scripts/cm-efficiency-presentation-delta.test.mjs +4 -3
- package/scripts/cm-efficiency-response.test.mjs +2 -1
- package/scripts/cm-executor-version-draft.test.mjs +251 -0
- package/scripts/cm-executor-version-entries.test.mjs +93 -0
- package/scripts/cm-executor-version-prd.test.mjs +154 -0
- package/scripts/cm-executor-version-records.test.mjs +256 -0
- package/scripts/cm-executor-version.test.mjs +250 -0
- package/scripts/cm-external-model-host.test.mjs +6 -1
- package/scripts/cm-external-review-reconciliation.test.mjs +1 -1
- package/scripts/cm-fix-closeout-preflight.test.mjs +123 -0
- package/scripts/cm-fix-diagnosis-module-correction.test.mjs +5 -1
- package/scripts/cm-fix-drive.mjs +7 -2
- package/scripts/cm-fix-drive.test.mjs +45 -0
- package/scripts/cm-fix-entry.mjs +5 -2
- package/scripts/cm-fix-frozen-baseline.test.mjs +50 -0
- package/scripts/cm-fix-host.mjs +9 -2
- package/scripts/cm-fix-test-extension.test.mjs +30 -2
- package/scripts/cm-host-check.test.mjs +12 -0
- package/scripts/cm-host-qa-executor.test.mjs +172 -1
- package/scripts/cm-host-qa-policy.test.mjs +55 -1
- package/scripts/cm-idea-drive.mjs +5 -2
- package/scripts/cm-idea-entry.mjs +5 -2
- package/scripts/cm-idea-host.mjs +3 -1
- package/scripts/cm-init-drive.mjs +8 -5
- package/scripts/cm-init-entry.mjs +5 -2
- package/scripts/cm-init-host.mjs +6 -2
- package/scripts/cm-log-event.mjs +10 -2
- package/scripts/cm-log-event.test.mjs +29 -0
- package/scripts/cm-prd-ai-draft-fixture.mjs +18 -0
- package/scripts/cm-prd-ai-draft.test.mjs +505 -0
- package/scripts/cm-prd-answer-gaps.test.mjs +110 -5
- package/scripts/cm-prd-completion.test.mjs +67 -4
- package/scripts/cm-prd-design-phase.test.mjs +48 -13
- package/scripts/cm-prd-drive.mjs +89 -20
- package/scripts/cm-prd-drive.test.mjs +109 -4
- package/scripts/cm-prd-entry.mjs +5 -2
- package/scripts/cm-prd-host.mjs +89 -20
- package/scripts/cm-prd-host.test.mjs +17 -8
- package/scripts/cm-prd-narrow-review.test.mjs +49 -1
- package/scripts/cm-prd-review-disposition.test.mjs +94 -1
- package/scripts/cm-prd-review-gate.mjs +11 -4
- package/scripts/cm-prd-self-check-rules.test.mjs +175 -10
- package/scripts/cm-prd-self-check.test.mjs +1 -1
- package/scripts/cm-refactor-drive.mjs +10 -4
- package/scripts/cm-refactor-entry.mjs +5 -2
- package/scripts/cm-refactor-host.mjs +3 -1
- package/scripts/cm-run-analysis.test.mjs +373 -1
- package/scripts/cm-skill-hints-autowire.test.mjs +1 -1
- package/scripts/cm-skill-hints-exam.mjs +3 -1
- package/scripts/cm-skill-hints-install.test.mjs +1 -1
- package/scripts/cm-skill-hints.mjs +106 -10
- package/scripts/cm-skill-hints.test.mjs +162 -6
- package/scripts/cm-skill-judge.mjs +2 -1
- package/scripts/cm-task-gate.mjs +88 -18
- package/scripts/cm-task-scope.test.mjs +1 -1
- package/scripts/cm-test-drive.mjs +13 -8
- package/scripts/cm-test-entry.mjs +5 -2
- package/scripts/cm-test-host.mjs +3 -1
- package/scripts/cm-upgrade-compat-batch.test.mjs +62 -9
- package/scripts/fixtures/fresh-completion-checks.mjs +8 -0
- package/scripts/fixtures/prd-review-gate-python-oracle.py +9 -0
- package/scripts/policy-binding-compat.test.mjs +3 -2
- package/scripts/test-cm-prd-review-gate.py +25 -0
- package/skills/cm-ai/SKILL.md +1 -1
- package/skills/cm-ai/references/N1-init.md +1 -1
- package/skills/cm-ai/references/N4-review.md +2 -2
- package/skills/cm-ai/references/N6-qa-eval.md +3 -1
- package/skills/cm-ai/references/js-host-recovery.md +4 -1
- package/skills/cm-ai/references/js-host.md +17 -8
- package/skills/cm-fix/references/js-host.md +20 -0
- package/skills/cm-fix/references/test-extension.md +1 -1
- package/skills/cm-prd/SKILL.md +8 -6
- package/skills/cm-prd/references/ai-draft.md +81 -0
- package/skills/cm-prd/references/change-mode.md +2 -0
- package/skills/cm-prd/references/greenfield.md +2 -0
- package/skills/cm-prd/references/js-change-recovery.md +2 -2
- package/skills/cm-prd/references/js-host.md +9 -6
- package/skills/cm-prd/references/light-mode.md +19 -0
- package/skills/cm-prd/references/requirement-grilling.md +2 -0
- package/skills/cm-prd/references/spec-self-check.md +1 -0
- package/skills/cm-prd/references/summary-card.md +1 -0
|
@@ -0,0 +1,191 @@
|
|
|
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 {spawnSync} from 'node:child_process';
|
|
7
|
+
import {cmAiNextStep,NEXT_STEP_PREFIX,NEXT_STEP_VERDICTS} from '../runtime/js/cm-ai/drive-next-step.mjs';
|
|
8
|
+
import {cmAiDriveNextStepFacts} from './cm-ai-drive.mjs';
|
|
9
|
+
|
|
10
|
+
const identity={repositoryId:'fixture',runId:'next-step-run',taskId:'T-001',attempt:1};
|
|
11
|
+
const row=(state,code,pendingAction='none',extra={})=>({result:{workflow:'cm-ai',identity,state,code,pendingAction,outcome:'reported',...extra}});
|
|
12
|
+
const v2={v2Conversation:true,exitCode:0,operation:'advance'};
|
|
13
|
+
const verdictOf=line=>{
|
|
14
|
+
assert.ok(line.startsWith(NEXT_STEP_PREFIX),line);
|
|
15
|
+
const verdict=line.slice(NEXT_STEP_PREFIX.length).split('|')[0];
|
|
16
|
+
assert.ok(NEXT_STEP_VERDICTS.includes(verdict),line);
|
|
17
|
+
assert.ok(!/[\r\n]/.test(line),'one line');
|
|
18
|
+
return verdict;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Regression (dogfood 2026-11-30): the session ended its turn after a driver
|
|
22
|
+
// step that still had session-owned work, so the user had to type "继续".
|
|
23
|
+
test('v2 conversation work the session owns says continue and forbids ending the turn',()=>{
|
|
24
|
+
for(const [input,options,expect] of [
|
|
25
|
+
[row('changes_requested','revision_answer_required','none',{outcome:'awaiting'}),v2,/develop-a2\.json/],
|
|
26
|
+
[row('changes_requested','revision_answer_required','none',{outcome:'awaiting'}),{...v2,bootstrap:true},/init-generate-a2\.json.*init-verify-a2\.json/],
|
|
27
|
+
[row('blocked','develop_checks_not_passed','resume'),v2,/develop_checks_not_passed/],
|
|
28
|
+
[row('blocked','check_answer_missing','resume'),v2,/check_answer_missing/],
|
|
29
|
+
[row('ready',null,'none'),{...v2,operation:'status',mode:'create'},/"edits":"disk"/],
|
|
30
|
+
]){
|
|
31
|
+
const line=cmAiNextStep(input,options);
|
|
32
|
+
assert.equal(verdictOf(line),'继续',line);assert.match(line,/不要结束本轮/);assert.match(line,expect);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('anything not proven session-owned goes to the user',()=>{
|
|
37
|
+
for(const [input,options] of [
|
|
38
|
+
// legacy and provider/protected runs carry per-round or per-flag authorization
|
|
39
|
+
[row('changes_requested','revision_answer_required'),{...v2,v2Conversation:false}],
|
|
40
|
+
[row('blocked','develop_checks_not_passed','resume'),{...v2,v2Conversation:false}],
|
|
41
|
+
// verification:"auto" stops for a person on this code
|
|
42
|
+
[row('blocked','verification_precheck_failed','resume'),v2],
|
|
43
|
+
[row('blocked','review_limit'),v2],
|
|
44
|
+
[row('blocked','develop_checks_not_passed','none'),v2],
|
|
45
|
+
[row('blocked','develop_package_too_large','resume'),v2],
|
|
46
|
+
[row('unknown',null,'abandon_effect'),v2],
|
|
47
|
+
[row('blocked','spec_drift','spec_rebind'),v2],
|
|
48
|
+
[row('ready',null,'none'),{...v2,operation:'status',mode:'resume'}],
|
|
49
|
+
[row('ready',null,'none'),{...v2,operation:'status',mode:'create',bootstrap:true}],
|
|
50
|
+
// a stale timed retry was refused and dispatched nothing
|
|
51
|
+
[row('blocked','develop_checks_not_passed','resume',{outcome:'rejected',staleRetry:true}),v2],
|
|
52
|
+
[{error:{code:'invalid_request'}},v2],
|
|
53
|
+
[{},v2],
|
|
54
|
+
[null,v2],
|
|
55
|
+
[{result:{workflow:'cm-prd',state:'run_done'}},v2],
|
|
56
|
+
]){
|
|
57
|
+
const line=cmAiNextStep(input,options);
|
|
58
|
+
assert.equal(verdictOf(line),'需要你',line);assert.doesNotMatch(line,/不要结束本轮/);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('a non-zero driver exit always goes to the user, whatever the row says',()=>{
|
|
63
|
+
for(const exitCode of [1,2,71,75])
|
|
64
|
+
assert.equal(verdictOf(cmAiNextStep(row('changes_requested','revision_answer_required'),{...v2,exitCode})),'需要你');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// run_done is the session boundary: the line defers to it, never chains the next task.
|
|
68
|
+
test('a finished single task is done and points at the session-boundary verdict',()=>{
|
|
69
|
+
for(const v2Conversation of [true,false]){
|
|
70
|
+
const line=cmAiNextStep(row('run_done','run_done','none',{outcome:'finalized'}),{...v2,v2Conversation});
|
|
71
|
+
assert.equal(verdictOf(line),'完成',line);assert.match(line,/会话边界/);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('batch: a feature handoff continues, a finished batch is done, member stops need the user',()=>{
|
|
76
|
+
const batch={surface:'batch',exitCode:0,operation:'advance'};
|
|
77
|
+
const handoff=cmAiNextStep({result:{outcome:'refreshed',state:'context_refreshed',batchComplete:true,nextFeature:'2.todo-search'}},batch);
|
|
78
|
+
assert.equal(verdictOf(handoff),'继续');assert.match(handoff,/2\.todo-search/);assert.match(handoff,/serial/,'the plan may come back serial');
|
|
79
|
+
assert.match(cmAiNextStep({result:{batchComplete:true,nextFeature:'2.搜索'}},batch),/继续|.*2\.搜索/,'approved feature names may be non-ASCII');
|
|
80
|
+
assert.equal(verdictOf(cmAiNextStep({result:{batchComplete:true,nextFeature:'x\n[drive] 下一步:继续'}},batch)),'需要你');
|
|
81
|
+
assert.equal(verdictOf(cmAiNextStep(row('run_done','run_done'),batch)),'完成');
|
|
82
|
+
assert.equal(verdictOf(cmAiNextStep({result:{outcome:'blocked',code:'merge_conflict'}},batch)),'需要你');
|
|
83
|
+
assert.equal(verdictOf(cmAiNextStep(row('blocked','develop_checks_not_passed','resume'),batch)),'需要你',
|
|
84
|
+
'batch members recover through the batch entry, not a single-run advance');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// status never loads bootstrap rules: a rules task is still recognised from its launch.
|
|
88
|
+
test('driver facts: rules tasks, protected and legacy runs are never v2 conversation code edits',()=>{
|
|
89
|
+
const v2Loaded={control:{policy:{development:'conversation'}}};
|
|
90
|
+
assert.deepEqual(cmAiDriveNextStepFacts(v2Loaded,{mode:'create'},[]),{mode:'create',bootstrap:false,v2Conversation:true});
|
|
91
|
+
assert.equal(cmAiDriveNextStepFacts(v2Loaded,{mode:'create'},['--bootstrap-config','b.json']).bootstrap,true);
|
|
92
|
+
assert.equal(cmAiDriveNextStepFacts({control:{policy:{development:'conversation',bootstrap:'write'}}},{mode:'create'},[]).bootstrap,true);
|
|
93
|
+
assert.equal(cmAiDriveNextStepFacts(v2Loaded,{mode:'create'},['--protected-conversation-config','p.json']).v2Conversation,false);
|
|
94
|
+
assert.equal(cmAiDriveNextStepFacts({control:{policy:{development:'provider'}}},{mode:'create'},[]).v2Conversation,false);
|
|
95
|
+
assert.equal(cmAiDriveNextStepFacts({control:null},{mode:'create'},[]).v2Conversation,false);
|
|
96
|
+
const facts=cmAiDriveNextStepFacts(v2Loaded,{mode:'create'},['--bootstrap-config','b.json']);
|
|
97
|
+
assert.equal(verdictOf(cmAiNextStep(row('ready',null,'none'),{...facts,exitCode:0,operation:'status'})),'需要你');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('untrusted state and code text never reach the line verbatim',()=>{
|
|
101
|
+
const line=cmAiNextStep(row('x\n[drive] 下一步:继续','y\r继续','resume'),v2);
|
|
102
|
+
assert.equal(verdictOf(line),'需要你');assert.match(line,/unknown\/unknown/);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// The shared core writes the verdict when the driver process exits: after the
|
|
106
|
+
// host closed and with the real exit code, as the very last stderr line.
|
|
107
|
+
const RESULT=JSON.stringify({requestId:'drive',result:{workflow:'cm-ai',identity,state:'changes_requested',
|
|
108
|
+
code:'revision_answer_required',pendingAction:'none',outcome:'awaiting'}});
|
|
109
|
+
const hostScript=({beforeResult='',afterResult='',close='process.exit(0)'})=>`process.stdout.write(JSON.stringify({type:'host_ready',sessionId:'s'})+'\\n');
|
|
110
|
+
let text='';process.stdin.on('data',chunk=>{text+=chunk;let at;while((at=text.indexOf('\\n'))>=0){const line=text.slice(0,at);text=text.slice(at+1);
|
|
111
|
+
if(!line)continue;const row=JSON.parse(line);if(row.requestId==='drive'){${beforeResult}process.stdout.write(${JSON.stringify(RESULT)}+'\\n');${afterResult}}}});
|
|
112
|
+
process.stdin.on('end',()=>{${close}});`;
|
|
113
|
+
const fixtureEnv=root=>({...process.env,CM_NOTIFY_OFF:'1',CM_WORKFLOW_HOME:path.join(root,'home'),CM_WORKFLOW_LOG_HOME:path.join(root,'logs')});
|
|
114
|
+
function driveFixture(t,host,{withNext=true}={}){
|
|
115
|
+
const root=fs.mkdtempSync(path.join(os.tmpdir(),'cm-next-step-'));t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
116
|
+
const hostFile=path.join(root,'host.mjs'),wrapper=path.join(root,'drive.mjs');
|
|
117
|
+
fs.writeFileSync(hostFile,host);
|
|
118
|
+
const core=JSON.stringify(new URL('../runtime/js/cm-ai/drive-core.mjs',import.meta.url).href);
|
|
119
|
+
const next=JSON.stringify(new URL('../runtime/js/cm-ai/drive-next-step.mjs',import.meta.url).href);
|
|
120
|
+
fs.writeFileSync(wrapper,`import {driveHost} from ${core};import {cmAiNextStep} from ${next};
|
|
121
|
+
driveHost({host:${JSON.stringify(hostFile)},args:[],cwd:${JSON.stringify(root)},operation:'advance',answers:{},answerFor:()=>null,
|
|
122
|
+
liveness:{closeMs:300,killMs:200}
|
|
123
|
+
${withNext?",nextStep:(row,{operation,exitCode})=>cmAiNextStep(row,{v2Conversation:true,operation,exitCode})":''}});`);
|
|
124
|
+
const run=spawnSync(process.execPath,[wrapper],{encoding:'utf8',timeout:20000,env:fixtureEnv(root)});
|
|
125
|
+
return {run,last:run.stderr.trimEnd().split('\n').at(-1),count:run.stderr.split('\n').filter(l=>l.startsWith(NEXT_STEP_PREFIX)).length};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
test('core: the verdict follows late host stderr and is printed exactly once',t=>{
|
|
129
|
+
const {run,last,count}=driveFixture(t,hostScript({afterResult:"process.stderr.write('[host] late diagnostic');"}));
|
|
130
|
+
assert.equal(run.status,0,run.stderr);
|
|
131
|
+
assert.equal(JSON.parse(run.stdout).result.state,'changes_requested','stdout stays one JSON result');
|
|
132
|
+
assert.equal(verdictOf(last),'继续',run.stderr);assert.equal(count,1);
|
|
133
|
+
const lines=run.stderr.trimEnd().split('\n');
|
|
134
|
+
assert.equal(lines.at(-2),'[host] late diagnostic','the late half line is kept, and the verdict starts its own line');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('core: a host stuck in close turns the verdict into needs-user with the real exit code',t=>{
|
|
138
|
+
const {run,last,count}=driveFixture(t,hostScript({close:'setInterval(()=>{},1000)'}));
|
|
139
|
+
assert.notEqual(run.status,0,run.stderr);
|
|
140
|
+
assert.equal(verdictOf(last),'需要你',run.stderr);assert.match(last,new RegExp(`退出码 ${run.status}`));assert.equal(count,1);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('core: a host that exits before any result still yields a needs-user verdict',t=>{
|
|
144
|
+
const {run,last}=driveFixture(t,hostScript({beforeResult:'process.exit(3);'}));
|
|
145
|
+
assert.notEqual(run.status,0,run.stderr);
|
|
146
|
+
assert.equal(verdictOf(last),'需要你',run.stderr);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('core: drivers that do not ask for a verdict print none',t=>{
|
|
150
|
+
const {run,count}=driveFixture(t,hostScript({}),{withNext:false});
|
|
151
|
+
assert.equal(run.status,0,run.stderr);assert.equal(count,0);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// A timed rate-limit re-run either prints its own verdict, or stops before it
|
|
155
|
+
// reaches the core (preflight); then the waiting parent writes one for it.
|
|
156
|
+
const RATE_LIMITED=JSON.stringify({requestId:'drive',result:{workflow:'cm-ai',identity,state:'pending_review',code:'review_provider_failed',
|
|
157
|
+
pendingAction:'resume',outcome:'reported',reviewFailure:'reviewer_rate_limited',packageDigest:'a'.repeat(64),reviewInvocationId:'inv-1'}});
|
|
158
|
+
for(const [label,preflight,expect] of [['re-run that reaches the host prints its own verdict',false,'继续'],
|
|
159
|
+
['re-run that stops in preflight still ends with one verdict',true,'需要你']]){
|
|
160
|
+
test(`core retry: ${label}`,t=>{
|
|
161
|
+
const root=fs.mkdtempSync(path.join(os.tmpdir(),'cm-next-step-retry-'));t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
162
|
+
const hostFile=path.join(root,'host.mjs'),wrapper=path.join(root,'drive.mjs'),plan=path.join(root,'plan.json');
|
|
163
|
+
fs.writeFileSync(plan,'{}');
|
|
164
|
+
fs.writeFileSync(hostFile,`const answer=process.env.CM_DRIVE_RATE_LIMIT_RETRY?${JSON.stringify(RESULT)}:${JSON.stringify(RATE_LIMITED)};
|
|
165
|
+
process.stdout.write(JSON.stringify({type:'host_ready',sessionId:'s'})+'\\n');
|
|
166
|
+
let text='';process.stdin.on('data',chunk=>{text+=chunk;let at;while((at=text.indexOf('\\n'))>=0){const line=text.slice(0,at);text=text.slice(at+1);
|
|
167
|
+
if(line&&JSON.parse(line).requestId==='drive')process.stdout.write(answer+'\\n');}});process.stdin.on('end',()=>process.exit(0));`);
|
|
168
|
+
const core=JSON.stringify(new URL('../runtime/js/cm-ai/drive-core.mjs',import.meta.url).href);
|
|
169
|
+
const next=JSON.stringify(new URL('../runtime/js/cm-ai/drive-next-step.mjs',import.meta.url).href);
|
|
170
|
+
fs.writeFileSync(wrapper,`import {driveHost} from ${core};import {cmAiNextStep} from ${next};
|
|
171
|
+
if(process.env.CM_DRIVE_RATE_LIMIT_RETRY&&${preflight}){process.stderr.write('preflight refused\\n');process.exit(2);}
|
|
172
|
+
driveHost({host:${JSON.stringify(hostFile)},args:[],cwd:${JSON.stringify(root)},operation:'advance',answers:{},answerFor:()=>null,
|
|
173
|
+
rateLimitRetry:true,liveness:{closeMs:300,killMs:200},
|
|
174
|
+
nextStep:(row,{operation,exitCode})=>cmAiNextStep(row,{v2Conversation:true,operation,exitCode})});`);
|
|
175
|
+
const run=spawnSync(process.execPath,[wrapper,'--plan',plan],{encoding:'utf8',timeout:20000,
|
|
176
|
+
env:{...fixtureEnv(root),CM_DRIVE_RATE_LIMIT_DELAYS_MS:'50'}});
|
|
177
|
+
const verdicts=run.stderr.split('\n').filter(l=>l.startsWith(NEXT_STEP_PREFIX));
|
|
178
|
+
assert.match(run.stderr,/审查限流等待结束/,run.stderr);
|
|
179
|
+
assert.equal(verdicts.length,1,run.stderr);assert.equal(verdictOf(run.stderr.trimEnd().split('\n').at(-1)),expect,run.stderr);
|
|
180
|
+
if(preflight)assert.equal(run.status,2,run.stderr);
|
|
181
|
+
assert.deepEqual(fs.readdirSync(os.tmpdir()).filter(n=>n.startsWith(`cm-next-step-${run.pid}-`)),[],'marker removed');
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// 2026-12-01 探针:批次停住却没有指引时,下一步不能让人去找「上面的恢复指引」。
|
|
186
|
+
test('a batch stop points at guidance only when there is some',()=>{
|
|
187
|
+
const stop=extra=>cmAiNextStep({result:{outcome:'blocked',code:'tool_preflight_missing',...extra}},{surface:'batch'});
|
|
188
|
+
assert.match(stop({guidance:{summary:'x'}}),/按上面的恢复指引处理/);
|
|
189
|
+
assert.match(stop({reason:'审查端是 claude'}),/按上面结果里的 reason 处理/);
|
|
190
|
+
assert.match(stop({}),/没有给出原因或恢复指引/);assert.doesNotMatch(stop({}),/恢复指引处理/);
|
|
191
|
+
});
|
package/scripts/cm-ai-drive.mjs
CHANGED
|
@@ -47,6 +47,7 @@ import {inspectCmAiQaTaskContext} from '../runtime/js/cm-ai/cm-ai-admission.mjs'
|
|
|
47
47
|
import {readLearningRetrospectiveContent} from '../runtime/js/cm-ai/cm-ai-context-refresh.mjs';
|
|
48
48
|
import {inspectFixInvestigation} from '../runtime/js/cm-fix/investigation.mjs';
|
|
49
49
|
import {readRunDefinition,assertCreatableRunId} from './cm-ai-run.mjs';
|
|
50
|
+
import {cmAiNextStep} from '../runtime/js/cm-ai/drive-next-step.mjs';
|
|
50
51
|
import {REVIEW_MATERIAL_LIMITS,captureReviewBaseline,reviewMaterialSizes,projectedReviewPackage} from '../runtime/js/cm-ai/review-package.mjs';
|
|
51
52
|
import {JOURNAL_PAYLOAD_LIMIT,developCheckpointReserve,taskReviewScope} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
52
53
|
import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
@@ -94,13 +95,13 @@ const FIX_REASONED=['abandon_step','abandon_review','rediagnose','rerun_blocked_
|
|
|
94
95
|
const FILES={develop:'develop.json',qa_assess:'qa-assess.json',documentation_inspect:'documentation-inspect.json',
|
|
95
96
|
documentation_sync:'documentation-sync.json',fix_learning:'learning.json',fix_diagnose:'diagnosis.json',
|
|
96
97
|
fix_test_author:'test-edits.json',fix_repair:'repair-edits.json',fix_retrospective:'retrospective.json'};
|
|
97
|
-
const PAIR_FLAGS=new Set(['--integration-evidence','--accept-integration-digest','--expected-control','--revise-scope','--scope-revision-reason','--development-rework-reason','--external-models-config','--review-config','--workflow-config',
|
|
98
|
+
const PAIR_FLAGS=new Set(['--integration-evidence','--accept-integration-digest','--expected-control','--revise-scope','--scope-revision-reason','--development-rework-reason','--review-continuation-reason','--external-models-config','--review-config','--workflow-config',
|
|
98
99
|
'--input-limit','--call-timeout-minutes',
|
|
99
100
|
'--protected-conversation-config','--protected-config','--revise-qa-config','--qa-config-revision-reason','--qa-environment-failure',
|
|
100
101
|
'--qa-fix-owner-config','--qa-fix-template-config','--qa-fix-review-config','--browser-qa',
|
|
101
102
|
'--bootstrap-config','--allow-provider-development-attempt','--supersede-reason','--supersede-target','--spec-rebind-reason',
|
|
102
103
|
'--review-runtime','--feature','--qa-fix-final-review-recovery-invocation']);
|
|
103
|
-
const FLAG_FLAGS=new Set(['--development-rework','--execution-optimizations','--external-models','--allow-development','--allow-qa','--allow-qa-fix-start','--auto-qa-fix',
|
|
104
|
+
const FLAG_FLAGS=new Set(['--development-rework','--review-continuation','--execution-optimizations','--external-models','--allow-development','--allow-qa','--allow-qa-fix-start','--auto-qa-fix',
|
|
104
105
|
'--verification-precheck',
|
|
105
106
|
'--allow-bootstrap-write','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--allow-develop-redo','--rerun-unknown-qa','--rerun-blocked-qa','--failover',
|
|
106
107
|
'--supersede-reviewed-evidence','--accept-superseded-code-drift','--rebind-spec-material',
|
|
@@ -178,6 +179,8 @@ function requireShape(ok,label){if(!ok)stop(2,`答案格式错误:${label}`);}
|
|
|
178
179
|
function exact(value,allowed,label){requireShape(object(value)&&Object.keys(value).every(key=>allowed.includes(key)),label);}
|
|
179
180
|
function answerPath(root,file){return path.join(root,file);}
|
|
180
181
|
export const developFilename=(root,attempt)=>attemptAnswerName(root,'develop',attempt);
|
|
182
|
+
// A third controlled review delivers attempt 2 again; it never reuses the round-2 answer.
|
|
183
|
+
export const CONTINUATION_DEVELOP_FILE='develop-a2-continuation.json';
|
|
181
184
|
// develop.json.edits maps an approved scope path to one of:
|
|
182
185
|
// "content-file" write these bytes (existing mode kept, new file 0644)
|
|
183
186
|
// {file:"content-file",mode} write, then set mode
|
|
@@ -441,8 +444,11 @@ export function preflightDevelopDeliveries({deliveries,answersRoot,codeProject,s
|
|
|
441
444
|
const delivered=diskChecks?null:new Map();
|
|
442
445
|
for(const {file,value,attempt=1} of deliveries){
|
|
443
446
|
if(value.status!=='succeeded')continue;
|
|
444
|
-
const label=path.basename(file);
|
|
445
|
-
|
|
447
|
+
const label=path.basename(file);
|
|
448
|
+
const isDisk=value.edits==='disk';
|
|
449
|
+
if(isDisk&&protectedMode)stop(2,`${label}: 受保护模式不能使用 edits:"disk",必须通过 answers 文件提供显式修改`);
|
|
450
|
+
let entries=[];
|
|
451
|
+
if(!isDisk)try{
|
|
446
452
|
entries=developEntries(value.edits,answersRoot,`${label}.edits`);
|
|
447
453
|
if(allowSymlinks)assertDisjointEditPaths(entries.map(([file])=>file));
|
|
448
454
|
}catch(error){stop(2,`答案格式错误:${error.message}`);}
|
|
@@ -523,13 +529,27 @@ export function preflightDevelopDeliveries({deliveries,answersRoot,codeProject,s
|
|
|
523
529
|
// The develop checkpoint journals the review package as one record. Build the
|
|
524
530
|
// package this delivery would produce with the runner's own assembly code and
|
|
525
531
|
// check it, plus the rest of the checkpoint, against the same budget.
|
|
526
|
-
|
|
532
|
+
if(isDisk&&next&&base){
|
|
533
|
+
for(const target of scope){
|
|
534
|
+
const before=base.get(target)??null,after=next.get(target)??null;
|
|
535
|
+
if(after&&!after.unsupported&&after.type!=='symlink'&&(!before||before.mode!==after.mode)){
|
|
536
|
+
if(![0o644,0o755].includes(after.mode))
|
|
537
|
+
stop(2,`${label}: 磁盘文件 ${target} 的权限位为 ${after.mode.toString(8)},新增或变更权限的文件仅允许 0644 或 0755`);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
const projectedTargets=isDisk
|
|
542
|
+
?scope.filter(target=>{
|
|
543
|
+
const a=base?.get(target)??null,b=next.get(target)??null;
|
|
544
|
+
return !(a===null&&b===null||a!==null&&b!==null&&!a.unsupported&&!b.unsupported&&a.sha256!==null&&a.sha256===b.sha256&&a.mode===b.mode);
|
|
545
|
+
}):entries.map(([target])=>target);
|
|
546
|
+
const projectable=material&&projectedTargets.every(target=>!next.get(target)?.unsupported);
|
|
527
547
|
if(projectable){
|
|
528
|
-
for(const
|
|
548
|
+
for(const target of projectedTargets){
|
|
529
549
|
const after=next.get(target);
|
|
530
550
|
projected.set(target,after===null?{path:target,contentBase64:null,mode:null}
|
|
531
551
|
:after.type==='symlink'?{path:target,symlink:after.target}
|
|
532
|
-
:{path:target,contentBase64:fs.readFileSync(after.source).toString('base64'),mode:after.mode});
|
|
552
|
+
:{path:target,contentBase64:fs.readFileSync(after.source??path.join(codeProject,target)).toString('base64'),mode:after.mode});
|
|
533
553
|
}
|
|
534
554
|
const projection=preview.exact?projectDevelopCheckpoint({preview,codeProject,attempt,value,projected,checks}):null;
|
|
535
555
|
if(projection){
|
|
@@ -659,8 +679,10 @@ export function validateCmAiAnswer(kind,value,root){
|
|
|
659
679
|
if(value.value.application)exact(value.value.application,['status','note'],'develop.json.value.application');
|
|
660
680
|
if(value.value.outcome==='implemented')try{readLearningRetrospectiveContent(value.value.retrospective);}
|
|
661
681
|
catch{stop(2,'答案格式错误:develop.json.value.retrospective');}
|
|
662
|
-
|
|
663
|
-
|
|
682
|
+
if(value.edits!=='disk'){
|
|
683
|
+
requireShape(object(value.edits),'develop.json.edits');
|
|
684
|
+
try{developEntries(value.edits,root,'develop.json.edits');}catch(error){stop(2,`答案格式错误:${error.message}`);}
|
|
685
|
+
}
|
|
664
686
|
}else {exact(value,['status','code'],'develop.json');requireShape(nonempty(value.code),'develop.json.code');}
|
|
665
687
|
}else if(kind==='qa_assess'){
|
|
666
688
|
try{readQaAssessment(value);}
|
|
@@ -737,7 +759,7 @@ function load(){
|
|
|
737
759
|
||!permissions.includes('--expected-control')
|
|
738
760
|
||!/^[a-f0-9]{64}$/.test(permissions[permissions.indexOf('--accept-integration-digest')+1]))
|
|
739
761
|
stop(2,'受控集成接纳只允许新版 resume 的 status;需要成对 --integration-evidence、--accept-integration-digest 和原 --expected-control 文件');
|
|
740
|
-
if(['--revise-scope','--scope-revision-reason','--development-rework','--development-rework-reason',
|
|
762
|
+
if(['--revise-scope','--scope-revision-reason','--development-rework','--development-rework-reason','--review-continuation','--review-continuation-reason',
|
|
741
763
|
'--revise-qa-config','--qa-config-revision-reason','--rerun-unknown-qa','--rerun-blocked-qa','--qa-environment-failure',
|
|
742
764
|
'--rebind-spec-material','--spec-rebind-reason','--supersede-reviewed-evidence','--supersede-reason',
|
|
743
765
|
'--supersede-target','--accept-superseded-code-drift','--hold-revision'].some(flag=>permissions.includes(flag)))
|
|
@@ -806,7 +828,7 @@ function load(){
|
|
|
806
828
|
const permissionFiles=[];
|
|
807
829
|
for(let i=0;i<permissions.length;i++)if(PAIR_FLAGS.has(permissions[i])
|
|
808
830
|
&&permissions[i]!=='--browser-qa'&&permissions[i]!=='--accept-integration-digest'
|
|
809
|
-
&&permissions[i]!=='--scope-revision-reason'&&permissions[i]!=='--development-rework-reason'&&permissions[i]!=='--qa-config-revision-reason'&&permissions[i]!=='--qa-environment-failure'&&permissions[i]!=='--allow-provider-development-attempt'
|
|
831
|
+
&&permissions[i]!=='--scope-revision-reason'&&permissions[i]!=='--development-rework-reason'&&permissions[i]!=='--review-continuation-reason'&&permissions[i]!=='--qa-config-revision-reason'&&permissions[i]!=='--qa-environment-failure'&&permissions[i]!=='--allow-provider-development-attempt'
|
|
810
832
|
&&permissions[i]!=='--supersede-reason'&&permissions[i]!=='--spec-rebind-reason'&&permissions[i]!=='--input-limit'&&permissions[i]!=='--call-timeout-minutes'
|
|
811
833
|
&&permissions[i]!=='--review-runtime'&&permissions[i]!=='--feature'&&permissions[i]!=='--qa-fix-final-review-recovery-invocation'){
|
|
812
834
|
const file=path.resolve(base,permissions[i+1]);if(!fs.existsSync(file))stop(2,`${permissions[i]} 文件不存在: ${file}`);
|
|
@@ -888,8 +910,14 @@ function load(){
|
|
|
888
910
|
const bootstrapAnswers=rules
|
|
889
911
|
?readBootstrapRulesAnswers({answers,operation,definition,plan,permissions,bootstrap,reachable,controlPolicy:control?.policy??null}):null;
|
|
890
912
|
const developAnswers=new Map(),deliveries=[];let holdRevision=holdBootstrapRevision;
|
|
913
|
+
// The grant is its own launch: run it with status, then drop the flags and advance.
|
|
914
|
+
if(permissions.includes('--review-continuation')&&operation!=='status')
|
|
915
|
+
stop(2,'第三次受控审查的授权与推进分两次:先带 --review-continuation 等参数运行 status 追加授权,再去掉这些参数 advance');
|
|
916
|
+
const continuing=journal?.history?.reviewContinuation!=null;
|
|
891
917
|
if(asks.includes('develop'))for(const attempt of reachable.attempts){
|
|
892
|
-
const file=answerPath(answers??'',developFilename(answers??'',attempt));
|
|
918
|
+
const file=answerPath(answers??'',attempt===2&&continuing?CONTINUATION_DEVELOP_FILE:developFilename(answers??'',attempt));
|
|
919
|
+
if(attempt===2&&continuing&&(!answers||!fs.existsSync(file)))
|
|
920
|
+
stop(2,`第三次受控审查的补正答案不存在: ${file};读取第 2 轮审查 findings 后写 answers/${CONTINUATION_DEVELOP_FILE}(不复用 develop-a2.json)再 advance`);
|
|
893
921
|
if(!answers||!fs.existsSync(file)){
|
|
894
922
|
const reviewFile=`.reviews/${definition.feature.replace(/^\d+\./,'')}-${definition.identity.taskId}-r1.md`;
|
|
895
923
|
// Resuming a retryable block: let the redo and its review run, then stop
|
|
@@ -904,10 +932,22 @@ function load(){
|
|
|
904
932
|
stop(2,`步骤 ${operation} 会反问 develop,但答案文件不存在: ${file}`);
|
|
905
933
|
}
|
|
906
934
|
const value=readJson(file,'develop');validateCmAiAnswer('develop',value,answers);
|
|
907
|
-
if(value.status==='succeeded'
|
|
935
|
+
if(value.status==='succeeded'&&value.edits==='disk'){
|
|
936
|
+
if(protectedMode)stop(2,`${path.basename(file)}: 受保护模式不能使用 edits:"disk"`);
|
|
937
|
+
if(plan.mode!=='resume')stop(2,`${path.basename(file)}: edits:"disk" 须先以 mode:create 运行 status 冻结任务基线,在工作区直接改完代码后再以 mode:resume 推进`);
|
|
938
|
+
if(!permissions.includes('--disk-edits'))permissions.push('--disk-edits');
|
|
939
|
+
}else if(value.status==='succeeded')for(const target of Object.keys(value.edits))
|
|
908
940
|
if(!definition.scope.includes(target))stop(2,`${path.basename(file)}.edits 越过批准 scope: ${target}`);
|
|
909
941
|
developAnswers.set(attempt,value);deliveries.push({file,value,attempt});
|
|
910
942
|
}
|
|
943
|
+
if(asks.includes('develop')&&!protectedMode&&plan.mode==='resume'&&RECHECK_CODES.includes(journal?.history?.state?.code)
|
|
944
|
+
&&!permissions.includes('--disk-edits')&&answers){
|
|
945
|
+
const currentAttempt=journal.history.state.attempt;
|
|
946
|
+
const recheckFile=answerPath(answers,currentAttempt===2&&continuing?CONTINUATION_DEVELOP_FILE:developFilename(answers,currentAttempt));
|
|
947
|
+
if(fs.existsSync(recheckFile)){
|
|
948
|
+
try{if(readJson(recheckFile,'develop')?.edits==='disk')permissions.push('--disk-edits');}catch{}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
911
951
|
if(deliveries.length)preflightDevelopDeliveries({deliveries,answersRoot:answers,codeProject:definition.codeProject,
|
|
912
952
|
scope:definition.scope,requirements:definition.requirements,
|
|
913
953
|
baseline:plan.mode==='create'?'disk':baselineScope(journal.baseline,definition.scope),
|
|
@@ -994,7 +1034,7 @@ async function answerFor(row,answer,paths,control){
|
|
|
994
1034
|
codeProjects:row.payload.codeProjects};
|
|
995
1035
|
if(row.payload.editMode==='protected-text-v1')return {status:'succeeded',value:value.value,
|
|
996
1036
|
edits:protectedDevelopEdits(value.edits,loaded.answers,loaded.definition.codeProject,row.payload.expected,editOptions)};
|
|
997
|
-
applyDevelopEdits(value.edits,loaded.answers,loaded.definition.codeProject,row.payload.request.payload.scope,editOptions);
|
|
1037
|
+
if(value.edits!=='disk')applyDevelopEdits(value.edits,loaded.answers,loaded.definition.codeProject,row.payload.request.payload.scope,editOptions);
|
|
998
1038
|
return {status:'succeeded',value:value.value};
|
|
999
1039
|
}
|
|
1000
1040
|
if(kind==='documentation_sync'){
|
|
@@ -1024,6 +1064,14 @@ export function buildCmAiDriveRequest(operation,plan,definition,identity=definit
|
|
|
1024
1064
|
...(plan.fixOperation==='recover_final_review'?{invocationId:plan.invocationId,reviewPackageDigest:plan.reviewPackageDigest,
|
|
1025
1065
|
previousInvocationStopped:plan.previousInvocationStopped}:{})}: {})}: {})};
|
|
1026
1066
|
}
|
|
1067
|
+
// What the next-step verdict may rely on. status runs never load bootstrap rules,
|
|
1068
|
+
// so a rules task is recognised from its launch flags and policy as well.
|
|
1069
|
+
export function cmAiDriveNextStepFacts(loaded,plan,permissions){
|
|
1070
|
+
return {mode:plan.mode,
|
|
1071
|
+
bootstrap:Boolean(loaded.bootstrapRules)||permissions.includes('--bootstrap-config')||loaded.control?.policy?.bootstrap==='write',
|
|
1072
|
+
v2Conversation:loaded.control?.policy?.development==='conversation'
|
|
1073
|
+
&&!permissions.includes('--protected-config')&&!permissions.includes('--protected-conversation-config')};
|
|
1074
|
+
}
|
|
1027
1075
|
export function buildCmAiDriveHostArgs(plan,permissions,config,controlConfig=null){
|
|
1028
1076
|
return ['serve','--config',config,'--mode',plan.mode,'--host-context',plan.hostContext,
|
|
1029
1077
|
...(Object.hasOwn(plan,'controlConfig')?['--control-config',controlConfig??plan.controlConfig]:['--allow-development']),
|
|
@@ -1050,11 +1098,15 @@ async function main(){
|
|
|
1050
1098
|
// Rules init_verify commands really run once the host has accepted the launch
|
|
1051
1099
|
// (host_ready) and before the operation is sent: a failure never becomes an
|
|
1052
1100
|
// unknown develop effect, and the host's own launch validation came first.
|
|
1101
|
+
// dogfood 2026-11-30(问题 11):create 下的 status 也会建出运行记录并冻结配置指纹,之后直接改 workflow 配置会报 fingerprint_mismatch。
|
|
1102
|
+
if(plan.mode==='create'&&operation==='status'&&!fs.existsSync(path.join(definition.specsDir,'.reviews','.execution',definition.identity.runId,'state.json')))
|
|
1103
|
+
stderr('[drive] 注意:宿主接受本次 create 启动后,status 也会建出本运行记录并冻结当前配置;之后直接改配置再启动会报 fingerprint_mismatch。只有已启用 QA 的单任务运行可按 js-host-qa-recovery.md「QA 配置修订」改 QA 配置;单任务完成后若原运行没开 QA,可按同文件「补挂 QA」在原 run 补开一次(v2 以 qa:"disabled" 创建的只把策略 qa 改为 run;legacy 原无 workflow 或 qa:null 的加 --allow-qa);其余改动要以新 runId 重建。');
|
|
1053
1104
|
if(plan.mode==='create')printHandoff(definition.specsDir);
|
|
1054
1105
|
driveHost({host:HOST,args:[...buildCmAiDriveHostArgs(plan,permissions,config,loaded.control?.file),...(loaded.holdRevision?['--hold-revision']:[])],cwd:definition.codeProject,operation,request,
|
|
1055
1106
|
answers:answer,paths:{answers:loaded.answers},answerFor,
|
|
1056
1107
|
sessionBoundary:result=>cmAiSessionBoundary(result,{specsDir:definition.specsDir,feature:definition.feature,identity:definition.identity}),
|
|
1057
1108
|
rateLimitRetry:rateLimitRetryEligible(operation,plan),
|
|
1109
|
+
nextStep:(row,{operation:sent,exitCode})=>cmAiNextStep(row,{surface:'single',exitCode,operation:sent,...cmAiDriveNextStepFacts(loaded,plan,permissions)}),
|
|
1058
1110
|
...(loaded.bootstrapRules?{beforeRequest:()=>loaded.bootstrapRules.prepare(plan.mode)}:{})});
|
|
1059
1111
|
}
|
|
1060
1112
|
if(process.argv[1]&&fs.realpathSync(process.argv[1])===fileURLToPath(import.meta.url))
|
|
@@ -578,10 +578,13 @@ test('new policy real driver reuses only declared checks and frozen resume keeps
|
|
|
578
578
|
const checks=[{id:'tests',command},{id:'ui',command,sameExecutionAs:'tests'}];
|
|
579
579
|
const plan=f.plan({permissions:['--execution-optimizations'],checks});
|
|
580
580
|
const first=f.drive(plan,'advance');assert.equal(first.status,0,first.stderr);assert.equal(JSON.parse(first.stdout).result.state,'fixture_completed',first.stdout+first.stderr);
|
|
581
|
-
|
|
581
|
+
// One shared physical run during development; the new run completes on the reviewed checks.
|
|
582
|
+
assert.equal(fs.readFileSync(path.join(f.root,'execution-count'),'utf8'),'x');
|
|
582
583
|
const before=fs.readFileSync(f.store),snapshot=JSON.parse(before);assert.equal(snapshot.records[0].payload.config.executionPolicy.checkReuse,'declared-adjacent-v1');
|
|
584
|
+
assert.equal(snapshot.records[0].payload.config.completionCheckReuse,'reviewed-unchanged-v1');
|
|
585
|
+
assert.equal(snapshot.records[0].payload.config.qaCadence,'feature-v1');
|
|
583
586
|
const resume=f.plan({mode:'resume',checks});const status=f.drive(resume,'status');assert.equal(status.status,0,status.stderr);
|
|
584
|
-
assert.equal(fs.readFileSync(path.join(f.root,'execution-count'),'utf8'),'
|
|
587
|
+
assert.equal(fs.readFileSync(path.join(f.root,'execution-count'),'utf8'),'x');assert.deepEqual(fs.readFileSync(f.store),before);
|
|
585
588
|
});
|
|
586
589
|
test('legacy real driver rejects optimization aliases before any host or command starts',t=>{
|
|
587
590
|
const f=fixture(t);prepared(f);const command=[process.execPath,'-e',"require('node:fs').writeFileSync('marker','bad')"];
|
|
@@ -605,8 +608,15 @@ test('driver forwards --feature for a later approved feature and --review-runtim
|
|
|
605
608
|
const bound=['--feature','1.work','--review-runtime','claude'];
|
|
606
609
|
const created=f.drive(f.plan({...bare,permissions:bound}),'status');
|
|
607
610
|
assert.equal(created.status,0,created.stderr);assert.equal(fs.existsSync(f.store),true);
|
|
611
|
+
// dogfood 2026-11-30(问题 11):create 下的 status 建出记录时先提醒配置已冻结;已有记录的 resume 不再提醒。
|
|
612
|
+
assert.match(created.stderr,/宿主接受本次 create 启动后,status 也会建出本运行记录并冻结当前配置/);assert.match(created.stderr,/只有已启用 QA 的单任务运行/);
|
|
613
|
+
// Review r2 (P3): disabled-QA single tasks can attach QA on the original run, so the hint must not send every change to a new runId.
|
|
614
|
+
assert.match(created.stderr,/单任务完成后若原运行没开 QA,可按同文件「补挂 QA」在原 run 补开一次/);
|
|
615
|
+
assert.match(created.stderr,/v2 以 qa:"disabled" 创建的只把策略 qa 改为 run/);assert.match(created.stderr,/legacy 原无 workflow 或 qa:null 的加 --allow-qa/);
|
|
616
|
+
// Review r1: once the record exists, a repeated create+status says nothing.
|
|
617
|
+
const again=f.drive(f.plan({...bare,permissions:bound}),'status');assert.doesNotMatch(again.stderr,/冻结当前配置/);
|
|
608
618
|
const resumed=f.drive(f.plan({...bare,mode:'resume',permissions:bound}),'status');
|
|
609
|
-
assert.equal(resumed.status,0,resumed.stderr);
|
|
619
|
+
assert.equal(resumed.status,0,resumed.stderr);assert.doesNotMatch(resumed.stderr,/冻结当前配置/);
|
|
610
620
|
const unbound=f.drive(f.plan({...bare,mode:'resume'}),'status');
|
|
611
621
|
assert.notEqual(unbound.status,0);assert.match(unbound.stdout+unbound.stderr,/fingerprint_mismatch/);
|
|
612
622
|
});
|
|
@@ -106,7 +106,8 @@ for(const runtime of ['codex','claude'])for(const initialWorkflow of ['absent','
|
|
|
106
106
|
}
|
|
107
107
|
const bin=path.join(f.root,'bin');fs.mkdirSync(bin);
|
|
108
108
|
const fake=path.join(bin,runtime);fs.copyFileSync(fileURLToPath(new URL(`./fixtures/${runtime}-review-process.mjs`,import.meta.url)),fake);
|
|
109
|
-
|
|
109
|
+
// Pin completion-check reuse on (its default): an inherited `off` would change the expected calls.
|
|
110
|
+
fs.chmodSync(fake,0o700);f.env={...process.env,PATH:bin+path.delimiter+process.env.PATH};delete f.env.CM_AI_COMPLETION_CHECK_REUSE;
|
|
110
111
|
// Actual separate CLI and loopback diagnostic process; the executable is synthetic.
|
|
111
112
|
let review;
|
|
112
113
|
const preview=spawnSync(process.execPath,[cli,'preflight','--config',f.config,'--review-model','fixture',
|
|
@@ -165,7 +166,8 @@ for(const runtime of ['codex','claude'])for(const initialWorkflow of ['absent','
|
|
|
165
166
|
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[ ] T-001'));
|
|
166
167
|
f.operation='advance';
|
|
167
168
|
const completed=await runCli(f,'authorized-review','resume');assert.equal(completed.code,0,completed.stderr);
|
|
168
|
-
|
|
169
|
+
// A new run completes on its reviewed command checks (completionCheckReuse): no fresh check call.
|
|
170
|
+
assert.deepEqual(completed.calls,workflow?['qa_assess','documentation_inspect']:[]);
|
|
169
171
|
const result=completed.rows.find(row=>row.requestId==='advance').result;
|
|
170
172
|
assert.equal(result.state,workflow?'run_done':'fixture_completed');assert.equal(result.code,workflow?'run_done':'qa_decision_required');
|
|
171
173
|
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[x] T-001'));
|
package/scripts/cm-ai-host.mjs
CHANGED
|
@@ -25,6 +25,7 @@ import {digest,json,need,shape,id} from '../runtime/js/cm-ai/effect-contract.mjs
|
|
|
25
25
|
import {readControlPolicyFile,withControlPolicyHost,readControlTarget} from '../runtime/js/cm-ai/control-policy.mjs';
|
|
26
26
|
import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs';
|
|
27
27
|
import {parseModelJson} from '../runtime/js/cm-ai/model-configuration-file.mjs';
|
|
28
|
+
import {EXECUTOR_REASON_CODES} from '../runtime/js/executor-version.mjs';
|
|
28
29
|
export {executionFor as createConversationExecution,reviewConfiguration as readConversationReviewConfiguration,reviewConfigurationValue as readConversationReviewConfigurationValue};
|
|
29
30
|
export function readScopeRevisionFile(file){
|
|
30
31
|
const before=fs.lstatSync(file);
|
|
@@ -73,9 +74,9 @@ export function readBootstrapConfiguration(file){
|
|
|
73
74
|
// Launch-input refusals keep their code and name the input, so the operator can
|
|
74
75
|
// find the exit without reading the host source.
|
|
75
76
|
const refuse=(ok,code,reason)=>{if(!ok)throw Object.assign(new Error(code),{code,reason});};
|
|
76
|
-
const REASONED_CODES=['supersede_unavailable','supersede_code_drift','handoff_exists','browser_capability_required',
|
|
77
|
+
const REASONED_CODES=['supersede_unavailable','tool_preflight_missing','supersede_code_drift','handoff_exists','browser_capability_required',
|
|
77
78
|
'browser_capability_unavailable','invalid_arguments','fingerprint_mismatch','task_selection_mismatch','review_configuration_required',
|
|
78
|
-
'spec_rebind_refused','spec_rebind_unavailable','protected_scope','invalid_input','snapshot_changed','runner_invocation'];
|
|
79
|
+
'spec_rebind_refused','spec_rebind_unavailable','protected_scope','invalid_input','snapshot_changed','runner_invocation',...EXECUTOR_REASON_CODES];
|
|
79
80
|
const fixLocalPermissions=new Map(['red-test','baseline','regression','learning-writeback','walkthrough','finish','abandon',
|
|
80
81
|
'abandon-review','test-author','repair','cause-review','final-review','rediagnosis','rerun-blocked-step','final-review-recovery']
|
|
81
82
|
.map(name=>[`--allow-qa-fix-${name}`,`--allow-${name}`]));
|
|
@@ -233,8 +234,8 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
233
234
|
const extra=new Map();
|
|
234
235
|
for(let index=controlPolicy?9:8;index<argv.length;index++){
|
|
235
236
|
const name=argv[index];refuse(!extra.has(name),'invalid_arguments',`参数重复:${name}`);
|
|
236
|
-
refuse(['--integration-evidence','--accept-integration-digest','--revise-scope','--scope-revision-reason','--development-rework','--development-rework-reason','--expected-control','--execution-optimizations','--external-models','--external-models-config','--verification-precheck','--revise-qa-config','--qa-config-revision-reason','--qa-environment-failure','--supersede-reviewed-evidence','--supersede-reason','--supersede-target','--accept-superseded-code-drift','--rebind-spec-material','--spec-rebind-reason','--original-host-context','--bootstrap-config','--allow-bootstrap-write','--protected-conversation-config','--protected-config','--allow-provider-development-attempt','--review-config','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--allow-develop-redo','--hold-revision','--workflow-config','--allow-qa','--browser-qa','--rerun-unknown-qa','--rerun-blocked-qa','--runtime','--review-runtime','--feature','--input-limit','--call-timeout-minutes','--failover','--qa-fix-owner-config','--qa-fix-template-config','--qa-fix-review-config','--qa-fix-final-review-recovery-invocation','--allow-qa-fix-start','--auto-qa-fix',...fixLocalPermissions.keys()].includes(name),'invalid_arguments',`未知参数:${name}`);
|
|
237
|
-
if(['--development-rework','--execution-optimizations','--external-models','--verification-precheck','--supersede-reviewed-evidence','--accept-superseded-code-drift','--rebind-spec-material','--allow-bootstrap-write','--allow-qa','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--allow-develop-redo','--hold-revision','--rerun-unknown-qa','--rerun-blocked-qa','--failover','--allow-qa-fix-start','--auto-qa-fix',...fixLocalPermissions.keys()].includes(name))extra.set(name,true);
|
|
237
|
+
refuse(['--integration-evidence','--accept-integration-digest','--revise-scope','--scope-revision-reason','--development-rework','--development-rework-reason','--review-continuation','--review-continuation-reason','--expected-control','--execution-optimizations','--external-models','--external-models-config','--verification-precheck','--revise-qa-config','--qa-config-revision-reason','--qa-environment-failure','--supersede-reviewed-evidence','--supersede-reason','--supersede-target','--accept-superseded-code-drift','--rebind-spec-material','--spec-rebind-reason','--original-host-context','--bootstrap-config','--allow-bootstrap-write','--protected-conversation-config','--protected-config','--allow-provider-development-attempt','--review-config','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--allow-develop-redo','--hold-revision','--disk-edits','--workflow-config','--allow-qa','--browser-qa','--rerun-unknown-qa','--rerun-blocked-qa','--runtime','--review-runtime','--feature','--input-limit','--call-timeout-minutes','--failover','--qa-fix-owner-config','--qa-fix-template-config','--qa-fix-review-config','--qa-fix-final-review-recovery-invocation','--allow-qa-fix-start','--auto-qa-fix',...fixLocalPermissions.keys()].includes(name),'invalid_arguments',`未知参数:${name}`);
|
|
238
|
+
if(['--development-rework','--review-continuation','--execution-optimizations','--external-models','--verification-precheck','--supersede-reviewed-evidence','--accept-superseded-code-drift','--rebind-spec-material','--allow-bootstrap-write','--allow-qa','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--allow-develop-redo','--hold-revision','--disk-edits','--rerun-unknown-qa','--rerun-blocked-qa','--failover','--allow-qa-fix-start','--auto-qa-fix',...fixLocalPermissions.keys()].includes(name))extra.set(name,true);
|
|
238
239
|
else{refuse(typeof argv[index+1]==='string'&&!argv[index+1].startsWith('--'),'invalid_arguments',`${name} 需要一个值`);extra.set(name,argv[++index]);}
|
|
239
240
|
}
|
|
240
241
|
if(controlPolicy){
|
|
@@ -259,7 +260,8 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
259
260
|
const autoFix=controlPolicy?controlPolicy.qaFix==='auto':extra.has('--auto-qa-fix');
|
|
260
261
|
const recoveryEnabled=flag=>controlPolicy?argv[4]==='resume':extra.has(flag);
|
|
261
262
|
const launchRecovery=['--integration-evidence','--accept-integration-digest','--revise-qa-config','--qa-config-revision-reason','--rerun-unknown-qa','--rerun-blocked-qa',
|
|
262
|
-
'--rebind-spec-material','--spec-rebind-reason','--revise-scope','--scope-revision-reason','--development-rework','--development-rework-reason'
|
|
263
|
+
'--rebind-spec-material','--spec-rebind-reason','--revise-scope','--scope-revision-reason','--development-rework','--development-rework-reason',
|
|
264
|
+
'--review-continuation','--review-continuation-reason'].some(flag=>extra.has(flag));
|
|
263
265
|
refuse(!extra.has('--expected-control')||(controlPolicy&&launchRecovery&&argv[4]==='resume'),'invalid_input',
|
|
264
266
|
'--expected-control 仅用于新版 --mode resume 的显式启动恢复。');
|
|
265
267
|
if(controlPolicy&&launchRecovery)refuse(argv[4]==='resume'&&extra.has('--expected-control'),'invalid_input',
|
|
@@ -267,6 +269,10 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
267
269
|
const expectedControl=extra.has('--expected-control')?readLaunchControlFile(extra.get('--expected-control')):null;
|
|
268
270
|
const scopeRequested=extra.has('--revise-scope')||extra.has('--scope-revision-reason');
|
|
269
271
|
const reworkRequested=extra.has('--development-rework')||extra.has('--development-rework-reason');
|
|
272
|
+
// Third controlled review: the pair grants one continuation on a v2 resume.
|
|
273
|
+
const continuationRequested=extra.has('--review-continuation')||extra.has('--review-continuation-reason');
|
|
274
|
+
refuse(!continuationRequested||controlPolicy&&argv[4]==='resume'&&extra.has('--review-continuation')
|
|
275
|
+
&&extra.has('--review-continuation-reason'),'invalid_input','第三次受控审查需要新版 --mode resume、--expected-control 以及成对的 --review-continuation 与 --review-continuation-reason。');
|
|
270
276
|
refuse(!scopeRequested&&!reworkRequested||controlPolicy&&argv[4]==='resume'
|
|
271
277
|
&&(!scopeRequested||extra.has('--revise-scope')&&extra.has('--scope-revision-reason'))
|
|
272
278
|
&&(!reworkRequested||extra.has('--development-rework')&&extra.has('--development-rework-reason')),'invalid_input');
|
|
@@ -275,7 +281,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
275
281
|
const integrationRequested=extra.has('--integration-evidence')||extra.has('--accept-integration-digest');
|
|
276
282
|
refuse(!integrationRequested||controlPolicy&&argv[4]==='resume'&&extra.has('--integration-evidence')
|
|
277
283
|
&&extra.has('--accept-integration-digest')&&/^[a-f0-9]{64}$/.test(extra.get('--accept-integration-digest'))
|
|
278
|
-
&&!['--revise-scope','--scope-revision-reason','--development-rework','--development-rework-reason',
|
|
284
|
+
&&!['--revise-scope','--scope-revision-reason','--development-rework','--development-rework-reason','--review-continuation','--review-continuation-reason',
|
|
279
285
|
'--revise-qa-config','--qa-config-revision-reason','--rerun-unknown-qa','--rerun-blocked-qa','--qa-environment-failure',
|
|
280
286
|
'--rebind-spec-material','--spec-rebind-reason','--supersede-reviewed-evidence','--supersede-reason',
|
|
281
287
|
'--supersede-target','--accept-superseded-code-drift','--hold-revision'].some(flag=>extra.has(flag)),
|
|
@@ -398,7 +404,9 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
398
404
|
?await protectedExecutionFor(definition,argv[6],extra,review,argv[4],workflow,bridge,bootstrap,externalModels,executionPolicy,controlPolicy)
|
|
399
405
|
:executionFor(definition,argv[6],bridge,review,null,workflow,qaEnabled,runtime,
|
|
400
406
|
{...(callTimeoutMs!==null?{callTimeoutMs}:{}),...(controlPolicy?{controlPolicy}:{}),...(extra.has('--review-runtime')?{reviewRuntime:extra.get('--review-runtime')}:{}),...(executionPolicy?{executionPolicy}:{}),...(externalModels?{externalModels}:{}),...(extra.has('--verification-precheck')?{verificationPrecheck:true}:{}),...(extra.has('--original-host-context')?{originalHostContextId:extra.get('--original-host-context')}:{}),...(protection?{protection}:{}),...(bootstrap?{bootstrap:{...bootstrap,allowWrite:(controlPolicy?controlPolicy.bootstrap==='write':extra.has('--allow-bootstrap-write'))}}:{})});
|
|
401
|
-
|
|
407
|
+
refuse(!extra.has('--disk-edits')||(argv[4]==='resume'&&!extra.has('--protected-config')&&!extra.has('--protected-conversation-config')),'invalid_arguments',
|
|
408
|
+
'--disk-edits 仅允许非受保护当前会话运行的 resume 模式(先用 mode:create 的 status 冻结基线,再在工作区直接修改代码)。');
|
|
409
|
+
run=await openControlRun(definition,argv[4],execution,{reviewedIntegration,qaConfigRevision,rerunUnknownQa:extra.has('--rerun-unknown-qa'),rerunBlockedQa:extra.has('--rerun-blocked-qa'),qaEnvironmentFailure:extra.get('--qa-environment-failure')??null,supersedeReason:extra.get('--supersede-reason')??null,acceptSupersededCodeDrift:extra.has('--accept-superseded-code-drift'),allowAbandonReview:recoveryEnabled('--allow-abandon-review'),allowAbandonEffect:recoveryEnabled('--allow-abandon-effect'),allowBootstrapReviewRecovery:recoveryEnabled('--allow-bootstrap-review-recovery'),allowDevelopRedo:recoveryEnabled('--allow-develop-redo'),...(extra.has('--hold-revision')?{holdRevision:true}:{}),...(extra.has('--disk-edits')?{diskEdits:true}:{}),scopeRevision,developmentReworkReason:extra.get('--development-rework-reason')??null,reviewContinuationReason:extra.get('--review-continuation-reason')??null,specRebindReason:extra.get('--spec-rebind-reason')??null,expectedControl,supersedeTarget});
|
|
402
410
|
}
|
|
403
411
|
if(run.blocked){output.write(JSON.stringify({outcome:'blocked',admission:run.blocked})+'\n');return 1;}
|
|
404
412
|
// 期限按每次启动传入值生效(只校验不低于创建时的值),所以每次都明确报出,不悄悄变化
|
|
@@ -466,7 +474,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
466
474
|
const protectedHistoryHint=code==='fingerprint_mismatch'&&argv[4]==='resume'&&argv.includes('--protected-config')
|
|
467
475
|
?' --protected-config 的配置指纹不匹配。旧 createCodexExecution 组装的 CLI 恢复入口已停用;无旧 grant 登记时不能仅凭指纹识别旧运行,不能自动转换。若属于这种旧运行,重复原参数无法恢复;保留现场,只读查看:node scripts/cm-ai-run.mjs inspect-history --config RUN_DEFINITION.json(使用原运行定义文件)。现代 provider 运行仍须核对原配置漂移。':null;
|
|
468
476
|
if(protectedHistoryHint)cause.reason=(typeof cause.reason==='string'?cause.reason:'')+protectedHistoryHint;
|
|
469
|
-
const reason=REASONED_CODES.includes(code)&&typeof cause?.reason==='string'&&cause.reason
|
|
477
|
+
const reason=REASONED_CODES.includes(code)&&typeof cause?.reason==='string'&&Buffer.byteLength(cause.reason,'utf8')<=8192
|
|
470
478
|
&&!/[\r\n\0]/.test(cause.reason)?cause.reason:null;
|
|
471
479
|
if(code==='handoff_exists')error.write(`[host] ${REVIEWED_HANDOFF_HINT}\n`);
|
|
472
480
|
if(['supersede_code_drift','fingerprint_mismatch'].includes(code)&&reason)error.write(`[host] ${reason}\n`);
|
|
@@ -614,3 +614,15 @@ test('host fixture startup failure retains bounded process diagnostics',async()=
|
|
|
614
614
|
assert(!JSON.stringify(result.diagnostic).includes(f.root));
|
|
615
615
|
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
616
616
|
});
|
|
617
|
+
|
|
618
|
+
import {preflightMissingReason} from '../runtime/js/cm-ai/host-conversation-execution.mjs';
|
|
619
|
+
// 2026-12-01 探针:tool_preflight_missing 没有原因。原因须写明审查端和重做命令,单行、不含本机路径。
|
|
620
|
+
test('tool_preflight_missing reason names the reviewer and the matching preflight command',()=>{
|
|
621
|
+
const other=preflightMissingReason('claude',{preflight:{passed:true,cli_model:'fixture'},model:'fixture',cwd:'/private/fixture-root'});
|
|
622
|
+
assert.match(other,/审查端是 claude,review-config 里的预检是给 codex 做的/);assert.match(other,/--review-model fixture --runtime claude/);
|
|
623
|
+
const none=preflightMissingReason('codex',{preflight:null,model:'unconfigured',cwd:'/private/fixture-root'});
|
|
624
|
+
assert.match(none,/没有预检回执/);assert.match(none,/--review-model \{审查模型\} --runtime codex/);
|
|
625
|
+
const external=preflightMissingReason('codex',{preflight:{passed:true,cli_model:'pair'},model:'pair',effort:'high',cwd:'/private/fixture-root'});
|
|
626
|
+
assert.match(external,/--external-provider codex --external-models-config/);assert.match(external,/必须等于本运行冻结的模型 pair、强度 high/);
|
|
627
|
+
for(const reason of [other,none,external]){assert.doesNotMatch(reason,/fixture-root|[\r\n\0]/);assert(Buffer.byteLength(reason,'utf8')<=8192);}
|
|
628
|
+
});
|