@aibyzero/cm-workflow 0.16.8 → 0.17.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 +31 -0
- package/README.md +22 -3
- package/VERSION +1 -1
- package/compat/claude-commands/cm-notify.md +3 -0
- package/docs/cm-control-policy-v2.md +331 -0
- package/docs/execution-optimizations.md +1 -1
- package/docs/external-models.md +3 -3
- package/docs/human-correction.md +5 -5
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +119 -78
- package/docs/next-steps.md +19 -2
- package/docs/untested-branches.md +2 -3
- package/docs/user-guide.md +105 -5
- package/package.json +2 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +49 -13
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +103 -68
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +79 -27
- package/runtime/js/cm-ai/code-projects.mjs +4 -1
- package/runtime/js/cm-ai/control-policy.mjs +111 -0
- package/runtime/js/cm-ai/developer-adapter.mjs +7 -0
- package/runtime/js/cm-ai/drive-bootstrap.mjs +11 -8
- package/runtime/js/cm-ai/drive-core.mjs +9 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +883 -69
- 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/external-run-guard.mjs +18 -7
- package/runtime/js/cm-ai/gate-bridge.mjs +4 -4
- package/runtime/js/cm-ai/host-check.mjs +4 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +33 -24
- 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 +49 -4
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +53 -9
- package/runtime/js/cm-ai/host-qa-policy.mjs +63 -21
- package/runtime/js/cm-ai/host-review-authority.mjs +2 -2
- package/runtime/js/cm-ai/host-review-file.mjs +1 -1
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-tool-bridge.mjs +43 -3
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +21 -10
- package/runtime/js/cm-ai/host.mjs +1 -2
- package/runtime/js/cm-ai/operator-guidance.mjs +89 -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-package.mjs +26 -5
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +1 -1
- 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 +629 -121
- 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/execution.mjs +176 -48
- package/runtime/js/cm-fix/host.mjs +2 -1
- package/runtime/js/cm-fix/pinned-baseline.mjs +24 -0
- package/runtime/js/cm-fix/progress.mjs +13 -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-init/review-evidence.mjs +3 -1
- package/runtime/js/cm-prd/review-correction.mjs +10 -4
- package/runtime/js/cm-prd/review-host.mjs +1 -1
- package/runtime/js/cm-prd/review-publication.mjs +5 -3
- 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 +80 -10
- package/runtime/js/cm-test/host.mjs +10 -3
- package/runtime/js/cm-test/session.mjs +45 -6
- package/runtime/js/notify-safe-read.mjs +49 -0
- package/runtime/js/notify-send.mjs +313 -0
- package/runtime/js/notify.mjs +164 -37
- package/runtime/js/policy-binding-compat.mjs +55 -0
- package/runtime/review.md +52 -7
- package/runtime/task-gates.md +107 -9
- 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 +71 -10
- 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 +89 -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 +98 -34
- package/scripts/cm-ai-batch-drive.test.mjs +124 -16
- package/scripts/cm-ai-batch-host.mjs +167 -29
- package/scripts/cm-ai-batch-host.test.mjs +303 -31
- package/scripts/cm-ai-batch-run-fixture.mjs +452 -0
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +26 -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 +213 -25
- package/scripts/cm-ai-batch-run.test.mjs +21 -341
- package/scripts/cm-ai-bootstrap-flow.test.mjs +1 -7
- package/scripts/cm-ai-bootstrap.test.mjs +2 -3
- package/scripts/cm-ai-control-launch.test.mjs +219 -0
- package/scripts/cm-ai-control-policy.test.mjs +124 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +270 -0
- package/scripts/cm-ai-develop-answer-invalid.test.mjs +97 -0
- package/scripts/cm-ai-develop-call-timeout.test.mjs +146 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +37 -23
- package/scripts/cm-ai-direct-review.test.mjs +348 -0
- package/scripts/cm-ai-documentation-sync-gap.test.mjs +424 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +54 -25
- package/scripts/cm-ai-drive.mjs +142 -58
- package/scripts/cm-ai-drive.test.mjs +70 -84
- package/scripts/cm-ai-fix-integration.test.mjs +3 -5
- package/scripts/cm-ai-fix-later-delivery.test.mjs +3 -6
- package/scripts/cm-ai-fix-run-delivery.test.mjs +3 -6
- package/scripts/cm-ai-host-cli-workflow.test.mjs +267 -0
- package/scripts/cm-ai-host-fixture.mjs +296 -0
- package/scripts/cm-ai-host-protected.test.mjs +253 -0
- package/scripts/cm-ai-host.mjs +122 -100
- package/scripts/cm-ai-host.test.mjs +35 -776
- package/scripts/cm-ai-launch-diagnostics.test.mjs +5 -3
- package/scripts/cm-ai-legacy-history.test.mjs +53 -0
- package/scripts/cm-ai-light-modules.test.mjs +54 -0
- package/scripts/cm-ai-multi-root.test.mjs +4 -4
- package/scripts/cm-ai-nested-execution.test.mjs +16 -19
- package/scripts/cm-ai-operator-guidance.test.mjs +30 -5
- package/scripts/cm-ai-progress.test.mjs +10 -8
- package/scripts/cm-ai-project-qa-gate.test.mjs +37 -10
- package/scripts/cm-ai-protected-scope.test.mjs +8 -5
- package/scripts/cm-ai-qa-answer-gaps.test.mjs +99 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +1 -9
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +12 -9
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +95 -13
- package/scripts/cm-ai-qa-fixed-log.test.mjs +41 -0
- package/scripts/cm-ai-qa-recovery-args.test.mjs +7 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +59 -14
- package/scripts/cm-ai-review-drift-precedence.test.mjs +1 -1
- package/scripts/cm-ai-review-failure.test.mjs +137 -32
- package/scripts/cm-ai-review-timeout-config.test.mjs +3 -1
- package/scripts/cm-ai-review-timeout.test.mjs +132 -67
- package/scripts/cm-ai-run.mjs +91 -28
- package/scripts/cm-ai-run.test.mjs +11 -38
- package/scripts/cm-ai-selection-guard.test.mjs +2 -2
- package/scripts/cm-ai-session-chain.test.mjs +18 -15
- package/scripts/cm-ai-spec-rebind.test.mjs +14 -18
- package/scripts/cm-ai-supersede.test.mjs +489 -51
- package/scripts/cm-blocked-reason.test.mjs +2 -3
- package/scripts/cm-capability-gate.test.mjs +33 -1
- 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 +23 -5
- package/scripts/cm-controlled-correction.test.mjs +469 -0
- package/scripts/cm-external-batch-host.test.mjs +30 -11
- package/scripts/cm-external-model-host.test.mjs +1 -1
- package/scripts/cm-external-model-recovery.test.mjs +32 -12
- package/scripts/cm-external-qa-fix.test.mjs +1 -1
- package/scripts/cm-external-review-reconciliation.test.mjs +6 -24
- package/scripts/cm-fix-abandon.test.mjs +163 -10
- package/scripts/cm-fix-drive-unprotected.test.mjs +37 -0
- package/scripts/cm-fix-drive.mjs +25 -7
- package/scripts/cm-fix-host.mjs +8 -7
- package/scripts/cm-fix-review-budget.test.mjs +13 -0
- package/scripts/cm-fix-review-recovery.test.mjs +36 -1
- 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 +23 -12
- package/scripts/cm-host-qa-policy.test.mjs +43 -16
- package/scripts/cm-host-review-authority.test.mjs +0 -31
- 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-knowledge-closeout.test.mjs +3 -3
- package/scripts/cm-log-event.mjs +21 -10
- package/scripts/cm-notify-command.test.mjs +936 -0
- package/scripts/cm-notify-read-drift.test.mjs +270 -0
- package/scripts/cm-notify.mjs +481 -0
- package/scripts/cm-notify.test.mjs +312 -23
- package/scripts/cm-patrol.test.mjs +3 -2
- 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-task-gate-correction.test.mjs +69 -16
- package/scripts/cm-task-gate.mjs +368 -34
- package/scripts/cm-task-gate.py +2 -0
- package/scripts/cm-task-gate.test.mjs +252 -4
- package/scripts/cm-test-answer-gaps.test.mjs +151 -0
- package/scripts/cm-test-drive.mjs +21 -5
- package/scripts/fixtures/bootstrap-review-runner.mjs +1 -7
- package/scripts/fixtures/claude-review-process.mjs +1 -1
- package/scripts/fixtures/native-gate-fixture.mjs +18 -0
- package/scripts/policy-binding-compat.test.mjs +103 -0
- package/scripts/scan-public-safety.py +4 -0
- package/scripts/validate-public-repo.py +4 -0
- package/skills/cm-ai/SKILL.md +8 -6
- package/skills/cm-ai/references/N3-execute-task.md +17 -2
- package/skills/cm-ai/references/N4-review.md +11 -21
- package/skills/cm-ai/references/N5-mark-done.md +1 -1
- package/skills/cm-ai/references/N6-qa-eval.md +49 -21
- package/skills/cm-ai/references/js-host-modes.md +35 -14
- package/skills/cm-ai/references/js-host-qa-recovery.md +85 -11
- package/skills/cm-ai/references/js-host-recovery.md +181 -21
- package/skills/cm-ai/references/js-host.md +76 -32
- package/skills/cm-check/SKILL.md +3 -3
- package/skills/cm-fix/SKILL.md +12 -0
- package/skills/cm-fix/references/js-host.md +44 -5
- package/skills/cm-idea/references/js-host.md +27 -2
- package/skills/cm-init/references/js-host.md +17 -4
- package/skills/cm-notify/SKILL.md +34 -0
- package/skills/cm-prd/references/js-change-recovery.md +35 -1
- package/skills/cm-prd/references/js-host.md +1 -1
- package/skills/cm-refactor/SKILL.md +12 -0
- package/skills/cm-refactor/references/js-host.md +17 -0
- package/skills/cm-test/references/js-host.md +14 -1
|
@@ -95,6 +95,15 @@ function createClaudeDeveloperStream(onNotice=null,onUsageTerminal=null){
|
|
|
95
95
|
if(substantive)assistant=true;return;
|
|
96
96
|
}
|
|
97
97
|
if(event.type==='user'){
|
|
98
|
+
// CLI-authored reminder (see claude-review-stream.mjs): a notice, never content.
|
|
99
|
+
if(event.isSynthetic===true){
|
|
100
|
+
const c=event.message?.content;
|
|
101
|
+
need(event.parent_tool_use_id===null&&event.message?.role==='user'&&Array.isArray(c)&&c.length===1
|
|
102
|
+
&&c[0]?.type==='text'&&typeof c[0].text==='string'&&Buffer.byteLength(c[0].text,'utf8')<=1024&&tools.size===0,'unexpected_tool_or_content');
|
|
103
|
+
need(noticeCount<32,'unexpected_event');noticeCount++;
|
|
104
|
+
try{onNotice?.({kind:'claude_system_notice',subtype:'synthetic_user'});}catch{}
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
98
107
|
need(event.message?.role==='user'&&Array.isArray(event.message.content),'invalid_event');
|
|
99
108
|
for(const block of event.message.content){need(block.type==='tool_result'&&tools.has(block.tool_use_id),'unexpected_tool_or_content');tools.delete(block.tool_use_id);}
|
|
100
109
|
return;
|
|
@@ -59,7 +59,11 @@ export function claudeWorker({cwd,model,preflight,cli='claude',timeoutMs=60000,s
|
|
|
59
59
|
try { child=spawnProcess(cli,args,{cwd,env:claudeEnvironment(),stdio:['pipe','pipe','pipe'],detached:true}); }
|
|
60
60
|
catch { usage.complete();resolve({status:'failed',code:'spawn_failed'});return; }
|
|
61
61
|
let buffer='', bytes=0, failure=null, settled=false, timedOut=false, killTimer, pendingClose;
|
|
62
|
-
let providerThread=null,providerTerminal=false,failedTerminal=false,receiptInvalid=false;
|
|
62
|
+
let providerThread=null,providerTerminal=false,failedTerminal=false,receiptInvalid=false,failureDetail=null;
|
|
63
|
+
// The boundary code carries the stream's body-free summary so the record
|
|
64
|
+
// shows what was rejected; stop() and callers keep matching the base code.
|
|
65
|
+
const withDetail=code=>code==='unexpected_tool_or_content'&&failureDetail!==null
|
|
66
|
+
?`${code}:${JSON.stringify(failureDetail)}`:code;
|
|
63
67
|
const cleanupGroup=ownedProcessCleanup(child,{killProcess});
|
|
64
68
|
const providerFailure=()=>['provider_failed','reviewer_auth_failed','reviewer_billing_error',
|
|
65
69
|
'reviewer_rate_limited','reviewer_server_error','reviewer_model_not_found','reviewer_api_error'].includes(failure);
|
|
@@ -110,7 +114,10 @@ export function claudeWorker({cwd,model,preflight,cli='claude',timeoutMs=60000,s
|
|
|
110
114
|
&&Number.isInteger(message.num_turns)&&message.num_turns>=1&&message.num_turns<=20)usage.terminal(message.usage);
|
|
111
115
|
stream.accept(message);
|
|
112
116
|
}
|
|
113
|
-
catch (error) {
|
|
117
|
+
catch (error) {
|
|
118
|
+
if(failure===null&&error?.code==='unexpected_tool_or_content'&&error.detail)failureDetail=error.detail;
|
|
119
|
+
stop(error instanceof SyntaxError?'invalid_event':error.code??'invalid_event');
|
|
120
|
+
}
|
|
114
121
|
};
|
|
115
122
|
signal.addEventListener('abort',abort,{once:true});
|
|
116
123
|
if (signal.aborted) abort();
|
|
@@ -142,7 +149,7 @@ export function claudeWorker({cwd,model,preflight,cli='claude',timeoutMs=60000,s
|
|
|
142
149
|
else if(!receiptInvalid&&typeof onTerminal==='function'&&failedTerminal&&providerFailure())onTerminal({status:'failed',code:'provider_failed'});
|
|
143
150
|
if (signal.aborted) {resolve({status:'cancelled',code:'cancelled'});return;}
|
|
144
151
|
if (failure || code!==0 || exitSignal!==null) {
|
|
145
|
-
resolve({status:'failed',code:failure??'incomplete_result'});return;
|
|
152
|
+
resolve({status:'failed',code:withDetail(failure??'incomplete_result')});return;
|
|
146
153
|
}
|
|
147
154
|
try {resolve(stream.finish());}
|
|
148
155
|
catch(error){resolve({status:'failed',code:error.code??'incomplete_result'});}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Process identity of a detached provider worker (its pid is also its process
|
|
2
|
+
// group id) and the host's later check that the whole group is gone. Only a
|
|
3
|
+
// definite ESRCH, or a pid that now belongs to a process started at another
|
|
4
|
+
// time, proves "gone"; Windows, permission errors and unreadable start times
|
|
5
|
+
// stay "unknown" and never grant a redo.
|
|
6
|
+
import {spawnSync} from 'node:child_process';
|
|
7
|
+
|
|
8
|
+
export const MAX_START_TIME_LENGTH=64;
|
|
9
|
+
export const validWorkerPid=pid=>Number.isSafeInteger(pid)&&pid>1&&pid<=0x7fffffff;
|
|
10
|
+
export const validStartTime=value=>value===null||typeof value==='string'&&value.length>0
|
|
11
|
+
&&value.length<=MAX_START_TIME_LENGTH&&/^[\x20-\x7e]+$/.test(value);
|
|
12
|
+
|
|
13
|
+
// `ps -o lstart=` in the C locale: a stable, second-resolution start time.
|
|
14
|
+
export function readProcessStartTime(pid,{platform=process.platform,run=spawnSync}={}){
|
|
15
|
+
if(platform==='win32'||!validWorkerPid(pid))return null;
|
|
16
|
+
try{
|
|
17
|
+
const result=run('ps',['-o','lstart=','-p',String(pid)],{encoding:'utf8',timeout:5000,
|
|
18
|
+
env:{...process.env,LC_ALL:'C',LANG:'C'},maxBuffer:4096});
|
|
19
|
+
if(result.error||result.status!==0)return null;
|
|
20
|
+
const value=String(result.stdout).trim().replace(/\s+/g,' ');
|
|
21
|
+
return validStartTime(value)?value:null;
|
|
22
|
+
}catch{return null;}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 'gone' | 'alive' | 'unknown'
|
|
26
|
+
export function inspectWorkerGroup({pid,startTime},{platform=process.platform,kill=process.kill.bind(process),
|
|
27
|
+
startTimeOf=value=>readProcessStartTime(value,{platform})}={}){
|
|
28
|
+
if(platform==='win32'||!validWorkerPid(pid)||!validStartTime(startTime))return 'unknown';
|
|
29
|
+
const probe=target=>{try{kill(target,0);return 'present';}catch(error){return error?.code==='ESRCH'?'absent':'unknown';}};
|
|
30
|
+
const group=probe(-pid);
|
|
31
|
+
if(group==='absent')return 'gone';
|
|
32
|
+
if(group==='unknown')return 'unknown';
|
|
33
|
+
// A process group exists under this id. POSIX never reuses a pid while a
|
|
34
|
+
// group with that id still exists, so a leader started at another time
|
|
35
|
+
// means the recorded worker group ended before the pid was reused.
|
|
36
|
+
const leader=probe(pid);
|
|
37
|
+
if(leader==='unknown')return 'unknown';
|
|
38
|
+
if(leader==='absent')return 'alive';
|
|
39
|
+
if(startTime===null)return 'unknown';
|
|
40
|
+
const current=startTimeOf(pid);
|
|
41
|
+
if(current===null)return 'unknown';
|
|
42
|
+
return current===startTime?'alive':'gone';
|
|
43
|
+
}
|
|
@@ -66,22 +66,47 @@ function stepRecord(id){
|
|
|
66
66
|
return abandonable.has(pending)?{base:match[1],suffix:match[2],pending}:null;
|
|
67
67
|
}
|
|
68
68
|
const retryBase=id=>id.replace(/-retry-[1-8]-(intent|result)$/,'-$1');
|
|
69
|
+
// V2 (F09/F13/F14/F28): a redone write step keeps the review baseline its first
|
|
70
|
+
// intent captured. The abandon (or blocked-rerun) record says so with
|
|
71
|
+
// baselinePinned; the redo's intent must carry exactly that baseline, so the
|
|
72
|
+
// abandoned attempt's residue is part of the reviewed diff, never of the
|
|
73
|
+
// "before" image. Older journals without the marker replay unchanged.
|
|
74
|
+
const PINNED_STEPS=new Set(['test_author','repair','revision_test_author','revision_repair']);
|
|
75
|
+
// V10 (F15/F18/F20): a legitimate blocked verdict of a local step may be rerun
|
|
76
|
+
// with a reason, at most twice per step kind; the blocked result stays history.
|
|
77
|
+
const RERUNNABLE=Object.freeze({test_author_blocked:'test_author',repair_blocked:'repair',regression_blocked:'regression',
|
|
78
|
+
post_review_regression_blocked:'post_review_regression',walkthrough_blocked:'walkthrough',
|
|
79
|
+
revision_test_author_blocked:'revision_test_author',revision_repair_blocked:'revision_repair',
|
|
80
|
+
revision_regression_blocked:'revision_regression',revision_post_review_regression_blocked:'revision_post_review_regression',
|
|
81
|
+
revision_walkthrough_blocked:'revision_walkthrough'});
|
|
82
|
+
export const MAX_FIX_BLOCKED_RERUNS=2;
|
|
83
|
+
// Record numbers cover every legal rerun: two per step kind across all kinds.
|
|
84
|
+
const MAX_FIX_BLOCKED_RERUN_RECORDS=Object.keys(RERUNNABLE).length*MAX_FIX_BLOCKED_RERUNS;
|
|
85
|
+
const BLOCKED_RERUN_ID=/^fix-blocked-rerun-([1-9]\d?)$/;
|
|
86
|
+
const blockedRerunNumber=id=>{const match=BLOCKED_RERUN_ID.exec(id);
|
|
87
|
+
const n=match?Number(match[1]):0;return n>=1&&n<=MAX_FIX_BLOCKED_RERUN_RECORDS?n:0;};
|
|
69
88
|
const latestStepRecord=(records,id)=>[...records].reverse().find(row=>retryBase(row.id)===id);
|
|
70
89
|
// A cause or second-round final review that produced no review result may be
|
|
71
90
|
// abandoned once, audited, and dispatched again under its own record prefix.
|
|
72
91
|
// Each cause review round has its own one-time abandonment: round 1 under
|
|
73
92
|
// fix-cause-*, the post-rediagnosis round 2 under fix-cause-rediagnosis-*.
|
|
74
93
|
const REVIEW_ABANDON={cause_review:'fix-cause',revision_final_review:'fix-revision-final'};
|
|
94
|
+
// V5 (F23/F26): a second no-result abandonment per round (MAX_FIX_REVIEW_ABANDONS)
|
|
95
|
+
// is recorded as <prefix>-abandoned-2 and redispatched under <prefix>-retry-2-*.
|
|
96
|
+
export const MAX_FIX_REVIEW_ABANDONS=2;
|
|
97
|
+
export const FIX_REVIEW_RECOVERY_LIMIT_REASON=`fix_review_recovery_limit: 首轮最终审查的 worker 连续没有打开审查线程就丢失,无线程恢复已用满 ${MAX_FIX_REVIEW_ABANDONS} 次,不再续审。`
|
|
98
|
+
+'先查清审查 CLI 为何起不来(登录、额度、网络或本机环境),原运行记录保留不改写;修好后发 cancel 结束本运行,用新的 runId 重新发起修复。';
|
|
99
|
+
const cycleId=(prefix,rows,suffix)=>rows.some(row=>row.id===`${prefix}-abandoned-2`)?`${prefix}-retry-2-${suffix}`
|
|
100
|
+
:rows.some(row=>row.id===`${prefix}-abandoned`)?`${prefix}-retry-${suffix}`:`${prefix}-${suffix}`;
|
|
75
101
|
const causeRecord=(records,suffix)=>{
|
|
76
102
|
const marker=records.findIndex(row=>row.id==='fix-rediagnosis-intent');
|
|
77
|
-
const tail=marker<0?null:records.slice(marker+1)
|
|
103
|
+
const tail=marker<0?null:records.slice(marker+1);
|
|
78
104
|
const row=marker<0?reviewCycleRecord(records,'fix-cause',suffix)
|
|
79
|
-
:tail.find(row=>row.id
|
|
105
|
+
:tail.find(row=>row.id===cycleId('fix-cause-rediagnosis',tail,suffix));
|
|
80
106
|
return suffix==='result'?reconciledFixResultRecord(records,row):row;
|
|
81
107
|
};
|
|
82
108
|
const reviewCycleRecord=(records,prefix,suffix)=>{
|
|
83
|
-
const row=records.
|
|
84
|
-
?records.find(row=>row.id===`${prefix}-retry-${suffix}`):records.find(row=>row.id===`${prefix}-${suffix}`);
|
|
109
|
+
const row=records.find(row=>row.id===cycleId(prefix,records,suffix));
|
|
85
110
|
return suffix==='result'?reconciledFixResultRecord(records,row):row;
|
|
86
111
|
};
|
|
87
112
|
// Reviews wait for their own budget (host review configuration), never for the
|
|
@@ -199,12 +224,15 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
199
224
|
try{store=inspectionSnapshot?{snapshot:()=>inspectionSnapshot,close(){},append(){need(false,'fix_read_only');}}:openExecutionStore({specsRoot,identity:{repositoryId:identity.repositoryId,runId:identity.runId},create,
|
|
200
225
|
fingerprints:{workflow:digest('cm-fix-stages-v1'),config:digest(configuration),inputs:digest(identity)}});}catch(error){guard?.close();throw error;}
|
|
201
226
|
const closeStore=()=>{try{store.close();}finally{guard?.close();}};
|
|
202
|
-
let active=null,closed=false;
|
|
227
|
+
let active=null,closed=false,lastPinned={};
|
|
203
228
|
const retryCount=base=>{
|
|
204
229
|
const records=store.snapshot().records;
|
|
205
230
|
return records.filter(row=>/^fix-abandoned-[1-8]$/.test(row.id)).filter(row=>{
|
|
206
231
|
const intent=records.find(item=>digest(item)===row.payload.intentDigest);
|
|
207
232
|
return intent&&stepRecord(retryBase(intent.id))?.base===base;
|
|
233
|
+
}).length+records.filter(row=>blockedRerunNumber(row.id)>0).filter(row=>{
|
|
234
|
+
const intent=records.find(item=>digest(item)===row.payload.intentDigest);
|
|
235
|
+
return intent&&stepRecord(retryBase(intent.id))?.base===base;
|
|
208
236
|
}).length;
|
|
209
237
|
};
|
|
210
238
|
const append=(recordId,kind,payload)=>{
|
|
@@ -391,8 +419,8 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
391
419
|
append(recordId,'result',payload);
|
|
392
420
|
}catch{/* Missing, conflicting or unbound receipts never change the original unknown. */}
|
|
393
421
|
}
|
|
394
|
-
|
|
395
|
-
|
|
422
|
+
// snapshot: the store's, or a candidate one a writer validates before appending.
|
|
423
|
+
function project(snapshot=store.snapshot()){
|
|
396
424
|
need(snapshot.records.length>0,'fix_history_invalid');
|
|
397
425
|
const [first,...records]=snapshot.records;
|
|
398
426
|
// Older runs could advance a recovered single-layer diagnosis without cause review.
|
|
@@ -417,7 +445,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
417
445
|
need(first.id==='fix-configuration'&&first.kind==='intent'&&digest(first.payload)===digest(initial),'fix_history_invalid');
|
|
418
446
|
let stage='reproduce',pending=null,reproduction=null,diagnosed=null,learning=null,cause=null,started=null,causeResult=null,red=null,redFiles=null,baseline=null,baselineFiles=null;
|
|
419
447
|
let pendingOrigin=null,pendingIntent=null;
|
|
420
|
-
const abandoned=[],retryCounts=new Map();
|
|
448
|
+
const abandoned=[],retryCounts=new Map(),pinned={},blockedReruns={};let lastStepResult=null;
|
|
421
449
|
let authorBaseline=null,authored=null,escalationIntent=null,escalation=null;
|
|
422
450
|
const redStage=()=>diagnosed?.status==='design_change'?'design_change_required':'red_test_required';
|
|
423
451
|
let repairBaseline=null,repaired=null;
|
|
@@ -425,6 +453,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
425
453
|
let finalRegistration=null,finalStarted=null,finalResult=null,finalRecovery=null,finalRecoveryCount=0;
|
|
426
454
|
let rediagnosis=null,rediagnosisThread=null;
|
|
427
455
|
let causeOrigin=null,causeResultPayload=null,causeAbandonment=null,revisionFinalResultPayload=null,revisionAbandonment=null;
|
|
456
|
+
let causeAbandonment2=null,revisionAbandonment2=null;
|
|
428
457
|
const finalInvocations=new Set(),finalThreads=new Set();
|
|
429
458
|
let joinedCount=0;const seenJoined=new Set();
|
|
430
459
|
let n5=null,postReviewRegression=null,walkthrough=null,revision=null,revisionBaseline=null,revisionRepair=null,revisionRegression=null;
|
|
@@ -443,6 +472,8 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
443
472
|
}
|
|
444
473
|
need(digest(inventory([...reviewedFiles.values()]))===digest(inventory(next.files)),'fix_revision_source_mismatch');
|
|
445
474
|
}
|
|
475
|
+
const pendingBaseline=kind=>({test_author:authorBaseline,repair:repairBaseline,revision_test_author:revisionAuthorBaseline,revision_repair:revisionBaseline})[kind];
|
|
476
|
+
const assertPinned=(kind,value)=>{if(pinned[kind])need(digest(value)===digest(pinned[kind]),'fix_history_invalid');};
|
|
446
477
|
const reviewLedger=fixReviewLedger(snapshot.records,configuration);
|
|
447
478
|
for(const storedRecord of records){
|
|
448
479
|
if(/^fix-review-(receipt|reconciled)-/.test(storedRecord.id))continue;
|
|
@@ -451,8 +482,12 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
451
482
|
if(abandonedMatch){
|
|
452
483
|
need(Number(abandonedMatch[1])===abandoned.length+1&&record.kind==='result'
|
|
453
484
|
&&stage==='unknown'&&abandonable.has(pending)&&pendingIntent&&pendingOrigin,'fix_history_invalid');
|
|
454
|
-
shape(record.payload,['pending','reason','abandonedAt','intentDigest']);
|
|
485
|
+
shape(record.payload,['pending','reason','abandonedAt','intentDigest',...(Object.hasOwn(record.payload,'baselinePinned')?['baselinePinned']:[])]);
|
|
455
486
|
need(record.payload.pending===pending&&record.payload.intentDigest===digest(pendingIntent),'fix_history_invalid');
|
|
487
|
+
if(Object.hasOwn(record.payload,'baselinePinned')){
|
|
488
|
+
need(record.payload.baselinePinned===true&&PINNED_STEPS.has(pending),'fix_history_invalid');
|
|
489
|
+
pinned[pending]??=pendingBaseline(pending);
|
|
490
|
+
}
|
|
456
491
|
need(typeof record.payload.reason==='string'&&record.payload.reason.trim().length>0
|
|
457
492
|
&&Buffer.byteLength(record.payload.reason,'utf8')<=1000
|
|
458
493
|
&&!/[\r\n\0\u0085\u2028\u2029]/.test(record.payload.reason)&&Number.isSafeInteger(record.payload.abandonedAt)
|
|
@@ -470,8 +505,39 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
470
505
|
if(pending==='revision_retrospective')revisionRetrospectivePackage=null;
|
|
471
506
|
stage=pendingOrigin;pending=null;pendingOrigin=null;pendingIntent=null;continue;
|
|
472
507
|
}
|
|
508
|
+
const blockedRerun=blockedRerunNumber(record.id)?[record.id,String(blockedRerunNumber(record.id))]:null;
|
|
509
|
+
if(blockedRerun){
|
|
510
|
+
const kind=RERUNNABLE[stage];
|
|
511
|
+
need(Number(blockedRerun[1])===Object.values(blockedReruns).reduce((a,b)=>a+b,0)+1&&record.kind==='result'
|
|
512
|
+
&&kind&&pending===null&&revision===null===!kind.startsWith('revision_')&&pendingIntent&&pendingOrigin&&lastStepResult
|
|
513
|
+
&&stepRecord(retryBase(pendingIntent.id))?.pending===kind&&stepRecord(retryBase(lastStepResult.id))?.pending===kind
|
|
514
|
+
&&(blockedReruns[kind]??0)<MAX_FIX_BLOCKED_RERUNS,'fix_history_invalid');
|
|
515
|
+
shape(record.payload,['stage','pending','reason','rerunAt','intentDigest','resultDigest',...(Object.hasOwn(record.payload,'baselinePinned')?['baselinePinned']:[])]);
|
|
516
|
+
need(record.payload.stage===stage&&record.payload.pending===kind&&record.payload.intentDigest===digest(pendingIntent)
|
|
517
|
+
&&record.payload.resultDigest===digest(lastStepResult)&&typeof record.payload.reason==='string'&&record.payload.reason.trim().length>0
|
|
518
|
+
&&Buffer.byteLength(record.payload.reason,'utf8')<=1000&&!/[\r\n\0\u0085\u2028\u2029]/.test(record.payload.reason)
|
|
519
|
+
&&Number.isSafeInteger(record.payload.rerunAt)&&record.payload.rerunAt>0,'fix_history_invalid');
|
|
520
|
+
if(Object.hasOwn(record.payload,'baselinePinned')){
|
|
521
|
+
need(record.payload.baselinePinned===true&&PINNED_STEPS.has(kind),'fix_history_invalid');pinned[kind]??=pendingBaseline(kind);
|
|
522
|
+
}
|
|
523
|
+
const base=stepRecord(retryBase(pendingIntent.id)).base;
|
|
524
|
+
need((retryCounts.get(base)??0)<8,'fix_history_invalid');retryCounts.set(base,(retryCounts.get(base)??0)+1);
|
|
525
|
+
blockedReruns[kind]=(blockedReruns[kind]??0)+1;
|
|
526
|
+
if(kind==='test_author'){authored=null;authorBaseline=null;}
|
|
527
|
+
if(kind==='repair'){repaired=null;repairBaseline=null;}
|
|
528
|
+
if(kind==='regression')regression=null;
|
|
529
|
+
if(kind==='post_review_regression')postReviewRegression=null;
|
|
530
|
+
if(kind==='walkthrough')walkthrough=null;
|
|
531
|
+
if(kind==='revision_test_author'){revisionAuthored=null;revisionAuthorBaseline=null;}
|
|
532
|
+
if(kind==='revision_repair'){revisionRepair=null;revisionBaseline=null;}
|
|
533
|
+
if(kind==='revision_regression')revisionRegression=null;
|
|
534
|
+
if(kind==='revision_post_review_regression')revisionPostRegression=null;
|
|
535
|
+
if(kind==='revision_walkthrough')revisionWalkthrough=null;
|
|
536
|
+
stage=pendingOrigin;pendingOrigin=null;pendingIntent=null;lastStepResult=null;continue;
|
|
537
|
+
}
|
|
473
538
|
const retried=/^(.*)-retry-([1-8])-(intent|result)$/.exec(record.id);
|
|
474
|
-
|
|
539
|
+
// A review cycle's second retry (fix-cause-retry-2-result) is not a step retry.
|
|
540
|
+
if(retried&&!/^fix-(?:cause(?:-rediagnosis)?|revision-final)$/.test(retried[1])){
|
|
475
541
|
const baseId=`${retried[1]}-${retried[3]}`,step=stepRecord(baseId);
|
|
476
542
|
need(step&&Number(retried[2])===retryCounts.get(step.base)
|
|
477
543
|
&&record.kind===retried[3],'fix_history_invalid');
|
|
@@ -480,7 +546,10 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
480
546
|
if(/^fix-final-recovery-(?:[1-9]\d*-)?authorized$/.test(record.id)){
|
|
481
547
|
need(!(configuration.externalModels||configuration.executionPolicy),'external_review_reconciliation_required');
|
|
482
548
|
need(record.id===`${recoveryPrefix(finalRecoveryCount+1)}-authorized`,'fix_history_invalid');
|
|
483
|
-
|
|
549
|
+
// V5 (F24): a first final review whose worker never opened a thread may
|
|
550
|
+
// also be recovered, bound to providerThreadId null, while fewer than
|
|
551
|
+
// MAX_FIX_REVIEW_ABANDONS recoveries were made (threaded ones keep their rule).
|
|
552
|
+
need(identity.attempt===1&&stage==='unknown'&&finalRegistration&&(finalStarted||finalRecoveryCount<MAX_FIX_REVIEW_ABANDONS)&&!revision
|
|
484
553
|
&&(!finalResult||finalResult.observationStatus==='unknown')&&record.kind==='result','fix_review_recovery_unavailable');
|
|
485
554
|
const value=record.payload;
|
|
486
555
|
shape(value,['invocationId','packageDigest','registrationDigest','providerThreadId','previousInvocationStopped','reason']);
|
|
@@ -510,7 +579,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
510
579
|
&&digest(value.reviewFeedback)===digest(causeResult.review),'fix_history_invalid');
|
|
511
580
|
if(value.learning!==null)inspectFixLearning(value.learning);
|
|
512
581
|
rediagnosis=value;rediagnosisThread=started;learning=value.learning;
|
|
513
|
-
cause=null;causeResult=null;causeResultPayload=null;started=null;causeAbandonment=null;
|
|
582
|
+
cause=null;causeResult=null;causeResultPayload=null;started=null;causeAbandonment=null;causeAbandonment2=null;
|
|
514
583
|
stage='unknown';pending='rediagnosis';continue;
|
|
515
584
|
}
|
|
516
585
|
if(record.id==='fix-rediagnosis-result'){
|
|
@@ -519,14 +588,17 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
519
588
|
stage=diagnosed.status==='needs_evidence'?'rediagnosis_blocked':'cause_review_required';continue;
|
|
520
589
|
}
|
|
521
590
|
// Round 2 (after rediagnosis) replays as the cause review cycle, including its own one-time abandonment and retry.
|
|
522
|
-
const causeRevised=/^fix-cause-rediagnosis-((?:retry-)?(?:registered|started|result)|abandoned)$/.exec(record.id);
|
|
591
|
+
const causeRevised=/^fix-cause-rediagnosis-((?:retry-(?:2-)?)?(?:registered|started|result)|abandoned(?:-2)?)$/.exec(record.id);
|
|
523
592
|
if(causeRevised){need(rediagnosis!==null,'fix_history_invalid');record={...record,id:`fix-cause-${causeRevised[1]}`};}
|
|
524
|
-
else if(rediagnosis!==null&&/^fix-cause-(?:(?:retry-)?(?:registered|started|result)|abandoned)$/.test(record.id))need(false,'fix_history_invalid');
|
|
525
|
-
// After
|
|
526
|
-
|
|
593
|
+
else if(rediagnosis!==null&&/^fix-cause-(?:(?:retry-(?:2-)?)?(?:registered|started|result)|abandoned(?:-2)?)$/.test(record.id))need(false,'fix_history_invalid');
|
|
594
|
+
// After an abandonment only the next cycle's records are valid: retry-*
|
|
595
|
+
// after the first, retry-2-* after the second (V5, at most two per round).
|
|
596
|
+
const reviewRetry=/^(fix-cause|fix-revision-final)-retry-(2-)?(registered|started|result)$/.exec(record.id);
|
|
527
597
|
if(reviewRetry){
|
|
528
|
-
|
|
529
|
-
|
|
598
|
+
const first=reviewRetry[1]==='fix-cause'?causeAbandonment:revisionAbandonment;
|
|
599
|
+
const second=reviewRetry[1]==='fix-cause'?causeAbandonment2:revisionAbandonment2;
|
|
600
|
+
need(reviewRetry[2]?second!==null:first!==null&&second===null,'fix_history_invalid');
|
|
601
|
+
record={...record,id:`${reviewRetry[1]}-${reviewRetry[3]}`};
|
|
530
602
|
}else if(/^fix-cause-(registered|started|result)$/.test(record.id))need(causeAbandonment===null,'fix_history_invalid');
|
|
531
603
|
else if(/^fix-revision-final-(registered|started|result)$/.test(record.id))need(revisionAbandonment===null,'fix_history_invalid');
|
|
532
604
|
const observed=/^fix-observation-(?:(\d+)-)?(resume-prepared|reproduce-intent|reproduce-result|diagnose-intent|diagnose-result)$/.exec(record.id);
|
|
@@ -540,6 +612,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
540
612
|
need(pending===null,'fix_history_invalid');
|
|
541
613
|
pendingOrigin=stage;pendingIntent=storedRecord;
|
|
542
614
|
}
|
|
615
|
+
if(localStep&&record.kind==='result')lastStepResult=storedRecord;
|
|
543
616
|
need(stage!=='cancelled'&&stage!=='escalated','fix_history_invalid');
|
|
544
617
|
const joined=joinedRecord.exec(record.id);
|
|
545
618
|
if(joined){
|
|
@@ -636,7 +709,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
636
709
|
if(record.id==='fix-revision-test-author-intent'){
|
|
637
710
|
need(revision?.tests&&stage==='revision_test_author_required'&&record.kind==='intent','fix_history_invalid');
|
|
638
711
|
shape(record.payload,['baseline','revisionDigest']);
|
|
639
|
-
revisionAuthorBaseline=readReviewBaseline(record.payload.baseline);
|
|
712
|
+
revisionAuthorBaseline=readReviewBaseline(record.payload.baseline);assertPinned('revision_test_author',revisionAuthorBaseline);
|
|
640
713
|
need(record.payload.revisionDigest===digest(revision)&&digest(revisionAuthorBaseline.identity)===digest(revision.nextIdentity)
|
|
641
714
|
&&digest(revisionAuthorBaseline.scope)===digest([...revision.tests.testFiles].sort())
|
|
642
715
|
&&digest(revisionAuthorBaseline.requirements)===digest([...configuration.repair.requirements].sort())
|
|
@@ -663,7 +736,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
663
736
|
if(record.id==='fix-revision-repair-intent'){
|
|
664
737
|
need(revision&&revisionBaseline===null&&['final_review_changes_requested','walkthrough_blocked','post_review_regression_blocked',...(revision.tests?['revision_prepared']:[])].includes(stage)&&record.kind==='intent','fix_history_invalid');
|
|
665
738
|
shape(record.payload,['baseline','revisionDigest','redDigest','testBaselineDigest']);
|
|
666
|
-
revisionBaseline=readReviewBaseline(record.payload.baseline);
|
|
739
|
+
revisionBaseline=readReviewBaseline(record.payload.baseline);assertPinned('revision_repair',revisionBaseline);
|
|
667
740
|
need(digest(revisionBaseline.identity)===digest(revision.nextIdentity)
|
|
668
741
|
&&revisionBaseline.rootDigest===repairBaseline.rootDigest&&(revisionBaseline.specsPath??null)===(repairBaseline.specsPath??null)
|
|
669
742
|
&&digest(revisionBaseline.scope)===digest(repairBaseline.scope)&&digest(revisionBaseline.requirements)===digest(repairBaseline.requirements)
|
|
@@ -740,11 +813,12 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
740
813
|
need(record.payload.outcome==='created'&&record.payload.status==='ready_for_review'&&/^[a-f0-9]{64}$/.test(record.payload.handoffSha256),'invalid_handoff_result');
|
|
741
814
|
revisionHandoff=record.payload;pending=null;stage='revision_final_review_required';continue;
|
|
742
815
|
}
|
|
743
|
-
if(
|
|
816
|
+
if(/^(fix-cause|fix-revision-final)-abandoned(-2)?$/.test(record.id)){
|
|
744
817
|
need(!(configuration.externalModels||configuration.executionPolicy),'external_review_reconciliation_required');
|
|
745
|
-
const causeKind=record.id
|
|
818
|
+
const causeKind=record.id.startsWith('fix-cause-'),secondAbandon=record.id.endsWith('-2');
|
|
746
819
|
const registration=causeKind?cause:revisionFinalRegistration,result=causeKind?causeResult:revisionFinalResult;
|
|
747
|
-
|
|
820
|
+
const prior=causeKind?[causeAbandonment,causeAbandonment2]:[revisionAbandonment,revisionAbandonment2];
|
|
821
|
+
need(record.kind==='result'&&(secondAbandon?prior[0]!==null&&prior[1]===null:prior[0]===null)&®istration&&stage==='unknown'
|
|
748
822
|
&&(pending===(causeKind?'cause_review':'revision_final_review')&&!result
|
|
749
823
|
||pending===null&&result&&result.observationStatus!=='completed'),'fix_history_invalid');
|
|
750
824
|
const value=record.payload,resultPayload=causeKind?causeResultPayload:revisionFinalResultPayload;
|
|
@@ -755,9 +829,11 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
755
829
|
need(typeof value.reason==='string'&&value.reason.trim().length>0&&Buffer.byteLength(value.reason,'utf8')<=1000
|
|
756
830
|
&&!/[\r\n\0\u0085\u2028\u2029]/.test(value.reason)&&Number.isSafeInteger(value.abandonedAt)&&value.abandonedAt>0,'fix_history_invalid');
|
|
757
831
|
if(causeKind){
|
|
758
|
-
|
|
832
|
+
if(secondAbandon)causeAbandonment2=value;else causeAbandonment=value;
|
|
833
|
+
stage=causeOrigin;cause=null;started=null;causeResult=null;causeResultPayload=null;causeResumeStage=null;
|
|
759
834
|
}else{
|
|
760
|
-
|
|
835
|
+
if(secondAbandon)revisionAbandonment2=value;else revisionAbandonment=value;
|
|
836
|
+
stage='revision_final_review_required';
|
|
761
837
|
revisionFinalRegistration=null;revisionFinalStarted=null;revisionFinalResult=null;revisionFinalResultPayload=null;
|
|
762
838
|
}
|
|
763
839
|
pending=null;continue;
|
|
@@ -774,7 +850,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
774
850
|
need(revision&&pending==='revision_final_review'&&revisionFinalStarted===null&&record.kind==='result','fix_history_invalid');
|
|
775
851
|
need(record.payload.providerThreadId!==finalRecovery?.providerThreadId,'final_context_mismatch');
|
|
776
852
|
shape(record.payload,['providerThreadId']);id(record.payload.providerThreadId);
|
|
777
|
-
need(record.payload.providerThreadId
|
|
853
|
+
need(![revisionAbandonment?.providerThreadId,revisionAbandonment2?.providerThreadId].includes(record.payload.providerThreadId),'final_context_mismatch');
|
|
778
854
|
const config=fixRevisionReviewConfiguration(revisionFeedback(),revision.nextIdentity,hostContextIds);
|
|
779
855
|
need(![...fixHostContexts(config),config.reviewer.contextId,...config.reviewer.excludedThreadIds].includes(record.payload.providerThreadId),'final_context_mismatch');
|
|
780
856
|
revisionFinalStarted=record.payload.providerThreadId;continue;
|
|
@@ -937,7 +1013,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
937
1013
|
if(record.id==='fix-repair-intent'){
|
|
938
1014
|
need(configuration.repair&&stage==='repair_required'&&repairBaseline===null&&record.kind==='intent','fix_history_invalid');
|
|
939
1015
|
shape(record.payload,['baseline','redDigest','testBaselineDigest']);
|
|
940
|
-
repairBaseline=readReviewBaseline(record.payload.baseline);
|
|
1016
|
+
repairBaseline=readReviewBaseline(record.payload.baseline);assertPinned('repair',repairBaseline);
|
|
941
1017
|
const codeRoot=fs.realpathSync(configuration.reproduction.cwd);
|
|
942
1018
|
need(digest(repairBaseline.identity)===digest(identity)&&repairBaseline.rootDigest===createHash('sha256').update(codeRoot).digest('hex')
|
|
943
1019
|
&&(repairBaseline.specsPath??null)===reviewSpecsPath(codeRoot,evidenceSpecsRoot)
|
|
@@ -955,7 +1031,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
955
1031
|
}
|
|
956
1032
|
if(record.id==='fix-test-author-intent'){
|
|
957
1033
|
need(configuration.testAuthor&&stage===redStage()&&authorBaseline===null&&record.kind==='intent','fix_history_invalid');
|
|
958
|
-
authorBaseline=readReviewBaseline(record.payload);
|
|
1034
|
+
authorBaseline=readReviewBaseline(record.payload);assertPinned('test_author',authorBaseline);
|
|
959
1035
|
const codeRoot=fs.realpathSync(configuration.reproduction.cwd);
|
|
960
1036
|
need(authorBaseline.rootDigest===createHash('sha256').update(codeRoot).digest('hex')
|
|
961
1037
|
&&(authorBaseline.specsPath??null)===reviewSpecsPath(codeRoot,evidenceSpecsRoot),'test_author_binding_mismatch');
|
|
@@ -1039,7 +1115,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1039
1115
|
need(pending==='cause_review'&&started===null&&record.kind==='result','fix_history_invalid');
|
|
1040
1116
|
shape(record.payload,['providerThreadId']);id(record.payload.providerThreadId);started=record.payload.providerThreadId;
|
|
1041
1117
|
need(![...hostContextIds,configuration.causeReview.contextId,finalStarted,rediagnosisThread,...configuration.causeReview.excludedThreadIds,
|
|
1042
|
-
causeAbandonment?.providerThreadId].includes(started),'cause_registration_mismatch');continue;
|
|
1118
|
+
causeAbandonment?.providerThreadId,causeAbandonment2?.providerThreadId].filter(Boolean).includes(started),'cause_registration_mismatch');continue;
|
|
1043
1119
|
}
|
|
1044
1120
|
if(record.id==='fix-cause-result'){
|
|
1045
1121
|
need(pending==='cause_review'&&record.kind==='result','fix_history_invalid');
|
|
@@ -1095,7 +1171,12 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1095
1171
|
// only what the journal and its closeout settled: later reviewed changes may
|
|
1096
1172
|
// legitimately move these files, and the caller checks the tree itself.
|
|
1097
1173
|
if(!durableHistory){
|
|
1098
|
-
|
|
1174
|
+
// F14 exemption: once a repair (or, while it is being redone, a test
|
|
1175
|
+
// authoring) pinned its baseline, that intent already passed this check;
|
|
1176
|
+
// the residue in its scope is the redo's input and is reviewed against
|
|
1177
|
+
// the pinned baseline, so it is not cause-review drift.
|
|
1178
|
+
if(causeResult?.review?.verdict==='approved'&&stage!=='cancelled'&&repairBaseline===null&&!pinned.repair
|
|
1179
|
+
&&!(pinned.test_author&&authored===null)){
|
|
1099
1180
|
try{
|
|
1100
1181
|
const current=createFixCausePackage({codeProject:configuration.reproduction.cwd,defect:configuration.defect,
|
|
1101
1182
|
context:Object.hasOwn(cause.request.payload.reviewPackage,'contextFiles'),status:{identity,stage:'cause_review_required',reproduction,diagnosis:diagnosed,learning,
|
|
@@ -1150,12 +1231,12 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1150
1231
|
try{verifyFixWalkthroughEvidence(walkthrough,evidenceSpecsRoot);}catch{stage='walkthrough_evidence_required';}
|
|
1151
1232
|
}
|
|
1152
1233
|
if(revision&&['final_review_changes_requested','walkthrough_blocked','post_review_regression_blocked'].includes(stage))stage='revision_prepared';
|
|
1153
|
-
if(stage==='revision_test_author_required'){
|
|
1234
|
+
if(stage==='revision_test_author_required'&&!pinned.revision_test_author){
|
|
1154
1235
|
try{verifyRevisionStart(captureReviewBaseline({root:configuration.reproduction.cwd,specsRoot:evidenceSpecsRoot,
|
|
1155
1236
|
identity:revision.nextIdentity,scope:revision.tests.testFiles,requirements:configuration.repair.requirements}));}
|
|
1156
1237
|
catch{stage='revision_test_evidence_required';}
|
|
1157
1238
|
}
|
|
1158
|
-
if(revisionAuthored?.outcome==='authored'&&!['unknown','cancelled'].includes(stage)){
|
|
1239
|
+
if(revisionAuthored?.outcome==='authored'&&!['unknown','cancelled'].includes(stage)&&!(pinned.revision_repair&&!revisionBaseline)){
|
|
1159
1240
|
try{
|
|
1160
1241
|
verifyExtensionFiles(configuration.reproduction.cwd,{plan:revision.tests,files:revisionAuthored.testFiles});
|
|
1161
1242
|
if(!revisionBaseline)verifyFixRepair({codeProject:configuration.reproduction.cwd,specsRoot:evidenceSpecsRoot,
|
|
@@ -1226,13 +1307,20 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1226
1307
|
const causeNoResult=noReviewResult(cause,causeResult,'cause_review');
|
|
1227
1308
|
const revisionNoResult=noReviewResult(revisionFinalRegistration,revisionFinalResult,'revision_final_review');
|
|
1228
1309
|
if(stage==='unknown'&&[...reviewLedger.receipts.values()].some(p=>reviewLedger.applied.has(p.invocationId)&&p.inspection.kind==='cm-provider-review-failure')){stage='review_provider_failed';pending=null;}
|
|
1229
|
-
const reviewAbandonable=!(configuration.externalModels||configuration.executionPolicy)&&causeNoResult&&!
|
|
1310
|
+
const reviewAbandonable=!(configuration.externalModels||configuration.executionPolicy)&&causeNoResult&&!causeAbandonment2?'cause_review':!(configuration.externalModels||configuration.executionPolicy)&&revisionNoResult&&!revisionAbandonment2?'revision_final_review':null;
|
|
1311
|
+
lastPinned=pinned;
|
|
1312
|
+
const rerunKind=RERUNNABLE[stage]&&(revision===null)!==RERUNNABLE[stage].startsWith('revision_')?RERUNNABLE[stage]:null;
|
|
1230
1313
|
const status=json({identity,stage,pending,abandoned,executionActive:active!==null,reproduction,diagnosis:diagnosed,learning,causeReview:causeResult,
|
|
1231
1314
|
...(reviewAbandonable?{reviewAbandonable}:{}),
|
|
1315
|
+
...(Object.keys(pinned).length?{pinnedBaselines:Object.fromEntries(Object.entries(pinned).map(([kind,value])=>[kind,value.baselineDigest]))}:{}),
|
|
1316
|
+
...(Object.keys(blockedReruns).length?{blockedReruns}:{}),
|
|
1317
|
+
...(rerunKind?{blockedRerun:{pending:rerunKind,used:blockedReruns[rerunKind]??0,limit:MAX_FIX_BLOCKED_RERUNS}}:{}),
|
|
1232
1318
|
...((configuration.externalModels||configuration.executionPolicy)&&stage==='unknown'?{reviewReconciliation:{available:reviewLedger.pending.length===1,invocationId:reviewLedger.pending[0]?.invocationId??null}}:{}),
|
|
1233
|
-
...(causeNoResult&&
|
|
1319
|
+
...(causeNoResult&&causeAbandonment2||revisionNoResult&&revisionAbandonment2?{reviewAbandonBudgetExhausted:true}:{}),
|
|
1234
1320
|
...(causeAbandonment?{causeReviewAbandonment:causeAbandonment}:{}),
|
|
1321
|
+
...(causeAbandonment2?{causeReviewAbandonment2:causeAbandonment2}:{}),
|
|
1235
1322
|
...(revisionAbandonment?{revisionFinalReviewAbandonment:revisionAbandonment}:{}),
|
|
1323
|
+
...(revisionAbandonment2?{revisionFinalReviewAbandonment2:revisionAbandonment2}:{}),
|
|
1236
1324
|
...(causeReviewCorrection?{causeReviewCorrection}:{}),...(rediagnosis?{rediagnosis}:{}),
|
|
1237
1325
|
...(observationResume?{observationResume,observationCycle}:{}),
|
|
1238
1326
|
...(observationReproduction?{observationReproduction}:{}),
|
|
@@ -1300,11 +1388,39 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1300
1388
|
&&stepRecord(retryBase(row.id))?.pending===current.pending);
|
|
1301
1389
|
need(intent,'fix_abandon_unavailable');
|
|
1302
1390
|
append(`fix-abandoned-${current.abandoned.length+1}`,'result',
|
|
1303
|
-
{pending:current.pending,reason,abandonedAt:Date.now(),intentDigest:digest(intent)
|
|
1391
|
+
{pending:current.pending,reason,abandonedAt:Date.now(),intentDigest:digest(intent),
|
|
1392
|
+
...(PINNED_STEPS.has(current.pending)?{baselinePinned:true}:{})});
|
|
1304
1393
|
logFixEvent({specsRoot:evidenceSpecsRoot,identity,configuration,event:'abandon',phase:current.pending,
|
|
1305
1394
|
detail:`显式放弃 unknown 步骤:${current.pending}`,data:{pending:current.pending,reason}});
|
|
1306
1395
|
return project();
|
|
1307
1396
|
},
|
|
1397
|
+
// V10: rerun a step whose legitimate verdict was blocked (test author or
|
|
1398
|
+
// repair answered blocked, regression or walkthrough inconclusive/blocked).
|
|
1399
|
+
// The blocked result stays in the journal; a write step keeps its baseline.
|
|
1400
|
+
rerunBlockedStep({reason,authorized=false}={}){
|
|
1401
|
+
need(!closed&&active===null,'fix_busy');need(authorized===true,'fix_blocked_rerun_authorization_required');
|
|
1402
|
+
need(typeof reason==='string'&&reason.trim().length>0&&Buffer.byteLength(reason,'utf8')<=1000
|
|
1403
|
+
&&!/[\r\n\0\u0085\u2028\u2029]/.test(reason),'fix_blocked_rerun_reason_required');
|
|
1404
|
+
const current=project();
|
|
1405
|
+
need(current.blockedRerun,'fix_blocked_rerun_unavailable');
|
|
1406
|
+
need(current.blockedRerun.used<MAX_FIX_BLOCKED_RERUNS,'fix_blocked_rerun_limit');
|
|
1407
|
+
const kind=current.blockedRerun.pending,records=store.snapshot().records;
|
|
1408
|
+
const intent=[...records].reverse().find(row=>row.kind==='intent'&&stepRecord(retryBase(row.id))?.pending===kind);
|
|
1409
|
+
const result=[...records].reverse().find(row=>row.kind==='result'&&stepRecord(retryBase(row.id))?.pending===kind);
|
|
1410
|
+
need(intent&&result,'fix_blocked_rerun_unavailable');
|
|
1411
|
+
const used=records.filter(row=>blockedRerunNumber(row.id)>0).length;
|
|
1412
|
+
const recordId=`fix-blocked-rerun-${used+1}`,payload={stage:current.stage,pending:kind,reason,rerunAt:Date.now(),
|
|
1413
|
+
intentDigest:digest(intent),resultDigest:digest(result),...(PINNED_STEPS.has(kind)?{baselinePinned:true}:{})};
|
|
1414
|
+
// The exact record must replay before it is appended (never a poisoned journal).
|
|
1415
|
+
const snapshot=store.snapshot(),candidate={version:1,seq:snapshot.records.length+1,id:recordId,kind:'result',payload,
|
|
1416
|
+
previousDigest:snapshot.records.at(-1)?.digest??null};
|
|
1417
|
+
try{project({...snapshot,records:[...snapshot.records,{...candidate,digest:digest(candidate)}]});}
|
|
1418
|
+
catch{need(false,'fix_blocked_rerun_unavailable');}
|
|
1419
|
+
append(recordId,'result',payload);
|
|
1420
|
+
logFixEvent({specsRoot:evidenceSpecsRoot,identity,configuration,event:'rerun',phase:kind,
|
|
1421
|
+
detail:`带理由重跑合法阻断的步骤:${kind}`,data:{pending:kind,stage:current.stage,reason}});
|
|
1422
|
+
return project();
|
|
1423
|
+
},
|
|
1308
1424
|
// One audited abandonment per review kind, mirroring cm-ai abandon_review. The
|
|
1309
1425
|
// host confirms the old reviewer process stopped; the record binds the exact
|
|
1310
1426
|
// registration, thread and any no-result observation. The retry needs the
|
|
@@ -1317,11 +1433,14 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1317
1433
|
const current=project();
|
|
1318
1434
|
need(current.reviewAbandonBudgetExhausted!==true,'fix_review_abandon_budget_exhausted');
|
|
1319
1435
|
need(current.reviewAbandonable,'fix_review_abandon_unavailable');
|
|
1320
|
-
const records=store.snapshot().records,
|
|
1436
|
+
const records=store.snapshot().records,base=current.reviewAbandonable==='cause_review'&¤t.rediagnosis
|
|
1321
1437
|
?'fix-cause-rediagnosis':REVIEW_ABANDON[current.reviewAbandonable];
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1438
|
+
// V5: the first abandonment ends the round's first cycle; the second ends the retry cycle.
|
|
1439
|
+
const again=Boolean(current.reviewAbandonable==='cause_review'?current.causeReviewAbandonment:current.revisionFinalReviewAbandonment);
|
|
1440
|
+
const prefix=again?`${base}-retry`:base;
|
|
1441
|
+
const registration=records.findLast(row=>row.id===`${prefix}-registered`),result=records.findLast(row=>row.id===`${prefix}-result`)??null;
|
|
1442
|
+
append(`${base}-abandoned${again?'-2':''}`,'result',{invocationId:registration.payload.request.invocationId,registrationDigest:digest(registration.payload),
|
|
1443
|
+
providerThreadId:records.findLast(row=>row.id===`${prefix}-started`)?.payload.providerThreadId??null,
|
|
1325
1444
|
resultDigest:result===null?null:digest(result.payload),reason,abandonedAt:Date.now()});
|
|
1326
1445
|
logFixEvent({specsRoot:evidenceSpecsRoot,identity,configuration,event:'abandon',phase:current.reviewAbandonable,
|
|
1327
1446
|
detail:`显式放弃无结果的审查:${current.reviewAbandonable}`,data:{pending:current.reviewAbandonable,reason}});
|
|
@@ -1333,8 +1452,11 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1333
1452
|
const current=project(),records=store.snapshot().records;
|
|
1334
1453
|
need(identity.attempt===1&¤t.stage==='unknown'&&!current.revision
|
|
1335
1454
|
&&(!current.finalReview||current.finalReview.observationStatus==='unknown'),'fix_review_recovery_unavailable');
|
|
1336
|
-
const prior=finalRecord(records,'registered')?.payload,thread=finalRecord(records,'started')?.payload.providerThreadId;
|
|
1337
|
-
need(prior
|
|
1455
|
+
const prior=finalRecord(records,'registered')?.payload,thread=finalRecord(records,'started')?.payload.providerThreadId??null;
|
|
1456
|
+
need(prior,'fix_review_recovery_unavailable');
|
|
1457
|
+
// V5 (F24): the thread-less recoveries are spent: an explicit limit, not a generic refusal.
|
|
1458
|
+
if(!thread&¤t.finalReviewRecoveryCount>=MAX_FIX_REVIEW_ABANDONS)throw Object.assign(new Error('fix_review_recovery_limit'),
|
|
1459
|
+
{code:'fix_review_recovery_limit',reason:FIX_REVIEW_RECOVERY_LIMIT_REASON});
|
|
1338
1460
|
if(current.finalReviewRecoveryCount>0||recoveryInvocationId!==null)
|
|
1339
1461
|
need(recoveryInvocationId===prior.request.invocationId,'fix_review_recovery_authorization_required');
|
|
1340
1462
|
need(invocationId===prior.request.invocationId&&packageDigest===prior.request.payload.reviewPackage.packageDigest
|
|
@@ -1558,7 +1680,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1558
1680
|
async reviewFinal(){
|
|
1559
1681
|
need(!closed&&active===null,'fix_busy');const start=project();if(!['final_review_required','revision_final_review_required'].includes(start.stage))return start;
|
|
1560
1682
|
const revising=start.stage==='revision_final_review_required';
|
|
1561
|
-
const prefix=revising?(start.revisionFinalReviewAbandonment?'fix-revision-final-retry':'fix-revision-final'):recoveryPrefix(start.finalReviewRecoveryCount);
|
|
1683
|
+
const prefix=revising?(start.revisionFinalReviewAbandonment2?'fix-revision-final-retry-2':start.revisionFinalReviewAbandonment?'fix-revision-final-retry':'fix-revision-final'):recoveryPrefix(start.finalReviewRecoveryCount);
|
|
1562
1684
|
need(finalReview&&typeof assertReviewReady==='function','final_review_unavailable');
|
|
1563
1685
|
const ready=assertReviewReady();if(types.isPromise(ready))Promise.prototype.then.call(ready,()=>{},()=>{});
|
|
1564
1686
|
need(ready===undefined,'final_sync_registration_required');
|
|
@@ -1579,7 +1701,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1579
1701
|
joinLiveHost();append(`${prefix}-registered`,'intent',value);registered=true;
|
|
1580
1702
|
},onStarted(providerThreadId){
|
|
1581
1703
|
need(providerThreadId!==start.finalReviewRecovery?.providerThreadId
|
|
1582
|
-
|
|
1704
|
+
&&!(revising&&[start.revisionFinalReviewAbandonment?.providerThreadId,start.revisionFinalReviewAbandonment2?.providerThreadId].filter(Boolean).includes(providerThreadId)),'final_context_mismatch');
|
|
1583
1705
|
if(!revising)need(!store.snapshot().records.some(row=>finalCycleRecord(row,'started')
|
|
1584
1706
|
&&row.payload.providerThreadId===providerThreadId),'final_context_mismatch');
|
|
1585
1707
|
append(`${prefix}-started`,'result',{providerThreadId});
|
|
@@ -1745,7 +1867,8 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1745
1867
|
const repair=prepareFixRepair({codeProject:configuration.reproduction.cwd,specsRoot:evidenceSpecsRoot,identity:executionIdentity,
|
|
1746
1868
|
...configuration.repair,defect:configuration.defect,diagnosis:start.diagnosis,
|
|
1747
1869
|
...(revising?{reviewFeedback:revisionFeedback(),...(testExtension()?{testExtension:testExtension()}:{})}:{}),
|
|
1748
|
-
redTest:configuration.redTest,baseline:configuration.baseline,redEvidence:start.redTest,beforeBaseline:start.baseline},{bridge,assertReviewReady
|
|
1870
|
+
redTest:configuration.redTest,baseline:configuration.baseline,redEvidence:start.redTest,beforeBaseline:start.baseline},{bridge,assertReviewReady,
|
|
1871
|
+
pinnedBaseline:lastPinned[revising?'revision_repair':'repair']??null,protectedMode:protectedSpecsRoot!==null});
|
|
1749
1872
|
const result=await repair.execute({authorized:true,signal:controller.signal,register(baseline){
|
|
1750
1873
|
append(`${prefix}-intent`,'intent',{baseline,redDigest:digest(start.redTest),testBaselineDigest:digest(start.baseline),...(revising?{revisionDigest:digest(start.revision)}:{})});registered=true;
|
|
1751
1874
|
}});
|
|
@@ -1753,6 +1876,8 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1753
1876
|
inspectFixRepair(result,repair.baseline,{allowUnchanged:revising&&Boolean(start.revision.tests)});append(`${prefix}-result`,'result',result);return project();
|
|
1754
1877
|
}catch(error){
|
|
1755
1878
|
if(preparing&&timedOut)need(false,'fix_learning_interrupted');
|
|
1879
|
+
// A pinned redo names the residue paths the operator must restore first.
|
|
1880
|
+
if(!registered&&!controller.signal.aborted&&['fix_pinned_residue','fix_protected_residue','fix_pinned_baseline_mismatch'].includes(error?.code))throw error;
|
|
1756
1881
|
if(!registered&&!controller.signal.aborted)need(false,error?.code==='fix_learning_context_changed'?'fix_learning_context_changed':'repair_preparation_failed');
|
|
1757
1882
|
return project();
|
|
1758
1883
|
}finally{clearTimeout(timer);active=null;}
|
|
@@ -1788,7 +1913,8 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1788
1913
|
need(project().stage===start.stage,'fix_evidence_changed');
|
|
1789
1914
|
const author=prepareFixTestAuthor({codeProject:configuration.reproduction.cwd,specsRoot:evidenceSpecsRoot,identity:executionIdentity,
|
|
1790
1915
|
testFiles:revising?start.revision.tests.testFiles:configuration.redTest.testFiles,requirements:revising?configuration.repair.requirements:configuration.testAuthor.requirements,
|
|
1791
|
-
defect:configuration.defect,diagnosis:start.diagnosis,reproduction:start.reproduction,...(revising?{reviewFeedback:inspectFixRepairReview(revisionFeedback(),executionIdentity),testPlan:start.revision.tests}:{})},{bridge,assertReviewReady
|
|
1916
|
+
defect:configuration.defect,diagnosis:start.diagnosis,reproduction:start.reproduction,...(revising?{reviewFeedback:inspectFixRepairReview(revisionFeedback(),executionIdentity),testPlan:start.revision.tests}:{})},{bridge,assertReviewReady,
|
|
1917
|
+
pinnedBaseline:lastPinned[revising?'revision_test_author':'test_author']??null,protectedMode:protectedSpecsRoot!==null});
|
|
1792
1918
|
const result=await author.execute({authorized:true,signal:controller.signal,register(baseline){
|
|
1793
1919
|
append(`${prefix}-intent`,'intent',revising?{baseline,revisionDigest:digest(start.revision)}:baseline);registered=true;
|
|
1794
1920
|
}});
|
|
@@ -1796,6 +1922,8 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1796
1922
|
inspectFixTestAuthor(result,author.baseline);append(`${prefix}-result`,'result',result);return project();
|
|
1797
1923
|
}catch(error){
|
|
1798
1924
|
if(preparing&&timedOut)need(false,'fix_learning_interrupted');
|
|
1925
|
+
// A pinned redo names the residue paths the operator must restore first.
|
|
1926
|
+
if(!registered&&!controller.signal.aborted&&['fix_pinned_residue','fix_protected_residue','fix_pinned_baseline_mismatch'].includes(error?.code))throw error;
|
|
1799
1927
|
if(!registered&&!controller.signal.aborted)need(false,error?.code==='fix_learning_context_changed'
|
|
1800
1928
|
?'fix_learning_context_changed':'test_author_preparation_failed');
|
|
1801
1929
|
return project();
|
|
@@ -1871,8 +1999,8 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1871
1999
|
need(configuration.causeReview&&causeReview&&typeof causeReview.authorize==='function'&&typeof causeReview.run==='function','cause_review_unavailable');
|
|
1872
2000
|
const reviewer=configuration.causeReview;
|
|
1873
2001
|
const budget=reviewTimeout(causeReview,configuration.reproduction.timeoutMs);
|
|
1874
|
-
const prefix=`${status.rediagnosis?'fix-cause-rediagnosis':'fix-cause'}${status.causeReviewAbandonment?'-retry':''}`;
|
|
1875
|
-
const
|
|
2002
|
+
const prefix=`${status.rediagnosis?'fix-cause-rediagnosis':'fix-cause'}${status.causeReviewAbandonment2?'-retry-2':status.causeReviewAbandonment?'-retry':''}`;
|
|
2003
|
+
const abandonedThreads=[status.causeReviewAbandonment?.providerThreadId,status.causeReviewAbandonment2?.providerThreadId].filter(Boolean);
|
|
1876
2004
|
const pkg=createFixCausePackage({codeProject:configuration.reproduction.cwd,defect:configuration.defect,status});
|
|
1877
2005
|
const request=requestFor({invocationId:`fix-cause.${randomUUID()}`,identity,role:'reviewer',provider:reviewer.provider,
|
|
1878
2006
|
requestedModel:reviewer.requestedModel,contextId:reviewer.contextId,payload:{reviewPackage:pkg,priorReview:null}});
|
|
@@ -1896,7 +2024,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1896
2024
|
JSON.stringify(causeExpectation(request,reviewConfiguration)));
|
|
1897
2025
|
if(event.event==='thread.started'){
|
|
1898
2026
|
// A retry is a fresh reviewer thread, never the abandoned one.
|
|
1899
|
-
need(event.provider_thread
|
|
2027
|
+
need(!abandonedThreads.includes(event.provider_thread)&&event.provider_thread!==status.rediagnosis?.priorProviderThreadId,'observation_context');
|
|
1900
2028
|
append(`${prefix}-started`,'result',{providerThreadId:event.provider_thread});started=event.provider_thread;
|
|
1901
2029
|
}
|
|
1902
2030
|
events.push(event);return true;
|