@resolveio/server-lib 22.3.149 → 22.3.151

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.
@@ -26,6 +26,15 @@ export interface ResolveIOSupportDiagnosisFailingPath {
26
26
  data_query?: string;
27
27
  description: string;
28
28
  }
29
+ export interface ResolveIOSupportDiagnosisBusinessProofContract {
30
+ issue_class: ResolveIOSupportIssueClass;
31
+ setup_state: string;
32
+ action_under_test: string;
33
+ expected_business_state_change: string;
34
+ prohibited_false_pass: string;
35
+ proof_artifacts: string[];
36
+ data_or_dom_assertion: string;
37
+ }
29
38
  export interface ResolveIOSupportDiagnosisProofPlan {
30
39
  before: string;
31
40
  before_state_unavailable_reason?: string;
@@ -35,6 +44,7 @@ export interface ResolveIOSupportDiagnosisProofPlan {
35
44
  route?: string;
36
45
  data_assertion?: string;
37
46
  artifact_expectation?: string;
47
+ business_proof_contract?: ResolveIOSupportDiagnosisBusinessProofContract;
38
48
  }
39
49
  export interface ResolveIOSupportDiagnosisHint {
40
50
  id?: string;
@@ -225,6 +225,24 @@ function normalizeSupportDiagnosisHints(values) {
225
225
  .filter(function (entry) { return entry.id || entry.ticketNumber || entry.title || entry.reason || entry.commitSha; })
226
226
  .slice(0, 8);
227
227
  }
228
+ function normalizeSupportDiagnosisBusinessProofContract(value, issueClassHint) {
229
+ var source = cleanObject(value);
230
+ if (!Object.keys(source).length) {
231
+ return undefined;
232
+ }
233
+ var issueClass = normalizeIssueClass(source.issue_class || source.issueClass || issueClassHint)
234
+ || normalizeIssueClass(issueClassHint)
235
+ || 'missing_wrong_data';
236
+ return {
237
+ issue_class: issueClass,
238
+ setup_state: pickText(source, ['setup_state', 'setupState', 'before', 'precondition'], 1000),
239
+ action_under_test: pickText(source, ['action_under_test', 'actionUnderTest', 'action', 'steps'], 1000),
240
+ expected_business_state_change: pickText(source, ['expected_business_state_change', 'expectedBusinessStateChange', 'expected_change', 'expectedChange', 'after'], 1000),
241
+ prohibited_false_pass: pickText(source, ['prohibited_false_pass', 'prohibitedFalsePass', 'false_pass', 'falsePass'], 1000),
242
+ proof_artifacts: cleanList(source.proof_artifacts || source.proofArtifacts || source.artifacts || source.artifact_paths || source.artifactPaths, 10, 500),
243
+ data_or_dom_assertion: pickText(source, ['data_or_dom_assertion', 'dataOrDomAssertion', 'data_assertion', 'dataAssertion', 'dom_assertion', 'domAssertion', 'assertion'], 1000)
244
+ };
245
+ }
228
246
  function normalizeOwnerFilePath(value) {
229
247
  return cleanText(value, 500)
230
248
  .replace(/\\/g, '/')
@@ -267,6 +285,7 @@ function normalizeResolveIOSupportDiagnosisGate(value, now) {
267
285
  var failingPathSource = cleanObject(source.failing_path || source.failingPath);
268
286
  var proofPlanSource = cleanObject(source.proof_plan || source.proofPlan);
269
287
  var issueClass = normalizeIssueClass(source.issue_class || source.issueClass);
288
+ var businessProofContract = normalizeSupportDiagnosisBusinessProofContract(proofPlanSource.business_proof_contract || proofPlanSource.businessProofContract || source.business_proof_contract || source.businessProofContract, issueClass || source.issue_class || source.issueClass);
270
289
  var ownerFiles = cleanList(source.owner_files || source.ownerFiles, 20, 500)
271
290
  .map(normalizeOwnerFilePath)
272
291
  .filter(Boolean);
@@ -304,7 +323,8 @@ function normalizeResolveIOSupportDiagnosisGate(value, now) {
304
323
  business_assertion: pickText(proofPlanSource, ['business_assertion', 'businessAssertion', 'assertion'], 1000),
305
324
  route: pickText(proofPlanSource, ['route', 'url'], 500),
306
325
  data_assertion: pickText(proofPlanSource, ['data_assertion', 'dataAssertion', 'mongo_delta', 'mongoDelta'], 1000),
307
- artifact_expectation: pickText(proofPlanSource, ['artifact_expectation', 'artifactExpectation', 'artifact', 'screenshot'], 1000)
326
+ artifact_expectation: pickText(proofPlanSource, ['artifact_expectation', 'artifactExpectation', 'artifact', 'screenshot'], 1000),
327
+ business_proof_contract: businessProofContract
308
328
  },
309
329
  similar_tickets: normalizeSupportDiagnosisHints(source.similar_tickets || source.similarTickets),
310
330
  similar_commits: normalizeSupportDiagnosisHints(source.similar_commits || source.similarCommits),
@@ -428,6 +448,33 @@ function validateResolveIOSupportDiagnosisGate(value, options) {
428
448
  if (proofPlanLooksRouteOnly(normalized.proof_plan)) {
429
449
  blockers.push('Diagnosis proof_plan cannot be route-load, screen-visible, or screenshot-only; it must name the business state/data/control change that proves the issue is fixed.');
430
450
  }
451
+ var proofContract = normalized.proof_plan.business_proof_contract;
452
+ if (!proofContract) {
453
+ blockers.push('Diagnosis proof_plan.business_proof_contract is required.');
454
+ }
455
+ else {
456
+ if (proofContract.issue_class !== normalized.issue_class) {
457
+ blockers.push("Diagnosis proof_plan.business_proof_contract.issue_class (".concat(proofContract.issue_class, ") must match diagnosis issue_class (").concat(normalized.issue_class, ")."));
458
+ }
459
+ if (!proofContract.setup_state) {
460
+ blockers.push('Diagnosis proof_plan.business_proof_contract.setup_state is required.');
461
+ }
462
+ if (!proofContract.action_under_test) {
463
+ blockers.push('Diagnosis proof_plan.business_proof_contract.action_under_test is required.');
464
+ }
465
+ if (!proofContract.expected_business_state_change) {
466
+ blockers.push('Diagnosis proof_plan.business_proof_contract.expected_business_state_change is required.');
467
+ }
468
+ if (!proofContract.prohibited_false_pass) {
469
+ blockers.push('Diagnosis proof_plan.business_proof_contract.prohibited_false_pass is required.');
470
+ }
471
+ if (!proofContract.proof_artifacts.length) {
472
+ blockers.push('Diagnosis proof_plan.business_proof_contract.proof_artifacts must include at least one required artifact.');
473
+ }
474
+ if (!proofContract.data_or_dom_assertion) {
475
+ blockers.push('Diagnosis proof_plan.business_proof_contract.data_or_dom_assertion is required.');
476
+ }
477
+ }
431
478
  if (!normalized.evidence.length) {
432
479
  blockers.push('Diagnosis evidence must include ticket/code/browser/log/Mongo proof.');
433
480
  }
@@ -440,13 +487,19 @@ function validateResolveIOSupportDiagnosisGate(value, options) {
440
487
  };
441
488
  }
442
489
  function buildResolveIOSupportIssueClassProbes(value) {
490
+ var _a;
443
491
  var validation = validateResolveIOSupportDiagnosisGate(value);
444
492
  var gate = validation.normalized || normalizeResolveIOSupportDiagnosisGate(value);
445
493
  if (!gate) {
446
494
  return [];
447
495
  }
448
496
  var route = gate.proof_plan.route || gate.issue_case.route_module;
449
- var proof = gate.proof_plan.business_assertion;
497
+ var proofContract = gate.proof_plan.business_proof_contract;
498
+ var proof = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.expected_business_state_change) || gate.proof_plan.business_assertion;
499
+ var assertion = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion) || gate.proof_plan.data_assertion || gate.proof_plan.after;
500
+ var artifacts = ((_a = proofContract === null || proofContract === void 0 ? void 0 : proofContract.proof_artifacts) === null || _a === void 0 ? void 0 : _a.length)
501
+ ? " Required artifacts: ".concat(proofContract.proof_artifacts.join(', '), ".")
502
+ : '';
450
503
  var common = {
451
504
  issue_class: gate.issue_class,
452
505
  probe_type: 'issue_class_probe',
@@ -484,7 +537,9 @@ function buildResolveIOSupportIssueClassProbes(value) {
484
537
  }
485
538
  };
486
539
  var selected = map[gate.issue_class];
487
- return [__assign(__assign({}, common), { objective: "Issue-class probe for ".concat(gate.issue_class, ": ").concat(gate.issue_case.customer_complaint), action: selected.action, expected_evidence: selected.expected })];
540
+ return [__assign(__assign({}, common), { objective: "Issue-class probe for ".concat(gate.issue_class, ": ").concat(gate.issue_case.customer_complaint), action: proofContract
541
+ ? "".concat(proofContract.action_under_test, " ").concat(selected.action)
542
+ : selected.action, expected_evidence: "".concat(selected.expected).concat(assertion ? " Assertion: ".concat(assertion, ".") : '').concat(artifacts).trim() })];
488
543
  }
489
544
  function hashResolveIOSupportV5Evidence(value) {
490
545
  var raw = typeof value === 'string' ? value : JSON.stringify(value || {});
@@ -561,6 +616,16 @@ function decideResolveIOSupportV5RepeatedFailureStop(input) {
561
616
  reason: 'support_v5_ping_pong_failure_loop'
562
617
  };
563
618
  }
619
+ if (managerDecision.action === 'park_repeated_failure' && managerDecision.newEvidence) {
620
+ return {
621
+ shouldStop: false,
622
+ repeatedCount: managerDecision.sameFailureCount,
623
+ failureClass: failureClass,
624
+ blockerFingerprint: blockerFingerprint,
625
+ evidenceHash: evidenceHash,
626
+ reason: 'support_v5_retry_allowed_changed_evidence_hash'
627
+ };
628
+ }
564
629
  if (managerDecision.action === 'park_repeated_failure') {
565
630
  return {
566
631
  shouldStop: true,
@@ -730,6 +795,9 @@ function applyResolveIOSupportDiagnosisGateToMicrotasks(bundle, diagnosisGate) {
730
795
  }
731
796
  var ownerFiles = gate.owner_files;
732
797
  var probes = buildResolveIOSupportIssueClassProbes(gate);
798
+ var proofContract = gate.proof_plan.business_proof_contract;
799
+ var businessProof = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.expected_business_state_change) || gate.proof_plan.business_assertion;
800
+ var businessAssertion = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion) || gate.proof_plan.data_assertion || gate.proof_plan.after;
733
801
  var now = isoNow();
734
802
  var diagnosisMicrotaskId = ((_a = (bundle.supportV5MicrotaskLedger || [])
735
803
  .find(function (task) { return task.type === 'diagnosis_gate'; })) === null || _a === void 0 ? void 0 : _a.microtaskId)
@@ -740,10 +808,10 @@ function applyResolveIOSupportDiagnosisGateToMicrotasks(bundle, diagnosisGate) {
740
808
  return __assign(__assign({}, task), { status: validation.valid ? 'pass' : 'needs_repair', blocker: validation.valid ? '' : validation.blockers.join(' | '), updatedAt: now });
741
809
  }
742
810
  if (task.lane === 'build' && /repair|product_repair|build_repair/i.test(String(task.type || ''))) {
743
- return __assign(__assign({}, task), { targetFiles: ownerFiles, contextRefs: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.contextRefs || [])), false), ['supportV5DiagnosisGate', 'owner_files'], false))), selfGate: "Repair only the diagnosed owner files unless you revise the diagnosis with new evidence. Owner files: ".concat(ownerFiles.join(', '), "."), acceptanceProof: gate.proof_plan.business_assertion, dependsOn: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.dependsOn || [])), false), [diagnosisMicrotaskId], false))), updatedAt: now });
811
+ return __assign(__assign({}, task), { targetFiles: ownerFiles, contextRefs: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.contextRefs || [])), false), ['supportV5DiagnosisGate', 'owner_files'], false))), selfGate: "Repair only the diagnosed owner files unless you revise the diagnosis with new evidence. Owner files: ".concat(ownerFiles.join(', '), "."), acceptanceProof: businessProof, dependsOn: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.dependsOn || [])), false), [diagnosisMicrotaskId], false))), updatedAt: now });
744
812
  }
