@resolveio/server-lib 22.3.185 → 22.3.187

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "22.3.185",
3
+ "version": "22.3.187",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",
@@ -1425,6 +1425,7 @@ function buildSupportQaEvidence(input) {
1425
1425
  var ticket = input.ticket || {};
1426
1426
  var qaCursor = plainObject(job.supportQaValidationCursor || job.support_qa_validation_cursor);
1427
1427
  var autonomousDecision = plainObject(job.supportV5AutonomousDecision || job.support_v5_autonomous_decision);
1428
+ var preflightGate = supportPreflightGateObject(ticket, job, __assign(__assign({}, plainObject(input.qaEvidence)), { supportV5AutonomousDecision: autonomousDecision }));
1428
1429
  var businessProofReadiness = plainObject(autonomousDecision.businessProofReadiness
1429
1430
  || autonomousDecision.business_proof_readiness
1430
1431
  || job.businessProofReadiness
@@ -1453,8 +1454,141 @@ function buildSupportQaEvidence(input) {
1453
1454
  else if (Object.keys(humanReviewPacket).length) {
1454
1455
  evidence.customerReplyPolicy = { humanReviewPacket: humanReviewPacket };
1455
1456
  }
1457
+ if (Object.keys(preflightGate).length) {
1458
+ evidence.supportV5PreflightGate = preflightGate;
1459
+ applySupportPreflightGateToQaEvidence(evidence, preflightGate);
1460
+ }
1456
1461
  return evidence;
1457
1462
  }
1463
+ function supportPreflightGateObject(ticket, job, evidence) {
1464
+ var _a, _b;
1465
+ var autonomousDecision = plainObject(job.supportV5AutonomousDecision
1466
+ || job.support_v5_autonomous_decision
1467
+ || evidence.supportV5AutonomousDecision
1468
+ || evidence.support_v5_autonomous_decision
1469
+ || ticket.supportV5AutonomousDecision
1470
+ || ticket.support_v5_autonomous_decision);
1471
+ var ticketAutomation = plainObject(ticket.automation);
1472
+ var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
1473
+ return evidenceObject(job.supportV5PreflightGate, job.support_v5_preflight_gate, job.preflightGate, job.preflight_gate, evidence.supportV5PreflightGate, evidence.support_v5_preflight_gate, evidence.preflightGate, evidence.preflight_gate, autonomousDecision.preflightGate, autonomousDecision.preflight_gate, (_a = autonomousDecision.rootCauseReadiness) === null || _a === void 0 ? void 0 : _a.preflightGate, (_b = autonomousDecision.root_cause_readiness) === null || _b === void 0 ? void 0 : _b.preflight_gate, ticket.supportV5PreflightGate, ticket.support_v5_preflight_gate, ticketManager.supportV5PreflightGate, ticketManager.support_v5_preflight_gate, ticketManager.preflightGate, ticketManager.preflight_gate);
1474
+ }
1475
+ function supportPreflightStatus(value) {
1476
+ return cleanText(value, 120).toLowerCase();
1477
+ }
1478
+ function supportPreflightFailedChecks(preflightGate) {
1479
+ var failed = __spreadArray(__spreadArray([], __read(asArray(preflightGate.failedChecks || preflightGate.failed_checks)), false), __read(asArray(preflightGate.checks).filter(function (check) {
1480
+ var status = supportPreflightStatus(check.status || check.state || check.outcome);
1481
+ return /fail|failed|blocked|missing|error/.test(status);
1482
+ })), false);
1483
+ var seen = new Set();
1484
+ return failed.filter(function (check) {
1485
+ var key = "".concat(cleanText(check.name || check.check || check.key, 160), ":").concat(cleanText(check.summary || check.message || check.error || check.reason, 500));
1486
+ if (seen.has(key)) {
1487
+ return false;
1488
+ }
1489
+ seen.add(key);
1490
+ return true;
1491
+ });
1492
+ }
1493
+ function supportPreflightArtifactPaths(preflightGate, checks) {
1494
+ return Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(cleanStringList(preflightGate.artifactPaths || preflightGate.artifact_paths, 60, 500)), false), __read(checks.flatMap(function (check) { return cleanStringList(check.artifactPaths || check.artifact_paths || check.artifacts, 20, 500); })), false), __read(checks.map(function (check) { return cleanText(check.artifactPath || check.artifact_path || check.path || check.file, 500); }).filter(Boolean)), false))).slice(0, 80);
1495
+ }
1496
+ function supportPreflightCheckMessage(check) {
1497
+ return cleanText(check.summary || check.message || check.error || check.reason || check.status, 1000);
1498
+ }
1499
+ function applySupportPreflightGateToQaEvidence(evidence, preflightGate) {
1500
+ var _a;
1501
+ var status = supportPreflightStatus(preflightGate.status);
1502
+ var failureClass = supportPreflightStatus(preflightGate.failureClass || preflightGate.failure_class);
1503
+ var failedChecks = supportPreflightFailedChecks(preflightGate);
1504
+ var artifactPaths = supportPreflightArtifactPaths(preflightGate, failedChecks);
1505
+ var compileResult = plainObject(preflightGate.compileResult || preflightGate.compile_result);
1506
+ var compileFailed = status === 'compile_failed'
1507
+ || failureClass === 'compile'
1508
+ || cleanText(compileResult.failureClass || compileResult.failure_class, 120).toLowerCase() === 'compile'
1509
+ || failedChecks.some(function (check) {
1510
+ var name = supportPreflightStatus(check.name || check.check || check.key);
1511
+ var checkClass = supportPreflightStatus(check.failureClass || check.failure_class);
1512
+ return name === 'compile' || checkClass === 'compile';
1513
+ });
1514
+ if (compileFailed) {
1515
+ var compileCheck = Object.keys(compileResult).length ? compileResult : failedChecks[0] || {};
1516
+ evidence.compile = __assign(__assign({}, plainObject(evidence.compile || evidence.build || evidence.buildResult || evidence.build_result)), { status: cleanText(compileCheck.status || preflightGate.status || 'fail', 80) || 'fail', command: cleanText(compileCheck.command || preflightGate.command || preflightGate.nextCommand || preflightGate.next_command, 500), artifactPath: artifactPaths[0] || cleanText(compileCheck.artifactPath || compileCheck.artifact_path || compileCheck.path, 500), message: supportPreflightCheckMessage(compileCheck) || cleanText(preflightGate.reason || ((_a = preflightGate.blockers) === null || _a === void 0 ? void 0 : _a[0]) || 'Support compile preflight failed before browser QA.', 1000), metadata: {
1517
+ source: 'supportV5PreflightGate',
1518
+ preflightStatus: status,
1519
+ preflightEvidenceHash: cleanText(preflightGate.evidenceHash || preflightGate.evidence_hash, 200),
1520
+ nextCommand: cleanText(preflightGate.nextCommand || preflightGate.next_command, 180)
1521
+ } });
1522
+ return;
1523
+ }
1524
+ var blocksRepair = preflightGate.blocksProductRepair === true || preflightGate.blocks_product_repair === true || /infra_failed|blocked|missing/.test(status);
1525
+ var checks = failedChecks.length
1526
+ ? failedChecks
1527
+ : Object.keys(preflightGate).length && (blocksRepair || status === 'passed')
1528
+ ? [{
1529
+ name: 'support_preflight',
1530
+ status: status === 'passed' ? 'pass' : 'blocked',
1531
+ summary: cleanStringList(preflightGate.blockers, 4, 500).join('; ') || cleanText(preflightGate.reason || preflightGate.status, 1000),
1532
+ artifactPaths: artifactPaths
1533
+ }]
1534
+ : [];
1535
+ if (!checks.length) {
1536
+ return;
1537
+ }
1538
+ evidence.infraChecks = __spreadArray(__spreadArray([], __read(asArray(evidence.infraChecks)), false), __read(checks.map(function (check) { return ({
1539
+ name: cleanText(check.name || check.check || check.key, 160) || 'support_preflight',
1540
+ status: cleanText(check.status || check.state || check.outcome || (status === 'passed' ? 'pass' : 'blocked'), 80),
1541
+ message: supportPreflightCheckMessage(check) || cleanStringList(preflightGate.blockers, 3, 500).join('; '),
1542
+ path: cleanText(check.path || check.artifactPath || check.artifact_path, 500) || artifactPaths[0],
1543
+ metadata: {
1544
+ source: 'supportV5PreflightGate',
1545
+ preflightStatus: status,
1546
+ preflightFailureClass: failureClass,
1547
+ preflightEvidenceHash: cleanText(preflightGate.evidenceHash || preflightGate.evidence_hash, 200),
1548
+ nextCommand: cleanText(preflightGate.nextCommand || preflightGate.next_command, 180)
1549
+ }
1550
+ }); })), false);
1551
+ }
1552
+ function supportPreflightGateResult(preflightGate, now) {
1553
+ if (!preflightGate || !Object.keys(preflightGate).length) {
1554
+ return undefined;
1555
+ }
1556
+ var statusText = supportPreflightStatus(preflightGate.status);
1557
+ var ready = preflightGate.ready === true;
1558
+ var blocksProductRepair = preflightGate.blocksProductRepair === true || preflightGate.blocks_product_repair === true;
1559
+ var failedChecks = supportPreflightFailedChecks(preflightGate);
1560
+ var artifactPaths = supportPreflightArtifactPaths(preflightGate, failedChecks);
1561
+ var gateStatus = ready || statusText === 'passed'
1562
+ ? 'pass'
1563
+ : /compile_failed|infra_failed|fail|failed/.test(statusText)
1564
+ ? 'fail'
1565
+ : blocksProductRepair || /missing|blocked/.test(statusText)
1566
+ ? 'blocked'
1567
+ : 'warn';
1568
+ var blockers = cleanStringList(preflightGate.blockers, 20, 500);
1569
+ return {
1570
+ key: 'support_preflight_gate',
1571
+ label: 'Support preflight gate',
1572
+ status: gateStatus,
1573
+ reason: gateStatus === 'pass'
1574
+ ? 'Support deterministic preflight passed before product-code repair.'
1575
+ : cleanText(blockers.join('; ') || preflightGate.reason || "Support deterministic preflight is ".concat(statusText || 'not ready', " before product-code repair."), 1200),
1576
+ evidenceRefs: artifactPaths,
1577
+ recordedAt: isoNow(now || preflightGate.recordedAt || preflightGate.recorded_at),
1578
+ metadata: {
1579
+ ready: ready,
1580
+ required: preflightGate.required === true,
1581
+ status: statusText,
1582
+ failureClass: cleanText(preflightGate.failureClass || preflightGate.failure_class, 120),
1583
+ nextCommand: cleanText(preflightGate.nextCommand || preflightGate.next_command, 180),
1584
+ blocksProductRepair: blocksProductRepair,
1585
+ blocksModelRepair: preflightGate.blocksModelRepair === true || preflightGate.blocks_model_repair === true,
1586
+ failedChecks: failedChecks.map(function (check) { return cleanText(check.name || check.check || check.key, 160); }).filter(Boolean),
1587
+ requiredEvidence: cleanStringList(preflightGate.requiredEvidence || preflightGate.required_evidence, 20, 500),
1588
+ evidenceHash: cleanText(preflightGate.evidenceHash || preflightGate.evidence_hash, 200)
1589
+ }
1590
+ };
1591
+ }
1458
1592
  function supportBusinessProofReadinessGate(readiness, now) {
1459
1593
  if (!readiness || !Object.keys(readiness).length) {
1460
1594
  return undefined;
@@ -1582,7 +1716,7 @@ function supportNextActionContractRequired(ticket, job, evidence) {
1582
1716
  || !!ticketManager.last_watchdog_decision;
1583
1717
  }
1584
1718
  function supportNextActionContractMetadata(contract) {
1585
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
1719
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
1586
1720
  var decisionBasis = plainObject(contract.decisionBasis || contract.decision_basis);
1587
1721
  var costRisk = plainObject(contract.costRisk || contract.cost_risk);
1588
1722
  var source = {
@@ -1621,8 +1755,12 @@ function supportNextActionContractMetadata(contract) {
1621
1755
  blockerFingerprint: cleanText(decisionBasis.blockerFingerprint || decisionBasis.blocker_fingerprint, 200),
1622
1756
  evidenceHash: cleanText(decisionBasis.evidenceHash || decisionBasis.evidence_hash, 200),
1623
1757
  sameFailureCount: numberValue((_o = decisionBasis.sameFailureCount) !== null && _o !== void 0 ? _o : decisionBasis.same_failure_count),
1624
- hotfixCommitRequired: booleanFlag((_r = (_q = (_p = decisionBasis.hotfixCommitRequired) !== null && _p !== void 0 ? _p : decisionBasis.hotfix_commit_required) !== null && _q !== void 0 ? _q : contract.hotfixCommitRequired) !== null && _r !== void 0 ? _r : contract.hotfix_commit_required),
1625
- liveHotfixBlockedUntilCommit: booleanFlag((_u = (_t = (_s = decisionBasis.liveHotfixBlockedUntilCommit) !== null && _s !== void 0 ? _s : decisionBasis.live_hotfix_blocked_until_commit) !== null && _t !== void 0 ? _t : contract.liveHotfixBlockedUntilCommit) !== null && _u !== void 0 ? _u : contract.live_hotfix_blocked_until_commit)
1758
+ preflightReady: booleanFlag((_p = decisionBasis.preflightReady) !== null && _p !== void 0 ? _p : decisionBasis.preflight_ready),
1759
+ preflightStatus: cleanText(decisionBasis.preflightStatus || decisionBasis.preflight_status, 120),
1760
+ preflightFailureClass: cleanText(decisionBasis.preflightFailureClass || decisionBasis.preflight_failure_class, 120),
1761
+ preflightEvidenceHash: cleanText(decisionBasis.preflightEvidenceHash || decisionBasis.preflight_evidence_hash, 200),
1762
+ 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),
1763
+ 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)
1626
1764
  };
1627
1765
  return source;
1628
1766
  }
@@ -2147,6 +2285,72 @@ function aicoderWorkflowProofCheckpointGate(checkpoint, now) {
2147
2285
  }
2148
2286
  };
