@resolveio/server-lib 22.3.191 → 22.3.192

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.
@@ -321,6 +321,71 @@ export interface ResolveIOAIManagerHotfixEvidenceRecord {
321
321
  readyForReleaseGate: boolean;
322
322
  readyForContinuation: boolean;
323
323
  }
324
+ export type ResolveIOAIManagerHotfixDurabilityStatus = 'not_required' | 'waiting_for_commit_proof' | 'ready_for_live_hotfix' | 'ready_for_release_gate' | 'ready_for_continuation';
325
+ export interface ResolveIOAIManagerHotfixDurabilityContractInput {
326
+ action?: string;
327
+ reason?: string;
328
+ evidence?: any;
329
+ policy?: ResolveIOAIManagerHotfixFirstReleasePolicy;
330
+ continuation?: Partial<ResolveIOAIManagerHotfixContinuationDecision> | null;
331
+ existing?: any;
332
+ source?: string;
333
+ releaseGatePassed?: boolean;
334
+ now?: Date | string;
335
+ }
336
+ export interface ResolveIOAIManagerHotfixDurabilityContract {
337
+ contractId: string;
338
+ contract_id: string;
339
+ createdAt: string;
340
+ created_at: string;
341
+ updatedAt: string;
342
+ updated_at: string;
343
+ source: string;
344
+ required: boolean;
345
+ action: string;
346
+ status: ResolveIOAIManagerHotfixDurabilityStatus;
347
+ reason: string;
348
+ canPrepareHotfixPatch: boolean;
349
+ can_prepare_hotfix_patch: boolean;
350
+ canHotfixBackend: boolean;
351
+ can_hotfix_backend: boolean;
352
+ liveHotfixBlockedUntilCommit: boolean;
353
+ live_hotfix_blocked_until_commit: boolean;
354
+ commitProofPassed: boolean;
355
+ commit_proof_passed: boolean;
356
+ commitProofStatus: ResolveIOAIManagerHotfixGitProofStatus | 'missing';
357
+ commit_proof_status: ResolveIOAIManagerHotfixGitProofStatus | 'missing';
358
+ sourceCommitSha: string;
359
+ source_commit_sha: string;
360
+ githubCommitUrl: string;
361
+ github_commit_url: string;
362
+ gitCommitStatus: string;
363
+ git_commit_status: string;
364
+ gitPushStatus: string;
365
+ git_push_status: string;
366
+ missingCommitProofFields: string[];
367
+ missing_commit_proof_fields: string[];
368
+ nextSafeAction: string;
369
+ next_safe_action: string;
370
+ phaseOrder: string[];
371
+ phase_order: string[];
372
+ requiredFields: string[];
373
+ required_fields: string[];
374
+ requiredEvidence: string[];
375
+ required_evidence: string[];
376
+ successCriteria: string[];
377
+ success_criteria: string[];
378
+ forbiddenActions: string[];
379
+ forbidden_actions: string[];
380
+ hotfixCommitGuard: Record<string, any>;
381
+ hotfix_commit_guard: Record<string, any>;
382
+ githubCommitGuard: ResolveIOAIManagerHotfixGitProof;
383
+ github_commit_guard: ResolveIOAIManagerHotfixGitProof;
384
+ validation: ResolveIOAIManagerHotfixEvidenceValidation;
385
+ continuation?: Partial<ResolveIOAIManagerHotfixContinuationDecision> | null;
386
+ extraRequest: string;
387
+ extra_request: string;
388
+ }
324
389
  export interface ResolveIOAIManagerRecoveryActionPacket {
325
390
  actionId: string;
326
391
  checkpointId: string;
@@ -634,6 +699,7 @@ export declare function validateResolveIOAIManagerHotfixEvidence(value: any, opt
634
699
  policy?: ResolveIOAIManagerHotfixFirstReleasePolicy;
635
700
  }): ResolveIOAIManagerHotfixEvidenceValidation;
636
701
  export declare function buildResolveIOAIManagerHotfixEvidenceRecord(input?: ResolveIOAIManagerHotfixEvidenceRecordInput): ResolveIOAIManagerHotfixEvidenceRecord;
