@resolveio/server-lib 22.3.162 → 22.3.163

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.
@@ -137,8 +137,142 @@ function pushEvent(events, event) {
137
137
  function eventDate(record) {
138
138
  return dateValue(record, ['recordedAt', 'createdAt', 'updatedAt', 'timestamp', 'time', 'date']);
139
139
  }
140
+ function normalizeManagerFailureRecord(value, fallback) {
141
+ if (fallback === void 0) { fallback = {}; }
142
+ var entry = plainObject(value);
143
+ if (!Object.keys(entry).length && !Object.keys(fallback).length) {
144
+ return undefined;
145
+ }
146
+ var blocker = cleanText(entry.blocker || entry.reason || entry.summary || entry.message || fallback.blocker || fallback.summary, 1200);
147
+ var failureClass = cleanText(entry.failureClass || entry.failure_class || entry.class || fallback.failureClass, 120);
148
+ var evidenceHash = cleanText(entry.evidenceHash || entry.evidence_hash || entry.hash || fallback.evidenceHash, 180);
149
+ var blockerFingerprint = cleanText(entry.blockerFingerprint || entry.blocker_fingerprint || fallback.blockerFingerprint, 180);
150
+ var lane = cleanText(entry.lane || fallback.lane || 'support', 80);
151
+ var stepType = cleanText(entry.stepType || entry.step_type || entry.type || fallback.stepType || 'support_step', 80);
152
+ var outcome = cleanText(entry.outcome || entry.status || entry.result || fallback.outcome || 'needs_repair', 80);
153
+ if (!blocker && !failureClass && !evidenceHash && !blockerFingerprint) {
154
+ return undefined;
155
+ }
156
+ return {
157
+ lane: lane,
158
+ stepType: stepType,
159
+ outcome: outcome,
160
+ failureClass: failureClass || undefined,
161
+ blocker: blocker || undefined,
162
+ summary: cleanText(entry.summary || entry.message || fallback.summary, 1200) || undefined,
163
+ blockerFingerprint: blockerFingerprint || undefined,
164
+ evidenceHash: evidenceHash || undefined,
165
+ changedFiles: cleanStringList(entry.changedFiles || entry.changed_files || fallback.changedFiles, 80, 500),
166
+ artifactPaths: cleanStringList(entry.artifactPaths || entry.artifact_paths || entry.artifacts || fallback.artifactPaths, 80, 500)
167
+ };
168
+ }
169
+ function supportManagerFailureRecords(job, evidence) {
170
+ var e_3, _a, e_4, _b;
171
+ var records = [];
172
+ var pushRecord = function (value, fallback) {
173
+ if (fallback === void 0) { fallback = {}; }
174
+ var record = normalizeManagerFailureRecord(value, fallback);
175
+ if (record) {
176
+ records.push(record);
177
+ }
178
+ };
179
+ try {
180
+ for (var _c = __values(asArray(job.supportV5StepHistory || job.support_v5_step_history || evidence.supportV5StepHistory || evidence.support_v5_step_history)), _d = _c.next(); !_d.done; _d = _c.next()) {
181
+ var entry = _d.value;
182
+ pushRecord(entry);
183
+ }
184
+ }
185
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
186
+ finally {
187
+ try {
188
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
189
+ }
190
+ finally { if (e_3) throw e_3.error; }
191
+ }
192
+ try {
193
+ for (var _e = __values(asArray(job.supportV5FailureFingerprints || job.support_v5_failure_fingerprints || evidence.supportV5FailureFingerprints || evidence.support_v5_failure_fingerprints)), _f = _e.next(); !_f.done; _f = _e.next()) {
194
+ var entry = _f.value;
195
+ var fingerprint = plainObject(entry);
196
+ var count = Math.max(1, Math.min(8, Number(fingerprint.count || fingerprint.repeatedCount || fingerprint.repeated_count || 1) || 1));
197
+ var fallback = {
198
+ lane: cleanText(fingerprint.lane || 'support', 80),
199
+ stepType: cleanText(fingerprint.stepType || fingerprint.step_type || 'support_step', 80),
200
+ outcome: cleanText(fingerprint.outcome || 'needs_repair', 80),
201
+ failureClass: cleanText(fingerprint.failureClass || fingerprint.failure_class || fingerprint.class, 120),
202
+ blocker: cleanText(fingerprint.blocker || fingerprint.reason || fingerprint.summary, 1200),
203
+ blockerFingerprint: cleanText(fingerprint.blockerFingerprint || fingerprint.blocker_fingerprint, 180),
204
+ evidenceHash: cleanText(fingerprint.evidenceHash || fingerprint.evidence_hash, 180)
205
+ };
206
+ for (var index = 0; index < count; index += 1) {
207
+ pushRecord(fingerprint, fallback);
208
+ }
209
+ }
210
+ }
211
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
212
+ finally {
213
+ try {
214
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
215
+ }
216
+ finally { if (e_4) throw e_4.error; }
217
+ }
218
+ var currentFailure = evidenceObject(job.supportV5CurrentFailure, job.support_v5_current_failure, job.supportV5RecoveryCurrent, job.support_v5_recovery_current, evidence.currentFailure, evidence.current_failure);
219
+ pushRecord(currentFailure);
220
+ return records.slice(-80);
221
+ }
222
+ function supportManagerNoBlindLoopGate(job, evidence, now) {
223
+ var _a;
224
+ var history = supportManagerFailureRecords(job, evidence);
225
+ if (!history.length) {
226
+ return undefined;
227
+ }
228
+ var budget = plainObject(job.supportV5Budget || job.support_v5_budget || evidence.supportV5Budget || evidence.support_v5_budget);
229
+ var maxSameFailureRepeats = Math.max(1, Number(budget.maxRepeatedNoProgress || budget.max_repeated_no_progress || budget.maxSameFailureRepeats || budget.max_same_failure_repeats || 3) || 3);
230
+ var decision = (0, ai_runner_manager_policy_1.decideResolveIOAIManagerPolicy)({
231
+ history: history,
232
+ maxSameFailureRepeats: maxSameFailureRepeats
233
+ });
234
+ var parksRun = /^(park_repeated_failure|park_ping_pong|manual_handoff)$/.test(decision.action);
235
+ var status = parksRun
236
+ ? 'blocked'
237
+ : decision.action === 'retry_infra'
238
+ ? 'warn'
239
+ : 'pass';
240
+ return {
241
+ key: 'manager_no_blind_loop_policy',
242
+ label: 'No-blind-loop manager policy',
243
+ status: status,
244
+ reason: decision.reason,
245
+ evidenceRefs: cleanStringList(decision.recoveryAction.requiredArtifacts, 20, 500),
246
+ recordedAt: isoNow(now),
247
+ metadata: {
248
+ action: decision.action,
249
+ failureClass: decision.failureClass,
250
+ blockerFingerprint: decision.blockerFingerprint,
251
+ evidenceHash: decision.evidenceHash,
252
+ sameFailureCount: decision.sameFailureCount,
253
+ pingPongCount: decision.pingPongCount,
254
+ newEvidence: decision.newEvidence,
255
+ materialEvidence: decision.materialEvidence,
256
+ evidenceStrength: decision.evidenceStrength,
257
+ evidenceSignals: decision.evidenceSignals,
258
+ loopBudgetShouldReset: decision.loopBudgetShouldReset,
259
+ productRepairFailure: decision.productRepairFailure,
260
+ recoveryClass: decision.recoveryPlan.recoveryClass,
261
+ allowedAction: decision.recoveryPlan.allowedAction,
262
+ dispatchAction: decision.recoveryAction.allowedDispatchAction,
263
+ evidenceOnly: decision.recoveryAction.evidenceOnly,
264
+ productRepairAllowed: decision.recoveryAction.productRepairAllowed,
265
+ expensiveModelAllowed: decision.recoveryAction.expensiveModelAllowed,
266
+ costCeilingUsd: decision.recoveryAction.costCeilingUsd,
267
+ requiresNewEvidence: ((_a = decision.recoveryAction.retryPolicy) === null || _a === void 0 ? void 0 : _a.requireNewEvidence) === true,
268
+ nextCommands: decision.recoveryAction.nextCommands,
269
+ requiredEvidence: decision.recoveryAction.requiredArtifacts,
270
+ forbiddenActions: decision.recoveryPlan.forbiddenActions
271
+ }
272
+ };
273
+ }
140
274
  function hotfixEvidenceCandidates() {
141
- var e_3, _a;
275
+ var e_5, _a;
142
276
  var sources = [];
143
277
  for (var _i = 0; _i < arguments.length; _i++) {
144
278
  sources[_i] = arguments[_i];
@@ -146,7 +280,7 @@ function hotfixEvidenceCandidates() {
146
280
  var result = [];
147
281
  var seen = new Set();
148
282
  var pushCandidate = function (value) {
149
- var e_4, _a, e_5, _b;
283
+ var e_6, _a, e_7, _b;
150
284
  var _c, _d;
151
285
  if (Array.isArray(value)) {
152
286
  try {
@@ -155,12 +289,12 @@ function hotfixEvidenceCandidates() {
155
289
  pushCandidate(entry);
156
290
  }
157
291
  }
158
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
292
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
159
293
  finally {
160
294
  try {
161
295
  if (value_1_1 && !value_1_1.done && (_a = value_1.return)) _a.call(value_1);
162
296
  }
163
- finally { if (e_4) throw e_4.error; }
297
+ finally { if (e_6) throw e_6.error; }
164
298
  }
165
299
  return;
166
300
  }
@@ -184,12 +318,12 @@ function hotfixEvidenceCandidates() {
184
318
  pushCandidate(nestedValue);
185
319
  }
186
320
  }
187
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
321
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
188
322
  finally {
189
323
  try {
190
324
  if (nestedValues_1_1 && !nestedValues_1_1.done && (_b = nestedValues_1.return)) _b.call(nestedValues_1);
191
325
  }
192
- finally { if (e_5) throw e_5.error; }
326
+ finally { if (e_7) throw e_7.error; }
193
327
  }
194
328
  return;
195
329
  }
@@ -214,12 +348,12 @@ function hotfixEvidenceCandidates() {
214
348
  pushCandidate(source);
215
349
  }
216
350
  }
217
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
351
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
218
352
  finally {
219
353
  try {
220
354
  if (sources_1_1 && !sources_1_1.done && (_a = sources_1.return)) _a.call(sources_1);
221
355
  }
222
- finally { if (e_3) throw e_3.error; }
356
+ finally { if (e_5) throw e_5.error; }
223
357
  }
224
358
  return result;
225
359
  }
@@ -310,7 +444,7 @@ function hotfixCommitProofGate(evidence, now) {
310
444
  };
311
445
  }
