@resolveio/server-lib 22.3.199 → 22.3.200

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.
@@ -50,6 +50,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
50
50
  exports.evaluateResolveIOSupportPreflightGate = evaluateResolveIOSupportPreflightGate;
51
51
  exports.selectResolveIOSupportSimilarCaseHints = selectResolveIOSupportSimilarCaseHints;
52
52
  exports.buildResolveIOSupportDiagnosisEvidencePack = buildResolveIOSupportDiagnosisEvidencePack;
53
+ exports.buildResolveIOSupportDiagnosisProofMatrix = buildResolveIOSupportDiagnosisProofMatrix;
53
54
  exports.evaluateResolveIOSupportDiagnosisEvidenceQuality = evaluateResolveIOSupportDiagnosisEvidenceQuality;
54
55
  exports.normalizeResolveIOSupportDiagnosisGate = normalizeResolveIOSupportDiagnosisGate;
55
56
  exports.extractResolveIOSupportDiagnosisGateFromText = extractResolveIOSupportDiagnosisGateFromText;
@@ -68,8 +69,11 @@ exports.validateResolveIOSupportNextActionContract = validateResolveIOSupportNex
68
69
  exports.buildResolveIOSupportManagerExecutionPacket = buildResolveIOSupportManagerExecutionPacket;
69
70
  exports.decideResolveIOSupportV5RepeatedFailureStop = decideResolveIOSupportV5RepeatedFailureStop;
70
71
  exports.evaluateResolveIOSupportEvidenceFreshness = evaluateResolveIOSupportEvidenceFreshness;
72
+ exports.validateResolveIOSupportEvidenceProbeContract = validateResolveIOSupportEvidenceProbeContract;
73
+ exports.buildResolveIOSupportEvidenceProbeContract = buildResolveIOSupportEvidenceProbeContract;
71
74
  exports.buildResolveIOSupportContinuationProofCheckpoint = buildResolveIOSupportContinuationProofCheckpoint;
72
75
  exports.changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles = changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles;
76
+ exports.buildResolveIOSupportOwnerScopedRepairContract = buildResolveIOSupportOwnerScopedRepairContract;
73
77
  exports.decideResolveIOSupportV5RepairGate = decideResolveIOSupportV5RepairGate;
74
78
  exports.applyResolveIOSupportDiagnosisGateToMicrotasks = applyResolveIOSupportDiagnosisGateToMicrotasks;
75
79
  exports.fingerprintResolveIOSupportV5Blocker = fingerprintResolveIOSupportV5Blocker;
