@resolveio/server-lib 22.3.194 → 22.3.195

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.194",
3
+ "version": "22.3.195",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",
@@ -272,6 +272,57 @@ function managerNoBlindLoopGateFromHistory(history, budgetSource, now) {
272
272
  }
273
273
  };
274
274
  }
275
+ function managerRecoveryExecutionProofGate(proof, now) {
276
+ if (!proof || !Object.keys(proof).length) {
277
+ return undefined;
278
+ }
279
+ var validation = (0, ai_runner_manager_policy_1.validateResolveIOAIManagerRecoveryExecutionProofContract)(proof);
280
+ var normalized = validation.normalized;
281
+ var statusText = cleanText(normalized.status, 120);
282
+ var gateStatus = validation.valid && normalized.canContinueRun === true && statusText === 'proof_ready'
283
+ ? 'pass'
284
+ : statusText === 'manual_handoff'
285
+ ? 'warn'
286
+ : 'blocked';
287
+ return {
288
+ key: 'manager_recovery_execution_proof',
289
+ label: 'Manager recovery execution proof',
290
+ status: gateStatus,
291
+ reason: normalized.blockers[0] || validation.blockers[0] || statusText || 'Manager recovery execution proof recorded.',
292
+ evidenceRefs: normalized.artifactPaths,
293
+ recordedAt: isoNow(now || normalized.createdAt),
294
+ metadata: {
295
+ contractId: normalized.contractId,
296
+ directiveId: normalized.directiveId,
297
+ surface: normalized.surface,
298
+ dispatchAction: normalized.dispatchAction,
299
+ phase: normalized.phase,
300
+ status: statusText,
301
+ canContinueRun: normalized.canContinueRun,
302
+ canRunProductRepair: normalized.canRunProductRepair,
303
+ canRunExpensiveModel: normalized.canRunExpensiveModel,
304
+ canResetLoopBudget: normalized.canResetLoopBudget,
305
+ proofRequiredBeforeContinuation: normalized.proofRequiredBeforeContinuation,
306
+ requiresNewEvidence: normalized.requiresNewEvidence,
307
+ newEvidence: normalized.newEvidence,
308
+ materialEvidence: normalized.materialEvidence,
309
+ evidenceStrength: normalized.evidenceStrength,
310
+ evidenceSignals: normalized.evidenceSignals,
311
+ startingFailureClass: normalized.startingFailureClass,
312
+ startingBlockerFingerprint: normalized.startingBlockerFingerprint,
313
+ startingEvidenceHash: normalized.startingEvidenceHash,
314
+ latestFailureClass: normalized.latestFailureClass,
315
+ latestBlockerFingerprint: normalized.latestBlockerFingerprint,
316
+ latestEvidenceHash: normalized.latestEvidenceHash,
317
+ requiredEvidence: normalized.requiredEvidence,
318
+ missingEvidence: normalized.missingEvidence,
319
+ changedFiles: normalized.changedFiles,
320
+ blockers: Array.from(new Set(__spreadArray(__spreadArray([], __read(normalized.blockers), false), __read(validation.blockers), false))),
321
+ nextAllowedAction: normalized.nextAllowedAction,
322
+ forbiddenActions: normalized.forbiddenActions
323
+ }
324
+ };
325
+ }
275
326
  function supportManagerNoBlindLoopGate(job, evidence, now) {
276
327
  return managerNoBlindLoopGateFromHistory(supportManagerFailureRecords(job, evidence), job.supportV5Budget || job.support_v5_budget || evidence.supportV5Budget || evidence.support_v5_budget, now);
277
328
  }
