@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.
@@ -1819,6 +1819,34 @@ function buildSupportQaEvidence(input) {
1819
1819
  if (Object.keys(managerRecoveryExecutionProof).length) {
1820
1820
  evidence.managerRecoveryExecutionProof = managerRecoveryExecutionProof;
1821
1821
  }
1822
+ var autonomyApproval = supportAutonomyApprovalObject(ticket, job, evidence);
1823
+ var productRepairDispatchGuard = supportProductRepairDispatchGuardObject(ticket, job, evidence);
1824
+ var humanDecisionRequest = supportHumanDecisionRequestObject(ticket, job, evidence);
1825
+ var managerContinuation = supportManagerContinuationObject(ticket, job, evidence);
1826
+ var prReadinessContract = supportPrReadinessContractObject(ticket, job, evidence);
1827
+ var prReviewContract = supportPrReviewContractObject(ticket, job, evidence);
1828
+ var prCreationResult = supportPrCreationResultObject(ticket, job, evidence);
1829
+ if (Object.keys(autonomyApproval).length) {
1830
+ evidence.supportV5AutonomyApproval = autonomyApproval;
1831
+ }
1832
+ if (Object.keys(productRepairDispatchGuard).length) {
1833
+ evidence.supportProductRepairDispatchGuard = productRepairDispatchGuard;
1834
+ }
1835
+ if (Object.keys(humanDecisionRequest).length) {
1836
+ evidence.supportHumanDecisionRequest = humanDecisionRequest;
1837
+ }
1838
+ if (Object.keys(managerContinuation).length) {
1839
+ evidence.supportManagerContinuation = managerContinuation;
1840
+ }
1841
+ if (Object.keys(prReadinessContract).length) {
1842
+ evidence.supportPrReadinessContract = prReadinessContract;
1843
+ }
1844
+ if (Object.keys(prReviewContract).length) {
1845
+ evidence.supportPrReviewContract = prReviewContract;
1846
+ }
1847
+ if (Object.keys(prCreationResult).length) {
1848
+ evidence.supportPrCreationResult = prCreationResult;
1849
+ }
1822
1850
  if (Object.keys(preflightGate).length) {
1823
1851
  evidence.supportV5PreflightGate = preflightGate;
1824
1852
  applySupportPreflightGateToQaEvidence(evidence, preflightGate);
@@ -2046,40 +2074,1707 @@ function supportCustomerReplyReadinessGate(contract, now) {
2046
2074
  if (!contract || !Object.keys(contract).length) {
2047
2075
  return undefined;
2048
2076
  }
2049
- var validation = (0, support_runner_v5_1.validateResolveIOSupportCustomerReplyReadinessContract)(contract);
2050
- var normalized = validation.normalized;
2051
- var status = cleanText(normalized.status, 120);
2052
- var gateStatus = normalized.canSendCustomerReply
2053
- ? 'blocked'
2054
- : validation.valid && (status === 'draft_ready' || status === 'clarification_required')
2055
- ? 'warn'
2056
- : 'blocked';
2077
+ var validation = (0, support_runner_v5_1.validateResolveIOSupportCustomerReplyReadinessContract)(contract);
2078
+ var normalized = validation.normalized;
2079
+ var status = cleanText(normalized.status, 120);
2080
+ var gateStatus = normalized.canSendCustomerReply
2081
+ ? 'blocked'
2082
+ : validation.valid && (status === 'draft_ready' || status === 'clarification_required')
2083
+ ? 'warn'
2084
+ : 'blocked';
2085
+ return {
2086
+ key: 'support_customer_reply_readiness',
2087
+ label: 'Support customer reply readiness',
2088
+ status: gateStatus,
2089
+ reason: normalized.reason || validation.blockers.join('; ') || status || 'Support customer reply readiness recorded.',
2090
+ evidenceRefs: normalized.evidenceRefs,
2091
+ recordedAt: isoNow(now || normalized.createdAt),
2092
+ metadata: {
2093
+ contractId: normalized.contractId,
2094
+ status: status,
2095
+ policyAction: normalized.policyAction,
2096
+ reviewType: normalized.reviewType,
2097
+ primaryCommand: normalized.primaryCommand,
2098
+ canDraftCustomerReply: normalized.canDraftCustomerReply,
2099
+ canSendCustomerReply: normalized.canSendCustomerReply,
2100
+ requiresHumanApproval: normalized.requiresHumanApproval,
2101
+ proofBacked: normalized.proofBacked,
2102
+ businessProofReady: normalized.businessProofReady,
2103
+ releaseReady: normalized.releaseReady,
2104
+ diagnosisReady: normalized.diagnosisReady,
2105
+ issueClassProbePlanReady: normalized.issueClassProbePlanReady,
2106
+ clarificationRequired: normalized.clarificationRequired,
2107
+ blockers: Array.from(new Set(__spreadArray(__spreadArray([], __read(normalized.blockers), false), __read(validation.blockers), false))),
2108
+ requiredEvidence: normalized.requiredEvidence,
2109
+ nextCommands: normalized.nextCommands,
2110
+ forbiddenActions: normalized.forbiddenActions
2111
+ }
2112
+ };
2113
+ }
2114
+ function supportProofBackedCustomerReplySendObject(ticket, job, evidence) {
2115
+ var ticketAutomation = plainObject(ticket.automation);
2116
+ var ticketReplyPolicy = plainObject(ticketAutomation.customer_reply_policy || ticketAutomation.customerReplyPolicy);
2117
+ var jobReplyPolicy = plainObject(job.customerReplyPolicy || job.customer_reply_policy);
2118
+ return evidenceObject(evidence.proofBackedCustomerReply, evidence.proof_backed_customer_reply, evidence.customerReplySendContract, evidence.customer_reply_send_contract, evidence.supportProofBackedCustomerReplySendContract, evidence.support_proof_backed_customer_reply_send_contract, job.proofBackedCustomerReply, job.proof_backed_customer_reply, job.customerReplySendContract, job.customer_reply_send_contract, job.supportProofBackedCustomerReplySendContract, job.support_proof_backed_customer_reply_send_contract, jobReplyPolicy.last_proof_backed_send_contract, jobReplyPolicy.lastProofBackedSendContract, jobReplyPolicy.last_manual_send, jobReplyPolicy.lastManualSend, ticketReplyPolicy.last_proof_backed_send_contract, ticketReplyPolicy.lastProofBackedSendContract, ticketReplyPolicy.last_manual_send, ticketReplyPolicy.lastManualSend);
2119
+ }
2120
+ function supportCustomerReplySendGuardObject(ticket, job, evidence) {
2121
+ var ticketAutomation = plainObject(ticket.automation);
2122
+ var ticketReplyPolicy = plainObject(ticketAutomation.customer_reply_policy || ticketAutomation.customerReplyPolicy);
2123
+ var jobReplyPolicy = plainObject(job.customerReplyPolicy || job.customer_reply_policy);
2124
+ var evidenceReplyPolicy = plainObject(evidence.customerReplyPolicy || evidence.customer_reply_policy);
2125
+ var sendContract = supportProofBackedCustomerReplySendObject(ticket, job, evidence);
2126
+ return evidenceObject(evidence.customerReplySendGuard, evidence.customer_reply_send_guard, evidence.supportCustomerReplySendGuard, evidence.support_customer_reply_send_guard, evidenceReplyPolicy.last_send_guard, evidenceReplyPolicy.lastSendGuard, evidenceReplyPolicy.last_blocked_send_guard, evidenceReplyPolicy.lastBlockedSendGuard, job.customerReplySendGuard, job.customer_reply_send_guard, job.supportCustomerReplySendGuard, job.support_customer_reply_send_guard, jobReplyPolicy.last_send_guard, jobReplyPolicy.lastSendGuard, jobReplyPolicy.last_blocked_send_guard, jobReplyPolicy.lastBlockedSendGuard, ticketReplyPolicy.last_send_guard, ticketReplyPolicy.lastSendGuard, ticketReplyPolicy.last_blocked_send_guard, ticketReplyPolicy.lastBlockedSendGuard, sendContract.send_guard, sendContract.sendGuard);
2127
+ }
2128
+ function supportProofBackedCustomerReplySendGate(sendContract, sendGuard, now) {
2129
+ if ((!sendContract || !Object.keys(sendContract).length) && (!sendGuard || !Object.keys(sendGuard).length)) {
2130
+ return undefined;
2131
+ }
2132
+ var contract = plainObject(sendContract.send_contract || sendContract.sendContract || sendContract);
2133
+ var guard = plainObject(sendGuard.send_guard || sendGuard.sendGuard || sendGuard || contract.send_guard || contract.sendGuard);
2134
+ var statusText = cleanText(contract.status || guard.status, 160).toLowerCase();
2135
+ var sentAfterManualApproval = /sent_after_manual_approval|manual_send_complete|sent/.test(statusText);
2136
+ var guardAllowed = guard.allowed === true || /ready_for_manual_send|allowed/.test(cleanText(guard.status, 160));
2137
+ var directSendAllowed = guard.direct_send_allowed === true || guard.directSendAllowed === true || contract.direct_send_allowed === true || contract.directSendAllowed === true;
2138
+ var requiresHumanApproval = guard.requires_human_approval !== false
2139
+ && guard.requiresHumanApproval !== false
2140
+ && contract.requires_human_approval !== false
2141
+ && contract.requiresHumanApproval !== false;
2142
+ var proofBacked = guard.proof_backed === true || guard.proofBacked === true || contract.proof_backed === true || contract.proofBacked === true;
2143
+ var businessProofReady = guard.business_proof_ready === true || guard.businessProofReady === true || contract.business_proof_ready === true || contract.businessProofReady === true;
2144
+ var releaseReady = guard.release_ready === true || guard.releaseReady === true || contract.release_ready === true || contract.releaseReady === true;
2145
+ var diagnosisReady = guard.diagnosis_ready === true || guard.diagnosisReady === true || contract.diagnosis_ready === true || contract.diagnosisReady === true;
2146
+ var probePlanReady = guard.issue_class_probe_plan_ready === true || guard.issueClassProbePlanReady === true || contract.issue_class_probe_plan_ready === true || contract.issueClassProbePlanReady === true;
2147
+ var pullRequestUrl = cleanText(contract.pull_request_url || contract.pullRequestUrl || guard.pull_request_url || guard.pullRequestUrl, 500);
2148
+ var blockers = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(cleanStringList(guard.blockers, 40, 500)), false), __read(cleanStringList(contract.blockers, 40, 500)), false), [
2149
+ directSendAllowed ? 'Direct customer send is not allowed; proof-backed replies require manual review/send.' : '',
2150
+ requiresHumanApproval ? '' : 'Proof-backed customer reply must require human approval.',
2151
+ (sentAfterManualApproval || guardAllowed) && !proofBacked ? 'Customer reply is not proof-backed.' : '',
2152
+ (sentAfterManualApproval || guardAllowed) && !businessProofReady ? 'AIQaBusinessAssertion business proof is not ready.' : '',
2153
+ (sentAfterManualApproval || guardAllowed) && !releaseReady ? 'Release or hotfix proof is not ready.' : '',
2154
+ (sentAfterManualApproval || guardAllowed) && !diagnosisReady ? 'Root-cause diagnosis is not ready.' : '',
2155
+ (sentAfterManualApproval || guardAllowed) && !probePlanReady ? 'Issue-class probe plan is not ready.' : '',
2156
+ (sentAfterManualApproval || guardAllowed) && !pullRequestUrl ? 'Proof-backed customer reply is missing the current PR reference.' : ''
2157
+ ], false).filter(Boolean)));
2158
+ var status = sentAfterManualApproval && blockers.length === 0
2159
+ ? 'pass'
2160
+ : guardAllowed && blockers.length === 0
2161
+ ? 'warn'
2162
+ : 'blocked';
2163
+ return {
2164
+ key: 'support_proof_backed_customer_reply_send',
2165
+ label: 'Support proof-backed customer reply send',
2166
+ status: status,
2167
+ reason: status === 'pass'
2168
+ ? 'Proof-backed customer reply was sent after manual approval with PR, business proof, release, diagnosis, and issue-class probe evidence.'
2169
+ : status === 'warn'
2170
+ ? 'Proof-backed customer reply is ready for manual review/send; automatic direct send remains blocked.'
2171
+ : blockers.join('; ') || cleanText(guard.policy_reason || contract.reason || 'Proof-backed customer reply send is blocked.', 1200),
2172
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(contract.evidence_refs || contract.evidenceRefs)), false), __read(asArray(guard.evidence_refs || guard.evidenceRefs)), false), __read(asArray(contract.required_evidence || contract.requiredEvidence)), false), [
2173
+ pullRequestUrl
2174
+ ], false), 80, 500),
2175
+ recordedAt: isoNow(now || contract.sent_at || contract.sentAt || contract.checked_at || contract.checkedAt || guard.checked_at || guard.checkedAt),
2176
+ metadata: {
2177
+ contractId: cleanText(contract.contract_id || contract.contractId, 180),
2178
+ status: cleanText(contract.status || guard.status, 160),
2179
+ guardStatus: cleanText(guard.status, 160),
2180
+ allowed: guardAllowed,
2181
+ sentAfterManualApproval: sentAfterManualApproval,
2182
+ directSendAllowed: directSendAllowed,
2183
+ manualSendAfterReviewAllowed: guard.manual_send_after_review_allowed === true || guard.manualSendAfterReviewAllowed === true || sentAfterManualApproval,
2184
+ requiresHumanApproval: requiresHumanApproval,
2185
+ proofBacked: proofBacked,
2186
+ businessProofReady: businessProofReady,
2187
+ releaseReady: releaseReady,
2188
+ diagnosisReady: diagnosisReady,
2189
+ issueClassProbePlanReady: probePlanReady,
2190
+ confidenceLevel: cleanText(guard.confidence_level || guard.confidenceLevel || contract.confidence_level || contract.confidenceLevel, 120),
2191
+ nextAction: cleanText(guard.next_action || guard.nextAction, 160),
2192
+ pullRequestUrl: pullRequestUrl,
2193
+ jobId: cleanText(contract.job_id || contract.jobId || guard.job_id || guard.jobId, 180),
2194
+ readinessContractId: cleanText(contract.readiness_contract_id || contract.readinessContractId || guard.readiness_contract_id || guard.readinessContractId, 180),
2195
+ readinessStatus: cleanText(contract.readiness_status || contract.readinessStatus || guard.readiness_status || guard.readinessStatus, 160),
2196
+ messageHash: cleanText(contract.message_hash || contract.messageHash, 180),
2197
+ recipients: cleanStringList(contract.recipients, 20, 240),
2198
+ requiredEvidence: cleanStringList(contract.required_evidence || contract.requiredEvidence || guard.required_evidence || guard.requiredEvidence, 40, 500),
2199
+ blockers: blockers
2200
+ }
2201
+ };
2202
+ }
2203
+ function supportAutonomyDecisionObject(ticket, job, evidence) {
2204
+ return plainObject(job.supportV5AutonomousDecision
2205
+ || job.support_v5_autonomous_decision
2206
+ || evidence.supportV5AutonomousDecision
2207
+ || evidence.support_v5_autonomous_decision
2208
+ || ticket.supportV5AutonomousDecision
2209
+ || ticket.support_v5_autonomous_decision);
2210
+ }
2211
+ function supportAutonomyApprovalObject(ticket, job, evidence) {
2212
+ var ticketAutomation = plainObject(ticket.automation);
2213
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2214
+ var runnerConsole = plainObject(ticketAutomation.runner_console || ticketAutomation.runnerConsole);
2215
+ var autonomousDecision = supportAutonomyDecisionObject(ticket, job, evidence);
2216
+ return evidenceObject(job.supportV5AutonomyApproval, job.support_v5_autonomy_approval, job.autonomyApproval, job.autonomy_approval, evidence.supportV5AutonomyApproval, evidence.support_v5_autonomy_approval, evidence.autonomyApproval, evidence.autonomy_approval, autonomousDecision.autonomyApproval, autonomousDecision.autonomy_approval, ticket.supportV5AutonomyApproval, ticket.support_v5_autonomy_approval, ticket.autonomyApproval, ticket.autonomy_approval, runnerConsole.autonomy_approval, runnerConsole.autonomyApproval, ticketManager.autonomy_approval, ticketManager.autonomyApproval);
2217
+ }
2218
+ function supportProductRepairDispatchGuardObject(ticket, job, evidence) {
2219
+ var ticketAutomation = plainObject(ticket.automation);
2220
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2221
+ var runnerConsole = plainObject(ticketAutomation.runner_console || ticketAutomation.runnerConsole);
2222
+ var autonomousDecision = supportAutonomyDecisionObject(ticket, job, evidence);
2223
+ var recovery = plainObject(autonomousDecision.managerRecovery || autonomousDecision.manager_recovery);
2224
+ var directive = plainObject(recovery.directive);
2225
+ return evidenceObject(job.supportProductRepairDispatchGuard, job.support_product_repair_dispatch_guard, job.productRepairDispatchGuard, job.product_repair_dispatch_guard, evidence.supportProductRepairDispatchGuard, evidence.support_product_repair_dispatch_guard, evidence.productRepairDispatchGuard, evidence.product_repair_dispatch_guard, autonomousDecision.productRepairDispatchGuard, autonomousDecision.product_repair_dispatch_guard, recovery.productRepairDispatchGuard, recovery.product_repair_dispatch_guard, directive.productRepairDispatchGuard, directive.product_repair_dispatch_guard, ticket.supportProductRepairDispatchGuard, ticket.support_product_repair_dispatch_guard, ticket.productRepairDispatchGuard, ticket.product_repair_dispatch_guard, runnerConsole.last_product_repair_dispatch_guard, runnerConsole.lastProductRepairDispatchGuard, runnerConsole.product_repair_dispatch_guard, runnerConsole.productRepairDispatchGuard, ticketManager.last_product_repair_dispatch_guard, ticketManager.lastProductRepairDispatchGuard, ticketManager.product_repair_dispatch_guard, ticketManager.productRepairDispatchGuard);
2226
+ }
2227
+ function supportAutoloopApprovalBlockObject(ticket, job, evidence) {
2228
+ var ticketAutomation = plainObject(ticket.automation);
2229
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2230
+ var runnerConsole = plainObject(ticketAutomation.runner_console || ticketAutomation.runnerConsole);
2231
+ var autoloop = plainObject(ticketAutomation.autoloop || ticket.autoloop);
2232
+ return evidenceObject(job.supportAutoloopApprovalBlock, job.support_autoloop_approval_block, job.autoloopApprovalBlock, job.autoloop_approval_block, evidence.supportAutoloopApprovalBlock, evidence.support_autoloop_approval_block, evidence.autoloopApprovalBlock, evidence.autoloop_approval_block, ticket.supportAutoloopApprovalBlock, ticket.support_autoloop_approval_block, ticket.autoloopApprovalBlock, ticket.autoloop_approval_block, autoloop.last_approval_block, autoloop.lastApprovalBlock, autoloop.approval_block, autoloop.approvalBlock, runnerConsole.last_autoloop_approval_block, runnerConsole.lastAutoloopApprovalBlock, ticketManager.last_autoloop_approval_block, ticketManager.lastAutoloopApprovalBlock);
2233
+ }
2234
+ function supportAutoloopNoProgressObject(ticket, job, evidence) {
2235
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
2236
+ var ticketAutomation = plainObject(ticket.automation);
2237
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2238
+ var runnerConsole = plainObject(ticketAutomation.runner_console || ticketAutomation.runnerConsole);
2239
+ var autoloop = plainObject(ticketAutomation.autoloop || ticket.autoloop);
2240
+ var explicit = evidenceObject(job.supportAutoloopNoProgress, job.support_autoloop_no_progress, job.autoloopNoProgress, job.autoloop_no_progress, evidence.supportAutoloopNoProgress, evidence.support_autoloop_no_progress, evidence.autoloopNoProgress, evidence.autoloop_no_progress, ticket.supportAutoloopNoProgress, ticket.support_autoloop_no_progress, ticket.autoloopNoProgress, ticket.autoloop_no_progress, autoloop.last_no_progress_block, autoloop.lastNoProgressBlock, autoloop.no_progress_block, autoloop.noProgressBlock, runnerConsole.last_autoloop_no_progress, runnerConsole.lastAutoloopNoProgress, ticketManager.last_autoloop_no_progress, ticketManager.lastAutoloopNoProgress);
2241
+ var history = asArray(explicit.history || autoloop.history)
2242
+ .map(function (entry) { return plainObject(entry); })
2243
+ .filter(function (entry) { return Object.keys(entry).length > 0; })
2244
+ .slice(-12);
2245
+ if (Object.keys(explicit).length) {
2246
+ return __assign(__assign({ source: 'support_autoloop_no_progress' }, explicit), { status: explicit.status || autoloop.status, run_id: explicit.run_id || explicit.runId || autoloop.run_id || autoloop.runId, handoff_required: (_c = (_b = (_a = explicit.handoff_required) !== null && _a !== void 0 ? _a : explicit.handoffRequired) !== null && _b !== void 0 ? _b : autoloop.handoff_required) !== null && _c !== void 0 ? _c : autoloop.handoffRequired, no_progress_streak: (_f = (_e = (_d = explicit.no_progress_streak) !== null && _d !== void 0 ? _d : explicit.noProgressStreak) !== null && _e !== void 0 ? _e : autoloop.no_progress_streak) !== null && _f !== void 0 ? _f : autoloop.noProgressStreak, last_progress_signal: (_j = (_h = (_g = explicit.last_progress_signal) !== null && _g !== void 0 ? _g : explicit.lastProgressSignal) !== null && _h !== void 0 ? _h : autoloop.last_progress_signal) !== null && _j !== void 0 ? _j : autoloop.lastProgressSignal, last_progress_reasons: explicit.last_progress_reasons || explicit.lastProgressReasons || autoloop.last_progress_reasons || autoloop.lastProgressReasons, last_evidence_changed: (_m = (_l = (_k = explicit.last_evidence_changed) !== null && _k !== void 0 ? _k : explicit.lastEvidenceChanged) !== null && _l !== void 0 ? _l : explicit.evidence_changed) !== null && _m !== void 0 ? _m : explicit.evidenceChanged, last_evidence_reasons: explicit.last_evidence_reasons || explicit.lastEvidenceReasons || explicit.evidence_reasons || explicit.evidenceReasons, last_strict_gate_reason: explicit.last_strict_gate_reason || explicit.lastStrictGateReason || autoloop.last_strict_gate_reason || autoloop.lastStrictGateReason, last_error: explicit.last_error || explicit.lastError || autoloop.last_error || autoloop.lastError, last_continuation_decision: explicit.last_continuation_decision || explicit.lastContinuationDecision || autoloop.last_continuation_decision || autoloop.lastContinuationDecision, last_continuation_dispatch: explicit.last_continuation_dispatch || explicit.lastContinuationDispatch || autoloop.last_continuation_dispatch || autoloop.lastContinuationDispatch, history: history, latest_history: plainObject(explicit.latest_history || explicit.latestHistory || history[history.length - 1]), cost: explicit.cost || autoloop.cost, recorded_at: explicit.recorded_at || explicit.recordedAt || autoloop.updated_at || autoloop.updatedAt || autoloop.last_iteration_at || autoloop.lastIterationAt });
2247
+ }
2248
+ var latestHistory = plainObject(history[history.length - 1]);
2249
+ var noProgressStreak = Math.max(0, Number(autoloop.no_progress_streak || autoloop.noProgressStreak || 0) || 0);
2250
+ var lastProgressSignal = booleanFlag((_q = (_p = (_o = autoloop.last_progress_signal) !== null && _o !== void 0 ? _o : autoloop.lastProgressSignal) !== null && _p !== void 0 ? _p : latestHistory.progress_signal) !== null && _q !== void 0 ? _q : latestHistory.progressSignal);
2251
+ var latestEvidenceChanged = booleanFlag((_t = (_s = (_r = autoloop.last_evidence_changed) !== null && _r !== void 0 ? _r : autoloop.lastEvidenceChanged) !== null && _s !== void 0 ? _s : latestHistory.evidence_changed) !== null && _t !== void 0 ? _t : latestHistory.evidenceChanged);
2252
+ var lastError = cleanText(autoloop.last_error || autoloop.lastError || latestHistory.error, 2000);
2253
+ var noProgressError = /no[-_\s]?progress|no new diff|no new .*evidence|without progress|retry blocked|same failure/i.test(lastError);
2254
+ if (noProgressStreak <= 0
2255
+ && lastProgressSignal !== false
2256
+ && latestEvidenceChanged !== false
2257
+ && !noProgressError) {
2258
+ return {};
2259
+ }
2260
+ return {
2261
+ source: 'support_autoloop_no_progress',
2262
+ status: cleanText(autoloop.status, 120),
2263
+ run_id: autoloop.run_id || autoloop.runId,
2264
+ handoff_required: autoloop.handoff_required === true || autoloop.handoffRequired === true,
2265
+ no_progress_streak: noProgressStreak,
2266
+ last_progress_signal: lastProgressSignal,
2267
+ last_progress_reasons: autoloop.last_progress_reasons || autoloop.lastProgressReasons || latestHistory.progress_reasons || latestHistory.progressReasons,
2268
+ last_evidence_changed: latestEvidenceChanged,
2269
+ last_evidence_reasons: autoloop.last_evidence_reasons || autoloop.lastEvidenceReasons || latestHistory.evidence_reasons || latestHistory.evidenceReasons,
2270
+ last_strict_gate_reason: autoloop.last_strict_gate_reason || autoloop.lastStrictGateReason || latestHistory.strict_gate_reason || latestHistory.strictGateReason,
2271
+ last_error: lastError,
2272
+ last_continuation_decision: autoloop.last_continuation_decision || autoloop.lastContinuationDecision || latestHistory.continuation_decision || latestHistory.continuationDecision,
2273
+ last_continuation_dispatch: autoloop.last_continuation_dispatch || autoloop.lastContinuationDispatch,
2274
+ history: history,
2275
+ latest_history: latestHistory,
2276
+ cost: autoloop.cost,
2277
+ recorded_at: autoloop.updated_at || autoloop.updatedAt || autoloop.last_iteration_at || autoloop.lastIterationAt
2278
+ };
2279
+ }
2280
+ function supportHumanDecisionRequestObject(ticket, job, evidence) {
2281
+ var ticketAutomation = plainObject(ticket.automation);
2282
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2283
+ var runnerConsole = plainObject(ticketAutomation.runner_console || ticketAutomation.runnerConsole);
2284
+ var autonomousDecision = supportAutonomyDecisionObject(ticket, job, evidence);
2285
+ var recovery = plainObject(autonomousDecision.managerRecovery || autonomousDecision.manager_recovery);
2286
+ var autoloopApprovalBlock = supportAutoloopApprovalBlockObject(ticket, job, evidence);
2287
+ return evidenceObject(job.supportHumanDecisionRequest, job.support_human_decision_request, job.humanDecisionRequest, job.human_decision_request, evidence.supportHumanDecisionRequest, evidence.support_human_decision_request, evidence.humanDecisionRequest, evidence.human_decision_request, autonomousDecision.humanDecisionRequest, autonomousDecision.human_decision_request, recovery.humanDecisionRequest, recovery.human_decision_request, ticket.supportHumanDecisionRequest, ticket.support_human_decision_request, ticket.humanDecisionRequest, ticket.human_decision_request, runnerConsole.last_human_decision_request, runnerConsole.lastHumanDecisionRequest, runnerConsole.human_decision_request, runnerConsole.humanDecisionRequest, ticketManager.last_human_decision_request, ticketManager.lastHumanDecisionRequest, ticketManager.human_decision_request, ticketManager.humanDecisionRequest, autoloopApprovalBlock.human_decision_request, autoloopApprovalBlock.humanDecisionRequest);
2288
+ }
2289
+ function supportPostApprovalAutostartObject(ticket, job, evidence) {
2290
+ var ticketAutomation = plainObject(ticket.automation);
2291
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2292
+ var runnerConsole = plainObject(ticketAutomation.runner_console || ticketAutomation.runnerConsole);
2293
+ var autonomousDecision = supportAutonomyDecisionObject(ticket, job, evidence);
2294
+ var autonomyApproval = supportAutonomyApprovalObject(ticket, job, evidence);
2295
+ var contract = evidenceObject(job.supportPostApprovalAutostartContract, job.support_post_approval_autostart_contract, job.postApprovalAutostartContract, job.post_approval_autostart_contract, evidence.supportPostApprovalAutostartContract, evidence.support_post_approval_autostart_contract, evidence.postApprovalAutostartContract, evidence.post_approval_autostart_contract, autonomousDecision.postApprovalAutostartContract, autonomousDecision.post_approval_autostart_contract, autonomyApproval.postApprovalAutostartContract, autonomyApproval.post_approval_autostart_contract, ticket.supportPostApprovalAutostartContract, ticket.support_post_approval_autostart_contract, ticket.postApprovalAutostartContract, ticket.post_approval_autostart_contract, runnerConsole.last_post_approval_autostart_contract, runnerConsole.lastPostApprovalAutostartContract, runnerConsole.post_approval_autostart_contract, runnerConsole.postApprovalAutostartContract, ticketManager.last_post_approval_autostart_contract, ticketManager.lastPostApprovalAutostartContract, ticketManager.post_approval_autostart_contract, ticketManager.postApprovalAutostartContract);
2296
+ var record = evidenceObject(job.supportPostApprovalAutostart, job.support_post_approval_autostart, job.postApprovalAutostart, job.post_approval_autostart, evidence.supportPostApprovalAutostart, evidence.support_post_approval_autostart, evidence.postApprovalAutostart, evidence.post_approval_autostart, autonomousDecision.postApprovalAutostart, autonomousDecision.post_approval_autostart, autonomyApproval.postApprovalAutostart, autonomyApproval.post_approval_autostart, ticket.supportPostApprovalAutostart, ticket.support_post_approval_autostart, ticket.postApprovalAutostart, ticket.post_approval_autostart, runnerConsole.last_post_approval_autostart, runnerConsole.lastPostApprovalAutostart, runnerConsole.post_approval_autostart, runnerConsole.postApprovalAutostart, ticketManager.last_post_approval_autostart, ticketManager.lastPostApprovalAutostart, ticketManager.post_approval_autostart, ticketManager.postApprovalAutostart);
2297
+ if (!Object.keys(contract).length && !Object.keys(record).length) {
2298
+ return {};
2299
+ }
2300
+ return {
2301
+ source: 'support_post_approval_autostart',
2302
+ contract: contract,
2303
+ record: record,
2304
+ status: record.status || contract.status,
2305
+ next_action: record.next_action || record.nextAction,
2306
+ recorded_at: record.recorded_at || record.recordedAt || contract.recorded_at || contract.recordedAt
2307
+ };
2308
+ }
2309
+ function supportPostApprovalResumeAttemptObject(ticket, job, evidence) {
2310
+ var ticketAutomation = plainObject(ticket.automation);
2311
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2312
+ var runnerConsole = plainObject(ticketAutomation.runner_console || ticketAutomation.runnerConsole);
2313
+ var record = evidenceObject(job.supportPostApprovalResumeAttempt, job.support_post_approval_resume_attempt, job.postApprovalResumeAttempt, job.post_approval_resume_attempt, evidence.supportPostApprovalResumeAttempt, evidence.support_post_approval_resume_attempt, evidence.postApprovalResumeAttempt, evidence.post_approval_resume_attempt, ticket.supportPostApprovalResumeAttempt, ticket.support_post_approval_resume_attempt, ticket.postApprovalResumeAttempt, ticket.post_approval_resume_attempt, runnerConsole.last_post_approval_resume_attempt, runnerConsole.lastPostApprovalResumeAttempt, ticketManager.last_post_approval_resume_attempt, ticketManager.lastPostApprovalResumeAttempt);
2314
+ if (!Object.keys(record).length) {
2315
+ return {};
2316
+ }
2317
+ return {
2318
+ source: 'support_post_approval_resume_attempt',
2319
+ record: record,
2320
+ status: record.status,
2321
+ next_action: record.next_action || record.nextAction,
2322
+ recorded_at: record.recorded_at || record.recordedAt
2323
+ };
2324
+ }
2325
+ function supportIntakeRevisionContractObject(ticket, job, evidence) {
2326
+ var ticketAutomation = plainObject(ticket.automation);
2327
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2328
+ var runnerConsole = plainObject(ticketAutomation.runner_console || ticketAutomation.runnerConsole);
2329
+ return evidenceObject(job.supportIntakeRevisionContract, job.support_intake_revision_contract, job.intakeRevisionContract, job.intake_revision_contract, evidence.supportIntakeRevisionContract, evidence.support_intake_revision_contract, evidence.intakeRevisionContract, evidence.intake_revision_contract, ticket.supportIntakeRevisionContract, ticket.support_intake_revision_contract, ticket.intakeRevisionContract, ticket.intake_revision_contract, runnerConsole.last_intake_revision_contract, runnerConsole.lastIntakeRevisionContract, runnerConsole.intake_revision_contract, runnerConsole.intakeRevisionContract, ticketManager.last_intake_revision_contract, ticketManager.lastIntakeRevisionContract, ticketManager.intake_revision_contract, ticketManager.intakeRevisionContract);
2330
+ }
2331
+ function supportManagerContinuationObject(ticket, job, evidence) {
2332
+ var ticketAutomation = plainObject(ticket.automation);
2333
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2334
+ var runnerConsole = plainObject(ticketAutomation.runner_console || ticketAutomation.runnerConsole);
2335
+ var autonomousDecision = supportAutonomyDecisionObject(ticket, job, evidence);
2336
+ var recovery = plainObject(autonomousDecision.managerRecovery || autonomousDecision.manager_recovery);
2337
+ var directive = plainObject(recovery.directive);
2338
+ var continuationContract = evidenceObject(job.supportManagerContinuationContract, job.support_manager_continuation_contract, job.continuationContract, job.continuation_contract, evidence.supportManagerContinuationContract, evidence.support_manager_continuation_contract, evidence.continuationContract, evidence.continuation_contract, autonomousDecision.continuationContract, autonomousDecision.continuation_contract, recovery.continuationContract, recovery.continuation_contract, directive.continuationContract, directive.continuation_contract, ticketManager.last_continuation_contract, ticketManager.lastContinuationContract, runnerConsole.last_continuation_contract, runnerConsole.lastContinuationContract);
2339
+ var operatorGuidanceResponse = evidenceObject(job.operatorGuidanceResponse, job.operator_guidance_response, job.supportOperatorGuidanceResponse, job.support_operator_guidance_response, evidence.operatorGuidanceResponse, evidence.operator_guidance_response, recovery.operatorGuidanceResponse, recovery.operator_guidance_response, ticketManager.last_operator_guidance_response, ticketManager.lastOperatorGuidanceResponse, runnerConsole.last_operator_guidance_response, runnerConsole.lastOperatorGuidanceResponse);
2340
+ var resumeUnblockContract = evidenceObject(continuationContract.resume_unblock_contract, continuationContract.resumeUnblockContract, operatorGuidanceResponse.resume_unblock_contract, operatorGuidanceResponse.resumeUnblockContract, recovery.resume_unblock_contract, recovery.resumeUnblockContract);
2341
+ var resumeUnblockResponse = evidenceObject(operatorGuidanceResponse.resume_unblock_response, operatorGuidanceResponse.resumeUnblockResponse, recovery.resume_unblock_response, recovery.resumeUnblockResponse);
2342
+ var resumeDispatch = evidenceObject(job.operatorGuidanceResumeDispatch, job.operator_guidance_resume_dispatch, evidence.operatorGuidanceResumeDispatch, evidence.operator_guidance_resume_dispatch, recovery.operatorGuidanceResumeDispatch, recovery.operator_guidance_resume_dispatch, ticketManager.last_operator_guidance_resume_dispatch, ticketManager.lastOperatorGuidanceResumeDispatch, runnerConsole.last_operator_guidance_resume_dispatch, runnerConsole.lastOperatorGuidanceResumeDispatch);
2343
+ if (!Object.keys(continuationContract).length && !Object.keys(operatorGuidanceResponse).length && !Object.keys(resumeUnblockContract).length && !Object.keys(resumeDispatch).length) {
2344
+ return {};
2345
+ }
2346
+ return {
2347
+ source: 'support_manager_continuation',
2348
+ continuation_contract: continuationContract,
2349
+ operator_guidance_response: operatorGuidanceResponse,
2350
+ resume_unblock_contract: resumeUnblockContract,
2351
+ resume_unblock_response: resumeUnblockResponse,
2352
+ resume_dispatch: resumeDispatch,
2353
+ manager_status: cleanText(ticketManager.status || runnerConsole.manager_status || runnerConsole.managerStatus, 120),
2354
+ recorded_at: operatorGuidanceResponse.recorded_at || operatorGuidanceResponse.recordedAt || resumeDispatch.created_at || resumeDispatch.createdAt || continuationContract.recorded_at || continuationContract.recordedAt
2355
+ };
2356
+ }
2357
+ function supportApprovalExplicitlyApprovesOverLimit(approval) {
2358
+ return approval.approve_over_max_hours === true
2359
+ || approval.approveOverMaxHours === true
2360
+ || approval.approve_over_six_hours === true
2361
+ || approval.approveOverSixHours === true
2362
+ || approval.over_limit_approved === true
2363
+ || approval.overLimitApproved === true
2364
+ || approval.over_max_auto_hours_approved === true
2365
+ || approval.overMaxAutoHoursApproved === true
2366
+ || approval.operator_approved_over_limit === true
2367
+ || approval.operatorApprovedOverLimit === true;
2368
+ }
2369
+ function sameSupportApprovalFileSet(left, right) {
2370
+ var normalizedLeft = Array.from(new Set(left.map(function (entry) { return entry.trim(); }).filter(Boolean))).sort();
2371
+ var normalizedRight = Array.from(new Set(right.map(function (entry) { return entry.trim(); }).filter(Boolean))).sort();
2372
+ return normalizedLeft.length === normalizedRight.length
2373
+ && normalizedLeft.every(function (entry, index) { return entry === normalizedRight[index]; });
2374
+ }
2375
+ function supportApprovalOwnerFilesDiffer(approval) {
2376
+ var currentOwnerFiles = cleanStringList(approval.current_owner_files
2377
+ || approval.currentOwnerFiles
2378
+ || approval.owner_files
2379
+ || approval.ownerFiles, 80, 500);
2380
+ var approvedOwnerFiles = cleanStringList(approval.approved_owner_files
2381
+ || approval.approvedOwnerFiles, 80, 500);
2382
+ if (!currentOwnerFiles.length || !approvedOwnerFiles.length) {
2383
+ return false;
2384
+ }
2385
+ return !sameSupportApprovalFileSet(currentOwnerFiles, approvedOwnerFiles);
2386
+ }
2387
+ function supportAutonomyApprovalGate(approval, now) {
2388
+ var _a, _b;
2389
+ if (!approval || !Object.keys(approval).length) {
2390
+ return undefined;
2391
+ }
2392
+ var approved = approval.approved === true;
2393
+ var statusText = cleanText(approval.status, 120).toLowerCase();
2394
+ var decisionKind = cleanText(approval.decision_kind || approval.decisionKind || approval.approval_kind || approval.approvalKind, 120);
2395
+ var approvalAction = cleanText(approval.approval_action || approval.approvalAction, 120);
2396
+ var blockers = cleanStringList(approval.blockers, 40, 500);
2397
+ var estimatedHours = numberValue((_a = approval.estimated_hours) !== null && _a !== void 0 ? _a : approval.estimatedHours);
2398
+ var maxAutoHours = numberValue((_b = approval.max_auto_hours_without_approval) !== null && _b !== void 0 ? _b : approval.maxAutoHoursWithoutApproval) || 6;
2399
+ var overLimitExplicitlyApproved = supportApprovalExplicitlyApprovesOverLimit(approval);
2400
+ var bugNotBug = cleanText(approval.bug_not_bug || approval.bugNotBug, 80);
2401
+ var bugNotBugKnown = approval.bug_not_bug_known === true
2402
+ || approval.bugNotBugKnown === true
2403
+ || bugNotBug === 'bug'
2404
+ || bugNotBug === 'not_bug'
2405
+ || bugNotBug === 'not bug';
2406
+ var bugNotBugApproved = approval.bug_not_bug_classification_approved === true || approval.bugNotBugClassificationApproved === true;
2407
+ var approvedOwnerFileSetChanged = supportApprovalOwnerFilesDiffer(approval);
2408
+ var ownerFiles = cleanStringList(approval.owner_files || approval.ownerFiles, 60, 500);
2409
+ var approvedOwnerFiles = cleanStringList(approval.approved_owner_files || approval.approvedOwnerFiles, 60, 500);
2410
+ var currentOwnerFiles = cleanStringList(approval.current_owner_files || approval.currentOwnerFiles || approval.owner_files || approval.ownerFiles, 60, 500);
2411
+ var approvedOwnerFileSet = new Set(approvedOwnerFiles);
2412
+ var currentOwnerFileSet = new Set(currentOwnerFiles);
2413
+ var computedOwnerFilesAdded = currentOwnerFiles.filter(function (entry) { return !approvedOwnerFileSet.has(entry); });
2414
+ var computedOwnerFilesRemoved = approvedOwnerFiles.filter(function (entry) { return !currentOwnerFileSet.has(entry); });
2415
+ var ownerFilesChangedSinceApproval = approval.owner_files_changed_since_approval === true
2416
+ || approval.ownerFilesChangedSinceApproval === true
2417
+ || approvedOwnerFileSetChanged
2418
+ || computedOwnerFilesAdded.length > 0
2419
+ || computedOwnerFilesRemoved.length > 0;
2420
+ var scopeFingerprint = cleanText(approval.scope_fingerprint || approval.scopeFingerprint, 180);
2421
+ var previousScopeFingerprint = cleanText(approval.previous_scope_fingerprint || approval.previousScopeFingerprint, 180);
2422
+ var scopeChangedSinceApproval = approval.scope_changed_since_approval === true
2423
+ || approval.scopeChangedSinceApproval === true
2424
+ || (!!scopeFingerprint && !!previousScopeFingerprint && scopeFingerprint !== previousScopeFingerprint);
2425
+ var diagnosisScopeFingerprint = cleanText(approval.diagnosis_scope_fingerprint || approval.diagnosisScopeFingerprint, 180);
2426
+ var previousDiagnosisScopeFingerprint = cleanText(approval.previous_diagnosis_scope_fingerprint || approval.previousDiagnosisScopeFingerprint, 180);
2427
+ var diagnosisScopeChangedSinceApproval = approval.diagnosis_scope_changed_since_approval === true
2428
+ || approval.diagnosisScopeChangedSinceApproval === true
2429
+ || (!!diagnosisScopeFingerprint && !!previousDiagnosisScopeFingerprint && diagnosisScopeFingerprint !== previousDiagnosisScopeFingerprint);
2430
+ var boundedAutopilotApproval = approval.after_approval_autopilot_until_a_grade === true
2431
+ || approval.afterApprovalAutopilotUntilAGrade === true
2432
+ || approval.autopilot_after_approval_until_a_grade === true
2433
+ || approval.le_six_hour_scope_can_autofix_after_approval === true
2434
+ || approval.leSixHourScopeCanAutofixAfterApproval === true
2435
+ || estimatedHours !== undefined
2436
+ || !!bugNotBug
2437
+ || cleanStringList(approval.owner_files || approval.ownerFiles, 20, 500).length > 0;
2438
+ if (approval.requires_over_limit_approval === true || approval.requiresOverLimitApproval === true) {
2439
+ blockers.push('Estimated work is over the automatic hour ceiling and requires operator approval.');
2440
+ }
2441
+ if (approval.requires_scope_reapproval === true || approval.requiresScopeReapproval === true || scopeChangedSinceApproval) {
2442
+ blockers.push('The approved support scope changed and requires on-the-fly reapproval.');
2443
+ }
2444
+ if (approval.requires_owner_file_reapproval === true || approval.requiresOwnerFileReapproval === true) {
2445
+ blockers.push('The owner-file set changed after approval and requires reapproval.');
2446
+ }
2447
+ if (approval.requires_intake_reapproval === true || approval.requiresIntakeReapproval === true) {
2448
+ blockers.push('The support intake/classification changed after approval and requires reapproval.');
2449
+ }
2450
+ if (approval.requires_diagnosis_scope_reapproval === true || approval.requiresDiagnosisScopeReapproval === true || diagnosisScopeChangedSinceApproval) {
2451
+ blockers.push('The accepted diagnosis/proof scope changed after approval and requires reapproval.');
2452
+ }
2453
+ if (approval.requires_classification_approval === true || approval.requiresClassificationApproval === true) {
2454
+ blockers.push('Bug/not-bug classification must be approved before product-code repair.');
2455
+ }
2456
+ if (approval.requires_estimate_hours === true || approval.requiresEstimateHours === true) {
2457
+ blockers.push('Estimated hours must be recorded before product-code repair.');
2458
+ }
2459
+ if (approved && boundedAutopilotApproval && bugNotBugKnown !== true) {
2460
+ blockers.push('Bug/not-bug classification must be set before approved support autopilot can repair product code.');
2461
+ }
2462
+ if (approved && boundedAutopilotApproval && bugNotBugApproved !== true) {
2463
+ blockers.push('Bug/not-bug classification must be approved before approved support autopilot can repair product code.');
2464
+ }
2465
+ if (approved && boundedAutopilotApproval && estimatedHours === undefined) {
2466
+ blockers.push('Estimated hours must be recorded before approved support autopilot can repair product code.');
2467
+ }
2468
+ if (approved && estimatedHours !== undefined && estimatedHours > maxAutoHours && overLimitExplicitlyApproved !== true) {
2469
+ blockers.push("Estimated work is ".concat(estimatedHours, " hours, above the ").concat(maxAutoHours, "-hour autonomy ceiling, and needs explicit over-limit operator approval."));
2470
+ }
2471
+ if (approved && approvedOwnerFileSetChanged) {
2472
+ blockers.push('Current owner files differ from approved owner files and require on-the-fly reapproval.');
2473
+ }
2474
+ var uniqueBlockers = Array.from(new Set(blockers));
2475
+ var autopilotCompletionContract = plainObject(approval.autopilot_completion_contract || approval.autopilotCompletionContract);
2476
+ var status = approved && uniqueBlockers.length === 0 ? 'pass' : 'blocked';
2477
+ var reason = approved
2478
+ ? 'Support autonomy is approved for bounded product-code repair until A-grade QA/business proof is reached.'
2479
+ : cleanText(uniqueBlockers.join(' ') || approval.reason || approval.approval_question || approval.approvalQuestion || statusText || 'Support autonomy approval is required before product-code repair.', 1200);
2480
+ return {
2481
+ key: 'support_autonomy_approval',
2482
+ label: 'Support autonomy approval',
2483
+ status: status,
2484
+ reason: status === 'pass' ? reason : cleanText(uniqueBlockers.join(' ') || reason, 1200),
2485
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(approval.required_completion_evidence || approval.requiredCompletionEvidence)), false), __read(asArray(approval.owner_files || approval.ownerFiles)), false), __read(asArray(approval.approved_owner_files || approval.approvedOwnerFiles)), false), 60, 500),
2486
+ recordedAt: isoNow(now || approval.approved_at || approval.approvedAt || approval.created_at || approval.createdAt || approval.recorded_at || approval.recordedAt),
2487
+ metadata: {
2488
+ contractId: cleanText(approval.contract_id || approval.contractId, 180),
2489
+ status: statusText,
2490
+ approved: approved,
2491
+ approvedAt: cleanText(approval.approved_at || approval.approvedAt, 80),
2492
+ approvedBy: cleanText(approval.approved_by || approval.approvedBy, 160),
2493
+ decisionKind: decisionKind,
2494
+ approvalAction: approvalAction,
2495
+ approvalLabel: cleanText(approval.approval_label || approval.approvalLabel, 160),
2496
+ preferredChoiceId: cleanText(approval.preferred_choice_id || approval.preferredChoiceId, 120),
2497
+ canApproveFromConsole: approval.can_approve_from_console !== false && approval.canApproveFromConsole !== false,
2498
+ estimatedHours: estimatedHours,
2499
+ estimatedHoursKnown: estimatedHours !== undefined,
2500
+ maxAutoHoursWithoutApproval: maxAutoHours,
2501
+ overMaxAutoHours: approval.over_max_auto_hours === true || approval.overMaxAutoHours === true,
2502
+ approveOverMaxHours: approval.approve_over_max_hours === true || approval.approveOverMaxHours === true,
2503
+ approveOverSixHours: approval.approve_over_six_hours === true || approval.approveOverSixHours === true,
2504
+ explicitOverLimitApproval: overLimitExplicitlyApproved,
2505
+ bugNotBug: bugNotBug,
2506
+ bugNotBugKnown: bugNotBugKnown,
2507
+ bugNotBugClassificationApproved: bugNotBugApproved,
2508
+ requiresOverLimitApproval: approval.requires_over_limit_approval === true || approval.requiresOverLimitApproval === true,
2509
+ requiresScopeReapproval: approval.requires_scope_reapproval === true || approval.requiresScopeReapproval === true,
2510
+ requiresOwnerFileReapproval: approval.requires_owner_file_reapproval === true || approval.requiresOwnerFileReapproval === true,
2511
+ requiresIntakeReapproval: approval.requires_intake_reapproval === true || approval.requiresIntakeReapproval === true,
2512
+ requiresDiagnosisScopeReapproval: approval.requires_diagnosis_scope_reapproval === true || approval.requiresDiagnosisScopeReapproval === true,
2513
+ requiresClassificationApproval: approval.requires_classification_approval === true || approval.requiresClassificationApproval === true,
2514
+ requiresEstimateHours: approval.requires_estimate_hours === true || approval.requiresEstimateHours === true,
2515
+ changeApprovalMode: cleanText(approval.change_approval_mode || approval.changeApprovalMode, 120),
2516
+ overSixHourRequiresExplicitOperatorApproval: approval.over_six_hour_requires_explicit_operator_approval === true || approval.overSixHourRequiresExplicitOperatorApproval === true,
2517
+ leSixHourScopeCanAutofixAfterApproval: approval.le_six_hour_scope_can_autofix_after_approval === true || approval.leSixHourScopeCanAutofixAfterApproval === true,
2518
+ afterApprovalAutopilotUntilAGrade: approval.after_approval_autopilot_until_a_grade === true || approval.afterApprovalAutopilotUntilAGrade === true || approval.autopilot_after_approval_until_a_grade === true,
2519
+ targetGrade: cleanText(approval.target_grade || approval.targetGrade || 'A', 20),
2520
+ autopilotCompletionStatus: cleanText(autopilotCompletionContract.status, 120),
2521
+ terminalTarget: cleanText(autopilotCompletionContract.required_terminal_state || autopilotCompletionContract.requiredTerminalState, 800),
2522
+ stopOrParkConditions: cleanStringList(autopilotCompletionContract.stop_or_park_conditions || autopilotCompletionContract.stopOrParkConditions, 20, 500),
2523
+ qaScreenshotsRequired: approval.qa_screenshots_required === true || approval.qaScreenshotsRequired === true,
2524
+ beforeActionAfterBusinessProofRequired: approval.before_action_after_business_proof_required === true || approval.beforeActionAfterBusinessProofRequired === true,
2525
+ aiqaBusinessAssertionRequired: approval.aiqa_business_assertion_required === true || approval.aiqaBusinessAssertionRequired === true,
2526
+ scopeFingerprint: scopeFingerprint,
2527
+ previousScopeFingerprint: previousScopeFingerprint,
2528
+ scopeChangedSinceApproval: scopeChangedSinceApproval,
2529
+ ownerFilesChangedSinceApproval: ownerFilesChangedSinceApproval,
2530
+ ownerFileFingerprint: cleanText(approval.owner_file_fingerprint || approval.ownerFileFingerprint, 180),
2531
+ approvedOwnerFileFingerprint: cleanText(approval.approved_owner_file_fingerprint || approval.approvedOwnerFileFingerprint, 180),
2532
+ ownerFilesAddedSinceApproval: cleanStringList(approval.owner_files_added_since_approval || approval.ownerFilesAddedSinceApproval, 40, 500).length
2533
+ ? cleanStringList(approval.owner_files_added_since_approval || approval.ownerFilesAddedSinceApproval, 40, 500)
2534
+ : computedOwnerFilesAdded,
2535
+ ownerFilesRemovedSinceApproval: cleanStringList(approval.owner_files_removed_since_approval || approval.ownerFilesRemovedSinceApproval, 40, 500).length
2536
+ ? cleanStringList(approval.owner_files_removed_since_approval || approval.ownerFilesRemovedSinceApproval, 40, 500)
2537
+ : computedOwnerFilesRemoved,
2538
+ diagnosisScopeFingerprint: diagnosisScopeFingerprint,
2539
+ previousDiagnosisScopeFingerprint: previousDiagnosisScopeFingerprint,
2540
+ diagnosisScopeIncluded: approval.diagnosis_scope_included === true || approval.diagnosisScopeIncluded === true || !!diagnosisScopeFingerprint,
2541
+ diagnosisScopeValid: approval.diagnosis_scope_valid === true || approval.diagnosisScopeValid === true,
2542
+ diagnosisScopeChangedSinceApproval: diagnosisScopeChangedSinceApproval,
2543
+ diagnosisScopeFields: cleanStringList(approval.diagnosis_scope_fields || approval.diagnosisScopeFields, 40, 160),
2544
+ diagnosisScopeBlockers: cleanStringList(approval.diagnosis_scope_blockers || approval.diagnosisScopeBlockers, 40, 500),
2545
+ approvedOwnerFileSetChanged: approvedOwnerFileSetChanged,
2546
+ boundedAutopilotApproval: boundedAutopilotApproval,
2547
+ autopilotApprovalBoundaryValid: status === 'pass',
2548
+ ownerFiles: ownerFiles,
2549
+ approvedOwnerFiles: approvedOwnerFiles,
2550
+ currentOwnerFiles: currentOwnerFiles,
2551
+ requiredCompletionEvidence: cleanStringList(approval.required_completion_evidence || approval.requiredCompletionEvidence, 30, 500),
2552
+ forbiddenWithoutReapproval: cleanStringList(approval.forbidden_without_reapproval || approval.forbiddenWithoutReapproval, 30, 500),
2553
+ blockers: uniqueBlockers
2554
+ }
2555
+ };
2556
+ }
2557
+ function supportProductRepairDispatchGuardGate(guard, now) {
2558
+ if (!guard || !Object.keys(guard).length) {
2559
+ return undefined;
2560
+ }
2561
+ var statusText = cleanText(guard.status, 120).toLowerCase();
2562
+ var allowed = guard.allowed === true || statusText === 'allowed';
2563
+ var blockers = cleanStringList(guard.blockers, 40, 500);
2564
+ if (guard.requires_owner_file_reapproval === true || guard.requiresOwnerFileReapproval === true) {
2565
+ blockers.push('Product repair dispatch is blocked until owner-file scope is reapproved.');
2566
+ }
2567
+ if (guard.requires_scope_reapproval === true || guard.requiresScopeReapproval === true) {
2568
+ blockers.push('Product repair dispatch is blocked until changed support scope is reapproved.');
2569
+ }
2570
+ if (guard.requires_over_limit_approval === true || guard.requiresOverLimitApproval === true) {
2571
+ blockers.push('Product repair dispatch is blocked until over-limit autonomy is approved.');
2572
+ }
2573
+ if (guard.requires_diagnosis_scope_reapproval === true || guard.requiresDiagnosisScopeReapproval === true) {
2574
+ blockers.push('Product repair dispatch is blocked until changed diagnosis scope is reapproved.');
2575
+ }
2576
+ var continuationContract = plainObject(guard.continuation_contract
2577
+ || guard.continuationContract
2578
+ || guard.autopilot_completion_contract
2579
+ || guard.autopilotCompletionContract);
2580
+ var status = allowed ? 'pass' : 'blocked';
2581
+ return {
2582
+ key: 'support_product_repair_dispatch_guard',
2583
+ label: 'Support product-repair dispatch guard',
2584
+ status: status,
2585
+ reason: allowed
2586
+ ? cleanText(guard.reason || 'Approved support autonomy allows owner-scoped product-code repair.', 1200)
2587
+ : cleanText(blockers.join(' ') || guard.reason || 'Support product-code repair dispatch is blocked until autonomy approval is current.', 1200),
2588
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(guard.owner_files || guard.ownerFiles)), false), __read(asArray(guard.approved_owner_files || guard.approvedOwnerFiles)), false), __read(asArray(guard.required_completion_evidence || guard.requiredCompletionEvidence)), false), 60, 500),
2589
+ recordedAt: isoNow(now || guard.recorded_at || guard.recordedAt || guard.created_at || guard.createdAt),
2590
+ metadata: {
2591
+ guard: cleanText(guard.guard, 160),
2592
+ status: statusText,
2593
+ allowed: allowed,
2594
+ action: cleanText(guard.action, 160),
2595
+ editsProductCode: guard.edits_product_code === true || guard.editsProductCode === true,
2596
+ canEditProductCode: guard.can_edit_product_code === true || guard.canEditProductCode === true,
2597
+ autoContinueAfterApproval: guard.auto_continue_after_approval === true || guard.autoContinueAfterApproval === true,
2598
+ nextAction: cleanText(guard.next_action || guard.nextAction, 160),
2599
+ approvalContractId: cleanText(guard.approval_contract_id || guard.approvalContractId, 180),
2600
+ continuationContractStatus: cleanText(continuationContract.status, 120),
2601
+ continuationContractMode: cleanText(continuationContract.mode, 160),
2602
+ terminalTarget: cleanText(guard.terminal_target
2603
+ || guard.terminalTarget
2604
+ || continuationContract.required_terminal_state
2605
+ || continuationContract.requiredTerminalState, 800),
2606
+ nextProofPhases: cleanStringList(guard.next_proof_phases || guard.nextProofPhases, 20, 240),
2607
+ allowedAutoActions: cleanStringList(guard.allowed_auto_actions || guard.allowedAutoActions, 20, 240),
2608
+ forbiddenActions: cleanStringList(guard.forbidden_actions || guard.forbiddenActions, 30, 500),
2609
+ scopeFingerprint: cleanText(guard.scope_fingerprint || guard.scopeFingerprint, 180),
2610
+ ownerFiles: cleanStringList(guard.owner_files || guard.ownerFiles, 60, 500),
2611
+ approvedOwnerFiles: cleanStringList(guard.approved_owner_files || guard.approvedOwnerFiles, 60, 500),
2612
+ currentOwnerFiles: cleanStringList(guard.current_owner_files || guard.currentOwnerFiles, 60, 500),
2613
+ ownerFileFingerprint: cleanText(guard.owner_file_fingerprint || guard.ownerFileFingerprint, 180),
2614
+ approvedOwnerFileFingerprint: cleanText(guard.approved_owner_file_fingerprint || guard.approvedOwnerFileFingerprint, 180),
2615
+ ownerFilesChangedSinceApproval: guard.owner_files_changed_since_approval === true || guard.ownerFilesChangedSinceApproval === true,
2616
+ ownerFilesAddedSinceApproval: cleanStringList(guard.owner_files_added_since_approval || guard.ownerFilesAddedSinceApproval, 40, 500),
2617
+ ownerFilesRemovedSinceApproval: cleanStringList(guard.owner_files_removed_since_approval || guard.ownerFilesRemovedSinceApproval, 40, 500),
2618
+ requiresOwnerFileReapproval: guard.requires_owner_file_reapproval === true || guard.requiresOwnerFileReapproval === true,
2619
+ requiresScopeReapproval: guard.requires_scope_reapproval === true || guard.requiresScopeReapproval === true,
2620
+ requiresOverLimitApproval: guard.requires_over_limit_approval === true || guard.requiresOverLimitApproval === true,
2621
+ requiresDiagnosisScopeReapproval: guard.requires_diagnosis_scope_reapproval === true || guard.requiresDiagnosisScopeReapproval === true,
2622
+ requiredCompletionEvidence: cleanStringList(guard.required_completion_evidence || guard.requiredCompletionEvidence, 30, 500),
2623
+ blockers: Array.from(new Set(blockers))
2624
+ }
2625
+ };
2626
+ }
2627
+ function supportAutoloopApprovalBlockGate(block, now) {
2628
+ var _a, _b, _c, _d, _e, _f;
2629
+ if (!block || !Object.keys(block).length) {
2630
+ return undefined;
2631
+ }
2632
+ var statusText = cleanText(block.status, 160).toLowerCase();
2633
+ var action = cleanText(block.action || block.next_action || block.nextAction, 160);
2634
+ var nextAction = cleanText(block.next_action || block.nextAction || action, 160);
2635
+ var decisionKind = cleanText(block.decision_kind || block.decisionKind, 160);
2636
+ var humanDecisionRequest = plainObject(block.human_decision_request || block.humanDecisionRequest);
2637
+ var productRepairDispatchGuard = plainObject(block.product_repair_dispatch_guard || block.productRepairDispatchGuard);
2638
+ var approvalContractId = cleanText(block.approval_contract_id || block.approvalContractId, 180);
2639
+ var blockers = cleanStringList(block.blockers, 40, 500);
2640
+ if (block.requires_over_limit_approval === true || block.requiresOverLimitApproval === true) {
2641
+ blockers.push('Autoloop is parked until explicit over-limit approval is recorded.');
2642
+ }
2643
+ if (block.requires_scope_reapproval === true || block.requiresScopeReapproval === true) {
2644
+ blockers.push('Autoloop is parked until the revised support scope is approved.');
2645
+ }
2646
+ if (block.requires_owner_file_reapproval === true || block.requiresOwnerFileReapproval === true) {
2647
+ blockers.push('Autoloop is parked until the changed owner-file set is reapproved.');
2648
+ }
2649
+ if (block.requires_diagnosis_scope_reapproval === true || block.requiresDiagnosisScopeReapproval === true) {
2650
+ blockers.push('Autoloop is parked until the changed diagnosis/proof scope is reapproved.');
2651
+ }
2652
+ if (block.requires_repair_intent_reapproval === true || block.requiresRepairIntentReapproval === true) {
2653
+ blockers.push('Autoloop is parked until the changed planned implementation intent is reapproved.');
2654
+ }
2655
+ if (block.requires_repair_intent === true || block.requiresRepairIntent === true) {
2656
+ blockers.push('Autoloop is parked until planned implementation intent is defined.');
2657
+ }
2658
+ if (block.requires_classification_approval === true || block.requiresClassificationApproval === true) {
2659
+ blockers.push('Autoloop is parked until bug/not-bug classification is approved.');
2660
+ }
2661
+ if (block.requires_estimate_hours === true || block.requiresEstimateHours === true) {
2662
+ blockers.push('Autoloop is parked until estimated hours are recorded.');
2663
+ }
2664
+ if (block.requires_elapsed_reapproval === true || block.requiresElapsedReapproval === true) {
2665
+ blockers.push('Autoloop is parked because elapsed runtime exceeded the approved wall-clock boundary.');
2666
+ }
2667
+ var uniqueBlockers = Array.from(new Set(blockers));
2668
+ var resolved = /resolved|approved|complete|completed|dismissed/.test(statusText);
2669
+ var blocked = !resolved && (/blocked|approval|required|waiting|pending|parked/.test(statusText) || !!nextAction || uniqueBlockers.length > 0);
2670
+ var gateStatus = blocked ? 'blocked' : 'warn';
2671
+ return {
2672
+ key: 'support_autoloop_approval_block',
2673
+ label: 'Support autoloop approval block',
2674
+ status: gateStatus,
2675
+ reason: cleanText(block.reason
2676
+ || uniqueBlockers.join(' ')
2677
+ || (blocked ? 'Support autoloop is parked until a specific approval or scope revision is recorded.' : 'Support autoloop approval block was recorded.'), 1200),
2678
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(block.required_completion_evidence || block.requiredCompletionEvidence)), false), __read(asArray(productRepairDispatchGuard.owner_files || productRepairDispatchGuard.ownerFiles)), false), __read(asArray(productRepairDispatchGuard.approved_owner_files || productRepairDispatchGuard.approvedOwnerFiles)), false), 60, 500),
2679
+ recordedAt: isoNow(now || block.created_at || block.createdAt || block.recorded_at || block.recordedAt),
2680
+ metadata: {
2681
+ recordId: cleanText(block.record_id || block.recordId, 180),
2682
+ status: statusText,
2683
+ action: action,
2684
+ nextAction: nextAction,
2685
+ approvalContractId: approvalContractId,
2686
+ scopeFingerprint: cleanText(block.scope_fingerprint || block.scopeFingerprint, 180),
2687
+ diagnosisScopeFingerprint: cleanText(block.diagnosis_scope_fingerprint || block.diagnosisScopeFingerprint, 180),
2688
+ repairIntentScopeFingerprint: cleanText(block.repair_intent_scope_fingerprint || block.repairIntentScopeFingerprint, 180),
2689
+ decisionKind: decisionKind,
2690
+ requiresOverLimitApproval: block.requires_over_limit_approval === true || block.requiresOverLimitApproval === true,
2691
+ requiresScopeReapproval: block.requires_scope_reapproval === true || block.requiresScopeReapproval === true,
2692
+ requiresOwnerFileReapproval: block.requires_owner_file_reapproval === true || block.requiresOwnerFileReapproval === true,
2693
+ requiresDiagnosisScopeReapproval: block.requires_diagnosis_scope_reapproval === true || block.requiresDiagnosisScopeReapproval === true,
2694
+ requiresRepairIntentReapproval: block.requires_repair_intent_reapproval === true || block.requiresRepairIntentReapproval === true,
2695
+ requiresRepairIntent: block.requires_repair_intent === true || block.requiresRepairIntent === true,
2696
+ requiresClassificationApproval: block.requires_classification_approval === true || block.requiresClassificationApproval === true,
2697
+ requiresEstimateHours: block.requires_estimate_hours === true || block.requiresEstimateHours === true,
2698
+ requiresElapsedReapproval: block.requires_elapsed_reapproval === true || block.requiresElapsedReapproval === true,
2699
+ elapsedRuntimeMs: numberValue((_a = block.elapsed_runtime_ms) !== null && _a !== void 0 ? _a : block.elapsedRuntimeMs),
2700
+ elapsedRuntimeHours: numberValue((_b = block.elapsed_runtime_hours) !== null && _b !== void 0 ? _b : block.elapsedRuntimeHours),
2701
+ maxApprovedRuntimeMs: numberValue((_c = block.max_approved_runtime_ms) !== null && _c !== void 0 ? _c : block.maxApprovedRuntimeMs),
2702
+ maxApprovedRuntimeHours: numberValue((_d = block.max_approved_runtime_hours) !== null && _d !== void 0 ? _d : block.maxApprovedRuntimeHours),
2703
+ maxWallClockMs: numberValue((_e = block.max_wall_clock_ms) !== null && _e !== void 0 ? _e : block.maxWallClockMs),
2704
+ maxWallClockHours: numberValue((_f = block.max_wall_clock_hours) !== null && _f !== void 0 ? _f : block.maxWallClockHours),
2705
+ onTheFlyScopeChangeApprovalRequired: block.on_the_fly_scope_change_approval_required === true || block.onTheFlyScopeChangeApprovalRequired === true,
2706
+ targetGrade: cleanText(block.target_grade || block.targetGrade || 'A', 20),
2707
+ requiredTerminalState: cleanText(block.required_terminal_state || block.requiredTerminalState, 800),
2708
+ humanDecisionRequestId: cleanText(humanDecisionRequest.request_id || humanDecisionRequest.requestId, 180),
2709
+ humanDecisionPreferredChoiceId: cleanText(humanDecisionRequest.preferred_choice_id || humanDecisionRequest.preferredChoiceId, 160),
2710
+ humanDecisionApprovalAction: cleanText(humanDecisionRequest.approval_action || humanDecisionRequest.approvalAction, 160),
2711
+ productRepairDispatchGuardStatus: cleanText(productRepairDispatchGuard.status, 120),
2712
+ productRepairDispatchNextAction: cleanText(productRepairDispatchGuard.next_action || productRepairDispatchGuard.nextAction, 160),
2713
+ blockers: uniqueBlockers
2714
+ }
2715
+ };
2716
+ }
2717
+ function supportAutoloopNoProgressGate(record, now) {
2718
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
2719
+ if (!record || !Object.keys(record).length) {
2720
+ return undefined;
2721
+ }
2722
+ var history = asArray(record.history)
2723
+ .map(function (entry) { return plainObject(entry); })
2724
+ .filter(function (entry) { return Object.keys(entry).length > 0; })
2725
+ .slice(-12);
2726
+ var latestHistory = plainObject(record.latest_history || record.latestHistory || history[history.length - 1]);
2727
+ var statusText = cleanText(record.status || latestHistory.status, 120).toLowerCase();
2728
+ var noProgressStreak = Math.max(0, Number((_d = (_c = (_b = (_a = record.no_progress_streak) !== null && _a !== void 0 ? _a : record.noProgressStreak) !== null && _b !== void 0 ? _b : latestHistory.no_progress_streak) !== null && _c !== void 0 ? _c : latestHistory.noProgressStreak) !== null && _d !== void 0 ? _d : 0) || 0);
2729
+ var lastProgressSignal = booleanFlag((_g = (_f = (_e = record.last_progress_signal) !== null && _e !== void 0 ? _e : record.lastProgressSignal) !== null && _f !== void 0 ? _f : latestHistory.progress_signal) !== null && _g !== void 0 ? _g : latestHistory.progressSignal);
2730
+ var evidenceChanged = booleanFlag((_m = (_l = (_k = (_j = (_h = record.last_evidence_changed) !== null && _h !== void 0 ? _h : record.lastEvidenceChanged) !== null && _j !== void 0 ? _j : record.evidence_changed) !== null && _k !== void 0 ? _k : record.evidenceChanged) !== null && _l !== void 0 ? _l : latestHistory.evidence_changed) !== null && _m !== void 0 ? _m : latestHistory.evidenceChanged);
2731
+ var handoffRequired = record.handoff_required === true || record.handoffRequired === true;
2732
+ var lastError = cleanText(record.last_error || record.lastError || latestHistory.error, 2000);
2733
+ var continuationDecision = plainObject(record.last_continuation_decision || record.lastContinuationDecision || latestHistory.continuation_decision || latestHistory.continuationDecision);
2734
+ var continuationDispatch = plainObject(record.last_continuation_dispatch || record.lastContinuationDispatch || latestHistory.continuation_dispatch || latestHistory.continuationDispatch);
2735
+ var continuationAction = cleanText(continuationDecision.action || continuationDispatch.action, 160);
2736
+ var noProgressError = /no[-_\s]?progress|no new diff|no new .*evidence|without progress|retry blocked|same failure/i.test(lastError);
2737
+ var stoppedOrParked = handoffRequired
2738
+ || /stopped|stop|park|parked|handoff|blocked/.test(statusText)
2739
+ || /park|handoff|blocked|manual/.test(continuationAction);
2740
+ var hasNoProgressEvidence = noProgressStreak > 0
2741
+ || lastProgressSignal === false
2742
+ || evidenceChanged === false
2743
+ || noProgressError;
2744
+ if (!hasNoProgressEvidence) {
2745
+ return undefined;
2746
+ }
2747
+ var blocked = stoppedOrParked && hasNoProgressEvidence;
2748
+ var strictGateReason = cleanText(record.last_strict_gate_reason || record.lastStrictGateReason || latestHistory.strict_gate_reason || latestHistory.strictGateReason, 500);
2749
+ var diffFingerprint = cleanText(record.diff_fingerprint || record.diffFingerprint || latestHistory.diff_fingerprint || latestHistory.diffFingerprint, 180);
2750
+ var failingCheckFingerprint = cleanText(record.failing_check_fingerprint || record.failingCheckFingerprint || latestHistory.failing_check_fingerprint || latestHistory.failingCheckFingerprint, 180);
2751
+ var progressReasons = cleanStringList(record.last_progress_reasons || record.lastProgressReasons || latestHistory.progress_reasons || latestHistory.progressReasons, 20, 240);
2752
+ var evidenceReasons = cleanStringList(record.last_evidence_reasons || record.lastEvidenceReasons || latestHistory.evidence_reasons || latestHistory.evidenceReasons, 20, 240);
2753
+ var blockers = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((noProgressStreak > 0 ? ["no_progress_streak=".concat(noProgressStreak)] : [])), false), __read((lastProgressSignal === false ? ['last_progress_signal=false'] : [])), false), __read((evidenceChanged === false ? ['evidence_changed=false'] : [])), false), __read((strictGateReason ? ["strict_gate=".concat(strictGateReason)] : [])), false), __read((lastError ? ["last_error=".concat(lastError)] : [])), false);
2754
+ return {
2755
+ key: 'support_autoloop_no_progress',
2756
+ label: 'Support autoloop no-progress guard',
2757
+ status: blocked ? 'blocked' : 'warn',
2758
+ reason: cleanText(record.reason
2759
+ || (blocked
2760
+ ? 'Support autoloop parked because no new diff/check/PR evidence was recorded before another repair loop.'
2761
+ : 'Support autoloop recorded no-progress evidence; require new material proof before another broad repair loop.'), 1200),
2762
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(progressReasons), false), __read(evidenceReasons), false), [
2763
+ diffFingerprint ? "diff_fingerprint=".concat(diffFingerprint) : '',
2764
+ failingCheckFingerprint ? "failing_check_fingerprint=".concat(failingCheckFingerprint) : '',
2765
+ strictGateReason ? "strict_gate=".concat(strictGateReason) : '',
2766
+ continuationAction ? "continuation_action=".concat(continuationAction) : ''
2767
+ ], false), 60, 500),
2768
+ recordedAt: isoNow(now || record.recorded_at || record.recordedAt || latestHistory.finished_at || latestHistory.finishedAt),
2769
+ metadata: {
2770
+ runId: cleanText(record.run_id || record.runId || latestHistory.run_id || latestHistory.runId, 180),
2771
+ status: statusText,
2772
+ noProgressStreak: noProgressStreak,
2773
+ lastProgressSignal: lastProgressSignal,
2774
+ evidenceChanged: evidenceChanged,
2775
+ handoffRequired: handoffRequired,
2776
+ lastError: lastError,
2777
+ strictGateReason: strictGateReason,
2778
+ diffFingerprint: diffFingerprint,
2779
+ failingCheckFingerprint: failingCheckFingerprint,
2780
+ continuationAction: continuationAction,
2781
+ continuationReason: cleanText(continuationDecision.reason || continuationDispatch.reason, 1000),
2782
+ continuationStatus: cleanText(continuationDispatch.status || continuationDecision.status, 120),
2783
+ progressReasons: progressReasons,
2784
+ evidenceReasons: evidenceReasons,
2785
+ requiresNewEvidence: true,
2786
+ productRepairAllowed: false,
2787
+ nextAction: 'collect_new_evidence_or_revise_diagnosis',
2788
+ requiredEvidence: [
2789
+ 'new diff/check/PR evidence, changed failing-check fingerprint, or a revised SupportDiagnosisGate with fresh proof',
2790
+ 'AIQaBusinessAssertion before/action/after proof when the ticket issue is fixed'
2791
+ ],
2792
+ forbiddenActions: [
2793
+ 'Do not start another product-code/model repair loop until new evidence changes the blocker fingerprint.',
2794
+ 'Do not treat route-load proof or scorecard-only proof as accepted support completion.'
2795
+ ],
2796
+ blockers: blockers
2797
+ }
2798
+ };
2799
+ }
2800
+ function supportHumanDecisionRequestGate(request, now) {
2801
+ if (!request || !Object.keys(request).length) {
2802
+ return undefined;
2803
+ }
2804
+ var statusText = cleanText(request.status, 120).toLowerCase();
2805
+ var required = request.required === true || /required|open|pending|waiting/.test(statusText);
2806
+ var resolved = /resolved|answered|approved|dismissed|complete/.test(statusText);
2807
+ var evidence = plainObject(request.evidence);
2808
+ var choices = asArray(request.choices);
2809
+ var gateStatus = required && !resolved ? 'blocked' : 'warn';
2810
+ return {
2811
+ key: 'support_human_decision_request',
2812
+ label: 'Support human decision request',
2813
+ status: gateStatus,
2814
+ reason: cleanText(request.reason || request.question || (gateStatus === 'blocked' ? 'Support run is waiting on an operator decision.' : 'Support human decision request was recorded.'), 1200),
2815
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(evidence.required_artifacts || evidence.requiredArtifacts)), false), __read(asArray(evidence.recent_artifact_paths || evidence.recentArtifactPaths)), false), __read(asArray(evidence.changed_files || evidence.changedFiles)), false), 60, 500),
2816
+ recordedAt: isoNow(now || request.created_at || request.createdAt || request.recorded_at || request.recordedAt),
2817
+ metadata: {
2818
+ requestId: cleanText(request.request_id || request.requestId, 180),
2819
+ required: required,
2820
+ status: statusText,
2821
+ decisionKind: cleanText(request.decision_kind || request.decisionKind, 120),
2822
+ approvalAction: cleanText(request.approval_action || request.approvalAction, 120),
2823
+ canApproveFromConsole: request.can_approve_from_console === true || request.canApproveFromConsole === true,
2824
+ preferredChoiceId: cleanText(request.preferred_choice_id || request.preferredChoiceId, 120),
2825
+ choiceCount: choices.length,
2826
+ choices: choices.slice(0, 6).map(function (choice) { return ({
2827
+ choiceId: cleanText(choice.choice_id || choice.choiceId, 120),
2828
+ action: cleanText(choice.action, 120),
2829
+ label: cleanText(choice.label, 160),
2830
+ safety: cleanText(choice.safety, 80),
2831
+ disabled: choice.disabled === true
2832
+ }); }).filter(function (choice) { return choice.choiceId || choice.action; }),
2833
+ failureClass: cleanText(evidence.failure_class || evidence.failureClass, 120),
2834
+ blockerFingerprint: cleanText(evidence.blocker_fingerprint || evidence.blockerFingerprint, 180),
2835
+ evidenceHash: cleanText(evidence.evidence_hash || evidence.evidenceHash, 180),
2836
+ dispatchAction: cleanText(evidence.dispatch_action || evidence.dispatchAction, 120),
2837
+ requiresOverLimitApproval: evidence.requires_over_limit_approval === true || evidence.requiresOverLimitApproval === true,
2838
+ requiresScopeReapproval: evidence.requires_scope_reapproval === true || evidence.requiresScopeReapproval === true,
2839
+ requiresIntakeReapproval: evidence.requires_intake_reapproval === true || evidence.requiresIntakeReapproval === true,
2840
+ requiresDiagnosisScopeReapproval: evidence.requires_diagnosis_scope_reapproval === true || evidence.requiresDiagnosisScopeReapproval === true,
2841
+ requiresClassificationApproval: evidence.requires_classification_approval === true || evidence.requiresClassificationApproval === true,
2842
+ requiresEstimateHours: evidence.requires_estimate_hours === true || evidence.requiresEstimateHours === true
2843
+ }
2844
+ };
2845
+ }
2846
+ function supportPostApprovalAutostartGate(packet, now) {
2847
+ if (!packet || !Object.keys(packet).length) {
2848
+ return undefined;
2849
+ }
2850
+ var contract = plainObject(packet.contract || packet.post_approval_autostart_contract || packet.postApprovalAutostartContract);
2851
+ var record = plainObject(packet.record || packet.post_approval_autostart || packet.postApprovalAutostart);
2852
+ if (!Object.keys(contract).length && !Object.keys(record).length) {
2853
+ return undefined;
2854
+ }
2855
+ var result = plainObject(record.result);
2856
+ var statusText = cleanText(record.status || packet.status || contract.status, 120).toLowerCase();
2857
+ var contractStatus = cleanText(contract.status, 120).toLowerCase();
2858
+ var resultStatus = cleanText(record.result_status || record.resultStatus || result.status, 120).toLowerCase();
2859
+ var nextAction = cleanText(record.next_action || record.nextAction || packet.next_action || packet.nextAction, 160);
2860
+ var error = cleanText(record.error || result.error, 1000);
2861
+ var runId = cleanText(record.run_id || record.runId || result.run_id || result.runId, 180);
2862
+ var resumeContract = plainObject(record.resume_contract || record.resumeContract || record.post_approval_resume_contract || record.postApprovalResumeContract);
2863
+ var failureClass = cleanText(record.failure_class || record.failureClass, 120);
2864
+ var blockerFingerprint = cleanText(record.blocker_fingerprint || record.blockerFingerprint, 180);
2865
+ var blockerReason = cleanText(record.blocker_reason || record.blockerReason, 1200);
2866
+ var scopeFingerprint = cleanText(record.scope_fingerprint
2867
+ || record.scopeFingerprint
2868
+ || contract.scope_fingerprint
2869
+ || contract.scopeFingerprint
2870
+ || resumeContract.scope_fingerprint
2871
+ || resumeContract.scopeFingerprint, 180);
2872
+ var approvalBoundaryValid = record.approval_boundary_valid === true
2873
+ || record.approvalBoundaryValid === true;
2874
+ var canRetryWithoutReapproval = record.can_retry_without_reapproval === true
2875
+ || record.canRetryWithoutReapproval === true;
2876
+ var safeRetryAction = cleanText(record.safe_retry_action || record.safeRetryAction || resumeContract.action, 160);
2877
+ var blockers = cleanStringList(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(contract.blockers)), false), __read(asArray(record.blockers)), false), __read(asArray(result.blockers)), false), [
2878
+ blockerReason,
2879
+ error,
2880
+ contractStatus === 'ready' && !Object.keys(record).length ? 'Autostart contract is ready but no dispatch result was recorded.' : ''
2881
+ ], false), 40, 500);
2882
+ var started = /^(started|already_running|running)$/.test(statusText)
2883
+ || /^(started|already_running|running)$/.test(resultStatus)
2884
+ || record.can_continue_without_codex_monitor === true
2885
+ || record.canContinueWithoutCodexMonitor === true;
2886
+ var skipped = statusText === 'skipped' || contractStatus === 'skipped';
2887
+ var blocked = !started && (/blocked|failed|fail|error/.test(statusText)
2888
+ || /blocked|failed|fail|error|busy/.test(resultStatus)
2889
+ || nextAction === 'resolve_autostart_blocker'
2890
+ || !!error
2891
+ || (contractStatus === 'ready' && !Object.keys(record).length));
2892
+ var gateStatus = started
2893
+ ? 'pass'
2894
+ : blocked
2895
+ ? 'blocked'
2896
+ : skipped
2897
+ ? 'warn'
2898
+ : 'warn';
2899
+ var options = plainObject(contract.options);
2900
+ var reason = started
2901
+ ? 'Approved support autonomy autostart dispatched the auto-improve loop; no parallel Codex monitor is required.'
2902
+ : blocked
2903
+ ? cleanText(blockers.join(' ') || contract.reason || result.message || 'Approved support autonomy did not autostart and needs a concrete blocker resolved.', 1200)
2904
+ : skipped
2905
+ ? cleanText(contract.reason || 'Approved support autonomy autostart was skipped by request; manual start is required when ready.', 1200)
2906
+ : cleanText(contract.reason || result.message || 'Approved support autonomy autostart result is recorded but not dispatch-ready.', 1200);
2907
+ return {
2908
+ key: 'support_post_approval_autostart',
2909
+ label: 'Support post-approval autostart',
2910
+ status: gateStatus,
2911
+ reason: reason,
2912
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(contract.required_terminal_evidence || contract.requiredTerminalEvidence)), false), __read(asArray(record.artifact_paths || record.artifactPaths)), false), __read(asArray(result.artifact_paths || result.artifactPaths)), false), 60, 500),
2913
+ recordedAt: isoNow(now || record.recorded_at || record.recordedAt || contract.recorded_at || contract.recordedAt),
2914
+ metadata: {
2915
+ source: cleanText(packet.source, 120),
2916
+ status: statusText || contractStatus,
2917
+ contractStatus: contractStatus,
2918
+ resultStatus: resultStatus,
2919
+ failureClass: failureClass,
2920
+ blockerFingerprint: blockerFingerprint,
2921
+ blockerReason: blockerReason,
2922
+ approvalBoundaryValid: approvalBoundaryValid,
2923
+ canRetryWithoutReapproval: canRetryWithoutReapproval,
2924
+ safeRetryAction: safeRetryAction,
2925
+ resumeContract: resumeContract,
2926
+ postApprovalResumeContract: resumeContract,
2927
+ started: started,
2928
+ skipped: skipped,
2929
+ blocked: blocked,
2930
+ nextAction: nextAction,
2931
+ runId: runId,
2932
+ activeTicketId: cleanText(result.active_ticket_id || result.activeTicketId, 180),
2933
+ activeRunId: cleanText(result.active_run_id || result.activeRunId, 180),
2934
+ error: error,
2935
+ contractId: cleanText(contract.contract_id || contract.contractId || record.contract_id || record.contractId, 180),
2936
+ recordId: cleanText(record.record_id || record.recordId, 180),
2937
+ approvalContractId: cleanText(contract.approval_contract_id || contract.approvalContractId || record.approval_contract_id || record.approvalContractId, 180),
2938
+ scopeFingerprint: scopeFingerprint,
2939
+ method: cleanText(record.method || contract.method, 180),
2940
+ autoStartEnabled: contract.auto_start_enabled === true || contract.autoStartEnabled === true || record.auto_start_enabled === true || record.autoStartEnabled === true,
2941
+ canContinueWithoutCodexMonitor: record.can_continue_without_codex_monitor === true || record.canContinueWithoutCodexMonitor === true,
2942
+ blocksManualCodexMonitoring: record.blocks_manual_codex_monitoring === true || record.blocksManualCodexMonitoring === true,
2943
+ terminalTarget: cleanText(contract.terminal_target || contract.terminalTarget, 800),
2944
+ targetGrade: cleanText(contract.target_grade || contract.targetGrade, 20),
2945
+ maxIterations: Number(options.max_iterations || options.maxIterations || 0),
2946
+ iterationTimeoutMs: Number(options.iteration_timeout_ms || options.iterationTimeoutMs || 0),
2947
+ autoCreatePr: options.auto_create_pr === true || options.autoCreatePr === true,
2948
+ forceNewJob: options.force_new_job === true || options.forceNewJob === true,
2949
+ forceRestart: options.force_restart === true || options.forceRestart === true,
2950
+ budgetSoftUsd: Number(options.budget_soft_usd || options.budgetSoftUsd || 0),
2951
+ budgetHardUsd: Number(options.budget_hard_usd || options.budgetHardUsd || 0),
2952
+ executionTier: cleanText(options.execution_tier || options.executionTier, 120),
2953
+ requiredTerminalEvidence: cleanStringList(contract.required_terminal_evidence || contract.requiredTerminalEvidence, 30, 500),
2954
+ allowedAutoActions: cleanStringList(contract.allowed_auto_actions || contract.allowedAutoActions, 30, 240),
2955
+ forbiddenWithoutReapproval: cleanStringList(contract.forbidden_without_reapproval || contract.forbiddenWithoutReapproval, 30, 500),
2956
+ blockers: blockers
2957
+ }
2958
+ };
2959
+ }
2960
+ function supportPostApprovalResumeAttemptGate(packet, now) {
2961
+ if (!packet || !Object.keys(packet).length) {
2962
+ return undefined;
2963
+ }
2964
+ var record = plainObject(packet.record || packet.post_approval_resume_attempt || packet.postApprovalResumeAttempt);
2965
+ if (!Object.keys(record).length) {
2966
+ return undefined;
2967
+ }
2968
+ var result = plainObject(record.result);
2969
+ var resumeContract = plainObject(record.resume_contract || record.resumeContract || record.post_approval_resume_contract || record.postApprovalResumeContract);
2970
+ var startGuard = plainObject(record.start_guard || record.startGuard || result.autoloop_start_guard || result.autoloopStartGuard);
2971
+ var statusText = cleanText(record.status || packet.status || result.status, 120).toLowerCase();
2972
+ var resultStatus = cleanText(record.result_status || record.resultStatus || result.status, 120).toLowerCase();
2973
+ var nextAction = cleanText(record.next_action || record.nextAction || packet.next_action || packet.nextAction, 160);
2974
+ var failureClass = cleanText(record.failure_class || record.failureClass, 120);
2975
+ var blockerFingerprint = cleanText(record.blocker_fingerprint || record.blockerFingerprint, 180);
2976
+ var blockerReason = cleanText(record.blocker_reason || record.blockerReason, 1200);
2977
+ var runId = cleanText(record.run_id || record.runId || result.run_id || result.runId, 180);
2978
+ var error = cleanText(record.error || result.error, 1000);
2979
+ var started = /^(started|already_running|running)$/.test(statusText)
2980
+ || /^(started|already_running|running)$/.test(resultStatus)
2981
+ || record.can_continue_without_codex_monitor === true
2982
+ || record.canContinueWithoutCodexMonitor === true;
2983
+ var blocked = !started && (/blocked|failed|fail|error|busy/.test(statusText)
2984
+ || /blocked|failed|fail|error|busy/.test(resultStatus)
2985
+ || !!failureClass
2986
+ || !!blockerReason
2987
+ || !!error
2988
+ || startGuard.allowed === false);
2989
+ var gateStatus = started
2990
+ ? 'pass'
2991
+ : blocked
2992
+ ? 'blocked'
2993
+ : 'warn';
2994
+ var blockers = cleanStringList(__spreadArray(__spreadArray([], __read(asArray(record.blockers)), false), [
2995
+ blockerReason,
2996
+ error,
2997
+ startGuard.reason,
2998
+ result.reason
2999
+ ], false), 40, 500);
3000
+ var reason = started
3001
+ ? 'Approved support auto-improve loop resume started under the recorded approval/scope contract.'
3002
+ : blocked
3003
+ ? cleanText(blockers.join(' ') || 'Approved support auto-improve loop resume did not start and needs a fresh blocker review before another retry.', 1200)
3004
+ : 'Approved support auto-improve loop resume attempt was recorded but has no terminal start result.';
3005
+ return {
3006
+ key: 'support_post_approval_resume_attempt',
3007
+ label: 'Support post-approval resume attempt',
3008
+ status: gateStatus,
3009
+ reason: reason,
3010
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray([], __read(asArray(record.artifact_paths || record.artifactPaths)), false), __read(asArray(result.artifact_paths || result.artifactPaths)), false), 60, 500),
3011
+ recordedAt: isoNow(now || record.recorded_at || record.recordedAt),
3012
+ metadata: {
3013
+ source: cleanText(packet.source, 120),
3014
+ status: statusText,
3015
+ resultStatus: resultStatus,
3016
+ failureClass: failureClass,
3017
+ blockerFingerprint: blockerFingerprint,
3018
+ blockerReason: blockerReason,
3019
+ started: started,
3020
+ blocked: blocked,
3021
+ nextAction: nextAction,
3022
+ runId: runId,
3023
+ activeTicketId: cleanText(record.active_ticket_id || record.activeTicketId || result.active_ticket_id || result.activeTicketId, 180),
3024
+ activeRunId: cleanText(record.active_run_id || record.activeRunId || result.active_run_id || result.activeRunId, 180),
3025
+ activeJobId: cleanText(record.active_job_id || record.activeJobId || result.active_job_id || result.activeJobId, 180),
3026
+ error: error,
3027
+ attemptId: cleanText(record.attempt_id || record.attemptId, 180),
3028
+ contractId: cleanText(record.contract_id || record.contractId || resumeContract.contract_id || resumeContract.contractId, 180),
3029
+ approvalContractId: cleanText(record.approval_contract_id || record.approvalContractId || resumeContract.approval_contract_id || resumeContract.approvalContractId, 180),
3030
+ scopeFingerprint: cleanText(record.scope_fingerprint || record.scopeFingerprint || resumeContract.scope_fingerprint || resumeContract.scopeFingerprint, 180),
3031
+ resumeContract: resumeContract,
3032
+ postApprovalResumeContract: resumeContract,
3033
+ startGuard: startGuard,
3034
+ startGuardStatus: cleanText(record.start_guard_status || record.startGuardStatus || startGuard.status, 120),
3035
+ canContinueWithoutCodexMonitor: record.can_continue_without_codex_monitor === true || record.canContinueWithoutCodexMonitor === true,
3036
+ productRepairAllowed: record.product_repair_allowed === true || record.productRepairAllowed === true,
3037
+ canSendCustomerReply: record.can_send_customer_reply === true || record.canSendCustomerReply === true,
3038
+ blockers: blockers
3039
+ }
3040
+ };
3041
+ }
3042
+ function supportIntakeRevisionContractGate(contract, now) {
3043
+ if (!contract || !Object.keys(contract).length) {
3044
+ return undefined;
3045
+ }
3046
+ var statusText = cleanText(contract.status, 120).toLowerCase();
3047
+ var changedFields = asArray(contract.changed_fields || contract.changedFields)
3048
+ .map(function (entry) { return ({
3049
+ field: cleanText(entry.field, 120),
3050
+ previous: cleanText(entry.previous, 500),
3051
+ next: cleanText(entry.next, 500)
3052
+ }); })
3053
+ .filter(function (entry) { return entry.field; });
3054
+ var changedFieldNames = cleanStringList(contract.changed_field_names || contract.changedFieldNames, 40, 120).length
3055
+ ? cleanStringList(contract.changed_field_names || contract.changedFieldNames, 40, 120)
3056
+ : changedFields.map(function (entry) { return entry.field; });
3057
+ var requiresReapproval = contract.requires_reapproval === true
3058
+ || contract.requiresReapproval === true
3059
+ || /approval_required|reapproval_required|waiting_for_operator/.test(statusText);
3060
+ var blocksProductRepair = contract.blocks_product_repair === true
3061
+ || contract.blocksProductRepair === true
3062
+ || requiresReapproval;
3063
+ var blocksAutoRetry = contract.blocks_auto_retry === true
3064
+ || contract.blocksAutoRetry === true
3065
+ || requiresReapproval;
3066
+ var gateStatus = blocksProductRepair
3067
+ ? 'blocked'
3068
+ : changedFieldNames.length
3069
+ ? 'warn'
3070
+ : 'pass';
3071
+ var reason = gateStatus === 'blocked'
3072
+ ? cleanText(contract.reason || 'Support intake/classification changed after approval; product repair is parked until the revised scope is approved.', 1200)
3073
+ : changedFieldNames.length
3074
+ ? cleanText(contract.reason || 'Support intake/classification edit was recorded without requiring reapproval.', 1200)
3075
+ : cleanText(contract.reason || 'Support intake revision contract is recorded.', 1200);
3076
+ return {
3077
+ key: 'support_intake_revision_contract',
3078
+ label: 'Support intake revision contract',
3079
+ status: gateStatus,
3080
+ reason: reason,
3081
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray([], __read(changedFieldNames), false), [
3082
+ contract.previous_autonomy_contract_id || contract.previousAutonomyContractId,
3083
+ contract.previous_scope_fingerprint || contract.previousScopeFingerprint,
3084
+ contract.next_scope_fingerprint || contract.nextScopeFingerprint
3085
+ ], false), 80, 500),
3086
+ recordedAt: isoNow(now || contract.updated_at || contract.updatedAt || contract.recorded_at || contract.recordedAt),
3087
+ metadata: {
3088
+ contractId: cleanText(contract.contract_id || contract.contractId, 180),
3089
+ status: statusText,
3090
+ requiresReapproval: requiresReapproval,
3091
+ blocksProductRepair: blocksProductRepair,
3092
+ blocksAutoRetry: blocksAutoRetry,
3093
+ requiredOperatorAction: cleanText(contract.required_operator_action || contract.requiredOperatorAction, 160),
3094
+ previousAutonomyContractId: cleanText(contract.previous_autonomy_contract_id || contract.previousAutonomyContractId, 180),
3095
+ previousScopeFingerprint: cleanText(contract.previous_scope_fingerprint || contract.previousScopeFingerprint, 180),
3096
+ nextScopeFingerprint: cleanText(contract.next_scope_fingerprint || contract.nextScopeFingerprint, 180),
3097
+ intakeScopeFingerprint: cleanText(contract.intake_scope_fingerprint || contract.intakeScopeFingerprint, 180),
3098
+ changedFieldNames: changedFieldNames,
3099
+ changedFields: changedFields,
3100
+ approvalImpactingEditFields: cleanStringList(contract.approval_impacting_edit_fields || contract.approvalImpactingEditFields, 40, 120),
3101
+ updatedBy: cleanText(contract.updated_by || contract.updatedBy, 160),
3102
+ blockers: cleanStringList(contract.blockers, 40, 500)
3103
+ }
3104
+ };
3105
+ }
3106
+ function supportManagerContinuationGate(packet, now) {
3107
+ var _a, _b, _c;
3108
+ if (!packet || !Object.keys(packet).length) {
3109
+ return undefined;
3110
+ }
3111
+ var continuationContract = plainObject(packet.continuation_contract || packet.continuationContract);
3112
+ var operatorGuidanceResponse = plainObject(packet.operator_guidance_response || packet.operatorGuidanceResponse);
3113
+ var resumeUnblockContract = plainObject(packet.resume_unblock_contract || packet.resumeUnblockContract);
3114
+ var resumeUnblockResponse = plainObject(packet.resume_unblock_response || packet.resumeUnblockResponse);
3115
+ var resumeDispatch = plainObject(packet.resume_dispatch || packet.resumeDispatch);
3116
+ var responseStatus = cleanText(operatorGuidanceResponse.status, 120).toLowerCase();
3117
+ var dispatchStatus = cleanText(resumeDispatch.status || ((_a = resumeDispatch.result) === null || _a === void 0 ? void 0 : _a.status), 120).toLowerCase();
3118
+ var continuationStatus = cleanText(continuationContract.status, 120).toLowerCase();
3119
+ var operatorAccepted = operatorGuidanceResponse.accepted === true || responseStatus === 'accepted' || responseStatus === 'consumed';
3120
+ var operatorConsumed = operatorGuidanceResponse.consumed === true || responseStatus === 'consumed' || !!cleanText(operatorGuidanceResponse.consumed_at || operatorGuidanceResponse.consumedAt, 120);
3121
+ var unblockContractPresent = Object.keys(resumeUnblockContract).length > 0;
3122
+ var dispatchQueued = /queued|scheduled|started|running|complete|completed|success|succeeded/.test(dispatchStatus);
3123
+ var canRunWithoutCodexMonitor = operatorGuidanceResponse.can_run_without_codex_monitor === true
3124
+ || operatorGuidanceResponse.canRunWithoutCodexMonitor === true
3125
+ || continuationContract.can_run_without_codex_monitor === true
3126
+ || continuationContract.canRunWithoutCodexMonitor === true;
3127
+ var action = cleanText(resumeUnblockContract.action
3128
+ || operatorGuidanceResponse.submit_action
3129
+ || operatorGuidanceResponse.submitAction
3130
+ || operatorGuidanceResponse.requested_action
3131
+ || operatorGuidanceResponse.requestedAction
3132
+ || continuationContract.action
3133
+ || continuationContract.next_action
3134
+ || continuationContract.nextAction, 180);
3135
+ var blockers = cleanStringList(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(packet.blockers)), false), __read(asArray(continuationContract.blockers)), false), __read(asArray(operatorGuidanceResponse.blockers)), false), __read(asArray(resumeUnblockContract.blockers)), false), [
3136
+ Object.keys(operatorGuidanceResponse).length && !operatorAccepted ? 'Operator guidance response is not accepted.' : '',
3137
+ operatorAccepted && !unblockContractPresent ? 'Accepted operator guidance is missing a resume_unblock_contract.' : '',
3138
+ dispatchStatus && /fail|failed|error|rejected|blocked/.test(dispatchStatus) ? 'Operator guidance resume dispatch failed or is blocked.' : ''
3139
+ ], false), 40, 500);
3140
+ var status = blockers.length
3141
+ ? 'blocked'
3142
+ : dispatchQueued || (operatorAccepted && unblockContractPresent)
3143
+ ? 'pass'
3144
+ : 'warn';
3145
+ var artifactPaths = cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(resumeUnblockResponse.artifact_paths || resumeUnblockResponse.artifactPaths)), false), __read(asArray(operatorGuidanceResponse.artifact_paths || operatorGuidanceResponse.artifactPaths)), false), __read(asArray(continuationContract.artifact_paths || continuationContract.artifactPaths)), false), 60, 500);
3146
+ var requiredStateTransition = cleanText(resumeUnblockContract.required_state_transition
3147
+ || resumeUnblockContract.requiredStateTransition
3148
+ || continuationContract.required_state_transition
3149
+ || continuationContract.requiredStateTransition
3150
+ || continuationContract.expected_state_transition
3151
+ || continuationContract.expectedStateTransition, 1000);
3152
+ return {
3153
+ key: 'support_manager_continuation',
3154
+ label: 'Support manager continuation',
3155
+ status: status,
3156
+ reason: status === 'pass'
3157
+ ? 'Support manager has a structured continuation/unblock path that can resume without a parallel Codex monitor.'
3158
+ : cleanText(blockers.join(' ') || continuationContract.reason || operatorGuidanceResponse.reason || 'Support manager continuation state is recorded but not yet dispatch-ready.', 1200),
3159
+ evidenceRefs: artifactPaths,
3160
+ recordedAt: isoNow(now || packet.recorded_at || packet.recordedAt),
3161
+ metadata: {
3162
+ source: cleanText(packet.source, 160),
3163
+ managerStatus: cleanText(packet.manager_status || packet.managerStatus, 120),
3164
+ continuationContractId: cleanText(continuationContract.contract_id || continuationContract.contractId, 180),
3165
+ continuationStatus: continuationStatus,
3166
+ action: action,
3167
+ requiredStateTransition: requiredStateTransition,
3168
+ operatorGuidanceResponseId: cleanText(operatorGuidanceResponse.response_id || operatorGuidanceResponse.responseId, 180),
3169
+ operatorGuidanceId: cleanText(operatorGuidanceResponse.guidance_id || operatorGuidanceResponse.guidanceId, 180),
3170
+ operatorGuidanceAccepted: operatorAccepted,
3171
+ operatorGuidanceConsumed: operatorConsumed,
3172
+ responseStatus: responseStatus,
3173
+ resumeUnblockContractId: cleanText(resumeUnblockContract.contract_id || resumeUnblockContract.contractId, 180),
3174
+ resumeUnblockAction: cleanText(resumeUnblockContract.action, 180),
3175
+ resumeDispatchStatus: dispatchStatus,
3176
+ resumeDispatchJobId: cleanText(resumeDispatch.job_id || resumeDispatch.jobId || ((_b = resumeDispatch.result) === null || _b === void 0 ? void 0 : _b.job_id) || ((_c = resumeDispatch.result) === null || _c === void 0 ? void 0 : _c.jobId), 180),
3177
+ canRunWithoutCodexMonitor: canRunWithoutCodexMonitor,
3178
+ safeToAutoRunAfterInput: operatorGuidanceResponse.safe_to_autorun_after_input === true || operatorGuidanceResponse.safeToAutorunAfterInput === true,
3179
+ blocksProductRepairUntilChangedEvidence: resumeUnblockContract.blocks_product_repair_until_changed_evidence === true || resumeUnblockContract.blocksProductRepairUntilChangedEvidence === true,
3180
+ proofRequiredBeforeContinuation: resumeUnblockContract.proof_required_before_continuation === true || resumeUnblockContract.proofRequiredBeforeContinuation === true,
3181
+ allowedAfterInput: cleanStringList(resumeUnblockContract.allowed_after_input || resumeUnblockContract.allowedAfterInput, 20, 240),
3182
+ materialEvidenceClaimed: resumeUnblockResponse.material_evidence_claimed === true || resumeUnblockResponse.materialEvidenceClaimed === true,
3183
+ materialEvidenceSignals: cleanStringList(resumeUnblockResponse.material_evidence_signals || resumeUnblockResponse.materialEvidenceSignals, 20, 240),
3184
+ artifactPaths: artifactPaths,
3185
+ blockers: blockers
3186
+ }
3187
+ };
3188
+ }
3189
+ function supportPrReadinessContractObject(ticket, job, evidence) {
3190
+ var ticketAutomation = plainObject(ticket.automation);
3191
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
3192
+ var runnerConsole = plainObject(ticketAutomation.runner_console || ticketAutomation.runnerConsole);
3193
+ var autonomousDecision = supportAutonomyDecisionObject(ticket, job, evidence);
3194
+ var recovery = plainObject(autonomousDecision.managerRecovery || autonomousDecision.manager_recovery);
3195
+ return evidenceObject(job.supportPrReadinessContract, job.support_pr_readiness_contract, job.prReadinessContract, job.pr_readiness_contract, evidence.supportPrReadinessContract, evidence.support_pr_readiness_contract, evidence.prReadinessContract, evidence.pr_readiness_contract, autonomousDecision.prReadinessContract, autonomousDecision.pr_readiness_contract, recovery.prReadinessContract, recovery.pr_readiness_contract, ticket.supportPrReadinessContract, ticket.support_pr_readiness_contract, ticket.prReadinessContract, ticket.pr_readiness_contract, runnerConsole.last_pr_readiness_contract, runnerConsole.lastPrReadinessContract, runnerConsole.pr_readiness_contract, runnerConsole.prReadinessContract, ticketManager.last_pr_readiness_contract, ticketManager.lastPrReadinessContract, ticketManager.pr_readiness_contract, ticketManager.prReadinessContract);
3196
+ }
3197
+ function supportPrReadinessContractGate(contract, now) {
3198
+ var _a;
3199
+ if (!contract || !Object.keys(contract).length) {
3200
+ return undefined;
3201
+ }
3202
+ var statusText = cleanText(contract.status, 120).toLowerCase();
3203
+ var ready = contract.ready === true || statusText === 'ready';
3204
+ var blockers = cleanStringList(contract.blockers, 50, 500);
3205
+ var businessProofArtifacts = cleanStringList(contract.business_proof_artifacts || contract.businessProofArtifacts, 80, 500);
3206
+ var modifiedFiles = cleanStringList(contract.modified_files || contract.modifiedFiles, 120, 500);
3207
+ var pullRequestUrl = cleanText(contract.pull_request_url || contract.pullRequestUrl, 500);
3208
+ var status = ready ? 'pass' : 'blocked';
3209
+ return {
3210
+ key: 'support_pr_readiness_contract',
3211
+ label: 'Support PR readiness contract',
3212
+ status: status,
3213
+ reason: ready
3214
+ ? cleanText(contract.reason || 'Business proof is ready and PR packaging can run without merge/release/customer send.', 1200)
3215
+ : cleanText(blockers.join(' ') || contract.reason || 'PR creation is blocked until support business proof and PR readiness evidence pass.', 1200),
3216
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray([], __read(businessProofArtifacts), false), __read(modifiedFiles), false), 120, 500),
3217
+ recordedAt: isoNow(now || contract.created_at || contract.createdAt || contract.recorded_at || contract.recordedAt),
3218
+ metadata: {
3219
+ contractId: cleanText(contract.contract_id || contract.contractId, 180),
3220
+ status: statusText,
3221
+ ready: ready,
3222
+ action: cleanText(contract.action, 120),
3223
+ dispatchAction: cleanText(contract.dispatch_action || contract.dispatchAction, 120),
3224
+ method: cleanText(contract.method, 180),
3225
+ businessProofReady: contract.business_proof_ready === true || contract.businessProofReady === true,
3226
+ diagnosisValid: contract.diagnosis_valid === true || contract.diagnosisValid === true,
3227
+ jobPhase: cleanText(contract.job_phase || contract.jobPhase, 120),
3228
+ jobId: cleanText(contract.job_id || contract.jobId, 180),
3229
+ pullRequestUrl: pullRequestUrl,
3230
+ pullRequestStatus: cleanText(contract.pull_request_status || contract.pullRequestStatus, 120),
3231
+ prFailureStatus: cleanText(contract.pr_failure_status || contract.prFailureStatus, 120),
3232
+ confidenceBlocksPr: contract.confidence_blocks_pr === true || contract.confidenceBlocksPr === true,
3233
+ passedBusinessAssertionCount: numberValue((_a = contract.passed_business_assertion_count) !== null && _a !== void 0 ? _a : contract.passedBusinessAssertionCount) || 0,
3234
+ businessProofArtifacts: businessProofArtifacts,
3235
+ modifiedFiles: modifiedFiles,
3236
+ requiredEvidence: cleanStringList(contract.required_evidence || contract.requiredEvidence, 40, 500),
3237
+ forbiddenActions: cleanStringList(contract.forbidden_actions || contract.forbiddenActions, 40, 500),
3238
+ nextActionAfterPr: cleanText(contract.next_action_after_pr || contract.nextActionAfterPr, 160),
3239
+ targetGrade: cleanText(contract.target_grade || contract.targetGrade || 'A', 20),
3240
+ mergeBlockedUntilHumanApproval: contract.merge_blocked_until_human_approval === true || contract.mergeBlockedUntilHumanApproval === true,
3241
+ customerReplyBlockedUntilReleaseGate: contract.customer_reply_blocked_until_release_gate === true || contract.customerReplyBlockedUntilReleaseGate === true,
3242
+ releaseBlockedUntilPrReview: contract.release_blocked_until_pr_review === true || contract.releaseBlockedUntilPrReview === true,
3243
+ blockers: blockers
3244
+ }
3245
+ };
3246
+ }
3247
+ function supportPrReviewContractObject(ticket, job, evidence) {
3248
+ var ticketAutomation = plainObject(ticket.automation);
3249
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
3250
+ var runnerConsole = plainObject(ticketAutomation.runner_console || ticketAutomation.runnerConsole);
3251
+ var autonomousDecision = supportAutonomyDecisionObject(ticket, job, evidence);
3252
+ var recovery = plainObject(autonomousDecision.managerRecovery || autonomousDecision.manager_recovery);
3253
+ var autopilotProgress = plainObject(autonomousDecision.autopilot_completion_progress || autonomousDecision.autopilotCompletionProgress);
3254
+ return evidenceObject(job.supportPrReviewContract, job.support_pr_review_contract, job.prReviewContract, job.pr_review_contract, evidence.supportPrReviewContract, evidence.support_pr_review_contract, evidence.prReviewContract, evidence.pr_review_contract, autonomousDecision.prReviewContract, autonomousDecision.pr_review_contract, recovery.prReviewContract, recovery.pr_review_contract, autopilotProgress.prReviewContract, autopilotProgress.pr_review_contract, ticket.supportPrReviewContract, ticket.support_pr_review_contract, ticket.prReviewContract, ticket.pr_review_contract, runnerConsole.last_pr_review_contract, runnerConsole.lastPrReviewContract, runnerConsole.pr_review_contract, runnerConsole.prReviewContract, ticketManager.last_pr_review_contract, ticketManager.lastPrReviewContract, ticketManager.pr_review_contract, ticketManager.prReviewContract);
3255
+ }
3256
+ function supportGradeMeetsA(value) {
3257
+ return /^(A\+|A|A-)$/i.test(cleanText(value, 20));
3258
+ }
3259
+ function supportPrReviewContractGate(contract, now) {
3260
+ if (!contract || !Object.keys(contract).length) {
3261
+ return undefined;
3262
+ }
3263
+ var grades = plainObject(contract.grades);
3264
+ var executionGrade = cleanText(contract.execution_grade || contract.executionGrade || grades.execution || grades.execution_grade || grades.executionGrade, 20).toUpperCase();
3265
+ var artifactsGrade = cleanText(contract.artifacts_grade || contract.artifactsGrade || grades.artifacts || grades.artifacts_grade || grades.artifactsGrade, 20).toUpperCase();
3266
+ var pullRequestGrade = cleanText(contract.pull_request_grade || contract.pullRequestGrade || grades.pull_request || grades.pullRequest || grades.pr || grades.pr_grade, 20).toUpperCase();
3267
+ var strictGatePassed = contract.strict_gate_passed === true
3268
+ || contract.strictGatePassed === true
3269
+ || contract.passes_strict_gate === true
3270
+ || contract.passesStrictGate === true;
3271
+ var statusText = cleanText(contract.status, 120).toLowerCase();
3272
+ var ready = contract.ready === true
3273
+ || strictGatePassed === true
3274
+ || (statusText === 'passed' && supportGradeMeetsA(executionGrade) && supportGradeMeetsA(artifactsGrade) && supportGradeMeetsA(pullRequestGrade));
3275
+ var blockers = cleanStringList(contract.blockers, 50, 500);
3276
+ var evidenceRefs = cleanStringList(contract.evidence_refs || contract.evidenceRefs || contract.artifacts || contract.artifact_paths || contract.artifactPaths, 100, 500);
3277
+ var continuationContract = plainObject(contract.continuation_contract || contract.continuationContract);
3278
+ var status = ready ? 'pass' : 'blocked';
3279
+ return {
3280
+ key: 'support_pr_review_contract',
3281
+ label: 'Support A-grade PR review',
3282
+ status: status,
3283
+ reason: ready
3284
+ ? cleanText(contract.reason || "Strict A-grade PR review passed (execution=".concat(executionGrade || '-', ", artifacts=").concat(artifactsGrade || '-', ", pull_request=").concat(pullRequestGrade || '-', ")."), 1200)
3285
+ : cleanText(blockers.join(' ') || contract.reason || 'A-grade PR review is blocked until strict execution, artifact, pull_request, AIQa, before/action/after, and screenshot/trace evidence pass.', 1200),
3286
+ evidenceRefs: evidenceRefs,
3287
+ recordedAt: isoNow(now || contract.created_at || contract.createdAt || contract.recorded_at || contract.recordedAt),
3288
+ metadata: {
3289
+ contractId: cleanText(contract.contract_id || contract.contractId, 180),
3290
+ status: statusText,
3291
+ ready: ready,
3292
+ strictGatePassed: strictGatePassed,
3293
+ strictGateReason: cleanText(contract.strict_gate_reason || contract.strictGateReason || contract.reason, 500),
3294
+ executionGrade: executionGrade,
3295
+ artifactsGrade: artifactsGrade,
3296
+ pullRequestGrade: pullRequestGrade,
3297
+ targetGrade: cleanText(contract.target_grade || contract.targetGrade || 'A', 20),
3298
+ pullRequestUrl: cleanText(contract.pull_request_url || contract.pullRequestUrl, 500),
3299
+ pullRequestStatus: cleanText(contract.pull_request_status || contract.pullRequestStatus, 120),
3300
+ failureClass: cleanText(contract.failure_class || contract.failureClass || continuationContract.failure_class || continuationContract.failureClass, 120),
3301
+ blockerFingerprint: cleanText(contract.blocker_fingerprint || contract.blockerFingerprint || continuationContract.blocker_fingerprint || continuationContract.blockerFingerprint, 180),
3302
+ evidenceHash: cleanText(contract.evidence_hash || contract.evidenceHash || continuationContract.evidence_hash || continuationContract.evidenceHash, 180),
3303
+ continuationContract: Object.keys(continuationContract).length ? {
3304
+ contractId: cleanText(continuationContract.contract_id || continuationContract.contractId, 180),
3305
+ status: cleanText(continuationContract.status, 120),
3306
+ action: cleanText(continuationContract.action, 160),
3307
+ failureClass: cleanText(continuationContract.failure_class || continuationContract.failureClass, 120),
3308
+ blockerFingerprint: cleanText(continuationContract.blocker_fingerprint || continuationContract.blockerFingerprint, 180),
3309
+ evidenceHash: cleanText(continuationContract.evidence_hash || continuationContract.evidenceHash, 180),
3310
+ reason: cleanText(continuationContract.reason, 1000),
3311
+ requiredEvidence: cleanStringList(continuationContract.required_evidence || continuationContract.requiredEvidence, 40, 500),
3312
+ resetEvidenceRequired: cleanStringList(continuationContract.reset_evidence_required || continuationContract.resetEvidenceRequired, 40, 500),
3313
+ stopConditions: cleanStringList(continuationContract.stop_conditions || continuationContract.stopConditions, 40, 500),
3314
+ canRunWithoutCodexMonitor: continuationContract.can_run_without_codex_monitor === true || continuationContract.canRunWithoutCodexMonitor === true,
3315
+ productRepairAllowed: continuationContract.product_repair_allowed === true || continuationContract.productRepairAllowed === true,
3316
+ releaseCustomerSideEffectsAllowed: continuationContract.release_customer_side_effects_allowed === true || continuationContract.releaseCustomerSideEffectsAllowed === true
3317
+ } : undefined,
3318
+ requiredEvidence: cleanStringList(contract.required_evidence || contract.requiredEvidence, 40, 500),
3319
+ forbiddenActions: cleanStringList(contract.forbidden_actions || contract.forbiddenActions, 40, 500),
3320
+ nextAction: cleanText(contract.next_action || contract.nextAction, 160),
3321
+ blockers: blockers,
3322
+ evidenceRefs: evidenceRefs
3323
+ }
3324
+ };
3325
+ }
3326
+ function supportPrCreationResultObject(ticket, job, evidence) {
3327
+ var ticketAutomation = plainObject(ticket.automation);
3328
+ var codex = plainObject(ticketAutomation.codex);
3329
+ var release = plainObject(ticketAutomation.release);
3330
+ var pushMaster = plainObject(release.push_master || release.pushMaster);
3331
+ var qaValidation = plainObject(ticketAutomation.qa_validation || ticketAutomation.qaValidation);
3332
+ var prReadinessContract = supportPrReadinessContractObject(ticket, job, evidence);
3333
+ var pullRequestUrl = cleanText(evidence.pullRequestUrl
3334
+ || evidence.pull_request_url
3335
+ || job.pullRequestUrl
3336
+ || job.pull_request_url
3337
+ || prReadinessContract.pull_request_url
3338
+ || prReadinessContract.pullRequestUrl
3339
+ || codex.pull_request_url
3340
+ || codex.pullRequestUrl
3341
+ || pushMaster.pull_request_url
3342
+ || pushMaster.pullRequestUrl
3343
+ || qaValidation.pull_request_url
3344
+ || qaValidation.pullRequestUrl, 500);
3345
+ var pullRequestStatus = cleanText(evidence.pullRequestStatus
3346
+ || evidence.pull_request_status
3347
+ || job.pullRequestStatus
3348
+ || job.pull_request_status
3349
+ || prReadinessContract.pull_request_status
3350
+ || prReadinessContract.pullRequestStatus
3351
+ || codex.pull_request_status
3352
+ || codex.pullRequestStatus, 120);
3353
+ var prFailureStatus = cleanText(evidence.prFailureStatus
3354
+ || evidence.pr_failure_status
3355
+ || prReadinessContract.pr_failure_status
3356
+ || prReadinessContract.prFailureStatus, 120);
3357
+ var error = cleanText(evidence.pullRequestError
3358
+ || evidence.pull_request_error
3359
+ || job.pullRequestError
3360
+ || job.pull_request_error
3361
+ || codex.error
3362
+ || pushMaster.notes, 1200);
3363
+ var status = cleanText(evidence.prCreationStatus
3364
+ || evidence.pr_creation_status
3365
+ || evidence.status
3366
+ || codex.status
3367
+ || pullRequestStatus
3368
+ || prFailureStatus
3369
+ || (pullRequestUrl ? 'created' : ''), 120);
3370
+ if (!pullRequestUrl && !pullRequestStatus && !prFailureStatus && !error && !status) {
3371
+ return {};
3372
+ }
3373
+ return {
3374
+ source: 'support_pr_creation_result',
3375
+ status: status,
3376
+ pull_request_url: pullRequestUrl,
3377
+ pull_request_status: pullRequestStatus,
3378
+ pr_failure_status: prFailureStatus,
3379
+ error: error,
3380
+ job_id: cleanText(job._id || job.id || job.jobId || prReadinessContract.job_id || prReadinessContract.jobId || codex.job_id || codex.jobId, 180),
3381
+ method: cleanText(prReadinessContract.method || evidence.method || 'createSupportTicketCodexPullRequestManual', 180),
3382
+ pr_readiness_contract_id: cleanText(prReadinessContract.contract_id || prReadinessContract.contractId, 180),
3383
+ release_push_master_status: cleanText(pushMaster.status, 120),
3384
+ release_push_master_notes: cleanText(pushMaster.notes, 1000),
3385
+ modified_files: cleanStringList(evidence.modifiedFiles
3386
+ || evidence.modified_files
3387
+ || job.modifiedFiles
3388
+ || job.modified_files
3389
+ || codex.modified_files
3390
+ || codex.modifiedFiles
3391
+ || prReadinessContract.modified_files
3392
+ || prReadinessContract.modifiedFiles, 120, 500),
3393
+ business_proof_ready: prReadinessContract.business_proof_ready === true || prReadinessContract.businessProofReady === true,
3394
+ diagnosis_valid: prReadinessContract.diagnosis_valid === true || prReadinessContract.diagnosisValid === true,
3395
+ merge_blocked_until_human_approval: prReadinessContract.merge_blocked_until_human_approval === true || prReadinessContract.mergeBlockedUntilHumanApproval === true,
3396
+ customer_reply_blocked_until_release_gate: prReadinessContract.customer_reply_blocked_until_release_gate === true || prReadinessContract.customerReplyBlockedUntilReleaseGate === true,
3397
+ release_blocked_until_pr_review: prReadinessContract.release_blocked_until_pr_review === true || prReadinessContract.releaseBlockedUntilPrReview === true
3398
+ };
3399
+ }
3400
+ function supportPrCreationResultGate(result, now) {
3401
+ if (!result || !Object.keys(result).length) {
3402
+ return undefined;
3403
+ }
3404
+ var statusText = cleanText(result.status, 120).toLowerCase();
3405
+ var pullRequestStatus = cleanText(result.pull_request_status || result.pullRequestStatus, 120).toLowerCase();
3406
+ var prFailureStatus = cleanText(result.pr_failure_status || result.prFailureStatus, 120).toLowerCase();
3407
+ var pullRequestUrl = cleanText(result.pull_request_url || result.pullRequestUrl, 500);
3408
+ var error = cleanText(result.error || result.message || result.reason, 1200);
3409
+ var blocked = /blocked|manual|pending_manual|dependency|release_safety/.test(statusText)
3410
+ || /blocked|manual|pending_manual|dependency|release_safety/.test(pullRequestStatus)
3411
+ || !!prFailureStatus;
3412
+ var failed = /fail|failed|error/.test(statusText)
3413
+ || /fail|failed|error/.test(pullRequestStatus)
3414
+ || /fail|failed|error/.test(prFailureStatus);
3415
+ var created = !!pullRequestUrl && !blocked && !failed;
3416
+ var status = created
3417
+ ? 'pass'
3418
+ : failed
3419
+ ? 'fail'
3420
+ : blocked
3421
+ ? 'blocked'
3422
+ : 'warn';
3423
+ var reason = created
3424
+ ? "Support PR was created: ".concat(pullRequestUrl)
3425
+ : failed
3426
+ ? cleanText(error || 'Support PR creation failed.', 1200)
3427
+ : blocked
3428
+ ? cleanText(error || result.release_push_master_notes || 'Support PR creation is blocked pending manual/platform repair.', 1200)
3429
+ : 'Support PR creation has non-terminal or incomplete status.';
3430
+ return {
3431
+ key: 'support_pr_creation_result',
3432
+ label: 'Support PR creation result',
3433
+ status: status,
3434
+ reason: reason,
3435
+ evidenceRefs: cleanStringList(__spreadArray([
3436
+ pullRequestUrl
3437
+ ], __read(asArray(result.modified_files || result.modifiedFiles)), false), 120, 500),
3438
+ recordedAt: isoNow(now || result.created_at || result.createdAt || result.updated_at || result.updatedAt),
3439
+ metadata: {
3440
+ status: statusText,
3441
+ pullRequestUrl: pullRequestUrl,
3442
+ pullRequestStatus: pullRequestStatus,
3443
+ prFailureStatus: prFailureStatus,
3444
+ error: error,
3445
+ jobId: cleanText(result.job_id || result.jobId, 180),
3446
+ method: cleanText(result.method, 180),
3447
+ prReadinessContractId: cleanText(result.pr_readiness_contract_id || result.prReadinessContractId, 180),
3448
+ releasePushMasterStatus: cleanText(result.release_push_master_status || result.releasePushMasterStatus, 120),
3449
+ releasePushMasterNotes: cleanText(result.release_push_master_notes || result.releasePushMasterNotes, 1000),
3450
+ modifiedFiles: cleanStringList(result.modified_files || result.modifiedFiles, 120, 500),
3451
+ businessProofReady: result.business_proof_ready === true || result.businessProofReady === true,
3452
+ diagnosisValid: result.diagnosis_valid === true || result.diagnosisValid === true,
3453
+ mergeBlockedUntilHumanApproval: result.merge_blocked_until_human_approval === true || result.mergeBlockedUntilHumanApproval === true,
3454
+ customerReplyBlockedUntilReleaseGate: result.customer_reply_blocked_until_release_gate === true || result.customerReplyBlockedUntilReleaseGate === true,
3455
+ releaseBlockedUntilPrReview: result.release_blocked_until_pr_review === true || result.releaseBlockedUntilPrReview === true,
3456
+ nextAction: created
3457
+ ? 'review_a_grade_pr_and_release_gate'
3458
+ : failed || blocked
3459
+ ? 'repair_pr_creation_blocker'
3460
+ : 'check_pr_creation_status'
3461
+ }
3462
+ };
3463
+ }
3464
+ function supportArtifactListHasScreenshotOrTrace(paths) {
3465
+ return paths.some(function (artifact) { return /\.(?:png|jpe?g|webp|gif|mp4|webm|zip)$/i.test(artifact)
3466
+ || /\b(?:trace|video|screenshot|screen-capture|playwright-report|test-results)\b/i.test(artifact); });
3467
+ }
3468
+ function supportStatusIn(value, statuses) {
3469
+ var normalized = cleanText(value, 120).toLowerCase();
3470
+ return !!normalized && statuses.includes(normalized);
3471
+ }
3472
+ function sameSupportEvidenceRef(left, right) {
3473
+ var normalizedLeft = cleanText(left, 500).toLowerCase();
3474
+ var normalizedRight = cleanText(right, 500).toLowerCase();
3475
+ return !!normalizedLeft && !!normalizedRight && normalizedLeft === normalizedRight;
3476
+ }
3477
+ function supportEvidenceRefMatchesCurrent(current, candidate) {
3478
+ var normalizedCandidate = cleanText(candidate, 500);
3479
+ return !normalizedCandidate || sameSupportEvidenceRef(current, normalizedCandidate);
3480
+ }
3481
+ function supportEvidenceRefPresent(candidate) {
3482
+ return !!cleanText(candidate, 500);
3483
+ }
3484
+ function supportReleaseCustomerAcceptanceObject(ticket, job, evidence, prReadinessContract) {
3485
+ var ticketAutomation = plainObject(ticket.automation);
3486
+ var jobAutomation = plainObject(job.automation);
3487
+ var evidenceRelease = plainObject(evidence.release || evidence.releaseEvidence || evidence.release_evidence);
3488
+ var release = __assign(__assign(__assign({}, plainObject(ticketAutomation.release)), plainObject(jobAutomation.release)), evidenceRelease);
3489
+ var pushMaster = plainObject(release.push_master || release.pushMaster);
3490
+ var deployProduction = plainObject(release.deploy_production || release.deployProduction || release.production);
3491
+ var hotfixEvidenceState = plainObject(release.hotfix_evidence || release.hotfixEvidence);
3492
+ var currentHotfix = plainObject(hotfixEvidenceState.current);
3493
+ var hotfixEvidence = plainObject(hotfixEvidenceState.normalized
3494
+ || currentHotfix.evidence
3495
+ || currentHotfix.normalized
3496
+ || hotfixEvidenceState.current_evidence
3497
+ || hotfixEvidenceState.currentEvidence);
3498
+ var customerReplyPolicy = plainObject(ticketAutomation.customer_reply_policy
3499
+ || ticketAutomation.customerReplyPolicy
3500
+ || job.customerReplyPolicy
3501
+ || job.customer_reply_policy
3502
+ || evidence.customerReplyPolicy
3503
+ || evidence.customer_reply_policy);
3504
+ var lastSendGuard = plainObject(customerReplyPolicy.last_send_guard || customerReplyPolicy.lastSendGuard);
3505
+ var lastManualSend = plainObject(customerReplyPolicy.last_manual_send || customerReplyPolicy.lastManualSend);
3506
+ var proofBackedSendContract = plainObject(customerReplyPolicy.last_proof_backed_send_contract || customerReplyPolicy.lastProofBackedSendContract);
3507
+ var customerReplyReadiness = plainObject(evidence.customerReplyReadiness
3508
+ || evidence.customer_reply_readiness
3509
+ || customerReplyPolicy.readinessContract
3510
+ || customerReplyPolicy.readiness_contract
3511
+ || job.customerReplyReadiness
3512
+ || job.customer_reply_readiness);
3513
+ var pullRequestUrl = cleanText(prReadinessContract.pull_request_url
3514
+ || prReadinessContract.pullRequestUrl
3515
+ || evidence.pull_request_url
3516
+ || evidence.pullRequestUrl
3517
+ || job.pullRequestUrl
3518
+ || job.pull_request_url, 500);
3519
+ var releasePullRequestUrl = cleanText(pushMaster.pull_request_url
3520
+ || pushMaster.pullRequestUrl
3521
+ || release.pull_request_url
3522
+ || release.pullRequestUrl, 500);
3523
+ var deployPullRequestUrl = cleanText(deployProduction.last_deploy_pull_request_url
3524
+ || deployProduction.lastDeployPullRequestUrl
3525
+ || deployProduction.pull_request_url
3526
+ || deployProduction.pullRequestUrl, 500);
3527
+ var replyPullRequestUrl = cleanText(proofBackedSendContract.pull_request_url
3528
+ || proofBackedSendContract.pullRequestUrl
3529
+ || proofBackedSendContract.pr_url
3530
+ || proofBackedSendContract.prUrl
3531
+ || lastManualSend.pull_request_url
3532
+ || lastManualSend.pullRequestUrl
3533
+ || lastManualSend.pr_url
3534
+ || lastManualSend.prUrl
3535
+ || lastSendGuard.pull_request_url
3536
+ || lastSendGuard.pullRequestUrl
3537
+ || lastSendGuard.pr_url
3538
+ || lastSendGuard.prUrl
3539
+ || customerReplyReadiness.pull_request_url
3540
+ || customerReplyReadiness.pullRequestUrl
3541
+ || customerReplyReadiness.pr_url
3542
+ || customerReplyReadiness.prUrl, 500);
3543
+ var prReady = prReadinessContract.ready === true || cleanText(prReadinessContract.status, 120).toLowerCase() === 'ready';
3544
+ var requiresFinalAcceptance = prReady && !!pullRequestUrl;
3545
+ if (!requiresFinalAcceptance) {
3546
+ return {};
3547
+ }
3548
+ var pushMasterStatus = cleanText(pushMaster.status, 120).toLowerCase();
3549
+ var deployProductionStatus = cleanText(deployProduction.status, 120).toLowerCase();
3550
+ var hotfixReleaseGateStatus = cleanText(hotfixEvidence.releaseGateStatus
3551
+ || hotfixEvidence.release_gate_status
3552
+ || hotfixEvidenceState.releaseGateStatus
3553
+ || hotfixEvidenceState.release_gate_status
3554
+ || hotfixEvidenceState.status, 120).toLowerCase();
3555
+ var pushMasterComplete = supportStatusIn(pushMasterStatus, ['completed', 'complete', 'merged', 'success', 'succeeded']);
3556
+ var productionDeployComplete = supportStatusIn(deployProductionStatus, ['completed', 'complete', 'deployed', 'success', 'succeeded', 'not_required', 'skipped']);
3557
+ var productionDeployNotRequired = deployProduction.deploy_not_required === true
3558
+ || deployProduction.deployNotRequired === true
3559
+ || deployProduction.not_required === true
3560
+ || deployProduction.notRequired === true;
3561
+ var hotfixReleaseGatePassed = supportStatusIn(hotfixReleaseGateStatus, ['pass', 'passed', 'success', 'succeeded', 'completed', 'complete']);
3562
+ var releasePrMatchesCurrent = supportEvidenceRefMatchesCurrent(pullRequestUrl, releasePullRequestUrl);
3563
+ var deployPrMatchesCurrent = supportEvidenceRefMatchesCurrent(pullRequestUrl, deployPullRequestUrl);
3564
+ var replyPrReferencePresent = supportEvidenceRefPresent(replyPullRequestUrl);
3565
+ var replyPrMatchesCurrent = replyPrReferencePresent && sameSupportEvidenceRef(pullRequestUrl, replyPullRequestUrl);
3566
+ var releaseReady = (pushMasterComplete || hotfixReleaseGatePassed)
3567
+ && (productionDeployComplete || productionDeployNotRequired || hotfixReleaseGatePassed)
3568
+ && releasePrMatchesCurrent
3569
+ && deployPrMatchesCurrent;
3570
+ var proofBackedSendStatus = cleanText(proofBackedSendContract.status || lastManualSend.status, 120).toLowerCase();
3571
+ var proofBackedSendRecorded = supportStatusIn(proofBackedSendStatus, ['sent_after_manual_approval', 'sent', 'sent_after_review', 'completed', 'complete'])
3572
+ && (proofBackedSendContract.proof_backed === true || proofBackedSendContract.proofBacked === true || lastManualSend.proof_backed === true || lastManualSend.proofBacked === true);
3573
+ var sendGuardReady = (lastSendGuard.allowed === true || lastSendGuard.manual_send_after_review_allowed === true || lastSendGuard.manualSendAfterReviewAllowed === true)
3574
+ && supportStatusIn(lastSendGuard.status, ['ready_for_manual_send', 'ready', 'pass', 'passed']);
3575
+ var readinessStatus = cleanText(customerReplyReadiness.status, 120).toLowerCase();
3576
+ var replyDraftReady = readinessStatus === 'draft_ready'
3577
+ && (customerReplyReadiness.canDraftCustomerReply === true || customerReplyReadiness.can_draft_customer_reply === true)
3578
+ && customerReplyReadiness.canSendCustomerReply !== true
3579
+ && customerReplyReadiness.can_send_customer_reply !== true
3580
+ && (customerReplyReadiness.proofBacked === true || customerReplyReadiness.proof_backed === true)
3581
+ && (customerReplyReadiness.businessProofReady === true || customerReplyReadiness.business_proof_ready === true)
3582
+ && (customerReplyReadiness.releaseReady === true || customerReplyReadiness.release_ready === true || releaseReady)
3583
+ && (customerReplyReadiness.diagnosisReady === true || customerReplyReadiness.diagnosis_ready === true);
3584
+ var customerReplyReady = (proofBackedSendRecorded || sendGuardReady || replyDraftReady) && replyPrMatchesCurrent;
3585
+ var staleEvidenceBlockers = [
3586
+ releasePrMatchesCurrent ? '' : 'Push-to-master evidence belongs to a different PR than the proof-backed support run.',
3587
+ deployPrMatchesCurrent ? '' : 'Production deploy evidence belongs to a different PR than the proof-backed support run.',
3588
+ replyPrReferencePresent ? '' : 'Proof-backed customer reply evidence is missing the current PR reference.',
3589
+ replyPrReferencePresent && !replyPrMatchesCurrent ? 'Proof-backed customer reply evidence belongs to a different PR than the proof-backed support run.' : ''
3590
+ ].filter(Boolean);
3591
+ return {
3592
+ source: 'support_release_customer_acceptance',
3593
+ required: true,
3594
+ pull_request_url: pullRequestUrl,
3595
+ release_pull_request_url: releasePullRequestUrl,
3596
+ deploy_pull_request_url: deployPullRequestUrl,
3597
+ reply_pull_request_url: replyPullRequestUrl,
3598
+ pr_ready: prReady,
3599
+ push_master_status: pushMasterStatus,
3600
+ deploy_production_status: deployProductionStatus,
3601
+ hotfix_release_gate_status: hotfixReleaseGateStatus,
3602
+ release_pr_matches_current: releasePrMatchesCurrent,
3603
+ deploy_pr_matches_current: deployPrMatchesCurrent,
3604
+ reply_pr_reference_present: replyPrReferencePresent,
3605
+ reply_pr_matches_current: replyPrMatchesCurrent,
3606
+ stale_evidence_blockers: staleEvidenceBlockers,
3607
+ push_master_complete: pushMasterComplete,
3608
+ production_deploy_complete: productionDeployComplete,
3609
+ production_deploy_not_required: productionDeployNotRequired,
3610
+ hotfix_release_gate_passed: hotfixReleaseGatePassed,
3611
+ release_ready: releaseReady,
3612
+ customer_reply_ready: customerReplyReady,
3613
+ customer_reply_readiness_status: readinessStatus,
3614
+ proof_backed_send_status: proofBackedSendStatus,
3615
+ proof_backed_send_recorded: proofBackedSendRecorded,
3616
+ send_guard_ready: sendGuardReady,
3617
+ reply_draft_ready: replyDraftReady,
3618
+ customer_reply_requires_human_approval: customerReplyReadiness.requiresHumanApproval !== false && customerReplyReadiness.requires_human_approval !== false,
3619
+ next_action: releaseReady
3620
+ ? (customerReplyReady ? 'no_action_required' : 'draft_or_review_proof_backed_customer_reply')
3621
+ : 'review_a_grade_pr_and_release_gate',
3622
+ evidence_refs: cleanStringList(__spreadArray(__spreadArray([
3623
+ pullRequestUrl,
3624
+ pushMaster.pull_request_url || pushMaster.pullRequestUrl,
3625
+ deployProduction.last_deploy_pull_request_url || deployProduction.lastDeployPullRequestUrl
3626
+ ], __read(asArray(customerReplyReadiness.evidenceRefs || customerReplyReadiness.evidence_refs)), false), __read(asArray(proofBackedSendContract.evidence_refs || proofBackedSendContract.evidenceRefs)), false), 80, 500)
3627
+ };
3628
+ }
3629
+ function supportReleaseCustomerAcceptanceGate(contract, now) {
3630
+ if (!contract || !Object.keys(contract).length) {
3631
+ return undefined;
3632
+ }
3633
+ var releaseReady = contract.release_ready === true || contract.releaseReady === true;
3634
+ var customerReplyReady = contract.customer_reply_ready === true || contract.customerReplyReady === true;
3635
+ var blockers = __spreadArray([
3636
+ releaseReady ? '' : 'Release/hotfix evidence is not ready after A-grade support PR proof.',
3637
+ customerReplyReady ? '' : 'Proof-backed customer reply is not sent or draft-ready for human review.'
3638
+ ], __read(cleanStringList(contract.stale_evidence_blockers || contract.staleEvidenceBlockers, 10, 500)), false).filter(Boolean);
3639
+ var status = blockers.length ? 'blocked' : 'pass';
3640
+ return {
3641
+ key: 'support_release_customer_acceptance',
3642
+ label: 'Support release/customer acceptance',
3643
+ status: status,
3644
+ reason: status === 'pass'
3645
+ ? 'A-grade PR proof, release/hotfix evidence, and proof-backed customer reply readiness are complete.'
3646
+ : blockers.join(' '),
3647
+ evidenceRefs: cleanStringList(contract.evidence_refs || contract.evidenceRefs, 80, 500),
3648
+ recordedAt: isoNow(now || contract.recorded_at || contract.recordedAt),
3649
+ metadata: {
3650
+ required: contract.required === true,
3651
+ pullRequestUrl: cleanText(contract.pull_request_url || contract.pullRequestUrl, 500),
3652
+ releasePullRequestUrl: cleanText(contract.release_pull_request_url || contract.releasePullRequestUrl, 500),
3653
+ deployPullRequestUrl: cleanText(contract.deploy_pull_request_url || contract.deployPullRequestUrl, 500),
3654
+ replyPullRequestUrl: cleanText(contract.reply_pull_request_url || contract.replyPullRequestUrl, 500),
3655
+ prReady: contract.pr_ready === true || contract.prReady === true,
3656
+ pushMasterStatus: cleanText(contract.push_master_status || contract.pushMasterStatus, 120),
3657
+ deployProductionStatus: cleanText(contract.deploy_production_status || contract.deployProductionStatus, 120),
3658
+ hotfixReleaseGateStatus: cleanText(contract.hotfix_release_gate_status || contract.hotfixReleaseGateStatus, 120),
3659
+ releasePrMatchesCurrent: contract.release_pr_matches_current === true || contract.releasePrMatchesCurrent === true,
3660
+ deployPrMatchesCurrent: contract.deploy_pr_matches_current === true || contract.deployPrMatchesCurrent === true,
3661
+ replyPrReferencePresent: contract.reply_pr_reference_present === true || contract.replyPrReferencePresent === true,
3662
+ replyPrMatchesCurrent: contract.reply_pr_matches_current === true || contract.replyPrMatchesCurrent === true,
3663
+ pushMasterComplete: contract.push_master_complete === true || contract.pushMasterComplete === true,
3664
+ productionDeployComplete: contract.production_deploy_complete === true || contract.productionDeployComplete === true,
3665
+ productionDeployNotRequired: contract.production_deploy_not_required === true || contract.productionDeployNotRequired === true,
3666
+ hotfixReleaseGatePassed: contract.hotfix_release_gate_passed === true || contract.hotfixReleaseGatePassed === true,
3667
+ releaseReady: releaseReady,
3668
+ customerReplyReady: customerReplyReady,
3669
+ customerReplyReadinessStatus: cleanText(contract.customer_reply_readiness_status || contract.customerReplyReadinessStatus, 120),
3670
+ proofBackedSendStatus: cleanText(contract.proof_backed_send_status || contract.proofBackedSendStatus, 120),
3671
+ proofBackedSendRecorded: contract.proof_backed_send_recorded === true || contract.proofBackedSendRecorded === true,
3672
+ sendGuardReady: contract.send_guard_ready === true || contract.sendGuardReady === true,
3673
+ replyDraftReady: contract.reply_draft_ready === true || contract.replyDraftReady === true,
3674
+ customerReplyRequiresHumanApproval: contract.customer_reply_requires_human_approval !== false && contract.customerReplyRequiresHumanApproval !== false,
3675
+ nextAction: cleanText(contract.next_action || contract.nextAction, 160),
3676
+ blockers: blockers
3677
+ }
3678
+ };
3679
+ }
3680
+ function supportAutopilotCompletionContractGate(approval, prReadinessContract, prReviewContract, now) {
3681
+ var _a, _b, _c, _d, _e, _f, _g;
3682
+ if (!approval || !Object.keys(approval).length) {
3683
+ return undefined;
3684
+ }
3685
+ var completionContract = plainObject(approval.autopilot_completion_contract || approval.autopilotCompletionContract);
3686
+ var requiresCompletion = approval.after_approval_autopilot_until_a_grade === true
3687
+ || approval.afterApprovalAutopilotUntilAGrade === true
3688
+ || approval.autopilot_after_approval_until_a_grade === true
3689
+ || Object.keys(completionContract).length > 0;
3690
+ if (!requiresCompletion) {
3691
+ return undefined;
3692
+ }
3693
+ var prReady = prReadinessContract.ready === true || cleanText(prReadinessContract.status, 120).toLowerCase() === 'ready';
3694
+ var businessProofReady = prReadinessContract.business_proof_ready === true || prReadinessContract.businessProofReady === true;
3695
+ var pullRequestUrl = cleanText(prReadinessContract.pull_request_url || prReadinessContract.pullRequestUrl, 500);
3696
+ var prReviewGate = supportPrReviewContractGate(prReviewContract, now);
3697
+ var prReviewReady = (prReviewGate === null || prReviewGate === void 0 ? void 0 : prReviewGate.status) === 'pass';
3698
+ var businessProofArtifacts = cleanStringList(prReadinessContract.business_proof_artifacts || prReadinessContract.businessProofArtifacts, 80, 500);
3699
+ var modifiedFiles = cleanStringList(prReadinessContract.modified_files || prReadinessContract.modifiedFiles, 120, 500);
3700
+ var requiredCompletionEvidence = cleanStringList(approval.required_completion_evidence
3701
+ || approval.requiredCompletionEvidence
3702
+ || completionContract.required_evidence
3703
+ || completionContract.requiredEvidence, 50, 500);
3704
+ var missing = [];
3705
+ if (businessProofReady !== true) {
3706
+ missing.push('AIQaBusinessAssertion before/action/after business proof is not ready.');
3707
+ }
3708
+ if (approval.qa_screenshots_required === true || approval.qaScreenshotsRequired === true) {
3709
+ if (!supportArtifactListHasScreenshotOrTrace(businessProofArtifacts)) {
3710
+ missing.push('QA screenshot or trace artifact is missing.');
3711
+ }
3712
+ }
3713
+ if (!modifiedFiles.length) {
3714
+ missing.push('Changed-file or diff evidence is missing.');
3715
+ }
3716
+ if (!prReady) {
3717
+ missing.push('PR readiness contract is not ready.');
3718
+ }
3719
+ if (prReady && !pullRequestUrl) {
3720
+ missing.push('A-grade PR has not been created yet.');
3721
+ }
3722
+ if (prReady && pullRequestUrl && !prReviewReady) {
3723
+ missing.push('A-grade execution/artifacts/pull_request review has not passed yet.');
3724
+ }
3725
+ var nextAction = businessProofReady !== true
3726
+ ? 'run_business_proof_qa'
3727
+ : prReady && !pullRequestUrl
3728
+ ? 'create_pr'
3729
+ : prReady && pullRequestUrl && !prReviewReady
3730
+ ? 'run_a_grade_pr_review'
3731
+ : !prReady
3732
+ ? 'continue_owner_scoped_repair'
3733
+ : 'review_a_grade_pr_and_release_gate';
3734
+ var status = missing.length ? 'blocked' : 'pass';
2057
3735
  return {
2058
- key: 'support_customer_reply_readiness',
2059
- label: 'Support customer reply readiness',
2060
- status: gateStatus,
2061
- reason: normalized.reason || validation.blockers.join('; ') || status || 'Support customer reply readiness recorded.',
2062
- evidenceRefs: normalized.evidenceRefs,
2063
- recordedAt: isoNow(now || normalized.createdAt),
3736
+ key: 'support_autopilot_completion_contract',
3737
+ label: 'Support approved-autopilot completion',
3738
+ status: status,
3739
+ reason: missing.length
3740
+ ? missing.join(' ')
3741
+ : 'Approved support autopilot reached A-grade PR proof; merge, release, deploy, and customer reply remain separately gated.',
3742
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(businessProofArtifacts), false), __read(modifiedFiles), false), [
3743
+ pullRequestUrl
3744
+ ], false), __read(((prReviewGate === null || prReviewGate === void 0 ? void 0 : prReviewGate.evidenceRefs) || [])), false), __read(requiredCompletionEvidence), false), 140, 500),
3745
+ recordedAt: isoNow(now || prReadinessContract.created_at || prReadinessContract.createdAt || approval.approved_at || approval.approvedAt),
2064
3746
  metadata: {
2065
- contractId: normalized.contractId,
2066
- status: status,
2067
- policyAction: normalized.policyAction,
2068
- reviewType: normalized.reviewType,
2069
- primaryCommand: normalized.primaryCommand,
2070
- canDraftCustomerReply: normalized.canDraftCustomerReply,
2071
- canSendCustomerReply: normalized.canSendCustomerReply,
2072
- requiresHumanApproval: normalized.requiresHumanApproval,
2073
- proofBacked: normalized.proofBacked,
2074
- businessProofReady: normalized.businessProofReady,
2075
- releaseReady: normalized.releaseReady,
2076
- diagnosisReady: normalized.diagnosisReady,
2077
- issueClassProbePlanReady: normalized.issueClassProbePlanReady,
2078
- clarificationRequired: normalized.clarificationRequired,
2079
- blockers: Array.from(new Set(__spreadArray(__spreadArray([], __read(normalized.blockers), false), __read(validation.blockers), false))),
2080
- requiredEvidence: normalized.requiredEvidence,
2081
- nextCommands: normalized.nextCommands,
2082
- forbiddenActions: normalized.forbiddenActions
3747
+ mode: cleanText(completionContract.mode || 'approved_scope_to_a_grade_pr', 160),
3748
+ status: status === 'pass' ? 'complete' : 'incomplete',
3749
+ approved: approval.approved === true,
3750
+ contractId: cleanText(approval.contract_id || approval.contractId, 180),
3751
+ prReadinessContractId: cleanText(prReadinessContract.contract_id || prReadinessContract.contractId, 180),
3752
+ prReviewContractId: cleanText((_a = prReviewGate === null || prReviewGate === void 0 ? void 0 : prReviewGate.metadata) === null || _a === void 0 ? void 0 : _a.contractId, 180),
3753
+ nextAction: nextAction,
3754
+ targetGrade: cleanText(approval.target_grade || approval.targetGrade || prReadinessContract.target_grade || prReadinessContract.targetGrade || 'A', 20),
3755
+ businessProofReady: businessProofReady,
3756
+ prReady: prReady,
3757
+ pullRequestUrl: pullRequestUrl,
3758
+ pullRequestStatus: cleanText(prReadinessContract.pull_request_status || prReadinessContract.pullRequestStatus, 120),
3759
+ prReviewReady: prReviewReady,
3760
+ prReviewStatus: cleanText((_b = prReviewGate === null || prReviewGate === void 0 ? void 0 : prReviewGate.metadata) === null || _b === void 0 ? void 0 : _b.status, 120),
3761
+ prReviewStrictGatePassed: ((_c = prReviewGate === null || prReviewGate === void 0 ? void 0 : prReviewGate.metadata) === null || _c === void 0 ? void 0 : _c.strictGatePassed) === true,
3762
+ prReviewStrictGateReason: cleanText((_d = prReviewGate === null || prReviewGate === void 0 ? void 0 : prReviewGate.metadata) === null || _d === void 0 ? void 0 : _d.strictGateReason, 500),
3763
+ prReviewExecutionGrade: cleanText((_e = prReviewGate === null || prReviewGate === void 0 ? void 0 : prReviewGate.metadata) === null || _e === void 0 ? void 0 : _e.executionGrade, 20),
3764
+ prReviewArtifactsGrade: cleanText((_f = prReviewGate === null || prReviewGate === void 0 ? void 0 : prReviewGate.metadata) === null || _f === void 0 ? void 0 : _f.artifactsGrade, 20),
3765
+ prReviewPullRequestGrade: cleanText((_g = prReviewGate === null || prReviewGate === void 0 ? void 0 : prReviewGate.metadata) === null || _g === void 0 ? void 0 : _g.pullRequestGrade, 20),
3766
+ qaScreenshotsRequired: approval.qa_screenshots_required === true || approval.qaScreenshotsRequired === true,
3767
+ beforeActionAfterBusinessProofRequired: approval.before_action_after_business_proof_required === true || approval.beforeActionAfterBusinessProofRequired === true,
3768
+ aiqaBusinessAssertionRequired: approval.aiqa_business_assertion_required === true || approval.aiqaBusinessAssertionRequired === true,
3769
+ hasScreenshotOrTrace: supportArtifactListHasScreenshotOrTrace(businessProofArtifacts),
3770
+ businessProofArtifacts: businessProofArtifacts,
3771
+ modifiedFiles: modifiedFiles,
3772
+ requiredCompletionEvidence: requiredCompletionEvidence,
3773
+ missingCompletionEvidence: missing,
3774
+ forbiddenActions: cleanStringList(completionContract.forbidden_actions || completionContract.forbiddenActions, 30, 500),
3775
+ mergeBlockedUntilHumanApproval: prReadinessContract.merge_blocked_until_human_approval === true || prReadinessContract.mergeBlockedUntilHumanApproval === true,
3776
+ customerReplyBlockedUntilReleaseGate: prReadinessContract.customer_reply_blocked_until_release_gate === true || prReadinessContract.customerReplyBlockedUntilReleaseGate === true,
3777
+ releaseBlockedUntilPrReview: prReadinessContract.release_blocked_until_pr_review === true || prReadinessContract.releaseBlockedUntilPrReview === true
2083
3778
  }
2084
3779
  };
2085
3780
  }
@@ -2129,7 +3824,7 @@ function supportNextActionContractRequired(ticket, job, evidence) {
2129
3824
  || !!ticketManager.last_watchdog_decision;
2130
3825
  }
2131
3826
  function supportNextActionContractMetadata(contract) {
2132
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
3827
+ var _a, _b, _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;
2133
3828
  var decisionBasis = plainObject(contract.decisionBasis || contract.decision_basis);
2134
3829
  var costRisk = plainObject(contract.costRisk || contract.cost_risk);
2135
3830
  var source = {
@@ -2161,19 +3856,31 @@ function supportNextActionContractMetadata(contract) {
2161
3856
  diagnosisValid: booleanFlag((_j = decisionBasis.diagnosisValid) !== null && _j !== void 0 ? _j : decisionBasis.diagnosis_valid),
2162
3857
  ownerFilesReady: booleanFlag((_k = decisionBasis.ownerFilesReady) !== null && _k !== void 0 ? _k : decisionBasis.owner_files_ready),
2163
3858
  proofPlanReady: booleanFlag((_l = decisionBasis.proofPlanReady) !== null && _l !== void 0 ? _l : decisionBasis.proof_plan_ready),
2164
- businessProofReady: booleanFlag((_m = decisionBasis.businessProofReady) !== null && _m !== void 0 ? _m : decisionBasis.business_proof_ready),
3859
+ proofMatrixReady: booleanFlag((_m = decisionBasis.proofMatrixReady) !== null && _m !== void 0 ? _m : decisionBasis.proof_matrix_ready),
3860
+ proofMatrixId: cleanText(decisionBasis.proofMatrixId || decisionBasis.proof_matrix_id, 200),
3861
+ ownerScopedRepairContractReady: booleanFlag((_o = decisionBasis.ownerScopedRepairContractReady) !== null && _o !== void 0 ? _o : decisionBasis.owner_scoped_repair_contract_ready),
3862
+ ownerScopedRepairContractId: cleanText(decisionBasis.ownerScopedRepairContractId || decisionBasis.owner_scoped_repair_contract_id, 200),
3863
+ businessProofReady: booleanFlag((_p = decisionBasis.businessProofReady) !== null && _p !== void 0 ? _p : decisionBasis.business_proof_ready),
2165
3864
  evidenceFreshnessStatus: cleanText(decisionBasis.evidenceFreshnessStatus || decisionBasis.evidence_freshness_status, 120),
2166
3865
  evidenceStrength: cleanText(decisionBasis.evidenceStrength || decisionBasis.evidence_strength, 120),
2167
3866
  failureClass: cleanText(decisionBasis.failureClass || decisionBasis.failure_class, 120),
2168
3867
  blockerFingerprint: cleanText(decisionBasis.blockerFingerprint || decisionBasis.blocker_fingerprint, 200),
2169
3868
  evidenceHash: cleanText(decisionBasis.evidenceHash || decisionBasis.evidence_hash, 200),
2170
- sameFailureCount: numberValue((_o = decisionBasis.sameFailureCount) !== null && _o !== void 0 ? _o : decisionBasis.same_failure_count),
2171
- preflightReady: booleanFlag((_p = decisionBasis.preflightReady) !== null && _p !== void 0 ? _p : decisionBasis.preflight_ready),
3869
+ sameFailureCount: numberValue((_q = decisionBasis.sameFailureCount) !== null && _q !== void 0 ? _q : decisionBasis.same_failure_count),
3870
+ preflightReady: booleanFlag((_r = decisionBasis.preflightReady) !== null && _r !== void 0 ? _r : decisionBasis.preflight_ready),
2172
3871
  preflightStatus: cleanText(decisionBasis.preflightStatus || decisionBasis.preflight_status, 120),
2173
3872
  preflightFailureClass: cleanText(decisionBasis.preflightFailureClass || decisionBasis.preflight_failure_class, 120),
2174
3873
  preflightEvidenceHash: cleanText(decisionBasis.preflightEvidenceHash || decisionBasis.preflight_evidence_hash, 200),
2175
- hotfixCommitRequired: booleanFlag((_s = (_r = (_q = decisionBasis.hotfixCommitRequired) !== null && _q !== void 0 ? _q : decisionBasis.hotfix_commit_required) !== null && _r !== void 0 ? _r : contract.hotfixCommitRequired) !== null && _s !== void 0 ? _s : contract.hotfix_commit_required),
2176
- liveHotfixBlockedUntilCommit: booleanFlag((_v = (_u = (_t = decisionBasis.liveHotfixBlockedUntilCommit) !== null && _t !== void 0 ? _t : decisionBasis.live_hotfix_blocked_until_commit) !== null && _u !== void 0 ? _u : contract.liveHotfixBlockedUntilCommit) !== null && _v !== void 0 ? _v : contract.live_hotfix_blocked_until_commit)
3874
+ hotfixCommitRequired: booleanFlag((_u = (_t = (_s = decisionBasis.hotfixCommitRequired) !== null && _s !== void 0 ? _s : decisionBasis.hotfix_commit_required) !== null && _t !== void 0 ? _t : contract.hotfixCommitRequired) !== null && _u !== void 0 ? _u : contract.hotfix_commit_required),
3875
+ liveHotfixBlockedUntilCommit: booleanFlag((_x = (_w = (_v = decisionBasis.liveHotfixBlockedUntilCommit) !== null && _v !== void 0 ? _v : decisionBasis.live_hotfix_blocked_until_commit) !== null && _w !== void 0 ? _w : contract.liveHotfixBlockedUntilCommit) !== null && _x !== void 0 ? _x : contract.live_hotfix_blocked_until_commit),
3876
+ evidenceProbeContractReady: booleanFlag((_y = decisionBasis.evidenceProbeContractReady) !== null && _y !== void 0 ? _y : decisionBasis.evidence_probe_contract_ready),
3877
+ evidenceProbeContractId: cleanText(decisionBasis.evidenceProbeContractId || decisionBasis.evidence_probe_contract_id, 200),
3878
+ autonomyMode: cleanText(decisionBasis.autonomyMode || decisionBasis.autonomy_mode, 120),
3879
+ autonomyCanAutoDispatch: booleanFlag((_z = decisionBasis.autonomyCanAutoDispatch) !== null && _z !== void 0 ? _z : decisionBasis.autonomy_can_auto_dispatch),
3880
+ autonomyReason: cleanText(decisionBasis.autonomyReason || decisionBasis.autonomy_reason, 1000),
3881
+ autonomyExpectedValueScore: numberValue((_0 = decisionBasis.autonomyExpectedValueScore) !== null && _0 !== void 0 ? _0 : decisionBasis.autonomy_expected_value_score),
3882
+ autonomyExpectedValuePositive: booleanFlag((_1 = decisionBasis.autonomyExpectedValuePositive) !== null && _1 !== void 0 ? _1 : decisionBasis.autonomy_expected_value_positive),
3883
+ autonomyProjectedSpendUsd: numberValue((_2 = decisionBasis.autonomyProjectedSpendUsd) !== null && _2 !== void 0 ? _2 : decisionBasis.autonomy_projected_spend_usd)
2177
3884
  };
2178
3885
  return source;
2179
3886
  }
@@ -2245,6 +3952,96 @@ function supportNextActionContractGate(contract, now, required) {
2245
3952
  metadata: __assign(__assign({}, metadata), { blockers: blockers, missingSafetyFlags: missingSafetyFlags })
2246
3953
  };
2247
3954
  }
3955
+ function supportEvidenceProbeContractObject(ticket, job, evidence) {
3956
+ var ticketAutomation = plainObject(ticket.automation);
3957
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
3958
+ var autonomousDecision = plainObject(job.supportV5AutonomousDecision
3959
+ || job.support_v5_autonomous_decision
3960
+ || evidence.supportV5AutonomousDecision
3961
+ || evidence.support_v5_autonomous_decision
3962
+ || ticket.supportV5AutonomousDecision
3963
+ || ticket.support_v5_autonomous_decision);
3964
+ return evidenceObject(autonomousDecision.evidenceProbeContract, autonomousDecision.evidence_probe_contract, job.supportV5EvidenceProbeContract, job.support_v5_evidence_probe_contract, job.evidenceProbeContract, job.evidence_probe_contract, evidence.supportV5EvidenceProbeContract, evidence.support_v5_evidence_probe_contract, evidence.evidenceProbeContract, evidence.evidence_probe_contract, ticket.supportV5EvidenceProbeContract, ticket.support_v5_evidence_probe_contract, ticket.evidenceProbeContract, ticket.evidence_probe_contract, ticketManager.evidenceProbeContract, ticketManager.evidence_probe_contract);
3965
+ }
3966
+ function supportEvidenceProbeContractMetadata(contract) {
3967
+ var _a, _b, _c, _d;
3968
+ var validation = (0, support_runner_v5_1.validateResolveIOSupportEvidenceProbeContract)(contract);
3969
+ var normalized = plainObject(validation.normalized);
3970
+ return {
3971
+ contractId: cleanText(normalized.contractId || contract.contractId || contract.contract_id, 200),
3972
+ status: cleanText(normalized.status || contract.status, 120),
3973
+ probeType: cleanText(normalized.probeType || contract.probeType || contract.probe_type, 120),
3974
+ evidenceOnly: normalized.evidenceOnly === true || contract.evidenceOnly === true || contract.evidence_only === true,
3975
+ productRepairAllowed: normalized.productRepairAllowed === true || contract.productRepairAllowed === true || contract.product_repair_allowed === true,
3976
+ canRunWithoutCodexMonitor: normalized.canRunWithoutCodexMonitor === true || contract.canRunWithoutCodexMonitor === true || contract.can_run_without_codex_monitor === true,
3977
+ issueClass: cleanText(normalized.issueClass || contract.issueClass || contract.issue_class, 120),
3978
+ planId: cleanText(normalized.planId || contract.planId || contract.plan_id, 200),
3979
+ activeRoute: cleanText(normalized.activeRoute || contract.activeRoute || contract.active_route, 500),
3980
+ actionUnderTest: cleanText(normalized.actionUnderTest || contract.actionUnderTest || contract.action_under_test, 1000),
3981
+ expectedBusinessProof: cleanText(normalized.expectedBusinessProof || contract.expectedBusinessProof || contract.expected_business_proof, 1400),
3982
+ startingFailureClass: cleanText(normalized.startingFailureClass || contract.startingFailureClass || contract.starting_failure_class, 120),
3983
+ startingBlockerFingerprint: cleanText(normalized.startingBlockerFingerprint || contract.startingBlockerFingerprint || contract.starting_blocker_fingerprint, 200),
3984
+ startingEvidenceHash: cleanText(normalized.startingEvidenceHash || contract.startingEvidenceHash || contract.starting_evidence_hash, 200),
3985
+ sameFailureCount: numberValue((_b = (_a = normalized.sameFailureCount) !== null && _a !== void 0 ? _a : contract.sameFailureCount) !== null && _b !== void 0 ? _b : contract.same_failure_count),
3986
+ pingPongCount: numberValue((_d = (_c = normalized.pingPongCount) !== null && _c !== void 0 ? _c : contract.pingPongCount) !== null && _d !== void 0 ? _d : contract.ping_pong_count),
3987
+ requiredNewSignals: cleanStringList(normalized.requiredNewSignals || contract.requiredNewSignals || contract.required_new_signals, 30, 500),
3988
+ requiredArtifacts: cleanStringList(normalized.requiredArtifacts || contract.requiredArtifacts || contract.required_artifacts, 30, 500),
3989
+ acceptableEvidence: cleanStringList(normalized.acceptableEvidence || contract.acceptableEvidence || contract.acceptable_evidence, 30, 500),
3990
+ nextCommands: cleanStringList(normalized.nextCommands || contract.nextCommands || contract.next_commands, 20, 300),
3991
+ forbiddenActions: cleanStringList(normalized.forbiddenActions || contract.forbiddenActions || contract.forbidden_actions, 20, 500),
3992
+ blockers: validation.blockers,
3993
+ validationValid: validation.valid,
3994
+ validationStatus: validation.status
3995
+ };
3996
+ }
3997
+ function supportEvidenceProbeContractGate(contract, now, required) {
3998
+ if (required === void 0) { required = false; }
3999
+ if (!contract || !Object.keys(contract).length) {
4000
+ if (!required) {
4001
+ return undefined;
4002
+ }
4003
+ var blocker = 'Support repeated-failure recovery is missing an evidence probe contract, so the manager cannot prove bounded evidence-only recovery.';
4004
+ return {
4005
+ key: 'support_evidence_probe_contract',
4006
+ label: 'Support evidence probe contract',
4007
+ status: 'blocked',
4008
+ reason: blocker,
4009
+ evidenceRefs: [],
4010
+ recordedAt: isoNow(now),
4011
+ metadata: {
4012
+ required: true,
4013
+ missingContract: true,
4014
+ evidenceOnly: false,
4015
+ productRepairAllowed: false,
4016
+ canRunWithoutCodexMonitor: false,
4017
+ blockers: [blocker]
4018
+ }
4019
+ };
4020
+ }
4021
+ var metadata = supportEvidenceProbeContractMetadata(contract);
4022
+ var blockers = cleanStringList(metadata.blockers, 40, 500);
4023
+ if (metadata.evidenceOnly !== true) {
4024
+ blockers.push('Evidence probe contract must be evidence-only.');
4025
+ }
4026
+ if (metadata.productRepairAllowed === true) {
4027
+ blockers.push('Evidence probe contract must not allow product repair.');
4028
+ }
4029
+ if (metadata.canRunWithoutCodexMonitor !== true) {
4030
+ blockers.push('Evidence probe contract is not ready for manager-only execution.');
4031
+ }
4032
+ var status = blockers.length ? 'blocked' : 'pass';
4033
+ return {
4034
+ key: 'support_evidence_probe_contract',
4035
+ label: 'Support evidence probe contract',
4036
+ status: status,
4037
+ reason: blockers.length
4038
+ ? blockers.join(' ')
4039
+ : "Support evidence probe contract allows bounded ".concat(metadata.probeType || 'evidence', " collection without product-code repair."),
4040
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(metadata.requiredNewSignals), false), __read(metadata.requiredArtifacts), false), __read(metadata.acceptableEvidence), false), 40, 500),
4041
+ recordedAt: isoNow(now || contract.createdAt || contract.created_at || contract.recordedAt || contract.recorded_at),
4042
+ metadata: __assign(__assign({}, metadata), { blockers: blockers })
4043
+ };
4044
+ }
2248
4045
  function supportManagerExecutionPacketObject(ticket, job, evidence, nextActionContract) {
2249
4046
  var ticketAutomation = plainObject(ticket.automation);
2250
4047
  var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
@@ -2269,10 +4066,11 @@ function supportManagerExecutionPacketObject(ticket, job, evidence, nextActionCo
2269
4066
  return {};
2270
4067
  }
2271
4068
  function supportManagerExecutionPacketMetadata(packet) {
2272
- var _a, _b, _c, _d;
4069
+ var _a, _b, _c, _d, _e, _f;
2273
4070
  var validation = plainObject(packet.validation);
2274
4071
  var validationBlockers = cleanStringList(validation.blockers, 40, 500);
2275
4072
  var directBlockers = cleanStringList(packet.blockers, 40, 500);
4073
+ var proofReset = plainObject(packet.proofResetContract || packet.proof_reset_contract);
2276
4074
  return {
2277
4075
  packetId: cleanText(packet.packetId || packet.packet_id, 200),
2278
4076
  status: cleanText(packet.status, 120),
@@ -2293,6 +4091,22 @@ function supportManagerExecutionPacketMetadata(packet) {
2293
4091
  forbiddenActions: cleanStringList(packet.forbiddenActions || packet.forbidden_actions, 40, 500),
2294
4092
  ownerFiles: cleanStringList(packet.ownerFiles || packet.owner_files, 40, 500),
2295
4093
  nextCommands: cleanStringList(packet.nextCommands || packet.next_commands, 40, 500),
4094
+ proofResetContract: Object.keys(proofReset).length ? {
4095
+ contractId: cleanText(proofReset.contractId || proofReset.contract_id, 200),
4096
+ status: cleanText(proofReset.status, 120),
4097
+ action: cleanText(proofReset.action, 160),
4098
+ retryScope: cleanText(proofReset.retryScope || proofReset.retry_scope, 120),
4099
+ maxAttemptsBeforeFreshEvidence: numberValue((_e = proofReset.maxAttemptsBeforeFreshEvidence) !== null && _e !== void 0 ? _e : proofReset.max_attempts_before_fresh_evidence),
4100
+ startingFailureClass: cleanText(proofReset.startingFailureClass || proofReset.starting_failure_class, 120),
4101
+ startingBlockerFingerprint: cleanText(proofReset.startingBlockerFingerprint || proofReset.starting_blocker_fingerprint, 200),
4102
+ startingEvidenceHash: cleanText(proofReset.startingEvidenceHash || proofReset.starting_evidence_hash, 200),
4103
+ requiredResetEvidence: cleanStringList(proofReset.requiredResetEvidence || proofReset.required_reset_evidence, 40, 500),
4104
+ proofRequiredBeforeContinuation: cleanStringList(proofReset.proofRequiredBeforeContinuation || proofReset.proof_required_before_continuation, 40, 500),
4105
+ stopConditions: cleanStringList(proofReset.stopConditions || proofReset.stop_conditions, 40, 500),
4106
+ canRunWithoutCodexMonitor: booleanFlag((_f = proofReset.canRunWithoutCodexMonitor) !== null && _f !== void 0 ? _f : proofReset.can_run_without_codex_monitor),
4107
+ sourceNextActionContractId: cleanText(proofReset.sourceNextActionContractId || proofReset.source_next_action_contract_id, 200),
4108
+ createdAt: cleanText(proofReset.createdAt || proofReset.created_at, 120)
4109
+ } : undefined,
2296
4110
  blockers: Array.from(new Set(__spreadArray(__spreadArray([], __read(directBlockers), false), __read(validationBlockers), false))).slice(0, 40),
2297
4111
  validation: {
2298
4112
  valid: booleanFlag(validation.valid),
@@ -2389,6 +4203,59 @@ function supportSimilarFixHintsObject(ticket, job, evidence) {
2389
4203
  var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2390
4204
  return evidenceObject(job.supportRootCauseSimilarFixHints, job.support_root_cause_similar_fix_hints, job.similarFixHints, job.similar_fix_hints, evidence.supportRootCauseSimilarFixHints, evidence.support_root_cause_similar_fix_hints, evidence.similarFixHints, evidence.similar_fix_hints, ticket.supportRootCauseSimilarFixHints, ticket.support_root_cause_similar_fix_hints, ticketManager.rootCauseSimilarFixHints, ticketManager.root_cause_similar_fix_hints);
2391
4205
  }
4206
+ function supportSimilarFixHintContractObject(ticket, job, evidence) {
4207
+ var ticketAutomation = plainObject(ticket.automation);
4208
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
4209
+ return evidenceObject(job.supportRootCauseSimilarFixHintContract, job.support_root_cause_similar_fix_hint_contract, job.similarFixHintContract, job.similar_fix_hint_contract, evidence.supportRootCauseSimilarFixHintContract, evidence.support_root_cause_similar_fix_hint_contract, evidence.similarFixHintContract, evidence.similar_fix_hint_contract, ticket.supportRootCauseSimilarFixHintContract, ticket.support_root_cause_similar_fix_hint_contract, ticketManager.rootCauseSimilarFixHintContract, ticketManager.root_cause_similar_fix_hint_contract);
4210
+ }
4211
+ function supportSimilarFixHintContractGate(contract, now) {
4212
+ var _a, _b, _c;
4213
+ if (!contract || !Object.keys(contract).length) {
4214
+ return undefined;
4215
+ }
4216
+ var usagePolicy = plainObject(contract.usage_policy || contract.usagePolicy);
4217
+ var rankedHints = asArray(contract.ranked_hints || contract.rankedHints);
4218
+ var ownerFileHints = cleanStringList(contract.owner_file_hints || contract.ownerFileHints, 30, 500);
4219
+ var similarHintsAreNotProof = usagePolicy.similar_hints_are_not_proof === true || usagePolicy.similarHintsAreNotProof === true;
4220
+ var ownerFilesRequireCurrentEvidence = usagePolicy.owner_files_require_current_ticket_evidence === true
4221
+ || usagePolicy.ownerFilesRequireCurrentTicketEvidence === true;
4222
+ var acceptedHypothesisCurrent = usagePolicy.accepted_hypothesis_must_be_current_ticket_specific === true
4223
+ || usagePolicy.acceptedHypothesisMustBeCurrentTicketSpecific === true;
4224
+ var requiredModelActions = cleanStringList(contract.required_model_actions || contract.requiredModelActions, 20, 500);
4225
+ var blockers = [
4226
+ !similarHintsAreNotProof ? 'Similar-fix hints must be advisory only and cannot be proof.' : '',
4227
+ !ownerFilesRequireCurrentEvidence ? 'Owner-file hints from similar fixes require current-ticket evidence before use.' : '',
4228
+ !acceptedHypothesisCurrent ? 'Accepted hypothesis must remain current-ticket specific.' : '',
4229
+ !requiredModelActions.length ? 'Similar-fix hint contract must include required model actions.' : ''
4230
+ ].filter(Boolean);
4231
+ var status = blockers.length ? 'warn' : 'pass';
4232
+ return {
4233
+ key: 'support_similar_fix_hint_contract',
4234
+ label: 'Support similar-fix hint contract',
4235
+ status: status,
4236
+ reason: blockers.join('; ') || 'Similar accepted fixes are available as advisory hints only; fresh SupportDiagnosisGate evidence is still required.',
4237
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(ownerFileHints), false), __read(rankedHints.flatMap(function (hint) { return cleanStringList((hint || {}).owner_files || (hint || {}).ownerFiles, 8, 500); })), false), __read(rankedHints.map(function (hint) { return (hint || {}).commit_sha || (hint || {}).commitSha; })), false), 60, 500),
4238
+ recordedAt: isoNow(now || contract.created_at || contract.createdAt),
4239
+ metadata: {
4240
+ contractId: cleanText(contract.contract_id || contract.contractId, 200),
4241
+ version: cleanText(contract.version, 120),
4242
+ status: cleanText(contract.status, 120),
4243
+ source: cleanText(contract.source, 160),
4244
+ candidateCount: numberValue((_a = contract.candidate_count) !== null && _a !== void 0 ? _a : contract.candidateCount),
4245
+ hintCount: numberValue((_c = (_b = contract.hint_count) !== null && _b !== void 0 ? _b : contract.hintCount) !== null && _c !== void 0 ? _c : rankedHints.length),
4246
+ rankedHintCount: rankedHints.length,
4247
+ ownerFileHints: ownerFileHints,
4248
+ similarHintsAreNotProof: similarHintsAreNotProof,
4249
+ ownerFilesRequireCurrentEvidence: ownerFilesRequireCurrentEvidence,
4250
+ acceptedHypothesisCurrent: acceptedHypothesisCurrent,
4251
+ mustRecordRejectedHintsOrAlternatives: usagePolicy.must_record_rejected_hints_or_alternatives === true
4252
+ || usagePolicy.mustRecordRejectedHintsOrAlternatives === true,
4253
+ advisoryOnly: similarHintsAreNotProof && ownerFilesRequireCurrentEvidence && acceptedHypothesisCurrent,
4254
+ requiredModelActions: requiredModelActions,
4255
+ blockers: blockers
4256
+ }
4257
+ };
4258
+ }
2392
4259
  function supportDiagnosisEvidencePackGate(pack, now) {
2393
4260
  if (!pack || !Object.keys(pack).length) {
2394
4261
  return undefined;
@@ -2432,6 +4299,132 @@ function supportDiagnosisEvidencePackGate(pack, now) {
2432
4299
  }
2433
4300
  };
2434
4301
  }
4302
+ function supportDiagnosisProofMatrixGate(matrixSource, now, required) {
4303
+ if (required === void 0) { required = false; }
4304
+ if (!matrixSource || !Object.keys(matrixSource).length) {
4305
+ if (!required) {
4306
+ return undefined;
4307
+ }
4308
+ return {
4309
+ key: 'support_diagnosis_proof_matrix',
4310
+ label: 'Support diagnosis proof matrix',
4311
+ status: 'blocked',
4312
+ reason: 'Support diagnosis proof matrix is required before owner-scoped product repair.',
4313
+ evidenceRefs: [],
4314
+ recordedAt: isoNow(now),
4315
+ metadata: {
4316
+ status: 'missing',
4317
+ blockers: ['Support diagnosis proof matrix is missing.']
4318
+ }
4319
+ };
4320
+ }
4321
+ var statusText = cleanText(matrixSource.status, 120);
4322
+ var blockers = cleanStringList(matrixSource.blockers, 40, 500);
4323
+ var ownerFileCoverage = asArray(matrixSource.ownerFileCoverage || matrixSource.owner_file_coverage);
4324
+ var uncoveredOwnerFiles = ownerFileCoverage
4325
+ .filter(function (entry) { return entry.covered !== true; })
4326
+ .map(function (entry) { return cleanText(entry.ownerFile || entry.owner_file, 500); })
4327
+ .filter(Boolean);
4328
+ var reproductionEvidence = asArray(matrixSource.reproductionEvidence || matrixSource.reproduction_evidence);
4329
+ var rootCauseEvidence = asArray(matrixSource.rootCauseEvidence || matrixSource.root_cause_evidence);
4330
+ var businessProofArtifacts = cleanStringList(matrixSource.businessProofArtifacts || matrixSource.business_proof_artifacts, 30, 500);
4331
+ var gateStatus = statusText === 'ready' && !blockers.length && !uncoveredOwnerFiles.length
4332
+ ? 'pass'
4333
+ : required
4334
+ ? 'blocked'
4335
+ : 'warn';
4336
+ return {
4337
+ key: 'support_diagnosis_proof_matrix',
4338
+ label: 'Support diagnosis proof matrix',
4339
+ status: gateStatus,
4340
+ reason: gateStatus === 'pass'
4341
+ ? 'Support diagnosis proof matrix ties reproduction, root-cause evidence, owner files, and business proof artifacts together.'
4342
+ : (blockers.join('; ') || (uncoveredOwnerFiles.length ? "Owner files lack proof matrix coverage: ".concat(uncoveredOwnerFiles.join(', ')) : 'Support diagnosis proof matrix is incomplete.')),
4343
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(reproductionEvidence.map(function (entry) { return entry.artifactPath || entry.artifact_path || entry.evidenceId || entry.evidence_id; })), false), __read(rootCauseEvidence.map(function (entry) { return entry.artifactPath || entry.artifact_path || entry.evidenceId || entry.evidence_id; })), false), __read(businessProofArtifacts), false), 60, 500),
4344
+ recordedAt: isoNow(now || matrixSource.generatedAt || matrixSource.generated_at),
4345
+ metadata: {
4346
+ matrixId: cleanText(matrixSource.matrixId || matrixSource.matrix_id, 180),
4347
+ status: statusText,
4348
+ issueClass: cleanText(matrixSource.issueClass || matrixSource.issue_class, 120),
4349
+ ownerFiles: cleanStringList(matrixSource.ownerFiles || matrixSource.owner_files, 40, 500),
4350
+ ownerFileCoverage: ownerFileCoverage.map(function (entry) { return ({
4351
+ ownerFile: cleanText(entry.ownerFile || entry.owner_file, 500),
4352
+ covered: entry.covered === true,
4353
+ evidenceIds: cleanStringList(entry.evidenceIds || entry.evidence_ids, 20, 180),
4354
+ failingPathFields: cleanStringList(entry.failingPathFields || entry.failing_path_fields, 10, 120)
4355
+ }); }),
4356
+ uncoveredOwnerFiles: uncoveredOwnerFiles,
4357
+ reproductionEvidenceCount: reproductionEvidence.length,
4358
+ rootCauseEvidenceCount: rootCauseEvidence.length,
4359
+ businessProofArtifacts: businessProofArtifacts,
4360
+ blockers: blockers
4361
+ }
4362
+ };
4363
+ }
4364
+ function supportOwnerScopedRepairContractGate(contract, now, required) {
4365
+ if (required === void 0) { required = false; }
4366
+ if (!contract || !Object.keys(contract).length) {
4367
+ if (!required) {
4368
+ return undefined;
4369
+ }
4370
+ return {
4371
+ key: 'support_owner_scoped_repair_contract',
4372
+ label: 'Support owner-scoped repair contract',
4373
+ status: 'blocked',
4374
+ reason: 'Owner-scoped repair contract is required before product-code repair.',
4375
+ evidenceRefs: [],
4376
+ recordedAt: isoNow(now),
4377
+ metadata: {
4378
+ status: 'missing',
4379
+ blockers: ['Support owner-scoped repair contract is missing.']
4380
+ }
4381
+ };
4382
+ }
4383
+ var statusText = cleanText(contract.status, 120);
4384
+ var blockers = cleanStringList(contract.blockers, 40, 500);
4385
+ var patchUnits = asArray(contract.patchUnits || contract.patch_units);
4386
+ var outsideOwnerFiles = cleanStringList(contract.outsideOwnerFiles || contract.outside_owner_files, 40, 500);
4387
+ var gateStatus = statusText === 'ready' && !blockers.length && !outsideOwnerFiles.length && contract.sourceEditsAllowed !== false
4388
+ ? 'pass'
4389
+ : required
4390
+ ? 'blocked'
4391
+ : 'warn';
4392
+ var requiredEvidenceAfterRepair = cleanStringList(contract.requiredEvidenceAfterRepair || contract.required_evidence_after_repair, 30, 500);
4393
+ return {
4394
+ key: 'support_owner_scoped_repair_contract',
4395
+ label: 'Support owner-scoped repair contract',
4396
+ status: gateStatus,
4397
+ reason: gateStatus === 'pass'
4398
+ ? 'Owner-scoped repair contract allows product-code edits only inside diagnosed owner files and requires compile plus business proof handoff.'
4399
+ : (blockers.join('; ') || (outsideOwnerFiles.length ? "Repair contract has out-of-scope files: ".concat(outsideOwnerFiles.join(', ')) : 'Owner-scoped repair contract is not ready.')),
4400
+ evidenceRefs: cleanStringList(__spreadArray([
4401
+ contract.proofMatrixId || contract.proof_matrix_id
4402
+ ], __read(requiredEvidenceAfterRepair), false), 40, 500),
4403
+ recordedAt: isoNow(now || contract.createdAt || contract.created_at),
4404
+ metadata: {
4405
+ contractId: cleanText(contract.contractId || contract.contract_id, 180),
4406
+ status: statusText,
4407
+ sourceEditsAllowed: contract.sourceEditsAllowed === true || contract.source_edits_allowed === true,
4408
+ canRunWithoutCodexMonitor: contract.canRunWithoutCodexMonitor === true || contract.can_run_without_codex_monitor === true,
4409
+ issueClass: cleanText(contract.issueClass || contract.issue_class, 120),
4410
+ ownerFiles: cleanStringList(contract.ownerFiles || contract.owner_files, 40, 500),
4411
+ proofMatrixId: cleanText(contract.proofMatrixId || contract.proof_matrix_id, 180),
4412
+ changedFiles: cleanStringList(contract.changedFiles || contract.changed_files, 60, 500),
4413
+ outsideOwnerFiles: outsideOwnerFiles,
4414
+ patchUnitCount: patchUnits.length,
4415
+ patchUnits: patchUnits.map(function (unit) { return ({
4416
+ ownerFile: cleanText(unit.ownerFile || unit.owner_file, 500),
4417
+ coverageEvidenceIds: cleanStringList(unit.coverageEvidenceIds || unit.coverage_evidence_ids, 20, 180),
4418
+ failingPathFields: cleanStringList(unit.failingPathFields || unit.failing_path_fields, 10, 120)
4419
+ }); }),
4420
+ requiredEvidenceBeforeRepair: cleanStringList(contract.requiredEvidenceBeforeRepair || contract.required_evidence_before_repair, 30, 500),
4421
+ requiredEvidenceAfterRepair: requiredEvidenceAfterRepair,
4422
+ nextCommands: cleanStringList(contract.nextCommands || contract.next_commands, 20, 240),
4423
+ forbiddenActions: cleanStringList(contract.forbiddenActions || contract.forbidden_actions, 20, 500),
4424
+ blockers: blockers
4425
+ }
4426
+ };
4427
+ }
2435
4428
  function supportIssueClassProbePlanGate(plan, diagnosisGate, now, required) {
2436
4429
  if (required === void 0) { required = false; }
2437
4430
  if (!plan || !Object.keys(plan).length) {
@@ -3455,7 +5448,7 @@ function applyAssistantAnswerQualityGate(qa, decision, now) {
3455
5448
  }
3456
5449
  function buildSupportAIRunFromEvidence(input) {
3457
5450
  var e_32, _a, e_33, _b;
3458
- 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, _73, _74, _75, _76, _77, _78, _79, _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90;
5451
+ 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, _73, _74, _75, _76, _77, _78, _79, _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128, _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144, _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160, _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176, _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192, _193, _194, _195, _196, _197, _198, _199, _200, _201, _202, _203, _204, _205, _206, _207, _208, _209, _210, _211, _212, _213, _214, _215, _216, _217, _218, _219, _220, _221, _222, _223, _224, _225, _226, _227, _228, _229, _230, _231, _232, _233, _234, _235, _236, _237, _238, _239, _240, _241, _242, _243, _244, _245, _246, _247, _248, _249, _250, _251, _252, _253, _254, _255, _256, _257, _258, _259, _260, _261, _262, _263, _264, _265, _266, _267, _268, _269, _270, _271, _272, _273, _274, _275, _276, _277, _278, _279, _280, _281, _282, _283, _284, _285, _286, _287, _288, _289, _290, _291, _292, _293, _294, _295, _296, _297, _298, _299, _300, _301, _302, _303, _304, _305, _306, _307, _308, _309, _310, _311, _312, _313, _314, _315, _316, _317, _318, _319, _320, _321, _322, _323, _324, _325, _326, _327, _328, _329, _330, _331, _332, _333, _334, _335, _336, _337, _338, _339, _340, _341, _342, _343, _344, _345, _346, _347, _348, _349, _350, _351, _352, _353, _354, _355, _356, _357, _358, _359, _360, _361, _362, _363, _364, _365, _366, _367, _368, _369, _370, _371, _372, _373, _374, _375, _376, _377, _378, _379, _380, _381, _382, _383, _384, _385, _386, _387, _388, _389, _390, _391, _392, _393, _394, _395, _396, _397, _398, _399, _400, _401, _402, _403, _404, _405, _406, _407, _408, _409, _410, _411, _412, _413, _414, _415, _416, _417, _418, _419, _420, _421, _422, _423, _424, _425, _426, _427, _428, _429, _430, _431, _432, _433, _434, _435, _436, _437, _438, _439, _440, _441, _442, _443, _444, _445, _446, _447, _448, _449, _450, _451, _452, _453, _454, _455, _456, _457, _458, _459, _460, _461, _462, _463, _464, _465, _466, _467, _468, _469, _470, _471, _472, _473, _474, _475, _476, _477, _478, _479, _480, _481, _482, _483, _484, _485, _486, _487, _488, _489, _490, _491, _492, _493, _494, _495, _496, _497, _498, _499, _500, _501, _502, _503, _504, _505, _506, _507, _508, _509, _510, _511, _512, _513, _514, _515, _516, _517, _518, _519, _520, _521, _522, _523, _524, _525, _526, _527, _528, _529, _530, _531, _532, _533, _534, _535, _536, _537, _538, _539, _540;
3459
5452
  var ticket = input.ticket || {};
3460
5453
  var job = input.job || {};
3461
5454
  var evidence = buildSupportQaEvidence(input);
@@ -3467,8 +5460,8 @@ function buildSupportAIRunFromEvidence(input) {
3467
5460
  addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
3468
5461
  addSourceId(sourceIds, 'buildPlanId', job.buildPlanId || ticket.buildPlanId);
3469
5462
  try {
3470
- for (var _91 = __values(asArray(input.taskEvents)), _92 = _91.next(); !_92.done; _92 = _91.next()) {
3471
- var event_1 = _92.value;
5463
+ for (var _541 = __values(asArray(input.taskEvents)), _542 = _541.next(); !_542.done; _542 = _541.next()) {
5464
+ var event_1 = _542.value;
3472
5465
  pushEvent(events, {
3473
5466
  type: event_1.type === 'human_intervention' ? 'human_intervention' : 'log',
3474
5467
  category: cleanText(event_1.category || event_1.phase || event_1.type, 160),
@@ -3485,13 +5478,13 @@ function buildSupportAIRunFromEvidence(input) {
3485
5478
  catch (e_32_1) { e_32 = { error: e_32_1 }; }
3486
5479
  finally {
3487
5480
  try {
3488
- if (_92 && !_92.done && (_a = _91.return)) _a.call(_91);
5481
+ if (_542 && !_542.done && (_a = _541.return)) _a.call(_541);
3489
5482
  }
3490
5483
  finally { if (e_32) throw e_32.error; }
3491
5484
  }
3492
5485
  try {
3493
- for (var _93 = __values(asArray(input.aiJobs)), _94 = _93.next(); !_94.done; _94 = _93.next()) {
3494
- var aiJob = _94.value;
5486
+ for (var _543 = __values(asArray(input.aiJobs)), _544 = _543.next(); !_544.done; _544 = _543.next()) {
5487
+ var aiJob = _544.value;
3495
5488
  pushEvent(events, {
3496
5489
  type: aiJob.model ? 'model_call' : 'log',
3497
5490
  category: cleanText(aiJob.category || aiJob.phase || aiJob.runner, 160),
@@ -3509,7 +5502,7 @@ function buildSupportAIRunFromEvidence(input) {
3509
5502
  catch (e_33_1) { e_33 = { error: e_33_1 }; }
3510
5503
  finally {
3511
5504
  try {
3512
- if (_94 && !_94.done && (_b = _93.return)) _b.call(_93);
5505
+ if (_544 && !_544.done && (_b = _543.return)) _b.call(_543);
3513
5506
  }
3514
5507
  finally { if (e_33) throw e_33.error; }
3515
5508
  }
@@ -3569,6 +5562,201 @@ function buildSupportAIRunFromEvidence(input) {
3569
5562
  metadata: customerReplyReadinessGate.metadata
3570
5563
  });
3571
5564
  }
5565
+ var customerReplySendContract = supportProofBackedCustomerReplySendObject(ticket, job, evidence);
5566
+ var customerReplySendGuard = supportCustomerReplySendGuardObject(ticket, job, evidence);
5567
+ var customerReplySendGate = supportProofBackedCustomerReplySendGate(customerReplySendContract, customerReplySendGuard, input.now);
5568
+ if (customerReplySendGate) {
5569
+ gates.push(customerReplySendGate);
5570
+ pushEvent(events, {
5571
+ type: customerReplySendGate.status === 'pass' ? 'human_intervention' : 'log',
5572
+ category: 'support_proof_backed_customer_reply_send',
5573
+ message: customerReplySendGate.reason,
5574
+ artifactPaths: customerReplySendGate.evidenceRefs,
5575
+ recordedAt: customerReplySendGate.recordedAt,
5576
+ metadata: customerReplySendGate.metadata
5577
+ });
5578
+ }
5579
+ var autonomyApproval = supportAutonomyApprovalObject(ticket, job, evidence);
5580
+ var autonomyApprovalGate = supportAutonomyApprovalGate(autonomyApproval, input.now);
5581
+ if (autonomyApprovalGate) {
5582
+ gates.push(autonomyApprovalGate);
5583
+ pushEvent(events, {
5584
+ type: 'human_intervention',
5585
+ category: 'support_autonomy_approval',
5586
+ message: autonomyApprovalGate.reason,
5587
+ artifactPaths: autonomyApprovalGate.evidenceRefs,
5588
+ recordedAt: autonomyApprovalGate.recordedAt,
5589
+ metadata: autonomyApprovalGate.metadata
5590
+ });
5591
+ }
5592
+ var productRepairDispatchGuard = supportProductRepairDispatchGuardObject(ticket, job, evidence);
5593
+ var productRepairDispatchGate = supportProductRepairDispatchGuardGate(productRepairDispatchGuard, input.now);
5594
+ if (productRepairDispatchGate) {
5595
+ gates.push(productRepairDispatchGate);
5596
+ pushEvent(events, {
5597
+ type: 'human_intervention',
5598
+ category: 'support_product_repair_dispatch_guard',
5599
+ message: productRepairDispatchGate.reason,
5600
+ artifactPaths: productRepairDispatchGate.evidenceRefs,
5601
+ recordedAt: productRepairDispatchGate.recordedAt,
5602
+ metadata: productRepairDispatchGate.metadata
5603
+ });
5604
+ }
5605
+ var autoloopApprovalBlock = supportAutoloopApprovalBlockObject(ticket, job, evidence);
5606
+ var autoloopApprovalBlockGate = supportAutoloopApprovalBlockGate(autoloopApprovalBlock, input.now);
5607
+ if (autoloopApprovalBlockGate) {
5608
+ gates.push(autoloopApprovalBlockGate);
5609
+ pushEvent(events, {
5610
+ type: 'human_intervention',
5611
+ category: 'support_autoloop_approval_block',
5612
+ message: autoloopApprovalBlockGate.reason,
5613
+ artifactPaths: autoloopApprovalBlockGate.evidenceRefs,
5614
+ recordedAt: autoloopApprovalBlockGate.recordedAt,
5615
+ metadata: autoloopApprovalBlockGate.metadata
5616
+ });
5617
+ }
5618
+ var autoloopNoProgress = supportAutoloopNoProgressObject(ticket, job, evidence);
5619
+ var autoloopNoProgressGate = supportAutoloopNoProgressGate(autoloopNoProgress, input.now);
5620
+ if (autoloopNoProgressGate) {
5621
+ gates.push(autoloopNoProgressGate);
5622
+ pushEvent(events, {
5623
+ type: autoloopNoProgressGate.status === 'blocked' ? 'human_intervention' : 'log',
5624
+ category: 'support_autoloop_no_progress',
5625
+ message: autoloopNoProgressGate.reason,
5626
+ artifactPaths: autoloopNoProgressGate.evidenceRefs,
5627
+ recordedAt: autoloopNoProgressGate.recordedAt,
5628
+ metadata: autoloopNoProgressGate.metadata
5629
+ });
5630
+ }
5631
+ var humanDecisionRequest = supportHumanDecisionRequestObject(ticket, job, evidence);
5632
+ var humanDecisionRequestGate = supportHumanDecisionRequestGate(humanDecisionRequest, input.now);
5633
+ if (humanDecisionRequestGate) {
5634
+ gates.push(humanDecisionRequestGate);
5635
+ pushEvent(events, {
5636
+ type: 'human_intervention',
5637
+ category: 'support_human_decision_request',
5638
+ message: humanDecisionRequestGate.reason,
5639
+ artifactPaths: humanDecisionRequestGate.evidenceRefs,
5640
+ recordedAt: humanDecisionRequestGate.recordedAt,
5641
+ metadata: humanDecisionRequestGate.metadata
5642
+ });
5643
+ }
5644
+ var postApprovalAutostart = supportPostApprovalAutostartObject(ticket, job, evidence);
5645
+ var postApprovalAutostartGate = supportPostApprovalAutostartGate(postApprovalAutostart, input.now);
5646
+ if (postApprovalAutostartGate) {
5647
+ gates.push(postApprovalAutostartGate);
5648
+ pushEvent(events, {
5649
+ type: 'log',
5650
+ category: 'support_post_approval_autostart',
5651
+ message: postApprovalAutostartGate.reason,
5652
+ artifactPaths: postApprovalAutostartGate.evidenceRefs,
5653
+ recordedAt: postApprovalAutostartGate.recordedAt,
5654
+ metadata: postApprovalAutostartGate.metadata
5655
+ });
5656
+ }
5657
+ var postApprovalResumeAttempt = supportPostApprovalResumeAttemptObject(ticket, job, evidence);
5658
+ var postApprovalResumeAttemptGate = supportPostApprovalResumeAttemptGate(postApprovalResumeAttempt, input.now);
5659
+ if (postApprovalResumeAttemptGate) {
5660
+ gates.push(postApprovalResumeAttemptGate);
5661
+ pushEvent(events, {
5662
+ type: 'log',
5663
+ category: 'support_post_approval_resume_attempt',
5664
+ message: postApprovalResumeAttemptGate.reason,
5665
+ artifactPaths: postApprovalResumeAttemptGate.evidenceRefs,
5666
+ recordedAt: postApprovalResumeAttemptGate.recordedAt,
5667
+ metadata: postApprovalResumeAttemptGate.metadata
5668
+ });
5669
+ }
5670
+ var intakeRevisionContract = supportIntakeRevisionContractObject(ticket, job, evidence);
5671
+ var intakeRevisionContractGate = supportIntakeRevisionContractGate(intakeRevisionContract, input.now);
5672
+ if (intakeRevisionContractGate) {
5673
+ gates.push(intakeRevisionContractGate);
5674
+ pushEvent(events, {
5675
+ type: 'human_intervention',
5676
+ category: 'support_intake_revision_contract',
5677
+ message: intakeRevisionContractGate.reason,
5678
+ artifactPaths: intakeRevisionContractGate.evidenceRefs,
5679
+ recordedAt: intakeRevisionContractGate.recordedAt,
5680
+ metadata: intakeRevisionContractGate.metadata
5681
+ });
5682
+ }
5683
+ var managerContinuation = supportManagerContinuationObject(ticket, job, evidence);
5684
+ var managerContinuationGate = supportManagerContinuationGate(managerContinuation, input.now);
5685
+ if (managerContinuationGate) {
5686
+ gates.push(managerContinuationGate);
5687
+ pushEvent(events, {
5688
+ type: 'human_intervention',
5689
+ category: 'support_manager_continuation',
5690
+ message: managerContinuationGate.reason,
5691
+ artifactPaths: managerContinuationGate.evidenceRefs,
5692
+ recordedAt: managerContinuationGate.recordedAt,
5693
+ metadata: managerContinuationGate.metadata
5694
+ });
5695
+ }
5696
+ var prReadinessContract = supportPrReadinessContractObject(ticket, job, evidence);
5697
+ var prReadinessContractGate = supportPrReadinessContractGate(prReadinessContract, input.now);
5698
+ if (prReadinessContractGate) {
5699
+ gates.push(prReadinessContractGate);
5700
+ pushEvent(events, {
5701
+ type: 'log',
5702
+ category: 'support_pr_readiness_contract',
5703
+ message: prReadinessContractGate.reason,
5704
+ artifactPaths: prReadinessContractGate.evidenceRefs,
5705
+ recordedAt: prReadinessContractGate.recordedAt,
5706
+ metadata: prReadinessContractGate.metadata
5707
+ });
5708
+ }
5709
+ var prReviewContract = supportPrReviewContractObject(ticket, job, evidence);
5710
+ var prReviewContractGate = supportPrReviewContractGate(prReviewContract, input.now);
5711
+ if (prReviewContractGate) {
5712
+ gates.push(prReviewContractGate);
5713
+ pushEvent(events, {
5714
+ type: 'log',
5715
+ category: 'support_pr_review_contract',
5716
+ message: prReviewContractGate.reason,
5717
+ artifactPaths: prReviewContractGate.evidenceRefs,
5718
+ recordedAt: prReviewContractGate.recordedAt,
5719
+ metadata: prReviewContractGate.metadata
5720
+ });
5721
+ }
5722
+ var prCreationResult = supportPrCreationResultObject(ticket, job, evidence);
5723
+ var prCreationResultGate = supportPrCreationResultGate(prCreationResult, input.now);
5724
+ if (prCreationResultGate) {
5725
+ gates.push(prCreationResultGate);
5726
+ pushEvent(events, {
5727
+ type: 'log',
5728
+ category: 'support_pr_creation_result',
5729
+ message: prCreationResultGate.reason,
5730
+ artifactPaths: prCreationResultGate.evidenceRefs,
5731
+ recordedAt: prCreationResultGate.recordedAt,
5732
+ metadata: prCreationResultGate.metadata
5733
+ });
5734
+ }
5735
+ var autopilotCompletionGate = supportAutopilotCompletionContractGate(autonomyApproval, prReadinessContract, prReviewContract, input.now);
5736
+ if (autopilotCompletionGate) {
5737
+ gates.push(autopilotCompletionGate);
5738
+ pushEvent(events, {
5739
+ type: 'log',
5740
+ category: 'support_autopilot_completion_contract',
5741
+ message: autopilotCompletionGate.reason,
5742
+ artifactPaths: autopilotCompletionGate.evidenceRefs,
5743
+ recordedAt: autopilotCompletionGate.recordedAt,
5744
+ metadata: autopilotCompletionGate.metadata
5745
+ });
5746
+ }
5747
+ var releaseCustomerAcceptance = supportReleaseCustomerAcceptanceObject(ticket, job, evidence, prReadinessContract);
5748
+ var releaseCustomerAcceptanceGate = supportReleaseCustomerAcceptanceGate(releaseCustomerAcceptance, input.now);
5749
+ if (releaseCustomerAcceptanceGate) {
5750
+ gates.push(releaseCustomerAcceptanceGate);
5751
+ pushEvent(events, {
5752
+ type: 'deploy',
5753
+ category: 'support_release_customer_acceptance',
5754
+ message: releaseCustomerAcceptanceGate.reason,
5755
+ artifactPaths: releaseCustomerAcceptanceGate.evidenceRefs,
5756
+ recordedAt: releaseCustomerAcceptanceGate.recordedAt,
5757
+ metadata: releaseCustomerAcceptanceGate.metadata
5758
+ });
5759
+ }
3572
5760
  var nextActionContract = supportNextActionContractObject(ticket, job, evidence);
3573
5761
  var nextActionContractRequired = supportNextActionContractRequired(ticket, job, evidence);
3574
5762
  var nextActionContractGate = supportNextActionContractGate(nextActionContract, input.now, nextActionContractRequired);
@@ -3583,6 +5771,22 @@ function buildSupportAIRunFromEvidence(input) {
3583
5771
  metadata: nextActionContractGate.metadata
3584
5772
  });
3585
5773
  }
5774
+ var evidenceProbeContract = supportEvidenceProbeContractObject(ticket, job, evidence);
5775
+ var evidenceProbeContractRequired = cleanText(nextActionContract.action, 160) === 'collect_new_evidence'
5776
+ || ((_c = noBlindLoopGate === null || noBlindLoopGate === void 0 ? void 0 : noBlindLoopGate.metadata) === null || _c === void 0 ? void 0 : _c.requiresNewEvidence) === true
5777
+ || Object.keys(evidenceProbeContract).length > 0;
5778
+ var evidenceProbeContractGate = supportEvidenceProbeContractGate(evidenceProbeContract, input.now, evidenceProbeContractRequired);
5779
+ if (evidenceProbeContractGate) {
5780
+ gates.push(evidenceProbeContractGate);
5781
+ pushEvent(events, {
5782
+ type: 'log',
5783
+ category: 'support_evidence_probe_contract',
5784
+ message: evidenceProbeContractGate.reason,
5785
+ artifactPaths: evidenceProbeContractGate.evidenceRefs,
5786
+ recordedAt: evidenceProbeContractGate.recordedAt,
5787
+ metadata: evidenceProbeContractGate.metadata
5788
+ });
5789
+ }
3586
5790
  var managerExecutionPacket = supportManagerExecutionPacketObject(ticket, job, evidence, nextActionContract);
3587
5791
  var managerExecutionPacketGate = supportManagerExecutionPacketGate(managerExecutionPacket, input.now, nextActionContractRequired);
3588
5792
  if (managerExecutionPacketGate) {
@@ -3640,7 +5844,7 @@ function buildSupportAIRunFromEvidence(input) {
3640
5844
  if (preflightGate) {
3641
5845
  gates.push(preflightGate);
3642
5846
  pushEvent(events, {
3643
- type: ((_c = preflightGate.metadata) === null || _c === void 0 ? void 0 : _c.failureClass) === 'compile' || preflightGateSource.status === 'compile_failed' ? 'qa_compile' : 'qa_infra',
5847
+ type: ((_d = preflightGate.metadata) === null || _d === void 0 ? void 0 : _d.failureClass) === 'compile' || preflightGateSource.status === 'compile_failed' ? 'qa_compile' : 'qa_infra',
3644
5848
  category: 'support_preflight_gate',
3645
5849
  message: preflightGate.reason,
3646
5850
  artifactPaths: preflightGate.evidenceRefs,
@@ -3651,6 +5855,19 @@ function buildSupportAIRunFromEvidence(input) {
3651
5855
  var diagnosisGate = evidenceObject(job.supportV5DiagnosisGate, job.support_v5_diagnosis_gate, job.diagnosisGate, ticket.supportV5DiagnosisGate, ticket.diagnosisGate, evidence.diagnosisGate, evidence.supportV5DiagnosisGate);
3652
5856
  var diagnosisEvidencePackSource = supportDiagnosisEvidencePackObject(ticket, job, evidence);
3653
5857
  var similarFixHints = supportSimilarFixHintsObject(ticket, job, evidence);
5858
+ var similarFixHintContract = supportSimilarFixHintContractObject(ticket, job, evidence);
5859
+ var similarFixHintContractGate = supportSimilarFixHintContractGate(similarFixHintContract, input.now);
5860
+ if (similarFixHintContractGate) {
5861
+ gates.push(similarFixHintContractGate);
5862
+ pushEvent(events, {
5863
+ type: 'log',
5864
+ category: 'support_similar_fix_hint_contract',
5865
+ message: similarFixHintContractGate.reason,
5866
+ artifactPaths: similarFixHintContractGate.evidenceRefs,
5867
+ recordedAt: similarFixHintContractGate.recordedAt,
5868
+ metadata: similarFixHintContractGate.metadata
5869
+ });
5870
+ }
3654
5871
  var diagnosisEvidencePack = Object.keys(diagnosisEvidencePackSource).length
3655
5872
  ? diagnosisEvidencePackSource
3656
5873
  : (Object.keys(diagnosisGate).length || Object.keys(similarFixHints).length)
@@ -3681,6 +5898,23 @@ function buildSupportAIRunFromEvidence(input) {
3681
5898
  metadata: diagnosisEvidencePackGate.metadata
3682
5899
  });
3683
5900
  }
5901
+ var diagnosisProofMatrix = Object.keys(plainObject(diagnosisEvidencePack.proofMatrix || diagnosisEvidencePack.proof_matrix)).length
5902
+ ? plainObject(diagnosisEvidencePack.proofMatrix || diagnosisEvidencePack.proof_matrix)
5903
+ : Object.keys(diagnosisGate).length
5904
+ ? (0, support_runner_v5_1.buildResolveIOSupportDiagnosisProofMatrix)(diagnosisGate, input.now)
5905
+ : {};
5906
+ var diagnosisProofMatrixGate = supportDiagnosisProofMatrixGate(diagnosisProofMatrix, input.now, Object.keys(diagnosisGate).length > 0 || nextActionContractRequired);
5907
+ if (diagnosisProofMatrixGate) {
5908
+ gates.push(diagnosisProofMatrixGate);
5909
+ pushEvent(events, {
5910
+ type: 'log',
5911
+ category: 'support_diagnosis_proof_matrix',
5912
+ message: diagnosisProofMatrixGate.reason,
5913
+ artifactPaths: diagnosisProofMatrixGate.evidenceRefs,
5914
+ recordedAt: diagnosisProofMatrixGate.recordedAt,
5915
+ metadata: diagnosisProofMatrixGate.metadata
5916
+ });
5917
+ }
3684
5918
  var issueClassProbePlanSource = supportIssueClassProbePlanObject(ticket, job, evidence);
3685
5919
  var issueClassProbePlan = Object.keys(issueClassProbePlanSource).length
3686
5920
  ? issueClassProbePlanSource
@@ -3701,6 +5935,36 @@ function buildSupportAIRunFromEvidence(input) {
3701
5935
  });
3702
5936
  }
3703
5937
  var productRepairEvidence = supportProductRepairEvidence(input, evidence);
5938
+ var autonomousDecisionForRepairContract = plainObject(job.supportV5AutonomousDecision
5939
+ || job.support_v5_autonomous_decision
5940
+ || evidence.supportV5AutonomousDecision
5941
+ || evidence.support_v5_autonomous_decision
5942
+ || ticket.supportV5AutonomousDecision
5943
+ || ticket.support_v5_autonomous_decision);
5944
+ var repairGateForRepairContract = plainObject(autonomousDecisionForRepairContract.repairGate || autonomousDecisionForRepairContract.repair_gate);
5945
+ var ownerScopedRepairContractSource = evidenceObject(autonomousDecisionForRepairContract.ownerScopedRepairContract, autonomousDecisionForRepairContract.owner_scoped_repair_contract, repairGateForRepairContract.ownerScopedRepairContract, repairGateForRepairContract.owner_scoped_repair_contract, job.supportV5OwnerScopedRepairContract, job.support_v5_owner_scoped_repair_contract, job.ownerScopedRepairContract, job.owner_scoped_repair_contract, evidence.supportV5OwnerScopedRepairContract, evidence.support_v5_owner_scoped_repair_contract, evidence.ownerScopedRepairContract, evidence.owner_scoped_repair_contract, ticket.supportV5OwnerScopedRepairContract, ticket.support_v5_owner_scoped_repair_contract, ticket.ownerScopedRepairContract, ticket.owner_scoped_repair_contract);
5946
+ var ownerScopedRepairContract = Object.keys(ownerScopedRepairContractSource).length
5947
+ ? ownerScopedRepairContractSource
5948
+ : Object.keys(diagnosisGate).length
5949
+ ? (0, support_runner_v5_1.buildResolveIOSupportOwnerScopedRepairContract)({
5950
+ diagnosisGate: diagnosisGate,
5951
+ changedFiles: productRepairEvidence.changedFiles,
5952
+ allowTestsOutsideOwnerFiles: true,
5953
+ now: input.now
5954
+ })
5955
+ : {};
5956
+ var ownerScopedRepairContractGate = supportOwnerScopedRepairContractGate(ownerScopedRepairContract, input.now, productRepairEvidence.attempted || cleanText(nextActionContract.action, 120) === 'run_owner_scoped_repair');
5957
+ if (ownerScopedRepairContractGate) {
5958
+ gates.push(ownerScopedRepairContractGate);
5959
+ pushEvent(events, {
5960
+ type: 'log',
5961
+ category: 'support_owner_scoped_repair_contract',
5962
+ message: ownerScopedRepairContractGate.reason,
5963
+ artifactPaths: ownerScopedRepairContractGate.evidenceRefs,
5964
+ recordedAt: ownerScopedRepairContractGate.recordedAt,
5965
+ metadata: ownerScopedRepairContractGate.metadata
5966
+ });
5967
+ }
3704
5968
  var diagnosisBeforeRepairGate = supportDiagnosisBeforeRepairGate(diagnosisGate, productRepairEvidence, input.now);
3705
5969
  if (diagnosisBeforeRepairGate) {
3706
5970
  gates.push(diagnosisBeforeRepairGate);
@@ -3732,7 +5996,7 @@ function buildSupportAIRunFromEvidence(input) {
3732
5996
  pushEvent(events, {
3733
5997
  type: 'log',
3734
5998
  category: 'diagnosis_gate',
3735
- message: cleanText(((_d = diagnosisGate.accepted_hypothesis) === null || _d === void 0 ? void 0 : _d.statement) || ((_e = diagnosisGate.acceptedHypothesis) === null || _e === void 0 ? void 0 : _e.statement) || diagnosisGate.summary || 'Support diagnosis gate recorded.', 1800),
5999
+ message: cleanText(((_e = diagnosisGate.accepted_hypothesis) === null || _e === void 0 ? void 0 : _e.statement) || ((_f = diagnosisGate.acceptedHypothesis) === null || _f === void 0 ? void 0 : _f.statement) || diagnosisGate.summary || 'Support diagnosis gate recorded.', 1800),
3736
6000
  metadata: {
3737
6001
  status: diagnosisGate.status,
3738
6002
  issueClass: diagnosisIssueClass,
@@ -3768,71 +6032,542 @@ function buildSupportAIRunFromEvidence(input) {
3768
6032
  costObservability: costObservabilityMetadata(costGate),
3769
6033
  hotfixDurability: hotfixDurabilityMetadata(gates),
3770
6034
  managerNoBlindLoopPolicy: managerNoBlindLoopMetadata(noBlindLoopGate),
6035
+ autonomyApproval: autonomyApprovalGate ? {
6036
+ status: autonomyApprovalGate.status,
6037
+ approved: ((_g = autonomyApprovalGate.metadata) === null || _g === void 0 ? void 0 : _g.approved) === true,
6038
+ contractId: cleanText((_h = autonomyApprovalGate.metadata) === null || _h === void 0 ? void 0 : _h.contractId, 180),
6039
+ decisionKind: cleanText((_j = autonomyApprovalGate.metadata) === null || _j === void 0 ? void 0 : _j.decisionKind, 120),
6040
+ approvalAction: cleanText((_k = autonomyApprovalGate.metadata) === null || _k === void 0 ? void 0 : _k.approvalAction, 120),
6041
+ preferredChoiceId: cleanText((_l = autonomyApprovalGate.metadata) === null || _l === void 0 ? void 0 : _l.preferredChoiceId, 120),
6042
+ canApproveFromConsole: ((_m = autonomyApprovalGate.metadata) === null || _m === void 0 ? void 0 : _m.canApproveFromConsole) === true,
6043
+ estimatedHours: Number(((_o = autonomyApprovalGate.metadata) === null || _o === void 0 ? void 0 : _o.estimatedHours) || 0),
6044
+ estimatedHoursKnown: ((_p = autonomyApprovalGate.metadata) === null || _p === void 0 ? void 0 : _p.estimatedHoursKnown) === true,
6045
+ maxAutoHoursWithoutApproval: Number(((_q = autonomyApprovalGate.metadata) === null || _q === void 0 ? void 0 : _q.maxAutoHoursWithoutApproval) || 0),
6046
+ overMaxAutoHours: ((_r = autonomyApprovalGate.metadata) === null || _r === void 0 ? void 0 : _r.overMaxAutoHours) === true,
6047
+ approveOverMaxHours: ((_s = autonomyApprovalGate.metadata) === null || _s === void 0 ? void 0 : _s.approveOverMaxHours) === true,
6048
+ approveOverSixHours: ((_t = autonomyApprovalGate.metadata) === null || _t === void 0 ? void 0 : _t.approveOverSixHours) === true,
6049
+ explicitOverLimitApproval: ((_u = autonomyApprovalGate.metadata) === null || _u === void 0 ? void 0 : _u.explicitOverLimitApproval) === true,
6050
+ bugNotBug: cleanText((_v = autonomyApprovalGate.metadata) === null || _v === void 0 ? void 0 : _v.bugNotBug, 80),
6051
+ bugNotBugKnown: ((_w = autonomyApprovalGate.metadata) === null || _w === void 0 ? void 0 : _w.bugNotBugKnown) === true,
6052
+ bugNotBugClassificationApproved: ((_x = autonomyApprovalGate.metadata) === null || _x === void 0 ? void 0 : _x.bugNotBugClassificationApproved) === true,
6053
+ requiresOverLimitApproval: ((_y = autonomyApprovalGate.metadata) === null || _y === void 0 ? void 0 : _y.requiresOverLimitApproval) === true,
6054
+ requiresScopeReapproval: ((_z = autonomyApprovalGate.metadata) === null || _z === void 0 ? void 0 : _z.requiresScopeReapproval) === true,
6055
+ requiresOwnerFileReapproval: ((_0 = autonomyApprovalGate.metadata) === null || _0 === void 0 ? void 0 : _0.requiresOwnerFileReapproval) === true,
6056
+ requiresIntakeReapproval: ((_1 = autonomyApprovalGate.metadata) === null || _1 === void 0 ? void 0 : _1.requiresIntakeReapproval) === true,
6057
+ requiresDiagnosisScopeReapproval: ((_2 = autonomyApprovalGate.metadata) === null || _2 === void 0 ? void 0 : _2.requiresDiagnosisScopeReapproval) === true,
6058
+ requiresClassificationApproval: ((_3 = autonomyApprovalGate.metadata) === null || _3 === void 0 ? void 0 : _3.requiresClassificationApproval) === true,
6059
+ requiresEstimateHours: ((_4 = autonomyApprovalGate.metadata) === null || _4 === void 0 ? void 0 : _4.requiresEstimateHours) === true,
6060
+ changeApprovalMode: cleanText((_5 = autonomyApprovalGate.metadata) === null || _5 === void 0 ? void 0 : _5.changeApprovalMode, 120),
6061
+ overSixHourRequiresExplicitOperatorApproval: ((_6 = autonomyApprovalGate.metadata) === null || _6 === void 0 ? void 0 : _6.overSixHourRequiresExplicitOperatorApproval) === true,
6062
+ leSixHourScopeCanAutofixAfterApproval: ((_7 = autonomyApprovalGate.metadata) === null || _7 === void 0 ? void 0 : _7.leSixHourScopeCanAutofixAfterApproval) === true,
6063
+ afterApprovalAutopilotUntilAGrade: ((_8 = autonomyApprovalGate.metadata) === null || _8 === void 0 ? void 0 : _8.afterApprovalAutopilotUntilAGrade) === true,
6064
+ targetGrade: cleanText((_9 = autonomyApprovalGate.metadata) === null || _9 === void 0 ? void 0 : _9.targetGrade, 20),
6065
+ autopilotCompletionStatus: cleanText((_10 = autonomyApprovalGate.metadata) === null || _10 === void 0 ? void 0 : _10.autopilotCompletionStatus, 120),
6066
+ terminalTarget: cleanText((_11 = autonomyApprovalGate.metadata) === null || _11 === void 0 ? void 0 : _11.terminalTarget, 800),
6067
+ stopOrParkConditions: cleanStringList((_12 = autonomyApprovalGate.metadata) === null || _12 === void 0 ? void 0 : _12.stopOrParkConditions, 20, 500),
6068
+ qaScreenshotsRequired: ((_13 = autonomyApprovalGate.metadata) === null || _13 === void 0 ? void 0 : _13.qaScreenshotsRequired) === true,
6069
+ beforeActionAfterBusinessProofRequired: ((_14 = autonomyApprovalGate.metadata) === null || _14 === void 0 ? void 0 : _14.beforeActionAfterBusinessProofRequired) === true,
6070
+ aiqaBusinessAssertionRequired: ((_15 = autonomyApprovalGate.metadata) === null || _15 === void 0 ? void 0 : _15.aiqaBusinessAssertionRequired) === true,
6071
+ scopeFingerprint: cleanText((_16 = autonomyApprovalGate.metadata) === null || _16 === void 0 ? void 0 : _16.scopeFingerprint, 180),
6072
+ previousScopeFingerprint: cleanText((_17 = autonomyApprovalGate.metadata) === null || _17 === void 0 ? void 0 : _17.previousScopeFingerprint, 180),
6073
+ scopeChangedSinceApproval: ((_18 = autonomyApprovalGate.metadata) === null || _18 === void 0 ? void 0 : _18.scopeChangedSinceApproval) === true,
6074
+ ownerFilesChangedSinceApproval: ((_19 = autonomyApprovalGate.metadata) === null || _19 === void 0 ? void 0 : _19.ownerFilesChangedSinceApproval) === true,
6075
+ ownerFileFingerprint: cleanText((_20 = autonomyApprovalGate.metadata) === null || _20 === void 0 ? void 0 : _20.ownerFileFingerprint, 180),
6076
+ approvedOwnerFileFingerprint: cleanText((_21 = autonomyApprovalGate.metadata) === null || _21 === void 0 ? void 0 : _21.approvedOwnerFileFingerprint, 180),
6077
+ approvedOwnerFileSetChanged: ((_22 = autonomyApprovalGate.metadata) === null || _22 === void 0 ? void 0 : _22.approvedOwnerFileSetChanged) === true,
6078
+ diagnosisScopeFingerprint: cleanText((_23 = autonomyApprovalGate.metadata) === null || _23 === void 0 ? void 0 : _23.diagnosisScopeFingerprint, 180),
6079
+ previousDiagnosisScopeFingerprint: cleanText((_24 = autonomyApprovalGate.metadata) === null || _24 === void 0 ? void 0 : _24.previousDiagnosisScopeFingerprint, 180),
6080
+ diagnosisScopeIncluded: ((_25 = autonomyApprovalGate.metadata) === null || _25 === void 0 ? void 0 : _25.diagnosisScopeIncluded) === true,
6081
+ diagnosisScopeValid: ((_26 = autonomyApprovalGate.metadata) === null || _26 === void 0 ? void 0 : _26.diagnosisScopeValid) === true,
6082
+ diagnosisScopeChangedSinceApproval: ((_27 = autonomyApprovalGate.metadata) === null || _27 === void 0 ? void 0 : _27.diagnosisScopeChangedSinceApproval) === true,
6083
+ diagnosisScopeFields: cleanStringList((_28 = autonomyApprovalGate.metadata) === null || _28 === void 0 ? void 0 : _28.diagnosisScopeFields, 40, 160),
6084
+ diagnosisScopeBlockers: cleanStringList((_29 = autonomyApprovalGate.metadata) === null || _29 === void 0 ? void 0 : _29.diagnosisScopeBlockers, 40, 500),
6085
+ boundedAutopilotApproval: ((_30 = autonomyApprovalGate.metadata) === null || _30 === void 0 ? void 0 : _30.boundedAutopilotApproval) === true,
6086
+ autopilotApprovalBoundaryValid: ((_31 = autonomyApprovalGate.metadata) === null || _31 === void 0 ? void 0 : _31.autopilotApprovalBoundaryValid) === true,
6087
+ ownerFilesAddedSinceApproval: cleanStringList((_32 = autonomyApprovalGate.metadata) === null || _32 === void 0 ? void 0 : _32.ownerFilesAddedSinceApproval, 40, 500),
6088
+ ownerFilesRemovedSinceApproval: cleanStringList((_33 = autonomyApprovalGate.metadata) === null || _33 === void 0 ? void 0 : _33.ownerFilesRemovedSinceApproval, 40, 500),
6089
+ ownerFiles: cleanStringList((_34 = autonomyApprovalGate.metadata) === null || _34 === void 0 ? void 0 : _34.ownerFiles, 60, 500),
6090
+ approvedOwnerFiles: cleanStringList((_35 = autonomyApprovalGate.metadata) === null || _35 === void 0 ? void 0 : _35.approvedOwnerFiles, 60, 500),
6091
+ currentOwnerFiles: cleanStringList((_36 = autonomyApprovalGate.metadata) === null || _36 === void 0 ? void 0 : _36.currentOwnerFiles, 60, 500),
6092
+ requiredCompletionEvidence: cleanStringList((_37 = autonomyApprovalGate.metadata) === null || _37 === void 0 ? void 0 : _37.requiredCompletionEvidence, 30, 500),
6093
+ forbiddenWithoutReapproval: cleanStringList((_38 = autonomyApprovalGate.metadata) === null || _38 === void 0 ? void 0 : _38.forbiddenWithoutReapproval, 30, 500),
6094
+ blockers: cleanStringList((_39 = autonomyApprovalGate.metadata) === null || _39 === void 0 ? void 0 : _39.blockers, 40, 500)
6095
+ } : undefined,
6096
+ productRepairDispatchGuard: productRepairDispatchGate ? {
6097
+ status: productRepairDispatchGate.status,
6098
+ allowed: ((_40 = productRepairDispatchGate.metadata) === null || _40 === void 0 ? void 0 : _40.allowed) === true,
6099
+ guardStatus: cleanText((_41 = productRepairDispatchGate.metadata) === null || _41 === void 0 ? void 0 : _41.status, 120),
6100
+ action: cleanText((_42 = productRepairDispatchGate.metadata) === null || _42 === void 0 ? void 0 : _42.action, 160),
6101
+ nextAction: cleanText((_43 = productRepairDispatchGate.metadata) === null || _43 === void 0 ? void 0 : _43.nextAction, 160),
6102
+ editsProductCode: ((_44 = productRepairDispatchGate.metadata) === null || _44 === void 0 ? void 0 : _44.editsProductCode) === true,
6103
+ canEditProductCode: ((_45 = productRepairDispatchGate.metadata) === null || _45 === void 0 ? void 0 : _45.canEditProductCode) === true,
6104
+ autoContinueAfterApproval: ((_46 = productRepairDispatchGate.metadata) === null || _46 === void 0 ? void 0 : _46.autoContinueAfterApproval) === true,
6105
+ approvalContractId: cleanText((_47 = productRepairDispatchGate.metadata) === null || _47 === void 0 ? void 0 : _47.approvalContractId, 180),
6106
+ continuationContractStatus: cleanText((_48 = productRepairDispatchGate.metadata) === null || _48 === void 0 ? void 0 : _48.continuationContractStatus, 120),
6107
+ continuationContractMode: cleanText((_49 = productRepairDispatchGate.metadata) === null || _49 === void 0 ? void 0 : _49.continuationContractMode, 160),
6108
+ terminalTarget: cleanText((_50 = productRepairDispatchGate.metadata) === null || _50 === void 0 ? void 0 : _50.terminalTarget, 800),
6109
+ nextProofPhases: cleanStringList((_51 = productRepairDispatchGate.metadata) === null || _51 === void 0 ? void 0 : _51.nextProofPhases, 20, 240),
6110
+ allowedAutoActions: cleanStringList((_52 = productRepairDispatchGate.metadata) === null || _52 === void 0 ? void 0 : _52.allowedAutoActions, 20, 240),
6111
+ forbiddenActions: cleanStringList((_53 = productRepairDispatchGate.metadata) === null || _53 === void 0 ? void 0 : _53.forbiddenActions, 30, 500),
6112
+ scopeFingerprint: cleanText((_54 = productRepairDispatchGate.metadata) === null || _54 === void 0 ? void 0 : _54.scopeFingerprint, 180),
6113
+ ownerFilesChangedSinceApproval: ((_55 = productRepairDispatchGate.metadata) === null || _55 === void 0 ? void 0 : _55.ownerFilesChangedSinceApproval) === true,
6114
+ ownerFileFingerprint: cleanText((_56 = productRepairDispatchGate.metadata) === null || _56 === void 0 ? void 0 : _56.ownerFileFingerprint, 180),
6115
+ approvedOwnerFileFingerprint: cleanText((_57 = productRepairDispatchGate.metadata) === null || _57 === void 0 ? void 0 : _57.approvedOwnerFileFingerprint, 180),
6116
+ ownerFilesAddedSinceApproval: cleanStringList((_58 = productRepairDispatchGate.metadata) === null || _58 === void 0 ? void 0 : _58.ownerFilesAddedSinceApproval, 40, 500),
6117
+ ownerFilesRemovedSinceApproval: cleanStringList((_59 = productRepairDispatchGate.metadata) === null || _59 === void 0 ? void 0 : _59.ownerFilesRemovedSinceApproval, 40, 500),
6118
+ requiresOverLimitApproval: ((_60 = productRepairDispatchGate.metadata) === null || _60 === void 0 ? void 0 : _60.requiresOverLimitApproval) === true,
6119
+ requiresScopeReapproval: ((_61 = productRepairDispatchGate.metadata) === null || _61 === void 0 ? void 0 : _61.requiresScopeReapproval) === true,
6120
+ requiresOwnerFileReapproval: ((_62 = productRepairDispatchGate.metadata) === null || _62 === void 0 ? void 0 : _62.requiresOwnerFileReapproval) === true,
6121
+ requiresDiagnosisScopeReapproval: ((_63 = productRepairDispatchGate.metadata) === null || _63 === void 0 ? void 0 : _63.requiresDiagnosisScopeReapproval) === true,
6122
+ ownerFiles: cleanStringList((_64 = productRepairDispatchGate.metadata) === null || _64 === void 0 ? void 0 : _64.ownerFiles, 60, 500),
6123
+ approvedOwnerFiles: cleanStringList((_65 = productRepairDispatchGate.metadata) === null || _65 === void 0 ? void 0 : _65.approvedOwnerFiles, 60, 500),
6124
+ currentOwnerFiles: cleanStringList((_66 = productRepairDispatchGate.metadata) === null || _66 === void 0 ? void 0 : _66.currentOwnerFiles, 60, 500),
6125
+ blockers: cleanStringList((_67 = productRepairDispatchGate.metadata) === null || _67 === void 0 ? void 0 : _67.blockers, 40, 500)
6126
+ } : undefined,
6127
+ autoloopApprovalBlock: autoloopApprovalBlockGate ? {
6128
+ status: autoloopApprovalBlockGate.status,
6129
+ recordId: cleanText((_68 = autoloopApprovalBlockGate.metadata) === null || _68 === void 0 ? void 0 : _68.recordId, 180),
6130
+ blockStatus: cleanText((_69 = autoloopApprovalBlockGate.metadata) === null || _69 === void 0 ? void 0 : _69.status, 160),
6131
+ action: cleanText((_70 = autoloopApprovalBlockGate.metadata) === null || _70 === void 0 ? void 0 : _70.action, 160),
6132
+ nextAction: cleanText((_71 = autoloopApprovalBlockGate.metadata) === null || _71 === void 0 ? void 0 : _71.nextAction, 160),
6133
+ approvalContractId: cleanText((_72 = autoloopApprovalBlockGate.metadata) === null || _72 === void 0 ? void 0 : _72.approvalContractId, 180),
6134
+ scopeFingerprint: cleanText((_73 = autoloopApprovalBlockGate.metadata) === null || _73 === void 0 ? void 0 : _73.scopeFingerprint, 180),
6135
+ diagnosisScopeFingerprint: cleanText((_74 = autoloopApprovalBlockGate.metadata) === null || _74 === void 0 ? void 0 : _74.diagnosisScopeFingerprint, 180),
6136
+ repairIntentScopeFingerprint: cleanText((_75 = autoloopApprovalBlockGate.metadata) === null || _75 === void 0 ? void 0 : _75.repairIntentScopeFingerprint, 180),
6137
+ decisionKind: cleanText((_76 = autoloopApprovalBlockGate.metadata) === null || _76 === void 0 ? void 0 : _76.decisionKind, 160),
6138
+ requiresOverLimitApproval: ((_77 = autoloopApprovalBlockGate.metadata) === null || _77 === void 0 ? void 0 : _77.requiresOverLimitApproval) === true,
6139
+ requiresScopeReapproval: ((_78 = autoloopApprovalBlockGate.metadata) === null || _78 === void 0 ? void 0 : _78.requiresScopeReapproval) === true,
6140
+ requiresOwnerFileReapproval: ((_79 = autoloopApprovalBlockGate.metadata) === null || _79 === void 0 ? void 0 : _79.requiresOwnerFileReapproval) === true,
6141
+ requiresDiagnosisScopeReapproval: ((_80 = autoloopApprovalBlockGate.metadata) === null || _80 === void 0 ? void 0 : _80.requiresDiagnosisScopeReapproval) === true,
6142
+ requiresRepairIntentReapproval: ((_81 = autoloopApprovalBlockGate.metadata) === null || _81 === void 0 ? void 0 : _81.requiresRepairIntentReapproval) === true,
6143
+ requiresRepairIntent: ((_82 = autoloopApprovalBlockGate.metadata) === null || _82 === void 0 ? void 0 : _82.requiresRepairIntent) === true,
6144
+ requiresClassificationApproval: ((_83 = autoloopApprovalBlockGate.metadata) === null || _83 === void 0 ? void 0 : _83.requiresClassificationApproval) === true,
6145
+ requiresEstimateHours: ((_84 = autoloopApprovalBlockGate.metadata) === null || _84 === void 0 ? void 0 : _84.requiresEstimateHours) === true,
6146
+ requiresElapsedReapproval: ((_85 = autoloopApprovalBlockGate.metadata) === null || _85 === void 0 ? void 0 : _85.requiresElapsedReapproval) === true,
6147
+ elapsedRuntimeMs: Number(((_86 = autoloopApprovalBlockGate.metadata) === null || _86 === void 0 ? void 0 : _86.elapsedRuntimeMs) || 0) || 0,
6148
+ elapsedRuntimeHours: Number(((_87 = autoloopApprovalBlockGate.metadata) === null || _87 === void 0 ? void 0 : _87.elapsedRuntimeHours) || 0) || 0,
6149
+ maxApprovedRuntimeMs: Number(((_88 = autoloopApprovalBlockGate.metadata) === null || _88 === void 0 ? void 0 : _88.maxApprovedRuntimeMs) || 0) || 0,
6150
+ maxApprovedRuntimeHours: Number(((_89 = autoloopApprovalBlockGate.metadata) === null || _89 === void 0 ? void 0 : _89.maxApprovedRuntimeHours) || 0) || 0,
6151
+ maxWallClockMs: Number(((_90 = autoloopApprovalBlockGate.metadata) === null || _90 === void 0 ? void 0 : _90.maxWallClockMs) || 0) || 0,
6152
+ maxWallClockHours: Number(((_91 = autoloopApprovalBlockGate.metadata) === null || _91 === void 0 ? void 0 : _91.maxWallClockHours) || 0) || 0,
6153
+ onTheFlyScopeChangeApprovalRequired: ((_92 = autoloopApprovalBlockGate.metadata) === null || _92 === void 0 ? void 0 : _92.onTheFlyScopeChangeApprovalRequired) === true,
6154
+ targetGrade: cleanText((_93 = autoloopApprovalBlockGate.metadata) === null || _93 === void 0 ? void 0 : _93.targetGrade, 20),
6155
+ requiredTerminalState: cleanText((_94 = autoloopApprovalBlockGate.metadata) === null || _94 === void 0 ? void 0 : _94.requiredTerminalState, 800),
6156
+ humanDecisionRequestId: cleanText((_95 = autoloopApprovalBlockGate.metadata) === null || _95 === void 0 ? void 0 : _95.humanDecisionRequestId, 180),
6157
+ humanDecisionPreferredChoiceId: cleanText((_96 = autoloopApprovalBlockGate.metadata) === null || _96 === void 0 ? void 0 : _96.humanDecisionPreferredChoiceId, 160),
6158
+ humanDecisionApprovalAction: cleanText((_97 = autoloopApprovalBlockGate.metadata) === null || _97 === void 0 ? void 0 : _97.humanDecisionApprovalAction, 160),
6159
+ productRepairDispatchGuardStatus: cleanText((_98 = autoloopApprovalBlockGate.metadata) === null || _98 === void 0 ? void 0 : _98.productRepairDispatchGuardStatus, 120),
6160
+ productRepairDispatchNextAction: cleanText((_99 = autoloopApprovalBlockGate.metadata) === null || _99 === void 0 ? void 0 : _99.productRepairDispatchNextAction, 160),
6161
+ blockers: cleanStringList((_100 = autoloopApprovalBlockGate.metadata) === null || _100 === void 0 ? void 0 : _100.blockers, 40, 500)
6162
+ } : undefined,
6163
+ autoloopNoProgress: autoloopNoProgressGate ? {
6164
+ status: autoloopNoProgressGate.status,
6165
+ runId: cleanText((_101 = autoloopNoProgressGate.metadata) === null || _101 === void 0 ? void 0 : _101.runId, 180),
6166
+ noProgressStreak: Number(((_102 = autoloopNoProgressGate.metadata) === null || _102 === void 0 ? void 0 : _102.noProgressStreak) || 0),
6167
+ lastProgressSignal: ((_103 = autoloopNoProgressGate.metadata) === null || _103 === void 0 ? void 0 : _103.lastProgressSignal) === true,
6168
+ evidenceChanged: ((_104 = autoloopNoProgressGate.metadata) === null || _104 === void 0 ? void 0 : _104.evidenceChanged) === true,
6169
+ handoffRequired: ((_105 = autoloopNoProgressGate.metadata) === null || _105 === void 0 ? void 0 : _105.handoffRequired) === true,
6170
+ requiresNewEvidence: ((_106 = autoloopNoProgressGate.metadata) === null || _106 === void 0 ? void 0 : _106.requiresNewEvidence) === true,
6171
+ productRepairAllowed: ((_107 = autoloopNoProgressGate.metadata) === null || _107 === void 0 ? void 0 : _107.productRepairAllowed) === true,
6172
+ nextAction: cleanText((_108 = autoloopNoProgressGate.metadata) === null || _108 === void 0 ? void 0 : _108.nextAction, 160),
6173
+ strictGateReason: cleanText((_109 = autoloopNoProgressGate.metadata) === null || _109 === void 0 ? void 0 : _109.strictGateReason, 500),
6174
+ diffFingerprint: cleanText((_110 = autoloopNoProgressGate.metadata) === null || _110 === void 0 ? void 0 : _110.diffFingerprint, 180),
6175
+ failingCheckFingerprint: cleanText((_111 = autoloopNoProgressGate.metadata) === null || _111 === void 0 ? void 0 : _111.failingCheckFingerprint, 180),
6176
+ continuationAction: cleanText((_112 = autoloopNoProgressGate.metadata) === null || _112 === void 0 ? void 0 : _112.continuationAction, 160),
6177
+ continuationReason: cleanText((_113 = autoloopNoProgressGate.metadata) === null || _113 === void 0 ? void 0 : _113.continuationReason, 1000),
6178
+ progressReasons: cleanStringList((_114 = autoloopNoProgressGate.metadata) === null || _114 === void 0 ? void 0 : _114.progressReasons, 20, 240),
6179
+ evidenceReasons: cleanStringList((_115 = autoloopNoProgressGate.metadata) === null || _115 === void 0 ? void 0 : _115.evidenceReasons, 20, 240),
6180
+ requiredEvidence: cleanStringList((_116 = autoloopNoProgressGate.metadata) === null || _116 === void 0 ? void 0 : _116.requiredEvidence, 20, 500),
6181
+ forbiddenActions: cleanStringList((_117 = autoloopNoProgressGate.metadata) === null || _117 === void 0 ? void 0 : _117.forbiddenActions, 20, 500),
6182
+ blockers: cleanStringList((_118 = autoloopNoProgressGate.metadata) === null || _118 === void 0 ? void 0 : _118.blockers, 40, 500)
6183
+ } : undefined,
6184
+ humanDecisionRequest: humanDecisionRequestGate ? {
6185
+ status: humanDecisionRequestGate.status,
6186
+ required: ((_119 = humanDecisionRequestGate.metadata) === null || _119 === void 0 ? void 0 : _119.required) === true,
6187
+ requestId: cleanText((_120 = humanDecisionRequestGate.metadata) === null || _120 === void 0 ? void 0 : _120.requestId, 180),
6188
+ decisionKind: cleanText((_121 = humanDecisionRequestGate.metadata) === null || _121 === void 0 ? void 0 : _121.decisionKind, 120),
6189
+ approvalAction: cleanText((_122 = humanDecisionRequestGate.metadata) === null || _122 === void 0 ? void 0 : _122.approvalAction, 120),
6190
+ preferredChoiceId: cleanText((_123 = humanDecisionRequestGate.metadata) === null || _123 === void 0 ? void 0 : _123.preferredChoiceId, 120),
6191
+ canApproveFromConsole: ((_124 = humanDecisionRequestGate.metadata) === null || _124 === void 0 ? void 0 : _124.canApproveFromConsole) === true,
6192
+ choiceCount: Number(((_125 = humanDecisionRequestGate.metadata) === null || _125 === void 0 ? void 0 : _125.choiceCount) || 0),
6193
+ requiresOverLimitApproval: ((_126 = humanDecisionRequestGate.metadata) === null || _126 === void 0 ? void 0 : _126.requiresOverLimitApproval) === true,
6194
+ requiresScopeReapproval: ((_127 = humanDecisionRequestGate.metadata) === null || _127 === void 0 ? void 0 : _127.requiresScopeReapproval) === true,
6195
+ requiresIntakeReapproval: ((_128 = humanDecisionRequestGate.metadata) === null || _128 === void 0 ? void 0 : _128.requiresIntakeReapproval) === true,
6196
+ requiresDiagnosisScopeReapproval: ((_129 = humanDecisionRequestGate.metadata) === null || _129 === void 0 ? void 0 : _129.requiresDiagnosisScopeReapproval) === true,
6197
+ requiresClassificationApproval: ((_130 = humanDecisionRequestGate.metadata) === null || _130 === void 0 ? void 0 : _130.requiresClassificationApproval) === true,
6198
+ requiresEstimateHours: ((_131 = humanDecisionRequestGate.metadata) === null || _131 === void 0 ? void 0 : _131.requiresEstimateHours) === true
6199
+ } : undefined,
6200
+ postApprovalAutostart: postApprovalAutostartGate ? {
6201
+ gateStatus: postApprovalAutostartGate.status,
6202
+ status: cleanText((_132 = postApprovalAutostartGate.metadata) === null || _132 === void 0 ? void 0 : _132.status, 120),
6203
+ contractStatus: cleanText((_133 = postApprovalAutostartGate.metadata) === null || _133 === void 0 ? void 0 : _133.contractStatus, 120),
6204
+ resultStatus: cleanText((_134 = postApprovalAutostartGate.metadata) === null || _134 === void 0 ? void 0 : _134.resultStatus, 120),
6205
+ failureClass: cleanText((_135 = postApprovalAutostartGate.metadata) === null || _135 === void 0 ? void 0 : _135.failureClass, 120),
6206
+ blockerFingerprint: cleanText((_136 = postApprovalAutostartGate.metadata) === null || _136 === void 0 ? void 0 : _136.blockerFingerprint, 180),
6207
+ blockerReason: cleanText((_137 = postApprovalAutostartGate.metadata) === null || _137 === void 0 ? void 0 : _137.blockerReason, 1200),
6208
+ approvalBoundaryValid: ((_138 = postApprovalAutostartGate.metadata) === null || _138 === void 0 ? void 0 : _138.approvalBoundaryValid) === true,
6209
+ canRetryWithoutReapproval: ((_139 = postApprovalAutostartGate.metadata) === null || _139 === void 0 ? void 0 : _139.canRetryWithoutReapproval) === true,
6210
+ safeRetryAction: cleanText((_140 = postApprovalAutostartGate.metadata) === null || _140 === void 0 ? void 0 : _140.safeRetryAction, 160),
6211
+ resumeContract: plainObject((_141 = postApprovalAutostartGate.metadata) === null || _141 === void 0 ? void 0 : _141.resumeContract),
6212
+ postApprovalResumeContract: plainObject((_142 = postApprovalAutostartGate.metadata) === null || _142 === void 0 ? void 0 : _142.postApprovalResumeContract),
6213
+ started: ((_143 = postApprovalAutostartGate.metadata) === null || _143 === void 0 ? void 0 : _143.started) === true,
6214
+ skipped: ((_144 = postApprovalAutostartGate.metadata) === null || _144 === void 0 ? void 0 : _144.skipped) === true,
6215
+ blocked: ((_145 = postApprovalAutostartGate.metadata) === null || _145 === void 0 ? void 0 : _145.blocked) === true,
6216
+ nextAction: cleanText((_146 = postApprovalAutostartGate.metadata) === null || _146 === void 0 ? void 0 : _146.nextAction, 160),
6217
+ runId: cleanText((_147 = postApprovalAutostartGate.metadata) === null || _147 === void 0 ? void 0 : _147.runId, 180),
6218
+ activeTicketId: cleanText((_148 = postApprovalAutostartGate.metadata) === null || _148 === void 0 ? void 0 : _148.activeTicketId, 180),
6219
+ activeRunId: cleanText((_149 = postApprovalAutostartGate.metadata) === null || _149 === void 0 ? void 0 : _149.activeRunId, 180),
6220
+ error: cleanText((_150 = postApprovalAutostartGate.metadata) === null || _150 === void 0 ? void 0 : _150.error, 1000),
6221
+ contractId: cleanText((_151 = postApprovalAutostartGate.metadata) === null || _151 === void 0 ? void 0 : _151.contractId, 180),
6222
+ recordId: cleanText((_152 = postApprovalAutostartGate.metadata) === null || _152 === void 0 ? void 0 : _152.recordId, 180),
6223
+ approvalContractId: cleanText((_153 = postApprovalAutostartGate.metadata) === null || _153 === void 0 ? void 0 : _153.approvalContractId, 180),
6224
+ scopeFingerprint: cleanText((_154 = postApprovalAutostartGate.metadata) === null || _154 === void 0 ? void 0 : _154.scopeFingerprint, 180),
6225
+ method: cleanText((_155 = postApprovalAutostartGate.metadata) === null || _155 === void 0 ? void 0 : _155.method, 180),
6226
+ autoStartEnabled: ((_156 = postApprovalAutostartGate.metadata) === null || _156 === void 0 ? void 0 : _156.autoStartEnabled) === true,
6227
+ canContinueWithoutCodexMonitor: ((_157 = postApprovalAutostartGate.metadata) === null || _157 === void 0 ? void 0 : _157.canContinueWithoutCodexMonitor) === true,
6228
+ blocksManualCodexMonitoring: ((_158 = postApprovalAutostartGate.metadata) === null || _158 === void 0 ? void 0 : _158.blocksManualCodexMonitoring) === true,
6229
+ terminalTarget: cleanText((_159 = postApprovalAutostartGate.metadata) === null || _159 === void 0 ? void 0 : _159.terminalTarget, 800),
6230
+ targetGrade: cleanText((_160 = postApprovalAutostartGate.metadata) === null || _160 === void 0 ? void 0 : _160.targetGrade, 20),
6231
+ maxIterations: Number(((_161 = postApprovalAutostartGate.metadata) === null || _161 === void 0 ? void 0 : _161.maxIterations) || 0),
6232
+ iterationTimeoutMs: Number(((_162 = postApprovalAutostartGate.metadata) === null || _162 === void 0 ? void 0 : _162.iterationTimeoutMs) || 0),
6233
+ autoCreatePr: ((_163 = postApprovalAutostartGate.metadata) === null || _163 === void 0 ? void 0 : _163.autoCreatePr) === true,
6234
+ forceNewJob: ((_164 = postApprovalAutostartGate.metadata) === null || _164 === void 0 ? void 0 : _164.forceNewJob) === true,
6235
+ forceRestart: ((_165 = postApprovalAutostartGate.metadata) === null || _165 === void 0 ? void 0 : _165.forceRestart) === true,
6236
+ budgetSoftUsd: Number(((_166 = postApprovalAutostartGate.metadata) === null || _166 === void 0 ? void 0 : _166.budgetSoftUsd) || 0),
6237
+ budgetHardUsd: Number(((_167 = postApprovalAutostartGate.metadata) === null || _167 === void 0 ? void 0 : _167.budgetHardUsd) || 0),
6238
+ executionTier: cleanText((_168 = postApprovalAutostartGate.metadata) === null || _168 === void 0 ? void 0 : _168.executionTier, 120),
6239
+ requiredTerminalEvidence: cleanStringList((_169 = postApprovalAutostartGate.metadata) === null || _169 === void 0 ? void 0 : _169.requiredTerminalEvidence, 30, 500),
6240
+ allowedAutoActions: cleanStringList((_170 = postApprovalAutostartGate.metadata) === null || _170 === void 0 ? void 0 : _170.allowedAutoActions, 30, 240),
6241
+ forbiddenWithoutReapproval: cleanStringList((_171 = postApprovalAutostartGate.metadata) === null || _171 === void 0 ? void 0 : _171.forbiddenWithoutReapproval, 30, 500),
6242
+ blockers: cleanStringList((_172 = postApprovalAutostartGate.metadata) === null || _172 === void 0 ? void 0 : _172.blockers, 40, 500)
6243
+ } : undefined,
6244
+ postApprovalResumeAttempt: postApprovalResumeAttemptGate ? {
6245
+ gateStatus: postApprovalResumeAttemptGate.status,
6246
+ status: cleanText((_173 = postApprovalResumeAttemptGate.metadata) === null || _173 === void 0 ? void 0 : _173.status, 120),
6247
+ resultStatus: cleanText((_174 = postApprovalResumeAttemptGate.metadata) === null || _174 === void 0 ? void 0 : _174.resultStatus, 120),
6248
+ failureClass: cleanText((_175 = postApprovalResumeAttemptGate.metadata) === null || _175 === void 0 ? void 0 : _175.failureClass, 120),
6249
+ blockerFingerprint: cleanText((_176 = postApprovalResumeAttemptGate.metadata) === null || _176 === void 0 ? void 0 : _176.blockerFingerprint, 180),
6250
+ blockerReason: cleanText((_177 = postApprovalResumeAttemptGate.metadata) === null || _177 === void 0 ? void 0 : _177.blockerReason, 1200),
6251
+ started: ((_178 = postApprovalResumeAttemptGate.metadata) === null || _178 === void 0 ? void 0 : _178.started) === true,
6252
+ blocked: ((_179 = postApprovalResumeAttemptGate.metadata) === null || _179 === void 0 ? void 0 : _179.blocked) === true,
6253
+ nextAction: cleanText((_180 = postApprovalResumeAttemptGate.metadata) === null || _180 === void 0 ? void 0 : _180.nextAction, 160),
6254
+ runId: cleanText((_181 = postApprovalResumeAttemptGate.metadata) === null || _181 === void 0 ? void 0 : _181.runId, 180),
6255
+ activeTicketId: cleanText((_182 = postApprovalResumeAttemptGate.metadata) === null || _182 === void 0 ? void 0 : _182.activeTicketId, 180),
6256
+ activeRunId: cleanText((_183 = postApprovalResumeAttemptGate.metadata) === null || _183 === void 0 ? void 0 : _183.activeRunId, 180),
6257
+ activeJobId: cleanText((_184 = postApprovalResumeAttemptGate.metadata) === null || _184 === void 0 ? void 0 : _184.activeJobId, 180),
6258
+ error: cleanText((_185 = postApprovalResumeAttemptGate.metadata) === null || _185 === void 0 ? void 0 : _185.error, 1000),
6259
+ attemptId: cleanText((_186 = postApprovalResumeAttemptGate.metadata) === null || _186 === void 0 ? void 0 : _186.attemptId, 180),
6260
+ contractId: cleanText((_187 = postApprovalResumeAttemptGate.metadata) === null || _187 === void 0 ? void 0 : _187.contractId, 180),
6261
+ approvalContractId: cleanText((_188 = postApprovalResumeAttemptGate.metadata) === null || _188 === void 0 ? void 0 : _188.approvalContractId, 180),
6262
+ scopeFingerprint: cleanText((_189 = postApprovalResumeAttemptGate.metadata) === null || _189 === void 0 ? void 0 : _189.scopeFingerprint, 180),
6263
+ resumeContract: plainObject((_190 = postApprovalResumeAttemptGate.metadata) === null || _190 === void 0 ? void 0 : _190.resumeContract),
6264
+ postApprovalResumeContract: plainObject((_191 = postApprovalResumeAttemptGate.metadata) === null || _191 === void 0 ? void 0 : _191.postApprovalResumeContract),
6265
+ startGuardStatus: cleanText((_192 = postApprovalResumeAttemptGate.metadata) === null || _192 === void 0 ? void 0 : _192.startGuardStatus, 120),
6266
+ canContinueWithoutCodexMonitor: ((_193 = postApprovalResumeAttemptGate.metadata) === null || _193 === void 0 ? void 0 : _193.canContinueWithoutCodexMonitor) === true,
6267
+ productRepairAllowed: ((_194 = postApprovalResumeAttemptGate.metadata) === null || _194 === void 0 ? void 0 : _194.productRepairAllowed) === true,
6268
+ canSendCustomerReply: ((_195 = postApprovalResumeAttemptGate.metadata) === null || _195 === void 0 ? void 0 : _195.canSendCustomerReply) === true,
6269
+ blockers: cleanStringList((_196 = postApprovalResumeAttemptGate.metadata) === null || _196 === void 0 ? void 0 : _196.blockers, 40, 500)
6270
+ } : undefined,
6271
+ intakeRevisionContract: intakeRevisionContractGate ? {
6272
+ status: intakeRevisionContractGate.status,
6273
+ contractStatus: cleanText((_197 = intakeRevisionContractGate.metadata) === null || _197 === void 0 ? void 0 : _197.status, 120),
6274
+ contractId: cleanText((_198 = intakeRevisionContractGate.metadata) === null || _198 === void 0 ? void 0 : _198.contractId, 180),
6275
+ requiresReapproval: ((_199 = intakeRevisionContractGate.metadata) === null || _199 === void 0 ? void 0 : _199.requiresReapproval) === true,
6276
+ blocksProductRepair: ((_200 = intakeRevisionContractGate.metadata) === null || _200 === void 0 ? void 0 : _200.blocksProductRepair) === true,
6277
+ blocksAutoRetry: ((_201 = intakeRevisionContractGate.metadata) === null || _201 === void 0 ? void 0 : _201.blocksAutoRetry) === true,
6278
+ requiredOperatorAction: cleanText((_202 = intakeRevisionContractGate.metadata) === null || _202 === void 0 ? void 0 : _202.requiredOperatorAction, 160),
6279
+ previousAutonomyContractId: cleanText((_203 = intakeRevisionContractGate.metadata) === null || _203 === void 0 ? void 0 : _203.previousAutonomyContractId, 180),
6280
+ previousScopeFingerprint: cleanText((_204 = intakeRevisionContractGate.metadata) === null || _204 === void 0 ? void 0 : _204.previousScopeFingerprint, 180),
6281
+ nextScopeFingerprint: cleanText((_205 = intakeRevisionContractGate.metadata) === null || _205 === void 0 ? void 0 : _205.nextScopeFingerprint, 180),
6282
+ intakeScopeFingerprint: cleanText((_206 = intakeRevisionContractGate.metadata) === null || _206 === void 0 ? void 0 : _206.intakeScopeFingerprint, 180),
6283
+ changedFieldNames: cleanStringList((_207 = intakeRevisionContractGate.metadata) === null || _207 === void 0 ? void 0 : _207.changedFieldNames, 40, 120),
6284
+ changedFields: asArray((_208 = intakeRevisionContractGate.metadata) === null || _208 === void 0 ? void 0 : _208.changedFields).map(function (entry) { return ({
6285
+ field: cleanText(entry.field, 120),
6286
+ previous: cleanText(entry.previous, 500),
6287
+ next: cleanText(entry.next, 500)
6288
+ }); }).filter(function (entry) { return entry.field; }),
6289
+ approvalImpactingEditFields: cleanStringList((_209 = intakeRevisionContractGate.metadata) === null || _209 === void 0 ? void 0 : _209.approvalImpactingEditFields, 40, 120),
6290
+ updatedBy: cleanText((_210 = intakeRevisionContractGate.metadata) === null || _210 === void 0 ? void 0 : _210.updatedBy, 160),
6291
+ blockers: cleanStringList((_211 = intakeRevisionContractGate.metadata) === null || _211 === void 0 ? void 0 : _211.blockers, 40, 500)
6292
+ } : undefined,
6293
+ managerContinuation: managerContinuationGate ? {
6294
+ status: managerContinuationGate.status,
6295
+ managerStatus: cleanText((_212 = managerContinuationGate.metadata) === null || _212 === void 0 ? void 0 : _212.managerStatus, 120),
6296
+ continuationContractId: cleanText((_213 = managerContinuationGate.metadata) === null || _213 === void 0 ? void 0 : _213.continuationContractId, 180),
6297
+ continuationStatus: cleanText((_214 = managerContinuationGate.metadata) === null || _214 === void 0 ? void 0 : _214.continuationStatus, 120),
6298
+ action: cleanText((_215 = managerContinuationGate.metadata) === null || _215 === void 0 ? void 0 : _215.action, 180),
6299
+ requiredStateTransition: cleanText((_216 = managerContinuationGate.metadata) === null || _216 === void 0 ? void 0 : _216.requiredStateTransition, 1000),
6300
+ operatorGuidanceResponseId: cleanText((_217 = managerContinuationGate.metadata) === null || _217 === void 0 ? void 0 : _217.operatorGuidanceResponseId, 180),
6301
+ operatorGuidanceAccepted: ((_218 = managerContinuationGate.metadata) === null || _218 === void 0 ? void 0 : _218.operatorGuidanceAccepted) === true,
6302
+ operatorGuidanceConsumed: ((_219 = managerContinuationGate.metadata) === null || _219 === void 0 ? void 0 : _219.operatorGuidanceConsumed) === true,
6303
+ resumeUnblockContractId: cleanText((_220 = managerContinuationGate.metadata) === null || _220 === void 0 ? void 0 : _220.resumeUnblockContractId, 180),
6304
+ resumeUnblockAction: cleanText((_221 = managerContinuationGate.metadata) === null || _221 === void 0 ? void 0 : _221.resumeUnblockAction, 180),
6305
+ resumeDispatchStatus: cleanText((_222 = managerContinuationGate.metadata) === null || _222 === void 0 ? void 0 : _222.resumeDispatchStatus, 120),
6306
+ resumeDispatchJobId: cleanText((_223 = managerContinuationGate.metadata) === null || _223 === void 0 ? void 0 : _223.resumeDispatchJobId, 180),
6307
+ canRunWithoutCodexMonitor: ((_224 = managerContinuationGate.metadata) === null || _224 === void 0 ? void 0 : _224.canRunWithoutCodexMonitor) === true,
6308
+ safeToAutoRunAfterInput: ((_225 = managerContinuationGate.metadata) === null || _225 === void 0 ? void 0 : _225.safeToAutoRunAfterInput) === true,
6309
+ blocksProductRepairUntilChangedEvidence: ((_226 = managerContinuationGate.metadata) === null || _226 === void 0 ? void 0 : _226.blocksProductRepairUntilChangedEvidence) === true,
6310
+ proofRequiredBeforeContinuation: ((_227 = managerContinuationGate.metadata) === null || _227 === void 0 ? void 0 : _227.proofRequiredBeforeContinuation) === true,
6311
+ allowedAfterInput: cleanStringList((_228 = managerContinuationGate.metadata) === null || _228 === void 0 ? void 0 : _228.allowedAfterInput, 20, 240),
6312
+ materialEvidenceClaimed: ((_229 = managerContinuationGate.metadata) === null || _229 === void 0 ? void 0 : _229.materialEvidenceClaimed) === true,
6313
+ materialEvidenceSignals: cleanStringList((_230 = managerContinuationGate.metadata) === null || _230 === void 0 ? void 0 : _230.materialEvidenceSignals, 20, 240),
6314
+ artifactPaths: cleanStringList((_231 = managerContinuationGate.metadata) === null || _231 === void 0 ? void 0 : _231.artifactPaths, 60, 500),
6315
+ blockers: cleanStringList((_232 = managerContinuationGate.metadata) === null || _232 === void 0 ? void 0 : _232.blockers, 40, 500)
6316
+ } : undefined,
6317
+ prReadinessContract: prReadinessContractGate ? {
6318
+ status: prReadinessContractGate.status,
6319
+ ready: ((_233 = prReadinessContractGate.metadata) === null || _233 === void 0 ? void 0 : _233.ready) === true,
6320
+ contractId: cleanText((_234 = prReadinessContractGate.metadata) === null || _234 === void 0 ? void 0 : _234.contractId, 180),
6321
+ action: cleanText((_235 = prReadinessContractGate.metadata) === null || _235 === void 0 ? void 0 : _235.action, 120),
6322
+ dispatchAction: cleanText((_236 = prReadinessContractGate.metadata) === null || _236 === void 0 ? void 0 : _236.dispatchAction, 120),
6323
+ method: cleanText((_237 = prReadinessContractGate.metadata) === null || _237 === void 0 ? void 0 : _237.method, 180),
6324
+ businessProofReady: ((_238 = prReadinessContractGate.metadata) === null || _238 === void 0 ? void 0 : _238.businessProofReady) === true,
6325
+ diagnosisValid: ((_239 = prReadinessContractGate.metadata) === null || _239 === void 0 ? void 0 : _239.diagnosisValid) === true,
6326
+ pullRequestUrl: cleanText((_240 = prReadinessContractGate.metadata) === null || _240 === void 0 ? void 0 : _240.pullRequestUrl, 500),
6327
+ pullRequestStatus: cleanText((_241 = prReadinessContractGate.metadata) === null || _241 === void 0 ? void 0 : _241.pullRequestStatus, 120),
6328
+ prFailureStatus: cleanText((_242 = prReadinessContractGate.metadata) === null || _242 === void 0 ? void 0 : _242.prFailureStatus, 120),
6329
+ passedBusinessAssertionCount: Number(((_243 = prReadinessContractGate.metadata) === null || _243 === void 0 ? void 0 : _243.passedBusinessAssertionCount) || 0),
6330
+ targetGrade: cleanText((_244 = prReadinessContractGate.metadata) === null || _244 === void 0 ? void 0 : _244.targetGrade, 20),
6331
+ mergeBlockedUntilHumanApproval: ((_245 = prReadinessContractGate.metadata) === null || _245 === void 0 ? void 0 : _245.mergeBlockedUntilHumanApproval) === true,
6332
+ customerReplyBlockedUntilReleaseGate: ((_246 = prReadinessContractGate.metadata) === null || _246 === void 0 ? void 0 : _246.customerReplyBlockedUntilReleaseGate) === true,
6333
+ releaseBlockedUntilPrReview: ((_247 = prReadinessContractGate.metadata) === null || _247 === void 0 ? void 0 : _247.releaseBlockedUntilPrReview) === true,
6334
+ businessProofArtifacts: cleanStringList((_248 = prReadinessContractGate.metadata) === null || _248 === void 0 ? void 0 : _248.businessProofArtifacts, 80, 500),
6335
+ modifiedFiles: cleanStringList((_249 = prReadinessContractGate.metadata) === null || _249 === void 0 ? void 0 : _249.modifiedFiles, 120, 500),
6336
+ requiredEvidence: cleanStringList((_250 = prReadinessContractGate.metadata) === null || _250 === void 0 ? void 0 : _250.requiredEvidence, 40, 500),
6337
+ blockers: cleanStringList((_251 = prReadinessContractGate.metadata) === null || _251 === void 0 ? void 0 : _251.blockers, 50, 500)
6338
+ } : undefined,
6339
+ prReviewContract: prReviewContractGate ? {
6340
+ status: prReviewContractGate.status,
6341
+ ready: ((_252 = prReviewContractGate.metadata) === null || _252 === void 0 ? void 0 : _252.ready) === true,
6342
+ contractId: cleanText((_253 = prReviewContractGate.metadata) === null || _253 === void 0 ? void 0 : _253.contractId, 180),
6343
+ strictGatePassed: ((_254 = prReviewContractGate.metadata) === null || _254 === void 0 ? void 0 : _254.strictGatePassed) === true,
6344
+ strictGateReason: cleanText((_255 = prReviewContractGate.metadata) === null || _255 === void 0 ? void 0 : _255.strictGateReason, 500),
6345
+ executionGrade: cleanText((_256 = prReviewContractGate.metadata) === null || _256 === void 0 ? void 0 : _256.executionGrade, 20),
6346
+ artifactsGrade: cleanText((_257 = prReviewContractGate.metadata) === null || _257 === void 0 ? void 0 : _257.artifactsGrade, 20),
6347
+ pullRequestGrade: cleanText((_258 = prReviewContractGate.metadata) === null || _258 === void 0 ? void 0 : _258.pullRequestGrade, 20),
6348
+ targetGrade: cleanText((_259 = prReviewContractGate.metadata) === null || _259 === void 0 ? void 0 : _259.targetGrade, 20),
6349
+ pullRequestUrl: cleanText((_260 = prReviewContractGate.metadata) === null || _260 === void 0 ? void 0 : _260.pullRequestUrl, 500),
6350
+ pullRequestStatus: cleanText((_261 = prReviewContractGate.metadata) === null || _261 === void 0 ? void 0 : _261.pullRequestStatus, 120),
6351
+ failureClass: cleanText((_262 = prReviewContractGate.metadata) === null || _262 === void 0 ? void 0 : _262.failureClass, 120),
6352
+ blockerFingerprint: cleanText((_263 = prReviewContractGate.metadata) === null || _263 === void 0 ? void 0 : _263.blockerFingerprint, 180),
6353
+ evidenceHash: cleanText((_264 = prReviewContractGate.metadata) === null || _264 === void 0 ? void 0 : _264.evidenceHash, 180),
6354
+ continuationContract: (_265 = prReviewContractGate.metadata) === null || _265 === void 0 ? void 0 : _265.continuationContract,
6355
+ nextAction: cleanText((_266 = prReviewContractGate.metadata) === null || _266 === void 0 ? void 0 : _266.nextAction, 160),
6356
+ requiredEvidence: cleanStringList((_267 = prReviewContractGate.metadata) === null || _267 === void 0 ? void 0 : _267.requiredEvidence, 40, 500),
6357
+ evidenceRefs: cleanStringList((_268 = prReviewContractGate.metadata) === null || _268 === void 0 ? void 0 : _268.evidenceRefs, 80, 500),
6358
+ blockers: cleanStringList((_269 = prReviewContractGate.metadata) === null || _269 === void 0 ? void 0 : _269.blockers, 50, 500)
6359
+ } : undefined,
6360
+ prCreationResult: prCreationResultGate ? {
6361
+ status: prCreationResultGate.status,
6362
+ resultStatus: cleanText((_270 = prCreationResultGate.metadata) === null || _270 === void 0 ? void 0 : _270.status, 120),
6363
+ pullRequestUrl: cleanText((_271 = prCreationResultGate.metadata) === null || _271 === void 0 ? void 0 : _271.pullRequestUrl, 500),
6364
+ pullRequestStatus: cleanText((_272 = prCreationResultGate.metadata) === null || _272 === void 0 ? void 0 : _272.pullRequestStatus, 120),
6365
+ prFailureStatus: cleanText((_273 = prCreationResultGate.metadata) === null || _273 === void 0 ? void 0 : _273.prFailureStatus, 120),
6366
+ error: cleanText((_274 = prCreationResultGate.metadata) === null || _274 === void 0 ? void 0 : _274.error, 1000),
6367
+ jobId: cleanText((_275 = prCreationResultGate.metadata) === null || _275 === void 0 ? void 0 : _275.jobId, 180),
6368
+ method: cleanText((_276 = prCreationResultGate.metadata) === null || _276 === void 0 ? void 0 : _276.method, 180),
6369
+ prReadinessContractId: cleanText((_277 = prCreationResultGate.metadata) === null || _277 === void 0 ? void 0 : _277.prReadinessContractId, 180),
6370
+ releasePushMasterStatus: cleanText((_278 = prCreationResultGate.metadata) === null || _278 === void 0 ? void 0 : _278.releasePushMasterStatus, 120),
6371
+ modifiedFiles: cleanStringList((_279 = prCreationResultGate.metadata) === null || _279 === void 0 ? void 0 : _279.modifiedFiles, 120, 500),
6372
+ businessProofReady: ((_280 = prCreationResultGate.metadata) === null || _280 === void 0 ? void 0 : _280.businessProofReady) === true,
6373
+ diagnosisValid: ((_281 = prCreationResultGate.metadata) === null || _281 === void 0 ? void 0 : _281.diagnosisValid) === true,
6374
+ mergeBlockedUntilHumanApproval: ((_282 = prCreationResultGate.metadata) === null || _282 === void 0 ? void 0 : _282.mergeBlockedUntilHumanApproval) === true,
6375
+ customerReplyBlockedUntilReleaseGate: ((_283 = prCreationResultGate.metadata) === null || _283 === void 0 ? void 0 : _283.customerReplyBlockedUntilReleaseGate) === true,
6376
+ releaseBlockedUntilPrReview: ((_284 = prCreationResultGate.metadata) === null || _284 === void 0 ? void 0 : _284.releaseBlockedUntilPrReview) === true,
6377
+ nextAction: cleanText((_285 = prCreationResultGate.metadata) === null || _285 === void 0 ? void 0 : _285.nextAction, 160)
6378
+ } : undefined,
6379
+ autopilotCompletion: autopilotCompletionGate ? {
6380
+ status: autopilotCompletionGate.status,
6381
+ completionStatus: cleanText((_286 = autopilotCompletionGate.metadata) === null || _286 === void 0 ? void 0 : _286.status, 120),
6382
+ nextAction: cleanText((_287 = autopilotCompletionGate.metadata) === null || _287 === void 0 ? void 0 : _287.nextAction, 160),
6383
+ targetGrade: cleanText((_288 = autopilotCompletionGate.metadata) === null || _288 === void 0 ? void 0 : _288.targetGrade, 20),
6384
+ businessProofReady: ((_289 = autopilotCompletionGate.metadata) === null || _289 === void 0 ? void 0 : _289.businessProofReady) === true,
6385
+ prReady: ((_290 = autopilotCompletionGate.metadata) === null || _290 === void 0 ? void 0 : _290.prReady) === true,
6386
+ pullRequestUrl: cleanText((_291 = autopilotCompletionGate.metadata) === null || _291 === void 0 ? void 0 : _291.pullRequestUrl, 500),
6387
+ pullRequestStatus: cleanText((_292 = autopilotCompletionGate.metadata) === null || _292 === void 0 ? void 0 : _292.pullRequestStatus, 120),
6388
+ prReviewReady: ((_293 = autopilotCompletionGate.metadata) === null || _293 === void 0 ? void 0 : _293.prReviewReady) === true,
6389
+ prReviewStatus: cleanText((_294 = autopilotCompletionGate.metadata) === null || _294 === void 0 ? void 0 : _294.prReviewStatus, 120),
6390
+ prReviewContractId: cleanText((_295 = autopilotCompletionGate.metadata) === null || _295 === void 0 ? void 0 : _295.prReviewContractId, 180),
6391
+ prReviewStrictGatePassed: ((_296 = autopilotCompletionGate.metadata) === null || _296 === void 0 ? void 0 : _296.prReviewStrictGatePassed) === true,
6392
+ prReviewStrictGateReason: cleanText((_297 = autopilotCompletionGate.metadata) === null || _297 === void 0 ? void 0 : _297.prReviewStrictGateReason, 500),
6393
+ prReviewExecutionGrade: cleanText((_298 = autopilotCompletionGate.metadata) === null || _298 === void 0 ? void 0 : _298.prReviewExecutionGrade, 20),
6394
+ prReviewArtifactsGrade: cleanText((_299 = autopilotCompletionGate.metadata) === null || _299 === void 0 ? void 0 : _299.prReviewArtifactsGrade, 20),
6395
+ prReviewPullRequestGrade: cleanText((_300 = autopilotCompletionGate.metadata) === null || _300 === void 0 ? void 0 : _300.prReviewPullRequestGrade, 20),
6396
+ qaScreenshotsRequired: ((_301 = autopilotCompletionGate.metadata) === null || _301 === void 0 ? void 0 : _301.qaScreenshotsRequired) === true,
6397
+ beforeActionAfterBusinessProofRequired: ((_302 = autopilotCompletionGate.metadata) === null || _302 === void 0 ? void 0 : _302.beforeActionAfterBusinessProofRequired) === true,
6398
+ aiqaBusinessAssertionRequired: ((_303 = autopilotCompletionGate.metadata) === null || _303 === void 0 ? void 0 : _303.aiqaBusinessAssertionRequired) === true,
6399
+ hasScreenshotOrTrace: ((_304 = autopilotCompletionGate.metadata) === null || _304 === void 0 ? void 0 : _304.hasScreenshotOrTrace) === true,
6400
+ businessProofArtifacts: cleanStringList((_305 = autopilotCompletionGate.metadata) === null || _305 === void 0 ? void 0 : _305.businessProofArtifacts, 80, 500),
6401
+ modifiedFiles: cleanStringList((_306 = autopilotCompletionGate.metadata) === null || _306 === void 0 ? void 0 : _306.modifiedFiles, 120, 500),
6402
+ requiredCompletionEvidence: cleanStringList((_307 = autopilotCompletionGate.metadata) === null || _307 === void 0 ? void 0 : _307.requiredCompletionEvidence, 50, 500),
6403
+ missingCompletionEvidence: cleanStringList((_308 = autopilotCompletionGate.metadata) === null || _308 === void 0 ? void 0 : _308.missingCompletionEvidence, 50, 500),
6404
+ mergeBlockedUntilHumanApproval: ((_309 = autopilotCompletionGate.metadata) === null || _309 === void 0 ? void 0 : _309.mergeBlockedUntilHumanApproval) === true,
6405
+ customerReplyBlockedUntilReleaseGate: ((_310 = autopilotCompletionGate.metadata) === null || _310 === void 0 ? void 0 : _310.customerReplyBlockedUntilReleaseGate) === true,
6406
+ releaseBlockedUntilPrReview: ((_311 = autopilotCompletionGate.metadata) === null || _311 === void 0 ? void 0 : _311.releaseBlockedUntilPrReview) === true
6407
+ } : undefined,
6408
+ releaseCustomerAcceptance: releaseCustomerAcceptanceGate ? {
6409
+ status: releaseCustomerAcceptanceGate.status,
6410
+ required: ((_312 = releaseCustomerAcceptanceGate.metadata) === null || _312 === void 0 ? void 0 : _312.required) === true,
6411
+ nextAction: cleanText((_313 = releaseCustomerAcceptanceGate.metadata) === null || _313 === void 0 ? void 0 : _313.nextAction, 160),
6412
+ pullRequestUrl: cleanText((_314 = releaseCustomerAcceptanceGate.metadata) === null || _314 === void 0 ? void 0 : _314.pullRequestUrl, 500),
6413
+ releasePullRequestUrl: cleanText((_315 = releaseCustomerAcceptanceGate.metadata) === null || _315 === void 0 ? void 0 : _315.releasePullRequestUrl, 500),
6414
+ deployPullRequestUrl: cleanText((_316 = releaseCustomerAcceptanceGate.metadata) === null || _316 === void 0 ? void 0 : _316.deployPullRequestUrl, 500),
6415
+ replyPullRequestUrl: cleanText((_317 = releaseCustomerAcceptanceGate.metadata) === null || _317 === void 0 ? void 0 : _317.replyPullRequestUrl, 500),
6416
+ prReady: ((_318 = releaseCustomerAcceptanceGate.metadata) === null || _318 === void 0 ? void 0 : _318.prReady) === true,
6417
+ pushMasterStatus: cleanText((_319 = releaseCustomerAcceptanceGate.metadata) === null || _319 === void 0 ? void 0 : _319.pushMasterStatus, 120),
6418
+ deployProductionStatus: cleanText((_320 = releaseCustomerAcceptanceGate.metadata) === null || _320 === void 0 ? void 0 : _320.deployProductionStatus, 120),
6419
+ hotfixReleaseGateStatus: cleanText((_321 = releaseCustomerAcceptanceGate.metadata) === null || _321 === void 0 ? void 0 : _321.hotfixReleaseGateStatus, 120),
6420
+ releasePrMatchesCurrent: ((_322 = releaseCustomerAcceptanceGate.metadata) === null || _322 === void 0 ? void 0 : _322.releasePrMatchesCurrent) === true,
6421
+ deployPrMatchesCurrent: ((_323 = releaseCustomerAcceptanceGate.metadata) === null || _323 === void 0 ? void 0 : _323.deployPrMatchesCurrent) === true,
6422
+ replyPrReferencePresent: ((_324 = releaseCustomerAcceptanceGate.metadata) === null || _324 === void 0 ? void 0 : _324.replyPrReferencePresent) === true,
6423
+ replyPrMatchesCurrent: ((_325 = releaseCustomerAcceptanceGate.metadata) === null || _325 === void 0 ? void 0 : _325.replyPrMatchesCurrent) === true,
6424
+ pushMasterComplete: ((_326 = releaseCustomerAcceptanceGate.metadata) === null || _326 === void 0 ? void 0 : _326.pushMasterComplete) === true,
6425
+ productionDeployComplete: ((_327 = releaseCustomerAcceptanceGate.metadata) === null || _327 === void 0 ? void 0 : _327.productionDeployComplete) === true,
6426
+ productionDeployNotRequired: ((_328 = releaseCustomerAcceptanceGate.metadata) === null || _328 === void 0 ? void 0 : _328.productionDeployNotRequired) === true,
6427
+ hotfixReleaseGatePassed: ((_329 = releaseCustomerAcceptanceGate.metadata) === null || _329 === void 0 ? void 0 : _329.hotfixReleaseGatePassed) === true,
6428
+ releaseReady: ((_330 = releaseCustomerAcceptanceGate.metadata) === null || _330 === void 0 ? void 0 : _330.releaseReady) === true,
6429
+ customerReplyReady: ((_331 = releaseCustomerAcceptanceGate.metadata) === null || _331 === void 0 ? void 0 : _331.customerReplyReady) === true,
6430
+ customerReplyReadinessStatus: cleanText((_332 = releaseCustomerAcceptanceGate.metadata) === null || _332 === void 0 ? void 0 : _332.customerReplyReadinessStatus, 120),
6431
+ proofBackedSendStatus: cleanText((_333 = releaseCustomerAcceptanceGate.metadata) === null || _333 === void 0 ? void 0 : _333.proofBackedSendStatus, 120),
6432
+ proofBackedSendRecorded: ((_334 = releaseCustomerAcceptanceGate.metadata) === null || _334 === void 0 ? void 0 : _334.proofBackedSendRecorded) === true,
6433
+ sendGuardReady: ((_335 = releaseCustomerAcceptanceGate.metadata) === null || _335 === void 0 ? void 0 : _335.sendGuardReady) === true,
6434
+ replyDraftReady: ((_336 = releaseCustomerAcceptanceGate.metadata) === null || _336 === void 0 ? void 0 : _336.replyDraftReady) === true,
6435
+ customerReplyRequiresHumanApproval: ((_337 = releaseCustomerAcceptanceGate.metadata) === null || _337 === void 0 ? void 0 : _337.customerReplyRequiresHumanApproval) === true,
6436
+ blockers: cleanStringList((_338 = releaseCustomerAcceptanceGate.metadata) === null || _338 === void 0 ? void 0 : _338.blockers, 20, 500)
6437
+ } : undefined,
6438
+ evidenceProbeContract: evidenceProbeContractGate ? {
6439
+ status: evidenceProbeContractGate.status,
6440
+ contractId: cleanText((_339 = evidenceProbeContractGate.metadata) === null || _339 === void 0 ? void 0 : _339.contractId, 200),
6441
+ contractStatus: cleanText((_340 = evidenceProbeContractGate.metadata) === null || _340 === void 0 ? void 0 : _340.status, 120),
6442
+ probeType: cleanText((_341 = evidenceProbeContractGate.metadata) === null || _341 === void 0 ? void 0 : _341.probeType, 120),
6443
+ evidenceOnly: ((_342 = evidenceProbeContractGate.metadata) === null || _342 === void 0 ? void 0 : _342.evidenceOnly) === true,
6444
+ productRepairAllowed: ((_343 = evidenceProbeContractGate.metadata) === null || _343 === void 0 ? void 0 : _343.productRepairAllowed) === true,
6445
+ canRunWithoutCodexMonitor: ((_344 = evidenceProbeContractGate.metadata) === null || _344 === void 0 ? void 0 : _344.canRunWithoutCodexMonitor) === true,
6446
+ issueClass: cleanText((_345 = evidenceProbeContractGate.metadata) === null || _345 === void 0 ? void 0 : _345.issueClass, 120),
6447
+ planId: cleanText((_346 = evidenceProbeContractGate.metadata) === null || _346 === void 0 ? void 0 : _346.planId, 200),
6448
+ activeRoute: cleanText((_347 = evidenceProbeContractGate.metadata) === null || _347 === void 0 ? void 0 : _347.activeRoute, 500),
6449
+ actionUnderTest: cleanText((_348 = evidenceProbeContractGate.metadata) === null || _348 === void 0 ? void 0 : _348.actionUnderTest, 1000),
6450
+ expectedBusinessProof: cleanText((_349 = evidenceProbeContractGate.metadata) === null || _349 === void 0 ? void 0 : _349.expectedBusinessProof, 1200),
6451
+ startingFailureClass: cleanText((_350 = evidenceProbeContractGate.metadata) === null || _350 === void 0 ? void 0 : _350.startingFailureClass, 120),
6452
+ startingEvidenceHash: cleanText((_351 = evidenceProbeContractGate.metadata) === null || _351 === void 0 ? void 0 : _351.startingEvidenceHash, 200),
6453
+ sameFailureCount: Number(((_352 = evidenceProbeContractGate.metadata) === null || _352 === void 0 ? void 0 : _352.sameFailureCount) || 0),
6454
+ requiredNewSignals: cleanStringList((_353 = evidenceProbeContractGate.metadata) === null || _353 === void 0 ? void 0 : _353.requiredNewSignals, 20, 500),
6455
+ requiredArtifacts: cleanStringList((_354 = evidenceProbeContractGate.metadata) === null || _354 === void 0 ? void 0 : _354.requiredArtifacts, 20, 500),
6456
+ acceptableEvidence: cleanStringList((_355 = evidenceProbeContractGate.metadata) === null || _355 === void 0 ? void 0 : _355.acceptableEvidence, 20, 500),
6457
+ nextCommands: cleanStringList((_356 = evidenceProbeContractGate.metadata) === null || _356 === void 0 ? void 0 : _356.nextCommands, 20, 300),
6458
+ blockers: cleanStringList((_357 = evidenceProbeContractGate.metadata) === null || _357 === void 0 ? void 0 : _357.blockers, 20, 500)
6459
+ } : undefined,
3771
6460
  diagnosisBeforeRepair: diagnosisBeforeRepairGate ? {
3772
6461
  status: diagnosisBeforeRepairGate.status,
3773
- diagnosisValid: ((_f = diagnosisBeforeRepairGate.metadata) === null || _f === void 0 ? void 0 : _f.diagnosisValid) === true,
3774
- diagnosisStatus: cleanText((_g = diagnosisBeforeRepairGate.metadata) === null || _g === void 0 ? void 0 : _g.diagnosisStatus, 120),
3775
- activityCount: Number(((_h = diagnosisBeforeRepairGate.metadata) === null || _h === void 0 ? void 0 : _h.activityCount) || 0),
3776
- changedFiles: cleanStringList((_j = diagnosisBeforeRepairGate.metadata) === null || _j === void 0 ? void 0 : _j.changedFiles, 40, 500),
3777
- allowedDispatchAction: cleanText((_k = diagnosisBeforeRepairGate.metadata) === null || _k === void 0 ? void 0 : _k.allowedDispatchAction, 160),
3778
- productRepairAllowed: ((_l = diagnosisBeforeRepairGate.metadata) === null || _l === void 0 ? void 0 : _l.productRepairAllowed) === true,
3779
- blockers: cleanStringList((_m = diagnosisBeforeRepairGate.metadata) === null || _m === void 0 ? void 0 : _m.blockers, 20, 500)
6462
+ diagnosisValid: ((_358 = diagnosisBeforeRepairGate.metadata) === null || _358 === void 0 ? void 0 : _358.diagnosisValid) === true,
6463
+ diagnosisStatus: cleanText((_359 = diagnosisBeforeRepairGate.metadata) === null || _359 === void 0 ? void 0 : _359.diagnosisStatus, 120),
6464
+ activityCount: Number(((_360 = diagnosisBeforeRepairGate.metadata) === null || _360 === void 0 ? void 0 : _360.activityCount) || 0),
6465
+ changedFiles: cleanStringList((_361 = diagnosisBeforeRepairGate.metadata) === null || _361 === void 0 ? void 0 : _361.changedFiles, 40, 500),
6466
+ allowedDispatchAction: cleanText((_362 = diagnosisBeforeRepairGate.metadata) === null || _362 === void 0 ? void 0 : _362.allowedDispatchAction, 160),
6467
+ productRepairAllowed: ((_363 = diagnosisBeforeRepairGate.metadata) === null || _363 === void 0 ? void 0 : _363.productRepairAllowed) === true,
6468
+ blockers: cleanStringList((_364 = diagnosisBeforeRepairGate.metadata) === null || _364 === void 0 ? void 0 : _364.blockers, 20, 500)
3780
6469
  } : undefined,
3781
6470
  ownerFileScope: ownerFileScopeGate ? {
3782
6471
  status: ownerFileScopeGate.status,
3783
- productRepairAllowed: ((_o = ownerFileScopeGate.metadata) === null || _o === void 0 ? void 0 : _o.productRepairAllowed) === true,
3784
- allowedDispatchAction: cleanText((_p = ownerFileScopeGate.metadata) === null || _p === void 0 ? void 0 : _p.allowedDispatchAction, 160),
3785
- ownerFiles: cleanStringList((_q = ownerFileScopeGate.metadata) === null || _q === void 0 ? void 0 : _q.ownerFiles, 40, 500),
3786
- changedFiles: cleanStringList((_r = ownerFileScopeGate.metadata) === null || _r === void 0 ? void 0 : _r.changedFiles, 60, 500),
3787
- outsideOwnerFiles: cleanStringList((_s = ownerFileScopeGate.metadata) === null || _s === void 0 ? void 0 : _s.outsideOwnerFiles, 40, 500),
3788
- allowedTestFilesOutsideOwnerScope: ((_t = ownerFileScopeGate.metadata) === null || _t === void 0 ? void 0 : _t.allowedTestFilesOutsideOwnerScope) === true,
3789
- requiredEvidence: cleanStringList((_u = ownerFileScopeGate.metadata) === null || _u === void 0 ? void 0 : _u.requiredEvidence, 20, 500)
6472
+ productRepairAllowed: ((_365 = ownerFileScopeGate.metadata) === null || _365 === void 0 ? void 0 : _365.productRepairAllowed) === true,
6473
+ allowedDispatchAction: cleanText((_366 = ownerFileScopeGate.metadata) === null || _366 === void 0 ? void 0 : _366.allowedDispatchAction, 160),
6474
+ ownerFiles: cleanStringList((_367 = ownerFileScopeGate.metadata) === null || _367 === void 0 ? void 0 : _367.ownerFiles, 40, 500),
6475
+ changedFiles: cleanStringList((_368 = ownerFileScopeGate.metadata) === null || _368 === void 0 ? void 0 : _368.changedFiles, 60, 500),
6476
+ outsideOwnerFiles: cleanStringList((_369 = ownerFileScopeGate.metadata) === null || _369 === void 0 ? void 0 : _369.outsideOwnerFiles, 40, 500),
6477
+ allowedTestFilesOutsideOwnerScope: ((_370 = ownerFileScopeGate.metadata) === null || _370 === void 0 ? void 0 : _370.allowedTestFilesOutsideOwnerScope) === true,
6478
+ requiredEvidence: cleanStringList((_371 = ownerFileScopeGate.metadata) === null || _371 === void 0 ? void 0 : _371.requiredEvidence, 20, 500)
3790
6479
  } : undefined,
3791
6480
  rootCauseEntryContract: Object.keys(rootCauseEntryContract).length ? {
3792
6481
  contractId: cleanText(rootCauseEntryContract.contract_id || rootCauseEntryContract.contractId, 160),
3793
6482
  version: cleanText(rootCauseEntryContract.version, 120),
3794
6483
  status: cleanText(rootCauseEntryContract.status, 120),
3795
6484
  issueClassProbeCount: asArray(rootCauseEntryContract.issue_class_probes || rootCauseEntryContract.issueClassProbes).length,
3796
- ownerFileMax: Number(((_v = rootCauseEntryContract.owner_file_policy) === null || _v === void 0 ? void 0 : _v.max_files) || ((_w = rootCauseEntryContract.ownerFilePolicy) === null || _w === void 0 ? void 0 : _w.maxFiles) || 0) || 0,
3797
- requiresBusinessAssertion: ((_x = rootCauseEntryContract.business_proof_policy) === null || _x === void 0 ? void 0 : _x.requires_aiqa_business_assertion) === true
3798
- || ((_y = rootCauseEntryContract.businessProofPolicy) === null || _y === void 0 ? void 0 : _y.requiresAiqaBusinessAssertion) === true
6485
+ ownerFileMax: Number(((_372 = rootCauseEntryContract.owner_file_policy) === null || _372 === void 0 ? void 0 : _372.max_files) || ((_373 = rootCauseEntryContract.ownerFilePolicy) === null || _373 === void 0 ? void 0 : _373.maxFiles) || 0) || 0,
6486
+ requiresBusinessAssertion: ((_374 = rootCauseEntryContract.business_proof_policy) === null || _374 === void 0 ? void 0 : _374.requires_aiqa_business_assertion) === true
6487
+ || ((_375 = rootCauseEntryContract.businessProofPolicy) === null || _375 === void 0 ? void 0 : _375.requiresAiqaBusinessAssertion) === true
3799
6488
  } : undefined,
3800
6489
  diagnosis: Object.keys(diagnosisGate).length ? {
3801
6490
  status: cleanText(diagnosisGate.status, 80),
3802
6491
  issueClass: diagnosisIssueClass,
3803
6492
  ownerFiles: diagnosisOwnerFiles,
3804
- acceptedHypothesis: cleanText(((_z = diagnosisGate.accepted_hypothesis) === null || _z === void 0 ? void 0 : _z.statement) || ((_0 = diagnosisGate.acceptedHypothesis) === null || _0 === void 0 ? void 0 : _0.statement), 1000),
3805
- proofPlan: diagnosisGate.proof_plan || diagnosisGate.proofPlan
6493
+ acceptedHypothesis: cleanText(((_376 = diagnosisGate.accepted_hypothesis) === null || _376 === void 0 ? void 0 : _376.statement) || ((_377 = diagnosisGate.acceptedHypothesis) === null || _377 === void 0 ? void 0 : _377.statement), 1000),
6494
+ proofPlan: diagnosisGate.proof_plan || diagnosisGate.proofPlan,
6495
+ proofMatrixId: cleanText((_378 = diagnosisProofMatrixGate === null || diagnosisProofMatrixGate === void 0 ? void 0 : diagnosisProofMatrixGate.metadata) === null || _378 === void 0 ? void 0 : _378.matrixId, 180),
6496
+ proofMatrixStatus: cleanText((_379 = diagnosisProofMatrixGate === null || diagnosisProofMatrixGate === void 0 ? void 0 : diagnosisProofMatrixGate.metadata) === null || _379 === void 0 ? void 0 : _379.status, 120)
6497
+ } : undefined,
6498
+ diagnosisProofMatrix: diagnosisProofMatrixGate ? {
6499
+ status: diagnosisProofMatrixGate.status,
6500
+ matrixId: cleanText((_380 = diagnosisProofMatrixGate.metadata) === null || _380 === void 0 ? void 0 : _380.matrixId, 180),
6501
+ matrixStatus: cleanText((_381 = diagnosisProofMatrixGate.metadata) === null || _381 === void 0 ? void 0 : _381.status, 120),
6502
+ issueClass: cleanText((_382 = diagnosisProofMatrixGate.metadata) === null || _382 === void 0 ? void 0 : _382.issueClass, 120),
6503
+ ownerFiles: cleanStringList((_383 = diagnosisProofMatrixGate.metadata) === null || _383 === void 0 ? void 0 : _383.ownerFiles, 40, 500),
6504
+ uncoveredOwnerFiles: cleanStringList((_384 = diagnosisProofMatrixGate.metadata) === null || _384 === void 0 ? void 0 : _384.uncoveredOwnerFiles, 40, 500),
6505
+ reproductionEvidenceCount: Number(((_385 = diagnosisProofMatrixGate.metadata) === null || _385 === void 0 ? void 0 : _385.reproductionEvidenceCount) || 0),
6506
+ rootCauseEvidenceCount: Number(((_386 = diagnosisProofMatrixGate.metadata) === null || _386 === void 0 ? void 0 : _386.rootCauseEvidenceCount) || 0),
6507
+ businessProofArtifacts: cleanStringList((_387 = diagnosisProofMatrixGate.metadata) === null || _387 === void 0 ? void 0 : _387.businessProofArtifacts, 40, 500),
6508
+ blockers: cleanStringList((_388 = diagnosisProofMatrixGate.metadata) === null || _388 === void 0 ? void 0 : _388.blockers, 40, 500)
6509
+ } : undefined,
6510
+ ownerScopedRepairContract: ownerScopedRepairContractGate ? {
6511
+ status: ownerScopedRepairContractGate.status,
6512
+ contractId: cleanText((_389 = ownerScopedRepairContractGate.metadata) === null || _389 === void 0 ? void 0 : _389.contractId, 180),
6513
+ contractStatus: cleanText((_390 = ownerScopedRepairContractGate.metadata) === null || _390 === void 0 ? void 0 : _390.status, 120),
6514
+ sourceEditsAllowed: ((_391 = ownerScopedRepairContractGate.metadata) === null || _391 === void 0 ? void 0 : _391.sourceEditsAllowed) === true,
6515
+ canRunWithoutCodexMonitor: ((_392 = ownerScopedRepairContractGate.metadata) === null || _392 === void 0 ? void 0 : _392.canRunWithoutCodexMonitor) === true,
6516
+ issueClass: cleanText((_393 = ownerScopedRepairContractGate.metadata) === null || _393 === void 0 ? void 0 : _393.issueClass, 120),
6517
+ ownerFiles: cleanStringList((_394 = ownerScopedRepairContractGate.metadata) === null || _394 === void 0 ? void 0 : _394.ownerFiles, 40, 500),
6518
+ proofMatrixId: cleanText((_395 = ownerScopedRepairContractGate.metadata) === null || _395 === void 0 ? void 0 : _395.proofMatrixId, 180),
6519
+ changedFiles: cleanStringList((_396 = ownerScopedRepairContractGate.metadata) === null || _396 === void 0 ? void 0 : _396.changedFiles, 60, 500),
6520
+ outsideOwnerFiles: cleanStringList((_397 = ownerScopedRepairContractGate.metadata) === null || _397 === void 0 ? void 0 : _397.outsideOwnerFiles, 40, 500),
6521
+ patchUnitCount: Number(((_398 = ownerScopedRepairContractGate.metadata) === null || _398 === void 0 ? void 0 : _398.patchUnitCount) || 0),
6522
+ requiredEvidenceAfterRepair: cleanStringList((_399 = ownerScopedRepairContractGate.metadata) === null || _399 === void 0 ? void 0 : _399.requiredEvidenceAfterRepair, 30, 500),
6523
+ blockers: cleanStringList((_400 = ownerScopedRepairContractGate.metadata) === null || _400 === void 0 ? void 0 : _400.blockers, 40, 500)
3806
6524
  } : undefined,
3807
6525
  diagnosisEvidencePack: diagnosisEvidencePackGate ? {
3808
- status: cleanText((_1 = diagnosisEvidencePackGate.metadata) === null || _1 === void 0 ? void 0 : _1.status, 120),
6526
+ status: cleanText((_401 = diagnosisEvidencePackGate.metadata) === null || _401 === void 0 ? void 0 : _401.status, 120),
3809
6527
  gateStatus: diagnosisEvidencePackGate.status,
3810
- packId: cleanText((_2 = diagnosisEvidencePackGate.metadata) === null || _2 === void 0 ? void 0 : _2.packId, 180),
3811
- readOnly: ((_3 = diagnosisEvidencePackGate.metadata) === null || _3 === void 0 ? void 0 : _3.readOnly) !== false,
3812
- sourceEditsAllowed: ((_4 = diagnosisEvidencePackGate.metadata) === null || _4 === void 0 ? void 0 : _4.sourceEditsAllowed) === true,
3813
- requiredOutputKey: cleanText((_5 = diagnosisEvidencePackGate.metadata) === null || _5 === void 0 ? void 0 : _5.requiredOutputKey, 120),
3814
- diagnosisValid: ((_6 = diagnosisEvidencePackGate.metadata) === null || _6 === void 0 ? void 0 : _6.diagnosisValid) === true,
3815
- issueClassHint: cleanText((_7 = diagnosisEvidencePackGate.metadata) === null || _7 === void 0 ? void 0 : _7.issueClassHint, 120),
3816
- ownerFileHints: cleanStringList((_8 = diagnosisEvidencePackGate.metadata) === null || _8 === void 0 ? void 0 : _8.ownerFileHints, 20, 500),
3817
- similarHintCount: Number(((_9 = diagnosisEvidencePackGate.metadata) === null || _9 === void 0 ? void 0 : _9.similarHintCount) || 0),
3818
- similarHintsAdvisoryOnly: ((_10 = diagnosisEvidencePackGate.metadata) === null || _10 === void 0 ? void 0 : _10.similarHintsAdvisoryOnly) === true,
3819
- issueClassProbeCount: Number(((_11 = diagnosisEvidencePackGate.metadata) === null || _11 === void 0 ? void 0 : _11.issueClassProbeCount) || 0),
3820
- validationBlockers: cleanStringList((_12 = diagnosisEvidencePackGate.metadata) === null || _12 === void 0 ? void 0 : _12.validationBlockers, 20, 500)
6528
+ packId: cleanText((_402 = diagnosisEvidencePackGate.metadata) === null || _402 === void 0 ? void 0 : _402.packId, 180),
6529
+ readOnly: ((_403 = diagnosisEvidencePackGate.metadata) === null || _403 === void 0 ? void 0 : _403.readOnly) !== false,
6530
+ sourceEditsAllowed: ((_404 = diagnosisEvidencePackGate.metadata) === null || _404 === void 0 ? void 0 : _404.sourceEditsAllowed) === true,
6531
+ requiredOutputKey: cleanText((_405 = diagnosisEvidencePackGate.metadata) === null || _405 === void 0 ? void 0 : _405.requiredOutputKey, 120),
6532
+ diagnosisValid: ((_406 = diagnosisEvidencePackGate.metadata) === null || _406 === void 0 ? void 0 : _406.diagnosisValid) === true,
6533
+ issueClassHint: cleanText((_407 = diagnosisEvidencePackGate.metadata) === null || _407 === void 0 ? void 0 : _407.issueClassHint, 120),
6534
+ ownerFileHints: cleanStringList((_408 = diagnosisEvidencePackGate.metadata) === null || _408 === void 0 ? void 0 : _408.ownerFileHints, 20, 500),
6535
+ similarHintCount: Number(((_409 = diagnosisEvidencePackGate.metadata) === null || _409 === void 0 ? void 0 : _409.similarHintCount) || 0),
6536
+ similarHintsAdvisoryOnly: ((_410 = diagnosisEvidencePackGate.metadata) === null || _410 === void 0 ? void 0 : _410.similarHintsAdvisoryOnly) === true,
6537
+ issueClassProbeCount: Number(((_411 = diagnosisEvidencePackGate.metadata) === null || _411 === void 0 ? void 0 : _411.issueClassProbeCount) || 0),
6538
+ validationBlockers: cleanStringList((_412 = diagnosisEvidencePackGate.metadata) === null || _412 === void 0 ? void 0 : _412.validationBlockers, 20, 500)
6539
+ } : undefined,
6540
+ similarFixHintContract: similarFixHintContractGate ? {
6541
+ gateStatus: similarFixHintContractGate.status,
6542
+ contractId: cleanText((_413 = similarFixHintContractGate.metadata) === null || _413 === void 0 ? void 0 : _413.contractId, 200),
6543
+ version: cleanText((_414 = similarFixHintContractGate.metadata) === null || _414 === void 0 ? void 0 : _414.version, 120),
6544
+ status: cleanText((_415 = similarFixHintContractGate.metadata) === null || _415 === void 0 ? void 0 : _415.status, 120),
6545
+ source: cleanText((_416 = similarFixHintContractGate.metadata) === null || _416 === void 0 ? void 0 : _416.source, 160),
6546
+ candidateCount: Number(((_417 = similarFixHintContractGate.metadata) === null || _417 === void 0 ? void 0 : _417.candidateCount) || 0),
6547
+ hintCount: Number(((_418 = similarFixHintContractGate.metadata) === null || _418 === void 0 ? void 0 : _418.hintCount) || 0),
6548
+ rankedHintCount: Number(((_419 = similarFixHintContractGate.metadata) === null || _419 === void 0 ? void 0 : _419.rankedHintCount) || 0),
6549
+ ownerFileHints: cleanStringList((_420 = similarFixHintContractGate.metadata) === null || _420 === void 0 ? void 0 : _420.ownerFileHints, 30, 500),
6550
+ advisoryOnly: ((_421 = similarFixHintContractGate.metadata) === null || _421 === void 0 ? void 0 : _421.advisoryOnly) === true,
6551
+ similarHintsAreNotProof: ((_422 = similarFixHintContractGate.metadata) === null || _422 === void 0 ? void 0 : _422.similarHintsAreNotProof) === true,
6552
+ ownerFilesRequireCurrentEvidence: ((_423 = similarFixHintContractGate.metadata) === null || _423 === void 0 ? void 0 : _423.ownerFilesRequireCurrentEvidence) === true,
6553
+ acceptedHypothesisCurrent: ((_424 = similarFixHintContractGate.metadata) === null || _424 === void 0 ? void 0 : _424.acceptedHypothesisCurrent) === true,
6554
+ requiredModelActions: cleanStringList((_425 = similarFixHintContractGate.metadata) === null || _425 === void 0 ? void 0 : _425.requiredModelActions, 20, 500),
6555
+ blockers: cleanStringList((_426 = similarFixHintContractGate.metadata) === null || _426 === void 0 ? void 0 : _426.blockers, 20, 500)
3821
6556
  } : undefined,
3822
6557
  issueClassProbePlan: issueClassProbePlanGate ? {
3823
- status: cleanText((_13 = issueClassProbePlanGate.metadata) === null || _13 === void 0 ? void 0 : _13.status, 120),
6558
+ status: cleanText((_427 = issueClassProbePlanGate.metadata) === null || _427 === void 0 ? void 0 : _427.status, 120),
3824
6559
  gateStatus: issueClassProbePlanGate.status,
3825
- planId: cleanText((_14 = issueClassProbePlanGate.metadata) === null || _14 === void 0 ? void 0 : _14.planId, 180),
3826
- issueClass: cleanText((_15 = issueClassProbePlanGate.metadata) === null || _15 === void 0 ? void 0 : _15.issueClass, 120),
3827
- diagnosisValid: ((_16 = issueClassProbePlanGate.metadata) === null || _16 === void 0 ? void 0 : _16.diagnosisValid) === true,
3828
- issueClassProbePlanReady: ((_17 = issueClassProbePlanGate.metadata) === null || _17 === void 0 ? void 0 : _17.issueClassProbePlanReady) === true,
3829
- activeRoute: cleanText((_18 = issueClassProbePlanGate.metadata) === null || _18 === void 0 ? void 0 : _18.activeRoute, 500),
3830
- action: cleanText((_19 = issueClassProbePlanGate.metadata) === null || _19 === void 0 ? void 0 : _19.action, 1000),
3831
- expectedBusinessProof: cleanText((_20 = issueClassProbePlanGate.metadata) === null || _20 === void 0 ? void 0 : _20.expectedBusinessProof, 1200),
3832
- acceptanceGate: cleanText((_21 = issueClassProbePlanGate.metadata) === null || _21 === void 0 ? void 0 : _21.acceptanceGate, 120),
3833
- requiredArtifacts: cleanStringList((_22 = issueClassProbePlanGate.metadata) === null || _22 === void 0 ? void 0 : _22.requiredArtifacts, 20, 500),
3834
- falsePassBlockers: cleanStringList((_23 = issueClassProbePlanGate.metadata) === null || _23 === void 0 ? void 0 : _23.falsePassBlockers, 20, 500),
3835
- blockers: cleanStringList((_24 = issueClassProbePlanGate.metadata) === null || _24 === void 0 ? void 0 : _24.blockers, 20, 500)
6560
+ planId: cleanText((_428 = issueClassProbePlanGate.metadata) === null || _428 === void 0 ? void 0 : _428.planId, 180),
6561
+ issueClass: cleanText((_429 = issueClassProbePlanGate.metadata) === null || _429 === void 0 ? void 0 : _429.issueClass, 120),
6562
+ diagnosisValid: ((_430 = issueClassProbePlanGate.metadata) === null || _430 === void 0 ? void 0 : _430.diagnosisValid) === true,
6563
+ issueClassProbePlanReady: ((_431 = issueClassProbePlanGate.metadata) === null || _431 === void 0 ? void 0 : _431.issueClassProbePlanReady) === true,
6564
+ activeRoute: cleanText((_432 = issueClassProbePlanGate.metadata) === null || _432 === void 0 ? void 0 : _432.activeRoute, 500),
6565
+ action: cleanText((_433 = issueClassProbePlanGate.metadata) === null || _433 === void 0 ? void 0 : _433.action, 1000),
6566
+ expectedBusinessProof: cleanText((_434 = issueClassProbePlanGate.metadata) === null || _434 === void 0 ? void 0 : _434.expectedBusinessProof, 1200),
6567
+ acceptanceGate: cleanText((_435 = issueClassProbePlanGate.metadata) === null || _435 === void 0 ? void 0 : _435.acceptanceGate, 120),
6568
+ requiredArtifacts: cleanStringList((_436 = issueClassProbePlanGate.metadata) === null || _436 === void 0 ? void 0 : _436.requiredArtifacts, 20, 500),
6569
+ falsePassBlockers: cleanStringList((_437 = issueClassProbePlanGate.metadata) === null || _437 === void 0 ? void 0 : _437.falsePassBlockers, 20, 500),
6570
+ blockers: cleanStringList((_438 = issueClassProbePlanGate.metadata) === null || _438 === void 0 ? void 0 : _438.blockers, 20, 500)
3836
6571
  } : undefined,
3837
6572
  businessProofReadiness: Object.keys(businessProofReadiness).length ? {
3838
6573
  ready: businessProofReadiness.ready === true,
@@ -3842,52 +6577,80 @@ function buildSupportAIRunFromEvidence(input) {
3842
6577
  } : undefined,
3843
6578
  nextActionContract: nextActionContractGate ? {
3844
6579
  status: nextActionContractGate.status,
3845
- action: cleanText((_25 = nextActionContractGate.metadata) === null || _25 === void 0 ? void 0 : _25.action, 160),
3846
- primaryCommand: cleanText((_26 = nextActionContractGate.metadata) === null || _26 === void 0 ? void 0 : _26.primaryCommand, 240),
3847
- safeToAutoRun: ((_27 = nextActionContractGate.metadata) === null || _27 === void 0 ? void 0 : _27.safeToAutoRun) === true,
3848
- canRunWithoutCodexMonitor: ((_28 = nextActionContractGate.metadata) === null || _28 === void 0 ? void 0 : _28.canRunWithoutCodexMonitor) === true,
3849
- codexFallbackRequired: ((_29 = nextActionContractGate.metadata) === null || _29 === void 0 ? void 0 : _29.codexFallbackRequired) === true,
3850
- requiresHumanApproval: ((_30 = nextActionContractGate.metadata) === null || _30 === void 0 ? void 0 : _30.requiresHumanApproval) === true,
3851
- rootCauseFirstSatisfied: ((_31 = nextActionContractGate.metadata) === null || _31 === void 0 ? void 0 : _31.rootCauseFirstSatisfied) === true,
3852
- hotfixCommitRequired: ((_32 = nextActionContractGate.metadata) === null || _32 === void 0 ? void 0 : _32.hotfixCommitRequired) === true,
3853
- liveHotfixBlockedUntilCommit: ((_33 = nextActionContractGate.metadata) === null || _33 === void 0 ? void 0 : _33.liveHotfixBlockedUntilCommit) === true,
3854
- failureClass: cleanText((_34 = nextActionContractGate.metadata) === null || _34 === void 0 ? void 0 : _34.failureClass, 120),
3855
- evidenceFreshnessStatus: cleanText((_35 = nextActionContractGate.metadata) === null || _35 === void 0 ? void 0 : _35.evidenceFreshnessStatus, 120),
3856
- sameFailureCount: Number(((_36 = nextActionContractGate.metadata) === null || _36 === void 0 ? void 0 : _36.sameFailureCount) || 0),
3857
- blockers: cleanStringList((_37 = nextActionContractGate.metadata) === null || _37 === void 0 ? void 0 : _37.blockers, 20, 500)
6580
+ action: cleanText((_439 = nextActionContractGate.metadata) === null || _439 === void 0 ? void 0 : _439.action, 160),
6581
+ primaryCommand: cleanText((_440 = nextActionContractGate.metadata) === null || _440 === void 0 ? void 0 : _440.primaryCommand, 240),
6582
+ safeToAutoRun: ((_441 = nextActionContractGate.metadata) === null || _441 === void 0 ? void 0 : _441.safeToAutoRun) === true,
6583
+ canRunWithoutCodexMonitor: ((_442 = nextActionContractGate.metadata) === null || _442 === void 0 ? void 0 : _442.canRunWithoutCodexMonitor) === true,
6584
+ codexFallbackRequired: ((_443 = nextActionContractGate.metadata) === null || _443 === void 0 ? void 0 : _443.codexFallbackRequired) === true,
6585
+ requiresHumanApproval: ((_444 = nextActionContractGate.metadata) === null || _444 === void 0 ? void 0 : _444.requiresHumanApproval) === true,
6586
+ rootCauseFirstSatisfied: ((_445 = nextActionContractGate.metadata) === null || _445 === void 0 ? void 0 : _445.rootCauseFirstSatisfied) === true,
6587
+ proofMatrixReady: ((_446 = nextActionContractGate.metadata) === null || _446 === void 0 ? void 0 : _446.proofMatrixReady) === true,
6588
+ proofMatrixId: cleanText((_447 = nextActionContractGate.metadata) === null || _447 === void 0 ? void 0 : _447.proofMatrixId, 200),
6589
+ ownerScopedRepairContractReady: ((_448 = nextActionContractGate.metadata) === null || _448 === void 0 ? void 0 : _448.ownerScopedRepairContractReady) === true,
6590
+ ownerScopedRepairContractId: cleanText((_449 = nextActionContractGate.metadata) === null || _449 === void 0 ? void 0 : _449.ownerScopedRepairContractId, 200),
6591
+ hotfixCommitRequired: ((_450 = nextActionContractGate.metadata) === null || _450 === void 0 ? void 0 : _450.hotfixCommitRequired) === true,
6592
+ liveHotfixBlockedUntilCommit: ((_451 = nextActionContractGate.metadata) === null || _451 === void 0 ? void 0 : _451.liveHotfixBlockedUntilCommit) === true,
6593
+ evidenceProbeContractReady: ((_452 = nextActionContractGate.metadata) === null || _452 === void 0 ? void 0 : _452.evidenceProbeContractReady) === true,
6594
+ evidenceProbeContractId: cleanText((_453 = nextActionContractGate.metadata) === null || _453 === void 0 ? void 0 : _453.evidenceProbeContractId, 200),
6595
+ autonomyMode: cleanText((_454 = nextActionContractGate.metadata) === null || _454 === void 0 ? void 0 : _454.autonomyMode, 120),
6596
+ autonomyCanAutoDispatch: ((_455 = nextActionContractGate.metadata) === null || _455 === void 0 ? void 0 : _455.autonomyCanAutoDispatch) === true,
6597
+ autonomyReason: cleanText((_456 = nextActionContractGate.metadata) === null || _456 === void 0 ? void 0 : _456.autonomyReason, 1000),
6598
+ autonomyExpectedValueScore: Number(((_457 = nextActionContractGate.metadata) === null || _457 === void 0 ? void 0 : _457.autonomyExpectedValueScore) || 0),
6599
+ autonomyExpectedValuePositive: ((_458 = nextActionContractGate.metadata) === null || _458 === void 0 ? void 0 : _458.autonomyExpectedValuePositive) === true,
6600
+ autonomyProjectedSpendUsd: Number(((_459 = nextActionContractGate.metadata) === null || _459 === void 0 ? void 0 : _459.autonomyProjectedSpendUsd) || 0),
6601
+ failureClass: cleanText((_460 = nextActionContractGate.metadata) === null || _460 === void 0 ? void 0 : _460.failureClass, 120),
6602
+ evidenceFreshnessStatus: cleanText((_461 = nextActionContractGate.metadata) === null || _461 === void 0 ? void 0 : _461.evidenceFreshnessStatus, 120),
6603
+ sameFailureCount: Number(((_462 = nextActionContractGate.metadata) === null || _462 === void 0 ? void 0 : _462.sameFailureCount) || 0),
6604
+ blockers: cleanStringList((_463 = nextActionContractGate.metadata) === null || _463 === void 0 ? void 0 : _463.blockers, 20, 500)
3858
6605
  } : undefined,
3859
6606
  managerExecutionPacket: managerExecutionPacketGate ? {
3860
- status: cleanText((_38 = managerExecutionPacketGate.metadata) === null || _38 === void 0 ? void 0 : _38.status, 120),
6607
+ status: cleanText((_464 = managerExecutionPacketGate.metadata) === null || _464 === void 0 ? void 0 : _464.status, 120),
3861
6608
  gateStatus: managerExecutionPacketGate.status,
3862
- action: cleanText((_39 = managerExecutionPacketGate.metadata) === null || _39 === void 0 ? void 0 : _39.action, 160),
3863
- primaryCommand: cleanText((_40 = managerExecutionPacketGate.metadata) === null || _40 === void 0 ? void 0 : _40.primaryCommand, 240),
3864
- executeNow: ((_41 = managerExecutionPacketGate.metadata) === null || _41 === void 0 ? void 0 : _41.executeNow) === true,
3865
- canRunWithoutCodexMonitor: ((_42 = managerExecutionPacketGate.metadata) === null || _42 === void 0 ? void 0 : _42.canRunWithoutCodexMonitor) === true,
3866
- codexFallbackRequired: ((_43 = managerExecutionPacketGate.metadata) === null || _43 === void 0 ? void 0 : _43.codexFallbackRequired) === true,
3867
- retryScope: cleanText((_44 = managerExecutionPacketGate.metadata) === null || _44 === void 0 ? void 0 : _44.retryScope, 120),
3868
- maxAttemptsBeforeFreshEvidence: Number(((_45 = managerExecutionPacketGate.metadata) === null || _45 === void 0 ? void 0 : _45.maxAttemptsBeforeFreshEvidence) || 0),
3869
- costRisk: cleanText((_46 = managerExecutionPacketGate.metadata) === null || _46 === void 0 ? void 0 : _46.costRisk, 120),
3870
- validationStatus: cleanText((_48 = (_47 = managerExecutionPacketGate.metadata) === null || _47 === void 0 ? void 0 : _47.validation) === null || _48 === void 0 ? void 0 : _48.status, 120),
3871
- validationValid: ((_50 = (_49 = managerExecutionPacketGate.metadata) === null || _49 === void 0 ? void 0 : _49.validation) === null || _50 === void 0 ? void 0 : _50.valid) === true,
3872
- proofRequiredBeforeContinuation: cleanStringList((_51 = managerExecutionPacketGate.metadata) === null || _51 === void 0 ? void 0 : _51.proofRequiredBeforeContinuation, 20, 500),
3873
- stopConditions: cleanStringList((_52 = managerExecutionPacketGate.metadata) === null || _52 === void 0 ? void 0 : _52.stopConditions, 20, 500),
3874
- forbiddenActions: cleanStringList((_53 = managerExecutionPacketGate.metadata) === null || _53 === void 0 ? void 0 : _53.forbiddenActions, 20, 500),
3875
- ownerFiles: cleanStringList((_54 = managerExecutionPacketGate.metadata) === null || _54 === void 0 ? void 0 : _54.ownerFiles, 40, 500),
3876
- blockers: cleanStringList((_55 = managerExecutionPacketGate.metadata) === null || _55 === void 0 ? void 0 : _55.blockers, 20, 500)
6609
+ action: cleanText((_465 = managerExecutionPacketGate.metadata) === null || _465 === void 0 ? void 0 : _465.action, 160),
6610
+ primaryCommand: cleanText((_466 = managerExecutionPacketGate.metadata) === null || _466 === void 0 ? void 0 : _466.primaryCommand, 240),
6611
+ executeNow: ((_467 = managerExecutionPacketGate.metadata) === null || _467 === void 0 ? void 0 : _467.executeNow) === true,
6612
+ canRunWithoutCodexMonitor: ((_468 = managerExecutionPacketGate.metadata) === null || _468 === void 0 ? void 0 : _468.canRunWithoutCodexMonitor) === true,
6613
+ codexFallbackRequired: ((_469 = managerExecutionPacketGate.metadata) === null || _469 === void 0 ? void 0 : _469.codexFallbackRequired) === true,
6614
+ retryScope: cleanText((_470 = managerExecutionPacketGate.metadata) === null || _470 === void 0 ? void 0 : _470.retryScope, 120),
6615
+ maxAttemptsBeforeFreshEvidence: Number(((_471 = managerExecutionPacketGate.metadata) === null || _471 === void 0 ? void 0 : _471.maxAttemptsBeforeFreshEvidence) || 0),
6616
+ costRisk: cleanText((_472 = managerExecutionPacketGate.metadata) === null || _472 === void 0 ? void 0 : _472.costRisk, 120),
6617
+ validationStatus: cleanText((_474 = (_473 = managerExecutionPacketGate.metadata) === null || _473 === void 0 ? void 0 : _473.validation) === null || _474 === void 0 ? void 0 : _474.status, 120),
6618
+ validationValid: ((_476 = (_475 = managerExecutionPacketGate.metadata) === null || _475 === void 0 ? void 0 : _475.validation) === null || _476 === void 0 ? void 0 : _476.valid) === true,
6619
+ proofRequiredBeforeContinuation: cleanStringList((_477 = managerExecutionPacketGate.metadata) === null || _477 === void 0 ? void 0 : _477.proofRequiredBeforeContinuation, 20, 500),
6620
+ stopConditions: cleanStringList((_478 = managerExecutionPacketGate.metadata) === null || _478 === void 0 ? void 0 : _478.stopConditions, 20, 500),
6621
+ forbiddenActions: cleanStringList((_479 = managerExecutionPacketGate.metadata) === null || _479 === void 0 ? void 0 : _479.forbiddenActions, 20, 500),
6622
+ ownerFiles: cleanStringList((_480 = managerExecutionPacketGate.metadata) === null || _480 === void 0 ? void 0 : _480.ownerFiles, 40, 500),
6623
+ proofResetContract: ((_481 = managerExecutionPacketGate.metadata) === null || _481 === void 0 ? void 0 : _481.proofResetContract) ? {
6624
+ contractId: cleanText(managerExecutionPacketGate.metadata.proofResetContract.contractId, 200),
6625
+ status: cleanText(managerExecutionPacketGate.metadata.proofResetContract.status, 120),
6626
+ action: cleanText(managerExecutionPacketGate.metadata.proofResetContract.action, 160),
6627
+ retryScope: cleanText(managerExecutionPacketGate.metadata.proofResetContract.retryScope, 120),
6628
+ maxAttemptsBeforeFreshEvidence: Number(managerExecutionPacketGate.metadata.proofResetContract.maxAttemptsBeforeFreshEvidence || 0),
6629
+ startingFailureClass: cleanText(managerExecutionPacketGate.metadata.proofResetContract.startingFailureClass, 120),
6630
+ startingBlockerFingerprint: cleanText(managerExecutionPacketGate.metadata.proofResetContract.startingBlockerFingerprint, 200),
6631
+ startingEvidenceHash: cleanText(managerExecutionPacketGate.metadata.proofResetContract.startingEvidenceHash, 200),
6632
+ requiredResetEvidence: cleanStringList(managerExecutionPacketGate.metadata.proofResetContract.requiredResetEvidence, 40, 500),
6633
+ proofRequiredBeforeContinuation: cleanStringList(managerExecutionPacketGate.metadata.proofResetContract.proofRequiredBeforeContinuation, 40, 500),
6634
+ stopConditions: cleanStringList(managerExecutionPacketGate.metadata.proofResetContract.stopConditions, 40, 500),
6635
+ canRunWithoutCodexMonitor: managerExecutionPacketGate.metadata.proofResetContract.canRunWithoutCodexMonitor === true,
6636
+ sourceNextActionContractId: cleanText(managerExecutionPacketGate.metadata.proofResetContract.sourceNextActionContractId, 200),
6637
+ createdAt: cleanText(managerExecutionPacketGate.metadata.proofResetContract.createdAt, 120)
6638
+ } : undefined,
6639
+ blockers: cleanStringList((_482 = managerExecutionPacketGate.metadata) === null || _482 === void 0 ? void 0 : _482.blockers, 20, 500)
3877
6640
  } : undefined,
3878
6641
  managerRecoveryExecutionProof: recoveryExecutionProofGate ? {
3879
- status: cleanText((_56 = recoveryExecutionProofGate.metadata) === null || _56 === void 0 ? void 0 : _56.status, 120),
6642
+ status: cleanText((_483 = recoveryExecutionProofGate.metadata) === null || _483 === void 0 ? void 0 : _483.status, 120),
3880
6643
  gateStatus: recoveryExecutionProofGate.status,
3881
- canContinueRun: ((_57 = recoveryExecutionProofGate.metadata) === null || _57 === void 0 ? void 0 : _57.canContinueRun) === true,
3882
- canRunProductRepair: ((_58 = recoveryExecutionProofGate.metadata) === null || _58 === void 0 ? void 0 : _58.canRunProductRepair) === true,
3883
- canRunExpensiveModel: ((_59 = recoveryExecutionProofGate.metadata) === null || _59 === void 0 ? void 0 : _59.canRunExpensiveModel) === true,
3884
- canResetLoopBudget: ((_60 = recoveryExecutionProofGate.metadata) === null || _60 === void 0 ? void 0 : _60.canResetLoopBudget) === true,
3885
- newEvidence: ((_61 = recoveryExecutionProofGate.metadata) === null || _61 === void 0 ? void 0 : _61.newEvidence) === true,
3886
- materialEvidence: ((_62 = recoveryExecutionProofGate.metadata) === null || _62 === void 0 ? void 0 : _62.materialEvidence) === true,
3887
- evidenceStrength: cleanText((_63 = recoveryExecutionProofGate.metadata) === null || _63 === void 0 ? void 0 : _63.evidenceStrength, 120),
3888
- nextAllowedAction: cleanText((_64 = recoveryExecutionProofGate.metadata) === null || _64 === void 0 ? void 0 : _64.nextAllowedAction, 180),
3889
- missingEvidence: cleanStringList((_65 = recoveryExecutionProofGate.metadata) === null || _65 === void 0 ? void 0 : _65.missingEvidence, 20, 500),
3890
- blockers: cleanStringList((_66 = recoveryExecutionProofGate.metadata) === null || _66 === void 0 ? void 0 : _66.blockers, 20, 500)
6644
+ canContinueRun: ((_484 = recoveryExecutionProofGate.metadata) === null || _484 === void 0 ? void 0 : _484.canContinueRun) === true,
6645
+ canRunProductRepair: ((_485 = recoveryExecutionProofGate.metadata) === null || _485 === void 0 ? void 0 : _485.canRunProductRepair) === true,
6646
+ canRunExpensiveModel: ((_486 = recoveryExecutionProofGate.metadata) === null || _486 === void 0 ? void 0 : _486.canRunExpensiveModel) === true,
6647
+ canResetLoopBudget: ((_487 = recoveryExecutionProofGate.metadata) === null || _487 === void 0 ? void 0 : _487.canResetLoopBudget) === true,
6648
+ newEvidence: ((_488 = recoveryExecutionProofGate.metadata) === null || _488 === void 0 ? void 0 : _488.newEvidence) === true,
6649
+ materialEvidence: ((_489 = recoveryExecutionProofGate.metadata) === null || _489 === void 0 ? void 0 : _489.materialEvidence) === true,
6650
+ evidenceStrength: cleanText((_490 = recoveryExecutionProofGate.metadata) === null || _490 === void 0 ? void 0 : _490.evidenceStrength, 120),
6651
+ nextAllowedAction: cleanText((_491 = recoveryExecutionProofGate.metadata) === null || _491 === void 0 ? void 0 : _491.nextAllowedAction, 180),
6652
+ missingEvidence: cleanStringList((_492 = recoveryExecutionProofGate.metadata) === null || _492 === void 0 ? void 0 : _492.missingEvidence, 20, 500),
6653
+ blockers: cleanStringList((_493 = recoveryExecutionProofGate.metadata) === null || _493 === void 0 ? void 0 : _493.blockers, 20, 500)
3891
6654
  } : undefined,
3892
6655
  customerReplyPolicy: Object.keys(customerReplyPolicy).length ? {
3893
6656
  action: cleanText(customerReplyPolicy.action, 120),
@@ -3895,31 +6658,57 @@ function buildSupportAIRunFromEvidence(input) {
3895
6658
  canDraftCustomerReply: customerReplyPolicy.canDraftCustomerReply === true || customerReplyPolicy.can_draft_customer_reply === true,
3896
6659
  canSendCustomerReply: customerReplyPolicy.canSendCustomerReply === true || customerReplyPolicy.can_send_customer_reply === true,
3897
6660
  reason: cleanText(customerReplyPolicy.reason, 1000),
3898
- reviewType: cleanText(((_67 = customerReplyPolicy.humanReviewPacket) === null || _67 === void 0 ? void 0 : _67.reviewType)
3899
- || ((_68 = customerReplyPolicy.human_review_packet) === null || _68 === void 0 ? void 0 : _68.review_type)
3900
- || ((_69 = customerReplyPolicy.human_review_packet) === null || _69 === void 0 ? void 0 : _69.reviewType), 160),
3901
- primaryAction: cleanText(((_70 = customerReplyPolicy.humanReviewPacket) === null || _70 === void 0 ? void 0 : _70.primaryAction)
3902
- || ((_71 = customerReplyPolicy.human_review_packet) === null || _71 === void 0 ? void 0 : _71.primary_action)
3903
- || ((_72 = customerReplyPolicy.human_review_packet) === null || _72 === void 0 ? void 0 : _72.primaryAction), 160),
6661
+ reviewType: cleanText(((_494 = customerReplyPolicy.humanReviewPacket) === null || _494 === void 0 ? void 0 : _494.reviewType)
6662
+ || ((_495 = customerReplyPolicy.human_review_packet) === null || _495 === void 0 ? void 0 : _495.review_type)
6663
+ || ((_496 = customerReplyPolicy.human_review_packet) === null || _496 === void 0 ? void 0 : _496.reviewType), 160),
6664
+ primaryAction: cleanText(((_497 = customerReplyPolicy.humanReviewPacket) === null || _497 === void 0 ? void 0 : _497.primaryAction)
6665
+ || ((_498 = customerReplyPolicy.human_review_packet) === null || _498 === void 0 ? void 0 : _498.primary_action)
6666
+ || ((_499 = customerReplyPolicy.human_review_packet) === null || _499 === void 0 ? void 0 : _499.primaryAction), 160),
3904
6667
  clarificationContract: customerReplyPolicy.clarificationContract || customerReplyPolicy.clarification_contract ? {
3905
- status: cleanText(((_73 = customerReplyPolicy.clarificationContract) === null || _73 === void 0 ? void 0 : _73.status) || ((_74 = customerReplyPolicy.clarification_contract) === null || _74 === void 0 ? void 0 : _74.status), 120),
3906
- missingField: cleanText(((_75 = customerReplyPolicy.clarificationContract) === null || _75 === void 0 ? void 0 : _75.missingField) || ((_76 = customerReplyPolicy.clarification_contract) === null || _76 === void 0 ? void 0 : _76.missing_field), 120),
3907
- oneQuestionOnly: ((_77 = customerReplyPolicy.clarificationContract) === null || _77 === void 0 ? void 0 : _77.oneQuestionOnly) === true || ((_78 = customerReplyPolicy.clarification_contract) === null || _78 === void 0 ? void 0 : _78.one_question_only) === true,
3908
- parksTicketUntilCustomerReply: ((_79 = customerReplyPolicy.clarificationContract) === null || _79 === void 0 ? void 0 : _79.parksTicketUntilCustomerReply) === true || ((_80 = customerReplyPolicy.clarification_contract) === null || _80 === void 0 ? void 0 : _80.parks_ticket_until_customer_reply) === true
6668
+ status: cleanText(((_500 = customerReplyPolicy.clarificationContract) === null || _500 === void 0 ? void 0 : _500.status) || ((_501 = customerReplyPolicy.clarification_contract) === null || _501 === void 0 ? void 0 : _501.status), 120),
6669
+ missingField: cleanText(((_502 = customerReplyPolicy.clarificationContract) === null || _502 === void 0 ? void 0 : _502.missingField) || ((_503 = customerReplyPolicy.clarification_contract) === null || _503 === void 0 ? void 0 : _503.missing_field), 120),
6670
+ oneQuestionOnly: ((_504 = customerReplyPolicy.clarificationContract) === null || _504 === void 0 ? void 0 : _504.oneQuestionOnly) === true || ((_505 = customerReplyPolicy.clarification_contract) === null || _505 === void 0 ? void 0 : _505.one_question_only) === true,
6671
+ parksTicketUntilCustomerReply: ((_506 = customerReplyPolicy.clarificationContract) === null || _506 === void 0 ? void 0 : _506.parksTicketUntilCustomerReply) === true || ((_507 = customerReplyPolicy.clarification_contract) === null || _507 === void 0 ? void 0 : _507.parks_ticket_until_customer_reply) === true
3909
6672
  } : undefined
3910
6673
  } : undefined,
3911
6674
  customerReplyReadiness: customerReplyReadinessGate ? {
3912
- status: cleanText((_81 = customerReplyReadinessGate.metadata) === null || _81 === void 0 ? void 0 : _81.status, 120),
6675
+ status: cleanText((_508 = customerReplyReadinessGate.metadata) === null || _508 === void 0 ? void 0 : _508.status, 120),
3913
6676
  gateStatus: customerReplyReadinessGate.status,
3914
- primaryCommand: cleanText((_82 = customerReplyReadinessGate.metadata) === null || _82 === void 0 ? void 0 : _82.primaryCommand, 180),
3915
- policyAction: cleanText((_83 = customerReplyReadinessGate.metadata) === null || _83 === void 0 ? void 0 : _83.policyAction, 120),
3916
- canDraftCustomerReply: ((_84 = customerReplyReadinessGate.metadata) === null || _84 === void 0 ? void 0 : _84.canDraftCustomerReply) === true,
3917
- canSendCustomerReply: ((_85 = customerReplyReadinessGate.metadata) === null || _85 === void 0 ? void 0 : _85.canSendCustomerReply) === true,
3918
- requiresHumanApproval: ((_86 = customerReplyReadinessGate.metadata) === null || _86 === void 0 ? void 0 : _86.requiresHumanApproval) === true,
3919
- proofBacked: ((_87 = customerReplyReadinessGate.metadata) === null || _87 === void 0 ? void 0 : _87.proofBacked) === true,
3920
- businessProofReady: ((_88 = customerReplyReadinessGate.metadata) === null || _88 === void 0 ? void 0 : _88.businessProofReady) === true,
3921
- releaseReady: ((_89 = customerReplyReadinessGate.metadata) === null || _89 === void 0 ? void 0 : _89.releaseReady) === true,
3922
- blockers: cleanStringList((_90 = customerReplyReadinessGate.metadata) === null || _90 === void 0 ? void 0 : _90.blockers, 20, 500)
6677
+ primaryCommand: cleanText((_509 = customerReplyReadinessGate.metadata) === null || _509 === void 0 ? void 0 : _509.primaryCommand, 180),
6678
+ policyAction: cleanText((_510 = customerReplyReadinessGate.metadata) === null || _510 === void 0 ? void 0 : _510.policyAction, 120),
6679
+ canDraftCustomerReply: ((_511 = customerReplyReadinessGate.metadata) === null || _511 === void 0 ? void 0 : _511.canDraftCustomerReply) === true,
6680
+ canSendCustomerReply: ((_512 = customerReplyReadinessGate.metadata) === null || _512 === void 0 ? void 0 : _512.canSendCustomerReply) === true,
6681
+ requiresHumanApproval: ((_513 = customerReplyReadinessGate.metadata) === null || _513 === void 0 ? void 0 : _513.requiresHumanApproval) === true,
6682
+ proofBacked: ((_514 = customerReplyReadinessGate.metadata) === null || _514 === void 0 ? void 0 : _514.proofBacked) === true,
6683
+ businessProofReady: ((_515 = customerReplyReadinessGate.metadata) === null || _515 === void 0 ? void 0 : _515.businessProofReady) === true,
6684
+ releaseReady: ((_516 = customerReplyReadinessGate.metadata) === null || _516 === void 0 ? void 0 : _516.releaseReady) === true,
6685
+ blockers: cleanStringList((_517 = customerReplyReadinessGate.metadata) === null || _517 === void 0 ? void 0 : _517.blockers, 20, 500)
6686
+ } : undefined,
6687
+ customerReplySend: customerReplySendGate ? {
6688
+ status: cleanText((_518 = customerReplySendGate.metadata) === null || _518 === void 0 ? void 0 : _518.status, 160),
6689
+ gateStatus: customerReplySendGate.status,
6690
+ contractId: cleanText((_519 = customerReplySendGate.metadata) === null || _519 === void 0 ? void 0 : _519.contractId, 180),
6691
+ guardStatus: cleanText((_520 = customerReplySendGate.metadata) === null || _520 === void 0 ? void 0 : _520.guardStatus, 160),
6692
+ allowed: ((_521 = customerReplySendGate.metadata) === null || _521 === void 0 ? void 0 : _521.allowed) === true,
6693
+ sentAfterManualApproval: ((_522 = customerReplySendGate.metadata) === null || _522 === void 0 ? void 0 : _522.sentAfterManualApproval) === true,
6694
+ directSendAllowed: ((_523 = customerReplySendGate.metadata) === null || _523 === void 0 ? void 0 : _523.directSendAllowed) === true,
6695
+ manualSendAfterReviewAllowed: ((_524 = customerReplySendGate.metadata) === null || _524 === void 0 ? void 0 : _524.manualSendAfterReviewAllowed) === true,
6696
+ requiresHumanApproval: ((_525 = customerReplySendGate.metadata) === null || _525 === void 0 ? void 0 : _525.requiresHumanApproval) === true,
6697
+ proofBacked: ((_526 = customerReplySendGate.metadata) === null || _526 === void 0 ? void 0 : _526.proofBacked) === true,
6698
+ businessProofReady: ((_527 = customerReplySendGate.metadata) === null || _527 === void 0 ? void 0 : _527.businessProofReady) === true,
6699
+ releaseReady: ((_528 = customerReplySendGate.metadata) === null || _528 === void 0 ? void 0 : _528.releaseReady) === true,
6700
+ diagnosisReady: ((_529 = customerReplySendGate.metadata) === null || _529 === void 0 ? void 0 : _529.diagnosisReady) === true,
6701
+ issueClassProbePlanReady: ((_530 = customerReplySendGate.metadata) === null || _530 === void 0 ? void 0 : _530.issueClassProbePlanReady) === true,
6702
+ confidenceLevel: cleanText((_531 = customerReplySendGate.metadata) === null || _531 === void 0 ? void 0 : _531.confidenceLevel, 120),
6703
+ nextAction: cleanText((_532 = customerReplySendGate.metadata) === null || _532 === void 0 ? void 0 : _532.nextAction, 160),
6704
+ pullRequestUrl: cleanText((_533 = customerReplySendGate.metadata) === null || _533 === void 0 ? void 0 : _533.pullRequestUrl, 500),
6705
+ jobId: cleanText((_534 = customerReplySendGate.metadata) === null || _534 === void 0 ? void 0 : _534.jobId, 180),
6706
+ readinessContractId: cleanText((_535 = customerReplySendGate.metadata) === null || _535 === void 0 ? void 0 : _535.readinessContractId, 180),
6707
+ readinessStatus: cleanText((_536 = customerReplySendGate.metadata) === null || _536 === void 0 ? void 0 : _536.readinessStatus, 160),
6708
+ messageHash: cleanText((_537 = customerReplySendGate.metadata) === null || _537 === void 0 ? void 0 : _537.messageHash, 180),
6709
+ recipients: cleanStringList((_538 = customerReplySendGate.metadata) === null || _538 === void 0 ? void 0 : _538.recipients, 20, 240),
6710
+ requiredEvidence: cleanStringList((_539 = customerReplySendGate.metadata) === null || _539 === void 0 ? void 0 : _539.requiredEvidence, 40, 500),
6711
+ blockers: cleanStringList((_540 = customerReplySendGate.metadata) === null || _540 === void 0 ? void 0 : _540.blockers, 40, 500)
3923
6712
  } : undefined
3924
6713
  }
3925
6714
  });