@@ -134,6 +138,489 @@ function cleanList(values, limit, max) {
134
138
  function cleanObject(value) {
135
139
  return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
136
140
  }
141
+ function cleanNumber(value) {
142
+ var parsed = Number(value);
143
+ return Number.isFinite(parsed) ? parsed : undefined;
144
+ }
145
+ function supportApprovalExplicitlyApprovesOverLimit(value) {
146
+ return value.approve_over_max_hours === true
147
+ || value.approveOverMaxHours === true
148
+ || value.approve_over_six_hours === true
149
+ || value.approveOverSixHours === true
150
+ || value.over_limit_approved === true
151
+ || value.overLimitApproved === true
152
+ || value.over_max_auto_hours_approved === true
153
+ || value.overMaxAutoHoursApproved === true
154
+ || value.operator_approved_over_limit === true
155
+ || value.operatorApprovedOverLimit === true;
156
+ }
157
+ function normalizeResolveIOSupportAutonomyApprovalContract(value, options) {
158
+ var _a, _b;
159
+ if (options === void 0) { options = {}; }
160
+ var source = cleanObject(value);
161
+ var required = options.required === true;
162
+ if (!Object.keys(source).length && !required) {
163
+ return undefined;
164
+ }
165
+ var ownerFiles = cleanList(source.owner_files || source.ownerFiles || options.ownerFiles, 80, 500)
166
+ .map(normalizeOwnerFilePath)
167
+ .filter(Boolean);
168
+ var approvedOwnerFiles = cleanList(source.approved_owner_files || source.approvedOwnerFiles || ownerFiles, 80, 500)
169
+ .map(normalizeOwnerFilePath)
170
+ .filter(Boolean);
171
+ var currentOwnerFiles = cleanList(source.current_owner_files || source.currentOwnerFiles || ownerFiles, 80, 500)
172
+ .map(normalizeOwnerFilePath)
173
+ .filter(Boolean);
174
+ var ownerFileFingerprint = cleanText(source.owner_file_fingerprint
175
+ || source.ownerFileFingerprint
176
+ || (currentOwnerFiles.length ? hashResolveIOSupportV5Evidence({ ownerFiles: currentOwnerFiles.slice().sort() }).slice(0, 18) : ''), 180);
177
+ var approvedOwnerFileFingerprint = cleanText(source.approved_owner_file_fingerprint
178
+ || source.approvedOwnerFileFingerprint
179
+ || (approvedOwnerFiles.length ? hashResolveIOSupportV5Evidence({ ownerFiles: approvedOwnerFiles.slice().sort() }).slice(0, 18) : ''), 180);
180
+ var currentOwnerFileSet = new Set(currentOwnerFiles);
181
+ var approvedOwnerFileSet = new Set(approvedOwnerFiles);
182
+ var ownerFilesAddedSinceApproval = cleanList(source.owner_files_added_since_approval || source.ownerFilesAddedSinceApproval, 80, 500)
183
+ .map(normalizeOwnerFilePath)
184
+ .filter(Boolean);
185
+ var ownerFilesRemovedSinceApproval = cleanList(source.owner_files_removed_since_approval || source.ownerFilesRemovedSinceApproval, 80, 500)
186
+ .map(normalizeOwnerFilePath)
187
+ .filter(Boolean);
188
+ var computedOwnerFilesAdded = currentOwnerFiles.filter(function (entry) { return !approvedOwnerFileSet.has(entry); });
189
+ var computedOwnerFilesRemoved = approvedOwnerFiles.filter(function (entry) { return !currentOwnerFileSet.has(entry); });
190
+ var ownerFilesChangedSinceApproval = source.owner_files_changed_since_approval === true
191
+ || source.ownerFilesChangedSinceApproval === true
192
+ || computedOwnerFilesAdded.length > 0
193
+ || computedOwnerFilesRemoved.length > 0
194
+ || (!!ownerFileFingerprint && !!approvedOwnerFileFingerprint && ownerFileFingerprint !== approvedOwnerFileFingerprint);
195
+ var scopeFingerprint = cleanText(source.scope_fingerprint || source.scopeFingerprint, 180);
196
+ var previousScopeFingerprint = cleanText(source.previous_scope_fingerprint || source.previousScopeFingerprint, 180);
197
+ var diagnosisScopeFingerprint = cleanText(source.diagnosis_scope_fingerprint || source.diagnosisScopeFingerprint, 180);
198
+ var previousDiagnosisScopeFingerprint = cleanText(source.previous_diagnosis_scope_fingerprint || source.previousDiagnosisScopeFingerprint, 180);
199
+ var scopeChangedSinceApproval = source.scope_changed_since_approval === true
200
+ || source.scopeChangedSinceApproval === true
201
+ || (!!scopeFingerprint && !!previousScopeFingerprint && scopeFingerprint !== previousScopeFingerprint);
202
+ var diagnosisScopeChangedSinceApproval = source.diagnosis_scope_changed_since_approval === true
203
+ || source.diagnosisScopeChangedSinceApproval === true
204
+ || (!!diagnosisScopeFingerprint && !!previousDiagnosisScopeFingerprint && diagnosisScopeFingerprint !== previousDiagnosisScopeFingerprint);
205
+ var onTheFlyScopeChangeApprovalRequired = source.on_the_fly_scope_change_approval_required === true
206
+ || source.onTheFlyScopeChangeApprovalRequired === true
207
+ || scopeChangedSinceApproval
208
+ || ownerFilesChangedSinceApproval
209
+ || diagnosisScopeChangedSinceApproval;
210
+ var estimatedHours = cleanNumber((_a = source.estimated_hours) !== null && _a !== void 0 ? _a : source.estimatedHours);
211
+ var maxAutoHoursWithoutApproval = cleanNumber((_b = source.max_auto_hours_without_approval) !== null && _b !== void 0 ? _b : source.maxAutoHoursWithoutApproval) || 6;
212
+ var overMaxAutoHours = source.over_max_auto_hours === true
213
+ || source.overMaxAutoHours === true
214
+ || (estimatedHours !== undefined && estimatedHours > maxAutoHoursWithoutApproval);
215
+ var explicitOverLimitApproval = supportApprovalExplicitlyApprovesOverLimit(source);
216
+ var bugNotBug = cleanText(source.bug_not_bug || source.bugNotBug, 80);
217
+ var bugNotBugKnown = source.bug_not_bug_known === true
218
+ || source.bugNotBugKnown === true
219
+ || bugNotBug === 'bug'
220
+ || bugNotBug === 'not_bug'
221
+ || bugNotBug === 'not bug';
222
+ var bugNotBugClassificationApproved = source.bug_not_bug_classification_approved === true
223
+ || source.bugNotBugClassificationApproved === true;
224
+ var afterApprovalAutopilotUntilAGrade = source.after_approval_autopilot_until_a_grade === true
225
+ || source.afterApprovalAutopilotUntilAGrade === true
226
+ || source.autopilot_after_approval_until_a_grade === true
227
+ || source.autopilotAfterApprovalUntilAGrade === true;
228
+ var completionContract = cleanObject(source.autopilot_completion_contract || source.autopilotCompletionContract);
229
+ var approved = source.approved === true;
230
+ var blockers = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(cleanList(source.blockers, 40, 500)), false), __read((!Object.keys(source).length && required ? ['Support autonomy approval is required before product-code repair.'] : [])), false), __read((source.requires_over_limit_approval === true || source.requiresOverLimitApproval === true ? ['Estimated work is over the automatic hour ceiling and requires operator approval.'] : [])), false), __read((source.requires_scope_reapproval === true || source.requiresScopeReapproval === true || scopeChangedSinceApproval ? ['The approved support scope changed and requires on-the-fly reapproval.'] : [])), false), __read((source.requires_owner_file_reapproval === true || source.requiresOwnerFileReapproval === true || ownerFilesChangedSinceApproval ? ['The owner-file set changed after approval and requires reapproval.'] : [])), false), __read((source.requires_intake_reapproval === true || source.requiresIntakeReapproval === true ? ['The support intake/classification changed after approval and requires reapproval.'] : [])), false), __read((source.requires_diagnosis_scope_reapproval === true || source.requiresDiagnosisScopeReapproval === true || diagnosisScopeChangedSinceApproval ? ['The accepted diagnosis/proof scope changed after approval and requires reapproval.'] : [])), false), __read((source.requires_classification_approval === true || source.requiresClassificationApproval === true ? ['Bug/not-bug classification must be approved before product-code repair.'] : [])), false), __read((source.requires_estimate_hours === true || source.requiresEstimateHours === true ? ['Estimated hours must be recorded before product-code repair.'] : [])), false), __read((approved && bugNotBugKnown !== true ? ['Bug/not-bug classification must be set before approved support autopilot can repair product code.'] : [])), false), __read((approved && bugNotBugClassificationApproved !== true ? ['Bug/not-bug classification must be approved before approved support autopilot can repair product code.'] : [])), false), __read((approved && estimatedHours === undefined ? ['Estimated hours must be recorded before approved support autopilot can repair product code.'] : [])), false), __read((approved && overMaxAutoHours && explicitOverLimitApproval !== true ? ["Estimated work is ".concat(estimatedHours, " hours, above the ").concat(maxAutoHoursWithoutApproval, "-hour autonomy ceiling, and needs explicit over-limit operator approval.")] : [])), false))).slice(0, 40);
231
+ var status = approved && blockers.length === 0
232
+ ? 'approved_autopilot'
233
+ : Object.keys(source).length ? 'approval_required' : 'missing';
234
+ var decisionKind = cleanText(source.decision_kind || source.decisionKind || source.approval_kind || source.approvalKind, 120)
235
+ || (status === 'approved_autopilot'
236
+ ? 'approved_autopilot'
237
+ : overMaxAutoHours && explicitOverLimitApproval !== true
238
+ ? 'over_limit_approval_required'
239
+ : bugNotBugClassificationApproved !== true
240
+ ? 'classification_approval_required'
241
+ : 'operator_approval_required');
242
+ var approvalAction = cleanText(source.approval_action || source.approvalAction, 120)
243
+ || (decisionKind === 'over_limit_approval_required' ? 'approve_support_autonomy_over_limit' : 'approve_support_autonomy');
244
+ return {
245
+ contractId: cleanText(source.contract_id || source.contractId, 180)
246
+ || stableIdFromText('support-autonomy-approval', [
247
+ decisionKind,
248
+ ownerFiles.join('|'),
249
+ String(estimatedHours !== null && estimatedHours !== void 0 ? estimatedHours : ''),
250
+ isoNow(options.now).slice(0, 16)
251
+ ].join('\n')),
252
+ status: status,
253
+ approved: status === 'approved_autopilot',
254
+ approvedAt: cleanText(source.approved_at || source.approvedAt, 80) || undefined,
255
+ approvedBy: cleanText(source.approved_by || source.approvedBy, 160) || undefined,
256
+ decisionKind: decisionKind,
257
+ approvalAction: approvalAction,
258
+ preferredChoiceId: cleanText(source.preferred_choice_id || source.preferredChoiceId, 120)
259
+ || (approvalAction === 'approve_support_autonomy_over_limit' ? 'approve_over_limit_autonomy' : 'approve_auto_fix_le_6h_bug'),
260
+ canApproveFromConsole: source.can_approve_from_console !== false && source.canApproveFromConsole !== false,
261
+ estimatedHours: estimatedHours,
262
+ estimatedHoursKnown: estimatedHours !== undefined || source.estimated_hours_known === true || source.estimatedHoursKnown === true,
263
+ maxAutoHoursWithoutApproval: maxAutoHoursWithoutApproval,
264
+ overMaxAutoHours: overMaxAutoHours,
265
+ explicitOverLimitApproval: explicitOverLimitApproval,
266
+ bugNotBug: bugNotBug,
267
+ bugNotBugKnown: bugNotBugKnown,
268
+ bugNotBugClassificationApproved: bugNotBugClassificationApproved,
269
+ requiresOverLimitApproval: source.requires_over_limit_approval === true || source.requiresOverLimitApproval === true || (overMaxAutoHours && explicitOverLimitApproval !== true),
270
+ requiresScopeReapproval: source.requires_scope_reapproval === true || source.requiresScopeReapproval === true || scopeChangedSinceApproval,
271
+ requiresOwnerFileReapproval: source.requires_owner_file_reapproval === true || source.requiresOwnerFileReapproval === true || ownerFilesChangedSinceApproval,
272
+ requiresIntakeReapproval: source.requires_intake_reapproval === true || source.requiresIntakeReapproval === true,
273
+ requiresDiagnosisScopeReapproval: source.requires_diagnosis_scope_reapproval === true || source.requiresDiagnosisScopeReapproval === true || diagnosisScopeChangedSinceApproval,
274
+ requiresClassificationApproval: source.requires_classification_approval === true || source.requiresClassificationApproval === true || bugNotBugClassificationApproved !== true,
275
+ requiresEstimateHours: source.requires_estimate_hours === true || source.requiresEstimateHours === true || estimatedHours === undefined,
276
+ changeApprovalMode: cleanText(source.change_approval_mode || source.changeApprovalMode, 120) || 'on_the_fly_reapproval_required',
277
+ afterApprovalAutopilotUntilAGrade: afterApprovalAutopilotUntilAGrade,
278
+ targetGrade: cleanText(source.target_grade || source.targetGrade || completionContract.target_grade || completionContract.targetGrade || 'A', 20),
279
+ terminalTarget: cleanText(source.terminal_target
280
+ || source.terminalTarget
281
+ || completionContract.required_terminal_state
282
+ || completionContract.requiredTerminalState, 800) || 'A-grade PR with QA screenshots, AIQaBusinessAssertion before/action/after proof, source commit proof, and changed files inside owner_files',
283
+ qaScreenshotsRequired: source.qa_screenshots_required === true || source.qaScreenshotsRequired === true,
284
+ beforeActionAfterBusinessProofRequired: source.before_action_after_business_proof_required === true || source.beforeActionAfterBusinessProofRequired === true,
285
+ aiqaBusinessAssertionRequired: source.aiqa_business_assertion_required === true || source.aiqaBusinessAssertionRequired === true,
286
+ ownerFiles: ownerFiles,
287
+ approvedOwnerFiles: approvedOwnerFiles,
288
+ currentOwnerFiles: currentOwnerFiles,
289
+ scopeFingerprint: scopeFingerprint,
290
+ previousScopeFingerprint: previousScopeFingerprint,
291
+ scopeChangedSinceApproval: scopeChangedSinceApproval,
292
+ ownerFileFingerprint: ownerFileFingerprint,
293
+ approvedOwnerFileFingerprint: approvedOwnerFileFingerprint,
294
+ ownerFilesChangedSinceApproval: ownerFilesChangedSinceApproval,
295
+ ownerFilesAddedSinceApproval: ownerFilesAddedSinceApproval.length ? ownerFilesAddedSinceApproval : computedOwnerFilesAdded,
296
+ ownerFilesRemovedSinceApproval: ownerFilesRemovedSinceApproval.length ? ownerFilesRemovedSinceApproval : computedOwnerFilesRemoved,
297
+ diagnosisScopeFingerprint: diagnosisScopeFingerprint,
298
+ previousDiagnosisScopeFingerprint: previousDiagnosisScopeFingerprint,
299
+ diagnosisScopeIncluded: source.diagnosis_scope_included === true || source.diagnosisScopeIncluded === true || !!diagnosisScopeFingerprint,
300
+ diagnosisScopeValid: source.diagnosis_scope_valid === true || source.diagnosisScopeValid === true,
301
+ diagnosisScopeChangedSinceApproval: diagnosisScopeChangedSinceApproval,
302
+ diagnosisScopeFields: cleanList(source.diagnosis_scope_fields || source.diagnosisScopeFields, 40, 160),
303
+ diagnosisScopeBlockers: cleanList(source.diagnosis_scope_blockers || source.diagnosisScopeBlockers, 40, 500),
304
+ requiresOperatorApprovalForAnyScopeChange: source.requires_operator_approval_for_any_scope_change !== false && source.requiresOperatorApprovalForAnyScopeChange !== false,
305
+ leSixHourScopeCanAutofixAfterApproval: source.le_six_hour_scope_can_autofix_after_approval === true
306
+ || source.leSixHourScopeCanAutofixAfterApproval === true
307
+ || (status === 'approved_autopilot' && estimatedHours !== undefined && estimatedHours <= maxAutoHoursWithoutApproval),
308
+ onTheFlyScopeChangeApprovalRequired: onTheFlyScopeChangeApprovalRequired,
309
+ requiredCompletionEvidence: cleanList(source.required_completion_evidence || source.requiredCompletionEvidence || completionContract.required_evidence || completionContract.requiredEvidence, 40, 500),
310
+ forbiddenWithoutReapproval: cleanList(source.forbidden_without_reapproval || source.forbiddenWithoutReapproval, 40, 500),
311
+ allowedAutoActions: cleanList(source.allowed_auto_actions || source.allowedAutoActions, 40, 240),
312
+ blockers: blockers,
313
+ autopilotApprovalBoundaryValid: status === 'approved_autopilot'
314
+ };
315
+ }
316
+ function buildResolveIOSupportProductRepairDispatchGuard(input) {
317
+ var _a, _b, _c, _d, _e;
318
+ if (!input.approval && !input.editsProductCode) {
319
+ return undefined;
320
+ }
321
+ var ownerFiles = cleanList(input.ownerFiles || ((_a = input.approval) === null || _a === void 0 ? void 0 : _a.ownerFiles), 80, 500)
322
+ .map(normalizeOwnerFilePath)
323
+ .filter(Boolean);
324
+ var approval = input.approval;
325
+ var allowed = input.editsProductCode ? (approval === null || approval === void 0 ? void 0 : approval.autopilotApprovalBoundaryValid) === true : true;
326
+ var nextAction = allowed
327
+ ? (input.editsProductCode ? 'run_targeted_product_repair' : 'continue_non_product_action')
328
+ : (approval === null || approval === void 0 ? void 0 : approval.approvalAction) || 'approve_support_autonomy';
329
+ var terminalTarget = (approval === null || approval === void 0 ? void 0 : approval.terminalTarget)
330
+ || 'A-grade PR with QA screenshots, AIQaBusinessAssertion before/action/after proof, source commit proof, and changed files inside owner_files';
331
+ var requiredCompletionEvidence = ((_b = approval === null || approval === void 0 ? void 0 : approval.requiredCompletionEvidence) === null || _b === void 0 ? void 0 : _b.length)
332
+ ? approval.requiredCompletionEvidence
333
+ : [
334
+ 'A-grade execution/artifacts/pull_request review',
335
+ 'GitHub PR URL',
336
+ 'QA screenshots with captions',
337
+ 'AIQaBusinessAssertion before/action/after business proof',
338
+ 'changed files subset of approved owner_files'
339
+ ];
340
+ return {
341
+ guard: 'support_autonomy_product_repair_dispatch_guard',
342
+ status: allowed ? 'allowed' : 'blocked',
343
+ allowed: allowed,
344
+ action: input.action,
345
+ editsProductCode: input.editsProductCode,
346
+ canEditProductCode: allowed && input.editsProductCode,
347
+ autoContinueAfterApproval: allowed && input.editsProductCode,
348
+ nextAction: nextAction,
349
+ reason: allowed
350
+ ? 'Approved bounded support autonomy allows this product-code repair inside the current owner-file and diagnosis scope.'
351
+ : (approval === null || approval === void 0 ? void 0 : approval.blockers.join(' | ')) || 'Support autonomy approval is required before product-code repair.',
352
+ approvalContractId: (approval === null || approval === void 0 ? void 0 : approval.contractId) || '',
353
+ continuationContractMode: 'approved_scope_to_a_grade_pr',
354
+ terminalTarget: terminalTarget,
355
+ nextProofPhases: [
356
+ 'confirm_support_diagnosis_gate',
357
+ 'run_owner_scoped_repair',
358
+ 'run_compile_preflight',
359
+ 'run_business_proof_qa_with_screenshots',
360
+ 'create_or_update_pr',
361
+ 'run_a_grade_review',
362
+ 'park_before_merge_release_or_customer_send'
363
+ ],
364
+ allowedAutoActions: [
365
+ 'run_read_only_diagnosis',
366
+ 'run_owner_scoped_repair',
367
+ 'run_compile_preflight',
368
+ 'run_business_proof_qa',
369
+ 'create_or_update_pr',
370
+ 'auto_improve_until_a_grade'
371
+ ],
372
+ forbiddenActions: ((_c = approval === null || approval === void 0 ? void 0 : approval.forbiddenWithoutReapproval) === null || _c === void 0 ? void 0 : _c.length) ? approval.forbiddenWithoutReapproval : [
373
+ 'estimated_hours greater than max_auto_hours_without_approval',
374
+ 'bug/not-bug classification change',
375
+ 'owner_files expansion or edit outside SupportDiagnosisGate owner_files',
376
+ 'accepted_hypothesis, failing_path, issue_case, or proof_plan change',
377
+ 'customer success reply, merge, release, or deploy before AIQaBusinessAssertion proof'
378
+ ],
379
+ ownerFiles: ownerFiles,
380
+ approvedOwnerFiles: ((_d = approval === null || approval === void 0 ? void 0 : approval.approvedOwnerFiles) === null || _d === void 0 ? void 0 : _d.length) ? approval.approvedOwnerFiles : ownerFiles,
381
+ currentOwnerFiles: ((_e = approval === null || approval === void 0 ? void 0 : approval.currentOwnerFiles) === null || _e === void 0 ? void 0 : _e.length) ? approval.currentOwnerFiles : ownerFiles,
382
+ scopeFingerprint: (approval === null || approval === void 0 ? void 0 : approval.scopeFingerprint) || '',
383
+ ownerFileFingerprint: (approval === null || approval === void 0 ? void 0 : approval.ownerFileFingerprint) || '',
384
+ approvedOwnerFileFingerprint: (approval === null || approval === void 0 ? void 0 : approval.approvedOwnerFileFingerprint) || '',
385
+ ownerFilesChangedSinceApproval: (approval === null || approval === void 0 ? void 0 : approval.ownerFilesChangedSinceApproval) === true,
386
+ ownerFilesAddedSinceApproval: (approval === null || approval === void 0 ? void 0 : approval.ownerFilesAddedSinceApproval) || [],
387
+ ownerFilesRemovedSinceApproval: (approval === null || approval === void 0 ? void 0 : approval.ownerFilesRemovedSinceApproval) || [],
388
+ requiresOverLimitApproval: (approval === null || approval === void 0 ? void 0 : approval.requiresOverLimitApproval) === true,
389
+ requiresScopeReapproval: (approval === null || approval === void 0 ? void 0 : approval.requiresScopeReapproval) === true,
390
+ requiresOwnerFileReapproval: (approval === null || approval === void 0 ? void 0 : approval.requiresOwnerFileReapproval) === true,
391
+ requiresDiagnosisScopeReapproval: (approval === null || approval === void 0 ? void 0 : approval.requiresDiagnosisScopeReapproval) === true,
392
+ requiredCompletionEvidence: requiredCompletionEvidence,
393
+ blockers: (approval === null || approval === void 0 ? void 0 : approval.blockers) || []
394
+ };
395
+ }
396
+ function supportAutopilotArtifactListHasScreenshotOrTrace(values) {
397
+ return cleanList(values, 80, 500).some(function (entry) {
398
+ var text = entry.toLowerCase();
399
+ return /screenshot|trace|video|har|browser-artifact|qa-artifact/.test(text)
400
+ || /\.(png|jpe?g|webp|gif|zip|trace|har|webm|mp4)(\?|#|$)/i.test(entry);
401
+ });
402
+ }
403
+ function supportAutopilotGradeMeetsA(value) {
404
+ return /^(A\+|A|A-)$/i.test(cleanText(value, 20));
405
+ }
406
+ function normalizeSupportAutopilotPrReviewContract(value) {
407
+ var _a, _b, _c, _d, _e, _f, _g, _h;
408
+ var contract = cleanObject(value);
409
+ var grades = cleanObject(contract.grades);
410
+ var executionGrade = cleanText(contract.execution_grade
411
+ || contract.executionGrade
412
+ || grades.execution
413
+ || grades.execution_grade
414
+ || grades.executionGrade, 20).toUpperCase();
415
+ var artifactsGrade = cleanText(contract.artifacts_grade
416
+ || contract.artifactsGrade
417
+ || grades.artifacts
418
+ || grades.artifacts_grade
419
+ || grades.artifactsGrade, 20).toUpperCase();
420
+ var pullRequestGrade = cleanText(contract.pull_request_grade
421
+ || contract.pullRequestGrade
422
+ || grades.pull_request
423
+ || grades.pullRequest
424
+ || grades.pr
425
+ || grades.pr_grade, 20).toUpperCase();
426
+ var strictGatePassed = contract.strict_gate_passed === true
427
+ || contract.strictGatePassed === true
428
+ || contract.passes_strict_gate === true
429
+ || contract.passesStrictGate === true;
430
+ var ready = contract.ready === true
431
+ || strictGatePassed === true
432
+ || (supportAutopilotGradeMeetsA(executionGrade)
433
+ && supportAutopilotGradeMeetsA(artifactsGrade)
434
+ && supportAutopilotGradeMeetsA(pullRequestGrade)
435
+ && cleanText(contract.status, 120).toLowerCase() === 'passed');
436
+ var status = cleanText(contract.status, 120)
437
+ || (ready ? 'passed' : Object.keys(contract).length ? 'blocked' : 'missing');
438
+ return {
439
+ contractId: cleanText(contract.contract_id || contract.contractId, 180),
440
+ status: status,
441
+ ready: ready,
442
+ strictGatePassed: ready && strictGatePassed !== false,
443
+ strictGateReason: cleanText(contract.strict_gate_reason || contract.strictGateReason || contract.reason, 500),
444
+ executionGrade: executionGrade,
445
+ artifactsGrade: artifactsGrade,
446
+ pullRequestGrade: pullRequestGrade,
447
+ evidenceRefs: cleanList(contract.evidence_refs || contract.evidenceRefs || contract.artifacts || contract.artifact_paths || contract.artifactPaths, 80, 500),
448
+ blockers: cleanList(contract.blockers, 40, 500),
449
+ nextAction: cleanText(contract.next_action || contract.nextAction || ((_a = contract.continuation_contract) === null || _a === void 0 ? void 0 : _a.action) || ((_b = contract.continuationContract) === null || _b === void 0 ? void 0 : _b.action), 160),
450
+ failureClass: cleanText(contract.failure_class || contract.failureClass || ((_c = contract.continuation_contract) === null || _c === void 0 ? void 0 : _c.failure_class) || ((_d = contract.continuationContract) === null || _d === void 0 ? void 0 : _d.failureClass), 120),
451
+ blockerFingerprint: cleanText(contract.blocker_fingerprint || contract.blockerFingerprint || ((_e = contract.continuation_contract) === null || _e === void 0 ? void 0 : _e.blocker_fingerprint) || ((_f = contract.continuationContract) === null || _f === void 0 ? void 0 : _f.blockerFingerprint), 180),
452
+ evidenceHash: cleanText(contract.evidence_hash || contract.evidenceHash || ((_g = contract.continuation_contract) === null || _g === void 0 ? void 0 : _g.evidence_hash) || ((_h = contract.continuationContract) === null || _h === void 0 ? void 0 : _h.evidenceHash), 180),
453
+ continuationContract: cleanObject(contract.continuation_contract || contract.continuationContract)
454
+ };
455
+ }
456
+ function buildResolveIOSupportAutopilotCompletionProgress(input) {
457
+ var _a;
458
+ var approval = input.approval;
459
+ var prReadinessContract = cleanObject(input.prReadinessContract);
460
+ var hasApprovalSource = !!approval || Object.keys(prReadinessContract).length > 0;
461
+ if (!hasApprovalSource) {
462
+ return undefined;
463
+ }
464
+ var createdAt = isoNow(input.now);
465
+ var prStatus = cleanText(prReadinessContract.status, 120).toLowerCase();
466
+ var prReady = prReadinessContract.ready === true || prStatus === 'ready';
467
+ var prReview = normalizeSupportAutopilotPrReviewContract(input.prReviewContract);
468
+ var prReviewReady = prReview.ready === true;
469
+ var pullRequestUrl = cleanText(prReadinessContract.pull_request_url
470
+ || prReadinessContract.pullRequestUrl, 500);
471
+ var pullRequestStatus = cleanText(prReadinessContract.pull_request_status
472
+ || prReadinessContract.pullRequestStatus, 120);
473
+ var businessProofArtifacts = cleanList(__spreadArray(__spreadArray(__spreadArray([], __read(cleanList(input.businessProofArtifacts, 80, 500)), false), __read(cleanList(input.businessProofReadiness.artifactPaths, 80, 500)), false), __read(cleanList(prReadinessContract.business_proof_artifacts || prReadinessContract.businessProofArtifacts, 80, 500)), false), 120, 500);
474
+ var changedFiles = cleanList(__spreadArray(__spreadArray([], __read(cleanList(input.changedFiles, 80, 500)), false), __read(cleanList(prReadinessContract.modified_files || prReadinessContract.modifiedFiles, 80, 500)), false), 120, 500).map(normalizeOwnerFilePath).filter(Boolean);
475
+ var businessProofReady = input.businessProofReadiness.ready === true
476
+ || prReadinessContract.business_proof_ready === true
477
+ || prReadinessContract.businessProofReady === true;
478
+ var hasScreenshotOrTrace = supportAutopilotArtifactListHasScreenshotOrTrace(businessProofArtifacts);
479
+ var changedFilesReady = changedFiles.length > 0;
480
+ var approvalBoundaryValid = (approval === null || approval === void 0 ? void 0 : approval.autopilotApprovalBoundaryValid) === true;
481
+ var approvalApproved = (approval === null || approval === void 0 ? void 0 : approval.approved) === true;
482
+ var targetGrade = (approval === null || approval === void 0 ? void 0 : approval.targetGrade) || cleanText(prReadinessContract.target_grade || prReadinessContract.targetGrade || 'A', 20) || 'A';
483
+ var terminalTarget = (approval === null || approval === void 0 ? void 0 : approval.terminalTarget)
484
+ || 'A-grade PR with QA screenshots, AIQaBusinessAssertion before/action/after proof, source commit proof, and changed files inside owner_files';
485
+ var requiredEvidence = Array.from(new Set(__spreadArray(__spreadArray([], __read(((approval === null || approval === void 0 ? void 0 : approval.requiredCompletionEvidence) || [])), false), [
486
+ 'SupportDiagnosisGate passed',
487
+ 'owner-scoped changed files',
488
+ 'AIQaBusinessAssertion before/action/after business proof',
489
+ 'QA screenshot or trace artifact',
490
+ 'A-grade PR URL',
491
+ 'A-grade execution/artifacts/pull_request review'
492
+ ], false))).slice(0, 24);
493
+ var completedEvidence = Array.from(new Set(__spreadArray([
494
+ input.diagnosisValid ? 'SupportDiagnosisGate passed' : '',
495
+ changedFilesReady ? 'changed files recorded' : '',
496
+ businessProofReady ? 'AIQaBusinessAssertion business proof ready' : '',
497
+ hasScreenshotOrTrace ? 'QA screenshot or trace artifact recorded' : '',
498
+ prReady ? 'PR readiness contract ready' : '',
499
+ pullRequestUrl ? "pull_request_url=".concat(pullRequestUrl) : '',
500
+ prReviewReady ? "A-grade PR review passed execution=".concat(prReview.executionGrade || '-', " artifacts=").concat(prReview.artifactsGrade || '-', " pull_request=").concat(prReview.pullRequestGrade || '-') : ''
501
+ ], __read(prReview.evidenceRefs), false).filter(Boolean))).slice(0, 24);
502
+ var missingEvidence = Array.from(new Set([
503
+ !approvalApproved ? 'approved support autonomy contract' : '',
504
+ approvalApproved && !approvalBoundaryValid ? 'valid autonomy approval boundary' : '',
505
+ !input.diagnosisValid ? 'SupportDiagnosisGate passed' : '',
506
+ input.preflightGate.blocksProductRepair ? 'passing support preflight/compile gate' : '',
507
+ !changedFilesReady ? 'owner-scoped changed-file evidence' : '',
508
+ !businessProofReady ? 'AIQaBusinessAssertion before/action/after business proof' : '',
509
+ (approval === null || approval === void 0 ? void 0 : approval.qaScreenshotsRequired) !== false && !hasScreenshotOrTrace ? 'QA screenshot or trace artifact' : '',
510
+ businessProofReady && !prReady ? 'PR readiness contract' : '',
511
+ businessProofReady && prReady && !pullRequestUrl ? 'A-grade PR URL' : '',
512
+ businessProofReady && prReady && !!pullRequestUrl && !prReviewReady ? 'A-grade execution/artifacts/pull_request review' : ''
513
+ ].filter(Boolean))).slice(0, 24);
514
+ var activePhase = 'not_required';
515
+ var nextAction = 'park_manual';
516
+ var status = 'not_required';
517
+ if (!approvalApproved || !approvalBoundaryValid) {
518
+ activePhase = 'approval_required';
519
+ nextAction = (approval === null || approval === void 0 ? void 0 : approval.approvalAction) === 'approve_support_autonomy_over_limit'
520
+ ? 'approve_support_autonomy_over_limit'
521
+ : 'approve_support_autonomy';
522
+ status = 'blocked';
523
+ }
524
+ else if (!input.diagnosisValid) {
525
+ activePhase = 'diagnosis';
526
+ nextAction = 'run_diagnosis_gate';
527
+ status = 'in_progress';
528
+ }
529
+ else if (input.preflightGate.blocksProductRepair) {
530
+ activePhase = 'preflight';
531
+ nextAction = 'repair_infra_only';
532
+ status = 'in_progress';
533
+ }
534
+ else if (!changedFilesReady) {
535
+ activePhase = 'repair';
536
+ nextAction = 'run_owner_scoped_repair';
537
+ status = 'in_progress';
538
+ }
539
+ else if (!businessProofReady || !hasScreenshotOrTrace) {
540
+ activePhase = 'business_proof';
541
+ nextAction = 'run_business_proof_qa';
542
+ status = 'in_progress';
543
+ }
544
+ else if (!prReady || !pullRequestUrl) {
545
+ activePhase = 'pr_packaging';
546
+ nextAction = 'create_pr';
547
+ status = 'ready_for_pr';
548
+ }
549
+ else if (!prReviewReady) {
550
+ activePhase = 'pr_review';
551
+ nextAction = 'run_a_grade_pr_review';
552
+ status = 'in_progress';
553
+ }
554
+ else {
555
+ activePhase = 'park_before_merge_release_customer';
556
+ nextAction = 'park_before_merge_release_or_customer_send';
557
+ status = 'complete';
558
+ }
559
+ var requiresHumanApproval = activePhase === 'approval_required'
560
+ || activePhase === 'park_before_merge_release_customer';
561
+ var canAutoDispatchNext = status !== 'blocked'
562
+ && status !== 'complete'
563
+ && requiresHumanApproval !== true
564
+ && nextAction !== 'approve_support_autonomy'
565
+ && nextAction !== 'approve_support_autonomy_over_limit';
566
+ return {
567
+ contractId: "support-autopilot-completion-".concat(hashResolveIOSupportV5Evidence({
568
+ approvalContractId: (approval === null || approval === void 0 ? void 0 : approval.contractId) || '',
569
+ activePhase: activePhase,
570
+ nextAction: nextAction,
571
+ businessProofReady: businessProofReady,
572
+ pullRequestUrl: pullRequestUrl,
573
+ prReviewReady: prReviewReady,
574
+ prReviewStatus: prReview.status,
575
+ prReviewStrictGateReason: prReview.strictGateReason,
576
+ prReviewExecutionGrade: prReview.executionGrade,
577
+ prReviewArtifactsGrade: prReview.artifactsGrade,
578
+ prReviewPullRequestGrade: prReview.pullRequestGrade,
579
+ createdAt: createdAt.slice(0, 16)
580
+ }).slice(0, 16)),
581
+ mode: 'approved_scope_to_a_grade_pr',
582
+ status: status,
583
+ activePhase: activePhase,
584
+ nextAction: nextAction,
585
+ nextCommand: nextAction === 'create_pr'
586
+ ? 'createSupportTicketCodexPullRequestManual'
587
+ : String(nextAction),
588
+ reason: status === 'complete'
589
+ ? 'Approved support autopilot reached A-grade PR proof; merge, release, deploy, and customer reply remain separately gated.'
590
+ : missingEvidence.join(' | ') || "Continue approved support autopilot phase ".concat(activePhase, "."),
591
+ approved: approvalApproved,
592
+ approvalBoundaryValid: approvalBoundaryValid,
593
+ approvalContractId: (approval === null || approval === void 0 ? void 0 : approval.contractId) || '',
594
+ targetGrade: targetGrade,
595
+ terminalTarget: terminalTarget,
596
+ businessProofReady: businessProofReady,
597
+ hasScreenshotOrTrace: hasScreenshotOrTrace,
598
+ changedFilesReady: changedFilesReady,
599
+ prReadinessReady: prReady,
600
+ prReviewReady: prReviewReady,
601
+ prReviewStatus: prReview.status,
602
+ prReviewContractId: prReview.contractId,
603
+ prReviewStrictGatePassed: prReview.strictGatePassed,
604
+ prReviewStrictGateReason: prReview.strictGateReason,
605
+ prReviewExecutionGrade: prReview.executionGrade,
606
+ prReviewArtifactsGrade: prReview.artifactsGrade,
607
+ prReviewPullRequestGrade: prReview.pullRequestGrade,
608
+ pullRequestUrl: pullRequestUrl,
609
+ pullRequestStatus: pullRequestStatus,
610
+ canContinueWithoutCodexMonitor: canAutoDispatchNext,
611
+ canAutoDispatchNext: canAutoDispatchNext,
612
+ requiresHumanApproval: requiresHumanApproval,
613
+ completedEvidence: completedEvidence,
614
+ missingEvidence: missingEvidence,
615
+ requiredEvidence: requiredEvidence,
616
+ forbiddenActions: Array.from(new Set(__spreadArray(__spreadArray([], __read(((approval === null || approval === void 0 ? void 0 : approval.forbiddenWithoutReapproval) || [])), false), [
617
+ 'Do not merge, release, deploy, or send customer success reply from approved autopilot completion alone.',
618
+ 'Do not mark complete without QA screenshots/traces, AIQaBusinessAssertion proof, changed files, PR URL, and A-grade PR review.'
619
+ ], false))).slice(0, 24),
620
+ blockers: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(((approval === null || approval === void 0 ? void 0 : approval.blockers) || [])), false), __read((((_a = input.productRepairDispatchGuard) === null || _a === void 0 ? void 0 : _a.status) === 'blocked' ? input.productRepairDispatchGuard.blockers : [])), false), __read(prReview.blockers), false), __read(missingEvidence), false))).slice(0, 24),
621
+ createdAt: createdAt
622
+ };
623
+ }
137
624
  function normalizeResolveIOSupportPreflightCheckName(value) {
138
625
  var normalized = cleanText(value, 120)
139
626
  .toLowerCase()
@@ -388,22 +875,41 @@ function normalizeSupportDiagnosisEvidence(values) {
388
875
  var allowed = new Set(['ticket', 'browser', 'mongo', 'log', 'code', 'commit', 'qa', 'other']);
389
876
  if (!Array.isArray(values)) {
390
877
  var summary = cleanText(values, 1200);
391
- return summary ? [{ type: 'other', summary: summary }] : [];
878
+ return summary ? [{
879
+ id: "evidence-".concat(hashResolveIOSupportV5Evidence({ type: 'other', summary: summary }).slice(0, 12)),
880
+ type: 'other',
881
+ summary: summary
882
+ }] : [];
392
883
  }
393
884
  var stringEvidence = values
394
885
  .filter(function (entry) { return typeof entry === 'string'; })
395
- .map(function (entry) { return ({
396
- type: 'other',
397
- summary: cleanText(entry, 1200)
398
- }); });
886
+ .map(function (entry) {
887
+ var summary = cleanText(entry, 1200);
888
+ return {
889
+ id: "evidence-".concat(hashResolveIOSupportV5Evidence({ type: 'other', summary: summary }).slice(0, 12)),
890
+ type: 'other',
891
+ summary: summary
892
+ };
893
+ });
399
894
  var objectEvidence = values
400
895
  .filter(function (entry) { return entry && typeof entry === 'object' && !Array.isArray(entry); })
401
896
  .map(function (entry) {
402
897
  var type = cleanText(entry.type, 80).toLowerCase();
898
+ var normalizedType = (allowed.has(type) ? type : 'other');
899
+ var summary = cleanText(entry.summary || entry.message || entry.evidence || entry.reason, 1200);
900
+ var artifactPath = cleanText(entry.artifactPath || entry.artifact_path || entry.path || entry.file, 500);
901
+ var ownerFiles = cleanList(entry.ownerFiles || entry.owner_files || entry.files, 12, 500)
902
+ .map(normalizeOwnerFilePath)
903
+ .filter(Boolean);
904
+ var evidenceRefs = cleanList(entry.evidenceRefs || entry.evidence_refs || entry.refs, 12, 500);
403
905
  return {
404
- type: (allowed.has(type) ? type : 'other'),
405
- summary: cleanText(entry.summary || entry.message || entry.evidence || entry.reason, 1200),
406
- artifactPath: cleanText(entry.artifactPath || entry.path || entry.file, 500)
906
+ id: cleanText(entry.id || entry.evidenceId || entry.evidence_id, 160)
907
+ || "evidence-".concat(hashResolveIOSupportV5Evidence({ type: normalizedType, summary: summary, artifactPath: artifactPath, ownerFiles: ownerFiles }).slice(0, 12)),
908
+ type: normalizedType,
909
+ summary: summary,
910
+ artifactPath: artifactPath,
911
+ ownerFiles: ownerFiles,
912
+ evidenceRefs: evidenceRefs
407
913
  };
408
914
  });
409
915
  return stringEvidence.concat(objectEvidence)
@@ -775,6 +1281,7 @@ function buildResolveIOSupportDiagnosisEvidencePack(input) {
775
1281
  var diagnosisSource = input.diagnosisGate || (bundle === null || bundle === void 0 ? void 0 : bundle.supportV5DiagnosisGate);
776
1282
  var validation = validateResolveIOSupportDiagnosisGate(diagnosisSource);
777
1283
  var normalizedDiagnosis = validation.normalized;
1284
+ var proofMatrix = validation.proofMatrix || buildResolveIOSupportDiagnosisProofMatrix(diagnosisSource, input.now);
778
1285
  var ownerFileHints = cleanList(__spreadArray(__spreadArray(__spreadArray([], __read(cleanList(input.ownerFiles, 16, 500)), false), __read(cleanList(normalizedDiagnosis === null || normalizedDiagnosis === void 0 ? void 0 : normalizedDiagnosis.owner_files, 16, 500)), false), __read(cleanList(activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.targetFiles, 8, 500)), false), 16, 500).map(normalizeOwnerFilePath).filter(Boolean);
779
1286
  var issueClassHint = normalizeIssueClass(input.issueClass || (normalizedDiagnosis === null || normalizedDiagnosis === void 0 ? void 0 : normalizedDiagnosis.issue_class));
780
1287
  var text = cleanText([
@@ -825,9 +1332,15 @@ function buildResolveIOSupportDiagnosisEvidencePack(input) {
825
1332
  activeMicrotaskId: activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.microtaskId,
826
1333
  similarCaseSelection: similarCaseSelection,
827
1334
  issueClassProbeCatalog: SUPPORT_ISSUE_CLASS_PROBE_CATALOG,
1335
+ proofMatrix: proofMatrix,
828
1336
  structuredFacts: {
829
1337
  currentDiagnosisStatus: validation.status,
830
1338
  currentDiagnosisValid: validation.valid,
1339
+ proofMatrixStatus: proofMatrix.status,
1340
+ proofMatrixId: proofMatrix.matrixId,
1341
+ proofMatrixBlockerCount: proofMatrix.blockers.length,
1342
+ ownerFileCoverageReady: proofMatrix.ownerFileCoverage.every(function (entry) { return entry.covered; }),
1343
+ coveredOwnerFileCount: proofMatrix.ownerFileCoverage.filter(function (entry) { return entry.covered; }).length,
831
1344
  reproductionStatus: normalizedDiagnosis === null || normalizedDiagnosis === void 0 ? void 0 : normalizedDiagnosis.issue_case.reproduction_status,
832
1345
  evidenceTypes: ((_e = validation.evidenceQuality) === null || _e === void 0 ? void 0 : _e.evidenceTypes) || [],
833
1346
  reproductionEvidenceTypes: ((_f = validation.evidenceQuality) === null || _f === void 0 ? void 0 : _f.reproductionEvidenceTypes) || [],
@@ -865,6 +1378,53 @@ function normalizeOwnerFilePath(value) {
865
1378
  .replace(/^\/+/, '')
866
1379
  .replace(/\s+$/g, '');
867
1380
  }
1381
+ function ownerFileComparablePathKeys(value) {
1382
+ var e_4, _a;
1383
+ var normalized = normalizeOwnerFilePath(value);
1384
+ if (!normalized) {
1385
+ return [];
1386
+ }
1387
+ var keys = new Set([normalized]);
1388
+ try {
1389
+ for (var _b = __values([
1390
+ 'angular/app/',
1391
+ 'server/src/',
1392
+ 'server/app/',
1393
+ 'client/src/',
1394
+ 'client/app/'
1395
+ ]), _c = _b.next(); !_c.done; _c = _b.next()) {
1396
+ var marker = _c.value;
1397
+ var escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1398
+ var match = normalized.match(new RegExp("(?:^|/)(".concat(escaped, ".+)$"), 'i'));
1399
+ if (match === null || match === void 0 ? void 0 : match[1]) {
1400
+ keys.add(match[1]);
1401
+ }
1402
+ }
1403
+ }
1404
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
1405
+ finally {
1406
+ try {
1407
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1408
+ }
1409
+ finally { if (e_4) throw e_4.error; }
1410
+ }
1411
+ return Array.from(keys);
1412
+ }
1413
+ function ownerFilePathMatchesDiagnosisOwner(filePath, ownerFile) {
1414
+ var normalizedFilePath = normalizeOwnerFilePath(filePath);
1415
+ var normalizedOwnerFile = normalizeOwnerFilePath(ownerFile);
1416
+ if (!normalizedFilePath || !normalizedOwnerFile) {
1417
+ return false;
1418
+ }
1419
+ var fileKeys = ownerFileComparablePathKeys(normalizedFilePath);
1420
+ var ownerKeys = ownerFileComparablePathKeys(normalizedOwnerFile);
1421
+ if (fileKeys.some(function (fileKey) { return ownerKeys.some(function (ownerKey) { return fileKey.toLowerCase() === ownerKey.toLowerCase(); }); })) {
1422
+ return true;
1423
+ }
1424
+ return normalizedFilePath === normalizedOwnerFile
1425
+ || normalizedFilePath.endsWith("/".concat(normalizedOwnerFile))
1426
+ || normalizedOwnerFile.endsWith("/".concat(normalizedFilePath));
1427
+ }
868
1428
  function ownerFileLooksBroad(value) {
869
1429
  var normalized = normalizeOwnerFilePath(value);
870
1430
  return !normalized
@@ -874,6 +1434,81 @@ function ownerFileLooksBroad(value) {
874
1434
  || /^(\.|src|server|angular|client|app|lib|packages?)$/i.test(normalized)
875
1435
  || /(^|\/)(node_modules|dist|build|coverage|\.git)(\/|$)/i.test(normalized);
876
1436
  }
1437
+ function ownerFileLooksNonProductEvidence(value) {
1438
+ var normalized = normalizeOwnerFilePath(value);
1439
+ return /(^|\/)(qa-artifacts?|screenshots?|screen-shots?|traces?|logs?|tmp|temp|coverage|dist|build|docs?)(\/|$)/i.test(normalized)
1440
+ || /(^|\/)(__tests__|tests?|spec)(\/|$)|\.(?:spec|test)\.[jt]sx?$/i.test(normalized)
1441
+ || /\.(?:png|jpe?g|gif|webp|svg|pdf|log|txt|md|markdown)$/i.test(normalized);
1442
+ }
1443
+ function supportDiagnosisTextLooksGeneric(value, minimumLength) {
1444
+ if (minimumLength === void 0) { minimumLength = 18; }
1445
+ var text = cleanText(value, 1000).toLowerCase();
1446
+ if (!text) {
1447
+ return false;
1448
+ }
1449
+ var compact = text.replace(/[^a-z0-9]+/g, ' ').trim();
1450
+ if (!compact) {
1451
+ return false;
1452
+ }
1453
+ var meaningfulWords = compact.split(/\s+/g).filter(function (word) { return word.length >= 4; });
1454
+ return compact.length < minimumLength
1455
+ || meaningfulWords.length < 3
1456
+ || /^(n a|na|none|null|unknown|todo|tbd|pending|fix|bug|issue|problem|broken|not working|works|should work)$/i.test(compact)
1457
+ || /\b(todo|tbd|placeholder|unknown|guess|maybe|probably|something|somewhere|stuff|things?)\b/i.test(compact)
1458
+ || /^(fix|debug|investigate|check|look into|test|verify)( the)? (issue|bug|problem|ticket|route|page)$/i.test(compact)
1459
+ || /^(the )?(issue|bug|problem|ticket|route|page)( is)? (fixed|broken|not working|wrong)$/i.test(compact);
1460
+ }
1461
+ function collectGenericSupportDiagnosisFields(gate) {
1462
+ var _a, _b, _c, _d;
1463
+ var fields = [
1464
+ ['issue_case.expected_result', gate.issue_case.expected_result, 18],
1465
+ ['issue_case.observed_result', gate.issue_case.observed_result, 18],
1466
+ ['accepted_hypothesis.statement', gate.accepted_hypothesis.statement, 24],
1467
+ ['accepted_hypothesis.falsifiable_test', gate.accepted_hypothesis.falsifiable_test, 24],
1468
+ ['proof_plan.before', gate.proof_plan.before || gate.proof_plan.before_state_unavailable_reason, 24],
1469
+ ['proof_plan.action', gate.proof_plan.action, 24],
1470
+ ['proof_plan.after', gate.proof_plan.after, 24],
1471
+ ['proof_plan.business_assertion', gate.proof_plan.business_assertion, 24],
1472
+ ['proof_plan.data_assertion', gate.proof_plan.data_assertion, 24],
1473
+ ['proof_plan.business_proof_contract.setup_state', (_a = gate.proof_plan.business_proof_contract) === null || _a === void 0 ? void 0 : _a.setup_state, 24],
1474
+ ['proof_plan.business_proof_contract.action_under_test', (_b = gate.proof_plan.business_proof_contract) === null || _b === void 0 ? void 0 : _b.action_under_test, 24],
1475
+ ['proof_plan.business_proof_contract.expected_business_state_change', (_c = gate.proof_plan.business_proof_contract) === null || _c === void 0 ? void 0 : _c.expected_business_state_change, 24],
1476
+ ['proof_plan.business_proof_contract.data_or_dom_assertion', (_d = gate.proof_plan.business_proof_contract) === null || _d === void 0 ? void 0 : _d.data_or_dom_assertion, 24]
1477
+ ];
1478
+ var genericFields = fields
1479
+ .filter(function (_a) {
1480
+ var _b = __read(_a, 3), field = _b[0], value = _b[1], minimumLength = _b[2];
1481
+ if (!cleanText(value, 1000)) {
1482
+ return false;
1483
+ }
1484
+ if ((field === 'proof_plan.data_assertion' || field === 'proof_plan.business_proof_contract.data_or_dom_assertion')
1485
+ && /\b(id|url|pdf)\b/i.test(cleanText(value, 1000))) {
1486
+ return supportDiagnosisTextLooksGeneric(value, 12);
1487
+ }
1488
+ return supportDiagnosisTextLooksGeneric(value, minimumLength);
1489
+ })
1490
+ .map(function (_a) {
1491
+ var _b = __read(_a, 1), field = _b[0];
1492
+ return field;
1493
+ });
1494
+ var genericEvidence = gate.accepted_hypothesis.evidence
1495
+ .map(function (entry, index) { return supportDiagnosisTextLooksGeneric(entry, 20) ? "accepted_hypothesis.evidence[".concat(index, "]") : ''; })
1496
+ .filter(Boolean);
1497
+ var genericRejectedAlternatives = gate.rejected_alternatives
1498
+ .map(function (entry, index) { return supportDiagnosisTextLooksGeneric(entry, 20) ? "rejected_alternatives[".concat(index, "]") : ''; })
1499
+ .filter(Boolean);
1500
+ return __spreadArray(__spreadArray(__spreadArray([], __read(genericFields), false), __read(genericEvidence), false), __read(genericRejectedAlternatives), false);
1501
+ }
1502
+ function supportProofArtifactLooksVague(value) {
1503
+ var text = cleanText(value, 500).toLowerCase();
1504
+ if (!text) {
1505
+ return true;
1506
+ }
1507
+ var compact = text.replace(/[^a-z0-9]+/g, ' ').trim();
1508
+ var businessSignal = /\b(dom|data|mongo|delta|row|rows|count|counts|record|records|persist|persisted|parsed|field|fields|pdf|export|invoice|upload|import|dropdown|selected|selection|id|total|timing|duration|latency|query|network|console|method|publication|response|before|after)\b/i.test(compact);
1509
+ var routeOnlySignal = /\b(screenshot|screen shot|browser trace|trace|log|page|route|screen)\b/i.test(compact);
1510
+ return !businessSignal || (/^(screenshot|screen shot|browser trace|trace|log|page screenshot|route screenshot|screen screenshot)$/i.test(compact) && routeOnlySignal);
1511
+ }
877
1512
  function proofPlanLooksRouteOnly(proofPlan) {
878
1513
  var assertionText = cleanText([
879
1514
  proofPlan.business_assertion,
@@ -890,9 +1525,146 @@ function proofPlanLooksRouteOnly(proofPlan) {
890
1525
  var businessSignal = /\b(save|saved|persist|persisted|create|created|update|updated|delete|deleted|filter|filtered|exclude|excluded|include|included|row|rows|record|records|count|counts|total|totals|value|values|data|mongo|query|result|results|invoice|pdf|export|download|upload|import|dropdown|selection|selected|form|submit|submitted|validation|error message|customer|account|user|permission|auth|control|button|status|calculation|performance|duration|latency)\b/.test(assertionText);
891
1526
  return routeOnlySignal && !businessSignal;
892
1527
  }
1528
+ function supportDiagnosisEvidenceLooksRouteOnly(entry) {
1529
+ var text = cleanText([entry.summary, entry.artifactPath].filter(Boolean).join(' '), 2200).toLowerCase();
1530
+ if (!text) {
1531
+ return false;
1532
+ }
1533
+ var routeOnlySignal = /\b(route|page|screen|dashboard|url|component|shell|screenshot|screen shot)\b/.test(text)
1534
+ && /\b(loads?|loaded|renders?|rendered|opens?|opened|visible|visibility|hydrates?|hydrated|captured|displayed)\b/.test(text);
1535
+ var businessSignal = /\b(save|saved|persist|persisted|create|created|update|updated|delete|deleted|filter|filtered|exclude|excluded|include|included|row|rows|record|records|count|counts|total|totals|value|values|data|mongo|query|result|results|invoice|pdf|export|download|upload|import|dropdown|selection|selected|form|submit|submitted|validation|error message|customer|account|user|permission|auth|control|button|status|calculation|performance|duration|latency|before|after)\b/.test(text);
1536
+ return routeOnlySignal && !businessSignal;
1537
+ }
1538
+ function supportDiagnosisEvidenceLooksBusinessSpecific(entry) {
1539
+ var text = cleanText([entry.summary, entry.artifactPath].filter(Boolean).join(' '), 2200).toLowerCase();
1540
+ if (!text || supportDiagnosisEvidenceLooksRouteOnly(entry)) {
1541
+ return false;
1542
+ }
1543
+ return /\b(save|saved|persist|persisted|create|created|update|updated|delete|deleted|filter|filtered|exclude|excluded|include|included|row|rows|record|records|count|counts|total|totals|value|values|data|mongo|query|result|results|invoice|pdf|export|download|upload|import|dropdown|selection|selected|form|submit|submitted|validation|error message|customer|account|user|permission|auth|control|button|status|calculation|performance|duration|latency|before|after)\b/.test(text);
1544
+ }
893
1545
  var SUPPORT_REPRODUCTION_EVIDENCE_TYPES = new Set(['browser', 'mongo', 'log', 'qa']);
894
1546
  var SUPPORT_ROOT_CAUSE_EVIDENCE_TYPES = new Set(['browser', 'mongo', 'log', 'code', 'commit', 'qa']);
895
1547
  var SUPPORT_ARTIFACT_RECOMMENDED_EVIDENCE_TYPES = new Set(['browser', 'mongo', 'log', 'qa']);
1548
+ function supportDiagnosisEvidenceRef(entry) {
1549
+ return {
1550
+ evidenceId: entry.id || "evidence-".concat(hashResolveIOSupportV5Evidence(entry).slice(0, 12)),
1551
+ type: entry.type,
1552
+ summary: cleanText(entry.summary, 1200),
1553
+ artifactPath: cleanText(entry.artifactPath, 500) || undefined,
1554
+ ownerFiles: cleanList(entry.ownerFiles, 12, 500).map(normalizeOwnerFilePath).filter(Boolean)
1555
+ };
1556
+ }
1557
+ function supportNormalizedPathMentioned(value, ownerFile) {
1558
+ var normalizedOwner = normalizeOwnerFilePath(ownerFile).toLowerCase();
1559
+ var text = cleanText(value, 2000).replace(/\\/g, '/').toLowerCase();
1560
+ return !!normalizedOwner && !!text && text.includes(normalizedOwner);
1561
+ }
1562
+ function supportDiagnosisOwnerFileCoverage(gate, evidenceRefs) {
1563
+ var failingPathFields = [
1564
+ ['frontend', gate.failing_path.frontend],
1565
+ ['backend', gate.failing_path.backend],
1566
+ ['shared_library', gate.failing_path.shared_library],
1567
+ ['data_query', gate.failing_path.data_query],
1568
+ ['description', gate.failing_path.description]
1569
+ ];
1570
+ return gate.owner_files.map(function (ownerFile) {
1571
+ var normalizedOwner = normalizeOwnerFilePath(ownerFile);
1572
+ var evidenceIds = evidenceRefs
1573
+ .filter(function (entry) { return entry.ownerFiles.map(normalizeOwnerFilePath).includes(normalizedOwner); })
1574
+ .map(function (entry) { return entry.evidenceId; });
1575
+ var matchedFailingPathFields = failingPathFields
1576
+ .filter(function (_a) {
1577
+ var _b = __read(_a, 2), value = _b[1];
1578
+ return supportNormalizedPathMentioned(value, normalizedOwner);
1579
+ })
1580
+ .map(function (_a) {
1581
+ var _b = __read(_a, 1), field = _b[0];
1582
+ return field;
1583
+ });
1584
+ return {
1585
+ ownerFile: normalizedOwner,
1586
+ covered: evidenceIds.length > 0 || matchedFailingPathFields.length > 0,
1587
+ evidenceIds: evidenceIds,
1588
+ failingPathFields: matchedFailingPathFields
1589
+ };
1590
+ });
1591
+ }
1592
+ function buildResolveIOSupportDiagnosisProofMatrix(value, now) {
1593
+ var gate = normalizeResolveIOSupportDiagnosisGate(value);
1594
+ if (!gate) {
1595
+ return {
1596
+ matrixId: "support-diagnosis-proof-matrix-".concat(hashResolveIOSupportV5Evidence({ missing: true, now: isoNow(now) }).slice(0, 16)),
1597
+ status: 'incomplete',
1598
+ ownerFiles: [],
1599
+ reproductionEvidence: [],
1600
+ rootCauseEvidence: [],
1601
+ ownerFileCoverage: [],
1602
+ businessProofArtifacts: [],
1603
+ proofPlanChecks: {
1604
+ beforeActionAfter: false,
1605
+ businessAssertion: false,
1606
+ businessProofContract: false,
1607
+ dataOrDomAssertion: false
1608
+ },
1609
+ blockers: ['SupportDiagnosisGate is missing.'],
1610
+ generatedAt: isoNow(now)
1611
+ };
1612
+ }
1613
+ var evidenceRefs = gate.evidence.map(supportDiagnosisEvidenceRef);
1614
+ var reproductionEvidence = evidenceRefs.filter(function (entry) { return SUPPORT_REPRODUCTION_EVIDENCE_TYPES.has(entry.type); });
1615
+ var businessReproductionEvidence = reproductionEvidence.filter(supportDiagnosisEvidenceLooksBusinessSpecific);
1616
+ var rootCauseEvidence = evidenceRefs.filter(function (entry) { return SUPPORT_ROOT_CAUSE_EVIDENCE_TYPES.has(entry.type); });
1617
+ var ownerFileCoverage = supportDiagnosisOwnerFileCoverage(gate, evidenceRefs);
1618
+ var proofContract = gate.proof_plan.business_proof_contract;
1619
+ var businessProofArtifacts = Array.from(new Set(cleanList(__spreadArray([
1620
+ gate.proof_plan.artifact_expectation
1621
+ ], __read(((proofContract === null || proofContract === void 0 ? void 0 : proofContract.proof_artifacts) || [])), false), 20, 500)));
1622
+ var proofPlanChecks = {
1623
+ beforeActionAfter: !!((gate.proof_plan.before || gate.proof_plan.before_state_unavailable_reason) && gate.proof_plan.action && gate.proof_plan.after),
1624
+ businessAssertion: !!gate.proof_plan.business_assertion,
1625
+ businessProofContract: !!proofContract,
1626
+ dataOrDomAssertion: !!(gate.proof_plan.data_assertion || (proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion))
1627
+ };
1628
+ var blockers = [];
1629
+ if (gate.issue_case.reproduction_status === 'reproduced' && !reproductionEvidence.length) {
1630
+ blockers.push('Proof matrix requires reproduction evidence for reproduced support diagnoses.');
1631
+ }
1632
+ if (gate.issue_case.reproduction_status === 'reproduced' && reproductionEvidence.length && !businessReproductionEvidence.length) {
1633
+ blockers.push('Proof matrix requires issue-specific business reproduction evidence; route-load or screenshot-only evidence cannot satisfy reproduction.');
1634
+ }
1635
+ if (!rootCauseEvidence.length) {
1636
+ blockers.push('Proof matrix requires typed root-cause evidence before repair.');
1637
+ }
1638
+ var uncoveredOwners = ownerFileCoverage.filter(function (entry) { return !entry.covered; }).map(function (entry) { return entry.ownerFile; });
1639
+ if (uncoveredOwners.length) {
1640
+ blockers.push("Proof matrix owner_files are not tied to failing_path or structured evidence ownerFiles: ".concat(uncoveredOwners.join(', '), "."));
1641
+ }
1642
+ if (!businessProofArtifacts.length) {
1643
+ blockers.push('Proof matrix requires business proof artifacts from the diagnosis proof_plan.');
1644
+ }
1645
+ if (!proofPlanChecks.beforeActionAfter || !proofPlanChecks.businessAssertion || !proofPlanChecks.businessProofContract || !proofPlanChecks.dataOrDomAssertion) {
1646
+ blockers.push('Proof matrix requires before/action/after, business assertion, business_proof_contract, and DOM/data assertion coverage.');
1647
+ }
1648
+ return {
1649
+ matrixId: "support-diagnosis-proof-matrix-".concat(hashResolveIOSupportV5Evidence({
1650
+ issueClass: gate.issue_class,
1651
+ ownerFiles: gate.owner_files,
1652
+ evidenceIds: evidenceRefs.map(function (entry) { return entry.evidenceId; }),
1653
+ businessProofArtifacts: businessProofArtifacts,
1654
+ proofPlanChecks: proofPlanChecks
1655
+ }).slice(0, 16)),
1656
+ status: blockers.length ? 'incomplete' : 'ready',
1657
+ issueClass: gate.issue_class,
1658
+ ownerFiles: gate.owner_files,
1659
+ reproductionEvidence: reproductionEvidence,
1660
+ rootCauseEvidence: rootCauseEvidence,
1661
+ ownerFileCoverage: ownerFileCoverage,
1662
+ businessProofArtifacts: businessProofArtifacts,
1663
+ proofPlanChecks: proofPlanChecks,
1664
+ blockers: blockers,
1665
+ generatedAt: isoNow(now || gate.updatedAt)
1666
+ };
1667
+ }
896
1668
  function evaluateResolveIOSupportDiagnosisEvidenceQuality(value) {
897
1669
  var normalized = normalizeResolveIOSupportDiagnosisGate(value);
898
1670
  if (!normalized) {
@@ -903,6 +1675,8 @@ function evaluateResolveIOSupportDiagnosisEvidenceQuality(value) {
903
1675
  reproductionEvidenceTypes: [],
904
1676
  rootCauseEvidenceTypes: [],
905
1677
  artifactBackedEvidenceCount: 0,
1678
+ routeOnlyReproductionEvidenceCount: 0,
1679
+ businessReproductionEvidenceCount: 0,
906
1680
  hasTicketContext: false,
907
1681
  hasRootCauseEvidence: false,
908
1682
  hasReproductionEvidence: false
@@ -917,6 +1691,9 @@ function evaluateResolveIOSupportDiagnosisEvidenceQuality(value) {
917
1691
  .filter(function (entry) { return SUPPORT_ROOT_CAUSE_EVIDENCE_TYPES.has(entry.type); })
918
1692
  .map(function (entry) { return entry.type; })));
919
1693
  var artifactBackedEvidenceCount = evidence.filter(function (entry) { return !!entry.artifactPath; }).length;
1694
+ var reproductionEvidence = evidence.filter(function (entry) { return SUPPORT_REPRODUCTION_EVIDENCE_TYPES.has(entry.type); });
1695
+ var routeOnlyReproductionEvidenceCount = reproductionEvidence.filter(supportDiagnosisEvidenceLooksRouteOnly).length;
1696
+ var businessReproductionEvidenceCount = reproductionEvidence.filter(supportDiagnosisEvidenceLooksBusinessSpecific).length;
920
1697
  var hasTicketContext = evidence.some(function (entry) { return entry.type === 'ticket'; })
921
1698
  || Boolean(normalized.issue_case.customer_complaint && normalized.issue_case.account_customer_context);
922
1699
  var hasRootCauseEvidence = rootCauseEvidenceTypes.length > 0;
@@ -934,6 +1711,9 @@ function evaluateResolveIOSupportDiagnosisEvidenceQuality(value) {
934
1711
  if (normalized.issue_case.reproduction_status === 'reproduced' && !hasReproductionEvidence) {
935
1712
  blockers.push('Diagnosis reproduced issue_case requires browser, Mongo, log, or QA reproduction evidence before repair.');
936
1713
  }
1714
+ if (normalized.issue_case.reproduction_status === 'reproduced' && hasReproductionEvidence && !businessReproductionEvidenceCount) {
1715
+ blockers.push('Diagnosis reproduced issue_case requires issue-specific business reproduction proof; route-load or screenshot-only evidence is route evidence only.');
1716
+ }
937
1717
  if (normalized.issue_case.reproduction_status === 'blocked'
938
1718
  && !normalized.issue_case.reproduction_blocker) {
939
1719
  blockers.push('Diagnosis blocked reproduction requires issue_case.reproduction_blocker.');
@@ -952,6 +1732,8 @@ function evaluateResolveIOSupportDiagnosisEvidenceQuality(value) {
952
1732
  reproductionEvidenceTypes: reproductionEvidenceTypes,
953
1733
  rootCauseEvidenceTypes: rootCauseEvidenceTypes,
954
1734
  artifactBackedEvidenceCount: artifactBackedEvidenceCount,
1735
+ routeOnlyReproductionEvidenceCount: routeOnlyReproductionEvidenceCount,
1736
+ businessReproductionEvidenceCount: businessReproductionEvidenceCount,
955
1737
  hasTicketContext: hasTicketContext,
956
1738
  hasRootCauseEvidence: hasRootCauseEvidence,
957
1739
  hasReproductionEvidence: hasReproductionEvidence
@@ -1020,7 +1802,7 @@ function normalizeResolveIOSupportDiagnosisGate(value, now) {
1020
1802
  return gate;
1021
1803
  }
1022
1804
  function extractResolveIOSupportDiagnosisGateFromText(value, now) {
1023
- var e_4, _a;
1805
+ var e_5, _a;
1024
1806
  var text = String(value || '').trim();
1025
1807
  if (!text) {
1026
1808
  return undefined;
@@ -1048,12 +1830,12 @@ function extractResolveIOSupportDiagnosisGateFromText(value, now) {
1048
1830
  }
1049
1831
  }
1050
1832
  }
1051
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1833
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1052
1834
  finally {
1053
1835
  try {
1054
1836
  if (candidates_1_1 && !candidates_1_1.done && (_a = candidates_1.return)) _a.call(candidates_1);
1055
1837
  }
1056
- finally { if (e_4) throw e_4.error; }
1838
+ finally { if (e_5) throw e_5.error; }
1057
1839
  }
1058
1840
  return undefined;
1059
1841
  }
@@ -1115,6 +1897,14 @@ function validateResolveIOSupportDiagnosisGate(value, options) {
1115
1897
  if (broadFiles.length) {
1116
1898
  blockers.push("Diagnosis owner_files contains broad or unsafe path(s): ".concat(broadFiles.join(', '), "."));
1117
1899
  }
1900
+ var nonProductEvidenceFiles = normalized.owner_files.filter(ownerFileLooksNonProductEvidence);
1901
+ if (nonProductEvidenceFiles.length) {
1902
+ blockers.push("Diagnosis owner_files must be exact product/source owner files, not tests/docs/artifacts/logs/screenshots: ".concat(nonProductEvidenceFiles.join(', '), "."));
1903
+ }
1904
+ var genericFields = collectGenericSupportDiagnosisFields(normalized);
1905
+ if (genericFields.length) {
1906
+ blockers.push("Diagnosis fields are too generic or placeholder-like; replace with ticket-specific falsifiable details: ".concat(genericFields.join(', '), "."));
1907
+ }
1118
1908
  if (!normalized.proof_plan.before && !normalized.proof_plan.before_state_unavailable_reason) {
1119
1909
  blockers.push('Diagnosis proof_plan.before is required unless proof_plan.before_state_unavailable_reason explains why before-state proof is impossible.');
1120
1910
  }
@@ -1153,6 +1943,9 @@ function validateResolveIOSupportDiagnosisGate(value, options) {
1153
1943
  if (!proofContract.proof_artifacts.length) {
1154
1944
  blockers.push('Diagnosis proof_plan.business_proof_contract.proof_artifacts must include at least one required artifact.');
1155
1945
  }
1946
+ else if (proofContract.proof_artifacts.every(supportProofArtifactLooksVague)) {
1947
+ blockers.push('Diagnosis proof_plan.business_proof_contract.proof_artifacts are too generic; include replayable DOM/data/Mongo/network/artifact proof tied to the business assertion.');
1948
+ }
1156
1949
  if (!proofContract.data_or_dom_assertion) {
1157
1950
  blockers.push('Diagnosis proof_plan.business_proof_contract.data_or_dom_assertion is required.');
1158
1951
  }
@@ -1162,13 +1955,16 @@ function validateResolveIOSupportDiagnosisGate(value, options) {
1162
1955
  }
1163
1956
  var evidenceQuality = evaluateResolveIOSupportDiagnosisEvidenceQuality(normalized);
1164
1957
  blockers.push.apply(blockers, __spreadArray([], __read(evidenceQuality.blockers), false));
1958
+ var proofMatrix = buildResolveIOSupportDiagnosisProofMatrix(normalized);
1959
+ blockers.push.apply(blockers, __spreadArray([], __read(proofMatrix.blockers), false));
1165
1960
  normalized.status = blockers.length ? 'incomplete' : 'passed';
1166
1961
  return {
1167
1962
  valid: blockers.length === 0,
1168
1963
  status: normalized.status,
1169
1964
  blockers: blockers,
1170
1965
  normalized: normalized,
1171
- evidenceQuality: evidenceQuality
1966
+ evidenceQuality: evidenceQuality,
1967
+ proofMatrix: proofMatrix
1172
1968
  };
1173
1969
  }
1174
1970
  function normalizeSupportConfidenceLevel(value) {
@@ -1202,7 +1998,7 @@ function supportStatusLooksPassed(value) {
1202
1998
  return /\b(pass|passed|success|succeeded|complete|completed|ready|not_required|not required)\b/i.test(cleanText(value, 200));
1203
1999
  }
1204
2000
  function nestedObject(source) {
1205
- var e_5, _a;
2001
+ var e_6, _a;
1206
2002
  var keys = [];
1207
2003
  for (var _i = 1; _i < arguments.length; _i++) {
1208
2004
  keys[_i - 1] = arguments[_i];
@@ -1216,17 +2012,17 @@ function nestedObject(source) {
1216
2012
  }
1217
2013
  }
1218
2014
  }
1219
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
2015
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1220
2016
  finally {
1221
2017
  try {
1222
2018
  if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
1223
2019
  }
1224
- finally { if (e_5) throw e_5.error; }
2020
+ finally { if (e_6) throw e_6.error; }
1225
2021
  }
1226
2022
  return {};
1227
2023
  }
1228
2024
  function resolveSupportReplyReleaseGate(input) {
1229
- var e_6, _a;
2025
+ var e_7, _a;
1230
2026
  var _b;
1231
2027
  var releaseEvidence = cleanObject(input.releaseEvidence);
1232
2028
  var releaseStatus = cleanText(input.releaseStatus
@@ -1297,12 +2093,12 @@ function resolveSupportReplyReleaseGate(input) {
1297
2093
  blockers.push("missing_".concat(field));
1298
2094
  }
1299
2095
  }
1300
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
2096
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
1301
2097
  finally {
1302
2098
  try {
1303
2099
  if (missingCommitProofFields_1_1 && !missingCommitProofFields_1_1.done && (_a = missingCommitProofFields_1.return)) _a.call(missingCommitProofFields_1);
1304
2100
  }
1305
- finally { if (e_6) throw e_6.error; }
2101
+ finally { if (e_7) throw e_7.error; }
1306
2102
  }
1307
2103
  var shouldEvaluateHotfix = statusBlocked || commitProofRequired || Object.keys(hotfixEvidence).length > 0;
1308
2104
  var hotfixContinuation = shouldEvaluateHotfix
@@ -1348,7 +2144,7 @@ function supportBusinessAssertionRouteOnly(value) {
1348
2144
  return /^(route_probe_pass|route_only_pass|route_pass|route_probe|route_loaded)$/i.test(cleanText(value, 80));
1349
2145
  }
1350
2146
  function normalizeSupportBusinessProofAssertions(input) {
1351
- var e_7, _a;
2147
+ var e_8, _a;
1352
2148
  var gate = normalizeResolveIOSupportDiagnosisGate(input.diagnosisGate);
1353
2149
  var proofPlan = gate === null || gate === void 0 ? void 0 : gate.proof_plan;
1354
2150
  var proofContract = proofPlan === null || proofPlan === void 0 ? void 0 : proofPlan.business_proof_contract;
@@ -1382,12 +2178,12 @@ function normalizeSupportBusinessProofAssertions(input) {
1382
2178
  });
1383
2179
  }
1384
2180
  }
1385
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
2181
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
1386
2182
  finally {
1387
2183
  try {
1388
2184
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1389
2185
  }
1390
- finally { if (e_7) throw e_7.error; }
2186
+ finally { if (e_8) throw e_8.error; }
1391
2187
  }
1392
2188
  var status = cleanText(input.businessAssertionStatus || input.outcomeLabel, 80);
1393
2189
  if (!assertions.length && (supportBusinessAssertionPassed(status) || supportBusinessAssertionRouteOnly(status) || supportBusinessAssertionFailed(status))) {
@@ -1425,8 +2221,59 @@ function supportBusinessProofAssertionText(assertion) {
1425
2221
  assertion.message
1426
2222
  ].filter(Boolean).join(' '), 4000);
1427
2223
  }
2224
+ function normalizeSupportProofRoute(value) {
2225
+ var raw = cleanText(value, 500);
2226
+ if (!raw) {
2227
+ return '';
2228
+ }
2229
+ var route = raw.split(/[?#]/)[0].replace(/\/+$/g, '') || '/';
2230
+ return route.toLowerCase();
2231
+ }
2232
+ function supportProofFieldMatches(candidate, expected, minimumLength) {
2233
+ if (minimumLength === void 0) { minimumLength = 12; }
2234
+ var candidateText = cleanText(candidate, 1400).toLowerCase();
2235
+ var expectedText = cleanText(expected, 1400).toLowerCase();
2236
+ if (!candidateText || !expectedText || expectedText.length < minimumLength) {
2237
+ return false;
2238
+ }
2239
+ return candidateText === expectedText
2240
+ || candidateText.includes(expectedText)
2241
+ || expectedText.includes(candidateText);
2242
+ }
2243
+ function supportBusinessProofAssertionHasStructuredContractMapping(assertion, gate) {
2244
+ var proofPlan = gate.proof_plan;
2245
+ var proofContract = proofPlan.business_proof_contract;
2246
+ var expectedRoute = normalizeSupportProofRoute(proofPlan.route || gate.issue_case.route_module);
2247
+ var assertionRoute = normalizeSupportProofRoute(assertion.route);
2248
+ var routeMatches = !expectedRoute || !assertionRoute || expectedRoute === assertionRoute;
2249
+ var actionMatches = [
2250
+ assertion.action,
2251
+ assertion.workflow
2252
+ ].some(function (candidate) { return [
2253
+ proofPlan.action,
2254
+ proofContract === null || proofContract === void 0 ? void 0 : proofContract.action_under_test
2255
+ ].some(function (expected) { return supportProofFieldMatches(candidate, expected, 12); }); });
2256
+ var expectedStateMatches = [
2257
+ assertion.expected,
2258
+ assertion.after,
2259
+ assertion.observed,
2260
+ assertion.dataProof,
2261
+ assertion.assertion
2262
+ ].some(function (candidate) { return [
2263
+ proofPlan.after,
2264
+ proofPlan.business_assertion,
2265
+ proofPlan.data_assertion,
2266
+ proofContract === null || proofContract === void 0 ? void 0 : proofContract.expected_business_state_change,
2267
+ proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion
2268
+ ].some(function (expected) { return supportProofFieldMatches(candidate, expected, 12); }); });
2269
+ var hasBusinessDataProof = !!cleanText(assertion.dataProof, 50)
2270
+ || Object.keys(cleanObject(assertion.mongoDelta)).length > 0
2271
+ || !!cleanText(assertion.observed, 80)
2272
+ || !!cleanText(assertion.after, 80);
2273
+ return routeMatches && actionMatches && expectedStateMatches && hasBusinessDataProof;
2274
+ }
1428
2275
  function supportBusinessProofAssertionMatchesContract(assertion, gate) {
1429
- var e_8, _a;
2276
+ var e_9, _a;
1430
2277
  if (!gate) {
1431
2278
  return false;
1432
2279
  }
@@ -1437,7 +2284,7 @@ function supportBusinessProofAssertionMatchesContract(assertion, gate) {
1437
2284
  || metadata.diagnosis_proof_plan_matched === true
1438
2285
  || metadata.proofPlanMatched === true
1439
2286
  || metadata.proof_plan_matched === true) {
1440
- return true;
2287
+ return supportBusinessProofAssertionHasStructuredContractMapping(assertion, gate);
1441
2288
  }
1442
2289
  var proofPlan = gate.proof_plan;
1443
2290
  var proofContract = proofPlan.business_proof_contract;
@@ -1466,12 +2313,12 @@ function supportBusinessProofAssertionMatchesContract(assertion, gate) {
1466
2313
  }
1467
2314
  }
1468
2315
  }
1469
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
2316
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
1470
2317
  finally {
1471
2318
  try {
1472
2319
  if (proofWords_1_1 && !proofWords_1_1.done && (_a = proofWords_1.return)) _a.call(proofWords_1);
1473
2320
  }
1474
- finally { if (e_8) throw e_8.error; }
2321
+ finally { if (e_9) throw e_9.error; }
1475
2322
  }
1476
2323
  return overlap >= Math.min(5, Math.max(3, Math.ceil(proofWords.size * 0.45)));
1477
2324
  }
@@ -1946,6 +2793,7 @@ function supportAutonomousReviewTypeForAction(action) {
1946
2793
  return 'owner_scoped_repair';
1947
2794
  case 'run_business_proof_qa':
1948
2795
  return 'business_proof_qa';
2796
+ case 'run_a_grade_pr_review':
1949
2797
  case 'repair_release_hotfix_first':
1950
2798
  case 'ready_for_release_gate':
1951
2799
  return 'release_hotfix';
@@ -2266,6 +3114,180 @@ function decideResolveIOSupportCustomerReplyPolicy(input) {
2266
3114
  }
2267
3115
  }, issueClassProbePlanValidation);
2268
3116
  }
3117
+ function buildSupportIssueClassBrowserSteps(args) {
3118
+ var route = cleanText(args.route, 500) || 'the affected route/module';
3119
+ var issueSteps = {
3120
+ no_op_submit: [
3121
+ 'Capture the form/action state before submit, including the target record id or validation state.',
3122
+ 'Trigger the exact submit/action control reported by the customer.',
3123
+ 'Verify the persisted state, success/validation message, or method/network result changed as expected.'
3124
+ ],
3125
+ missing_wrong_data: [
3126
+ 'Load the named customer/account/record context before changing any filters or data.',
3127
+ 'Compare visible DOM values against the persisted/source-of-truth data.',
3128
+ 'Verify the corrected visible values remain tied to the same customer/account context.'
3129
+ ],
3130
+ filter_query_mismatch: [
3131
+ 'Capture the unfiltered or before-filter row/count state for the affected dataset.',
3132
+ 'Apply the exact reported filter/query/search inputs.',
3133
+ 'Assert included rows/counts and excluded wrong rows against DOM plus data/query proof.'
3134
+ ],
3135
+ invoice_pdf_export: [
3136
+ 'Open the affected invoice/report/export route and capture source rows/totals before export.',
3137
+ 'Trigger the exact PDF/export/download action.',
3138
+ 'Parse or inspect the generated artifact and verify expected rows, totals, fields, or file output.'
3139
+ ],
3140
+ upload_import: [
3141
+ 'Attach the representative import file or fixture and capture pre-import row/count state.',
3142
+ 'Run the upload/import action through the visible workflow.',
3143
+ 'Verify result messaging plus persisted row/count delta or rejected-row evidence.'
3144
+ ],
3145
+ route_auth_hydration: [
3146
+ 'Seed or replay auth for the affected user/account before route navigation.',
3147
+ 'Open the exact route and wait for the functional screen, not only the shell/nav.',
3148
+ 'Assert required controls/data are hydrated and capture console/network errors if hydration fails.'
3149
+ ],
3150
+ slow_query_performance: [
3151
+ 'Capture before timing/log evidence for the reported query or workflow.',
3152
+ 'Run the same query/workflow after repair with equivalent inputs and account context.',
3153
+ 'Verify timing target or improvement while preserving result equivalence.'
3154
+ ]
3155
+ };
3156
+ return __spreadArray(__spreadArray([
3157
+ "Navigate to ".concat(route, " as the affected user/account context.")
3158
+ ], __read((issueSteps[args.issueClass] || issueSteps.missing_wrong_data)), false), [
3159
+ args.before ? "Before proof: ".concat(args.before) : '',
3160
+ args.action ? "Action under test: ".concat(args.action) : "Action under test: ".concat(args.action || 'execute the reported workflow action'),
3161
+ args.after ? "Expected after state: ".concat(args.after) : '',
3162
+ args.assertion ? "DOM/data assertion: ".concat(args.assertion) : ''
3163
+ ], false).map(function (entry) { return cleanText(entry, 500); })
3164
+ .filter(Boolean)
3165
+ .slice(0, 10);
3166
+ }
3167
+ function buildSupportIssueClassDataProofRequirements(args) {
3168
+ var issueRequirements = {
3169
+ no_op_submit: ['pre-submit state', 'submit action result', 'persisted state or validation delta'],
3170
+ missing_wrong_data: ['expected source-of-truth record', 'visible DOM/data snapshot', 'same-account/customer proof'],
3171
+ filter_query_mismatch: ['filter input values', 'included row/count proof', 'excluded wrong-row proof', 'query/publication proof when available'],
3172
+ invoice_pdf_export: ['export trigger trace', 'generated file artifact path', 'parsed generated content proof'],
3173
+ upload_import: ['input file fixture', 'import result message', 'persisted row/count delta'],
3174
+ route_auth_hydration: ['auth context', 'hydrated DOM proof', 'console/network error log'],
3175
+ slow_query_performance: ['before timing', 'after timing', 'result equivalence proof', 'query/log trace']
3176
+ };
3177
+ return Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read((issueRequirements[args.issueClass] || issueRequirements.missing_wrong_data)), false), __read(args.requiredArtifacts), false), [
3178
+ args.assertion
3179
+ ], false).map(function (entry) { return cleanText(entry, 260); }).filter(Boolean))).slice(0, 16);
3180
+ }
3181
+ function buildSupportIssueClassProbeAssertionTemplate(args) {
3182
+ return {
3183
+ assertion: args.stateTransition.assertion || args.expected,
3184
+ status: 'pending',
3185
+ workflow: args.objective,
3186
+ route: cleanText(args.route, 500) || undefined,
3187
+ before: args.stateTransition.before,
3188
+ action: args.stateTransition.action,
3189
+ expected: args.expected,
3190
+ observed: '',
3191
+ dataProof: '',
3192
+ artifactPaths: args.requiredArtifacts,
3193
+ metadata: {
3194
+ supportDiagnosisProof: true,
3195
+ issueClass: args.issueClass,
3196
+ probePlanRequired: true,
3197
+ routeOnlyIsFalsePass: true
3198
+ }
3199
+ };
3200
+ }
3201
+ function buildSupportIssueClassProbeQaRow(args) {
3202
+ var rowId = "support-issue-probe-".concat(hashResolveIOSupportV5Evidence({
3203
+ issueClass: args.issueClass,
3204
+ route: args.route,
3205
+ action: args.action,
3206
+ assertion: args.stateTransition.assertion
3207
+ }).slice(0, 16));
3208
+ return {
3209
+ row_id: rowId,
3210
+ issue_class: args.issueClass,
3211
+ probe_type: 'issue_class_probe',
3212
+ route: cleanText(args.route, 500) || undefined,
3213
+ action_under_test: args.action,
3214
+ browser_steps: args.browserSteps,
3215
+ expected_result: args.expected,
3216
+ expected_dom_or_data_proof: args.expectedEvidence,
3217
+ required_artifacts: args.requiredArtifacts,
3218
+ false_pass_blockers: args.falsePassBlockers,
3219
+ state_transition: args.stateTransition,
3220
+ acceptance_gate: 'aiqa_business_assertion',
3221
+ requires_aiqa_business_assertion: true,
3222
+ route_only_is_false_pass: true,
3223
+ mobile_viewport_required: args.issueClass === 'route_auth_hydration'
3224
+ };
3225
+ }
3226
+ function normalizeResolveIOSupportIssueClassProbeQaRow(value, fallback) {
3227
+ var source = cleanObject(value);
3228
+ if (!Object.keys(source).length && !fallback.action) {
3229
+ return undefined;
3230
+ }
3231
+ var stateTransition = cleanObject(source.state_transition || source.stateTransition);
3232
+ var normalizedStateTransition = {
3233
+ before: cleanText(stateTransition.before, 800) || fallback.stateTransition.before,
3234
+ action: cleanText(stateTransition.action, 800) || fallback.stateTransition.action,
3235
+ after: cleanText(stateTransition.after, 800) || fallback.stateTransition.after,
3236
+ assertion: cleanText(stateTransition.assertion, 1000) || fallback.stateTransition.assertion
3237
+ };
3238
+ var browserSteps = cleanList(source.browser_steps || source.browserSteps, 12, 500).length
3239
+ ? cleanList(source.browser_steps || source.browserSteps, 12, 500)
3240
+ : fallback.browserSteps;
3241
+ return {
3242
+ row_id: cleanText(source.row_id || source.rowId || source.id, 180) || "support-issue-probe-".concat(hashResolveIOSupportV5Evidence({
3243
+ issueClass: fallback.issueClass,
3244
+ route: source.route || fallback.route,
3245
+ action: source.action_under_test || source.actionUnderTest || fallback.action,
3246
+ assertion: normalizedStateTransition.assertion
3247
+ }).slice(0, 16)),
3248
+ issue_class: (normalizeIssueClass(source.issue_class || source.issueClass) || fallback.issueClass),
3249
+ probe_type: (cleanText(source.probe_type || source.probeType, 80) || 'issue_class_probe'),
3250
+ route: cleanText(source.route, 500) || fallback.route,
3251
+ action_under_test: cleanText(source.action_under_test || source.actionUnderTest || source.action, 1200) || fallback.action,
3252
+ browser_steps: browserSteps,
3253
+ expected_result: cleanText(source.expected_result || source.expectedResult, 1600) || fallback.expectedBusinessProof,
3254
+ expected_dom_or_data_proof: cleanText(source.expected_dom_or_data_proof || source.expectedDomOrDataProof || source.expected_evidence || source.expectedEvidence, 1600) || fallback.expectedEvidence,
3255
+ required_artifacts: cleanList(source.required_artifacts || source.requiredArtifacts, 16, 260).length
3256
+ ? cleanList(source.required_artifacts || source.requiredArtifacts, 16, 260)
3257
+ : fallback.requiredArtifacts,
3258
+ false_pass_blockers: cleanList(source.false_pass_blockers || source.falsePassBlockers, 12, 260).length
3259
+ ? cleanList(source.false_pass_blockers || source.falsePassBlockers, 12, 260)
3260
+ : fallback.falsePassBlockers,
3261
+ state_transition: normalizedStateTransition,
3262
+ acceptance_gate: 'aiqa_business_assertion',
3263
+ requires_aiqa_business_assertion: true,
3264
+ route_only_is_false_pass: true,
3265
+ mobile_viewport_required: source.mobile_viewport_required === true || source.mobileViewportRequired === true
3266
+ };
3267
+ }
3268
+ function normalizeResolveIOSupportIssueClassProbeAssertionTemplate(value, fallback) {
3269
+ var source = cleanObject(value);
3270
+ return {
3271
+ assertion: cleanText(source.assertion, 1600) || fallback.stateTransition.assertion || fallback.expected,
3272
+ status: 'pending',
3273
+ workflow: cleanText(source.workflow, 1000) || fallback.objective,
3274
+ route: cleanText(source.route, 500) || fallback.route,
3275
+ before: cleanText(source.before, 800) || fallback.stateTransition.before,
3276
+ action: cleanText(source.action, 800) || fallback.stateTransition.action,
3277
+ expected: cleanText(source.expected, 1600) || fallback.expected,
3278
+ observed: cleanText(source.observed, 1600),
3279
+ dataProof: cleanText(source.dataProof || source.data_proof, 1600),
3280
+ artifactPaths: cleanList(source.artifactPaths || source.artifact_paths, 20, 500).length
3281
+ ? cleanList(source.artifactPaths || source.artifact_paths, 20, 500)
3282
+ : fallback.requiredArtifacts,
3283
+ metadata: {
3284
+ supportDiagnosisProof: true,
3285
+ issueClass: fallback.issueClass,
3286
+ probePlanRequired: true,
3287
+ routeOnlyIsFalsePass: true
3288
+ }
3289
+ };
3290
+ }
2269
3291
  function buildResolveIOSupportIssueClassProbes(value) {
2270
3292
  var validation = validateResolveIOSupportDiagnosisGate(value);
2271
3293
  var gate = validation.normalized || normalizeResolveIOSupportDiagnosisGate(value);
@@ -2337,13 +3359,51 @@ function buildResolveIOSupportIssueClassProbes(value) {
2337
3359
  var selected = map[gate.issue_class];
2338
3360
  var catalog = SUPPORT_ISSUE_CLASS_PROBE_CATALOG.find(function (entry) { return entry.issue_class === gate.issue_class; });
2339
3361
  var requiredArtifacts = Array.from(new Set(__spreadArray(__spreadArray([], __read(contractArtifacts), false), __read(selected.requiredArtifacts), false)));
2340
- return [__assign(__assign({}, common), { failure_class: selected.failureClass, objective: "Issue-class probe for ".concat(gate.issue_class, ": ").concat(gate.issue_case.customer_complaint), action: proofContract
2341
- ? "".concat(proofContract.action_under_test, " ").concat(selected.action)
2342
- : selected.action, expected_evidence: "".concat(selected.expected).concat(assertion ? " Assertion: ".concat(assertion, ".") : '').concat(requiredArtifacts.length ? " Required artifacts: ".concat(requiredArtifacts.join(', '), ".") : '').trim(), expected_business_proof: proof || gate.proof_plan.business_assertion, required_artifacts: requiredArtifacts, false_pass_blockers: (catalog === null || catalog === void 0 ? void 0 : catalog.false_pass_blockers) || [
2343
- 'route loaded only',
2344
- 'screenshot without business state proof',
2345
- 'model claim without DOM/data proof'
2346
- ] })];
3362
+ var stateTransition = common.state_transition;
3363
+ var action = proofContract
3364
+ ? "".concat(proofContract.action_under_test, " ").concat(selected.action)
3365
+ : selected.action;
3366
+ var expectedEvidence = "".concat(selected.expected).concat(assertion ? " Assertion: ".concat(assertion, ".") : '').concat(requiredArtifacts.length ? " Required artifacts: ".concat(requiredArtifacts.join(', '), ".") : '').trim();
3367
+ var objective = "Issue-class probe for ".concat(gate.issue_class, ": ").concat(gate.issue_case.customer_complaint);
3368
+ var falsePassBlockers = (catalog === null || catalog === void 0 ? void 0 : catalog.false_pass_blockers) || [
3369
+ 'route loaded only',
3370
+ 'screenshot without business state proof',
3371
+ 'model claim without DOM/data proof'
3372
+ ];
3373
+ var browserSteps = buildSupportIssueClassBrowserSteps({
3374
+ issueClass: gate.issue_class,
3375
+ route: route,
3376
+ action: stateTransition.action || action,
3377
+ before: stateTransition.before,
3378
+ after: stateTransition.after,
3379
+ assertion: stateTransition.assertion
3380
+ });
3381
+ var dataProofRequirements = buildSupportIssueClassDataProofRequirements({
3382
+ issueClass: gate.issue_class,
3383
+ assertion: stateTransition.assertion,
3384
+ requiredArtifacts: requiredArtifacts
3385
+ });
3386
+ var qaRow = buildSupportIssueClassProbeQaRow({
3387
+ issueClass: gate.issue_class,
3388
+ route: route,
3389
+ objective: objective,
3390
+ action: action,
3391
+ expected: proof || gate.proof_plan.business_assertion,
3392
+ expectedEvidence: expectedEvidence,
3393
+ stateTransition: stateTransition,
3394
+ requiredArtifacts: requiredArtifacts,
3395
+ falsePassBlockers: falsePassBlockers,
3396
+ browserSteps: browserSteps
3397
+ });
3398
+ var assertionTemplate = buildSupportIssueClassProbeAssertionTemplate({
3399
+ issueClass: gate.issue_class,
3400
+ route: route,
3401
+ objective: objective,
3402
+ expected: proof || gate.proof_plan.business_assertion,
3403
+ stateTransition: stateTransition,
3404
+ requiredArtifacts: requiredArtifacts
3405
+ });
3406
+ return [__assign(__assign({}, common), { failure_class: selected.failureClass, objective: objective, action: action, browser_steps: browserSteps, expected_evidence: expectedEvidence, expected_business_proof: proof || gate.proof_plan.business_assertion, data_proof_requirements: dataProofRequirements, required_artifacts: requiredArtifacts, qa_rows: [qaRow], active_qa_row: qaRow, aiqa_business_assertion_template: assertionTemplate, false_pass_blockers: falsePassBlockers })];
2347
3407
  }
2348
3408
  function normalizeResolveIOSupportIssueClassProbe(value, diagnosisGate) {
2349
3409
  var source = cleanObject(value);
@@ -2354,28 +3414,109 @@ function normalizeResolveIOSupportIssueClassProbe(value, diagnosisGate) {
2354
3414
  var stateTransition = cleanObject(source.state_transition || source.stateTransition);
2355
3415
  var route = cleanText(source.route, 500);
2356
3416
  var failureClass = cleanText(source.failure_class || source.failureClass || 'business', 80);
3417
+ var normalizedIssueClass = (issueClass || (diagnosisGate === null || diagnosisGate === void 0 ? void 0 : diagnosisGate.issue_class) || 'missing_wrong_data');
3418
+ var action = cleanText(source.action, 1200);
3419
+ var expectedEvidence = cleanText(source.expected_evidence || source.expectedEvidence, 1600);
3420
+ var expectedBusinessProof = cleanText(source.expected_business_proof || source.expectedBusinessProof, 1600);
3421
+ var requiredArtifacts = cleanList(source.required_artifacts || source.requiredArtifacts, 12, 220);
3422
+ var falsePassBlockers = cleanList(source.false_pass_blockers || source.falsePassBlockers, 8, 260);
3423
+ var normalizedStateTransition = {
3424
+ before: cleanText(stateTransition.before, 800),
3425
+ action: cleanText(stateTransition.action, 800),
3426
+ after: cleanText(stateTransition.after, 800),
3427
+ assertion: cleanText(stateTransition.assertion, 1000)
3428
+ };
3429
+ var browserSteps = cleanList(source.browser_steps || source.browserSteps, 12, 500).length
3430
+ ? cleanList(source.browser_steps || source.browserSteps, 12, 500)
3431
+ : buildSupportIssueClassBrowserSteps({
3432
+ issueClass: normalizedIssueClass,
3433
+ route: route,
3434
+ action: normalizedStateTransition.action || action,
3435
+ before: normalizedStateTransition.before,
3436
+ after: normalizedStateTransition.after,
3437
+ assertion: normalizedStateTransition.assertion
3438
+ });
3439
+ var dataProofRequirements = cleanList(source.data_proof_requirements || source.dataProofRequirements, 16, 260).length
3440
+ ? cleanList(source.data_proof_requirements || source.dataProofRequirements, 16, 260)
3441
+ : buildSupportIssueClassDataProofRequirements({
3442
+ issueClass: normalizedIssueClass,
3443
+ assertion: normalizedStateTransition.assertion,
3444
+ requiredArtifacts: requiredArtifacts
3445
+ });
3446
+ var rawQaRows = Array.isArray(source.qa_rows)
3447
+ ? source.qa_rows
3448
+ : Array.isArray(source.qaRows)
3449
+ ? source.qaRows
3450
+ : source.active_qa_row || source.activeQaRow
3451
+ ? [source.active_qa_row || source.activeQaRow]
3452
+ : [];
3453
+ var normalizedQaRows = rawQaRows
3454
+ .map(function (row) { return normalizeResolveIOSupportIssueClassProbeQaRow(row, {
3455
+ issueClass: normalizedIssueClass,
3456
+ route: route,
3457
+ action: action,
3458
+ expectedBusinessProof: expectedBusinessProof,
3459
+ expectedEvidence: expectedEvidence,
3460
+ requiredArtifacts: requiredArtifacts,
3461
+ falsePassBlockers: falsePassBlockers,
3462
+ stateTransition: normalizedStateTransition,
3463
+ browserSteps: browserSteps
3464
+ }); })
3465
+ .filter(function (row) { return !!row; });
3466
+ if (!normalizedQaRows.length && action && expectedEvidence) {
3467
+ normalizedQaRows.push(buildSupportIssueClassProbeQaRow({
3468
+ issueClass: normalizedIssueClass,
3469
+ route: route,
3470
+ objective: cleanText(source.objective, 1000),
3471
+ action: action,
3472
+ expected: expectedBusinessProof,
3473
+ expectedEvidence: expectedEvidence,
3474
+ stateTransition: normalizedStateTransition,
3475
+ requiredArtifacts: requiredArtifacts,
3476
+ falsePassBlockers: falsePassBlockers,
3477
+ browserSteps: browserSteps
3478
+ }));
3479
+ }
3480
+ var assertionTemplateSource = cleanObject(source.aiqa_business_assertion_template || source.aiqaBusinessAssertionTemplate);
3481
+ var assertionTemplate = Object.keys(assertionTemplateSource).length
3482
+ ? normalizeResolveIOSupportIssueClassProbeAssertionTemplate(assertionTemplateSource, {
3483
+ issueClass: normalizedIssueClass,
3484
+ route: route,
3485
+ objective: cleanText(source.objective, 1000),
3486
+ expected: expectedBusinessProof,
3487
+ stateTransition: normalizedStateTransition,
3488
+ requiredArtifacts: requiredArtifacts
3489
+ })
3490
+ : buildSupportIssueClassProbeAssertionTemplate({
3491
+ issueClass: normalizedIssueClass,
3492
+ route: route,
3493
+ objective: cleanText(source.objective, 1000),
3494
+ expected: expectedBusinessProof,
3495
+ stateTransition: normalizedStateTransition,
3496
+ requiredArtifacts: requiredArtifacts
3497
+ });
2357
3498
  return {
2358
- issue_class: (issueClass || (diagnosisGate === null || diagnosisGate === void 0 ? void 0 : diagnosisGate.issue_class) || 'missing_wrong_data'),
3499
+ issue_class: normalizedIssueClass,
2359
3500
  probe_type: (cleanText(source.probe_type || source.probeType, 80) || 'issue_class_probe'),
2360
3501
  failure_class: failureClass,
2361
3502
  objective: cleanText(source.objective, 1000),
2362
3503
  route: route,
2363
- action: cleanText(source.action, 1200),
2364
- expected_evidence: cleanText(source.expected_evidence || source.expectedEvidence, 1600),
2365
- expected_business_proof: cleanText(source.expected_business_proof || source.expectedBusinessProof, 1600),
2366
- required_artifacts: cleanList(source.required_artifacts || source.requiredArtifacts, 12, 220),
2367
- state_transition: {
2368
- before: cleanText(stateTransition.before, 800),
2369
- action: cleanText(stateTransition.action, 800),
2370
- after: cleanText(stateTransition.after, 800),
2371
- assertion: cleanText(stateTransition.assertion, 1000)
2372
- },
3504
+ action: action,
3505
+ browser_steps: browserSteps,
3506
+ expected_evidence: expectedEvidence,
3507
+ expected_business_proof: expectedBusinessProof,
3508
+ data_proof_requirements: dataProofRequirements,
3509
+ required_artifacts: requiredArtifacts,
3510
+ qa_rows: normalizedQaRows,
3511
+ active_qa_row: normalizedQaRows[0],
3512
+ aiqa_business_assertion_template: assertionTemplate,
3513
+ state_transition: normalizedStateTransition,
2373
3514
  acceptance_gate: cleanText(source.acceptance_gate || source.acceptanceGate, 120) === 'aiqa_business_assertion'
2374
3515
  ? 'aiqa_business_assertion'
2375
3516
  : 'aiqa_business_assertion',
2376
3517
  blocks_acceptance_without_business_assertion: source.blocks_acceptance_without_business_assertion !== false
2377
3518
  && source.blocksAcceptanceWithoutBusinessAssertion !== false,
2378
- false_pass_blockers: cleanList(source.false_pass_blockers || source.falsePassBlockers, 8, 260)
3519
+ false_pass_blockers: falsePassBlockers
2379
3520
  };
2380
3521
  }
2381
3522
  function validateResolveIOSupportIssueClassProbePlan(value, diagnosisGate, now) {
@@ -2402,6 +3543,25 @@ function validateResolveIOSupportIssueClassProbePlan(value, diagnosisGate, now)
2402
3543
  var planRequiredArtifacts = cleanList(source.requiredArtifacts || source.required_artifacts, 16, 220);
2403
3544
  var activeRequiredArtifacts = cleanList(activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.required_artifacts, 16, 220);
2404
3545
  var requiredArtifacts = planRequiredArtifacts.length ? planRequiredArtifacts : activeRequiredArtifacts;
3546
+ var planQaRows = Array.isArray(source.qaRows)
3547
+ ? source.qaRows
3548
+ : Array.isArray(source.qa_rows)
3549
+ ? source.qa_rows
3550
+ : [];
3551
+ var qaRows = (planQaRows.length ? planQaRows : probes.flatMap(function (probe) { return probe.qa_rows || []; }))
3552
+ .map(function (row) { return normalizeResolveIOSupportIssueClassProbeQaRow(row, {
3553
+ issueClass: (issueClass || (normalizedDiagnosis === null || normalizedDiagnosis === void 0 ? void 0 : normalizedDiagnosis.issue_class) || 'missing_wrong_data'),
3554
+ route: activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.route,
3555
+ action: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.action) || '',
3556
+ expectedBusinessProof: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.expected_business_proof) || '',
3557
+ expectedEvidence: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.expected_evidence) || '',
3558
+ requiredArtifacts: requiredArtifacts,
3559
+ falsePassBlockers: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.false_pass_blockers) || (catalog === null || catalog === void 0 ? void 0 : catalog.false_pass_blockers) || [],
3560
+ stateTransition: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.state_transition) || { before: '', action: '', after: '', assertion: '' },
3561
+ browserSteps: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.browser_steps) || []
3562
+ }); })
3563
+ .filter(function (row) { return !!row; });
3564
+ var activeQaRow = qaRows[0] || (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.active_qa_row);
2405
3565
  var falsePassBlockers = cleanList(source.falsePassBlockers || source.false_pass_blockers, 12, 260).length
2406
3566
  ? cleanList(source.falsePassBlockers || source.false_pass_blockers, 12, 260)
2407
3567
  : cleanList(activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.false_pass_blockers, 12, 260).length
@@ -2454,6 +3614,29 @@ function validateResolveIOSupportIssueClassProbePlan(value, diagnosisGate, now)
2454
3614
  if (activeRequiredArtifacts.length < 2) {
2455
3615
  blockers.push('Active issue-class probe must require at least two proof artifacts.');
2456
3616
  }
3617
+ if (cleanList(activeProbe.browser_steps, 12, 500).length < 3) {
3618
+ blockers.push('Issue-class probe must include executable browser_steps for the business workflow.');
3619
+ }
3620
+ if (cleanList(activeProbe.data_proof_requirements, 16, 260).length < 2) {
3621
+ blockers.push('Issue-class probe must include DOM/data proof requirements.');
3622
+ }
3623
+ }
3624
+ if (!qaRows.length || !activeQaRow) {
3625
+ blockers.push('Issue-class probe plan must include at least one executable QA row.');
3626
+ }
3627
+ if (activeQaRow) {
3628
+ if (activeQaRow.acceptance_gate !== 'aiqa_business_assertion' || activeQaRow.requires_aiqa_business_assertion !== true) {
3629
+ blockers.push('Issue-class QA row must require AIQaBusinessAssertion.');
3630
+ }
3631
+ if (activeQaRow.route_only_is_false_pass !== true) {
3632
+ blockers.push('Issue-class QA row must mark route-only evidence as a false pass.');
3633
+ }
3634
+ if (cleanList(activeQaRow.browser_steps, 12, 500).length < 3) {
3635
+ blockers.push('Issue-class QA row must include executable browser steps.');
3636
+ }
3637
+ if (!cleanText(activeQaRow.expected_dom_or_data_proof, 1600)) {
3638
+ blockers.push('Issue-class QA row must include expected DOM/data proof.');
3639
+ }
2457
3640
  }
2458
3641
  if (requiredArtifacts.length < 2) {
2459
3642
  blockers.push('Issue-class probe plan must require at least two proof artifacts.');
@@ -2477,6 +3660,8 @@ function validateResolveIOSupportIssueClassProbePlan(value, diagnosisGate, now)
2477
3660
  diagnosisValid: diagnosisValidation.valid === true,
2478
3661
  probes: probes,
2479
3662
  activeProbe: activeProbe,
3663
+ qaRows: qaRows,
3664
+ activeQaRow: activeQaRow,
2480
3665
  requiredArtifacts: requiredArtifacts,
2481
3666
  acceptanceGate: 'aiqa_business_assertion',
2482
3667
  falsePassBlockers: falsePassBlockers,
@@ -2498,6 +3683,7 @@ function buildResolveIOSupportIssueClassProbePlan(diagnosisGate, now) {
2498
3683
  ? buildResolveIOSupportIssueClassProbes(diagnosisValidation.normalized)
2499
3684
  : [];
2500
3685
  var activeProbe = probes[0];
3686
+ var qaRows = probes.flatMap(function (probe) { return probe.qa_rows || []; });
2501
3687
  var issueClass = ((_a = diagnosisValidation.normalized) === null || _a === void 0 ? void 0 : _a.issue_class) || (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.issue_class);
2502
3688
  var catalog = SUPPORT_ISSUE_CLASS_PROBE_CATALOG.find(function (entry) { return entry.issue_class === issueClass; });
2503
3689
  var provisional = {
@@ -2512,6 +3698,8 @@ function buildResolveIOSupportIssueClassProbePlan(diagnosisGate, now) {
2512
3698
  diagnosisValid: diagnosisValidation.valid === true,
2513
3699
  probes: probes,
2514
3700
  activeProbe: activeProbe,
3701
+ qaRows: qaRows,
3702
+ activeQaRow: qaRows[0],
2515
3703
  requiredArtifacts: cleanList(activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.required_artifacts, 16, 220),
2516
3704
  acceptanceGate: 'aiqa_business_assertion',
2517
3705
  falsePassBlockers: ((_b = activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.false_pass_blockers) === null || _b === void 0 ? void 0 : _b.length)
@@ -2548,6 +3736,12 @@ function supportManagerRetryScopeForAction(action) {
2548
3736
  if (action === 'run_business_proof_qa') {
2549
3737
  return 'business_proof_only';
2550
3738
  }
3739
+ if (action === 'create_pr') {
3740
+ return 'pr_packaging_only';
3741
+ }
3742
+ if (action === 'run_a_grade_pr_review') {
3743
+ return 'pr_review_only';
3744
+ }
2551
3745
  if (action === 'repair_release_hotfix_first') {
2552
3746
  return 'release_hotfix_only';
2553
3747
  }
@@ -2559,8 +3753,65 @@ function supportManagerRetryScopeForAction(action) {
2559
3753
  }
2560
3754
  return 'none';
2561
3755
  }
3756
+ function supportManagerDispatchActionForNextAction(action, fields, preflightGate) {
3757
+ if (action === 'collect_new_evidence' || action === 'run_business_proof_qa') {
3758
+ return 'run_evidence_probe';
3759
+ }
3760
+ if (action === 'run_diagnosis_gate' || action === 'revise_diagnosis_scope') {
3761
+ return 'run_read_only_diagnosis';
3762
+ }
3763
+ if (action === 'repair_infra_only') {
3764
+ return (preflightGate === null || preflightGate === void 0 ? void 0 : preflightGate.failureClass) === 'compile' ? 'run_compile_repair' : 'run_infra_repair';
3765
+ }
3766
+ if (action === 'run_owner_scoped_repair') {
3767
+ return 'run_targeted_product_repair';
3768
+ }
3769
+ if (action === 'repair_release_hotfix_first') {
3770
+ return 'run_release_repair';
3771
+ }
3772
+ if (action === 'create_pr') {
3773
+ return 'continue_gate';
3774
+ }
3775
+ if (action === 'run_a_grade_pr_review') {
3776
+ return 'continue_gate';
3777
+ }
3778
+ if (action === 'ready_for_release_gate' || action === 'draft_customer_reply') {
3779
+ return 'continue_gate';
3780
+ }
3781
+ if ((fields === null || fields === void 0 ? void 0 : fields.canRunQa) === true) {
3782
+ return 'run_evidence_probe';
3783
+ }
3784
+ if ((fields === null || fields === void 0 ? void 0 : fields.canRunModel) === true) {
3785
+ return 'run_read_only_diagnosis';
3786
+ }
3787
+ return 'park_manual';
3788
+ }
3789
+ function supportProjectedActionCostUsdForNextAction(action, fields) {
3790
+ if (action === 'run_owner_scoped_repair') {
3791
+ return 2.5;
3792
+ }
3793
+ if (action === 'run_diagnosis_gate' || action === 'revise_diagnosis_scope') {
3794
+ return 1.2;
3795
+ }
3796
+ if (action === 'repair_release_hotfix_first' || (fields === null || fields === void 0 ? void 0 : fields.canHotfixBackend) === true) {
3797
+ return 0.35;
3798
+ }
3799
+ if (action === 'create_pr') {
3800
+ return 0.1;
3801
+ }
3802
+ if (action === 'run_a_grade_pr_review') {
3803
+ return 0.1;
3804
+ }
3805
+ if (action === 'repair_infra_only' || action === 'run_business_proof_qa' || action === 'collect_new_evidence') {
3806
+ return 0.25;
3807
+ }
3808
+ if (action === 'draft_customer_reply') {
3809
+ return 0.1;
3810
+ }
3811
+ return (fields === null || fields === void 0 ? void 0 : fields.canRunModel) === true ? 1 : (fields === null || fields === void 0 ? void 0 : fields.canRunQa) === true ? 0.25 : 0;
3812
+ }
2562
3813
  function supportManagerMaxAttemptsForContract(contract) {
2563
- if (contract.action === 'run_owner_scoped_repair' || contract.action === 'repair_release_hotfix_first') {
3814
+ if (contract.action === 'run_owner_scoped_repair' || contract.action === 'repair_release_hotfix_first' || contract.action === 'create_pr' || contract.action === 'run_a_grade_pr_review') {
2564
3815
  return 1;
2565
3816
  }
2566
3817
  if (contract.action === 'repair_infra_only') {
@@ -2571,9 +3822,29 @@ function supportManagerMaxAttemptsForContract(contract) {
2571
3822
  }
2572
3823
  return contract.costRisk === 'expensive_model' ? 1 : 2;
2573
3824
  }
3825
+ function supportManagerRequiredResetEvidenceForContract(contract) {
3826
+ var _a, _b;
3827
+ var resetFromStopConditions = cleanList(contract === null || contract === void 0 ? void 0 : contract.stopConditions, 32, 600)
3828
+ .map(function (entry) {
3829
+ var match = entry.match(/Reset requires:\s*(.+)$/i);
3830
+ return cleanText((match === null || match === void 0 ? void 0 : match[1]) || '', 500);
3831
+ })
3832
+ .filter(Boolean);
3833
+ var defaults = [
3834
+ ((_a = contract === null || contract === void 0 ? void 0 : contract.decisionBasis) === null || _a === void 0 ? void 0 : _a.blockerFingerprint) ? 'changed blocker fingerprint' : '',
3835
+ ((_b = contract === null || contract === void 0 ? void 0 : contract.decisionBasis) === null || _b === void 0 ? void 0 : _b.evidenceHash) ? 'changed evidence hash' : '',
3836
+ (contract === null || contract === void 0 ? void 0 : contract.action) === 'run_business_proof_qa' ? 'fresh AIQaBusinessAssertion with before/action/after proof artifact' : '',
3837
+ (contract === null || contract === void 0 ? void 0 : contract.action) === 'run_owner_scoped_repair' ? 'owner-scoped diff plus compile proof and fresh business proof handoff' : '',
3838
+ (contract === null || contract === void 0 ? void 0 : contract.action) === 'run_a_grade_pr_review' ? 'fresh strict PR review evidence or changed PR review blocker fingerprint' : '',
3839
+ (contract === null || contract === void 0 ? void 0 : contract.action) === 'repair_infra_only' ? 'fresh infra/preflight evidence hash' : ''
3840
+ ].filter(Boolean);
3841
+ return Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(resetFromStopConditions), false), __read(defaults), false), [
3842
+ 'fresh artifact path, verifier signal, or validated state transition for the selected action'
3843
+ ], false))).slice(0, 16);
3844
+ }
2574
3845
  function validateResolveIOSupportNextActionContract(value) {
2575
- var e_9, _a;
2576
- var _b, _c, _d;
3846
+ var e_10, _a;
3847
+ var _b, _c, _d, _e, _f;
2577
3848
  var contract = cleanObject(value);
2578
3849
  var blockers = [];
2579
3850
  var warnings = [];
@@ -2588,18 +3859,18 @@ function validateResolveIOSupportNextActionContract(value) {
2588
3859
  ];
2589
3860
  try {
2590
3861
  for (var requiredStringFields_1 = __values(requiredStringFields), requiredStringFields_1_1 = requiredStringFields_1.next(); !requiredStringFields_1_1.done; requiredStringFields_1_1 = requiredStringFields_1.next()) {
2591
- var _e = __read(requiredStringFields_1_1.value, 2), field = _e[0], fieldValue = _e[1];
3862
+ var _g = __read(requiredStringFields_1_1.value, 2), field = _g[0], fieldValue = _g[1];
2592
3863
  if (!cleanText(fieldValue, 500)) {
2593
3864
  blockers.push("NextActionContract.".concat(field, " is required."));
2594
3865
  }
2595
3866
  }
2596
3867
  }
2597
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
3868
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
2598
3869
  finally {
2599
3870
  try {
2600
3871
  if (requiredStringFields_1_1 && !requiredStringFields_1_1.done && (_a = requiredStringFields_1.return)) _a.call(requiredStringFields_1);
2601
3872
  }
2602
- finally { if (e_9) throw e_9.error; }
3873
+ finally { if (e_10) throw e_10.error; }
2603
3874
  }
2604
3875
  if (!Array.isArray(contract.nextCommands) || !contract.nextCommands.length) {
2605
3876
  blockers.push('NextActionContract.nextCommands must include at least the primary command.');
@@ -2649,12 +3920,34 @@ function validateResolveIOSupportNextActionContract(value) {
2649
3920
  blockers.push('Business proof QA must require AIQaBusinessAssertion or before/action/after proof.');
2650
3921
  }
2651
3922
  }
3923
+ if (action === 'create_pr') {
3924
+ if (((_c = contract.decisionBasis) === null || _c === void 0 ? void 0 : _c.businessProofReady) !== true) {
3925
+ blockers.push('PR packaging requires businessProofReady=true.');
3926
+ }
3927
+ if (!contract.successEvidence.some(function (entry) { return /pull_request_url|PR|pull request/i.test(entry); })) {
3928
+ blockers.push('PR packaging must require pull_request_url evidence.');
3929
+ }
3930
+ if (!contract.forbiddenActions.some(function (entry) { return /merge|release|deploy|customer/i.test(entry); })) {
3931
+ blockers.push('PR packaging must forbid merge, release, deploy, and customer-send side effects.');
3932
+ }
3933
+ }
3934
+ if (action === 'run_a_grade_pr_review') {
3935
+ if (((_d = contract.decisionBasis) === null || _d === void 0 ? void 0 : _d.businessProofReady) !== true) {
3936
+ blockers.push('A-grade PR review requires businessProofReady=true.');
3937
+ }
3938
+ if (!contract.successEvidence.some(function (entry) { return /A-grade|execution\/artifacts\/pull_request|strict gate|grade/i.test(entry); })) {
3939
+ blockers.push('A-grade PR review must require strict grade evidence.');
3940
+ }
3941
+ if (!contract.forbiddenActions.some(function (entry) { return /merge|release|deploy|customer/i.test(entry); })) {
3942
+ blockers.push('A-grade PR review must forbid merge, release, deploy, and customer-send side effects.');
3943
+ }
3944
+ }
2652
3945
  if (action === 'repair_release_hotfix_first') {
2653
- if (((_c = contract.decisionBasis) === null || _c === void 0 ? void 0 : _c.hotfixCommitRequired) === true
3946
+ if (((_e = contract.decisionBasis) === null || _e === void 0 ? void 0 : _e.hotfixCommitRequired) === true
2654
3947
  && !__spreadArray(__spreadArray(__spreadArray([], __read(contract.successEvidence), false), __read(contract.stopConditions), false), __read(contract.forbiddenActions), false).some(function (entry) { return /sourceCommitSha|githubCommitUrl|gitCommitStatus|gitPushStatus|GitHub commit/i.test(entry); })) {
2655
3948
  blockers.push('Hotfix release action requires GitHub commit and push proof before continuation.');
2656
3949
  }
2657
- if (((_d = contract.decisionBasis) === null || _d === void 0 ? void 0 : _d.liveHotfixBlockedUntilCommit) === true && contract.safeToAutoRun === true && primaryCommand !== 'record_hotfix_evidence') {
3950
+ if (((_f = contract.decisionBasis) === null || _f === void 0 ? void 0 : _f.liveHotfixBlockedUntilCommit) === true && contract.safeToAutoRun === true && primaryCommand !== 'record_hotfix_evidence') {
2658
3951
  warnings.push('Live hotfix is blocked until commit proof; manager should record evidence before any live apply.');
2659
3952
  }
2660
3953
  }
@@ -2677,6 +3970,7 @@ function validateResolveIOSupportNextActionContract(value) {
2677
3970
  };
2678
3971
  }
2679
3972
  function buildResolveIOSupportManagerExecutionPacket(contract, now) {
3973
+ var _a, _b, _c, _d, _e;
2680
3974
  var validation = validateResolveIOSupportNextActionContract(contract);
2681
3975
  var createdAt = isoNow(now || (contract === null || contract === void 0 ? void 0 : contract.createdAt));
2682
3976
  var executeNow = validation.valid === true
@@ -2691,6 +3985,33 @@ function buildResolveIOSupportManagerExecutionPacket(contract, now) {
2691
3985
  var proofRequiredBeforeContinuation = Array.from(new Set(__spreadArray(__spreadArray([], __read(cleanList(contract === null || contract === void 0 ? void 0 : contract.successEvidence, 24, 500)), false), [
2692
3986
  cleanText(contract === null || contract === void 0 ? void 0 : contract.expectedStateTransition, 500)
2693
3987
  ], false).filter(Boolean))).slice(0, 24);
3988
+ var retryScope = supportManagerRetryScopeForAction(contract === null || contract === void 0 ? void 0 : contract.action);
3989
+ var maxAttemptsBeforeFreshEvidence = supportManagerMaxAttemptsForContract(contract);
3990
+ var stopConditions = cleanList(contract === null || contract === void 0 ? void 0 : contract.stopConditions, 24, 500);
3991
+ var requiredResetEvidence = supportManagerRequiredResetEvidenceForContract(contract);
3992
+ var proofResetContract = {
3993
+ contractId: "support-proof-reset-".concat(hashResolveIOSupportV5Evidence({
3994
+ contractId: contract === null || contract === void 0 ? void 0 : contract.contractId,
3995
+ action: contract === null || contract === void 0 ? void 0 : contract.action,
3996
+ retryScope: retryScope,
3997
+ blockerFingerprint: (_a = contract === null || contract === void 0 ? void 0 : contract.decisionBasis) === null || _a === void 0 ? void 0 : _a.blockerFingerprint,
3998
+ evidenceHash: (_b = contract === null || contract === void 0 ? void 0 : contract.decisionBasis) === null || _b === void 0 ? void 0 : _b.evidenceHash,
3999
+ createdAt: createdAt.slice(0, 16)
4000
+ }).slice(0, 16)),
4001
+ status: executeNow ? 'ready' : (status === 'manual_required' ? 'manual_required' : 'blocked'),
4002
+ action: contract === null || contract === void 0 ? void 0 : contract.action,
4003
+ retryScope: retryScope,
4004
+ maxAttemptsBeforeFreshEvidence: maxAttemptsBeforeFreshEvidence,
4005
+ startingFailureClass: cleanText((_c = contract === null || contract === void 0 ? void 0 : contract.decisionBasis) === null || _c === void 0 ? void 0 : _c.failureClass, 120),
4006
+ startingBlockerFingerprint: cleanText((_d = contract === null || contract === void 0 ? void 0 : contract.decisionBasis) === null || _d === void 0 ? void 0 : _d.blockerFingerprint, 180),
4007
+ startingEvidenceHash: cleanText((_e = contract === null || contract === void 0 ? void 0 : contract.decisionBasis) === null || _e === void 0 ? void 0 : _e.evidenceHash, 180),
4008
+ requiredResetEvidence: requiredResetEvidence,
4009
+ proofRequiredBeforeContinuation: proofRequiredBeforeContinuation,
4010
+ stopConditions: stopConditions,
4011
+ canRunWithoutCodexMonitor: (contract === null || contract === void 0 ? void 0 : contract.canRunWithoutCodexMonitor) === true && executeNow,
4012
+ sourceNextActionContractId: cleanText(contract === null || contract === void 0 ? void 0 : contract.contractId, 180),
4013
+ createdAt: createdAt
4014
+ };
2694
4015
  return {
2695
4016
  packetId: "support-manager-exec-".concat(hashResolveIOSupportV5Evidence({
2696
4017
  contractId: contract === null || contract === void 0 ? void 0 : contract.contractId,
@@ -2708,15 +4029,16 @@ function buildResolveIOSupportManagerExecutionPacket(contract, now) {
2708
4029
  executeNow: executeNow,
2709
4030
  canRunWithoutCodexMonitor: (contract === null || contract === void 0 ? void 0 : contract.canRunWithoutCodexMonitor) === true,
2710
4031
  codexFallbackRequired: (contract === null || contract === void 0 ? void 0 : contract.codexFallbackRequired) === true,
2711
- retryScope: supportManagerRetryScopeForAction(contract === null || contract === void 0 ? void 0 : contract.action),
2712
- maxAttemptsBeforeFreshEvidence: supportManagerMaxAttemptsForContract(contract),
4032
+ retryScope: retryScope,
4033
+ maxAttemptsBeforeFreshEvidence: maxAttemptsBeforeFreshEvidence,
2713
4034
  costRisk: (contract === null || contract === void 0 ? void 0 : contract.costRisk) || 'manual_blocked',
2714
4035
  proofRequiredBeforeContinuation: proofRequiredBeforeContinuation,
2715
4036
  expectedStateTransition: cleanText(contract === null || contract === void 0 ? void 0 : contract.expectedStateTransition, 1000),
2716
- stopConditions: cleanList(contract === null || contract === void 0 ? void 0 : contract.stopConditions, 24, 500),
4037
+ stopConditions: stopConditions,
2717
4038
  forbiddenActions: cleanList(contract === null || contract === void 0 ? void 0 : contract.forbiddenActions, 24, 500),
2718
4039
  ownerFiles: cleanList(contract === null || contract === void 0 ? void 0 : contract.ownerFiles, 24, 500),
2719
4040
  nextCommands: cleanList(contract === null || contract === void 0 ? void 0 : contract.nextCommands, 24, 240),
4041
+ proofResetContract: proofResetContract,
2720
4042
  blockers: Array.from(new Set(__spreadArray(__spreadArray([], __read(cleanList(contract === null || contract === void 0 ? void 0 : contract.blockers, 24, 500)), false), __read(validation.blockers), false))).slice(0, 24),
2721
4043
  validation: validation,
2722
4044
  createdAt: createdAt
@@ -2973,6 +4295,180 @@ function evaluateResolveIOSupportEvidenceFreshness(input) {
2973
4295
  artifactPaths: artifactPaths
2974
4296
  };
2975
4297
  }
4298
+ function validateResolveIOSupportEvidenceProbeContract(value) {
4299
+ var source = cleanObject(value);
4300
+ if (!Object.keys(source).length) {
4301
+ return {
4302
+ valid: false,
4303
+ status: 'blocked',
4304
+ blockers: ['Support evidence probe contract is missing.']
4305
+ };
4306
+ }
4307
+ var status = cleanText(source.status, 80) === 'ready' ? 'ready' : 'blocked';
4308
+ var normalized = {
4309
+ contractId: cleanText(source.contractId || source.contract_id, 180),
4310
+ status: status,
4311
+ probeType: cleanText(source.probeType || source.probe_type, 80) || 'manual',
4312
+ evidenceOnly: true,
4313
+ productRepairAllowed: false,
4314
+ canRunWithoutCodexMonitor: source.canRunWithoutCodexMonitor === true || source.can_run_without_codex_monitor === true,
4315
+ issueClass: normalizeIssueClass(source.issueClass || source.issue_class) || undefined,
4316
+ planId: cleanText(source.planId || source.plan_id, 180) || undefined,
4317
+ activeRoute: cleanText(source.activeRoute || source.active_route, 500) || undefined,
4318
+ actionUnderTest: cleanText(source.actionUnderTest || source.action_under_test, 1000) || undefined,
4319
+ expectedBusinessProof: cleanText(source.expectedBusinessProof || source.expected_business_proof, 1400) || undefined,
4320
+ stateTransition: cleanObject(source.stateTransition || source.state_transition),
4321
+ startingFailureClass: cleanText(source.startingFailureClass || source.starting_failure_class, 120),
4322
+ startingBlockerFingerprint: cleanText(source.startingBlockerFingerprint || source.starting_blocker_fingerprint, 180),
4323
+ startingEvidenceHash: cleanText(source.startingEvidenceHash || source.starting_evidence_hash, 180),
4324
+ sameFailureCount: Math.max(0, Number(source.sameFailureCount || source.same_failure_count || 0) || 0),
4325
+ pingPongCount: Math.max(0, Number(source.pingPongCount || source.ping_pong_count || 0) || 0),
4326
+ requiredNewSignals: cleanList(source.requiredNewSignals || source.required_new_signals, 20, 500),
4327
+ requiredArtifacts: cleanList(source.requiredArtifacts || source.required_artifacts, 20, 500),
4328
+ acceptableEvidence: cleanList(source.acceptableEvidence || source.acceptable_evidence, 20, 500),
4329
+ blockers: cleanList(source.blockers, 20, 500),
4330
+ forbiddenActions: cleanList(source.forbiddenActions || source.forbidden_actions, 20, 500),
4331
+ nextCommands: cleanList(source.nextCommands || source.next_commands, 16, 260),
4332
+ createdAt: cleanText(source.createdAt || source.created_at, 80) || isoNow()
4333
+ };
4334
+ var blockers = __spreadArray([], __read(normalized.blockers), false);
4335
+ if (!normalized.contractId) {
4336
+ blockers.push('Evidence probe contract requires contractId.');
4337
+ }
4338
+ if (!['issue_class_probe', 'business_proof', 'preflight', 'release', 'manual'].includes(normalized.probeType)) {
4339
+ blockers.push('Evidence probe contract probeType is invalid.');
4340
+ }
4341
+ if (source.evidenceOnly === false || source.evidence_only === false) {
4342
+ blockers.push('Evidence probe contract must be evidenceOnly=true.');
4343
+ }
4344
+ if (source.productRepairAllowed === true || source.product_repair_allowed === true) {
4345
+ blockers.push('Evidence probe contract must block productRepairAllowed.');
4346
+ }
4347
+ if (!normalized.requiredNewSignals.length) {
4348
+ blockers.push('Evidence probe contract requires at least one new signal that can unblock the loop.');
4349
+ }
4350
+ if (!normalized.requiredArtifacts.length) {
4351
+ blockers.push('Evidence probe contract requires concrete artifact requirements.');
4352
+ }
4353
+ if (!normalized.acceptableEvidence.length) {
4354
+ blockers.push('Evidence probe contract requires acceptableEvidence.');
4355
+ }
4356
+ if (!normalized.nextCommands.length) {
4357
+ blockers.push('Evidence probe contract requires nextCommands.');
4358
+ }
4359
+ if (!normalized.forbiddenActions.some(function (entry) { return /product-code|repair loop|source edit|owner_files/i.test(entry); })) {
4360
+ blockers.push('Evidence probe contract must explicitly forbid product-code repair/source edits.');
4361
+ }
4362
+ if (normalized.probeType === 'issue_class_probe') {
4363
+ if (!normalized.issueClass) {
4364
+ blockers.push('Issue-class evidence probe requires issueClass.');
4365
+ }
4366
+ if (!normalized.activeRoute) {
4367
+ blockers.push('Issue-class evidence probe requires activeRoute.');
4368
+ }
4369
+ if (!normalized.actionUnderTest) {
4370
+ blockers.push('Issue-class evidence probe requires actionUnderTest.');
4371
+ }
4372
+ if (!normalized.expectedBusinessProof) {
4373
+ blockers.push('Issue-class evidence probe requires expectedBusinessProof.');
4374
+ }
4375
+ if (!normalized.acceptableEvidence.some(function (entry) { return /AIQaBusinessAssertion|before\/action\/after|DOM|Mongo|data/i.test(entry); })) {
4376
+ blockers.push('Issue-class evidence probe must require AIQaBusinessAssertion or before/action/after DOM/data/Mongo proof.');
4377
+ }
4378
+ }
4379
+ normalized.blockers = Array.from(new Set(blockers)).slice(0, 20);
4380
+ normalized.status = normalized.blockers.length ? 'blocked' : 'ready';
4381
+ normalized.canRunWithoutCodexMonitor = normalized.status === 'ready' && normalized.evidenceOnly === true && normalized.productRepairAllowed === false;
4382
+ return {
4383
+ valid: normalized.status === 'ready',
4384
+ status: normalized.status,
4385
+ blockers: normalized.blockers,
4386
+ normalized: normalized
4387
+ };
4388
+ }
4389
+ function buildResolveIOSupportEvidenceProbeContract(input) {
4390
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4391
+ var now = isoNow(input.now);
4392
+ var diagnosisValidation = validateResolveIOSupportDiagnosisGate(input.diagnosisGate);
4393
+ var issueClassProbePlanValidation = validateResolveIOSupportIssueClassProbePlan(input.issueClassProbePlan, diagnosisValidation.normalized, input.now);
4394
+ var activeProbe = issueClassProbePlanValidation.activeProbe
4395
+ || ((_a = issueClassProbePlanValidation.normalized) === null || _a === void 0 ? void 0 : _a.activeProbe);
4396
+ var freshness = input.evidenceFreshness || evaluateResolveIOSupportEvidenceFreshness({
4397
+ failureClass: input.failureClass,
4398
+ blocker: input.blocker,
4399
+ evidenceHash: input.evidenceHash
4400
+ });
4401
+ var probeType = activeProbe
4402
+ ? 'issue_class_probe'
4403
+ : /^(infra|compile)$/i.test(freshness.failureClass)
4404
+ ? 'preflight'
4405
+ : /release/i.test(freshness.failureClass)
4406
+ ? 'release'
4407
+ : diagnosisValidation.valid
4408
+ ? 'business_proof'
4409
+ : 'manual';
4410
+ var requiredNewSignals = Array.from(new Set(__spreadArray(__spreadArray([], __read(cleanList(freshness.requiredResetEvidence, 20, 500)), false), [
4411
+ 'changed blockerFingerprint from the starting failure',
4412
+ 'changed evidenceHash from the starting failure',
4413
+ 'fresh artifact path not already attached to the repeated failure',
4414
+ activeProbe ? 'AIQaBusinessAssertion mapped to the active IssueClassProbePlan' : 'fresh before/action/after proof artifact'
4415
+ ], false))).slice(0, 20);
4416
+ var requiredArtifacts = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(cleanList(input.requiredEvidence, 20, 500)), false), __read(cleanList(activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.required_artifacts, 20, 500)), false), __read(cleanList((_b = issueClassProbePlanValidation.normalized) === null || _b === void 0 ? void 0 : _b.requiredArtifacts, 20, 500)), false), __read((probeType === 'preflight' ? ['preflight log with changed infra/compile status'] : [])), false), __read((probeType === 'release' ? ['release/hotfix gate result with changed status'] : [])), false), __read((activeProbe ? ['AIQaBusinessAssertion JSON artifact'] : [])), false))).slice(0, 20);
4417
+ var acceptableEvidence = Array.from(new Set([
4418
+ activeProbe ? 'AIQaBusinessAssertion tied to the active issue-class probe' : 'before/action/after business proof artifact',
4419
+ activeProbe ? "state transition proof: ".concat(activeProbe.state_transition.before || 'before', " -> ").concat(activeProbe.state_transition.action || activeProbe.action, " -> ").concat(activeProbe.state_transition.after || 'after') : '',
4420
+ 'changed blockerFingerprint or evidenceHash',
4421
+ 'new DOM/data/Mongo/network artifact proving the blocker changed',
4422
+ 'new compile/infra/release proof only if the failure class changed'
4423
+ ].filter(Boolean))).slice(0, 20);
4424
+ var blockers = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read((diagnosisValidation.valid ? [] : ['Valid SupportDiagnosisGate is required before bounded support evidence collection.'])), false), __read((probeType === 'issue_class_probe' && !issueClassProbePlanValidation.valid ? issueClassProbePlanValidation.blockers : [])), false), __read((freshness.mustCollectNewEvidence ? [] : ['Evidence probe contract is intended for repeated/stale failures that must collect new evidence.'])), false))).slice(0, 20);
4425
+ var nextCommands = Array.from(new Set([
4426
+ activeProbe ? 'execute_active_issue_class_probe_evidence_only' : 'collect_before_action_after_evidence_only',
4427
+ 'record_changed_blocker_or_evidence_hash',
4428
+ 'write_aiqa_business_assertion_or_blocker_artifact',
4429
+ 'return_to_diagnosis_or_owner_scoped_repair_only_after_probe_passes'
4430
+ ])).slice(0, 12);
4431
+ var contract = {
4432
+ contractId: "support-evidence-probe-".concat(hashResolveIOSupportV5Evidence({
4433
+ issueClass: (_c = diagnosisValidation.normalized) === null || _c === void 0 ? void 0 : _c.issue_class,
4434
+ planId: (_d = issueClassProbePlanValidation.normalized) === null || _d === void 0 ? void 0 : _d.planId,
4435
+ failureClass: freshness.failureClass,
4436
+ blockerFingerprint: freshness.blockerFingerprint,
4437
+ evidenceHash: freshness.evidenceHash,
4438
+ requiredNewSignals: requiredNewSignals,
4439
+ createdAt: now.slice(0, 16)
4440
+ }).slice(0, 16)),
4441
+ status: blockers.length ? 'blocked' : 'ready',
4442
+ probeType: probeType,
4443
+ evidenceOnly: true,
4444
+ productRepairAllowed: false,
4445
+ canRunWithoutCodexMonitor: blockers.length === 0,
4446
+ issueClass: ((_e = diagnosisValidation.normalized) === null || _e === void 0 ? void 0 : _e.issue_class) || (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.issue_class),
4447
+ planId: (_f = issueClassProbePlanValidation.normalized) === null || _f === void 0 ? void 0 : _f.planId,
4448
+ activeRoute: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.route) || ((_g = diagnosisValidation.normalized) === null || _g === void 0 ? void 0 : _g.proof_plan.route),
4449
+ actionUnderTest: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.action) || ((_h = diagnosisValidation.normalized) === null || _h === void 0 ? void 0 : _h.proof_plan.action),
4450
+ expectedBusinessProof: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.expected_business_proof) || ((_j = diagnosisValidation.normalized) === null || _j === void 0 ? void 0 : _j.proof_plan.business_assertion),
4451
+ stateTransition: activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.state_transition,
4452
+ startingFailureClass: freshness.failureClass,
4453
+ startingBlockerFingerprint: freshness.blockerFingerprint,
4454
+ startingEvidenceHash: freshness.evidenceHash,
4455
+ sameFailureCount: freshness.sameFailureCount,
4456
+ pingPongCount: freshness.pingPongCount,
4457
+ requiredNewSignals: requiredNewSignals,
4458
+ requiredArtifacts: requiredArtifacts,
4459
+ acceptableEvidence: acceptableEvidence,
4460
+ blockers: blockers,
4461
+ forbiddenActions: [
4462
+ 'Do not edit product-code or source files during this evidence probe.',
4463
+ 'Do not run another repair loop from the same blockerFingerprint and evidenceHash.',
4464
+ 'Do not treat route-load, screenshot-only, scorecard-only, or model-claim proof as acceptance.'
4465
+ ],
4466
+ nextCommands: nextCommands,
4467
+ createdAt: now
4468
+ };
4469
+ var validation = validateResolveIOSupportEvidenceProbeContract(contract);
4470
+ return validation.normalized || contract;
4471
+ }
2976
4472
  function buildResolveIOSupportContinuationProofCheckpoint(input) {
2977
4473
  var evidenceFreshness = input.evidenceFreshness;
2978
4474
  var action = input.action;
@@ -3036,14 +4532,14 @@ function changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles(diagnosisGate, c
3036
4532
  if (!validation.valid || !validation.normalized) {
3037
4533
  return cleanList(changedFiles, 80, 500);
3038
4534
  }
3039
- var owners = new Set(validation.normalized.owner_files.map(normalizeOwnerFilePath));
4535
+ var owners = validation.normalized.owner_files.map(normalizeOwnerFilePath).filter(Boolean);
3040
4536
  return cleanList(changedFiles, 120, 500)
3041
4537
  .map(normalizeOwnerFilePath)
3042
4538
  .filter(function (filePath) {
3043
4539
  if (!filePath) {
3044
4540
  return false;
3045
4541
  }
3046
- if (owners.has(filePath)) {
4542
+ if (owners.some(function (ownerFile) { return ownerFilePathMatchesDiagnosisOwner(filePath, ownerFile); })) {
3047
4543
  return false;
3048
4544
  }
3049
4545
  if (options.allowTests && /(^|\/)(tests?|spec|__tests__)(\/|$)|\.(?:spec|test)\.[jt]sx?$/i.test(filePath)) {
@@ -3052,6 +4548,94 @@ function changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles(diagnosisGate, c
3052
4548
  return true;
3053
4549
  });
3054
4550
  }
4551
+ function supportRepairPurposeForOwnerFile(gate, coverage) {
4552
+ var _a;
4553
+ if (!gate) {
4554
+ return 'Repair is blocked until SupportDiagnosisGate validates.';
4555
+ }
4556
+ var pathParts = coverage.failingPathFields.length
4557
+ ? coverage.failingPathFields.join('/')
4558
+ : 'diagnosed failing path';
4559
+ var proof = ((_a = gate.proof_plan.business_proof_contract) === null || _a === void 0 ? void 0 : _a.expected_business_state_change)
4560
+ || gate.proof_plan.business_assertion
4561
+ || gate.proof_plan.after;
4562
+ return cleanText("Update ".concat(coverage.ownerFile, " only for ").concat(pathParts, "; preserve unrelated behavior and prove: ").concat(proof), 1000);
4563
+ }
4564
+ function buildResolveIOSupportOwnerScopedRepairContract(input) {
4565
+ if (input === void 0) { input = {}; }
4566
+ var diagnosisValidation = validateResolveIOSupportDiagnosisGate(input.diagnosisGate);
4567
+ var gate = diagnosisValidation.normalized;
4568
+ var proofMatrix = diagnosisValidation.proofMatrix || buildResolveIOSupportDiagnosisProofMatrix(input.diagnosisGate, input.now);
4569
+ var ownerFiles = (gate === null || gate === void 0 ? void 0 : gate.owner_files) || proofMatrix.ownerFiles || [];
4570
+ var changedFiles = cleanList(input.changedFiles, 120, 500)
4571
+ .map(normalizeOwnerFilePath)
4572
+ .filter(Boolean);
4573
+ var outsideOwnerFiles = changedFiles.length
4574
+ ? changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles(gate || input.diagnosisGate, changedFiles, {
4575
+ allowTests: input.allowTestsOutsideOwnerFiles === true
4576
+ })
4577
+ : [];
4578
+ var patchUnits = proofMatrix.ownerFileCoverage.map(function (coverage) { return ({
4579
+ ownerFile: coverage.ownerFile,
4580
+ coverageEvidenceIds: coverage.evidenceIds,
4581
+ failingPathFields: coverage.failingPathFields,
4582
+ repairPurpose: supportRepairPurposeForOwnerFile(gate, coverage),
4583
+ requiredLocalChecks: [
4584
+ 'compile or targeted typecheck passes',
4585
+ 'targeted unit/integration check when available',
4586
+ 'no edits outside owner_files except explicitly allowed tests'
4587
+ ]
4588
+ }); });
4589
+ var blockers = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(diagnosisValidation.blockers), false), __read(proofMatrix.blockers), false), __read((outsideOwnerFiles.length ? ["Repair contract changed files outside owner_files: ".concat(outsideOwnerFiles.join(', '))] : [])), false), __read((ownerFiles.length ? [] : ['Repair contract requires a non-empty owner_files set.'])), false), __read((patchUnits.length ? [] : ['Repair contract requires at least one owner-file patch unit.'])), false))).slice(0, 40);
4590
+ var status = blockers.length ? 'blocked' : 'ready';
4591
+ var requiredEvidenceBeforeRepair = [
4592
+ 'valid SupportDiagnosisGate',
4593
+ 'ready SupportDiagnosisProofMatrix',
4594
+ 'owner_files coverage for every patch unit',
4595
+ 'preflight/compile gate not blocking product repair'
4596
+ ];
4597
+ var requiredEvidenceAfterRepair = [
4598
+ 'changed files are within owner_files',
4599
+ 'compile or targeted unit gate passes',
4600
+ 'fresh AIQaBusinessAssertion mapped to diagnosis proof_plan',
4601
+ 'business proof artifacts include before/action/after DOM/data or Mongo proof'
4602
+ ];
4603
+ var createdAt = isoNow(input.now);
4604
+ return {
4605
+ contractId: "support-owner-scoped-repair-".concat(hashResolveIOSupportV5Evidence({
4606
+ issueClass: gate === null || gate === void 0 ? void 0 : gate.issue_class,
4607
+ ownerFiles: ownerFiles,
4608
+ proofMatrixId: proofMatrix.matrixId,
4609
+ changedFiles: changedFiles,
4610
+ outsideOwnerFiles: outsideOwnerFiles,
4611
+ createdAt: createdAt.slice(0, 16)
4612
+ }).slice(0, 16)),
4613
+ status: status,
4614
+ sourceEditsAllowed: status === 'ready',
4615
+ canRunWithoutCodexMonitor: status === 'ready',
4616
+ issueClass: gate === null || gate === void 0 ? void 0 : gate.issue_class,
4617
+ ownerFiles: ownerFiles,
4618
+ proofMatrixId: proofMatrix.matrixId,
4619
+ changedFiles: changedFiles,
4620
+ outsideOwnerFiles: outsideOwnerFiles,
4621
+ patchUnits: patchUnits,
4622
+ requiredEvidenceBeforeRepair: requiredEvidenceBeforeRepair,
4623
+ requiredEvidenceAfterRepair: requiredEvidenceAfterRepair,
4624
+ nextCommands: [
4625
+ 'load_owner_files_only',
4626
+ 'apply_smallest_fix_to_patch_units',
4627
+ 'run_smallest_compile_or_unit_gate',
4628
+ 'handoff_to_business_proof_qa'
4629
+ ],
4630
+ forbiddenActions: [
4631
+ 'Do not edit outside owner_files unless SupportDiagnosisGate is revised with new evidence.',
4632
+ 'Do not accept route-load, screenshot-only, scorecard-only, or model-claim proof.',
4633
+ 'Do not draft a customer resolution until business proof readiness passes.'
4634
+ ],
4635
+ blockers: blockers,
4636
+ createdAt: createdAt
4637
+ };
4638
+ }
3055
4639
  function decideResolveIOSupportV5RepairGate(input) {
3056
4640
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
3057
4641
  var activeStepType = cleanText(input.activeStepType, 80);
@@ -3062,6 +4646,11 @@ function decideResolveIOSupportV5RepairGate(input) {
3062
4646
  });
