@resolveio/server-lib 22.3.165 → 22.3.167
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 +2 -1
- package/util/ai-run-evidence-adapters.js +159 -17
- package/util/ai-run-evidence-adapters.js.map +1 -1
- package/util/ai-run-evidence.js +11 -0
- package/util/ai-run-evidence.js.map +1 -1
- package/util/support-runner-v5.d.ts +24 -0
- package/util/support-runner-v5.js +84 -0
- package/util/support-runner-v5.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@resolveio/server-lib",
|
|
3
|
-
"version": "22.3.
|
|
3
|
+
"version": "22.3.167",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"package": "./build_package.sh",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"method-publication-generator-test": "node --require ts-node/register tests/method-publication-generator.test.ts",
|
|
29
29
|
"ai-run-evidence-test": "node --require ts-node/register tests/ai-run-evidence.test.ts",
|
|
30
30
|
"ai-run-eval-test": "node --require ts-node/register tests/ai-run-eval.test.ts",
|
|
31
|
+
"support-runner-v5-test": "node --require ts-node/register tests/support-runner-v5.test.ts",
|
|
31
32
|
"ai-assistant-nightly-eval": "npm run ai-assistant-corpus-build && npm run ai-assistant-data-parity-e2e && npm run ai-assistant-corpus-replay-e2e && npm run ai-assistant-eval-triage"
|
|
32
33
|
},
|
|
33
34
|
"author": "",
|
|
@@ -54,6 +54,7 @@ exports.buildAssistantAIRunFromEvidence = buildAssistantAIRunFromEvidence;
|
|
|
54
54
|
var ai_run_evidence_1 = require("./ai-run-evidence");
|
|
55
55
|
var aicoder_runner_v6_1 = require("./aicoder-runner-v6");
|
|
56
56
|
var ai_runner_manager_policy_1 = require("./ai-runner-manager-policy");
|
|
57
|
+
var support_runner_v5_1 = require("./support-runner-v5");
|
|
57
58
|
function cleanText(value, max) {
|
|
58
59
|
if (max === void 0) { max = 1000; }
|
|
59
60
|
return String(value || '').replace(/\s+/g, ' ').trim().slice(0, max);
|
|
@@ -1202,6 +1203,124 @@ function applySupportDiagnosisProofGate(qa, diagnosisGate, now) {
|
|
|
1202
1203
|
gate
|
|
1203
1204
|
], false) });
|
|
1204
1205
|
}
|
|
1206
|
+
var SUPPORT_PRODUCT_REPAIR_STEP_TYPES = new Set([
|
|
1207
|
+
'build_repair',
|
|
1208
|
+
'owner_scoped_repair',
|
|
1209
|
+
'product_repair',
|
|
1210
|
+
'code_repair'
|
|
1211
|
+
]);
|
|
1212
|
+
var SUPPORT_PRODUCT_REPAIR_ACTIONS = new Set([
|
|
1213
|
+
'run_owner_scoped_repair',
|
|
1214
|
+
'run_targeted_product_repair',
|
|
1215
|
+
'allow_product_repair'
|
|
1216
|
+
]);
|
|
1217
|
+
function supportSourceEditFiles(value) {
|
|
1218
|
+
return cleanStringList(value, 80, 500)
|
|
1219
|
+
.filter(function (filePath) {
|
|
1220
|
+
var normalized = filePath.replace(/\\/g, '/').toLowerCase();
|
|
1221
|
+
if (!normalized || /(^|\/)(qa-artifacts|runner-evidence|logs?|tmp|dist|node_modules)(\/|$)/.test(normalized)) {
|
|
1222
|
+
return false;
|
|
1223
|
+
}
|
|
1224
|
+
return /\.(?:ts|tsx|js|jsx|html|scss|css|json|mjs|cjs|vue|svelte|md)$/i.test(normalized);
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
function supportRepairActivityFromRecord(value, source, index) {
|
|
1228
|
+
var record = plainObject(value);
|
|
1229
|
+
if (!Object.keys(record).length) {
|
|
1230
|
+
return undefined;
|
|
1231
|
+
}
|
|
1232
|
+
var stepType = cleanText(record.stepType || record.step_type || record.type, 120);
|
|
1233
|
+
var action = cleanText(record.action || record.primaryAction || record.primary_action || record.allowedDispatchAction || record.allowed_dispatch_action, 120);
|
|
1234
|
+
var lane = cleanText(record.lane || record.phase || record.category, 120).toLowerCase();
|
|
1235
|
+
var changedFiles = supportSourceEditFiles(record.changedFiles
|
|
1236
|
+
|| record.changed_files
|
|
1237
|
+
|| record.modifiedFiles
|
|
1238
|
+
|| record.modified_files
|
|
1239
|
+
|| record.editedFiles
|
|
1240
|
+
|| record.edited_files
|
|
1241
|
+
|| record.files);
|
|
1242
|
+
var explicitProductRepair = SUPPORT_PRODUCT_REPAIR_STEP_TYPES.has(stepType)
|
|
1243
|
+
|| SUPPORT_PRODUCT_REPAIR_ACTIONS.has(action)
|
|
1244
|
+
|| (lane === 'build' && changedFiles.length > 0);
|
|
1245
|
+
if (!explicitProductRepair) {
|
|
1246
|
+
return undefined;
|
|
1247
|
+
}
|
|
1248
|
+
var activityRef = cleanText(record.microtaskId
|
|
1249
|
+
|| record.microtask_id
|
|
1250
|
+
|| record.taskId
|
|
1251
|
+
|| record.task_id
|
|
1252
|
+
|| record.jobId
|
|
1253
|
+
|| record.job_id
|
|
1254
|
+
|| record._id
|
|
1255
|
+
|| record.id
|
|
1256
|
+
|| "".concat(source, ":").concat(index), 240);
|
|
1257
|
+
return { changedFiles: changedFiles, activityRef: activityRef };
|
|
1258
|
+
}
|
|
1259
|
+
function supportProductRepairEvidence(input, evidence) {
|
|
1260
|
+
var job = input.job || {};
|
|
1261
|
+
var records = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(job.supportV5StepHistory)), false), __read(asArray(job.support_v5_step_history)), false), __read(asArray(job.stepHistory)), false), __read(asArray(job.step_history)), false), __read(asArray(evidence.supportV5StepHistory)), false), __read(asArray(evidence.support_v5_step_history)), false), __read(asArray(evidence.stepHistory)), false), __read(asArray(evidence.step_history)), false), __read(asArray(input.taskEvents)), false), __read(asArray(input.aiJobs)), false), __read(asArray(input.buildPlans)), false);
|
|
1262
|
+
var activityRefs = [];
|
|
1263
|
+
var changedFiles = [];
|
|
1264
|
+
var activityCount = 0;
|
|
1265
|
+
records.forEach(function (record, index) {
|
|
1266
|
+
var activity = supportRepairActivityFromRecord(record, 'support_repair_activity', index);
|
|
1267
|
+
if (!activity) {
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
activityCount += 1;
|
|
1271
|
+
if (activity.activityRef) {
|
|
1272
|
+
activityRefs.push(activity.activityRef);
|
|
1273
|
+
}
|
|
1274
|
+
changedFiles.push.apply(changedFiles, __spreadArray([], __read(activity.changedFiles), false));
|
|
1275
|
+
});
|
|
1276
|
+
var directChangedFiles = supportSourceEditFiles(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(job.changedFiles)), false), __read(asArray(job.changed_files)), false), __read(asArray(job.modifiedFiles)), false), __read(asArray(job.modified_files)), false), __read(asArray(job.editedFiles)), false), __read(asArray(job.edited_files)), false), __read(asArray(evidence.changedFiles)), false), __read(asArray(evidence.changed_files)), false), __read(asArray(evidence.modifiedFiles)), false), __read(asArray(evidence.modified_files)), false), __read(asArray(evidence.editedFiles)), false), __read(asArray(evidence.edited_files)), false), __read(asArray(input.commits).flatMap(function (commit) { return asArray(commit.changedFiles || commit.changed_files || commit.files); })), false));
|
|
1277
|
+
if (directChangedFiles.length) {
|
|
1278
|
+
activityCount += 1;
|
|
1279
|
+
activityRefs.push('changed_files');
|
|
1280
|
+
changedFiles.push.apply(changedFiles, __spreadArray([], __read(directChangedFiles), false));
|
|
1281
|
+
}
|
|
1282
|
+
var uniqueChangedFiles = Array.from(new Set(changedFiles.map(function (filePath) { return cleanText(filePath, 500); }).filter(Boolean))).slice(0, 80);
|
|
1283
|
+
return {
|
|
1284
|
+
attempted: activityCount > 0,
|
|
1285
|
+
changedFiles: uniqueChangedFiles,
|
|
1286
|
+
activityRefs: Array.from(new Set(activityRefs.map(function (ref) { return cleanText(ref, 240); }).filter(Boolean))).slice(0, 40),
|
|
1287
|
+
activityCount: activityCount
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
function supportDiagnosisBeforeRepairGate(diagnosisGate, repairEvidence, now) {
|
|
1291
|
+
var _a, _b;
|
|
1292
|
+
if (!repairEvidence.attempted) {
|
|
1293
|
+
return undefined;
|
|
1294
|
+
}
|
|
1295
|
+
var validation = (0, support_runner_v5_1.validateResolveIOSupportDiagnosisGate)(diagnosisGate);
|
|
1296
|
+
var status = validation.valid ? 'pass' : 'blocked';
|
|
1297
|
+
return {
|
|
1298
|
+
key: 'support_diagnosis_before_repair',
|
|
1299
|
+
label: 'Support diagnosis before repair',
|
|
1300
|
+
status: status,
|
|
1301
|
+
reason: validation.valid
|
|
1302
|
+
? 'Support product repair has a valid root-cause diagnosis gate and owner-file scope.'
|
|
1303
|
+
: 'Support product repair is blocked until a valid SupportDiagnosisGate records reproduction/classification, accepted hypothesis, rejected alternatives, owner_files, and before/action/after proof.',
|
|
1304
|
+
evidenceRefs: repairEvidence.changedFiles,
|
|
1305
|
+
recordedAt: isoNow(now),
|
|
1306
|
+
metadata: {
|
|
1307
|
+
repairAttempted: true,
|
|
1308
|
+
activityCount: repairEvidence.activityCount,
|
|
1309
|
+
activityRefs: repairEvidence.activityRefs,
|
|
1310
|
+
changedFiles: repairEvidence.changedFiles,
|
|
1311
|
+
diagnosisValid: validation.valid,
|
|
1312
|
+
diagnosisStatus: validation.status,
|
|
1313
|
+
blockers: validation.blockers,
|
|
1314
|
+
ownerFiles: ((_a = validation.normalized) === null || _a === void 0 ? void 0 : _a.owner_files) || [],
|
|
1315
|
+
issueClass: (_b = validation.normalized) === null || _b === void 0 ? void 0 : _b.issue_class,
|
|
1316
|
+
productRepairAllowed: validation.valid,
|
|
1317
|
+
allowedDispatchAction: validation.valid ? 'run_owner_scoped_repair' : 'run_read_only_diagnosis',
|
|
1318
|
+
requiredEvidence: validation.valid
|
|
1319
|
+
? ['AIQaBusinessAssertion mapped to diagnosis proof_plan before acceptance']
|
|
1320
|
+
: ['support_diagnosis_gate JSON', 'reproduction or blocked-reproduction reason', 'accepted_hypothesis with evidence', 'owner_files', 'proof_plan before/action/after']
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1205
1324
|
function evidenceObject() {
|
|
1206
1325
|
var e_23, _a;
|
|
1207
1326
|
var values = [];
|
|
@@ -1899,7 +2018,7 @@ function applyAssistantAnswerQualityGate(qa, decision, now) {
|
|
|
1899
2018
|
}
|
|
1900
2019
|
function buildSupportAIRunFromEvidence(input) {
|
|
1901
2020
|
var e_28, _a, e_29, _b;
|
|
1902
|
-
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
2021
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
1903
2022
|
var ticket = input.ticket || {};
|
|
1904
2023
|
var job = input.job || {};
|
|
1905
2024
|
var evidence = buildSupportQaEvidence(input);
|
|
@@ -1911,8 +2030,8 @@ function buildSupportAIRunFromEvidence(input) {
|
|
|
1911
2030
|
addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
|
|
1912
2031
|
addSourceId(sourceIds, 'buildPlanId', job.buildPlanId || ticket.buildPlanId);
|
|
1913
2032
|
try {
|
|
1914
|
-
for (var
|
|
1915
|
-
var event_1 =
|
|
2033
|
+
for (var _z = __values(asArray(input.taskEvents)), _0 = _z.next(); !_0.done; _0 = _z.next()) {
|
|
2034
|
+
var event_1 = _0.value;
|
|
1916
2035
|
pushEvent(events, {
|
|
1917
2036
|
type: event_1.type === 'human_intervention' ? 'human_intervention' : 'log',
|
|
1918
2037
|
category: cleanText(event_1.category || event_1.phase || event_1.type, 160),
|
|
@@ -1929,13 +2048,13 @@ function buildSupportAIRunFromEvidence(input) {
|
|
|
1929
2048
|
catch (e_28_1) { e_28 = { error: e_28_1 }; }
|
|
1930
2049
|
finally {
|
|
1931
2050
|
try {
|
|
1932
|
-
if (
|
|
2051
|
+
if (_0 && !_0.done && (_a = _z.return)) _a.call(_z);
|
|
1933
2052
|
}
|
|
1934
2053
|
finally { if (e_28) throw e_28.error; }
|
|
1935
2054
|
}
|
|
1936
2055
|
try {
|
|
1937
|
-
for (var
|
|
1938
|
-
var aiJob =
|
|
2056
|
+
for (var _1 = __values(asArray(input.aiJobs)), _2 = _1.next(); !_2.done; _2 = _1.next()) {
|
|
2057
|
+
var aiJob = _2.value;
|
|
1939
2058
|
pushEvent(events, {
|
|
1940
2059
|
type: aiJob.model ? 'model_call' : 'log',
|
|
1941
2060
|
category: cleanText(aiJob.category || aiJob.phase || aiJob.runner, 160),
|
|
@@ -1953,7 +2072,7 @@ function buildSupportAIRunFromEvidence(input) {
|
|
|
1953
2072
|
catch (e_29_1) { e_29 = { error: e_29_1 }; }
|
|
1954
2073
|
finally {
|
|
1955
2074
|
try {
|
|
1956
|
-
if (
|
|
2075
|
+
if (_2 && !_2.done && (_b = _1.return)) _b.call(_1);
|
|
1957
2076
|
}
|
|
1958
2077
|
finally { if (e_29) throw e_29.error; }
|
|
1959
2078
|
}
|
|
@@ -2014,6 +2133,19 @@ function buildSupportAIRunFromEvidence(input) {
|
|
|
2014
2133
|
}
|
|
2015
2134
|
var cost = collectUsageEvents(asArray(input.usageLedger), events);
|
|
2016
2135
|
var diagnosisGate = evidenceObject(job.supportV5DiagnosisGate, job.support_v5_diagnosis_gate, job.diagnosisGate, ticket.supportV5DiagnosisGate, ticket.diagnosisGate, evidence.diagnosisGate, evidence.supportV5DiagnosisGate);
|
|
2136
|
+
var productRepairEvidence = supportProductRepairEvidence(input, evidence);
|
|
2137
|
+
var diagnosisBeforeRepairGate = supportDiagnosisBeforeRepairGate(diagnosisGate, productRepairEvidence, input.now);
|
|
2138
|
+
if (diagnosisBeforeRepairGate) {
|
|
2139
|
+
gates.push(diagnosisBeforeRepairGate);
|
|
2140
|
+
pushEvent(events, {
|
|
2141
|
+
type: 'log',
|
|
2142
|
+
category: 'support_diagnosis_before_repair',
|
|
2143
|
+
message: diagnosisBeforeRepairGate.reason,
|
|
2144
|
+
artifactPaths: diagnosisBeforeRepairGate.evidenceRefs,
|
|
2145
|
+
recordedAt: diagnosisBeforeRepairGate.recordedAt,
|
|
2146
|
+
metadata: diagnosisBeforeRepairGate.metadata
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2017
2149
|
var qa = applySupportDiagnosisProofGate(buildQaFromEvidence(evidence, input.now), diagnosisGate, input.now);
|
|
2018
2150
|
var diagnosisOwnerFiles = asArray(diagnosisGate.owner_files || diagnosisGate.ownerFiles);
|
|
2019
2151
|
var diagnosisIssueClass = cleanText(diagnosisGate.issue_class || diagnosisGate.issueClass, 120);
|
|
@@ -2055,20 +2187,30 @@ function buildSupportAIRunFromEvidence(input) {
|
|
|
2055
2187
|
versionCount: asArray(input.versions).length,
|
|
2056
2188
|
buildPlanCount: asArray(input.buildPlans).length,
|
|
2057
2189
|
managerNoBlindLoopPolicy: managerNoBlindLoopMetadata(noBlindLoopGate),
|
|
2190
|
+
diagnosisBeforeRepair: diagnosisBeforeRepairGate ? {
|
|
2191
|
+
status: diagnosisBeforeRepairGate.status,
|
|
2192
|
+
diagnosisValid: ((_e = diagnosisBeforeRepairGate.metadata) === null || _e === void 0 ? void 0 : _e.diagnosisValid) === true,
|
|
2193
|
+
diagnosisStatus: cleanText((_f = diagnosisBeforeRepairGate.metadata) === null || _f === void 0 ? void 0 : _f.diagnosisStatus, 120),
|
|
2194
|
+
activityCount: Number(((_g = diagnosisBeforeRepairGate.metadata) === null || _g === void 0 ? void 0 : _g.activityCount) || 0),
|
|
2195
|
+
changedFiles: cleanStringList((_h = diagnosisBeforeRepairGate.metadata) === null || _h === void 0 ? void 0 : _h.changedFiles, 40, 500),
|
|
2196
|
+
allowedDispatchAction: cleanText((_j = diagnosisBeforeRepairGate.metadata) === null || _j === void 0 ? void 0 : _j.allowedDispatchAction, 160),
|
|
2197
|
+
productRepairAllowed: ((_k = diagnosisBeforeRepairGate.metadata) === null || _k === void 0 ? void 0 : _k.productRepairAllowed) === true,
|
|
2198
|
+
blockers: cleanStringList((_l = diagnosisBeforeRepairGate.metadata) === null || _l === void 0 ? void 0 : _l.blockers, 20, 500)
|
|
2199
|
+
} : undefined,
|
|
2058
2200
|
rootCauseEntryContract: Object.keys(rootCauseEntryContract).length ? {
|
|
2059
2201
|
contractId: cleanText(rootCauseEntryContract.contract_id || rootCauseEntryContract.contractId, 160),
|
|
2060
2202
|
version: cleanText(rootCauseEntryContract.version, 120),
|
|
2061
2203
|
status: cleanText(rootCauseEntryContract.status, 120),
|
|
2062
2204
|
issueClassProbeCount: asArray(rootCauseEntryContract.issue_class_probes || rootCauseEntryContract.issueClassProbes).length,
|
|
2063
|
-
ownerFileMax: Number(((
|
|
2064
|
-
requiresBusinessAssertion: ((
|
|
2065
|
-
|| ((
|
|
2205
|
+
ownerFileMax: Number(((_m = rootCauseEntryContract.owner_file_policy) === null || _m === void 0 ? void 0 : _m.max_files) || ((_o = rootCauseEntryContract.ownerFilePolicy) === null || _o === void 0 ? void 0 : _o.maxFiles) || 0) || 0,
|
|
2206
|
+
requiresBusinessAssertion: ((_p = rootCauseEntryContract.business_proof_policy) === null || _p === void 0 ? void 0 : _p.requires_aiqa_business_assertion) === true
|
|
2207
|
+
|| ((_q = rootCauseEntryContract.businessProofPolicy) === null || _q === void 0 ? void 0 : _q.requiresAiqaBusinessAssertion) === true
|
|
2066
2208
|
} : undefined,
|
|
2067
2209
|
diagnosis: Object.keys(diagnosisGate).length ? {
|
|
2068
2210
|
status: cleanText(diagnosisGate.status, 80),
|
|
2069
2211
|
issueClass: diagnosisIssueClass,
|
|
2070
2212
|
ownerFiles: diagnosisOwnerFiles,
|
|
2071
|
-
acceptedHypothesis: cleanText(((
|
|
2213
|
+
acceptedHypothesis: cleanText(((_r = diagnosisGate.accepted_hypothesis) === null || _r === void 0 ? void 0 : _r.statement) || ((_s = diagnosisGate.acceptedHypothesis) === null || _s === void 0 ? void 0 : _s.statement), 1000),
|
|
2072
2214
|
proofPlan: diagnosisGate.proof_plan || diagnosisGate.proofPlan
|
|
2073
2215
|
} : undefined,
|
|
2074
2216
|
businessProofReadiness: Object.keys(businessProofReadiness).length ? {
|
|
@@ -2083,12 +2225,12 @@ function buildSupportAIRunFromEvidence(input) {
|
|
|
2083
2225
|
canDraftCustomerReply: customerReplyPolicy.canDraftCustomerReply === true || customerReplyPolicy.can_draft_customer_reply === true,
|
|
2084
2226
|
canSendCustomerReply: customerReplyPolicy.canSendCustomerReply === true || customerReplyPolicy.can_send_customer_reply === true,
|
|
2085
2227
|
reason: cleanText(customerReplyPolicy.reason, 1000),
|
|
2086
|
-
reviewType: cleanText(((
|
|
2087
|
-
|| ((
|
|
2088
|
-
|| ((
|
|
2089
|
-
primaryAction: cleanText(((
|
|
2090
|
-
|| ((
|
|
2091
|
-
|| ((
|
|
2228
|
+
reviewType: cleanText(((_t = customerReplyPolicy.humanReviewPacket) === null || _t === void 0 ? void 0 : _t.reviewType)
|
|
2229
|
+
|| ((_u = customerReplyPolicy.human_review_packet) === null || _u === void 0 ? void 0 : _u.review_type)
|
|
2230
|
+
|| ((_v = customerReplyPolicy.human_review_packet) === null || _v === void 0 ? void 0 : _v.reviewType), 160),
|
|
2231
|
+
primaryAction: cleanText(((_w = customerReplyPolicy.humanReviewPacket) === null || _w === void 0 ? void 0 : _w.primaryAction)
|
|
2232
|
+
|| ((_x = customerReplyPolicy.human_review_packet) === null || _x === void 0 ? void 0 : _x.primary_action)
|
|
2233
|
+
|| ((_y = customerReplyPolicy.human_review_packet) === null || _y === void 0 ? void 0 : _y.primaryAction), 160)
|
|
2092
2234
|
} : undefined
|
|
2093
2235
|
}
|
|
2094
2236
|
});
|