@resolveio/server-lib 22.3.168 → 22.3.170

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.
@@ -549,6 +549,45 @@ export interface ResolveIOSupportRootCauseReadiness {
549
549
  artifactFingerprint?: string;
550
550
  proofFreshness?: ResolveIOSupportBusinessProofReadiness['proofFreshness'];
551
551
  }
552
+ export type ResolveIOSupportNextActionCostRisk = 'free_or_deterministic' | 'small_model_or_qa' | 'expensive_model' | 'release_or_customer_send' | 'manual_blocked';
553
+ export interface ResolveIOSupportNextActionContract {
554
+ contractId: string;
555
+ action: ResolveIOSupportV5AutonomousNextAction;
556
+ label: string;
557
+ primaryCommand: string;
558
+ lane: ResolveIOSupportV5Lane | 'release' | 'customer';
559
+ stepType: ResolveIOSupportV5StepType | 'release_gate' | 'customer_reply';
560
+ safeToAutoRun: boolean;
561
+ requiresHumanApproval: boolean;
562
+ canRunWithoutCodexMonitor: boolean;
563
+ codexFallbackRequired: boolean;
564
+ codexFallbackReason: string;
565
+ costRisk: ResolveIOSupportNextActionCostRisk;
566
+ rootCauseFirstSatisfied: boolean;
567
+ decisionBasis: {
568
+ diagnosisValid: boolean;
569
+ ownerFilesReady: boolean;
570
+ proofPlanReady: boolean;
571
+ businessProofReady: boolean;
572
+ evidenceFreshnessStatus: ResolveIOSupportEvidenceFreshnessStatus;
573
+ evidenceStrength: ResolveIOAIManagerEvidenceStrength;
574
+ failureClass: string;
575
+ blockerFingerprint: string;
576
+ evidenceHash: string;
577
+ sameFailureCount: number;
578
+ hotfixCommitRequired: boolean;
579
+ liveHotfixBlockedUntilCommit: boolean;
580
+ };
581
+ preconditions: string[];
582
+ expectedStateTransition: string;
583
+ successEvidence: string[];
584
+ stopConditions: string[];
585
+ forbiddenActions: string[];
586
+ ownerFiles: string[];
587
+ blockers: string[];
588
+ nextCommands: string[];
589
+ createdAt: string;
590
+ }
552
591
  export interface ResolveIOSupportV5AutonomousDecisionInput {
553
592
  bundle: ResolveIOSupportV5StateBundle;
554
593
  changedFiles?: any;
@@ -606,6 +645,7 @@ export interface ResolveIOSupportV5AutonomousDecision {
606
645
  evidenceFreshness: ResolveIOSupportEvidenceFreshness;
607
646
  rootCauseReadiness: ResolveIOSupportRootCauseReadiness;
608
647
  continuationProofCheckpoint: ResolveIOSupportContinuationProofCheckpoint;
648
+ nextActionContract: ResolveIOSupportNextActionContract;
609
649
  humanReviewPacket: ResolveIOSupportHumanReviewPacket;
610
650
  hotfixContinuation?: ResolveIOAIManagerHotfixContinuationDecision;
611
651
  recordedAt: string;
@@ -2512,6 +2512,138 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
2512
2512
  proofFreshness: businessProofReadiness.proofFreshness
2513
2513
  };
2514
2514
  };