3063
4647
  var ownerFiles = ((_a = diagnosisValidation.normalized) === null || _a === void 0 ? void 0 : _a.owner_files) || [];
3064
4648
  var outsideOwnerFiles = changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles(diagnosisValidation.normalized || input.diagnosisGate, input.changedFiles, { allowTests: input.allowTestsOutsideOwnerFiles === true });
4649
+ var ownerScopedRepairContract = buildResolveIOSupportOwnerScopedRepairContract({
4650
+ diagnosisGate: diagnosisValidation.normalized || input.diagnosisGate,
4651
+ changedFiles: input.changedFiles,
4652
+ allowTestsOutsideOwnerFiles: input.allowTestsOutsideOwnerFiles === true
4653
+ });
3065
4654
  var repeatedFailure = ((_b = input.history) === null || _b === void 0 ? void 0 : _b.length) ? decideResolveIOSupportV5RepeatedFailureStop({
3066
4655
  history: input.history,
3067
4656
  failureClass: failureClass,
@@ -3137,31 +4726,31 @@ function decideResolveIOSupportV5RepairGate(input) {
3137
4726
  };
3138
4727
  if (repeatedFailure === null || repeatedFailure === void 0 ? void 0 : repeatedFailure.shouldStop) {
3139
4728
  var recoveryPlan_1 = recoveryPlanFor('park_repeated_failure', repeatedFailure.reason, repeatedFailure.failureClass, true);
3140
- return __assign({ action: 'park_repeated_failure', canEditProductCode: false, blockers: [repeatedFailure.reason], ownerFiles: ownerFiles, issueClass: (_c = diagnosisValidation.normalized) === null || _c === void 0 ? void 0 : _c.issue_class, proofPlan: (_d = diagnosisValidation.normalized) === null || _d === void 0 ? void 0 : _d.proof_plan, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_1));
4729
+ return __assign({ action: 'park_repeated_failure', canEditProductCode: false, blockers: [repeatedFailure.reason], ownerFiles: ownerFiles, issueClass: (_c = diagnosisValidation.normalized) === null || _c === void 0 ? void 0 : _c.issue_class, proofPlan: (_d = diagnosisValidation.normalized) === null || _d === void 0 ? void 0 : _d.proof_plan, ownerScopedRepairContract: ownerScopedRepairContract, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_1));
3141
4730
  }
3142
4731
  if (preflightGate.blocksProductRepair) {
3143
4732
  var recoveryFailureClass = preflightGate.failureClass === 'compile' ? 'compile' : 'infra';
3144
4733
  var recoveryPlan_2 = recoveryPlanFor('retry_infra', 'support_v5_preflight_gate_blocks_product_repair', recoveryFailureClass, false);
3145
4734
  return __assign({ action: 'infra_repair_only', canEditProductCode: false, blockers: preflightGate.blockers.length
3146
4735
  ? preflightGate.blockers
3147
- : ['Deterministic support preflight must pass before product-code repair.'], ownerFiles: ownerFiles, issueClass: (_e = diagnosisValidation.normalized) === null || _e === void 0 ? void 0 : _e.issue_class, proofPlan: (_f = diagnosisValidation.normalized) === null || _f === void 0 ? void 0 : _f.proof_plan, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_2));
4736
+ : ['Deterministic support preflight must pass before product-code repair.'], ownerFiles: ownerFiles, issueClass: (_e = diagnosisValidation.normalized) === null || _e === void 0 ? void 0 : _e.issue_class, proofPlan: (_f = diagnosisValidation.normalized) === null || _f === void 0 ? void 0 : _f.proof_plan, ownerScopedRepairContract: ownerScopedRepairContract, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_2));
3148
4737
  }
