@aibyzero/cm-workflow 0.16.7 → 0.16.9
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 +37 -0
- package/README.md +39 -3
- package/VERSION +1 -1
- package/assets/readme/workflow-recovery-detailed.png +0 -0
- package/assets/readme/workflow-stages-detailed.png +0 -0
- package/compat/claude-commands/cm-notify.md +3 -0
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +61 -4
- package/docs/next-steps.md +8 -2
- package/docs/user-guide.md +204 -0
- package/package.json +2 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +49 -13
- package/runtime/js/cm-ai/cm-ai-admission.mjs +3 -1
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +138 -26
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +142 -21
- package/runtime/js/cm-ai/code-projects.mjs +4 -1
- package/runtime/js/cm-ai/codex-review-adapter.mjs +2 -1
- package/runtime/js/cm-ai/developer-adapter.mjs +7 -0
- package/runtime/js/cm-ai/drive-core.mjs +26 -4
- package/runtime/js/cm-ai/durable-runner-state.mjs +951 -43
- package/runtime/js/cm-ai/effect-abandon-log.mjs +5 -2
- package/runtime/js/cm-ai/effect-contract.mjs +6 -1
- package/runtime/js/cm-ai/execution-store.mjs +4 -2
- package/runtime/js/cm-ai/external-run-guard.mjs +18 -7
- package/runtime/js/cm-ai/host-check.mjs +4 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +11 -4
- package/runtime/js/cm-ai/host-documentation.mjs +53 -12
- package/runtime/js/cm-ai/host-project-execution.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-executor.mjs +86 -17
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +44 -9
- package/runtime/js/cm-ai/host-session.mjs +47 -7
- package/runtime/js/cm-ai/host-tool-bridge.mjs +55 -6
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +4 -2
- package/runtime/js/cm-ai/operator-guidance.mjs +112 -3
- package/runtime/js/cm-ai/provider-review-observation.mjs +50 -0
- package/runtime/js/cm-ai/qa-resource-release.mjs +46 -0
- package/runtime/js/cm-ai/qa-round-budget.mjs +13 -0
- package/runtime/js/cm-ai/review-dispatch-limits.mjs +18 -0
- package/runtime/js/cm-ai/review-package.mjs +10 -1
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +29 -6
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +1 -1
- package/runtime/js/cm-ai/task-commit.mjs +39 -0
- package/runtime/js/cm-ai/task-runner.mjs +636 -65
- package/runtime/js/cm-ai/worker-claude-developer.mjs +9 -0
- package/runtime/js/cm-ai/worker-claude.mjs +10 -3
- package/runtime/js/cm-ai/worker-process-identity.mjs +43 -0
- package/runtime/js/cm-fix/cause-package.mjs +37 -8
- package/runtime/js/cm-fix/diagnosis.mjs +43 -0
- package/runtime/js/cm-fix/execution.mjs +356 -187
- package/runtime/js/cm-fix/host.mjs +2 -1
- package/runtime/js/cm-fix/investigation.mjs +25 -9
- package/runtime/js/cm-fix/pinned-baseline.mjs +24 -0
- package/runtime/js/cm-fix/progress.mjs +15 -3
- package/runtime/js/cm-fix/protected-edits.mjs +10 -3
- package/runtime/js/cm-fix/repair.mjs +11 -3
- package/runtime/js/cm-fix/test-author.mjs +10 -3
- package/runtime/js/cm-idea/session.mjs +67 -4
- package/runtime/js/cm-prd/review-correction.mjs +10 -4
- package/runtime/js/cm-prd/session.mjs +43 -0
- package/runtime/js/cm-refactor/records.mjs +98 -8
- package/runtime/js/cm-refactor/workflow.mjs +79 -9
- package/runtime/js/cm-test/host.mjs +10 -3
- package/runtime/js/cm-test/session.mjs +45 -6
- package/runtime/js/notify-run.mjs +26 -0
- package/runtime/js/notify-safe-read.mjs +49 -0
- package/runtime/js/notify-send.mjs +312 -0
- package/runtime/js/notify.mjs +492 -0
- package/runtime/js/policy-binding-compat.mjs +54 -0
- package/runtime/model-efficiency.md +17 -0
- package/scripts/ci-test-shards.mjs +67 -0
- package/scripts/ci-test-shards.test.mjs +64 -0
- package/scripts/ci-test-weights.json +222 -0
- package/scripts/cm-ai-abandon-effect-position.test.mjs +70 -2
- package/scripts/cm-ai-answer-gap-dispatch.test.mjs +86 -0
- package/scripts/cm-ai-answer-gap-driver.test.mjs +51 -0
- package/scripts/cm-ai-answer-gap-fixture.mjs +96 -0
- package/scripts/cm-ai-answer-gap-recheck.test.mjs +70 -0
- package/scripts/cm-ai-answer-gap-redo.test.mjs +103 -0
- package/scripts/cm-ai-batch-drive.mjs +55 -10
- package/scripts/cm-ai-batch-drive.test.mjs +65 -0
- package/scripts/cm-ai-batch-host.mjs +132 -13
- package/scripts/cm-ai-batch-host.test.mjs +255 -7
- package/scripts/cm-ai-batch-run-fixture.mjs +499 -0
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +38 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +7 -0
- package/scripts/cm-ai-batch-run-reschedule.test.mjs +17 -0
- package/scripts/cm-ai-batch-run.mjs +189 -22
- package/scripts/cm-ai-batch-run.test.mjs +22 -334
- package/scripts/cm-ai-develop-answer-invalid.test.mjs +104 -0
- package/scripts/cm-ai-develop-call-timeout.test.mjs +153 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +4 -3
- package/scripts/cm-ai-documentation-sync-gap.test.mjs +424 -0
- package/scripts/cm-ai-drive.mjs +68 -23
- package/scripts/cm-ai-drive.test.mjs +37 -2
- package/scripts/cm-ai-fix-run-delivery.test.mjs +138 -0
- package/scripts/cm-ai-host-cli-workflow.test.mjs +271 -0
- package/scripts/cm-ai-host-fixture.mjs +268 -0
- package/scripts/cm-ai-host-protected.test.mjs +251 -0
- package/scripts/cm-ai-host.mjs +28 -16
- package/scripts/cm-ai-host.test.mjs +17 -759
- package/scripts/cm-ai-light-modules.test.mjs +57 -0
- package/scripts/cm-ai-operator-guidance.test.mjs +30 -5
- package/scripts/cm-ai-project-qa-gate.test.mjs +71 -4
- package/scripts/cm-ai-protected-scope.test.mjs +7 -3
- package/scripts/cm-ai-qa-answer-gaps.test.mjs +99 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +78 -11
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +127 -8
- package/scripts/cm-ai-review-dispatch-exit.test.mjs +475 -0
- package/scripts/cm-ai-review-failure.test.mjs +124 -13
- package/scripts/cm-ai-review-timeout.test.mjs +188 -10
- package/scripts/cm-ai-run.mjs +15 -6
- package/scripts/cm-ai-supersede.test.mjs +486 -41
- package/scripts/cm-check-drive-files.mjs +8 -0
- package/scripts/cm-check-drive.test.mjs +2 -5
- package/scripts/cm-check-runtime.sh +4 -2
- package/scripts/cm-claude-developer-worker.test.mjs +15 -0
- package/scripts/cm-claude-review-stream.test.mjs +21 -16
- package/scripts/cm-claude-review-synthetic.test.mjs +155 -0
- package/scripts/cm-claude-worker.test.mjs +18 -2
- package/scripts/cm-external-model-recovery.test.mjs +29 -3
- package/scripts/cm-fix-abandon.test.mjs +249 -10
- package/scripts/cm-fix-cause-package.test.mjs +33 -0
- package/scripts/cm-fix-drive-unprotected.test.mjs +37 -0
- package/scripts/cm-fix-drive.mjs +34 -8
- package/scripts/cm-fix-host.mjs +8 -7
- package/scripts/cm-fix-rediagnosis.test.mjs +71 -4
- package/scripts/cm-fix-review-budget.test.mjs +13 -0
- package/scripts/cm-fix-review-recovery.test.mjs +35 -0
- package/scripts/cm-host-answer-timeout.test.mjs +65 -0
- package/scripts/cm-host-call-kinds.test.mjs +28 -0
- package/scripts/cm-host-documentation.test.mjs +49 -0
- package/scripts/cm-host-qa-executor.test.mjs +143 -10
- package/scripts/cm-idea-answer-gaps.test.mjs +164 -0
- package/scripts/cm-idea-drive.mjs +49 -11
- package/scripts/cm-idea-drive.test.mjs +66 -0
- package/scripts/cm-idea-host.mjs +106 -16
- package/scripts/cm-init-answer-gaps.test.mjs +258 -0
- package/scripts/cm-init-drive.mjs +41 -7
- package/scripts/cm-init-host.mjs +61 -12
- package/scripts/cm-log-event.mjs +49 -12
- package/scripts/cm-notify-command.test.mjs +900 -0
- package/scripts/cm-notify-read-drift.test.mjs +205 -0
- package/scripts/cm-notify.mjs +469 -0
- package/scripts/cm-notify.test.mjs +685 -0
- package/scripts/cm-patrol.mjs +83 -0
- package/scripts/cm-patrol.test.mjs +161 -0
- package/scripts/cm-prd-answer-gaps.test.mjs +216 -0
- package/scripts/cm-prd-drive.mjs +18 -5
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-host.mjs +37 -4
- package/scripts/cm-prd-review-disposition.test.mjs +6 -1
- package/scripts/cm-prd-review-gate.mjs +56 -0
- package/scripts/cm-refactor-answer-gaps.test.mjs +206 -0
- package/scripts/cm-refactor-drive.mjs +52 -8
- package/scripts/cm-refactor-drive.test.mjs +44 -0
- package/scripts/cm-refactor-host.test.mjs +10 -6
- package/scripts/cm-release-smoke.sh +2 -0
- package/scripts/cm-test-answer-gaps.test.mjs +151 -0
- package/scripts/cm-test-drive.mjs +21 -5
- package/scripts/cm-token-report.mjs +497 -0
- package/scripts/cm-token-report.test.mjs +346 -0
- package/scripts/fixtures/claude-review-process.mjs +1 -1
- package/scripts/policy-binding-compat.test.mjs +99 -0
- package/scripts/scan-public-safety.py +4 -0
- package/scripts/validate-public-repo.py +4 -0
- package/skills/cm-ai/SKILL.md +7 -3
- package/skills/cm-ai/references/N6-qa-eval.md +2 -2
- package/skills/cm-ai/references/js-host-modes.md +90 -0
- package/skills/cm-ai/references/js-host-qa-recovery.md +136 -0
- package/skills/cm-ai/references/js-host-recovery.md +311 -0
- package/skills/cm-ai/references/js-host.md +76 -331
- package/skills/cm-check/SKILL.md +3 -3
- package/skills/cm-fix/SKILL.md +2 -0
- package/skills/cm-fix/references/js-host.md +56 -10
- package/skills/cm-idea/references/js-host.md +27 -2
- package/skills/cm-init/references/js-host.md +16 -3
- package/skills/cm-notify/SKILL.md +34 -0
- package/skills/cm-prd/SKILL.md +2 -0
- package/skills/cm-prd/references/js-change-recovery.md +35 -1
- package/skills/cm-refactor/references/js-host.md +17 -0
- package/skills/cm-test/references/js-host.md +14 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// The partial runtime scripts/cm-check-drive.test.mjs copies into a temp dir. Shared so the light-module
|
|
2
|
+
// guard (cm-ai-light-modules.test.mjs) imports operator-guidance.mjs from exactly this copy.
|
|
3
|
+
export const CHECK_DRIVE_COPIED_FILES=Object.freeze([
|
|
4
|
+
'scripts/cm-check-entry.mjs','scripts/cm-check-host.mjs','scripts/cm-check-drive.mjs',
|
|
5
|
+
'scripts/cm-workflow-config.mjs','runtime/js/cm-check/host.mjs','runtime/js/cm-ai/drive-core.mjs',
|
|
6
|
+
'runtime/js/cm-ai/operator-guidance.mjs','runtime/js/cm-ai/review-dispatch-limits.mjs',
|
|
7
|
+
'runtime/js/cm-ai/host-tool-bridge.mjs','runtime/js/cm-ai/host-session.mjs','runtime/js/cm-ai/diagnostic-reason.mjs','runtime/js/cm-ai/effect-contract.mjs',
|
|
8
|
+
'runtime/js/cm-ai/contracts.mjs','runtime/js/cm-init/draft-inspection.mjs','skills/cm-check/SKILL.md']);
|
|
@@ -5,16 +5,13 @@ import os from 'node:os';
|
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import {spawnSync} from 'node:child_process';
|
|
7
7
|
import {fileURLToPath} from 'node:url';
|
|
8
|
+
import {CHECK_DRIVE_COPIED_FILES} from './cm-check-drive-files.mjs';
|
|
8
9
|
|
|
9
10
|
const root=fileURLToPath(new URL('..',import.meta.url));
|
|
10
11
|
function fixture(t,exit=0){
|
|
11
12
|
const dir=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-check-drive-')));
|
|
12
13
|
t.after(()=>fs.rmSync(dir,{recursive:true,force:true}));
|
|
13
|
-
for(const file of
|
|
14
|
-
'scripts/cm-workflow-config.mjs','runtime/js/cm-check/host.mjs','runtime/js/cm-ai/drive-core.mjs',
|
|
15
|
-
'runtime/js/cm-ai/operator-guidance.mjs',
|
|
16
|
-
'runtime/js/cm-ai/host-tool-bridge.mjs','runtime/js/cm-ai/host-session.mjs','runtime/js/cm-ai/diagnostic-reason.mjs','runtime/js/cm-ai/effect-contract.mjs',
|
|
17
|
-
'runtime/js/cm-ai/contracts.mjs','runtime/js/cm-init/draft-inspection.mjs','skills/cm-check/SKILL.md']){
|
|
14
|
+
for(const file of CHECK_DRIVE_COPIED_FILES){
|
|
18
15
|
fs.mkdirSync(path.dirname(path.join(dir,file)),{recursive:true});fs.copyFileSync(path.join(root,file),path.join(dir,file));
|
|
19
16
|
}
|
|
20
17
|
fs.writeFileSync(path.join(dir,'VERSION'),'0.0.0\n');fs.writeFileSync(path.join(dir,'README.md'),'# Fixture\n');
|
|
@@ -284,13 +284,15 @@ for module in \
|
|
|
284
284
|
durable-runner-state.mjs effect-contract.mjs execution-store.mjs gate-bridge.mjs \
|
|
285
285
|
host.mjs host-session.mjs diagnostic-reason.mjs index.mjs provider-review-observation.mjs review-package.mjs \
|
|
286
286
|
review-result.schema.json review-runner.mjs task-commit-codec.mjs task-commit.mjs \
|
|
287
|
-
task-owner.mjs task-runner.mjs worker-codex.mjs; do
|
|
287
|
+
task-owner.mjs task-runner.mjs worker-codex.mjs operator-guidance.mjs review-dispatch-limits.mjs; do
|
|
288
288
|
require_file "runtime/js/cm-ai/$module"
|
|
289
289
|
done
|
|
290
290
|
require_file "scripts/cm-check-runtime.ps1"
|
|
291
291
|
require_file "scripts/cm-security.mjs"
|
|
292
292
|
require_file "scripts/cm-security.test.mjs"
|
|
293
293
|
require_file "runtime/js/cm-security/scan.mjs"
|
|
294
|
+
require_file "scripts/cm-notify.mjs"
|
|
295
|
+
require_file "runtime/js/notify-send.mjs"
|
|
294
296
|
require_file "scripts/cm-check-update.mjs"
|
|
295
297
|
require_file "scripts/cm-check-update.test.mjs"
|
|
296
298
|
require_file "scripts/cm-release-smoke.sh"
|
|
@@ -650,7 +652,7 @@ for consumer in \
|
|
|
650
652
|
fail "external-expert AUTO routing is not wired into $consumer"
|
|
651
653
|
done
|
|
652
654
|
|
|
653
|
-
for name in cm-idea cm-init cm-prd cm-ai cm-test cm-security cm-fix cm-refactor cm-check cm-runtime; do
|
|
655
|
+
for name in cm-idea cm-init cm-prd cm-ai cm-test cm-security cm-fix cm-refactor cm-check cm-runtime cm-notify; do
|
|
654
656
|
require_file "skills/$name/SKILL.md"
|
|
655
657
|
require_file "compat/claude-commands/$name.md"
|
|
656
658
|
wrapper="$ROOT/compat/claude-commands/$name.md"
|
|
@@ -275,3 +275,18 @@ test('proposal validation preserves schema fields and strict success/failure bra
|
|
|
275
275
|
assert.throws(()=>validateClaudeProposal(invalid),undefined,JSON.stringify(invalid));
|
|
276
276
|
}
|
|
277
277
|
});
|
|
278
|
+
|
|
279
|
+
// The developer stream admits the same CLI-authored reminders as the review stream.
|
|
280
|
+
test('developer stream treats a synthetic CLI reminder as a notice, except between a tool call and its result',async t=>{
|
|
281
|
+
const root=fixture(t),control={signal:new AbortController().signal};
|
|
282
|
+
const synthetic={type:'user',session_id:'synthetic-claude-developer',parent_tool_use_id:null,isSynthetic:true,
|
|
283
|
+
message:{role:'user',content:[{type:'text',text:'[structured-output-enforce] You MUST call the StructuredOutput tool.'}]}};
|
|
284
|
+
const baseline=await fakeWorker(root)({prompt:prompt()},control);
|
|
285
|
+
const notices=[];
|
|
286
|
+
const reminded=await fakeWorker(root,{noticeEvents:[synthetic],noticeAt:1,onNotice:n=>notices.push(n)})({prompt:prompt()},control);
|
|
287
|
+
assert.deepEqual(reminded,baseline);
|
|
288
|
+
assert.deepEqual(notices,[{kind:'claude_system_notice',subtype:'synthetic_user'}]);
|
|
289
|
+
const pending=await fakeWorker(root,{mode:'read',noticeEvents:[synthetic],noticeAt:2})({prompt:prompt()},control);
|
|
290
|
+
assert.equal(pending.code,'unexpected_tool_or_content');
|
|
291
|
+
assert.deepEqual(fs.readdirSync(root),[]);
|
|
292
|
+
});
|
|
@@ -10,19 +10,25 @@ const transcript = () => [
|
|
|
10
10
|
num_turns:1, structured_output:{verdict:'approved'}},
|
|
11
11
|
];
|
|
12
12
|
test('Claude result maps to original observer syntax, never invents process close', () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
const events=[], stream=createClaudeReviewStream(event=>events.push(event));
|
|
14
|
+
transcript().forEach(message=>stream.accept(message));
|
|
15
|
+
assert.deepEqual(stream.finish(), {status:'succeeded',value:{verdict:'approved'}});
|
|
16
|
+
assert.deepEqual(events,[
|
|
17
|
+
{event:'thread.started',provider_thread:'fresh-review'},
|
|
18
|
+
{event:'turn.started',item_type:null},
|
|
19
|
+
{event:'item.completed',item_type:'agent_message'},
|
|
20
|
+
{event:'turn.completed',item_type:null},
|
|
21
|
+
]);
|
|
22
|
+
});
|
|
23
|
+
// The verdict is only ever structured_output: prose in `result`, even valid
|
|
24
|
+
// JSON, is never parsed as one (a reviewer that answered in text has not answered).
|
|
25
|
+
test('result text is never a verdict without structured_output', () => {
|
|
26
|
+
const events=[], stream=createClaudeReviewStream(event=>events.push(event));
|
|
27
|
+
const messages=transcript();delete messages[2].structured_output;messages[2].result='{"verdict":"approved"}';
|
|
28
|
+
messages.slice(0,2).forEach(message=>stream.accept(message));
|
|
29
|
+
assert.throws(()=>stream.accept(messages[2]),{code:'invalid_output_json'});
|
|
30
|
+
assert.throws(()=>stream.finish(),{code:'incomplete_result'});
|
|
31
|
+
assert.deepEqual(events,[{event:'thread.started',provider_thread:'fresh-review'},{event:'turn.started',item_type:null}]);
|
|
26
32
|
});
|
|
27
33
|
test('wrong session, tools, child agents, errors, repeated or incomplete terminals fail closed', () => {
|
|
28
34
|
const mutations=[
|
|
@@ -113,13 +119,12 @@ const rateLimit = (overrides={}) => ({type:'rate_limit_event',session_id:'fresh-
|
|
|
113
119
|
nested:{text:'private provider payload'},list:['private provider payload']},...overrides});
|
|
114
120
|
const expectedNotice = {kind:'rate_limit',info:{status:'allowed',rateLimitType:'five_hour',
|
|
115
121
|
resetsAt:123,active:true,reason:null}};
|
|
116
|
-
test('rate limit notices preserve
|
|
122
|
+
test('rate limit notices preserve stage and exact observer events',()=>{
|
|
117
123
|
const baseline=[],original=createClaudeReviewStream(e=>baseline.push(e));
|
|
118
124
|
transcript().forEach(m=>original.accept(m));
|
|
119
|
-
for(const
|
|
125
|
+
for(const count of [1,8,32]){
|
|
120
126
|
const events=[],notices=[],stream=createClaudeReviewStream(e=>events.push(e),n=>notices.push(n));
|
|
121
127
|
const messages=transcript();
|
|
122
|
-
if(!structured){delete messages[2].structured_output;messages[2].result='{"verdict":"approved"}';}
|
|
123
128
|
stream.accept(messages[0]);
|
|
124
129
|
for(let i=0;i<count;i++){
|
|
125
130
|
if(i===1)stream.accept(messages[1]);
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import {createClaudeReviewStream} from '../runtime/js/cm-ai/claude-review-stream.mjs';
|
|
4
|
+
import {reviewerBoundaryExit,abandonableReviewerExit,REVIEWER_REJECTION_CHECKS} from '../runtime/js/cm-ai/provider-review-observation.mjs';
|
|
5
|
+
|
|
6
|
+
// Claude CLI 2.1.x injects user-role reminders of its own (isSynthetic: true):
|
|
7
|
+
// e.g. "[structured-output-enforce] You MUST call the StructuredOutput tool"
|
|
8
|
+
// after a text-only answer, or "[Your previous response had no visible
|
|
9
|
+
// output…]" after a thinking-only one. The model cannot author user messages.
|
|
10
|
+
// They carry no verdict and run nothing, so the decoder counts them as notices
|
|
11
|
+
// and ignores their body instead of killing the reviewer (the T-009 incident).
|
|
12
|
+
const init=()=>({type:'system',subtype:'init',session_id:'fresh-review'});
|
|
13
|
+
const assistant=content=>({type:'assistant',session_id:'fresh-review',parent_tool_use_id:null,message:{role:'assistant',content}});
|
|
14
|
+
const text=t=>({type:'text',text:t});
|
|
15
|
+
const tool=(id,name='StructuredOutput')=>({type:'tool_use',id,name,input:{}});
|
|
16
|
+
const toolResult=(id,is_error=false)=>({type:'user',session_id:'fresh-review',parent_tool_use_id:null,
|
|
17
|
+
message:{role:'user',content:[{type:'tool_result',tool_use_id:id,is_error,content:'synthetic result'}]}});
|
|
18
|
+
const synthetic=(body='[structured-output-enforce] You MUST call the StructuredOutput tool to provide your final answer.',over={})=>({
|
|
19
|
+
type:'user',session_id:'fresh-review',parent_tool_use_id:null,isSynthetic:true,
|
|
20
|
+
message:{role:'user',content:[text(body)]},...over});
|
|
21
|
+
const result=(over={})=>({type:'result',subtype:'success',session_id:'fresh-review',is_error:false,num_turns:2,
|
|
22
|
+
structured_output:{verdict:'approved'},...over});
|
|
23
|
+
function run(messages){
|
|
24
|
+
const events=[],notices=[],stream=createClaudeReviewStream(e=>events.push(e),n=>notices.push(n));
|
|
25
|
+
messages.forEach(m=>stream.accept(m));
|
|
26
|
+
return {value:stream.finish(),events,notices};
|
|
27
|
+
}
|
|
28
|
+
function rejected(messages){
|
|
29
|
+
const stream=createClaudeReviewStream(()=>{});
|
|
30
|
+
try{messages.forEach(m=>stream.accept(m));}catch(error){return error;}
|
|
31
|
+
assert.fail('expected a rejection');
|
|
32
|
+
}
|
|
33
|
+
const OBSERVER=[{event:'thread.started',provider_thread:'fresh-review'},{event:'turn.started',item_type:null},
|
|
34
|
+
{event:'item.completed',item_type:'agent_message'},{event:'turn.completed',item_type:null}];
|
|
35
|
+
|
|
36
|
+
test('a CLI reminder after text, after thinking only, or before any output is a notice; the verdict still comes from StructuredOutput',()=>{
|
|
37
|
+
const tail=[assistant([tool('out')]),toolResult('out'),result()];
|
|
38
|
+
const wires={
|
|
39
|
+
afterText:[init(),assistant([{type:'thinking',thinking:'private'}]),assistant([text('Review follows.')]),synthetic(),...tail],
|
|
40
|
+
afterThinking:[init(),assistant([{type:'thinking',thinking:'private'}]),synthetic('[Your previous response had no visible output. Please respond with text or tool calls.]'),...tail],
|
|
41
|
+
beforeOutput:[init(),synthetic(),...tail],
|
|
42
|
+
twice:[init(),assistant([text('a')]),synthetic(),assistant([text('b')]),synthetic('The previous response failed to produce a valid tool call. Try again.'),...tail],
|
|
43
|
+
};
|
|
44
|
+
for(const [name,wire] of Object.entries(wires)){
|
|
45
|
+
const {value,events,notices}=run(wire);
|
|
46
|
+
assert.deepEqual(value,{status:'succeeded',value:{verdict:'approved'}},name);
|
|
47
|
+
assert.deepEqual(events,OBSERVER,name);
|
|
48
|
+
assert.ok(notices.length>=1&¬ices.every(n=>n.kind==='claude_system_notice'&&n.subtype==='synthetic_user'&&!('text' in n)),name);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('a reminder never becomes a verdict: text in result after a reminder is invalid_output_json',()=>{
|
|
53
|
+
const error=rejected([init(),assistant([text('Review follows.')]),synthetic(),assistant([text('{"verdict":"approved"}')]),
|
|
54
|
+
{...result({num_turns:2}),structured_output:undefined,result:'{"verdict":"approved"}'}]);
|
|
55
|
+
assert.equal(error.code,'invalid_output_json');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('synthetic messages are narrowly admitted: shape, size, pending tools and the 32 notice slots',()=>{
|
|
59
|
+
const big='x'.repeat(1025);
|
|
60
|
+
for(const [name,message] of Object.entries({
|
|
61
|
+
twoBlocks:synthetic('a',{message:{role:'user',content:[text('a'),text('b')]}}),
|
|
62
|
+
notText:synthetic('a',{message:{role:'user',content:[{type:'image'}]}}),
|
|
63
|
+
tooLong:synthetic(big),
|
|
64
|
+
childAgent:synthetic('a',{parent_tool_use_id:'child'}),
|
|
65
|
+
wrongRole:synthetic('a',{message:{role:'assistant',content:[text('a')]}}),
|
|
66
|
+
noText:synthetic('a',{message:{role:'user',content:[{type:'text'}]}}),
|
|
67
|
+
})){
|
|
68
|
+
const error=rejected([init(),assistant([text('a')]),message]);
|
|
69
|
+
assert.equal(error.code,'unexpected_tool_or_content',name);
|
|
70
|
+
assert.deepEqual(error.detail,{k:'user_content',m:'user',b:name==='notText'?'image':name==='twoBlocks'||name==='tooLong'||name==='childAgent'||name==='wrongRole'||name==='noText'?'text':null,t:null,e:null},name);
|
|
71
|
+
}
|
|
72
|
+
// Nothing may be injected between a tool call and its result.
|
|
73
|
+
const pending=rejected([init(),assistant([tool('out')]),synthetic()]);
|
|
74
|
+
assert.equal(pending.code,'unexpected_tool_or_content');assert.equal(pending.detail.k,'user_content');
|
|
75
|
+
// A user text that the CLI did not mark synthetic is still a boundary break.
|
|
76
|
+
const unmarked=rejected([init(),assistant([text('a')]),synthetic('a',{isSynthetic:undefined})]);
|
|
77
|
+
assert.equal(unmarked.code,'unexpected_tool_or_content');assert.equal(unmarked.detail.k,'user_content');
|
|
78
|
+
// Notice slots are shared with rate limit and system notices.
|
|
79
|
+
const many=[init(),assistant([text('a')])];for(let i=0;i<32;i++)many.push(synthetic());
|
|
80
|
+
assert.equal(run([...many,assistant([tool('out')]),toolResult('out'),result()]).value.status,'succeeded');
|
|
81
|
+
assert.equal(rejected([...many,synthetic()]).code,'unexpected_event');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('every rejection point reports a fixed, body-free summary',()=>{
|
|
85
|
+
const cases=[
|
|
86
|
+
[[init(),assistant([])],{k:'empty_content',m:'assistant',b:null,t:null,e:null}],
|
|
87
|
+
[[init(),assistant([{type:'image'}])],{k:'block_type',m:'assistant',b:'image',t:null,e:null}],
|
|
88
|
+
[[init(),assistant([{type:'tool_use',name:'Bash'}])],{k:'block_type',m:'assistant',b:'tool_use',t:'Bash',e:null}],
|
|
89
|
+
[[init(),assistant([tool('a'),tool('a','Bash')])],{k:'duplicate_tool_id',m:'assistant',b:'tool_use',t:'Bash',e:null}],
|
|
90
|
+
[[init(),{...toolResult('a'),message:{role:'user',content:[]}}],{k:'user_content',m:'user',b:null,t:null,e:null}],
|
|
91
|
+
[[init(),{...toolResult('a'),message:{role:'user',content:[text('tool succeeded')]}}],{k:'user_content',m:'user',b:'text',t:null,e:null}],
|
|
92
|
+
[[init(),toolResult('missing',true)],{k:'unknown_tool_result',m:'user',b:'tool_result',t:null,e:null}],
|
|
93
|
+
[[init(),assistant([tool('b','Bash')]),toolResult('b',false)],{k:'tool_result_not_error',m:'user',b:'tool_result',t:'Bash',e:false}],
|
|
94
|
+
[[init(),assistant([tool('b','Read')]),{...toolResult('b'),message:{role:'user',content:[{type:'tool_result',tool_use_id:'b',content:'x'}]}}],
|
|
95
|
+
{k:'tool_result_not_error',m:'user',b:'tool_result',t:'Read',e:null}],
|
|
96
|
+
];
|
|
97
|
+
for(const [wire,detail] of cases){
|
|
98
|
+
const error=rejected(wire);
|
|
99
|
+
assert.equal(error.code,'unexpected_tool_or_content');assert.deepEqual(error.detail,detail,JSON.stringify(detail));
|
|
100
|
+
assert.ok(!JSON.stringify(error.detail).includes('synthetic result'));
|
|
101
|
+
}
|
|
102
|
+
const limit=[init()];for(let i=0;i<17;i++)limit.push(assistant([tool(`d${i}`,'Bash')]),toolResult(`d${i}`,true));
|
|
103
|
+
assert.deepEqual(rejected(limit).detail,{k:'tool_attempt_limit',m:'assistant',b:'tool_use',t:'Bash',e:null});
|
|
104
|
+
// Hostile tool names and block types never reach the summary.
|
|
105
|
+
const hostile=rejected([init(),assistant([tool('h','Bash; rm -rf / '+'x'.repeat(80))]),toolResult('h',false)]);
|
|
106
|
+
assert.deepEqual(hostile.detail,{k:'tool_result_not_error',m:'user',b:'tool_result',t:null,e:false});
|
|
107
|
+
assert.deepEqual(rejected([init(),assistant([{type:'weird type!'}])]).detail,{k:'block_type',m:'assistant',b:null,t:null,e:null});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// The worker appends the summary to the base code; the observation reader
|
|
111
|
+
// parses it strictly and decides whether the operator may abandon the exit.
|
|
112
|
+
test('boundary exit codes parse strictly; only exits that cannot have run a tool, with the process closed and nothing received, are abandonable',()=>{
|
|
113
|
+
const suffix=d=>`unexpected_tool_or_content:${JSON.stringify(d)}`;
|
|
114
|
+
assert.deepEqual(reviewerBoundaryExit('unexpected_tool_or_content'),{check:null,message:null,block:null,tool:null,isError:null});
|
|
115
|
+
assert.deepEqual(reviewerBoundaryExit(suffix({k:'user_content',m:'user',b:'text',t:null,e:null})),{check:'user_content',message:'user',block:'text',tool:null,isError:null});
|
|
116
|
+
for(const bad of [null,'','timeout','unexpected_assistant','unexpected_tool_or_content:',
|
|
117
|
+
'unexpected_tool_or_content:{}',suffix({k:'bogus',m:'user',b:null,t:null,e:null}),suffix({k:'user_content',m:'system',b:null,t:null,e:null}),
|
|
118
|
+
suffix({k:'user_content',m:'user',b:'bad type',t:null,e:null}),suffix({k:'user_content',m:'user',b:null,t:'rm -rf',e:null}),
|
|
119
|
+
suffix({k:'user_content',m:'user',b:null,t:null,e:'true'}),suffix({k:'user_content',m:'user',b:null,t:null,e:null,x:1}),
|
|
120
|
+
suffix({k:'user_content',m:'user',b:null,t:null}),'unexpected_tool_or_content:[]','unexpected_tool_or_content:'+'{"k":"user_content","m":"user","b":null,"t":null,"e":null,"pad":"'+'x'.repeat(300)+'"}'])
|
|
121
|
+
assert.equal(reviewerBoundaryExit(bad),null,String(bad).slice(0,60));
|
|
122
|
+
assert.deepEqual(REVIEWER_REJECTION_CHECKS,['empty_content','block_type','tool_attempt_limit','duplicate_tool_id','user_content','unknown_tool_result','tool_result_not_error']);
|
|
123
|
+
const closed={event:'process_closed',exit_code:null,signal:'SIGKILL',timed_out:false};
|
|
124
|
+
const started=[{event:'thread.started',provider_thread:'t'},{event:'turn.started',item_type:null}];
|
|
125
|
+
const observation=(code,events=[...started,closed],status='failed')=>({version:1,kind:'cm-provider-review-observation',requestDigest:'0'.repeat(64),events,result:{status,code}});
|
|
126
|
+
assert.equal(abandonableReviewerExit(observation('unexpected_tool_or_content')),true,'legacy code without summary');
|
|
127
|
+
for(const k of ['user_content','empty_content','tool_attempt_limit'])
|
|
128
|
+
assert.equal(abandonableReviewerExit(observation(suffix({k,m:'user',b:null,t:null,e:null}))),true,k);
|
|
129
|
+
for(const k of ['tool_result_not_error','unknown_tool_result','duplicate_tool_id','block_type'])
|
|
130
|
+
assert.equal(abandonableReviewerExit(observation(suffix({k,m:'user',b:null,t:null,e:null}))),false,k);
|
|
131
|
+
assert.equal(abandonableReviewerExit(observation('unexpected_tool_or_content',[...started])),false,'no process_closed');
|
|
132
|
+
assert.equal(abandonableReviewerExit(observation('unexpected_tool_or_content',[...started,{...closed,timed_out:true}])),false,'timed out');
|
|
133
|
+
assert.equal(abandonableReviewerExit(observation('unexpected_tool_or_content',[...started,{event:'item.completed',item_type:'agent_message'},closed])),false,'final message received');
|
|
134
|
+
assert.equal(abandonableReviewerExit(observation('unexpected_tool_or_content',[...started,{event:'turn.failed',item_type:null},closed])),false,'terminal observed');
|
|
135
|
+
assert.equal(abandonableReviewerExit(observation('unexpected_tool_or_content',[...started,closed],'cancelled')),false,'not failed');
|
|
136
|
+
assert.equal(abandonableReviewerExit(observation('output_limit')),false,'other code');
|
|
137
|
+
assert.equal(abandonableReviewerExit(observation('unexpected_tool_or_content',[{event:'bogus'}])),false,'invalid stream');
|
|
138
|
+
assert.equal(abandonableReviewerExit(null),false);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test('the 1024-byte limit is measured in UTF-8 bytes; synthetic, rate limit and system notices share the 32 slots',()=>{
|
|
142
|
+
const tail=[assistant([tool('out')]),toolResult('out'),result()];
|
|
143
|
+
const cjk='审'.repeat(341)+'x'; // 341*3+1 = 1024 bytes
|
|
144
|
+
assert.equal(run([init(),assistant([text('a')]),synthetic(cjk),...tail]).value.status,'succeeded');
|
|
145
|
+
assert.equal(rejected([init(),assistant([text('a')]),synthetic('审'.repeat(342))]).detail.k,'user_content'); // 1026 bytes
|
|
146
|
+
assert.equal(run([init(),assistant([text('a')]),synthetic('x'.repeat(1024)),...tail]).value.status,'succeeded');
|
|
147
|
+
const rateLimit=()=>({type:'rate_limit_event',session_id:'fresh-review',rate_limit_info:{status:'allowed'}});
|
|
148
|
+
const system=()=>({type:'system',subtype:'api_retry',session_id:'fresh-review',attempt:1});
|
|
149
|
+
const mixed=[init(),assistant([text('a')])];
|
|
150
|
+
for(let i=0;i<32;i++)mixed.push(i%3===0?synthetic():i%3===1?rateLimit():system());
|
|
151
|
+
const ok=run([...mixed,...tail]);
|
|
152
|
+
assert.equal(ok.value.status,'succeeded');assert.equal(ok.notices.length,32);
|
|
153
|
+
assert.equal(rejected([...mixed,synthetic()]).code,'unexpected_event');
|
|
154
|
+
assert.equal(rejected([...mixed,rateLimit()]).code,'unexpected_event');
|
|
155
|
+
});
|
|
@@ -14,7 +14,7 @@ const messages=[
|
|
|
14
14
|
{type:'system',subtype:'init',session_id:'fresh-review'},
|
|
15
15
|
{type:'assistant',session_id:'fresh-review',parent_tool_use_id:null,
|
|
16
16
|
message:{role:'assistant',content:[{type:'text',text:'review'}]}},
|
|
17
|
-
{type:'result',subtype:'success',session_id:'fresh-review',is_error:false,num_turns:1,result:'{"verdict":"approved"}'},
|
|
17
|
+
{type:'result',subtype:'success',session_id:'fresh-review',is_error:false,num_turns:1,structured_output:{verdict:'approved'},result:'{"verdict":"approved"}'},
|
|
18
18
|
];
|
|
19
19
|
test('review schema is canonical without metadata and invalidates legacy preflight fingerprint',()=>{
|
|
20
20
|
const args=claudeReviewArgs(config.model),index=args.indexOf('--json-schema');
|
|
@@ -59,7 +59,8 @@ test('successful forbidden tool triggers synchronous group SIGKILL without compl
|
|
|
59
59
|
assert.deepEqual(kills,[{pid:-12345,signal:'SIGKILL'}]);
|
|
60
60
|
},observed)});
|
|
61
61
|
const result=await worker({prompt:'synthetic'}, {signal:new AbortController().signal,onEvent:e=>events.push(e)});
|
|
62
|
-
|
|
62
|
+
// The base code is kept for callers; the suffix names what was rejected, never its content.
|
|
63
|
+
assert.deepEqual(result,{status:'failed',code:'unexpected_tool_or_content:{"k":"tool_result_not_error","m":"user","b":"tool_result","t":"Bash","e":false}'});
|
|
63
64
|
assert.ok(!events.some(e=>e.event==='turn.completed'||e.event==='item.completed'));
|
|
64
65
|
assert.equal(events.at(-1).signal,'SIGKILL');
|
|
65
66
|
});
|
|
@@ -206,3 +207,18 @@ test('worker forwards system notice summaries without changing result or observa
|
|
|
206
207
|
assert.deepEqual(await runMessages(wire),baseline);
|
|
207
208
|
assert.deepEqual(await runMessages(wire,()=>{throw Error('notice consumer');}),baseline);
|
|
208
209
|
});
|
|
210
|
+
|
|
211
|
+
// A CLI-authored reminder (isSynthetic user text) is a notice, not a boundary
|
|
212
|
+
// break: the worker neither kills the reviewer nor changes the observer events.
|
|
213
|
+
test('synthetic CLI reminder is reported as a notice; between a call and its result it is still rejected with a summary',async()=>{
|
|
214
|
+
const synthetic={type:'user',session_id:'fresh-review',parent_tool_use_id:null,isSynthetic:true,
|
|
215
|
+
message:{role:'user',content:[{type:'text',text:'[structured-output-enforce] You MUST call the StructuredOutput tool.'}]}};
|
|
216
|
+
const baseline=await runMessages(messages);
|
|
217
|
+
const notices=[];
|
|
218
|
+
const reminded=await runMessages([messages[0],messages[1],synthetic,{...messages[2],num_turns:2}],n=>notices.push(n));
|
|
219
|
+
assert.deepEqual(reminded.result,baseline.result);assert.deepEqual(reminded.events,baseline.events);
|
|
220
|
+
assert.deepEqual(notices,[{kind:'claude_system_notice',subtype:'synthetic_user'}]);
|
|
221
|
+
const pending=await runMessages([messages[0],{...messages[1],message:{role:'assistant',content:[{type:'tool_use',id:'out',name:'StructuredOutput',input:{}}]}},synthetic,messages[2]]);
|
|
222
|
+
assert.deepEqual(pending.result,{status:'failed',code:'unexpected_tool_or_content:{"k":"user_content","m":"user","b":"text","t":null,"e":null}'});
|
|
223
|
+
assert.ok(!pending.events.some(e=>e.event==='item.completed'));
|
|
224
|
+
});
|
|
@@ -11,6 +11,7 @@ import {readRunnerHistory} from '../runtime/js/cm-ai/durable-runner-state.mjs';
|
|
|
11
11
|
import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
12
12
|
import {writeHandoff,writeReview} from '../experiments/js-orchestration/native-gate-fixture.mjs';
|
|
13
13
|
import {acquireExternalRunGuard} from '../runtime/js/cm-ai/external-run-guard.mjs';
|
|
14
|
+
import {memberSupersedeAdmitted} from './cm-ai-batch-run.mjs';
|
|
14
15
|
const grant=(request,issuedAt)=>{
|
|
15
16
|
const value={version:1,kind:'cm-review-dispatch-grant',grantId:'grant-'+request.invocationId,adapterId:'codex-review-adapter',
|
|
16
17
|
invocationId:request.invocationId,requestDigest:request.requestDigest,identity:request.identity,reviewerId:'reviewer',logicalContextId:request.contextId,
|
|
@@ -44,7 +45,7 @@ async function fixture(fn,review,{strict=true,timeoutMs=2000,externalDeveloper=f
|
|
|
44
45
|
};
|
|
45
46
|
const effect=(kind,attempt=1,id=kind+'-'+attempt)=>({version:1,id,identity:{...identity,attempt},kind});
|
|
46
47
|
const guard=(override={})=>acquireExternalRunGuard({specsDir:specsRoot,codeProject:root,feature:'feature',identity:{...identity,runId:'another-run'},...override});
|
|
47
|
-
try{await fn({make:()=>make('create'),reopen,prefix,effect,records,guard,closeStore:()=>store.close(),calls:()=>calls,developerCalls:()=>developerCalls});}finally{store.close();fs.rmSync(tmp,{recursive:true,force:true});}
|
|
48
|
+
try{await fn({make:()=>make('create'),reopen,prefix,effect,records,guard,specsRoot,root,closeStore:()=>store.close(),calls:()=>calls,developerCalls:()=>developerCalls});}finally{store.close();fs.rmSync(tmp,{recursive:true,force:true});}
|
|
48
49
|
}
|
|
49
50
|
const start=(request,onEvent)=>{onEvent({event:'thread.started',provider_thread:'actual-review-'+request.identity.attempt});onEvent({event:'turn.started',item_type:null});};
|
|
50
51
|
const noTerminal=(request,{onEvent})=>{start(request,onEvent);onEvent({event:'process_closed',exit_code:143,signal:null,timed_out:true});return {status:'failed',code:'timeout'};};
|
|
@@ -67,7 +68,28 @@ for(const [name,review] of [['close without provider terminal',noTerminal],['out
|
|
|
67
68
|
assert.throws(()=>f.guard({identity:{repositoryId:'fixture',runId:'other-task-run',taskId:'T-002',attempt:1}}),{code:'external_prior_attempt_unresolved'});
|
|
68
69
|
assert.throws(()=>f.guard({feature:'other-feature',identity:{repositoryId:'fixture',runId:'other-feature-run',taskId:'T-002',attempt:1}}),{code:'external_prior_attempt_unresolved'});assert.equal(f.calls(),1);
|
|
69
70
|
const init=rows[0].payload;assert.equal(readRunnerHistory(rows,init.config,3).state.state,'unknown');
|
|
71
|
+
// Batch 4 review round 2: the batch's unresolved hint decides supersede from the same
|
|
72
|
+
// entry conditions as the guard above, so this strict raw-unknown run (which the
|
|
73
|
+
// supersede state check alone would take) is not sent to supersede.
|
|
74
|
+
assert.equal(memberSupersedeAdmitted(f.specsRoot,'strict-run',readRunnerHistory(rows,init.config,3)),false);
|
|
70
75
|
},review,{timeoutMs:40}));
|
|
76
|
+
// The same probe on a non-strict run left unknown: admitted. The supersede it names is
|
|
77
|
+
// an ordinary single-task launch; the guard such a launch takes when a strict binding
|
|
78
|
+
// exists on the root (strictOnly) does not refuse it. A strict
|
|
79
|
+
// new run would refuse any unresolved same-task prior run, so the hint names an
|
|
80
|
+
// ordinary launch.
|
|
81
|
+
test('a non-strict unknown run is admitted to supersede by the batch hint check and the guard alike',()=>fixture(async f=>{
|
|
82
|
+
const runner=f.make();await runner.executeEffect(f.effect('develop'));
|
|
83
|
+
const reviewed=await runner.executeEffect(f.effect('review'));assert.equal(reviewed.state,'unknown',JSON.stringify(reviewed));f.closeStore();
|
|
84
|
+
const rows=JSON.parse(fs.readFileSync(path.join(f.specsRoot,'.reviews/.execution/strict-run/state.json'),'utf8')).records;
|
|
85
|
+
const history=readRunnerHistory(rows,rows[0].payload.config,3);assert.equal(history.pending,null);
|
|
86
|
+
assert.equal(memberSupersedeAdmitted(f.specsRoot,'strict-run',history),true);
|
|
87
|
+
const identity={repositoryId:'fixture',runId:'another-run',taskId:'T-001',attempt:1};
|
|
88
|
+
acquireExternalRunGuard({specsDir:f.specsRoot,codeProject:f.root,feature:'feature',identity},{strictOnly:true}).close();
|
|
89
|
+
assert.throws(()=>acquireExternalRunGuard({specsDir:f.specsRoot,codeProject:f.root,feature:'feature',identity}),{code:'external_prior_attempt_unresolved'});
|
|
90
|
+
// (This runner fixture carries no task-learning feature, so the supersede check itself
|
|
91
|
+
// is probed on a real batch member journal in cm-ai-batch-run.test.mjs.)
|
|
92
|
+
},(request,{onEvent})=>{onEvent({event:'thread.started',provider_thread:'review-lost'});throw Error('Synthetic lost reviewer');},{strict:false}));
|
|
71
93
|
for(const type of ['review-invocation-registered','review-invocation-started','review-invocation-result'])test(type+' crash prefix preserves original attempt and rejects old abandonment paths',()=>fixture(async f=>{
|
|
72
94
|
let runner=f.make();await runner.executeEffect(f.effect('develop'));await runner.executeEffect(f.effect('review'));runner=f.prefix(type);
|
|
73
95
|
assert.equal(runner.status().state,'unknown');assert.equal(runner.status().pendingReviewInvocation,undefined);assert.equal(runner.status().pendingEffectKind,undefined);
|
|
@@ -76,9 +98,13 @@ for(const type of ['review-invocation-registered','review-invocation-started','r
|
|
|
76
98
|
await runner.executeEffect(f.effect('review',1,'new-call'));assert.equal(f.calls(),1);assert.equal(JSON.stringify(f.records()),before);
|
|
77
99
|
assert.throws(f.guard,{code:'external_prior_attempt_unresolved'});
|
|
78
100
|
},noTerminal));
|
|
79
|
-
test('legacy missing marker
|
|
101
|
+
test('legacy missing marker keeps the local no-result redispatch contract (two per round)',()=>fixture(async f=>{
|
|
80
102
|
const runner=f.make();await runner.executeEffect(f.effect('develop'));assert.equal((await runner.executeEffect(f.effect('review'))).state,'pending_review');
|
|
81
|
-
|
|
103
|
+
const second=await runner.executeEffect(f.effect('review',1,'retry'));
|
|
104
|
+
assert.equal(second.state,'blocked');assert.equal(second.reviewRedispatchStopRequired,true);assert.equal(f.calls(),2);
|
|
105
|
+
assert.equal(runner.abandonReview({allowed:true,reason:'reviewer stopped'}).state,'pending_review');
|
|
106
|
+
const spent=await runner.executeEffect(f.effect('review',1,'retry-2'));
|
|
107
|
+
assert.equal(spent.state,'blocked');assert.equal(spent.code,'review_redispatch_limit');assert.equal(f.calls(),3);
|
|
82
108
|
},noTerminal,{strict:false}));
|
|
83
109
|
test('valid changes_requested permits a fresh separately authorized second attempt and completion',()=>fixture(async f=>{
|
|
84
110
|
const runner=f.make();await runner.executeEffect(f.effect('develop'));assert.equal((await runner.executeEffect(f.effect('review'))).state,'changes_requested');
|