312
446
  function collectHotfixEvidenceEvents(sources, events, gates, now) {
313
- var e_6, _a;
447
+ var e_8, _a;
314
448
  var _b, _c;
315
449
  try {
316
450
  for (var _d = __values(hotfixEvidenceCandidates.apply(void 0, __spreadArray([], __read(sources), false))), _e = _d.next(); !_e.done; _e = _d.next()) {
@@ -357,16 +491,16 @@ function collectHotfixEvidenceEvents(sources, events, gates, now) {
357
491
  }
358
492
  }
359
493
  }
360
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
494
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
361
495
  finally {
362
496
  try {
363
497
  if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
364
498
  }
365
- finally { if (e_6) throw e_6.error; }
499
+ finally { if (e_8) throw e_8.error; }
366
500
  }
367
501
  }
368
502
  function collectUsageEvents(entries, events) {
369
- var e_7, _a;
503
+ var e_9, _a;
370
504
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
371
505
  if (!entries.length) {
372
506
  return undefined;
@@ -397,17 +531,17 @@ function collectUsageEvents(entries, events) {
397
531
  });
398
532
  }
399
533
  }
400
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
534
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
401
535
  finally {
402
536
  try {
403
537
  if (normalizedEntries_1_1 && !normalizedEntries_1_1.done && (_a = normalizedEntries_1.return)) _a.call(normalizedEntries_1);
404
538
  }
405
- finally { if (e_7) throw e_7.error; }
539
+ finally { if (e_9) throw e_9.error; }
406
540
  }