3149
4738
  if (failureClass === 'infra' || failureClass === 'compile') {
3150
4739
  var recoveryPlan_3 = recoveryPlanFor('retry_infra', 'support_v5_infra_or_compile_repair_required', failureClass, false);
3151
- return __assign({ action: 'infra_repair_only', canEditProductCode: false, blockers: ['Infra/compile/Puppeteer/startup failures must be repaired in the harness lane before product-code repair.'], ownerFiles: ownerFiles, issueClass: (_g = diagnosisValidation.normalized) === null || _g === void 0 ? void 0 : _g.issue_class, proofPlan: (_h = diagnosisValidation.normalized) === null || _h === void 0 ? void 0 : _h.proof_plan, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_3));
4740
+ return __assign({ action: 'infra_repair_only', canEditProductCode: false, blockers: ['Infra/compile/Puppeteer/startup failures must be repaired in the harness lane before product-code repair.'], ownerFiles: ownerFiles, issueClass: (_g = diagnosisValidation.normalized) === null || _g === void 0 ? void 0 : _g.issue_class, proofPlan: (_h = diagnosisValidation.normalized) === null || _h === void 0 ? void 0 : _h.proof_plan, ownerScopedRepairContract: ownerScopedRepairContract, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_3));
3152
4741
  }
3153
4742
  if (activeStepType === 'diagnosis_gate' || !diagnosisValidation.valid) {
3154
4743
  var recoveryPlan_4 = recoveryPlanFor('continue', 'support_v5_diagnosis_gate_required', 'diagnosis', false);
3155
4744
  return __assign({ action: 'diagnose_only', canEditProductCode: false, blockers: diagnosisValidation.blockers.length
3156
4745
  ? diagnosisValidation.blockers
3157
- : ['SupportDiagnosisGate is required before product-code repair.'], ownerFiles: ownerFiles, issueClass: (_j = diagnosisValidation.normalized) === null || _j === void 0 ? void 0 : _j.issue_class, proofPlan: (_k = diagnosisValidation.normalized) === null || _k === void 0 ? void 0 : _k.proof_plan, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_4));
4746
+ : ['SupportDiagnosisGate is required before product-code repair.'], ownerFiles: ownerFiles, issueClass: (_j = diagnosisValidation.normalized) === null || _j === void 0 ? void 0 : _j.issue_class, proofPlan: (_k = diagnosisValidation.normalized) === null || _k === void 0 ? void 0 : _k.proof_plan, ownerScopedRepairContract: ownerScopedRepairContract, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_4));
3158
4747
  }