745
813
  if (task.lane === 'qa' && task.type === 'qa_row') {
746
- return __assign(__assign({}, task), { contextRefs: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.contextRefs || [])), false), ['supportV5DiagnosisGate', 'proof_plan'], false))), selfGate: ((_a = probes[0]) === null || _a === void 0 ? void 0 : _a.action) || task.selfGate, acceptanceProof: gate.proof_plan.business_assertion || task.acceptanceProof, targetFiles: ownerFiles, updatedAt: now });
814
+ return __assign(__assign({}, task), { contextRefs: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.contextRefs || [])), false), ['supportV5DiagnosisGate', 'proof_plan'], false))), selfGate: ((_a = probes[0]) === null || _a === void 0 ? void 0 : _a.action) || task.selfGate, acceptanceProof: businessProof || task.acceptanceProof, targetFiles: ownerFiles, updatedAt: now });
747
815
  }
748
816
  return task;
749
817
  });
@@ -754,9 +822,9 @@ function applyResolveIOSupportDiagnosisGateToMicrotasks(bundle, diagnosisGate) {
754
822
  "Accepted hypothesis: ".concat(gate.accepted_hypothesis.statement),
755
823
  "Owner files: ".concat(ownerFiles.join(', '))
756
824
  ].filter(Boolean).join(' | '), updatedAt: now }), qa: __assign(__assign({}, bundle.supportV5LaneMemory.qa), { activeQaRow: {
757
- workflow: gate.proof_plan.business_assertion,
825
+ workflow: (proofContract === null || proofContract === void 0 ? void 0 : proofContract.action_under_test) || gate.proof_plan.action,
758
826
  route: gate.proof_plan.route || gate.issue_case.route_module,
759
- assertion: gate.proof_plan.after,
827
+ assertion: businessAssertion,
760
828
  status: 'pending'
761
829
  }, updatedAt: now }) }) });