407
541
  return (0, ai_run_evidence_1.buildAIRunCost)(entries);
408
542
  }
409
543
  function collectCommitEvents(commits, events) {
410
- var e_8, _a;
544
+ var e_10, _a;
411
545
  try {
412
546
  for (var _b = __values(commits.slice(0, 80)), _c = _b.next(); !_c.done; _c = _b.next()) {
413
547
  var commit = _c.value;
@@ -423,12 +557,12 @@ function collectCommitEvents(commits, events) {
423
557
  });
424
558
  }
425
559
  }
426
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
560
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
427
561
  finally {
428
562
  try {
429
563
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
430
564
  }
431
- finally { if (e_8) throw e_8.error; }
565
+ finally { if (e_10) throw e_10.error; }
432
566
  }
433
567
  }
434
568
  function statusFromBoolean(value, fallback) {
@@ -441,7 +575,7 @@ function statusFromBoolean(value, fallback) {
441
575
  return fallback;
442
576
  }
443
577
  function collectArtifacts(evidence) {
444
- var e_9, _a, e_10, _b, e_11, _c;
578
+ var e_11, _a, e_12, _b, e_13, _c;
445
579
  var artifacts = [];
446
580
  try {
447
581
  for (var _d = __values(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.artifacts)), _e = _d.next(); !_e.done; _e = _d.next()) {
@@ -456,12 +590,12 @@ function collectArtifacts(evidence) {
456
590
  });
457
591
  }
458
592
  }
459
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
593
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
460
594
  finally {
461
595
  try {
462
596
  if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
463
597
  }
464
- finally { if (e_9) throw e_9.error; }
598
+ finally { if (e_11) throw e_11.error; }
465
599
  }
466
600
  var screenshots = asArray((evidence === null || evidence === void 0 ? void 0 : evidence.screenshots) || (evidence === null || evidence === void 0 ? void 0 : evidence.qaScreenshots) || (evidence === null || evidence === void 0 ? void 0 : evidence.browserScreenshots));
467
601
  try {
@@ -482,12 +616,12 @@ function collectArtifacts(evidence) {
482
616
  }
483
617
  }
484
618
  }
485
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
619
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
486
620
  finally {
487
621
  try {
488
622
  if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
489
623
  }
490
- finally { if (e_10) throw e_10.error; }
624
+ finally { if (e_12) throw e_12.error; }
491
625
  }
492
626
  var artifactRefs = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.artifactPaths)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.artifact_paths)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.runnerEvidenceArtifacts)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.runner_evidence_artifacts)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.supportQaArtifacts)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.support_qa_artifacts)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.qa_artifacts)), false);
493
627
  try {
@@ -508,17 +642,17 @@ function collectArtifacts(evidence) {
508
642
  }
509
643
  }
510
644
  }
511
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
645
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
512
646
  finally {
513
647
  try {
514
648
  if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
515
649
  }
516
- finally { if (e_11) throw e_11.error; }
650
+ finally { if (e_13) throw e_13.error; }
517
651
  }
518
652
  return artifacts;
519
653
  }
520
654
  function collectInfraChecks(evidence) {
521
- var e_12, _a;
655
+ var e_14, _a;
522
656
  var _b;
523
657
  var checks = [];
524
658
  try {
@@ -535,12 +669,12 @@ function collectInfraChecks(evidence) {
535
669
  });
536
670
  }
537
671
  }