3159
4748
  if (outsideOwnerFiles.length) {
3160
4749
  var recoveryPlan_5 = recoveryPlanFor('continue', 'support_v5_out_of_scope_requires_diagnosis_revision', 'owner_scope', false);
3161
- return __assign({ action: 'reject_out_of_scope', canEditProductCode: false, blockers: ["Changed files outside diagnosis owner_files; revise diagnosis with new evidence before broadening edits: ".concat(outsideOwnerFiles.join(', '))], ownerFiles: ownerFiles, issueClass: (_l = diagnosisValidation.normalized) === null || _l === void 0 ? void 0 : _l.issue_class, proofPlan: (_m = diagnosisValidation.normalized) === null || _m === void 0 ? void 0 : _m.proof_plan, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_5));
4750
+ return __assign({ action: 'reject_out_of_scope', canEditProductCode: false, blockers: ["Changed files outside diagnosis owner_files; revise diagnosis with new evidence before broadening edits: ".concat(outsideOwnerFiles.join(', '))], ownerFiles: ownerFiles, issueClass: (_l = diagnosisValidation.normalized) === null || _l === void 0 ? void 0 : _l.issue_class, proofPlan: (_m = diagnosisValidation.normalized) === null || _m === void 0 ? void 0 : _m.proof_plan, ownerScopedRepairContract: ownerScopedRepairContract, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_5));
3162
4751
  }
