@aibyzero/cm-workflow 0.21.7 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +52 -0
- package/README.md +10 -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 +36 -10
- package/docs/js-workflow-control.md +65 -30
- 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/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 +23 -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-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-correction.mjs +65 -5
- package/runtime/js/cm-prd/review-disposition.mjs +10 -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 +55 -9
- package/scripts/cm-ai-batch-host.test.mjs +22 -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 +435 -33
- 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 +16 -8
- 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-runtime.sh +9 -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-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 +89 -20
- package/scripts/cm-prd-drive.test.mjs +109 -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 +11 -4
- 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-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/fixtures/fresh-completion-checks.mjs +8 -0
- package/scripts/fixtures/prd-review-gate-python-oracle.py +9 -0
- package/scripts/policy-binding-compat.test.mjs +3 -2
- package/scripts/test-cm-prd-review-gate.py +25 -0
- 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 +4 -1
- package/skills/cm-ai/references/js-host.md +17 -8
- 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
|
@@ -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
|
|
|
@@ -308,6 +308,15 @@ done
|
|
|
308
308
|
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
309
|
grep -q 'development-rework-authorized' "$ROOT/$consumer" || fail "missing development rework journal pairing: $consumer"
|
|
310
310
|
done
|
|
311
|
+
require_file "runtime/js/cm-ai/review-continuation.mjs"
|
|
312
|
+
require_file "scripts/cm-ai-review-continuation.test.mjs"
|
|
313
|
+
for consumer in scripts/cm-ai-host.mjs scripts/cm-ai-drive.mjs runtime/js/cm-ai/operator-guidance.mjs "$CONTROL_POLICY_DOC"; do
|
|
314
|
+
grep -q 'review-continuation-reason' "$ROOT/$consumer" || fail "missing review continuation launch consumer: $consumer"
|
|
315
|
+
done
|
|
316
|
+
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
|
|
317
|
+
grep -q 'review-continuation-authorized' "$ROOT/$consumer" || fail "missing review continuation journal pairing: $consumer"
|
|
318
|
+
done
|
|
319
|
+
grep -q 'REVIEW_CONTINUATION_MARKER_PROTOCOL' "$ROOT/scripts/cm-task-gate.mjs" || fail "missing runner-owned correction marker check"
|
|
311
320
|
require_file "runtime/js/cm-ai/scope-revision.mjs"
|
|
312
321
|
require_file "scripts/cm-ai-scope-revision.test.mjs"
|
|
313
322
|
for consumer in runtime/js/cm-ai/control-policy.mjs runtime/js/cm-ai/host-session.mjs \
|
|
@@ -19,7 +19,8 @@ const INPUT_LIMIT=1048576,marker='\n<cm-review-data-json>\n';
|
|
|
19
19
|
// clause added after #223, so its digest differs from the #223-era value.
|
|
20
20
|
// Re-pinned deliberately when the reviewer instructions gained the requirement-evidence rule,
|
|
21
21
|
// and again when they gained the cm-host-replay-v1 rule (host-observed baseline/red record).
|
|
22
|
-
|
|
22
|
+
// Re-pinned deliberately when the verdict rules required a concrete reachable input for every P0-P2 finding (bd972a8).
|
|
23
|
+
const LEGACY_PREFIX_SHA='9cfb8912d9323c181e53982183804b4ba153fb6757298350135911556c0539f8';
|
|
23
24
|
const sha=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
24
25
|
const checks=[{id:'unit',command:['node','synthetic-unit.mjs'],outcome:'passed',exitCode:0,evidence:'Synthetic unit evidence, not a command execution'},
|
|
25
26
|
{id:'boundary',command:['node','synthetic-boundary.mjs'],outcome:'passed',exitCode:0,evidence:'Synthetic boundary evidence, not a provider call'}];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// The developer must see the reviewer's own rejection rules before it returns
|
|
2
|
+
// (2026-11-28: 169 of 172 second rounds across 5 projects came from first-review
|
|
3
|
+
// changes_requested, mostly defects a self-check finds). Guards that the prompt
|
|
4
|
+
// carries the shared VERDICT_RULES and the checklist, not a drifting copy.
|
|
5
|
+
import test from 'node:test';
|
|
6
|
+
import assert from 'node:assert/strict';
|
|
7
|
+
// Load the runner first: it reaches the developer adapter through an import cycle.
|
|
8
|
+
import '../runtime/js/cm-ai/task-runner.mjs';
|
|
9
|
+
import {SELF_REVIEW,buildDeveloperPrompt} from '../runtime/js/cm-ai/developer-adapter.mjs';
|
|
10
|
+
import {VERDICT_RULES} from '../runtime/js/cm-ai/review-verdict-rules.mjs';
|
|
11
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
12
|
+
|
|
13
|
+
function request(payload){
|
|
14
|
+
const body={version:1,invocationId:'inv-1',identity:{repositoryId:'repo',runId:'run-1',taskId:'T-001',attempt:2},
|
|
15
|
+
role:'developer',provider:'codex',requestedModel:'m',contextId:'ctx-1',payload};
|
|
16
|
+
return {...body,requestDigest:digest(body)};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
test('developer prompt carries the reviewer verdict rules and the self-review checklist',()=>{
|
|
20
|
+
assert.ok(SELF_REVIEW.includes(VERDICT_RULES),'self-review must embed the exact reviewer rules');
|
|
21
|
+
const prompt=buildDeveloperPrompt(request({scope:['src/a.js'],requirements:[],priorReview:null}),'codex');
|
|
22
|
+
assert.ok(prompt.includes(SELF_REVIEW),'every developer prompt must include the self-review section');
|
|
23
|
+
for(const phrase of ['failure and cancellation branch','out-of-order responses','real entry point',
|
|
24
|
+
'device, simulator or browser walkthrough','same defect class'])assert.ok(prompt.includes(phrase),phrase);
|
|
25
|
+
// The checklist sits before the data block, so task data cannot displace it.
|
|
26
|
+
assert.ok(prompt.indexOf(SELF_REVIEW)<prompt.indexOf('<cm-developer-data-json>'));
|
|
27
|
+
});
|
|
@@ -192,9 +192,10 @@ test('default and V1 prompts match the frozen pre-V2 bytes for both existing ada
|
|
|
192
192
|
// wording. These exact hashes came from each adapter before this change; they were
|
|
193
193
|
// re-pinned deliberately when the reviewer instructions gained the
|
|
194
194
|
// requirement-evidence rule (cm-requirement-evidence-v1), and again when they
|
|
195
|
-
// gained the host-replay rule (cm-host-replay-v1)
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
// gained the host-replay rule (cm-host-replay-v1), and again when the verdict
|
|
196
|
+
// rules required a concrete reachable input for every P0-P2 finding (bd972a8).
|
|
197
|
+
const expected={full:new Set(['50ca577f390ddb6ebf0f336a4c60f68e1070f07df1edc70f567ac37542878003']),
|
|
198
|
+
v1:new Set(['9176e11b924230ca4003d4ed2b59f5e1404087a25dd6599762438ee2a64ba909'])};
|
|
198
199
|
for(const provider of ['claude','codex']){
|
|
199
200
|
const request=reviewRequest(provider),full=buildReviewPrompt(request,provider);
|
|
200
201
|
assert.equal(full,buildReviewPrompt(request,provider,null));
|
|
@@ -83,7 +83,8 @@ test('unknown original call stays unknown and cannot be repaired or redispatched
|
|
|
83
83
|
test('legacy session is byte-preserved and cannot acquire optimization policy',t=>{
|
|
84
84
|
const f=fixture(t,{legacy:true});let s=f.open();s.checkpoint({original:true});s.close();const before=fs.readFileSync(f.stateFile);
|
|
85
85
|
assert.throws(()=>f.open(true),/execution_policy_legacy_run/);assert.deepEqual(fs.readFileSync(f.stateFile),before);
|
|
86
|
-
|
|
86
|
+
// Created without a policy: format 3 since 0.22.0 (format 1 before), never gaining one.
|
|
87
|
+
s=f.open(false);assert.equal(s.state.version,3);assert(!Object.hasOwn(s.state,'executionPolicy'));s.close();
|
|
87
88
|
});
|
|
88
89
|
test('real host transport routes repair without invoking a review channel',async t=>{
|
|
89
90
|
const f=fixture(t),s=f.open();s.begin({operation:'final_review',mode:'independent',stage:'split',feature:'1.guide'},null);
|