702
+ export declare function buildResolveIOAIManagerHotfixDurabilityContract(input?: ResolveIOAIManagerHotfixDurabilityContractInput): ResolveIOAIManagerHotfixDurabilityContract;
637
703
  export declare function decideResolveIOAIManagerHotfixContinuation(input?: ResolveIOAIManagerHotfixContinuationInput): ResolveIOAIManagerHotfixContinuationDecision;
638
704
  export declare function decideResolveIOAIManagerHotfixCommitGuard(input?: ResolveIOAIManagerHotfixContinuationInput): ResolveIOAIManagerHotfixCommitGuardDecision;
639
705
  export declare function buildResolveIOAIManagerHotfixFirstReleasePolicy(input?: ResolveIOAIManagerHotfixFirstReleasePolicyInput): ResolveIOAIManagerHotfixFirstReleasePolicy;
@@ -53,6 +53,7 @@ exports.normalizeResolveIOAIManagerHotfixEvidence = normalizeResolveIOAIManagerH
53
53
  exports.evaluateResolveIOAIManagerHotfixGitProof = evaluateResolveIOAIManagerHotfixGitProof;
54
54
  exports.validateResolveIOAIManagerHotfixEvidence = validateResolveIOAIManagerHotfixEvidence;
55
55
  exports.buildResolveIOAIManagerHotfixEvidenceRecord = buildResolveIOAIManagerHotfixEvidenceRecord;
56
+ exports.buildResolveIOAIManagerHotfixDurabilityContract = buildResolveIOAIManagerHotfixDurabilityContract;
56
57
  exports.decideResolveIOAIManagerHotfixContinuation = decideResolveIOAIManagerHotfixContinuation;
57
58
  exports.decideResolveIOAIManagerHotfixCommitGuard = decideResolveIOAIManagerHotfixCommitGuard;
58
59
  exports.buildResolveIOAIManagerHotfixFirstReleasePolicy = buildResolveIOAIManagerHotfixFirstReleasePolicy;
@@ -939,8 +940,250 @@ function buildResolveIOAIManagerHotfixEvidenceRecord(input) {
939
940
  readyForContinuation: validation.valid === true && validation.hotfixSatisfied === true && hotfixStatusPassed(normalized === null || normalized === void 0 ? void 0 : normalized.releaseGateStatus)
940
941
  };
941
942
  }