@@ -1622,6 +1673,8 @@ function buildSupportQaEvidence(input) {
1622
1673
  var ticket = input.ticket || {};
1623
1674
  var qaCursor = plainObject(job.supportQaValidationCursor || job.support_qa_validation_cursor);
1624
1675
  var autonomousDecision = plainObject(job.supportV5AutonomousDecision || job.support_v5_autonomous_decision);
1676
+ var ticketAutomation = plainObject(ticket.automation);
1677
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
1625
1678
  var preflightGate = supportPreflightGateObject(ticket, job, __assign(__assign({}, plainObject(input.qaEvidence)), { supportV5AutonomousDecision: autonomousDecision }));
1626
1679
  var businessProofReadiness = plainObject(autonomousDecision.businessProofReadiness
1627
1680
  || autonomousDecision.business_proof_readiness
@@ -1637,6 +1690,14 @@ function buildSupportQaEvidence(input) {
1637
1690
  || customerReplyPolicy.readiness_contract
1638
1691
  || job.customerReplyReadiness
1639
1692
  || job.customer_reply_readiness);
1693
+ var managerRecoveryExecutionProof = plainObject(job.managerRecoveryExecutionProof
1694
+ || job.manager_recovery_execution_proof
1695
+ || job.supportManagerRecoveryExecutionProof
1696
+ || job.support_manager_recovery_execution_proof
1697
+ || autonomousDecision.recoveryExecutionProof
1698
+ || autonomousDecision.recovery_execution_proof
1699
+ || ticketManager.last_recovery_execution_proof
1700
+ || ticketManager.recovery_execution_proof);
1640
1701
  var humanReviewPacket = plainObject(autonomousDecision.humanReviewPacket
1641
1702
  || autonomousDecision.human_review_packet
1642
1703
  || customerReplyPolicy.humanReviewPacket
@@ -1660,6 +1721,9 @@ function buildSupportQaEvidence(input) {
1660
1721
  if (Object.keys(customerReplyReadiness).length) {
1661
1722
  evidence.customerReplyReadiness = customerReplyReadiness;
1662
1723
  }
1724
+ if (Object.keys(managerRecoveryExecutionProof).length) {
1725
+ evidence.managerRecoveryExecutionProof = managerRecoveryExecutionProof;
1726
+ }
1663
1727
  if (Object.keys(preflightGate).length) {
1664
1728
  evidence.supportV5PreflightGate = preflightGate;
1665
1729
  applySupportPreflightGateToQaEvidence(evidence, preflightGate);
@@ -3171,7 +3235,7 @@ function applyAssistantAnswerQualityGate(qa, decision, now) {
3171
3235
  }
3172
3236
  function buildSupportAIRunFromEvidence(input) {
3173
3237
  var e_32, _a, e_33, _b;
3174
- 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, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61;
3238
+ 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, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72;
3175
3239
  var ticket = input.ticket || {};
3176
3240
  var job = input.job || {};
3177
3241
  var evidence = buildSupportQaEvidence(input);
@@ -3183,8 +3247,8 @@ function buildSupportAIRunFromEvidence(input) {
3183
3247
  addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
3184
3248
  addSourceId(sourceIds, 'buildPlanId', job.buildPlanId || ticket.buildPlanId);
3185
3249
  try {
3186
- for (var _62 = __values(asArray(input.taskEvents)), _63 = _62.next(); !_63.done; _63 = _62.next()) {
3187
- var event_1 = _63.value;
3250
+ for (var _73 = __values(asArray(input.taskEvents)), _74 = _73.next(); !_74.done; _74 = _73.next()) {
3251
+ var event_1 = _74.value;
3188
3252
  pushEvent(events, {
3189
3253
  type: event_1.type === 'human_intervention' ? 'human_intervention' : 'log',
3190
3254
  category: cleanText(event_1.category || event_1.phase || event_1.type, 160),
@@ -3201,13 +3265,13 @@ function buildSupportAIRunFromEvidence(input) {
3201
3265
  catch (e_32_1) { e_32 = { error: e_32_1 }; }
3202
3266
  finally {
3203
3267
  try {
3204
- if (_63 && !_63.done && (_a = _62.return)) _a.call(_62);
3268
+ if (_74 && !_74.done && (_a = _73.return)) _a.call(_73);
3205
3269
  }
3206
3270
  finally { if (e_32) throw e_32.error; }
3207
3271
  }
3208
3272
  try {
3209
- for (var _64 = __values(asArray(input.aiJobs)), _65 = _64.next(); !_65.done; _65 = _64.next()) {
3210
- var aiJob = _65.value;
3273
+ for (var _75 = __values(asArray(input.aiJobs)), _76 = _75.next(); !_76.done; _76 = _75.next()) {
3274
+ var aiJob = _76.value;
3211
3275
  pushEvent(events, {
3212
3276
  type: aiJob.model ? 'model_call' : 'log',
3213
3277
  category: cleanText(aiJob.category || aiJob.phase || aiJob.runner, 160),
@@ -3225,7 +3289,7 @@ function buildSupportAIRunFromEvidence(input) {
3225
3289
  catch (e_33_1) { e_33 = { error: e_33_1 }; }
3226
3290
  finally {
3227
3291
  try {
3228
- if (_65 && !_65.done && (_b = _64.return)) _b.call(_64);
3292
+ if (_76 && !_76.done && (_b = _75.return)) _b.call(_75);
3229
3293
  }
3230
3294
  finally { if (e_33) throw e_33.error; }
3231
3295
  }
@@ -3299,6 +3363,19 @@ function buildSupportAIRunFromEvidence(input) {
3299
3363
  metadata: nextActionContractGate.metadata
3300
3364
  });
3301
3365
  }
3366
+ var managerRecoveryExecutionProof = plainObject(evidence.managerRecoveryExecutionProof || evidence.manager_recovery_execution_proof);
3367
+ var recoveryExecutionProofGate = managerRecoveryExecutionProofGate(managerRecoveryExecutionProof, input.now);
3368
+ if (recoveryExecutionProofGate) {
3369
+ gates.push(recoveryExecutionProofGate);
3370
+ pushEvent(events, {
3371
+ type: 'log',
3372
+ category: 'manager_recovery_execution_proof',
3373
+ message: recoveryExecutionProofGate.reason,
3374
+ artifactPaths: recoveryExecutionProofGate.evidenceRefs,
3375
+ recordedAt: recoveryExecutionProofGate.recordedAt,
3376
+ metadata: recoveryExecutionProofGate.metadata
3377
+ });
3378
+ }
3302
3379
  var ticketAutomation = plainObject(ticket.automation);
3303
3380
  var ticketManagerState = plainObject(ticketAutomation.manager || ticket.manager);
3304
3381
  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);
@@ -3535,37 +3612,51 @@ function buildSupportAIRunFromEvidence(input) {
3535
3612
  sameFailureCount: Number(((_36 = nextActionContractGate.metadata) === null || _36 === void 0 ? void 0 : _36.sameFailureCount) || 0),
3536
3613
  blockers: cleanStringList((_37 = nextActionContractGate.metadata) === null || _37 === void 0 ? void 0 : _37.blockers, 20, 500)
3537
3614
  } : undefined,
3615
+ managerRecoveryExecutionProof: recoveryExecutionProofGate ? {
3616
+ status: cleanText((_38 = recoveryExecutionProofGate.metadata) === null || _38 === void 0 ? void 0 : _38.status, 120),
3617
+ gateStatus: recoveryExecutionProofGate.status,
3618
+ canContinueRun: ((_39 = recoveryExecutionProofGate.metadata) === null || _39 === void 0 ? void 0 : _39.canContinueRun) === true,
3619
+ canRunProductRepair: ((_40 = recoveryExecutionProofGate.metadata) === null || _40 === void 0 ? void 0 : _40.canRunProductRepair) === true,
3620
+ canRunExpensiveModel: ((_41 = recoveryExecutionProofGate.metadata) === null || _41 === void 0 ? void 0 : _41.canRunExpensiveModel) === true,
3621
+ canResetLoopBudget: ((_42 = recoveryExecutionProofGate.metadata) === null || _42 === void 0 ? void 0 : _42.canResetLoopBudget) === true,
3622
+ newEvidence: ((_43 = recoveryExecutionProofGate.metadata) === null || _43 === void 0 ? void 0 : _43.newEvidence) === true,
3623
+ materialEvidence: ((_44 = recoveryExecutionProofGate.metadata) === null || _44 === void 0 ? void 0 : _44.materialEvidence) === true,
3624
+ evidenceStrength: cleanText((_45 = recoveryExecutionProofGate.metadata) === null || _45 === void 0 ? void 0 : _45.evidenceStrength, 120),
3625
+ nextAllowedAction: cleanText((_46 = recoveryExecutionProofGate.metadata) === null || _46 === void 0 ? void 0 : _46.nextAllowedAction, 180),
3626
+ missingEvidence: cleanStringList((_47 = recoveryExecutionProofGate.metadata) === null || _47 === void 0 ? void 0 : _47.missingEvidence, 20, 500),
3627
+ blockers: cleanStringList((_48 = recoveryExecutionProofGate.metadata) === null || _48 === void 0 ? void 0 : _48.blockers, 20, 500)
3628
+ } : undefined,
3538
3629
  customerReplyPolicy: Object.keys(customerReplyPolicy).length ? {
3539
3630
  action: cleanText(customerReplyPolicy.action, 120),
3540
3631
  safety: cleanText(customerReplyPolicy.safety, 120),
3541
3632
  canDraftCustomerReply: customerReplyPolicy.canDraftCustomerReply === true || customerReplyPolicy.can_draft_customer_reply === true,
3542
3633
  canSendCustomerReply: customerReplyPolicy.canSendCustomerReply === true || customerReplyPolicy.can_send_customer_reply === true,
3543
3634
  reason: cleanText(customerReplyPolicy.reason, 1000),
3544
- reviewType: cleanText(((_38 = customerReplyPolicy.humanReviewPacket) === null || _38 === void 0 ? void 0 : _38.reviewType)
3545
- || ((_39 = customerReplyPolicy.human_review_packet) === null || _39 === void 0 ? void 0 : _39.review_type)
3546
- || ((_40 = customerReplyPolicy.human_review_packet) === null || _40 === void 0 ? void 0 : _40.reviewType), 160),
3547
- primaryAction: cleanText(((_41 = customerReplyPolicy.humanReviewPacket) === null || _41 === void 0 ? void 0 : _41.primaryAction)
3548
- || ((_42 = customerReplyPolicy.human_review_packet) === null || _42 === void 0 ? void 0 : _42.primary_action)
3549
- || ((_43 = customerReplyPolicy.human_review_packet) === null || _43 === void 0 ? void 0 : _43.primaryAction), 160),
3635
+ reviewType: cleanText(((_49 = customerReplyPolicy.humanReviewPacket) === null || _49 === void 0 ? void 0 : _49.reviewType)
3636
+ || ((_50 = customerReplyPolicy.human_review_packet) === null || _50 === void 0 ? void 0 : _50.review_type)
3637
+ || ((_51 = customerReplyPolicy.human_review_packet) === null || _51 === void 0 ? void 0 : _51.reviewType), 160),
3638
+ primaryAction: cleanText(((_52 = customerReplyPolicy.humanReviewPacket) === null || _52 === void 0 ? void 0 : _52.primaryAction)
3639
+ || ((_53 = customerReplyPolicy.human_review_packet) === null || _53 === void 0 ? void 0 : _53.primary_action)
3640
+ || ((_54 = customerReplyPolicy.human_review_packet) === null || _54 === void 0 ? void 0 : _54.primaryAction), 160),
3550
3641
  clarificationContract: customerReplyPolicy.clarificationContract || customerReplyPolicy.clarification_contract ? {
3551
- status: cleanText(((_44 = customerReplyPolicy.clarificationContract) === null || _44 === void 0 ? void 0 : _44.status) || ((_45 = customerReplyPolicy.clarification_contract) === null || _45 === void 0 ? void 0 : _45.status), 120),
3552
- missingField: cleanText(((_46 = customerReplyPolicy.clarificationContract) === null || _46 === void 0 ? void 0 : _46.missingField) || ((_47 = customerReplyPolicy.clarification_contract) === null || _47 === void 0 ? void 0 : _47.missing_field), 120),
3553
- oneQuestionOnly: ((_48 = customerReplyPolicy.clarificationContract) === null || _48 === void 0 ? void 0 : _48.oneQuestionOnly) === true || ((_49 = customerReplyPolicy.clarification_contract) === null || _49 === void 0 ? void 0 : _49.one_question_only) === true,
3554
- parksTicketUntilCustomerReply: ((_50 = customerReplyPolicy.clarificationContract) === null || _50 === void 0 ? void 0 : _50.parksTicketUntilCustomerReply) === true || ((_51 = customerReplyPolicy.clarification_contract) === null || _51 === void 0 ? void 0 : _51.parks_ticket_until_customer_reply) === true
3642
+ status: cleanText(((_55 = customerReplyPolicy.clarificationContract) === null || _55 === void 0 ? void 0 : _55.status) || ((_56 = customerReplyPolicy.clarification_contract) === null || _56 === void 0 ? void 0 : _56.status), 120),
3643
+ missingField: cleanText(((_57 = customerReplyPolicy.clarificationContract) === null || _57 === void 0 ? void 0 : _57.missingField) || ((_58 = customerReplyPolicy.clarification_contract) === null || _58 === void 0 ? void 0 : _58.missing_field), 120),
3644
+ oneQuestionOnly: ((_59 = customerReplyPolicy.clarificationContract) === null || _59 === void 0 ? void 0 : _59.oneQuestionOnly) === true || ((_60 = customerReplyPolicy.clarification_contract) === null || _60 === void 0 ? void 0 : _60.one_question_only) === true,
3645
+ parksTicketUntilCustomerReply: ((_61 = customerReplyPolicy.clarificationContract) === null || _61 === void 0 ? void 0 : _61.parksTicketUntilCustomerReply) === true || ((_62 = customerReplyPolicy.clarification_contract) === null || _62 === void 0 ? void 0 : _62.parks_ticket_until_customer_reply) === true
3555
3646
  } : undefined
3556
3647
  } : undefined,
3557
3648
  customerReplyReadiness: customerReplyReadinessGate ? {
3558
- status: cleanText((_52 = customerReplyReadinessGate.metadata) === null || _52 === void 0 ? void 0 : _52.status, 120),
3649
+ status: cleanText((_63 = customerReplyReadinessGate.metadata) === null || _63 === void 0 ? void 0 : _63.status, 120),
3559
3650
  gateStatus: customerReplyReadinessGate.status,
3560
- primaryCommand: cleanText((_53 = customerReplyReadinessGate.metadata) === null || _53 === void 0 ? void 0 : _53.primaryCommand, 180),
3561
- policyAction: cleanText((_54 = customerReplyReadinessGate.metadata) === null || _54 === void 0 ? void 0 : _54.policyAction, 120),
3562
- canDraftCustomerReply: ((_55 = customerReplyReadinessGate.metadata) === null || _55 === void 0 ? void 0 : _55.canDraftCustomerReply) === true,
3563
- canSendCustomerReply: ((_56 = customerReplyReadinessGate.metadata) === null || _56 === void 0 ? void 0 : _56.canSendCustomerReply) === true,
3564
- requiresHumanApproval: ((_57 = customerReplyReadinessGate.metadata) === null || _57 === void 0 ? void 0 : _57.requiresHumanApproval) === true,
3565
- proofBacked: ((_58 = customerReplyReadinessGate.metadata) === null || _58 === void 0 ? void 0 : _58.proofBacked) === true,
3566
- businessProofReady: ((_59 = customerReplyReadinessGate.metadata) === null || _59 === void 0 ? void 0 : _59.businessProofReady) === true,
3567
- releaseReady: ((_60 = customerReplyReadinessGate.metadata) === null || _60 === void 0 ? void 0 : _60.releaseReady) === true,
3568
- blockers: cleanStringList((_61 = customerReplyReadinessGate.metadata) === null || _61 === void 0 ? void 0 : _61.blockers, 20, 500)
3651
+ primaryCommand: cleanText((_64 = customerReplyReadinessGate.metadata) === null || _64 === void 0 ? void 0 : _64.primaryCommand, 180),
3652
+ policyAction: cleanText((_65 = customerReplyReadinessGate.metadata) === null || _65 === void 0 ? void 0 : _65.policyAction, 120),
3653
+ canDraftCustomerReply: ((_66 = customerReplyReadinessGate.metadata) === null || _66 === void 0 ? void 0 : _66.canDraftCustomerReply) === true,
3654
+ canSendCustomerReply: ((_67 = customerReplyReadinessGate.metadata) === null || _67 === void 0 ? void 0 : _67.canSendCustomerReply) === true,
3655
+ requiresHumanApproval: ((_68 = customerReplyReadinessGate.metadata) === null || _68 === void 0 ? void 0 : _68.requiresHumanApproval) === true,
3656
+ proofBacked: ((_69 = customerReplyReadinessGate.metadata) === null || _69 === void 0 ? void 0 : _69.proofBacked) === true,
3657
+ businessProofReady: ((_70 = customerReplyReadinessGate.metadata) === null || _70 === void 0 ? void 0 : _70.businessProofReady) === true,
3658
+ releaseReady: ((_71 = customerReplyReadinessGate.metadata) === null || _71 === void 0 ? void 0 : _71.releaseReady) === true,
3659
+ blockers: cleanStringList((_72 = customerReplyReadinessGate.metadata) === null || _72 === void 0 ? void 0 : _72.blockers, 20, 500)
3569
3660
  } : undefined
3570
3661
  }
3571
3662
  });