538
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
672
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
539
673
  finally {
540
674
  try {
541
675
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
542
676
  }
543
- finally { if (e_12) throw e_12.error; }
677
+ finally { if (e_14) throw e_14.error; }
544
678
  }
545
679
  if (evidence === null || evidence === void 0 ? void 0 : evidence.preflightStatus) {
546
680
  checks.push({
@@ -573,7 +707,7 @@ function collectCompileResult(evidence) {
573
707
  };
574
708
  }
575
709
  function collectRouteProbes(evidence) {
576
- var e_13, _a, e_14, _b;
710
+ var e_15, _a, e_16, _b;
577
711
  var probes = [];
578
712
  var rows = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.routeProbes)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.route_probes)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.routes)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.browserRoutes)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.browser_routes)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.workflowProbes)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.workflow_probes)), false);
579
713
  var directProbe = plainObject((evidence === null || evidence === void 0 ? void 0 : evidence.routeProbe) || (evidence === null || evidence === void 0 ? void 0 : evidence.route_probe) || (evidence === null || evidence === void 0 ? void 0 : evidence.workflowProbe) || (evidence === null || evidence === void 0 ? void 0 : evidence.workflow_probe));
@@ -597,12 +731,12 @@ function collectRouteProbes(evidence) {
597
731
  });
598
732
  }
599
733
  }
600
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
734
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
601
735
  finally {
602
736
  try {
603
737
  if (rows_1_1 && !rows_1_1.done && (_a = rows_1.return)) _a.call(rows_1);
604
738
  }
605
- finally { if (e_13) throw e_13.error; }
739
+ finally { if (e_15) throw e_15.error; }
606
740
  }
607
741
  var screenshots = asArray((evidence === null || evidence === void 0 ? void 0 : evidence.screenshots) || (evidence === null || evidence === void 0 ? void 0 : evidence.qaScreenshots) || (evidence === null || evidence === void 0 ? void 0 : evidence.browserScreenshots));
608
742
  try {
@@ -624,17 +758,17 @@ function collectRouteProbes(evidence) {
624
758
  }
625
759
  }
626
760
  }
627
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
761
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
628
762
  finally {
629
763
  try {
630
764
  if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
631
765
  }
632
- finally { if (e_14) throw e_14.error; }
766
+ finally { if (e_16) throw e_16.error; }
633
767
  }
634
768
  return probes;
635
769
  }
636
770
  function collectBusinessAssertions(evidence) {
637
- var e_15, _a;
771
+ var e_17, _a;
638
772
  var assertions = [];
639
773
  var rows = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.businessAssertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.business_assertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.workflowAssertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.workflow_assertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.assertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.qaRows)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.qa_rows)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.rows)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.supportQaAssertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.support_qa_assertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.aiQaBusinessAssertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.ai_qa_business_assertions)), false);
640
774
  try {
@@ -657,12 +791,12 @@ function collectBusinessAssertions(evidence) {
657
791
  });
658
792
  }
659
793
  }
660
- catch (e_15_1) { e_15 = { error: e_15_1 }; }
794
+ catch (e_17_1) { e_17 = { error: e_17_1 }; }
661
795
  finally {
662
796
  try {
663
797
  if (rows_2_1 && !rows_2_1.done && (_a = rows_2.return)) _a.call(rows_2);
664
798
  }
665
- finally { if (e_15) throw e_15.error; }
799
+ finally { if (e_17) throw e_17.error; }
666
800
  }
667
801
  if (!assertions.length && (evidence === null || evidence === void 0 ? void 0 : evidence.qaRunOutcome) === 'business_assertion_passed') {
668
802
  assertions.push({
@@ -721,7 +855,7 @@ function businessAssertionPassed(assertion) {
721
855
  return /^(pass|passed|success|ok|done)$/i.test(cleanText(assertion.status, 40));
722
856
  }
723
857
  function supportAssertionMatchesDiagnosisProof(assertion, proofPlan) {
724
- var e_16, _a;
858
+ var e_18, _a;
725
859
  var metadata = assertion.metadata || {};
726
860
  if (metadata.diagnosisProofPlanMatched === true || metadata.proofPlanMatched === true || metadata.supportDiagnosisProof === true) {
727
861
  return true;
@@ -766,12 +900,12 @@ function supportAssertionMatchesDiagnosisProof(assertion, proofPlan) {
766
900
  }
767
901
  }
768
902
  }
769
- catch (e_16_1) { e_16 = { error: e_16_1 }; }
903
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
770
904
  finally {
771
905
  try {
772
906
  if (proofTokens_1_1 && !proofTokens_1_1.done && (_a = proofTokens_1.return)) _a.call(proofTokens_1);
773
907
  }
774
- finally { if (e_16) throw e_16.error; }
908
+ finally { if (e_18) throw e_18.error; }
775
909
  }
776
910
  return overlap >= Math.min(4, Math.max(3, Math.ceil(proofTokens.size * 0.45)));
777
911
  }
@@ -902,7 +1036,7 @@ function applySupportDiagnosisProofGate(qa, diagnosisGate, now) {
902
1036
  ], false) });
903
1037
  }