2515
+ var nextActionExpectedTransition = function (action, primaryCommand) {
2516
+ if (action === 'run_diagnosis_gate') {
2517
+ return 'SupportDiagnosisGate changes from missing/incomplete to passed, blocked with one clarification question, or rejected with explicit blockers; no source files are edited.';
2518
+ }
2519
+ if (action === 'ask_customer_clarification') {
2520
+ return 'One customer clarification question is prepared for human review and the ticket parks until the missing reproduction/account context is supplied.';
2521
+ }
2522
+ if (action === 'repair_infra_only') {
2523
+ return 'Infra/preflight evidence changes or passes without charging the failure as product-code repair.';
2524
+ }
2525
+ if (action === 'revise_diagnosis_scope') {
2526
+ return 'SupportDiagnosisGate owner_files, failing_path, and proof_plan are revised together with new evidence before any broader edit.';
2527
+ }
2528
+ if (action === 'run_owner_scoped_repair') {
2529
+ return 'Only diagnosis owner_files change, a compile/unit gate is recorded, and the next state is business proof QA rather than acceptance.';
2530
+ }
2531
+ if (action === 'run_business_proof_qa') {
2532
+ return 'A fresh AIQaBusinessAssertion maps to the active proof_plan and records before/action/after DOM, data, or Mongo proof.';
2533
+ }
2534
+ if (action === 'repair_release_hotfix_first') {
2535
+ return primaryCommand === 'record_hotfix_evidence'
2536
+ ? 'Hotfix evidence is recorded with sourceCommitSha, githubCommitUrl, and passed gitPushStatus before any live backend apply or continuation.'
2537
+ : 'The smallest release/hotfix gate changes state, with duplicate full deploy blocked unless force evidence is explicit.';
2538
+ }
2539
+ if (action === 'ready_for_release_gate') {
2540
+ return 'Release gate records compile, business proof, and deployment readiness without treating route-only evidence as acceptance.';
2541
+ }
2542
+ if (action === 'draft_customer_reply') {
2543
+ return 'A customer resolution draft is prepared from accepted business proof and remains unsent until human approval.';
2544
+ }
2545
+ if (action === 'collect_new_evidence') {
2546
+ return 'The next run records a changed blocker fingerprint, changed evidence hash, fresh artifact path, or explicit business/infra/compile/release proof.';
2547
+ }
2548
+ return 'The runner stays parked until a human changes scope, budget, evidence, or autonomy policy.';
2549
+ };
2550
+ var buildNextActionContract = function (action, label, reason, fields, rootCauseReadiness, continuationProofCheckpoint, primaryCommand, nextCommands, requiredEvidence, forbiddenActions, blockers) {
2551
+ var lane = (fields.lane || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'supervisor');
2552
+ var stepType = (fields.stepType || activeStepType);
2553
+ var liveHotfixBlockedUntilCommit = fields.liveHotfixBlockedUntilCommit === true;
2554
+ var hotfixCommitRequired = action === 'repair_release_hotfix_first'
2555
+ || liveHotfixBlockedUntilCommit
2556
+ || fields.canHotfixBackend === true;
2557
+ var requiresHumanApproval = action === 'park_manual'
2558
+ || action === 'ask_customer_clarification'
2559
+ || rootCauseReadiness.requiresHumanDecision === true;
2560
+ var safeToAutoRun = fields.canRunAutonomously === true
2561
+ && !requiresHumanApproval
2562
+ && (action !== 'run_owner_scoped_repair' || (rootCauseReadiness.rootCauseFirstSatisfied === true && evidenceFreshness.mustCollectNewEvidence !== true))
2563
+ && (action !== 'repair_release_hotfix_first' || primaryCommand !== 'apply_backend_hotfix_only_after_commit_proof' || liveHotfixBlockedUntilCommit !== true);
2564
+ var costRisk = requiresHumanApproval
2565
+ ? 'manual_blocked'
2566
+ : (fields.canHotfixBackend === true || action === 'draft_customer_reply')
2567
+ ? 'release_or_customer_send'
2568
+ : fields.canRunModel === true
2569
+ ? 'expensive_model'
2570
+ : fields.canRunQa === true
2571
+ ? 'small_model_or_qa'
2572
+ : 'free_or_deterministic';
2573
+ var canRunWithoutCodexMonitor = safeToAutoRun
2574
+ && continuationProofCheckpoint.required === true
2575
+ && forbiddenActions.length > 0
2576
+ && (requiredEvidence.length > 0 || action === 'repair_infra_only' || action === 'run_diagnosis_gate');
2577
+ var codexFallbackRequired = !canRunWithoutCodexMonitor && !requiresHumanApproval;
2578
+ var codexFallbackReason = codexFallbackRequired
2579
+ ? (blockers[0] || continuationProofCheckpoint.reason || 'next_action_contract_missing_required_evidence')
2580
+ : requiresHumanApproval
2581
+ ? 'human_decision_required_not_codex_fallback'
2582
+ : !canRunWithoutCodexMonitor
2583
+ ? 'structured_contract_blocks_auto_run_without_requesting_codex_monitor'
2584
+ : 'structured_next_action_contract_allows_manager_execution_without_external_codex_monitor';
2585
+ var preconditions = Array.from(new Set(__spreadArray([
2586
+ action !== 'run_diagnosis_gate' ? 'SupportDiagnosisGate validation checked before action.' : 'Diagnosis is read-only and cannot edit source files.',
2587
+ action === 'run_owner_scoped_repair' ? 'Root-cause-first gate is satisfied and owner_files are the only editable product files.' : '',
2588
+ action === 'run_business_proof_qa' ? 'Business proof QA must use the diagnosis proof_plan and generated issue-class probe.' : '',
2589
+ action === 'repair_release_hotfix_first' ? 'Live backend hotfix is blocked until GitHub commit proof is recorded and passed.' : '',
2590
+ evidenceFreshness.mustCollectNewEvidence === true ? 'Current failure is stale or repeated; only evidence collection is allowed until proof changes.' : ''
2591
+ ], __read(requiredEvidence), false).filter(Boolean))).slice(0, 24);
2592
+ var stopConditions = Array.from(new Set(__spreadArray([
2593
+ 'Stop if the same failure class, blocker fingerprint, and evidence hash repeat without material evidence.',
2594
+ 'Stop if the action would edit outside diagnosis owner_files without a revised diagnosis gate.',
2595
+ 'Stop if route-load, screenshot-only, scorecard-only, or model-claim proof is the only acceptance evidence.',
2596
+ liveHotfixBlockedUntilCommit ? 'Stop before live backend hotfix until sourceCommitSha, githubCommitUrl, and passed gitPushStatus are recorded.' : ''
2597
+ ], __read(continuationProofCheckpoint.requiredResetEvidence.map(function (entry) { return "Reset requires: ".concat(entry); })), false).filter(Boolean))).slice(0, 24);
2598
+ var createdAt = isoNow(input.now);
2599
+ return {
2600
+ contractId: "support-next-action-".concat(hashResolveIOSupportV5Evidence({
2601
+ action: action,
2602
+ primaryCommand: primaryCommand,
2603
+ reason: reason,
2604
+ blockers: blockers,
2605
+ requiredEvidence: requiredEvidence,
2606
+ evidenceFreshness: evidenceFreshness.evidenceHash,
2607
+ blockerFingerprint: evidenceFreshness.blockerFingerprint,
2608
+ createdAt: createdAt.slice(0, 16)
2609
+ }).slice(0, 16)),
2610
+ action: action,
2611
+ label: label,
2612
+ primaryCommand: primaryCommand,
2613
+ lane: lane,
2614
+ stepType: stepType,
2615
+ safeToAutoRun: safeToAutoRun,
2616
+ requiresHumanApproval: requiresHumanApproval,
2617
+ canRunWithoutCodexMonitor: canRunWithoutCodexMonitor,
2618
+ codexFallbackRequired: codexFallbackRequired,
2619
+ codexFallbackReason: codexFallbackReason,
2620
+ costRisk: costRisk,
2621
+ rootCauseFirstSatisfied: rootCauseReadiness.rootCauseFirstSatisfied === true,
2622
+ decisionBasis: {
2623
+ diagnosisValid: rootCauseReadiness.diagnosisValid === true,
2624
+ ownerFilesReady: rootCauseReadiness.ownerFilesReady === true,
2625
+ proofPlanReady: rootCauseReadiness.proofPlanReady === true,
2626
+ businessProofReady: businessProofReadiness.ready === true,
2627
+ evidenceFreshnessStatus: evidenceFreshness.status,
2628
+ evidenceStrength: evidenceFreshness.evidenceStrength,
2629
+ failureClass: evidenceFreshness.failureClass,
2630
+ blockerFingerprint: evidenceFreshness.blockerFingerprint,
2631
+ evidenceHash: evidenceFreshness.evidenceHash,
2632
+ sameFailureCount: evidenceFreshness.sameFailureCount,
2633
+ hotfixCommitRequired: hotfixCommitRequired,
2634
+ liveHotfixBlockedUntilCommit: liveHotfixBlockedUntilCommit
2635
+ },
2636
+ preconditions: preconditions,
2637
+ expectedStateTransition: nextActionExpectedTransition(action, primaryCommand),
2638
+ successEvidence: Array.from(new Set(requiredEvidence.length ? requiredEvidence : continuationProofCheckpoint.requiredEvidence)).slice(0, 24),
2639
+ stopConditions: stopConditions,
2640
+ forbiddenActions: forbiddenActions.slice(0, 24),
2641
+ ownerFiles: ownerFiles.slice(0, 24),
2642
+ blockers: blockers.slice(0, 24),
2643
+ nextCommands: nextCommands.slice(0, 24),
2644
+ createdAt: createdAt
2645
+ };
2646
+ };
2515
2647
  var makeDecision = function (action, label, reason, fields) {
2516
2648
  var _a;
2517
2649
  var primaryCommand = fields.primaryCommand || action;
@@ -2532,6 +2664,7 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
2532
2664
  requiredResetEvidence: fields.requiredEvidence,
2533
2665
  blocksProductRepair: evidenceFreshness.mustCollectNewEvidence === true
2534
2666
  });
2667
+ var nextActionContract = buildNextActionContract(action, label, reason, fields, rootCauseReadiness, continuationProofCheckpoint, primaryCommand, nextCommands, requiredEvidence, forbiddenActions, blockers);
2535
2668
  var humanReviewPacket = fields.humanReviewPacket
2536
2669
  || (action === 'draft_customer_reply' && customerReplyPolicy.humanReviewPacket ? customerReplyPolicy.humanReviewPacket : undefined)
2537
2670
  || buildResolveIOSupportHumanReviewPacket({
@@ -2590,6 +2723,7 @@ function decideResolveIOSupportV5AutonomousNextAction(input) {
2590
2723
  evidenceFreshness: evidenceFreshness,
2591
2724
  rootCauseReadiness: rootCauseReadiness,
2592
2725
  continuationProofCheckpoint: continuationProofCheckpoint,
2726
+ nextActionContract: nextActionContract,
2593
2727
  humanReviewPacket: humanReviewPacket,
2594
2728
  hotfixContinuation: fields.hotfixContinuation,
2595
2729
  recordedAt: isoNow(input.now)