@resolveio/server-lib 22.3.159 → 22.3.161

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "22.3.159",
3
+ "version": "22.3.161",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",
@@ -741,6 +741,94 @@ function supportDiagnosisProofGateResult(diagnosisGate, now) {
741
741
  }
742
742
  };
743
743
  }
744
+ var SUPPORT_ROOT_CAUSE_ENTRY_REQUIRED_FIELDS = [
745
+ 'issue_case',
746
+ 'issue_class',
747
+ 'accepted_hypothesis',
748
+ 'rejected_alternatives',
749
+ 'failing_path',
750
+ 'owner_files',
751
+ 'proof_plan',
752
+ 'evidence'
753
+ ];
754
+ var SUPPORT_ROOT_CAUSE_ENTRY_ISSUE_CLASSES = [
755
+ 'no_op_submit',
756
+ 'missing_wrong_data',
757
+ 'filter_query_mismatch',
758
+ 'invoice_pdf_export',
759
+ 'upload_import',
760
+ 'route_auth_hydration',
761
+ 'slow_query_performance'
762
+ ];
763
+ function supportRootCauseEntryContractGate(contract, now) {
764
+ if (!contract || !Object.keys(contract).length) {
765
+ return undefined;
766
+ }
767
+ var requiredOutput = plainObject(contract.required_output || contract.requiredOutput);
768
+ var ownerPolicy = plainObject(contract.owner_file_policy || contract.ownerFilePolicy);
769
+ var businessProofPolicy = plainObject(contract.business_proof_policy || contract.businessProofPolicy);
770
+ var failurePolicy = plainObject(contract.failure_policy || contract.failurePolicy);
771
+ var probes = asArray(contract.issue_class_probes || contract.issueClassProbes);
772
+ var requiredFields = cleanStringList(requiredOutput.required_fields || requiredOutput.requiredFields, 30, 160);
773
+ var issueClasses = probes.map(function (probe) { return cleanText(probe.issue_class || probe.issueClass, 120); }).filter(Boolean);
774
+ var missingRequiredFields = SUPPORT_ROOT_CAUSE_ENTRY_REQUIRED_FIELDS.filter(function (field) { return !requiredFields.includes(field); });
775
+ var missingIssueClasses = SUPPORT_ROOT_CAUSE_ENTRY_ISSUE_CLASSES.filter(function (issueClass) { return !issueClasses.includes(issueClass); });
776
+ var blockers = [];
777
+ if (!cleanText(contract.contract_id || contract.contractId, 160)) {
778
+ blockers.push('Root-cause entry contract is missing contract_id.');
779
+ }
780
+ if (cleanText(requiredOutput.object_key || requiredOutput.objectKey, 120) !== 'support_diagnosis_gate') {
781
+ blockers.push('Root-cause entry contract must require support_diagnosis_gate output.');
782
+ }
783
+ if (missingRequiredFields.length) {
784
+ blockers.push("Root-cause entry contract missing required output fields: ".concat(missingRequiredFields.join(', '), "."));
785
+ }
786
+ var ownerFileMax = Number(ownerPolicy.max_files || ownerPolicy.maxFiles || 0);
787
+ if (!Number.isFinite(ownerFileMax) || ownerFileMax <= 0 || ownerFileMax > 12) {
788
+ blockers.push('Root-cause entry contract must cap owner_files to a small exact file set.');
789
+ }
790
+ if (ownerPolicy.edits_outside_owner_files_require_revised_diagnosis !== true && ownerPolicy.editsOutsideOwnerFilesRequireRevisedDiagnosis !== true) {
791
+ blockers.push('Root-cause entry contract must require revised diagnosis before edits outside owner_files.');
792
+ }
793
+ if (businessProofPolicy.requires_aiqa_business_assertion !== true && businessProofPolicy.requiresAiqaBusinessAssertion !== true) {
794
+ blockers.push('Root-cause entry contract must require AIQaBusinessAssertion business proof.');
795
+ }
796
+ if (businessProofPolicy.route_load_screenshot_scorecard_model_claim_not_acceptance !== true && businessProofPolicy.routeLoadScreenshotScorecardModelClaimNotAcceptance !== true) {
797
+ blockers.push('Root-cause entry contract must reject route-load/screenshot/scorecard/model-claim acceptance.');
798
+ }
799
+ if (failurePolicy.repeated_failure_without_new_evidence_parks_run !== true && failurePolicy.repeatedFailureWithoutNewEvidenceParksRun !== true) {
800
+ blockers.push('Root-cause entry contract must park repeated failures without new evidence.');
801
+ }
802
+ if (missingIssueClasses.length) {
803
+ blockers.push("Root-cause entry contract missing issue-class probes: ".concat(missingIssueClasses.join(', '), "."));
804
+ }
805
+ var status = blockers.length ? 'fail' : 'pass';
806
+ return {
807
+ key: 'support_root_cause_entry_contract',
808
+ label: 'Root-cause entry contract',
809
+ status: status,
810
+ reason: blockers.length
811
+ ? blockers.join(' ')
812
+ : 'Support run has a structured root-cause-first entry contract with issue-class probes, owner-file policy, and business-proof policy.',
813
+ evidenceRefs: cleanStringList(businessProofPolicy.required_artifacts || businessProofPolicy.requiredArtifacts, 20, 500),
814
+ recordedAt: isoNow(now),
815
+ metadata: {
816
+ contractId: cleanText(contract.contract_id || contract.contractId, 160),
817
+ version: cleanText(contract.version, 120),
818
+ status: cleanText(contract.status, 120),
819
+ requiredOutputKey: cleanText(requiredOutput.object_key || requiredOutput.objectKey, 120),
820
+ requiredFields: requiredFields,
821
+ missingRequiredFields: missingRequiredFields,
822
+ ownerFileMax: ownerFileMax,
823
+ requiresRevisedDiagnosisForOutOfScopeEdits: ownerPolicy.edits_outside_owner_files_require_revised_diagnosis === true || ownerPolicy.editsOutsideOwnerFilesRequireRevisedDiagnosis === true,
824
+ requiresBusinessAssertion: businessProofPolicy.requires_aiqa_business_assertion === true || businessProofPolicy.requiresAiqaBusinessAssertion === true,
825
+ routeOnlyAcceptanceRejected: businessProofPolicy.route_load_screenshot_scorecard_model_claim_not_acceptance === true || businessProofPolicy.routeLoadScreenshotScorecardModelClaimNotAcceptance === true,
826
+ issueClassProbeCount: issueClasses.length,
827
+ issueClasses: issueClasses,
828
+ missingIssueClasses: missingIssueClasses
829
+ }
830
+ };
831
+ }
744
832
  function applySupportDiagnosisProofGate(qa, diagnosisGate, now) {
745
833
  var proofPlan = diagnosisGate.proof_plan || diagnosisGate.proofPlan || {};
746
834
  var requiredBusinessAssertion = cleanText(proofPlan.business_assertion || proofPlan.businessAssertion, 1000);
@@ -1454,7 +1542,7 @@ function applyAssistantAnswerQualityGate(qa, decision, now) {
1454
1542
  }
1455
1543
  function buildSupportAIRunFromEvidence(input) {
1456
1544
  var e_22, _a, e_23, _b;
1457
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1545
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1458
1546
  var ticket = input.ticket || {};
1459
1547
  var job = input.job || {};
1460
1548
  var evidence = buildSupportQaEvidence(input);
@@ -1466,8 +1554,8 @@ function buildSupportAIRunFromEvidence(input) {
1466
1554
  addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
1467
1555
  addSourceId(sourceIds, 'buildPlanId', job.buildPlanId || ticket.buildPlanId);
1468
1556
  try {
1469
- for (var _o = __values(asArray(input.taskEvents)), _p = _o.next(); !_p.done; _p = _o.next()) {
1470
- var event_1 = _p.value;
1557
+ for (var _s = __values(asArray(input.taskEvents)), _t = _s.next(); !_t.done; _t = _s.next()) {
1558
+ var event_1 = _t.value;
1471
1559
  pushEvent(events, {
1472
1560
  type: event_1.type === 'human_intervention' ? 'human_intervention' : 'log',
1473
1561
  category: cleanText(event_1.category || event_1.phase || event_1.type, 160),
@@ -1484,13 +1572,13 @@ function buildSupportAIRunFromEvidence(input) {
1484
1572
  catch (e_22_1) { e_22 = { error: e_22_1 }; }
1485
1573
  finally {
1486
1574
  try {
1487
- if (_p && !_p.done && (_a = _o.return)) _a.call(_o);
1575
+ if (_t && !_t.done && (_a = _s.return)) _a.call(_s);
1488
1576
  }
1489
1577
  finally { if (e_22) throw e_22.error; }
1490
1578
  }
1491
1579
  try {
1492
- for (var _q = __values(asArray(input.aiJobs)), _r = _q.next(); !_r.done; _r = _q.next()) {
1493
- var aiJob = _r.value;
1580
+ for (var _u = __values(asArray(input.aiJobs)), _v = _u.next(); !_v.done; _v = _u.next()) {
1581
+ var aiJob = _v.value;
1494
1582
  pushEvent(events, {
1495
1583
  type: aiJob.model ? 'model_call' : 'log',
1496
1584
  category: cleanText(aiJob.category || aiJob.phase || aiJob.runner, 160),
@@ -1508,7 +1596,7 @@ function buildSupportAIRunFromEvidence(input) {
1508
1596
  catch (e_23_1) { e_23 = { error: e_23_1 }; }
1509
1597
  finally {
1510
1598
  try {
1511
- if (_r && !_r.done && (_b = _q.return)) _b.call(_q);
1599
+ if (_v && !_v.done && (_b = _u.return)) _b.call(_u);
1512
1600
  }
1513
1601
  finally { if (e_23) throw e_23.error; }
1514
1602
  }
@@ -1540,6 +1628,21 @@ function buildSupportAIRunFromEvidence(input) {
1540
1628
  metadata: customerReplyPolicyGate.metadata
1541
1629
  });
1542
1630
  }
1631
+ var ticketAutomation = plainObject(ticket.automation);
1632
+ var ticketManagerState = plainObject(ticketAutomation.manager || ticket.manager);
1633
+ var rootCauseEntryContract = evidenceObject(job.supportRootCauseEntryContract, job.support_root_cause_entry_contract, job.rootCauseEntryContract, ticket.supportRootCauseEntryContract, ticket.rootCauseEntryContract, ticketManagerState.root_cause_entry_contract, ticketManagerState.rootCauseEntryContract, evidence.rootCauseEntryContract, evidence.root_cause_entry_contract);
1634
+ var rootCauseEntryContractGate = supportRootCauseEntryContractGate(rootCauseEntryContract, input.now);
1635
+ if (rootCauseEntryContractGate) {
1636
+ gates.push(rootCauseEntryContractGate);
1637
+ pushEvent(events, {
1638
+ type: 'log',
1639
+ category: 'support_root_cause_entry_contract',
1640
+ message: rootCauseEntryContractGate.reason,
1641
+ artifactPaths: rootCauseEntryContractGate.evidenceRefs,
1642
+ recordedAt: rootCauseEntryContractGate.recordedAt,
1643
+ metadata: rootCauseEntryContractGate.metadata
1644
+ });
1645
+ }
1543
1646
  var cost = collectUsageEvents(asArray(input.usageLedger), events);
1544
1647
  var diagnosisGate = evidenceObject(job.supportV5DiagnosisGate, job.support_v5_diagnosis_gate, job.diagnosisGate, ticket.supportV5DiagnosisGate, ticket.diagnosisGate, evidence.diagnosisGate, evidence.supportV5DiagnosisGate);
1545
1648
  var qa = applySupportDiagnosisProofGate(buildQaFromEvidence(evidence, input.now), diagnosisGate, input.now);
@@ -1582,11 +1685,20 @@ function buildSupportAIRunFromEvidence(input) {
1582
1685
  metadata: {
1583
1686
  versionCount: asArray(input.versions).length,
1584
1687
  buildPlanCount: asArray(input.buildPlans).length,
1688
+ rootCauseEntryContract: Object.keys(rootCauseEntryContract).length ? {
1689
+ contractId: cleanText(rootCauseEntryContract.contract_id || rootCauseEntryContract.contractId, 160),
1690
+ version: cleanText(rootCauseEntryContract.version, 120),
1691
+ status: cleanText(rootCauseEntryContract.status, 120),
1692
+ issueClassProbeCount: asArray(rootCauseEntryContract.issue_class_probes || rootCauseEntryContract.issueClassProbes).length,
1693
+ 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,
1694
+ requiresBusinessAssertion: ((_g = rootCauseEntryContract.business_proof_policy) === null || _g === void 0 ? void 0 : _g.requires_aiqa_business_assertion) === true
1695
+ || ((_h = rootCauseEntryContract.businessProofPolicy) === null || _h === void 0 ? void 0 : _h.requiresAiqaBusinessAssertion) === true
1696
+ } : undefined,
1585
1697
  diagnosis: Object.keys(diagnosisGate).length ? {
1586
1698
  status: cleanText(diagnosisGate.status, 80),
1587
1699
  issueClass: diagnosisIssueClass,
1588
1700
  ownerFiles: diagnosisOwnerFiles,
1589
- acceptedHypothesis: cleanText(((_e = diagnosisGate.accepted_hypothesis) === null || _e === void 0 ? void 0 : _e.statement) || ((_f = diagnosisGate.acceptedHypothesis) === null || _f === void 0 ? void 0 : _f.statement), 1000),
1701
+ 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),
1590
1702
  proofPlan: diagnosisGate.proof_plan || diagnosisGate.proofPlan
1591
1703
  } : undefined,
1592
1704
  businessProofReadiness: Object.keys(businessProofReadiness).length ? {
@@ -1601,12 +1713,12 @@ function buildSupportAIRunFromEvidence(input) {
1601
1713
  canDraftCustomerReply: customerReplyPolicy.canDraftCustomerReply === true || customerReplyPolicy.can_draft_customer_reply === true,
1602
1714
  canSendCustomerReply: customerReplyPolicy.canSendCustomerReply === true || customerReplyPolicy.can_send_customer_reply === true,
1603
1715
  reason: cleanText(customerReplyPolicy.reason, 1000),
1604
- reviewType: cleanText(((_g = customerReplyPolicy.humanReviewPacket) === null || _g === void 0 ? void 0 : _g.reviewType)
1605
- || ((_h = customerReplyPolicy.human_review_packet) === null || _h === void 0 ? void 0 : _h.review_type)
1606
- || ((_j = customerReplyPolicy.human_review_packet) === null || _j === void 0 ? void 0 : _j.reviewType), 160),
1607
- primaryAction: cleanText(((_k = customerReplyPolicy.humanReviewPacket) === null || _k === void 0 ? void 0 : _k.primaryAction)
1608
- || ((_l = customerReplyPolicy.human_review_packet) === null || _l === void 0 ? void 0 : _l.primary_action)
1609
- || ((_m = customerReplyPolicy.human_review_packet) === null || _m === void 0 ? void 0 : _m.primaryAction), 160)
1716
+ reviewType: cleanText(((_l = customerReplyPolicy.humanReviewPacket) === null || _l === void 0 ? void 0 : _l.reviewType)
1717
+ || ((_m = customerReplyPolicy.human_review_packet) === null || _m === void 0 ? void 0 : _m.review_type)
1718
+ || ((_o = customerReplyPolicy.human_review_packet) === null || _o === void 0 ? void 0 : _o.reviewType), 160),
1719
+ primaryAction: cleanText(((_p = customerReplyPolicy.humanReviewPacket) === null || _p === void 0 ? void 0 : _p.primaryAction)
1720
+ || ((_q = customerReplyPolicy.human_review_packet) === null || _q === void 0 ? void 0 : _q.primary_action)
1721
+ || ((_r = customerReplyPolicy.human_review_packet) === null || _r === void 0 ? void 0 : _r.primaryAction), 160)
1610
1722
  } : undefined
1611
1723
  }
1612
1724
  });