904
1038
  function evidenceObject() {
905
- var e_17, _a;
1039
+ var e_19, _a;
906
1040
  var values = [];
907
1041
  for (var _i = 0; _i < arguments.length; _i++) {
908
1042
  values[_i] = arguments[_i];
@@ -915,17 +1049,17 @@ function evidenceObject() {
915
1049
  }
916
1050
  }
917
1051
  }
918
- catch (e_17_1) { e_17 = { error: e_17_1 }; }
1052
+ catch (e_19_1) { e_19 = { error: e_19_1 }; }
919
1053
  finally {
920
1054
  try {
921
1055
  if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1);
922
1056
  }
923
- finally { if (e_17) throw e_17.error; }
1057
+ finally { if (e_19) throw e_19.error; }
924
1058
  }
925
1059
  return {};
926
1060
  }
927
1061
  function mergeEvidenceRecords() {
928
- var e_18, _a, e_19, _b;
1062
+ var e_20, _a, e_21, _b;
929
1063
  var values = [];
930
1064
  for (var _i = 0; _i < arguments.length; _i++) {
931
1065
  values[_i] = arguments[_i];
@@ -936,7 +1070,7 @@ function mergeEvidenceRecords() {
936
1070
  var value = values_2_1.value;
937
1071
  var source = plainObject(value);
938
1072
  try {
939
- for (var _c = (e_19 = void 0, __values(Object.entries(source))), _d = _c.next(); !_d.done; _d = _c.next()) {
1073
+ for (var _c = (e_21 = void 0, __values(Object.entries(source))), _d = _c.next(); !_d.done; _d = _c.next()) {
940
1074
  var _e = __read(_d.value, 2), key = _e[0], entry = _e[1];
941
1075
  if (entry === undefined || entry === null || entry === '') {
942
1076
  continue;
@@ -952,21 +1086,21 @@ function mergeEvidenceRecords() {
952
1086
  merged[key] = entry;
953
1087
  }
954
1088
  }
955
- catch (e_19_1) { e_19 = { error: e_19_1 }; }
1089
+ catch (e_21_1) { e_21 = { error: e_21_1 }; }
956
1090
  finally {
957
1091
  try {
958
1092
  if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
959
1093
  }
960
- finally { if (e_19) throw e_19.error; }
1094
+ finally { if (e_21) throw e_21.error; }
961
1095
  }
962
1096
  }
963
1097
  }
964
- catch (e_18_1) { e_18 = { error: e_18_1 }; }
1098
+ catch (e_20_1) { e_20 = { error: e_20_1 }; }
965
1099
  finally {
966
1100
  try {
967
1101
  if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2);
968
1102
  }
969
- finally { if (e_18) throw e_18.error; }
1103
+ finally { if (e_20) throw e_20.error; }
970
1104
  }
971
1105
  return merged;
972
1106
  }
@@ -1083,7 +1217,7 @@ function supportCustomerReplyPolicyGate(policy, now) {
1083
1217
  };
1084
1218
  }
1085
1219
  function firstNonEmptyText(values, max) {
1086
- var e_20, _a;
1220
+ var e_22, _a;
1087
1221
  if (max === void 0) { max = 1000; }
1088
1222
  try {
1089
1223
  for (var values_3 = __values(values), values_3_1 = values_3.next(); !values_3_1.done; values_3_1 = values_3.next()) {
@@ -1094,12 +1228,12 @@ function firstNonEmptyText(values, max) {
1094
1228
  }
1095
1229
  }
1096
1230
  }
1097
- catch (e_20_1) { e_20 = { error: e_20_1 }; }
1231
+ catch (e_22_1) { e_22 = { error: e_22_1 }; }
1098
1232
  finally {
1099
1233
  try {
1100
1234
  if (values_3_1 && !values_3_1.done && (_a = values_3.return)) _a.call(values_3);
1101
1235
  }
1102
- finally { if (e_20) throw e_20.error; }
1236
+ finally { if (e_22) throw e_22.error; }
1103
1237
  }
1104
1238
  return undefined;
1105
1239
  }
@@ -1334,7 +1468,7 @@ function assistantDateWindowObject(quality) {
1334
1468
  return Object.keys(dateWindow).length ? dateWindow : nestedWindow;
1335
1469
  }
1336
1470
  function collectMongoProjectionObjects(value, result) {
1337
- var e_21, _a;
1471
+ var e_23, _a;
1338
1472
  if (result === void 0) { result = []; }
1339
1473
  if (!value || typeof value !== 'object') {
1340
1474
  return result;
@@ -1346,12 +1480,12 @@ function collectMongoProjectionObjects(value, result) {
1346
1480
  collectMongoProjectionObjects(entry, result);
1347
1481
  }
1348
1482
  }
1349
- catch (e_21_1) { e_21 = { error: e_21_1 }; }
1483
+ catch (e_23_1) { e_23 = { error: e_23_1 }; }
1350
1484
  finally {
1351
1485
  try {
1352
1486
  if (value_2_1 && !value_2_1.done && (_a = value_2.return)) _a.call(value_2);
1353
1487
  }
1354
- finally { if (e_21) throw e_21.error; }
1488
+ finally { if (e_23) throw e_23.error; }
1355
1489
  }
1356
1490
  return result;
1357
1491
  }
@@ -1592,8 +1726,8 @@ function applyAssistantAnswerQualityGate(qa, decision, now) {
1592
1726
  ], false) });
