@aibyzero/cm-workflow 0.21.7 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +64 -0
- package/README.md +15 -1
- package/VERSION +1 -1
- package/docs/architecture.md +9 -0
- package/docs/cm-acceptance-completion.md +3 -1
- package/docs/cm-control-policy-v2.md +35 -3
- package/docs/execution-optimizations.md +1 -1
- package/docs/external-models.md +1 -0
- package/docs/human-correction.md +1 -1
- package/docs/installation.md +63 -19
- package/docs/js-workflow-control.md +67 -31
- package/docs/next-steps.md +10 -0
- package/docs/runtime-failover.md +2 -2
- package/docs/user-guide.md +1 -1
- package/package.json +1 -1
- package/runtime/js/cm-ai/batch-location.mjs +14 -0
- package/runtime/js/cm-ai/batch-plan.mjs +6 -2
- package/runtime/js/cm-ai/claude-probe-diagnosis.mjs +21 -0
- package/runtime/js/cm-ai/claude-review-stream.mjs +20 -7
- package/runtime/js/cm-ai/claude-tool-preview.mjs +4 -2
- package/runtime/js/cm-ai/cm-ai-admission.mjs +9 -3
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +51 -8
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +30 -4
- package/runtime/js/cm-ai/codex-review-adapter.mjs +2 -4
- package/runtime/js/cm-ai/delivery-evidence.mjs +3 -1
- package/runtime/js/cm-ai/developer-adapter.mjs +15 -1
- package/runtime/js/cm-ai/drive-core.mjs +50 -6
- package/runtime/js/cm-ai/drive-next-step.mjs +61 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +85 -23
- package/runtime/js/cm-ai/execution-snapshot.mjs +5 -2
- package/runtime/js/cm-ai/execution-store.mjs +21 -3
- package/runtime/js/cm-ai/external-run-guard.mjs +9 -1
- package/runtime/js/cm-ai/host-check.mjs +4 -2
- package/runtime/js/cm-ai/host-conversation-execution.mjs +29 -2
- package/runtime/js/cm-ai/host-handoff.mjs +7 -0
- package/runtime/js/cm-ai/host-progress.mjs +18 -0
- package/runtime/js/cm-ai/host-qa-executor.mjs +47 -15
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +11 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +24 -14
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +1 -1
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/operator-guidance.mjs +126 -2
- package/runtime/js/cm-ai/project-qa-gate.mjs +13 -2
- package/runtime/js/cm-ai/provider-review-observation.mjs +7 -3
- package/runtime/js/cm-ai/qa-plan-notes.mjs +106 -0
- package/runtime/js/cm-ai/review-continuation.mjs +102 -0
- package/runtime/js/cm-ai/review-evidence-file.mjs +11 -0
- package/runtime/js/cm-ai/review-package.mjs +25 -4
- package/runtime/js/cm-ai/review-presentation.mjs +31 -14
- package/runtime/js/cm-ai/review-runner.mjs +5 -4
- package/runtime/js/cm-ai/review-verdict-rules.mjs +7 -0
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +30 -1
- package/runtime/js/cm-ai/task-commit-codec.mjs +11 -1
- package/runtime/js/cm-ai/task-commit.mjs +7 -4
- package/runtime/js/cm-ai/task-owner.mjs +5 -2
- package/runtime/js/cm-ai/task-runner.mjs +343 -52
- package/runtime/js/cm-ai/worker-claude-developer.mjs +3 -1
- package/runtime/js/cm-ai/worker-claude.mjs +5 -1
- package/runtime/js/cm-check/host.mjs +13 -3
- package/runtime/js/cm-fix/diagnosis.mjs +16 -3
- package/runtime/js/cm-fix/execution.mjs +47 -9
- package/runtime/js/cm-fix/finish.mjs +9 -1
- package/runtime/js/cm-fix/step-timing.mjs +222 -0
- package/runtime/js/cm-idea/session.mjs +22 -3
- package/runtime/js/cm-init/review-evidence.mjs +20 -7
- package/runtime/js/cm-prd/ai-draft.mjs +260 -0
- package/runtime/js/cm-prd/analysis.mjs +27 -9
- package/runtime/js/cm-prd/change.mjs +29 -8
- package/runtime/js/cm-prd/failed-correction.mjs +24 -4
- package/runtime/js/cm-prd/narrow-review.mjs +63 -3
- package/runtime/js/cm-prd/review-channels.mjs +5 -0
- package/runtime/js/cm-prd/review-correction.mjs +65 -5
- package/runtime/js/cm-prd/review-disposition.mjs +10 -1
- package/runtime/js/cm-prd/review-publication.mjs +2 -1
- package/runtime/js/cm-prd/self-check.mjs +121 -9
- package/runtime/js/cm-prd/session.mjs +55 -13
- package/runtime/js/cm-prd/summary.mjs +34 -6
- package/runtime/js/cm-prd/task-scope-record.mjs +40 -15
- package/runtime/js/cm-refactor/records.mjs +82 -11
- package/runtime/js/cm-refactor/workflow.mjs +3 -1
- package/runtime/js/executor-version.mjs +81 -0
- package/runtime/js/python-log-writer.mjs +15 -0
- package/runtime/js/run-analysis.mjs +136 -11
- package/runtime/logging.md +6 -0
- package/runtime/review.md +2 -1
- package/scripts/ci-test-weights.json +1 -0
- package/scripts/cm-ai-admission.mjs +27 -1
- package/scripts/cm-ai-admission.test.mjs +34 -2
- package/scripts/cm-ai-answer-gap-recheck.test.mjs +3 -2
- package/scripts/cm-ai-batch-drive.mjs +54 -17
- package/scripts/cm-ai-batch-drive.test.mjs +123 -6
- package/scripts/cm-ai-batch-host.mjs +64 -11
- package/scripts/cm-ai-batch-host.test.mjs +23 -3
- package/scripts/cm-ai-batch-location.test.mjs +22 -1
- package/scripts/cm-ai-batch-merge.mjs +102 -0
- package/scripts/cm-ai-batch-plan.mjs +55 -2
- package/scripts/cm-ai-batch-plan.test.mjs +228 -6
- package/scripts/cm-ai-batch-run-fixture.mjs +239 -15
- package/scripts/cm-ai-batch-run-parallel.test.mjs +23 -1
- package/scripts/cm-ai-batch-run.mjs +437 -34
- package/scripts/cm-ai-batch-session-member.test.mjs +85 -0
- package/scripts/cm-ai-check-recheck-cancellation.test.mjs +23 -2
- package/scripts/cm-ai-completion-summary.test.mjs +2 -1
- package/scripts/cm-ai-control-v2-drive.test.mjs +39 -9
- package/scripts/cm-ai-direct-review.test.mjs +1 -1
- package/scripts/cm-ai-disk-edits.test.mjs +229 -0
- package/scripts/cm-ai-drive-next-step.test.mjs +191 -0
- package/scripts/cm-ai-drive.mjs +66 -14
- package/scripts/cm-ai-drive.test.mjs +13 -3
- package/scripts/cm-ai-host-cli-workflow.test.mjs +4 -2
- package/scripts/cm-ai-host.mjs +20 -9
- package/scripts/cm-ai-host.test.mjs +12 -0
- package/scripts/cm-ai-operator-guidance.test.mjs +132 -1
- package/scripts/cm-ai-project-qa-gate.test.mjs +26 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +18 -0
- package/scripts/cm-ai-review-continuation.test.mjs +335 -0
- package/scripts/cm-ai-review-failure.test.mjs +13 -10
- package/scripts/cm-ai-review-timeout.test.mjs +1 -1
- package/scripts/cm-ai-run.mjs +42 -11
- package/scripts/cm-ai-run.test.mjs +26 -0
- package/scripts/cm-ai-supersede.test.mjs +10 -2
- package/scripts/cm-capability-gate.test.mjs +1 -1
- package/scripts/cm-check-host.test.mjs +54 -0
- package/scripts/cm-check-runtime.sh +27 -15
- package/scripts/cm-check-update.mjs +83 -8
- package/scripts/cm-check-update.test.mjs +114 -1
- package/scripts/cm-claude-developer-worker.test.mjs +29 -1
- package/scripts/cm-claude-managed-preflight.test.mjs +126 -0
- package/scripts/cm-claude-probe.test.mjs +5 -0
- package/scripts/cm-claude-review-stream.test.mjs +4 -1
- package/scripts/cm-claude-worker.test.mjs +29 -0
- package/scripts/cm-codex-prompt-input.test.mjs +2 -1
- package/scripts/cm-developer-self-review.test.mjs +27 -0
- package/scripts/cm-efficiency-presentation-delta.test.mjs +4 -3
- package/scripts/cm-efficiency-response.test.mjs +2 -1
- package/scripts/cm-executor-version-draft.test.mjs +251 -0
- package/scripts/cm-executor-version-entries.test.mjs +93 -0
- package/scripts/cm-executor-version-prd.test.mjs +154 -0
- package/scripts/cm-executor-version-records.test.mjs +256 -0
- package/scripts/cm-executor-version.test.mjs +250 -0
- package/scripts/cm-external-model-host.test.mjs +6 -1
- package/scripts/cm-external-review-reconciliation.test.mjs +1 -1
- package/scripts/cm-fix-closeout-preflight.test.mjs +123 -0
- package/scripts/cm-fix-diagnosis-module-correction.test.mjs +5 -1
- package/scripts/cm-fix-drive.mjs +7 -2
- package/scripts/cm-fix-drive.test.mjs +45 -0
- package/scripts/cm-fix-entry.mjs +5 -2
- package/scripts/cm-fix-frozen-baseline.test.mjs +50 -0
- package/scripts/cm-fix-host.mjs +9 -2
- package/scripts/cm-fix-review-preflight.mjs +2 -0
- package/scripts/cm-fix-review-verification-integration.test.mjs +19 -0
- package/scripts/cm-fix-test-extension.test.mjs +30 -2
- package/scripts/cm-host-check.test.mjs +12 -0
- package/scripts/cm-host-qa-executor.test.mjs +172 -1
- package/scripts/cm-host-qa-policy.test.mjs +55 -1
- package/scripts/cm-idea-drive.mjs +5 -2
- package/scripts/cm-idea-entry.mjs +5 -2
- package/scripts/cm-idea-host.mjs +3 -1
- package/scripts/cm-init-drive.mjs +8 -5
- package/scripts/cm-init-entry.mjs +5 -2
- package/scripts/cm-init-host.mjs +6 -2
- package/scripts/cm-log-event.mjs +10 -2
- package/scripts/cm-log-event.test.mjs +29 -0
- package/scripts/cm-prd-ai-draft-fixture.mjs +18 -0
- package/scripts/cm-prd-ai-draft.test.mjs +505 -0
- package/scripts/cm-prd-answer-gaps.test.mjs +110 -5
- package/scripts/cm-prd-completion.test.mjs +67 -4
- package/scripts/cm-prd-design-phase.test.mjs +48 -13
- package/scripts/cm-prd-drive.mjs +91 -21
- package/scripts/cm-prd-drive.test.mjs +126 -4
- package/scripts/cm-prd-entry.mjs +5 -2
- package/scripts/cm-prd-host.mjs +89 -20
- package/scripts/cm-prd-host.test.mjs +17 -8
- package/scripts/cm-prd-narrow-review.test.mjs +49 -1
- package/scripts/cm-prd-review-disposition.test.mjs +94 -1
- package/scripts/cm-prd-review-gate.mjs +13 -5
- package/scripts/cm-prd-review-publication.test.mjs +34 -0
- package/scripts/cm-prd-self-check-rules.test.mjs +175 -10
- package/scripts/cm-prd-self-check.test.mjs +1 -1
- package/scripts/cm-refactor-drive.mjs +10 -4
- package/scripts/cm-refactor-entry.mjs +5 -2
- package/scripts/cm-refactor-host.mjs +3 -1
- package/scripts/cm-release-smoke.sh +3 -2
- package/scripts/cm-run-analysis.test.mjs +373 -1
- package/scripts/cm-skill-hints-autowire.test.mjs +1 -1
- package/scripts/cm-skill-hints-exam.mjs +3 -1
- package/scripts/cm-skill-hints-install.test.mjs +1 -1
- package/scripts/cm-skill-hints.mjs +106 -10
- package/scripts/cm-skill-hints.test.mjs +162 -6
- package/scripts/cm-skill-judge.mjs +2 -1
- package/scripts/cm-task-gate.mjs +88 -18
- package/scripts/cm-task-scope.test.mjs +1 -1
- package/scripts/cm-test-drive.mjs +13 -8
- package/scripts/cm-test-entry.mjs +5 -2
- package/scripts/cm-test-host.mjs +3 -1
- package/scripts/cm-upgrade-compat-batch.test.mjs +62 -9
- package/scripts/cm-workflow-config.test.mjs +8 -3
- package/scripts/fixtures/fresh-completion-checks.mjs +8 -0
- package/scripts/fixtures/prd-review-gate-python-oracle.py +10 -1
- package/scripts/policy-binding-compat.test.mjs +3 -2
- package/scripts/scan-public-safety.py +1 -0
- package/scripts/shell-pipe-early-exit.test.mjs +96 -0
- package/scripts/test-cm-prd-review-gate.py +55 -0
- package/scripts/test-shell-compat.sh +7 -5
- package/skills/cm-ai/SKILL.md +1 -1
- package/skills/cm-ai/references/N1-init.md +1 -1
- package/skills/cm-ai/references/N4-review.md +2 -2
- package/skills/cm-ai/references/N6-qa-eval.md +3 -1
- package/skills/cm-ai/references/js-host-recovery.md +5 -1
- package/skills/cm-ai/references/js-host.md +17 -8
- package/skills/cm-check/SKILL.md +3 -0
- package/skills/cm-fix/references/isolated-review.md +1 -1
- package/skills/cm-fix/references/js-host.md +20 -0
- package/skills/cm-fix/references/test-extension.md +1 -1
- package/skills/cm-prd/SKILL.md +8 -6
- package/skills/cm-prd/references/ai-draft.md +81 -0
- package/skills/cm-prd/references/change-mode.md +2 -0
- package/skills/cm-prd/references/greenfield.md +2 -0
- package/skills/cm-prd/references/js-change-recovery.md +2 -2
- package/skills/cm-prd/references/js-host.md +9 -6
- package/skills/cm-prd/references/light-mode.md +19 -0
- package/skills/cm-prd/references/requirement-grilling.md +2 -0
- package/skills/cm-prd/references/spec-self-check.md +1 -0
- package/skills/cm-prd/references/summary-card.md +1 -0
- package/templates/auto-update/cm-update.sh +2 -2
|
@@ -24,6 +24,7 @@ import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
|
24
24
|
import {isSupportedExecutionPlatform} from '../runtime/js/cm-ai/execution-platform.mjs';
|
|
25
25
|
import {rateLimitRetryEligible} from '../runtime/js/cm-ai/drive-rate-limit.mjs';
|
|
26
26
|
import {guardFixtureSource,killFixtureProcesses} from './fixtures/process-cleanup.mjs';
|
|
27
|
+
import {withFreshCompletionChecks} from './fixtures/fresh-completion-checks.mjs';
|
|
27
28
|
// An exported CM_NOTIFY_OFF silences every notice; these fixtures expect notices on
|
|
28
29
|
// (review 2026-11-17). Tests of the switch itself set it explicitly.
|
|
29
30
|
delete process.env.CM_NOTIFY_OFF;
|
|
@@ -591,13 +592,15 @@ async function runnerFixture(t,fn,{timeoutMs=1000,reviewTimeoutMs,reviewerProvid
|
|
|
591
592
|
taskCompletion:{reviewsDir,handoffs:[path.join(reviewsDir,'a1.json'),path.join(reviewsDir,'a2.json')]},
|
|
592
593
|
reviewInvocation:{developerThreadId:'actual-developer',excludedThreadIds:['actual-main'],
|
|
593
594
|
...(reviewTimeoutMs===undefined?{}:{timeoutMs:reviewTimeoutMs})}};
|
|
594
|
-
|
|
595
|
+
// Mirrors the run entry's creation escape hatch (withFreshCompletionChecks).
|
|
596
|
+
const make=(mode,extra={})=>createTaskRunner({...options,reviewInvocation:{...options.reviewInvocation,...extra},persistence:{store,mode,version:3},
|
|
597
|
+
...(process.env.CM_AI_COMPLETION_CHECK_REUSE==='off'?{completionCheckReuse:false}:{})});
|
|
595
598
|
const reopen=(extra={})=>{store.close();store=openTaskExecutionStore({...owner,create:false});return make('resume',extra);};
|
|
596
599
|
// Simulate a host that died right after the last record of this type.
|
|
597
600
|
const resumePrefix=type=>{
|
|
598
601
|
const current=store.snapshot(),at=current.records.findLastIndex(record=>record.payload.type===type);assert(at>=0);store.close();
|
|
599
602
|
const statePath=path.join(specsRoot,'.reviews','.execution',runIdentity.runId,'state.json');
|
|
600
|
-
const body={version:current.version,identity:current.identity,fingerprints:current.fingerprints,records:current.records.slice(0,at+1)};
|
|
603
|
+
const body={version:current.version,identity:current.identity,fingerprints:current.fingerprints,...(Object.hasOwn(current,"createdBy")?{createdBy:current.createdBy}:{}),records:current.records.slice(0,at+1)};
|
|
601
604
|
fs.writeFileSync(statePath,JSON.stringify({...body,revision:digest(body)})+'\n',{mode:0o600});
|
|
602
605
|
store=openTaskExecutionStore({...owner,create:false});return make('resume');
|
|
603
606
|
};
|
|
@@ -1087,7 +1090,7 @@ function completionFixture(t){
|
|
|
1087
1090
|
...(packageDigest?{packageDigest}:{})}),operation);
|
|
1088
1091
|
return {...f,pass,run};
|
|
1089
1092
|
}
|
|
1090
|
-
test('repeated completion re-check blocks stop at completion_retry_limit instead of an uncompletable approval (real host)',t=>{
|
|
1093
|
+
test('repeated completion re-check blocks stop at completion_retry_limit instead of an uncompletable approval (real host)',t=>withFreshCompletionChecks(()=>(t=>{
|
|
1091
1094
|
const f=completionFixture(t);f.pass(true);
|
|
1092
1095
|
const delivered=f.run('start',{mode:'create'});
|
|
1093
1096
|
assert.equal(delivered.status,0,delivered.stderr);assert.equal(delivered.result.state,'awaiting_review');
|
|
@@ -1116,9 +1119,9 @@ test('repeated completion re-check blocks stop at completion_retry_limit instead
|
|
|
1116
1119
|
assert.deepEqual(f.intents(),intents);
|
|
1117
1120
|
assert.match(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8'),/\[ \] T-001/);
|
|
1118
1121
|
assert.equal(f.replay().state.code,'completion_retry_limit');
|
|
1119
|
-
});
|
|
1122
|
+
})(t)));
|
|
1120
1123
|
|
|
1121
|
-
test('completion re-checks no longer eat the six effects: develop blocks plus re-checks still complete (real host)',t=>{
|
|
1124
|
+
test('completion re-checks no longer eat the six effects: develop blocks plus re-checks still complete (real host)',t=>withFreshCompletionChecks(()=>(t=>{
|
|
1122
1125
|
const f=completionFixture(t);f.pass(false);
|
|
1123
1126
|
for(const mode of ['create','resume'])assert.equal(f.run('advance',{mode}).result.code,'develop_checks_not_passed');
|
|
1124
1127
|
f.pass(true);
|
|
@@ -1132,9 +1135,9 @@ test('completion re-checks no longer eat the six effects: develop blocks plus re
|
|
|
1132
1135
|
const completed=f.run('complete',{packageDigest});
|
|
1133
1136
|
assert.equal(completed.status,0,completed.stderr);assert.equal(completed.result.state,'fixture_completed',JSON.stringify(completed.result));
|
|
1134
1137
|
assert.match(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8'),/\[x\] T-001/);
|
|
1135
|
-
});
|
|
1138
|
+
})(t)));
|
|
1136
1139
|
|
|
1137
|
-
test('#retry-limit replay accepts the completion limit only once the re-check bound is spent',t=>{
|
|
1140
|
+
test('#retry-limit replay accepts the completion limit only once the re-check bound is spent',t=>withFreshCompletionChecks(()=>(t=>{
|
|
1138
1141
|
const f=completionFixture(t);f.pass(true);
|
|
1139
1142
|
const packageDigest=f.run('start',{mode:'create'}).result.packageDigest;
|
|
1140
1143
|
f.run('decision',{review:true,packageDigest});f.pass(false);
|
|
@@ -1158,9 +1161,9 @@ test('#retry-limit replay accepts the completion limit only once the re-check bo
|
|
|
1158
1161
|
const extended=[...structuredClone(records),intent].map((row,index)=>({...row,seq:index+1,
|
|
1159
1162
|
id:`runner.${String(index+1).padStart(6,'0')}`}));
|
|
1160
1163
|
assert.throws(()=>readRunnerHistory(rechain(extended),configuration,3),{code:'runner_stage'});
|
|
1161
|
-
});
|
|
1164
|
+
})(t)));
|
|
1162
1165
|
|
|
1163
|
-
test('#retry-limit an older journal past the completion re-check bound converts on the next complete request',t=>runnerFixture(t,async f=>{
|
|
1166
|
+
test('#retry-limit an older journal past the completion re-check bound converts on the next complete request',t=>withFreshCompletionChecks(()=>(t=>runnerFixture(t,async f=>{
|
|
1164
1167
|
let failing=false;f.setChecks(()=>failing?[{...checksPassed[0],outcome:'failed',exitCode:1}]:checksPassed);
|
|
1165
1168
|
let runner=f.make();
|
|
1166
1169
|
await runner.executeEffect(f.effect('develop'));
|
|
@@ -1177,7 +1180,7 @@ test('#retry-limit an older journal past the completion re-check bound converts
|
|
|
1177
1180
|
assert.equal(f.records().at(-1).payload.type,'completion-retry-limit');
|
|
1178
1181
|
assert.equal(f.records().filter(row=>row.payload.type==='effect-intent').length,intents,'no intent');
|
|
1179
1182
|
assert.deepEqual(f.reopen().status(),converted);
|
|
1180
|
-
}));
|
|
1183
|
+
}))(t)));
|
|
1181
1184
|
|
|
1182
1185
|
// Claude boundary exits (the T-009 incident shape): a user-role text the CLI did
|
|
1183
1186
|
// not mark synthetic stops the reviewer with a summary and stays unknown; the
|
|
@@ -60,7 +60,7 @@ async function fixture(fn,{reviewRun,times,timeoutMs=1000,provider='codex'}={})
|
|
|
60
60
|
const current=store.snapshot(),at=last?current.records.findLastIndex(record=>record.payload.type===type)
|
|
61
61
|
:current.records.findIndex(record=>record.payload.type===type);assert(at>=0);store.close();
|
|
62
62
|
const statePath=path.join(specsRoot,'.reviews','.execution',identity.runId,'state.json');
|
|
63
|
-
const body={version:current.version,identity:current.identity,fingerprints:current.fingerprints,records:current.records.slice(0,at+1)};
|
|
63
|
+
const body={version:current.version,identity:current.identity,fingerprints:current.fingerprints,...(Object.hasOwn(current,"createdBy")?{createdBy:current.createdBy}:{}),records:current.records.slice(0,at+1)};
|
|
64
64
|
fs.writeFileSync(statePath,JSON.stringify({...body,revision:digest(body)})+'\n',{mode:0o600});
|
|
65
65
|
store=openTaskExecutionStore({...owner,create:false});return make('resume');
|
|
66
66
|
};
|
package/scripts/cm-ai-run.mjs
CHANGED
|
@@ -28,6 +28,7 @@ import {RUN_ID_RULE,validRunId} from './cm-log-event.mjs';
|
|
|
28
28
|
import {JOURNAL_PAYLOAD_LIMIT,boundedReason,shape,hex} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
29
29
|
import {protectedScopePaths} from '../runtime/js/cm-ai/developer-adapter.mjs';
|
|
30
30
|
import {closeoutPolicyCandidates} from '../runtime/js/cm-ai/knowledge-closeout.mjs';
|
|
31
|
+
import {EXECUTOR_REASON_CODES,assertResumable} from '../runtime/js/executor-version.mjs';
|
|
31
32
|
|
|
32
33
|
const usage='cm-ai-run.mjs inspect-history --config RUN_DEFINITION.json (validated read-only history; no owner lock or provider dispatch)\ncm-ai-run.mjs serve --config RUN_DEFINITION.json --mode create|resume (no provider dispatch)\nNew runs bind approved specification material from specsDir; requirements may be [] or supplemental code-project files. Manifest drift blocks as spec_drift; legacy journals retain their original format.';
|
|
33
34
|
const fail=code=>{throw Object.assign(new Error(code),{code});};
|
|
@@ -226,12 +227,21 @@ export function assertCreatableRunId(identity){
|
|
|
226
227
|
if(!validRunId(identity?.runId))fail(`invalid_config: identity.runId must be ${RUN_ID_RULE} (run log requirement)`);
|
|
227
228
|
}
|
|
228
229
|
|
|
230
|
+
// The runner's qaCadence creation choice. An older empty store finished on resume keeps
|
|
231
|
+
// the historical count; a batch member takes its batch's (batch-run open), empty store or not.
|
|
232
|
+
export function runnerQaCadence({runnerMode,mode,batchQaCadence=null}){
|
|
233
|
+
if(![null,'legacy','feature-v1'].includes(batchQaCadence))fail('invalid_config: batchQaCadence');
|
|
234
|
+
if(runnerMode!=='create')return {};
|
|
235
|
+
return (batchQaCadence===null?mode!=='create':batchQaCadence==='legacy')?{qaCadence:false}:{};
|
|
236
|
+
}
|
|
237
|
+
|
|
229
238
|
// Definition is data, never an import path, command, grant or executable callback.
|
|
230
239
|
// legacyQa rebuilds the historical QA executor form for stores created before
|
|
231
240
|
// the built-in plan left the fingerprint; it is never used to create a store.
|
|
232
|
-
export function runConfigMaterial(definition,execution,{parallelSelection=null,bootstrapConfig=null,legacyQa=false,knowledgeCloseout=null}={}){
|
|
241
|
+
export function runConfigMaterial(definition,execution,{parallelSelection=null,bootstrapConfig=null,legacyQa=false,knowledgeCloseout=null,batchCompletion=null}={}){
|
|
233
242
|
if(execution===null)return parallelSelection===null?definition:{definition,parallelSelection};
|
|
234
243
|
return {definition,...(parallelSelection===null?{}:{parallelSelection}),execution:execution.configuration,
|
|
244
|
+
...(batchCompletion===null?{}:{batchCompletion}),
|
|
235
245
|
...(knowledgeCloseout===null?{}:{knowledgeCloseout}),
|
|
236
246
|
...(bootstrapConfig?{bootstrap:bootstrapConfig}:{}),
|
|
237
247
|
...(Object.hasOwn(execution,'developmentAttempt')?{developmentAuthorization:'per-attempt-v1'}:{}),
|
|
@@ -251,7 +261,9 @@ export function inspectRunHistory(definition){
|
|
|
251
261
|
// histories this runtime cannot project report null rather than a guess.
|
|
252
262
|
let supersedeTarget=null;
|
|
253
263
|
try{supersedeTarget=controlLaunchTarget(snapshot);}catch{supersedeTarget=null;}
|
|
264
|
+
// createdBy null: the run predates recorded executor releases (created before 0.22.0).
|
|
254
265
|
return {identity:snapshot.identity,revision:snapshot.revision,fingerprints:snapshot.fingerprints,supersedeTarget,
|
|
266
|
+
createdBy:snapshot.createdBy??null,
|
|
255
267
|
records:snapshot.records.map(record=>({seq:record.seq,id:record.id,kind:record.kind,type:record.payload.type??null,
|
|
256
268
|
legacyReviewGrant:record.payload.type==='review-invocation-registered'
|
|
257
269
|
&&(Object.hasOwn(record.payload,'grant')||Object.hasOwn(record.payload,'authorizationAt'))}))};
|
|
@@ -261,6 +273,8 @@ export function assertSupportedResumeHistory(definition){
|
|
|
261
273
|
try{snapshot=readExecutionSnapshot({specsRoot:definition.specsDir,
|
|
262
274
|
identity:{repositoryId:definition.identity.repositoryId,runId:definition.identity.runId}});}
|
|
263
275
|
catch(error){if(error.code==='ENOENT')return null;throw error;}
|
|
276
|
+
// Refuse a run a newer executor created before anything else is opened or written.
|
|
277
|
+
if(snapshot.version===2)assertResumable(snapshot.createdBy);
|
|
264
278
|
if(snapshot.records.some(record=>record.payload.type==='review-invocation-registered'
|
|
265
279
|
&&(Object.hasOwn(record.payload,'grant')||Object.hasOwn(record.payload,'authorizationAt'))))
|
|
266
280
|
throw Object.assign(new Error('runner_invocation'),{code:'runner_invocation',
|
|
@@ -292,11 +306,16 @@ export async function openControlRun(definition,mode,execution=null,options={}){
|
|
|
292
306
|
return {...result,close:()=>{try{close();}finally{guard?.close();}}};
|
|
293
307
|
}catch(error){releaseHolds();guard?.close();throw error;}
|
|
294
308
|
}
|
|
295
|
-
async function openControlRunOwned(definition,mode,execution=null,{supersedeHolds=null,supersedeTarget=null,rerunUnknownQa=false,rerunBlockedQa=false,qaEnvironmentFailure=null,parallelSelection=null,qaConfigRevision=null,supersedeReason=null,acceptSupersededCodeDrift=false,allowAbandonReview=false,allowAbandonEffect=false,allowBootstrapReviewRecovery=false,allowDevelopRedo=false,holdRevision=false,specRebindReason=null,expectedControl=null,scopeRevision=null,developmentReworkReason=null,reviewedIntegration=null}={},acquireGuard=async()=>{}){
|
|
309
|
+
async function openControlRunOwned(definition,mode,execution=null,{supersedeHolds=null,supersedeTarget=null,rerunUnknownQa=false,rerunBlockedQa=false,qaEnvironmentFailure=null,parallelSelection=null,qaConfigRevision=null,supersedeReason=null,acceptSupersededCodeDrift=false,allowAbandonReview=false,allowAbandonEffect=false,allowBootstrapReviewRecovery=false,allowDevelopRedo=false,holdRevision=false,diskEdits=false,specRebindReason=null,expectedControl=null,scopeRevision=null,developmentReworkReason=null,reviewContinuationReason=null,reviewedIntegration=null,batchCompletion=null,batchQaCadence=null}={},acquireGuard=async()=>{}){
|
|
296
310
|
// Check before importing node:sqlite: legacy Node users get a useful error.
|
|
297
311
|
if(!isSupportedExecutionPlatform())fail('unsupported_runner_platform');
|
|
312
|
+
if(batchCompletion!==null&&(execution===null||parallelSelection?.group?.length<2||!parallelSelection
|
|
313
|
+
||typeof batchCompletion.verify!=='function'))fail('invalid_input');
|
|
314
|
+
const batchCompletionBinding=batchCompletion?.binding??null;
|
|
315
|
+
if(batchCompletion!==null&&batchCompletionBinding===null)fail('invalid_input');
|
|
298
316
|
const {conversationProtection,externalConversationDefinition}=await import('../runtime/js/cm-ai/host-conversation-execution.mjs');
|
|
299
317
|
if(!['create','resume'].includes(mode))fail('invalid_mode');
|
|
318
|
+
runnerQaCadence({runnerMode:mode,mode,batchQaCadence});
|
|
300
319
|
if(mode==='create')assertCreatableRunId(definition?.identity);
|
|
301
320
|
// The developer adapter refuses these paths on every dispatch. Refuse the
|
|
302
321
|
// run here, before any journal, intent or execution directory exists, so it
|
|
@@ -309,6 +328,8 @@ async function openControlRunOwned(definition,mode,execution=null,{supersedeHold
|
|
|
309
328
|
if(allowBootstrapReviewRecovery&&mode!=='resume')fail('bootstrap_review_recovery_unavailable');
|
|
310
329
|
if(allowDevelopRedo&&mode!=='resume')fail('develop_redo_unavailable');
|
|
311
330
|
if(typeof holdRevision!=='boolean')fail('invalid_input');
|
|
331
|
+
if(typeof diskEdits!=='boolean')fail('invalid_input');
|
|
332
|
+
if(diskEdits&&(mode!=='resume'||execution===null||protectedExecutions.has(execution)||execution.configuration.providerDevelopment||conversationProtection(execution)!==null))fail('invalid_arguments');
|
|
312
333
|
if(specRebindReason!==null&&(mode!=='resume'||execution===null||typeof specRebindReason!=='string'||!specRebindReason.trim()
|
|
313
334
|
||Buffer.byteLength(specRebindReason,'utf8')>500||/[\r\n\0]/.test(specRebindReason)))fail('spec_rebind_unavailable');
|
|
314
335
|
if(typeof acceptSupersededCodeDrift!=='boolean'||acceptSupersededCodeDrift&&supersedeReason===null)
|
|
@@ -320,13 +341,13 @@ async function openControlRunOwned(definition,mode,execution=null,{supersedeHold
|
|
|
320
341
|
||(rerunUnknownQa||rerunBlockedQa)&&(mode!=='resume'||!execution?.qaExecutor))fail('qa_recovery_authorization_required');
|
|
321
342
|
const {openTaskExecutionStore}=await import('../runtime/js/cm-ai/task-owner.mjs');
|
|
322
343
|
const controlPolicy=execution?.configuration?.controlPolicy??null;
|
|
323
|
-
const elevatedRecovery=scopeRevision!==null||developmentReworkReason!==null;
|
|
344
|
+
const elevatedRecovery=scopeRevision!==null||developmentReworkReason!==null||reviewContinuationReason!==null;
|
|
324
345
|
const launchRecovery=qaConfigRevision!==null||rerunUnknownQa||rerunBlockedQa||specRebindReason!==null||elevatedRecovery||reviewedIntegration!==null;
|
|
325
346
|
if(elevatedRecovery){
|
|
326
347
|
if(!controlPolicy||mode!=='resume'||parallelSelection!==null||conversationProtection(execution)!==null
|
|
327
348
|
||protectedExecutions.has(execution)||execution.configuration.providerDevelopment)fail('recovery_launch_unavailable');
|
|
328
|
-
if([scopeRevision!==null,developmentReworkReason!==null,qaConfigRevision!==null,rerunUnknownQa,rerunBlockedQa,specRebindReason!==null].filter(Boolean).length!==1)fail('invalid_input');
|
|
329
|
-
const reason=scopeRevision?.reason??developmentReworkReason;
|
|
349
|
+
if([scopeRevision!==null,developmentReworkReason!==null,reviewContinuationReason!==null,qaConfigRevision!==null,rerunUnknownQa,rerunBlockedQa,specRebindReason!==null].filter(Boolean).length!==1)fail('invalid_input');
|
|
350
|
+
const reason=scopeRevision?.reason??developmentReworkReason??reviewContinuationReason;
|
|
330
351
|
if(typeof reason!=='string'||!reason.trim()||Buffer.byteLength(reason,'utf8')>500||/[\r\n\0]/.test(reason))fail('invalid_input');
|
|
331
352
|
}
|
|
332
353
|
if(reviewedIntegration!==null){
|
|
@@ -370,7 +391,7 @@ async function openControlRunOwned(definition,mode,execution=null,{supersedeHold
|
|
|
370
391
|
if(execution!==null){
|
|
371
392
|
const {shape,json,validCallTimeout}=await import('../runtime/js/cm-ai/effect-contract.mjs');
|
|
372
393
|
shape(execution,['configuration','developer','reviewers','reviewInvocation','check','excludedContexts','timeoutMs',
|
|
373
|
-
...['bootstrap','developmentAttempt','qaDecisionProvider','qaLogHome','qaExecutor','applicableAgentFiles','documentationProvider','documentationResult','documentationSync','verificationGate'].filter(key=>Object.hasOwn(execution,key))]);
|
|
394
|
+
...['bootstrap','developmentAttempt','qaDecisionProvider','qaLogHome','qaExecutor','applicableAgentFiles','documentationProvider','documentationResult','documentationSync','verificationGate','onChecksReused'].filter(key=>Object.hasOwn(execution,key))]);
|
|
374
395
|
json(execution.configuration);validCallTimeout(execution.timeoutMs);
|
|
375
396
|
if(Object.hasOwn(execution.configuration,'codeProject'))
|
|
376
397
|
if(execution.configuration.codeProject!==definition.codeProject)fail('execution_root_mismatch');
|
|
@@ -509,7 +530,7 @@ async function openControlRunOwned(definition,mode,execution=null,{supersedeHold
|
|
|
509
530
|
?readExecutionSnapshot({specsRoot:specsDir,identity:storeIdentity}):null;
|
|
510
531
|
let opened,lastMismatch;
|
|
511
532
|
for(const knowledgeCloseout of closeoutPolicyCandidates(execution,mode,snapshot)){
|
|
512
|
-
const materialOptions={parallelSelection,bootstrapConfig,knowledgeCloseout};
|
|
533
|
+
const materialOptions={parallelSelection,bootstrapConfig,knowledgeCloseout,batchCompletion:batchCompletionBinding};
|
|
513
534
|
try{opened=openFor(runConfigMaterial(definition,execution,materialOptions));break;}
|
|
514
535
|
catch(error){
|
|
515
536
|
if(mode!=='resume'||error.code!=='fingerprint_mismatch')throw error;
|
|
@@ -529,7 +550,7 @@ async function openControlRunOwned(definition,mode,execution=null,{supersedeHold
|
|
|
529
550
|
if(!opened&&mode==='resume'&&isImplicitQaDecision(execution?.qaDecisionProvider)){
|
|
530
551
|
const {qaDecisionProvider,...original}=execution;
|
|
531
552
|
for(const knowledgeCloseout of closeoutPolicyCandidates(original,mode,snapshot)){
|
|
532
|
-
try{opened=openFor(runConfigMaterial(definition,original,{parallelSelection,bootstrapConfig,knowledgeCloseout}));implicitQaSuppressed=true;break;}
|
|
553
|
+
try{opened=openFor(runConfigMaterial(definition,original,{parallelSelection,bootstrapConfig,knowledgeCloseout,batchCompletion:batchCompletionBinding}));implicitQaSuppressed=true;break;}
|
|
533
554
|
catch(error){if(error.code!=='fingerprint_mismatch')throw error;}
|
|
534
555
|
}
|
|
535
556
|
}
|
|
@@ -565,16 +586,25 @@ async function openControlRunOwned(definition,mode,execution=null,{supersedeHold
|
|
|
565
586
|
...(execution?.configuration.externalModels?{externalModels:execution.configuration.externalModels}:{}),excludedContexts:['control-host'],
|
|
566
587
|
...(controlPolicy?{controlPolicy:savedPolicy??controlPolicy}:{}),
|
|
567
588
|
...(parallelSelection===null?{}:{parallelSelection}),
|
|
589
|
+
...(batchCompletion===null?{}:{batchCompletionGate:batchCompletion.verify}),
|
|
568
590
|
developer:{provider:'codex',requestedModel:'unconfigured',contextId:'control-developer',run:unavailable},
|
|
569
591
|
reviewers:[],check:unavailable,taskCompletion:{reviewsDir,handoffs},taskLearning:{feature},
|
|
570
592
|
persistence:{store,mode:runnerMode,version:execution===null?2:3},
|
|
571
593
|
...(execution===null?{}:{providerDevelopment:protectedExecutions.has(execution)
|
|
572
|
-
||Boolean(execution.configuration.providerDevelopment),protectedDevelopment:conversationProtection(execution)!==null
|
|
594
|
+
||Boolean(execution.configuration.providerDevelopment),protectedDevelopment:conversationProtection(execution)!==null,
|
|
595
|
+
...(diskEdits?{diskEdits:true}:{})}),
|
|
573
596
|
...(execution===null?{}:{developer,reviewers:execution.reviewers,
|
|
574
597
|
...(execution.bootstrap?{bootstrap:execution.bootstrap}:{}),
|
|
575
598
|
reviewInvocation:execution.reviewInvocation,check:execution.check,
|
|
576
599
|
excludedContexts:execution.excludedContexts,timeoutMs:execution.timeoutMs,
|
|
577
600
|
...(Object.hasOwn(execution,'verificationGate')?{verificationGate:execution.verificationGate}:{}),
|
|
601
|
+
...(typeof execution.onChecksReused==='function'?{onChecksReused:execution.onChecksReused}:{}),
|
|
602
|
+
// Escape hatch for checks that read inputs outside the code (env files,
|
|
603
|
+
// services): a run created with this off always reruns checks at completion.
|
|
604
|
+
// An older empty store finished on resume keeps the old default (no reuse).
|
|
605
|
+
...(runnerMode==='create'&&(mode!=='create'||process.env.CM_AI_COMPLETION_CHECK_REUSE==='off')?{completionCheckReuse:false}:{}),
|
|
606
|
+
// Same rule for the N6 cadence: an older empty store keeps the historical count.
|
|
607
|
+
...runnerQaCadence({runnerMode,mode,batchQaCadence}),
|
|
578
608
|
taskLearning:{feature,hostHandoff:true}})},
|
|
579
609
|
// The entry validates the declaration (single line, with --rerun-blocked-qa) before any durable write.
|
|
580
610
|
entry:{specsDir,codeProject,feature,identity,rerunUnknownQa,rerunBlockedQa,
|
|
@@ -588,6 +618,7 @@ async function openControlRunOwned(definition,mode,execution=null,{supersedeHold
|
|
|
588
618
|
if(elevatedRecovery||reviewedIntegration!==null){
|
|
589
619
|
const result=reviewedIntegration!==null?host.acceptReviewedIntegration({allowed:true,...reviewedIntegration})
|
|
590
620
|
:scopeRevision!==null?host.reviseScope({allowed:true,...scopeRevision})
|
|
621
|
+
:reviewContinuationReason!==null?host.authorizeReviewContinuation({allowed:true,reason:reviewContinuationReason})
|
|
591
622
|
:host.reworkDevelopment({allowed:true,reason:developmentReworkReason});
|
|
592
623
|
if(result.outcome==='rejected')fail(result.code);
|
|
593
624
|
}
|
|
@@ -656,7 +687,7 @@ async function openControlRunOwned(definition,mode,execution=null,{supersedeHold
|
|
|
656
687
|
return result;
|
|
657
688
|
}};
|
|
658
689
|
const controlHost=controlPolicy?withControlPolicyHost(legacyHost,{identity,snapshot:()=>store.snapshot(),launchTarget:controlLaunchTarget}):null;
|
|
659
|
-
return {host:legacyHost,...(controlHost?{controlHost}:{}),inspectFixAssociation:host.inspectFixAssociation,acceptCompletedFix:host.acceptCompletedFix,acceptReviewedIntegration:host.acceptReviewedIntegration,
|
|
690
|
+
return {host:legacyHost,...(host.preflightBatchCompletion?{preflightBatchCompletion:host.preflightBatchCompletion}:{}),...(controlHost?{controlHost}:{}),inspectFixAssociation:host.inspectFixAssociation,acceptCompletedFix:host.acceptCompletedFix,acceptReviewedIntegration:host.acceptReviewedIntegration,
|
|
660
691
|
checkpoint:()=>store.snapshot().revision,close:()=>store.close()};
|
|
661
692
|
}catch(error){store.close();throw error;}
|
|
662
693
|
}
|
|
@@ -678,7 +709,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
678
709
|
// Config diagnostics contain field names/reasons, never field values or provider text.
|
|
679
710
|
const code=typeof cause.code==='string'&&(/^[a-z_]+$/.test(cause.code)
|
|
680
711
|
||cause.code.startsWith('invalid_config: '))?cause.code:'control_failed';
|
|
681
|
-
const reason=code==='runner_invocation'&&typeof cause.reason==='string'?cause.reason:null;
|
|
712
|
+
const reason=(code==='runner_invocation'||EXECUTOR_REASON_CODES.has(code))&&typeof cause.reason==='string'?cause.reason:null;
|
|
682
713
|
error.write(JSON.stringify({error:{code,...(reason?{reason}:{})}})+'\n');return 1;
|
|
683
714
|
}finally{run?.close();}
|
|
684
715
|
}
|
|
@@ -178,6 +178,18 @@ test(`trusted host execution uses the same entry and sole gate: ${mode} nested=$
|
|
|
178
178
|
if(repaired)assert.equal(JSON.parse(stdout).result.identity.attempt,2);
|
|
179
179
|
if(mode==='spec_drift')assert.equal(JSON.parse(stdout).result.code,'spec_drift');
|
|
180
180
|
if(mode==='review_limit')assert.equal(JSON.parse(stdout).result.code,'review_limit');
|
|
181
|
+
if(mode==='review_limit'){
|
|
182
|
+
// Decision card built from the replayed journal: both rounds, the real check
|
|
183
|
+
// run and the changed files; read-only and with no third round offered.
|
|
184
|
+
const card=JSON.parse(stdout).result.reviewLimitCard;
|
|
185
|
+
assert.equal(card.authorizationGranted,false);assert.equal(card.dispatchedCalls,0);assert.deepEqual(card.missing,[]);
|
|
186
|
+
assert.deepEqual(card.rounds.map(r=>[r.attempt,r.verdict,r.findings[0].path]),[[1,'changes_requested','a.js'],[2,'changes_requested','a.js']]);
|
|
187
|
+
assert.equal(card.rounds[1].findings[0].sameFileAsRound1,true);
|
|
188
|
+
assert.deepEqual(card.checks,{fromAttempt:2,fromReview:2,items:[{id:'content',outcome:'passed'}]});
|
|
189
|
+
assert(card.changes.items.some(c=>c.path==='a.js'&&c.kind==='modified'));
|
|
190
|
+
assert.deepEqual(card.exits.map(e=>[e.id,e.available]),[['supersede',true],['spec_change',true],['review_continuation',false],['human_correction',false]]);
|
|
191
|
+
assert.equal(JSON.parse(stdout).result.guidance.recoveryOperation,null);
|
|
192
|
+
}
|
|
181
193
|
assert.equal(fs.readFileSync(path.join(f.specsDir,'1.login','tasks.md'),'utf8').includes('[x]'),completed);
|
|
182
194
|
assert(fs.existsSync(path.join(f.specsDir,'.reviews','login-T-001-a1-handoff.json')));
|
|
183
195
|
assert.equal(f.invoke('resume',[request('status')]).status,1);
|
|
@@ -342,6 +354,20 @@ test('duplicate paths reject before writes and a genuine empty initializer can r
|
|
|
342
354
|
assert.equal(resumed.rows[0].result.state,'pending_review');
|
|
343
355
|
}));
|
|
344
356
|
|
|
357
|
+
// Reviews q1/q2: the N6 cadence a created runner freezes. A new batch's member keeps
|
|
358
|
+
// feature-v1 even when it resumes an empty store; a pre-qa_cadence batch never gets it.
|
|
359
|
+
test('runner QA cadence choice for created, empty-store and batch member runs',async()=>{
|
|
360
|
+
const {runnerQaCadence}=await import('./cm-ai-run.mjs');
|
|
361
|
+
assert.deepEqual(runnerQaCadence({runnerMode:'create',mode:'create'}),{});
|
|
362
|
+
assert.deepEqual(runnerQaCadence({runnerMode:'create',mode:'resume'}),{qaCadence:false});
|
|
363
|
+
assert.deepEqual(runnerQaCadence({runnerMode:'resume',mode:'resume'}),{});
|
|
364
|
+
assert.deepEqual(runnerQaCadence({runnerMode:'create',mode:'resume',batchQaCadence:'feature-v1'}),{});
|
|
365
|
+
assert.deepEqual(runnerQaCadence({runnerMode:'create',mode:'create',batchQaCadence:'legacy'}),{qaCadence:false});
|
|
366
|
+
assert.deepEqual(runnerQaCadence({runnerMode:'create',mode:'resume',batchQaCadence:'legacy'}),{qaCadence:false});
|
|
367
|
+
assert.deepEqual(runnerQaCadence({runnerMode:'resume',mode:'resume',batchQaCadence:'legacy'}),{});
|
|
368
|
+
assert.throws(()=>runnerQaCadence({runnerMode:'create',mode:'create',batchQaCadence:'other'}),/batchQaCadence/);
|
|
369
|
+
});
|
|
370
|
+
|
|
345
371
|
test('configuration object key order does not change durable identity', {skip:!platform},()=>fixture(async f=>{
|
|
346
372
|
assert.equal(f.invoke('create',[request('status')]).status,0);
|
|
347
373
|
const reordered=Object.fromEntries(Object.entries(f.definition).reverse());
|
|
@@ -24,6 +24,7 @@ import {abandonEffectPlanError,buildCmAiDriveRequest,buildCmAiDriveHostArgs} fro
|
|
|
24
24
|
import {spawn as spawnChild,spawnSync} from 'node:child_process';
|
|
25
25
|
import {createDeveloperRun} from '../runtime/js/cm-ai/developer-adapter.mjs';
|
|
26
26
|
import {readProcessStartTime} from '../runtime/js/cm-ai/worker-process-identity.mjs';
|
|
27
|
+
import {withFreshCompletionChecks} from './fixtures/fresh-completion-checks.mjs';
|
|
27
28
|
|
|
28
29
|
// Never write the real ~/.cm-workflow home or its global log from this suite.
|
|
29
30
|
const isolatedHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-supersede-home-'));
|
|
@@ -662,7 +663,7 @@ test('out-of-scope delivery names the paths and re-checks after they are removed
|
|
|
662
663
|
// A42: a completion re-check answering with another check list than the reviewed
|
|
663
664
|
// package is a retryable completion_checks_changed naming both lists; older
|
|
664
665
|
// journals with the terminal package_mismatch shape replay the same way.
|
|
665
|
-
test('completion check-list mismatch is retryable and legacy package_mismatch replays as completion_checks_changed',async()=>{
|
|
666
|
+
test('completion check-list mismatch is retryable and legacy package_mismatch replays as completion_checks_changed',t=>withFreshCompletionChecks(()=>(async()=>{
|
|
666
667
|
const f=runFixture();
|
|
667
668
|
try{
|
|
668
669
|
const runId='completion-check-list',identity=identityFor(runId),content='written\n';
|
|
@@ -707,7 +708,7 @@ test('completion check-list mismatch is retryable and legacy package_mismatch re
|
|
|
707
708
|
assert.equal(completed.state,'fixture_completed',JSON.stringify(completed));
|
|
708
709
|
}finally{run.close();}
|
|
709
710
|
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
710
|
-
});
|
|
711
|
+
})(t)));
|
|
711
712
|
|
|
712
713
|
test('effect-interrupted replay binds intent and last record; forged and duplicate records are refused',async()=>{
|
|
713
714
|
const f=runFixture();
|
|
@@ -1083,6 +1084,13 @@ test('explicit restart archives reviewed bytes and records a new-run authorizati
|
|
|
1083
1084
|
const events=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse)
|
|
1084
1085
|
.filter(row=>row.event==='supersede'&&row.run_id==='run-three-0003');
|
|
1085
1086
|
assert.equal(events.length,1);
|
|
1087
|
+
// How the replaced run ended is logged as a separate diagnostic row, so the
|
|
1088
|
+
// restart event keeps its historical content and id.
|
|
1089
|
+
assert.equal(Object.hasOwn(events[0],'predecessor_outcomes'),false);
|
|
1090
|
+
const causes=fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse)
|
|
1091
|
+
.filter(row=>row.event==='supersede_cause'&&row.run_id==='run-three-0003');
|
|
1092
|
+
assert.equal(causes.length,1);assert.equal(causes[0].diagnostic,true);assert.equal(causes[0].record_digest,events[0].record_digest);
|
|
1093
|
+
assert.deepEqual(causes[0].causes,{[[first.state,first.code].filter(Boolean).join('/')]:1});
|
|
1086
1094
|
}finally{fs.rmSync(f.root,{recursive:true,force:true});}
|
|
1087
1095
|
});
|
|
1088
1096
|
|
|
@@ -66,7 +66,7 @@ function started(f,...extra){
|
|
|
66
66
|
const runDir=path.join(f.specsDir,'.reviews','.execution',identity.runId);
|
|
67
67
|
assert(fs.statSync(path.join(runDir,'writer.sqlite')).isFile());
|
|
68
68
|
const state=JSON.parse(fs.readFileSync(path.join(runDir,'state.json'),'utf8'));
|
|
69
|
-
assert.equal(state.version,1);assert.deepEqual(state.identity,{repositoryId:identity.repositoryId,runId:identity.runId});
|
|
69
|
+
assert.equal(state.version,2);assert.equal(state.createdBy.version,1);assert.deepEqual(state.identity,{repositoryId:identity.repositoryId,runId:identity.runId});
|
|
70
70
|
return state;
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -195,6 +195,60 @@ test('a Claude-compatible installation waives only the Codex-owned halves and st
|
|
|
195
195
|
assert.deepEqual(report.result.checks.filter(row=>row.status==='not_applicable').map(row=>row.id),[1,7]);
|
|
196
196
|
});
|
|
197
197
|
|
|
198
|
+
// 回归点:扩展名外的文本文件(claude-compat 的 templates/cm-VERSION、钩子模板)曾不进摘要,
|
|
199
|
+
// 第 7 组唯一的版本标志引用必被判 check_evidence_invalid(2026-12 实跑 0.25.0 被卡住)。
|
|
200
|
+
test('extensionless markers such as templates/cm-VERSION and hook templates are citable and drift-checked',{timeout:8000},async t=>{
|
|
201
|
+
const prepare=()=>{
|
|
202
|
+
const f=fixture(t);
|
|
203
|
+
fs.mkdirSync(path.join(f.dir,'templates/hooks'),{recursive:true});
|
|
204
|
+
fs.writeFileSync(path.join(f.dir,'templates/cm-VERSION'),'9.9.9\n');
|
|
205
|
+
fs.writeFileSync(path.join(f.dir,'templates/hooks/pre-commit-cm-task-check'),'#!/bin/sh\nexit 0\n');
|
|
206
|
+
return f;
|
|
207
|
+
};
|
|
208
|
+
const cite=value=>{
|
|
209
|
+
value.checks.find(check=>check.id===7).evidence=[{path:'templates/cm-VERSION',line:1}];
|
|
210
|
+
value.checks.find(check=>check.id===6).evidence=[{path:'templates/hooks/pre-commit-cm-task-check',line:2}];
|
|
211
|
+
return value;
|
|
212
|
+
};
|
|
213
|
+
let f=prepare();
|
|
214
|
+
let report=await createCmCheckHost(f.input,{call:async(kind,payload)=>kind==='check_runtime'?mechanical(payload):cite(assessment(payload))})
|
|
215
|
+
.handle({requestId:'ext-1',operation:'start'});
|
|
216
|
+
assert.equal(report.result.overall,'PASSED',JSON.stringify(report.result));
|
|
217
|
+
f=prepare();
|
|
218
|
+
report=await createCmCheckHost(f.input,{call:async(kind,payload)=>{
|
|
219
|
+
if(kind==='check_runtime')return mechanical(payload);
|
|
220
|
+
fs.writeFileSync(path.join(f.dir,'templates/cm-VERSION'),'9.9.8\n');
|
|
221
|
+
return cite(assessment(payload));
|
|
222
|
+
}}).handle({requestId:'ext-2',operation:'start'});
|
|
223
|
+
assert.equal(report.result.overall,'BLOCKED',JSON.stringify(report.result));
|
|
224
|
+
assert.equal(report.result.reason,'check_source_changed','a same-length edit to the version marker must count as drift');
|
|
225
|
+
f=prepare();
|
|
226
|
+
report=await createCmCheckHost(f.input,{call:async(kind,payload)=>{
|
|
227
|
+
if(kind==='check_runtime')return mechanical(payload);
|
|
228
|
+
const value=cite(assessment(payload));value.checks.find(check=>check.id===7).evidence=[{path:'templates/cm-VERSION',line:9}];return value;
|
|
229
|
+
}}).handle({requestId:'ext-3',operation:'start'});
|
|
230
|
+
assert.equal(report.result.reason,'check_evidence_invalid','a line past the end of the marker is still refused');
|
|
231
|
+
f=prepare();fs.writeFileSync(path.join(f.dir,'templates/.DS_Store'),'aaaa');
|
|
232
|
+
report=await createCmCheckHost(f.input,{call:async(kind,payload)=>{
|
|
233
|
+
if(kind==='check_runtime')return mechanical(payload);
|
|
234
|
+
fs.writeFileSync(path.join(f.dir,'templates/.DS_Store'),'bbbb');
|
|
235
|
+
return cite(assessment(payload));
|
|
236
|
+
}}).handle({requestId:'ext-4',operation:'start'});
|
|
237
|
+
assert.equal(report.result.overall,'PASSED','Finder rewriting a same-size dotfile mid-check is not drift: '+JSON.stringify(report.result));
|
|
238
|
+
// 第三方技能里无扩展名、不可读的文件仍只记元数据,不能拖垮整次检查。
|
|
239
|
+
f=prepare();fs.mkdirSync(path.join(f.dir,'skills/third-party'),{recursive:true});
|
|
240
|
+
const locked=path.join(f.dir,'skills/third-party/blob');fs.writeFileSync(locked,'secret');fs.chmodSync(locked,0o000);
|
|
241
|
+
t.after(()=>fs.existsSync(locked)&&fs.chmodSync(locked,0o600));
|
|
242
|
+
report=await createCmCheckHost(f.input,{call:async(kind,payload)=>kind==='check_runtime'?mechanical(payload):cite(assessment(payload))})
|
|
243
|
+
.handle({requestId:'ext-5',operation:'start'});
|
|
244
|
+
assert.equal(report.result.overall,'PASSED','an unreadable third-party extensionless file must not block: '+JSON.stringify(report.result));
|
|
245
|
+
// 二进制的 templates 标志只查漂移,不能冒充文本证据。
|
|
246
|
+
f=prepare();fs.writeFileSync(path.join(f.dir,'templates/cm-VERSION'),Buffer.from([0x39,0x0a,0x00,0xff,0x0a]));
|
|
247
|
+
report=await createCmCheckHost(f.input,{call:async(kind,payload)=>kind==='check_runtime'?mechanical(payload):cite(assessment(payload))})
|
|
248
|
+
.handle({requestId:'ext-6',operation:'start'});
|
|
249
|
+
assert.equal(report.result.reason,'check_evidence_invalid','a binary marker cannot be cited as text');
|
|
250
|
+
});
|
|
251
|
+
|
|
198
252
|
test('not_applicable is refused outside the mode-scoped groups and when findings are missing',{timeout:5000},async t=>{
|
|
199
253
|
for(const mutate of [
|
|
200
254
|
value=>{const row=value.checks.find(check=>check.id===3);row.status='not_applicable';row.evidence=[];row.findings=['not a mode-scoped group'];},
|
|
@@ -3,6 +3,9 @@ set -euo pipefail
|
|
|
3
3
|
|
|
4
4
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
5
5
|
FAILURES=0
|
|
6
|
+
# Substring test without a pipe or temp file: under pipefail, `printf | grep -q`
|
|
7
|
+
# can fail with SIGPIPE, and bash 3.2 here-strings need a writable temp dir.
|
|
8
|
+
contains() { case "$1" in *"$2"*) return 0 ;; esac; return 1; }
|
|
6
9
|
|
|
7
10
|
fail() {
|
|
8
11
|
echo "FAIL: $*" >&2
|
|
@@ -308,6 +311,15 @@ done
|
|
|
308
311
|
for consumer in runtime/js/cm-ai/task-runner.mjs runtime/js/cm-ai/durable-runner-state.mjs scripts/cm-ai-development-rework.test.mjs; do
|
|
309
312
|
grep -q 'development-rework-authorized' "$ROOT/$consumer" || fail "missing development rework journal pairing: $consumer"
|
|
310
313
|
done
|
|
314
|
+
require_file "runtime/js/cm-ai/review-continuation.mjs"
|
|
315
|
+
require_file "scripts/cm-ai-review-continuation.test.mjs"
|
|
316
|
+
for consumer in scripts/cm-ai-host.mjs scripts/cm-ai-drive.mjs runtime/js/cm-ai/operator-guidance.mjs "$CONTROL_POLICY_DOC"; do
|
|
317
|
+
grep -q 'review-continuation-reason' "$ROOT/$consumer" || fail "missing review continuation launch consumer: $consumer"
|
|
318
|
+
done
|
|
319
|
+
for consumer in runtime/js/cm-ai/task-runner.mjs runtime/js/cm-ai/durable-runner-state.mjs scripts/cm-ai-review-continuation.test.mjs; do
|
|
320
|
+
grep -q 'review-continuation-authorized' "$ROOT/$consumer" || fail "missing review continuation journal pairing: $consumer"
|
|
321
|
+
done
|
|
322
|
+
grep -q 'REVIEW_CONTINUATION_MARKER_PROTOCOL' "$ROOT/scripts/cm-task-gate.mjs" || fail "missing runner-owned correction marker check"
|
|
311
323
|
require_file "runtime/js/cm-ai/scope-revision.mjs"
|
|
312
324
|
require_file "scripts/cm-ai-scope-revision.test.mjs"
|
|
313
325
|
for consumer in runtime/js/cm-ai/control-policy.mjs runtime/js/cm-ai/host-session.mjs \
|
|
@@ -544,8 +556,8 @@ grep -q "never satisfies N4" "$ROOT/runtime/external-expert.md" ||
|
|
|
544
556
|
fail "external-expert can be mistaken for independent review"
|
|
545
557
|
grep -Fq "Version 1 external-expert evidence never satisfies" "$ROOT/runtime/review.md" ||
|
|
546
558
|
fail "independent review contract does not exclude external-expert evidence"
|
|
547
|
-
tr -d '\r' < "$ROOT/runtime/review.md" | tr '\n' ' '
|
|
548
|
-
|
|
559
|
+
review_flat="$(tr -d '\r' < "$ROOT/runtime/review.md" | tr '\n' ' ')" || review_flat=""
|
|
560
|
+
contains "$review_flat" "A conversation that contributed to the plan, diagnosis, tests, or patch is an authoring channel" ||
|
|
549
561
|
fail "independent review contract does not preserve all external authoring categories"
|
|
550
562
|
grep -Fq '{SPECS_DIR}/.external/' "$ROOT/runtime/external-expert.md" ||
|
|
551
563
|
fail "external-expert has no isolated evidence location"
|
|
@@ -750,14 +762,14 @@ prd_spec_review_section=$(sed -n '/^### Step 10\.6:/,/^### Step 11:/p' \
|
|
|
750
762
|
"$ROOT/skills/cm-prd/SKILL.md")
|
|
751
763
|
[ "$(printf '%s' "$prd_design_review_section" | grep -Fc 'ROUND_LIMIT=1')" -eq 1 ] &&
|
|
752
764
|
[ "$(printf '%s' "$prd_spec_review_section" | grep -Fc 'ROUND_LIMIT=1')" -eq 1 ] &&
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
765
|
+
contains "$prd_design_review_section" '后续 10.5 自检' &&
|
|
766
|
+
contains "$prd_spec_review_section" '重跑一次 10.5 自检' &&
|
|
767
|
+
contains "$prd_design_review_section" '禁止 review → 修正 → 再 review' &&
|
|
768
|
+
contains "$prd_spec_review_section" '禁止 review → 修正 → 再 review' &&
|
|
769
|
+
contains "$prd_design_review_section" '包括 `self-degraded`' &&
|
|
770
|
+
contains "$prd_spec_review_section" '包括 `self-degraded`' &&
|
|
771
|
+
contains "$prd_design_review_section" '不得生成 `design-r2.md`' &&
|
|
772
|
+
contains "$prd_spec_review_section" '不得生成 `split-r2.md`' &&
|
|
761
773
|
grep -Fq 'cm-prd Step 9.5/10.6 固定为一次审查调用' \
|
|
762
774
|
"$ROOT/runtime/review.md" &&
|
|
763
775
|
grep -Fq 'The rules in this section apply to N4 reviews of implemented task diffs.' \
|
|
@@ -765,10 +777,10 @@ prd_spec_review_section=$(sed -n '/^### Step 10\.6:/,/^### Step 11:/p' \
|
|
|
765
777
|
grep -Fq 'Maximum two review rounds per task.' "$ROOT/runtime/review.md" &&
|
|
766
778
|
grep -Fq 'reviewer/independent/at/scope' "$ROOT/runtime/review.md" ||
|
|
767
779
|
fail "cm-prd pre-implementation reviews are not mechanically limited to one round"
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
780
|
+
contains "$prd_design_review_section" 'cm-prd-review-gate.py inspect --stage design' &&
|
|
781
|
+
contains "$prd_spec_review_section" 'cm-prd-review-gate.py inspect --stage split' &&
|
|
782
|
+
contains "$prd_design_review_section" 'resume_disposition' &&
|
|
783
|
+
contains "$prd_spec_review_section" 'resume_disposition' &&
|
|
772
784
|
grep -Fq 'r1 内容哈希漂移' "$ROOT/runtime/review.md" ||
|
|
773
785
|
fail "cm-prd single-round reviews have no crash-safe disposition recovery gate"
|
|
774
786
|
|
|
@@ -1049,7 +1061,7 @@ done
|
|
|
1049
1061
|
|
|
1050
1062
|
while IFS= read -r skill; do
|
|
1051
1063
|
dir="$(basename "$(dirname "$skill")")"
|
|
1052
|
-
declared="$(sed -n 's/^name:[[:space:]]*//p' "$skill" |
|
|
1064
|
+
declared="$(sed -n 's/^name:[[:space:]]*//p' "$skill" | sed -n '1p' | tr -d '\r\"')"
|
|
1053
1065
|
[ "$declared" = "$dir" ] || fail "skill name mismatch: ${skill#$ROOT/} declares '$declared'"
|
|
1054
1066
|
done < <(find "$ROOT/skills" -mindepth 2 -maxdepth 2 -name SKILL.md -type f | sort)
|
|
1055
1067
|
|