@resolveio/server-lib 22.3.130 → 22.3.132
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/package.json +1 -1
- package/util/ai-runner-manager-policy.d.ts +34 -0
- package/util/ai-runner-manager-policy.js +166 -9
- package/util/ai-runner-manager-policy.js.map +1 -1
- package/util/aicoder-runner-v6.d.ts +2 -0
- package/util/aicoder-runner-v6.js +64 -8
- package/util/aicoder-runner-v6.js.map +1 -1
- package/util/support-runner-v5.d.ts +3 -0
- package/util/support-runner-v5.js +44 -9
- package/util/support-runner-v5.js.map +1 -1
package/package.json
CHANGED
|
@@ -12,6 +12,38 @@ export interface ResolveIOAIManagerFailureRecord {
|
|
|
12
12
|
summary?: string;
|
|
13
13
|
recordedAt?: Date | string;
|
|
14
14
|
}
|
|
15
|
+
export type ResolveIOAIManagerRecoveryClass = 'advance_after_proof' | 'diagnosis_only' | 'diagnosis_revision' | 'infra_repair' | 'compile_repair' | 'journey_contract_repair' | 'business_proof_repair' | 'release_repair' | 'product_code_repair' | 'blocked_until_new_evidence' | 'manual_handoff' | 'continue';
|
|
16
|
+
export interface ResolveIOAIManagerRecoveryPlan {
|
|
17
|
+
recoveryClass: ResolveIOAIManagerRecoveryClass;
|
|
18
|
+
lane: string;
|
|
19
|
+
stepType: string;
|
|
20
|
+
nextActionLabel: string;
|
|
21
|
+
objective: string;
|
|
22
|
+
allowedAction: string;
|
|
23
|
+
productRepairAllowed: boolean;
|
|
24
|
+
expensiveModelAllowed: boolean;
|
|
25
|
+
maxAttemptsBeforePark: number;
|
|
26
|
+
finiteSteps: string[];
|
|
27
|
+
requiredEvidence: string[];
|
|
28
|
+
loopResetEvidence: string[];
|
|
29
|
+
forbiddenActions: string[];
|
|
30
|
+
notes: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface ResolveIOAIManagerRecoveryPlanInput {
|
|
33
|
+
action?: ResolveIOAIManagerAction | string;
|
|
34
|
+
reason?: string;
|
|
35
|
+
failureClass?: string;
|
|
36
|
+
lane?: string;
|
|
37
|
+
stepType?: string;
|
|
38
|
+
blocker?: string;
|
|
39
|
+
sameFailureCount?: number;
|
|
40
|
+
pingPongCount?: number;
|
|
41
|
+
newEvidence?: boolean;
|
|
42
|
+
productRepairFailure?: boolean;
|
|
43
|
+
changedFiles?: string[];
|
|
44
|
+
artifactPaths?: string[];
|
|
45
|
+
maxSameFailureRepeats?: number;
|
|
46
|
+
}
|
|
15
47
|
export interface ResolveIOAIManagerPolicyInput {
|
|
16
48
|
history?: ResolveIOAIManagerFailureRecord[];
|
|
17
49
|
current?: ResolveIOAIManagerFailureRecord;
|
|
@@ -31,8 +63,10 @@ export interface ResolveIOAIManagerPolicyDecision {
|
|
|
31
63
|
newEvidence: boolean;
|
|
32
64
|
loopBudgetShouldReset: boolean;
|
|
33
65
|
productRepairFailure: boolean;
|
|
66
|
+
recoveryPlan: ResolveIOAIManagerRecoveryPlan;
|
|
34
67
|
}
|
|
35
68
|
export declare function normalizeResolveIOAIManagerFailureClass(value: any): string;
|
|
36
69
|
export declare function fingerprintResolveIOAIManagerBlocker(value: any): string;
|
|
37
70
|
export declare function hashResolveIOAIManagerEvidence(record: ResolveIOAIManagerFailureRecord | undefined): string;
|
|
71
|
+
export declare function buildResolveIOAIManagerRecoveryPlan(input?: ResolveIOAIManagerRecoveryPlanInput): ResolveIOAIManagerRecoveryPlan;
|
|
38
72
|
export declare function decideResolveIOAIManagerPolicy(input: ResolveIOAIManagerPolicyInput): ResolveIOAIManagerPolicyDecision;
|
|
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
25
|
exports.normalizeResolveIOAIManagerFailureClass = normalizeResolveIOAIManagerFailureClass;
|
|
26
26
|
exports.fingerprintResolveIOAIManagerBlocker = fingerprintResolveIOAIManagerBlocker;
|
|
27
27
|
exports.hashResolveIOAIManagerEvidence = hashResolveIOAIManagerEvidence;
|
|
28
|
+
exports.buildResolveIOAIManagerRecoveryPlan = buildResolveIOAIManagerRecoveryPlan;
|
|
28
29
|
exports.decideResolveIOAIManagerPolicy = decideResolveIOAIManagerPolicy;
|
|
29
30
|
function cleanText(value, max) {
|
|
30
31
|
if (max === void 0) { max = 2000; }
|
|
@@ -131,6 +132,136 @@ function isPassingOutcome(record) {
|
|
|
131
132
|
function isManualOutcome(record) {
|
|
132
133
|
return /^(manual_handoff|park_manual|stopped)$/i.test(cleanText(record === null || record === void 0 ? void 0 : record.outcome, 80));
|
|
133
134
|
}
|
|
135
|
+
function buildResolveIOAIManagerRecoveryPlan(input) {
|
|
136
|
+
if (input === void 0) { input = {}; }
|
|
137
|
+
var action = cleanText(input.action, 80) || 'continue';
|
|
138
|
+
var reason = cleanText(input.reason, 240);
|
|
139
|
+
var failureClass = normalizeResolveIOAIManagerFailureClass(input.failureClass);
|
|
140
|
+
var lane = cleanText(input.lane, 80) || 'supervisor';
|
|
141
|
+
var stepType = cleanText(input.stepType, 80) || 'unknown';
|
|
142
|
+
var blocker = cleanText(input.blocker, 700);
|
|
143
|
+
var changedFiles = cleanList(input.changedFiles, 12, 240);
|
|
144
|
+
var artifactPaths = cleanList(input.artifactPaths, 12, 240);
|
|
145
|
+
var maxAttemptsBeforePark = Math.max(1, Number(input.maxSameFailureRepeats || 3) || 3);
|
|
146
|
+
var commonNotes = [
|
|
147
|
+
reason ? "policy_reason=".concat(reason) : '',
|
|
148
|
+
blocker ? "blocker=".concat(blocker) : '',
|
|
149
|
+
changedFiles.length ? "changed_files=".concat(changedFiles.join(', ')) : '',
|
|
150
|
+
artifactPaths.length ? "artifacts=".concat(artifactPaths.join(', ')) : ''
|
|
151
|
+
].filter(Boolean);
|
|
152
|
+
var base = {
|
|
153
|
+
lane: lane,
|
|
154
|
+
stepType: stepType,
|
|
155
|
+
maxAttemptsBeforePark: maxAttemptsBeforePark,
|
|
156
|
+
notes: commonNotes
|
|
157
|
+
};
|
|
158
|
+
var makePlan = function (recoveryClass, nextActionLabel, objective, allowedAction, productRepairAllowed, expensiveModelAllowed, finiteSteps, requiredEvidence, loopResetEvidence, forbiddenActions) { return (__assign(__assign({}, base), { recoveryClass: recoveryClass, nextActionLabel: nextActionLabel, objective: objective, allowedAction: allowedAction, productRepairAllowed: productRepairAllowed, expensiveModelAllowed: expensiveModelAllowed, finiteSteps: finiteSteps, requiredEvidence: requiredEvidence, loopResetEvidence: loopResetEvidence, forbiddenActions: forbiddenActions })); };
|
|
159
|
+
if (action === 'reset_loop_budget') {
|
|
160
|
+
return makePlan('advance_after_proof', 'Advance After Proof', 'Checkpoint the passing evidence and move to the next required gate.', 'advance_to_next_gate', false, false, [
|
|
161
|
+
'Record the passing artifact, changed files, and gate result.',
|
|
162
|
+
'Reset the loop counter because a real gate passed.',
|
|
163
|
+
'Select the next unmet deterministic gate instead of repeating the previous repair.'
|
|
164
|
+
], ['passing gate record', 'artifact or log proving the passed check'], ['new passing gate result', 'new business proof artifact'], ['rerun the same repair after a pass', 'mark accepted without the required downstream gate']);
|
|
165
|
+
}
|
|
166
|
+
if (action === 'manual_handoff') {
|
|
167
|
+
return makePlan('manual_handoff', 'Manual Review', 'Stop autonomous repair and expose the blocker, evidence, and last safe state.', 'manual_review_only', false, false, [
|
|
168
|
+
'Freeze further product-code edits.',
|
|
169
|
+
'Show the blocker fingerprint, evidence hash, and prior attempts.',
|
|
170
|
+
'Require a human edit to classification, scope, or retry policy before another model/code loop.'
|
|
171
|
+
], ['blocker fingerprint', 'evidence hash', 'attempt history'], ['manual policy change', 'new external evidence'], ['start another automatic model repair', 'hide the failed evidence']);
|
|
172
|
+
}
|
|
173
|
+
if (action === 'budget_stop') {
|
|
174
|
+
return makePlan('manual_handoff', 'Budget Stop Review', 'Stop autonomous model/code loops until a cheaper scoped next action is selected.', 'budget_review_only', false, false, [
|
|
175
|
+
'Freeze further model repair loops.',
|
|
176
|
+
'Show the prompt/token/runtime budget that tripped the guard.',
|
|
177
|
+
'Select a cheaper deterministic gate, infra repair, diagnosis revision, or manual scope edit before resuming.'
|
|
178
|
+
], ['budget guard reason', 'latest prompt estimate', 'last blocker/evidence hash'], ['manual scope reduction', 'new deterministic evidence', 'approved budget policy change'], ['start another broad model prompt', 'reset budget without new evidence', 'hide cost context']);
|
|
179
|
+
}
|
|
180
|
+
if (failureClass === 'diagnosis' || stepType === 'diagnosis_gate') {
|
|
181
|
+
return makePlan('diagnosis_only', 'Run Diagnosis Gate', 'Produce a falsifiable root-cause diagnosis before any repair.', 'read_only_diagnosis', false, true, [
|
|
182
|
+
'Reproduce or explicitly classify the customer issue.',
|
|
183
|
+
'Accept one falsifiable hypothesis and record rejected alternatives.',
|
|
184
|
+
'Identify the frontend/backend/shared failing path.',
|
|
185
|
+
'Select a small owner_files set.',
|
|
186
|
+
'Define exact before/action/after business proof.'
|
|
187
|
+
], ['issue_case', 'accepted_hypothesis', 'rejected_alternatives', 'failing_path', 'owner_files', 'proof_plan'], ['new reproduction artifact', 'new query/log/code evidence', 'validated diagnosis gate'], ['edit product code', 'run broad repo repair', 'accept route-load evidence as success']);
|
|
188
|
+
}
|
|
189
|
+
if (failureClass === 'owner_scope' || failureClass === 'out_of_scope' || /out.?of.?scope|owner_files/i.test(reason)) {
|
|
190
|
+
return makePlan('diagnosis_revision', 'Revise Diagnosis Scope', 'Revise owner_files only when new evidence proves the current scope is wrong.', 'diagnosis_revision_only', false, true, [
|
|
191
|
+
'Compare changed files against the diagnosis owner_files.',
|
|
192
|
+
'Collect evidence proving why the new file is in the failing path.',
|
|
193
|
+
'Update accepted_hypothesis, failing_path, owner_files, and proof_plan together.',
|
|
194
|
+
'Resume repair only after the revised gate validates.'
|
|
195
|
+
], ['out-of-scope file list', 'new failing-path evidence', 'revalidated diagnosis gate'], ['revised owner_files with evidence', 'new business proof requirement'], ['keep broad edits without diagnosis', 'add convenience refactors', 'continue repair outside owner_files']);
|
|
196
|
+
}
|
|
197
|
+
if (action === 'retry_infra') {
|
|
198
|
+
var isCompile = failureClass === 'compile';
|
|
199
|
+
return makePlan(isCompile ? 'compile_repair' : 'infra_repair', isCompile ? 'Repair Compile Gate' : 'Repair Infra Gate', isCompile
|
|
200
|
+
? 'Fix the deterministic compile/build blocker before spending another product repair loop.'
|
|
201
|
+
: 'Fix the deterministic harness/browser/server/Mongo blocker before product repair.', isCompile ? 'compile_repair_only' : 'infra_repair_only', false, false, isCompile
|
|
202
|
+
? [
|
|
203
|
+
'Read the exact compile/build log and identify the first actionable error.',
|
|
204
|
+
'Fix missing dependency, stale artifact, command, cache, or type wiring required by the compile gate.',
|
|
205
|
+
'Rerun the same finite compile command.',
|
|
206
|
+
'Return the compile log artifact and status.'
|
|
207
|
+
]
|
|
208
|
+
: [
|
|
209
|
+
'Run preflight for Puppeteer, Chrome executable, ports, Mongo/settings, and startup command.',
|
|
210
|
+
'Repair only the failing harness/environment item.',
|
|
211
|
+
'Rerun the same infra check.',
|
|
212
|
+
'Return the infra log and pass/fail status.'
|
|
213
|
+
], isCompile
|
|
214
|
+
? ['compile command', 'compile log artifact', 'first failing error fixed or still failing']
|
|
215
|
+
: ['preflight command', 'infra log artifact', 'specific repaired environment item'], ['same check now passes', 'new infra/compile blocker hash'], ['run product-code model repair', 'count this as product failure', 'accept route/business success without the compile/infra gate']);
|
|
216
|
+
}
|
|
217
|
+
if (action === 'park_repeated_failure' || action === 'park_ping_pong') {
|
|
218
|
+
return makePlan('blocked_until_new_evidence', action === 'park_ping_pong' ? 'Park Ping-Pong Loop' : 'Park Repeated Failure', 'Stop the current loop until new evidence changes the diagnosis, route, or repair target.', 'collect_new_evidence_only', false, false, [
|
|
219
|
+
'Do not rerun the same prompt or same repair.',
|
|
220
|
+
'Show the repeated blocker and evidence hash.',
|
|
221
|
+
'Collect a new artifact: failing DOM state, stack trace, network response, Mongo delta, compile log, or revised diagnosis.',
|
|
222
|
+
'Reset the loop only after the new evidence hash changes.'
|
|
223
|
+
], ['same failure count', 'blocker fingerprint', 'evidence hash'], ['changed evidence hash', 'new artifact path', 'revised diagnosis or journey contract'], ['alternate between two failed patches', 'increase loop budget without evidence', 'hide the park reason']);
|
|
224
|
+
}
|
|
225
|
+
if (failureClass === 'journey') {
|
|
226
|
+
return makePlan('journey_contract_repair', 'Repair Journey Contract', 'Fix the first/next/last workflow contract before app code work continues.', 'journey_contract_repair', false, true, [
|
|
227
|
+
'Open docs/APP_JOURNEY_CONTRACT.md.',
|
|
228
|
+
'Define first_screen, north_star_workflow, screen_sequence, data_story, completion_states, and qa_assertions.',
|
|
229
|
+
'Ensure each CTA maps to an action, route, method, calculation, or state transition.',
|
|
230
|
+
'Validate that sample data can drive the promised workflow.'
|
|
231
|
+
], ['validated journey_contract JSON', 'CTA-to-action mapping', 'workflow QA assertions'], ['journey validation passes', 'new workflow QA rows generated'], ['build empty routes', 'add link-only dashboard actions', 'defer workflow design to wow pass']);
|
|
232
|
+
}
|
|
233
|
+
if (failureClass === 'release') {
|
|
234
|
+
return makePlan('release_repair', 'Repair Release Gate', 'Repair deploy/publish/sample-data release evidence without rewriting working app flow.', 'release_repair_only', false, false, [
|
|
235
|
+
'Read the deploy/publish/sample-data log.',
|
|
236
|
+
'Identify whether the blocker is domain, asset, seed data, route, permission, or CDN.',
|
|
237
|
+
'Repair the release artifact/config/seed issue.',
|
|
238
|
+
'Rerun only the failed release gate.'
|
|
239
|
+
], ['deploy or publish log', 'sample-data status', 'failed release gate rerun'], ['release gate passes', 'new release blocker hash'], ['change core workflow after business QA passed', 'mark accepted from scorecard only', 'rerun full builder loop']);
|
|
240
|
+
}
|
|
241
|
+
if (failureClass === 'business' || failureClass === 'qa_evidence' || failureClass === 'route') {
|
|
242
|
+
return makePlan('business_proof_repair', 'Repair Business Proof', 'Fix the exact failing workflow assertion and prove before/action/after behavior.', 'business_repair', true, true, [
|
|
243
|
+
'Open the failing QA row or proof_plan.',
|
|
244
|
+
'Trace the UI action to method/publication/query/calculation.',
|
|
245
|
+
'Patch the smallest owner or workflow files.',
|
|
246
|
+
'Rerun only the failed business assertion.',
|
|
247
|
+
'Record DOM/data/Mongo/artifact proof.'
|
|
248
|
+
], ['failing assertion', 'action trace', 'business proof artifact'], ['business assertion passes', 'new failed assertion with new evidence'], ['treat route load as success', 'rerun unrelated QA rows first', 'accept scorecard-only evidence']);
|
|
249
|
+
}
|
|
250
|
+
if (input.productRepairFailure !== false || failureClass === 'product_code') {
|
|
251
|
+
return makePlan('product_code_repair', 'Run Targeted Product Repair', 'Repair the current product-code blocker with the smallest scoped edit and immediate proof.', 'targeted_product_repair', true, true, [
|
|
252
|
+
'Inspect the current blocker, artifacts, changed files, and owner/workflow scope.',
|
|
253
|
+
'Form one small repair hypothesis.',
|
|
254
|
+
'Patch only files justified by the active diagnosis or journey contract.',
|
|
255
|
+
'Rerun the smallest failed gate.',
|
|
256
|
+
'Record new evidence before any additional loop.'
|
|
257
|
+
], ['owner/workflow scope', 'repair diff', 'failed gate rerun artifact'], ['new evidence hash', 'same gate passes'], ['broad repo search-and-edit', 'rerun the same prompt without inspecting artifacts', 'change unrelated UI polish']);
|
|
258
|
+
}
|
|
259
|
+
return makePlan('continue', 'Continue Current Gate', 'Continue the current lane because no blocking loop or infra condition was detected.', 'continue', false, false, [
|
|
260
|
+
'Use the active lane memory.',
|
|
261
|
+
'Run the next finite gate.',
|
|
262
|
+
'Record artifacts and evidence hash.'
|
|
263
|
+
], ['active lane memory', 'finite gate artifact'], ['new gate result', 'new artifact path'], ['spawn duplicate runners', 'advance without evidence']);
|
|
264
|
+
}
|
|
134
265
|
function collectOpenTail(records) {
|
|
135
266
|
var tail = [];
|
|
136
267
|
for (var index = records.length - 1; index >= 0; index -= 1) {
|
|
@@ -208,27 +339,53 @@ function decideResolveIOAIManagerPolicy(input) {
|
|
|
208
339
|
loopBudgetShouldReset: false,
|
|
209
340
|
productRepairFailure: !infraClasses.has(failureClass) && !ignoredClasses.has(failureClass)
|
|
210
341
|
};
|
|
342
|
+
var withPlan = function (action, reason, overrides) {
|
|
343
|
+
if (overrides === void 0) { overrides = {}; }
|
|
344
|
+
var merged = __assign(__assign({}, base), overrides);
|
|
345
|
+
return __assign(__assign({}, merged), { action: action, reason: reason, recoveryPlan: buildResolveIOAIManagerRecoveryPlan({
|
|
346
|
+
action: action,
|
|
347
|
+
reason: reason,
|
|
348
|
+
failureClass: merged.failureClass,
|
|
349
|
+
lane: current.lane,
|
|
350
|
+
stepType: current.stepType,
|
|
351
|
+
blocker: current.blocker || current.summary,
|
|
352
|
+
sameFailureCount: merged.sameFailureCount,
|
|
353
|
+
pingPongCount: merged.pingPongCount,
|
|
354
|
+
newEvidence: merged.newEvidence,
|
|
355
|
+
productRepairFailure: merged.productRepairFailure,
|
|
356
|
+
changedFiles: current.changedFiles,
|
|
357
|
+
artifactPaths: current.artifactPaths,
|
|
358
|
+
maxSameFailureRepeats: maxSameFailureRepeats
|
|
359
|
+
}) });
|
|
360
|
+
};
|
|
211
361
|
if (isPassingOutcome(current)) {
|
|
212
|
-
return
|
|
362
|
+
return withPlan('reset_loop_budget', 'manager_policy_progress_passed', {
|
|
363
|
+
loopBudgetShouldReset: true,
|
|
364
|
+
productRepairFailure: false
|
|
365
|
+
});
|
|
213
366
|
}
|
|
214
367
|
if (isManualOutcome(current)) {
|
|
215
|
-
return
|
|
368
|
+
return withPlan('manual_handoff', 'manager_policy_manual_or_stopped');
|
|
216
369
|
}
|
|
217
370
|
if (infraClasses.has(failureClass)) {
|
|
218
|
-
return
|
|
371
|
+
return withPlan('retry_infra', 'manager_policy_infra_failure_routes_to_infra_repair', {
|
|
372
|
+
productRepairFailure: false
|
|
373
|
+
});
|
|
219
374
|
}
|
|
220
375
|
if (pingPongCount >= maxPingPongTransitions) {
|
|
221
|
-
return
|
|
376
|
+
return withPlan('park_ping_pong', 'manager_policy_ping_pong_failure_loop');
|
|
222
377
|
}
|
|
223
378
|
if (sameFailureCount >= maxSameFailureRepeats && !newEvidence) {
|
|
224
|
-
return
|
|
379
|
+
return withPlan('park_repeated_failure', 'manager_policy_same_failure_without_new_evidence');
|
|
225
380
|
}
|
|
226
381
|
if (newEvidence || !previousSameFailure) {
|
|
227
|
-
return
|
|
228
|
-
|
|
229
|
-
|
|
382
|
+
return withPlan('continue', newEvidence
|
|
383
|
+
? 'manager_policy_new_evidence_resets_loop_budget'
|
|
384
|
+
: 'manager_policy_new_failure_or_lane', {
|
|
385
|
+
loopBudgetShouldReset: true
|
|
386
|
+
});
|
|
230
387
|
}
|
|
231
|
-
return
|
|
388
|
+
return withPlan('continue', 'manager_policy_retry_below_repeat_limit');
|
|
232
389
|
}
|
|
233
390
|
|
|
234
391
|
//# sourceMappingURL=ai-runner-manager-policy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/ai-runner-manager-policy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4EA,0FAiBC;AAED,oFAUC;AAED,wEAcC;AA6ED,wEAgFC;AA1OD,SAAS,SAAS,CAAC,KAAU,EAAE,GAAU;IAAV,oBAAA,EAAA,UAAU;IACxC,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,SAAS,CAAC,MAAW,EAAE,KAAU,EAAE,GAAS;;IAArB,sBAAA,EAAA,UAAU;IAAE,oBAAA,EAAA,SAAS;IACpD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAC;IACX,CAAC;IACD,IAAM,MAAM,GAAa,EAAE,CAAC;;QAC5B,KAAoB,IAAA,WAAA,SAAA,MAAM,CAAA,8BAAA,kDAAE,CAAC;YAAxB,IAAM,KAAK,mBAAA;YACf,IAAM,UAAU,GAAG,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACzC,IAAI,UAAU,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;g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;gBAClB,CAAC,CAAC,gDAAgD;gBAClD,CAAC,CAAC,oCAAoC,EACvC,qBAAqB,EAAE,IAAI,IAC1B;IACH,CAAC;IACD,6BACI,IAAI,KACP,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,yCAAyC,IAChD;AACH,CAAC","file":"ai-runner-manager-policy.js","sourcesContent":["export type ResolveIOAIManagerAction =\n\t| 'continue'\n\t| 'retry_infra'\n\t| 'reset_loop_budget'\n\t| 'park_repeated_failure'\n\t| 'park_ping_pong'\n\t| 'manual_handoff';\n\nexport interface ResolveIOAIManagerFailureRecord {\n\toutcome?: string;\n\tlane?: string;\n\tstepType?: string;\n\tfailureClass?: string;\n\tblocker?: string;\n\tblockerFingerprint?: string;\n\tevidenceHash?: string;\n\tchangedFiles?: string[];\n\tartifactPaths?: string[];\n\tsummary?: string;\n\trecordedAt?: Date | string;\n}\n\nexport interface ResolveIOAIManagerPolicyInput {\n\thistory?: ResolveIOAIManagerFailureRecord[];\n\tcurrent?: ResolveIOAIManagerFailureRecord;\n\tmaxSameFailureRepeats?: number;\n\tmaxPingPongTransitions?: number;\n\tinfraFailureClasses?: string[];\n\tignoredFailureClasses?: string[];\n}\n\nexport interface ResolveIOAIManagerPolicyDecision {\n\taction: ResolveIOAIManagerAction;\n\treason: string;\n\tfailureClass: string;\n\tblockerFingerprint: string;\n\tevidenceHash: string;\n\tsameFailureCount: number;\n\tpingPongCount: number;\n\tnewEvidence: boolean;\n\tloopBudgetShouldReset: boolean;\n\tproductRepairFailure: boolean;\n}\n\nfunction cleanText(value: any, max = 2000): string {\n\treturn String(value || '').replace(/\\s+/g, ' ').trim().slice(0, max);\n}\n\nfunction cleanList(values: any, limit = 40, max = 500): string[] {\n\tif (!Array.isArray(values)) {\n\t\treturn [];\n\t}\n\tconst result: string[] = [];\n\tfor (const value of values) {\n\t\tconst normalized = cleanText(value, max);\n\t\tif (normalized && !result.includes(normalized)) {\n\t\t\tresult.push(normalized);\n\t\t}\n\t\tif (result.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn result;\n}\n\nfunction stableHash(prefix: string, value: any): string {\n\tconst normalized = typeof value === 'string'\n\t\t? cleanText(value, 12000)\n\t\t: JSON.stringify(value || {});\n\tlet hash = 0;\n\tfor (let index = 0; index < normalized.length; index += 1) {\n\t\thash = ((hash << 5) - hash + normalized.charCodeAt(index)) | 0;\n\t}\n\treturn `${prefix}-${Math.abs(hash).toString(36) || '0'}`;\n}\n\nexport function normalizeResolveIOAIManagerFailureClass(value: any): string {\n\tconst normalized = cleanText(value, 80)\n\t\t.toLowerCase()\n\t\t.replace(/[\\s-]+/g, '_');\n\tif (!normalized) {\n\t\treturn 'unknown';\n\t}\n\tif (/^(qa_infra|infrastructure|harness|puppeteer|chrome|mongo|port|startup)$/.test(normalized)) {\n\t\treturn 'infra';\n\t}\n\tif (/^(build|compile|typescript|tsc|angular_build|ng_build)$/.test(normalized)) {\n\t\treturn 'compile';\n\t}\n\tif (/^(false_pass|route_only|missing_business_proof)$/.test(normalized)) {\n\t\treturn 'business';\n\t}\n\treturn normalized.slice(0, 80);\n}\n\nexport function fingerprintResolveIOAIManagerBlocker(value: any): string {\n\tconst normalized = cleanText(value, 4000)\n\t\t.toLowerCase()\n\t\t.replace(/[a-f0-9]{16,}/g, '<id>')\n\t\t.replace(/\\b\\d{2,}\\b/g, '<n>')\n\t\t.replace(/\\bline\\s+<n>\\b/g, 'line <n>')\n\t\t.replace(/https?:\\/\\/\\S+/g, '<url>')\n\t\t.replace(/\\s+/g, ' ')\n\t\t.trim();\n\treturn stableHash('mgr-blocker', normalized);\n}\n\nexport function hashResolveIOAIManagerEvidence(record: ResolveIOAIManagerFailureRecord | undefined): string {\n\tif (!record) {\n\t\treturn stableHash('mgr-evidence', '');\n\t}\n\tconst explicit = cleanText(record.evidenceHash, 120);\n\tif (explicit) {\n\t\treturn explicit;\n\t}\n\treturn stableHash('mgr-evidence', {\n\t\tfailureClass: normalizeResolveIOAIManagerFailureClass(record.failureClass),\n\t\tblocker: cleanText(record.blocker || record.summary, 2000),\n\t\tchangedFiles: cleanList(record.changedFiles, 80, 500).sort(),\n\t\tartifactPaths: cleanList(record.artifactPaths, 80, 500).sort()\n\t});\n}\n\nfunction failureKey(record: ResolveIOAIManagerFailureRecord | undefined): string {\n\tif (!record) {\n\t\treturn '';\n\t}\n\tconst failureClass = normalizeResolveIOAIManagerFailureClass(record.failureClass);\n\tconst blockerFingerprint = cleanText(record.blockerFingerprint, 120)\n\t\t|| fingerprintResolveIOAIManagerBlocker(record.blocker || record.summary || '');\n\treturn `${cleanText(record.lane, 80)}:${cleanText(record.stepType, 80)}:${failureClass}:${blockerFingerprint}`;\n}\n\nfunction failureEvidenceKey(record: ResolveIOAIManagerFailureRecord | undefined): string {\n\treturn `${failureKey(record)}:${hashResolveIOAIManagerEvidence(record)}`;\n}\n\nfunction isPassingOutcome(record: ResolveIOAIManagerFailureRecord | undefined): boolean {\n\treturn /^(pass|accepted|ready_to_publish|published|ready_for_merge|complete|completed)$/i.test(cleanText(record?.outcome, 80));\n}\n\nfunction isManualOutcome(record: ResolveIOAIManagerFailureRecord | undefined): boolean {\n\treturn /^(manual_handoff|park_manual|stopped)$/i.test(cleanText(record?.outcome, 80));\n}\n\nfunction collectOpenTail(records: ResolveIOAIManagerFailureRecord[]): ResolveIOAIManagerFailureRecord[] {\n\tconst tail: ResolveIOAIManagerFailureRecord[] = [];\n\tfor (let index = records.length - 1; index >= 0; index -= 1) {\n\t\tconst record = records[index];\n\t\tif (isPassingOutcome(record)) {\n\t\t\tbreak;\n\t\t}\n\t\ttail.unshift(record);\n\t}\n\treturn tail;\n}\n\nfunction countSameFailure(records: ResolveIOAIManagerFailureRecord[], current: ResolveIOAIManagerFailureRecord): number {\n\tconst currentKey = failureEvidenceKey(current);\n\tlet count = 0;\n\tfor (let index = records.length - 1; index >= 0; index -= 1) {\n\t\tconst record = records[index];\n\t\tif (isPassingOutcome(record)) {\n\t\t\tbreak;\n\t\t}\n\t\tif (failureEvidenceKey(record) !== currentKey) {\n\t\t\tbreak;\n\t\t}\n\t\tcount += 1;\n\t}\n\treturn count;\n}\n\nfunction countPingPong(records: ResolveIOAIManagerFailureRecord[], current: ResolveIOAIManagerFailureRecord): number {\n\tconst tail = collectOpenTail(records).filter((record) => {\n\t\treturn cleanText(record.lane, 80) === cleanText(current.lane, 80)\n\t\t\t&& cleanText(record.stepType, 80) === cleanText(current.stepType, 80);\n\t});\n\tif (tail.length < 4) {\n\t\treturn 0;\n\t}\n\tconst keys = tail.map(failureKey).filter(Boolean);\n\tconst last = keys.slice(-6);\n\tif (last.length < 4) {\n\t\treturn 0;\n\t}\n\tconst distinct = Array.from(new Set(last));\n\tif (distinct.length !== 2) {\n\t\treturn 0;\n\t}\n\tfor (let index = 2; index < last.length; index += 1) {\n\t\tif (last[index] !== last[index - 2]) {\n\t\t\treturn 0;\n\t\t}\n\t}\n\treturn last.length - 1;\n}\n\nexport function decideResolveIOAIManagerPolicy(input: ResolveIOAIManagerPolicyInput): ResolveIOAIManagerPolicyDecision {\n\tconst history = Array.isArray(input.history) ? input.history : [];\n\tconst current = input.current || history[history.length - 1] || {};\n\tconst failureClass = normalizeResolveIOAIManagerFailureClass(current.failureClass);\n\tconst blockerFingerprint = cleanText(current.blockerFingerprint, 120)\n\t\t|| fingerprintResolveIOAIManagerBlocker(current.blocker || current.summary || '');\n\tconst evidenceHash = hashResolveIOAIManagerEvidence(current);\n\tconst previous = history.length > 1 ? history[history.length - 2] : undefined;\n\tconst previousSameFailure = previous && failureKey(previous) === failureKey(current);\n\tconst previousEvidenceHash = previousSameFailure ? hashResolveIOAIManagerEvidence(previous) : '';\n\tconst newEvidence = !!previousSameFailure && !!previousEvidenceHash && previousEvidenceHash !== evidenceHash;\n\tconst sameFailureCount = countSameFailure(history, current);\n\tconst pingPongCount = countPingPong(history, current);\n\tconst maxSameFailureRepeats = Math.max(1, Number(input.maxSameFailureRepeats || 3) || 3);\n\tconst maxPingPongTransitions = Math.max(3, Number(input.maxPingPongTransitions || 3) || 3);\n\tconst infraClasses = new Set((input.infraFailureClasses || ['infra', 'compile']).map(normalizeResolveIOAIManagerFailureClass));\n\tconst ignoredClasses = new Set((input.ignoredFailureClasses || []).map(normalizeResolveIOAIManagerFailureClass));\n\tconst base = {\n\t\tfailureClass,\n\t\tblockerFingerprint,\n\t\tevidenceHash,\n\t\tsameFailureCount,\n\t\tpingPongCount,\n\t\tnewEvidence,\n\t\tloopBudgetShouldReset: false,\n\t\tproductRepairFailure: !infraClasses.has(failureClass) && !ignoredClasses.has(failureClass)\n\t};\n\tif (isPassingOutcome(current)) {\n\t\treturn {\n\t\t\t...base,\n\t\t\taction: 'reset_loop_budget',\n\t\t\treason: 'manager_policy_progress_passed',\n\t\t\tloopBudgetShouldReset: true,\n\t\t\tproductRepairFailure: false\n\t\t};\n\t}\n\tif (isManualOutcome(current)) {\n\t\treturn {\n\t\t\t...base,\n\t\t\taction: 'manual_handoff',\n\t\t\treason: 'manager_policy_manual_or_stopped'\n\t\t};\n\t}\n\tif (infraClasses.has(failureClass)) {\n\t\treturn {\n\t\t\t...base,\n\t\t\taction: 'retry_infra',\n\t\t\treason: 'manager_policy_infra_failure_routes_to_infra_repair',\n\t\t\tproductRepairFailure: false\n\t\t};\n\t}\n\tif (pingPongCount >= maxPingPongTransitions) {\n\t\treturn {\n\t\t\t...base,\n\t\t\taction: 'park_ping_pong',\n\t\t\treason: 'manager_policy_ping_pong_failure_loop'\n\t\t};\n\t}\n\tif (sameFailureCount >= maxSameFailureRepeats && !newEvidence) {\n\t\treturn {\n\t\t\t...base,\n\t\t\taction: 'park_repeated_failure',\n\t\t\treason: 'manager_policy_same_failure_without_new_evidence'\n\t\t};\n\t}\n\tif (newEvidence || !previousSameFailure) {\n\t\treturn {\n\t\t\t...base,\n\t\t\taction: 'continue',\n\t\t\treason: newEvidence\n\t\t\t\t? 'manager_policy_new_evidence_resets_loop_budget'\n\t\t\t\t: 'manager_policy_new_failure_or_lane',\n\t\t\tloopBudgetShouldReset: true\n\t\t};\n\t}\n\treturn {\n\t\t...base,\n\t\taction: 'continue',\n\t\treason: 'manager_policy_retry_below_repeat_limit'\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/util/ai-runner-manager-policy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4HA,0FAiBC;AAED,oFAUC;AAED,wEAcC;AAwBD,kFA2RC;AAuDD,wEAqFC;AA5gBD,SAAS,SAAS,CAAC,KAAU,EAAE,GAAU;IAAV,oBAAA,EAAA,UAAU;IACxC,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,SAAS,CAAC,MAAW,EAAE,KAAU,EAAE,GAAS;;IAArB,sBAAA,EAAA,UAAU;IAAE,oBAAA,EAAA,SAAS;IACpD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAC;IACX,CAAC;IACD,IAAM,MAAM,GAAa,EAAE,CAAC;;QAC5B,KAAoB,IAAA,WAAA,SAAA,MAAM,CAAA,8BAAA,kDAAE,CAAC;YAAxB,IAAM,KAAK,mBAAA;YACf,IAAM,UAAU,GAAG,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACzC,IAAI,UAAU,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;gBAChD,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACzB,CAAC;YACD,IAAI,MAAM,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;gBAC5B,MAAM;YACP,CAAC;QACF,CAAC;;;;;;;;;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,UAAU,CAAC,MAAc,EAAE,KAAU;IAC7C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AAE,CAAC;QAC/D,OAAO,QAAQ,CAAC,uBAAuB,EAAE,kDAAkD,CAAC,CAAC;IAC9F,CAAC;IACD,IAAI,WAAW,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzC,OAAO,QAAQ,CAAC,UAAU,EAAE,WAAW;YACrC,CAAC,CAAC,gDAAgD;YAClD,CAAC,CAAC,oCAAoC,EAAE;YACzC,qBAAqB,EAAE,IAAI;SAC3B,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC,UAAU,EAAE,yCAAyC,CAAC,CAAC;AACxE,CAAC","file":"ai-runner-manager-policy.js","sourcesContent":["export type ResolveIOAIManagerAction =\n\t| 'continue'\n\t| 'retry_infra'\n\t| 'reset_loop_budget'\n\t| 'park_repeated_failure'\n\t| 'park_ping_pong'\n\t| 'manual_handoff';\n\nexport interface ResolveIOAIManagerFailureRecord {\n\toutcome?: string;\n\tlane?: string;\n\tstepType?: string;\n\tfailureClass?: string;\n\tblocker?: string;\n\tblockerFingerprint?: string;\n\tevidenceHash?: string;\n\tchangedFiles?: string[];\n\tartifactPaths?: string[];\n\tsummary?: string;\n\trecordedAt?: Date | string;\n}\n\nexport type ResolveIOAIManagerRecoveryClass =\n\t| 'advance_after_proof'\n\t| 'diagnosis_only'\n\t| 'diagnosis_revision'\n\t| 'infra_repair'\n\t| 'compile_repair'\n\t| 'journey_contract_repair'\n\t| 'business_proof_repair'\n\t| 'release_repair'\n\t| 'product_code_repair'\n\t| 'blocked_until_new_evidence'\n\t| 'manual_handoff'\n\t| 'continue';\n\nexport interface ResolveIOAIManagerRecoveryPlan {\n\trecoveryClass: ResolveIOAIManagerRecoveryClass;\n\tlane: string;\n\tstepType: string;\n\tnextActionLabel: string;\n\tobjective: string;\n\tallowedAction: string;\n\tproductRepairAllowed: boolean;\n\texpensiveModelAllowed: boolean;\n\tmaxAttemptsBeforePark: number;\n\tfiniteSteps: string[];\n\trequiredEvidence: string[];\n\tloopResetEvidence: string[];\n\tforbiddenActions: string[];\n\tnotes: string[];\n}\n\nexport interface ResolveIOAIManagerRecoveryPlanInput {\n\taction?: ResolveIOAIManagerAction | string;\n\treason?: string;\n\tfailureClass?: string;\n\tlane?: string;\n\tstepType?: string;\n\tblocker?: string;\n\tsameFailureCount?: number;\n\tpingPongCount?: number;\n\tnewEvidence?: boolean;\n\tproductRepairFailure?: boolean;\n\tchangedFiles?: string[];\n\tartifactPaths?: string[];\n\tmaxSameFailureRepeats?: number;\n}\n\nexport interface ResolveIOAIManagerPolicyInput {\n\thistory?: ResolveIOAIManagerFailureRecord[];\n\tcurrent?: ResolveIOAIManagerFailureRecord;\n\tmaxSameFailureRepeats?: number;\n\tmaxPingPongTransitions?: number;\n\tinfraFailureClasses?: string[];\n\tignoredFailureClasses?: string[];\n}\n\nexport interface ResolveIOAIManagerPolicyDecision {\n\taction: ResolveIOAIManagerAction;\n\treason: string;\n\tfailureClass: string;\n\tblockerFingerprint: string;\n\tevidenceHash: string;\n\tsameFailureCount: number;\n\tpingPongCount: number;\n\tnewEvidence: boolean;\n\tloopBudgetShouldReset: boolean;\n\tproductRepairFailure: boolean;\n\trecoveryPlan: ResolveIOAIManagerRecoveryPlan;\n}\n\nfunction cleanText(value: any, max = 2000): string {\n\treturn String(value || '').replace(/\\s+/g, ' ').trim().slice(0, max);\n}\n\nfunction cleanList(values: any, limit = 40, max = 500): string[] {\n\tif (!Array.isArray(values)) {\n\t\treturn [];\n\t}\n\tconst result: string[] = [];\n\tfor (const value of values) {\n\t\tconst normalized = cleanText(value, max);\n\t\tif (normalized && !result.includes(normalized)) {\n\t\t\tresult.push(normalized);\n\t\t}\n\t\tif (result.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn result;\n}\n\nfunction stableHash(prefix: string, value: any): string {\n\tconst normalized = typeof value === 'string'\n\t\t? cleanText(value, 12000)\n\t\t: JSON.stringify(value || {});\n\tlet hash = 0;\n\tfor (let index = 0; index < normalized.length; index += 1) {\n\t\thash = ((hash << 5) - hash + normalized.charCodeAt(index)) | 0;\n\t}\n\treturn `${prefix}-${Math.abs(hash).toString(36) || '0'}`;\n}\n\nexport function normalizeResolveIOAIManagerFailureClass(value: any): string {\n\tconst normalized = cleanText(value, 80)\n\t\t.toLowerCase()\n\t\t.replace(/[\\s-]+/g, '_');\n\tif (!normalized) {\n\t\treturn 'unknown';\n\t}\n\tif (/^(qa_infra|infrastructure|harness|puppeteer|chrome|mongo|port|startup)$/.test(normalized)) {\n\t\treturn 'infra';\n\t}\n\tif (/^(build|compile|typescript|tsc|angular_build|ng_build)$/.test(normalized)) {\n\t\treturn 'compile';\n\t}\n\tif (/^(false_pass|route_only|missing_business_proof)$/.test(normalized)) {\n\t\treturn 'business';\n\t}\n\treturn normalized.slice(0, 80);\n}\n\nexport function fingerprintResolveIOAIManagerBlocker(value: any): string {\n\tconst normalized = cleanText(value, 4000)\n\t\t.toLowerCase()\n\t\t.replace(/[a-f0-9]{16,}/g, '<id>')\n\t\t.replace(/\\b\\d{2,}\\b/g, '<n>')\n\t\t.replace(/\\bline\\s+<n>\\b/g, 'line <n>')\n\t\t.replace(/https?:\\/\\/\\S+/g, '<url>')\n\t\t.replace(/\\s+/g, ' ')\n\t\t.trim();\n\treturn stableHash('mgr-blocker', normalized);\n}\n\nexport function hashResolveIOAIManagerEvidence(record: ResolveIOAIManagerFailureRecord | undefined): string {\n\tif (!record) {\n\t\treturn stableHash('mgr-evidence', '');\n\t}\n\tconst explicit = cleanText(record.evidenceHash, 120);\n\tif (explicit) {\n\t\treturn explicit;\n\t}\n\treturn stableHash('mgr-evidence', {\n\t\tfailureClass: normalizeResolveIOAIManagerFailureClass(record.failureClass),\n\t\tblocker: cleanText(record.blocker || record.summary, 2000),\n\t\tchangedFiles: cleanList(record.changedFiles, 80, 500).sort(),\n\t\tartifactPaths: cleanList(record.artifactPaths, 80, 500).sort()\n\t});\n}\n\nfunction failureKey(record: ResolveIOAIManagerFailureRecord | undefined): string {\n\tif (!record) {\n\t\treturn '';\n\t}\n\tconst failureClass = normalizeResolveIOAIManagerFailureClass(record.failureClass);\n\tconst blockerFingerprint = cleanText(record.blockerFingerprint, 120)\n\t\t|| fingerprintResolveIOAIManagerBlocker(record.blocker || record.summary || '');\n\treturn `${cleanText(record.lane, 80)}:${cleanText(record.stepType, 80)}:${failureClass}:${blockerFingerprint}`;\n}\n\nfunction failureEvidenceKey(record: ResolveIOAIManagerFailureRecord | undefined): string {\n\treturn `${failureKey(record)}:${hashResolveIOAIManagerEvidence(record)}`;\n}\n\nfunction isPassingOutcome(record: ResolveIOAIManagerFailureRecord | undefined): boolean {\n\treturn /^(pass|accepted|ready_to_publish|published|ready_for_merge|complete|completed)$/i.test(cleanText(record?.outcome, 80));\n}\n\nfunction isManualOutcome(record: ResolveIOAIManagerFailureRecord | undefined): boolean {\n\treturn /^(manual_handoff|park_manual|stopped)$/i.test(cleanText(record?.outcome, 80));\n}\n\nexport function buildResolveIOAIManagerRecoveryPlan(input: ResolveIOAIManagerRecoveryPlanInput = {}): ResolveIOAIManagerRecoveryPlan {\n\tconst action = cleanText(input.action, 80) || 'continue';\n\tconst reason = cleanText(input.reason, 240);\n\tconst failureClass = normalizeResolveIOAIManagerFailureClass(input.failureClass);\n\tconst lane = cleanText(input.lane, 80) || 'supervisor';\n\tconst stepType = cleanText(input.stepType, 80) || 'unknown';\n\tconst blocker = cleanText(input.blocker, 700);\n\tconst changedFiles = cleanList(input.changedFiles, 12, 240);\n\tconst artifactPaths = cleanList(input.artifactPaths, 12, 240);\n\tconst maxAttemptsBeforePark = Math.max(1, Number(input.maxSameFailureRepeats || 3) || 3);\n\tconst commonNotes = [\n\t\treason ? `policy_reason=${reason}` : '',\n\t\tblocker ? `blocker=${blocker}` : '',\n\t\tchangedFiles.length ? `changed_files=${changedFiles.join(', ')}` : '',\n\t\tartifactPaths.length ? `artifacts=${artifactPaths.join(', ')}` : ''\n\t].filter(Boolean);\n\tconst base: Omit<ResolveIOAIManagerRecoveryPlan, 'recoveryClass' | 'nextActionLabel' | 'objective' | 'allowedAction' | 'productRepairAllowed' | 'expensiveModelAllowed' | 'finiteSteps' | 'requiredEvidence' | 'loopResetEvidence' | 'forbiddenActions'> = {\n\t\tlane,\n\t\tstepType,\n\t\tmaxAttemptsBeforePark,\n\t\tnotes: commonNotes\n\t};\n\tconst makePlan = (\n\t\trecoveryClass: ResolveIOAIManagerRecoveryClass,\n\t\tnextActionLabel: string,\n\t\tobjective: string,\n\t\tallowedAction: string,\n\t\tproductRepairAllowed: boolean,\n\t\texpensiveModelAllowed: boolean,\n\t\tfiniteSteps: string[],\n\t\trequiredEvidence: string[],\n\t\tloopResetEvidence: string[],\n\t\tforbiddenActions: string[]\n\t): ResolveIOAIManagerRecoveryPlan => ({\n\t\t...base,\n\t\trecoveryClass,\n\t\tnextActionLabel,\n\t\tobjective,\n\t\tallowedAction,\n\t\tproductRepairAllowed,\n\t\texpensiveModelAllowed,\n\t\tfiniteSteps,\n\t\trequiredEvidence,\n\t\tloopResetEvidence,\n\t\tforbiddenActions\n\t});\n\tif (action === 'reset_loop_budget') {\n\t\treturn makePlan(\n\t\t\t'advance_after_proof',\n\t\t\t'Advance After Proof',\n\t\t\t'Checkpoint the passing evidence and move to the next required gate.',\n\t\t\t'advance_to_next_gate',\n\t\t\tfalse,\n\t\t\tfalse,\n\t\t\t[\n\t\t\t\t'Record the passing artifact, changed files, and gate result.',\n\t\t\t\t'Reset the loop counter because a real gate passed.',\n\t\t\t\t'Select the next unmet deterministic gate instead of repeating the previous repair.'\n\t\t\t],\n\t\t\t['passing gate record', 'artifact or log proving the passed check'],\n\t\t\t['new passing gate result', 'new business proof artifact'],\n\t\t\t['rerun the same repair after a pass', 'mark accepted without the required downstream gate']\n\t\t);\n\t}\n\tif (action === 'manual_handoff') {\n\t\treturn makePlan(\n\t\t\t'manual_handoff',\n\t\t\t'Manual Review',\n\t\t\t'Stop autonomous repair and expose the blocker, evidence, and last safe state.',\n\t\t\t'manual_review_only',\n\t\t\tfalse,\n\t\t\tfalse,\n\t\t\t[\n\t\t\t\t'Freeze further product-code edits.',\n\t\t\t\t'Show the blocker fingerprint, evidence hash, and prior attempts.',\n\t\t\t\t'Require a human edit to classification, scope, or retry policy before another model/code loop.'\n\t\t\t],\n\t\t\t['blocker fingerprint', 'evidence hash', 'attempt history'],\n\t\t\t['manual policy change', 'new external evidence'],\n\t\t\t['start another automatic model repair', 'hide the failed evidence']\n\t\t);\n\t}\n\tif (action === 'budget_stop') {\n\t\treturn makePlan(\n\t\t\t'manual_handoff',\n\t\t\t'Budget Stop Review',\n\t\t\t'Stop autonomous model/code loops until a cheaper scoped next action is selected.',\n\t\t\t'budget_review_only',\n\t\t\tfalse,\n\t\t\tfalse,\n\t\t\t[\n\t\t\t\t'Freeze further model repair loops.',\n\t\t\t\t'Show the prompt/token/runtime budget that tripped the guard.',\n\t\t\t\t'Select a cheaper deterministic gate, infra repair, diagnosis revision, or manual scope edit before resuming.'\n\t\t\t],\n\t\t\t['budget guard reason', 'latest prompt estimate', 'last blocker/evidence hash'],\n\t\t\t['manual scope reduction', 'new deterministic evidence', 'approved budget policy change'],\n\t\t\t['start another broad model prompt', 'reset budget without new evidence', 'hide cost context']\n\t\t);\n\t}\n\tif (failureClass === 'diagnosis' || stepType === 'diagnosis_gate') {\n\t\treturn makePlan(\n\t\t\t'diagnosis_only',\n\t\t\t'Run Diagnosis Gate',\n\t\t\t'Produce a falsifiable root-cause diagnosis before any repair.',\n\t\t\t'read_only_diagnosis',\n\t\t\tfalse,\n\t\t\ttrue,\n\t\t\t[\n\t\t\t\t'Reproduce or explicitly classify the customer issue.',\n\t\t\t\t'Accept one falsifiable hypothesis and record rejected alternatives.',\n\t\t\t\t'Identify the frontend/backend/shared failing path.',\n\t\t\t\t'Select a small owner_files set.',\n\t\t\t\t'Define exact before/action/after business proof.'\n\t\t\t],\n\t\t\t['issue_case', 'accepted_hypothesis', 'rejected_alternatives', 'failing_path', 'owner_files', 'proof_plan'],\n\t\t\t['new reproduction artifact', 'new query/log/code evidence', 'validated diagnosis gate'],\n\t\t\t['edit product code', 'run broad repo repair', 'accept route-load evidence as success']\n\t\t);\n\t}\n\tif (failureClass === 'owner_scope' || failureClass === 'out_of_scope' || /out.?of.?scope|owner_files/i.test(reason)) {\n\t\treturn makePlan(\n\t\t\t'diagnosis_revision',\n\t\t\t'Revise Diagnosis Scope',\n\t\t\t'Revise owner_files only when new evidence proves the current scope is wrong.',\n\t\t\t'diagnosis_revision_only',\n\t\t\tfalse,\n\t\t\ttrue,\n\t\t\t[\n\t\t\t\t'Compare changed files against the diagnosis owner_files.',\n\t\t\t\t'Collect evidence proving why the new file is in the failing path.',\n\t\t\t\t'Update accepted_hypothesis, failing_path, owner_files, and proof_plan together.',\n\t\t\t\t'Resume repair only after the revised gate validates.'\n\t\t\t],\n\t\t\t['out-of-scope file list', 'new failing-path evidence', 'revalidated diagnosis gate'],\n\t\t\t['revised owner_files with evidence', 'new business proof requirement'],\n\t\t\t['keep broad edits without diagnosis', 'add convenience refactors', 'continue repair outside owner_files']\n\t\t);\n\t}\n\tif (action === 'retry_infra') {\n\t\tconst isCompile = failureClass === 'compile';\n\t\treturn makePlan(\n\t\t\tisCompile ? 'compile_repair' : 'infra_repair',\n\t\t\tisCompile ? 'Repair Compile Gate' : 'Repair Infra Gate',\n\t\t\tisCompile\n\t\t\t\t? 'Fix the deterministic compile/build blocker before spending another product repair loop.'\n\t\t\t\t: 'Fix the deterministic harness/browser/server/Mongo blocker before product repair.',\n\t\t\tisCompile ? 'compile_repair_only' : 'infra_repair_only',\n\t\t\tfalse,\n\t\t\tfalse,\n\t\t\tisCompile\n\t\t\t\t? [\n\t\t\t\t\t'Read the exact compile/build log and identify the first actionable error.',\n\t\t\t\t\t'Fix missing dependency, stale artifact, command, cache, or type wiring required by the compile gate.',\n\t\t\t\t\t'Rerun the same finite compile command.',\n\t\t\t\t\t'Return the compile log artifact and status.'\n\t\t\t\t]\n\t\t\t\t: [\n\t\t\t\t\t'Run preflight for Puppeteer, Chrome executable, ports, Mongo/settings, and startup command.',\n\t\t\t\t\t'Repair only the failing harness/environment item.',\n\t\t\t\t\t'Rerun the same infra check.',\n\t\t\t\t\t'Return the infra log and pass/fail status.'\n\t\t\t\t],\n\t\t\tisCompile\n\t\t\t\t? ['compile command', 'compile log artifact', 'first failing error fixed or still failing']\n\t\t\t\t: ['preflight command', 'infra log artifact', 'specific repaired environment item'],\n\t\t\t['same check now passes', 'new infra/compile blocker hash'],\n\t\t\t['run product-code model repair', 'count this as product failure', 'accept route/business success without the compile/infra gate']\n\t\t);\n\t}\n\tif (action === 'park_repeated_failure' || action === 'park_ping_pong') {\n\t\treturn makePlan(\n\t\t\t'blocked_until_new_evidence',\n\t\t\taction === 'park_ping_pong' ? 'Park Ping-Pong Loop' : 'Park Repeated Failure',\n\t\t\t'Stop the current loop until new evidence changes the diagnosis, route, or repair target.',\n\t\t\t'collect_new_evidence_only',\n\t\t\tfalse,\n\t\t\tfalse,\n\t\t\t[\n\t\t\t\t'Do not rerun the same prompt or same repair.',\n\t\t\t\t'Show the repeated blocker and evidence hash.',\n\t\t\t\t'Collect a new artifact: failing DOM state, stack trace, network response, Mongo delta, compile log, or revised diagnosis.',\n\t\t\t\t'Reset the loop only after the new evidence hash changes.'\n\t\t\t],\n\t\t\t['same failure count', 'blocker fingerprint', 'evidence hash'],\n\t\t\t['changed evidence hash', 'new artifact path', 'revised diagnosis or journey contract'],\n\t\t\t['alternate between two failed patches', 'increase loop budget without evidence', 'hide the park reason']\n\t\t);\n\t}\n\tif (failureClass === 'journey') {\n\t\treturn makePlan(\n\t\t\t'journey_contract_repair',\n\t\t\t'Repair Journey Contract',\n\t\t\t'Fix the first/next/last workflow contract before app code work continues.',\n\t\t\t'journey_contract_repair',\n\t\t\tfalse,\n\t\t\ttrue,\n\t\t\t[\n\t\t\t\t'Open docs/APP_JOURNEY_CONTRACT.md.',\n\t\t\t\t'Define first_screen, north_star_workflow, screen_sequence, data_story, completion_states, and qa_assertions.',\n\t\t\t\t'Ensure each CTA maps to an action, route, method, calculation, or state transition.',\n\t\t\t\t'Validate that sample data can drive the promised workflow.'\n\t\t\t],\n\t\t\t['validated journey_contract JSON', 'CTA-to-action mapping', 'workflow QA assertions'],\n\t\t\t['journey validation passes', 'new workflow QA rows generated'],\n\t\t\t['build empty routes', 'add link-only dashboard actions', 'defer workflow design to wow pass']\n\t\t);\n\t}\n\tif (failureClass === 'release') {\n\t\treturn makePlan(\n\t\t\t'release_repair',\n\t\t\t'Repair Release Gate',\n\t\t\t'Repair deploy/publish/sample-data release evidence without rewriting working app flow.',\n\t\t\t'release_repair_only',\n\t\t\tfalse,\n\t\t\tfalse,\n\t\t\t[\n\t\t\t\t'Read the deploy/publish/sample-data log.',\n\t\t\t\t'Identify whether the blocker is domain, asset, seed data, route, permission, or CDN.',\n\t\t\t\t'Repair the release artifact/config/seed issue.',\n\t\t\t\t'Rerun only the failed release gate.'\n\t\t\t],\n\t\t\t['deploy or publish log', 'sample-data status', 'failed release gate rerun'],\n\t\t\t['release gate passes', 'new release blocker hash'],\n\t\t\t['change core workflow after business QA passed', 'mark accepted from scorecard only', 'rerun full builder loop']\n\t\t);\n\t}\n\tif (failureClass === 'business' || failureClass === 'qa_evidence' || failureClass === 'route') {\n\t\treturn makePlan(\n\t\t\t'business_proof_repair',\n\t\t\t'Repair Business Proof',\n\t\t\t'Fix the exact failing workflow assertion and prove before/action/after behavior.',\n\t\t\t'business_repair',\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\t[\n\t\t\t\t'Open the failing QA row or proof_plan.',\n\t\t\t\t'Trace the UI action to method/publication/query/calculation.',\n\t\t\t\t'Patch the smallest owner or workflow files.',\n\t\t\t\t'Rerun only the failed business assertion.',\n\t\t\t\t'Record DOM/data/Mongo/artifact proof.'\n\t\t\t],\n\t\t\t['failing assertion', 'action trace', 'business proof artifact'],\n\t\t\t['business assertion passes', 'new failed assertion with new evidence'],\n\t\t\t['treat route load as success', 'rerun unrelated QA rows first', 'accept scorecard-only evidence']\n\t\t);\n\t}\n\tif (input.productRepairFailure !== false || failureClass === 'product_code') {\n\t\treturn makePlan(\n\t\t\t'product_code_repair',\n\t\t\t'Run Targeted Product Repair',\n\t\t\t'Repair the current product-code blocker with the smallest scoped edit and immediate proof.',\n\t\t\t'targeted_product_repair',\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\t[\n\t\t\t\t'Inspect the current blocker, artifacts, changed files, and owner/workflow scope.',\n\t\t\t\t'Form one small repair hypothesis.',\n\t\t\t\t'Patch only files justified by the active diagnosis or journey contract.',\n\t\t\t\t'Rerun the smallest failed gate.',\n\t\t\t\t'Record new evidence before any additional loop.'\n\t\t\t],\n\t\t\t['owner/workflow scope', 'repair diff', 'failed gate rerun artifact'],\n\t\t\t['new evidence hash', 'same gate passes'],\n\t\t\t['broad repo search-and-edit', 'rerun the same prompt without inspecting artifacts', 'change unrelated UI polish']\n\t\t);\n\t}\n\treturn makePlan(\n\t\t'continue',\n\t\t'Continue Current Gate',\n\t\t'Continue the current lane because no blocking loop or infra condition was detected.',\n\t\t'continue',\n\t\tfalse,\n\t\tfalse,\n\t\t[\n\t\t\t'Use the active lane memory.',\n\t\t\t'Run the next finite gate.',\n\t\t\t'Record artifacts and evidence hash.'\n\t\t],\n\t\t['active lane memory', 'finite gate artifact'],\n\t\t['new gate result', 'new artifact path'],\n\t\t['spawn duplicate runners', 'advance without evidence']\n\t);\n}\n\nfunction collectOpenTail(records: ResolveIOAIManagerFailureRecord[]): ResolveIOAIManagerFailureRecord[] {\n\tconst tail: ResolveIOAIManagerFailureRecord[] = [];\n\tfor (let index = records.length - 1; index >= 0; index -= 1) {\n\t\tconst record = records[index];\n\t\tif (isPassingOutcome(record)) {\n\t\t\tbreak;\n\t\t}\n\t\ttail.unshift(record);\n\t}\n\treturn tail;\n}\n\nfunction countSameFailure(records: ResolveIOAIManagerFailureRecord[], current: ResolveIOAIManagerFailureRecord): number {\n\tconst currentKey = failureEvidenceKey(current);\n\tlet count = 0;\n\tfor (let index = records.length - 1; index >= 0; index -= 1) {\n\t\tconst record = records[index];\n\t\tif (isPassingOutcome(record)) {\n\t\t\tbreak;\n\t\t}\n\t\tif (failureEvidenceKey(record) !== currentKey) {\n\t\t\tbreak;\n\t\t}\n\t\tcount += 1;\n\t}\n\treturn count;\n}\n\nfunction countPingPong(records: ResolveIOAIManagerFailureRecord[], current: ResolveIOAIManagerFailureRecord): number {\n\tconst tail = collectOpenTail(records).filter((record) => {\n\t\treturn cleanText(record.lane, 80) === cleanText(current.lane, 80)\n\t\t\t&& cleanText(record.stepType, 80) === cleanText(current.stepType, 80);\n\t});\n\tif (tail.length < 4) {\n\t\treturn 0;\n\t}\n\tconst keys = tail.map(failureKey).filter(Boolean);\n\tconst last = keys.slice(-6);\n\tif (last.length < 4) {\n\t\treturn 0;\n\t}\n\tconst distinct = Array.from(new Set(last));\n\tif (distinct.length !== 2) {\n\t\treturn 0;\n\t}\n\tfor (let index = 2; index < last.length; index += 1) {\n\t\tif (last[index] !== last[index - 2]) {\n\t\t\treturn 0;\n\t\t}\n\t}\n\treturn last.length - 1;\n}\n\nexport function decideResolveIOAIManagerPolicy(input: ResolveIOAIManagerPolicyInput): ResolveIOAIManagerPolicyDecision {\n\tconst history = Array.isArray(input.history) ? input.history : [];\n\tconst current = input.current || history[history.length - 1] || {};\n\tconst failureClass = normalizeResolveIOAIManagerFailureClass(current.failureClass);\n\tconst blockerFingerprint = cleanText(current.blockerFingerprint, 120)\n\t\t|| fingerprintResolveIOAIManagerBlocker(current.blocker || current.summary || '');\n\tconst evidenceHash = hashResolveIOAIManagerEvidence(current);\n\tconst previous = history.length > 1 ? history[history.length - 2] : undefined;\n\tconst previousSameFailure = previous && failureKey(previous) === failureKey(current);\n\tconst previousEvidenceHash = previousSameFailure ? hashResolveIOAIManagerEvidence(previous) : '';\n\tconst newEvidence = !!previousSameFailure && !!previousEvidenceHash && previousEvidenceHash !== evidenceHash;\n\tconst sameFailureCount = countSameFailure(history, current);\n\tconst pingPongCount = countPingPong(history, current);\n\tconst maxSameFailureRepeats = Math.max(1, Number(input.maxSameFailureRepeats || 3) || 3);\n\tconst maxPingPongTransitions = Math.max(3, Number(input.maxPingPongTransitions || 3) || 3);\n\tconst infraClasses = new Set((input.infraFailureClasses || ['infra', 'compile']).map(normalizeResolveIOAIManagerFailureClass));\n\tconst ignoredClasses = new Set((input.ignoredFailureClasses || []).map(normalizeResolveIOAIManagerFailureClass));\n\tconst base = {\n\t\tfailureClass,\n\t\tblockerFingerprint,\n\t\tevidenceHash,\n\t\tsameFailureCount,\n\t\tpingPongCount,\n\t\tnewEvidence,\n\t\tloopBudgetShouldReset: false,\n\t\tproductRepairFailure: !infraClasses.has(failureClass) && !ignoredClasses.has(failureClass)\n\t};\n\tconst withPlan = (\n\t\taction: ResolveIOAIManagerAction,\n\t\treason: string,\n\t\toverrides: Partial<Omit<ResolveIOAIManagerPolicyDecision, 'action' | 'reason' | 'recoveryPlan'>> = {}\n\t): ResolveIOAIManagerPolicyDecision => {\n\t\tconst merged = {\n\t\t\t...base,\n\t\t\t...overrides\n\t\t};\n\t\treturn {\n\t\t\t...merged,\n\t\t\taction,\n\t\t\treason,\n\t\t\trecoveryPlan: buildResolveIOAIManagerRecoveryPlan({\n\t\t\t\taction,\n\t\t\t\treason,\n\t\t\t\tfailureClass: merged.failureClass,\n\t\t\t\tlane: current.lane,\n\t\t\t\tstepType: current.stepType,\n\t\t\t\tblocker: current.blocker || current.summary,\n\t\t\t\tsameFailureCount: merged.sameFailureCount,\n\t\t\t\tpingPongCount: merged.pingPongCount,\n\t\t\t\tnewEvidence: merged.newEvidence,\n\t\t\t\tproductRepairFailure: merged.productRepairFailure,\n\t\t\t\tchangedFiles: current.changedFiles,\n\t\t\t\tartifactPaths: current.artifactPaths,\n\t\t\t\tmaxSameFailureRepeats\n\t\t\t})\n\t\t};\n\t};\n\tif (isPassingOutcome(current)) {\n\t\treturn withPlan('reset_loop_budget', 'manager_policy_progress_passed', {\n\t\t\tloopBudgetShouldReset: true,\n\t\t\tproductRepairFailure: false\n\t\t});\n\t}\n\tif (isManualOutcome(current)) {\n\t\treturn withPlan('manual_handoff', 'manager_policy_manual_or_stopped');\n\t}\n\tif (infraClasses.has(failureClass)) {\n\t\treturn withPlan('retry_infra', 'manager_policy_infra_failure_routes_to_infra_repair', {\n\t\t\tproductRepairFailure: false\n\t\t});\n\t}\n\tif (pingPongCount >= maxPingPongTransitions) {\n\t\treturn withPlan('park_ping_pong', 'manager_policy_ping_pong_failure_loop');\n\t}\n\tif (sameFailureCount >= maxSameFailureRepeats && !newEvidence) {\n\t\treturn withPlan('park_repeated_failure', 'manager_policy_same_failure_without_new_evidence');\n\t}\n\tif (newEvidence || !previousSameFailure) {\n\t\treturn withPlan('continue', newEvidence\n\t\t\t\t? 'manager_policy_new_evidence_resets_loop_budget'\n\t\t\t\t: 'manager_policy_new_failure_or_lane', {\n\t\t\tloopBudgetShouldReset: true\n\t\t});\n\t}\n\treturn withPlan('continue', 'manager_policy_retry_below_repeat_limit');\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ResolveIOAIManagerRecoveryPlan } from './ai-runner-manager-policy';
|
|
1
2
|
export type ResolveIOAICoderV6Lane = 'intake' | 'plan' | 'build' | 'qa' | 'repair' | 'review' | 'publish';
|
|
2
3
|
export type ResolveIOAICoderV6StepType = 'intake' | 'journey_contract' | 'journey_validation' | 'plan' | 'task' | 'workflow_build' | 'workflow_qa' | 'build' | 'qa' | 'repair' | 'review' | 'test_deploy' | 'live_deploy' | 'publish' | 'cleanup';
|
|
3
4
|
export type ResolveIOAICoderV6Outcome = 'pass' | 'needs_repair' | 'retry_same_step' | 'park_manual' | 'budget_stop' | 'infra_retry' | 'ready_to_publish' | 'published';
|
|
@@ -173,6 +174,7 @@ export interface ResolveIOAICoderV6ContinuationDecision {
|
|
|
173
174
|
nextStep: ResolveIOAICoderV6StepType;
|
|
174
175
|
repeatedNoProgressCount: number;
|
|
175
176
|
budgetExceeded: boolean;
|
|
177
|
+
recoveryPlan: ResolveIOAIManagerRecoveryPlan;
|
|
176
178
|
}
|
|
177
179
|
export declare function fingerprintResolveIOAICoderV6Blocker(value: any): string;
|
|
178
180
|
export declare function buildResolveIOAICoderV6Budget(existing?: Partial<ResolveIOAICoderV6Budget>): ResolveIOAICoderV6Budget;
|
|
@@ -379,6 +379,10 @@ function decideResolveIOAICoderV6Continuation(bundle) {
|
|
|
379
379
|
maxPingPongTransitions: 3,
|
|
380
380
|
infraFailureClasses: ['infra']
|
|
381
381
|
});
|
|
382
|
+
var recoveryPlanFor = function (action, reason, extra) {
|
|
383
|
+
if (extra === void 0) { extra = {}; }
|
|
384
|
+
return (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryPlan)(__assign({ action: action, reason: reason, failureClass: last === null || last === void 0 ? void 0 : last.failureClass, lane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane, stepType: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep, blocker: (last === null || last === void 0 ? void 0 : last.blocker) || (last === null || last === void 0 ? void 0 : last.summary), changedFiles: last === null || last === void 0 ? void 0 : last.changedFiles, artifactPaths: last === null || last === void 0 ? void 0 : last.artifactPaths, maxSameFailureRepeats: budget.maxRepeatedNoProgress + 1 }, extra));
|
|
385
|
+
};
|
|
382
386
|
var budgetExceeded = (budget.loopCount >= budget.maxLoopsPerRun && !managerDecision.loopBudgetShouldReset)
|
|
383
387
|
|| budget.totalPromptTokenEstimate >= budget.maxTotalPromptTokens
|
|
384
388
|
|| ((last === null || last === void 0 ? void 0 : last.promptTokenEstimate) || 0) > budget.maxPromptTokensPerNonInitialStep * 2;
|
|
@@ -389,7 +393,10 @@ function decideResolveIOAICoderV6Continuation(bundle) {
|
|
|
389
393
|
nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane,
|
|
390
394
|
nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep,
|
|
391
395
|
repeatedNoProgressCount: repeatedNoProgressCount,
|
|
392
|
-
budgetExceeded: budgetExceeded
|
|
396
|
+
budgetExceeded: budgetExceeded,
|
|
397
|
+
recoveryPlan: recoveryPlanFor('budget_stop', 'aicoder_v6_budget_guard', {
|
|
398
|
+
productRepairFailure: false
|
|
399
|
+
})
|
|
393
400
|
};
|
|
394
401
|
}
|
|
395
402
|
if (managerDecision.action === 'park_ping_pong') {
|
|
@@ -399,7 +406,8 @@ function decideResolveIOAICoderV6Continuation(bundle) {
|
|
|
399
406
|
nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane,
|
|
400
407
|
nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep,
|
|
401
408
|
repeatedNoProgressCount: managerDecision.pingPongCount,
|
|
402
|
-
budgetExceeded: false
|
|
409
|
+
budgetExceeded: false,
|
|
410
|
+
recoveryPlan: managerDecision.recoveryPlan
|
|
403
411
|
};
|
|
404
412
|
}
|
|
405
413
|
if (managerDecision.action === 'park_repeated_failure') {
|
|
@@ -409,7 +417,19 @@ function decideResolveIOAICoderV6Continuation(bundle) {
|
|
|
409
417
|
nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane,
|
|
410
418
|
nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep,
|
|
411
419
|
repeatedNoProgressCount: managerDecision.sameFailureCount,
|
|
412
|
-
budgetExceeded: false
|
|
420
|
+
budgetExceeded: false,
|
|
421
|
+
recoveryPlan: managerDecision.recoveryPlan
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
if (managerDecision.action === 'retry_infra') {
|
|
425
|
+
return {
|
|
426
|
+
action: 'infra_retry',
|
|
427
|
+
reason: 'aicoder_v6_infra_retry',
|
|
428
|
+
nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane,
|
|
429
|
+
nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep,
|
|
430
|
+
repeatedNoProgressCount: repeatedNoProgressCount,
|
|
431
|
+
budgetExceeded: false,
|
|
432
|
+
recoveryPlan: managerDecision.recoveryPlan
|
|
413
433
|
};
|
|
414
434
|
}
|
|
415
435
|
if (repeatedNoProgressCount > budget.maxRepeatedNoProgress) {
|
|
@@ -419,17 +439,44 @@ function decideResolveIOAICoderV6Continuation(bundle) {
|
|
|
419
439
|
nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane,
|
|
420
440
|
nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep,
|
|
421
441
|
repeatedNoProgressCount: repeatedNoProgressCount,
|
|
422
|
-
budgetExceeded: false
|
|
442
|
+
budgetExceeded: false,
|
|
443
|
+
recoveryPlan: recoveryPlanFor('park', 'aicoder_v6_repeated_no_progress', {
|
|
444
|
+
action: 'park_repeated_failure',
|
|
445
|
+
productRepairFailure: true
|
|
446
|
+
})
|
|
423
447
|
};
|
|
424
448
|
}
|
|
425
449
|
if ((last === null || last === void 0 ? void 0 : last.outcome) === 'needs_repair') {
|
|
450
|
+
if (last.failureClass === 'journey') {
|
|
451
|
+
return {
|
|
452
|
+
action: 'retry_same_step',
|
|
453
|
+
reason: 'aicoder_v6_journey_contract_repair_required',
|
|
454
|
+
nextLane: 'plan',
|
|
455
|
+
nextStep: last.stepType === 'journey_validation' ? 'journey_contract' : last.stepType,
|
|
456
|
+
repeatedNoProgressCount: repeatedNoProgressCount,
|
|
457
|
+
budgetExceeded: false,
|
|
458
|
+
recoveryPlan: managerDecision.recoveryPlan
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
if (last.failureClass === 'release') {
|
|
462
|
+
return {
|
|
463
|
+
action: 'retry_same_step',
|
|
464
|
+
reason: 'aicoder_v6_release_repair_required',
|
|
465
|
+
nextLane: 'publish',
|
|
466
|
+
nextStep: last.stepType,
|
|
467
|
+
repeatedNoProgressCount: repeatedNoProgressCount,
|
|
468
|
+
budgetExceeded: false,
|
|
469
|
+
recoveryPlan: managerDecision.recoveryPlan
|
|
470
|
+
};
|
|
471
|
+
}
|
|
426
472
|
return {
|
|
427
473
|
action: last.lane === 'repair' ? 'retry_same_step' : 'switch_to_repair',
|
|
428
474
|
reason: 'aicoder_v6_repair_required',
|
|
429
475
|
nextLane: 'repair',
|
|
430
476
|
nextStep: 'repair',
|
|
431
477
|
repeatedNoProgressCount: repeatedNoProgressCount,
|
|
432
|
-
budgetExceeded: false
|
|
478
|
+
budgetExceeded: false,
|
|
479
|
+
recoveryPlan: managerDecision.recoveryPlan
|
|
433
480
|
};
|
|
434
481
|
}
|
|
435
482
|
if ((last === null || last === void 0 ? void 0 : last.outcome) === 'infra_retry') {
|
|
@@ -439,7 +486,11 @@ function decideResolveIOAICoderV6Continuation(bundle) {
|
|
|
439
486
|
nextLane: last.lane,
|
|
440
487
|
nextStep: last.stepType,
|
|
441
488
|
repeatedNoProgressCount: repeatedNoProgressCount,
|
|
442
|
-
budgetExceeded: false
|
|
489
|
+
budgetExceeded: false,
|
|
490
|
+
recoveryPlan: recoveryPlanFor('infra_retry', 'aicoder_v6_infra_retry', {
|
|
491
|
+
failureClass: 'infra',
|
|
492
|
+
productRepairFailure: false
|
|
493
|
+
})
|
|
443
494
|
};
|
|
444
495
|
}
|
|
445
496
|
if ((last === null || last === void 0 ? void 0 : last.outcome) === 'ready_to_publish') {
|
|
@@ -449,7 +500,11 @@ function decideResolveIOAICoderV6Continuation(bundle) {
|
|
|
449
500
|
nextLane: 'publish',
|
|
450
501
|
nextStep: 'publish',
|
|
451
502
|
repeatedNoProgressCount: repeatedNoProgressCount,
|
|
452
|
-
budgetExceeded: false
|
|
503
|
+
budgetExceeded: false,
|
|
504
|
+
recoveryPlan: recoveryPlanFor('ready_to_publish', 'aicoder_v6_ready_to_publish', {
|
|
505
|
+
failureClass: 'release',
|
|
506
|
+
productRepairFailure: false
|
|
507
|
+
})
|
|
453
508
|
};
|
|
454
509
|
}
|
|
455
510
|
return {
|
|
@@ -458,7 +513,8 @@ function decideResolveIOAICoderV6Continuation(bundle) {
|
|
|
458
513
|
nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane,
|
|
459
514
|
nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep,
|
|
460
515
|
repeatedNoProgressCount: repeatedNoProgressCount,
|
|
461
|
-
budgetExceeded: false
|
|
516
|
+
budgetExceeded: false,
|
|
517
|
+
recoveryPlan: managerDecision.recoveryPlan || recoveryPlanFor('continue', 'aicoder_v6_continue')
|
|
462
518
|
};
|
|
463
519
|
}
|
|
464
520
|
function buildResolveIOAICoderV6DiagnoseFirstPrompt(lines) {
|