2149
2287
  }
2288
+ function aicoderNextActionContractObject(app, job, evidence) {
2289
+ var continuationDecision = plainObject(job.aicoderV6ContinuationDecision
2290
+ || job.aiCoderV6ContinuationDecision
2291
+ || job.aicoder_v6_continuation_decision
2292
+ || job.ai_coder_v6_continuation_decision
2293
+ || app.aicoderV6ContinuationDecision
2294
+ || app.aiCoderV6ContinuationDecision
2295
+ || app.aicoder_v6_continuation_decision
2296
+ || evidence.aicoderV6ContinuationDecision
2297
+ || evidence.aiCoderV6ContinuationDecision
2298
+ || evidence.aicoder_v6_continuation_decision);
2299
+ return evidenceObject(continuationDecision.nextActionContract, continuationDecision.next_action_contract, job.nextActionContract, job.next_action_contract, job.aicoderNextActionContract, job.aicoder_next_action_contract, job.aiCoderNextActionContract, job.ai_coder_next_action_contract, app.nextActionContract, app.next_action_contract, evidence.nextActionContract, evidence.next_action_contract, evidence.aicoderNextActionContract, evidence.aicoder_next_action_contract);
2300
+ }
2301
+ function aicoderNextActionContractGate(contract, now) {
2302
+ var _a, _b, _c, _d, _e;
2303
+ if (!contract || !Object.keys(contract).length) {
2304
+ return undefined;
2305
+ }
2306
+ var safeToAutoRun = booleanFlag((_a = contract.safeToAutoRun) !== null && _a !== void 0 ? _a : contract.safe_to_auto_run) === true;
2307
+ var requiresHumanApproval = booleanFlag((_b = contract.requiresHumanApproval) !== null && _b !== void 0 ? _b : contract.requires_human_approval) === true;
2308
+ var canRunWithoutCodexMonitor = booleanFlag((_c = contract.canRunWithoutCodexMonitor) !== null && _c !== void 0 ? _c : contract.can_run_without_codex_monitor) === true;
2309
+ var codexFallbackRequired = booleanFlag((_d = contract.codexFallbackRequired) !== null && _d !== void 0 ? _d : contract.codex_fallback_required) === true;
2310
+ var blockers = cleanStringList(contract.blockers, 40, 500);
2311
+ var primaryCommand = cleanText(contract.primaryCommand || contract.primary_command, 200);
2312
+ var gateStatus = canRunWithoutCodexMonitor
2313
+ ? 'pass'
2314
+ : requiresHumanApproval
2315
+ ? 'blocked'
2316
+ : codexFallbackRequired
2317
+ ? 'warn'
2318
+ : safeToAutoRun ? 'warn' : 'blocked';
2319
+ return {
2320
+ key: 'aicoder_next_action_contract',
2321
+ label: 'AICoder next action contract',
2322
+ status: gateStatus,
2323
+ reason: gateStatus === 'pass'
2324
+ ? "AICoder can run ".concat(primaryCommand || 'the next action', " without a Codex monitor.")
2325
+ : (blockers.join(' ') || cleanText(contract.codexFallbackReason || contract.codex_fallback_reason || contract.expectedStateTransition || contract.expected_state_transition, 1200) || 'AICoder next action is not safe to run unattended.'),
2326
+ evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(contract.preconditions)), false), __read(asArray(contract.successEvidence || contract.success_evidence)), false), __read(asArray(contract.stopConditions || contract.stop_conditions)), false), 40, 500),
2327
+ recordedAt: isoNow(now || contract.createdAt || contract.created_at || contract.recordedAt || contract.recorded_at),
2328
+ metadata: {
2329
+ contractId: cleanText(contract.contractId || contract.contract_id, 200),
2330
+ action: cleanText(contract.action, 120),
2331
+ label: cleanText(contract.label, 200),
2332
+ primaryCommand: primaryCommand,
2333
+ lane: cleanText(contract.lane, 120),
2334
+ stepType: cleanText(contract.stepType || contract.step_type, 120),
2335
+ safeToAutoRun: safeToAutoRun,
2336
+ requiresHumanApproval: requiresHumanApproval,
2337
+ canRunWithoutCodexMonitor: canRunWithoutCodexMonitor,
2338
+ codexFallbackRequired: codexFallbackRequired,
2339
+ codexFallbackReason: cleanText(contract.codexFallbackReason || contract.codex_fallback_reason, 1000),
2340
+ costRisk: cleanText(contract.costRisk || contract.cost_risk, 120),
2341
+ workflowFirstSatisfied: booleanFlag((_e = contract.workflowFirstSatisfied) !== null && _e !== void 0 ? _e : contract.workflow_first_satisfied) === true,
2342
+ decisionBasis: plainObject(contract.decisionBasis || contract.decision_basis),
2343
+ preconditions: cleanStringList(contract.preconditions, 40, 500),
2344
+ expectedStateTransition: cleanText(contract.expectedStateTransition || contract.expected_state_transition, 1000),
2345
+ successEvidence: cleanStringList(contract.successEvidence || contract.success_evidence, 40, 500),
2346
+ stopConditions: cleanStringList(contract.stopConditions || contract.stop_conditions, 40, 500),
2347
+ forbiddenActions: cleanStringList(contract.forbiddenActions || contract.forbidden_actions, 40, 500),
2348
+ nextCommands: cleanStringList(contract.nextCommands || contract.next_commands, 40, 240),
2349
+ blockers: blockers,
2350
+ ownerFiles: cleanStringList(contract.ownerFiles || contract.owner_files, 40, 500)
2351
+ }
2352
+ };
2353
+ }
2150
2354
  function adapterStatusPassed(value) {
2151
2355
  var normalized = cleanText(value, 120).toLowerCase();
2152
2356
  return !!normalized && /(pass|passed|success|succeeded|ok|done|complete|completed|ready|saved|published|deployed)/i.test(normalized);
@@ -2520,7 +2724,7 @@ function applyAssistantAnswerQualityGate(qa, decision, now) {
2520
2724
  }
2521
2725
  function buildSupportAIRunFromEvidence(input) {
2522
2726
  var e_28, _a, e_29, _b;
2523
- 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;
2727
+ 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;
2524
2728
  var ticket = input.ticket || {};
2525
2729
  var job = input.job || {};
2526
2730
  var evidence = buildSupportQaEvidence(input);
@@ -2532,8 +2736,8 @@ function buildSupportAIRunFromEvidence(input) {
2532
2736
  addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
2533
2737
  addSourceId(sourceIds, 'buildPlanId', job.buildPlanId || ticket.buildPlanId);
2534
2738
  try {
2535
- for (var _36 = __values(asArray(input.taskEvents)), _37 = _36.next(); !_37.done; _37 = _36.next()) {
2536
- var event_1 = _37.value;
2739
+ for (var _37 = __values(asArray(input.taskEvents)), _38 = _37.next(); !_38.done; _38 = _37.next()) {
2740
+ var event_1 = _38.value;
2537
2741
  pushEvent(events, {
2538
2742
  type: event_1.type === 'human_intervention' ? 'human_intervention' : 'log',
2539
2743
  category: cleanText(event_1.category || event_1.phase || event_1.type, 160),
@@ -2550,13 +2754,13 @@ function buildSupportAIRunFromEvidence(input) {
2550
2754
  catch (e_28_1) { e_28 = { error: e_28_1 }; }
2551
2755
  finally {
2552
2756
  try {
2553
- if (_37 && !_37.done && (_a = _36.return)) _a.call(_36);
2757
+ if (_38 && !_38.done && (_a = _37.return)) _a.call(_37);
2554
2758
  }
2555
2759
  finally { if (e_28) throw e_28.error; }
2556
2760
  }
2557
2761
  try {
2558
- for (var _38 = __values(asArray(input.aiJobs)), _39 = _38.next(); !_39.done; _39 = _38.next()) {
2559
- var aiJob = _39.value;
2762
+ for (var _39 = __values(asArray(input.aiJobs)), _40 = _39.next(); !_40.done; _40 = _39.next()) {
2763
+ var aiJob = _40.value;
2560
2764
  pushEvent(events, {
2561
2765
  type: aiJob.model ? 'model_call' : 'log',
2562
2766
  category: cleanText(aiJob.category || aiJob.phase || aiJob.runner, 160),
@@ -2574,7 +2778,7 @@ function buildSupportAIRunFromEvidence(input) {
2574
2778
  catch (e_29_1) { e_29 = { error: e_29_1 }; }
2575
2779
  finally {
2576
2780
  try {
2577
- if (_39 && !_39.done && (_b = _38.return)) _b.call(_38);
2781
+ if (_40 && !_40.done && (_b = _39.return)) _b.call(_39);
2578
2782
  }
2579
2783
  finally { if (e_29) throw e_29.error; }
2580
2784
  }
@@ -2648,6 +2852,19 @@ function buildSupportAIRunFromEvidence(input) {
2648
2852
  });
2649
2853
  }
2650
2854
  var cost = collectUsageEvents(asArray(input.usageLedger), events);
2855
+ var preflightGateSource = supportPreflightGateObject(ticket, job, evidence);
2856
+ var preflightGate = supportPreflightGateResult(preflightGateSource, input.now);
2857
+ if (preflightGate) {
2858
+ gates.push(preflightGate);
2859
+ pushEvent(events, {
2860
+ type: ((_c = preflightGate.metadata) === null || _c === void 0 ? void 0 : _c.failureClass) === 'compile' || preflightGateSource.status === 'compile_failed' ? 'qa_compile' : 'qa_infra',
2861
+ category: 'support_preflight_gate',
2862
+ message: preflightGate.reason,
2863
+ artifactPaths: preflightGate.evidenceRefs,
2864
+ recordedAt: preflightGate.recordedAt,
2865
+ metadata: preflightGate.metadata
2866
+ });
2867
+ }
2651
2868
  var diagnosisGate = evidenceObject(job.supportV5DiagnosisGate, job.support_v5_diagnosis_gate, job.diagnosisGate, ticket.supportV5DiagnosisGate, ticket.diagnosisGate, evidence.diagnosisGate, evidence.supportV5DiagnosisGate);
2652
2869
  var diagnosisEvidencePackSource = supportDiagnosisEvidencePackObject(ticket, job, evidence);
2653
2870
  var similarFixHints = supportSimilarFixHintsObject(ticket, job, evidence);
@@ -2720,7 +2937,7 @@ function buildSupportAIRunFromEvidence(input) {
2720
2937
  pushEvent(events, {
2721
2938
  type: 'log',
2722
2939
  category: 'diagnosis_gate',
2723
- message: cleanText(((_c = diagnosisGate.accepted_hypothesis) === null || _c === void 0 ? void 0 : _c.statement) || ((_d = diagnosisGate.acceptedHypothesis) === null || _d === void 0 ? void 0 : _d.statement) || diagnosisGate.summary || 'Support diagnosis gate recorded.', 1800),
2940
+ 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),
2724
2941
  metadata: {
2725
2942
  status: diagnosisGate.status,
2726
2943
  issueClass: diagnosisIssueClass,
@@ -2757,59 +2974,59 @@ function buildSupportAIRunFromEvidence(input) {
2757
2974
  managerNoBlindLoopPolicy: managerNoBlindLoopMetadata(noBlindLoopGate),
2758
2975
  diagnosisBeforeRepair: diagnosisBeforeRepairGate ? {
2759
2976
  status: diagnosisBeforeRepairGate.status,
2760
- diagnosisValid: ((_e = diagnosisBeforeRepairGate.metadata) === null || _e === void 0 ? void 0 : _e.diagnosisValid) === true,
2761
- diagnosisStatus: cleanText((_f = diagnosisBeforeRepairGate.metadata) === null || _f === void 0 ? void 0 : _f.diagnosisStatus, 120),
2762
- activityCount: Number(((_g = diagnosisBeforeRepairGate.metadata) === null || _g === void 0 ? void 0 : _g.activityCount) || 0),
2763
- changedFiles: cleanStringList((_h = diagnosisBeforeRepairGate.metadata) === null || _h === void 0 ? void 0 : _h.changedFiles, 40, 500),
2764
- allowedDispatchAction: cleanText((_j = diagnosisBeforeRepairGate.metadata) === null || _j === void 0 ? void 0 : _j.allowedDispatchAction, 160),
2765
- productRepairAllowed: ((_k = diagnosisBeforeRepairGate.metadata) === null || _k === void 0 ? void 0 : _k.productRepairAllowed) === true,
2766
- blockers: cleanStringList((_l = diagnosisBeforeRepairGate.metadata) === null || _l === void 0 ? void 0 : _l.blockers, 20, 500)
2977
+ diagnosisValid: ((_f = diagnosisBeforeRepairGate.metadata) === null || _f === void 0 ? void 0 : _f.diagnosisValid) === true,
2978
+ diagnosisStatus: cleanText((_g = diagnosisBeforeRepairGate.metadata) === null || _g === void 0 ? void 0 : _g.diagnosisStatus, 120),
2979
+ activityCount: Number(((_h = diagnosisBeforeRepairGate.metadata) === null || _h === void 0 ? void 0 : _h.activityCount) || 0),
2980
+ changedFiles: cleanStringList((_j = diagnosisBeforeRepairGate.metadata) === null || _j === void 0 ? void 0 : _j.changedFiles, 40, 500),
2981
+ allowedDispatchAction: cleanText((_k = diagnosisBeforeRepairGate.metadata) === null || _k === void 0 ? void 0 : _k.allowedDispatchAction, 160),
2982
+ productRepairAllowed: ((_l = diagnosisBeforeRepairGate.metadata) === null || _l === void 0 ? void 0 : _l.productRepairAllowed) === true,
2983
+ blockers: cleanStringList((_m = diagnosisBeforeRepairGate.metadata) === null || _m === void 0 ? void 0 : _m.blockers, 20, 500)
2767
2984
  } : undefined,
2768
2985
  rootCauseEntryContract: Object.keys(rootCauseEntryContract).length ? {
2769
2986
  contractId: cleanText(rootCauseEntryContract.contract_id || rootCauseEntryContract.contractId, 160),
2770
2987
  version: cleanText(rootCauseEntryContract.version, 120),
2771
2988
  status: cleanText(rootCauseEntryContract.status, 120),
2772
2989
  issueClassProbeCount: asArray(rootCauseEntryContract.issue_class_probes || rootCauseEntryContract.issueClassProbes).length,
2773
- ownerFileMax: Number(((_m = rootCauseEntryContract.owner_file_policy) === null || _m === void 0 ? void 0 : _m.max_files) || ((_o = rootCauseEntryContract.ownerFilePolicy) === null || _o === void 0 ? void 0 : _o.maxFiles) || 0) || 0,
2774
- requiresBusinessAssertion: ((_p = rootCauseEntryContract.business_proof_policy) === null || _p === void 0 ? void 0 : _p.requires_aiqa_business_assertion) === true
2775
- || ((_q = rootCauseEntryContract.businessProofPolicy) === null || _q === void 0 ? void 0 : _q.requiresAiqaBusinessAssertion) === true
2990
+ ownerFileMax: Number(((_o = rootCauseEntryContract.owner_file_policy) === null || _o === void 0 ? void 0 : _o.max_files) || ((_p = rootCauseEntryContract.ownerFilePolicy) === null || _p === void 0 ? void 0 : _p.maxFiles) || 0) || 0,
2991
+ requiresBusinessAssertion: ((_q = rootCauseEntryContract.business_proof_policy) === null || _q === void 0 ? void 0 : _q.requires_aiqa_business_assertion) === true
2992
+ || ((_r = rootCauseEntryContract.businessProofPolicy) === null || _r === void 0 ? void 0 : _r.requiresAiqaBusinessAssertion) === true
2776
2993
  } : undefined,
2777
2994
  diagnosis: Object.keys(diagnosisGate).length ? {
2778
2995
  status: cleanText(diagnosisGate.status, 80),
2779
2996
  issueClass: diagnosisIssueClass,
2780
2997
  ownerFiles: diagnosisOwnerFiles,
2781
- acceptedHypothesis: cleanText(((_r = diagnosisGate.accepted_hypothesis) === null || _r === void 0 ? void 0 : _r.statement) || ((_s = diagnosisGate.acceptedHypothesis) === null || _s === void 0 ? void 0 : _s.statement), 1000),
2998
+ acceptedHypothesis: cleanText(((_s = diagnosisGate.accepted_hypothesis) === null || _s === void 0 ? void 0 : _s.statement) || ((_t = diagnosisGate.acceptedHypothesis) === null || _t === void 0 ? void 0 : _t.statement), 1000),
2782
2999
  proofPlan: diagnosisGate.proof_plan || diagnosisGate.proofPlan
2783
3000
  } : undefined,
2784
3001
  diagnosisEvidencePack: diagnosisEvidencePackGate ? {
2785
- status: cleanText((_t = diagnosisEvidencePackGate.metadata) === null || _t === void 0 ? void 0 : _t.status, 120),
3002
+ status: cleanText((_u = diagnosisEvidencePackGate.metadata) === null || _u === void 0 ? void 0 : _u.status, 120),
2786
3003
  gateStatus: diagnosisEvidencePackGate.status,
2787
- packId: cleanText((_u = diagnosisEvidencePackGate.metadata) === null || _u === void 0 ? void 0 : _u.packId, 180),
2788
- readOnly: ((_v = diagnosisEvidencePackGate.metadata) === null || _v === void 0 ? void 0 : _v.readOnly) !== false,
2789
- sourceEditsAllowed: ((_w = diagnosisEvidencePackGate.metadata) === null || _w === void 0 ? void 0 : _w.sourceEditsAllowed) === true,
2790
- requiredOutputKey: cleanText((_x = diagnosisEvidencePackGate.metadata) === null || _x === void 0 ? void 0 : _x.requiredOutputKey, 120),
2791
- diagnosisValid: ((_y = diagnosisEvidencePackGate.metadata) === null || _y === void 0 ? void 0 : _y.diagnosisValid) === true,
2792
- issueClassHint: cleanText((_z = diagnosisEvidencePackGate.metadata) === null || _z === void 0 ? void 0 : _z.issueClassHint, 120),
2793
- ownerFileHints: cleanStringList((_0 = diagnosisEvidencePackGate.metadata) === null || _0 === void 0 ? void 0 : _0.ownerFileHints, 20, 500),
2794
- similarHintCount: Number(((_1 = diagnosisEvidencePackGate.metadata) === null || _1 === void 0 ? void 0 : _1.similarHintCount) || 0),
2795
- similarHintsAdvisoryOnly: ((_2 = diagnosisEvidencePackGate.metadata) === null || _2 === void 0 ? void 0 : _2.similarHintsAdvisoryOnly) === true,
2796
- issueClassProbeCount: Number(((_3 = diagnosisEvidencePackGate.metadata) === null || _3 === void 0 ? void 0 : _3.issueClassProbeCount) || 0),
2797
- validationBlockers: cleanStringList((_4 = diagnosisEvidencePackGate.metadata) === null || _4 === void 0 ? void 0 : _4.validationBlockers, 20, 500)
3004
+ packId: cleanText((_v = diagnosisEvidencePackGate.metadata) === null || _v === void 0 ? void 0 : _v.packId, 180),
3005
+ readOnly: ((_w = diagnosisEvidencePackGate.metadata) === null || _w === void 0 ? void 0 : _w.readOnly) !== false,
3006
+ sourceEditsAllowed: ((_x = diagnosisEvidencePackGate.metadata) === null || _x === void 0 ? void 0 : _x.sourceEditsAllowed) === true,
3007
+ requiredOutputKey: cleanText((_y = diagnosisEvidencePackGate.metadata) === null || _y === void 0 ? void 0 : _y.requiredOutputKey, 120),
3008
+ diagnosisValid: ((_z = diagnosisEvidencePackGate.metadata) === null || _z === void 0 ? void 0 : _z.diagnosisValid) === true,
3009
+ issueClassHint: cleanText((_0 = diagnosisEvidencePackGate.metadata) === null || _0 === void 0 ? void 0 : _0.issueClassHint, 120),
3010
+ ownerFileHints: cleanStringList((_1 = diagnosisEvidencePackGate.metadata) === null || _1 === void 0 ? void 0 : _1.ownerFileHints, 20, 500),
3011
+ similarHintCount: Number(((_2 = diagnosisEvidencePackGate.metadata) === null || _2 === void 0 ? void 0 : _2.similarHintCount) || 0),
3012
+ similarHintsAdvisoryOnly: ((_3 = diagnosisEvidencePackGate.metadata) === null || _3 === void 0 ? void 0 : _3.similarHintsAdvisoryOnly) === true,
3013
+ issueClassProbeCount: Number(((_4 = diagnosisEvidencePackGate.metadata) === null || _4 === void 0 ? void 0 : _4.issueClassProbeCount) || 0),
3014
+ validationBlockers: cleanStringList((_5 = diagnosisEvidencePackGate.metadata) === null || _5 === void 0 ? void 0 : _5.validationBlockers, 20, 500)
2798
3015
  } : undefined,
2799
3016
  issueClassProbePlan: issueClassProbePlanGate ? {
2800
- status: cleanText((_5 = issueClassProbePlanGate.metadata) === null || _5 === void 0 ? void 0 : _5.status, 120),
3017
+ status: cleanText((_6 = issueClassProbePlanGate.metadata) === null || _6 === void 0 ? void 0 : _6.status, 120),
2801
3018
  gateStatus: issueClassProbePlanGate.status,
2802
- planId: cleanText((_6 = issueClassProbePlanGate.metadata) === null || _6 === void 0 ? void 0 : _6.planId, 180),
2803
- issueClass: cleanText((_7 = issueClassProbePlanGate.metadata) === null || _7 === void 0 ? void 0 : _7.issueClass, 120),
2804
- diagnosisValid: ((_8 = issueClassProbePlanGate.metadata) === null || _8 === void 0 ? void 0 : _8.diagnosisValid) === true,
2805
- issueClassProbePlanReady: ((_9 = issueClassProbePlanGate.metadata) === null || _9 === void 0 ? void 0 : _9.issueClassProbePlanReady) === true,
2806
- activeRoute: cleanText((_10 = issueClassProbePlanGate.metadata) === null || _10 === void 0 ? void 0 : _10.activeRoute, 500),
2807
- action: cleanText((_11 = issueClassProbePlanGate.metadata) === null || _11 === void 0 ? void 0 : _11.action, 1000),
2808
- expectedBusinessProof: cleanText((_12 = issueClassProbePlanGate.metadata) === null || _12 === void 0 ? void 0 : _12.expectedBusinessProof, 1200),
2809
- acceptanceGate: cleanText((_13 = issueClassProbePlanGate.metadata) === null || _13 === void 0 ? void 0 : _13.acceptanceGate, 120),
2810
- requiredArtifacts: cleanStringList((_14 = issueClassProbePlanGate.metadata) === null || _14 === void 0 ? void 0 : _14.requiredArtifacts, 20, 500),
2811
- falsePassBlockers: cleanStringList((_15 = issueClassProbePlanGate.metadata) === null || _15 === void 0 ? void 0 : _15.falsePassBlockers, 20, 500),
2812
- blockers: cleanStringList((_16 = issueClassProbePlanGate.metadata) === null || _16 === void 0 ? void 0 : _16.blockers, 20, 500)
3019
+ planId: cleanText((_7 = issueClassProbePlanGate.metadata) === null || _7 === void 0 ? void 0 : _7.planId, 180),
3020
+ issueClass: cleanText((_8 = issueClassProbePlanGate.metadata) === null || _8 === void 0 ? void 0 : _8.issueClass, 120),
3021
+ diagnosisValid: ((_9 = issueClassProbePlanGate.metadata) === null || _9 === void 0 ? void 0 : _9.diagnosisValid) === true,
3022
+ issueClassProbePlanReady: ((_10 = issueClassProbePlanGate.metadata) === null || _10 === void 0 ? void 0 : _10.issueClassProbePlanReady) === true,
3023
+ activeRoute: cleanText((_11 = issueClassProbePlanGate.metadata) === null || _11 === void 0 ? void 0 : _11.activeRoute, 500),
3024
+ action: cleanText((_12 = issueClassProbePlanGate.metadata) === null || _12 === void 0 ? void 0 : _12.action, 1000),
3025
+ expectedBusinessProof: cleanText((_13 = issueClassProbePlanGate.metadata) === null || _13 === void 0 ? void 0 : _13.expectedBusinessProof, 1200),
3026
+ acceptanceGate: cleanText((_14 = issueClassProbePlanGate.metadata) === null || _14 === void 0 ? void 0 : _14.acceptanceGate, 120),
3027
+ requiredArtifacts: cleanStringList((_15 = issueClassProbePlanGate.metadata) === null || _15 === void 0 ? void 0 : _15.requiredArtifacts, 20, 500),
3028
+ falsePassBlockers: cleanStringList((_16 = issueClassProbePlanGate.metadata) === null || _16 === void 0 ? void 0 : _16.falsePassBlockers, 20, 500),
3029
+ blockers: cleanStringList((_17 = issueClassProbePlanGate.metadata) === null || _17 === void 0 ? void 0 : _17.blockers, 20, 500)
2813
3030
  } : undefined,
2814
3031
  businessProofReadiness: Object.keys(businessProofReadiness).length ? {
2815
3032
  ready: businessProofReadiness.ready === true,
@@ -2819,19 +3036,19 @@ function buildSupportAIRunFromEvidence(input) {
2819
3036
  } : undefined,
2820
3037
  nextActionContract: nextActionContractGate ? {
2821
3038
  status: nextActionContractGate.status,
2822
- action: cleanText((_17 = nextActionContractGate.metadata) === null || _17 === void 0 ? void 0 : _17.action, 160),
2823
- primaryCommand: cleanText((_18 = nextActionContractGate.metadata) === null || _18 === void 0 ? void 0 : _18.primaryCommand, 240),
2824
- safeToAutoRun: ((_19 = nextActionContractGate.metadata) === null || _19 === void 0 ? void 0 : _19.safeToAutoRun) === true,
2825
- canRunWithoutCodexMonitor: ((_20 = nextActionContractGate.metadata) === null || _20 === void 0 ? void 0 : _20.canRunWithoutCodexMonitor) === true,
2826
- codexFallbackRequired: ((_21 = nextActionContractGate.metadata) === null || _21 === void 0 ? void 0 : _21.codexFallbackRequired) === true,
2827
- requiresHumanApproval: ((_22 = nextActionContractGate.metadata) === null || _22 === void 0 ? void 0 : _22.requiresHumanApproval) === true,
2828
- rootCauseFirstSatisfied: ((_23 = nextActionContractGate.metadata) === null || _23 === void 0 ? void 0 : _23.rootCauseFirstSatisfied) === true,
2829
- hotfixCommitRequired: ((_24 = nextActionContractGate.metadata) === null || _24 === void 0 ? void 0 : _24.hotfixCommitRequired) === true,
2830
- liveHotfixBlockedUntilCommit: ((_25 = nextActionContractGate.metadata) === null || _25 === void 0 ? void 0 : _25.liveHotfixBlockedUntilCommit) === true,
2831
- failureClass: cleanText((_26 = nextActionContractGate.metadata) === null || _26 === void 0 ? void 0 : _26.failureClass, 120),
2832
- evidenceFreshnessStatus: cleanText((_27 = nextActionContractGate.metadata) === null || _27 === void 0 ? void 0 : _27.evidenceFreshnessStatus, 120),
2833
- sameFailureCount: Number(((_28 = nextActionContractGate.metadata) === null || _28 === void 0 ? void 0 : _28.sameFailureCount) || 0),
2834
- blockers: cleanStringList((_29 = nextActionContractGate.metadata) === null || _29 === void 0 ? void 0 : _29.blockers, 20, 500)
3039
+ action: cleanText((_18 = nextActionContractGate.metadata) === null || _18 === void 0 ? void 0 : _18.action, 160),
3040
+ primaryCommand: cleanText((_19 = nextActionContractGate.metadata) === null || _19 === void 0 ? void 0 : _19.primaryCommand, 240),
3041
+ safeToAutoRun: ((_20 = nextActionContractGate.metadata) === null || _20 === void 0 ? void 0 : _20.safeToAutoRun) === true,
3042
+ canRunWithoutCodexMonitor: ((_21 = nextActionContractGate.metadata) === null || _21 === void 0 ? void 0 : _21.canRunWithoutCodexMonitor) === true,
3043
+ codexFallbackRequired: ((_22 = nextActionContractGate.metadata) === null || _22 === void 0 ? void 0 : _22.codexFallbackRequired) === true,
3044
+ requiresHumanApproval: ((_23 = nextActionContractGate.metadata) === null || _23 === void 0 ? void 0 : _23.requiresHumanApproval) === true,
3045
+ rootCauseFirstSatisfied: ((_24 = nextActionContractGate.metadata) === null || _24 === void 0 ? void 0 : _24.rootCauseFirstSatisfied) === true,
3046
+ hotfixCommitRequired: ((_25 = nextActionContractGate.metadata) === null || _25 === void 0 ? void 0 : _25.hotfixCommitRequired) === true,
3047
+ liveHotfixBlockedUntilCommit: ((_26 = nextActionContractGate.metadata) === null || _26 === void 0 ? void 0 : _26.liveHotfixBlockedUntilCommit) === true,
3048
+ failureClass: cleanText((_27 = nextActionContractGate.metadata) === null || _27 === void 0 ? void 0 : _27.failureClass, 120),
3049
+ evidenceFreshnessStatus: cleanText((_28 = nextActionContractGate.metadata) === null || _28 === void 0 ? void 0 : _28.evidenceFreshnessStatus, 120),
3050
+ sameFailureCount: Number(((_29 = nextActionContractGate.metadata) === null || _29 === void 0 ? void 0 : _29.sameFailureCount) || 0),
3051
+ blockers: cleanStringList((_30 = nextActionContractGate.metadata) === null || _30 === void 0 ? void 0 : _30.blockers, 20, 500)
2835
3052
  } : undefined,
2836
3053
  customerReplyPolicy: Object.keys(customerReplyPolicy).length ? {
2837
3054
  action: cleanText(customerReplyPolicy.action, 120),
@@ -2839,19 +3056,19 @@ function buildSupportAIRunFromEvidence(input) {
2839
3056
  canDraftCustomerReply: customerReplyPolicy.canDraftCustomerReply === true || customerReplyPolicy.can_draft_customer_reply === true,
2840
3057
  canSendCustomerReply: customerReplyPolicy.canSendCustomerReply === true || customerReplyPolicy.can_send_customer_reply === true,
2841
3058
  reason: cleanText(customerReplyPolicy.reason, 1000),
2842
- reviewType: cleanText(((_30 = customerReplyPolicy.humanReviewPacket) === null || _30 === void 0 ? void 0 : _30.reviewType)
2843
- || ((_31 = customerReplyPolicy.human_review_packet) === null || _31 === void 0 ? void 0 : _31.review_type)
2844
- || ((_32 = customerReplyPolicy.human_review_packet) === null || _32 === void 0 ? void 0 : _32.reviewType), 160),
2845
- primaryAction: cleanText(((_33 = customerReplyPolicy.humanReviewPacket) === null || _33 === void 0 ? void 0 : _33.primaryAction)
2846
- || ((_34 = customerReplyPolicy.human_review_packet) === null || _34 === void 0 ? void 0 : _34.primary_action)
2847
- || ((_35 = customerReplyPolicy.human_review_packet) === null || _35 === void 0 ? void 0 : _35.primaryAction), 160)
3059
+ reviewType: cleanText(((_31 = customerReplyPolicy.humanReviewPacket) === null || _31 === void 0 ? void 0 : _31.reviewType)
3060
+ || ((_32 = customerReplyPolicy.human_review_packet) === null || _32 === void 0 ? void 0 : _32.review_type)
3061
+ || ((_33 = customerReplyPolicy.human_review_packet) === null || _33 === void 0 ? void 0 : _33.reviewType), 160),
3062
+ primaryAction: cleanText(((_34 = customerReplyPolicy.humanReviewPacket) === null || _34 === void 0 ? void 0 : _34.primaryAction)
3063
+ || ((_35 = customerReplyPolicy.human_review_packet) === null || _35 === void 0 ? void 0 : _35.primary_action)
3064
+ || ((_36 = customerReplyPolicy.human_review_packet) === null || _36 === void 0 ? void 0 : _36.primaryAction), 160)
2848
3065
  } : undefined
2849
3066
  }
2850
3067
  });
2851
3068
  }
2852
3069
  function buildAICoderAIRunFromEvidence(input) {
2853
3070
  var e_30, _a;
2854
- var _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, _3, _4, _5, _6;
3071
+ var _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, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
2855
3072
  var app = input.app || {};
2856
3073
  var job = input.job || {};
2857
3074
  var evidence = buildAICoderQaEvidence(input);
@@ -2862,8 +3079,8 @@ function buildAICoderAIRunFromEvidence(input) {
2862
3079
  addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
2863
3080
  addSourceId(sourceIds, 'domain', app.domain || app.customDomain || job.domain);
2864
3081
  try {
2865
- for (var _7 = __values(asArray(input.logs)), _8 = _7.next(); !_8.done; _8 = _7.next()) {
2866
- var log = _8.value;
3082
+ for (var _26 = __values(asArray(input.logs)), _27 = _26.next(); !_27.done; _27 = _26.next()) {
3083
+ var log = _27.value;
2867
3084
  pushEvent(events, {
2868
3085
  type: log.type === 'scorecard' ? 'scorecard' : 'log',
2869
3086
  category: cleanText(log.category || log.phase || log.level, 160),
@@ -2881,7 +3098,7 @@ function buildAICoderAIRunFromEvidence(input) {
2881
3098
  catch (e_30_1) { e_30 = { error: e_30_1 }; }
2882
3099
  finally {
2883
3100
  try {
2884
- if (_8 && !_8.done && (_a = _7.return)) _a.call(_7);
3101
+ if (_27 && !_27.done && (_a = _26.return)) _a.call(_26);
2885
3102
  }
2886
3103
  finally { if (e_30) throw e_30.error; }
2887
3104
  }
@@ -2976,6 +3193,19 @@ function buildAICoderAIRunFromEvidence(input) {
2976
3193
  metadata: workflowProofCheckpointGate.metadata
2977
3194
  });
2978
3195
  }
3196
+ var nextActionContract = aicoderNextActionContractObject(app, job, evidence);
3197
+ var nextActionContractGate = aicoderNextActionContractGate(nextActionContract, input.now);
3198
+ if (nextActionContractGate) {
3199
+ gates.push(nextActionContractGate);
3200
+ pushEvent(events, {
3201
+ type: 'log',
3202
+ category: 'aicoder_next_action_contract',
3203
+ message: nextActionContractGate.reason,
3204
+ artifactPaths: nextActionContractGate.evidenceRefs,
3205
+ recordedAt: nextActionContractGate.recordedAt,
3206
+ metadata: nextActionContractGate.metadata
3207
+ });
3208
+ }
2979
3209
  var qa = applyAICoderWorkflowProofGate(buildQaFromEvidence(evidence, input.now), workflowReadiness, input.now);
2980
3210
  return (0, ai_run_evidence_1.buildAIRun)({
2981
3211
  source: 'aicoder_app',
@@ -3048,6 +3278,28 @@ function buildAICoderAIRunFromEvidence(input) {
3048
3278
  workflowProofFingerprint: cleanText((_4 = workflowProofCheckpointGate.metadata) === null || _4 === void 0 ? void 0 : _4.workflowProofFingerprint, 200),
3049
3279
  artifactFingerprint: cleanText((_5 = workflowProofCheckpointGate.metadata) === null || _5 === void 0 ? void 0 : _5.artifactFingerprint, 200),
3050
3280
  blockers: cleanStringList((_6 = workflowProofCheckpointGate.metadata) === null || _6 === void 0 ? void 0 : _6.blockers, 20, 500)
3281
+ } : undefined,
3282
+ nextActionContract: nextActionContractGate ? {
3283
+ gateStatus: nextActionContractGate.status,
3284
+ contractId: cleanText((_7 = nextActionContractGate.metadata) === null || _7 === void 0 ? void 0 : _7.contractId, 200),
3285
+ action: cleanText((_8 = nextActionContractGate.metadata) === null || _8 === void 0 ? void 0 : _8.action, 120),
3286
+ label: cleanText((_9 = nextActionContractGate.metadata) === null || _9 === void 0 ? void 0 : _9.label, 200),
3287
+ primaryCommand: cleanText((_10 = nextActionContractGate.metadata) === null || _10 === void 0 ? void 0 : _10.primaryCommand, 200),
3288
+ lane: cleanText((_11 = nextActionContractGate.metadata) === null || _11 === void 0 ? void 0 : _11.lane, 120),
3289
+ stepType: cleanText((_12 = nextActionContractGate.metadata) === null || _12 === void 0 ? void 0 : _12.stepType, 120),
3290
+ safeToAutoRun: ((_13 = nextActionContractGate.metadata) === null || _13 === void 0 ? void 0 : _13.safeToAutoRun) === true,
3291
+ requiresHumanApproval: ((_14 = nextActionContractGate.metadata) === null || _14 === void 0 ? void 0 : _14.requiresHumanApproval) === true,
3292
+ canRunWithoutCodexMonitor: ((_15 = nextActionContractGate.metadata) === null || _15 === void 0 ? void 0 : _15.canRunWithoutCodexMonitor) === true,
3293
+ codexFallbackRequired: ((_16 = nextActionContractGate.metadata) === null || _16 === void 0 ? void 0 : _16.codexFallbackRequired) === true,
3294
+ costRisk: cleanText((_17 = nextActionContractGate.metadata) === null || _17 === void 0 ? void 0 : _17.costRisk, 120),
3295
+ workflowFirstSatisfied: ((_18 = nextActionContractGate.metadata) === null || _18 === void 0 ? void 0 : _18.workflowFirstSatisfied) === true,
3296
+ decisionBasis: plainObject((_19 = nextActionContractGate.metadata) === null || _19 === void 0 ? void 0 : _19.decisionBasis),
3297
+ preconditions: cleanStringList((_20 = nextActionContractGate.metadata) === null || _20 === void 0 ? void 0 : _20.preconditions, 20, 500),
3298
+ successEvidence: cleanStringList((_21 = nextActionContractGate.metadata) === null || _21 === void 0 ? void 0 : _21.successEvidence, 20, 500),
3299
+ stopConditions: cleanStringList((_22 = nextActionContractGate.metadata) === null || _22 === void 0 ? void 0 : _22.stopConditions, 20, 500),
3300
+ forbiddenActions: cleanStringList((_23 = nextActionContractGate.metadata) === null || _23 === void 0 ? void 0 : _23.forbiddenActions, 20, 500),
3301
+ nextCommands: cleanStringList((_24 = nextActionContractGate.metadata) === null || _24 === void 0 ? void 0 : _24.nextCommands, 20, 240),
3302
+ blockers: cleanStringList((_25 = nextActionContractGate.metadata) === null || _25 === void 0 ? void 0 : _25.blockers, 20, 500)
3051
3303
  } : undefined
3052
3304
  }
3053
3305
  });