943
+ function pickFirstHotfixText(sources, keys, max, seen) {
944
+ var e_4, _a, e_5, _b, e_6, _c;
945
+ if (max === void 0) { max = 500; }
946
+ if (seen === void 0) { seen = new WeakSet(); }
947
+ try {
948
+ for (var sources_1 = __values(sources), sources_1_1 = sources_1.next(); !sources_1_1.done; sources_1_1 = sources_1.next()) {
949
+ var source = sources_1_1.value;
950
+ var record = cleanObject(source);
951
+ if (!Object.keys(record).length || seen.has(record)) {
952
+ continue;
953
+ }
954
+ seen.add(record);
955
+ try {
956
+ for (var keys_1 = (e_5 = void 0, __values(keys)), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
957
+ var key = keys_1_1.value;
958
+ var value = cleanText(record[key], max);
959
+ if (value) {
960
+ return value;
961
+ }
962
+ }
963
+ }
964
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
965
+ finally {
966
+ try {
967
+ if (keys_1_1 && !keys_1_1.done && (_b = keys_1.return)) _b.call(keys_1);
968
+ }
969
+ finally { if (e_5) throw e_5.error; }
970
+ }
971
+ try {
972
+ for (var _d = (e_6 = void 0, __values(['evidence', 'hotfixEvidence', 'hotfix_evidence', 'hotfixCommitProof', 'hotfix_commit_proof', 'hotfixCommitGuard', 'hotfix_commit_guard', 'githubCommitGuard', 'github_commit_guard'])), _e = _d.next(); !_e.done; _e = _d.next()) {
973
+ var nestedKey = _e.value;
974
+ var nestedValue = pickFirstHotfixText([record[nestedKey]], keys, max, seen);
975
+ if (nestedValue) {
976
+ return nestedValue;
977
+ }
978
+ }
979
+ }
980
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
981
+ finally {
982
+ try {
983
+ if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
984
+ }
985
+ finally { if (e_6) throw e_6.error; }
986
+ }
987
+ }
988
+ }
989
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
990
+ finally {
991
+ try {
992
+ if (sources_1_1 && !sources_1_1.done && (_a = sources_1.return)) _a.call(sources_1);
993
+ }
994
+ finally { if (e_4) throw e_4.error; }
995
+ }
996
+ return '';
997
+ }
998
+ function hotfixDurabilityExtraRequest(contract) {
999
+ if (!contract.required) {
1000
+ return '';
1001
+ }
1002
+ return [
1003
+ 'Manager hotfix durability contract:',
1004
+ "- Contract id: ".concat(contract.contractId),
1005
+ "- Live backend hotfix blocked until commit proof: ".concat(contract.liveHotfixBlockedUntilCommit ? 'yes' : 'no'),
1006
+ "- GitHub commit proof passed: ".concat(contract.commitProofPassed ? 'yes' : 'no'),
1007
+ contract.missingCommitProofFields.length ? "- Missing commit proof fields: ".concat(contract.missingCommitProofFields.join(', ')) : '',
1008
+ contract.phaseOrder.length ? "- Required phase order: ".concat(contract.phaseOrder.join(' -> ')) : '',
1009
+ contract.requiredFields.length ? "- Required evidence fields: ".concat(contract.requiredFields.join(', ')) : '',
1010
+ contract.successCriteria.length ? "- Success criteria: ".concat(contract.successCriteria.join(' | ')) : '',
1011
+ contract.forbiddenActions.length ? "- Forbidden actions: ".concat(contract.forbiddenActions.join(' | ')) : '',
1012
+ '- Prepare the hotfix patch and GitHub commit proof before any live backend apply/restart.',
1013
+ '- After commit proof exists, apply the backend hotfix only through the existing hotfix path, record restart/checksum evidence, run the runner-manager self-test, and rerun the smallest release gate.'
1014
+ ].filter(Boolean).join('\n').slice(0, 3600);
1015
+ }
1016
+ function buildResolveIOAIManagerHotfixDurabilityContract(input) {
1017
+ var _a, _b, _c, _d, _e;
1018
+ if (input === void 0) { input = {}; }
1019
+ var existing = cleanObject(input.existing);
1020
+ var evidence = Object.keys(cleanObject(input.evidence)).length ? input.evidence : existing.evidence || existing.hotfixEvidence || existing.hotfix_evidence || existing;
1021
+ var validation = validateResolveIOAIManagerHotfixEvidence(evidence, { policy: input.policy });
1022
+ var continuation = input.continuation || undefined;
1023
+ var githubCommitGuard = validation.githubCommitGuard || evaluateResolveIOAIManagerHotfixGitProof(evidence, validation.channel);
1024
+ var sources = [evidence, existing, continuation, continuation === null || continuation === void 0 ? void 0 : continuation.githubCommitGuard, continuation === null || continuation === void 0 ? void 0 : continuation.github_commit_guard, githubCommitGuard];
1025
+ var action = cleanText(input.action || existing.action || existing.dispatchAction || existing.dispatch_action || 'run_release_repair', 160);
1026
+ var actionRequiresHotfix = /release_repair|hotfix|apply.*backend|deploy|publish/i.test(action);
1027
+ var required = existing.required === true
1028
+ || actionRequiresHotfix
1029
+ || githubCommitGuard.required === true
1030
+ || ((_a = validation.githubCommitGuard) === null || _a === void 0 ? void 0 : _a.required) === true
1031
+ || ((_b = continuation === null || continuation === void 0 ? void 0 : continuation.githubCommitGuard) === null || _b === void 0 ? void 0 : _b.required) === true
1032
+ || ((_c = continuation === null || continuation === void 0 ? void 0 : continuation.github_commit_guard) === null || _c === void 0 ? void 0 : _c.required) === true
1033
+ || ((_d = input.policy) === null || _d === void 0 ? void 0 : _d.hotfixPreferred) === true;
1034
+ var sourceCommitSha = githubCommitGuard.sourceCommitSha || pickFirstHotfixText(sources, ['sourceCommitSha', 'source_commit_sha', 'commitSha', 'commit_sha'], 120);
1035
+ var githubCommitUrl = githubCommitGuard.githubCommitUrl || pickFirstHotfixText(sources, ['githubCommitUrl', 'github_commit_url', 'commitUrl', 'commit_url'], 500);
1036
+ var gitCommitStatus = githubCommitGuard.gitCommitStatus || pickFirstHotfixText(sources, ['gitCommitStatus', 'git_commit_status', 'commitStatus', 'commit_status'], 160);
1037
+ var gitPushStatus = githubCommitGuard.gitPushStatus || pickFirstHotfixText(sources, ['gitPushStatus', 'git_push_status', 'pushStatus', 'push_status'], 160);
1038
+ var commitPassed = hotfixStatusPassed(gitCommitStatus);
1039
+ var pushPassed = hotfixStatusPassed(gitPushStatus);
1040
+ var sourceShaPassed = isFullGitCommitSha(sourceCommitSha);
1041
+ var githubUrlSha = extractGithubCommitSha(githubCommitUrl);
1042
+ var githubUrlPassed = !!githubUrlSha && (!sourceShaPassed || githubUrlSha === sourceCommitSha.toLowerCase());
1043
+ var missingCommitProofFields = [
1044
+ sourceShaPassed ? '' : 'sourceCommitSha',
1045
+ githubUrlPassed ? '' : 'githubCommitUrl',
1046
+ commitPassed ? '' : 'gitCommitStatus=passed',
1047
+ pushPassed ? '' : 'gitPushStatus=passed'
1048
+ ].filter(Boolean);
1049
+ var commitProofPassed = required ? missingCommitProofFields.length === 0 : githubCommitGuard.passed === true;
1050
+ var liveHotfixBlockedUntilCommit = required && commitProofPassed !== true;
1051
+ var releaseGatePassed = input.releaseGatePassed === true
1052
+ || hotfixStatusPassed((_e = validation.normalized) === null || _e === void 0 ? void 0 : _e.releaseGateStatus)
1053
+ || (continuation === null || continuation === void 0 ? void 0 : continuation.canContinueRun) === true;
1054
+ var canPrepareHotfixPatch = required && (existing.canPrepareHotfixPatch === true || existing.can_prepare_hotfix_patch === true || actionRequiresHotfix || (continuation === null || continuation === void 0 ? void 0 : continuation.action) === 'record_hotfix_evidence');
1055
+ var canHotfixBackend = required && commitProofPassed === true && canPrepareHotfixPatch === true;
1056
+ var status = 'not_required';
1057
+ if (required && liveHotfixBlockedUntilCommit) {
1058
+ status = 'waiting_for_commit_proof';
1059
+ }
1060
+ else if (required && validation.valid && releaseGatePassed) {
1061
+ status = 'ready_for_continuation';
1062
+ }
1063
+ else if (required && validation.valid) {
1064
+ status = 'ready_for_release_gate';
1065
+ }
1066
+ else if (required) {
1067
+ status = 'ready_for_live_hotfix';
1068
+ }
1069
+ var phaseOrder = Array.from(new Set(cleanList(existing.phaseOrder || existing.phase_order, 12, 200).concat([
1070
+ 'prepare_hotfix_patch_without_live_apply',
1071
+ 'commit_and_push_hotfix_to_github',
1072
+ 'record_hotfix_evidence',
1073
+ 'apply_backend_hotfix_only_after_commit_proof',
1074
+ 'run_runner_manager_self_test',
1075
+ 'rerun_smallest_release_gate'
1076
+ ]))).slice(0, 12);
1077
+ var requiredFields = Array.from(new Set(cleanList(existing.requiredFields || existing.required_fields, 20, 200).concat([
1078
+ 'sourceCommitSha',
1079
+ 'githubCommitUrl',
1080
+ 'gitCommitStatus=passed',
1081
+ 'gitPushStatus=passed',
1082
+ 'hotfixPatchDiff',
1083
+ 'restartOrChecksumEvidence',
1084
+ 'releaseGateResult'
1085
+ ]))).slice(0, 20);
1086
+ var requiredEvidence = Array.from(new Set(cleanList(existing.requiredEvidence || existing.required_evidence, 24, 300).concat(requiredFields, validation.requiredEvidence || []))).slice(0, 24);
1087
+ var successCriteria = Array.from(new Set(cleanList(existing.successCriteria || existing.success_criteria, 14, 300).concat([
1088
+ 'Hotfix patch exists without live apply side effects.',
1089
+ 'GitHub commit and push proof are recorded before live hotfix.',
1090
+ 'Backend restart/checksum evidence and runner-manager self-test pass.',
1091
+ 'Only the smallest relevant release gate is rerun after hotfix evidence.'
1092
+ ]))).slice(0, 14);
1093
+ var forbiddenActions = Array.from(new Set(cleanList(existing.forbiddenActions || existing.forbidden_actions, 14, 500).concat([
1094
+ 'Do not apply or restart a live backend before sourceCommitSha, githubCommitUrl, passed gitCommitStatus, and passed gitPushStatus are recorded.',
1095
+ 'Do not run a full server deploy as a substitute for a targeted backend hotfix.',
1096
+ 'Do not continue the ticket from route-only or release-status-only evidence.'
1097
+ ]))).slice(0, 14);
1098
+ var now = cleanDateString(input.now || new Date());
1099
+ var createdAt = cleanDateString(existing.createdAt || existing.created_at || now);
1100
+ var reason = cleanText(input.reason || existing.reason || (continuation === null || continuation === void 0 ? void 0 : continuation.reason) || validation.blockers.join('; '), 1000);
1101
+ var contractId = cleanText(existing.contractId || existing.contract_id, 160)
1102
+ || "hotfix-durability-".concat(fingerprintResolveIOAIManagerBlocker([
1103
+ action,
1104
+ reason,
1105
+ phaseOrder.join('|'),
1106
+ createdAt.slice(0, 16)
1107
+ ].join('\n')).slice(0, 16));
1108
+ var nextSafeAction = !required
1109
+ ? 'continue'
1110
+ : liveHotfixBlockedUntilCommit
1111
+ ? 'commit_and_push_hotfix_to_github'
1112
+ : validation.valid
1113
+ ? (releaseGatePassed ? 'continue_current_runner' : 'rerun_smallest_release_gate')
1114
+ : 'apply_backend_hotfix_only_after_commit_proof';
1115
+ var hotfixCommitGuard = {
1116
+ required: required,
1117
+ blocks_live_hotfix: liveHotfixBlockedUntilCommit,
1118
+ passed: commitProofPassed,
1119
+ status: commitProofPassed ? 'passed' : 'missing',
1120
+ sourceCommitSha: sourceCommitSha,
1121
+ githubCommitUrl: githubCommitUrl,
1122
+ gitCommitStatus: gitCommitStatus,
1123
+ gitPushStatus: gitPushStatus,
1124
+ missingFields: missingCommitProofFields,
1125
+ required_fields: ['sourceCommitSha', 'githubCommitUrl', 'gitCommitStatus=passed', 'gitPushStatus=passed'],
1126
+ next_action: liveHotfixBlockedUntilCommit ? 'commit_and_push_hotfix_to_github' : 'record_hotfix_evidence'
1127
+ };
1128
+ var contract = {
1129
+ contractId: contractId,
1130
+ contract_id: contractId,
1131
+ createdAt: createdAt,
1132
+ created_at: createdAt,
1133
+ updatedAt: now,
1134
+ updated_at: now,
1135
+ source: cleanText(input.source || existing.source || 'ai_manager_hotfix_durability', 160),
1136
+ required: required,
1137
+ action: action,
1138
+ status: status,
1139
+ reason: reason,
1140
+ canPrepareHotfixPatch: canPrepareHotfixPatch,
1141
+ can_prepare_hotfix_patch: canPrepareHotfixPatch,
1142
+ canHotfixBackend: canHotfixBackend,
1143
+ can_hotfix_backend: canHotfixBackend,
1144
+ liveHotfixBlockedUntilCommit: liveHotfixBlockedUntilCommit,
1145
+ live_hotfix_blocked_until_commit: liveHotfixBlockedUntilCommit,
1146
+ commitProofPassed: commitProofPassed,
1147
+ commit_proof_passed: commitProofPassed,
1148
+ commitProofStatus: commitProofPassed ? 'passed' : 'missing',
1149
+ commit_proof_status: commitProofPassed ? 'passed' : 'missing',
1150
+ sourceCommitSha: sourceCommitSha,
1151
+ source_commit_sha: sourceCommitSha,
1152
+ githubCommitUrl: githubCommitUrl,
1153
+ github_commit_url: githubCommitUrl,
1154
+ gitCommitStatus: gitCommitStatus,
1155
+ git_commit_status: gitCommitStatus,
1156
+ gitPushStatus: gitPushStatus,
1157
+ git_push_status: gitPushStatus,
1158
+ missingCommitProofFields: missingCommitProofFields,
1159
+ missing_commit_proof_fields: missingCommitProofFields,
1160
+ nextSafeAction: nextSafeAction,
1161
+ next_safe_action: nextSafeAction,
1162
+ phaseOrder: phaseOrder,
1163
+ phase_order: phaseOrder,
1164
+ requiredFields: requiredFields,
1165
+ required_fields: requiredFields,
1166
+ requiredEvidence: requiredEvidence,
1167
+ required_evidence: requiredEvidence,
1168
+ successCriteria: successCriteria,
1169
+ success_criteria: successCriteria,
1170
+ forbiddenActions: forbiddenActions,
1171
+ forbidden_actions: forbiddenActions,
1172
+ hotfixCommitGuard: hotfixCommitGuard,
1173
+ hotfix_commit_guard: hotfixCommitGuard,
1174
+ githubCommitGuard: __assign(__assign({}, githubCommitGuard), { required: required, passed: commitProofPassed, status: commitProofPassed ? 'passed' : (required ? 'missing' : githubCommitGuard.status), managerMustCommitBeforeHotfix: liveHotfixBlockedUntilCommit, sourceCommitSha: sourceCommitSha, githubCommitUrl: githubCommitUrl, gitCommitStatus: gitCommitStatus, gitPushStatus: gitPushStatus }),
1175
+ github_commit_guard: __assign(__assign({}, githubCommitGuard), { required: required, passed: commitProofPassed, status: commitProofPassed ? 'passed' : (required ? 'missing' : githubCommitGuard.status), managerMustCommitBeforeHotfix: liveHotfixBlockedUntilCommit, sourceCommitSha: sourceCommitSha, githubCommitUrl: githubCommitUrl, gitCommitStatus: gitCommitStatus, gitPushStatus: gitPushStatus }),
1176
+ validation: validation,
1177
+ continuation: continuation,
1178
+ extraRequest: '',
1179
+ extra_request: ''
1180
+ };
1181
+ contract.extraRequest = hotfixDurabilityExtraRequest(contract);
1182
+ contract.extra_request = contract.extraRequest;
1183
+ return contract;
1184
+ }
942
1185
  function decideResolveIOAIManagerHotfixContinuation(input) {
943
- var e_4, _a;
1186
+ var e_7, _a;
944
1187
  var _b, _c;
945
1188
  if (input === void 0) { input = {}; }
946
1189
  var validation = validateResolveIOAIManagerHotfixEvidence(input.evidence, { policy: input.policy });
@@ -975,12 +1218,12 @@ function decideResolveIOAIManagerHotfixContinuation(input) {
975
1218
  }
976
1219
  }
977
1220
  }
978
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1221
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
979
1222
  finally {
980
1223
  try {
981
1224
  if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
982
1225
  }
983
- finally { if (e_4) throw e_4.error; }
1226
+ finally { if (e_7) throw e_7.error; }
984
1227
  }
985
1228
  }
986
1229
  else if (!validation.valid || validation.status === 'missing' || validation.status === 'incomplete') {