3163
4752
  var recoveryPlan = recoveryPlanFor('continue', 'support_v5_product_repair_allowed_after_diagnosis', failureClass || 'product_code', true);
3164
- return __assign({ action: 'allow_product_repair', canEditProductCode: true, blockers: [], ownerFiles: ownerFiles, issueClass: (_o = diagnosisValidation.normalized) === null || _o === void 0 ? void 0 : _o.issue_class, proofPlan: (_p = diagnosisValidation.normalized) === null || _p === void 0 ? void 0 : _p.proof_plan, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan));
4753
+ return __assign({ action: 'allow_product_repair', canEditProductCode: true, blockers: [], ownerFiles: ownerFiles, issueClass: (_o = diagnosisValidation.normalized) === null || _o === void 0 ? void 0 : _o.issue_class, proofPlan: (_p = diagnosisValidation.normalized) === null || _p === void 0 ? void 0 : _p.proof_plan, ownerScopedRepairContract: ownerScopedRepairContract, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan));
3165
4754
  }
3166
4755
  function applyResolveIOSupportDiagnosisGateToMicrotasks(bundle, diagnosisGate) {
3167
4756
  var _a;
@@ -3182,6 +4771,29 @@ function applyResolveIOSupportDiagnosisGateToMicrotasks(bundle, diagnosisGate) {
3182
4771
  || (proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion)
3183
4772
  || gate.proof_plan.data_assertion
3184
4773
  || gate.proof_plan.after;
4774
+ var repairObjective = cleanText([
4775
+ "Patch the accepted root cause in ".concat(ownerFiles.join(', '), "."),
4776
+ "Hypothesis: ".concat(gate.accepted_hypothesis.statement),
4777
+ "Business proof: ".concat(gate.proof_plan.business_assertion)
4778
+ ].filter(Boolean).join(' '), 520);
4779
+ var repairSelfGate = [
4780
+ "Modify only the diagnosed owner files unless you revise the diagnosis with new evidence. Owner files: ".concat(ownerFiles.join(', '), "."),
4781
+ "Implement the falsifiable fix for: ".concat(gate.accepted_hypothesis.statement),
4782
+ 'Do not re-run read-only reproduction as the repair; make the smallest product-code change and report targeted proof.'
4783
+ ].join(' ');
4784
+ var qaObjective = cleanText([
4785
+ 'QA proof for diagnosis business assertion:',
4786
+ (proofContract === null || proofContract === void 0 ? void 0 : proofContract.action_under_test) || gate.proof_plan.action,
4787
+ '=>',
4788
+ businessAssertion || businessProof
4789
+ ].filter(Boolean).join(' '), 420);
4790
+ var looksLikeReadOnlyDiagnosisTask = function (task) {
4791
+ var text = "".concat(task.objective || '', "\n").concat(task.selfGate || '', "\n").concat(task.blocker || '');
4792
+ if (!/\b(replicat|reproduc|diagnos|analy[sz]|investigat|inspect|review|classif|read[-\s]*only|attached\s+template|upload\s+issue)\b/i.test(text)) {
4793
+ return false;
4794
+ }
4795
+ return !/\b(patch|repair|fix|implement|correct|update|change product-code|product-code change)\b/i.test(task.objective || '');
4796
+ };
3185
4797
  var diagnosisMicrotaskId = ((_a = (bundle.supportV5MicrotaskLedger || [])
3186
4798
  .find(function (task) { return task.type === 'diagnosis_gate'; })) === null || _a === void 0 ? void 0 : _a.microtaskId)
3187
4799
  || stableIdFromText('diagnosis', "Root-cause-first diagnosis gate for: ".concat(cleanText(bundle.supportV5ScopeDigest || gate.issue_case.customer_complaint, 360) || 'support ticket'));
@@ -3190,10 +4802,12 @@ function applyResolveIOSupportDiagnosisGateToMicrotasks(bundle, diagnosisGate) {
3190
4802
  return __assign(__assign({}, task), { status: validation.valid ? 'pass' : 'needs_repair', blocker: validation.valid ? '' : validation.blockers.join(' | '), updatedAt: now });
3191
4803
  }
3192
4804
  if (task.lane === 'build' && /repair|product_repair|build_repair/i.test(String(task.type || ''))) {
3193
- return __assign(__assign({}, task), { targetFiles: ownerFiles, contextRefs: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.contextRefs || [])), false), ['supportV5DiagnosisGate', 'owner_files'], false))), selfGate: "Repair only the diagnosed owner files unless you revise the diagnosis with new evidence. Owner files: ".concat(ownerFiles.join(', '), "."), acceptanceProof: businessProof, dependsOn: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.dependsOn || [])), false), [diagnosisMicrotaskId], false))), updatedAt: now });
4805
+ var staleDiagnosisTask = validation.valid && looksLikeReadOnlyDiagnosisTask(task);
4806
+ return __assign(__assign({}, task), { status: staleDiagnosisTask ? 'pending' : task.status, objective: staleDiagnosisTask ? repairObjective : task.objective, targetFiles: ownerFiles, contextRefs: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.contextRefs || [])), false), ['supportV5DiagnosisGate', 'owner_files', 'proof_plan', 'accepted_hypothesis'], false))), selfGate: repairSelfGate, acceptanceProof: businessProof, dependsOn: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.dependsOn || [])), false), [diagnosisMicrotaskId], false))), attempts: staleDiagnosisTask ? 0 : task.attempts, blocker: staleDiagnosisTask ? '' : task.blocker, updatedAt: now });
3194
4807
  }
