@aibyzero/cm-workflow 0.16.9 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +12 -0
- package/README.md +9 -1
- package/VERSION +1 -1
- 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/human-correction.md +5 -5
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +101 -84
- 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/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 +111 -0
- package/runtime/js/cm-ai/drive-bootstrap.mjs +11 -8
- 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-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-tool-bridge.mjs +3 -0
- 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 +1 -24
- 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 +36 -99
- 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-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 +52 -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 +62 -38
- 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 +34 -8
- 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 +124 -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 +54 -25
- package/scripts/cm-ai-drive.mjs +96 -54
- package/scripts/cm-ai-drive.test.mjs +43 -84
- 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 +38 -10
- 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 +19 -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-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 +15 -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-runtime.sh +1 -1
- package/scripts/cm-claude-worker.test.mjs +5 -3
- package/scripts/cm-controlled-correction.test.mjs +469 -0
- package/scripts/cm-external-batch-host.test.mjs +30 -11
- 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-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-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 +91 -19
- package/scripts/cm-patrol.test.mjs +3 -2
- 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/fixtures/bootstrap-review-runner.mjs +1 -7
- 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 +65 -28
- 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
package/scripts/cm-ai-host.mjs
CHANGED
|
@@ -2,26 +2,39 @@
|
|
|
2
2
|
import {readLaunchExecutionPolicy} from '../runtime/js/cm-ai/execution-policy.mjs';
|
|
3
3
|
import {readLaunchExternalModels} from '../runtime/js/cm-ai/external-model-launch.mjs';
|
|
4
4
|
import {loadExternalModels,externalPair} from '../runtime/js/cm-ai/external-models.mjs';
|
|
5
|
-
//
|
|
6
|
-
//
|
|
5
|
+
// Current-conversation host. Legacy keeps explicit attempt choices; v2 uses
|
|
6
|
+
// its bound policy. Both retain V3 review binding; preflight is local diagnostics.
|
|
7
7
|
import {selectExternalModels} from '../runtime/js/cm-ai/external-models.mjs';
|
|
8
8
|
import fs from 'node:fs';
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
import {spawnSync} from 'node:child_process';
|
|
11
11
|
import {fileURLToPath} from 'node:url';
|
|
12
12
|
import {REVIEWED_HANDOFF_HINT} from '../runtime/js/cm-ai/host-handoff.mjs';
|
|
13
|
-
import {readRunDefinition,openControlRun,createCodexExecution,assertCreatableScope} from './cm-ai-run.mjs';
|
|
13
|
+
import {readRunDefinition,openControlRun,createCodexExecution,assertCreatableScope,controlLaunchTarget,assertSupportedResumeHistory} from './cm-ai-run.mjs';
|
|
14
14
|
import {createConversationExecution as executionFor} from '../runtime/js/cm-ai/host-conversation-execution.mjs';
|
|
15
15
|
import {createHostToolBridge,HOST_ANSWER_BACKSTOP_MS} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
16
16
|
import {serveCmAiHost,parseHostInputLimit,inputLimitReason} from '../runtime/js/cm-ai/host-session.mjs';
|
|
17
17
|
import {createQaFixOwnerHost} from '../runtime/js/cm-ai/host-qa-fix-owner.mjs';
|
|
18
18
|
import {createFixLearningPreparation} from '../runtime/js/cm-fix/learning.mjs';
|
|
19
19
|
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
20
|
-
import {createHostReviewAuthority} from '../runtime/js/cm-ai/host-review-authority.mjs';
|
|
21
20
|
import {loadConfig,declaredRuntimes,resolveProtectedRuntimes} from './cm-workflow-config.mjs';
|
|
22
21
|
import {readHostWorkflowConfiguration,featureHasBrowserCases,readBrowserCapability} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
|
|
23
22
|
import {digest,json,need,shape,id} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
23
|
+
import {readControlPolicyFile,withControlPolicyHost,readControlTarget} from '../runtime/js/cm-ai/control-policy.mjs';
|
|
24
|
+
import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs';
|
|
25
|
+
import {parseModelJson} from '../runtime/js/cm-ai/model-configuration-file.mjs';
|
|
24
26
|
export {executionFor as createConversationExecution,reviewConfiguration as readConversationReviewConfiguration,reviewConfigurationValue as readConversationReviewConfigurationValue};
|
|
27
|
+
export function readLaunchControlFile(file){
|
|
28
|
+
const before=fs.lstatSync(file);
|
|
29
|
+
need(before.isFile()&&!before.isSymbolicLink()&&before.nlink===1&&before.size<=65536,'invalid_input');
|
|
30
|
+
const descriptor=fs.openSync(file,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW);
|
|
31
|
+
try{
|
|
32
|
+
const bytes=fs.readFileSync(descriptor),after=fs.fstatSync(descriptor),current=fs.lstatSync(file);
|
|
33
|
+
need([after,current].every(info=>['dev','ino','size','mtimeMs','ctimeMs'].every(key=>info[key]===before[key]))
|
|
34
|
+
&&bytes.length===before.size,'snapshot_changed');
|
|
35
|
+
return readControlTarget(parseModelJson(new TextDecoder('utf-8',{fatal:true}).decode(bytes)));
|
|
36
|
+
}finally{fs.closeSync(descriptor);}
|
|
37
|
+
}
|
|
25
38
|
export function withHandoffDiagnostic(host,error){
|
|
26
39
|
return {...host,async handle(request){
|
|
27
40
|
const result=await host.handle(request);
|
|
@@ -46,12 +59,12 @@ export function readBootstrapConfiguration(file){
|
|
|
46
59
|
const refuse=(ok,code,reason)=>{if(!ok)throw Object.assign(new Error(code),{code,reason});};
|
|
47
60
|
const REASONED_CODES=['supersede_unavailable','supersede_code_drift','handoff_exists','browser_capability_required',
|
|
48
61
|
'browser_capability_unavailable','invalid_arguments','fingerprint_mismatch','task_selection_mismatch','review_configuration_required',
|
|
49
|
-
'spec_rebind_refused','spec_rebind_unavailable','protected_scope'];
|
|
62
|
+
'spec_rebind_refused','spec_rebind_unavailable','protected_scope','invalid_input','snapshot_changed','runner_invocation'];
|
|
50
63
|
const fixLocalPermissions=new Map(['red-test','baseline','regression','learning-writeback','walkthrough','finish','abandon',
|
|
51
64
|
'abandon-review','test-author','repair','cause-review','final-review','rediagnosis','rerun-blocked-step','final-review-recovery']
|
|
52
65
|
.map(name=>[`--allow-qa-fix-${name}`,`--allow-${name}`]));
|
|
53
66
|
|
|
54
|
-
const usage='cm-ai-host.mjs serve --config RUN_DEFINITION.json --mode create|resume --host-context ID --allow-development --review-config PATH (required at create; resume passes the same file) [--original-host-context ID] [--runtime codex|claude] [--review-runtime codex|claude] [--feature N.slug] [--input-limit BYTES] [--failover] [--allow-
|
|
67
|
+
const usage='cm-ai-host.mjs serve --config RUN_DEFINITION.json --mode create|resume --host-context ID --allow-development --review-config PATH (required at create; resume passes the same file) [--original-host-context ID] [--runtime codex|claude] [--review-runtime codex|claude] [--feature N.slug] [--input-limit BYTES] [--failover] [--allow-abandon-review] [--allow-abandon-effect] [--allow-bootstrap-review-recovery] [--allow-develop-redo] [--hold-revision] [--workflow-config PATH] [--allow-qa] [--browser-qa available|unavailable]\nInput limit is transport-only: integer 65536-4194304 bytes, default 65536; it bounds every input line and every tool reply, and may change on resume. A longer line stops the session with request_too_large. Review config is {model,preflight[,disabledSkills][,timeoutMs]}; timeoutMs is the reviewer transport budget in milliseconds (integer 1-3600000, default 900000), independent of protected mode and outside the authorized configuration digest. --browser-qa declares interactive QA capability for applicable carriers including browser and ios-simulator.\nNew runs: --external-models [--external-models-config FILE] freezes one pair per actual external provider; resume reads only its snapshot. preflight --config RUN_DEFINITION.json --external-provider codex|claude uses the saved pair.\ncm-ai-host.mjs preflight --config RUN_DEFINITION.json --review-model MODEL [--runtime codex|claude] (synthetic loopback only)';
|
|
55
68
|
|
|
56
69
|
export function formatClaudeModelHint(config,version=null){
|
|
57
70
|
const marker=config?.preflight?.request_checks?.find(check=>check?.model_recognized===false);
|
|
@@ -112,12 +125,12 @@ export async function runReviewPreflight(definition,{model,effort,runtime='codex
|
|
|
112
125
|
real_model_requests:receipt.real_model_requests,listener_closed:receipt.listener_closed}};
|
|
113
126
|
}
|
|
114
127
|
|
|
115
|
-
async function protectedExecutionFor(definition,hostContextId,extra,review,mode,workflow,bridge,bootstrap=null,externalModels=null,executionPolicy=null){
|
|
128
|
+
async function protectedExecutionFor(definition,hostContextId,extra,review,mode,workflow,bridge,bootstrap=null,externalModels=null,executionPolicy=null,controlPolicy=null){
|
|
116
129
|
const runtime=extra.get('--runtime')??'codex';
|
|
117
130
|
const selected=resolveProtectedRuntimes(loadConfig({projectRoot:definition.codeProject}),runtime);
|
|
118
131
|
need(review!==null,'review_configuration_required');
|
|
119
|
-
|
|
120
|
-
|
|
132
|
+
const attempt=controlPolicy?1:Number(extra.get('--allow-provider-development-attempt'));
|
|
133
|
+
need([1,2].includes(attempt),'provider_development_authorization_required');
|
|
121
134
|
need(mode!=='create'||attempt===1,'invalid_development_attempt');
|
|
122
135
|
// Child fix configuration is checked before opening the parent store below.
|
|
123
136
|
const file=extra.get('--protected-config'),info=fs.lstatSync(file);
|
|
@@ -126,71 +139,38 @@ async function protectedExecutionFor(definition,hostContextId,extra,review,mode,
|
|
|
126
139
|
if(externalModels){const pair=externalModels.providers[selected.coderRuntime];need(!Object.hasOwn(config,'model')||config.model===pair.model,'external_model_configuration_conflict');need(!Object.hasOwn(config,'effort')||config.effort===pair.effort,'external_model_configuration_conflict');config={...config,...pair};}
|
|
127
140
|
shape(config,['model','checkCommands','timeoutMs',...(externalModels?['effort']:[])]);
|
|
128
141
|
return executionFor(definition,hostContextId,bridge,review,
|
|
129
|
-
|
|
130
|
-
workflow,extra.has('--allow-qa'),runtime,{
|
|
142
|
+
null,
|
|
143
|
+
workflow,controlPolicy?controlPolicy.qa==='run':extra.has('--allow-qa'),runtime,{
|
|
131
144
|
...(extra.has('--original-host-context')?{originalHostContextId:extra.get('--original-host-context')}:{}),
|
|
132
145
|
protection:{checkCommands:config.checkCommands,timeoutMs:config.timeoutMs},
|
|
133
146
|
providerDevelopment:{model:config.model,attempt,...selected,...(externalModels?{effort:config.effort}:{})},
|
|
134
147
|
...(executionPolicy?{executionPolicy}:{}),
|
|
148
|
+
...(controlPolicy?{controlPolicy}:{}),
|
|
135
149
|
...(externalModels?{externalModels}:{}),
|
|
136
150
|
...(extra.has('--verification-precheck')?{verificationPrecheck:true}:{}),
|
|
137
|
-
...(bootstrap?{bootstrap:{...bootstrap,allowWrite:extra.has('--allow-bootstrap-write')}}:{}),
|
|
151
|
+
...(bootstrap?{bootstrap:{...bootstrap,allowWrite:controlPolicy?controlPolicy.bootstrap==='write':extra.has('--allow-bootstrap-write')}}:{}),
|
|
138
152
|
});
|
|
139
153
|
}
|
|
140
154
|
|
|
141
155
|
|
|
142
|
-
// Existing Codex-only runs retain their exact configuration/context identities.
|
|
143
|
-
// A successful original fingerprint check is the sole authority for this path;
|
|
144
|
-
// no migration, journal rewrite, or in-flight provider switch is permitted.
|
|
145
|
-
async function legacyProtectedExecutionFor(definition,hostContextId,extra,review,mode,workflow,bridge,bootstrap=null){
|
|
146
|
-
need((extra.get('--runtime')??'codex')==='codex','protected_runtime_unsupported');
|
|
147
|
-
need(!extra.has('--verification-precheck'),'verification_precheck_unavailable');
|
|
148
|
-
need(review!==null,'review_configuration_required');
|
|
149
|
-
need(['1','2'].includes(extra.get('--allow-provider-development-attempt')),'provider_development_authorization_required');
|
|
150
|
-
const attempt=Number(extra.get('--allow-provider-development-attempt'));
|
|
151
|
-
need(mode!=='create'||attempt===1,'invalid_development_attempt');
|
|
152
|
-
// Child fix configuration is checked before opening the parent store below.
|
|
153
|
-
const file=extra.get('--protected-config'),info=fs.lstatSync(file);
|
|
154
|
-
need(info.isFile()&&!info.isSymbolicLink()&&info.size<=64*1024,'invalid_protected_config');
|
|
155
|
-
const config=json(JSON.parse(fs.readFileSync(file,'utf8')));shape(config,['model','checkCommands','timeoutMs']);
|
|
156
|
-
const authority=createHostReviewAuthority({hostContextId,reviewerId:'reviewer',adapterId:'codex-review-adapter',
|
|
157
|
-
decide:async binding=>String(binding.identity.attempt)===extra.get('--allow-review-attempt')?{status:'approved'}:null});
|
|
158
|
-
return createCodexExecution({codeProject:definition.codeProject,specsRoot:definition.specsDir,
|
|
159
|
-
developerModel:config.model,checkCommands:config.checkCommands,timeoutMs:config.timeoutMs,
|
|
160
|
-
hostContextId,developerContextId:'cm-protected-author',reviewerModel:review.model,
|
|
161
|
-
reviewerPreflight:review.preflight,disabledSkills:review.disabledSkills,
|
|
162
|
-
...(workflow?{workflow:{definition,configuration:workflow}}:{}),
|
|
163
|
-
...(bootstrap?{bootstrap:{definition,selection:bootstrap.selection}}:{})},
|
|
164
|
-
{hostDecision:null,developmentAttempt:attempt,hostDecisionProvider:authority.hostDecisionProvider,authorizeReview:authority.authorize,
|
|
165
|
-
...(workflow?{workflow:{bridge,allowQa:extra.has('--allow-qa')}}:{}),
|
|
166
|
-
...(bootstrap?{bootstrap:{bridge,allowWrite:extra.has('--allow-bootstrap-write')}}:{}),
|
|
167
|
-
authorizeDevelopment:request=>({status:request.identity.attempt===attempt
|
|
168
|
-
&&digest({...request.identity,attempt:1})===digest(definition.identity)?'approved':'denied'})});
|
|
169
|
-
}
|
|
170
|
-
function canResumeLegacyProtected(definition,runtime){
|
|
171
|
-
if(runtime!=='codex')return false;
|
|
172
|
-
const config=loadConfig({projectRoot:definition.codeProject});
|
|
173
|
-
return ['unknown','codex'].includes(declaredRuntimes(config).available)
|
|
174
|
-
&&['coder','reviewer'].every(role=>['current-ai','codex-cli'].includes(config.roles[role].adapter));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
156
|
export async function main(argv=process.argv.slice(2),{input=process.stdin,output=process.stdout,error=process.stderr}={}){
|
|
157
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Control v2: serve --config RUN --mode create|resume --host-context ID --control-config POLICY --review-config REVIEW. No --allow-*; policy selects optional modes, not human authentication. Old launches remain legacy. See docs/cm-control-policy-v2.md.\n');
|
|
178
158
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Optional --execution-optimizations freezes policy v1 for new runs only; recovery retains the original policy and legacy runs reject retrofit. See docs/execution-optimizations.md.\n');
|
|
179
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--original-host-context ID is resume-only: keep the creating session in durable configuration while --host-context remains the real live session. Omit it for same-session resume; a different session must declare the creating session. Equal IDs are equivalent to omission. Parent conversation runs only
|
|
159
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--original-host-context ID is resume-only: keep the creating session in durable configuration while --host-context remains the real live session. Omit it for same-session resume; a different session must declare the creating session. Equal IDs are equivalent to omission. Parent conversation runs only. Historical grant runs cannot resume; inspect them with cm-ai-run.mjs inspect-history --config RUN. The old protected assembly entrance is discontinued.\n');
|
|
180
160
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Approved bootstrap feature (0.bootstrap or a single numbered *.bootstrap): --bootstrap-config PATH {selection:null for scaffold, or original cm-init selection for rules} and --allow-bootstrap-write. Original scope must include fixed instruction targets; they are host-written inside the original task effect, checked/reviewed and reloaded. No Git/install/network grant. Optional codeProjects selects disjoint real roots below codeProject; prefix scope/requirements and use protected current-session checks with a declared codeProject per command.\n');
|
|
181
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Protected current-session mode (Codex or Claude; also batch): --protected-conversation-config PATH with {checkCommands,timeoutMs}; timeoutMs bounds check commands and is the reviewer budget only when review-config has no timeoutMs. A review transport timeout with no result can resume once per attempt with fresh review
|
|
182
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Protected single-task CLI mode: add --protected-config PATH --allow-provider-development-attempt 1|2 and --review-config PATH. Protected config is {model,checkCommands,timeoutMs}; roots and host identity come from the original run definition and launch. This explicitly permits one task attempt of real developer execution and its declared native-sandbox checks; --allow-development alone does not. Review
|
|
161
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Protected current-session mode (Codex or Claude; also batch): --protected-conversation-config PATH with {checkCommands,timeoutMs}; timeoutMs bounds check commands and is the reviewer budget only when review-config has no timeoutMs. A review transport timeout with no result can resume once per attempt with a fresh review context; a result-bearing timeout still requires reconciliation. No extra model call. The current host returns scoped UTF-8 edits (optional mode "0755"/"0644" on written files; new files are 0644); native Codex sandbox applies them and runs the declared checks. Original author runtime, Review checks and QA capability choices remain required. Do not combine with --protected-config. The input limit defaults to 64 KiB and may be raised with --input-limit; unavailable/binary changes stop, never switch to direct writes.\n');
|
|
162
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Protected single-task CLI mode: add --protected-config PATH --allow-provider-development-attempt 1|2 and --review-config PATH. Protected config is {model,checkCommands,timeoutMs}; roots and host identity come from the original run definition and launch. This explicitly permits one task attempt of real developer execution and its declared native-sandbox checks; --allow-development alone does not. Review dispatches directly with the configured reviewer. Diagnostics check capability. Optional original --workflow-config PATH and --allow-qa connect protected QA commands and documentation within the same developer invocation before Review; host semantic/browser/inspection requests retain their original contracts, not arbitrary writes. Default current-session mode is unchanged. Protected parent mode selects coder/reviewer CLIs from the project declaration; Claude returns protected-text-v1 proposals for host validation and sandbox application; original QA-fix options require child configuration.protectSpecs=true and all original child action permissions. Protected fix writes use text proposals, not direct host edits. The original QA/documentation/finalizer gates remain required. No installation or Git authority.\n');
|
|
183
163
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--browser-qa is required when the approved contract for this feature contains blocking or policy-enabled interactive QA cases and QA is enabled. It covers the declared carrier (browser, ios-simulator, and others); the flag name is retained for compatibility. It is a declaration by the launching session, not a probe. The gate applies to create and resume, and is not persisted. unavailable refuses to start.\n');
|
|
184
164
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--revise-qa-config PREVIOUS_WORKFLOW.json --qa-config-revision-reason REASON: 仅 resume 且 --allow-qa;核对旧配置后追加 QA 修订,旧 QA 作废留史,下一轮仍受三轮上限约束。未知 QA 须先处理;不能修改开发配置或重开 N5。\n');
|
|
185
165
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--auto-qa-fix optionally connects parent advance -> fix_run -> re-QA. Requires --qa-fix-template-config, --allow-qa-fix-start, original action permissions and project policies.auto_fix=auto. Explicit/never policies stop. Unknown, blocked or incomplete repair stops; status/cancel remain available and no fourth QA round is dispatched.\n');
|
|
186
166
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--qa-fix-template-config PATH is an alternative to --qa-fix-owner-config. Supply {specsRoot, feature, identity: parent identity, configuration: original fix configuration without qaSource}. Each fix request binds it to the latest completed QA failure; identity/digests are generated, commands/scope/permissions are not. Existing child configuration remains immutable.\n');
|
|
187
167
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('fix_run continuously executes normal stages of the fixed QA child using the same binding as fix_advance. Requires --allow-qa-fix-start and every original per-action permission/configuration. Stops on unknown, blocked, observation, revision-required or unchanged state; a design-change child closes as escalated and reports qa_fix_incomplete, never qa_fix_completed. It does not auto-switch child configuration or run parent QA.\n');
|
|
188
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('fix_action delegates to the shared original cm-fix dispatcher. Local flags: --allow-qa-fix-red-test, --allow-qa-fix-baseline, --allow-qa-fix-regression, --allow-qa-fix-learning-writeback, --allow-qa-fix-walkthrough, --allow-qa-fix-finish, --allow-qa-fix-abandon, --allow-qa-fix-abandon-review, --allow-qa-fix-rediagnosis, --allow-qa-fix-rerun-blocked-step, --allow-qa-fix-final-review-recovery [--qa-fix-final-review-recovery-invocation ID]. Recovery fixOperations rediagnose, rerun_blocked_step (reason), revision_test_check (regression flag) and recover_final_review ({invocationId, reviewPackageDigest = the child final review package digest, previousInvocationStopped:true, reason}) go to the same cm-fix dispatcher with the same conditions as cm-fix-host; a missing flag returns qa_fix_action_authorization_required naming the parent flag, a cm-fix refusal returns its own code, and the parent reopens either way. abandon_step also requires a reason in the fix_action request and only applies to eligible local unknown steps; abandon_review requires --allow-qa-fix-abandon-review and a reason, and applies once to the child cause review and once to its second-round final review while that registered review has no review result. The parent run\'s own --allow-abandon-review does not reach the child. Adapter flags: --allow-qa-fix-test-author, --allow-qa-fix-repair, --allow-qa-fix-cause-review, --allow-qa-fix-final-review, with separate --qa-fix-review-config PATH and matching original child reviewer metadata. All require --allow-qa-fix-start and the original action configuration/gates. Parent --review-config
|
|
168
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('fix_action delegates to the shared original cm-fix dispatcher. Local flags: --allow-qa-fix-red-test, --allow-qa-fix-baseline, --allow-qa-fix-regression, --allow-qa-fix-learning-writeback, --allow-qa-fix-walkthrough, --allow-qa-fix-finish, --allow-qa-fix-abandon, --allow-qa-fix-abandon-review, --allow-qa-fix-rediagnosis, --allow-qa-fix-rerun-blocked-step, --allow-qa-fix-final-review-recovery [--qa-fix-final-review-recovery-invocation ID]. Recovery fixOperations rediagnose, rerun_blocked_step (reason), revision_test_check (regression flag) and recover_final_review ({invocationId, reviewPackageDigest = the child final review package digest, previousInvocationStopped:true, reason}) go to the same cm-fix dispatcher with the same conditions as cm-fix-host; a missing flag returns qa_fix_action_authorization_required naming the parent flag, a cm-fix refusal returns its own code, and the parent reopens either way. abandon_step also requires a reason in the fix_action request and only applies to eligible local unknown steps; abandon_review requires --allow-qa-fix-abandon-review and a reason, and applies once to the child cause review and once to its second-round final review while that registered review has no review result. The parent run\'s own --allow-abandon-review does not reach the child. Adapter flags: --allow-qa-fix-test-author, --allow-qa-fix-repair, --allow-qa-fix-cause-review, --allow-qa-fix-final-review, with separate --qa-fix-review-config PATH and matching original child reviewer metadata. All require --allow-qa-fix-start and the original action configuration/gates. Parent --review-config does not configure child review.\n');
|
|
189
169
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--allow-qa-fix-start additionally permits fix_advance to create or resume the fixed QA child and run only its original Learning/reproduction/diagnosis stages. Child runtime must match this host. A new child hostContextId must be the live session or the parent durable creator; an existing child retains its fingerprint-verified configuration. Child opens and review grants use the live session. It does not authorize test authoring, repair, independent provider Review, finish, Git or re-QA. Active child status/cancel use the original child owner; repeated advance never resets an unknown or completed step.\n');
|
|
190
170
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--qa-fix-owner-config PATH enables read-only fix_status. The file contains the existing fix owner definition {specsRoot, identity, configuration}, including its exact original qaSource and immutable configuration, not provider grants. fix_status binds the parent identity/packageDigest/testRunId, serially closes the parent writer, opens only an existing child, reads its original completion evidence, closes it and resumes the same parent. It does not create/execute repairs, rerun QA or clear correction gates.\n');
|
|
191
171
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Protected current-session invalid_result means local value/Learning validation failed before file writes. Fix the reply, keep the same configuration, host identity and runId, restart with --mode resume and advance: blocked/developer_result_invalid retries develop at the same attempt. no_new_lesson requires reason:null (dogfood incident: nonempty reason previously wrote files then stranded the run as unknown). Already-applied proposals must match expected disk hashes; conflicts block as protected_edit_stale. Worker exceptions/timeouts and old unknown history are not retryable.\n');
|
|
192
172
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('New cm-ai runs carry approved specification data in developer requests and review packages: task/verification, all AC lines, design (64 KiB UTF-8 maximum, truncated:true above it), task-related test cases and manifest hashes. Sources must match .cm-specs-status.specFiles or spec_drift blocks. requirements may be [] or additional code-project files; specs never become writable scope. Legacy runs/packages retain their original representation. Dogfood: separate specs/code roots previously left developers and reviewers without task/interface contracts.\n');
|
|
193
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Completed fixture_completed runs originally without QA may explicitly attach N6 once on --mode resume with --workflow-config (non-null qa) and --allow-qa. Original definition, scope, requirements, identity and non-workflow configuration must match. The immutable qa-attached journal record binds the full resumed config fingerprint; later resumes require that same configuration and fresh --allow-qa. qa still requests qa_assess; no automatic decision or repeated development/Review. Dogfood: missing workflow at create previously stranded mandatory feature QA.\n');
|
|
173
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Completed fixture_completed runs originally without QA may explicitly attach N6 once on --mode resume with --workflow-config (non-null qa) and --allow-qa. Original definition, scope, requirements, identity and non-workflow configuration must match. The immutable qa-attached journal record binds the full resumed config fingerprint; later resumes require that same configuration and fresh --allow-qa. qa still requests qa_assess ({confirmed:true}, inventory source only); fixed checkpoints and registered paths decide N6; no automatic decision or repeated development/Review. Dogfood: missing workflow at create previously stranded mandatory feature QA.\n');
|
|
194
174
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--rerun-unknown-qa requires --mode resume and fresh --allow-qa with the original workflow config. Only an unfinished QA invocation whose recorded case results are all PASS and which has no fixed execution report may be abandoned and rerun under a new testRunId at the same qaRound. The abandoned record lists partial_pass_cases; every case is rerun and old PASS evidence is history only. FAIL/BLOCKED results and unclosed resources remain blocked; no complete is fabricated. Exception: a call stopped as a whole (qa_execution_timeout) with no report and no FAIL, whose every case_blocked is a host request timeout (host_request_timeout: true; an older row without that field needs the full qa.timeoutMs elapsed since case_start plus an operator --qa-environment-failure REASON attesting no session answer, recorded verbatim as legacy_timeout_attestation, otherwise qa_environment_failure_required) and never session-declared, is superseded (reason host_request_timeout) and rerun at qaRound+1; --rerun-blocked-qa on it is refused as qa_rerun_unknown_qa_required. The same applies to a call stopped as a whole (timeout, host death or a hard-invalid answer) whose other BLOCKED rows were session-declared or host-judged evidence/environment/cleanup gaps (blocked_reason): they are listed as host_blocked_cases. The whole-round deadline scales with the frozen plan (commands x command timeout, logic cases x request window, browser cases x two windows, plus one minute; at least 30 minutes, at most 24 hours). A cleanup_failed QA command resource whose recorded process group the host proves gone is released first (released_by host_verified).\n');
|
|
195
175
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--rerun-blocked-qa requires --mode resume, the original --workflow-config and fresh --allow-qa. Only the latest completed BLOCKED invocation with zero failures and exclusively host/environment evidence gaps can be superseded: browser evidenceProblem, failed cleanup, environment mismatch, host timeout or a host-declared BLOCKED answer; logic INSUFFICIENT_EVIDENCE or blocked only by a mapped command without exit code; QA commands that produced no exit code (timeout, killed, spawn/output failure). Missing/deferred command rows ([需确认], commands-unavailable, no-applicable-cases, no browser capability) and source drift are excluded. A new testRunId reruns every case at qaRound+1 (three rounds, plus at most two given back for rounds superseded for host or answer problems: host_request_timeout, host_evidence_problem); superseded and start link previous_test_run_id. The flag is consumed once, never persisted; no development/Review/task replay or new QA decision. Do not combine with --rerun-unknown-qa.\n');
|
|
196
176
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('For a QA decision an older host recorded as blocked/host_request_timeout, --rerun-blocked-qa instead re-asks qa_assess once and appends a decision linked by previous_decision_id; history is kept (current hosts report a missed qa_assess window as retryable rejected/qa_decision_timeout and record nothing). --qa-environment-failure REASON (with --rerun-blocked-qa, single line, at most 500 UTF-8 bytes) declares that the non-zero QA command exits of the latest completed FAIL came from the environment: only command exits and logic cases failed solely by them qualify, never browser FAIL or CONTRADICTED; the superseded row records reason, failed_cases and blocked_cases. Every rerun reuses the three-round QA budget. Single-task host only.\n');
|
|
@@ -203,7 +183,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
203
183
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('--rebind-spec-material --spec-rebind-reason REASON:仅 resume。规格经 cm-prd --change 重新批准后,若本任务的描述、验证要求、验收标准、设计摘录与测试用例都未变,只换绑批准哈希并写 specification-rebound 记录,已有开发与审查结论保留;内容有变则拒绝并列出变化。status 的 spec_drift 会说明是否可换绑。\n');
|
|
204
184
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('当前会话手动驱动请用 scripts/cm-ai-drive.mjs(批次 cm-ai-batch-drive.mjs;修复 cm-fix-drive.mjs;规格 cm-prd-drive.mjs);详情见 skills/cm-ai/references/js-host.md。\n');
|
|
205
185
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('External-model mode freezes one model/effort pair per provider. Unknown or invalid external results require reconciliation; automatic retries and abandonment are disabled. See docs/external-models.md.\n');
|
|
206
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\n');return 0;}
|
|
186
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\nV2: replace --allow-development with --control-config FILE. Explicit resume QA reruns, QA configuration revisions and specification rebinds require --expected-control FILE containing the original status.launchControlTarget; ordinary host recovery uses status.controlTarget.\n');return 0;}
|
|
207
187
|
let run,bridge;
|
|
208
188
|
try{
|
|
209
189
|
if(argv[0]==='preflight'){
|
|
@@ -224,15 +204,46 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
224
204
|
}
|
|
225
205
|
return config.preflight.passed?0:1;
|
|
226
206
|
}
|
|
207
|
+
let controlPolicy=null;
|
|
208
|
+
if(argv[0]==='serve'&&argv[7]==='--control-config'){
|
|
209
|
+
refuse(!argv.some(value=>value.startsWith('--allow-')),'invalid_arguments',
|
|
210
|
+
'新版控制入口不接受 --allow-*;用 control-config 选择执行模式。旧运行请保留原入口与参数。');
|
|
211
|
+
controlPolicy=readControlPolicyFile(argv[8]);
|
|
212
|
+
// Keep the policy entry separate; never synthesize legacy argv or grants.
|
|
213
|
+
}
|
|
227
214
|
need(argv.length>=8&&argv[0]==='serve'&&argv[1]==='--config'&&argv[3]==='--mode'
|
|
228
|
-
&&argv[5]==='--host-context'&&argv[7]==='--allow-development','host_launch_authorization_required');
|
|
215
|
+
&&argv[5]==='--host-context'&&(controlPolicy!==null||argv[7]==='--allow-development'),'host_launch_authorization_required');
|
|
229
216
|
const extra=new Map();
|
|
230
|
-
for(let index=8;index<argv.length;index++){
|
|
217
|
+
for(let index=controlPolicy?9:8;index<argv.length;index++){
|
|
231
218
|
const name=argv[index];refuse(!extra.has(name),'invalid_arguments',`参数重复:${name}`);
|
|
232
|
-
refuse(['--execution-optimizations','--external-models','--external-models-config','--verification-precheck','--revise-qa-config','--qa-config-revision-reason','--qa-environment-failure','--supersede-reviewed-evidence','--supersede-reason','--accept-superseded-code-drift','--rebind-spec-material','--spec-rebind-reason','--original-host-context','--bootstrap-config','--allow-bootstrap-write','--protected-conversation-config','--protected-config','--allow-provider-development-attempt','--review-config','--allow-
|
|
219
|
+
refuse(['--expected-control','--execution-optimizations','--external-models','--external-models-config','--verification-precheck','--revise-qa-config','--qa-config-revision-reason','--qa-environment-failure','--supersede-reviewed-evidence','--supersede-reason','--accept-superseded-code-drift','--rebind-spec-material','--spec-rebind-reason','--original-host-context','--bootstrap-config','--allow-bootstrap-write','--protected-conversation-config','--protected-config','--allow-provider-development-attempt','--review-config','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--allow-develop-redo','--hold-revision','--workflow-config','--allow-qa','--browser-qa','--rerun-unknown-qa','--rerun-blocked-qa','--runtime','--review-runtime','--feature','--input-limit','--failover','--qa-fix-owner-config','--qa-fix-template-config','--qa-fix-review-config','--qa-fix-final-review-recovery-invocation','--allow-qa-fix-start','--auto-qa-fix',...fixLocalPermissions.keys()].includes(name),'invalid_arguments',`未知参数:${name}`);
|
|
233
220
|
if(['--execution-optimizations','--external-models','--verification-precheck','--supersede-reviewed-evidence','--accept-superseded-code-drift','--rebind-spec-material','--allow-bootstrap-write','--allow-qa','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--allow-develop-redo','--hold-revision','--rerun-unknown-qa','--rerun-blocked-qa','--failover','--allow-qa-fix-start','--auto-qa-fix',...fixLocalPermissions.keys()].includes(name))extra.set(name,true);
|
|
234
221
|
else{refuse(typeof argv[index+1]==='string'&&!argv[index+1].startsWith('--'),'invalid_arguments',`${name} 需要一个值`);extra.set(name,argv[++index]);}
|
|
235
222
|
}
|
|
223
|
+
if(controlPolicy){
|
|
224
|
+
// Policy choices go directly to execution contracts, not the legacy flag map.
|
|
225
|
+
refuse((controlPolicy.development==='provider')===extra.has('--protected-config'),'invalid_arguments',
|
|
226
|
+
'development:provider 需要 --protected-config;conversation 模式不启动 provider 开发。');
|
|
227
|
+
refuse((controlPolicy.bootstrap==='write')===extra.has('--bootstrap-config'),'invalid_arguments',
|
|
228
|
+
'bootstrap:write 需要 --bootstrap-config;加载规则配置必须明确选择 write 模式。');
|
|
229
|
+
refuse(controlPolicy.qaFix!=='disabled'||!['--qa-fix-owner-config','--qa-fix-template-config'].some(flag=>extra.has(flag)),
|
|
230
|
+
'invalid_arguments','加载 QA 修复配置必须选择 manual 或 auto 模式。');
|
|
231
|
+
refuse(!extra.has('--auto-qa-fix')||controlPolicy.qaFix==='auto','invalid_input','自动 QA 修复需要 qaFix:auto。');
|
|
232
|
+
refuse(!['--supersede-reviewed-evidence','--supersede-reason','--accept-superseded-code-drift']
|
|
233
|
+
.some(flag=>extra.has(flag)),'supersede_unavailable',
|
|
234
|
+
'新版启动入口暂不作废旧运行;保留现场,不自动更新目标后换运行。');
|
|
235
|
+
}
|
|
236
|
+
const qaEnabled=controlPolicy?controlPolicy.qa==='run':extra.has('--allow-qa');
|
|
237
|
+
const fixEnabled=controlPolicy?controlPolicy.qaFix!=='disabled':extra.has('--allow-qa-fix-start');
|
|
238
|
+
const autoFix=controlPolicy?controlPolicy.qaFix==='auto':extra.has('--auto-qa-fix');
|
|
239
|
+
const recoveryEnabled=flag=>controlPolicy?argv[4]==='resume':extra.has(flag);
|
|
240
|
+
const launchRecovery=['--revise-qa-config','--qa-config-revision-reason','--rerun-unknown-qa','--rerun-blocked-qa',
|
|
241
|
+
'--rebind-spec-material','--spec-rebind-reason'].some(flag=>extra.has(flag));
|
|
242
|
+
refuse(!extra.has('--expected-control')||(controlPolicy&&launchRecovery&&argv[4]==='resume'),'invalid_input',
|
|
243
|
+
'--expected-control 仅用于新版 --mode resume 的显式 QA 恢复、QA 配置修订或规格重绑。');
|
|
244
|
+
if(controlPolicy&&launchRecovery)refuse(argv[4]==='resume'&&extra.has('--expected-control'),'invalid_input',
|
|
245
|
+
'启动恢复需要 --mode resume 与 --expected-control FILE,文件须保存原 status 的 launchControlTarget;目标变化时先核对,不能自动替换。');
|
|
246
|
+
const expectedControl=extra.has('--expected-control')?readLaunchControlFile(extra.get('--expected-control')):null;
|
|
236
247
|
let inputLimit;
|
|
237
248
|
try{inputLimit=parseHostInputLimit(extra.get('--input-limit'));}
|
|
238
249
|
catch(error){refuse(error.code!=='invalid_arguments','invalid_arguments','--input-limit 须为 65536–4194304 的整数字节数');throw error;}
|
|
@@ -240,7 +251,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
240
251
|
need(!extra.has('--supersede-reviewed-evidence')&&!extra.has('--supersede-reason')&&!extra.has('--accept-superseded-code-drift')
|
|
241
252
|
||(argv[4]==='create'&&extra.has('--supersede-reviewed-evidence')&&extra.has('--supersede-reason')),
|
|
242
253
|
'supersede_unavailable');
|
|
243
|
-
need(!revisionRequested||(argv[4]==='resume'&&
|
|
254
|
+
need(!revisionRequested||(argv[4]==='resume'&&qaEnabled&&extra.has('--revise-qa-config')
|
|
244
255
|
&&extra.has('--qa-config-revision-reason')&&!extra.has('--rerun-unknown-qa')&&!extra.has('--rerun-blocked-qa')),'qa_revision_authorization_required');
|
|
245
256
|
need(!extra.has('--allow-abandon-review')||argv[4]==='resume','review_abandon_unavailable');
|
|
246
257
|
refuse(extra.has('--rebind-spec-material')===extra.has('--spec-rebind-reason')&&(!extra.has('--rebind-spec-material')||argv[4]==='resume'),
|
|
@@ -255,22 +266,22 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
255
266
|
if(originalHostContextId===argv[6])extra.delete('--original-host-context');
|
|
256
267
|
let review=null;
|
|
257
268
|
const workflow=extra.has('--workflow-config')?readHostWorkflowConfiguration(extra.get('--workflow-config')):null;
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
269
|
+
refuse(!qaEnabled||workflow?.qa!=null,'invalid_arguments',
|
|
270
|
+
controlPolicy
|
|
271
|
+
?(workflow===null?'QA 执行需要同时提供 --workflow-config':'QA 执行需要 --workflow-config 中的 qa 不为 null;没有 QA 时不要启用执行')
|
|
272
|
+
:(workflow===null?'--allow-qa 需要同时提供 --workflow-config':'--allow-qa 需要 --workflow-config 中的 qa 不为 null;本运行没有 QA 时去掉 --allow-qa'));
|
|
262
273
|
need(!(extra.has('--rerun-unknown-qa')&&extra.has('--rerun-blocked-qa')),'qa_recovery_authorization_required');
|
|
263
|
-
need(!(extra.has('--rerun-unknown-qa')||extra.has('--rerun-blocked-qa'))||(argv[4]==='resume'&&
|
|
274
|
+
need(!(extra.has('--rerun-unknown-qa')||extra.has('--rerun-blocked-qa'))||(argv[4]==='resume'&&qaEnabled),'qa_recovery_authorization_required');
|
|
264
275
|
need(!extra.has('--qa-environment-failure')||extra.has('--rerun-blocked-qa')||extra.has('--rerun-unknown-qa'),'qa_recovery_authorization_required');
|
|
265
276
|
const hasFix=extra.has('--qa-fix-owner-config')||extra.has('--qa-fix-template-config');
|
|
266
277
|
need(!(extra.has('--qa-fix-owner-config')&&extra.has('--qa-fix-template-config')),'invalid_fix_config');
|
|
267
|
-
need(!
|
|
278
|
+
need(!fixEnabled||hasFix,'qa_fix_source_required');
|
|
268
279
|
need(!extra.has('--qa-fix-review-config')||hasFix,'qa_fix_source_required');
|
|
269
|
-
need(!
|
|
270
|
-
need(![...fixLocalPermissions.keys()].some(flag=>extra.has(flag))||
|
|
280
|
+
need(!autoFix||(extra.has('--qa-fix-template-config')&&fixEnabled),'qa_fix_auto_authorization_required');
|
|
281
|
+
need(![...fixLocalPermissions.keys()].some(flag=>extra.has(flag))||fixEnabled,'qa_fix_start_authorization_required');
|
|
271
282
|
// Same binding as cm-fix-host --final-review-recovery-invocation, for the child.
|
|
272
|
-
refuse(!extra.has('--qa-fix-final-review-recovery-invocation')||extra.has('--allow-qa-fix-final-review-recovery'),'invalid_arguments',
|
|
273
|
-
'--qa-fix-final-review-recovery-invocation 需要同时提供 --allow-qa-fix-final-review-recovery');
|
|
283
|
+
refuse(!extra.has('--qa-fix-final-review-recovery-invocation')||(controlPolicy?fixEnabled:extra.has('--allow-qa-fix-final-review-recovery')),'invalid_arguments',
|
|
284
|
+
controlPolicy?'QA 修复回执恢复需要已启用 QA Fix 模式':'--qa-fix-final-review-recovery-invocation 需要同时提供 --allow-qa-fix-final-review-recovery');
|
|
274
285
|
if(extra.has('--qa-fix-final-review-recovery-invocation'))id(extra.get('--qa-fix-final-review-recovery-invocation'));
|
|
275
286
|
need(!extra.has('--allow-provider-development-attempt')||extra.has('--protected-config'),'protected_configuration_required');
|
|
276
287
|
refuse(!(extra.has('--review-runtime')&&(extra.has('--protected-config')||extra.has('--external-models'))),'invalid_arguments',
|
|
@@ -278,10 +289,11 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
278
289
|
refuse(!(extra.has('--protected-config')&&extra.has('--protected-conversation-config')),'invalid_arguments','--protected-config 与 --protected-conversation-config 不能同时使用');
|
|
279
290
|
const protection=extra.has('--protected-conversation-config')?readConversationProtection(extra.get('--protected-conversation-config')):null;
|
|
280
291
|
const bootstrap=extra.has('--bootstrap-config')?readBootstrapConfiguration(extra.get('--bootstrap-config')):null;
|
|
281
|
-
need(!extra.has('--allow-bootstrap-write')||bootstrap!==null,'bootstrap_configuration_required');
|
|
292
|
+
need(!(controlPolicy?controlPolicy.bootstrap==='write':extra.has('--allow-bootstrap-write'))||bootstrap!==null,'bootstrap_configuration_required');
|
|
282
293
|
// Checked before the definition is read so the conflict is reported on its own.
|
|
283
294
|
need(!(extra.has('--failover')&&extra.has('--protected-config')),'failover_unsupported_in_protected_mode');
|
|
284
295
|
let definition=readRunDefinition(argv[2]);
|
|
296
|
+
if(argv[4]==='resume')assertSupportedResumeHistory(definition);
|
|
285
297
|
// --feature binds an explicit batch choice into the run definition, exactly
|
|
286
298
|
// as a printed featureSelection does; resume must repeat it (fingerprint).
|
|
287
299
|
if(extra.has('--feature')){
|
|
@@ -301,7 +313,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
301
313
|
// Launch-time capability assertion. See host-workflow-capabilities: this is a
|
|
302
314
|
// fresh declaration, not a probe the host performs.
|
|
303
315
|
readBrowserCapability(extra.get('--browser-qa'),
|
|
304
|
-
workflow?.qa!=null&&featureHasBrowserCases(definition.specsDir,definition.feature,definition.codeProject)
|
|
316
|
+
(!controlPolicy||qaEnabled)&&workflow?.qa!=null&&featureHasBrowserCases(definition.specsDir,definition.feature,definition.codeProject)
|
|
305
317
|
?[workflow.qa.environment?.carrier??'browser']:[]);
|
|
306
318
|
// Tool replies travel on the same input lines, so they share the one limit.
|
|
307
319
|
bridge=createHostToolBridge({responseLimit:inputLimit,answerTimeoutMs:HOST_ANSWER_BACKSTOP_MS});
|
|
@@ -331,29 +343,16 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
331
343
|
fix=json(JSON.parse(fs.readFileSync(file,'utf8')),64*1024);
|
|
332
344
|
if(extra.has('--protected-config')||protection)need(fix.configuration?.protectSpecs===true,'protected_fix_required');
|
|
333
345
|
}
|
|
334
|
-
// The reviewer
|
|
335
|
-
// it cannot be added on resume. Requiring it at create removes the trap of
|
|
336
|
-
// a run that can reach awaiting_review but never be reviewed. Authorizing a
|
|
337
|
-
// review attempt is still the separate --allow-review-attempt.
|
|
346
|
+
// The reviewer configuration remains bound into the durable fingerprint.
|
|
338
347
|
refuse(argv[4]!=='create'||review!==null,'review_configuration_required',
|
|
339
|
-
'create 必须带 --review-config:审查配置写进运行指纹,resume
|
|
348
|
+
'create 必须带 --review-config:审查配置写进运行指纹,resume 时不能再补。配置完成后自动派发 fresh Review。');
|
|
340
349
|
let execution;
|
|
341
|
-
if(argv[4]==='resume'&&!extra.has('--original-host-context')&&extra.has('--protected-config')&&!externalModels&&!executionPolicy&&canResumeLegacyProtected(definition,runtime)){
|
|
342
|
-
try{
|
|
343
|
-
execution=await legacyProtectedExecutionFor(definition,argv[6],extra,review,argv[4],workflow,bridge,bootstrap);
|
|
344
|
-
run=await openControlRun(definition,argv[4],execution,{qaConfigRevision,rerunUnknownQa:extra.has('--rerun-unknown-qa'),rerunBlockedQa:extra.has('--rerun-blocked-qa'),qaEnvironmentFailure:extra.get('--qa-environment-failure')??null,supersedeReason:extra.get('--supersede-reason')??null,acceptSupersededCodeDrift:extra.has('--accept-superseded-code-drift'),allowAbandonReview:extra.has('--allow-abandon-review'),allowAbandonEffect:extra.has('--allow-abandon-effect'),allowBootstrapReviewRecovery:extra.has('--allow-bootstrap-review-recovery'),allowDevelopRedo:extra.has('--allow-develop-redo'),...(extra.has('--hold-revision')?{holdRevision:true}:{}),specRebindReason:extra.get('--spec-rebind-reason')??null});
|
|
345
|
-
error.write('cm-ai-host: resumed original Codex protected execution after exact fingerprint validation.\n');
|
|
346
|
-
}catch(cause){
|
|
347
|
-
if(!['fingerprint_mismatch','tool_preflight_missing'].includes(cause.code))throw cause;
|
|
348
|
-
execution=undefined;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
350
|
if(!run){
|
|
352
351
|
execution=extra.has('--protected-config')
|
|
353
|
-
?await protectedExecutionFor(definition,argv[6],extra,review,argv[4],workflow,bridge,bootstrap,externalModels,executionPolicy)
|
|
354
|
-
:executionFor(definition,argv[6],bridge,review,
|
|
355
|
-
{...(extra.has('--review-runtime')?{reviewRuntime:extra.get('--review-runtime')}:{}),...(executionPolicy?{executionPolicy}:{}),...(externalModels?{externalModels}:{}),...(extra.has('--verification-precheck')?{verificationPrecheck:true}:{}),...(extra.has('--original-host-context')?{originalHostContextId:extra.get('--original-host-context')}:{}),...(protection?{protection}:{}),...(bootstrap?{bootstrap:{...bootstrap,allowWrite:extra.has('--allow-bootstrap-write')}}:{})});
|
|
356
|
-
run=await openControlRun(definition,argv[4],execution,{qaConfigRevision,rerunUnknownQa:extra.has('--rerun-unknown-qa'),rerunBlockedQa:extra.has('--rerun-blocked-qa'),qaEnvironmentFailure:extra.get('--qa-environment-failure')??null,supersedeReason:extra.get('--supersede-reason')??null,acceptSupersededCodeDrift:extra.has('--accept-superseded-code-drift'),allowAbandonReview:
|
|
352
|
+
?await protectedExecutionFor(definition,argv[6],extra,review,argv[4],workflow,bridge,bootstrap,externalModels,executionPolicy,controlPolicy)
|
|
353
|
+
:executionFor(definition,argv[6],bridge,review,null,workflow,qaEnabled,runtime,
|
|
354
|
+
{...(controlPolicy?{controlPolicy}:{}),...(extra.has('--review-runtime')?{reviewRuntime:extra.get('--review-runtime')}:{}),...(executionPolicy?{executionPolicy}:{}),...(externalModels?{externalModels}:{}),...(extra.has('--verification-precheck')?{verificationPrecheck:true}:{}),...(extra.has('--original-host-context')?{originalHostContextId:extra.get('--original-host-context')}:{}),...(protection?{protection}:{}),...(bootstrap?{bootstrap:{...bootstrap,allowWrite:(controlPolicy?controlPolicy.bootstrap==='write':extra.has('--allow-bootstrap-write'))}}:{})});
|
|
355
|
+
run=await openControlRun(definition,argv[4],execution,{qaConfigRevision,rerunUnknownQa:extra.has('--rerun-unknown-qa'),rerunBlockedQa:extra.has('--rerun-blocked-qa'),qaEnvironmentFailure:extra.get('--qa-environment-failure')??null,supersedeReason:extra.get('--supersede-reason')??null,acceptSupersededCodeDrift:extra.has('--accept-superseded-code-drift'),allowAbandonReview:recoveryEnabled('--allow-abandon-review'),allowAbandonEffect:recoveryEnabled('--allow-abandon-effect'),allowBootstrapReviewRecovery:recoveryEnabled('--allow-bootstrap-review-recovery'),allowDevelopRedo:recoveryEnabled('--allow-develop-redo'),...(extra.has('--hold-revision')?{holdRevision:true}:{}),specRebindReason:extra.get('--spec-rebind-reason')??null,expectedControl});
|
|
357
356
|
}
|
|
358
357
|
if(run.blocked){output.write(JSON.stringify({outcome:'blocked',admission:run.blocked})+'\n');return 1;}
|
|
359
358
|
if(hasFix){
|
|
@@ -361,11 +360,17 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
361
360
|
&&fs.realpathSync(fix.configuration.reproduction.cwd)===fs.realpathSync(definition.codeProject)
|
|
362
361
|
&&(templated?fix.feature:fix.configuration.qaSource.feature)===definition.feature,'qa_fix_source_mismatch');
|
|
363
362
|
if(templated)need(digest(fix.identity)===digest(definition.identity),'qa_fix_source_mismatch');
|
|
364
|
-
if(
|
|
365
|
-
|
|
363
|
+
if(fixEnabled)need((fix.configuration.runtime??'codex')===runtime,'qa_fix_host_mismatch');
|
|
364
|
+
let fixPermissions=[...fixLocalPermissions].filter(([flag])=>controlPolicy
|
|
365
|
+
?!['test-author','repair','cause-review','final-review'].some(name=>flag.endsWith('-'+name))
|
|
366
|
+
:extra.has(flag)).map(([,permission])=>permission);
|
|
366
367
|
const fixRuntime=fix.configuration.runtime??'codex';
|
|
367
368
|
const fixModels=externalModels?selectExternalModels(externalModels,[fixRuntime]):null;
|
|
368
369
|
const fixReview=extra.has('--qa-fix-review-config')?reviewConfiguration(extra.get('--qa-fix-review-config'),fixModels?.providers[fixRuntime]??null):null;
|
|
370
|
+
if(controlPolicy&&fixReview)fixPermissions.push(...[...fixLocalPermissions]
|
|
371
|
+
.filter(([flag])=>flag.endsWith('-cause-review')||flag.endsWith('-final-review')
|
|
372
|
+
||fix.configuration.testAuthor&&flag.endsWith('-test-author')||fix.configuration.repair&&flag.endsWith('-repair'))
|
|
373
|
+
.map(([,permission])=>permission));
|
|
369
374
|
need(!fixPermissions.includes('--allow-test-author')||(fix.configuration.testAuthor&&fixReview),'test_author_configuration_required');
|
|
370
375
|
need(!fixPermissions.includes('--allow-repair')||(fix.configuration.repair&&fixReview),'repair_configuration_required');
|
|
371
376
|
const fixReviewHost=createFixReviewHost({codeProject:definition.codeProject,
|
|
@@ -380,8 +385,8 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
380
385
|
}
|
|
381
386
|
}else if(fixReview)need(digest(fix.configuration.causeReview??null)===digest(fixReviewHost.reviewer),'qa_fix_review_configuration_mismatch');
|
|
382
387
|
const host=createQaFixOwnerHost({parent:run,hostContextId:argv[6],parentHostContextId:execution.configuration.hostContextId,...(templated?{template:fix}:{fix}),reopenParent:()=>openControlRun(definition,'resume',execution),
|
|
383
|
-
externalModels:fixModels,executionPolicy,fixPermissions,fixAuthorities:{authority:fixReviewHost.authority,finalAuthority:fixReviewHost.finalAuthority},
|
|
384
|
-
allowStart:
|
|
388
|
+
externalModels:fixModels,executionPolicy,controlPolicy,fixPermissions,fixAuthorities:{authority:fixReviewHost.authority,finalAuthority:fixReviewHost.finalAuthority},
|
|
389
|
+
allowStart:fixEnabled,autoFix:autoFix,
|
|
385
390
|
recoveryInvocationId:extra.get('--qa-fix-final-review-recovery-invocation')??null,fixExecution:{bridge,...fixReviewHost.execution,
|
|
386
391
|
prepare:createFixLearningPreparation({bridge,codeProject:definition.codeProject,
|
|
387
392
|
applicableAgentFiles:fix.configuration.applicableAgentFiles??[]})}});
|
|
@@ -390,7 +395,9 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
390
395
|
// PTY sessions are used by desktop tool hosts. Disable echo only on this
|
|
391
396
|
// process's own terminal so tool results are not mistaken for output frames.
|
|
392
397
|
const rawMode=input.isTTY&&typeof input.setRawMode==='function';if(rawMode)input.setRawMode(true);
|
|
393
|
-
const
|
|
398
|
+
const controlled=controlPolicy?withControlPolicyHost(run.host,{identity:definition.identity,
|
|
399
|
+
snapshot:()=>readExecutionSnapshot({specsRoot:definition.specsDir,identity:{repositoryId:definition.identity.repositoryId,runId:definition.identity.runId}}),launchTarget:controlLaunchTarget}):run.host;
|
|
400
|
+
const diagnosticHost=withHandoffDiagnostic(controlled,error);
|
|
394
401
|
try{await serveHostTransport({host:diagnosticHost,input,output,toolBridge:bridge,errorOutput:error},extra.get('--input-limit'));}
|
|
395
402
|
finally{if(rawMode)input.setRawMode(false);}
|
|
396
403
|
return 0;
|
|
@@ -403,6 +410,9 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
403
410
|
const snapshotReason=['out_of_scope','unsupported_file','limit_exceeded','package_mismatch'].includes(code)
|
|
404
411
|
&&typeof cause?.message==='string'&&cause.message.length<=8192&&!/[\r\n\0]/.test(cause.message)
|
|
405
412
|
?cause.message:null;
|
|
413
|
+
const protectedHistoryHint=code==='fingerprint_mismatch'&&argv[4]==='resume'&&argv.includes('--protected-config')
|
|
414
|
+
?' --protected-config 的配置指纹不匹配。旧 createCodexExecution 组装的 CLI 恢复入口已停用;无旧 grant 登记时不能仅凭指纹识别旧运行,不能自动转换。若属于这种旧运行,重复原参数无法恢复;保留现场,只读查看:node scripts/cm-ai-run.mjs inspect-history --config RUN_DEFINITION.json(使用原运行定义文件)。现代 provider 运行仍须核对原配置漂移。':null;
|
|
415
|
+
if(protectedHistoryHint)cause.reason=(typeof cause.reason==='string'?cause.reason:'')+protectedHistoryHint;
|
|
406
416
|
const reason=REASONED_CODES.includes(code)&&typeof cause?.reason==='string'&&cause.reason.length<=8192
|
|
407
417
|
&&!/[\r\n\0]/.test(cause.reason)?cause.reason:null;
|
|
408
418
|
if(code==='handoff_exists')error.write(`[host] ${REVIEWED_HANDOFF_HINT}\n`);
|
|
@@ -9,7 +9,7 @@ import {createHostToolBridge} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
|
9
9
|
import {createConversationExecution,main as hostMain} from './cm-ai-host.mjs';
|
|
10
10
|
import {readRunDefinition,openControlRun} from './cm-ai-run.mjs';
|
|
11
11
|
import {fixtureProcesses} from './fixtures/process-cleanup.mjs';
|
|
12
|
-
import {cli,identity,request,fixture,launchArgs,runCli,protectedResultFixture,implementedValue,lastCheckpoint,installTimeoutReviewer} from './cm-ai-host-fixture.mjs';
|
|
12
|
+
import {cli,identity,request,fixture,launchArgs,runCli,protectedResultFixture,implementedValue,lastCheckpoint,installTimeoutReviewer,syntheticReviewConfig} from './cm-ai-host-fixture.mjs';
|
|
13
13
|
|
|
14
14
|
test('single host input limit parsing and transport pass-through need no running host',async()=>{
|
|
15
15
|
const {serveHostTransport}=await import('./cm-ai-host.mjs');
|
|
@@ -169,8 +169,8 @@ test('host create refuses a scope with AGENTS.md and lists the protected paths b
|
|
|
169
169
|
});
|
|
170
170
|
|
|
171
171
|
|
|
172
|
-
test('current conversation
|
|
173
|
-
const f=fixture();
|
|
172
|
+
test('current conversation start performs real file/check work and preserves its development-only replay',async()=>{
|
|
173
|
+
const f=fixture();f.operation='start';
|
|
174
174
|
try{
|
|
175
175
|
const denied=spawnSync(process.execPath,[cli,...f.args.slice(0,-1)],{encoding:'utf8',timeout:3000});
|
|
176
176
|
assert.equal(denied.status,1);assert(denied.stderr.includes('host_launch_authorization_required'));
|
|
@@ -182,13 +182,13 @@ test('current conversation CLI performs real file/check work and stops at the or
|
|
|
182
182
|
assert.deepEqual(roleEvents.map(row=>row.role),['coder','tester']);
|
|
183
183
|
assert(roleEvents.every(row=>!Object.hasOwn(row,'effective_model')&&row.task==='T-001'));
|
|
184
184
|
const result=first.rows.find(row=>row.requestId==='advance').result;
|
|
185
|
-
assert.equal(result.state,'awaiting_review');assert.equal(result.code,
|
|
185
|
+
assert.equal(result.state,'awaiting_review');assert.equal(result.code,null);
|
|
186
186
|
assert(first.rows.some(row=>row.type==='host_response'&&row.accepted===false));
|
|
187
187
|
assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[ ] T-001'));
|
|
188
188
|
const handoff=JSON.parse(fs.readFileSync(path.join(f.specsDir,'.reviews','work-T-001-a1-handoff.json'),'utf8'));
|
|
189
189
|
assert.equal(handoff.status,'ready_for_review');assert(handoff.changed_files.includes('target.mjs'));
|
|
190
190
|
const second=await runCli(f,'normal','resume');assert.equal(second.code,0,second.stderr);
|
|
191
|
-
assert.deepEqual(second.calls,[]);assert.equal(second.rows.find(row=>row.requestId==='advance').result.code,
|
|
191
|
+
assert.deepEqual(second.calls,[]);assert.equal(second.rows.find(row=>row.requestId==='advance').result.code,null);
|
|
192
192
|
const resumedRoles=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse)
|
|
193
193
|
.filter(row=>row.event==='decision'&&row.phase==='route');
|
|
194
194
|
assert.deepEqual(resumedRoles,roleEvents);
|
|
@@ -225,7 +225,7 @@ for(const mode of ['disconnect','cancel'])test(`current conversation ${mode} pre
|
|
|
225
225
|
});
|
|
226
226
|
|
|
227
227
|
for(const mode of ['normal','disconnect','cancel'])test(`Claude conversation uses original runner development and recovery: ${mode}`,async()=>{
|
|
228
|
-
const f=fixture();f.runtime='claude';f.args.push('--runtime','claude');
|
|
228
|
+
const f=fixture();f.operation='start';f.runtime='claude';f.args.push('--runtime','claude');
|
|
229
229
|
try{
|
|
230
230
|
const first=await runCli(f,mode);assert.equal(first.code,0,first.stderr);
|
|
231
231
|
const state=mode==='normal'?'awaiting_review':mode==='disconnect'?'blocked':'cancelled';
|
|
@@ -251,7 +251,7 @@ for(const mode of ['normal','disconnect','cancel'])test(`Claude conversation use
|
|
|
251
251
|
test('Claude Review option rejects before store instead of borrowing the Codex reviewer',()=>{
|
|
252
252
|
const f=fixture();
|
|
253
253
|
try{
|
|
254
|
-
const result=spawnSync(process.execPath,[cli,...f.args,'--runtime','claude'
|
|
254
|
+
const result=spawnSync(process.execPath,[cli,...f.args,'--runtime','claude'],{encoding:'utf8',timeout:3000});
|
|
255
255
|
assert.equal(result.status,1);assert(result.stderr.includes('review_configuration_required'));
|
|
256
256
|
assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));
|
|
257
257
|
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
@@ -290,7 +290,7 @@ test('fixture watchdog stopping a host mid-review leaves no process from the fix
|
|
|
290
290
|
// Keep the 15-minute reviewer budget: only the watchdog can end this review.
|
|
291
291
|
const review=JSON.parse(preview.stdout);assert.equal(review.timeoutMs,900000);
|
|
292
292
|
const config=path.join(f.root,'review.json');fs.writeFileSync(config,JSON.stringify(review));
|
|
293
|
-
f.args.push('--review-config',config
|
|
293
|
+
f.args.push('--review-config',config);
|
|
294
294
|
f.develop=payload=>({status:'succeeded',value:implementedValue(),
|
|
295
295
|
edits:[{path:'target.mjs',beforeSha256:payload.expected['target.mjs'],content:'export const value = 42;\n'}]});
|
|
296
296
|
setMode('timeout');
|
|
@@ -324,14 +324,14 @@ test('new host refuses unapproved manifest bytes before any developer call',asyn
|
|
|
324
324
|
});
|
|
325
325
|
|
|
326
326
|
test('host develops from specification with no code requirements and replays identical material',async()=>{
|
|
327
|
-
const f=fixture();
|
|
327
|
+
const f=fixture();f.operation='start';
|
|
328
328
|
try{
|
|
329
329
|
const definition=JSON.parse(fs.readFileSync(f.config));definition.requirements=[];
|
|
330
330
|
fs.writeFileSync(f.config,JSON.stringify(definition));
|
|
331
331
|
const first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
|
|
332
332
|
assert.equal(first.rows.find(row=>row.requestId==='advance').result.state,'awaiting_review');
|
|
333
333
|
const resumed=await runCli(f,'normal','resume');assert.equal(resumed.code,0,resumed.stderr);assert.deepEqual(resumed.calls,[]);
|
|
334
|
-
assert.equal(resumed.rows.find(row=>row.requestId==='advance').result.code,
|
|
334
|
+
assert.equal(resumed.rows.find(row=>row.requestId==='advance').result.code,null);
|
|
335
335
|
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
336
336
|
});
|
|
337
337
|
|
|
@@ -388,7 +388,7 @@ test('step31 CLI resumes completed evidence BLOCKED QA and reaches the original
|
|
|
388
388
|
fs.writeFileSync(workflow,JSON.stringify({documentationPaths:['README.md'],applicableAgentFiles:[],qa:{
|
|
389
389
|
commands:[{id:'value-check',command:[process.execPath,'-e',"import('./target.mjs').then(m=>{if(m.value!==42)process.exit(1)})"],caseIds:[]}],
|
|
390
390
|
environment:{kind:'web',carrier:'browser',target:'http://127.0.0.1',scope:'local'}}}));
|
|
391
|
-
f.args.push('--review-config',review,'--
|
|
391
|
+
f.args.push('--review-config',review,'--workflow-config',workflow,'--allow-qa','--browser-qa','available');
|
|
392
392
|
let corrected=false;
|
|
393
393
|
f.qaBrowser=payload=>{
|
|
394
394
|
const file=path.join(f.specsDir,'.reviews','browser-evidence.txt');fs.writeFileSync(file,'Synthetic observed browser evidence');
|
|
@@ -445,7 +445,7 @@ test('F7 CLI explicitly revises missing QA commands after N5 and resumes the sam
|
|
|
445
445
|
environment:{kind:'web',carrier:'browser',target:'fixture',scope:'local'}}};
|
|
446
446
|
const oldFile=path.join(f.root,'workflow-old.json'),file=path.join(f.root,'workflow.json');
|
|
447
447
|
fs.writeFileSync(oldFile,JSON.stringify(oldWorkflow));fs.writeFileSync(file,JSON.stringify(oldWorkflow));
|
|
448
|
-
f.args.push('--review-config',review,'--
|
|
448
|
+
f.args.push('--review-config',review,'--workflow-config',file,'--allow-qa');
|
|
449
449
|
const first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
|
|
450
450
|
assert.equal(first.rows.find(row=>row.requestId==='advance').result.code,'qa_result_blocked');
|
|
451
451
|
const stateFile=path.join(f.specsDir,'.reviews','.execution',identity.runId,'state.json');
|
|
@@ -485,9 +485,9 @@ function protectedDriveFixture({scope,files={},checkCommands=[{id:'noop',command
|
|
|
485
485
|
const plan=path.join(f.root,`plan-${Math.random().toString(36).slice(2)}.json`);
|
|
486
486
|
fs.writeFileSync(plan,JSON.stringify({config:'run.json',mode:'create',hostContext:'native-host-fixture',
|
|
487
487
|
permissions:['--protected-conversation-config','protection.json','--review-config',f.reviewFile,...permissions],answers:'answers'}));
|
|
488
|
-
return spawnSync('/bin/sh',['-c',`umask ${umask}; exec "$0" "$@"`,process.execPath,protectedDriver,'--plan',plan,'
|
|
488
|
+
return spawnSync('/bin/sh',['-c',`umask ${umask}; exec "$0" "$@"`,process.execPath,protectedDriver,'--plan',plan,'start'],
|
|
489
489
|
{encoding:'utf8',timeout:120000,
|
|
490
|
-
env:{...
|
|
490
|
+
env:{...f.env,CM_WORKFLOW_HOME:path.join(f.root,'home'),CM_WORKFLOW_LOG_HOME:path.join(f.root,'logs')}});
|
|
491
491
|
};
|
|
492
492
|
return f;
|
|
493
493
|
}
|
|
@@ -534,8 +534,8 @@ const withEarlierPendingFeature=f=>{
|
|
|
534
534
|
fs.writeFileSync(path.join(f.specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:['0.early','1.work'],specFiles:buildManifest(f.specsDir)}));
|
|
535
535
|
};
|
|
536
536
|
const serveOnce=(f,extra,mode='create')=>{
|
|
537
|
-
const args=[...launchArgs(f)];args[4]=mode;
|
|
538
|
-
const out=spawnSync(process.execPath,[cli,...args
|
|
537
|
+
const args=[...launchArgs({...f,args:[...f.args,...extra]})];args[4]=mode;
|
|
538
|
+
const out=spawnSync(process.execPath,[cli,...args],{encoding:'utf8',timeout:20000,
|
|
539
539
|
input:[request('status')].map(JSON.stringify).join('\n')+'\n'});
|
|
540
540
|
return {...out,rows:out.stdout.trim().split('\n').filter(Boolean).map(JSON.parse)};
|
|
541
541
|
};
|
|
@@ -572,7 +572,8 @@ test('--review-runtime binds the other tool as reviewer and must be repeated on
|
|
|
572
572
|
const {claudeReviewFingerprint}=await import('../runtime/js/cm-ai/worker-claude.mjs');
|
|
573
573
|
const model='fixture';const review={model,disabledSkills:[],preflight:{passed:true,provider:'claude',
|
|
574
574
|
config_fingerprint:claudeReviewFingerprint({cwd:f.codeProject,model}),prompt_transport:'stdin'}};
|
|
575
|
-
const make=options=>createConversationExecution(definition,'native-host-fixture',bridge,
|
|
575
|
+
const make=options=>createConversationExecution(definition,'native-host-fixture',bridge,
|
|
576
|
+
syntheticReviewConfig(f.codeProject,options.reviewRuntime??'codex'),null,null,false,'codex',options);
|
|
576
577
|
const original=make({reviewRuntime:'claude'});
|
|
577
578
|
assert.equal(original.developer.provider,'codex');assert.equal(original.reviewers[0].provider,'claude');
|
|
578
579
|
assert.equal(original.configuration.reviewRuntime,'claude');
|
|
@@ -581,7 +582,7 @@ test('--review-runtime binds the other tool as reviewer and must be repeated on
|
|
|
581
582
|
await assert.rejects(openControlRun(definition,'resume',make({})),{code:'fingerprint_mismatch'});
|
|
582
583
|
assert.throws(()=>make({reviewRuntime:'codex'}),{code:'runtime_selection_mismatch'});
|
|
583
584
|
assert.throws(()=>make({reviewRuntime:'other'}),{code:'invalid_runtime'});
|
|
584
|
-
assert.throws(()=>createConversationExecution(definition,'native-host-fixture',bridge,{...review,preflight:{}},
|
|
585
|
+
assert.throws(()=>createConversationExecution(definition,'native-host-fixture',bridge,{...review,preflight:{}},null,null,false,'codex',{reviewRuntime:'claude'}),{code:'tool_preflight_missing'});
|
|
585
586
|
}finally{bridge.close();fs.rmSync(f.root,{recursive:true,force:true});}
|
|
586
587
|
});
|
|
587
588
|
test('ordinary CLI accepts --review-runtime claude under a Codex host and refuses an invalid runtime before any journal',()=>{
|