@resolveio/server-lib 22.3.156 → 22.3.158

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.
@@ -374,6 +374,52 @@ export interface ResolveIOSupportV5ContinuationDecision {
374
374
  recoveryEvidenceProbe: ResolveIOAIManagerRecoveryEvidenceProbe;
375
375
  recoveryAction: ResolveIOAIManagerRecoveryActionPacket;
376
376
  }
377
+ export type ResolveIOSupportV5AutonomousNextAction = 'run_diagnosis_gate' | 'repair_infra_only' | 'revise_diagnosis_scope' | 'run_owner_scoped_repair' | 'run_business_proof_qa' | 'repair_release_hotfix_first' | 'collect_new_evidence' | 'draft_customer_reply' | 'ready_for_release_gate' | 'park_manual';
378
+ export interface ResolveIOSupportV5AutonomousDecisionInput {
379
+ bundle: ResolveIOSupportV5StateBundle;
380
+ changedFiles?: any;
381
+ failureClass?: ResolveIOSupportV5FailureClass | string;
382
+ blocker?: any;
383
+ evidence?: any;
384
+ evidenceHash?: string;
385
+ outcomeLabel?: string;
386
+ confidence?: any;
387
+ businessAssertionStatus?: string;
388
+ businessProofArtifacts?: any[];
389
+ unresolvedBlockers?: any[];
390
+ releaseStatus?: string;
391
+ maxOwnerFiles?: number;
392
+ now?: Date | string;
393
+ }
394
+ export interface ResolveIOSupportV5AutonomousDecision {
395
+ action: ResolveIOSupportV5AutonomousNextAction;
396
+ label: string;
397
+ reason: string;
398
+ canRunAutonomously: boolean;
399
+ canEditProductCode: boolean;
400
+ canRunModel: boolean;
401
+ canRunQa: boolean;
402
+ canHotfixBackend: boolean;
403
+ canDraftCustomerReply: boolean;
404
+ canSendCustomerReply: boolean;
405
+ lane: ResolveIOSupportV5Lane | 'release' | 'customer';
406
+ stepType: ResolveIOSupportV5StepType | 'release_gate' | 'customer_reply';
407
+ microtaskId?: string;
408
+ primaryCommand: string;
409
+ nextCommands: string[];
410
+ requiredEvidence: string[];
411
+ forbiddenActions: string[];
412
+ blockers: string[];
413
+ ownerFiles: string[];
414
+ issueClass?: ResolveIOSupportIssueClass;
415
+ expectedProof?: string;
416
+ activeMicrotask?: ResolveIOSupportV5Microtask;
417
+ diagnosisValidation: ResolveIOSupportDiagnosisGateValidation;
418
+ repairGate: ResolveIOSupportV5RepairGateDecision;
419
+ continuation: ResolveIOSupportV5ContinuationDecision;
420
+ customerReplyPolicy: ResolveIOSupportCustomerReplyPolicy;
421
+ recordedAt: string;
422
+ }
377
423
  export declare function evaluateResolveIOSupportDiagnosisEvidenceQuality(value: any): ResolveIOSupportDiagnosisEvidenceQuality;
378
424
  export declare function normalizeResolveIOSupportDiagnosisGate(value: any, now?: Date | string): ResolveIOSupportDiagnosisGate | undefined;
379
425
  export declare function extractResolveIOSupportDiagnosisGateFromText(value: string, now?: Date | string): ResolveIOSupportDiagnosisGate | undefined;
