@resolveio/server-lib 22.3.169 → 22.3.171

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.169",
3
+ "version": "22.3.171",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",
@@ -1502,6 +1502,108 @@ function supportCustomerReplyPolicyGate(policy, now) {
1502
1502
  }
1503
1503
  };
1504
1504
  }
1505
+ function supportNextActionContractObject(ticket, job, evidence) {
1506
+ var ticketAutomation = plainObject(ticket.automation);
1507
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
1508
+ var autonomousDecision = plainObject(job.supportV5AutonomousDecision
1509
+ || job.support_v5_autonomous_decision
1510
+ || evidence.supportV5AutonomousDecision
1511
+ || evidence.support_v5_autonomous_decision
1512
+ || ticket.supportV5AutonomousDecision
1513
+ || ticket.support_v5_autonomous_decision);
1514
+ return evidenceObject(autonomousDecision.nextActionContract, autonomousDecision.next_action_contract, job.supportV5NextActionContract, job.support_v5_next_action_contract, job.nextActionContract, job.next_action_contract, evidence.supportV5NextActionContract, evidence.support_v5_next_action_contract, evidence.nextActionContract, evidence.next_action_contract, ticket.supportV5NextActionContract, ticket.support_v5_next_action_contract, ticket.nextActionContract, ticket.next_action_contract, ticketManager.nextActionContract, ticketManager.next_action_contract);
1515
+ }
1516
+ function supportNextActionContractMetadata(contract) {
1517
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
1518
+ var decisionBasis = plainObject(contract.decisionBasis || contract.decision_basis);
1519
+ var costRisk = plainObject(contract.costRisk || contract.cost_risk);
1520
+ var source = {
1521
+ contractId: cleanText(contract.contractId || contract.contract_id, 200),
1522
+ action: cleanText(contract.action, 160),
1523
+ label: cleanText(contract.label, 300),
1524
+ primaryCommand: cleanText(contract.primaryCommand || contract.primary_command, 240),
1525
+ lane: cleanText(contract.lane, 120),
1526
+ stepType: cleanText(contract.stepType || contract.step_type, 120),
1527
+ safeToAutoRun: booleanFlag((_a = contract.safeToAutoRun) !== null && _a !== void 0 ? _a : contract.safe_to_auto_run),
1528
+ requiresHumanApproval: booleanFlag((_b = contract.requiresHumanApproval) !== null && _b !== void 0 ? _b : contract.requires_human_approval),
1529
+ canRunWithoutCodexMonitor: booleanFlag((_c = contract.canRunWithoutCodexMonitor) !== null && _c !== void 0 ? _c : contract.can_run_without_codex_monitor),
1530
+ codexFallbackRequired: booleanFlag((_d = contract.codexFallbackRequired) !== null && _d !== void 0 ? _d : contract.codex_fallback_required),
1531
+ codexFallbackReason: cleanText(contract.codexFallbackReason || contract.codex_fallback_reason, 1000),
1532
+ rootCauseFirstSatisfied: booleanFlag((_e = contract.rootCauseFirstSatisfied) !== null && _e !== void 0 ? _e : contract.root_cause_first_satisfied),
1533
+ preconditions: cleanStringList(contract.preconditions, 40, 500),
1534
+ expectedStateTransition: cleanText(contract.expectedStateTransition || contract.expected_state_transition, 1000),
1535
+ successEvidence: cleanStringList(contract.successEvidence || contract.success_evidence, 40, 500),
1536
+ stopConditions: cleanStringList(contract.stopConditions || contract.stop_conditions, 40, 500),
1537
+ forbiddenActions: cleanStringList(contract.forbiddenActions || contract.forbidden_actions, 40, 500),
1538
+ ownerFiles: cleanStringList(contract.ownerFiles || contract.owner_files || decisionBasis.ownerFiles || decisionBasis.owner_files, 40, 500),
1539
+ blockers: cleanStringList(contract.blockers, 40, 500),
1540
+ nextCommands: cleanStringList(contract.nextCommands || contract.next_commands, 40, 500),
1541
+ costRisk: {
1542
+ level: cleanText(costRisk.level || contract.costRiskLevel || contract.cost_risk_level, 80),
1543
+ estimatedUsd: numberValue((_h = (_g = (_f = costRisk.estimatedUsd) !== null && _f !== void 0 ? _f : costRisk.estimated_usd) !== null && _g !== void 0 ? _g : contract.estimatedUsd) !== null && _h !== void 0 ? _h : contract.estimated_usd),
1544
+ reason: cleanText(costRisk.reason, 800)
1545
+ },
1546
+ diagnosisValid: booleanFlag((_j = decisionBasis.diagnosisValid) !== null && _j !== void 0 ? _j : decisionBasis.diagnosis_valid),
1547
+ ownerFilesReady: booleanFlag((_k = decisionBasis.ownerFilesReady) !== null && _k !== void 0 ? _k : decisionBasis.owner_files_ready),
1548
+ proofPlanReady: booleanFlag((_l = decisionBasis.proofPlanReady) !== null && _l !== void 0 ? _l : decisionBasis.proof_plan_ready),
1549
+ businessProofReady: booleanFlag((_m = decisionBasis.businessProofReady) !== null && _m !== void 0 ? _m : decisionBasis.business_proof_ready),
1550
+ evidenceFreshnessStatus: cleanText(decisionBasis.evidenceFreshnessStatus || decisionBasis.evidence_freshness_status, 120),
1551
+ evidenceStrength: cleanText(decisionBasis.evidenceStrength || decisionBasis.evidence_strength, 120),
1552
+ failureClass: cleanText(decisionBasis.failureClass || decisionBasis.failure_class, 120),
1553
+ blockerFingerprint: cleanText(decisionBasis.blockerFingerprint || decisionBasis.blocker_fingerprint, 200),
1554
+ evidenceHash: cleanText(decisionBasis.evidenceHash || decisionBasis.evidence_hash, 200),
1555
+ sameFailureCount: numberValue((_o = decisionBasis.sameFailureCount) !== null && _o !== void 0 ? _o : decisionBasis.same_failure_count),
1556
+ hotfixCommitRequired: booleanFlag((_r = (_q = (_p = decisionBasis.hotfixCommitRequired) !== null && _p !== void 0 ? _p : decisionBasis.hotfix_commit_required) !== null && _q !== void 0 ? _q : contract.hotfixCommitRequired) !== null && _r !== void 0 ? _r : contract.hotfix_commit_required),
1557
+ liveHotfixBlockedUntilCommit: booleanFlag((_u = (_t = (_s = decisionBasis.liveHotfixBlockedUntilCommit) !== null && _s !== void 0 ? _s : decisionBasis.live_hotfix_blocked_until_commit) !== null && _t !== void 0 ? _t : contract.liveHotfixBlockedUntilCommit) !== null && _u !== void 0 ? _u : contract.live_hotfix_blocked_until_commit)
1558
+ };
1559
+ return source;
1560
+ }
1561
+ function supportNextActionContractGate(contract, now) {
1562
+ if (!contract || !Object.keys(contract).length) {
1563
+ return undefined;
1564
+ }
1565
+ var metadata = supportNextActionContractMetadata(contract);
1566
+ var blockers = cleanStringList(metadata.blockers, 40, 500);
1567
+ if (metadata.safeToAutoRun === false) {
1568
+ blockers.push('Next action contract marks the action unsafe for autonomous run.');
1569
+ }
1570
+ if (metadata.canRunWithoutCodexMonitor === false) {
1571
+ blockers.push('Next action requires Codex fallback/monitoring instead of manager-only execution.');
1572
+ }
1573
+ if (metadata.codexFallbackRequired === true) {
1574
+ blockers.push(metadata.codexFallbackReason || 'Next action contract requires Codex fallback.');
1575
+ }
1576
+ if (metadata.requiresHumanApproval === true) {
1577
+ blockers.push('Next action contract requires human approval.');
1578
+ }
1579
+ if (metadata.liveHotfixBlockedUntilCommit === true) {
1580
+ blockers.push('Live hotfix is blocked until the manager records and pushes the GitHub commit proof.');
1581
+ }
1582
+ var missingSafetyFlags = [
1583
+ metadata.safeToAutoRun === undefined ? 'safeToAutoRun' : '',
1584
+ metadata.canRunWithoutCodexMonitor === undefined ? 'canRunWithoutCodexMonitor' : '',
1585
+ metadata.codexFallbackRequired === undefined ? 'codexFallbackRequired' : ''
1586
+ ].filter(Boolean);
1587
+ var status = blockers.length
1588
+ ? 'blocked'
1589
+ : missingSafetyFlags.length
1590
+ ? 'warn'
1591
+ : 'pass';
1592
+ var actionLabel = metadata.label || metadata.action || metadata.primaryCommand || 'support next action';
1593
+ return {
1594
+ key: 'support_next_action_contract',
1595
+ label: 'Support next-action contract',
1596
+ status: status,
1597
+ reason: blockers.length
1598
+ ? blockers.join(' ')
1599
+ : missingSafetyFlags.length
1600
+ ? "Support next-action contract is present for ".concat(actionLabel, ", but missing explicit safety flags: ").concat(missingSafetyFlags.join(', '), ".")
1601
+ : "Support next-action contract allows ".concat(actionLabel, " without Codex monitoring."),
1602
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(metadata.successEvidence), false), __read(metadata.preconditions), false), __read(metadata.stopConditions), false), 40, 500),
1603
+ recordedAt: isoNow(now || contract.createdAt || contract.created_at || contract.recordedAt || contract.recorded_at),
1604
+ metadata: __assign(__assign({}, metadata), { blockers: blockers, missingSafetyFlags: missingSafetyFlags })
1605
+ };
1606
+ }
1505
1607
  function firstNonEmptyText(values, max) {
1506
1608
  var e_26, _a;
1507
1609
  if (max === void 0) { max = 1000; }
@@ -1523,6 +1625,25 @@ function firstNonEmptyText(values, max) {
1523
1625
  }
1524
1626
  return undefined;
1525
1627
  }