1593
1727
  }
1594
1728
  function buildSupportAIRunFromEvidence(input) {
1595
- var e_22, _a, e_23, _b;
1596
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1729
+ var e_24, _a, e_25, _b;
1730
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
1597
1731
  var ticket = input.ticket || {};
1598
1732
  var job = input.job || {};
1599
1733
  var evidence = buildSupportQaEvidence(input);
@@ -1605,8 +1739,8 @@ function buildSupportAIRunFromEvidence(input) {
1605
1739
  addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
1606
1740
  addSourceId(sourceIds, 'buildPlanId', job.buildPlanId || ticket.buildPlanId);
1607
1741
  try {
1608
- for (var _s = __values(asArray(input.taskEvents)), _t = _s.next(); !_t.done; _t = _s.next()) {
1609
- var event_1 = _t.value;
1742
+ for (var _2 = __values(asArray(input.taskEvents)), _3 = _2.next(); !_3.done; _3 = _2.next()) {
1743
+ var event_1 = _3.value;
1610
1744
  pushEvent(events, {
1611
1745
  type: event_1.type === 'human_intervention' ? 'human_intervention' : 'log',
1612
1746
  category: cleanText(event_1.category || event_1.phase || event_1.type, 160),
@@ -1620,16 +1754,16 @@ function buildSupportAIRunFromEvidence(input) {
1620
1754
  });
1621
1755
  }
1622
1756
  }
1623
- catch (e_22_1) { e_22 = { error: e_22_1 }; }
1757
+ catch (e_24_1) { e_24 = { error: e_24_1 }; }
1624
1758
  finally {
1625
1759
  try {
1626
- if (_t && !_t.done && (_a = _s.return)) _a.call(_s);
1760
+ if (_3 && !_3.done && (_a = _2.return)) _a.call(_2);
1627
1761
  }
1628
- finally { if (e_22) throw e_22.error; }
1762
+ finally { if (e_24) throw e_24.error; }
1629
1763
  }
1630
1764
  try {
1631
- for (var _u = __values(asArray(input.aiJobs)), _v = _u.next(); !_v.done; _v = _u.next()) {
1632
- var aiJob = _v.value;
1765
+ for (var _4 = __values(asArray(input.aiJobs)), _5 = _4.next(); !_5.done; _5 = _4.next()) {
1766
+ var aiJob = _5.value;
1633
1767
  pushEvent(events, {
1634
1768
  type: aiJob.model ? 'model_call' : 'log',
1635
1769
  category: cleanText(aiJob.category || aiJob.phase || aiJob.runner, 160),
@@ -1644,15 +1778,27 @@ function buildSupportAIRunFromEvidence(input) {
1644
1778
  });
1645
1779
  }
1646
1780
  }
1647
- catch (e_23_1) { e_23 = { error: e_23_1 }; }
1781
+ catch (e_25_1) { e_25 = { error: e_25_1 }; }
1648
1782
  finally {
1649
1783
  try {
1650
- if (_v && !_v.done && (_b = _u.return)) _b.call(_u);
1784
+ if (_5 && !_5.done && (_b = _4.return)) _b.call(_4);
1651
1785
  }
1652
- finally { if (e_23) throw e_23.error; }
1786
+ finally { if (e_25) throw e_25.error; }
1653
1787
  }
1654
1788
  collectCommitEvents(asArray(input.commits), events);
1655
1789
  collectHotfixEvidenceEvents([job, ticket, evidence, input.qaEvidence], events, gates, input.now);
1790
+ var noBlindLoopGate = supportManagerNoBlindLoopGate(job, evidence, input.now);
1791
+ if (noBlindLoopGate) {
1792
+ gates.push(noBlindLoopGate);
1793
+ pushEvent(events, {
1794
+ type: 'log',
1795
+ category: 'manager_no_blind_loop_policy',
1796
+ message: noBlindLoopGate.reason,
1797
+ artifactPaths: noBlindLoopGate.evidenceRefs,
1798
+ recordedAt: noBlindLoopGate.recordedAt,
1799
+ metadata: noBlindLoopGate.metadata
1800
+ });
1801
+ }
1656
1802
  var businessProofReadiness = plainObject(evidence.businessProofReadiness || evidence.business_proof_readiness);
1657
1803
  var businessProofReadinessGate = supportBusinessProofReadinessGate(businessProofReadiness, input.now);
1658
1804
  if (businessProofReadinessGate) {
@@ -1736,20 +1882,33 @@ function buildSupportAIRunFromEvidence(input) {
1736
1882
  metadata: {
1737
1883
  versionCount: asArray(input.versions).length,
1738
1884
  buildPlanCount: asArray(input.buildPlans).length,
1885
+ managerNoBlindLoopPolicy: noBlindLoopGate ? {
1886
+ action: cleanText((_e = noBlindLoopGate.metadata) === null || _e === void 0 ? void 0 : _e.action, 120),
1887
+ status: noBlindLoopGate.status,
1888
+ failureClass: cleanText((_f = noBlindLoopGate.metadata) === null || _f === void 0 ? void 0 : _f.failureClass, 120),
1889
+ sameFailureCount: Number(((_g = noBlindLoopGate.metadata) === null || _g === void 0 ? void 0 : _g.sameFailureCount) || 0),
1890
+ pingPongCount: Number(((_h = noBlindLoopGate.metadata) === null || _h === void 0 ? void 0 : _h.pingPongCount) || 0),
1891
+ newEvidence: ((_j = noBlindLoopGate.metadata) === null || _j === void 0 ? void 0 : _j.newEvidence) === true,
1892
+ materialEvidence: ((_k = noBlindLoopGate.metadata) === null || _k === void 0 ? void 0 : _k.materialEvidence) === true,
1893
+ evidenceStrength: cleanText((_l = noBlindLoopGate.metadata) === null || _l === void 0 ? void 0 : _l.evidenceStrength, 120),
1894
+ loopBudgetShouldReset: ((_m = noBlindLoopGate.metadata) === null || _m === void 0 ? void 0 : _m.loopBudgetShouldReset) === true,
1895
+ dispatchAction: cleanText((_o = noBlindLoopGate.metadata) === null || _o === void 0 ? void 0 : _o.dispatchAction, 160),
1896
+ requiresNewEvidence: ((_p = noBlindLoopGate.metadata) === null || _p === void 0 ? void 0 : _p.requiresNewEvidence) === true
1897
+ } : undefined,
1739
1898
  rootCauseEntryContract: Object.keys(rootCauseEntryContract).length ? {
1740
1899
  contractId: cleanText(rootCauseEntryContract.contract_id || rootCauseEntryContract.contractId, 160),
1741
1900
  version: cleanText(rootCauseEntryContract.version, 120),
1742
1901
  status: cleanText(rootCauseEntryContract.status, 120),
1743
1902
  issueClassProbeCount: asArray(rootCauseEntryContract.issue_class_probes || rootCauseEntryContract.issueClassProbes).length,
1744
- ownerFileMax: Number(((_e = rootCauseEntryContract.owner_file_policy) === null || _e === void 0 ? void 0 : _e.max_files) || ((_f = rootCauseEntryContract.ownerFilePolicy) === null || _f === void 0 ? void 0 : _f.maxFiles) || 0) || 0,
1745
- requiresBusinessAssertion: ((_g = rootCauseEntryContract.business_proof_policy) === null || _g === void 0 ? void 0 : _g.requires_aiqa_business_assertion) === true
1746
- || ((_h = rootCauseEntryContract.businessProofPolicy) === null || _h === void 0 ? void 0 : _h.requiresAiqaBusinessAssertion) === true
1903
+ ownerFileMax: Number(((_q = rootCauseEntryContract.owner_file_policy) === null || _q === void 0 ? void 0 : _q.max_files) || ((_r = rootCauseEntryContract.ownerFilePolicy) === null || _r === void 0 ? void 0 : _r.maxFiles) || 0) || 0,
1904
+ requiresBusinessAssertion: ((_s = rootCauseEntryContract.business_proof_policy) === null || _s === void 0 ? void 0 : _s.requires_aiqa_business_assertion) === true
1905
+ || ((_t = rootCauseEntryContract.businessProofPolicy) === null || _t === void 0 ? void 0 : _t.requiresAiqaBusinessAssertion) === true
1747
1906
  } : undefined,
1748
1907
  diagnosis: Object.keys(diagnosisGate).length ? {
1749
1908
  status: cleanText(diagnosisGate.status, 80),
1750
1909
  issueClass: diagnosisIssueClass,
1751
1910
  ownerFiles: diagnosisOwnerFiles,
1752
- acceptedHypothesis: cleanText(((_j = diagnosisGate.accepted_hypothesis) === null || _j === void 0 ? void 0 : _j.statement) || ((_k = diagnosisGate.acceptedHypothesis) === null || _k === void 0 ? void 0 : _k.statement), 1000),
1911
+ acceptedHypothesis: cleanText(((_u = diagnosisGate.accepted_hypothesis) === null || _u === void 0 ? void 0 : _u.statement) || ((_v = diagnosisGate.acceptedHypothesis) === null || _v === void 0 ? void 0 : _v.statement), 1000),
1753
1912
  proofPlan: diagnosisGate.proof_plan || diagnosisGate.proofPlan
1754
1913
  } : undefined,
1755
1914
  businessProofReadiness: Object.keys(businessProofReadiness).length ? {
@@ -1764,18 +1923,18 @@ function buildSupportAIRunFromEvidence(input) {
1764
1923
  canDraftCustomerReply: customerReplyPolicy.canDraftCustomerReply === true || customerReplyPolicy.can_draft_customer_reply === true,
1765
1924
  canSendCustomerReply: customerReplyPolicy.canSendCustomerReply === true || customerReplyPolicy.can_send_customer_reply === true,
1766
1925
  reason: cleanText(customerReplyPolicy.reason, 1000),
1767
- reviewType: cleanText(((_l = customerReplyPolicy.humanReviewPacket) === null || _l === void 0 ? void 0 : _l.reviewType)
1768
- || ((_m = customerReplyPolicy.human_review_packet) === null || _m === void 0 ? void 0 : _m.review_type)
1769
- || ((_o = customerReplyPolicy.human_review_packet) === null || _o === void 0 ? void 0 : _o.reviewType), 160),
1770
- primaryAction: cleanText(((_p = customerReplyPolicy.humanReviewPacket) === null || _p === void 0 ? void 0 : _p.primaryAction)
1771
- || ((_q = customerReplyPolicy.human_review_packet) === null || _q === void 0 ? void 0 : _q.primary_action)
1772
- || ((_r = customerReplyPolicy.human_review_packet) === null || _r === void 0 ? void 0 : _r.primaryAction), 160)
1926
+ reviewType: cleanText(((_w = customerReplyPolicy.humanReviewPacket) === null || _w === void 0 ? void 0 : _w.reviewType)
1927
+ || ((_x = customerReplyPolicy.human_review_packet) === null || _x === void 0 ? void 0 : _x.review_type)
1928
+ || ((_y = customerReplyPolicy.human_review_packet) === null || _y === void 0 ? void 0 : _y.reviewType), 160),
1929
+ primaryAction: cleanText(((_z = customerReplyPolicy.humanReviewPacket) === null || _z === void 0 ? void 0 : _z.primaryAction)
1930
+ || ((_0 = customerReplyPolicy.human_review_packet) === null || _0 === void 0 ? void 0 : _0.primary_action)
1931
+ || ((_1 = customerReplyPolicy.human_review_packet) === null || _1 === void 0 ? void 0 : _1.primaryAction), 160)
1773
1932
  } : undefined
1774
1933
  }
1775
1934
  });
1776
1935
  }
1777
1936
  function buildAICoderAIRunFromEvidence(input) {
1778
- var e_24, _a;
1937
+ var e_26, _a;
1779
1938
  var _b, _c, _d, _e, _f, _g, _h;
1780
1939
  var app = input.app || {};
1781
1940
  var job = input.job || {};
@@ -1803,12 +1962,12 @@ function buildAICoderAIRunFromEvidence(input) {
1803
1962
  });
1804
1963
  }
1805
1964
  }
1806
- catch (e_24_1) { e_24 = { error: e_24_1 }; }
1965
+ catch (e_26_1) { e_26 = { error: e_26_1 }; }
1807
1966
  finally {
1808
1967
  try {
1809
1968
  if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
1810
1969
  }
1811
- finally { if (e_24) throw e_24.error; }
1970
+ finally { if (e_26) throw e_26.error; }
1812
1971
  }
1813
1972
  collectCommitEvents(asArray(input.commits), events);
1814
1973
  collectHotfixEvidenceEvents([job, app, evidence, input.qaEvidence], events, gates, input.now);
@@ -1911,7 +2070,7 @@ function buildAICoderAIRunFromEvidence(input) {
1911
2070
  });
1912
2071
  }
1913
2072
  function buildAssistantAIRunFromEvidence(input) {
1914
- var e_25, _a, e_26, _b, e_27, _c;
2073
+ var e_27, _a, e_28, _b, e_29, _c;
1915
2074
  var _d, _e, _f, _g;
1916
2075
  var conversation = input.conversation || {};
1917
2076
  var events = [];
@@ -1937,12 +2096,12 @@ function buildAssistantAIRunFromEvidence(input) {
1937
2096
  });
1938
2097
  }
1939
2098
  }
