@aibyzero/cm-workflow 0.16.8 → 0.16.9
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 +19 -0
- package/README.md +14 -3
- package/VERSION +1 -1
- package/compat/claude-commands/cm-notify.md +3 -0
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +25 -1
- package/docs/next-steps.md +8 -2
- package/docs/user-guide.md +105 -5
- package/package.json +2 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +49 -13
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +111 -20
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +69 -22
- package/runtime/js/cm-ai/code-projects.mjs +4 -1
- package/runtime/js/cm-ai/developer-adapter.mjs +7 -0
- package/runtime/js/cm-ai/drive-core.mjs +9 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +951 -43
- package/runtime/js/cm-ai/effect-abandon-log.mjs +5 -2
- package/runtime/js/cm-ai/effect-contract.mjs +6 -1
- package/runtime/js/cm-ai/external-run-guard.mjs +18 -7
- package/runtime/js/cm-ai/host-check.mjs +4 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +11 -4
- package/runtime/js/cm-ai/host-documentation.mjs +53 -12
- package/runtime/js/cm-ai/host-project-execution.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-executor.mjs +49 -4
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +44 -9
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-tool-bridge.mjs +40 -3
- package/runtime/js/cm-ai/operator-guidance.mjs +112 -3
- package/runtime/js/cm-ai/provider-review-observation.mjs +50 -0
- package/runtime/js/cm-ai/qa-resource-release.mjs +46 -0
- package/runtime/js/cm-ai/qa-round-budget.mjs +13 -0
- package/runtime/js/cm-ai/review-dispatch-limits.mjs +18 -0
- package/runtime/js/cm-ai/review-package.mjs +10 -1
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +1 -1
- package/runtime/js/cm-ai/task-commit.mjs +39 -0
- package/runtime/js/cm-ai/task-runner.mjs +636 -65
- package/runtime/js/cm-ai/worker-claude-developer.mjs +9 -0
- package/runtime/js/cm-ai/worker-claude.mjs +10 -3
- package/runtime/js/cm-ai/worker-process-identity.mjs +43 -0
- package/runtime/js/cm-fix/execution.mjs +176 -48
- package/runtime/js/cm-fix/host.mjs +2 -1
- package/runtime/js/cm-fix/pinned-baseline.mjs +24 -0
- package/runtime/js/cm-fix/progress.mjs +13 -3
- package/runtime/js/cm-fix/protected-edits.mjs +10 -3
- package/runtime/js/cm-fix/repair.mjs +11 -3
- package/runtime/js/cm-fix/test-author.mjs +10 -3
- package/runtime/js/cm-idea/session.mjs +67 -4
- package/runtime/js/cm-prd/review-correction.mjs +10 -4
- package/runtime/js/cm-prd/session.mjs +43 -0
- package/runtime/js/cm-refactor/records.mjs +98 -8
- package/runtime/js/cm-refactor/workflow.mjs +79 -9
- package/runtime/js/cm-test/host.mjs +10 -3
- package/runtime/js/cm-test/session.mjs +45 -6
- package/runtime/js/notify-safe-read.mjs +49 -0
- package/runtime/js/notify-send.mjs +312 -0
- package/runtime/js/notify.mjs +137 -33
- package/runtime/js/policy-binding-compat.mjs +54 -0
- package/scripts/ci-test-shards.mjs +67 -0
- package/scripts/ci-test-shards.test.mjs +64 -0
- package/scripts/ci-test-weights.json +222 -0
- package/scripts/cm-ai-abandon-effect-position.test.mjs +70 -2
- package/scripts/cm-ai-answer-gap-dispatch.test.mjs +86 -0
- package/scripts/cm-ai-answer-gap-driver.test.mjs +51 -0
- package/scripts/cm-ai-answer-gap-fixture.mjs +96 -0
- package/scripts/cm-ai-answer-gap-recheck.test.mjs +70 -0
- package/scripts/cm-ai-answer-gap-redo.test.mjs +103 -0
- package/scripts/cm-ai-batch-drive.mjs +55 -10
- package/scripts/cm-ai-batch-drive.test.mjs +65 -0
- package/scripts/cm-ai-batch-host.mjs +132 -13
- package/scripts/cm-ai-batch-host.test.mjs +255 -7
- package/scripts/cm-ai-batch-run-fixture.mjs +499 -0
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +38 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +7 -0
- package/scripts/cm-ai-batch-run-reschedule.test.mjs +17 -0
- package/scripts/cm-ai-batch-run.mjs +184 -22
- package/scripts/cm-ai-batch-run.test.mjs +21 -341
- package/scripts/cm-ai-develop-answer-invalid.test.mjs +104 -0
- package/scripts/cm-ai-develop-call-timeout.test.mjs +153 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +4 -3
- package/scripts/cm-ai-documentation-sync-gap.test.mjs +424 -0
- package/scripts/cm-ai-drive.mjs +64 -22
- package/scripts/cm-ai-drive.test.mjs +29 -2
- package/scripts/cm-ai-host-cli-workflow.test.mjs +271 -0
- package/scripts/cm-ai-host-fixture.mjs +268 -0
- package/scripts/cm-ai-host-protected.test.mjs +251 -0
- package/scripts/cm-ai-host.mjs +27 -15
- package/scripts/cm-ai-host.test.mjs +17 -759
- package/scripts/cm-ai-light-modules.test.mjs +57 -0
- package/scripts/cm-ai-operator-guidance.test.mjs +30 -5
- package/scripts/cm-ai-protected-scope.test.mjs +7 -3
- package/scripts/cm-ai-qa-answer-gaps.test.mjs +99 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +78 -11
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +56 -10
- package/scripts/cm-ai-review-dispatch-exit.test.mjs +475 -0
- package/scripts/cm-ai-review-failure.test.mjs +124 -13
- package/scripts/cm-ai-review-timeout.test.mjs +188 -10
- package/scripts/cm-ai-run.mjs +15 -6
- package/scripts/cm-ai-supersede.test.mjs +486 -41
- package/scripts/cm-check-drive-files.mjs +8 -0
- package/scripts/cm-check-drive.test.mjs +2 -5
- package/scripts/cm-check-runtime.sh +4 -2
- package/scripts/cm-claude-developer-worker.test.mjs +15 -0
- package/scripts/cm-claude-review-stream.test.mjs +21 -16
- package/scripts/cm-claude-review-synthetic.test.mjs +155 -0
- package/scripts/cm-claude-worker.test.mjs +18 -2
- package/scripts/cm-external-model-recovery.test.mjs +29 -3
- package/scripts/cm-fix-abandon.test.mjs +163 -10
- package/scripts/cm-fix-drive-unprotected.test.mjs +37 -0
- package/scripts/cm-fix-drive.mjs +25 -7
- package/scripts/cm-fix-host.mjs +8 -7
- package/scripts/cm-fix-review-budget.test.mjs +13 -0
- package/scripts/cm-fix-review-recovery.test.mjs +35 -0
- package/scripts/cm-host-answer-timeout.test.mjs +65 -0
- package/scripts/cm-host-call-kinds.test.mjs +28 -0
- package/scripts/cm-host-documentation.test.mjs +49 -0
- package/scripts/cm-host-qa-executor.test.mjs +22 -10
- package/scripts/cm-idea-answer-gaps.test.mjs +164 -0
- package/scripts/cm-idea-drive.mjs +49 -11
- package/scripts/cm-idea-drive.test.mjs +66 -0
- package/scripts/cm-idea-host.mjs +106 -16
- package/scripts/cm-init-answer-gaps.test.mjs +258 -0
- package/scripts/cm-init-drive.mjs +41 -7
- package/scripts/cm-init-host.mjs +61 -12
- package/scripts/cm-log-event.mjs +21 -10
- package/scripts/cm-notify-command.test.mjs +900 -0
- package/scripts/cm-notify-read-drift.test.mjs +205 -0
- package/scripts/cm-notify.mjs +469 -0
- package/scripts/cm-notify.test.mjs +221 -4
- package/scripts/cm-prd-answer-gaps.test.mjs +216 -0
- package/scripts/cm-prd-drive.mjs +18 -5
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-host.mjs +37 -4
- package/scripts/cm-prd-review-disposition.test.mjs +6 -1
- package/scripts/cm-prd-review-gate.mjs +56 -0
- package/scripts/cm-refactor-answer-gaps.test.mjs +206 -0
- package/scripts/cm-refactor-drive.mjs +52 -8
- package/scripts/cm-refactor-drive.test.mjs +44 -0
- package/scripts/cm-refactor-host.test.mjs +10 -6
- package/scripts/cm-release-smoke.sh +2 -0
- package/scripts/cm-test-answer-gaps.test.mjs +151 -0
- package/scripts/cm-test-drive.mjs +21 -5
- package/scripts/fixtures/claude-review-process.mjs +1 -1
- package/scripts/policy-binding-compat.test.mjs +99 -0
- package/scripts/scan-public-safety.py +4 -0
- package/scripts/validate-public-repo.py +4 -0
- package/skills/cm-ai/references/js-host-qa-recovery.md +27 -1
- package/skills/cm-ai/references/js-host-recovery.md +120 -8
- package/skills/cm-ai/references/js-host.md +14 -7
- package/skills/cm-check/SKILL.md +3 -3
- package/skills/cm-fix/references/js-host.md +44 -5
- package/skills/cm-idea/references/js-host.md +27 -2
- package/skills/cm-init/references/js-host.md +16 -3
- package/skills/cm-notify/SKILL.md +34 -0
- package/skills/cm-prd/references/js-change-recovery.md +35 -1
- package/skills/cm-refactor/references/js-host.md +17 -0
- package/skills/cm-test/references/js-host.md +14 -1
package/scripts/cm-ai-drive.mjs
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
// fix_repair, fix_retrospective; host-qa-fix-owner.mjs
|
|
26
26
|
// forwards to cm-fix host.run/handle.
|
|
27
27
|
// fix_action selected cm-fix step; host-qa-fix-owner.mjs fix_action.
|
|
28
|
-
// status/cancel/abandon_review/abandon_effect/bootstrap_review_recover/fix_status/context_refresh: none; cm-ai-conversation-entry.mjs
|
|
28
|
+
// status/cancel/abandon_review/abandon_effect/bootstrap_review_recover/develop_redo/fix_status/context_refresh: none; cm-ai-conversation-entry.mjs
|
|
29
29
|
// status/cancel/context_refresh; host-qa-fix-owner.mjs fix_status.
|
|
30
30
|
// verification_precheck optional execution.verificationGate in
|
|
31
31
|
// host-conversation-execution.mjs; CLI has no runner for it.
|
|
@@ -56,7 +56,7 @@ import {codeProjectPaths,resolveCodeProjects} from '../runtime/js/cm-ai/code-pro
|
|
|
56
56
|
import {parseHostInputLimit} from '../runtime/js/cm-ai/host-session.mjs';
|
|
57
57
|
import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs';
|
|
58
58
|
import {readCloseoutReport} from '../runtime/js/cm-ai/knowledge-closeout.mjs';
|
|
59
|
-
import {readRunnerHistory,attemptBaseline} from '../runtime/js/cm-ai/durable-runner-state.mjs';
|
|
59
|
+
import {readRunnerHistory,attemptBaseline,projectedRunnerStatus,RECHECK_CODES,DOCUMENTATION_SYNC_CODES} from '../runtime/js/cm-ai/durable-runner-state.mjs';
|
|
60
60
|
import {developmentRetryable} from '../runtime/js/cm-ai/cm-ai-conversation-entry.mjs';
|
|
61
61
|
import {stderr,stop,readJson,loadPlanFile,requireFields,preflightAnswers,driveHost,planCheckTimeout} from '../runtime/js/cm-ai/drive-core.mjs';
|
|
62
62
|
import {attemptAnswerName,inspectDriverBootstrap,readBootstrapRulesAnswers,createBootstrapRulesResponder} from '../runtime/js/cm-ai/drive-bootstrap.mjs';
|
|
@@ -64,7 +64,7 @@ import {driverLiveEvidence} from '../runtime/js/cm-ai/live-evidence.mjs';
|
|
|
64
64
|
|
|
65
65
|
// PLAN.liveEvidence: fresh current-session evidence; see docs/live-evidence-drivers.md.
|
|
66
66
|
const HOST=fileURLToPath(new URL('./cm-ai-host.mjs',import.meta.url));
|
|
67
|
-
const OPERATIONS=new Set(['advance','start','resume','status','cancel','reconcile_review','abandon_review','abandon_effect','bootstrap_review_recover','decision','complete','qa','qa_result',
|
|
67
|
+
const OPERATIONS=new Set(['advance','start','resume','status','cancel','reconcile_review','abandon_review','abandon_effect','bootstrap_review_recover','develop_redo','decision','complete','qa','qa_result',
|
|
68
68
|
'fix_status','fix_advance','fix_action','fix_run','run_finalize','context_refresh','finish']);
|
|
69
69
|
const ADVANCE=new Set(['advance','start','resume']);
|
|
70
70
|
const PACKAGE_OPERATIONS=new Set(['decision','complete','qa','qa_result','context_refresh','finish','run_finalize']);
|
|
@@ -72,11 +72,17 @@ const TEST_RUN_OPERATIONS=new Set(['qa_result','context_refresh','finish','run_f
|
|
|
72
72
|
const FIX_ASKS={advance:['fix_learning','fix_diagnose'],author_tests:['fix_learning','fix_test_author'],
|
|
73
73
|
repair:['fix_learning','fix_repair'],retrospective:['fix_learning','fix_retrospective'],
|
|
74
74
|
red_test:['fix_learning'],baseline:['fix_learning'],regression:['fix_learning'],
|
|
75
|
-
post_review_regression:['fix_learning'],prepare_revision:['fix_learning']};
|
|
75
|
+
post_review_regression:['fix_learning'],prepare_revision:['fix_learning'],rediagnose:['fix_learning','fix_diagnose']};
|
|
76
76
|
const FIX_ACTIONS=new Set(['red_test','baseline','author_tests','repair','regression','retrospective',
|
|
77
77
|
'learning_writeback','handoff','final_review_package','final_review','publish_review','check_n5',
|
|
78
78
|
'post_review_regression','publish_dossier','walkthrough','finish','prepare_revision',
|
|
79
|
-
'cause_review_package','cause_review','reconcile_review','abandon_step','abandon_review'
|
|
79
|
+
'cause_review_package','cause_review','reconcile_review','abandon_step','abandon_review',
|
|
80
|
+
'rediagnose','rerun_blocked_step','recover_final_review','revision_test_check']);
|
|
81
|
+
// Q23: parent launch flag per recovery fixOperation (host-qa-fix-owner.mjs QA_FIX_ACTION_FLAGS).
|
|
82
|
+
const FIX_ACTION_FLAGS={abandon_step:'--allow-qa-fix-abandon',abandon_review:'--allow-qa-fix-abandon-review',
|
|
83
|
+
rediagnose:'--allow-qa-fix-rediagnosis',rerun_blocked_step:'--allow-qa-fix-rerun-blocked-step',
|
|
84
|
+
recover_final_review:'--allow-qa-fix-final-review-recovery',revision_test_check:'--allow-qa-fix-regression'};
|
|
85
|
+
const FIX_REASONED=['abandon_step','abandon_review','rediagnose','rerun_blocked_step','recover_final_review'];
|
|
80
86
|
const FILES={develop:'develop.json',qa_assess:'qa-assess.json',documentation_inspect:'documentation-inspect.json',
|
|
81
87
|
documentation_sync:'documentation-sync.json',fix_learning:'learning.json',fix_diagnose:'diagnosis.json',
|
|
82
88
|
fix_test_author:'test-edits.json',fix_repair:'repair-edits.json',fix_retrospective:'retrospective.json'};
|
|
@@ -85,13 +91,13 @@ const PAIR_FLAGS=new Set(['--external-models-config','--allow-review-attempt','-
|
|
|
85
91
|
'--protected-conversation-config','--protected-config','--revise-qa-config','--qa-config-revision-reason','--qa-environment-failure',
|
|
86
92
|
'--qa-fix-owner-config','--qa-fix-template-config','--qa-fix-review-config','--browser-qa',
|
|
87
93
|
'--bootstrap-config','--allow-provider-development-attempt','--supersede-reason','--spec-rebind-reason',
|
|
88
|
-
'--review-runtime','--feature']);
|
|
94
|
+
'--review-runtime','--feature','--qa-fix-final-review-recovery-invocation']);
|
|
89
95
|
const FLAG_FLAGS=new Set(['--execution-optimizations','--external-models','--allow-development','--allow-qa','--allow-qa-fix-start','--auto-qa-fix',
|
|
90
96
|
'--verification-precheck',
|
|
91
|
-
'--allow-bootstrap-write','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--rerun-unknown-qa','--rerun-blocked-qa','--failover',
|
|
97
|
+
'--allow-bootstrap-write','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--allow-develop-redo','--rerun-unknown-qa','--rerun-blocked-qa','--failover',
|
|
92
98
|
'--supersede-reviewed-evidence','--accept-superseded-code-drift','--rebind-spec-material',
|
|
93
99
|
...['red-test','baseline','regression','learning-writeback','walkthrough','finish','abandon','abandon-review',
|
|
94
|
-
'test-author','repair','cause-review','final-review'].map(name=>`--allow-qa-fix-${name}`)]);
|
|
100
|
+
'test-author','repair','cause-review','final-review','rediagnosis','rerun-blocked-step','final-review-recovery'].map(name=>`--allow-qa-fix-${name}`)]);
|
|
95
101
|
const object=value=>value!==null&&typeof value==='object'&&!Array.isArray(value);
|
|
96
102
|
const nonempty=value=>typeof value==='string'&&value.trim().length>0;
|
|
97
103
|
// Needs the resolved --bootstrap-config path in permissions.
|
|
@@ -107,6 +113,11 @@ export const abandonEffectPlanError=(operation,plan,permissions)=>operation!=='a
|
|
|
107
113
|
&&typeof plan.reason==='string'&&plan.reason.trim().length>0
|
|
108
114
|
&&Buffer.byteLength(plan.reason,'utf8')<=500&&!/[\r\n\0]/.test(plan.reason)?null:
|
|
109
115
|
'abandon_effect 需要 resume、--allow-abandon-effect 与单行 reason(最多 500 UTF-8 字节)';
|
|
116
|
+
export const developRedoPlanError=(operation,plan,permissions)=>operation!=='develop_redo'?null:
|
|
117
|
+
plan.mode==='resume'&&permissions.includes('--allow-develop-redo')
|
|
118
|
+
&&typeof plan.reason==='string'&&plan.reason.trim().length>0
|
|
119
|
+
&&Buffer.byteLength(plan.reason,'utf8')<=500&&!/[\r\n\0]/.test(plan.reason)?null:
|
|
120
|
+
'develop_redo 需要 resume、--allow-develop-redo 与单行 reason(最多 500 UTF-8 字节),并先确认会话已停止修改代码';
|
|
110
121
|
export const bootstrapReviewRecoveryPlanError=(operation,plan,permissions)=>operation!=='bootstrap_review_recover'?null:
|
|
111
122
|
plan.mode==='resume'&&permissions.includes('--allow-bootstrap-review-recovery')
|
|
112
123
|
&&typeof plan.reason==='string'&&plan.reason.trim().length>0
|
|
@@ -414,7 +425,7 @@ export function readRunJournal(definition){
|
|
|
414
425
|
const snapshot=readExecutionSnapshot({specsRoot:definition.specsDir,identity:{
|
|
415
426
|
repositoryId:definition.identity.repositoryId,runId:definition.identity.runId}});
|
|
416
427
|
const first=snapshot.records[0];
|
|
417
|
-
return {history:readRunnerHistory(snapshot.records,first.payload.config,3),baseline:first.payload.baseline,
|
|
428
|
+
return {history:readRunnerHistory(snapshot.records,first.payload.config,3),config:first.payload.config,baseline:first.payload.baseline,
|
|
418
429
|
frame:journalRestBytes(snapshot.records)};
|
|
419
430
|
}
|
|
420
431
|
function reachableDevelopAttempts({plan,operation,journal,permissions}){
|
|
@@ -426,11 +437,23 @@ function reachableDevelopAttempts({plan,operation,journal,permissions}){
|
|
|
426
437
|
if(journal.error)stop(2,`无法只读检查恢复存档: ${journal.error.code??journal.error.message}`);
|
|
427
438
|
// learning is the journal's Learning result the next develop effect starts from
|
|
428
439
|
// (bootstrap rules bind their on-disk files to its recorded evidence).
|
|
429
|
-
|
|
440
|
+
// Q28: decide from what the host will show (projected answer-gap blocks), not the raw replay state.
|
|
441
|
+
return {...projectDevelopAttempts(projectedRunnerStatus(journal.history,journal.config),operation,permissions),
|
|
442
|
+
learning:journal.history.state.learningResult??null};
|
|
430
443
|
}
|
|
431
444
|
export function projectDevelopAttempts(status,operation,permissions){
|
|
432
445
|
const {state,attempt,reviewPackage}=status;
|
|
433
|
-
|
|
446
|
+
// One advance can continue past the round-1 review into round 2 when it holds
|
|
447
|
+
// --allow-review-attempt 1 (Codex round 1 on Q28): preflight that round too.
|
|
448
|
+
const reviewAfterDevelop=operation==='advance'&&attempt===1
|
|
449
|
+
&&permissions.some((flag,index)=>flag==='--allow-review-attempt'&&permissions[index+1]==='1');
|
|
450
|
+
// A re-check (check_answer_*) re-runs only the checks: no developer answer for
|
|
451
|
+
// this round, only for the round its review may lead to.
|
|
452
|
+
// Q16/Q17: a documentation-only redo reuses the journaled developer answer.
|
|
453
|
+
if(state==='blocked'&&(RECHECK_CODES.includes(status.code)||DOCUMENTATION_SYNC_CODES.includes(status.code)))
|
|
454
|
+
return {attempts:reviewAfterDevelop?[2]:[],reviewFirst:false,reviewAfterDevelop,holdable:true,packageDigest:null};
|
|
455
|
+
if(developmentRetryable(status))
|
|
456
|
+
return {attempts:reviewAfterDevelop?[1,2]:[attempt],reviewFirst:false,reviewAfterDevelop,holdable:true,packageDigest:null};
|
|
434
457
|
if(state==='ready'&&attempt===1&&operation==='advance'
|
|
435
458
|
&&permissions.some((flag,index)=>flag==='--allow-review-attempt'&&permissions[index+1]==='1'))
|
|
436
459
|
return {attempts:[1,2],reviewFirst:false,reviewAfterDevelop:true,packageDigest:null};
|
|
@@ -537,7 +560,7 @@ export function validateCmAiAnswer(kind,value,root){
|
|
|
537
560
|
}
|
|
538
561
|
function load(){
|
|
539
562
|
if(process.argv.length===3&&['--help','-h'].includes(process.argv[2])){
|
|
540
|
-
process.stdout.write('用法: cm-ai-drive.mjs --plan PLAN.json <operation>\nPLAN: config, mode, hostContext, originalHostContext (换会话 resume 必填), runtime, permissions, answers, checks, checkTimeoutMs。\nchecks 每项为 {id,command,timeoutMs?};checkTimeoutMs 与每项 timeoutMs 为 1..3600000 整数,默认 900000 ms(15 分钟)。\nabandon_review 需要 mode:resume、permissions:["--allow-abandon-review"] 与 PLAN.reason;abandon_effect 需要 mode:resume、permissions:["--allow-abandon-effect"] 与 PLAN.reason(均为单行、最多 500 UTF-8 字节)。 bootstrap_review_recover 需要 mode:resume、permissions:["--allow-bootstrap-review-recovery"] 与 PLAN.reason;只核对原运行的已写规则与 handoff,不需要答案文件。\n人工答案放 answers/;check 只运行 PLAN.checks,不读取静态执行证据。bootstrap T-001 骨架可用;T-002 规范任务(纯规范 scope、单代码根、非 --protected-config)读 answers/init-generate.json({status:"generated",documents:[{path,contentFile}]},覆盖全部 targets)与 answers/init-verify.json(commands 为驾驶员实跑的草稿命令 {id,command,timeoutMs?},可选 commandsNotRun;checks 只含 globs/file_references/constraint_preservation/rule_applicability;constraintChanges:[];application/retrospective 沿原 Learning);第 1 轮也可用 *-a1.json,第 2 轮只读 init-generate-a2.json 与 init-verify-a2.json,且须先 decision 读取首轮 findings,不能带 --allow-review-attempt 跨轮。commands 在宿主接受启动后、发送操作前由驾驶员实跑(须先带 --allow-bootstrap-write 等宿主授权;受保护模式在 specs 沙箱内),失败或改动了预检核对的文件即退出 2 且不发送操作(create 时改用 resume 重跑);结果只来自实跑,答案文件不能提供。\n'
|
|
563
|
+
process.stdout.write('用法: cm-ai-drive.mjs --plan PLAN.json <operation>\nPLAN: config, mode, hostContext, originalHostContext (换会话 resume 必填), runtime, permissions, answers, checks, checkTimeoutMs。\nchecks 每项为 {id,command,timeoutMs?};checkTimeoutMs 与每项 timeoutMs 为 1..3600000 整数,默认 900000 ms(15 分钟)。\nabandon_review 需要 mode:resume、permissions:["--allow-abandon-review"] 与 PLAN.reason;abandon_effect 需要 mode:resume、permissions:["--allow-abandon-effect"] 与 PLAN.reason(均为单行、最多 500 UTF-8 字节)。develop_redo 需要 mode:resume、permissions:["--allow-develop-redo"] 与 PLAN.reason,先确认会话已停止修改代码。 bootstrap_review_recover 需要 mode:resume、permissions:["--allow-bootstrap-review-recovery"] 与 PLAN.reason;只核对原运行的已写规则与 handoff,不需要答案文件。\n人工答案放 answers/;check 只运行 PLAN.checks,不读取静态执行证据。bootstrap T-001 骨架可用;T-002 规范任务(纯规范 scope、单代码根、非 --protected-config)读 answers/init-generate.json({status:"generated",documents:[{path,contentFile}]},覆盖全部 targets)与 answers/init-verify.json(commands 为驾驶员实跑的草稿命令 {id,command,timeoutMs?},可选 commandsNotRun;checks 只含 globs/file_references/constraint_preservation/rule_applicability;constraintChanges:[];application/retrospective 沿原 Learning);第 1 轮也可用 *-a1.json,第 2 轮只读 init-generate-a2.json 与 init-verify-a2.json,且须先 decision 读取首轮 findings,不能带 --allow-review-attempt 跨轮。commands 在宿主接受启动后、发送操作前由驾驶员实跑(须先带 --allow-bootstrap-write 等宿主授权;受保护模式在 specs 沙箱内),失败或改动了预检核对的文件即退出 2 且不发送操作(create 时改用 resume 重跑);结果只来自实跑,答案文件不能提供。\n'
|
|
541
564
|
+'develop.json.edits 每项是 scope 路径到下列之一:"内容文件"(写入;已有文件保留权限,新文件 0644)、{"file":"内容文件","mode":"0755"|"0644"}、{"mode":"0755"|"0644"}(只改已有文件权限)、{"delete":true}(删除已有文件)。改名 = 删旧路径 + 写新路径,两者都要在 scope 内;同时列在 requirements 里的路径不能删除。\n'
|
|
542
565
|
+'启动前拒绝:单个 scope 文件超过 1 MiB、审查材料(按审查包快照:scope、requirements 与树中全部 AGENTS.md 正文)合计超过 2 MiB 或超过 256 个文件、交付后与任务基线完全相同(edits 为空或内容和权限都没变)、开发检查点(含 handoff 与 AGENTS.md 回写,按宿主同一套构建代码计)装不进运行存档单条 1 MiB 记录减去为有界审查与完成记录推出的预留,或任务基线装不进一条记录。受保护模式(--protected-conversation-config)只收合法 UTF-8 文本,应答大于 --input-limit(默认 65536)时提示应加的值。\n'
|
|
543
566
|
+'runId 需 8–128 个字符(运行日志要求),create 前检查。resume 时按存档里的当前轮次发送 identity,第 2 轮的 decision/complete/qa 等无需手改。\n');
|
|
@@ -573,6 +596,8 @@ function load(){
|
|
|
573
596
|
if(abandonError)stop(2,abandonError);
|
|
574
597
|
const abandonEffectError=abandonEffectPlanError(operation,plan,permissions);
|
|
575
598
|
if(abandonEffectError)stop(2,abandonEffectError);
|
|
599
|
+
const developRedoError=developRedoPlanError(operation,plan,permissions);
|
|
600
|
+
if(developRedoError)stop(2,developRedoError);
|
|
576
601
|
const bootstrapRecoveryError=bootstrapReviewRecoveryPlanError(operation,plan,permissions);
|
|
577
602
|
if(bootstrapRecoveryError)stop(2,bootstrapRecoveryError);
|
|
578
603
|
const config=path.resolve(base,plan.config),answers=plan.answers?path.resolve(base,plan.answers):null;
|
|
@@ -609,7 +634,7 @@ function load(){
|
|
|
609
634
|
&&permissions[i]!=='--allow-review-attempt'&&permissions[i]!=='--browser-qa'
|
|
610
635
|
&&permissions[i]!=='--qa-config-revision-reason'&&permissions[i]!=='--qa-environment-failure'&&permissions[i]!=='--allow-provider-development-attempt'
|
|
611
636
|
&&permissions[i]!=='--supersede-reason'&&permissions[i]!=='--spec-rebind-reason'&&permissions[i]!=='--input-limit'
|
|
612
|
-
&&permissions[i]!=='--review-runtime'&&permissions[i]!=='--feature'){
|
|
637
|
+
&&permissions[i]!=='--review-runtime'&&permissions[i]!=='--feature'&&permissions[i]!=='--qa-fix-final-review-recovery-invocation'){
|
|
613
638
|
const file=path.resolve(base,permissions[i+1]);if(!fs.existsSync(file))stop(2,`${permissions[i]} 文件不存在: ${file}`);
|
|
614
639
|
permissions[i+1]=file;permissionFiles.push(file);i++;
|
|
615
640
|
}
|
|
@@ -642,9 +667,14 @@ function load(){
|
|
|
642
667
|
if(operation==='fix_action'){
|
|
643
668
|
if(plan.fixOperation==='reconcile_review'&&(plan.mode!=='resume'||!nonempty(plan.invocationId)))stop(2,'fix reconciliation requires resume and original invocationId');
|
|
644
669
|
if(!FIX_ACTIONS.has(plan.fixOperation))stop(2,'fix_action 需要宿主支持的 fixOperation');
|
|
645
|
-
const
|
|
646
|
-
if(
|
|
647
|
-
|
|
670
|
+
const actionFlag=FIX_ACTION_FLAGS[plan.fixOperation];
|
|
671
|
+
if(actionFlag&&!permissions.includes(actionFlag))stop(2,`${plan.fixOperation} 需要 ${actionFlag}`);
|
|
672
|
+
if(FIX_REASONED.includes(plan.fixOperation)&&!(nonempty(plan.reason)&&Buffer.byteLength(plan.reason,'utf8')<=1000
|
|
673
|
+
&&!/[\r\n\0\u0085\u2028\u2029]/.test(plan.reason)))stop(2,`${plan.fixOperation} 需要单行 reason(最多 1000 UTF-8 字节)`);
|
|
674
|
+
if(plan.fixOperation==='rediagnose'&&plan.mode!=='resume')stop(2,'rediagnose 需要 mode:resume');
|
|
675
|
+
if(plan.fixOperation==='recover_final_review'&&(plan.mode!=='resume'||!nonempty(plan.invocationId)
|
|
676
|
+
||!/^[a-f0-9]{64}$/.test(plan.reviewPackageDigest??'')||plan.previousInvocationStopped!==true))
|
|
677
|
+
stop(2,'recover_final_review 需要 mode:resume、原 invocationId、子运行终审包 reviewPackageDigest,以及确认旧审查进程已停的 previousInvocationStopped:true');
|
|
648
678
|
asks.push(...(FIX_ASKS[plan.fixOperation]??[]));
|
|
649
679
|
}
|
|
650
680
|
let live;
|
|
@@ -671,11 +701,19 @@ function load(){
|
|
|
671
701
|
:{attempts:[],reviewFirst:false,packageDigest:null};
|
|
672
702
|
const bootstrapAnswers=rules
|
|
673
703
|
?readBootstrapRulesAnswers({answers,operation,definition,plan,permissions,bootstrap,reachable}):null;
|
|
674
|
-
const developAnswers=new Map(),deliveries=[];
|
|
704
|
+
const developAnswers=new Map(),deliveries=[];let holdRevision=false;
|
|
675
705
|
if(asks.includes('develop'))for(const attempt of reachable.attempts){
|
|
676
706
|
const file=answerPath(answers??'',developFilename(answers??'',attempt));
|
|
677
707
|
if(!answers||!fs.existsSync(file)){
|
|
678
708
|
const reviewFile=`.reviews/${definition.feature.replace(/^\d+\./,'')}-${definition.identity.taskId}-r1.md`;
|
|
709
|
+
// Resuming a retryable block: let the redo and its review run, then stop
|
|
710
|
+
// at changes_requested (revision_answer_required) instead of asking a
|
|
711
|
+
// round-2 develop nobody can answer.
|
|
712
|
+
if(reachable.reviewAfterDevelop&&reachable.holdable&&attempt===2){
|
|
713
|
+
holdRevision=true;
|
|
714
|
+
stderr(`没有 ${path.basename(file)}:本次 advance 的首轮审查若要求修改,任务会停在 changes_requested(revision_answer_required),不会发起第 2 轮开发;读取 ${reviewFile} 的 findings,写 answers/develop-a2.json 后再 advance`);
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
679
717
|
if(reachable.reviewAfterDevelop&&attempt===2)
|
|
680
718
|
stop(2,`缺少 ${file};本次 advance 带 --allow-review-attempt 1,宿主完成首轮审查后可能直接进入第 2 轮 develop。可选:1) 从 PLAN.permissions 移除 --allow-review-attempt 1,先 advance 到 awaiting_review;再用该运行返回的 packageDigest 执行 decision,读取 ${reviewFile} 的 findings;若要求修改,写 answers/develop-a2.json 后 advance。2) 若有意一次跑完,预先写 answers/develop-a2.json 后重试 advance。develop-a2.json 必须针对首轮 findings 修改;与第 1 轮被要求修改的代码逐字节相同时,第 2 轮停在 blocked/develop_unchanged_after_review,不送审,改好后再 advance。`);
|
|
681
719
|
if(reachable.reviewFirst)stop(2,`缺少 ${path.basename(file)};请先以 decision 和当前 packageDigest ${reachable.packageDigest} 单独运行审查,读取 .reviews/${definition.feature.replace(/^\d+\./,'')}-${definition.identity.taskId}-r${attempt-1}.md 中的 findings,写 answers/develop-a${attempt}.json 后再 advance`);
|
|
@@ -694,13 +732,15 @@ function load(){
|
|
|
694
732
|
exact:!permissions.includes('--bootstrap-config')})});
|
|
695
733
|
const unique=[...new Set(asks.filter(kind=>FILES[kind]&&kind!=='develop'))];
|
|
696
734
|
const answer=preflightAnswers(unique,kind=>{
|
|
697
|
-
|
|
735
|
+
// A rediagnosis is a new conclusion; never reuse the first diagnosis file (same as cm-fix-drive).
|
|
736
|
+
const file=answerPath(answers??'',operation==='fix_action'&&plan.fixOperation==='rediagnose'&&kind==='fix_diagnose'
|
|
737
|
+
?'diagnosis-rediagnosis.json':FILES[kind]);
|
|
698
738
|
if(!answers||!fs.existsSync(file))stop(2,`步骤 ${operation} 会反问 ${kind},但答案文件不存在: ${file}`);
|
|
699
739
|
const value=readJson(file,kind);validateCmAiAnswer(kind,value,answers);return value;
|
|
700
740
|
});
|
|
701
741
|
if(answer.documentation_sync)for(const target of Object.keys(answer.documentation_sync.edits))
|
|
702
742
|
if(!workflow.documentationPaths.includes(target))stop(2,`documentation-sync.json.edits 越过文档 scope: ${target}`);
|
|
703
|
-
return {...loaded,definition,identity,permissions,config,answers,answer,developAnswers,live,executionPolicy,
|
|
743
|
+
return {...loaded,definition,identity,permissions,config,answers,answer,developAnswers,live,executionPolicy,holdRevision,
|
|
704
744
|
bootstrapRules:bootstrapAnswers&&createBootstrapRulesResponder({definition,plan,bootstrap,answers:bootstrapAnswers,
|
|
705
745
|
// Same execution as the task checks: the host's specs sandbox in protected mode, else the driver's own.
|
|
706
746
|
specsRoot:protectedMode?definition.specsDir:null,watch:[config,...permissionFiles]})};
|
|
@@ -777,13 +817,15 @@ async function answerFor(row,answer,paths,control){
|
|
|
777
817
|
export function buildCmAiDriveRequest(operation,plan,definition,identity=definition.identity){
|
|
778
818
|
return {version:1,identity,
|
|
779
819
|
...(operation==='reconcile_review'?{invocationId:plan.invocationId}:{}),
|
|
780
|
-
...(['abandon_review','abandon_effect','bootstrap_review_recover'].includes(operation)?{reason:plan.reason}:{}),
|
|
820
|
+
...(['abandon_review','abandon_effect','bootstrap_review_recover','develop_redo'].includes(operation)?{reason:plan.reason}:{}),
|
|
781
821
|
...(PACKAGE_OPERATIONS.has(operation)?{packageDigest:plan.packageDigest}:{}),
|
|
782
822
|
...(TEST_RUN_OPERATIONS.has(operation)?{testRunId:plan.testRunId}:{}),
|
|
783
823
|
...(['fix_status','fix_advance','fix_action','fix_run'].includes(operation)?{
|
|
784
824
|
packageDigest:plan.packageDigest,testRunId:plan.testRunId,
|
|
785
825
|
...(operation==='fix_action'?{fixOperation:plan.fixOperation,...(plan.fixOperation==='reconcile_review'?{invocationId:plan.invocationId}:{}),
|
|
786
|
-
...(
|
|
826
|
+
...(FIX_REASONED.includes(plan.fixOperation)?{reason:plan.reason}:{}),
|
|
827
|
+
...(plan.fixOperation==='recover_final_review'?{invocationId:plan.invocationId,reviewPackageDigest:plan.reviewPackageDigest,
|
|
828
|
+
previousInvocationStopped:plan.previousInvocationStopped}:{})}: {})}: {})};
|
|
787
829
|
}
|
|
788
830
|
export function buildCmAiDriveHostArgs(plan,permissions,config){
|
|
789
831
|
return ['serve','--config',config,'--mode',plan.mode,'--host-context',plan.hostContext,
|
|
@@ -807,7 +849,7 @@ async function main(){
|
|
|
807
849
|
// Rules init_verify commands really run once the host has accepted the launch
|
|
808
850
|
// (host_ready) and before the operation is sent: a failure never becomes an
|
|
809
851
|
// unknown develop effect, and the host's own launch validation came first.
|
|
810
|
-
driveHost({host:HOST,args:buildCmAiDriveHostArgs(plan,permissions,config),cwd:definition.codeProject,operation,request,
|
|
852
|
+
driveHost({host:HOST,args:[...buildCmAiDriveHostArgs(plan,permissions,config),...(loaded.holdRevision?['--hold-revision']:[])],cwd:definition.codeProject,operation,request,
|
|
811
853
|
answers:answer,paths:{answers:loaded.answers},answerFor,
|
|
812
854
|
...(loaded.bootstrapRules?{beforeRequest:()=>loaded.bootstrapRules.prepare(plan.mode)}:{})});
|
|
813
855
|
}
|
|
@@ -285,9 +285,11 @@ test('driver resumes an interrupted develop and sends the bound abandon_effect r
|
|
|
285
285
|
reason:'Old host and its checks have exited'});
|
|
286
286
|
const result=f.drive(plan,'abandon_effect');assert.equal(result.status,0,result.stderr);
|
|
287
287
|
const response=JSON.parse(result.stdout).result;
|
|
288
|
-
|
|
288
|
+
// V8: the run continues from develop_interrupted instead of being voided.
|
|
289
|
+
assert.equal(response.state,'blocked');assert.equal(response.code,'develop_interrupted');
|
|
290
|
+
assert.equal(response.pendingAction,'resume');
|
|
289
291
|
const saved=JSON.parse(fs.readFileSync(f.store,'utf8'));
|
|
290
|
-
assert.deepEqual(saved.records.slice(-2).map(row=>row.payload.type),['effect-intent','effect-
|
|
292
|
+
assert.deepEqual(saved.records.slice(-2).map(row=>row.payload.type),['effect-intent','effect-interrupted']);
|
|
291
293
|
});
|
|
292
294
|
test('real host drives split-root bootstrap scaffold, then refuses rules without answer files before creating T-002 run',
|
|
293
295
|
{skip:process.platform!=='darwin'},t=>{
|
|
@@ -554,6 +556,31 @@ test('QA-fix child action requires its own answer before any host request',t=>{
|
|
|
554
556
|
{fix_repair:{'target.mjs':'repair.txt'}},f.answers),
|
|
555
557
|
{outcome:'repaired',edits:[{path:'target.mjs',beforeSha256:'old-hash',content:'export const value = 43;\n'}]});
|
|
556
558
|
});
|
|
559
|
+
test('Q23 QA-fix recovery fixOperations need their parent flag and fields before any host request',t=>{
|
|
560
|
+
const f=fixture(t);prepared(f);assert.equal(f.drive(f.plan(),'advance').status,0);
|
|
561
|
+
const binding={feature:'1.work',identity,packageDigest:'a'.repeat(64),testRunId:'qa-child'};
|
|
562
|
+
fs.writeFileSync(path.join(f.root,'fix-owner.json'),JSON.stringify({specsRoot:f.specsDir,identity:{...identity,runId:'fix-run'},
|
|
563
|
+
configuration:{hostContextId:'drive-host-a',reproduction:{cwd:f.codeProject},qaSource:binding}}));
|
|
564
|
+
const base={mode:'resume',originalHostContext:'drive-host-a',packageDigest:'a'.repeat(64),testRunId:'qa-child',
|
|
565
|
+
permissions:['--qa-fix-owner-config','fix-owner.json','--allow-qa-fix-start']};
|
|
566
|
+
const run=(extra,flags=[])=>f.drive(f.plan({...base,...extra,permissions:[...base.permissions,...flags]}),'fix_action');
|
|
567
|
+
let result=run({fixOperation:'rediagnose',reason:'审查要求补证'});
|
|
568
|
+
assert.equal(result.status,2);assert.match(result.stderr,/--allow-qa-fix-rediagnosis/);
|
|
569
|
+
result=run({fixOperation:'rediagnose',reason:'审查要求补证'},['--allow-qa-fix-rediagnosis']);
|
|
570
|
+
assert.equal(result.status,2);assert.match(result.stderr,/learning\.json/);
|
|
571
|
+
f.write('learning.json',{status:'no_relevant_lesson',summary:'No applicable project lesson'});
|
|
572
|
+
f.write('diagnosis.json',{status:'diagnosed',rootCause:'first',affectedPaths:['a.mjs'],affectedModules:['a'],plan:'p',crossLayer:false});
|
|
573
|
+
result=run({fixOperation:'rediagnose',reason:'审查要求补证'},['--allow-qa-fix-rediagnosis']);
|
|
574
|
+
assert.equal(result.status,2);assert.match(result.stderr,/diagnosis-rediagnosis\.json/);
|
|
575
|
+
result=run({fixOperation:'rerun_blocked_step'},['--allow-qa-fix-rerun-blocked-step']);
|
|
576
|
+
assert.equal(result.status,2);assert.match(result.stderr,/reason/);
|
|
577
|
+
result=run({fixOperation:'recover_final_review',reason:'旧审查已停',invocationId:'final-1',reviewPackageDigest:'b'.repeat(64)},
|
|
578
|
+
['--allow-qa-fix-final-review-recovery']);
|
|
579
|
+
assert.equal(result.status,2);assert.match(result.stderr,/previousInvocationStopped/);
|
|
580
|
+
result=run({fixOperation:'recover_final_review',reason:'旧审查已停',invocationId:'final-1',reviewPackageDigest:'b'.repeat(64),
|
|
581
|
+
previousInvocationStopped:true},['--allow-qa-fix-final-review-recovery','--qa-fix-final-review-recovery-invocation','final-1']);
|
|
582
|
+
assert.equal(result.status,1,result.stderr);assert.match(result.stderr,/qa_fix_parent_not_completed/);
|
|
583
|
+
});
|
|
557
584
|
test('QA-fix answer travels through the shared JSONL core',t=>{
|
|
558
585
|
const f=fixture(t),host=path.join(f.root,'child-host.mjs'),wrapper=path.join(f.root,'child-drive.mjs');
|
|
559
586
|
fs.writeFileSync(host,`process.stdout.write(JSON.stringify({type:'host_ready',sessionId:'child'})+'\\n');
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import {spawnSync} from 'node:child_process';
|
|
6
|
+
import {fileURLToPath} from 'node:url';
|
|
7
|
+
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
8
|
+
import {cli,identity,request,fixture,runCli} from './cm-ai-host-fixture.mjs';
|
|
9
|
+
|
|
10
|
+
for(const variant of ['codex','claude','protected'])test(`automatic fix ${variant} CLI starts before QA and finishes through original transport`,async()=>{
|
|
11
|
+
const runtime=variant==='protected'?'codex':variant;
|
|
12
|
+
const f=fixture();f.workflow=true;f.fix=true;f.runtime=runtime;
|
|
13
|
+
try{
|
|
14
|
+
f.protected=variant==='protected';
|
|
15
|
+
const definition=JSON.parse(fs.readFileSync(f.config,'utf8'));definition.scope.push('README.md');
|
|
16
|
+
if(f.protected){const nested=path.join(f.codeProject,'specs');fs.renameSync(f.specsDir,nested);f.specsDir=nested;definition.specsDir=nested;}
|
|
17
|
+
fs.writeFileSync(f.config,JSON.stringify(definition));
|
|
18
|
+
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.json'),JSON.stringify({version:1,...(f.protected?{runtimes:{available:'codex'}}:{}),policies:{auto_fix:'auto',delivery:'diff'}}));
|
|
19
|
+
fs.writeFileSync(path.join(f.codeProject,'red.mjs'),"import {value} from './target.mjs';if(value!==43){console.error('BUG');process.exit(1)}");
|
|
20
|
+
fs.writeFileSync(path.join(f.codeProject,'baseline.mjs'),"import {value} from './target.mjs';if(typeof value!=='number')process.exit(1)");
|
|
21
|
+
const bin=path.join(f.root,'bin');fs.mkdirSync(bin);
|
|
22
|
+
const fake=path.join(bin,runtime);fs.copyFileSync(fileURLToPath(new URL(`./fixtures/${runtime}-review-process.mjs`,import.meta.url)),fake);fs.chmodSync(fake,0o700);
|
|
23
|
+
if(f.protected){
|
|
24
|
+
const located=spawnSync('/usr/bin/which',['codex'],{encoding:'utf8'});assert.equal(located.status,0);
|
|
25
|
+
const real=located.stdout.trim(),reviewFixture=fileURLToPath(new URL('./fixtures/codex-review-process.mjs',import.meta.url));
|
|
26
|
+
fs.writeFileSync(fake,String.raw`#!${process.execPath}
|
|
27
|
+
const fs=require('node:fs'),cp=require('node:child_process'),a=require('node:assert/strict');
|
|
28
|
+
const args=process.argv.slice(2),real=${JSON.stringify(real)};
|
|
29
|
+
if(args[0]==='sandbox'){const r=cp.spawnSync(real,args,{stdio:'inherit'});process.exit(r.status??1);}
|
|
30
|
+
let input='';process.stdin.on('data',s=>input+=s);process.stdin.on('end',()=>{
|
|
31
|
+
if(!input.includes('<cm-developer-data-json>')){
|
|
32
|
+
const r=cp.spawnSync(process.execPath,[${JSON.stringify(reviewFixture)},...args],{input,encoding:'utf8'});
|
|
33
|
+
process.stdout.write(r.stdout??'');process.stderr.write(r.stderr??'');process.exit(r.status??1);
|
|
34
|
+
}
|
|
35
|
+
const profile=[];for(let i=0;i<args.length;i++)if(args[i]==='-c'&&/^(default_permissions=|permissions.cm-specs=)/.test(args[i+1]))profile.push(args[i],args[i+1]);
|
|
36
|
+
a.equal(profile.length,4);
|
|
37
|
+
const code="const fs=require('node:fs');fs.writeFileSync('target.mjs','export const value = 42;\\n');fs.writeFileSync('README.md','# Before fix\\n');";
|
|
38
|
+
const r=cp.spawnSync(real,['sandbox','-P','cm-specs','--include-managed-config','-C',process.cwd(),...profile,'--',process.execPath,'-e',code],{encoding:'utf8'});
|
|
39
|
+
if(r.status!==0){process.stderr.write(r.stderr??'');process.exit(1);}
|
|
40
|
+
for(const row of [{type:'thread.started',thread_id:'synthetic-protected-developer'},{type:'turn.started'},
|
|
41
|
+
{type:'item.completed',item:{type:'agent_message',text:JSON.stringify({outcome:'implemented',application:{status:'no_relevant_lesson',note:null},retrospective:{status:'no_new_lesson',candidates:[],reason:null}})}},{type:'turn.completed'}])process.stdout.write(JSON.stringify(row)+'\n');
|
|
42
|
+
});
|
|
43
|
+
`,{mode:0o700});
|
|
44
|
+
// Every original fix command also asserts actual native specs/instruction protection.
|
|
45
|
+
const assertion="import fs from 'node:fs';import a from 'node:assert/strict';"
|
|
46
|
+
+"for(const file of ['specs/1.work/tasks.md','AGENTS.md'])a.throws(()=>fs.writeFileSync(file,'forged'),e=>['EPERM','EACCES'].includes(e.code));\n";
|
|
47
|
+
for(const name of ['red.mjs','baseline.mjs'])fs.writeFileSync(path.join(f.codeProject,name),assertion+fs.readFileSync(path.join(f.codeProject,name),'utf8'));
|
|
48
|
+
}
|
|
49
|
+
f.env={...process.env,PATH:bin+path.delimiter+process.env.PATH,CM_WORKFLOW_LOG_HOME:path.join(f.root,'private-logs')};
|
|
50
|
+
const preview=spawnSync(process.execPath,[cli,'preflight','--config',f.config,'--review-model','fixture','--runtime',runtime],
|
|
51
|
+
{encoding:'utf8',env:f.env,timeout:5000});
|
|
52
|
+
assert.equal(preview.status,0,preview.stderr);
|
|
53
|
+
const review=JSON.parse(preview.stdout),reviewFile=path.join(f.root,'review.json');
|
|
54
|
+
fs.writeFileSync(reviewFile,JSON.stringify(review));
|
|
55
|
+
const command=[process.execPath,'red.mjs'];
|
|
56
|
+
const workflowFile=path.join(f.root,'workflow.json');
|
|
57
|
+
fs.writeFileSync(workflowFile,JSON.stringify({documentationPaths:['README.md'],applicableAgentFiles:[],
|
|
58
|
+
qa:{commands:[{id:'value-check',command,caseIds:[]}],environment:{kind:'web',carrier:'browser',target:'http://127.0.0.1',scope:'local'}}}));
|
|
59
|
+
const permissions=['red-test','baseline','repair','regression','final-review','walkthrough','finish'];
|
|
60
|
+
const reviewHost=createFixReviewHost({codeProject:f.codeProject,hostContextId:'native-host-fixture',runtime,review,
|
|
61
|
+
permissions:permissions.map(name=>`--allow-${name}`)});
|
|
62
|
+
const configuration={hostContextId:'native-host-fixture',...(runtime==='claude'?{runtime}:{}),defect:'Exported value must be 43',
|
|
63
|
+
...(f.protected?{protectSpecs:true}:{}),
|
|
64
|
+
causeReview:reviewHost.reviewer,reproduction:{cwd:f.codeProject,command,expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000},
|
|
65
|
+
redTest:{cwd:f.codeProject,testFiles:['red.mjs'],command,expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000},
|
|
66
|
+
baseline:{cwd:f.codeProject,testFiles:['baseline.mjs'],commands:[{id:'baseline',command:[process.execPath,'baseline.mjs']}],timeoutMs:2000},
|
|
67
|
+
repair:{scope:['target.mjs','README.md'],requirements:['requirements.md']},
|
|
68
|
+
walkthrough:{timeoutMs:2000,flows:[{id:'value',modules:['value'],steps:['Read exported value'],expected:['43'],kind:'commands',command}]}};
|
|
69
|
+
const template=path.join(f.root,'template.json');fs.writeFileSync(template,JSON.stringify({specsRoot:f.specsDir,feature:'1.work',identity,configuration}));
|
|
70
|
+
f.args.push('--runtime',runtime,'--review-config',reviewFile,'--allow-review-attempt','1','--workflow-config',workflowFile,'--allow-qa',
|
|
71
|
+
'--qa-fix-template-config',template,'--qa-fix-review-config',reviewFile,'--allow-qa-fix-start','--auto-qa-fix',
|
|
72
|
+
...permissions.map(name=>`--allow-qa-fix-${name}`));
|
|
73
|
+
if(f.protected){
|
|
74
|
+
const protectedFile=path.join(f.root,'protected.json');
|
|
75
|
+
fs.writeFileSync(protectedFile,JSON.stringify({model:'fixture',timeoutMs:5000,checkCommands:[{id:'syntax',command:[process.execPath,'--check','target.mjs']}]}));
|
|
76
|
+
f.args.push('--protected-config',protectedFile,'--allow-provider-development-attempt','1');
|
|
77
|
+
fs.writeFileSync(template,JSON.stringify({specsRoot:f.specsDir,feature:'1.work',identity,configuration:{...configuration,protectSpecs:false}}));
|
|
78
|
+
const denied=await runCli(f,'normal');assert.equal(denied.code,1);assert(denied.stderr.includes('protected_fix_required'));
|
|
79
|
+
assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));fs.writeFileSync(template,JSON.stringify({specsRoot:f.specsDir,feature:'1.work',identity,configuration}));
|
|
80
|
+
}
|
|
81
|
+
assert.equal(fs.existsSync(path.join(f.specsDir,'运行日志.jsonl')),false);
|
|
82
|
+
const first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
|
|
83
|
+
assert.equal(first.rows.find(row=>row.requestId==='advance').result.code,'run_done',JSON.stringify(first.rows.at(-1)));
|
|
84
|
+
for(const kind of [...(f.protected?[]:['develop']),'fix_diagnose','fix_repair','fix_retrospective'])assert.equal(first.calls.filter(item=>item===kind).length,1,kind);
|
|
85
|
+
if(f.protected)assert(!first.calls.some(kind=>['develop','check','documentation_sync'].includes(kind)));
|
|
86
|
+
assert(first.calls.includes('fix_learning')); // Original owner refreshes Learning before multiple stages.
|
|
87
|
+
const resumed=await runCli(f,'normal','resume');assert.equal(resumed.code,0,resumed.stderr);
|
|
88
|
+
assert.equal(resumed.rows.find(row=>row.requestId==='advance').result.code,'run_done');
|
|
89
|
+
assert.deepEqual(resumed.calls,['documentation_inspect']);
|
|
90
|
+
const rows=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
91
|
+
assert.equal(rows.filter(row=>row.workflow==='cm-ai'&&row.event==='test_run'&&row.phase==='start').length,2);
|
|
92
|
+
assert.equal(rows.filter(row=>row.workflow==='cm-ai'&&row.event==='run_done').length,1);
|
|
93
|
+
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[x] T-001'));
|
|
94
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
for(const runtime of ['codex','claude'])for(const initialWorkflow of ['absent','qa-null','qa'])test(`configured ${runtime} CLI waits for the authorized attempt and resumes via the original review worker/gate workflow=${initialWorkflow}`,async()=>{
|
|
98
|
+
const workflow=initialWorkflow==='qa';
|
|
99
|
+
const f=fixture();
|
|
100
|
+
try{
|
|
101
|
+
f.workflow=workflow;
|
|
102
|
+
if(runtime==='claude'){f.runtime=runtime;f.args.push('--runtime',runtime);}
|
|
103
|
+
if(workflow){
|
|
104
|
+
const definition=JSON.parse(fs.readFileSync(f.config,'utf8'));definition.scope.push('README.md');
|
|
105
|
+
fs.writeFileSync(f.config,JSON.stringify(definition));
|
|
106
|
+
}
|
|
107
|
+
const bin=path.join(f.root,'bin');fs.mkdirSync(bin);
|
|
108
|
+
const fake=path.join(bin,runtime);fs.copyFileSync(fileURLToPath(new URL(`./fixtures/${runtime}-review-process.mjs`,import.meta.url)),fake);
|
|
109
|
+
fs.chmodSync(fake,0o700);f.env={...process.env,PATH:bin+path.delimiter+process.env.PATH};
|
|
110
|
+
// Actual separate CLI and loopback diagnostic process; the executable is synthetic.
|
|
111
|
+
let review;
|
|
112
|
+
const preview=spawnSync(process.execPath,[cli,'preflight','--config',f.config,'--review-model','fixture',
|
|
113
|
+
...(runtime==='claude'?['--runtime','claude']:[])],
|
|
114
|
+
{encoding:'utf8',env:f.env,timeout:5000});
|
|
115
|
+
assert.equal(preview.status,0,preview.stderr);
|
|
116
|
+
review=JSON.parse(preview.stdout);assert.equal(review.preflight.passed,true);
|
|
117
|
+
if(runtime==='codex')assert.equal(review.preflight.real_model_requests,0);
|
|
118
|
+
else assert.equal(review.preflight.isolation,'macos-loopback-sandbox');
|
|
119
|
+
assert.equal(review.preflight.listener_closed,true);
|
|
120
|
+
const config=path.join(f.root,'review.json');fs.writeFileSync(config,JSON.stringify(review));
|
|
121
|
+
f.args.push('--review-config',config);
|
|
122
|
+
if(runtime==='claude'){
|
|
123
|
+
fs.writeFileSync(config,JSON.stringify({...review,preflight:{...review.preflight,provider:'codex'}}));
|
|
124
|
+
const denied=spawnSync(process.execPath,[cli,...f.args,'--allow-review-attempt','1'],{encoding:'utf8',env:f.env,timeout:3000});
|
|
125
|
+
assert.equal(denied.status,1);assert(denied.stderr.includes('tool_preflight_missing'));
|
|
126
|
+
assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));
|
|
127
|
+
fs.writeFileSync(config,JSON.stringify(review));
|
|
128
|
+
}
|
|
129
|
+
if(workflow){
|
|
130
|
+
const workflowFile=path.join(f.root,'workflow.json');
|
|
131
|
+
fs.writeFileSync(workflowFile,JSON.stringify({documentationPaths:['README.md'],applicableAgentFiles:[],
|
|
132
|
+
qa:{commands:[{id:'value-check',command:[process.execPath,'-e',"import('./target.mjs').then(m=>{if(m.value!==42)process.exit(1)})"],caseIds:[]}],
|
|
133
|
+
environment:{kind:'web',carrier:'browser',target:'http://127.0.0.1',scope:'local'}}}));
|
|
134
|
+
f.args.push('--workflow-config',workflowFile);
|
|
135
|
+
const denied=spawnSync(process.execPath,[cli,...f.args],{encoding:'utf8',env:f.env,timeout:5000});
|
|
136
|
+
assert.equal(denied.status,1);assert(denied.stderr.includes('qa_authorization_required'));
|
|
137
|
+
assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));
|
|
138
|
+
f.args.push('--allow-qa');
|
|
139
|
+
}
|
|
140
|
+
if(!workflow)fs.writeFileSync(path.join(f.codeProject,'README.md'),'# Fixture value 42\n');
|
|
141
|
+
const attachmentFile=path.join(f.root,'attachment.json');
|
|
142
|
+
const attachmentConfig={documentationPaths:[],applicableAgentFiles:[],
|
|
143
|
+
qa:{commands:[{id:'syntax',command:[process.execPath,'--check','target.mjs'],caseIds:[]}],
|
|
144
|
+
environment:{kind:'web',carrier:'browser',target:'http://127.0.0.1',scope:'local'}}};
|
|
145
|
+
if(initialWorkflow==='qa-null'){
|
|
146
|
+
fs.writeFileSync(attachmentFile,JSON.stringify({...attachmentConfig,qa:null}));
|
|
147
|
+
f.args.push('--workflow-config',attachmentFile);
|
|
148
|
+
}
|
|
149
|
+
const first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
|
|
150
|
+
assert.equal(first.rows.find(row=>row.requestId==='advance').result.code,'decision_required');
|
|
151
|
+
const initialArgs=[...f.args];
|
|
152
|
+
const attemptAttachment=()=>{
|
|
153
|
+
fs.writeFileSync(attachmentFile,JSON.stringify(attachmentConfig));
|
|
154
|
+
if(initialWorkflow==='absent')f.args.push('--workflow-config',attachmentFile);
|
|
155
|
+
f.args.push('--allow-qa');
|
|
156
|
+
};
|
|
157
|
+
if(!workflow){
|
|
158
|
+
attemptAttachment();
|
|
159
|
+
const early=await runCli(f,'normal','resume');
|
|
160
|
+
assert.equal(early.code,1);assert.match(early.stderr,/qa_attach_not_completed/);assert.deepEqual(early.calls,[]);
|
|
161
|
+
f.args=[...initialArgs];
|
|
162
|
+
if(initialWorkflow==='qa-null')fs.writeFileSync(attachmentFile,JSON.stringify({...attachmentConfig,qa:null}));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[ ] T-001'));
|
|
166
|
+
// An approved different round cannot authorize this pending round.
|
|
167
|
+
f.args.push('--allow-review-attempt','2');
|
|
168
|
+
const wrong=await runCli(f,'normal','resume');assert.equal(wrong.code,0,wrong.stderr);
|
|
169
|
+
assert.deepEqual(wrong.calls,[]);assert.equal(wrong.rows.find(row=>row.requestId==='advance').result.code,'decision_required');
|
|
170
|
+
f.args[f.args.length-1]='1';
|
|
171
|
+
const completed=await runCli(f,'authorized-review','resume');assert.equal(completed.code,0,completed.stderr);
|
|
172
|
+
assert.deepEqual(completed.calls,workflow?['check','qa_assess','documentation_inspect']:['check']);
|
|
173
|
+
const result=completed.rows.find(row=>row.requestId==='advance').result;
|
|
174
|
+
assert.equal(result.state,workflow?'run_done':'fixture_completed');assert.equal(result.code,workflow?'run_done':'qa_decision_required');
|
|
175
|
+
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[x] T-001'));
|
|
176
|
+
const reopened=await runCli(f,'normal','resume');assert.equal(reopened.code,0,reopened.stderr);
|
|
177
|
+
assert.deepEqual(reopened.calls,workflow?['documentation_inspect']:[]);
|
|
178
|
+
assert.equal(reopened.rows.find(row=>row.requestId==='advance').result.code,workflow?'run_done':'qa_decision_required');
|
|
179
|
+
if(!workflow){
|
|
180
|
+
const stateFile=path.join(f.specsDir,'.reviews','.execution',identity.runId,'state.json');
|
|
181
|
+
const before=JSON.parse(fs.readFileSync(stateFile,'utf8'));
|
|
182
|
+
attemptAttachment();
|
|
183
|
+
// Explicit QA permission is still required, even though task work is done.
|
|
184
|
+
f.args.pop();
|
|
185
|
+
const denied=await runCli(f,'normal','resume');assert.equal(denied.code,1);
|
|
186
|
+
assert.match(denied.stderr,/qa_authorization_required/);assert.deepEqual(denied.calls,[]);
|
|
187
|
+
assert.deepEqual(JSON.parse(fs.readFileSync(stateFile,'utf8')),before);
|
|
188
|
+
f.args.push('--allow-qa');
|
|
189
|
+
// No hidden host-context or definition changes can ride the attachment.
|
|
190
|
+
const originalHost=f.args[6];f.args[6]='different-host';
|
|
191
|
+
const changedHost=await runCli(f,'normal','resume');assert.equal(changedHost.code,1);
|
|
192
|
+
assert.match(changedHost.stderr,/fingerprint_mismatch/);f.args[6]=originalHost;
|
|
193
|
+
const originalDefinition=fs.readFileSync(f.config,'utf8');
|
|
194
|
+
for(const field of ['scope','requirements']){
|
|
195
|
+
const changed=JSON.parse(originalDefinition);changed[field].push('extra.md');
|
|
196
|
+
fs.writeFileSync(f.config,JSON.stringify(changed));
|
|
197
|
+
const rejected=await runCli(f,'normal','resume');assert.equal(rejected.code,1);
|
|
198
|
+
assert.match(rejected.stderr,/fingerprint_mismatch/);fs.writeFileSync(f.config,originalDefinition);
|
|
199
|
+
}
|
|
200
|
+
f.workflow=true;
|
|
201
|
+
const {readRunnerHistory}=await import('../runtime/js/cm-ai/durable-runner-state.mjs');
|
|
202
|
+
const {digest}=await import('../runtime/js/cm-ai/effect-contract.mjs');
|
|
203
|
+
const history=readRunnerHistory(before.records,before.records[0].payload.config,3);
|
|
204
|
+
f.request={...request('qa','advance'),packageDigest:history.state.reviewPackage.packageDigest};
|
|
205
|
+
const attached=await runCli(f,'authorized-review','resume');assert.equal(attached.code,0,attached.stderr);
|
|
206
|
+
assert.deepEqual(attached.calls,['qa_assess']);
|
|
207
|
+
assert.equal(attached.rows.find(row=>row.requestId==='advance').result.code,'qa_triggered');
|
|
208
|
+
delete f.request;
|
|
209
|
+
// A killed no-result N6 run needs a fresh, explicit resume permission.
|
|
210
|
+
// The option is transport authority, never part of the stored fingerprint.
|
|
211
|
+
const {recordCmAiQaRun}=await import('../runtime/js/cm-ai/cm-ai-qa-log.mjs');
|
|
212
|
+
recordCmAiQaRun({specsDir:f.specsDir,codeProject:f.codeProject,feature:'1.work',identity,
|
|
213
|
+
packageDigest:history.state.reviewPackage.packageDigest,testRunId:'interrupted-qa',mode:'commands',caseCount:1,
|
|
214
|
+
phase:'start',logHome:path.join(f.root,'logs')});
|
|
215
|
+
const unknown=await runCli(f,'normal','resume');assert.equal(unknown.code,0,unknown.stderr);
|
|
216
|
+
assert.equal(unknown.rows.find(row=>row.requestId==='advance').result.code,'qa_execution_unknown');
|
|
217
|
+
assert.deepEqual(unknown.calls,[]);
|
|
218
|
+
f.args.push('--rerun-unknown-qa');
|
|
219
|
+
const finished=await runCli(f,'normal','resume');assert.equal(finished.code,0,finished.stderr);
|
|
220
|
+
f.args.pop();
|
|
221
|
+
assert.deepEqual(finished.calls,['documentation_inspect']);
|
|
222
|
+
assert.equal(finished.rows.find(row=>row.requestId==='advance').result.state,'run_done');
|
|
223
|
+
const qaRows=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse)
|
|
224
|
+
.filter(row=>row.event==='test_run');
|
|
225
|
+
assert.deepEqual(qaRows.filter(row=>row.phase==='start').map(row=>row.attempt),[1,1]);
|
|
226
|
+
assert.equal(qaRows.filter(row=>row.phase==='abandoned').length,1);
|
|
227
|
+
const after=JSON.parse(fs.readFileSync(stateFile,'utf8'));
|
|
228
|
+
assert.deepEqual(after.fingerprints,before.fingerprints);
|
|
229
|
+
assert.deepEqual(after.records.slice(0,before.records.length),before.records);
|
|
230
|
+
const records=after.records.filter(row=>row.payload.type==='qa-attached');assert.equal(records.length,1);
|
|
231
|
+
assert.deepEqual(Object.keys(records[0].payload.record).sort(),['attachedAt','hostContextId','qaFingerprint','version']);
|
|
232
|
+
assert.equal(records[0].payload.record.hostContextId,'native-host-fixture');
|
|
233
|
+
// Replay rejects a duplicate even with a correctly recalculated hash chain.
|
|
234
|
+
const last=records[0],body={...last,seq:after.records.length+1,
|
|
235
|
+
id:`runner.${String(after.records.length+1).padStart(6,'0')}`,previousDigest:after.records.at(-1).digest};
|
|
236
|
+
delete body.digest;
|
|
237
|
+
assert.throws(()=>readRunnerHistory([...after.records,{...body,digest:digest(body)}],
|
|
238
|
+
after.records[0].payload.config,3),{code:'qa_attachment_duplicate'});
|
|
239
|
+
assert.equal(readRunnerHistory(after.records,after.records[0].payload.config,3).state.state,'fixture_completed');
|
|
240
|
+
// Crash prefix: attachment durable, audit row absent. Resume repairs it.
|
|
241
|
+
const log=path.join(f.specsDir,'运行日志.jsonl');
|
|
242
|
+
fs.writeFileSync(log,fs.readFileSync(log,'utf8').trim().split('\n')
|
|
243
|
+
.filter(line=>JSON.parse(line).phase!=='qa_attach').join('\n')+'\n');
|
|
244
|
+
const again=await runCli(f,'normal','resume');assert.equal(again.code,0,again.stderr);
|
|
245
|
+
assert.deepEqual(again.calls,['documentation_inspect']);
|
|
246
|
+
assert.deepEqual(JSON.parse(fs.readFileSync(stateFile,'utf8')),after);
|
|
247
|
+
const logs=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
248
|
+
const attachLogs=logs.filter(row=>row.event==='decision'&&row.phase==='qa_attach');assert.equal(attachLogs.length,1);
|
|
249
|
+
assert.equal(attachLogs[0].qaFingerprint,records[0].payload.record.qaFingerprint);
|
|
250
|
+
assert.equal(logs.filter(row=>row.event==='test_run'&&row.phase==='start').length,2);
|
|
251
|
+
// Removing QA after it was bound cannot fall back to the original config.
|
|
252
|
+
const attachedArgs=[...f.args];f.args=[...initialArgs];
|
|
253
|
+
if(initialWorkflow==='qa-null')fs.writeFileSync(attachmentFile,JSON.stringify({...attachmentConfig,qa:null}));
|
|
254
|
+
const removed=await runCli(f,'normal','resume');assert.equal(removed.code,1);assert.match(removed.stderr,/fingerprint_mismatch/);
|
|
255
|
+
f.args=attachedArgs;
|
|
256
|
+
fs.writeFileSync(attachmentFile,JSON.stringify({...attachmentConfig,qa:{...attachmentConfig.qa,
|
|
257
|
+
commands:[{id:'different',command:[process.execPath,'--version'],caseIds:[]}]}}));
|
|
258
|
+
const changed=await runCli(f,'normal','resume');assert.equal(changed.code,1);assert.match(changed.stderr,/fingerprint_mismatch/);
|
|
259
|
+
assert.deepEqual(changed.calls,[]);assert.deepEqual(JSON.parse(fs.readFileSync(stateFile,'utf8')),after);
|
|
260
|
+
}
|
|
261
|
+
if(workflow){
|
|
262
|
+
const file=f.args[f.args.indexOf('--workflow-config')+1];
|
|
263
|
+
const config=JSON.parse(fs.readFileSync(file,'utf8'));config.qa.commands[0].id='different';
|
|
264
|
+
fs.writeFileSync(file,JSON.stringify(config));
|
|
265
|
+
const changed=await runCli(f,'normal','resume');assert.equal(changed.code,1);assert.match(changed.stderr,/fingerprint_mismatch/);
|
|
266
|
+
const rows=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
267
|
+
assert.equal(rows.filter(row=>row.event==='run_done').length,1);
|
|
268
|
+
assert.equal(rows.filter(row=>row.event==='test_run'&&row.phase==='start').length,1);
|
|
269
|
+
}
|
|
270
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
271
|
+
});
|