762
830
  }
@@ -1231,7 +1299,7 @@ function buildResolveIOSupportV5DiagnoseFirstPrompt(lines) {
1231
1299
  ].filter(Boolean);
1232
1300
  }
1233
1301
  function buildResolveIOSupportV5MicrotaskPrompt(input) {
1234
- var _a, _b, _c;
1302
+ var _a, _b, _c, _d, _e, _f;
1235
1303
  var activeMicrotask = selectResolveIOSupportV5ActiveMicrotask(input.bundle.supportV5MicrotaskLedger || [], input.bundle.supportV5ActiveMicrotaskId);
1236
1304
  var diagnosisValidation = validateResolveIOSupportDiagnosisGate(input.bundle.supportV5DiagnosisGate);
1237
1305
  var diagnosisGate = diagnosisValidation.normalized || input.bundle.supportV5DiagnosisGate;
@@ -1277,10 +1345,11 @@ function buildResolveIOSupportV5MicrotaskPrompt(input) {
1277
1345
  name: 'root_cause_first_diagnosis_contract',
1278
1346
  text: [
1279
1347
  'Before any product-code repair, produce strict JSON only:',
1280
- '{"support_diagnosis_gate":{"issue_case":{"customer_complaint":"","expected_result":"","observed_result":"","route_module":"","account_customer_context":"","reproduction_status":"reproduced|blocked|classified","reproduction_blocker":""},"issue_class":"no_op_submit|missing_wrong_data|filter_query_mismatch|invoice_pdf_export|upload_import|route_auth_hydration|slow_query_performance","accepted_hypothesis":{"statement":"","falsifiable_test":"","evidence":[""]},"rejected_alternatives":[""],"failing_path":{"frontend":"","backend":"","shared_library":"","data_query":"","description":""},"owner_files":["small/exact/file.ts"],"proof_plan":{"before":"","before_state_unavailable_reason":"","action":"","after":"","business_assertion":"","route":"","data_assertion":"","artifact_expectation":""},"similar_tickets":[],"similar_commits":[],"evidence":[{"type":"ticket|browser|mongo|log|code|commit|qa|other","summary":"","artifactPath":""}],"status":"passed"}}',
1348
+ '{"support_diagnosis_gate":{"issue_case":{"customer_complaint":"","expected_result":"","observed_result":"","route_module":"","account_customer_context":"","reproduction_status":"reproduced|blocked|classified","reproduction_blocker":""},"issue_class":"no_op_submit|missing_wrong_data|filter_query_mismatch|invoice_pdf_export|upload_import|route_auth_hydration|slow_query_performance","accepted_hypothesis":{"statement":"","falsifiable_test":"","evidence":[""]},"rejected_alternatives":[""],"failing_path":{"frontend":"","backend":"","shared_library":"","data_query":"","description":""},"owner_files":["small/exact/file.ts"],"proof_plan":{"before":"","before_state_unavailable_reason":"","action":"","after":"","business_assertion":"","route":"","data_assertion":"","artifact_expectation":"","business_proof_contract":{"issue_class":"same as diagnosis issue_class","setup_state":"","action_under_test":"","expected_business_state_change":"","prohibited_false_pass":"Route load, screenshot, scorecard, or model claim alone is not acceptance.","proof_artifacts":["browser trace/screenshot/json/mongo delta"],"data_or_dom_assertion":""}},"similar_tickets":[],"similar_commits":[],"evidence":[{"type":"ticket|browser|mongo|log|code|commit|qa|other","summary":"","artifactPath":""}],"status":"passed"}}',
1281
1349
  'Owner files must be a small exact editable set, not directories, globs, generated wrappers, or broad repo areas.',
1282
1350
  'The accepted hypothesis must be falsifiable and backed by evidence; prior similar tickets or commits are hints only and cannot bypass fresh diagnosis.',
1283
- 'The proof plan must be before/action/after business proof. If before-state proof is impossible, explain exactly why in before_state_unavailable_reason.'
1351
+ 'The proof plan must be before/action/after business proof plus business_proof_contract. If before-state proof is impossible, explain exactly why in before_state_unavailable_reason.',
1352
+ 'The business_proof_contract must name the setup state, action under test, expected business state change, prohibited false pass, required artifacts, and DOM/data assertion.'
1284
1353
  ].join('\n')
1285
1354
  } : {
1286
1355
  name: 'diagnosis_gate_context',
@@ -1290,6 +1359,9 @@ function buildResolveIOSupportV5MicrotaskPrompt(input) {
1290
1359
  "Failing path: ".concat(diagnosisGate.failing_path.description || diagnosisGate.failing_path.frontend || diagnosisGate.failing_path.backend || ''),
1291
1360
  "Owner files: ".concat(diagnosisGate.owner_files.join(', ')),
1292
1361
  "Business proof required: ".concat(diagnosisGate.proof_plan.business_assertion),
1362
+ diagnosisGate.proof_plan.business_proof_contract
1363
+ ? "Business proof contract: ".concat((_d = diagnosisGate.proof_plan.business_proof_contract) === null || _d === void 0 ? void 0 : _d.action_under_test, " -> ").concat((_e = diagnosisGate.proof_plan.business_proof_contract) === null || _e === void 0 ? void 0 : _e.expected_business_state_change, "; assertion ").concat((_f = diagnosisGate.proof_plan.business_proof_contract) === null || _f === void 0 ? void 0 : _f.data_or_dom_assertion)
1364
+ : '',
1293
1365
  "Before/action/after: ".concat(diagnosisGate.proof_plan.before || diagnosisGate.proof_plan.before_state_unavailable_reason, " -> ").concat(diagnosisGate.proof_plan.action, " -> ").concat(diagnosisGate.proof_plan.after)
1294
1366
  ].filter(Boolean).join('\n') : 'SupportDiagnosisGate is not valid. Park instead of editing product code.'
1295
1367
  },