3195
4808
  if (task.lane === 'qa' && task.type === 'qa_row') {
3196
- return __assign(__assign({}, task), { contextRefs: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.contextRefs || [])), false), ['supportV5DiagnosisGate', 'supportV5IssueClassProbePlan', 'proof_plan'], false))), selfGate: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.action) || task.selfGate, acceptanceProof: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.expected_business_proof) || businessProof || task.acceptanceProof, targetFiles: ownerFiles, updatedAt: now });
4809
+ var staleQaTask = validation.valid && looksLikeReadOnlyDiagnosisTask(task);
4810
+ return __assign(__assign({}, task), { objective: staleQaTask ? qaObjective : task.objective, contextRefs: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.contextRefs || [])), false), ['supportV5DiagnosisGate', 'supportV5IssueClassProbePlan', 'proof_plan'], false))), selfGate: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.action) || task.selfGate, acceptanceProof: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.expected_business_proof) || businessProof || task.acceptanceProof, targetFiles: ownerFiles, attempts: staleQaTask ? 0 : task.attempts, blocker: staleQaTask ? '' : task.blocker, updatedAt: now });
3197
4811
  }
3198
4812
  return task;
3199
4813
  });
@@ -3272,7 +4886,7 @@ function buildResolveIOSupportV5ScopeDigest(input) {
3272
4886
  return raw.slice(0, maxChars);
3273
4887
  }
3274
4888
  function buildResolveIOSupportV5MicrotaskLedger(input) {
3275
- var e_10, _a;
4889
+ var e_11, _a;
3276
4890
  var existing = Array.isArray(input.existing) ? input.existing : [];
3277
4891
  var completedByObjective = new Map();
3278
4892
  try {
@@ -3283,12 +4897,12 @@ function buildResolveIOSupportV5MicrotaskLedger(input) {
3283
4897
  }
3284
4898
  }
3285
4899
  }
3286
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
4900
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
3287
4901
  finally {
3288
4902
  try {
3289
4903
  if (existing_1_1 && !existing_1_1.done && (_a = existing_1.return)) _a.call(existing_1);
3290
4904
  }
3291
- finally { if (e_10) throw e_10.error; }
4905
+ finally { if (e_11) throw e_11.error; }
3292
4906
  }
3293
4907
  var now = isoNow(input.now);
3294
4908
  var requirements = cleanList(input.requirements, 30, 240);
@@ -3737,6 +5351,7 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
3737
5351
  ignoreInfra: true
3738
5352
  });
3739
5353
  var ownerFiles = ((_a = diagnosisValidation.normalized) === null || _a === void 0 ? void 0 : _a.owner_files) || repairGate.ownerFiles || [];
5354
+ var diagnosisProofMatrix = diagnosisValidation.proofMatrix || buildResolveIOSupportDiagnosisProofMatrix(bundle.supportV5DiagnosisGate, input.now);
3740
5355
  var proofContract = (_b = diagnosisValidation.normalized) === null || _b === void 0 ? void 0 : _b.proof_plan.business_proof_contract;
3741
5356
  var expectedProof = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion)
3742
5357
  || ((_c = diagnosisValidation.normalized) === null || _c === void 0 ? void 0 : _c.proof_plan.business_assertion)
@@ -3770,6 +5385,8 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
3770
5385
  revise_diagnosis_scope: 'scope_revision_required',
3771
5386
  run_owner_scoped_repair: 'owner_scoped_repair_ready',
3772
5387
  run_business_proof_qa: 'business_proof_required',
5388
+ create_pr: 'pr_packaging_ready',
5389
+ run_a_grade_pr_review: 'pr_review_required',
3773
5390
  repair_release_hotfix_first: 'release_hotfix_required',
3774
5391
  collect_new_evidence: 'collect_new_evidence',
3775
5392
  draft_customer_reply: 'customer_reply_draft_ready',
@@ -3783,6 +5400,8 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
3783
5400
  scope_revision_required: 'scope',
3784
5401
  owner_scoped_repair_ready: 'repair',
3785
5402
  business_proof_required: 'business_proof',
5403
+ pr_packaging_ready: 'release',
5404
+ pr_review_required: 'release',
3786
5405
  release_hotfix_required: 'release',
3787
5406
  release_gate_ready: 'release',
3788
5407
  customer_reply_draft_ready: 'customer_reply',
@@ -3793,9 +5412,11 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
3793
5412
  var diagnosisValid = diagnosisValidation.valid === true;
3794
5413
  var ownerFilesReady = diagnosisValid && ownerFiles.length > 0;
3795
5414
  var proofPlanReady = diagnosisValid && !!proofContract;
5415
+ var proofMatrixReady = diagnosisProofMatrix.status === 'ready';
5416
+ var ownerScopedRepairContractReady = repairGate.ownerScopedRepairContract.status === 'ready';
3796
5417
  var issueClassProbePlanReady = issueClassProbePlanValidation.valid === true;
3797
5418
  var preflightReady = preflightGate.blocksProductRepair !== true;
3798
- var rootCauseFirstSatisfied = diagnosisValid && ownerFilesReady && proofPlanReady && issueClassProbePlanReady && preflightReady;
5419
+ var rootCauseFirstSatisfied = diagnosisValid && ownerFilesReady && proofPlanReady && proofMatrixReady && issueClassProbePlanReady && preflightReady;
3799
5420
  var sameFailureParked = evidenceFreshness.mustCollectNewEvidence === true
3800
5421
  || (action === 'collect_new_evidence' && /repeated|no_progress|ping_pong|same failure|same evidence/i.test(reason));
3801
5422
  return {
@@ -3806,10 +5427,12 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
3806
5427
  diagnosisValid: diagnosisValid,
3807
5428
  ownerFilesReady: ownerFilesReady,
3808
5429
  proofPlanReady: proofPlanReady,
5430
+ proofMatrixReady: proofMatrixReady,
5431
+ ownerScopedRepairContractReady: ownerScopedRepairContractReady,
3809
5432
  businessProofReady: businessProofReadiness.ready === true,
3810
5433
  infraOnly: action === 'repair_infra_only',
3811
5434
  sameFailureParked: sameFailureParked,
3812
- canEditProductCode: fields.canEditProductCode === true && rootCauseFirstSatisfied,
5435
+ canEditProductCode: fields.canEditProductCode === true && rootCauseFirstSatisfied && ownerScopedRepairContractReady,
3813
5436
  canRunIssueClassProbe: rootCauseFirstSatisfied && (action === 'run_business_proof_qa' || status === 'business_proof_required'),
3814
5437
  canRunBusinessProofQa: rootCauseFirstSatisfied && (action === 'run_business_proof_qa' || !businessProofReadiness.ready),
3815
5438
  canRelease: action === 'ready_for_release_gate' && businessProofReadiness.ready === true,
@@ -3821,12 +5444,14 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
3821
5444
  preflightStatus: preflightGate.status,
3822
5445
  preflightFailureClass: preflightGate.failureClass,
3823
5446
  reason: reason,
3824
- blockers: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(blockers), false), __read(issueClassProbePlanValidation.blockers), false), __read(preflightGate.blockers), false))),
5447
+ blockers: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(blockers), false), __read(diagnosisProofMatrix.blockers), false), __read(repairGate.ownerScopedRepairContract.blockers), false), __read(issueClassProbePlanValidation.blockers), false), __read(preflightGate.blockers), false))),
3825
5448
  ownerFiles: ownerFiles,
3826
5449
  issueClass: ((_a = diagnosisValidation.normalized) === null || _a === void 0 ? void 0 : _a.issue_class) || repairGate.issueClass,
3827
5450
  expectedProof: expectedProof,
3828
5451
  issueClassProbes: issueClassProbes,
3829
5452
  issueClassProbePlan: issueClassProbePlan,
5453
+ proofMatrix: diagnosisProofMatrix,
5454
+ ownerScopedRepairContract: repairGate.ownerScopedRepairContract,
3830
5455
  businessProofStatus: businessProofReadiness.status,
3831
5456
  proofFingerprint: businessProofReadiness.proofFingerprint,
3832
5457
  artifactFingerprint: businessProofReadiness.artifactFingerprint,
@@ -3853,6 +5478,12 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
3853
5478
  if (action === 'run_business_proof_qa') {
3854
5479
  return 'A fresh AIQaBusinessAssertion maps to the validated IssueClassProbePlan and records before/action/after DOM, data, or Mongo proof.';
3855
5480
  }
5481
+ if (action === 'create_pr') {
5482
+ return 'A support PR is created or updated from the proof-ready run, with merge/release/customer-send still blocked behind human/release gates.';
5483
+ }
5484
+ if (action === 'run_a_grade_pr_review') {
5485
+ return 'The support PR is checked against strict execution, artifact, pull-request, AIQa, before/action/after, and screenshot/trace evidence; merge/release/customer-send remain blocked.';
5486
+ }
3856
5487
  if (action === 'repair_release_hotfix_first') {
3857
5488
  return primaryCommand === 'record_hotfix_evidence'
3858
5489
  ? 'Hotfix evidence is recorded with sourceCommitSha, githubCommitUrl, passed gitCommitStatus, and passed gitPushStatus before any live backend apply or continuation.'
@@ -3869,20 +5500,34 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
3869
5500
  }
3870
5501
  return 'The runner stays parked until a human changes scope, budget, evidence, or autonomy policy.';
3871
5502
  };
3872
- var buildNextActionContract = function (action, label, reason, fields, rootCauseReadiness, continuationProofCheckpoint, primaryCommand, nextCommands, requiredEvidence, forbiddenActions, blockers) {
5503
+ var buildNextActionContract = function (action, label, reason, fields, rootCauseReadiness, continuationProofCheckpoint, primaryCommand, nextCommands, requiredEvidence, forbiddenActions, blockers, evidenceProbeContract, autonomyApproval, productRepairDispatchGuard, autopilotCompletionProgress) {
5504
+ var _a, _b, _c, _d, _e, _f;
3873
5505
  var lane = (fields.lane || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'supervisor');
3874
5506
  var stepType = (fields.stepType || activeStepType);
3875
5507
  var liveHotfixBlockedUntilCommit = fields.liveHotfixBlockedUntilCommit === true;
3876
5508
  var hotfixCommitRequired = action === 'repair_release_hotfix_first'
3877
5509
  || liveHotfixBlockedUntilCommit
3878
5510
  || fields.canHotfixBackend === true;
3879
- var requiresHumanApproval = action === 'park_manual'
5511
+ var baseRequiresHumanApproval = action === 'park_manual'
3880
5512
  || action === 'ask_customer_clarification'
3881
5513
  || rootCauseReadiness.requiresHumanDecision === true;
5514
+ var dispatchAction = supportManagerDispatchActionForNextAction(action, fields, preflightGate);
5515
+ var autonomyPolicy = input.autonomyPolicy
5516
+ ? (0, ai_runner_manager_policy_1.decideResolveIOAIManagerAutonomyPolicy)(__assign(__assign({}, input.autonomyPolicy), { dispatchAction: dispatchAction, projectedActionCostUsd: (_a = input.autonomyPolicy.projectedActionCostUsd) !== null && _a !== void 0 ? _a : supportProjectedActionCostUsdForNextAction(action, fields), evidenceStrength: input.autonomyPolicy.evidenceStrength || evidenceFreshness.evidenceStrength, materialEvidence: (_b = input.autonomyPolicy.materialEvidence) !== null && _b !== void 0 ? _b : evidenceFreshness.materialEvidence, newEvidence: (_c = input.autonomyPolicy.newEvidence) !== null && _c !== void 0 ? _c : evidenceFreshness.newEvidence, evidenceSignals: input.autonomyPolicy.evidenceSignals || evidenceFreshness.evidenceSignals, operatorApproved: (_d = input.operatorApproved) !== null && _d !== void 0 ? _d : input.autonomyPolicy.operatorApproved }))
5517
+ : undefined;
5518
+ var productRepairApprovalBlocked = (productRepairDispatchGuard === null || productRepairDispatchGuard === void 0 ? void 0 : productRepairDispatchGuard.status) === 'blocked';
5519
+ var autonomyBlocksAutoRun = (!!autonomyPolicy && autonomyPolicy.canAutoDispatch !== true)
5520
+ || productRepairApprovalBlocked;
5521
+ var requiresHumanApproval = baseRequiresHumanApproval
5522
+ || (autonomyPolicy === null || autonomyPolicy === void 0 ? void 0 : autonomyPolicy.requiresHumanApproval) === true
5523
+ || (autonomyPolicy === null || autonomyPolicy === void 0 ? void 0 : autonomyPolicy.blocked) === true
5524
+ || productRepairApprovalBlocked;
3882
5525
  var safeToAutoRun = fields.canRunAutonomously === true
3883
- && !requiresHumanApproval
3884
- && (action !== 'run_owner_scoped_repair' || (rootCauseReadiness.rootCauseFirstSatisfied === true && evidenceFreshness.mustCollectNewEvidence !== true))
5526
+ && !baseRequiresHumanApproval
5527
+ && !autonomyBlocksAutoRun
5528
+ && (action !== 'run_owner_scoped_repair' || (rootCauseReadiness.rootCauseFirstSatisfied === true && rootCauseReadiness.ownerScopedRepairContractReady === true && evidenceFreshness.mustCollectNewEvidence !== true))
3885
5529
  && (action !== 'run_business_proof_qa' || rootCauseReadiness.issueClassProbePlanReady === true)
5530
+ && (action !== 'collect_new_evidence' || (evidenceProbeContract === null || evidenceProbeContract === void 0 ? void 0 : evidenceProbeContract.status) === 'ready')
3886
5531
  && (action !== 'repair_release_hotfix_first' || primaryCommand !== 'apply_backend_hotfix_only_after_commit_proof' || liveHotfixBlockedUntilCommit !== true);
3887
5532
  var costRisk = requiresHumanApproval
3888
5533
  ? 'manual_blocked'
@@ -3909,13 +5554,22 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
3909
5554
  action !== 'run_diagnosis_gate' ? 'SupportDiagnosisGate validation checked before action.' : 'Diagnosis is read-only and cannot edit source files.',
3910
5555
  action === 'run_owner_scoped_repair' ? 'Root-cause-first gate is satisfied and owner_files are the only editable product files.' : '',
3911
5556
  action === 'run_business_proof_qa' ? 'Business proof QA must use the diagnosis proof_plan and validated IssueClassProbePlan.' : '',
5557
+ action === 'create_pr' ? 'Business proof and changed-file evidence are ready; this action only packages/updates the support PR.' : '',
5558
+ action === 'run_a_grade_pr_review' ? 'A support PR exists and must pass strict A-grade review before any merge, release, deploy, or customer reply.' : '',
3912
5559
  action === 'repair_release_hotfix_first' ? 'Live backend hotfix is blocked until GitHub commit proof is recorded and passed.' : '',
3913
- evidenceFreshness.mustCollectNewEvidence === true ? 'Current failure is stale or repeated; only evidence collection is allowed until proof changes.' : ''
5560
+ productRepairDispatchGuard ? "Support autonomy approval ".concat((autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.status) || 'missing', ": ").concat(productRepairDispatchGuard.reason, ".") : '',
5561
+ autopilotCompletionProgress ? "Approved-autopilot phase ".concat(autopilotCompletionProgress.activePhase, ": ").concat(autopilotCompletionProgress.reason, ".") : '',
5562
+ evidenceFreshness.mustCollectNewEvidence === true ? 'Current failure is stale or repeated; only evidence collection is allowed until proof changes.' : '',
5563
+ autonomyPolicy ? "Autonomy policy ".concat(autonomyPolicy.mode, ": ").concat(autonomyPolicy.reason, ".") : ''
3914
5564
  ], __read(requiredEvidence), false).filter(Boolean))).slice(0, 24);
3915
5565
  var stopConditions = Array.from(new Set(__spreadArray([
3916
5566
  'Stop if the same failure class, blocker fingerprint, and evidence hash repeat without material evidence.',
3917
5567
  'Stop if the action would edit outside diagnosis owner_files without a revised diagnosis gate.',
3918
5568
  'Stop if route-load, screenshot-only, scorecard-only, or model-claim proof is the only acceptance evidence.',
5569
+ action === 'create_pr' ? 'Stop before merge, release, deploy, or customer-send; PR packaging is the only allowed side effect.' : '',
5570
+ action === 'run_a_grade_pr_review' ? 'Stop before merge, release, deploy, or customer-send; this action only records strict A-grade PR review evidence.' : '',
5571
+ (autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.overMaxAutoHours) && autonomyApproval.explicitOverLimitApproval !== true ? "Stop before product-code repair: estimated work is over ".concat(autonomyApproval.maxAutoHoursWithoutApproval, " hours without explicit over-limit approval.") : '',
5572
+ (productRepairDispatchGuard === null || productRepairDispatchGuard === void 0 ? void 0 : productRepairDispatchGuard.status) === 'blocked' ? 'Stop before product-code repair until the autonomy approval/dispatch guard is allowed.' : '',
3919
5573
  liveHotfixBlockedUntilCommit ? 'Stop before live backend hotfix until sourceCommitSha, githubCommitUrl, passed gitCommitStatus, and passed gitPushStatus are recorded.' : ''
3920
5574
  ], __read(continuationProofCheckpoint.requiredResetEvidence.map(function (entry) { return "Reset requires: ".concat(entry); })), false).filter(Boolean))).slice(0, 24);
3921
5575
  var createdAt = isoNow(input.now);
@@ -3946,12 +5600,16 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
3946
5600
  diagnosisValid: rootCauseReadiness.diagnosisValid === true,
3947
5601
  ownerFilesReady: rootCauseReadiness.ownerFilesReady === true,
3948
5602
  proofPlanReady: rootCauseReadiness.proofPlanReady === true,
5603
+ proofMatrixReady: rootCauseReadiness.proofMatrixReady === true,
5604
+ proofMatrixId: (_e = rootCauseReadiness.proofMatrix) === null || _e === void 0 ? void 0 : _e.matrixId,
5605
+ ownerScopedRepairContractReady: rootCauseReadiness.ownerScopedRepairContractReady === true,
5606
+ ownerScopedRepairContractId: (_f = rootCauseReadiness.ownerScopedRepairContract) === null || _f === void 0 ? void 0 : _f.contractId,
3949
5607
  businessProofReady: businessProofReadiness.ready === true,
3950
5608
  evidenceFreshnessStatus: evidenceFreshness.status,
3951
5609
  evidenceStrength: evidenceFreshness.evidenceStrength,
3952
- failureClass: evidenceFreshness.failureClass,
3953
- blockerFingerprint: evidenceFreshness.blockerFingerprint,
3954
- evidenceHash: evidenceFreshness.evidenceHash,
5610
+ failureClass: cleanText(fields.failureClass || evidenceFreshness.failureClass, 120),
5611
+ blockerFingerprint: cleanText(fields.blockerFingerprint || evidenceFreshness.blockerFingerprint, 180),
5612
+ evidenceHash: cleanText(fields.evidenceHash || evidenceFreshness.evidenceHash, 180),
3955
5613
  sameFailureCount: evidenceFreshness.sameFailureCount,
3956
5614
  issueClassProbePlanReady: rootCauseReadiness.issueClassProbePlanReady === true,
3957
5615
  preflightReady: rootCauseReadiness.preflightReady === true,
@@ -3959,16 +5617,56 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
3959
5617
  preflightFailureClass: preflightGate.failureClass,
3960
5618
  preflightEvidenceHash: preflightGate.evidenceHash,
3961
5619
  hotfixCommitRequired: hotfixCommitRequired,
3962
- liveHotfixBlockedUntilCommit: liveHotfixBlockedUntilCommit
5620
+ liveHotfixBlockedUntilCommit: liveHotfixBlockedUntilCommit,
5621
+ evidenceProbeContractReady: evidenceProbeContract ? evidenceProbeContract.status === 'ready' : undefined,
5622
+ evidenceProbeContractId: evidenceProbeContract === null || evidenceProbeContract === void 0 ? void 0 : evidenceProbeContract.contractId,
5623
+ autonomyMode: autonomyPolicy === null || autonomyPolicy === void 0 ? void 0 : autonomyPolicy.mode,
5624
+ autonomyCanAutoDispatch: autonomyPolicy === null || autonomyPolicy === void 0 ? void 0 : autonomyPolicy.canAutoDispatch,
5625
+ autonomyReason: autonomyPolicy === null || autonomyPolicy === void 0 ? void 0 : autonomyPolicy.reason,
5626
+ autonomyExpectedValueScore: autonomyPolicy === null || autonomyPolicy === void 0 ? void 0 : autonomyPolicy.expectedValueScore,
5627
+ autonomyExpectedValuePositive: autonomyPolicy === null || autonomyPolicy === void 0 ? void 0 : autonomyPolicy.expectedValuePositive,
5628
+ autonomyProjectedSpendUsd: autonomyPolicy === null || autonomyPolicy === void 0 ? void 0 : autonomyPolicy.projectedSpendUsd,
5629
+ autonomyApprovalRequired: !!autonomyApproval || input.requireAutonomyApprovalForProductRepair === true,
5630
+ autonomyApprovalApproved: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.approved,
5631
+ autonomyApprovalBoundaryValid: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.autopilotApprovalBoundaryValid,
5632
+ autonomyApprovalDecisionKind: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.decisionKind,
5633
+ autonomyApprovalAction: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.approvalAction,
5634
+ approvedScopeHours: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.estimatedHours,
5635
+ maxAutoHoursWithoutApproval: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.maxAutoHoursWithoutApproval,
5636
+ overMaxAutoHours: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.overMaxAutoHours,
5637
+ bugNotBug: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.bugNotBug,
5638
+ bugNotBugClassificationApproved: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.bugNotBugClassificationApproved,
5639
+ scopeFingerprint: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.scopeFingerprint,
5640
+ scopeChangedSinceApproval: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.scopeChangedSinceApproval,
5641
+ ownerFileFingerprint: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.ownerFileFingerprint,
5642
+ approvedOwnerFileFingerprint: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.approvedOwnerFileFingerprint,
5643
+ ownerFilesChangedSinceApproval: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.ownerFilesChangedSinceApproval,
5644
+ ownerFilesAddedSinceApproval: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.ownerFilesAddedSinceApproval,
5645
+ ownerFilesRemovedSinceApproval: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.ownerFilesRemovedSinceApproval,
5646
+ diagnosisScopeFingerprint: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.diagnosisScopeFingerprint,
5647
+ previousDiagnosisScopeFingerprint: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.previousDiagnosisScopeFingerprint,
5648
+ diagnosisScopeIncluded: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.diagnosisScopeIncluded,
5649
+ diagnosisScopeValid: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.diagnosisScopeValid,
5650
+ diagnosisScopeChangedSinceApproval: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.diagnosisScopeChangedSinceApproval,
5651
+ diagnosisScopeFields: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.diagnosisScopeFields,
5652
+ diagnosisScopeBlockers: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.diagnosisScopeBlockers,
5653
+ requiresOperatorApprovalForAnyScopeChange: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.requiresOperatorApprovalForAnyScopeChange,
5654
+ leSixHourScopeCanAutofixAfterApproval: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.leSixHourScopeCanAutofixAfterApproval,
5655
+ onTheFlyScopeChangeApprovalRequired: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.onTheFlyScopeChangeApprovalRequired,
5656
+ afterApprovalAutopilotUntilAGrade: autonomyApproval === null || autonomyApproval === void 0 ? void 0 : autonomyApproval.afterApprovalAutopilotUntilAGrade,
5657
+ autopilotCompletionStatus: autopilotCompletionProgress === null || autopilotCompletionProgress === void 0 ? void 0 : autopilotCompletionProgress.status,
5658
+ autopilotCompletionPhase: autopilotCompletionProgress === null || autopilotCompletionProgress === void 0 ? void 0 : autopilotCompletionProgress.activePhase,
5659
+ autopilotCompletionNextAction: autopilotCompletionProgress === null || autopilotCompletionProgress === void 0 ? void 0 : autopilotCompletionProgress.nextAction,
5660
+ autopilotCompletionReady: (autopilotCompletionProgress === null || autopilotCompletionProgress === void 0 ? void 0 : autopilotCompletionProgress.status) === 'complete'
3963
5661
  },
