@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
|
@@ -20,20 +20,20 @@ test('drivers prepare the redo answer for a timed-out develop (develop_call_time
|
|
|
20
20
|
assert.deepEqual(projectDevelopAttempts(history.state,'advance',[]).attempts,[]);
|
|
21
21
|
const projected=projectedRunnerStatus(history,config);
|
|
22
22
|
assert.deepEqual([projected.state,projected.code],['blocked','develop_call_timeout']);
|
|
23
|
-
assert.deepEqual(projectDevelopAttempts(projected,'advance',[]).attempts,[1]);
|
|
24
|
-
assert.deepEqual(batchDevelopAttempts(projected,'1.work/T-002',[]),[1]);
|
|
23
|
+
assert.deepEqual(projectDevelopAttempts(projected,'advance',[]).attempts,[1,2]);
|
|
24
|
+
assert.deepEqual(batchDevelopAttempts(projected,'1.work/T-002',[]),[1,2]);
|
|
25
25
|
});
|
|
26
26
|
test('drivers prepare no developer answer for a re-check (check_answer_missing)',async t=>{
|
|
27
27
|
const f=gapFixture(t,'driver-recheck');
|
|
28
28
|
await gapSession(f,'create',gapExecution(f,{developer:['round-1\n'],checks:['hang']}),[['advance',1]]);
|
|
29
29
|
const {history,config}=replay(f),projected=projectedRunnerStatus(history,config);
|
|
30
30
|
assert.deepEqual([projected.state,projected.code],['blocked','check_answer_missing']);
|
|
31
|
-
assert.deepEqual(projectDevelopAttempts(projected,'advance',[]).attempts,[]);
|
|
32
|
-
assert.deepEqual(batchDevelopAttempts(projected,'1.work/T-002',[]),[]);
|
|
33
|
-
// Codex round 1: with
|
|
34
|
-
const reach=projectDevelopAttempts(projected,'advance',[
|
|
31
|
+
assert.deepEqual(projectDevelopAttempts(projected,'advance',[]).attempts,[2]);
|
|
32
|
+
assert.deepEqual(batchDevelopAttempts(projected,'1.work/T-002',[]),[2]);
|
|
33
|
+
// Codex round 1: with direct round-1 review, the same advance can reach round 2.
|
|
34
|
+
const reach=projectDevelopAttempts(projected,'advance',[]);
|
|
35
35
|
assert.deepEqual([reach.attempts,reach.reviewAfterDevelop,reach.holdable],[[2],true,true]);
|
|
36
|
-
assert.deepEqual(batchDevelopAttempts(projected,'1.work/T-002',[
|
|
36
|
+
assert.deepEqual(batchDevelopAttempts(projected,'1.work/T-002',[]),[2]);
|
|
37
37
|
// Without a round-2 answer the driver launches with --hold-revision: the re-check and
|
|
38
38
|
// its review run, then the task stops at changes_requested; no develop is asked.
|
|
39
39
|
const before=f.calls.developer;
|
|
@@ -41,11 +41,11 @@ test('drivers prepare no developer answer for a re-check (check_answer_missing)'
|
|
|
41
41
|
assert.deepEqual([held.state,held.code,held.identity.attempt],['changes_requested','revision_answer_required',2],JSON.stringify(held));
|
|
42
42
|
assert.equal(f.calls.developer,before);
|
|
43
43
|
});
|
|
44
|
-
test('drivers preflight both rounds for a retryable round-1 block
|
|
44
|
+
test('drivers preflight both rounds for a retryable round-1 block before direct round-1 review',()=>{
|
|
45
45
|
const status={state:'blocked',code:'develop_call_timeout',attempt:1};
|
|
46
|
-
const reach=projectDevelopAttempts(status,'advance',[
|
|
46
|
+
const reach=projectDevelopAttempts(status,'advance',[]);
|
|
47
47
|
assert.deepEqual([reach.attempts,reach.reviewAfterDevelop],[[1,2],true]);
|
|
48
|
-
assert.deepEqual(projectDevelopAttempts(status,'advance',[]).attempts,[1]);
|
|
49
|
-
assert.deepEqual(batchDevelopAttempts(status,'1.work/T-002',[
|
|
50
|
-
assert.deepEqual(batchDevelopAttempts({...status,attempt:2},'1.work/T-002',[
|
|
48
|
+
assert.deepEqual(projectDevelopAttempts(status,'advance',[]).attempts,[1,2]);
|
|
49
|
+
assert.deepEqual(batchDevelopAttempts(status,'1.work/T-002',[]),[1,2]);
|
|
50
|
+
assert.deepEqual(batchDevelopAttempts({...status,attempt:2},'1.work/T-002',[]),[2]);
|
|
51
51
|
});
|
|
@@ -67,14 +67,7 @@ export function gapExecution(f,{developer=[],checks=[],verdicts=[]}={}){
|
|
|
67
67
|
throw Object.assign(new Error(beforeDispatch),{code:beforeDispatch});}
|
|
68
68
|
return developerRun(request,control);
|
|
69
69
|
}},
|
|
70
|
-
reviewers:[reviewer],reviewInvocation:{developerThreadId:'author-thread',excludedThreadIds:['control'],
|
|
71
|
-
authorize:(value,{authorizationAt})=>{const body={version:1,kind:'cm-review-dispatch-grant',
|
|
72
|
-
grantId:'grant',adapterId:'codex-review-adapter',invocationId:value.invocationId,
|
|
73
|
-
requestDigest:value.requestDigest,identity:value.identity,reviewerId:'reviewer',
|
|
74
|
-
logicalContextId:value.contextId,packageDigest:value.payload.reviewPackage.packageDigest,
|
|
75
|
-
hostContextId:'control',decisionId:'approved',decision:'approved',issuedAt:authorizationAt,
|
|
76
|
-
expiresAt:authorizationAt+60000};return {...body,grantDigest:digest(body)};}},
|
|
77
|
-
hostDecision:{status:'approved'},check:(request,control)=>{
|
|
70
|
+
reviewers:[reviewer],reviewInvocation:{developerThreadId:'author-thread',excludedThreadIds:['control']},check:(request,control)=>{
|
|
78
71
|
f.calls.check++;
|
|
79
72
|
const item=checkQueue.shift();
|
|
80
73
|
if(item==='hang')return new Promise(()=>{});
|
|
@@ -22,14 +22,15 @@ import fs from 'node:fs';
|
|
|
22
22
|
import path from 'node:path';
|
|
23
23
|
import {fileURLToPath} from 'node:url';
|
|
24
24
|
import {createHostCheck,reportHostCheckProgress} from '../runtime/js/cm-ai/host-check.mjs';
|
|
25
|
-
import {
|
|
25
|
+
import {readQaAssessment} from '../runtime/js/cm-ai/host-qa-policy.mjs';
|
|
26
26
|
import {validateHostWorkflowConfiguration} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
|
|
27
27
|
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
28
28
|
import {validateRunDefinition} from './cm-ai-run.mjs';
|
|
29
29
|
import {createCmAiBatch} from './cm-ai-batch-run.mjs';
|
|
30
30
|
import {readConversationReviewConfiguration,readConversationProtection} from './cm-ai-host.mjs';
|
|
31
31
|
import {validateCmAiAnswer,developFilename,preflightDevelopDeliveries,baselineScope,inputLimitFrom,
|
|
32
|
-
applyDevelopEdits,protectedDevelopEdits,developPreview,plannedCheckResults,journalRestBytes
|
|
32
|
+
applyDevelopEdits,protectedDevelopEdits,developPreview,plannedCheckResults,journalRestBytes,
|
|
33
|
+
readDriverControl,controlDevelopAttempts} from './cm-ai-drive.mjs';
|
|
33
34
|
import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs';
|
|
34
35
|
import {readRunnerHistory,projectedRunnerStatus,RECHECK_CODES,DOCUMENTATION_SYNC_CODES} from '../runtime/js/cm-ai/durable-runner-state.mjs';
|
|
35
36
|
import {developmentRetryable} from '../runtime/js/cm-ai/cm-ai-conversation-entry.mjs';
|
|
@@ -45,7 +46,7 @@ const KINDS={develop:'develop.json',qa_assess:'qa-assess.json',
|
|
|
45
46
|
const MEMBER_ACTION_FLAGS={develop_redo:'--allow-develop-redo',abandon_effect:'--allow-abandon-effect',
|
|
46
47
|
abandon_review:'--allow-abandon-review',bootstrap_review_recover:'--allow-bootstrap-review-recovery'};
|
|
47
48
|
const PAIRS=new Set(['--external-models-config','--runtime','--review-config','--browser-qa','--protected-conversation-config',
|
|
48
|
-
'--protected-config','--allow-provider-development','--
|
|
49
|
+
'--protected-config','--allow-provider-development','--input-limit','--qa-environment-failure',...Object.values(MEMBER_ACTION_FLAGS)]);
|
|
49
50
|
const FLAGS=new Set(['--execution-optimizations','--external-models','--allow-qa','--rerun-unknown-qa','--rerun-blocked-qa','--verification-precheck',
|
|
50
51
|
'--allow-bootstrap-write']);
|
|
51
52
|
const isObject=x=>x!==null&&typeof x==='object'&&!Array.isArray(x);
|
|
@@ -60,23 +61,21 @@ export function batchMemberActionPlanError(operation,plan,permissions,keys){
|
|
|
60
61
|
if(!permissions.some((name,index)=>name===flag&&permissions[index+1]===plan.taskKey))return `${operation} 需要 permissions 中的 ${flag} ${plan.taskKey}`;
|
|
61
62
|
return null;
|
|
62
63
|
}
|
|
63
|
-
export function batchDevelopAttempts(state,key,permissions){
|
|
64
|
-
|
|
64
|
+
export function batchDevelopAttempts(state,key,permissions,controlPolicy=null){
|
|
65
|
+
if(controlPolicy)return controlPolicy.development==='provider'?[]:controlDevelopAttempts(state,'advance').attempts;
|
|
66
|
+
// The configured round-1 review may lead into round 2 within the
|
|
65
67
|
// same advance (Codex round 1 on Q28): list it too; a missing a2 answer then
|
|
66
68
|
// holds the task after that review (revision_answer_required) instead of
|
|
67
69
|
// sending an unanswerable develop request.
|
|
68
|
-
const reviewNext=state.attempt===1
|
|
70
|
+
const reviewNext=state.attempt===1;
|
|
69
71
|
// A re-check (check_answer_*) re-runs only the checks: no developer answer for this round.
|
|
70
72
|
if(state.state==='blocked'&&RECHECK_CODES.includes(state.code))return reviewNext?[2]:[];
|
|
71
73
|
// Q16/Q17: a documentation-only redo reuses the journaled developer answer.
|
|
72
74
|
if(state.state==='blocked'&&DOCUMENTATION_SYNC_CODES.includes(state.code))return reviewNext?[2]:[];
|
|
73
75
|
if(developmentRetryable(state))return reviewNext?[1,2]:[state.attempt];
|
|
74
|
-
if(state.state==='ready'&&state.attempt===1
|
|
75
|
-
flag==='--allow-review'&&permissions[index+1]===`${key}:1`))return [1,2];
|
|
76
|
+
if(state.state==='ready'&&state.attempt===1)return [1,2];
|
|
76
77
|
if(['ready','changes_requested'].includes(state.state))return [state.attempt];
|
|
77
|
-
if(['awaiting_review','pending_review'].includes(state.state)&&state.attempt<2
|
|
78
|
-
&&permissions.some((flag,index)=>flag==='--allow-review'
|
|
79
|
-
&&permissions[index+1]===`${key}:${state.attempt}`))return [state.attempt+1];
|
|
78
|
+
if(['awaiting_review','pending_review'].includes(state.state)&&state.attempt<2)return [state.attempt+1];
|
|
80
79
|
return [];
|
|
81
80
|
}
|
|
82
81
|
function actualCwd(bundle,key,generation=1){
|
|
@@ -105,16 +104,21 @@ function checkCommandShape(commands,key,plan,executionPolicy){
|
|
|
105
104
|
}
|
|
106
105
|
function preflight(){
|
|
107
106
|
if(process.argv.length===3&&['--help','-h'].includes(process.argv[2])){
|
|
107
|
+
process.stdout.write('新版 PLAN.controlConfig 为相对 PLAN 的 v2 控制配置路径;permissions 禁止所有 --allow-*,批次 qaFix 只能为 disabled。普通 advance 自动独立审查;缺少 develop-a2.json 时保持 revision_answer_required。显式成员恢复需要 resume、taskKey 与此前 status 返回的 PLAN.expectedControl,驾驶员不会读取新目标覆盖它。\n');
|
|
108
108
|
process.stdout.write('用法: cm-ai-batch-drive.mjs --plan PLAN.json <operation>\n'
|
|
109
109
|
+'operation: advance, status, cancel, reconcile_review(taskKey、invocationId), develop_redo / abandon_effect / abandon_review / bootstrap_review_recover(resume、PLAN.taskKey、单行 PLAN.reason,permissions 带对应 --allow-… 任务)。PLAN: config, mode, hostContext, permissions, answers, checks, checkTimeoutMs。\n'
|
|
110
110
|
+'checks 每项为 {id,command,timeoutMs?};超时为 1..3600000 整数,默认 900000 ms(15 分钟)。\n'
|
|
111
111
|
+'develop.json.edits 与单任务驾驶员相同:内容文件、{file,mode}、{mode}、{delete:true};启动前同样拒绝超限、空交付与受保护模式下的非 UTF-8 内容(尚未开跑的后续任务不看代码树,只做答案本身就能判定的检查:单文件 1 MiB、答案写入的 scope 文件合计 2 MiB,等等;运行存档单条记录上限要看该任务开跑时的代码树,驾驶员事先算不出,超限交付写入后由宿主拦下,停在可重试的 blocked/develop_package_too_large)。\n'
|
|
112
|
-
+'
|
|
112
|
+
+'按已有配置自动审查,还没有 develop-a2.json 时照常启动:审查若要求修改,该任务停在 changes_requested(revision_answer_required),读 .reviews/<feature>-<task>-r1.md 的 findings 写好 develop-a2.json 后再 advance。\n');
|
|
113
113
|
process.exit(0);
|
|
114
114
|
}
|
|
115
115
|
const loaded=loadPlanFile({name:'cm-ai-batch-drive.mjs',known:new Set(['advance','status','cancel','reconcile_review',...Object.keys(MEMBER_ACTION_FLAGS)])});
|
|
116
116
|
const {plan,base,operation}=loaded;
|
|
117
117
|
requireFields(plan,['config','mode','hostContext','permissions']);
|
|
118
|
+
let control;
|
|
119
|
+
try{control=readDriverControl(plan,base,operation,operation==='reconcile_review'||Object.hasOwn(MEMBER_ACTION_FLAGS,operation));}
|
|
120
|
+
catch(error){stop(2,error.message);}
|
|
121
|
+
if(control&&control.policy.qaFix!=='disabled')stop(2,'invalid_arguments: batch qaFix 必须为 disabled');
|
|
118
122
|
try{planCheckTimeout(plan);}catch(error){stop(2,error.message);}
|
|
119
123
|
if(!['create','resume'].includes(plan.mode))stop(2,'mode 只能是 create 或 resume');
|
|
120
124
|
if(!nonempty(plan.hostContext))stop(2,'hostContext 必须是当前真实会话 ID');
|
|
@@ -186,7 +190,11 @@ function preflight(){
|
|
|
186
190
|
let externalModels;
|
|
187
191
|
try{externalModels=readBatchExternalModels({batch,started:hasStore,enabled:permissions.includes('--external-models'),inputFile:argumentValue('--external-models-config'),providers:[routes.coderRuntime,routes.reviewerRuntime].filter(Boolean)});}catch(error){stop(2,error.code??'external_model_configuration_invalid');}
|
|
188
192
|
if(operation==='reconcile_review'&&(plan.mode!=='resume'||!keys.includes(plan.taskKey)||!nonempty(plan.invocationId)))stop(2,'reconcile_review requires resume, taskKey and original invocationId');
|
|
189
|
-
|
|
193
|
+
if(control&&Object.hasOwn(MEMBER_ACTION_FLAGS,operation)){
|
|
194
|
+
if(!keys.includes(plan.taskKey)||!nonempty(plan.reason)||Buffer.byteLength(plan.reason,'utf8')>500||/[\r\n\0]/.test(plan.reason))
|
|
195
|
+
stop(2,`${operation} 需要本批次 taskKey、expectedControl 与单行 reason(最多 500 UTF-8 字节)`);
|
|
196
|
+
}
|
|
197
|
+
const memberError=control?null:batchMemberActionPlanError(operation,plan,permissions,keys);if(memberError)stop(2,memberError);
|
|
190
198
|
for(let i=0;i<permissions.length;i++)if(PAIRS.has(permissions[i])){
|
|
191
199
|
const name=permissions[i],value=permissions[++i];
|
|
192
200
|
if(['--review-config','--protected-conversation-config','--protected-config'].includes(name)){
|
|
@@ -206,7 +214,7 @@ function preflight(){
|
|
|
206
214
|
permissions[i]=file;
|
|
207
215
|
}else if(Object.values(MEMBER_ACTION_FLAGS).includes(name)){
|
|
208
216
|
if(!keys.includes(value))stop(2,`${name} 需要本批次的 FEATURE/TASK: ${value}`);
|
|
209
|
-
}else if(
|
|
217
|
+
}else if(name==='--allow-provider-development'){
|
|
210
218
|
const cut=value.lastIndexOf(':');
|
|
211
219
|
if(!keys.includes(value.slice(0,cut))||!['1','2'].includes(value.slice(cut+1)))
|
|
212
220
|
stop(2,`${name} 任务授权无效: ${value}`);
|
|
@@ -217,14 +225,12 @@ function preflight(){
|
|
|
217
225
|
stop(2,'--runtime 只能是 codex 或 claude');
|
|
218
226
|
if(permissions.includes('--browser-qa')&&!['available','unavailable'].includes(argument('--browser-qa')))
|
|
219
227
|
stop(2,'--browser-qa 只能是 available 或 unavailable');
|
|
220
|
-
if(permissions.includes('--allow-review')&&!permissions.includes('--review-config'))
|
|
221
|
-
stop(2,'--allow-review 需要 --review-config');
|
|
222
228
|
if(permissions.includes('--allow-provider-development')&&!permissions.includes('--protected-config'))
|
|
223
229
|
stop(2,'--allow-provider-development 需要 --protected-config');
|
|
224
|
-
if(Object.values(bundle.workflows).some(workflow=>workflow?.qa)&&!permissions.includes('--allow-qa'))
|
|
230
|
+
if(!control&&Object.values(bundle.workflows).some(workflow=>workflow?.qa)&&!permissions.includes('--allow-qa'))
|
|
225
231
|
stop(2,'有 QA 工作流时缺少 --allow-qa');
|
|
226
232
|
const protectedMode=permissions.includes('--protected-config')||permissions.includes('--protected-conversation-config');
|
|
227
|
-
const providerAll=permissions.includes('--protected-config')&&keys.every(key=>
|
|
233
|
+
const providerAll=control?control.policy.development==='provider':permissions.includes('--protected-config')&&keys.every(key=>
|
|
228
234
|
permissions.includes(`${key}:1`)&&permissions[permissions.indexOf(`${key}:1`)-1]==='--allow-provider-development');
|
|
229
235
|
let live;
|
|
230
236
|
try{live=driverLiveEvidence(plan,{base,protectedRoots:[batch.codeProject,batch.specsDir,path.resolve(batch.codeProject,'..','.cm-worktrees'),...(batch.codeProjects??[])],
|
|
@@ -246,11 +252,13 @@ function preflight(){
|
|
|
246
252
|
kinds.push('check');
|
|
247
253
|
if(workflow?.documentationPaths?.length)kinds.push('documentation_sync');
|
|
248
254
|
}
|
|
249
|
-
if(workflow
|
|
255
|
+
if(workflow&&(control||workflow.qa)){
|
|
250
256
|
// A rescheduled second generation runs serially and asks qa_assess like a serial task.
|
|
251
257
|
if(!batch.parallel?.some(group=>group.includes(key))||rescheduled.has(key))kinds.push('qa_assess');
|
|
252
|
-
|
|
253
|
-
|
|
258
|
+
if(workflow.qa&&(!control||control.policy.qa==='run')){
|
|
259
|
+
const cases=readJson(path.join(batch.specsDir,task.feature,'test-cases.json'),'test-cases');
|
|
260
|
+
for(const kind of ['logic','browser'])if(cases?.cases?.some(item=>item.kind===kind))kinds.push(`qa_${kind}`);
|
|
261
|
+
}
|
|
254
262
|
}
|
|
255
263
|
if(workflow)kinds.push('documentation_inspect');
|
|
256
264
|
const evidence=kinds.filter(kind=>['qa_logic','qa_browser'].includes(kind)&&!live.has(kind));
|
|
@@ -271,23 +279,23 @@ function preflight(){
|
|
|
271
279
|
const snapshot=readExecutionSnapshot({specsRoot:batch.specsDir,identity:{repositoryId:batch.repositoryId,runId:existing[0]}});
|
|
272
280
|
const history=readRunnerHistory(snapshot.records,snapshot.records[0].payload.config,3);
|
|
273
281
|
// Q28: decide from what the host will show (projected answer-gap blocks), not the raw replay state.
|
|
274
|
-
attempts=batchDevelopAttempts(projectedRunnerStatus(history,snapshot.records[0].payload.config),key,permissions);current=history.state.attempt;
|
|
282
|
+
attempts=batchDevelopAttempts(projectedRunnerStatus(history,snapshot.records[0].payload.config),key,permissions,control?.policy??null);current=history.state.attempt;
|
|
275
283
|
journal={baseline:snapshot.records[0].payload.baseline,generation:existing[1].generation,
|
|
276
284
|
frame:journalRestBytes(snapshot.records)};
|
|
277
285
|
}catch(error){stop(2,`任务 ${key} 无法只读检查恢复存档: ${error.code??error.message}`);}
|
|
278
286
|
}
|
|
279
287
|
// A task with no run yet (a new batch, or a later task on resume) starts at
|
|
280
|
-
// attempt 1;
|
|
281
|
-
if(journal===null
|
|
288
|
+
// attempt 1; the configured first-round review can reach attempt 2 as well.
|
|
289
|
+
if(journal===null)attempts=[1,2];
|
|
282
290
|
const deliveries=[],definition=definitions.get(key);
|
|
283
291
|
for(const attempt of attempts){
|
|
284
292
|
const file=path.join(taskRoot??'',developFilename(taskRoot??'',attempt));
|
|
285
293
|
if(!taskRoot||!fs.existsSync(file)){
|
|
286
|
-
// A later attempt is only reached if the review
|
|
294
|
+
// A later attempt is only reached if the configured review asks
|
|
287
295
|
// for changes. Without its answer the task stops right after that review.
|
|
288
296
|
if(attempt>current){
|
|
289
297
|
holds.push(key);
|
|
290
|
-
stderr(`任务 ${key} 没有 ${path.basename(file)}
|
|
298
|
+
stderr(`任务 ${key} 没有 ${path.basename(file)}:本次审查若要求修改,任务会停在 changes_requested(revision_answer_required),不会发起第 ${attempt} 轮开发;读取 .reviews/${task.feature.replace(/^\d+\./,'')}-${task.taskId}-r${attempt-1}.md 的 findings,写 ${file} 后再 advance`);
|
|
291
299
|
continue;
|
|
292
300
|
}
|
|
293
301
|
stop(2,attempt===1?`任务 ${key} 会反问 develop,但答案文件不存在: ${file}`
|
|
@@ -322,7 +330,7 @@ function preflight(){
|
|
|
322
330
|
if(answers[key].documentation_sync)for(const target of Object.keys(answers[key].documentation_sync.edits))
|
|
323
331
|
if(!workflow.documentationPaths.includes(target))stop(2,`任务 ${key} documentation-sync.json.edits 越过文档 scope: ${target}`);
|
|
324
332
|
}
|
|
325
|
-
return {...loaded,executionPolicy,bundle,definitions,runs,config,permissions,answers,developAnswers,answerRoot:root,holds,live};
|
|
333
|
+
return {...loaded,control,executionPolicy,bundle,definitions,runs,config,permissions,answers,developAnswers,answerRoot:root,holds,live};
|
|
326
334
|
}
|
|
327
335
|
|
|
328
336
|
let loaded;
|
|
@@ -382,16 +390,27 @@ async function answerFor(row,answers,paths,control){
|
|
|
382
390
|
contextDigest:row.payload.contextDigest,
|
|
383
391
|
at:value.at??new Date().toISOString().replace(/\.\d{3}Z$/,'Z')};
|
|
384
392
|
if(row.kind==='qa_assess'){
|
|
385
|
-
|
|
393
|
+
readQaAssessment(value);return value;
|
|
386
394
|
}
|
|
387
395
|
return null;
|
|
388
396
|
}
|
|
397
|
+
export function buildCmAiBatchDriveHostArgs(plan,permissions,config,controlConfig=null,holds=[]){
|
|
398
|
+
return ['serve','--config',config,...(Object.hasOwn(plan,'controlConfig')?['--mode',plan.mode]:[]),
|
|
399
|
+
'--host-context',plan.hostContext,
|
|
400
|
+
...(Object.hasOwn(plan,'controlConfig')?['--control-config',controlConfig??plan.controlConfig]:['--allow-development']),
|
|
401
|
+
...permissions,...holds.flatMap(key=>['--hold-revision',key])];
|
|
402
|
+
}
|
|
403
|
+
export function buildCmAiBatchDriveRequest(operation,plan){
|
|
404
|
+
const recovery=operation==='reconcile_review'||Object.hasOwn(MEMBER_ACTION_FLAGS,operation);
|
|
405
|
+
return {...(Object.hasOwn(plan,'controlConfig')?{version:2,...(recovery?{expectedControl:plan.expectedControl}:{})}:{}),
|
|
406
|
+
...(operation==='reconcile_review'?{taskKey:plan.taskKey,invocationId:plan.invocationId}
|
|
407
|
+
:Object.hasOwn(MEMBER_ACTION_FLAGS,operation)?{taskKey:plan.taskKey,reason:plan.reason}:{})};
|
|
408
|
+
}
|
|
389
409
|
function main(){
|
|
390
410
|
loaded=preflight();
|
|
391
411
|
const {plan,operation,bundle,config,permissions}=loaded;
|
|
392
|
-
driveHost({host:HOST,args:
|
|
393
|
-
|
|
394
|
-
:Object.hasOwn(MEMBER_ACTION_FLAGS,operation)?{taskKey:plan.taskKey,reason:plan.reason}:{},
|
|
412
|
+
driveHost({host:HOST,args:buildCmAiBatchDriveHostArgs(plan,permissions,config,loaded.control?.file,loaded.holds),
|
|
413
|
+
cwd:bundle.batch.codeProject,operation,request:buildCmAiBatchDriveRequest(operation,plan),
|
|
395
414
|
answers:loaded.answers,answerFor});
|
|
396
415
|
}
|
|
397
416
|
if(process.argv[1]&&fs.realpathSync(process.argv[1])===fileURLToPath(import.meta.url))main();
|
|
@@ -7,6 +7,7 @@ import {spawnSync} from 'node:child_process';
|
|
|
7
7
|
import {fileURLToPath} from 'node:url';
|
|
8
8
|
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
9
9
|
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
10
|
+
import {claudeReviewFingerprint} from '../runtime/js/cm-ai/worker-claude.mjs';
|
|
10
11
|
import {batchDevelopAttempts} from './cm-ai-batch-drive.mjs';
|
|
11
12
|
import {runLiveDriver} from './fixtures/live-evidence-driver.mjs';
|
|
12
13
|
|
|
@@ -41,6 +42,8 @@ function fixture(t,count=1){
|
|
|
41
42
|
fs.writeFileSync(path.join(root,'review.json'),JSON.stringify({model:'fixture',preflight:{passed:true,
|
|
42
43
|
cli_model:'fixture',prompt_transport:'stdin',config_fingerprint:configFingerprint({cwd:codeProject,model:'fixture'})}}));
|
|
43
44
|
fs.copyFileSync(reviewer,path.join(bin,'codex'));fs.chmodSync(path.join(bin,'codex'),0o700);
|
|
45
|
+
const claudeReviewer=fileURLToPath(new URL('./fixtures/claude-review-process.mjs',import.meta.url));
|
|
46
|
+
fs.copyFileSync(claudeReviewer,path.join(bin,'claude'));fs.chmodSync(path.join(bin,'claude'),0o700);
|
|
44
47
|
const answers=path.join(root,'answers','1.work','T-001');fs.mkdirSync(answers,{recursive:true});
|
|
45
48
|
fs.writeFileSync(path.join(answers,'target.txt'),'export const value = 42;\n');
|
|
46
49
|
const write=(name,value)=>fs.writeFileSync(path.join(answers,name),JSON.stringify(value));
|
|
@@ -49,7 +52,7 @@ function fixture(t,count=1){
|
|
|
49
52
|
const value={config:'batch.json',mode:'create',hostContext:'batch-host-a',
|
|
50
53
|
permissions:['--allow-qa'],answers:'answers',checks:Object.fromEntries(batch.tasks.map(task=>
|
|
51
54
|
[`1.work/${task.taskId}`,[{id:'syntax',command:[process.execPath,'--check',task.taskId==='T-001'?'target.mjs':'target2.mjs']}]])),...extra};
|
|
52
|
-
// A new batch requires
|
|
55
|
+
// A new batch requires bound review configuration for automatic review execution.
|
|
53
56
|
if(!value.permissions.includes('--review-config'))value.permissions=[...value.permissions,'--review-config','review.json'];
|
|
54
57
|
fs.writeFileSync(file,JSON.stringify(value));
|
|
55
58
|
return file;
|
|
@@ -62,8 +65,7 @@ function fixture(t,count=1){
|
|
|
62
65
|
}
|
|
63
66
|
function prepared(f){
|
|
64
67
|
f.write('develop.json',develop);
|
|
65
|
-
f.write('qa-assess.json',{
|
|
66
|
-
changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}});
|
|
68
|
+
f.write('qa-assess.json',{confirmed:true});
|
|
67
69
|
f.write('documentation-inspect.json',{status:'completed',reason:'README and task artifacts inspected'});
|
|
68
70
|
}
|
|
69
71
|
function noStore(f){assert.equal(fs.existsSync(f.store),false);assert.equal(fs.existsSync(path.join(f.specsDir,'运行日志.jsonl')),false);}
|
|
@@ -73,7 +75,7 @@ test('batch reaches live logic and browser QA through the real member host',asyn
|
|
|
73
75
|
acIds:[],taskIds:['T-001'],title:'Fixture observation',preconditions:[],steps:['Observe fixture'],expected:['value is 42'],cleanup:[]}));
|
|
74
76
|
fs.writeFileSync(path.join(f.specsDir,'1.work/test-cases.json'),JSON.stringify({schemaVersion:'1.0',feature:'work',cases}));
|
|
75
77
|
fs.writeFileSync(path.join(f.specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.work'],specFiles:buildManifest(f.specsDir)}));
|
|
76
|
-
const plan=f.plan({permissions:['--allow-qa','--
|
|
78
|
+
const plan=f.plan({permissions:['--allow-qa','--browser-qa','available'],
|
|
77
79
|
liveEvidence:{directory:'exchange',kinds:['qa_logic','qa_browser'],timeoutMs:1000}});
|
|
78
80
|
const out=await runLiveDriver(DRIVER,plan,'advance',row=>row.kind==='qa_logic'
|
|
79
81
|
?{verdict:'SUPPORTED',evidence:['Fixture target.mjs exports 42']}
|
|
@@ -93,7 +95,7 @@ test('batch live verification request can reject a written requirement without r
|
|
|
93
95
|
assert.equal(row.kind,'verification_precheck');
|
|
94
96
|
assert.match(fs.readFileSync(path.join(f.codeProject,'target.mjs'),'utf8'),/42/);
|
|
95
97
|
return {items:[{requirement:'value is 43',satisfied:false,evidence:'Fixture source exports 42'}]};
|
|
96
|
-
},{timeoutMs:60000,env:{...process.env,CM_WORKFLOW_HOME:path.join(f.root,'home'),CM_WORKFLOW_LOG_HOME:path.join(f.root,'logs')}});
|
|
98
|
+
},{timeoutMs:60000,env:{...process.env,PATH:path.join(f.root,'bin')+path.delimiter+process.env.PATH,CM_WORKFLOW_HOME:path.join(f.root,'home'),CM_WORKFLOW_LOG_HOME:path.join(f.root,'logs')}});
|
|
97
99
|
assert.equal(out.status,0,out.stderr);assert.equal(out.requests.length,1);
|
|
98
100
|
assert.match(out.stdout,/verification_precheck_failed/);
|
|
99
101
|
});
|
|
@@ -125,10 +127,10 @@ test('real batch host advances with authored edit and actual check, then resumes
|
|
|
125
127
|
const again=f.drive(f.plan({mode:'resume',originalHostContext:'batch-host-a'}),'advance');
|
|
126
128
|
assert.equal(again.status,0,again.stderr);
|
|
127
129
|
});
|
|
128
|
-
test('real batch reaches completion with
|
|
130
|
+
test('real batch reaches completion with automatic configured fixture review',t=>{
|
|
129
131
|
const f=fixture(t);prepared(f);
|
|
130
132
|
f.write('develop-a2.json',develop);
|
|
131
|
-
const permissions=['--allow-qa','--review-config','review.json'
|
|
133
|
+
const permissions=['--allow-qa','--review-config','review.json'];
|
|
132
134
|
const first=f.drive(f.plan({permissions}),'advance');
|
|
133
135
|
assert.equal(first.status,0,first.stderr);assert.match(first.stderr,/应答 check/);
|
|
134
136
|
let result=JSON.parse(first.stdout).result,stderr=first.stderr;
|
|
@@ -156,7 +158,7 @@ const developIntents=f=>{
|
|
|
156
158
|
};
|
|
157
159
|
test('batch review without a second-round answer stops at changes_requested after the first review',t=>{
|
|
158
160
|
const f=fixture(t);prepared(f);changesRequested(f);
|
|
159
|
-
const permissions=['--allow-qa','--review-config','review.json'
|
|
161
|
+
const permissions=['--allow-qa','--review-config','review.json'];
|
|
160
162
|
const run=f.drive(f.plan({permissions}),'advance');
|
|
161
163
|
assert.equal(run.status,0,run.stderr);
|
|
162
164
|
assert.match(run.stderr,/没有 develop-a2\.json/);assert.match(run.stderr,/\.reviews\/work-T-001-r1\.md/);
|
|
@@ -182,16 +184,19 @@ test('batch resume holds a later task that has no run yet when its second-round
|
|
|
182
184
|
for(const name of ['qa-assess.json','documentation-inspect.json'])
|
|
183
185
|
fs.copyFileSync(path.join(f.answers,name),path.join(later,name));
|
|
184
186
|
fs.writeFileSync(path.join(later,'develop.json'),JSON.stringify({...develop,edits:{'target2.mjs':'target2.txt'}}));
|
|
185
|
-
// T-001
|
|
187
|
+
// T-001 holds after declared changes, so T-002 has no run when the batch resumes.
|
|
188
|
+
changesRequested(f);
|
|
186
189
|
const first=f.drive(f.plan({permissions:['--allow-qa','--review-config','review.json']}),'advance');
|
|
187
|
-
assert.equal(first.status,0,first.stderr);assert.equal(JSON.parse(first.stdout).result.state,'
|
|
190
|
+
assert.equal(first.status,0,first.stderr);assert.equal(JSON.parse(first.stdout).result.state,'changes_requested');
|
|
191
|
+
fs.writeFileSync(path.join(f.answers,'target-a2.txt'),'export const value = 42; // revised\n');
|
|
192
|
+
f.write('develop-a2.json',{...develop,edits:{'target.mjs':'target-a2.txt'}});
|
|
188
193
|
// The reviewer approves T-001 and asks for changes on T-002.
|
|
189
194
|
const cli=path.join(f.root,'bin','codex');
|
|
190
195
|
fs.writeFileSync(cli,fs.readFileSync(reviewer,'utf8').replace("verdict:'approved'",
|
|
191
196
|
"verdict:prompt.includes('target2.mjs')?'changes_requested':'approved'")
|
|
192
197
|
.replace('findings:[]',"findings:prompt.includes('target2.mjs')?[{id:'F1',severity:'P2',path:'target2.mjs',message:'Revise',evidence:'Fixture finding'}]:[]"));
|
|
193
198
|
fs.chmodSync(cli,0o700);
|
|
194
|
-
const permissions=['--allow-qa','--review-config','review.json'
|
|
199
|
+
const permissions=['--allow-qa','--review-config','review.json'];
|
|
195
200
|
let result;
|
|
196
201
|
for(let n=0;n<4;n++){
|
|
197
202
|
const next=f.drive(f.plan({mode:'resume',originalHostContext:'batch-host-a',permissions}),'advance');
|
|
@@ -203,7 +208,7 @@ test('batch resume holds a later task that has no run yet when its second-round
|
|
|
203
208
|
});
|
|
204
209
|
test('batch hold without a second-round answer does not interfere with an approving review',t=>{
|
|
205
210
|
const f=fixture(t);prepared(f);
|
|
206
|
-
const permissions=['--allow-qa','--review-config','review.json'
|
|
211
|
+
const permissions=['--allow-qa','--review-config','review.json'];
|
|
207
212
|
const first=f.drive(f.plan({permissions}),'advance');assert.equal(first.status,0,first.stderr);
|
|
208
213
|
let result=JSON.parse(first.stdout).result;
|
|
209
214
|
for(let n=0;n<4&&result.state!=='run_done';n++){
|
|
@@ -243,7 +248,7 @@ test('batch driver lets a later task\'s second-round delete bring its delivered
|
|
|
243
248
|
const later=path.join(f.root,'answers','1.work','T-002');
|
|
244
249
|
fs.writeFileSync(path.join(later,'gen_c.bin.txt'),Buffer.alloc(100*1024,0x61));
|
|
245
250
|
fs.writeFileSync(path.join(later,'develop-a2.json'),JSON.stringify({...develop,edits:{'gen/b.bin':{delete:true},'gen/c.bin':'gen_c.bin.txt'}}));
|
|
246
|
-
const run=f.drive(f.plan({permissions:['--allow-qa','--review-config','review.json'
|
|
251
|
+
const run=f.drive(f.plan({permissions:['--allow-qa','--review-config','review.json']}),'advance');
|
|
247
252
|
assert.equal(run.status,0,run.stderr);assert.doesNotMatch(run.stderr,/仅答案写入/);assert.equal(fs.existsSync(f.store),true);
|
|
248
253
|
});
|
|
249
254
|
test('batch driver refuses a no-op or non-UTF-8 protected develop answer before launch',t=>{
|
|
@@ -264,7 +269,7 @@ test('batch review revision applies the second-round develop content',t=>{
|
|
|
264
269
|
.replace('findings:[]',"findings:[{id:'F1',severity:'P2',path:'target.mjs',message:'Revise value',evidence:'Fixture finding'}]"));
|
|
265
270
|
fs.writeFileSync(path.join(f.answers,'target-a2.txt'),'export const value = 43;\n');
|
|
266
271
|
f.write('develop-a2.json',{...develop,edits:{'target.mjs':'target-a2.txt'}});
|
|
267
|
-
const permissions=['--allow-qa','--review-config','review.json'
|
|
272
|
+
const permissions=['--allow-qa','--review-config','review.json'];
|
|
268
273
|
const run=f.drive(f.plan({permissions}),'advance');assert.equal(run.status,0,run.stderr);
|
|
269
274
|
assert.equal(fs.readFileSync(path.join(f.codeProject,'target.mjs'),'utf8'),'export const value = 43;\n');
|
|
270
275
|
});
|
|
@@ -288,6 +293,8 @@ test('D1 batch rejects invalid check timeout before opening a host',t=>{
|
|
|
288
293
|
|
|
289
294
|
test('D1 batch retries failed checks before review in the same attempt',t=>{
|
|
290
295
|
const f=fixture(t);prepared(f);
|
|
296
|
+
fs.writeFileSync(path.join(f.root,'review.json'),JSON.stringify({model:'fixture',preflight:{passed:true,provider:'claude',
|
|
297
|
+
prompt_transport:'stdin',config_fingerprint:claudeReviewFingerprint({cwd:f.codeProject,model:'fixture'})}}));
|
|
291
298
|
const failed={[key]:[{id:'test',command:[process.execPath,'-e','process.exit(1)']}]};
|
|
292
299
|
const first=f.drive(f.plan({permissions:['--allow-qa','--runtime','claude'],checks:failed}),'advance');assert.equal(first.status,0,first.stderr);
|
|
293
300
|
const result=JSON.parse(first.stdout).result;
|
|
@@ -360,8 +367,9 @@ test('optimized real batch driver shares only a declared same-plan check and rej
|
|
|
360
367
|
const checks={[key]:[{id:'first',command},{id:'same',command,sameExecutionAs:'first'}]};
|
|
361
368
|
const denied=f.drive(f.plan({checks}), 'advance');assert.equal(denied.status,2);noStore(f);assert(!fs.existsSync(counter));
|
|
362
369
|
const out=f.drive(f.plan({permissions:['--allow-qa','--execution-optimizations'],checks}), 'advance');
|
|
363
|
-
assert.equal(out.status,0,out.stderr);assert.equal(JSON.parse(out.stdout).result.state,'
|
|
364
|
-
|
|
370
|
+
assert.equal(out.status,0,out.stderr);assert.equal(JSON.parse(out.stdout).result.state,'run_done',out.stdout+out.stderr);
|
|
371
|
+
// One physical command per phase: development and the required completion recheck.
|
|
372
|
+
assert.equal(fs.readFileSync(counter,'utf8'),'xx');
|
|
365
373
|
});
|
|
366
374
|
|
|
367
375
|
// Q24 driver: develop_redo goes through the batch host to the stopped member; the
|
|
@@ -404,8 +412,7 @@ test(`${label} batch driver preflights a rescheduled second generation before it
|
|
|
404
412
|
fs.writeFileSync(path.join(dir(id),`${file}.txt`),content);
|
|
405
413
|
fs.writeFileSync(path.join(dir(id),'develop.json'),JSON.stringify({...develop,
|
|
406
414
|
value:outcome==='implemented'?develop.value:{outcome:'blocked',reason:'Synthetic dependency is missing'},edits:{[`${file}.mjs`]:`${file}.txt`}}));
|
|
407
|
-
for(const [name,value] of [['qa-assess.json',{
|
|
408
|
-
changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}}],
|
|
415
|
+
for(const [name,value] of [['qa-assess.json',{confirmed:true}],
|
|
409
416
|
['documentation-inspect.json',{status:'completed',reason:'README and task artifacts inspected'}]])
|
|
410
417
|
fs.writeFileSync(path.join(dir(id),name),JSON.stringify(value));
|
|
411
418
|
};
|
|
@@ -414,7 +421,7 @@ test(`${label} batch driver preflights a rescheduled second generation before it
|
|
|
414
421
|
answer('T-003','target3','export const value = 3;\n');
|
|
415
422
|
const checks=Object.fromEntries(['T-001','T-002','T-003'].map((id,n)=>[`1.work/${id}`,
|
|
416
423
|
[{id:'syntax',command:[process.execPath,'--check',n===0?'target.mjs':`target${n+1}.mjs`]}]]));
|
|
417
|
-
const permissions=['--allow-qa',...(strict?['--execution-optimizations']:[])
|
|
424
|
+
const permissions=['--allow-qa',...(strict?['--execution-optimizations']:[])];
|
|
418
425
|
const first=f.drive(f.plan({permissions,checks}),'advance');assert.equal(first.status,0,first.stderr);
|
|
419
426
|
const stopped=JSON.parse(first.stdout).result;
|
|
420
427
|
assert.equal(stopped.code,'batch_member_rescheduled',first.stdout+first.stderr);assert.deepEqual(stopped.rescheduled,['1.work/T-002']);
|
|
@@ -428,3 +435,39 @@ test(`${label} batch driver preflights a rescheduled second generation before it
|
|
|
428
435
|
assert.equal(done.state,'run_done',resumed.stdout+resumed.stderr);
|
|
429
436
|
assert.equal(fs.readFileSync(path.join(f.codeProject,'target2.mjs'),'utf8'),'export const value = 2;\n');
|
|
430
437
|
});
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
test('batch ordinary advance preflights reachable revision answers without review grants',()=>{
|
|
441
|
+
assert.deepEqual(batchDevelopAttempts({state:'ready',attempt:1},key,[]),[1,2]);
|
|
442
|
+
assert.deepEqual(batchDevelopAttempts({state:'awaiting_review',attempt:1},key,[]),[2]);
|
|
443
|
+
assert.deepEqual(batchDevelopAttempts({state:'pending_review',attempt:1},key,[]),[2]);
|
|
444
|
+
assert.deepEqual(batchDevelopAttempts({state:'blocked',code:'develop_checks_not_passed',attempt:1},key,[]),[1,2]);
|
|
445
|
+
assert.deepEqual(batchDevelopAttempts({state:'blocked',code:'check_answer_missing',attempt:1},key,[]),[2]);
|
|
446
|
+
assert.deepEqual(batchDevelopAttempts({state:'changes_requested',attempt:2},key,[]),[2]);
|
|
447
|
+
});
|
|
448
|
+
test('batch driver rejects removed review grant before starting a batch',t=>{
|
|
449
|
+
const f=fixture(t);prepared(f);
|
|
450
|
+
const out=f.drive(f.plan({permissions:['--allow-qa','--allow-review',key+':1']}),'advance');
|
|
451
|
+
assert.equal(out.status,2,out.stderr);assert.match(out.stderr,/permissions 无效.*--allow-review/);noStore(f);
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
test('batch configured review reaches both rounds and completes without a review grant',t=>{
|
|
455
|
+
const f=fixture(t);prepared(f);
|
|
456
|
+
fs.writeFileSync(path.join(f.answers,'revised.txt'),'export const value = 42; // revised after findings\n');
|
|
457
|
+
f.write('develop-a2.json',{...develop,edits:{'target.mjs':'revised.txt'}});
|
|
458
|
+
const cli=path.join(f.root,'bin','codex');
|
|
459
|
+
fs.writeFileSync(cli,fs.readFileSync(reviewer,'utf8')
|
|
460
|
+
.replace("verdict:'approved'","verdict:data.reviewPackage.identity.attempt===1?'changes_requested':'approved'")
|
|
461
|
+
.replace('findings:[]',"findings:data.reviewPackage.identity.attempt===1?[{id:'F1',severity:'P2',path:'target.mjs',message:'Revise',evidence:'Fixture finding'}]:[]"));
|
|
462
|
+
fs.chmodSync(cli,0o700);
|
|
463
|
+
let out=f.drive(f.plan(),'advance');assert.equal(out.status,0,out.stderr);
|
|
464
|
+
let result=JSON.parse(out.stdout).result;
|
|
465
|
+
for(let n=0;n<4&&result.state!=='run_done';n++){
|
|
466
|
+
out=f.drive(f.plan({mode:'resume',originalHostContext:'batch-host-a'}),'advance');
|
|
467
|
+
assert.equal(out.status,0,out.stderr);result=JSON.parse(out.stdout).result;
|
|
468
|
+
}
|
|
469
|
+
assert.equal(result.state,'run_done',JSON.stringify(result));
|
|
470
|
+
assert.deepEqual(developIntents(f),['develop-1','develop-2']);
|
|
471
|
+
assert.match(fs.readFileSync(path.join(f.specsDir,'.reviews','work-T-001-r1.md'),'utf8'),/verdict: changes_requested/);
|
|
472
|
+
assert.match(fs.readFileSync(path.join(f.specsDir,'.reviews','work-T-001-r2.md'),'utf8'),/verdict: approved/);
|
|
473
|
+
});
|