@resolveio/server-lib 22.3.137 → 22.3.138
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 +1 -1
- package/util/ai-runner-manager-policy.d.ts +41 -0
- package/util/ai-runner-manager-policy.js +145 -0
- package/util/ai-runner-manager-policy.js.map +1 -1
- package/util/aicoder-runner-v6.d.ts +2 -1
- package/util/aicoder-runner-v6.js +4 -1
- package/util/aicoder-runner-v6.js.map +1 -1
- package/util/support-runner-v5.d.ts +2 -1
- package/util/support-runner-v5.js +4 -1
- package/util/support-runner-v5.js.map +1 -1
package/package.json
CHANGED
|
@@ -114,6 +114,45 @@ export interface ResolveIOAIManagerRecoveryActionPacket {
|
|
|
114
114
|
blockedReason?: string;
|
|
115
115
|
createdAt: string;
|
|
116
116
|
}
|
|
117
|
+
export type ResolveIOAIManagerRecoveryActionDispatchAction = 'run_evidence_probe' | 'run_read_only_diagnosis' | 'run_infra_repair' | 'run_compile_repair' | 'run_journey_contract_repair' | 'run_business_assertion_repair' | 'run_release_repair' | 'run_targeted_product_repair' | 'advance' | 'continue_gate' | 'park_manual';
|
|
118
|
+
export type ResolveIOAIManagerRecoveryActionDispatchStatus = 'queued' | 'started' | 'completed' | 'failed' | 'parked';
|
|
119
|
+
export interface ResolveIOAIManagerRecoveryActionDispatchRecord {
|
|
120
|
+
dispatchId: string;
|
|
121
|
+
actionId: string;
|
|
122
|
+
checkpointId: string;
|
|
123
|
+
probeId: string;
|
|
124
|
+
mode: ResolveIOAIManagerRecoveryAutomationMode;
|
|
125
|
+
dispatchAction: ResolveIOAIManagerRecoveryActionDispatchAction;
|
|
126
|
+
status: ResolveIOAIManagerRecoveryActionDispatchStatus;
|
|
127
|
+
evidenceHash: string;
|
|
128
|
+
blockerFingerprint: string;
|
|
129
|
+
productRepairAllowed: boolean;
|
|
130
|
+
expensiveModelAllowed: boolean;
|
|
131
|
+
reason: string;
|
|
132
|
+
artifactPaths: string[];
|
|
133
|
+
startedAt?: string;
|
|
134
|
+
completedAt?: string;
|
|
135
|
+
createdAt: string;
|
|
136
|
+
}
|
|
137
|
+
export interface ResolveIOAIManagerRecoveryActionDispatchInput {
|
|
138
|
+
action?: ResolveIOAIManagerRecoveryActionPacket;
|
|
139
|
+
history?: ResolveIOAIManagerRecoveryActionDispatchRecord[];
|
|
140
|
+
current?: ResolveIOAIManagerFailureRecord;
|
|
141
|
+
operatorApproved?: boolean;
|
|
142
|
+
now?: Date | string;
|
|
143
|
+
}
|
|
144
|
+
export interface ResolveIOAIManagerRecoveryActionDispatchDecision {
|
|
145
|
+
dispatchAction: ResolveIOAIManagerRecoveryActionDispatchAction;
|
|
146
|
+
allowed: boolean;
|
|
147
|
+
reason: string;
|
|
148
|
+
status: ResolveIOAIManagerRecoveryActionDispatchStatus;
|
|
149
|
+
canRunProductRepair: boolean;
|
|
150
|
+
canRunExpensiveModel: boolean;
|
|
151
|
+
shouldRecordDispatch: boolean;
|
|
152
|
+
requiresNewEvidence: boolean;
|
|
153
|
+
newEvidence: boolean;
|
|
154
|
+
dispatchRecord?: ResolveIOAIManagerRecoveryActionDispatchRecord;
|
|
155
|
+
}
|
|
117
156
|
export interface ResolveIOAIManagerRecoveryCheckpointInput {
|
|
118
157
|
plan: ResolveIOAIManagerRecoveryPlan;
|
|
119
158
|
current?: ResolveIOAIManagerFailureRecord;
|
|
@@ -198,6 +237,8 @@ export declare function hashResolveIOAIManagerEvidence(record: ResolveIOAIManage
|
|
|
198
237
|
export declare function buildResolveIOAIManagerRecoveryCheckpoint(input: ResolveIOAIManagerRecoveryCheckpointInput): ResolveIOAIManagerRecoveryCheckpoint;
|
|
199
238
|
export declare function buildResolveIOAIManagerRecoveryEvidenceProbe(input: ResolveIOAIManagerRecoveryEvidenceProbeInput): ResolveIOAIManagerRecoveryEvidenceProbe;
|
|
200
239
|
export declare function buildResolveIOAIManagerRecoveryActionPacket(input: ResolveIOAIManagerRecoveryActionPacketInput): ResolveIOAIManagerRecoveryActionPacket;
|
|
240
|
+
export declare function decideResolveIOAIManagerRecoveryActionDispatch(input: ResolveIOAIManagerRecoveryActionDispatchInput): ResolveIOAIManagerRecoveryActionDispatchDecision;
|
|
241
|
+
export declare function appendResolveIOAIManagerRecoveryActionDispatch(history: ResolveIOAIManagerRecoveryActionDispatchRecord[] | undefined, record: ResolveIOAIManagerRecoveryActionDispatchRecord | undefined, limit?: number): ResolveIOAIManagerRecoveryActionDispatchRecord[];
|
|
201
242
|
export declare function decideResolveIOAIManagerRecoveryGate(input: ResolveIOAIManagerRecoveryGateInput): ResolveIOAIManagerRecoveryGateDecision;
|
|
202
243
|
export declare function buildResolveIOAIManagerRecoveryPlan(input?: ResolveIOAIManagerRecoveryPlanInput): ResolveIOAIManagerRecoveryPlan;
|
|
203
244
|
export declare function decideResolveIOAIManagerPolicy(input: ResolveIOAIManagerPolicyInput): ResolveIOAIManagerPolicyDecision;
|
|
@@ -53,6 +53,8 @@ exports.hashResolveIOAIManagerEvidence = hashResolveIOAIManagerEvidence;
|
|
|
53
53
|
exports.buildResolveIOAIManagerRecoveryCheckpoint = buildResolveIOAIManagerRecoveryCheckpoint;
|
|
54
54
|
exports.buildResolveIOAIManagerRecoveryEvidenceProbe = buildResolveIOAIManagerRecoveryEvidenceProbe;
|
|
55
55
|
exports.buildResolveIOAIManagerRecoveryActionPacket = buildResolveIOAIManagerRecoveryActionPacket;
|
|
56
|
+
exports.decideResolveIOAIManagerRecoveryActionDispatch = decideResolveIOAIManagerRecoveryActionDispatch;
|
|
57
|
+
exports.appendResolveIOAIManagerRecoveryActionDispatch = appendResolveIOAIManagerRecoveryActionDispatch;
|
|
56
58
|
exports.decideResolveIOAIManagerRecoveryGate = decideResolveIOAIManagerRecoveryGate;
|
|
57
59
|
exports.buildResolveIOAIManagerRecoveryPlan = buildResolveIOAIManagerRecoveryPlan;
|
|
58
60
|
exports.decideResolveIOAIManagerPolicy = decideResolveIOAIManagerPolicy;
|
|
@@ -417,6 +419,149 @@ function buildResolveIOAIManagerRecoveryActionPacket(input) {
|
|
|
417
419
|
stopWhen: stopWhen
|
|
418
420
|
} }, (mode === 'collect_evidence' ? { blockedReason: 'Manager parked this loop until the recovery action records new evidence.' } : {})), { createdAt: now });
|
|
419
421
|
}
|
|
422
|
+
function dispatchActionForMode(mode) {
|
|
423
|
+
var map = {
|
|
424
|
+
advance: 'advance',
|
|
425
|
+
collect_evidence: 'run_evidence_probe',
|
|
426
|
+
read_only_diagnosis: 'run_read_only_diagnosis',
|
|
427
|
+
repair_infra: 'run_infra_repair',
|
|
428
|
+
repair_compile: 'run_compile_repair',
|
|
429
|
+
repair_journey_contract: 'run_journey_contract_repair',
|
|
430
|
+
repair_business_assertion: 'run_business_assertion_repair',
|
|
431
|
+
repair_release: 'run_release_repair',
|
|
432
|
+
targeted_product_repair: 'run_targeted_product_repair',
|
|
433
|
+
manual_review: 'park_manual',
|
|
434
|
+
continue_gate: 'continue_gate'
|
|
435
|
+
};
|
|
436
|
+
return map[mode] || 'park_manual';
|
|
437
|
+
}
|
|
438
|
+
function buildRecoveryDispatchRecord(action, dispatchAction, status, reason, current, now) {
|
|
439
|
+
var evidenceHash = (current === null || current === void 0 ? void 0 : current.evidenceHash) || action.checkpointId || action.actionId;
|
|
440
|
+
var blockerFingerprint = resolveResolveIOAIManagerBlockerFingerprint(current, action.objective);
|
|
441
|
+
var artifactPaths = cleanList(current === null || current === void 0 ? void 0 : current.artifactPaths, 20, 500);
|
|
442
|
+
var createdAt = isoNow(now);
|
|
443
|
+
return __assign(__assign(__assign({ dispatchId: stableHash('mgr-dispatch', {
|
|
444
|
+
actionId: action.actionId,
|
|
445
|
+
dispatchAction: dispatchAction,
|
|
446
|
+
evidenceHash: evidenceHash,
|
|
447
|
+
blockerFingerprint: blockerFingerprint,
|
|
448
|
+
status: status
|
|
449
|
+
}), actionId: action.actionId, checkpointId: action.checkpointId, probeId: action.probeId, mode: action.mode, dispatchAction: dispatchAction, status: status, evidenceHash: evidenceHash, blockerFingerprint: blockerFingerprint, productRepairAllowed: action.productRepairAllowed && dispatchAction === 'run_targeted_product_repair', expensiveModelAllowed: action.expensiveModelAllowed && dispatchAction !== 'run_evidence_probe', reason: reason, artifactPaths: artifactPaths }, (status === 'started' ? { startedAt: createdAt } : {})), (status === 'completed' ? { completedAt: createdAt } : {})), { createdAt: createdAt });
|
|
450
|
+
}
|
|
451
|
+
function decideResolveIOAIManagerRecoveryActionDispatch(input) {
|
|
452
|
+
var action = input.action;
|
|
453
|
+
var history = Array.isArray(input.history) ? input.history.filter(Boolean).slice(-50) : [];
|
|
454
|
+
var current = input.current || {};
|
|
455
|
+
if (!action) {
|
|
456
|
+
return {
|
|
457
|
+
dispatchAction: 'park_manual',
|
|
458
|
+
allowed: false,
|
|
459
|
+
reason: 'recovery_dispatch_missing_action',
|
|
460
|
+
status: 'parked',
|
|
461
|
+
canRunProductRepair: false,
|
|
462
|
+
canRunExpensiveModel: false,
|
|
463
|
+
shouldRecordDispatch: false,
|
|
464
|
+
requiresNewEvidence: true,
|
|
465
|
+
newEvidence: false
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
var dispatchAction = dispatchActionForMode(action.mode);
|
|
469
|
+
var evidenceHash = current.evidenceHash || action.checkpointId || action.actionId;
|
|
470
|
+
var blockerFingerprint = resolveResolveIOAIManagerBlockerFingerprint(current, action.objective);
|
|
471
|
+
var sameActionHistory = history.filter(function (entry) { return entry.actionId === action.actionId; });
|
|
472
|
+
var sameEvidenceHistory = sameActionHistory.filter(function (entry) { return entry.evidenceHash === evidenceHash
|
|
473
|
+
&& entry.blockerFingerprint === blockerFingerprint; });
|
|
474
|
+
var activeDispatch = sameEvidenceHistory.find(function (entry) { return entry.status === 'queued' || entry.status === 'started'; });
|
|
475
|
+
var completedDispatch = sameEvidenceHistory.find(function (entry) { return entry.status === 'completed' || entry.status === 'failed'; });
|
|
476
|
+
var newEvidence = sameActionHistory.length > 0 && sameEvidenceHistory.length === 0;
|
|
477
|
+
var requiresNewEvidence = action.retryPolicy.requireNewEvidence === true;
|
|
478
|
+
var manualOnly = action.mode === 'manual_review' || !action.autoRunnable;
|
|
479
|
+
var productDispatch = dispatchAction === 'run_targeted_product_repair';
|
|
480
|
+
var expensiveDispatch = !['run_evidence_probe', 'advance', 'continue_gate', 'park_manual'].includes(dispatchAction);
|
|
481
|
+
if (manualOnly && input.operatorApproved !== true) {
|
|
482
|
+
var record_1 = buildRecoveryDispatchRecord(action, 'park_manual', 'parked', 'recovery_dispatch_requires_manual_review', current, input.now);
|
|
483
|
+
return {
|
|
484
|
+
dispatchAction: 'park_manual',
|
|
485
|
+
allowed: false,
|
|
486
|
+
reason: record_1.reason,
|
|
487
|
+
status: 'parked',
|
|
488
|
+
canRunProductRepair: false,
|
|
489
|
+
canRunExpensiveModel: false,
|
|
490
|
+
shouldRecordDispatch: true,
|
|
491
|
+
requiresNewEvidence: requiresNewEvidence,
|
|
492
|
+
newEvidence: newEvidence,
|
|
493
|
+
dispatchRecord: record_1
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
if (productDispatch && action.productRepairAllowed !== true) {
|
|
497
|
+
var record_2 = buildRecoveryDispatchRecord(action, 'park_manual', 'parked', 'recovery_dispatch_product_repair_not_allowed', current, input.now);
|
|
498
|
+
return {
|
|
499
|
+
dispatchAction: 'park_manual',
|
|
500
|
+
allowed: false,
|
|
501
|
+
reason: record_2.reason,
|
|
502
|
+
status: 'parked',
|
|
503
|
+
canRunProductRepair: false,
|
|
504
|
+
canRunExpensiveModel: false,
|
|
505
|
+
shouldRecordDispatch: true,
|
|
506
|
+
requiresNewEvidence: true,
|
|
507
|
+
newEvidence: newEvidence,
|
|
508
|
+
dispatchRecord: record_2
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
if (activeDispatch) {
|
|
512
|
+
return {
|
|
513
|
+
dispatchAction: 'park_manual',
|
|
514
|
+
allowed: false,
|
|
515
|
+
reason: 'recovery_dispatch_already_running_for_same_evidence',
|
|
516
|
+
status: 'parked',
|
|
517
|
+
canRunProductRepair: false,
|
|
518
|
+
canRunExpensiveModel: false,
|
|
519
|
+
shouldRecordDispatch: false,
|
|
520
|
+
requiresNewEvidence: true,
|
|
521
|
+
newEvidence: false
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
if (completedDispatch && requiresNewEvidence && !newEvidence) {
|
|
525
|
+
var record_3 = buildRecoveryDispatchRecord(action, 'park_manual', 'parked', 'recovery_dispatch_same_evidence_already_attempted', current, input.now);
|
|
526
|
+
return {
|
|
527
|
+
dispatchAction: 'park_manual',
|
|
528
|
+
allowed: false,
|
|
529
|
+
reason: record_3.reason,
|
|
530
|
+
status: 'parked',
|
|
531
|
+
canRunProductRepair: false,
|
|
532
|
+
canRunExpensiveModel: false,
|
|
533
|
+
shouldRecordDispatch: true,
|
|
534
|
+
requiresNewEvidence: true,
|
|
535
|
+
newEvidence: false,
|
|
536
|
+
dispatchRecord: record_3
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
var status = dispatchAction === 'advance' || dispatchAction === 'continue_gate'
|
|
540
|
+
? 'completed'
|
|
541
|
+
: 'started';
|
|
542
|
+
var record = buildRecoveryDispatchRecord(action, dispatchAction, status, 'recovery_dispatch_allowed', current, input.now);
|
|
543
|
+
return {
|
|
544
|
+
dispatchAction: dispatchAction,
|
|
545
|
+
allowed: true,
|
|
546
|
+
reason: 'recovery_dispatch_allowed',
|
|
547
|
+
status: status,
|
|
548
|
+
canRunProductRepair: productDispatch && action.productRepairAllowed === true,
|
|
549
|
+
canRunExpensiveModel: expensiveDispatch && action.expensiveModelAllowed === true,
|
|
550
|
+
shouldRecordDispatch: true,
|
|
551
|
+
requiresNewEvidence: requiresNewEvidence,
|
|
552
|
+
newEvidence: newEvidence,
|
|
553
|
+
dispatchRecord: record
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
function appendResolveIOAIManagerRecoveryActionDispatch(history, record, limit) {
|
|
557
|
+
if (limit === void 0) { limit = 50; }
|
|
558
|
+
var existing = Array.isArray(history) ? history.filter(Boolean) : [];
|
|
559
|
+
if (!record) {
|
|
560
|
+
return existing.slice(-limit);
|
|
561
|
+
}
|
|
562
|
+
var deduped = existing.filter(function (entry) { return entry.dispatchId !== record.dispatchId; });
|
|
563
|
+
return __spreadArray(__spreadArray([], __read(deduped), false), [record], false).slice(-limit);
|
|
564
|
+
}
|
|
420
565
|
function listHasNewEntry(current, previous) {
|
|
421
566
|
var existing = new Set(previous.map(function (entry) { return cleanText(entry, 500); }).filter(Boolean));
|
|
422
567
|
return current.some(function (entry) {
|