1628
+ function booleanFlag(value) {
1629
+ if (value === true || value === false) {
1630
+ return value;
1631
+ }
1632
+ if (typeof value === 'string') {
1633
+ var normalized = value.trim().toLowerCase();
1634
+ if (/^(true|yes|1|passed|pass|ready|safe)$/.test(normalized)) {
1635
+ return true;
1636
+ }
1637
+ if (/^(false|no|0|failed|fail|blocked|unsafe)$/.test(normalized)) {
1638
+ return false;
1639
+ }
1640
+ }
1641
+ return undefined;
1642
+ }
1643
+ function numberValue(value) {
1644
+ var parsed = Number(value);
1645
+ return Number.isFinite(parsed) ? parsed : undefined;
1646
+ }
1526
1647
  function buildAICoderQaEvidence(input) {
1527
1648
  var _a, _b, _c;
1528
1649
  var app = input.app || {};
@@ -1645,6 +1766,85 @@ function aicoderWorkflowProofReadinessGate(readiness, now) {
1645
1766
  }
1646
1767
  };
1647
1768
  }
1769
+ function aicoderWorkflowProofCheckpointObject(app, job, evidence) {
1770
+ var workflowMemory = plainObject(job.aiCoderV6WorkflowMemory
1771
+ || job.ai_coder_v6_workflow_memory
1772
+ || app.aiCoderV6WorkflowMemory
1773
+ || app.ai_coder_v6_workflow_memory
1774
+ || evidence.aiCoderV6WorkflowMemory
1775
+ || evidence.ai_coder_v6_workflow_memory);
1776
+ var continuationDecision = plainObject(job.aicoderV6ContinuationDecision
1777
+ || job.aiCoderV6ContinuationDecision
1778
+ || job.aicoder_v6_continuation_decision
1779
+ || job.ai_coder_v6_continuation_decision
1780
+ || app.aicoderV6ContinuationDecision
1781
+ || app.aiCoderV6ContinuationDecision
1782
+ || app.aicoder_v6_continuation_decision
1783
+ || evidence.aicoderV6ContinuationDecision
1784
+ || evidence.aiCoderV6ContinuationDecision
1785
+ || evidence.aicoder_v6_continuation_decision);
1786
+ return evidenceObject(continuationDecision.workflowProofCheckpoint, continuationDecision.workflow_proof_checkpoint, workflowMemory.workflowProofCheckpoint, workflowMemory.workflow_proof_checkpoint, job.workflowProofCheckpoint, job.workflow_proof_checkpoint, job.aicoderWorkflowProofCheckpoint, job.aicoder_workflow_proof_checkpoint, app.workflowProofCheckpoint, app.workflow_proof_checkpoint, evidence.workflowProofCheckpoint, evidence.workflow_proof_checkpoint, evidence.aicoderWorkflowProofCheckpoint, evidence.aicoder_workflow_proof_checkpoint);
1787
+ }
1788
+ function aicoderWorkflowProofCheckpointGate(checkpoint, now) {
1789
+ var _a, _b, _c, _d, _e;
1790
+ if (!checkpoint || !Object.keys(checkpoint).length) {
1791
+ return undefined;
1792
+ }
1793
+ var blocksProductRepairUntilJourneyContract = booleanFlag((_a = checkpoint.blocksProductRepairUntilJourneyContract) !== null && _a !== void 0 ? _a : checkpoint.blocks_product_repair_until_journey_contract) === true;
1794
+ var blocksPublishUntilWorkflowProof = booleanFlag((_b = checkpoint.blocksPublishUntilWorkflowProof) !== null && _b !== void 0 ? _b : checkpoint.blocks_publish_until_workflow_proof) === true;
1795
+ var blocksPublishUntilReleaseGate = booleanFlag((_c = checkpoint.blocksPublishUntilReleaseGate) !== null && _c !== void 0 ? _c : checkpoint.blocks_publish_until_release_gate) === true;
1796
+ var blocksWowUiUntilWorkflowProof = booleanFlag((_d = checkpoint.blocksWowUiUntilWorkflowProof) !== null && _d !== void 0 ? _d : checkpoint.blocks_wow_ui_until_workflow_proof) === true;
1797
+ var statusText = cleanText(checkpoint.status, 120);
1798
+ var required = booleanFlag(checkpoint.required) !== false;
1799
+ var blockers = cleanStringList(checkpoint.blockers, 40, 500);
1800
+ if (blocksProductRepairUntilJourneyContract) {
1801
+ blockers.push('Product repair is blocked until the journey contract is valid.');
1802
+ }
1803
+ if (blocksPublishUntilWorkflowProof) {
1804
+ blockers.push('Publish is blocked until workflow business proof passes.');
1805
+ }
1806
+ if (blocksPublishUntilReleaseGate) {
1807
+ blockers.push('Publish is blocked until release gate evidence passes.');
1808
+ }
1809
+ if (blocksWowUiUntilWorkflowProof) {
1810
+ blockers.push('Wow UI polish is blocked until workflow proof exists.');
1811
+ }
1812
+ var gateStatus = !required || statusText === 'ready_to_continue'
1813
+ ? 'pass'
1814
+ : blockers.length
1815
+ ? 'blocked'
1816
+ : 'warn';
1817
+ return {
1818
+ key: 'aicoder_workflow_proof_checkpoint',
1819
+ label: 'AICoder workflow proof checkpoint',
1820
+ status: gateStatus,
1821
+ reason: gateStatus === 'pass'
1822
+ ? 'AICoder workflow checkpoint allows the next action.'
1823
+ : (blockers.join(' ') || cleanText(checkpoint.nextAction || checkpoint.next_action || statusText, 1200) || 'AICoder workflow checkpoint requires more proof before continuing.'),
1824
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray([], __read(asArray(checkpoint.requiredEvidence || checkpoint.required_evidence)), false), __read(asArray(checkpoint.requiredResetEvidence || checkpoint.required_reset_evidence)), false), 40, 500),
1825
+ recordedAt: isoNow(now || checkpoint.recordedAt || checkpoint.recorded_at || checkpoint.createdAt || checkpoint.created_at),
1826
+ metadata: {
1827
+ required: required,
1828
+ status: statusText,
1829
+ readinessStatus: cleanText(checkpoint.readinessStatus || checkpoint.readiness_status, 120),
1830
+ nextGate: cleanText(checkpoint.nextGate || checkpoint.next_gate, 120),
1831
+ nextAction: cleanText(checkpoint.nextAction || checkpoint.next_action, 1000),
1832
+ startingFailureClass: cleanText(checkpoint.startingFailureClass || checkpoint.starting_failure_class, 120),
1833
+ startingBlockerFingerprint: cleanText(checkpoint.startingBlockerFingerprint || checkpoint.starting_blocker_fingerprint, 200),
1834
+ startingEvidenceHash: cleanText(checkpoint.startingEvidenceHash || checkpoint.starting_evidence_hash, 200),
1835
+ workflowProofFingerprint: cleanText(checkpoint.workflowProofFingerprint || checkpoint.workflow_proof_fingerprint, 200),
1836
+ artifactFingerprint: cleanText(checkpoint.artifactFingerprint || checkpoint.artifact_fingerprint, 200),
1837
+ requiredEvidence: cleanStringList(checkpoint.requiredEvidence || checkpoint.required_evidence, 40, 500),
1838
+ requiredResetEvidence: cleanStringList(checkpoint.requiredResetEvidence || checkpoint.required_reset_evidence, 40, 500),
1839
+ successRequiresWorkflowBusinessProof: booleanFlag((_e = checkpoint.successRequiresWorkflowBusinessProof) !== null && _e !== void 0 ? _e : checkpoint.success_requires_workflow_business_proof) === true,
1840
+ blocksProductRepairUntilJourneyContract: blocksProductRepairUntilJourneyContract,
1841
+ blocksPublishUntilWorkflowProof: blocksPublishUntilWorkflowProof,
1842
+ blocksPublishUntilReleaseGate: blocksPublishUntilReleaseGate,
1843
+ blocksWowUiUntilWorkflowProof: blocksWowUiUntilWorkflowProof,
1844
+ blockers: blockers
1845
+ }
1846
+ };
1847
+ }
1648
1848
  function adapterStatusPassed(value) {
1649
1849
  var normalized = cleanText(value, 120).toLowerCase();
1650
1850
  return !!normalized && /(pass|passed|success|succeeded|ok|done|complete|completed|ready|saved|published|deployed)/i.test(normalized);
@@ -2018,7 +2218,7 @@ function applyAssistantAnswerQualityGate(qa, decision, now) {
2018
2218
  }
2019
2219
  function buildSupportAIRunFromEvidence(input) {
2020
2220
  var e_28, _a, e_29, _b;
2021
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
2221
+ 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;
2022
2222
  var ticket = input.ticket || {};
2023
2223
  var job = input.job || {};
2024
2224
  var evidence = buildSupportQaEvidence(input);
@@ -2030,8 +2230,8 @@ function buildSupportAIRunFromEvidence(input) {
2030
2230
  addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
2031
2231
  addSourceId(sourceIds, 'buildPlanId', job.buildPlanId || ticket.buildPlanId);
2032
2232
  try {
2033
- for (var _z = __values(asArray(input.taskEvents)), _0 = _z.next(); !_0.done; _0 = _z.next()) {
2034
- var event_1 = _0.value;
2233
+ for (var _12 = __values(asArray(input.taskEvents)), _13 = _12.next(); !_13.done; _13 = _12.next()) {
2234
+ var event_1 = _13.value;
2035
2235
  pushEvent(events, {
2036
2236
  type: event_1.type === 'human_intervention' ? 'human_intervention' : 'log',
2037
2237
  category: cleanText(event_1.category || event_1.phase || event_1.type, 160),
@@ -2048,13 +2248,13 @@ function buildSupportAIRunFromEvidence(input) {
2048
2248
  catch (e_28_1) { e_28 = { error: e_28_1 }; }
2049
2249
  finally {
2050
2250
  try {
2051
- if (_0 && !_0.done && (_a = _z.return)) _a.call(_z);
2251
+ if (_13 && !_13.done && (_a = _12.return)) _a.call(_12);
2052
2252
  }
2053
2253
  finally { if (e_28) throw e_28.error; }
2054
2254
  }
2055
2255
  try {
2056
- for (var _1 = __values(asArray(input.aiJobs)), _2 = _1.next(); !_2.done; _2 = _1.next()) {
2057
- var aiJob = _2.value;
2256
+ for (var _14 = __values(asArray(input.aiJobs)), _15 = _14.next(); !_15.done; _15 = _14.next()) {
2257
+ var aiJob = _15.value;
2058
2258
  pushEvent(events, {
2059
2259
  type: aiJob.model ? 'model_call' : 'log',
2060
2260
  category: cleanText(aiJob.category || aiJob.phase || aiJob.runner, 160),
@@ -2072,7 +2272,7 @@ function buildSupportAIRunFromEvidence(input) {
2072
2272
  catch (e_29_1) { e_29 = { error: e_29_1 }; }
2073
2273
  finally {
2074
2274
  try {
2075
- if (_2 && !_2.done && (_b = _1.return)) _b.call(_1);
2275
+ if (_15 && !_15.done && (_b = _14.return)) _b.call(_14);
2076
2276
  }
2077
2277
  finally { if (e_29) throw e_29.error; }
2078
2278
  }
@@ -2116,6 +2316,19 @@ function buildSupportAIRunFromEvidence(input) {
2116
2316
  metadata: customerReplyPolicyGate.metadata
2117
2317
  });
2118
2318
  }
2319
+ var nextActionContract = supportNextActionContractObject(ticket, job, evidence);
2320
+ var nextActionContractGate = supportNextActionContractGate(nextActionContract, input.now);
2321
+ if (nextActionContractGate) {
2322
+ gates.push(nextActionContractGate);
2323
+ pushEvent(events, {
2324
+ type: 'log',
2325
+ category: 'support_next_action_contract',
2326
+ message: nextActionContractGate.reason,
2327
+ artifactPaths: nextActionContractGate.evidenceRefs,
2328
+ recordedAt: nextActionContractGate.recordedAt,
2329
+ metadata: nextActionContractGate.metadata
2330
+ });
2331
+ }
2119
2332
  var ticketAutomation = plainObject(ticket.automation);
2120
2333
  var ticketManagerState = plainObject(ticketAutomation.manager || ticket.manager);
2121
2334
  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);
@@ -2219,25 +2432,41 @@ function buildSupportAIRunFromEvidence(input) {
2219
2432
  reason: cleanText(businessProofReadiness.reason, 1000),
2220
2433
  blockers: cleanStringList(businessProofReadiness.blockers, 20, 500)
2221
2434
  } : undefined,
2435
+ nextActionContract: nextActionContractGate ? {
2436
+ status: nextActionContractGate.status,
2437
+ action: cleanText((_t = nextActionContractGate.metadata) === null || _t === void 0 ? void 0 : _t.action, 160),
2438
+ primaryCommand: cleanText((_u = nextActionContractGate.metadata) === null || _u === void 0 ? void 0 : _u.primaryCommand, 240),
2439
+ safeToAutoRun: ((_v = nextActionContractGate.metadata) === null || _v === void 0 ? void 0 : _v.safeToAutoRun) === true,
2440
+ canRunWithoutCodexMonitor: ((_w = nextActionContractGate.metadata) === null || _w === void 0 ? void 0 : _w.canRunWithoutCodexMonitor) === true,
2441
+ codexFallbackRequired: ((_x = nextActionContractGate.metadata) === null || _x === void 0 ? void 0 : _x.codexFallbackRequired) === true,
2442
+ requiresHumanApproval: ((_y = nextActionContractGate.metadata) === null || _y === void 0 ? void 0 : _y.requiresHumanApproval) === true,
2443
+ rootCauseFirstSatisfied: ((_z = nextActionContractGate.metadata) === null || _z === void 0 ? void 0 : _z.rootCauseFirstSatisfied) === true,
2444
+ hotfixCommitRequired: ((_0 = nextActionContractGate.metadata) === null || _0 === void 0 ? void 0 : _0.hotfixCommitRequired) === true,
2445
+ liveHotfixBlockedUntilCommit: ((_1 = nextActionContractGate.metadata) === null || _1 === void 0 ? void 0 : _1.liveHotfixBlockedUntilCommit) === true,
2446
+ failureClass: cleanText((_2 = nextActionContractGate.metadata) === null || _2 === void 0 ? void 0 : _2.failureClass, 120),
2447
+ evidenceFreshnessStatus: cleanText((_3 = nextActionContractGate.metadata) === null || _3 === void 0 ? void 0 : _3.evidenceFreshnessStatus, 120),
2448
+ sameFailureCount: Number(((_4 = nextActionContractGate.metadata) === null || _4 === void 0 ? void 0 : _4.sameFailureCount) || 0),
2449
+ blockers: cleanStringList((_5 = nextActionContractGate.metadata) === null || _5 === void 0 ? void 0 : _5.blockers, 20, 500)
2450
+ } : undefined,
2222
2451
  customerReplyPolicy: Object.keys(customerReplyPolicy).length ? {
2223
2452
  action: cleanText(customerReplyPolicy.action, 120),
2224
2453
  safety: cleanText(customerReplyPolicy.safety, 120),
2225
2454
  canDraftCustomerReply: customerReplyPolicy.canDraftCustomerReply === true || customerReplyPolicy.can_draft_customer_reply === true,
2226
2455
  canSendCustomerReply: customerReplyPolicy.canSendCustomerReply === true || customerReplyPolicy.can_send_customer_reply === true,
2227
2456
  reason: cleanText(customerReplyPolicy.reason, 1000),
2228
- reviewType: cleanText(((_t = customerReplyPolicy.humanReviewPacket) === null || _t === void 0 ? void 0 : _t.reviewType)
2229
- || ((_u = customerReplyPolicy.human_review_packet) === null || _u === void 0 ? void 0 : _u.review_type)
2230
- || ((_v = customerReplyPolicy.human_review_packet) === null || _v === void 0 ? void 0 : _v.reviewType), 160),
2231
- primaryAction: cleanText(((_w = customerReplyPolicy.humanReviewPacket) === null || _w === void 0 ? void 0 : _w.primaryAction)
2232
- || ((_x = customerReplyPolicy.human_review_packet) === null || _x === void 0 ? void 0 : _x.primary_action)
2233
- || ((_y = customerReplyPolicy.human_review_packet) === null || _y === void 0 ? void 0 : _y.primaryAction), 160)
2457
+ reviewType: cleanText(((_6 = customerReplyPolicy.humanReviewPacket) === null || _6 === void 0 ? void 0 : _6.reviewType)
2458
+ || ((_7 = customerReplyPolicy.human_review_packet) === null || _7 === void 0 ? void 0 : _7.review_type)
2459
+ || ((_8 = customerReplyPolicy.human_review_packet) === null || _8 === void 0 ? void 0 : _8.reviewType), 160),
2460
+ primaryAction: cleanText(((_9 = customerReplyPolicy.humanReviewPacket) === null || _9 === void 0 ? void 0 : _9.primaryAction)
2461
+ || ((_10 = customerReplyPolicy.human_review_packet) === null || _10 === void 0 ? void 0 : _10.primary_action)
2462
+ || ((_11 = customerReplyPolicy.human_review_packet) === null || _11 === void 0 ? void 0 : _11.primaryAction), 160)
2234
2463
  } : undefined
2235
2464
  }
2236
2465
  });
2237
2466
  }
2238
2467
  function buildAICoderAIRunFromEvidence(input) {
2239
2468
  var e_30, _a;
2240
- var _b, _c, _d, _e, _f, _g, _h;
2469
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
2241
2470
  var app = input.app || {};
2242
2471
  var job = input.job || {};
2243
2472
  var evidence = buildAICoderQaEvidence(input);
@@ -2248,8 +2477,8 @@ function buildAICoderAIRunFromEvidence(input) {
2248
2477
  addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
2249
2478
  addSourceId(sourceIds, 'domain', app.domain || app.customDomain || job.domain);
2250
2479
  try {
2251
- for (var _j = __values(asArray(input.logs)), _k = _j.next(); !_k.done; _k = _j.next()) {
2252
- var log = _k.value;
2480
+ for (var _v = __values(asArray(input.logs)), _w = _v.next(); !_w.done; _w = _v.next()) {
2481
+ var log = _w.value;
2253
2482
  pushEvent(events, {
2254
2483
  type: log.type === 'scorecard' ? 'scorecard' : 'log',
2255
2484
  category: cleanText(log.category || log.phase || log.level, 160),
@@ -2267,7 +2496,7 @@ function buildAICoderAIRunFromEvidence(input) {
2267
2496
  catch (e_30_1) { e_30 = { error: e_30_1 }; }
2268
2497
  finally {
2269
2498
  try {
2270
- if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
2499
+ if (_w && !_w.done && (_a = _v.return)) _a.call(_v);
2271
2500
  }
2272
2501
  finally { if (e_30) throw e_30.error; }
2273
2502
  }
@@ -2338,6 +2567,19 @@ function buildAICoderAIRunFromEvidence(input) {
2338
2567
  recordedAt: workflowReadinessGate.recordedAt,
2339
2568
  metadata: workflowReadinessGate.metadata
2340
2569
  });
2570
+ var workflowProofCheckpoint = aicoderWorkflowProofCheckpointObject(app, job, evidence);
2571
+ var workflowProofCheckpointGate = aicoderWorkflowProofCheckpointGate(workflowProofCheckpoint, input.now);
2572
+ if (workflowProofCheckpointGate) {
2573
+ gates.push(workflowProofCheckpointGate);
2574
+ pushEvent(events, {
2575
+ type: 'log',
2576
+ category: 'aicoder_workflow_proof_checkpoint',
2577
+ message: workflowProofCheckpointGate.reason,
2578
+ artifactPaths: workflowProofCheckpointGate.evidenceRefs,
2579
+ recordedAt: workflowProofCheckpointGate.recordedAt,
2580
+ metadata: workflowProofCheckpointGate.metadata
2581
+ });
2582
+ }
2341
2583
  var qa = applyAICoderWorkflowProofGate(buildQaFromEvidence(evidence, input.now), workflowReadiness, input.now);
2342
2584
  return (0, ai_run_evidence_1.buildAIRun)({
2343
2585
  source: 'aicoder_app',
@@ -2380,7 +2622,21 @@ function buildAICoderAIRunFromEvidence(input) {
2380
2622
  workflowProofFingerprint: workflowReadiness.workflowProofFingerprint,
2381
2623
  artifactFingerprint: workflowReadiness.artifactFingerprint,
2382
2624
  proofFreshness: workflowReadiness.proofFreshness
2383
- }
2625
+ },
2626
+ workflowProofCheckpoint: workflowProofCheckpointGate ? {
2627
+ status: cleanText((_j = workflowProofCheckpointGate.metadata) === null || _j === void 0 ? void 0 : _j.status, 120),
2628
+ gateStatus: workflowProofCheckpointGate.status,
2629
+ readinessStatus: cleanText((_k = workflowProofCheckpointGate.metadata) === null || _k === void 0 ? void 0 : _k.readinessStatus, 120),
2630
+ nextGate: cleanText((_l = workflowProofCheckpointGate.metadata) === null || _l === void 0 ? void 0 : _l.nextGate, 120),
2631
+ nextAction: cleanText((_m = workflowProofCheckpointGate.metadata) === null || _m === void 0 ? void 0 : _m.nextAction, 1000),
2632
+ blocksProductRepairUntilJourneyContract: ((_o = workflowProofCheckpointGate.metadata) === null || _o === void 0 ? void 0 : _o.blocksProductRepairUntilJourneyContract) === true,
2633
+ blocksPublishUntilWorkflowProof: ((_p = workflowProofCheckpointGate.metadata) === null || _p === void 0 ? void 0 : _p.blocksPublishUntilWorkflowProof) === true,
2634
+ blocksPublishUntilReleaseGate: ((_q = workflowProofCheckpointGate.metadata) === null || _q === void 0 ? void 0 : _q.blocksPublishUntilReleaseGate) === true,
2635
+ blocksWowUiUntilWorkflowProof: ((_r = workflowProofCheckpointGate.metadata) === null || _r === void 0 ? void 0 : _r.blocksWowUiUntilWorkflowProof) === true,
2636
+ workflowProofFingerprint: cleanText((_s = workflowProofCheckpointGate.metadata) === null || _s === void 0 ? void 0 : _s.workflowProofFingerprint, 200),
2637
+ artifactFingerprint: cleanText((_t = workflowProofCheckpointGate.metadata) === null || _t === void 0 ? void 0 : _t.artifactFingerprint, 200),
2638
+ blockers: cleanStringList((_u = workflowProofCheckpointGate.metadata) === null || _u === void 0 ? void 0 : _u.blockers, 20, 500)
2639
+ } : undefined
2384
2640
  }
2385
2641
  });
2386
2642
  }