@resolveio/server-lib 22.3.199 → 22.3.201

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.
@@ -353,6 +353,7 @@ function addGateOnce(gates, gate) {
353
353
  }
354
354
  function classifyAIRunOutcome(input) {
355
355
  var e_4, _a;
356
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
356
357
  if (input === void 0) { input = {}; }
357
358
  var now = isoNow(input.now);
358
359
  var gates = Array.isArray(input.gates) ? __spreadArray([], __read(input.gates), false) : [];
@@ -360,19 +361,91 @@ function classifyAIRunOutcome(input) {
360
361
  var qa = normalizeQaRun(input.qa);
361
362
  if (qa) {
362
363
  try {
363
- for (var _b = __values(qa.gateResults), _c = _b.next(); !_c.done; _c = _b.next()) {
364
- var gate = _c.value;
364
+ for (var _z = __values(qa.gateResults), _0 = _z.next(); !_0.done; _0 = _z.next()) {
365
+ var gate = _0.value;
365
366
  addGateOnce(gates, gate);
366
367
  }
367
368
  }
368
369
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
369
370
  finally {
370
371
  try {
371
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
372
+ if (_0 && !_0.done && (_a = _z.return)) _a.call(_z);
372
373
  }
373
374
  finally { if (e_4) throw e_4.error; }
374
375
  }
375
376
  }
377
+ var supportParkedByStatus = input.source === 'support_ticket'
378
+ && (input.manualHandoff === true || input.stopped === true || /stop|stopped|cancel|cancelled|paused|handoff/i.test("".concat(input.status || '', " ").concat(input.phase || '')));
379
+ if (supportParkedByStatus) {
380
+ var blockedSupportAutoloopNoProgressGate_1 = gates.find(function (gate) { return gate.key === 'support_autoloop_no_progress' && gate.status === 'blocked'; });
381
+ if (blockedSupportAutoloopNoProgressGate_1) {
382
+ return {
383
+ outcome: 'manual_handoff',
384
+ reason: "Support autoloop parked before another repair loop because no new evidence was recorded: ".concat(blockedSupportAutoloopNoProgressGate_1.reason),
385
+ nextAction: 'Collect new material evidence, rerun read-only diagnosis or issue-class proof, then resume only if the blocker fingerprint changes.',
386
+ gates: gates,
387
+ warnings: warnings,
388
+ recordedAt: now
389
+ };
390
+ }
391
+ var blockedSupportAutoloopApprovalGate_1 = gates.find(function (gate) { return gate.key === 'support_autoloop_approval_block' && gate.status === 'blocked'; });
392
+ if (blockedSupportAutoloopApprovalGate_1) {
393
+ var nextAction = cleanText((_b = blockedSupportAutoloopApprovalGate_1.metadata) === null || _b === void 0 ? void 0 : _b.nextAction, 160)
394
+ || cleanText((_c = blockedSupportAutoloopApprovalGate_1.metadata) === null || _c === void 0 ? void 0 : _c.action, 160);
395
+ var elapsedReapproval = ((_d = blockedSupportAutoloopApprovalGate_1.metadata) === null || _d === void 0 ? void 0 : _d.requiresElapsedReapproval) === true;
396
+ return {
397
+ outcome: 'manual_handoff',
398
+ reason: "Support autoloop parked before another repair loop because approval/scope is blocked: ".concat(blockedSupportAutoloopApprovalGate_1.reason),
399
+ nextAction: elapsedReapproval
400
+ ? 'Approve continued runtime beyond the current wall-clock boundary or park the ticket for manual review; do not run another model/code/QA continuation until that decision is recorded.'
401
+ : nextAction
402
+ ? "Run ".concat(nextAction, " or revise the blocked scope, then resume the approved autoloop toward A-grade QA/business proof.")
403
+ : 'Approve the blocked support autonomy scope or revise the diagnosis, owner files, planned change, estimate, or classification before the autoloop continues.',
404
+ gates: gates,
405
+ warnings: warnings,
406
+ recordedAt: now
407
+ };
408
+ }
409
+ var blockedSupportAutonomyApprovalGate_1 = gates.find(function (gate) { return gate.key === 'support_autonomy_approval' && gate.status === 'blocked'; });
410
+ if (blockedSupportAutonomyApprovalGate_1) {
411
+ return {
412
+ outcome: 'manual_handoff',
413
+ reason: "Support autonomy is waiting on operator approval or revised intake/diagnosis scope: ".concat(blockedSupportAutonomyApprovalGate_1.reason),
414
+ nextAction: ((_e = blockedSupportAutonomyApprovalGate_1.metadata) === null || _e === void 0 ? void 0 : _e.approvalAction)
415
+ ? "Use ".concat(blockedSupportAutonomyApprovalGate_1.metadata.approvalAction, " or revise the blocked scope, then allow the runner to continue until A-grade QA/business proof.")
416
+ : 'Approve the bounded support autonomy request or revise classification, estimate, owner files, or diagnosis scope before product-code repair.',
417
+ gates: gates,
418
+ warnings: warnings,
419
+ recordedAt: now
420
+ };
421
+ }
422
+ var blockedSupportProductRepairDispatchGate_1 = gates.find(function (gate) { return gate.key === 'support_product_repair_dispatch_guard' && gate.status === 'blocked'; });
423
+ if (blockedSupportProductRepairDispatchGate_1) {
424
+ return {
425
+ outcome: 'manual_handoff',
426
+ reason: "Support product-code repair dispatch is blocked by the approval/scope guard: ".concat(blockedSupportProductRepairDispatchGate_1.reason),
427
+ nextAction: ((_f = blockedSupportProductRepairDispatchGate_1.metadata) === null || _f === void 0 ? void 0 : _f.nextAction)
428
+ ? "Run ".concat(blockedSupportProductRepairDispatchGate_1.metadata.nextAction, " before product-code repair continues.")
429
+ : 'Approve the current support autonomy scope or revise the diagnosis/owner-file set before product-code repair continues.',
430
+ gates: gates,
431
+ warnings: warnings,
432
+ recordedAt: now
433
+ };
434
+ }
435
+ var blockedSupportHumanDecisionGate_1 = gates.find(function (gate) { return gate.key === 'support_human_decision_request' && gate.status === 'blocked'; });
436
+ if (blockedSupportHumanDecisionGate_1) {
437
+ return {
438
+ outcome: 'manual_handoff',
439
+ reason: "Support run is waiting on a specific operator decision: ".concat(blockedSupportHumanDecisionGate_1.reason),
440
+ nextAction: ((_g = blockedSupportHumanDecisionGate_1.metadata) === null || _g === void 0 ? void 0 : _g.preferredChoiceId)
441
+ ? "Choose ".concat(blockedSupportHumanDecisionGate_1.metadata.preferredChoiceId, " or an equivalent safe console action, then resume the runner.")
442
+ : 'Answer the requested support runner decision, then resume the runner.',
443
+ gates: gates,
444
+ warnings: warnings,
445
+ recordedAt: now
446
+ };
447
+ }
448
+ }
376
449
  if (input.manualHandoff === true) {
377
450
  return {
378
451
  outcome: 'manual_handoff',
@@ -425,6 +498,17 @@ function classifyAIRunOutcome(input) {
425
498
  recordedAt: now
426
499
  };
427
500
  }
501
+ var blockedSupportAutoloopNoProgressGate = gates.find(function (gate) { return gate.key === 'support_autoloop_no_progress' && gate.status === 'blocked'; });
502
+ if (input.source === 'support_ticket' && blockedSupportAutoloopNoProgressGate) {
503
+ return {
504
+ outcome: 'manual_handoff',
505
+ reason: "Support autoloop parked before another repair loop because no new evidence was recorded: ".concat(blockedSupportAutoloopNoProgressGate.reason),
506
+ nextAction: 'Collect new material evidence, rerun read-only diagnosis or issue-class proof, then resume only if the blocker fingerprint changes.',
507
+ gates: gates,
508
+ warnings: warnings,
509
+ recordedAt: now
510
+ };
511
+ }
428
512
  var blockedSupportDiagnosisBeforeRepairGate = gates.find(function (gate) { return gate.key === 'support_diagnosis_before_repair' && gate.status === 'blocked'; });
429
513
  if (blockedSupportDiagnosisBeforeRepairGate) {
430
514
  return {
@@ -447,6 +531,110 @@ function classifyAIRunOutcome(input) {
447
531
  recordedAt: now
448
532
  };
449
533
  }
534
+ var blockedSupportIntakeRevisionGate = gates.find(function (gate) { return gate.key === 'support_intake_revision_contract' && gate.status === 'blocked'; });
535
+ if (input.source === 'support_ticket' && blockedSupportIntakeRevisionGate) {
536
+ var requiredOperatorAction = cleanText((_h = blockedSupportIntakeRevisionGate.metadata) === null || _h === void 0 ? void 0 : _h.requiredOperatorAction, 160);
537
+ return {
538
+ outcome: 'manual_handoff',
539
+ reason: "Support intake/classification changed after approval: ".concat(blockedSupportIntakeRevisionGate.reason),
540
+ nextAction: requiredOperatorAction
541
+ ? "Run ".concat(requiredOperatorAction, " to approve the revised intake/scope before product-code repair continues.")
542
+ : 'Approve the revised support intake/scope before product-code repair continues.',
543
+ gates: gates,
544
+ warnings: warnings,
545
+ recordedAt: now
546
+ };
547
+ }
548
+ var blockedSupportAutoloopApprovalGate = gates.find(function (gate) { return gate.key === 'support_autoloop_approval_block' && gate.status === 'blocked'; });
549
+ if (input.source === 'support_ticket' && blockedSupportAutoloopApprovalGate) {
550
+ var nextAction = cleanText((_j = blockedSupportAutoloopApprovalGate.metadata) === null || _j === void 0 ? void 0 : _j.nextAction, 160)
551
+ || cleanText((_k = blockedSupportAutoloopApprovalGate.metadata) === null || _k === void 0 ? void 0 : _k.action, 160);
552
+ var elapsedReapproval = ((_l = blockedSupportAutoloopApprovalGate.metadata) === null || _l === void 0 ? void 0 : _l.requiresElapsedReapproval) === true;
553
+ return {
554
+ outcome: 'manual_handoff',
555
+ reason: "Support autoloop parked before another repair loop because approval/scope is blocked: ".concat(blockedSupportAutoloopApprovalGate.reason),
556
+ nextAction: elapsedReapproval
557
+ ? 'Approve continued runtime beyond the current wall-clock boundary or park the ticket for manual review; do not run another model/code/QA continuation until that decision is recorded.'
558
+ : nextAction
559
+ ? "Run ".concat(nextAction, " or revise the blocked scope, then resume the approved autoloop toward A-grade QA/business proof.")
560
+ : 'Approve the blocked support autonomy scope or revise the diagnosis, owner files, planned change, estimate, or classification before the autoloop continues.',
561
+ gates: gates,
562
+ warnings: warnings,
563
+ recordedAt: now
564
+ };
565
+ }
566
+ var blockedSupportAutonomyApprovalGate = gates.find(function (gate) { return gate.key === 'support_autonomy_approval' && gate.status === 'blocked'; });
567
+ if (input.source === 'support_ticket' && blockedSupportAutonomyApprovalGate) {
568
+ return {
569
+ outcome: 'manual_handoff',
570
+ reason: "Support autonomy is waiting on operator approval or revised intake/diagnosis scope: ".concat(blockedSupportAutonomyApprovalGate.reason),
571
+ nextAction: ((_m = blockedSupportAutonomyApprovalGate.metadata) === null || _m === void 0 ? void 0 : _m.approvalAction)
572
+ ? "Use ".concat(blockedSupportAutonomyApprovalGate.metadata.approvalAction, " or revise the blocked scope, then allow the runner to continue until A-grade QA/business proof.")
573
+ : 'Approve the bounded support autonomy request or revise classification, estimate, owner files, or diagnosis scope before product-code repair.',
574
+ gates: gates,
575
+ warnings: warnings,
576
+ recordedAt: now
577
+ };
578
+ }
579
+ var blockedSupportProductRepairDispatchGate = gates.find(function (gate) { return gate.key === 'support_product_repair_dispatch_guard' && gate.status === 'blocked'; });
580
+ if (input.source === 'support_ticket' && blockedSupportProductRepairDispatchGate) {
581
+ return {
582
+ outcome: 'manual_handoff',
583
+ reason: "Support product-code repair dispatch is blocked by the approval/scope guard: ".concat(blockedSupportProductRepairDispatchGate.reason),
584
+ nextAction: ((_o = blockedSupportProductRepairDispatchGate.metadata) === null || _o === void 0 ? void 0 : _o.nextAction)
585
+ ? "Run ".concat(blockedSupportProductRepairDispatchGate.metadata.nextAction, " before product-code repair continues.")
586
+ : 'Approve the current support autonomy scope or revise the diagnosis/owner-file set before product-code repair continues.',
587
+ gates: gates,
588
+ warnings: warnings,
589
+ recordedAt: now
590
+ };
591
+ }
592
+ var blockedSupportHumanDecisionGate = gates.find(function (gate) { return gate.key === 'support_human_decision_request' && gate.status === 'blocked'; });
593
+ if (input.source === 'support_ticket' && blockedSupportHumanDecisionGate) {
594
+ return {
595
+ outcome: 'manual_handoff',
596
+ reason: "Support run is waiting on a specific operator decision: ".concat(blockedSupportHumanDecisionGate.reason),
597
+ nextAction: ((_p = blockedSupportHumanDecisionGate.metadata) === null || _p === void 0 ? void 0 : _p.preferredChoiceId)
598
+ ? "Choose ".concat(blockedSupportHumanDecisionGate.metadata.preferredChoiceId, " or an equivalent safe console action, then resume the runner.")
599
+ : 'Answer the requested support runner decision, then resume the runner.',
600
+ gates: gates,
601
+ warnings: warnings,
602
+ recordedAt: now
603
+ };
604
+ }
605
+ var blockedSupportPostApprovalResumeAttemptGate = gates.find(function (gate) { return gate.key === 'support_post_approval_resume_attempt' && gate.status === 'blocked'; });
606
+ if (input.source === 'support_ticket' && blockedSupportPostApprovalResumeAttemptGate) {
607
+ var nextAction = cleanText((_q = blockedSupportPostApprovalResumeAttemptGate.metadata) === null || _q === void 0 ? void 0 : _q.nextAction, 160);
608
+ var failureClass = cleanText((_r = blockedSupportPostApprovalResumeAttemptGate.metadata) === null || _r === void 0 ? void 0 : _r.failureClass, 160);
609
+ return {
610
+ outcome: 'manual_handoff',
611
+ reason: "Approved support autoloop resume did not start: ".concat(blockedSupportPostApprovalResumeAttemptGate.reason),
612
+ nextAction: nextAction
613
+ ? "Review ".concat(failureClass || 'resume blocker', " and run ").concat(nextAction, " only after the blocker fingerprint changes; product repair and customer reply remain blocked.")
614
+ : 'Review the approved autoloop resume blocker and require a changed blocker fingerprint before another retry.',
615
+ gates: gates,
616
+ warnings: warnings,
617
+ recordedAt: now
618
+ };
619
+ }
620
+ var blockedSupportPostApprovalAutostartGate = gates.find(function (gate) { return gate.key === 'support_post_approval_autostart' && gate.status === 'blocked'; });
621
+ if (input.source === 'support_ticket' && blockedSupportPostApprovalAutostartGate) {
622
+ var nextAction = cleanText((_s = blockedSupportPostApprovalAutostartGate.metadata) === null || _s === void 0 ? void 0 : _s.nextAction, 160);
623
+ var canRetryWithoutReapproval = ((_t = blockedSupportPostApprovalAutostartGate.metadata) === null || _t === void 0 ? void 0 : _t.canRetryWithoutReapproval) === true;
624
+ var safeRetryAction = cleanText((_u = blockedSupportPostApprovalAutostartGate.metadata) === null || _u === void 0 ? void 0 : _u.safeRetryAction, 160);
625
+ return {
626
+ outcome: 'manual_handoff',
627
+ reason: "Support autonomy was approved, but the post-approval autostart did not begin: ".concat(blockedSupportPostApprovalAutostartGate.reason),
628
+ nextAction: canRetryWithoutReapproval && safeRetryAction === 'run_autoloop'
629
+ ? 'Retry the approved auto-improve loop under the same approval/scope fingerprint; no product repair or customer reply is allowed until the loop starts and records proof.'
630
+ : nextAction === 'resolve_autostart_blocker'
631
+ ? 'Resolve the autostart blocker or clear the active run, then rerun runSupportTicketAutoImproveLoopManual under the approved scope until A-grade PR proof.'
632
+ : 'Review the post-approval autostart result, then resume the approved auto-improve loop without changing scope.',
633
+ gates: gates,
634
+ warnings: warnings,
635
+ recordedAt: now
636
+ };
637
+ }
450
638
  if ((qa === null || qa === void 0 ? void 0 : qa.outcome) === 'infra_failed') {
451
639
  return {
452
640
  outcome: 'qa_infra_failed',
@@ -582,6 +770,62 @@ function classifyAIRunOutcome(input) {
582
770
  recordedAt: now
583
771
  };
584
772
  }
773
+ var failedSupportPrCreationGate = gates.find(function (gate) { return gate.key === 'support_pr_creation_result' && (gate.status === 'fail' || gate.status === 'blocked'); });
774
+ if (input.source === 'support_ticket' && failedSupportPrCreationGate) {
775
+ return {
776
+ outcome: 'release_blocked',
777
+ reason: "Support PR creation is blocked after proof-ready work: ".concat(failedSupportPrCreationGate.reason),
778
+ nextAction: ((_v = failedSupportPrCreationGate.metadata) === null || _v === void 0 ? void 0 : _v.nextAction) === 'repair_pr_creation_blocker'
779
+ ? 'Repair the PR creation/release-safety blocker or route to platform repair; do not rerun product-code repair unless new issue evidence changes.'
780
+ : 'Check PR creation status before another repair loop.',
781
+ gates: gates,
782
+ warnings: warnings,
783
+ recordedAt: now
784
+ };
785
+ }
786
+ var blockedSupportAutopilotCompletionGate = gates.find(function (gate) { return gate.key === 'support_autopilot_completion_contract' && gate.status === 'blocked'; });
787
+ if (input.source === 'support_ticket' && blockedSupportAutopilotCompletionGate) {
788
+ var nextAction = cleanText((_w = blockedSupportAutopilotCompletionGate.metadata) === null || _w === void 0 ? void 0 : _w.nextAction, 160);
789
+ var missingEvidence = Array.isArray((_x = blockedSupportAutopilotCompletionGate.metadata) === null || _x === void 0 ? void 0 : _x.missingCompletionEvidence)
790
+ ? blockedSupportAutopilotCompletionGate.metadata.missingCompletionEvidence
791
+ .map(function (entry) { return cleanText(entry, 240); })
792
+ .filter(Boolean)
793
+ : [];
794
+ var outcome = nextAction === 'create_pr'
795
+ ? 'release_blocked'
796
+ : (input.explicitAccepted === true || scorecardPassed || statusLooksPassed("".concat(input.status || '', " ").concat(input.phase || '')) || hasBusinessPass)
797
+ ? 'false_pass'
798
+ : 'qa_incomplete';
799
+ return {
800
+ outcome: outcome,
801
+ reason: "Approved support autopilot has not reached A-grade PR proof: ".concat(blockedSupportAutopilotCompletionGate.reason),
802
+ nextAction: nextAction === 'create_pr'
803
+ ? 'Create the proof-backed support PR; merge, release, deploy, and customer reply remain separately gated.'
804
+ : nextAction === 'run_business_proof_qa'
805
+ ? 'Run issue-specific business proof QA until AIQaBusinessAssertion, before/action/after proof, and screenshot/trace evidence pass.'
806
+ : nextAction === 'run_a_grade_pr_review'
807
+ ? 'Run strict A-grade PR review; do not merge, release, deploy, or send the customer reply until execution, artifact, pull_request, business-proof, and screenshot/trace evidence pass.'
808
+ : 'Continue only the bounded owner-scoped support workflow until PR readiness or a new blocker/scope change.',
809
+ gates: gates,
810
+ warnings: missingEvidence.length
811
+ ? __spreadArray(__spreadArray([], __read(warnings), false), __read(missingEvidence.map(function (entry) { return "missing_completion_evidence:".concat(entry); })), false) : warnings,
812
+ recordedAt: now
813
+ };
814
+ }
815
+ var blockedSupportReleaseCustomerGate = gates.find(function (gate) { return gate.key === 'support_release_customer_acceptance' && (gate.status === 'blocked' || gate.status === 'fail'); });
816
+ if (input.source === 'support_ticket' && blockedSupportReleaseCustomerGate) {
817
+ var nextAction = cleanText((_y = blockedSupportReleaseCustomerGate.metadata) === null || _y === void 0 ? void 0 : _y.nextAction, 160);
818
+ return {
819
+ outcome: 'release_blocked',
820
+ reason: "Support PR proof is ready, but release/customer acceptance is incomplete: ".concat(blockedSupportReleaseCustomerGate.reason),
821
+ nextAction: nextAction === 'draft_or_review_proof_backed_customer_reply'
822
+ ? 'Draft or review the proof-backed customer reply from the accepted QA/release evidence; do not rerun product-code repair unless new issue evidence appears.'
823
+ : 'Complete the release/hotfix gate for the A-grade PR, then generate or review the proof-backed customer reply.',
824
+ gates: gates,
825
+ warnings: warnings,
826
+ recordedAt: now
827
+ };
828
+ }
585
829
  var blockedAICoderNextActionContractGate = gates.find(function (gate) { return gate.key === 'aicoder_next_action_contract' && (gate.status === 'blocked' || gate.status === 'fail'); });
586
830
  if (input.source === 'aicoder_app' && blockedAICoderNextActionContractGate) {
587
831
  var claimedSuccess = input.explicitAccepted === true