@@ -411,6 +457,7 @@ export declare function initializeResolveIOSupportV5State(input: ResolveIOSuppor
411
457
  export declare function recordResolveIOSupportV5Step(bundle: ResolveIOSupportV5StateBundle, step: ResolveIOSupportV5StepInput): ResolveIOSupportV5StateBundle;
412
458
  export declare function recordResolveIOSupportV5MicrotaskUsage(bundle: ResolveIOSupportV5StateBundle, usage: Omit<ResolveIOSupportV5MicrotaskUsage, 'recordedAt'>): ResolveIOSupportV5StateBundle;
413
459
  export declare function decideResolveIOSupportV5Continuation(bundle: ResolveIOSupportV5StateBundle): ResolveIOSupportV5ContinuationDecision;
460
+ export declare function decideResolveIOSupportV5AutonomousNextAction(input: ResolveIOSupportV5AutonomousDecisionInput): ResolveIOSupportV5AutonomousDecision;
414
461
  export declare function buildResolveIOSupportV5DiagnoseFirstPrompt(lines: {
415
462
  goal?: string;
416
463
  approvedScope?: string[];
@@ -68,6 +68,7 @@ exports.initializeResolveIOSupportV5State = initializeResolveIOSupportV5State;
68
68
  exports.recordResolveIOSupportV5Step = recordResolveIOSupportV5Step;
69
69
  exports.recordResolveIOSupportV5MicrotaskUsage = recordResolveIOSupportV5MicrotaskUsage;
70
70
  exports.decideResolveIOSupportV5Continuation = decideResolveIOSupportV5Continuation;
71
+ exports.decideResolveIOSupportV5AutonomousNextAction = decideResolveIOSupportV5AutonomousNextAction;
71
72
  exports.buildResolveIOSupportV5DiagnoseFirstPrompt = buildResolveIOSupportV5DiagnoseFirstPrompt;
72
73
  exports.buildResolveIOSupportV5MicrotaskPrompt = buildResolveIOSupportV5MicrotaskPrompt;
73
74
  exports.summarizeResolveIOSupportV5MicrotaskUsage = summarizeResolveIOSupportV5MicrotaskUsage;
@@ -1510,6 +1511,230 @@ function decideResolveIOSupportV5Continuation(bundle) {
1510
1511
  var recoveryPlan = recoveryPlanFor('continue', 'support_v5_continue');
1511
1512
  return __assign({ action: 'continue', reason: 'support_v5_continue', nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.supportV5SupervisorState.activeStep, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, recoveryFieldsFor(recoveryPlan));
1512
1513
  }
1514
+ function decideResolveIOSupportV5AutonomousNextAction(input) {
1515
+ var _a, _b, _c;
1516
+ var bundle = input.bundle;
1517
+ var activeMicrotask = selectResolveIOSupportV5ActiveMicrotask(bundle.supportV5MicrotaskLedger || [], bundle.supportV5ActiveMicrotaskId);
1518
+ var diagnosisValidation = validateResolveIOSupportDiagnosisGate(bundle.supportV5DiagnosisGate, {
1519
+ maxOwnerFiles: input.maxOwnerFiles
1520
+ });
1521
+ var activeStepType = cleanText((activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.type) || (!diagnosisValidation.valid ? bundle.supportV5SupervisorState.activeStep : 'cleanup') || 'diagnosis_gate', 80);
1522
+ var repairGate = decideResolveIOSupportV5RepairGate({
1523
+ diagnosisGate: bundle.supportV5DiagnosisGate,
1524
+ activeStepType: activeStepType,
1525
+ changedFiles: input.changedFiles,
1526
+ failureClass: input.failureClass,
1527
+ blocker: input.blocker,
1528
+ evidence: input.evidence,
1529
+ evidenceHash: input.evidenceHash,
1530
+ history: bundle.supportV5StepHistory,
1531
+ maxOwnerFiles: input.maxOwnerFiles,
1532
+ allowTestsOutsideOwnerFiles: true
1533
+ });
1534
+ var continuation = decideResolveIOSupportV5Continuation(bundle);
1535
+ var customerReplyPolicy = decideResolveIOSupportCustomerReplyPolicy({
1536
+ diagnosisGate: bundle.supportV5DiagnosisGate,
1537
+ outcomeLabel: input.outcomeLabel,
1538
+ confidence: input.confidence,
1539
+ businessAssertionStatus: input.businessAssertionStatus,
1540
+ businessProofArtifacts: input.businessProofArtifacts,
1541
+ unresolvedBlockers: input.unresolvedBlockers,
1542
+ releaseStatus: input.releaseStatus
1543
+ });
1544
+ var ownerFiles = ((_a = diagnosisValidation.normalized) === null || _a === void 0 ? void 0 : _a.owner_files) || repairGate.ownerFiles || [];
1545
+ var proofContract = (_b = diagnosisValidation.normalized) === null || _b === void 0 ? void 0 : _b.proof_plan.business_proof_contract;
1546
+ var expectedProof = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion)
1547
+ || ((_c = diagnosisValidation.normalized) === null || _c === void 0 ? void 0 : _c.proof_plan.business_assertion)
1548
+ || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.acceptanceProof)
1549
+ || '';
1550
+ var makeDecision = function (action, label, reason, fields) {
1551
+ var _a;
1552
+ return ({
1553
+ action: action,
1554
+ label: label,
1555
+ reason: reason,
1556
+ canRunAutonomously: fields.canRunAutonomously === true,
1557
+ canEditProductCode: fields.canEditProductCode === true,
1558
+ canRunModel: fields.canRunModel === true,
1559
+ canRunQa: fields.canRunQa === true,
1560
+ canHotfixBackend: fields.canHotfixBackend === true,
1561
+ canDraftCustomerReply: fields.canDraftCustomerReply === true,
1562
+ canSendCustomerReply: false,
1563
+ lane: fields.lane || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'supervisor',
1564
+ stepType: fields.stepType || activeStepType,
1565
+ microtaskId: activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.microtaskId,
1566
+ primaryCommand: fields.primaryCommand || action,
1567
+ nextCommands: fields.nextCommands || [fields.primaryCommand || action],
1568
+ requiredEvidence: fields.requiredEvidence || [],
1569
+ forbiddenActions: Array.from(new Set(__spreadArray([
1570
+ 'Do not send customer email without explicit human approval.',
1571
+ 'Do not broaden owner_files without revised diagnosis evidence.',
1572
+ 'Do not accept route-load, screenshot-only, scorecard-only, or model-claim proof.'
1573
+ ], __read((fields.forbiddenActions || [])), false))),
1574
+ blockers: fields.blockers || [],
1575
+ ownerFiles: ownerFiles,
1576
+ issueClass: ((_a = diagnosisValidation.normalized) === null || _a === void 0 ? void 0 : _a.issue_class) || repairGate.issueClass,
1577
+ expectedProof: expectedProof,
1578
+ activeMicrotask: activeMicrotask,
1579
+ diagnosisValidation: diagnosisValidation,
1580
+ repairGate: repairGate,
1581
+ continuation: continuation,
1582
+ customerReplyPolicy: customerReplyPolicy,
1583
+ recordedAt: isoNow(input.now)
1584
+ });
1585
+ };
1586
+ if (continuation.action === 'park' && continuation.reason === 'support_v5_budget_guard') {
1587
+ return makeDecision('park_manual', 'Park Manual', continuation.reason, {
1588
+ canRunAutonomously: false,
1589
+ lane: 'supervisor',
1590
+ stepType: 'cleanup',
1591
+ primaryCommand: 'park_support_ticket_for_manual_budget_review',
1592
+ requiredEvidence: ['budget summary', 'latest blocker', 'operator decision'],
1593
+ blockers: ['Support V5 budget guard is active.']
1594
+ });
1595
+ }
1596
+ if (continuation.action === 'park') {
1597
+ return makeDecision('collect_new_evidence', 'Collect New Evidence', continuation.reason, {
1598
+ canRunAutonomously: true,
1599
+ canRunModel: false,
1600
+ canRunQa: true,
1601
+ lane: (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'qa',
1602
+ stepType: activeStepType,
1603
+ primaryCommand: 'run_support_v5_recovery_evidence_probe',
1604
+ nextCommands: continuation.recoveryAction.nextCommands,
1605
+ requiredEvidence: continuation.recoveryAction.requiredArtifacts,
1606
+ blockers: [continuation.reason],
1607
+ forbiddenActions: ['Do not run another product-code repair until blockerFingerprint or evidenceHash changes.']
1608
+ });
1609
+ }
1610
+ if (repairGate.action === 'diagnose_only' || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.type) === 'diagnosis_gate' || !diagnosisValidation.valid) {
1611
+ return makeDecision('run_diagnosis_gate', 'Run Diagnosis Gate', 'support_v5_root_cause_first_required', {
1612
+ canRunAutonomously: true,
1613
+ canRunModel: true,
1614
+ canEditProductCode: false,
1615
+ lane: 'build',
1616
+ stepType: 'diagnosis_gate',
1617
+ primaryCommand: 'run_support_v5_read_only_diagnosis_gate',
1618
+ nextCommands: ['retrieve_similar_tickets_and_commits', 'run_reproduction_or_classification_probe', 'write_support_diagnosis_gate_json'],
1619
+ requiredEvidence: [
1620
+ 'issue_case expected/observed/account context',
1621
+ 'accepted falsifiable hypothesis',
1622
+ 'rejected alternatives',
1623
+ 'failing path',
1624
+ 'small owner_files set',
1625
+ 'before/action/after business proof plan'
1626
+ ],
1627
+ blockers: repairGate.blockers,
1628
+ forbiddenActions: ['No source edits during diagnosis.']
1629
+ });
1630
+ }
1631
+ if (repairGate.action === 'infra_repair_only') {
1632
+ return makeDecision('repair_infra_only', 'Repair Infra Only', 'support_v5_infra_failure_before_product_repair', {
1633
+ canRunAutonomously: true,
1634
+ canRunModel: false,
1635
+ canEditProductCode: false,
1636
+ canRunQa: true,
1637
+ lane: 'qa',
1638
+ stepType: activeStepType,
1639
+ primaryCommand: 'run_support_v5_infra_repair',
1640
+ nextCommands: ['rerun_puppeteer_compile_startup_preflight', 'repair_harness_or_cache_only', 'record_infra_artifact'],
1641
+ requiredEvidence: ['preflight log', 'compile/startup/browser status', 'new infra blocker hash or pass'],
1642
+ blockers: repairGate.blockers,
1643
+ forbiddenActions: ['Do not charge infra failures as product-code repair failures.']
1644
+ });
1645
+ }
1646
+ if (repairGate.action === 'reject_out_of_scope') {
1647
+ return makeDecision('revise_diagnosis_scope', 'Revise Diagnosis Scope', 'support_v5_owner_scope_block', {
1648
+ canRunAutonomously: true,
1649
+ canRunModel: true,
1650
+ canEditProductCode: false,
1651
+ lane: 'build',
1652
+ stepType: 'diagnosis_gate',
1653
+ primaryCommand: 'revise_support_diagnosis_gate_with_new_owner_file_evidence',
1654
+ nextCommands: ['attach_out_of_scope_diff', 'prove_new_owner_file_is_required', 'update_support_diagnosis_gate'],
1655
+ requiredEvidence: ['new root-cause evidence for each added owner file'],
1656
+ blockers: repairGate.blockers,
1657
+ forbiddenActions: ['Do not edit files outside owner_files before diagnosis is revised.']
1658
+ });
1659
+ }
1660
+ if (repairGate.action === 'park_repeated_failure') {
1661
+ return makeDecision('collect_new_evidence', 'Collect New Evidence', 'support_v5_repeated_failure_needs_new_evidence', {
1662
+ canRunAutonomously: true,
1663
+ canRunModel: false,
1664
+ canRunQa: true,
1665
+ lane: (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'qa',
1666
+ stepType: activeStepType,
1667
+ primaryCommand: 'run_support_v5_recovery_evidence_probe',
1668
+ nextCommands: repairGate.recoveryAction.nextCommands,
1669
+ requiredEvidence: repairGate.recoveryAction.requiredArtifacts,
1670
+ blockers: repairGate.blockers,
1671
+ forbiddenActions: ['Do not run another repair loop until new material evidence exists.']
1672
+ });
1673
+ }
1674
+ if (supportReleaseLooksBlocked(input.releaseStatus)) {
1675
+ return makeDecision('repair_release_hotfix_first', 'Hotfix Release', 'support_v5_release_blocked_hotfix_first', {
1676
+ canRunAutonomously: true,
1677
+ canRunModel: false,
1678
+ canEditProductCode: false,
1679
+ canHotfixBackend: true,
1680
+ lane: 'release',
1681
+ stepType: 'release_gate',
1682
+ primaryCommand: 'run_support_release_hotfix_first_gate',
1683
+ nextCommands: ['classify_release_blocker', 'hotfix_backend_or_release_artifact', 'record_github_commit_for_hotfix', 'rerun_release_gate_once'],
1684
+ requiredEvidence: ['hotfix evidence', 'sourceCommitSha and githubCommitUrl', 'health/self-test pass', 'release gate result'],
1685
+ blockers: cleanList(input.unresolvedBlockers, 20, 500)
1686
+ });
1687
+ }
1688
+ if ((activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) === 'qa' || /^(qa_row|qa_retest|business_proof|route_probe|issue_class_probe)$/.test(activeStepType)) {
1689
+ return makeDecision('run_business_proof_qa', 'Run Business Proof QA', 'support_v5_business_assertion_required', {
1690
+ canRunAutonomously: true,
1691
+ canRunQa: true,
1692
+ canRunModel: false,
1693
+ canEditProductCode: false,
1694
+ lane: 'qa',
1695
+ stepType: /^(qa_row|qa_retest|business_proof|route_probe|issue_class_probe)$/.test(activeStepType) ? activeStepType : 'qa_row',
1696
+ primaryCommand: 'run_support_v5_business_proof_qa_row',
1697
+ nextCommands: ['start_local_stack_if_needed', 'execute_issue_class_probe', 'record_before_action_after_artifacts', 'write_aiqa_business_assertion'],
1698
+ requiredEvidence: ['AIQaBusinessAssertion pass', 'DOM/data proof', 'artifact path', 'Mongo delta when data-changing'],
1699
+ forbiddenActions: ['Route probe pass alone remains route evidence only.']
1700
+ });
1701
+ }
1702
+ if (!activeMicrotask && customerReplyPolicy.action === 'draft_resolution_reply') {
1703
+ return makeDecision('draft_customer_reply', 'Draft Customer Reply', customerReplyPolicy.reason, {
1704
+ canRunAutonomously: true,
1705
+ canRunModel: true,
1706
+ canDraftCustomerReply: true,
1707
+ lane: 'customer',
1708
+ stepType: 'customer_reply',
1709
+ primaryCommand: 'draft_support_customer_resolution_reply',
1710
+ nextCommands: ['summarize_business_proof', 'draft_customer_reply_for_human_review'],
1711
+ requiredEvidence: customerReplyPolicy.requiredEvidence,
1712
+ forbiddenActions: ['Draft only; do not send.']
1713
+ });
1714
+ }
1715
+ if (!activeMicrotask && supportBusinessAssertionPassed(input.businessAssertionStatus || input.outcomeLabel)) {
1716
+ return makeDecision('ready_for_release_gate', 'Run Release Gate', 'support_v5_business_proof_complete_release_gate_ready', {
1717
+ canRunAutonomously: true,
1718
+ canRunQa: true,
1719
+ lane: 'release',
1720
+ stepType: 'release_gate',
1721
+ primaryCommand: 'run_support_release_gate_once',
1722
+ nextCommands: ['verify_compile_and_business_proof_artifacts', 'run_release_gate_once', 'record_release_status'],
1723
+ requiredEvidence: ['compile pass', 'business assertion artifact', 'release status']
1724
+ });
1725
+ }
1726
+ return makeDecision('run_owner_scoped_repair', 'Run Owner-Scoped Repair', 'support_v5_product_repair_allowed_after_diagnosis', {
1727
+ canRunAutonomously: true,
1728
+ canRunModel: true,
1729
+ canEditProductCode: true,
1730
+ lane: (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'build',
1731
+ stepType: activeStepType || 'build_repair',
1732
+ primaryCommand: 'run_support_v5_owner_scoped_repair',
1733
+ nextCommands: ['load_owner_files_only', 'apply_smallest_fix', 'run_smallest_compile_or_unit_gate', 'handoff_to_business_proof_qa'],
1734
+ requiredEvidence: ['changed files within owner_files', 'compile/unit proof', 'next QA row'],
1735
+ forbiddenActions: ['Do not edit outside owner_files unless diagnosis is revised with new evidence.']
1736
+ });
1737
+ }
1513
1738
  function buildResolveIOSupportV5DiagnoseFirstPrompt(lines) {
1514
1739
  var _a, _b;
1515
1740
  return [