3964
5662
  preconditions: preconditions,
3965
5663
  expectedStateTransition: nextActionExpectedTransition(action, primaryCommand),
3966
5664
  successEvidence: Array.from(new Set(requiredEvidence.length ? requiredEvidence : continuationProofCheckpoint.requiredEvidence)).slice(0, 24),
3967
5665
  stopConditions: stopConditions,
3968
- forbiddenActions: forbiddenActions.slice(0, 24),
5666
+ forbiddenActions: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(forbiddenActions), false), __read(((autopilotCompletionProgress === null || autopilotCompletionProgress === void 0 ? void 0 : autopilotCompletionProgress.forbiddenActions) || [])), false), __read(((productRepairDispatchGuard === null || productRepairDispatchGuard === void 0 ? void 0 : productRepairDispatchGuard.forbiddenActions) || [])), false), __read(((autonomyPolicy === null || autonomyPolicy === void 0 ? void 0 : autonomyPolicy.forbiddenActions) || [])), false))).slice(0, 24),
3969
5667
  ownerFiles: ownerFiles.slice(0, 24),
3970
- blockers: blockers.slice(0, 24),
3971
- nextCommands: nextCommands.slice(0, 24),
5668
+ blockers: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(blockers), false), __read((autopilotCompletionProgress && autopilotCompletionProgress.status !== 'complete' ? autopilotCompletionProgress.blockers : [])), false), __read(((productRepairDispatchGuard === null || productRepairDispatchGuard === void 0 ? void 0 : productRepairDispatchGuard.status) === 'blocked' ? productRepairDispatchGuard.blockers : [])), false), __read((autonomyPolicy && autonomyPolicy.canAutoDispatch !== true ? ["autonomy_policy:".concat(autonomyPolicy.reason)] : [])), false))).slice(0, 24),
5669
+ nextCommands: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(((productRepairDispatchGuard === null || productRepairDispatchGuard === void 0 ? void 0 : productRepairDispatchGuard.status) === 'blocked' && productRepairDispatchGuard.nextAction ? [productRepairDispatchGuard.nextAction] : [])), false), __read((autopilotCompletionProgress && autopilotCompletionProgress.nextAction !== action ? [autopilotCompletionProgress.nextCommand] : [])), false), __read(nextCommands), false))).slice(0, 24),
3972
5670
  createdAt: createdAt
3973
5671
  };
3974
5672
  };
@@ -3988,13 +5686,22 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
3988
5686
  && action === 'collect_new_evidence'
3989
5687
  && nextActionContract.safeToAutoRun === true
3990
5688
  && nextActionContract.canRunWithoutCodexMonitor === true;
5689
+ var approvalAction = cleanText(nextActionContract.decisionBasis.autonomyApprovalAction, 120);
5690
+ var approvalDecisionKind = cleanText(nextActionContract.decisionBasis.autonomyApprovalDecisionKind, 120);
5691
+ var approvalChoiceId = approvalAction
5692
+ ? (approvalAction === 'approve_support_autonomy_over_limit' || /over_limit/i.test(approvalDecisionKind)
5693
+ ? 'approve_over_limit_autonomy'
5694
+ : 'approve_auto_fix_le_6h_bug')
5695
+ : '';
3991
5696
  var preferredChoiceId = autoDispatchAllowed
3992
5697
  ? 'run_bounded_evidence_probe'
3993
- : action === 'ask_customer_clarification'
3994
- ? 'review_customer_clarification'
3995
- : action === 'run_diagnosis_gate' || action === 'revise_diagnosis_scope'
3996
- ? 'revise_diagnosis_gate'
3997
- : 'keep_parked';
5698
+ : approvalChoiceId
5699
+ ? approvalChoiceId
5700
+ : action === 'ask_customer_clarification'
5701
+ ? 'review_customer_clarification'
5702
+ : action === 'run_diagnosis_gate' || action === 'revise_diagnosis_scope'
5703
+ ? 'revise_diagnosis_gate'
5704
+ : 'keep_parked';
3998
5705
  var baseRequiredEvidence = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(requiredEvidence), false), __read(continuationProofCheckpoint.requiredResetEvidence), false), __read(evidenceFreshness.requiredResetEvidence), false).filter(Boolean))).slice(0, 20);
3999
5706
  var choices = [];
4000
5707
  if (repeatedEvidenceBlocked) {
@@ -4010,6 +5717,21 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
4010
5717
  allowedWithoutCodexMonitor: autoDispatchAllowed
4011
5718
  });
4012
5719
  }
5720
+ if (approvalAction) {
5721
+ choices.push({
5722
+ choiceId: approvalChoiceId || 'approve_support_autonomy',
5723
+ label: approvalChoiceId === 'approve_over_limit_autonomy' ? 'Approve Over Limit' : 'Approve Autopilot',
5724
+ action: approvalAction,
5725
+ description: approvalChoiceId === 'approve_over_limit_autonomy'
5726
+ ? 'Approve this over-six-hour support scope; after approval the runner continues only inside the approved diagnosis/owner-file boundary until A-grade PR proof or a new scope blocker.'
5727
+ : 'Approve this bounded bug/not-bug support scope; after approval the runner continues to A-grade PR proof with QA screenshots and before/action/after business proof.',
5728
+ safety: approvalChoiceId === 'approve_over_limit_autonomy' ? 'high' : 'medium',
5729
+ requiresConfirmation: true,
5730
+ nextCommand: approvalAction,
5731
+ expectedResult: 'Autonomy approval gate changes to approved_autopilot or records the exact scope/estimate/classification field that still blocks product-code repair.',
5732
+ allowedWithoutCodexMonitor: false
5733
+ });
5734
+ }
4013
5735
  choices.push({
4014
5736
  choiceId: 'revise_diagnosis_gate',
4015
5737
  label: 'Revise Diagnosis',
@@ -4095,7 +5817,7 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
4095
5817
  };
4096
5818
  };
4097
5819
  var makeDecision = function (action, label, reason, fields) {
4098
- var _a;
5820
+ var _a, _b, _c, _d, _e;
4099
5821
  var primaryCommand = fields.primaryCommand || action;
4100
5822
  var nextCommands = Array.from(new Set(__spreadArray([
4101
5823
  primaryCommand
@@ -4116,7 +5838,48 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
4116
5838
  requiredResetEvidence: fields.requiredEvidence,
4117
5839
  blocksProductRepair: evidenceFreshness.mustCollectNewEvidence === true
4118
5840
  });
4119
- var nextActionContract = buildNextActionContract(action, label, reason, fields, rootCauseReadiness, continuationProofCheckpoint, primaryCommand, nextCommands, requiredEvidence, forbiddenActions, blockers);
5841
+ var editsProductCode = fields.canEditProductCode === true || action === 'run_owner_scoped_repair';
5842
+ var autonomyApproval = normalizeResolveIOSupportAutonomyApprovalContract(input.autonomyApproval, {
5843
+ required: input.requireAutonomyApprovalForProductRepair === true && editsProductCode,
5844
+ action: action,
5845
+ ownerFiles: ownerFiles,
5846
+ now: input.now
5847
+ });
5848
+ var productRepairDispatchGuard = autonomyApproval
5849
+ ? buildResolveIOSupportProductRepairDispatchGuard({
5850
+ action: action,
5851
+ approval: autonomyApproval,
5852
+ editsProductCode: editsProductCode,
5853
+ ownerFiles: ownerFiles,
5854
+ now: input.now
5855
+ })
5856
+ : undefined;
5857
+ var autopilotCompletionProgress = buildResolveIOSupportAutopilotCompletionProgress({
5858
+ approval: autonomyApproval,
5859
+ productRepairDispatchGuard: productRepairDispatchGuard,
5860
+ action: action,
5861
+ diagnosisValid: diagnosisValidation.valid === true,
5862
+ preflightGate: preflightGate,
5863
+ businessProofReadiness: businessProofReadiness,
5864
+ businessProofArtifacts: input.businessProofArtifacts,
5865
+ changedFiles: input.changedFiles,
5866
+ prReadinessContract: input.prReadinessContract,
5867
+ prReviewContract: input.prReviewContract,
5868
+ now: input.now
5869
+ });
5870
+ var evidenceProbeContract = action === 'collect_new_evidence'
5871
+ ? buildResolveIOSupportEvidenceProbeContract({
5872
+ diagnosisGate: diagnosisValidation.normalized,
5873
+ issueClassProbePlan: issueClassProbePlan,
5874
+ evidenceFreshness: evidenceFreshness,
5875
+ requiredEvidence: requiredEvidence,
5876
+ now: input.now
5877
+ })
5878
+ : undefined;
5879
+ var autonomyPolicy = input.autonomyPolicy
5880
+ ? (0, ai_runner_manager_policy_1.decideResolveIOAIManagerAutonomyPolicy)(__assign(__assign({}, input.autonomyPolicy), { dispatchAction: supportManagerDispatchActionForNextAction(action, fields, preflightGate), projectedActionCostUsd: (_a = input.autonomyPolicy.projectedActionCostUsd) !== null && _a !== void 0 ? _a : supportProjectedActionCostUsdForNextAction(action, fields), evidenceStrength: input.autonomyPolicy.evidenceStrength || evidenceFreshness.evidenceStrength, materialEvidence: (_b = input.autonomyPolicy.materialEvidence) !== null && _b !== void 0 ? _b : evidenceFreshness.materialEvidence, newEvidence: (_c = input.autonomyPolicy.newEvidence) !== null && _c !== void 0 ? _c : evidenceFreshness.newEvidence, evidenceSignals: input.autonomyPolicy.evidenceSignals || evidenceFreshness.evidenceSignals, operatorApproved: (_d = input.operatorApproved) !== null && _d !== void 0 ? _d : input.autonomyPolicy.operatorApproved }))
5881
+ : undefined;
5882
+ var nextActionContract = buildNextActionContract(action, label, reason, fields, rootCauseReadiness, continuationProofCheckpoint, primaryCommand, nextCommands, requiredEvidence, forbiddenActions, blockers, evidenceProbeContract, autonomyApproval, productRepairDispatchGuard, autopilotCompletionProgress);
4120
5883
  var managerExecutionPacket = buildResolveIOSupportManagerExecutionPacket(nextActionContract, input.now);
4121
5884
  var humanReviewPacket = fields.humanReviewPacket
4122
5885
  || (action === 'draft_customer_reply' && customerReplyPolicy.humanReviewPacket ? customerReplyPolicy.humanReviewPacket : undefined)
@@ -4171,7 +5934,7 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
4171
5934
  forbiddenActions: forbiddenActions,
4172
5935
  blockers: blockers,
4173
5936
  ownerFiles: ownerFiles,
4174
- issueClass: ((_a = diagnosisValidation.normalized) === null || _a === void 0 ? void 0 : _a.issue_class) || repairGate.issueClass,
5937
+ issueClass: ((_e = diagnosisValidation.normalized) === null || _e === void 0 ? void 0 : _e.issue_class) || repairGate.issueClass,
4175
5938
  expectedProof: expectedProof,
4176
5939
  issueClassProbes: issueClassProbes,
4177
5940
  issueClassProbePlan: issueClassProbePlan,
@@ -4191,6 +5954,11 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
4191
5954
  managerExecutionPacket: managerExecutionPacket,
4192
5955
  humanReviewPacket: humanReviewPacket,
4193
5956
  humanDecisionRequest: humanDecisionRequest,
5957
+ evidenceProbeContract: evidenceProbeContract,
5958
+ autonomyApproval: autonomyApproval,
5959
+ productRepairDispatchGuard: productRepairDispatchGuard,
5960
+ autopilotCompletionProgress: autopilotCompletionProgress,
5961
+ autonomyPolicy: autonomyPolicy,
4194
5962
  hotfixContinuation: fields.hotfixContinuation,
4195
5963
  hotfixDurabilityContract: fields.hotfixDurabilityContract,
4196
5964
  recordedAt: isoNow(input.now)
@@ -4468,6 +6236,164 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
4468
6236
  forbiddenActions: ['Do not run release or customer reply until businessProofReadiness.ready=true.']
4469
6237
  });
4470
6238
  }
6239
+ var prReadinessContract = cleanObject(input.prReadinessContract);
6240
+ var prReadinessStatus = cleanText(prReadinessContract.status, 120).toLowerCase();
6241
+ var prReadinessReady = prReadinessContract.ready === true || prReadinessStatus === 'ready';
6242
+ var pullRequestUrl = cleanText(prReadinessContract.pull_request_url || prReadinessContract.pullRequestUrl, 500);
6243
+ var prReviewContract = normalizeSupportAutopilotPrReviewContract(input.prReviewContract);
6244
+ var prReviewReady = prReviewContract.ready === true;
6245
+ var approvalSource = cleanObject(input.autonomyApproval);
6246
+ var approvedAutopilotUntilPr = (approvalSource.approved === true || cleanText(approvalSource.status, 120).toLowerCase() === 'approved_autopilot')
6247
+ && (approvalSource.after_approval_autopilot_until_a_grade === true
6248
+ || approvalSource.afterApprovalAutopilotUntilAGrade === true
6249
+ || approvalSource.autopilot_after_approval_until_a_grade === true
6250
+ || approvalSource.autopilotAfterApprovalUntilAGrade === true
6251
+ || !!approvalSource.autopilot_completion_contract
6252
+ || !!approvalSource.autopilotCompletionContract);
6253
+ if (!activeMicrotask && businessProofReadiness.ready && (approvedAutopilotUntilPr || prReadinessReady) && !pullRequestUrl) {
6254
+ return makeDecision('create_pr', 'Create PR', 'support_v5_business_proof_complete_create_a_grade_pr', {
6255
+ canRunAutonomously: true,
6256
+ canRunModel: false,
6257
+ canRunQa: false,
6258
+ canEditProductCode: false,
6259
+ lane: 'release',
6260
+ stepType: 'release_gate',
6261
+ primaryCommand: 'createSupportTicketCodexPullRequestManual',
6262
+ nextCommands: [
6263
+ 'create_pr',
6264
+ 'createSupportTicketCodexPullRequestManual',
6265
+ 'record_support_pr_readiness_contract',
6266
+ 'run_a_grade_pr_review',
6267
+ 'park_before_merge_release_or_customer_send'
6268
+ ],
6269
+ requiredEvidence: [
6270
+ 'AIQaBusinessAssertion pass',
6271
+ 'QA screenshot or trace artifact',
6272
+ 'changed files subset of owner_files',
6273
+ 'PR readiness contract',
6274
+ 'pull_request_url'
6275
+ ],
6276
+ forbiddenActions: [
6277
+ 'Do not merge the PR from this action.',
6278
+ 'Do not release, deploy, or send customer success reply from PR packaging alone.'
6279
+ ]
6280
+ });
6281
+ }
6282
+ if (!activeMicrotask && businessProofReadiness.ready && approvedAutopilotUntilPr && pullRequestUrl) {
6283
+ if (!prReviewReady) {
6284
+ if (prReviewContract.nextAction === 'run_business_proof_qa') {
6285
+ return makeDecision('run_business_proof_qa', 'Run Business Proof QA', 'support_v5_a_grade_review_requires_business_proof', {
6286
+ failureClass: prReviewContract.failureClass || 'business_proof',
6287
+ blockerFingerprint: prReviewContract.blockerFingerprint,
6288
+ evidenceHash: prReviewContract.evidenceHash,
6289
+ canRunAutonomously: true,
6290
+ canRunQa: true,
6291
+ canRunModel: false,
6292
+ canEditProductCode: false,
6293
+ lane: 'qa',
6294
+ stepType: 'business_proof',
6295
+ primaryCommand: 'run_support_v5_business_proof_qa_row',
6296
+ nextCommands: ['execute_issue_class_probe', 'record_before_action_after_artifacts', 'write_aiqa_business_assertion', 'rerun_support_a_grade_pr_review'],
6297
+ requiredEvidence: Array.from(new Set(__spreadArray([
6298
+ 'AIQaBusinessAssertion before/action/after proof',
6299
+ 'QA screenshot or trace artifact'
6300
+ ], __read(prReviewContract.evidenceRefs), false))),
6301
+ blockers: Array.from(new Set(__spreadArray(__spreadArray([], __read(prReviewContract.blockers), false), [
6302
+ prReviewContract.strictGateReason ? "strict_gate:".concat(prReviewContract.strictGateReason) : '',
6303
+ prReviewContract.blockerFingerprint ? "blocker_fingerprint:".concat(prReviewContract.blockerFingerprint) : ''
6304
+ ], false).filter(Boolean))),
6305
+ forbiddenActions: ['Do not merge, release, deploy, or send customer reply until A-grade PR review passes.']
6306
+ });
6307
+ }
6308
+ if (prReviewContract.nextAction === 'run_owner_scoped_repair') {
6309
+ return makeDecision('run_owner_scoped_repair', 'Run Owner-Scoped Repair', 'support_v5_a_grade_review_requires_owner_scoped_repair', {
6310
+ failureClass: prReviewContract.failureClass || 'grade_below_target',
6311
+ blockerFingerprint: prReviewContract.blockerFingerprint,
6312
+ evidenceHash: prReviewContract.evidenceHash,
6313
+ canRunAutonomously: true,
6314
+ canRunModel: true,
6315
+ canEditProductCode: true,
6316
+ lane: 'build',
6317
+ stepType: 'build_repair',
6318
+ primaryCommand: 'run_support_v5_owner_scoped_repair',
6319
+ nextCommands: ['repair_strict_gate_blocker_inside_owner_files', 'run_compile_preflight', 'run_business_proof_qa', 'rerun_support_a_grade_pr_review'],
6320
+ requiredEvidence: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(repairGate.ownerScopedRepairContract.requiredEvidenceBeforeRepair), false), __read(repairGate.ownerScopedRepairContract.requiredEvidenceAfterRepair), false), [
6321
+ 'A-grade PR review blocker resolved'
6322
+ ], false))),
6323
+ blockers: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(repairGate.ownerScopedRepairContract.blockers), false), __read(prReviewContract.blockers), false), [
6324
+ prReviewContract.strictGateReason ? "strict_gate:".concat(prReviewContract.strictGateReason) : '',
6325
+ prReviewContract.blockerFingerprint ? "blocker_fingerprint:".concat(prReviewContract.blockerFingerprint) : ''
6326
+ ], false).filter(Boolean))),
6327
+ forbiddenActions: Array.from(new Set(__spreadArray(__spreadArray([], __read(repairGate.ownerScopedRepairContract.forbiddenActions), false), [
6328
+ 'Do not edit outside owner_files unless diagnosis is revised with new evidence.',
6329
+ 'Do not merge, release, deploy, or send customer reply until A-grade PR review passes.'
6330
+ ], false)))
6331
+ });
6332
+ }
6333
+ return makeDecision('run_a_grade_pr_review', 'Run A-grade PR Review', 'support_v5_pr_exists_a_grade_review_required', {
6334
+ failureClass: prReviewContract.failureClass || 'pr_review_evidence_missing',
6335
+ blockerFingerprint: prReviewContract.blockerFingerprint,
6336
+ evidenceHash: prReviewContract.evidenceHash,
6337
+ canRunAutonomously: true,
6338
+ canRunModel: false,
6339
+ canRunQa: true,
6340
+ canEditProductCode: false,
6341
+ lane: 'release',
6342
+ stepType: 'release_gate',
6343
+ primaryCommand: 'run_support_a_grade_pr_review',
6344
+ nextCommands: [
6345
+ 'run_support_a_grade_pr_review',
6346
+ 'fetch_support_testing_status_for_pr_review',
6347
+ 'record_support_pr_review_contract',
6348
+ 'park_before_merge_release_or_customer_send'
6349
+ ],
6350
+ requiredEvidence: [
6351
+ 'pull_request_url',
6352
+ 'A-grade execution/artifacts/pull_request review',
6353
+ 'strict gate pass',
6354
+ 'AIQaBusinessAssertion before/action/after proof',
6355
+ 'QA screenshot or trace artifact'
6356
+ ],
6357
+ blockers: Array.from(new Set(__spreadArray(__spreadArray([], __read(prReviewContract.blockers), false), [
6358
+ prReviewContract.strictGateReason ? "strict_gate:".concat(prReviewContract.strictGateReason) : '',
6359
+ prReviewContract.blockerFingerprint ? "blocker_fingerprint:".concat(prReviewContract.blockerFingerprint) : '',
6360
+ 'A-grade PR review has not passed yet.'
6361
+ ], false).filter(Boolean))),
6362
+ forbiddenActions: [
6363
+ 'Do not merge the PR from this action.',
6364
+ 'Do not release, deploy, or send customer reply from PR review alone.',
6365
+ 'If strict review fails, route to the bounded blocker action instead of accepting from PR URL alone.'
6366
+ ]
6367
+ });
6368
+ }
6369
+ return makeDecision('park_manual', 'Review A-grade PR', 'support_v5_approved_autopilot_reached_a_grade_pr_review_required', {
6370
+ canRunAutonomously: false,
6371
+ canRunModel: false,
6372
+ canRunQa: false,
6373
+ canEditProductCode: false,
6374
+ lane: 'release',
6375
+ stepType: 'release_gate',
6376
+ primaryCommand: 'review_a_grade_pr_and_release_gate',
6377
+ nextCommands: [
6378
+ 'review_a_grade_pr_and_release_gate',
6379
+ 'approve_merge_release_or_customer_reply',
6380
+ 'park_before_merge_release_or_customer_send'
6381
+ ],
6382
+ requiredEvidence: [
6383
+ 'pull_request_url',
6384
+ 'A-grade execution/artifacts/pull_request review',
6385
+ 'strict gate pass',
6386
+ 'AIQaBusinessAssertion pass',
6387
+ 'QA screenshots or trace artifacts',
6388
+ 'human approval before merge/release/customer send'
6389
+ ],
6390
+ blockers: ['Approved autopilot reached PR proof; merge, release, deploy, and customer reply require separate human/release approval.'],
6391
+ forbiddenActions: [
6392
+ 'Do not merge the PR without human approval.',
6393
+ 'Do not release, deploy, or send customer reply from approved-autopilot completion alone.'
6394
+ ]
6395
+ });
6396
+ }
4471
6397
  if (!activeMicrotask && businessProofReadiness.ready) {
4472
6398
  return makeDecision('ready_for_release_gate', 'Run Release Gate', 'support_v5_business_proof_complete_release_gate_ready', {
4473
6399
  canRunAutonomously: true,
@@ -4486,9 +6412,10 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
4486
6412
  lane: (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'build',
4487
6413
  stepType: activeStepType || 'build_repair',
4488
6414
  primaryCommand: 'run_support_v5_owner_scoped_repair',
4489
- nextCommands: ['load_owner_files_only', 'apply_smallest_fix', 'run_smallest_compile_or_unit_gate', 'handoff_to_business_proof_qa'],
4490
- requiredEvidence: ['changed files within owner_files', 'compile/unit proof', 'next QA row'],
4491
- forbiddenActions: ['Do not edit outside owner_files unless diagnosis is revised with new evidence.']
6415
+ nextCommands: repairGate.ownerScopedRepairContract.nextCommands,
6416
+ requiredEvidence: Array.from(new Set(__spreadArray(__spreadArray([], __read(repairGate.ownerScopedRepairContract.requiredEvidenceBeforeRepair), false), __read(repairGate.ownerScopedRepairContract.requiredEvidenceAfterRepair), false))),
6417
+ blockers: repairGate.ownerScopedRepairContract.blockers,
6418
+ forbiddenActions: repairGate.ownerScopedRepairContract.forbiddenActions
4492
6419
  });
4493
6420
  }
4494
6421
  function buildResolveIOSupportV5DiagnoseFirstPrompt(lines) {
@@ -4744,7 +6671,7 @@ function buildResolveIOSupportV5MicrotaskPrompt(input) {
4744
6671
  };
4745
6672
  }
4746
6673
  function summarizeResolveIOSupportV5MicrotaskUsage(bundle) {
4747
- var e_11, _a, e_12, _b;
6674
+ var e_12, _a, e_13, _b;
4748
6675
  var byMicrotask = new Map();
4749
6676
  var bySection = new Map();
4750
6677
  var totalPromptTokenEstimate = 0;
@@ -4759,17 +6686,17 @@ function summarizeResolveIOSupportV5MicrotaskUsage(bundle) {
4759
6686
  existing.calls += 1;
4760
6687
  byMicrotask.set(usage.microtaskId, existing);
4761
6688
  try {
4762
- for (var _e = (e_12 = void 0, __values(usage.promptSections || [])), _f = _e.next(); !_f.done; _f = _e.next()) {
6689
+ for (var _e = (e_13 = void 0, __values(usage.promptSections || [])), _f = _e.next(); !_f.done; _f = _e.next()) {
4763
6690
  var section = _f.value;
4764
6691
  bySection.set(section.name, (bySection.get(section.name) || 0) + section.tokenEstimate);
4765
6692
  }
4766
6693
  }
4767
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
6694
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
4768
6695
  finally {
4769
6696
  try {
4770
6697
  if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
4771
6698
  }
4772
- finally { if (e_12) throw e_12.error; }
6699
+ finally { if (e_13) throw e_13.error; }
4773
6700
  }
4774
6701
  var hardCap = usage.lane === 'qa' ? promptBudget.qaMicrotaskHardCap : promptBudget.buildMicrotaskHardCap;
4775
6702
  if ((usage.promptTokenEstimate || 0) > hardCap) {
@@ -4777,12 +6704,12 @@ function summarizeResolveIOSupportV5MicrotaskUsage(bundle) {
4777
6704
  }
4778
6705
  }
4779
6706
  }
4780
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
6707
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
4781
6708
  finally {
4782
6709
  try {
4783
6710
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
4784
6711
  }
4785
- finally { if (e_11) throw e_11.error; }
6712
+ finally { if (e_12) throw e_12.error; }
4786
6713
  }
4787
6714
  return {
4788
6715
  totalPromptTokenEstimate: totalPromptTokenEstimate,