@aibyzero/cm-workflow 0.16.5 → 0.16.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +14 -0
- package/CHANGELOG.md +19 -1
- package/README.md +17 -4
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/VERSION +1 -1
- package/docs/architecture.md +43 -0
- package/docs/execution-optimizations.md +33 -0
- package/docs/external-models.md +114 -0
- package/docs/fixes/.reviews/20260929-bootstrap-unchanged-review-r1.md +7 -0
- package/docs/fixes/.reviews/20260930-develop-package-limit-recovery-r4.md +9 -0
- package/docs/fixes/20260929-bootstrap-rule-refresh-conflict.md +22 -0
- package/docs/fixes/20260929-bootstrap-unchanged-review.md +26 -0
- package/docs/fixes/20260930-develop-package-limit-recovery.md +65 -0
- package/docs/human-correction.md +31 -0
- package/docs/installation.md +28 -7
- package/docs/js-workflow-control.md +96 -6
- package/docs/live-evidence-drivers.md +62 -0
- package/docs/next-steps.md +15 -10
- package/docs/untested-branches.md +27 -4
- package/docs/user-guide.md +23 -8
- package/install-codex.sh +28 -11
- package/package.json +1 -1
- package/runtime/js/cm-ai/claude-review-adapter.mjs +7 -4
- package/runtime/js/cm-ai/claude-tool-preview.mjs +4 -4
- package/runtime/js/cm-ai/cm-ai-admission.mjs +34 -10
- package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +9 -5
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +111 -34
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +93 -31
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +13 -57
- package/runtime/js/cm-ai/codex-config.mjs +3 -2
- package/runtime/js/cm-ai/codex-review-adapter.mjs +34 -15
- package/runtime/js/cm-ai/committed-rule-basis.mjs +76 -0
- package/runtime/js/cm-ai/developer-adapter.mjs +8 -5
- package/runtime/js/cm-ai/drive-bootstrap.mjs +22 -12
- package/runtime/js/cm-ai/drive-core.mjs +9 -3
- package/runtime/js/cm-ai/durable-runner-state.mjs +146 -14
- package/runtime/js/cm-ai/effect-contract.mjs +1 -1
- package/runtime/js/cm-ai/execution-policy.mjs +58 -0
- package/runtime/js/cm-ai/external-group-models.mjs +53 -0
- package/runtime/js/cm-ai/external-model-launch.mjs +23 -0
- package/runtime/js/cm-ai/external-models.mjs +52 -0
- package/runtime/js/cm-ai/external-run-guard.mjs +96 -0
- package/runtime/js/cm-ai/host-bootstrap.mjs +70 -20
- package/runtime/js/cm-ai/host-check.mjs +30 -4
- package/runtime/js/cm-ai/host-conversation-execution.mjs +59 -17
- package/runtime/js/cm-ai/host-documentation.mjs +2 -2
- package/runtime/js/cm-ai/host-progress.mjs +80 -0
- package/runtime/js/cm-ai/host-project-execution.mjs +16 -11
- package/runtime/js/cm-ai/host-qa-executor.mjs +54 -8
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +22 -5
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +3 -1
- package/runtime/js/cm-ai/knowledge-closeout.mjs +56 -0
- package/runtime/js/cm-ai/legacy-model-run-preview.mjs +24 -0
- package/runtime/js/cm-ai/legacy-model-settings.mjs +59 -0
- package/runtime/js/cm-ai/live-evidence.mjs +96 -0
- package/runtime/js/cm-ai/log-rows.mjs +36 -0
- package/runtime/js/cm-ai/model-configuration-file.mjs +63 -0
- package/runtime/js/cm-ai/model_configuration_write.py +214 -0
- package/runtime/js/cm-ai/native-usage-log.mjs +26 -0
- package/runtime/js/cm-ai/operator-guidance.mjs +89 -0
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +22 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +15 -0
- package/runtime/js/cm-ai/provider-usage.mjs +39 -0
- package/runtime/js/cm-ai/review-package.mjs +11 -0
- package/runtime/js/cm-ai/review-presentation.mjs +45 -0
- package/runtime/js/cm-ai/review-reconciliation.mjs +20 -0
- package/runtime/js/cm-ai/status-projection.mjs +93 -0
- package/runtime/js/cm-ai/task-runner.mjs +176 -25
- package/runtime/js/cm-ai/tool-preview.mjs +8 -4
- package/runtime/js/cm-ai/worker-claude-developer.mjs +16 -7
- package/runtime/js/cm-ai/worker-claude.mjs +63 -19
- package/runtime/js/cm-ai/worker-codex-developer.mjs +15 -9
- package/runtime/js/cm-ai/worker-codex.mjs +45 -19
- package/runtime/js/cm-fix/cause-evidence.mjs +5 -3
- package/runtime/js/cm-fix/cause-invocation.mjs +6 -3
- package/runtime/js/cm-fix/cause-package.mjs +10 -1
- package/runtime/js/cm-fix/execution.mjs +183 -40
- package/runtime/js/cm-fix/final-review.mjs +18 -10
- package/runtime/js/cm-fix/finish.mjs +2 -19
- package/runtime/js/cm-fix/host-review.mjs +25 -6
- package/runtime/js/cm-fix/host.mjs +4 -1
- package/runtime/js/cm-fix/layout.mjs +1 -1
- package/runtime/js/cm-fix/log-events.mjs +29 -0
- package/runtime/js/cm-fix/metrics.mjs +3 -2
- package/runtime/js/cm-fix/progress.mjs +4 -0
- package/runtime/js/cm-fix/review-reconciliation.mjs +64 -0
- package/runtime/js/cm-prd/analysis.mjs +5 -2
- package/runtime/js/cm-prd/response-recovery.mjs +23 -0
- package/runtime/js/cm-prd/review-host.mjs +2 -1
- package/runtime/js/cm-prd/review-publication.mjs +23 -13
- package/runtime/js/cm-prd/review-time.mjs +29 -0
- package/runtime/js/cm-prd/session.mjs +53 -6
- package/runtime/js/cm-security/finalize.mjs +32 -0
- package/runtime/js/cm-test/recovery.mjs +4 -4
- package/runtime/review.md +5 -0
- package/runtime/task-gates.md +6 -0
- package/runtime/workflow-config.md +10 -1
- package/scripts/cm-ai-admission.mjs +14 -3
- package/scripts/cm-ai-batch-drive.mjs +52 -23
- package/scripts/cm-ai-batch-drive.test.mjs +47 -2
- package/scripts/cm-ai-batch-host.mjs +44 -16
- package/scripts/cm-ai-batch-run.mjs +77 -29
- package/scripts/cm-ai-bootstrap-flow.test.mjs +3 -2
- package/scripts/cm-ai-bootstrap-merge.test.mjs +118 -1
- package/scripts/cm-ai-bootstrap.test.mjs +80 -87
- package/scripts/cm-ai-conversation-entry-ops.test.mjs +15 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +102 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +2 -2
- package/scripts/cm-ai-drive.mjs +73 -28
- package/scripts/cm-ai-drive.test.mjs +119 -1
- package/scripts/cm-ai-feature-selection.test.mjs +178 -0
- package/scripts/cm-ai-host.mjs +79 -27
- package/scripts/cm-ai-host.test.mjs +88 -0
- package/scripts/cm-ai-operator-guidance.test.mjs +94 -0
- package/scripts/cm-ai-progress.test.mjs +521 -0
- package/scripts/cm-ai-protected-scope.test.mjs +194 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +21 -0
- package/scripts/cm-ai-review-failure.test.mjs +71 -11
- package/scripts/cm-ai-run.mjs +94 -19
- package/scripts/cm-ai-run.test.mjs +2 -1
- package/scripts/cm-bootstrap-review-recovery.test.mjs +70 -0
- package/scripts/cm-check-drive.test.mjs +1 -0
- package/scripts/cm-check-runtime.sh +11 -0
- package/scripts/cm-claude-install-layout.test.mjs +26 -0
- package/scripts/cm-claude-probe.test.mjs +1 -1
- package/scripts/cm-codex-plugin-metadata.py +83 -0
- package/scripts/cm-codex-plugin-metadata.test.mjs +55 -0
- package/scripts/cm-efficiency-checks.test.mjs +37 -0
- package/scripts/cm-efficiency-diagnostics.test.mjs +74 -0
- package/scripts/cm-efficiency-offline.mjs +35 -0
- package/scripts/cm-efficiency-policy.test.mjs +48 -0
- package/scripts/cm-efficiency-presentation.test.mjs +35 -0
- package/scripts/cm-efficiency-response.test.mjs +117 -0
- package/scripts/cm-efficiency-usage.test.mjs +148 -0
- package/scripts/cm-external-batch-host.test.mjs +157 -0
- package/scripts/cm-external-fix-host.test.mjs +281 -0
- package/scripts/cm-external-fix-reconciliation.test.mjs +105 -0
- package/scripts/cm-external-group-models.test.mjs +60 -0
- package/scripts/cm-external-model-host.test.mjs +180 -0
- package/scripts/cm-external-model-recovery.test.mjs +108 -0
- package/scripts/cm-external-models.test.mjs +89 -0
- package/scripts/cm-external-process-cleanup.test.mjs +71 -0
- package/scripts/cm-external-qa-fix.test.mjs +170 -0
- package/scripts/cm-external-review-reconciliation.test.mjs +314 -0
- package/scripts/cm-fix-drive.mjs +28 -13
- package/scripts/cm-fix-final-review.test.mjs +11 -6
- package/scripts/cm-fix-host.mjs +17 -10
- package/scripts/cm-fix-large-log.test.mjs +113 -0
- package/scripts/cm-fix-protected-edits.test.mjs +12 -0
- package/scripts/cm-fix-rediagnosis.test.mjs +168 -0
- package/scripts/cm-fix-review-budget.test.mjs +7 -1
- package/scripts/cm-host-qa-executor.test.mjs +329 -3
- package/scripts/cm-knowledge-closeout.test.mjs +160 -0
- package/scripts/cm-live-evidence.test.mjs +64 -0
- package/scripts/cm-log-event.mjs +34 -7
- package/scripts/cm-log-event.py +15 -0
- package/scripts/cm-model-setup.mjs +79 -0
- package/scripts/cm-prd-drive.mjs +32 -11
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-host.mjs +26 -6
- package/scripts/cm-prd-host.test.mjs +4 -0
- package/scripts/cm-prd-review-host.test.mjs +17 -0
- package/scripts/cm-prd-session-recovery.test.mjs +44 -2
- package/scripts/cm-prd-task-grouping.test.mjs +206 -0
- package/scripts/cm-release-smoke.sh +5 -1
- package/scripts/cm-review-scope-recovery.test.mjs +5 -3
- package/scripts/cm-runtime-i18n.mjs +15 -4
- package/scripts/cm-runtime-install.mjs +8 -4
- package/scripts/cm-runtime.mjs +116 -23
- package/scripts/cm-runtime.test.mjs +121 -12
- package/scripts/cm-security.test.mjs +32 -0
- package/scripts/cm-task-gate-correction.test.mjs +117 -0
- package/scripts/cm-task-gate.mjs +146 -10
- package/scripts/cm-task-gate.py +1 -0
- package/scripts/cm-test-branch-impact.test.mjs +11 -0
- package/scripts/cm-test-drive.mjs +10 -4
- package/scripts/cm-test-drive.test.mjs +14 -1
- package/scripts/cm-tool-preview-context.test.mjs +12 -0
- package/scripts/cm-usage-report.py +22 -3
- package/scripts/cm-workflow-config.mjs +10 -1
- package/scripts/fixtures/bootstrap-review-runner.mjs +102 -0
- package/scripts/fixtures/live-evidence-driver.mjs +35 -0
- package/scripts/fixtures/process-cleanup.mjs +3 -1
- package/scripts/test-cm-native-usage.py +62 -0
- package/scripts/test-external-model-setup.py +91 -0
- package/scripts/test-model-configuration-write.py +201 -0
- package/scripts/test-npm-install.py +10 -1
- package/skills/cm-ai/SKILL.md +2 -2
- package/skills/cm-ai/references/N1-init.md +1 -1
- package/skills/cm-ai/references/N8-finish.md +5 -0
- package/skills/cm-ai/references/js-host.md +16 -7
- package/skills/cm-ai/references/knowledge-closeout.md +90 -0
- package/skills/cm-fix/SKILL.md +1 -1
- package/skills/cm-fix/references/js-host.md +30 -2
- package/skills/cm-prd/SKILL.md +5 -4
- package/skills/cm-prd/references/spec-self-check.md +3 -1
- package/skills/cm-runtime/SKILL.md +29 -6
- package/skills/cm-security/SKILL.md +4 -2
- package/skills/cm-security/references/scan-contract.md +1 -0
- package/templates/cm-workflow.yml +1 -1
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {readExecutionPolicy} from '../cm-ai/execution-policy.mjs';
|
|
2
|
+
import {readExecutionSnapshot} from '../cm-ai/execution-snapshot.mjs';
|
|
3
|
+
import {acquireExternalRunGuard,externalRunGuardExists} from '../cm-ai/external-run-guard.mjs';
|
|
4
|
+
import {fixReviewLedger,reconciledFixResultRecord} from './review-reconciliation.mjs';
|
|
5
|
+
import {readReconciliationReceipt} from '../cm-ai/review-reconciliation.mjs';
|
|
6
|
+
import {readExternalModels} from '../cm-ai/external-models.mjs';
|
|
1
7
|
// Fixed initial cm-fix stages over the shared durable store; no task completion authority.
|
|
2
8
|
import {inventory,readTestExtensionPlan,extensionConfig,inspectExtensionCheck,currentTestFiles,verifyExtensionFiles,extendRevisionReviewBaseline} from './test-extension.mjs';
|
|
3
9
|
import path from 'node:path';
|
|
@@ -9,7 +15,7 @@ import {inspectFixQaSource,readFixQaSourceHistory,qaFixIdentity,fixQaDiagnosisEv
|
|
|
9
15
|
import {digest,id,json,need,shape,text,validIdentity,requestFor,failureCode} from '../cm-ai/effect-contract.mjs';
|
|
10
16
|
import {createFixReproduction,inspectFixReproduction} from './reproduce.mjs';
|
|
11
17
|
import {inspectFixLearning} from './learning.mjs';
|
|
12
|
-
import {createFixCausePackage,verifyFixCauseTransition} from './cause-package.mjs';
|
|
18
|
+
import {createFixCausePackage,verifyFixCauseTransition,rediagnosisPackage} from './cause-package.mjs';
|
|
13
19
|
import {validateCauseReviewer,inspectCauseRegistration,inspectCauseResult,causeExpectation,fixHostContexts,MAX_FIX_JOINED_HOSTS} from './cause-invocation.mjs';
|
|
14
20
|
import {inspectProviderCauseReview} from '../cm-ai/provider-review-observation.mjs';
|
|
15
21
|
import {publishCauseEvidence} from './cause-evidence.mjs';
|
|
@@ -63,8 +69,17 @@ const latestStepRecord=(records,id)=>[...records].reverse().find(row=>retryBase(
|
|
|
63
69
|
// A cause or second-round final review that produced no review result may be
|
|
64
70
|
// abandoned once, audited, and dispatched again under its own record prefix.
|
|
65
71
|
const REVIEW_ABANDON={cause_review:'fix-cause',revision_final_review:'fix-revision-final'};
|
|
66
|
-
const
|
|
67
|
-
|
|
72
|
+
const causeRecord=(records,suffix)=>{
|
|
73
|
+
const marker=records.findIndex(row=>row.id==='fix-rediagnosis-intent');
|
|
74
|
+
const row=marker<0?reviewCycleRecord(records,'fix-cause',suffix)
|
|
75
|
+
:records.slice(marker+1).find(row=>row.id===`fix-cause-rediagnosis-${suffix}`);
|
|
76
|
+
return suffix==='result'?reconciledFixResultRecord(records,row):row;
|
|
77
|
+
};
|
|
78
|
+
const reviewCycleRecord=(records,prefix,suffix)=>{
|
|
79
|
+
const row=records.some(row=>row.id===`${prefix}-abandoned`)
|
|
80
|
+
?records.find(row=>row.id===`${prefix}-retry-${suffix}`):records.find(row=>row.id===`${prefix}-${suffix}`);
|
|
81
|
+
return suffix==='result'?reconciledFixResultRecord(records,row):row;
|
|
82
|
+
};
|
|
68
83
|
// Reviews wait for their own budget (host review configuration), never for the
|
|
69
84
|
// reproduction command's. Embedders that supply none keep the historical budget.
|
|
70
85
|
function reviewTimeout(adapter,fallback){
|
|
@@ -91,7 +106,22 @@ function diagnosis(raw){
|
|
|
91
106
|
return value;
|
|
92
107
|
}
|
|
93
108
|
|
|
94
|
-
|
|
109
|
+
const HISTORY_INSPECTION=Symbol('fix-history-inspection');
|
|
110
|
+
// Same owner projection, backed by a read-only journal and no writer/dispatch.
|
|
111
|
+
export function inspectFixExecutionHistory({specsRoot,identity}){
|
|
112
|
+
const snapshot=readExecutionSnapshot({specsRoot,identity});
|
|
113
|
+
const initial=snapshot.records[0]?.payload;need(initial?.workflow==='cm-fix-stages-v1','fix_history_invalid');
|
|
114
|
+
validIdentity(initial.identity);
|
|
115
|
+
const runIdentity={repositoryId:initial.identity.repositoryId,runId:initial.identity.runId};
|
|
116
|
+
need(digest(runIdentity)===digest(snapshot.identity)&&digest(runIdentity)===digest(identity),'identity_mismatch');
|
|
117
|
+
need(digest(snapshot.fingerprints)===digest({workflow:digest('cm-fix-stages-v1'),config:digest(initial.configuration),inputs:digest(initial.identity)}),'fingerprint_mismatch');
|
|
118
|
+
const {archiveMode,...configuration}=initial.configuration;
|
|
119
|
+
need(archiveMode===undefined||archiveMode==='bare','fix_history_invalid');
|
|
120
|
+
const owner=openFixExecution({specsRoot:archiveMode==='bare'?null:specsRoot,identity:initial.identity,configuration,create:false},{[HISTORY_INSPECTION]:snapshot});
|
|
121
|
+
try{return owner.status();}finally{owner.close();}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function openFixExecution(options,{bridge=null,prepare=null,causeReview=null,finalReview=null,assertReviewReady=null,[HISTORY_INSPECTION]:inspectionSnapshot=null}={}){
|
|
95
125
|
shape(options,['identity','configuration','create',...(Object.hasOwn(options,'hostContextId')?['hostContextId']:[]),
|
|
96
126
|
...(Object.hasOwn(options,'specsRoot')?['specsRoot']:[])]);
|
|
97
127
|
const {identity,configuration:originalConfiguration,create}=json(options,64*1024);validIdentity(identity);
|
|
@@ -100,7 +130,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
100
130
|
const configuration=json({...originalConfiguration,...(bare?{archiveMode:'bare'}:{})});
|
|
101
131
|
need(typeof create==='boolean','invalid_input');
|
|
102
132
|
const specsRoot=fixArchiveRoot(options.specsRoot,configuration.reproduction.cwd,create);
|
|
103
|
-
shape(configuration,['hostContextId','defect','reproduction',
|
|
133
|
+
shape(configuration,['hostContextId','defect','reproduction',...(Object.hasOwn(configuration,'externalModels')?['externalModels']:[]),...(Object.hasOwn(configuration,'executionPolicy')?['executionPolicy']:[]),
|
|
104
134
|
...(bare?['archiveMode']:[]),
|
|
105
135
|
...(Object.hasOwn(configuration,'protectSpecs')?['protectSpecs']:[]),
|
|
106
136
|
...(Object.hasOwn(configuration,'qaSource')?['qaSource']:[]),
|
|
@@ -111,6 +141,8 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
111
141
|
...(Object.hasOwn(configuration,'baseline')?['baseline']:[]),
|
|
112
142
|
...(Object.hasOwn(configuration,'testAuthor')?['testAuthor']:[]),
|
|
113
143
|
...(Object.hasOwn(configuration,'repair')?['repair']:[]),...(Object.hasOwn(configuration,'walkthrough')?['walkthrough']:[])]);
|
|
144
|
+
if(configuration.executionPolicy)readExecutionPolicy(configuration.executionPolicy);
|
|
145
|
+
if(configuration.externalModels){readExternalModels(configuration.externalModels);need(configuration.causeReview,'external_review_configuration_required');need(configuration.causeReview?.requestedModel===configuration.externalModels.providers[configuration.causeReview.provider]?.model,'external_model_pair_conflict');}
|
|
114
146
|
id(configuration.hostContextId);text(configuration.defect);
|
|
115
147
|
need(!bare||!configuration.qaSource,'fix_qa_specs_required');
|
|
116
148
|
if(isVisual(configuration.reproduction)||isVisual(configuration.redTest)){
|
|
@@ -161,8 +193,13 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
161
193
|
}
|
|
162
194
|
if(create)assertFixEvidenceNamesFree(evidenceSpecsRoot,identity,configuration);
|
|
163
195
|
if(create&&Object.hasOwn(configuration,'qaSource'))inspectFixQaSource({specsRoot,identity,configuration});
|
|
164
|
-
const
|
|
165
|
-
|
|
196
|
+
const codeProject=fs.realpathSync(configuration.reproduction.cwd);
|
|
197
|
+
const guard=!inspectionSnapshot&&((configuration.externalModels||configuration.executionPolicy)||externalRunGuardExists(evidenceSpecsRoot,codeProject))
|
|
198
|
+
?acquireExternalRunGuard({specsDir:evidenceSpecsRoot,codeProject,identity,feature:configuration.qaSource?.feature??'fix'}, {strictOnly:!(configuration.externalModels||configuration.executionPolicy)}):null;
|
|
199
|
+
let store;
|
|
200
|
+
try{store=inspectionSnapshot?{snapshot:()=>inspectionSnapshot,close(){},append(){need(false,'fix_read_only');}}:openExecutionStore({specsRoot,identity:{repositoryId:identity.repositoryId,runId:identity.runId},create,
|
|
201
|
+
fingerprints:{workflow:digest('cm-fix-stages-v1'),config:digest(configuration),inputs:digest(identity)}});}catch(error){guard?.close();throw error;}
|
|
202
|
+
const closeStore=()=>{try{store.close();}finally{guard?.close();}};
|
|
166
203
|
let active=null,closed=false;
|
|
167
204
|
const retryCount=base=>{
|
|
168
205
|
const records=store.snapshot().records;
|
|
@@ -199,19 +236,22 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
199
236
|
// bound human decision. Selection never falls back to an older result.
|
|
200
237
|
const recoveryPrefix=cycle=>cycle===0?'fix-final':cycle===1?'fix-final-recovery':`fix-final-recovery-${cycle}`;
|
|
201
238
|
const recoveryCount=records=>records.filter(row=>/^fix-final-recovery-(?:[1-9]\d*-)?authorized$/.test(row.id)).length;
|
|
202
|
-
const finalRecord=(records,suffix)=>records.find(row=>row.id===`${recoveryPrefix(recoveryCount(records))}-${suffix}`);
|
|
239
|
+
const finalRecord=(records,suffix)=>{const row=records.find(row=>row.id===`${recoveryPrefix(recoveryCount(records))}-${suffix}`);return suffix==='result'?reconciledFixResultRecord(records,row):row;};
|
|
203
240
|
const finalCycleRecord=(row,suffix)=>new RegExp(`^fix-final-(?:recovery-(?:[1-9]\\d*-)?)?${suffix}$`).test(row.id);
|
|
204
241
|
const publishCause=(inspectOnly=false)=>{
|
|
205
242
|
const records=store.snapshot().records;
|
|
206
243
|
return publishCauseEvidence({specsRoot:evidenceSpecsRoot,configuration:reviewConfiguration,inspectOnly,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
244
|
+
round:records.some(row=>row.id==='fix-rediagnosis-intent')?2:1,
|
|
245
|
+
registration:causeRecord(records,'registered')?.payload,
|
|
246
|
+
started:causeRecord(records,'started')?.payload.providerThreadId??null,
|
|
247
|
+
result:causeRecord(records,'result')?.payload});
|
|
210
248
|
};
|
|
249
|
+
const causeThreads=(thread,records=store.snapshot().records)=>[...new Set([thread,
|
|
250
|
+
records.find(row=>row.id==='fix-rediagnosis-intent')?.payload.priorProviderThreadId].filter(Boolean))];
|
|
211
251
|
const publishFinal=(inspectOnly=false)=>{
|
|
212
252
|
const records=store.snapshot().records;
|
|
213
253
|
return publishFixFinalEvidence({specsRoot:evidenceSpecsRoot,configuration:reviewConfiguration,inspectOnly,
|
|
214
|
-
causeThread:
|
|
254
|
+
causeThread:causeThreads(causeRecord(records,'started')?.payload.providerThreadId),
|
|
215
255
|
registration:finalRecord(records,'registered')?.payload,
|
|
216
256
|
started:finalRecord(records,'started')?.payload.providerThreadId??null,
|
|
217
257
|
result:finalRecord(records,'result')?.payload});
|
|
@@ -220,7 +260,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
220
260
|
const records=store.snapshot().records;
|
|
221
261
|
const failed=latestStepRecord(records,'fix-walkthrough-result')?.payload;
|
|
222
262
|
const regression=latestStepRecord(records,'fix-post-regression-result')?.payload;
|
|
223
|
-
return {configuration:fixFinalReviewConfiguration(reviewConfiguration,
|
|
263
|
+
return {configuration:fixFinalReviewConfiguration(reviewConfiguration,causeThreads(causeRecord(records,'started')?.payload.providerThreadId)),
|
|
224
264
|
registration:finalRecord(records,'registered')?.payload,
|
|
225
265
|
started:finalRecord(records,'started')?.payload.providerThreadId??null,
|
|
226
266
|
result:finalRecord(records,'result')?.payload,
|
|
@@ -339,6 +379,19 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
339
379
|
&&row.dossier_file===dossier.path&&row.dossier_sha256===dossier.sha256),'fix_escalation_exit_conflict');
|
|
340
380
|
return current;
|
|
341
381
|
}
|
|
382
|
+
function saveReviewReceipt(prefix,raw){
|
|
383
|
+
if(!(configuration.externalModels||configuration.executionPolicy)||!raw||project().stage!=='unknown')return;
|
|
384
|
+
try{
|
|
385
|
+
const records=store.snapshot().records,registration=records.find(r=>r.id===prefix+'-registered'),started=records.find(r=>r.id===prefix+'-started'),result=records.find(r=>r.id===prefix+'-result');
|
|
386
|
+
need(registration&&started&&result,'review_reconciliation_evidence_required');
|
|
387
|
+
const invocationId=registration.payload.request.invocationId;
|
|
388
|
+
const payload={prefix,invocationId,registeredDigest:digest(registration),startedDigest:digest(started),resultDigest:digest(result),receipt:readReconciliationReceipt(raw)};
|
|
389
|
+
const recordId='fix-review-receipt-'+digest(invocationId).slice(0,24);
|
|
390
|
+
need(!records.some(r=>r.id===recordId),'review_reconciliation_duplicate');
|
|
391
|
+
fixReviewLedger([...records,{id:recordId,seq:records.length+1,kind:'result',payload}],configuration);
|
|
392
|
+
append(recordId,'result',payload);
|
|
393
|
+
}catch{/* Missing, conflicting or unbound receipts never change the original unknown. */}
|
|
394
|
+
}
|
|
342
395
|
function project(){
|
|
343
396
|
const snapshot=store.snapshot();
|
|
344
397
|
need(snapshot.records.length>0,'fix_history_invalid');
|
|
@@ -371,6 +424,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
371
424
|
let repairBaseline=null,repaired=null;
|
|
372
425
|
let regression=null,retrospective=null,retrospectivePackage=null,writeback=null,learningPackage=null,handoff=null;
|
|
373
426
|
let finalRegistration=null,finalStarted=null,finalResult=null,finalRecovery=null,finalRecoveryCount=0;
|
|
427
|
+
let rediagnosis=null,rediagnosisThread=null;
|
|
374
428
|
let causeOrigin=null,causeResultPayload=null,causeAbandonment=null,revisionFinalResultPayload=null,revisionAbandonment=null;
|
|
375
429
|
const finalInvocations=new Set(),finalThreads=new Set();
|
|
376
430
|
let joinedCount=0;const seenJoined=new Set();
|
|
@@ -390,8 +444,10 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
390
444
|
}
|
|
391
445
|
need(digest(inventory([...reviewedFiles.values()]))===digest(inventory(next.files)),'fix_revision_source_mismatch');
|
|
392
446
|
}
|
|
447
|
+
const reviewLedger=fixReviewLedger(snapshot.records,configuration);
|
|
393
448
|
for(const storedRecord of records){
|
|
394
|
-
|
|
449
|
+
if(/^fix-review-(receipt|reconciled)-/.test(storedRecord.id))continue;
|
|
450
|
+
let record=reviewLedger.overlays.has(storedRecord.id)?{...storedRecord,payload:reviewLedger.overlays.get(storedRecord.id)}:storedRecord;
|
|
395
451
|
const abandonedMatch=/^fix-abandoned-([1-8])$/.exec(record.id);
|
|
396
452
|
if(abandonedMatch){
|
|
397
453
|
need(Number(abandonedMatch[1])===abandoned.length+1&&record.kind==='result'
|
|
@@ -423,6 +479,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
423
479
|
record={...record,id:baseId};
|
|
424
480
|
}
|
|
425
481
|
if(/^fix-final-recovery-(?:[1-9]\d*-)?authorized$/.test(record.id)){
|
|
482
|
+
need(!(configuration.externalModels||configuration.executionPolicy),'external_review_reconciliation_required');
|
|
426
483
|
need(record.id===`${recoveryPrefix(finalRecoveryCount+1)}-authorized`,'fix_history_invalid');
|
|
427
484
|
need(identity.attempt===1&&stage==='unknown'&&finalRegistration&&finalStarted&&!revision
|
|
428
485
|
&&(!finalResult||finalResult.observationStatus==='unknown')&&record.kind==='result','fix_review_recovery_unavailable');
|
|
@@ -441,6 +498,30 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
441
498
|
need(finalRecovery&&record.id===`${recoveryPrefix(finalRecoveryCount)}-${suffix}`,'fix_history_invalid');
|
|
442
499
|
record={...record,id:`fix-final-${suffix}`};
|
|
443
500
|
}else if(/^fix-final-(registered|started|result)$/.test(record.id))need(!finalRecovery,'fix_history_invalid');
|
|
501
|
+
if(record.id==='fix-rediagnosis-intent'){
|
|
502
|
+
need(record.kind==='intent'&&stage==='rediagnosis_required'&&pending===null&&rediagnosis===null
|
|
503
|
+
&&causeResult?.observationStatus==='completed'&&causeResult.review.verdict==='changes_requested'
|
|
504
|
+
&&authorBaseline===null&&red===null,'fix_history_invalid');
|
|
505
|
+
const value=record.payload;
|
|
506
|
+
shape(value,['reason','historyDigest','priorRegistrationDigest','priorObservationDigest','priorPackageDigest','priorProviderThreadId','reviewFeedback','learning']);
|
|
507
|
+
text(value.reason);need(Buffer.byteLength(value.reason,'utf8')<=1000&&!/[\r\n\0\u0085\u2028\u2029]/.test(value.reason),'fix_history_invalid');
|
|
508
|
+
need(value.historyDigest===digest(snapshot.records.slice(0,record.seq-1))
|
|
509
|
+
&&value.priorRegistrationDigest===digest(cause)&&value.priorObservationDigest===causeResult.observationDigest
|
|
510
|
+
&&value.priorPackageDigest===cause.request.payload.reviewPackage.packageDigest&&value.priorProviderThreadId===started
|
|
511
|
+
&&digest(value.reviewFeedback)===digest(causeResult.review),'fix_history_invalid');
|
|
512
|
+
if(value.learning!==null)inspectFixLearning(value.learning);
|
|
513
|
+
rediagnosis=value;rediagnosisThread=started;learning=value.learning;
|
|
514
|
+
cause=null;causeResult=null;causeResultPayload=null;started=null;causeAbandonment=null;
|
|
515
|
+
stage='unknown';pending='rediagnosis';continue;
|
|
516
|
+
}
|
|
517
|
+
if(record.id==='fix-rediagnosis-result'){
|
|
518
|
+
need(record.kind==='result'&&pending==='rediagnosis'&&rediagnosis!==null,'fix_history_invalid');
|
|
519
|
+
diagnosed=diagnosis(record.payload);pending=null;
|
|
520
|
+
stage=diagnosed.status==='needs_evidence'?'rediagnosis_blocked':'cause_review_required';continue;
|
|
521
|
+
}
|
|
522
|
+
const causeRevised=/^fix-cause-rediagnosis-(registered|started|result)$/.exec(record.id);
|
|
523
|
+
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)$/.test(record.id))need(false,'fix_history_invalid');
|
|
444
525
|
// After a one-time abandonment only the retry cycle's records are valid.
|
|
445
526
|
const reviewRetry=/^(fix-cause|fix-revision-final)-retry-(registered|started|result)$/.exec(record.id);
|
|
446
527
|
if(reviewRetry){
|
|
@@ -660,6 +741,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
660
741
|
revisionHandoff=record.payload;pending=null;stage='revision_final_review_required';continue;
|
|
661
742
|
}
|
|
662
743
|
if(record.id==='fix-cause-abandoned'||record.id==='fix-revision-final-abandoned'){
|
|
744
|
+
need(!(configuration.externalModels||configuration.executionPolicy),'external_review_reconciliation_required');
|
|
663
745
|
const causeKind=record.id==='fix-cause-abandoned';
|
|
664
746
|
const registration=causeKind?cause:revisionFinalRegistration,result=causeKind?causeResult:revisionFinalResult;
|
|
665
747
|
need(record.kind==='result'&&(causeKind?causeAbandonment:revisionAbandonment)===null&®istration&&stage==='unknown'
|
|
@@ -763,7 +845,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
763
845
|
}
|
|
764
846
|
if(record.id==='fix-final-registered'){
|
|
765
847
|
need(stage==='final_review_required'&&record.kind==='intent','fix_history_invalid');
|
|
766
|
-
finalRegistration=inspectFixFinalRegistration(record.payload,fixFinalReviewConfiguration(reviewConfiguration,started));
|
|
848
|
+
finalRegistration=inspectFixFinalRegistration(record.payload,fixFinalReviewConfiguration(reviewConfiguration,causeThreads(started)));
|
|
767
849
|
need(!finalInvocations.has(finalRegistration.request.invocationId),'fix_review_recovery_mismatch');
|
|
768
850
|
finalInvocations.add(finalRegistration.request.invocationId);
|
|
769
851
|
if(finalRecovery)need(finalRegistration.request.invocationId!==finalRecovery.invocationId
|
|
@@ -776,14 +858,14 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
776
858
|
if(record.id==='fix-final-started'){
|
|
777
859
|
need(pending==='final_review'&&finalStarted===null&&record.kind==='result','fix_history_invalid');
|
|
778
860
|
shape(record.payload,['providerThreadId']);id(record.payload.providerThreadId);
|
|
779
|
-
const config=fixFinalReviewConfiguration(reviewConfiguration,started);
|
|
861
|
+
const config=fixFinalReviewConfiguration(reviewConfiguration,causeThreads(started));
|
|
780
862
|
need(!finalThreads.has(record.payload.providerThreadId),'final_context_mismatch');
|
|
781
863
|
need(![...fixHostContexts(config),config.reviewer.contextId,...config.reviewer.excludedThreadIds].includes(record.payload.providerThreadId),'final_context_mismatch');
|
|
782
864
|
finalStarted=record.payload.providerThreadId;finalThreads.add(finalStarted);continue;
|
|
783
865
|
}
|
|
784
866
|
if(record.id==='fix-final-result'){
|
|
785
867
|
need(pending==='final_review'&&record.kind==='result','fix_history_invalid');
|
|
786
|
-
finalResult=inspectFixFinalResult(record.payload,finalRegistration,fixFinalReviewConfiguration(reviewConfiguration,started),finalStarted);
|
|
868
|
+
finalResult=inspectFixFinalResult(record.payload,finalRegistration,fixFinalReviewConfiguration(reviewConfiguration,causeThreads(started)),finalStarted);
|
|
787
869
|
pending=null;stage=finalResult.observationStatus==='completed'
|
|
788
870
|
?finalResult.review.verdict==='approved'?'final_review_evidence_required':finalResult.review.verdict==='changes_requested'?'final_review_changes_requested':'final_review_blocked':'unknown';
|
|
789
871
|
continue;
|
|
@@ -949,13 +1031,14 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
949
1031
|
}else need(!Object.hasOwn(pkg,'correction'),'cause_registration_mismatch');
|
|
950
1032
|
need(digest(pkg.identity)===digest(identity)&&pkg.defect===configuration.defect
|
|
951
1033
|
&&digest(pkg.reproduction)===digest(reproduction)&&digest(pkg.diagnosis)===digest(diagnosed)
|
|
952
|
-
&&digest(pkg.learning)===digest(learning)
|
|
1034
|
+
&&digest(pkg.learning)===digest(learning)
|
|
1035
|
+
&&digest(pkg.rediagnosis??null)===digest(rediagnosis===null?null:rediagnosisPackage(rediagnosis)),'cause_registration_mismatch');
|
|
953
1036
|
causeOrigin=stage;stage='unknown';pending='cause_review';continue;
|
|
954
1037
|
}
|
|
955
1038
|
if(record.id==='fix-cause-started'){
|
|
956
1039
|
need(pending==='cause_review'&&started===null&&record.kind==='result','fix_history_invalid');
|
|
957
1040
|
shape(record.payload,['providerThreadId']);id(record.payload.providerThreadId);started=record.payload.providerThreadId;
|
|
958
|
-
need(![...hostContextIds,configuration.causeReview.contextId,finalStarted,...configuration.causeReview.excludedThreadIds,
|
|
1041
|
+
need(![...hostContextIds,configuration.causeReview.contextId,finalStarted,rediagnosisThread,...configuration.causeReview.excludedThreadIds,
|
|
959
1042
|
causeAbandonment?.providerThreadId].includes(started),'cause_registration_mismatch');continue;
|
|
960
1043
|
}
|
|
961
1044
|
if(record.id==='fix-cause-result'){
|
|
@@ -963,7 +1046,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
963
1046
|
causeResult=inspectCauseResult(record.payload,cause,reviewConfiguration,started);causeResultPayload=record.payload;pending=null;
|
|
964
1047
|
stage=causeResult.observationStatus!=='completed'?'unknown':causeResult.review.verdict==='approved'
|
|
965
1048
|
?(causeResumeStage??(diagnosed.status==='design_change'?'design_change_required':'red_test_required'))
|
|
966
|
-
:causeResult.review.verdict==='changes_requested'?'rediagnosis_required':'cause_review_blocked';continue;
|
|
1049
|
+
:causeResult.review.verdict==='changes_requested'?(rediagnosis?'rediagnosis_review_limit_reached':'rediagnosis_required'):'cause_review_blocked';continue;
|
|
967
1050
|
}
|
|
968
1051
|
if(record.id.startsWith('fix-learning-')){
|
|
969
1052
|
need(record.kind==='result'&&pending===null&&['reproduce','diagnose','observation_resume_prepared','observation_diagnose_required'].includes(stage),'fix_history_invalid');
|
|
@@ -1011,6 +1094,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1011
1094
|
try{
|
|
1012
1095
|
const current=createFixCausePackage({codeProject:configuration.reproduction.cwd,defect:configuration.defect,
|
|
1013
1096
|
status:{identity,stage:'cause_review_required',reproduction,diagnosis:diagnosed,learning,
|
|
1097
|
+
...(rediagnosis?{rediagnosis}:{}),
|
|
1014
1098
|
...(cause.request.payload.reviewPackage.correction?{causeReviewCorrection:cause.request.payload.reviewPackage.correction}:{})}});
|
|
1015
1099
|
verifyFixCauseTransition(cause.request.payload.reviewPackage,current,authorBaseline,authored);
|
|
1016
1100
|
}catch{stage='cause_review_drift';}
|
|
@@ -1133,15 +1217,17 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1133
1217
|
// disconnect or cancellation observation. Each kind may be abandoned once.
|
|
1134
1218
|
const noReviewResult=(registration,result,kind)=>stage==='unknown'&®istration!==null
|
|
1135
1219
|
&&(pending===kind&&!result||pending===null&&result!==null&&result.observationStatus!=='completed');
|
|
1136
|
-
const causeNoResult=noReviewResult(cause,causeResult,'cause_review');
|
|
1220
|
+
const causeNoResult=rediagnosis===null&&noReviewResult(cause,causeResult,'cause_review');
|
|
1137
1221
|
const revisionNoResult=noReviewResult(revisionFinalRegistration,revisionFinalResult,'revision_final_review');
|
|
1138
|
-
|
|
1222
|
+
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;}
|
|
1223
|
+
const reviewAbandonable=!(configuration.externalModels||configuration.executionPolicy)&&causeNoResult&&!causeAbandonment?'cause_review':!(configuration.externalModels||configuration.executionPolicy)&&revisionNoResult&&!revisionAbandonment?'revision_final_review':null;
|
|
1139
1224
|
const status=json({identity,stage,pending,abandoned,executionActive:active!==null,reproduction,diagnosis:diagnosed,learning,causeReview:causeResult,
|
|
1140
1225
|
...(reviewAbandonable?{reviewAbandonable}:{}),
|
|
1226
|
+
...((configuration.externalModels||configuration.executionPolicy)&&stage==='unknown'?{reviewReconciliation:{available:reviewLedger.pending.length===1,invocationId:reviewLedger.pending[0]?.invocationId??null}}:{}),
|
|
1141
1227
|
...(causeNoResult&&causeAbandonment||revisionNoResult&&revisionAbandonment?{reviewAbandonBudgetExhausted:true}:{}),
|
|
1142
1228
|
...(causeAbandonment?{causeReviewAbandonment:causeAbandonment}:{}),
|
|
1143
1229
|
...(revisionAbandonment?{revisionFinalReviewAbandonment:revisionAbandonment}:{}),
|
|
1144
|
-
...(causeReviewCorrection?{causeReviewCorrection}:{}),
|
|
1230
|
+
...(causeReviewCorrection?{causeReviewCorrection}:{}),...(rediagnosis?{rediagnosis}:{}),
|
|
1145
1231
|
...(observationResume?{observationResume,observationCycle}:{}),
|
|
1146
1232
|
...(observationReproduction?{observationReproduction}:{}),
|
|
1147
1233
|
...(observationDiagnosis?{observationDiagnosis}:{}),
|
|
@@ -1177,15 +1263,26 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1177
1263
|
try{
|
|
1178
1264
|
// The existing shared writer lock is already held here: a live parent
|
|
1179
1265
|
// cannot overlap this child. Recheck current evidence before registration.
|
|
1180
|
-
if(Object.hasOwn(configuration,'qaSource')){
|
|
1266
|
+
if(!inspectionSnapshot&&Object.hasOwn(configuration,'qaSource')){
|
|
1181
1267
|
const completed=store.snapshot().records.length>0&&project().completionEligible===true;
|
|
1182
1268
|
(completed?readFixQaSourceHistory:inspectFixQaSource)({specsRoot,identity,configuration});
|
|
1183
1269
|
}
|
|
1184
1270
|
if(store.snapshot().records.length===0)append('fix-configuration','intent',initial);
|
|
1185
1271
|
project();
|
|
1186
|
-
}catch(error){
|
|
1272
|
+
}catch(error){closeStore();throw error;}
|
|
1187
1273
|
return Object.freeze({
|
|
1188
1274
|
status:project,
|
|
1275
|
+
reconcileReview({invocationId}={}){
|
|
1276
|
+
need(!closed&&active===null&&(configuration.externalModels||configuration.executionPolicy),'review_reconciliation_unavailable');id(invocationId);
|
|
1277
|
+
const ledger=fixReviewLedger(store.snapshot().records,configuration);
|
|
1278
|
+
if(ledger.applied.has(invocationId))return project();
|
|
1279
|
+
need(project().stage==='unknown','review_reconciliation_unavailable');
|
|
1280
|
+
const proof=ledger.pending.find(p=>p.invocationId===invocationId);
|
|
1281
|
+
need(proof,ledger.pending.length?'review_reconciliation_binding':'review_reconciliation_evidence_required');
|
|
1282
|
+
const {prefix,registeredDigest,startedDigest,resultDigest,receiptDigest}=proof;
|
|
1283
|
+
append('fix-review-reconciled-'+digest(invocationId).slice(0,24),'result',{prefix,invocationId,registeredDigest,startedDigest,resultDigest,receiptDigest});
|
|
1284
|
+
return project();
|
|
1285
|
+
},
|
|
1189
1286
|
abandonStep({reason,authorized=false}={}){
|
|
1190
1287
|
need(!closed&&active===null,'fix_busy');
|
|
1191
1288
|
const current=project();
|
|
@@ -1207,6 +1304,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1207
1304
|
// registration, thread and any no-result observation. The retry needs the
|
|
1208
1305
|
// original review permission and a fresh reviewer thread.
|
|
1209
1306
|
abandonReview({reason,authorized=false}={}){
|
|
1307
|
+
need(!(configuration.externalModels||configuration.executionPolicy),'external_review_reconciliation_required');
|
|
1210
1308
|
need(!closed&&active===null,'fix_busy');need(authorized===true,'fix_review_abandon_authorization_required');
|
|
1211
1309
|
need(typeof reason==='string'&&reason.trim().length>0&&Buffer.byteLength(reason,'utf8')<=1000
|
|
1212
1310
|
&&!/[\r\n\0\u0085\u2028\u2029]/.test(reason),'fix_review_abandon_reason_required');
|
|
@@ -1223,6 +1321,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1223
1321
|
return project();
|
|
1224
1322
|
},
|
|
1225
1323
|
recoverFinalReview({authorized=false,recoveryInvocationId=null,invocationId,packageDigest,previousInvocationStopped,reason}={}){
|
|
1324
|
+
need(!(configuration.externalModels||configuration.executionPolicy),'external_review_reconciliation_required');
|
|
1226
1325
|
need(!closed&&active===null,'fix_busy');need(authorized===true,'fix_review_recovery_authorization_required');
|
|
1227
1326
|
const current=project(),records=store.snapshot().records;
|
|
1228
1327
|
need(identity.attempt===1&¤t.stage==='unknown'&&!current.revision
|
|
@@ -1328,7 +1427,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1328
1427
|
const ended=escalationEvents(status,dossier);need(ended.length===1,'fix_escalation_exit_conflict');
|
|
1329
1428
|
if(!status.escalation)append('fix-escalation-result','result',{dossier,eventId:ended[0].event_id});
|
|
1330
1429
|
const result={...project(),dossier:archived.dossier,escalationRunEnded:true};
|
|
1331
|
-
closed=true;
|
|
1430
|
+
closed=true;closeStore();return result;
|
|
1332
1431
|
}
|
|
1333
1432
|
if(['observation','observation_not_reproduced','observation_needs_evidence'].includes(status.stage)){
|
|
1334
1433
|
const archived=this.publishDossier();
|
|
@@ -1342,7 +1441,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1342
1441
|
detail:`观测中:等${status.observationDiagnosis?.plan??status.diagnosis?.plan??JSON.stringify(configuration.reproduction.expectedFailure)}`,
|
|
1343
1442
|
data});
|
|
1344
1443
|
const result={...archived,observationRunEnded:true};
|
|
1345
|
-
closed=true;
|
|
1444
|
+
closed=true;closeStore();return result;
|
|
1346
1445
|
}
|
|
1347
1446
|
if(status.revisionN5){
|
|
1348
1447
|
need(['revision_closeout_required','revision_closeout_incomplete','completed'].includes(status.stage),'fix_closeout_unavailable');
|
|
@@ -1460,11 +1559,11 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1460
1559
|
const checks=reviewChecks(revising?start.revisionRegression:start.regression),selectedHandoff=revising?revisionHandoffPath():handoffPath();
|
|
1461
1560
|
const pkg=createReviewPackage({root:configuration.reproduction.cwd,baseline,checks,handoffPath:selectedHandoff});
|
|
1462
1561
|
if(start.finalReviewRecovery&&!revising)need(pkg.packageDigest===start.finalReviewRecovery.packageDigest,'fix_review_recovery_drift');
|
|
1463
|
-
const run=createFixFinalReview({reviewPackage:pkg,configuration:revising?fixRevisionReviewConfiguration(revisionFeedback(),start.revision.nextIdentity,hostContextIds):fixFinalReviewConfiguration(reviewConfiguration,start.causeReview?.providerThreadId
|
|
1562
|
+
const run=createFixFinalReview({reviewPackage:pkg,configuration:revising?fixRevisionReviewConfiguration(revisionFeedback(),start.revision.nextIdentity,hostContextIds):fixFinalReviewConfiguration(reviewConfiguration,causeThreads(start.causeReview?.providerThreadId)),
|
|
1464
1563
|
timeoutMs:reviewTimeout(finalReview,configuration.reproduction.timeoutMs)},finalReview);
|
|
1465
|
-
const controller=new AbortController();active=controller;let registered=false;
|
|
1564
|
+
const controller=new AbortController();active=controller;let registered=false,capturedReceipt=null,receiptConflict=false;
|
|
1466
1565
|
try{
|
|
1467
|
-
const result=await run({signal:controller.signal,register(value){
|
|
1566
|
+
const result=await run({signal:controller.signal,...((configuration.externalModels||configuration.executionPolicy)?{onReconciliation(raw){try{const receipt=readReconciliationReceipt(raw);if(capturedReceipt&&digest(receipt)!==digest(capturedReceipt))receiptConflict=true;else capturedReceipt=receipt;}catch{receiptConflict=true;}}}:{}),register(value){
|
|
1468
1567
|
need(project().stage===start.stage,'fix_evidence_changed');
|
|
1469
1568
|
if(!revising)need(!store.snapshot().records.some(row=>finalCycleRecord(row,'registered')
|
|
1470
1569
|
&&row.payload.request.invocationId===value.request.invocationId),'fix_review_recovery_mismatch');
|
|
@@ -1479,7 +1578,8 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1479
1578
|
append(`${prefix}-started`,'result',{providerThreadId});
|
|
1480
1579
|
}});
|
|
1481
1580
|
if(result.outcome==='denied')return {...project(),reason:'permission_denied'};
|
|
1482
|
-
if(result.outcome==='observed'&&!controller.signal.aborted)append(`${prefix}-result`,'result',result.value);
|
|
1581
|
+
if((result.outcome==='observed'||(configuration.externalModels||configuration.executionPolicy)&&result.value)&&!controller.signal.aborted)append(`${prefix}-result`,'result',result.value);
|
|
1582
|
+
if(!receiptConflict)saveReviewReceipt(prefix,capturedReceipt);
|
|
1483
1583
|
if(result.outcome==='unknown')return {...project(),reason:result.reason,diagnostic:result.diagnostic};
|
|
1484
1584
|
return project();
|
|
1485
1585
|
}catch(error){
|
|
@@ -1764,12 +1864,12 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1764
1864
|
need(configuration.causeReview&&causeReview&&typeof causeReview.authorize==='function'&&typeof causeReview.run==='function','cause_review_unavailable');
|
|
1765
1865
|
const reviewer=configuration.causeReview;
|
|
1766
1866
|
const budget=reviewTimeout(causeReview,configuration.reproduction.timeoutMs);
|
|
1767
|
-
const prefix=status.causeReviewAbandonment?'fix-cause-retry':'fix-cause';
|
|
1867
|
+
const prefix=status.rediagnosis?'fix-cause-rediagnosis':status.causeReviewAbandonment?'fix-cause-retry':'fix-cause';
|
|
1768
1868
|
const abandonedThread=status.causeReviewAbandonment?.providerThreadId??null;
|
|
1769
1869
|
const pkg=createFixCausePackage({codeProject:configuration.reproduction.cwd,defect:configuration.defect,status});
|
|
1770
1870
|
const request=requestFor({invocationId:`fix-cause.${randomUUID()}`,identity,role:'reviewer',provider:reviewer.provider,
|
|
1771
1871
|
requestedModel:reviewer.requestedModel,contextId:reviewer.contextId,payload:{reviewPackage:pkg,priorReview:null}});
|
|
1772
|
-
const controller=new AbortController();active=controller;let timer,registered=false;
|
|
1872
|
+
const controller=new AbortController();active=controller;let timer,registered=false,capturedReceipt=null,receiptConflict=false;
|
|
1773
1873
|
try{
|
|
1774
1874
|
const authorizationAt=Date.now(),grant=causeReview.authorize(request,{authorizationAt});
|
|
1775
1875
|
if(types.isPromise(grant)){grant.catch(()=>{});need(false,'cause_authorization_invalid');}
|
|
@@ -1789,7 +1889,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1789
1889
|
JSON.stringify(causeExpectation(request,reviewConfiguration)));
|
|
1790
1890
|
if(event.event==='thread.started'){
|
|
1791
1891
|
// A retry is a fresh reviewer thread, never the abandoned one.
|
|
1792
|
-
need(event.provider_thread!==abandonedThread,'observation_context');
|
|
1892
|
+
need(event.provider_thread!==abandonedThread&&event.provider_thread!==status.rediagnosis?.priorProviderThreadId,'observation_context');
|
|
1793
1893
|
append(`${prefix}-started`,'result',{providerThreadId:event.provider_thread});started=event.provider_thread;
|
|
1794
1894
|
}
|
|
1795
1895
|
events.push(event);return true;
|
|
@@ -1799,13 +1899,14 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1799
1899
|
const interrupted=new Promise((resolve,reject)=>{rejectAbort=()=>reject(Object.assign(new Error('cause_review_interrupted'),{code:'cause_review_interrupted'}));});
|
|
1800
1900
|
controller.signal.addEventListener('abort',rejectAbort,{once:true});
|
|
1801
1901
|
timer=setTimeout(()=>{timedOut=true;controller.abort();},budget);
|
|
1802
|
-
let result;
|
|
1902
|
+
let result,transport;
|
|
1803
1903
|
try{
|
|
1804
|
-
|
|
1904
|
+
transport=Promise.resolve().then(()=>{
|
|
1805
1905
|
need(!controller.signal.aborted,'cause_review_interrupted');
|
|
1806
|
-
return causeReview.run(request,{signal:controller.signal,onEvent});
|
|
1807
|
-
})
|
|
1808
|
-
|
|
1906
|
+
return causeReview.run(request,{signal:controller.signal,onEvent,...((configuration.externalModels||configuration.executionPolicy)?{onReconciliation(raw){try{const receipt=readReconciliationReceipt(raw);if(capturedReceipt&&digest(receipt)!==digest(capturedReceipt))receiptConflict=true;else capturedReceipt=receipt;}catch{receiptConflict=true;}}}:{})});
|
|
1907
|
+
});
|
|
1908
|
+
result=await Promise.race([interrupted,transport]);
|
|
1909
|
+
}catch(error){if(!timedOut||invalid)throw error;if((configuration.externalModels||configuration.executionPolicy)){let drain;await Promise.race([transport.catch(()=>{}),new Promise(resolve=>{drain=setTimeout(resolve,2500);})]);clearTimeout(drain);}}
|
|
1809
1910
|
finally{sealed=true;controller.signal.removeEventListener('abort',rejectAbort);}
|
|
1810
1911
|
// The review budget expiring is a recorded no-result observation, not an
|
|
1811
1912
|
// unrecorded interruption; a cancellation or invalid stream stays unknown.
|
|
@@ -1813,6 +1914,7 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1813
1914
|
const value={dispatchAt,observation:observation(timedOut?{status:'failed',code:'timeout'}:result)};
|
|
1814
1915
|
inspectCauseResult(value,registration,reviewConfiguration,started);
|
|
1815
1916
|
append(`${prefix}-result`,'result',value);
|
|
1917
|
+
if(!receiptConflict)saveReviewReceipt(prefix,capturedReceipt);
|
|
1816
1918
|
if(project().causeReview?.observationStatus==='completed')publishCause();
|
|
1817
1919
|
return project();
|
|
1818
1920
|
}catch(error){
|
|
@@ -1821,6 +1923,47 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1821
1923
|
}
|
|
1822
1924
|
finally{clearTimeout(timer);active=null;}
|
|
1823
1925
|
},
|
|
1926
|
+
async rediagnose({authorized=false,reason}={}){
|
|
1927
|
+
need(!closed&&active===null,'fix_busy');need(authorized===true,'fix_rediagnosis_authorization_required');
|
|
1928
|
+
const start=project();need(start.stage==='rediagnosis_required'&&!start.rediagnosis,'fix_rediagnosis_unavailable');
|
|
1929
|
+
text(reason);need(Buffer.byteLength(reason,'utf8')<=1000&&!/[\r\n\0\u0085\u2028\u2029]/.test(reason),'fix_rediagnosis_reason_invalid');
|
|
1930
|
+
need(bridge!==null,'fix_rediagnosis_unavailable');publishCause(true);
|
|
1931
|
+
const prior=causeRecord(store.snapshot().records,'registered').payload;
|
|
1932
|
+
const assertBasis=()=>{
|
|
1933
|
+
const pkg=createFixCausePackage({codeProject:configuration.reproduction.cwd,defect:configuration.defect,
|
|
1934
|
+
status:{...start,stage:'cause_review_required'}});
|
|
1935
|
+
need(pkg.packageDigest===prior.request.payload.reviewPackage.packageDigest,'fix_rediagnosis_source_changed');
|
|
1936
|
+
const slug=identity.taskId.slice(6);
|
|
1937
|
+
const slot=path.join(evidenceSpecsRoot,'.reviews',`fix-${slug}-cause-r2.md`);
|
|
1938
|
+
let occupied=false;
|
|
1939
|
+
try{fs.lstatSync(slot);occupied=true;}catch(error){if(error.code!=='ENOENT')throw error;}
|
|
1940
|
+
need(!occupied,'fix_rediagnosis_evidence_conflict');
|
|
1941
|
+
return pkg;
|
|
1942
|
+
};
|
|
1943
|
+
const pkg=assertBasis();
|
|
1944
|
+
const controller=new AbortController();active=controller;let registered=false,timer;
|
|
1945
|
+
try{
|
|
1946
|
+
timer=setTimeout(()=>controller.abort(),configuration.reproduction.timeoutMs);
|
|
1947
|
+
const learning=prepare===null?start.learning:inspectFixLearning(await prepare({identity,defect:configuration.defect},controller.signal));
|
|
1948
|
+
need(!controller.signal.aborted,'fix_learning_interrupted');
|
|
1949
|
+
need(project().stage===start.stage,'fix_evidence_changed');
|
|
1950
|
+
// Preparation awaits current-session work; recheck its original evidence before the single continuation is registered.
|
|
1951
|
+
assertBasis();
|
|
1952
|
+
const history=store.snapshot().records;
|
|
1953
|
+
append('fix-rediagnosis-intent','intent',{reason,historyDigest:digest(history),priorRegistrationDigest:digest(prior),
|
|
1954
|
+
priorObservationDigest:start.causeReview.observationDigest,priorPackageDigest:pkg.packageDigest,
|
|
1955
|
+
priorProviderThreadId:start.causeReview.providerThreadId,
|
|
1956
|
+
reviewFeedback:start.causeReview.review,learning});registered=true;
|
|
1957
|
+
const value=diagnosis(await bridge.call('fix_diagnose',{identity,defect:configuration.defect,
|
|
1958
|
+
codeProject:configuration.reproduction.cwd,reproduction:start.reproduction,previousDiagnosis:start.diagnosis,
|
|
1959
|
+
reviewFeedback:start.causeReview.review,diagnosticRecord:fixInvestigationRequest,
|
|
1960
|
+
...fixQaDiagnosisEvidence({specsRoot,identity,configuration})},controller.signal));
|
|
1961
|
+
if(controller.signal.aborted)return project();
|
|
1962
|
+
if(configuration.qaSource)inspectFixQaSource({specsRoot,identity,configuration});
|
|
1963
|
+
append('fix-rediagnosis-result','result',value);return project();
|
|
1964
|
+
}catch(error){if(!registered)throw error;return project();}
|
|
1965
|
+
finally{clearTimeout(timer);active=null;}
|
|
1966
|
+
},
|
|
1824
1967
|
async advance({authorized=false}={}){
|
|
1825
1968
|
need(!closed,'store_closed');need(active===null,'fix_busy');
|
|
1826
1969
|
const start=project();
|
|
@@ -1922,6 +2065,6 @@ export function openFixExecution(options,{bridge=null,prepare=null,causeReview=n
|
|
|
1922
2065
|
const current=project();if(current.stage==='cancelled'||current.stage==='escalated')return current;
|
|
1923
2066
|
append('fix-cancel','cancel',{reason:'user_cancelled'});active?.abort();return project();
|
|
1924
2067
|
},
|
|
1925
|
-
close(){need(active===null,'fix_busy');closed=true;
|
|
2068
|
+
close(){need(active===null,'fix_busy');closed=true;closeStore();},
|
|
1926
2069
|
});
|
|
1927
2070
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {readExecutionPolicy} from '../cm-ai/execution-policy.mjs';
|
|
2
|
+
import {inspectFixReconciledResult} from './review-reconciliation.mjs';
|
|
1
3
|
// Existing V3 grants and standard implementation-review observations only.
|
|
2
4
|
// The owning execution store registers callbacks; this module issues no receipt.
|
|
3
5
|
import {randomUUID} from 'node:crypto';
|
|
@@ -15,10 +17,10 @@ import {inspectFixRegressionFailure} from './regression-evidence.mjs';
|
|
|
15
17
|
export function fixFinalReviewConfiguration(configuration,causeThread=null){
|
|
16
18
|
const hosts=fixHostContexts(configuration);
|
|
17
19
|
const base=validateCauseReviewer(configuration.causeReview,hosts);
|
|
18
|
-
return {hostContextId:configuration.hostContextId,...(hosts.length>1?{hostContextIds:hosts}:{}),
|
|
20
|
+
return {...(configuration.executionPolicy?{executionPolicy:readExecutionPolicy(configuration.executionPolicy)}:{}),...(configuration.externalModels?{externalModels:configuration.externalModels}:{}),hostContextId:configuration.hostContextId,...(hosts.length>1?{hostContextIds:hosts}:{}),
|
|
19
21
|
reviewer:{...base,reviewerId:'fix-final-reviewer',
|
|
20
22
|
adapterId:`${base.provider}-review-adapter`,contextId:'fix-final-review-context',
|
|
21
|
-
excludedThreadIds:[...new Set([...base.excludedThreadIds,...(causeThread?[causeThread]:[])])]}};
|
|
23
|
+
excludedThreadIds:[...new Set([...base.excludedThreadIds,...(Array.isArray(causeThread)?causeThread:causeThread?[causeThread]:[])])]}};
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
function expectation(request,configuration){
|
|
@@ -46,7 +48,7 @@ function reviewDiagnostic(phase,error,event=null){
|
|
|
46
48
|
}
|
|
47
49
|
export function inspectFixFinalRegistration(raw,configuration){
|
|
48
50
|
const value=json(raw,12*1024*1024);shape(value,['request','authorizationAt','registeredAt','grant']);
|
|
49
|
-
const reviewer=validateCauseReviewer(configuration.reviewer,fixHostContexts(configuration),configuration.reviewFeedback?34
|
|
51
|
+
const reviewer=validateCauseReviewer(configuration.reviewer,fixHostContexts(configuration),configuration.reviewFeedback?35:34),request=value.request;
|
|
50
52
|
need(request.provider===reviewer.provider&&request.requestedModel===reviewer.requestedModel&&request.contextId===reviewer.contextId,'final_registration_mismatch');
|
|
51
53
|
const pkg=readReviewPackage(request.payload.reviewPackage);
|
|
52
54
|
const previous=configuration.reviewFeedback?inspectFixRepairReview(configuration.reviewFeedback,pkg.identity):null;
|
|
@@ -59,10 +61,12 @@ export function inspectFixFinalRegistration(raw,configuration){
|
|
|
59
61
|
return value;
|
|
60
62
|
}
|
|
61
63
|
export function inspectFixFinalResult(raw,registration,configuration,started){
|
|
62
|
-
const value=json(raw,1024*1024);shape(value,['dispatchAt','observation']);
|
|
64
|
+
const value=json(raw,1024*1024);shape(value,['dispatchAt','observation',...(Object.hasOwn(value,'reconciliationReceipt')?['reconciliationReceipt']:[])]);
|
|
63
65
|
need(Number.isSafeInteger(value.dispatchAt)&&value.dispatchAt>=registration.registeredAt
|
|
64
66
|
&&value.dispatchAt<registration.grant.expiresAt,'final_registration_mismatch');
|
|
65
|
-
|
|
67
|
+
need(!value.reconciliationReceipt||(configuration.externalModels||configuration.executionPolicy),'review_reconciliation_unavailable');
|
|
68
|
+
const expected=expectation(registration.request,configuration);
|
|
69
|
+
const checked=value.reconciliationReceipt?inspectFixReconciledResult(value,expected):inspectProviderReview(JSON.stringify(value.observation),JSON.stringify(expected));
|
|
66
70
|
need(checked.providerThreadId===started,'final_registration_mismatch');return checked;
|
|
67
71
|
}
|
|
68
72
|
|
|
@@ -108,16 +112,17 @@ export function fixRevisionReviewConfiguration(feedback,nextIdentity,hostContext
|
|
|
108
112
|
|
|
109
113
|
export function createFixFinalReview({reviewPackage,configuration,timeoutMs},{authorize,run}){
|
|
110
114
|
const pkg=readReviewPackage(reviewPackage);need(pkg.handoff,'final_handoff_required');
|
|
111
|
-
const config=json(configuration,12*1024*1024);shape(config,['hostContextId','reviewer',
|
|
115
|
+
const config=json(configuration,12*1024*1024);shape(config,['hostContextId','reviewer',...(Object.hasOwn(config,'externalModels')?['externalModels']:[]),...(Object.hasOwn(config,'executionPolicy')?['executionPolicy']:[]),
|
|
112
116
|
...(Object.hasOwn(config,'hostContextIds')?['hostContextIds']:[]),
|
|
113
117
|
...(Object.hasOwn(config,'reviewFeedback')?['reviewFeedback']:[])]);
|
|
118
|
+
if(config.executionPolicy)readExecutionPolicy(config.executionPolicy);
|
|
114
119
|
const previous=config.reviewFeedback?inspectFixRepairReview(config.reviewFeedback,pkg.identity):null;
|
|
115
|
-
const reviewer=validateCauseReviewer(config.reviewer,fixHostContexts(config),previous?34
|
|
120
|
+
const reviewer=validateCauseReviewer(config.reviewer,fixHostContexts(config),previous?35:34);
|
|
116
121
|
if(previous)need(reviewer.excludedThreadIds.includes(previous.providerThreadId),'final_context_mismatch');
|
|
117
122
|
need(Number.isInteger(timeoutMs)&&timeoutMs>0&&timeoutMs<=3600000,'invalid_timeout');
|
|
118
123
|
need(typeof authorize==='function'&&typeof run==='function','final_review_unavailable');
|
|
119
124
|
let used=false;
|
|
120
|
-
return async({signal,register,onStarted})=>{
|
|
125
|
+
return async({signal,register,onStarted,onReconciliation})=>{
|
|
121
126
|
need(!used,'final_review_already_attempted');need(!signal.aborted,'cancelled');
|
|
122
127
|
need(typeof register==='function'&&typeof onStarted==='function','final_registration_required');used=true;
|
|
123
128
|
const request=requestFor({invocationId:`fix-final.${randomUUID()}`,identity:pkg.identity,role:'reviewer',provider:reviewer.provider,
|
|
@@ -145,9 +150,11 @@ export function createFixFinalReview({reviewPackage,configuration,timeoutMs},{au
|
|
|
145
150
|
events.push(event);return true;
|
|
146
151
|
}catch(error){diagnostic=reviewDiagnostic(eventPhase,error,event);controller.abort();return false;}
|
|
147
152
|
};
|
|
153
|
+
let transport;
|
|
148
154
|
try{
|
|
149
155
|
timer=setTimeout(()=>{timedOut=true;controller.abort();},timeoutMs);
|
|
150
|
-
|
|
156
|
+
transport=Promise.resolve().then(()=>{need(!controller.signal.aborted,'cancelled');return run(request,{signal:controller.signal,onEvent,...(onReconciliation?{onReconciliation}:{})});});
|
|
157
|
+
const result=await Promise.race([interrupted,transport]);
|
|
151
158
|
need(!controller.signal.aborted,'interrupted');
|
|
152
159
|
const value={dispatchAt,observation:observation(result)};
|
|
153
160
|
phase='result';
|
|
@@ -155,7 +162,8 @@ export function createFixFinalReview({reviewPackage,configuration,timeoutMs},{au
|
|
|
155
162
|
return {outcome:'observed',value,inspection,completionEligible:false};
|
|
156
163
|
}catch(error){
|
|
157
164
|
const reason=timedOut?'timeout':signal.aborted?'cancelled':'transport_incomplete';
|
|
158
|
-
|
|
165
|
+
if(timedOut&&onReconciliation&&transport){let drain;await Promise.race([transport.catch(()=>{}),new Promise(resolve=>{drain=setTimeout(resolve,2500);})]);clearTimeout(drain);}
|
|
166
|
+
return {outcome:'unknown',...((config.externalModels||config.executionPolicy)&&timedOut&&!diagnostic?{value:{dispatchAt,observation:observation({status:'failed',code:'timeout'})}}:{}),reason,diagnostic:diagnostic??(reason==='transport_incomplete'
|
|
159
167
|
?reviewDiagnostic(phase,error):{phase:'transport',code:reason}),completionEligible:false};
|
|
160
168
|
}
|
|
161
169
|
finally{sealed=true;clearTimeout(timer);signal.removeEventListener('abort',cancel);controller.signal.removeEventListener('abort',rejectAbort);controller.abort();}
|
|
@@ -11,25 +11,8 @@ import {logFixEvent} from './start.mjs';
|
|
|
11
11
|
import {loadConfig} from '../../../scripts/cm-workflow-config.mjs';
|
|
12
12
|
import {fixDossierRelative} from './layout.mjs';
|
|
13
13
|
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
const base='.reviews/host-log-mirror/runs',directory=path.join(specsRoot,base);
|
|
17
|
-
if(!fs.existsSync(directory))return [];
|
|
18
|
-
const names=[];
|
|
19
|
-
for(const month of fs.readdirSync(directory).sort()){
|
|
20
|
-
need(/^\d{4}-\d{2}$/.test(month)&&fs.realpathSync(path.join(directory,month))===path.join(directory,month),'fix_log_failed');
|
|
21
|
-
for(const file of fs.readdirSync(path.join(directory,month)).sort())if(file.endsWith('.jsonl'))names.push(`${base}/${month}/${file}`);
|
|
22
|
-
}
|
|
23
|
-
return names.flatMap(name=>{
|
|
24
|
-
const [file]=readReviewSourceFiles(specsRoot,[name]);
|
|
25
|
-
return new TextDecoder('utf-8',{fatal:true}).decode(Buffer.from(file.contentBase64,'base64')).trim().split('\n').filter(Boolean).map(JSON.parse);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
if(!fs.existsSync(path.join(specsRoot,'运行日志.jsonl')))return [];
|
|
29
|
-
const [file]=readReviewSourceFiles(specsRoot,['运行日志.jsonl']);
|
|
30
|
-
const body=new TextDecoder('utf-8',{fatal:true}).decode(Buffer.from(file.contentBase64,'base64')).trim();
|
|
31
|
-
return body?body.split('\n').map(JSON.parse):[];
|
|
32
|
-
}
|
|
14
|
+
export {eventsAt} from './log-events.mjs';
|
|
15
|
+
import {eventsAt} from './log-events.mjs';
|
|
33
16
|
const matches=(row,identity)=>row.workflow==='cm-fix'&&row.node==='FIX'&&row.run_id===identity.runId
|
|
34
17
|
&&row.repository_id===identity.repositoryId&&row.task===identity.taskId&&row.attempt===identity.attempt;
|
|
35
18
|
export const isFixObservationExit=row=>row.event==='run_done'&&row.phase==='observation'&&row.result==='observing';
|