@aibyzero/cm-workflow 0.16.4 → 0.16.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +22 -0
- package/CHANGELOG.md +57 -0
- package/README.md +22 -4
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/VERSION +1 -1
- package/docs/architecture.md +43 -0
- package/docs/execution-optimizations.md +33 -0
- package/docs/external-models.md +114 -0
- package/docs/fixes/.reviews/20260929-bootstrap-unchanged-review-r1.md +7 -0
- package/docs/fixes/.reviews/20260930-develop-package-limit-recovery-r4.md +9 -0
- package/docs/fixes/20260929-bootstrap-rule-refresh-conflict.md +22 -0
- package/docs/fixes/20260929-bootstrap-unchanged-review.md +26 -0
- package/docs/fixes/20260930-develop-package-limit-recovery.md +65 -0
- package/docs/human-correction.md +31 -0
- package/docs/installation.md +48 -7
- package/docs/js-workflow-control.md +293 -33
- package/docs/live-evidence-drivers.md +62 -0
- package/docs/next-steps.md +15 -10
- package/docs/runtime-failover.md +1 -1
- package/docs/untested-branches.md +27 -4
- package/docs/user-guide.md +23 -8
- package/install-codex.sh +28 -11
- package/package.json +1 -1
- package/runtime/js/cm-ai/accepted-fix.mjs +23 -5
- package/runtime/js/cm-ai/bootstrap-feature.mjs +15 -0
- package/runtime/js/cm-ai/claude-review-adapter.mjs +7 -4
- package/runtime/js/cm-ai/claude-review-stream.mjs +12 -0
- package/runtime/js/cm-ai/claude-tool-preview.mjs +4 -4
- package/runtime/js/cm-ai/cm-ai-admission.mjs +115 -41
- package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +3 -2
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +208 -34
- package/runtime/js/cm-ai/cm-ai-learning-handoff-writer.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-learning-writer.mjs +22 -5
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +181 -57
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +15 -58
- package/runtime/js/cm-ai/codex-config.mjs +3 -2
- package/runtime/js/cm-ai/codex-review-adapter.mjs +56 -17
- package/runtime/js/cm-ai/committed-rule-basis.mjs +76 -0
- package/runtime/js/cm-ai/developer-adapter.mjs +6 -2
- package/runtime/js/cm-ai/diagnostic-reason.mjs +10 -0
- package/runtime/js/cm-ai/drive-bootstrap.mjs +315 -0
- package/runtime/js/cm-ai/drive-core.mjs +47 -9
- package/runtime/js/cm-ai/durable-runner-state.mjs +413 -56
- package/runtime/js/cm-ai/effect-abandon-log.mjs +19 -0
- package/runtime/js/cm-ai/effect-contract.mjs +44 -2
- package/runtime/js/cm-ai/execution-policy.mjs +58 -0
- package/runtime/js/cm-ai/execution-store-limits.mjs +18 -0
- package/runtime/js/cm-ai/execution-store.mjs +6 -4
- package/runtime/js/cm-ai/external-group-models.mjs +53 -0
- package/runtime/js/cm-ai/external-model-launch.mjs +23 -0
- package/runtime/js/cm-ai/external-models.mjs +52 -0
- package/runtime/js/cm-ai/external-run-guard.mjs +96 -0
- package/runtime/js/cm-ai/fix-code-association.mjs +171 -18
- package/runtime/js/cm-ai/host-bootstrap.mjs +126 -29
- package/runtime/js/cm-ai/host-check.mjs +30 -4
- package/runtime/js/cm-ai/host-conversation-execution.mjs +66 -20
- package/runtime/js/cm-ai/host-handoff.mjs +13 -6
- package/runtime/js/cm-ai/host-progress.mjs +80 -0
- package/runtime/js/cm-ai/host-project-execution.mjs +16 -11
- package/runtime/js/cm-ai/host-qa-executor.mjs +23 -9
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +23 -6
- package/runtime/js/cm-ai/host-qa-policy.mjs +16 -7
- package/runtime/js/cm-ai/host-session.mjs +12 -4
- package/runtime/js/cm-ai/host-tool-bridge.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +16 -5
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/knowledge-closeout.mjs +56 -0
- package/runtime/js/cm-ai/launch-mismatch.mjs +42 -0
- package/runtime/js/cm-ai/legacy-model-run-preview.mjs +24 -0
- package/runtime/js/cm-ai/legacy-model-settings.mjs +59 -0
- package/runtime/js/cm-ai/live-evidence.mjs +96 -0
- package/runtime/js/cm-ai/log-rows.mjs +21 -0
- package/runtime/js/cm-ai/model-configuration-file.mjs +63 -0
- package/runtime/js/cm-ai/model_configuration_write.py +214 -0
- package/runtime/js/cm-ai/native-usage-log.mjs +26 -0
- package/runtime/js/cm-ai/operator-guidance.mjs +86 -0
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +22 -0
- package/runtime/js/cm-ai/project-qa-gate.mjs +84 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +68 -9
- package/runtime/js/cm-ai/provider-usage.mjs +39 -0
- package/runtime/js/cm-ai/qa-config-revision.mjs +44 -10
- package/runtime/js/cm-ai/review-abandon-log.mjs +21 -0
- package/runtime/js/cm-ai/review-package.mjs +438 -31
- package/runtime/js/cm-ai/review-presentation.mjs +45 -0
- package/runtime/js/cm-ai/review-reconciliation.mjs +20 -0
- package/runtime/js/cm-ai/review-runner.mjs +47 -1
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +97 -0
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +104 -10
- package/runtime/js/cm-ai/reviewed-evidence-supersession-record.mjs +42 -3
- package/runtime/js/cm-ai/specification-material.mjs +154 -12
- package/runtime/js/cm-ai/status-projection.mjs +93 -0
- package/runtime/js/cm-ai/task-commit.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +658 -75
- package/runtime/js/cm-ai/tool-preview.mjs +8 -4
- package/runtime/js/cm-ai/worker-claude-developer.mjs +16 -7
- package/runtime/js/cm-ai/worker-claude.mjs +63 -19
- package/runtime/js/cm-ai/worker-codex-developer.mjs +15 -9
- package/runtime/js/cm-ai/worker-codex.mjs +45 -19
- package/runtime/js/cm-fix/cause-evidence.mjs +5 -3
- package/runtime/js/cm-fix/cause-invocation.mjs +6 -3
- package/runtime/js/cm-fix/cause-package.mjs +10 -1
- package/runtime/js/cm-fix/execution.mjs +279 -52
- package/runtime/js/cm-fix/final-review.mjs +18 -10
- package/runtime/js/cm-fix/host-review.mjs +32 -9
- package/runtime/js/cm-fix/host.mjs +6 -1
- package/runtime/js/cm-fix/layout.mjs +1 -1
- package/runtime/js/cm-fix/progress.mjs +5 -0
- package/runtime/js/cm-fix/protected-edits.mjs +15 -4
- package/runtime/js/cm-fix/qa-source.mjs +6 -4
- package/runtime/js/cm-fix/review-reconciliation.mjs +64 -0
- package/runtime/js/cm-prd/analysis.mjs +2 -1
- package/runtime/js/cm-prd/change.mjs +28 -10
- package/runtime/js/cm-prd/draft.mjs +5 -2
- package/runtime/js/cm-prd/response-recovery.mjs +23 -0
- package/runtime/js/cm-prd/review-preparation.mjs +10 -3
- package/runtime/js/cm-prd/review-publication.mjs +27 -15
- package/runtime/js/cm-prd/review-time.mjs +29 -0
- package/runtime/js/cm-prd/self-check.mjs +6 -3
- package/runtime/js/cm-prd/session.mjs +53 -6
- package/runtime/js/cm-prd/summary.mjs +3 -1
- package/runtime/js/cm-prd/validation-reason.mjs +20 -0
- package/runtime/js/cm-security/finalize.mjs +32 -0
- package/runtime/js/spec-task-line.mjs +117 -0
- package/runtime/js/specs-status.mjs +10 -3
- package/runtime/review.md +5 -0
- package/runtime/task-gates.md +6 -0
- package/runtime/workflow-config.md +10 -1
- package/scripts/cm-ai-abandon-effect-position.test.mjs +201 -0
- package/scripts/cm-ai-admission.mjs +18 -11
- package/scripts/cm-ai-admission.test.mjs +65 -1
- package/scripts/cm-ai-batch-drive.mjs +135 -34
- package/scripts/cm-ai-batch-drive.test.mjs +209 -3
- package/scripts/cm-ai-batch-host.mjs +63 -24
- package/scripts/cm-ai-batch-host.test.mjs +2 -1
- package/scripts/cm-ai-batch-run.mjs +101 -34
- package/scripts/cm-ai-batch-run.test.mjs +56 -5
- package/scripts/cm-ai-bootstrap-driver-preflight.test.mjs +45 -0
- package/scripts/cm-ai-bootstrap-flow.test.mjs +159 -0
- package/scripts/cm-ai-bootstrap-merge.test.mjs +162 -0
- package/scripts/cm-ai-bootstrap.test.mjs +174 -89
- package/scripts/cm-ai-conversation-entry-ops.test.mjs +97 -2
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +924 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +468 -0
- package/scripts/cm-ai-drive-timeout.test.mjs +17 -0
- package/scripts/cm-ai-drive.mjs +526 -60
- package/scripts/cm-ai-drive.test.mjs +336 -10
- package/scripts/cm-ai-fix-later-delivery.test.mjs +383 -0
- package/scripts/cm-ai-host.mjs +142 -43
- package/scripts/cm-ai-host.test.mjs +232 -12
- package/scripts/cm-ai-launch-diagnostics.test.mjs +142 -0
- package/scripts/cm-ai-multi-root.test.mjs +9 -3
- package/scripts/cm-ai-operator-guidance.test.mjs +94 -0
- package/scripts/cm-ai-progress.test.mjs +521 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +308 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +187 -15
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +157 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +27 -2
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +400 -0
- package/scripts/cm-ai-review-drift-precedence.test.mjs +90 -0
- package/scripts/cm-ai-review-failure.test.mjs +977 -0
- package/scripts/cm-ai-review-timeout-config.test.mjs +29 -7
- package/scripts/cm-ai-review-timeout.test.mjs +199 -4
- package/scripts/cm-ai-run.mjs +206 -62
- package/scripts/cm-ai-run.test.mjs +6 -4
- package/scripts/cm-ai-runner-error-code-regression.test.mjs +219 -0
- package/scripts/cm-ai-selection-guard.test.mjs +100 -0
- package/scripts/cm-ai-session-chain.test.mjs +7 -3
- package/scripts/cm-ai-spec-rebind.test.mjs +481 -0
- package/scripts/cm-ai-supersede.test.mjs +571 -17
- package/scripts/cm-ai-verification-gate.test.mjs +2 -1
- package/scripts/cm-bootstrap-review-recovery.test.mjs +70 -0
- package/scripts/cm-capability-gate.test.mjs +21 -2
- package/scripts/cm-check-drive.test.mjs +2 -1
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +12 -1
- package/scripts/cm-claude-developer-worker.test.mjs +3 -1
- package/scripts/cm-claude-install-layout.test.mjs +26 -0
- package/scripts/cm-claude-probe.test.mjs +10 -2
- package/scripts/cm-claude-review-stream.test.mjs +25 -0
- package/scripts/cm-claude-worker.test.mjs +11 -4
- package/scripts/cm-codex-developer-worker.test.mjs +4 -2
- package/scripts/cm-codex-plugin-metadata.py +83 -0
- package/scripts/cm-codex-plugin-metadata.test.mjs +55 -0
- package/scripts/cm-efficiency-checks.test.mjs +37 -0
- package/scripts/cm-efficiency-diagnostics.test.mjs +74 -0
- package/scripts/cm-efficiency-offline.mjs +35 -0
- package/scripts/cm-efficiency-policy.test.mjs +48 -0
- package/scripts/cm-efficiency-presentation.test.mjs +35 -0
- package/scripts/cm-efficiency-response.test.mjs +117 -0
- package/scripts/cm-efficiency-usage.test.mjs +148 -0
- package/scripts/cm-external-batch-host.test.mjs +157 -0
- package/scripts/cm-external-fix-host.test.mjs +281 -0
- package/scripts/cm-external-fix-reconciliation.test.mjs +105 -0
- package/scripts/cm-external-group-models.test.mjs +60 -0
- package/scripts/cm-external-model-host.test.mjs +180 -0
- package/scripts/cm-external-model-recovery.test.mjs +108 -0
- package/scripts/cm-external-models.test.mjs +89 -0
- package/scripts/cm-external-process-cleanup.test.mjs +71 -0
- package/scripts/cm-external-qa-fix.test.mjs +170 -0
- package/scripts/cm-external-review-reconciliation.test.mjs +314 -0
- package/scripts/cm-failover.mjs +8 -8
- package/scripts/cm-fix-abandon.test.mjs +123 -5
- package/scripts/cm-fix-cause-package.test.mjs +2 -0
- package/scripts/cm-fix-drive.mjs +70 -23
- package/scripts/cm-fix-drive.test.mjs +36 -1
- package/scripts/cm-fix-final-review.test.mjs +11 -6
- package/scripts/cm-fix-host.mjs +24 -14
- package/scripts/cm-fix-protected-edits.test.mjs +12 -0
- package/scripts/cm-fix-rediagnosis.test.mjs +168 -0
- package/scripts/cm-fix-review-budget.test.mjs +147 -0
- package/scripts/cm-fixture-process-cleanup.test.mjs +95 -0
- package/scripts/cm-host-check.test.mjs +6 -3
- package/scripts/cm-host-qa-executor.test.mjs +213 -17
- package/scripts/cm-host-session-diagnostic.test.mjs +10 -0
- package/scripts/cm-interactive-qa-diagnostic.test.mjs +53 -0
- package/scripts/cm-knowledge-closeout.test.mjs +160 -0
- package/scripts/cm-live-evidence.test.mjs +64 -0
- package/scripts/cm-log-event.mjs +25 -2
- package/scripts/cm-log-event.py +15 -0
- package/scripts/cm-log-event.test.mjs +31 -0
- package/scripts/cm-model-setup.mjs +79 -0
- package/scripts/cm-prd-completion.test.mjs +75 -0
- package/scripts/cm-prd-draft.test.mjs +14 -0
- package/scripts/cm-prd-drive.mjs +32 -11
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-gate-diagnostic.test.mjs +100 -0
- package/scripts/cm-prd-host.mjs +13 -4
- package/scripts/cm-prd-review-gate.mjs +126 -81
- package/scripts/cm-prd-review-gate.test.mjs +105 -1
- package/scripts/cm-prd-review-preparation.test.mjs +15 -0
- package/scripts/cm-prd-review-publication.test.mjs +6 -0
- package/scripts/cm-prd-self-check.test.mjs +6 -0
- package/scripts/cm-prd-summary.test.mjs +9 -0
- package/scripts/cm-release-smoke.sh +5 -1
- package/scripts/cm-review-dependency-snapshot.test.mjs +15 -0
- package/scripts/cm-review-inventory.test.mjs +253 -1
- package/scripts/cm-runtime-i18n.mjs +15 -4
- package/scripts/cm-runtime-install.mjs +8 -4
- package/scripts/cm-runtime.mjs +116 -23
- package/scripts/cm-runtime.test.mjs +121 -12
- package/scripts/cm-security.test.mjs +32 -0
- package/scripts/cm-spec-manifest.mjs +28 -10
- package/scripts/cm-spec-manifest.test.mjs +8 -4
- package/scripts/cm-spec-task-line.test.mjs +138 -0
- package/scripts/cm-specs-status.test.mjs +12 -1
- package/scripts/cm-task-gate-correction.test.mjs +117 -0
- package/scripts/cm-task-gate.mjs +164 -20
- package/scripts/cm-task-gate.py +2 -1
- package/scripts/cm-test-branch-impact.test.mjs +6 -3
- package/scripts/cm-test-drive.mjs +10 -4
- package/scripts/cm-test-drive.test.mjs +14 -1
- package/scripts/cm-tool-preview-context.test.mjs +12 -0
- package/scripts/cm-usage-report.py +22 -3
- package/scripts/cm-workflow-config.mjs +10 -1
- package/scripts/fixtures/bootstrap-review-runner.mjs +102 -0
- package/scripts/fixtures/claude-review-process.mjs +1 -0
- package/scripts/fixtures/live-evidence-driver.mjs +35 -0
- package/scripts/fixtures/process-cleanup.mjs +101 -0
- package/scripts/test-cm-log-event.py +2 -0
- package/scripts/test-cm-native-usage.py +62 -0
- package/scripts/test-cm-prd-review-gate.py +2 -1
- package/scripts/test-external-model-setup.py +91 -0
- package/scripts/test-model-configuration-write.py +201 -0
- package/scripts/test-npm-install.py +11 -2
- package/scripts/test-scan-public-safety.py +1 -1
- package/scripts/test-spec-manifest.py +16 -8
- package/scripts/test-task-gate.py +2 -2
- package/scripts/test-workflow-config.py +1 -0
- package/scripts/validate-public-repo.py +1 -0
- package/skills/cm-ai/SKILL.md +2 -2
- package/skills/cm-ai/references/N1-init.md +1 -1
- package/skills/cm-ai/references/N8-finish.md +5 -0
- package/skills/cm-ai/references/js-host.md +270 -43
- package/skills/cm-ai/references/knowledge-closeout.md +90 -0
- package/skills/cm-fix/SKILL.md +1 -1
- package/skills/cm-fix/references/js-host.md +52 -3
- package/skills/cm-prd/references/js-change-recovery.md +1 -1
- package/skills/cm-prd/references/js-host.md +6 -0
- package/skills/cm-runtime/SKILL.md +29 -6
- package/skills/cm-security/SKILL.md +4 -2
- package/skills/cm-security/references/scan-contract.md +1 -0
- package/templates/cm-workflow.yml +1 -1
|
@@ -7,15 +7,23 @@ import path from 'node:path';
|
|
|
7
7
|
import {spawn,spawnSync} from 'node:child_process';
|
|
8
8
|
import {fileURLToPath} from 'node:url';
|
|
9
9
|
import {createHostToolBridge} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
10
|
-
import {createConversationExecution} from './cm-ai-host.mjs';
|
|
10
|
+
import {createConversationExecution,main as hostMain} from './cm-ai-host.mjs';
|
|
11
11
|
import {readRunDefinition,openControlRun} from './cm-ai-run.mjs';
|
|
12
12
|
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
13
|
+
import {fixtureProcesses,guardFixtureSource,killFixtureProcesses} from './fixtures/process-cleanup.mjs';
|
|
13
14
|
|
|
14
15
|
// Keep runtime declarations and log mirrors independent of the invoking user's home.
|
|
15
16
|
const isolatedWorkflowHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-ai-host-home-'));
|
|
16
17
|
process.env.CM_WORKFLOW_HOME=path.join(isolatedWorkflowHome,'user');
|
|
17
18
|
process.env.CM_WORKFLOW_LOG_HOME=path.join(isolatedWorkflowHome,'logs');
|
|
18
19
|
after(()=>fs.rmSync(isolatedWorkflowHome,{recursive:true,force:true}));
|
|
20
|
+
// Every fixture root is swept once the file finishes: a surviving fake CLI or
|
|
21
|
+
// host is a leak even if its test passed (2026-09-28: fake reviewers ran 17h).
|
|
22
|
+
const fixtureRoots=new Set();
|
|
23
|
+
after(()=>{
|
|
24
|
+
const leaked=[...fixtureRoots].flatMap(root=>killFixtureProcesses(root));
|
|
25
|
+
assert.deepEqual(leaked.map(row=>row.command.slice(0,160)),[],'fixture processes outlived their tests');
|
|
26
|
+
});
|
|
19
27
|
|
|
20
28
|
const cli=fileURLToPath(new URL('./cm-ai-host.mjs',import.meta.url));
|
|
21
29
|
const identity={repositoryId:'host-fixture',runId:'host-fixture-run',taskId:'T-001',attempt:1};
|
|
@@ -43,6 +51,35 @@ test('single host CLI rejects out-of-range and non-integer input limits before o
|
|
|
43
51
|
assert.equal(run.status,1);assert.match(run.stderr,/invalid_arguments/);
|
|
44
52
|
}
|
|
45
53
|
});
|
|
54
|
+
test('killing a real host at develop request leaves the original effect intent for recovery',async()=>{
|
|
55
|
+
const f=fixture();
|
|
56
|
+
try{
|
|
57
|
+
let buffer='',sawDevelop=false,stderr='';
|
|
58
|
+
const child=spawn(process.execPath,[cli,...launchArgs(f)],{stdio:['pipe','pipe','pipe'],env:process.env});
|
|
59
|
+
child.stderr.on('data',chunk=>{stderr+=chunk;});
|
|
60
|
+
const done=new Promise((resolve,reject)=>{
|
|
61
|
+
const timer=setTimeout(()=>{child.kill('SIGKILL');reject(new Error('host kill fixture timed out: '+stderr));},10000);
|
|
62
|
+
child.stdout.on('data',chunk=>{
|
|
63
|
+
buffer+=chunk;
|
|
64
|
+
let newline;
|
|
65
|
+
while((newline=buffer.indexOf('\n'))!==-1){
|
|
66
|
+
const line=buffer.slice(0,newline);buffer=buffer.slice(newline+1);
|
|
67
|
+
if(!line)continue;
|
|
68
|
+
const row=JSON.parse(line);
|
|
69
|
+
if(row.type==='host_ready')child.stdin.write(JSON.stringify(request('advance'))+'\n');
|
|
70
|
+
if(row.type==='host_request'&&row.kind==='develop'){sawDevelop=true;child.kill('SIGKILL');}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
child.once('error',error=>{clearTimeout(timer);reject(error);});
|
|
74
|
+
child.once('exit',(code,signal)=>{clearTimeout(timer);resolve({code,signal});});
|
|
75
|
+
});
|
|
76
|
+
const exited=await done;
|
|
77
|
+
assert.equal(sawDevelop,true,stderr);assert.equal(exited.signal,'SIGKILL');
|
|
78
|
+
const state=JSON.parse(fs.readFileSync(path.join(f.specsDir,'.reviews','.execution',identity.runId,'state.json'),'utf8'));
|
|
79
|
+
assert(state.records.some(row=>row.payload.type==='effect-intent'&&row.payload.effect.kind==='develop'));
|
|
80
|
+
assert.equal(state.records.some(row=>row.payload.type==='effect-checkpoint'),false);
|
|
81
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
82
|
+
});
|
|
46
83
|
test('resume accepts a changed transport input limit without changing the durable fingerprint',async()=>{
|
|
47
84
|
const f=fixture(),bridge=createHostToolBridge();
|
|
48
85
|
try{
|
|
@@ -56,13 +93,15 @@ test('resume accepts a changed transport input limit without changing the durabl
|
|
|
56
93
|
await serveHostTransport({host:{}},'65536',async options=>{limit=options.inputLimit;});
|
|
57
94
|
assert.equal(limit,65536);
|
|
58
95
|
const resumed=await openControlRun(definition,'resume',execution);resumed.close();
|
|
96
|
+
const otherSession=createConversationExecution(definition,'other-host-fixture',bridge,null,null,null,false,'codex');
|
|
97
|
+
await assert.rejects(openControlRun(definition,'resume',otherSession),{code:'fingerprint_mismatch'});
|
|
59
98
|
await serveHostTransport({host:{}},'1048576',async options=>{limit=options.inputLimit;});
|
|
60
99
|
assert.equal(limit,1048576);
|
|
61
100
|
assert.deepEqual(JSON.parse(fs.readFileSync(state,'utf8')).fingerprints,before);
|
|
62
101
|
}finally{bridge.close();fs.rmSync(f.root,{recursive:true,force:true});}
|
|
63
102
|
});
|
|
64
103
|
function fixture(){
|
|
65
|
-
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-native-host-')));
|
|
104
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-native-host-')));fixtureRoots.add(root);
|
|
66
105
|
const specsDir=path.join(root,'specs'),codeProject=path.join(root,'code'),feature='1.work',config=path.join(root,'run.json');
|
|
67
106
|
fs.mkdirSync(codeProject);fs.mkdirSync(path.join(specsDir,feature),{recursive:true});
|
|
68
107
|
for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(specsDir,feature,name),'# Fixture\n');
|
|
@@ -70,15 +109,97 @@ function fixture(){
|
|
|
70
109
|
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],specFiles:buildManifest(specsDir)}));
|
|
71
110
|
fs.writeFileSync(path.join(codeProject,'requirements.md'),'# Fixture\n');
|
|
72
111
|
fs.writeFileSync(config,JSON.stringify({version:1,specsDir,codeProject,feature,identity,scope:['target.mjs'],requirements:['requirements.md']}));
|
|
73
|
-
|
|
112
|
+
// create requires a bound review configuration; it grants no review attempt.
|
|
113
|
+
const reviewFile=path.join(root,'placeholder-review.json');
|
|
114
|
+
fs.writeFileSync(reviewFile,JSON.stringify({model:'fixture',preflight:{}}));
|
|
115
|
+
return {root,specsDir,codeProject,config,reviewFile,args:['serve','--config',config,'--mode','create','--host-context','native-host-fixture','--allow-development']};
|
|
74
116
|
}
|
|
117
|
+
// A test that supplies its own --review-config keeps it; others use the placeholder.
|
|
118
|
+
const launchArgs=f=>f.args.includes('--review-config')?f.args:[...f.args,'--review-config',f.reviewFile];
|
|
119
|
+
|
|
120
|
+
test('D1 SIGKILL at a real host develop request leaves an intent without checkpoint',async()=>{
|
|
121
|
+
const f=fixture();
|
|
122
|
+
try{
|
|
123
|
+
const result=await new Promise((resolve,reject)=>{
|
|
124
|
+
const child=spawn(process.execPath,[cli,...launchArgs(f)],{stdio:['pipe','pipe','pipe']});
|
|
125
|
+
let buffer='',asked=false;
|
|
126
|
+
const timer=setTimeout(()=>{child.kill('SIGKILL');reject(Error('host request timeout'));},15000);
|
|
127
|
+
child.once('error',error=>{clearTimeout(timer);reject(error);});
|
|
128
|
+
child.stdout.on('data',chunk=>{
|
|
129
|
+
buffer+=chunk;
|
|
130
|
+
for(let newline;(newline=buffer.indexOf('\n'))!==-1;){
|
|
131
|
+
const line=buffer.slice(0,newline);buffer=buffer.slice(newline+1);
|
|
132
|
+
if(!line)continue;
|
|
133
|
+
const row=JSON.parse(line);
|
|
134
|
+
if(row.type==='host_ready')child.stdin.write(JSON.stringify(request('advance'))+'\n');
|
|
135
|
+
if(row.type==='host_request'&&row.kind==='develop'){asked=true;child.kill('SIGKILL');}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
child.once('close',(code,signal)=>{clearTimeout(timer);resolve({code,signal,asked});});
|
|
139
|
+
});
|
|
140
|
+
assert.equal(result.signal,'SIGKILL');assert.equal(result.asked,true);
|
|
141
|
+
const state=path.join(f.specsDir,'.reviews','.execution',identity.runId,'state.json');
|
|
142
|
+
const records=JSON.parse(fs.readFileSync(state,'utf8')).records;
|
|
143
|
+
assert.equal(records.at(-1).payload.type,'effect-intent');
|
|
144
|
+
assert.equal(records.some(row=>row.payload.type==='effect-checkpoint'),false);
|
|
145
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('split-root SwiftUI Claude control run creates a baseline beside Git-ignored Xcode and SwiftPM output',async()=>{
|
|
149
|
+
const f=fixture(),bridge=createHostToolBridge();
|
|
150
|
+
try{
|
|
151
|
+
const specs5=path.join(f.root,'specs5'),app=path.join(f.root,'app');
|
|
152
|
+
fs.renameSync(f.specsDir,specs5);fs.renameSync(f.codeProject,app);
|
|
153
|
+
fs.mkdirSync(path.join(app,'Sources'));fs.writeFileSync(path.join(app,'Sources','App.swift'),'import SwiftUI\n');
|
|
154
|
+
fs.writeFileSync(path.join(app,'.gitignore'),'custom-cache/\n');
|
|
155
|
+
assert.equal(spawnSync('git',['init','-q',app]).status,0);
|
|
156
|
+
fs.mkdirSync(path.join(app,'.build'));fs.symlinkSync('missing',path.join(app,'.build','workspace-state'));
|
|
157
|
+
fs.mkdirSync(path.join(app,'custom-cache'));fs.symlinkSync('missing',path.join(app,'custom-cache','linked'));
|
|
158
|
+
fs.mkdirSync(path.join(app,'DerivedData','Build'),{recursive:true});
|
|
159
|
+
for(let i=0;i<10005;i++)fs.writeFileSync(path.join(app,'DerivedData','Build',String(i)),'');
|
|
160
|
+
fs.mkdirSync(path.join(app,'App.xcodeproj','xcuserdata'),{recursive:true});
|
|
161
|
+
fs.writeFileSync(path.join(app,'App.xcodeproj','xcuserdata','UserInterfaceState.xcuserstate'),'bplist00');
|
|
162
|
+
fs.writeFileSync(path.join(app,'.DS_Store'),'finder');
|
|
163
|
+
const run=JSON.parse(fs.readFileSync(f.config,'utf8'));
|
|
164
|
+
fs.writeFileSync(f.config,JSON.stringify({...run,specsDir:specs5,codeProject:app,scope:['Sources/App.swift']}));
|
|
165
|
+
const definition=readRunDefinition(f.config);
|
|
166
|
+
const execution=createConversationExecution(definition,'native-host-fixture',bridge,null,null,null,false,'claude');
|
|
167
|
+
const opened=await openControlRun(definition,'create',execution);
|
|
168
|
+
try{
|
|
169
|
+
const baseline=opened.runner?.baseline??JSON.parse(fs.readFileSync(path.join(specs5,'.reviews','.execution',identity.runId,'state.json'),'utf8')).records[0].payload.baseline;
|
|
170
|
+
assert(baseline.files.some(file=>file.path==='Sources/App.swift'));
|
|
171
|
+
assert(!baseline.files.some(file=>/\.build|DerivedData|xcuserdata|custom-cache|DS_Store/.test(file.path)));
|
|
172
|
+
}finally{opened.close();}
|
|
173
|
+
}finally{bridge.close();fs.rmSync(f.root,{recursive:true,force:true});}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('host create reports the offending unsupported file on stderr before transport starts',async()=>{
|
|
177
|
+
const f=fixture(),lines=[];
|
|
178
|
+
try{
|
|
179
|
+
fs.symlinkSync('missing',path.join(f.codeProject,'alien.swift'));
|
|
180
|
+
const exit=await hostMain(launchArgs(f),{input:{},output:{write(){}},error:{write(value){lines.push(value);}}});
|
|
181
|
+
assert.equal(exit,1);
|
|
182
|
+
assert.match(lines.join(''),/\[host\] unsupported_file: alien\.swift/);
|
|
183
|
+
assert.match(lines.join(''),/"reason":"unsupported_file: alien\.swift"/);
|
|
184
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
185
|
+
});
|
|
75
186
|
|
|
76
187
|
function runCli(f,mode,action='create'){
|
|
77
188
|
return new Promise((resolve,reject)=>{
|
|
78
|
-
const args=[...f
|
|
189
|
+
const args=[...launchArgs(f)];args[4]=action;
|
|
79
190
|
const child=spawn(process.execPath,[cli,...args],{stdio:['pipe','pipe','pipe'],env:f.env??process.env});
|
|
80
191
|
let buffer='',stderr='',closed=false,sessionId;const rows=[],calls=[];
|
|
81
|
-
|
|
192
|
+
// Provider children run in their own process groups: stopping only the host
|
|
193
|
+
// would orphan a hung fake reviewer, so failure and watchdog paths stop the
|
|
194
|
+
// whole fixture tree. f.watchdog(expire) may replace the timer; it returns a disarm function.
|
|
195
|
+
let disarm=()=>{};
|
|
196
|
+
const fail=error=>{
|
|
197
|
+
disarm();child.kill('SIGKILL');
|
|
198
|
+
try{killFixtureProcesses(f.root);}catch(cleanup){error=new AggregateError([error,cleanup],String(error?.message??error));}
|
|
199
|
+
reject(error);
|
|
200
|
+
};
|
|
201
|
+
disarm=(f.watchdog??(expire=>{const timer=setTimeout(expire,Number(process.env.CM_TEST_FIXTURE_TIMEOUT_MS??60000));
|
|
202
|
+
return ()=>clearTimeout(timer);}))(()=>fail(new Error('host fixture timed out')));
|
|
82
203
|
child.stderr.on('data',chunk=>{stderr+=chunk;});
|
|
83
204
|
child.once('error',reject);
|
|
84
205
|
const send=value=>child.stdin.write(JSON.stringify(value)+'\n');
|
|
@@ -166,10 +287,10 @@ function runCli(f,mode,action='create'){
|
|
|
166
287
|
closed=true;
|
|
167
288
|
if(mode!=='disconnect'||action==='resume')send({type:'host_close',sessionId});
|
|
168
289
|
}
|
|
169
|
-
}catch(error){
|
|
290
|
+
}catch(error){fail(error);return;}
|
|
170
291
|
}
|
|
171
292
|
});
|
|
172
|
-
child.once('close',code=>{
|
|
293
|
+
child.once('close',code=>{disarm();resolve({code,stderr,rows,calls});});
|
|
173
294
|
send(f.request??request('advance'));
|
|
174
295
|
});
|
|
175
296
|
}
|
|
@@ -789,7 +910,7 @@ function installTimeoutReviewer(f,runtime){
|
|
|
789
910
|
fs.renameSync(fake,delegate);
|
|
790
911
|
const modeFile=path.join(f.root,'review-mode.json');
|
|
791
912
|
fs.writeFileSync(modeFile,JSON.stringify('approved'));
|
|
792
|
-
fs.writeFileSync(fake,String.raw`#!${process.execPath}
|
|
913
|
+
fs.writeFileSync(fake,guardFixtureSource(String.raw`#!${process.execPath}
|
|
793
914
|
const fs=require('node:fs'),cp=require('node:child_process'),crypto=require('node:crypto');
|
|
794
915
|
const args=process.argv.slice(2),runtime=${JSON.stringify(runtime)},modeFile=${JSON.stringify(modeFile)};
|
|
795
916
|
if(args[0]==='sandbox'){const r=cp.spawnSync(${JSON.stringify(delegate)},args,{stdio:'inherit'});process.exit(r.status??1);}
|
|
@@ -811,9 +932,11 @@ let prompt='';process.stdin.on('data',s=>prompt+=s);process.stdin.on('end',()=>{
|
|
|
811
932
|
send({type:'result',subtype:'success',session_id:thread,is_error:false,num_turns:1,result:'{"verdict":"approved"}'});
|
|
812
933
|
}
|
|
813
934
|
}
|
|
935
|
+
// A hung reviewer announces its pid so the watchdog regression can find it.
|
|
936
|
+
fs.writeFileSync(modeFile+'.hung',String(process.pid));
|
|
814
937
|
setInterval(()=>{},1000);
|
|
815
938
|
});
|
|
816
|
-
|
|
939
|
+
`),{mode:0o700});
|
|
817
940
|
return mode=>fs.writeFileSync(modeFile,JSON.stringify(mode));
|
|
818
941
|
}
|
|
819
942
|
for(const [runtime,second] of [['codex','approved'],['claude','approved'],['codex','timeout'],['codex','result'],['claude','result']])
|
|
@@ -824,18 +947,22 @@ test(`protected conversation review timeout ${runtime} -> ${second}`,async()=>{
|
|
|
824
947
|
const setMode=installTimeoutReviewer(f,runtime);
|
|
825
948
|
const preview=spawnSync(process.execPath,[cli,'preflight','--config',f.config,'--review-model','fixture','--runtime',runtime],
|
|
826
949
|
{encoding:'utf8',env:f.env,timeout:5000});assert.equal(preview.status,0,preview.stderr);
|
|
827
|
-
const
|
|
950
|
+
const review=JSON.parse(preview.stdout);assert.equal(review.timeoutMs,900000);
|
|
951
|
+
delete review.timeoutMs;
|
|
952
|
+
const config=path.join(f.root,'review.json');fs.writeFileSync(config,JSON.stringify(review));
|
|
828
953
|
f.args.push('--review-config',config,'--allow-review-attempt','1');
|
|
829
954
|
f.develop=payload=>({status:'succeeded',value:implementedValue(),
|
|
830
955
|
edits:[{path:'target.mjs',beforeSha256:payload.expected['target.mjs'],content:'export const value = 42;\n'}]});
|
|
831
956
|
setMode(second==='result'?'result':'timeout');
|
|
832
957
|
const start=Date.now(),first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
|
|
833
958
|
const result=first.rows.find(row=>row.requestId==='advance').result;
|
|
834
|
-
// A
|
|
959
|
+
// A legacy review config without timeoutMs inherits the protected conversation's 5s reviewer budget.
|
|
835
960
|
assert(Date.now()-start>=4900);assert(Date.now()-start<14000);
|
|
836
961
|
assert.equal(result.state,second==='result'?'unknown':'pending_review');
|
|
837
962
|
assert.equal(result.code,second==='result'?'transport_timeout':'review_transport_timeout');
|
|
838
|
-
|
|
963
|
+
// A final message cut off by the timeout is never retried by itself; its
|
|
964
|
+
// only exit is the explicit, audited abandon_review (see cm-ai-review-failure).
|
|
965
|
+
assert.equal(result.pendingAction,second==='result'?'abandon_review':'resume');
|
|
839
966
|
const before=lastCheckpoint(f),original=before.reviewInvocation;
|
|
840
967
|
assert.equal(before.calls.at(-1).terminal,second==='result'?'unknown':'failed');
|
|
841
968
|
assert.equal(original.result.outcome,'timed_out');
|
|
@@ -876,6 +1003,39 @@ test(`protected conversation review timeout ${runtime} -> ${second}`,async()=>{
|
|
|
876
1003
|
}
|
|
877
1004
|
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
878
1005
|
});
|
|
1006
|
+
// Regression (2026-09-28): a host stopped by the fixture watchdog while its
|
|
1007
|
+
// detached fake reviewer hung left that reviewer running for 17+ hours.
|
|
1008
|
+
test('fixture watchdog stopping a host mid-review leaves no process from the fixture root',async()=>{
|
|
1009
|
+
const f=protectedResultFixture();
|
|
1010
|
+
try{
|
|
1011
|
+
f.runtime='claude';f.args.push('--runtime','claude');
|
|
1012
|
+
const setMode=installTimeoutReviewer(f,'claude');
|
|
1013
|
+
const preview=spawnSync(process.execPath,[cli,'preflight','--config',f.config,'--review-model','fixture','--runtime','claude'],
|
|
1014
|
+
{encoding:'utf8',env:f.env,timeout:5000});assert.equal(preview.status,0,preview.stderr);
|
|
1015
|
+
// Keep the 15-minute reviewer budget: only the watchdog can end this review.
|
|
1016
|
+
const review=JSON.parse(preview.stdout);assert.equal(review.timeoutMs,900000);
|
|
1017
|
+
const config=path.join(f.root,'review.json');fs.writeFileSync(config,JSON.stringify(review));
|
|
1018
|
+
f.args.push('--review-config',config,'--allow-review-attempt','1');
|
|
1019
|
+
f.develop=payload=>({status:'succeeded',value:implementedValue(),
|
|
1020
|
+
edits:[{path:'target.mjs',beforeSha256:payload.expected['target.mjs'],content:'export const value = 42;\n'}]});
|
|
1021
|
+
setMode('timeout');
|
|
1022
|
+
const hung=path.join(f.root,'review-mode.json.hung');
|
|
1023
|
+
// Fire as soon as the reviewer hangs, but never later than the usual
|
|
1024
|
+
// fixture deadline: a host stalled before review is a bounded failure.
|
|
1025
|
+
f.watchdog=expire=>{
|
|
1026
|
+
const poll=setInterval(()=>{if(fs.existsSync(hung)&&fs.readFileSync(hung,'utf8')){clearInterval(poll);expire();}},25);
|
|
1027
|
+
const limit=setTimeout(expire,Number(process.env.CM_TEST_FIXTURE_TIMEOUT_MS??60000));
|
|
1028
|
+
return ()=>{clearInterval(poll);clearTimeout(limit);};
|
|
1029
|
+
};
|
|
1030
|
+
await assert.rejects(runCli(f,'normal'),/host fixture timed out/);
|
|
1031
|
+
assert(fs.existsSync(hung),'the host was stopped by the outer deadline before its reviewer hung');
|
|
1032
|
+
const reviewer=Number(fs.readFileSync(hung,'utf8'));assert(Number.isSafeInteger(reviewer)&&reviewer>1);
|
|
1033
|
+
const gone=()=>{try{process.kill(reviewer,0);return false;}catch(error){return error.code==='ESRCH';}};
|
|
1034
|
+
for(const deadline=Date.now()+3000;!gone()&&Date.now()<deadline;)await new Promise(resolve=>setTimeout(resolve,25));
|
|
1035
|
+
assert(gone(),`hung fake reviewer ${reviewer} survived the watchdog`);
|
|
1036
|
+
assert.deepEqual(fixtureProcesses(f.root),[]);
|
|
1037
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
1038
|
+
});
|
|
879
1039
|
|
|
880
1040
|
test('new host refuses unapproved manifest bytes before any developer call',async()=>{
|
|
881
1041
|
const f=fixture();
|
|
@@ -1030,3 +1190,63 @@ test('F7 CLI explicitly revises missing QA commands after N5 and resumes the sam
|
|
|
1030
1190
|
assert.deepEqual(JSON.parse(fs.readFileSync(stateFile)),after);
|
|
1031
1191
|
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
1032
1192
|
});
|
|
1193
|
+
|
|
1194
|
+
// Protected current-session driver answers (#10, #11, #31). These reach the real
|
|
1195
|
+
// Codex sandbox that applies protected edits, so they live in this excluded file.
|
|
1196
|
+
const protectedDriver=fileURLToPath(new URL('./cm-ai-drive.mjs',import.meta.url));
|
|
1197
|
+
function protectedDriveFixture({scope,files={},checkCommands=[{id:'noop',command:['/usr/bin/true']}]}){
|
|
1198
|
+
const f=fixture(),definition=JSON.parse(fs.readFileSync(f.config,'utf8'));
|
|
1199
|
+
definition.scope=scope;fs.writeFileSync(f.config,JSON.stringify(definition));
|
|
1200
|
+
for(const [file,content] of Object.entries(files)){
|
|
1201
|
+
fs.mkdirSync(path.dirname(path.join(f.codeProject,file)),{recursive:true});
|
|
1202
|
+
fs.writeFileSync(path.join(f.codeProject,file),content);fs.chmodSync(path.join(f.codeProject,file),0o644);
|
|
1203
|
+
}
|
|
1204
|
+
const answers=path.join(f.root,'answers');fs.mkdirSync(answers);
|
|
1205
|
+
fs.writeFileSync(path.join(f.root,'protection.json'),JSON.stringify({checkCommands,timeoutMs:120000}));
|
|
1206
|
+
f.content=(name,bytes)=>fs.writeFileSync(path.join(answers,name),bytes);
|
|
1207
|
+
f.developAnswer=edits=>fs.writeFileSync(path.join(answers,'develop.json'),JSON.stringify({status:'succeeded',
|
|
1208
|
+
value:implementedValue(),edits}));
|
|
1209
|
+
f.drive=(permissions=[],umask='022')=>{
|
|
1210
|
+
const plan=path.join(f.root,`plan-${Math.random().toString(36).slice(2)}.json`);
|
|
1211
|
+
fs.writeFileSync(plan,JSON.stringify({config:'run.json',mode:'create',hostContext:'native-host-fixture',
|
|
1212
|
+
permissions:['--protected-conversation-config','protection.json','--review-config',f.reviewFile,...permissions],answers:'answers'}));
|
|
1213
|
+
return spawnSync('/bin/sh',['-c',`umask ${umask}; exec "$0" "$@"`,process.execPath,protectedDriver,'--plan',plan,'advance'],
|
|
1214
|
+
{encoding:'utf8',timeout:120000,
|
|
1215
|
+
env:{...process.env,CM_WORKFLOW_HOME:path.join(f.root,'home'),CM_WORKFLOW_LOG_HOME:path.join(f.root,'logs')}});
|
|
1216
|
+
};
|
|
1217
|
+
return f;
|
|
1218
|
+
}
|
|
1219
|
+
const lastPackageChanges=f=>new Map(lastCheckpoint(f).reviewPackage.changes.map(change=>[change.path,change]));
|
|
1220
|
+
test('#10 the driver carries a protected develop reply above 64 KiB once --input-limit is raised',()=>{
|
|
1221
|
+
const f=protectedDriveFixture({scope:['App.xcodeproj/project.pbxproj']});
|
|
1222
|
+
try{
|
|
1223
|
+
const content='// !$*UTF8*$!\n'+'\t\tA1D0000000000000000001 /* x */ = {isa = PBXBuildFile; };\n'.repeat(1500);
|
|
1224
|
+
f.content('pbxproj.txt',content);f.developAnswer({'App.xcodeproj/project.pbxproj':'pbxproj.txt'});
|
|
1225
|
+
const run=f.drive(['--input-limit','1048576']);
|
|
1226
|
+
assert.equal(run.signal,null,'driver waited on a rejected reply');assert.equal(run.status,0,run.stderr);
|
|
1227
|
+
assert.equal(JSON.parse(run.stdout).result.state,'awaiting_review',run.stdout);
|
|
1228
|
+
assert.equal(fs.readFileSync(path.join(f.codeProject,'App.xcodeproj','project.pbxproj'),'utf8'),content);
|
|
1229
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
1230
|
+
});
|
|
1231
|
+
test('#11 #31 protected driver deletes, sets the executable bit, creates new files 0644 and keeps BOM/CRLF text exact',()=>{
|
|
1232
|
+
const f=protectedDriveFixture({scope:['scripts/test.sh','old/Legacy.swift','new/Legacy.swift','App/Home.swift'],
|
|
1233
|
+
files:{'scripts/test.sh':'#!/bin/sh\necho TEST SUCCEEDED\n','old/Legacy.swift':'// legacy\n'},
|
|
1234
|
+
checkCommands:[{id:'test',command:['./scripts/test.sh']}]});
|
|
1235
|
+
try{
|
|
1236
|
+
const home=Buffer.from('import SwiftUI\r\nstruct Home {}\r\n','utf8');
|
|
1237
|
+
f.content('legacy.swift','// legacy\n');f.content('home.swift',home);
|
|
1238
|
+
f.developAnswer({'scripts/test.sh':{mode:'0755'},'old/Legacy.swift':{delete:true},
|
|
1239
|
+
'new/Legacy.swift':'legacy.swift','App/Home.swift':'home.swift'});
|
|
1240
|
+
const run=f.drive([],'077');
|
|
1241
|
+
assert.equal(run.status,0,run.stderr);assert.equal(JSON.parse(run.stdout).result.state,'awaiting_review',run.stdout);
|
|
1242
|
+
assert.equal(fs.statSync(path.join(f.codeProject,'scripts/test.sh')).mode&0o777,0o755);
|
|
1243
|
+
assert.equal(fs.existsSync(path.join(f.codeProject,'old/Legacy.swift')),false);
|
|
1244
|
+
assert.equal(fs.statSync(path.join(f.codeProject,'new/Legacy.swift')).mode&0o777,0o644);
|
|
1245
|
+
assert.equal(fs.statSync(path.join(f.codeProject,'App/Home.swift')).mode&0o777,0o644);
|
|
1246
|
+
assert.deepEqual(fs.readFileSync(path.join(f.codeProject,'App/Home.swift')),home);
|
|
1247
|
+
const changes=lastPackageChanges(f);
|
|
1248
|
+
assert.equal(changes.get('scripts/test.sh').before.mode,0o644);assert.equal(changes.get('scripts/test.sh').after.mode,0o755);
|
|
1249
|
+
assert.equal(changes.get('old/Legacy.swift').after,null);
|
|
1250
|
+
assert.equal(changes.get('new/Legacy.swift').after.mode,0o644);
|
|
1251
|
+
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
1252
|
+
});
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// #25 launch-input mistakes name the input instead of a bare code.
|
|
2
|
+
import test,{after} from 'node:test';
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import {spawnSync} from 'node:child_process';
|
|
8
|
+
import {fileURLToPath} from 'node:url';
|
|
9
|
+
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
10
|
+
import {readRunDefinition,openControlRun} from './cm-ai-run.mjs';
|
|
11
|
+
import {createConversationExecution} from './cm-ai-host.mjs';
|
|
12
|
+
import {createHostToolBridge} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
13
|
+
|
|
14
|
+
const home=fs.mkdtempSync(path.join(os.tmpdir(),'cm-launch-diagnostics-home-'));
|
|
15
|
+
process.env.CM_WORKFLOW_HOME=path.join(home,'user');process.env.CM_WORKFLOW_LOG_HOME=path.join(home,'logs');
|
|
16
|
+
after(()=>fs.rmSync(home,{recursive:true,force:true}));
|
|
17
|
+
const cli=fileURLToPath(new URL('./cm-ai-host.mjs',import.meta.url));
|
|
18
|
+
const driver=fileURLToPath(new URL('./cm-ai-drive.mjs',import.meta.url));
|
|
19
|
+
const identity={repositoryId:'launch-fixture',runId:'launch-fixture-run',taskId:'T-001',attempt:1};
|
|
20
|
+
|
|
21
|
+
function fixture(t){
|
|
22
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-launch-diagnostics-')));
|
|
23
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
24
|
+
const specsDir=path.join(root,'specs'),codeProject=path.join(root,'code'),feature='1.work';
|
|
25
|
+
fs.mkdirSync(codeProject);fs.mkdirSync(path.join(specsDir,feature),{recursive:true});
|
|
26
|
+
for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(specsDir,feature,name),'# Fixture\n');
|
|
27
|
+
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),'- [ ] T-001: fixture\n');
|
|
28
|
+
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],specFiles:buildManifest(specsDir)}));
|
|
29
|
+
fs.writeFileSync(path.join(codeProject,'requirements.md'),'# Fixture\n');
|
|
30
|
+
const config=path.join(root,'run.json'),review=path.join(root,'review.json'),workflow=path.join(root,'workflow.json');
|
|
31
|
+
fs.writeFileSync(config,JSON.stringify({version:1,specsDir,codeProject,feature,identity,scope:['target.mjs'],requirements:['requirements.md']}));
|
|
32
|
+
fs.writeFileSync(review,JSON.stringify({model:'fixture',preflight:{}}));
|
|
33
|
+
fs.writeFileSync(workflow,JSON.stringify({documentationPaths:[],applicableAgentFiles:[],qa:null}));
|
|
34
|
+
const env={...process.env,CM_WORKFLOW_HOME:path.join(root,'home'),CM_WORKFLOW_LOG_HOME:path.join(root,'logs'),NODE_NO_WARNINGS:'1'};
|
|
35
|
+
const host=(mode,{hostContext='session-a',extra=[]}={})=>{
|
|
36
|
+
const result=spawnSync(process.execPath,[cli,'serve','--config',config,'--mode',mode,'--host-context',hostContext,
|
|
37
|
+
'--allow-development',...extra],{encoding:'utf8',env,timeout:20000,
|
|
38
|
+
input:JSON.stringify({version:1,operation:'status',requestId:'status',identity})+'\n'});
|
|
39
|
+
const line=result.stderr.split('\n').find(item=>item.startsWith('{"error"'));
|
|
40
|
+
return {...result,error:line?JSON.parse(line).error:null};
|
|
41
|
+
};
|
|
42
|
+
return {root,specsDir,codeProject,config,review,workflow,env,host};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
test('create without --review-config is refused with the reason and leaves no run',t=>{
|
|
46
|
+
const f=fixture(t);
|
|
47
|
+
const refused=f.host('create');
|
|
48
|
+
assert.equal(refused.status,1);assert.equal(refused.error.code,'review_configuration_required');
|
|
49
|
+
assert.match(refused.error.reason,/--review-config/);assert.match(refused.error.reason,/preflight/);
|
|
50
|
+
assert.equal(fs.existsSync(path.join(f.specsDir,'.reviews','.execution',identity.runId)),false);
|
|
51
|
+
const created=f.host('create',{extra:['--review-config',f.review]});
|
|
52
|
+
assert.equal(created.status,0,created.stderr);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('fingerprint_mismatch names the launch input that differs',t=>{
|
|
56
|
+
const f=fixture(t);
|
|
57
|
+
assert.equal(f.host('create',{extra:['--runtime','claude','--review-config',f.review]}).status,0);
|
|
58
|
+
const same=f.host('resume',{extra:['--runtime','claude','--review-config',f.review]});
|
|
59
|
+
assert.equal(same.status,0,same.stderr);
|
|
60
|
+
for(const [label,options,pattern] of [
|
|
61
|
+
['runtime omitted',{extra:['--review-config',f.review]},/--runtime:创建时为 claude,本次为 codex/],
|
|
62
|
+
['review config omitted',{extra:['--runtime','claude']},/--review-config:创建时用了审查模型 fixture,本次没有提供/],
|
|
63
|
+
['other session without --original-host-context',{hostContext:'session-b',extra:['--runtime','claude','--review-config',f.review]},
|
|
64
|
+
/--host-context:创建会话为 session-a.*--original-host-context session-a/],
|
|
65
|
+
['workflow config added',{extra:['--runtime','claude','--review-config',f.review,'--workflow-config',f.workflow]},
|
|
66
|
+
/--workflow-config/],
|
|
67
|
+
]){
|
|
68
|
+
const result=f.host('resume',options);
|
|
69
|
+
assert.equal(result.status,1,label);assert.equal(result.error.code,'fingerprint_mismatch',label);
|
|
70
|
+
assert.match(result.error.reason,pattern,label);
|
|
71
|
+
}
|
|
72
|
+
// The explicit cross-session form still reopens: the diagnosis never widens the check.
|
|
73
|
+
assert.equal(f.host('resume',{hostContext:'session-b',extra:['--original-host-context','session-a',
|
|
74
|
+
'--runtime','claude','--review-config',f.review]}).status,0);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('a legacy run created without review config explains why the config cannot be added on resume',async t=>{
|
|
78
|
+
const f=fixture(t),bridge=createHostToolBridge();
|
|
79
|
+
try{
|
|
80
|
+
// Shape written by earlier versions: no review binding at create.
|
|
81
|
+
const definition=readRunDefinition(f.config);
|
|
82
|
+
const created=await openControlRun(definition,'create',createConversationExecution(definition,'session-a',bridge,null,null,null,false,'claude'));
|
|
83
|
+
created.close();
|
|
84
|
+
}finally{bridge.close();}
|
|
85
|
+
const result=f.host('resume',{extra:['--runtime','claude','--review-config',f.review]});
|
|
86
|
+
assert.equal(result.status,1);assert.equal(result.error.code,'fingerprint_mismatch');
|
|
87
|
+
assert.match(result.error.reason,/创建时没有审查配置.*不能补加.*cancel/);
|
|
88
|
+
assert.equal(f.host('resume',{extra:['--runtime','claude']}).status,0,'the original launch still reopens it');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('driver PLAN without runtime reaches the host diagnosis for a Claude run',t=>{
|
|
92
|
+
const f=fixture(t);
|
|
93
|
+
assert.equal(f.host('create',{extra:['--runtime','claude','--review-config',f.review]}).status,0);
|
|
94
|
+
const plan=path.join(f.root,'plan.json');
|
|
95
|
+
fs.writeFileSync(plan,JSON.stringify({config:'run.json',mode:'resume',hostContext:'session-a',
|
|
96
|
+
permissions:['--review-config','review.json']}));
|
|
97
|
+
const result=spawnSync(process.execPath,[driver,'--plan',plan,'status'],{encoding:'utf8',env:f.env,timeout:30000});
|
|
98
|
+
assert.notEqual(result.status,0);
|
|
99
|
+
assert.match(result.stderr,/fingerprint_mismatch/);assert.match(result.stderr,/--runtime:创建时为 claude/);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('invalid_arguments names the argument',t=>{
|
|
103
|
+
const f=fixture(t);
|
|
104
|
+
for(const [extra,pattern] of [
|
|
105
|
+
[['--allow-qa','--review-config',f.review],/--allow-qa 需要同时提供 --workflow-config/],
|
|
106
|
+
[['--workflow-config',f.workflow,'--allow-qa','--review-config',f.review],/qa 不为 null/],
|
|
107
|
+
[['--browser-qa','available','--review-config',f.review],/没有适用的交互式 QA/],
|
|
108
|
+
[['--no-such-flag'],/未知参数:--no-such-flag/],
|
|
109
|
+
[['--review-config',f.review,'--review-config',f.review],/参数重复:--review-config/],
|
|
110
|
+
[['--allow-review-attempt','3','--review-config',f.review],/只接受 1 或 2/],
|
|
111
|
+
[['--input-limit','12'],/--input-limit/],
|
|
112
|
+
]){
|
|
113
|
+
const result=f.host('create',{extra});
|
|
114
|
+
assert.equal(result.status,1,extra.join(' '));assert.equal(result.error.code,'invalid_arguments',extra.join(' '));
|
|
115
|
+
assert.match(result.error.reason,pattern,extra.join(' '));
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('usage marks --review-config as required at create',()=>{
|
|
120
|
+
const help=spawnSync(process.execPath,[cli,'--help'],{encoding:'utf8'});
|
|
121
|
+
assert.equal(help.status,0);assert.match(help.stdout,/--allow-development --review-config PATH \(required at create/);
|
|
122
|
+
assert.doesNotMatch(help.stdout,/\[--review-config PATH\]/);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('a new batch requires --review-config like single-task create; a started batch keeps its launch',async t=>{
|
|
126
|
+
const f=fixture(t),batchCli=fileURLToPath(new URL('./cm-ai-batch-host.mjs',import.meta.url));
|
|
127
|
+
const {batchTaskRunId}=await import('./cm-ai-batch-run.mjs');
|
|
128
|
+
const batch={version:1,repositoryId:'launch-fixture',batchId:'launch-batch-1',specsDir:f.specsDir,codeProject:f.codeProject,
|
|
129
|
+
tasks:[{feature:'1.work',taskId:'T-001',scope:['target.mjs'],requirements:['requirements.md']}]};
|
|
130
|
+
const config=path.join(f.root,'batch.json');fs.writeFileSync(config,JSON.stringify({batch,workflows:{'1.work/T-001':null}}));
|
|
131
|
+
const launch=extra=>{const result=spawnSync(process.execPath,[batchCli,'serve','--config',config,'--host-context','batch-host',
|
|
132
|
+
'--allow-development',...extra],{encoding:'utf8',env:f.env,timeout:20000,input:''});
|
|
133
|
+
const line=result.stderr.split('\n').find(item=>item.startsWith('{"error"'));return {...result,error:line?JSON.parse(line).error:null};};
|
|
134
|
+
const refused=launch([]);
|
|
135
|
+
assert.equal(refused.status,1);assert.equal(refused.error.code,'review_configuration_required');
|
|
136
|
+
assert.match(refused.error.reason,/新批次必须带 --review-config/);
|
|
137
|
+
assert.equal(launch(['--review-config',f.review]).status,0);
|
|
138
|
+
// A batch whose member run already exists resumes with its original launch.
|
|
139
|
+
const store=path.join(f.specsDir,'.reviews','.execution',batchTaskRunId(batch.batchId,'1.work/T-001'));
|
|
140
|
+
fs.mkdirSync(store,{recursive:true});fs.writeFileSync(path.join(store,'state.json'),'{}');
|
|
141
|
+
assert.equal(launch([]).status,0,'no review_configuration_required for a started batch');
|
|
142
|
+
});
|
|
@@ -148,14 +148,20 @@ test('a selected root may contain protected specs but specs cannot be a selected
|
|
|
148
148
|
assert.throws(()=>captureReviewBaseline({...options,specsRoot,codeProjectPaths:['apps/api/specs']}),{code:'protected_specs'});
|
|
149
149
|
});
|
|
150
150
|
|
|
151
|
-
test('single-root baseline
|
|
151
|
+
test('single-root baseline and package bind ignore policy with an empty unchanged scope',t=>{
|
|
152
152
|
const {root}=fixture(t),single=path.join(root,'apps/api');
|
|
153
153
|
const baseline=captureReviewBaseline({root:single,identity,scope:['source.mjs'],requirements:['requirement.md']});
|
|
154
|
-
assert.deepEqual(Object.keys(baseline).sort(),['version','kind','identity','rootDigest','scope','requirements','files','baselineDigest'].sort());
|
|
154
|
+
assert.deepEqual(Object.keys(baseline).sort(),['version','kind','identity','rootDigest','scope','requirements','files','ignorePolicy','baselineDigest'].sort());
|
|
155
|
+
assert.deepEqual(Object.keys(baseline.ignorePolicy).sort(),
|
|
156
|
+
['version','builtinDigest','mode','ignoredPaths','ignoredDirectories','coreExcludesFile'].sort());
|
|
157
|
+
assert.equal(baseline.ignorePolicy.version,2);
|
|
158
|
+
assert.deepEqual(readReviewBaseline(baseline),baseline);
|
|
155
159
|
assert.deepEqual(baseline,resign(baseline,'baselineDigest'));
|
|
156
160
|
write(single,'source.mjs','changed\n');const pkg=createReviewPackage({root:single,baseline,checks});
|
|
157
161
|
assert.deepEqual(Object.keys(pkg).sort(),['version','kind','identity','rootDigest','baseIdentity','scope','changes','unchangedScope','requirements','checks',
|
|
158
|
-
'artifactDigest','requirementsDigest','checksDigest','packageDigest'].sort());
|
|
162
|
+
'ignorePolicy','artifactDigest','requirementsDigest','checksDigest','packageDigest'].sort());
|
|
163
|
+
assert.deepEqual(pkg.ignorePolicy,baseline.ignorePolicy);
|
|
164
|
+
assert.deepEqual(readReviewPackage(pkg),pkg);
|
|
159
165
|
assert.deepEqual(pkg.unchangedScope,[]);
|
|
160
166
|
assert.equal(verifyReviewPackage({root:single,baseline,checks,reviewPackage:pkg,expectedDigest:pkg.packageDigest}).outcome,'matched');
|
|
161
167
|
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import {operatorGuidance,guidanceText} from '../runtime/js/cm-ai/operator-guidance.mjs';
|
|
4
|
+
import {batchMemberResult} from './cm-ai-batch-run.mjs';
|
|
5
|
+
|
|
6
|
+
const identity={repositoryId:'fixture',runId:'guidance-run',taskId:'T-001',attempt:1};
|
|
7
|
+
const result=(state,code,pendingAction,extra={})=>({workflow:'cm-ai',identity,state,code,pendingAction,outcome:'reported',...extra});
|
|
8
|
+
const explain=(...args)=>operatorGuidance(result(...args));
|
|
9
|
+
|
|
10
|
+
test('only native resume paths advertise same-run development and never grant permission',()=>{
|
|
11
|
+
for(const code of ['develop_checks_not_passed','develop_package_too_large','developer_result_invalid',
|
|
12
|
+
'verification_precheck_failed','check_output_out_of_scope','develop_empty_changes','develop_unchanged_after_review',
|
|
13
|
+
'develop_requirement_missing','bootstrap_verification_failed']){
|
|
14
|
+
const input=result('blocked',code,'resume',{reason:'technical detail'}),before=JSON.stringify(input);
|
|
15
|
+
const guidance=operatorGuidance(input);
|
|
16
|
+
assert.equal(guidance.recoveryOperation,'advance',code);assert.equal(guidance.authorizationGranted,false);
|
|
17
|
+
assert.match(guidance.nextStep,/本轮交付和检查/);assert.match(guidance.prerequisites.join(' '),/原配置、runId/);
|
|
18
|
+
assert.equal(JSON.stringify(input),before,'guidance cannot mutate authority');
|
|
19
|
+
assert.equal(explain('blocked',code,'none').recoveryOperation,null,'no action when native recovery unavailable');
|
|
20
|
+
assert.equal(explain('unknown',code,'reconcile').recoveryOperation,null,'same code is not retry permission');
|
|
21
|
+
}
|
|
22
|
+
assert.match(explain('blocked','develop_package_too_large','resume').nextStep,/先走规格变更/);
|
|
23
|
+
assert.match(explain('blocked','develop_checks_not_passed','resume').summary,/尚未进入独立审查/);
|
|
24
|
+
});
|
|
25
|
+
test('bootstrap recovery restores the package without redispatching developer',()=>{
|
|
26
|
+
const g=explain('blocked','bootstrap_review_mismatch','bootstrap_review_recover');
|
|
27
|
+
assert.equal(g.recoveryOperation,'bootstrap_review_recover');assert.match(g.nextStep,/不重新派发开发/);
|
|
28
|
+
assert.match(g.prerequisites.join(' '),/--allow-bootstrap-review-recovery/);
|
|
29
|
+
assert.equal(explain('blocked','bootstrap_review_mismatch','none').recoveryOperation,null);
|
|
30
|
+
});
|
|
31
|
+
test('spec drift and rejection precede otherwise retryable package or development actions',()=>{
|
|
32
|
+
assert.equal(explain('blocked','spec_drift','bootstrap_review_recover').recoveryOperation,null);
|
|
33
|
+
assert.equal(explain('blocked','spec_drift','spec_rebind').recoveryOperation,null);
|
|
34
|
+
for(const outcome of ['rejected','denied']){
|
|
35
|
+
const g=explain('blocked','develop_checks_not_passed','resume',{outcome});
|
|
36
|
+
assert.equal(g.recoveryOperation,null);assert.match(g.summary,/拒绝/);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
test('unknown must be audited; abandonment is conditional and never an advance instruction',()=>{
|
|
40
|
+
for(const action of ['abandon_effect','abandon_review']){
|
|
41
|
+
const g=explain('unknown','execution_error',action);
|
|
42
|
+
assert.equal(g.recoveryOperation,action);assert.match(g.nextStep,/子进程已退出/);
|
|
43
|
+
assert.match(g.nextStep,/不代表成功/);assert.equal(g.authorizationGranted,false);
|
|
44
|
+
}
|
|
45
|
+
assert.equal(explain('unknown','limit_exceeded','reconcile').recoveryOperation,null);
|
|
46
|
+
assert.match(explain('unknown','execution_error','reconcile').nextStep,/只读核对/);
|
|
47
|
+
});
|
|
48
|
+
test('active operation suppresses recovery and completion is kept separate from development',()=>{
|
|
49
|
+
const g=operatorGuidance(result('unknown','execution_error','abandon_effect'),{executionActive:true});
|
|
50
|
+
assert.equal(g.recoveryOperation,null);assert.match(g.nextStep,/不重复派发/);
|
|
51
|
+
assert.equal(explain('blocked','completion_package_changed','complete').recoveryOperation,'complete');
|
|
52
|
+
assert.match(explain('blocked','completion_checks_changed','complete').nextStep,/不重新开发/);
|
|
53
|
+
assert.equal(explain('blocked','checks_not_passed','none').recoveryOperation,null);
|
|
54
|
+
assert.match(explain('blocked','checks_not_passed','none').summary,/旧完成阶段/);
|
|
55
|
+
assert.equal(explain('fixture_completed','correction_review_required','none').recoveryOperation,null);
|
|
56
|
+
});
|
|
57
|
+
test('unrecognized and successful states do not invent a recovery contract',()=>{
|
|
58
|
+
assert.equal(explain('blocked','unrecognized_code','none').recoveryOperation,null);
|
|
59
|
+
for(const code of ['constructor','__proto__','toString'])assert.equal(explain('blocked',code,'resume').recoveryOperation,null);
|
|
60
|
+
assert.equal(explain('blocked','bootstrap_instruction_conflict','none').recoveryOperation,null);
|
|
61
|
+
for(const state of ['ready','awaiting_review','approved','fixture_completed','run_done'])assert.equal(explain(state,null,'none'),null);
|
|
62
|
+
assert.equal(operatorGuidance(null),null);assert.equal(operatorGuidance({workflow:'cm-fix',state:'blocked',identity}),null);
|
|
63
|
+
});
|
|
64
|
+
test('review redispatch keeps package and fresh authorization prerequisites',()=>{
|
|
65
|
+
const g=explain('pending_review','review_transport_timeout','resume');
|
|
66
|
+
assert.equal(g.recoveryOperation,'advance');assert.match(g.prerequisites.join(' '),/审查包绑定不变/);
|
|
67
|
+
assert.match(g.nextStep,/本轮绑定/);
|
|
68
|
+
});
|
|
69
|
+
test('rendering never uses raw reason and malformed foreign guidance is ignored',()=>{
|
|
70
|
+
const value=result('unknown','execution_error','reconcile',{reason:'private raw provider message'});
|
|
71
|
+
value.guidance=operatorGuidance(value);const rendered=guidanceText(value);
|
|
72
|
+
assert(!rendered.includes(value.reason));assert.match(rendered,/只读核对/);
|
|
73
|
+
assert.equal(guidanceText({...value,workflow:'cm-fix'}),null);
|
|
74
|
+
for(const change of [{authorizationGranted:true},{summary:'control\nline'},{prerequisites:null},{nextStep:'x'.repeat(2001)}])
|
|
75
|
+
assert.equal(guidanceText({...value,guidance:{...value.guidance,...change}}),null);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('batch guidance matches its narrower control surface and never advertises single-host flags',()=>{
|
|
79
|
+
const member=(...args)=>{const value=result(...args);return {...value,guidance:operatorGuidance(value)};};
|
|
80
|
+
const blocked=member('blocked','develop_checks_not_passed','resume');
|
|
81
|
+
const wrapped=batchMemberResult(blocked);
|
|
82
|
+
assert.equal(wrapped.pendingAction,blocked.pendingAction);assert.equal(wrapped.guidance.recoveryOperation,'advance');
|
|
83
|
+
assert.match(guidanceText(wrapped),/原批次入口/);assert.doesNotMatch(guidanceText(wrapped),/--mode/);
|
|
84
|
+
assert.match(guidanceText(batchMemberResult(member('blocked','completion_checks_changed','complete'))),/成员宿主继续完成复核/);
|
|
85
|
+
for(const [state,code,action] of [['unknown','execution_error','abandon_effect'],
|
|
86
|
+
['unknown','execution_error','abandon_review'],['blocked','bootstrap_review_mismatch','bootstrap_review_recover']]){
|
|
87
|
+
const output=batchMemberResult(member(state,code,action));
|
|
88
|
+
assert.equal(output.guidance.recoveryOperation,null);assert.doesNotMatch(guidanceText(output),/--allow-/);
|
|
89
|
+
assert.match(guidanceText(output),/批次入口不支持/);
|
|
90
|
+
}
|
|
91
|
+
const rebound=batchMemberResult(member('blocked','spec_drift','spec_rebind'));
|
|
92
|
+
assert.equal(rebound.pendingAction,'none');assert.match(rebound.guidance.nextStep,/不能换绑/);
|
|
93
|
+
assert.equal(rebound.guidance.recoveryOperation,null);
|
|
94
|
+
});
|