1940
- catch (e_25_1) { e_25 = { error: e_25_1 }; }
2099
+ catch (e_27_1) { e_27 = { error: e_27_1 }; }
1941
2100
  finally {
1942
2101
  try {
1943
2102
  if (_j && !_j.done && (_a = _h.return)) _a.call(_h);
1944
2103
  }
1945
- finally { if (e_25) throw e_25.error; }
2104
+ finally { if (e_27) throw e_27.error; }
1946
2105
  }
1947
2106
  try {
1948
2107
  for (var _k = __values(asArray(input.issueReports)), _l = _k.next(); !_l.done; _l = _k.next()) {
@@ -1960,12 +2119,12 @@ function buildAssistantAIRunFromEvidence(input) {
1960
2119
  });
1961
2120
  }
1962
2121
  }
1963
- catch (e_26_1) { e_26 = { error: e_26_1 }; }
2122
+ catch (e_28_1) { e_28 = { error: e_28_1 }; }
1964
2123
  finally {
1965
2124
  try {
1966
2125
  if (_l && !_l.done && (_b = _k.return)) _b.call(_k);
1967
2126
  }
1968
- finally { if (e_26) throw e_26.error; }
2127
+ finally { if (e_28) throw e_28.error; }
1969
2128
  }
1970
2129
  var cost = collectUsageEvents(asArray(input.usageLedger), events);
1971
2130
  var answerQuality = assistantQualityObject(input);
@@ -1997,12 +2156,12 @@ function buildAssistantAIRunFromEvidence(input) {
1997
2156
  });
1998
2157
  }
1999
2158
  }
2000
- catch (e_27_1) { e_27 = { error: e_27_1 }; }
2159
+ catch (e_29_1) { e_29 = { error: e_29_1 }; }
2001
2160
  finally {
2002
2161
  try {
2003
2162
  if (_o && !_o.done && (_c = _m.return)) _c.call(_m);
2004
2163
  }
2005
- finally { if (e_27) throw e_27.error; }
2164
+ finally { if (e_29) throw e_29.error; }
2006
2165
  }
2007
2166
  var answerQualityDecision = evaluateAssistantAnswerQuality({
2008
2167
  answerQuality: answerQuality,