@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
|
@@ -4,6 +4,13 @@ import fs from 'node:fs';
|
|
|
4
4
|
import os from 'node:os';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import {createTaskRunner} from '../runtime/js/cm-ai/task-runner.mjs';
|
|
7
|
+
import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
|
|
8
|
+
import {withHandoffDiagnostic} from './cm-ai-host.mjs';
|
|
9
|
+
import {controlledState,stageAllowed,completedEffectCount,runnerStatus,readRunnerHistory} from '../runtime/js/cm-ai/durable-runner-state.mjs';
|
|
10
|
+
import {openTaskExecutionStore} from '../runtime/js/cm-ai/task-owner.mjs';
|
|
11
|
+
import {digest,requestFor} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
12
|
+
import {reviewPaths,reviewReceipt} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
13
|
+
import {createReviewPackage} from '../runtime/js/cm-ai/review-package.mjs';
|
|
7
14
|
|
|
8
15
|
test('adapter exception code getter cannot escape the runner failure boundary',async t=>{
|
|
9
16
|
const root=fs.mkdtempSync(path.join(os.tmpdir(),'cm-runner-error-code-'));
|
|
@@ -27,3 +34,215 @@ test('adapter exception code getter cannot escape the runner failure boundary',a
|
|
|
27
34
|
assert.equal(result.code,'execution_error');
|
|
28
35
|
assert.equal(getterReads,0);
|
|
29
36
|
});
|
|
37
|
+
|
|
38
|
+
test('check-created untracked output blocks with paths and retries in the same run',async t=>{
|
|
39
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-check-output-')));
|
|
40
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
41
|
+
fs.writeFileSync(path.join(root,'code.js'),'old');
|
|
42
|
+
fs.writeFileSync(path.join(root,'requirements.md'),'fixture');
|
|
43
|
+
const identity={repositoryId:'fixture',runId:'check-output',taskId:'T-001',attempt:1};
|
|
44
|
+
let checks=0;
|
|
45
|
+
const hostCheck=createHostCheck({cwd:root,commands:[{id:'build',command:[process.execPath,'-e',
|
|
46
|
+
"require('node:fs').mkdirSync('build',{recursive:true});require('node:fs').writeFileSync('build/product','x')"]}]});
|
|
47
|
+
const runner=createTaskRunner({root,identity,scope:['code.js'],requirements:['requirements.md'],
|
|
48
|
+
excludedContexts:['main'],timeoutMs:5000,
|
|
49
|
+
developer:{provider:'codex',requestedModel:'fixture',contextId:'developer',run:request=>{
|
|
50
|
+
fs.writeFileSync(path.join(root,'code.js'),'new');
|
|
51
|
+
return {version:1,invocationId:request.invocationId,contextId:request.contextId,provider:request.provider,
|
|
52
|
+
effectiveModel:'fixture',status:'succeeded',accepted:true,result:{outcome:'implemented'}};
|
|
53
|
+
}},
|
|
54
|
+
reviewers:[{id:'reviewer',provider:'codex',requestedModel:'fixture',allowed:true,available:true,
|
|
55
|
+
contexts:['review-one','review-two'],run:()=>{throw new Error('must not review');}}],
|
|
56
|
+
check:async(...args)=>{checks++;return checks===1?hostCheck(...args):
|
|
57
|
+
[{id:'build',command:['fixture'],outcome:'passed',exitCode:0,evidence:'fixture'}];},
|
|
58
|
+
commit:()=>{throw new Error('must not commit');}});
|
|
59
|
+
const first=await runner.executeEffect({version:1,id:'develop-1',identity,kind:'develop'});
|
|
60
|
+
assert.equal(first.state,'blocked');assert.equal(first.code,'check_output_out_of_scope');
|
|
61
|
+
assert.equal(runner.verificationBlocks(),1);
|
|
62
|
+
assert.match(first.reason,/build\/product/);assert(!first.reason.includes(root));
|
|
63
|
+
fs.rmSync(path.join(root,'build'),{recursive:true});
|
|
64
|
+
const second=await runner.executeEffect({version:1,id:'develop-2',identity,kind:'develop'});
|
|
65
|
+
assert.equal(second.state,'awaiting_review');assert.equal(second.code,null);
|
|
66
|
+
assert.equal(checks,2);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('developer-created out of scope file remains unknown with a path diagnostic',async t=>{
|
|
70
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-developer-outscope-')));
|
|
71
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
72
|
+
fs.writeFileSync(path.join(root,'code.js'),'old');fs.writeFileSync(path.join(root,'requirements.md'),'fixture');
|
|
73
|
+
const identity={repositoryId:'fixture',runId:'developer-outscope',taskId:'T-001',attempt:1};
|
|
74
|
+
const runner=createTaskRunner({root,identity,scope:['code.js'],requirements:['requirements.md'],
|
|
75
|
+
excludedContexts:['main'],timeoutMs:5000,
|
|
76
|
+
developer:{provider:'codex',requestedModel:'fixture',contextId:'developer',run:request=>{
|
|
77
|
+
fs.writeFileSync(path.join(root,'code.js'),'new');fs.writeFileSync(path.join(root,'unexpected.js'),'developer');
|
|
78
|
+
return {version:1,invocationId:request.invocationId,contextId:request.contextId,provider:request.provider,
|
|
79
|
+
effectiveModel:'fixture',status:'succeeded',accepted:true,result:{outcome:'implemented'}};
|
|
80
|
+
}},
|
|
81
|
+
reviewers:[{id:'reviewer',provider:'codex',requestedModel:'fixture',allowed:true,available:true,
|
|
82
|
+
contexts:['review-one','review-two'],run:()=>{throw new Error('must not review');}}],
|
|
83
|
+
check:async()=>[{id:'unit',command:['fixture'],outcome:'passed',exitCode:0,evidence:'fixture'}],
|
|
84
|
+
commit:()=>{throw new Error('must not commit');}});
|
|
85
|
+
const result=await runner.executeEffect({version:1,id:'develop-1',identity,kind:'develop'});
|
|
86
|
+
assert.equal(result.state,'unknown');assert.equal(result.code,'out_of_scope');
|
|
87
|
+
assert.match(result.reason,/unexpected\.js/);assert(!result.reason.includes(root));
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('host stderr repeats the bounded relative scope diagnostic',async()=>{
|
|
91
|
+
let stderr='';
|
|
92
|
+
const host=withHandoffDiagnostic({handle:async()=>({state:'blocked',code:'check_output_out_of_scope',
|
|
93
|
+
reason:'out_of_scope: build/product'})},{write:text=>{stderr+=text;}});
|
|
94
|
+
const result=await host.handle({operation:'status'});
|
|
95
|
+
assert.equal(result.reason,'out_of_scope: build/product');
|
|
96
|
+
assert.match(stderr,/build\/product/);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('a later control error clears stale scope paths from status',()=>{
|
|
100
|
+
const next=controlledState({state:'blocked',code:'check_output_out_of_scope',
|
|
101
|
+
reason:'out_of_scope: build/product',workflowError:null},'workflow-error',false);
|
|
102
|
+
assert.equal(next.code,'workflow_error');
|
|
103
|
+
assert.equal(next.reason,null);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('legacy state without a reason remains readable and check-output retry does not consume the effect cap',()=>{
|
|
107
|
+
const state={state:'blocked',code:'out_of_scope',attempt:1,reviewPackage:null,receipt:null,receipts:[],calls:[],
|
|
108
|
+
cancelAfterCommit:false,workflowError:null,cancellationRequested:false};
|
|
109
|
+
const status=runnerStatus(state,{identity:{repositoryId:'fixture',runId:'legacy',taskId:'T-001',attempt:1}});
|
|
110
|
+
assert.equal(Object.hasOwn(status,'reason'),false);
|
|
111
|
+
assert.equal(stageAllowed('develop','blocked','check_output_out_of_scope'),true);
|
|
112
|
+
assert.equal(completedEffectCount([{effect:{kind:'develop'},result:{state:'blocked',code:'check_output_out_of_scope'}}]),0);
|
|
113
|
+
assert.equal(stageAllowed('develop','blocked','develop_checks_not_passed'),true);
|
|
114
|
+
assert.equal(stageAllowed('develop','blocked','checks_not_passed'),false);
|
|
115
|
+
// Completion holds no effect slot (an approved run can always complete); the
|
|
116
|
+
// legacy completion-gate checks_not_passed stays terminal through its stage.
|
|
117
|
+
assert.equal(completedEffectCount([{effect:{kind:'complete'},result:{state:'blocked',code:'checks_not_passed'}}]),0);
|
|
118
|
+
assert.equal(stageAllowed('complete','blocked','checks_not_passed'),false);
|
|
119
|
+
assert.equal(completedEffectCount([{effect:{kind:'develop'},result:{state:'blocked',code:'develop_checks_not_passed'}}]),1);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('check-output block and reason replay from the stored run before retry',async t=>{
|
|
123
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-check-replay-')));
|
|
124
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
125
|
+
const code=path.join(root,'code'),specs=path.join(root,'specs');
|
|
126
|
+
fs.mkdirSync(code);fs.mkdirSync(path.join(specs,'.reviews'),{recursive:true});
|
|
127
|
+
fs.writeFileSync(path.join(code,'code.js'),'old');fs.writeFileSync(path.join(code,'requirements.md'),'fixture');
|
|
128
|
+
const tasksPath=path.join(specs,'tasks.md');fs.writeFileSync(tasksPath,'- [ ] T-001: fixture\n');
|
|
129
|
+
const identity={repositoryId:'fixture',runId:'check-replay',taskId:'T-001',attempt:1};
|
|
130
|
+
const owner={tasksPath,feature:'feature',specsRoot:specs,identity:{repositoryId:identity.repositoryId,runId:identity.runId},
|
|
131
|
+
fingerprints:{workflow:digest('fixture'),config:digest('fixture-config'),inputs:digest('fixture-input')},create:true};
|
|
132
|
+
let store=openTaskExecutionStore(owner);
|
|
133
|
+
t.after(()=>store.close());
|
|
134
|
+
let checks=0;
|
|
135
|
+
const options={root:code,identity,scope:['code.js'],requirements:['requirements.md'],excludedContexts:['main'],timeoutMs:5000,
|
|
136
|
+
developer:{provider:'codex',requestedModel:'fixture',contextId:'developer',run:request=>{
|
|
137
|
+
fs.writeFileSync(path.join(code,'code.js'),'new');
|
|
138
|
+
return {version:1,invocationId:request.invocationId,contextId:request.contextId,provider:request.provider,
|
|
139
|
+
effectiveModel:'fixture',status:'succeeded',accepted:true,result:{outcome:'implemented'}};
|
|
140
|
+
}},
|
|
141
|
+
reviewers:[{id:'reviewer',provider:'codex',requestedModel:'fixture',allowed:true,available:true,
|
|
142
|
+
contexts:['review-one','review-two'],run:()=>{throw new Error('must not review');}}],
|
|
143
|
+
check:async()=>{
|
|
144
|
+
checks++;
|
|
145
|
+
if(checks===1){fs.mkdirSync(path.join(code,'build'));fs.writeFileSync(path.join(code,'build/product'),'x');}
|
|
146
|
+
return [{id:'unit',command:['fixture'],outcome:'passed',exitCode:0,evidence:'fixture'}];
|
|
147
|
+
},commit:()=>{throw new Error('must not commit');}};
|
|
148
|
+
const first=createTaskRunner({...options,persistence:{store,mode:'create'}});
|
|
149
|
+
const blocked=await first.executeEffect({version:1,id:'develop-1',identity,kind:'develop'});
|
|
150
|
+
assert.equal(blocked.code,'check_output_out_of_scope');
|
|
151
|
+
assert.equal(first.verificationBlocks(),1);
|
|
152
|
+
store.close();store=openTaskExecutionStore({...owner,create:false});
|
|
153
|
+
const resumed=createTaskRunner({...options,persistence:{store,mode:'resume'}});
|
|
154
|
+
assert.equal(resumed.status().reason,blocked.reason);
|
|
155
|
+
assert.equal(resumed.verificationBlocks(),1);
|
|
156
|
+
fs.rmSync(path.join(code,'build'),{recursive:true});
|
|
157
|
+
const next=await resumed.executeEffect({version:1,id:'develop-2',identity,kind:'develop'});
|
|
158
|
+
assert.equal(next.state,'awaiting_review');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test('legacy completion checks_not_passed never reopens develop live or after replay',async t=>{
|
|
162
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-legacy-complete-')));
|
|
163
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
164
|
+
const code=path.join(root,'code'),specs=path.join(root,'specs');
|
|
165
|
+
fs.mkdirSync(code);fs.mkdirSync(path.join(specs,'.reviews'),{recursive:true});
|
|
166
|
+
fs.writeFileSync(path.join(code,'code.js'),'old');
|
|
167
|
+
fs.writeFileSync(path.join(code,'requirements.md'),'fixture');
|
|
168
|
+
const tasksPath=path.join(specs,'tasks.md');fs.writeFileSync(tasksPath,'- [ ] T-001: fixture\n');
|
|
169
|
+
const identity={repositoryId:'fixture',runId:'legacy-complete',taskId:'T-001',attempt:1};
|
|
170
|
+
const owner={tasksPath,feature:'feature',specsRoot:specs,identity:{repositoryId:identity.repositoryId,runId:identity.runId},
|
|
171
|
+
fingerprints:{workflow:digest('legacy-complete'),config:digest('fixture'),inputs:digest('fixture')},create:true};
|
|
172
|
+
let store=openTaskExecutionStore(owner);
|
|
173
|
+
t.after(()=>store.close());
|
|
174
|
+
let checks=0,developCalls=0;
|
|
175
|
+
const terminal=(request,result)=>({version:1,invocationId:request.invocationId,contextId:request.contextId,
|
|
176
|
+
provider:request.provider,effectiveModel:'fixture',status:'succeeded',accepted:true,result});
|
|
177
|
+
const options={root:code,identity,scope:['code.js'],requirements:['requirements.md'],excludedContexts:['main'],timeoutMs:5000,
|
|
178
|
+
developer:{provider:'codex',requestedModel:'fixture',contextId:'developer',run:request=>{
|
|
179
|
+
developCalls++;fs.writeFileSync(path.join(code,'code.js'),'new');
|
|
180
|
+
return terminal(request,{outcome:'implemented'});
|
|
181
|
+
}},
|
|
182
|
+
reviewers:[{id:'reviewer',provider:'codex',requestedModel:'fixture',allowed:true,available:true,
|
|
183
|
+
contexts:['review-one','review-two'],run:request=>terminal(request,{verdict:'approved',
|
|
184
|
+
packageDigest:request.payload.reviewPackage.packageDigest,
|
|
185
|
+
examinedPaths:reviewPaths(request.payload.reviewPackage),findings:[],summary:'fixture review'})}],
|
|
186
|
+
check:()=>{checks++;return [{id:'unit',command:['fixture'],outcome:checks===1?'passed':'failed',
|
|
187
|
+
exitCode:checks===1?0:1,evidence:'fixture'}];},
|
|
188
|
+
commit:()=>{throw new Error('must not commit');}};
|
|
189
|
+
const effect=(kind,id=kind)=>({version:1,id,identity,kind});
|
|
190
|
+
const first=createTaskRunner({...options,persistence:{store,mode:'create'}});
|
|
191
|
+
assert.equal((await first.executeEffect(effect('develop'))).state,'awaiting_review');
|
|
192
|
+
assert.equal((await first.executeEffect(effect('review'))).state,'approved');
|
|
193
|
+
store.close();
|
|
194
|
+
|
|
195
|
+
// A pre-D1 journal could approve a failed-check review package. Rebind its
|
|
196
|
+
// package, request and receipt so replay validates the actual legacy path.
|
|
197
|
+
const statePath=path.join(specs,'.reviews','.execution',identity.runId,'state.json');
|
|
198
|
+
const saved=JSON.parse(fs.readFileSync(statePath,'utf8'));
|
|
199
|
+
const failed=[{id:'unit',command:['fixture'],outcome:'failed',exitCode:1,evidence:'fixture'}];
|
|
200
|
+
const legacyPackage=createReviewPackage({root:code,baseline:saved.records[0].payload.baseline,checks:failed});
|
|
201
|
+
const dev=saved.records.find(record=>record.payload.type==='effect-checkpoint'
|
|
202
|
+
&&record.payload.checkpoint.state==='awaiting_review').payload.checkpoint;
|
|
203
|
+
const approved=saved.records.at(-1).payload.checkpoint;
|
|
204
|
+
dev.reviewPackage=legacyPackage;dev.currentChecks=failed;
|
|
205
|
+
dev.cache.at(-1).result.packageDigest=legacyPackage.packageDigest;
|
|
206
|
+
const reviewCall=approved.calls.at(-1);
|
|
207
|
+
const reviewRequest=requestFor({invocationId:reviewCall.invocationId,identity,role:'reviewer',
|
|
208
|
+
provider:'codex',requestedModel:'fixture',contextId:'review-one',
|
|
209
|
+
payload:{reviewPackage:legacyPackage,priorReview:null}});
|
|
210
|
+
const reviewResult={verdict:'approved',packageDigest:legacyPackage.packageDigest,
|
|
211
|
+
examinedPaths:reviewPaths(legacyPackage),findings:[],summary:'fixture review'};
|
|
212
|
+
reviewCall.requestDigest=reviewRequest.requestDigest;reviewCall.resultDigest=digest(reviewResult);
|
|
213
|
+
const receipt=reviewReceipt({request:reviewRequest,call:reviewCall,result:reviewResult,
|
|
214
|
+
reviewPackage:legacyPackage,developerProvider:'codex',fallbackReasons:[]});
|
|
215
|
+
approved.reviewPackage=legacyPackage;approved.currentChecks=failed;
|
|
216
|
+
approved.receipt=receipt;approved.receipts=[receipt];approved.priorReview=reviewResult;
|
|
217
|
+
approved.cache[0]=structuredClone(dev.cache[0]);
|
|
218
|
+
const reviewed=approved.cache.at(-1).result;
|
|
219
|
+
reviewed.packageDigest=legacyPackage.packageDigest;
|
|
220
|
+
reviewed.receipt=receipt;reviewed.receipts=[receipt];reviewed.calls=approved.calls;
|
|
221
|
+
for(let i=0;i<saved.records.length;i++){
|
|
222
|
+
const {digest:ignored,...record}=saved.records[i];
|
|
223
|
+
record.previousDigest=i?saved.records[i-1].digest:null;
|
|
224
|
+
saved.records[i]={...record,digest:digest(record)};
|
|
225
|
+
}
|
|
226
|
+
const {revision:ignored,...body}=saved;
|
|
227
|
+
fs.writeFileSync(statePath,JSON.stringify({...body,revision:digest(body)})+'\n');
|
|
228
|
+
assert.equal(readRunnerHistory(saved.records,saved.records[0].payload.config).state.state,'approved');
|
|
229
|
+
const reopen=()=>{
|
|
230
|
+
store.close();store=openTaskExecutionStore({...owner,create:false});
|
|
231
|
+
return createTaskRunner({...options,persistence:{store,mode:'resume'}});
|
|
232
|
+
};
|
|
233
|
+
const live=reopen();
|
|
234
|
+
assert.equal(live.status().state,'approved');
|
|
235
|
+
assert.equal(live.status().receipt.checksDigest,digest(failed));
|
|
236
|
+
const blocked=await live.executeEffect(effect('complete'));
|
|
237
|
+
assert.equal(blocked.state,'blocked');assert.equal(blocked.code,'checks_not_passed');
|
|
238
|
+
assert.equal(live.status().code,'checks_not_passed');
|
|
239
|
+
assert.equal(live.verificationBlocks(),0);
|
|
240
|
+
assert.deepEqual(await live.executeEffect(effect('develop','develop-after-complete')),
|
|
241
|
+
{outcome:'rejected',code:'stage_mismatch'});
|
|
242
|
+
assert.equal(developCalls,1);
|
|
243
|
+
const replay=reopen();
|
|
244
|
+
assert.equal(replay.status().code,'checks_not_passed');
|
|
245
|
+
assert.deepEqual(await replay.executeEffect(effect('develop','develop-after-replay')),
|
|
246
|
+
{outcome:'rejected',code:'stage_mismatch'});
|
|
247
|
+
assert.equal(developCalls,1);
|
|
248
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {spawnSync} from 'node:child_process';
|
|
7
|
+
import {fileURLToPath} from 'node:url';
|
|
8
|
+
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
9
|
+
import {openControlRun,validateRunDefinition} from './cm-ai-run.mjs';
|
|
10
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
11
|
+
|
|
12
|
+
function fixture(t){
|
|
13
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-ai-selection-guard-')));
|
|
14
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
15
|
+
const specsDir=path.join(root,'specs'),codeProject=path.join(root,'code'),feature='1.work';
|
|
16
|
+
fs.mkdirSync(path.join(specsDir,feature),{recursive:true});fs.mkdirSync(codeProject);
|
|
17
|
+
for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(specsDir,feature,name),'# Fixture\n');
|
|
18
|
+
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),'- [ ] T-001: first\n- [ ] T-002: second\n- [ ] T-003: final\n\n- T-003 依赖 T-001, T-002\n');
|
|
19
|
+
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],specFiles:buildManifest(specsDir)}));
|
|
20
|
+
fs.writeFileSync(path.join(codeProject,'a.mjs'),'export const value = 1;\n');
|
|
21
|
+
const definition=(runId,taskId='T-001',taskSelection)=>validateRunDefinition({version:1,specsDir,codeProject,feature,
|
|
22
|
+
identity:{repositoryId:'guard-fixture',runId,taskId,attempt:1},scope:['a.mjs'],requirements:[],
|
|
23
|
+
...(taskSelection?{taskSelection}: {})});
|
|
24
|
+
const execution={configuration:{kind:'guard-fixture'},timeoutMs:1000,excludedContexts:['host'],hostDecision:null,
|
|
25
|
+
qaLogHome:path.join(root,'logs'),
|
|
26
|
+
developer:{provider:'codex',requestedModel:'fixture',contextId:'author',run:async()=>{throw Error('unexpected development');}},
|
|
27
|
+
reviewers:[{id:'reviewer',adapterId:'codex-review-adapter',provider:'codex',requestedModel:'fixture',allowed:true,
|
|
28
|
+
available:true,contexts:['review-one','review-two'],run:async()=>{throw Error('unexpected review');}}],
|
|
29
|
+
reviewInvocation:{developerThreadId:'author',excludedThreadIds:['host'],authorize:()=>{throw Error('unexpected review');}},
|
|
30
|
+
check:async()=>{throw Error('unexpected check');}};
|
|
31
|
+
return {root,specsDir,codeProject,feature,definition,execution};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
test('single task selection accepts only the same feature eligible task and resumes with its exact fingerprint',async t=>{
|
|
35
|
+
const f=fixture(t),selected={version:1,taskId:'T-002'},definition=f.definition('selected-run','T-002',selected);
|
|
36
|
+
assert.throws(()=>f.definition('invalid-selection-run','T-002',{version:1,taskId:'T-001'}),{code:'invalid_task_selection'});
|
|
37
|
+
await assert.rejects(openControlRun(f.definition('legacy-refused','T-002'),'create',f.execution),{code:'task_selection_mismatch'});
|
|
38
|
+
await assert.rejects(openControlRun(f.definition('dependent-refused','T-003',{version:1,taskId:'T-003'}),'create',f.execution),{code:'task_selection_mismatch'});
|
|
39
|
+
const run=await openControlRun(definition,'create',f.execution);run.close();
|
|
40
|
+
const statePath=path.join(f.specsDir,'.reviews','.execution','selected-run','state.json');
|
|
41
|
+
const before=fs.readFileSync(statePath);
|
|
42
|
+
const resumed=await openControlRun(definition,'resume',f.execution);resumed.close();
|
|
43
|
+
assert.deepEqual(fs.readFileSync(statePath),before);
|
|
44
|
+
await assert.rejects(openControlRun(f.definition('selected-run','T-002'),'resume',f.execution),{code:'fingerprint_mismatch'});
|
|
45
|
+
assert.equal(JSON.parse(before).fingerprints.config,digest({definition,execution:f.execution.configuration}));
|
|
46
|
+
let called=0;
|
|
47
|
+
f.execution.developer.run=async()=>{called++;throw Error('fixture development stop');};
|
|
48
|
+
const launched=await openControlRun(definition,'resume',f.execution);
|
|
49
|
+
try{
|
|
50
|
+
const result=await launched.host.handle({version:1,operation:'start',requestId:'selected-start',identity:definition.identity});
|
|
51
|
+
assert.notEqual(result.code,'task_mismatch');
|
|
52
|
+
assert.notEqual(result.code,'learning_context_invalid');
|
|
53
|
+
assert.equal(called,1);
|
|
54
|
+
}finally{launched.close();}
|
|
55
|
+
const legacy=f.definition('legacy-run-0001');
|
|
56
|
+
const oldRun=await openControlRun(legacy,'create',f.execution);oldRun.close();
|
|
57
|
+
const legacyState=path.join(f.specsDir,'.reviews','.execution','legacy-run-0001','state.json');
|
|
58
|
+
const legacyBytes=fs.readFileSync(legacyState);
|
|
59
|
+
const oldResume=await openControlRun(legacy,'resume',f.execution);oldResume.close();
|
|
60
|
+
assert.deepEqual(fs.readFileSync(legacyState),legacyBytes);
|
|
61
|
+
assert.equal(JSON.parse(legacyBytes).fingerprints.config,digest({definition:legacy,execution:f.execution.configuration}));
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('attempt-2 reviewed handoff also refuses create before the store exists',async t=>{
|
|
65
|
+
const f=fixture(t),reviews=path.join(f.specsDir,'.reviews');fs.mkdirSync(reviews);
|
|
66
|
+
const name='work-T-001-a2-handoff.json';
|
|
67
|
+
fs.writeFileSync(path.join(reviews,name),'{}\n');
|
|
68
|
+
fs.writeFileSync(path.join(reviews,'work-T-001-r2.md'),`---\nhandoff: ${name}\n---\n`);
|
|
69
|
+
await assert.rejects(openControlRun(f.definition('attempt-two-run'),'create',f.execution),{code:'handoff_exists'});
|
|
70
|
+
assert.equal(fs.existsSync(path.join(reviews,'.execution','attempt-two-run')),false);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('reviewed handoff collision refuses create before store and supersede authorization proceeds',async t=>{
|
|
74
|
+
const f=fixture(t),old=f.definition('old-run-0001'),reviews=path.join(f.specsDir,'.reviews');
|
|
75
|
+
const original=await openControlRun(old,'create',f.execution);
|
|
76
|
+
const cancelled=await original.host.handle({version:1,operation:'cancel',requestId:'cancel',identity:old.identity});
|
|
77
|
+
assert.equal(cancelled.state,'cancelled');original.close();
|
|
78
|
+
const name='work-T-001-a1-handoff.json';
|
|
79
|
+
fs.writeFileSync(path.join(reviews,name),'{}\n');
|
|
80
|
+
fs.writeFileSync(path.join(reviews,'work-T-001-r1.md'),`---\nhandoff: ${name}\n---\n`);
|
|
81
|
+
const newRun=f.definition('new-run-0002');
|
|
82
|
+
await assert.rejects(openControlRun(newRun,'create',f.execution),error=>
|
|
83
|
+
error.code==='handoff_exists'&&/--supersede-reviewed-evidence/.test(error.reason));
|
|
84
|
+
assert.equal(fs.existsSync(path.join(reviews,'.execution','new-run-0002')),false);
|
|
85
|
+
const restarted=await openControlRun(newRun,'create',f.execution,{supersedeReason:'Operator requested restart'});
|
|
86
|
+
restarted.close();
|
|
87
|
+
const state=JSON.parse(fs.readFileSync(path.join(reviews,'.execution','new-run-0002','state.json')));
|
|
88
|
+
assert(state.records.some(row=>row.payload.type==='evidence-superseded'));
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('driver same-session resume without original context reaches the missing-store check without launching a host',t=>{
|
|
92
|
+
const f=fixture(t),config=path.join(f.root,'run.json'),plan=path.join(f.root,'plan.json');
|
|
93
|
+
fs.writeFileSync(config,JSON.stringify(f.definition('resume-run-0001')));
|
|
94
|
+
fs.writeFileSync(plan,JSON.stringify({config:'run.json',mode:'resume',hostContext:'same-session',permissions:[]}));
|
|
95
|
+
const driver=fileURLToPath(new URL('./cm-ai-drive.mjs',import.meta.url));
|
|
96
|
+
const result=spawnSync(process.execPath,[driver,'--plan',plan,'status'],{encoding:'utf8'});
|
|
97
|
+
assert.equal(result.status,2,result.stderr);
|
|
98
|
+
assert.match(result.stderr,/恢复存档不存在/);
|
|
99
|
+
assert.doesNotMatch(result.stderr,/originalHostContext/);
|
|
100
|
+
});
|
|
@@ -59,7 +59,9 @@ function launch(f,{host='session-A',original,mode='resume',operation='status',re
|
|
|
59
59
|
if(row.type==='host_request'){
|
|
60
60
|
let result;
|
|
61
61
|
if(row.kind==='develop'){
|
|
62
|
-
|
|
62
|
+
// Attempt 2 must change the rejected bytes (develop_unchanged_after_review).
|
|
63
|
+
fs.writeFileSync(path.join(f.codeProject,'target.mjs'),row.payload.request.identity.attempt===1
|
|
64
|
+
?'export const value = 42;\n':'export const value = 43;\n');
|
|
63
65
|
result={status:'succeeded',value:{outcome:'implemented',application:{status:'no_relevant_lesson',note:null},
|
|
64
66
|
retrospective:{status:'no_new_lesson',candidates:[],reason:null}}};
|
|
65
67
|
}else{
|
|
@@ -228,9 +230,11 @@ test('second review excludes earlier joined host even when the current host is C
|
|
|
228
230
|
// can open B with these unchanged bytes, but rejects B's grant as unauthorized.
|
|
229
231
|
test('runner session chain without CLI reaches B grant and replays it in C',async t=>{
|
|
230
232
|
const f=fixture(t);
|
|
231
|
-
const bridge={async call(kind){
|
|
233
|
+
const bridge={async call(kind,payload){
|
|
232
234
|
if(kind==='develop'){
|
|
233
|
-
|
|
235
|
+
// Attempt 2 must change the rejected bytes (develop_unchanged_after_review).
|
|
236
|
+
fs.writeFileSync(path.join(f.codeProject,'target.mjs'),payload.request.identity.attempt===1
|
|
237
|
+
?'export const value = 42;\n':'export const value = 43;\n');
|
|
234
238
|
return {status:'succeeded',value:{outcome:'implemented',application:{status:'no_relevant_lesson',note:null},
|
|
235
239
|
retrospective:{status:'no_new_lesson',candidates:[],reason:null}}};
|
|
236
240
|
}
|