@akagilnc/pi-workflow-roles 0.1.2369 → 0.1.2379
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/dist/public-cli/main.js +690 -590
- package/package.json +1 -1
- package/resources/engines/agy.md +10 -2
- package/src/analyst-gate-cycles-read.ts +45 -5
- package/src/public-cli/settlement.ts +191 -71
- package/src/public-cli/terminal.ts +57 -0
package/dist/public-cli/main.js
CHANGED
|
@@ -20004,6 +20004,17 @@ function formatTerminalResult(result2) {
|
|
|
20004
20004
|
for (const artifact of result2.artifacts) {
|
|
20005
20005
|
lines.push(`artifact ${artifact.kind} ${encodeTerminalField(artifact.path)}`);
|
|
20006
20006
|
}
|
|
20007
|
+
if (result2.menxia !== void 0) {
|
|
20008
|
+
lines.push(
|
|
20009
|
+
`menxia ${encodeTerminalField(result2.menxia.actualSeats.join(","))} ${result2.menxia.rounds.length}`
|
|
20010
|
+
);
|
|
20011
|
+
for (const round of result2.menxia.rounds) {
|
|
20012
|
+
const reason = round.dispatch.reason === void 0 ? "" : encodeTerminalField(round.dispatch.reason);
|
|
20013
|
+
lines.push(
|
|
20014
|
+
`menxia-round ${round.roundIndex} ${round.dispatch.status} ${round.dispatch.officer} ${reason} ${round.officer.seat} ${encodeTerminalField(round.officer.status)} ${encodeTerminalField(JSON.stringify(round.officer.findings))}`
|
|
20015
|
+
);
|
|
20016
|
+
}
|
|
20017
|
+
}
|
|
20007
20018
|
if (result2.resume !== void 0) {
|
|
20008
20019
|
lines.push(`resume ${encodeTerminalField(result2.resume.command)}`);
|
|
20009
20020
|
} else if (result2.runId !== void 0) {
|
|
@@ -20028,6 +20039,372 @@ var init_terminal = __esm({
|
|
|
20028
20039
|
}
|
|
20029
20040
|
});
|
|
20030
20041
|
|
|
20042
|
+
// src/ledger-session-read.ts
|
|
20043
|
+
import { readFile as readFile9 } from "node:fs/promises";
|
|
20044
|
+
function isRecord5(value) {
|
|
20045
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20046
|
+
}
|
|
20047
|
+
async function readLedgerSessionJsonl(path) {
|
|
20048
|
+
const text = await readFile9(path, "utf8");
|
|
20049
|
+
const lines = text.split("\n");
|
|
20050
|
+
const rows = [];
|
|
20051
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
20052
|
+
const line2 = lines[index];
|
|
20053
|
+
if (!line2.trim()) continue;
|
|
20054
|
+
let row;
|
|
20055
|
+
try {
|
|
20056
|
+
row = JSON.parse(line2);
|
|
20057
|
+
} catch (error) {
|
|
20058
|
+
if (!(error instanceof SyntaxError)) throw error;
|
|
20059
|
+
const completedByTerminator = index < lines.length - 1;
|
|
20060
|
+
if (completedByTerminator) {
|
|
20061
|
+
throw new LedgerSessionJsonlError(
|
|
20062
|
+
`malformed JSONL record in ${path} at line ${index + 1}: ${error.message}`,
|
|
20063
|
+
{ path, line: index + 1, prefixRows: rows }
|
|
20064
|
+
);
|
|
20065
|
+
}
|
|
20066
|
+
break;
|
|
20067
|
+
}
|
|
20068
|
+
if (!isRecord5(row)) {
|
|
20069
|
+
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
20070
|
+
throw new LedgerSessionJsonlError(
|
|
20071
|
+
`complete non-object JSONL record in ${path} at line ${index + 1}: expected object, got ${kind}`,
|
|
20072
|
+
{ path, line: index + 1, prefixRows: rows }
|
|
20073
|
+
);
|
|
20074
|
+
}
|
|
20075
|
+
rows.push(row);
|
|
20076
|
+
}
|
|
20077
|
+
return rows;
|
|
20078
|
+
}
|
|
20079
|
+
function extractSessionTimestampSpan(rows) {
|
|
20080
|
+
let startedAt;
|
|
20081
|
+
let endedAt;
|
|
20082
|
+
for (const row of rows) {
|
|
20083
|
+
if (typeof row.timestamp !== "string" || !row.timestamp) continue;
|
|
20084
|
+
if (startedAt === void 0) startedAt = row.timestamp;
|
|
20085
|
+
endedAt = row.timestamp;
|
|
20086
|
+
}
|
|
20087
|
+
return {
|
|
20088
|
+
...startedAt !== void 0 ? { startedAt } : {},
|
|
20089
|
+
...endedAt !== void 0 ? { endedAt } : {}
|
|
20090
|
+
};
|
|
20091
|
+
}
|
|
20092
|
+
function extractSessionModelSequence(rows) {
|
|
20093
|
+
const seen = /* @__PURE__ */ new Set();
|
|
20094
|
+
const ordered = [];
|
|
20095
|
+
const push = (raw) => {
|
|
20096
|
+
const model = raw.trim();
|
|
20097
|
+
if (model === "" || seen.has(model)) return;
|
|
20098
|
+
seen.add(model);
|
|
20099
|
+
ordered.push(model);
|
|
20100
|
+
};
|
|
20101
|
+
for (const row of rows) {
|
|
20102
|
+
if (row.type === "model_change" && typeof row.modelId === "string") {
|
|
20103
|
+
push(row.modelId);
|
|
20104
|
+
}
|
|
20105
|
+
const message = isRecord5(row.message) ? row.message : void 0;
|
|
20106
|
+
if (message?.role === "assistant" && typeof message.model === "string") {
|
|
20107
|
+
push(message.model);
|
|
20108
|
+
}
|
|
20109
|
+
}
|
|
20110
|
+
return ordered;
|
|
20111
|
+
}
|
|
20112
|
+
function bashCommandFirstLine(command) {
|
|
20113
|
+
const match = /^[^\r\n]*/.exec(command);
|
|
20114
|
+
return match?.[0] ?? "";
|
|
20115
|
+
}
|
|
20116
|
+
function extractSessionToolIntervals(rows) {
|
|
20117
|
+
const order = [];
|
|
20118
|
+
const openById = /* @__PURE__ */ new Map();
|
|
20119
|
+
for (const row of rows) {
|
|
20120
|
+
const rowTimestamp = typeof row.timestamp === "string" ? row.timestamp : void 0;
|
|
20121
|
+
const message = isRecord5(row.message) ? row.message : void 0;
|
|
20122
|
+
if (message?.role === "assistant" && Array.isArray(message.content)) {
|
|
20123
|
+
const callTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
|
|
20124
|
+
for (const part of message.content) {
|
|
20125
|
+
if (!isRecord5(part) || part.type !== "toolCall") continue;
|
|
20126
|
+
if (typeof part.id !== "string" || part.id.length === 0) {
|
|
20127
|
+
throw new Error("toolCall frame missing string id");
|
|
20128
|
+
}
|
|
20129
|
+
if (typeof part.name !== "string" || part.name.length === 0) {
|
|
20130
|
+
throw new Error(`toolCall ${part.id} missing string name`);
|
|
20131
|
+
}
|
|
20132
|
+
if (callTimestamp === void 0 || callTimestamp.length === 0) {
|
|
20133
|
+
throw new Error(`toolCall ${part.id} missing timestamp`);
|
|
20134
|
+
}
|
|
20135
|
+
if (openById.has(part.id)) {
|
|
20136
|
+
throw new Error(`duplicate toolCall id ${part.id}`);
|
|
20137
|
+
}
|
|
20138
|
+
const args = isRecord5(part.arguments) ? part.arguments : void 0;
|
|
20139
|
+
const command = part.name === "bash" && args !== void 0 && typeof args.command === "string" ? bashCommandFirstLine(args.command) : void 0;
|
|
20140
|
+
const interval = {
|
|
20141
|
+
toolCallId: part.id,
|
|
20142
|
+
toolName: part.name,
|
|
20143
|
+
startedAt: callTimestamp,
|
|
20144
|
+
...command !== void 0 ? { command } : {}
|
|
20145
|
+
};
|
|
20146
|
+
order.push(interval);
|
|
20147
|
+
openById.set(part.id, interval);
|
|
20148
|
+
}
|
|
20149
|
+
}
|
|
20150
|
+
if (message?.role === "toolResult") {
|
|
20151
|
+
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) {
|
|
20152
|
+
throw new Error("toolResult frame missing string toolCallId");
|
|
20153
|
+
}
|
|
20154
|
+
const resultTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
|
|
20155
|
+
if (resultTimestamp === void 0 || resultTimestamp.length === 0) {
|
|
20156
|
+
throw new Error(`toolResult ${message.toolCallId} missing timestamp`);
|
|
20157
|
+
}
|
|
20158
|
+
const open5 = openById.get(message.toolCallId);
|
|
20159
|
+
if (open5 === void 0) {
|
|
20160
|
+
const toolName = typeof message.toolName === "string" && message.toolName.length > 0 ? message.toolName : "unknown";
|
|
20161
|
+
order.push({
|
|
20162
|
+
toolCallId: message.toolCallId,
|
|
20163
|
+
toolName,
|
|
20164
|
+
startedAt: resultTimestamp,
|
|
20165
|
+
endedAt: resultTimestamp
|
|
20166
|
+
});
|
|
20167
|
+
continue;
|
|
20168
|
+
}
|
|
20169
|
+
if (open5.endedAt !== void 0) {
|
|
20170
|
+
throw new Error(`duplicate toolResult for toolCallId ${message.toolCallId}`);
|
|
20171
|
+
}
|
|
20172
|
+
open5.endedAt = resultTimestamp;
|
|
20173
|
+
}
|
|
20174
|
+
}
|
|
20175
|
+
return order.map((interval) => {
|
|
20176
|
+
const base = {
|
|
20177
|
+
toolCallId: interval.toolCallId,
|
|
20178
|
+
toolName: interval.toolName,
|
|
20179
|
+
startedAt: interval.startedAt,
|
|
20180
|
+
...interval.command !== void 0 ? { command: interval.command } : {}
|
|
20181
|
+
};
|
|
20182
|
+
return interval.endedAt === void 0 ? base : { ...base, endedAt: interval.endedAt };
|
|
20183
|
+
});
|
|
20184
|
+
}
|
|
20185
|
+
var LedgerSessionJsonlError;
|
|
20186
|
+
var init_ledger_session_read = __esm({
|
|
20187
|
+
"src/ledger-session-read.ts"() {
|
|
20188
|
+
"use strict";
|
|
20189
|
+
LedgerSessionJsonlError = class extends Error {
|
|
20190
|
+
path;
|
|
20191
|
+
line;
|
|
20192
|
+
prefixRows;
|
|
20193
|
+
constructor(message, init) {
|
|
20194
|
+
super(message);
|
|
20195
|
+
this.name = "LedgerSessionJsonlError";
|
|
20196
|
+
this.path = init.path;
|
|
20197
|
+
this.line = init.line;
|
|
20198
|
+
this.prefixRows = init.prefixRows;
|
|
20199
|
+
}
|
|
20200
|
+
};
|
|
20201
|
+
}
|
|
20202
|
+
});
|
|
20203
|
+
|
|
20204
|
+
// src/analyst-gate-cycles-read.ts
|
|
20205
|
+
import { readdir as readdir3 } from "node:fs/promises";
|
|
20206
|
+
import { join as join12 } from "node:path";
|
|
20207
|
+
function isRecord6(value) {
|
|
20208
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20209
|
+
}
|
|
20210
|
+
function isMissingDirectoryError(error) {
|
|
20211
|
+
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
20212
|
+
}
|
|
20213
|
+
function normalizeOfficerArg(raw) {
|
|
20214
|
+
if (typeof raw !== "string") return void 0;
|
|
20215
|
+
return OFFICER_ARG_ALIASES[raw.trim()];
|
|
20216
|
+
}
|
|
20217
|
+
function asStringFindings(value) {
|
|
20218
|
+
if (!Array.isArray(value)) return [];
|
|
20219
|
+
return value.filter((item) => typeof item === "string");
|
|
20220
|
+
}
|
|
20221
|
+
function optionalDispatchReason(raw) {
|
|
20222
|
+
if (typeof raw !== "string") return void 0;
|
|
20223
|
+
if (raw.trim() === "") return void 0;
|
|
20224
|
+
return raw;
|
|
20225
|
+
}
|
|
20226
|
+
function isGateTerminatingToolName(toolName) {
|
|
20227
|
+
return DISPATCH_TOOLS.has(toolName) || OFFICER_TOOL_TO_FACE[toolName] !== void 0;
|
|
20228
|
+
}
|
|
20229
|
+
function acceptedGateReceiptIds(rows) {
|
|
20230
|
+
const accepted = /* @__PURE__ */ new Set();
|
|
20231
|
+
for (const row of rows) {
|
|
20232
|
+
const message = isRecord6(row.message) ? row.message : void 0;
|
|
20233
|
+
if (message?.role !== "toolResult") continue;
|
|
20234
|
+
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
|
|
20235
|
+
if (message.isError === false) accepted.add(message.toolCallId);
|
|
20236
|
+
}
|
|
20237
|
+
return accepted;
|
|
20238
|
+
}
|
|
20239
|
+
function extractLastAcceptedGateToolCall(rows) {
|
|
20240
|
+
const acceptedIds = acceptedGateReceiptIds(rows);
|
|
20241
|
+
let last;
|
|
20242
|
+
for (const row of rows) {
|
|
20243
|
+
const message = isRecord6(row.message) ? row.message : void 0;
|
|
20244
|
+
if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
20245
|
+
for (const part of message.content) {
|
|
20246
|
+
if (!isRecord6(part) || part.type !== "toolCall") continue;
|
|
20247
|
+
if (typeof part.id !== "string" || part.id.length === 0) continue;
|
|
20248
|
+
if (!acceptedIds.has(part.id)) continue;
|
|
20249
|
+
if (typeof part.name !== "string" || part.name.length === 0) continue;
|
|
20250
|
+
if (!isGateTerminatingToolName(part.name)) continue;
|
|
20251
|
+
last = {
|
|
20252
|
+
toolName: part.name,
|
|
20253
|
+
args: isRecord6(part.arguments) ? part.arguments : void 0
|
|
20254
|
+
};
|
|
20255
|
+
}
|
|
20256
|
+
}
|
|
20257
|
+
return last;
|
|
20258
|
+
}
|
|
20259
|
+
function requireAcceptedGateStatus(args, filePath) {
|
|
20260
|
+
if (args === void 0 || typeof args.status !== "string" || args.status.trim() === "") {
|
|
20261
|
+
throw new Error(
|
|
20262
|
+
`accepted gate receipt missing usable status in ${filePath}`
|
|
20263
|
+
);
|
|
20264
|
+
}
|
|
20265
|
+
return args.status.trim();
|
|
20266
|
+
}
|
|
20267
|
+
function requireAcceptedGateSpan(rows, filePath) {
|
|
20268
|
+
const span = extractSessionTimestampSpan(rows);
|
|
20269
|
+
if (span.startedAt === void 0 || span.endedAt === void 0) {
|
|
20270
|
+
throw new Error(
|
|
20271
|
+
`accepted gate volume missing session timestamp span in ${filePath}`
|
|
20272
|
+
);
|
|
20273
|
+
}
|
|
20274
|
+
const startedMs = Date.parse(span.startedAt);
|
|
20275
|
+
const endedMs = Date.parse(span.endedAt);
|
|
20276
|
+
if (!Number.isFinite(startedMs) || !Number.isFinite(endedMs) || endedMs < startedMs) {
|
|
20277
|
+
throw new Error(
|
|
20278
|
+
`accepted gate volume has unusable timestamp span in ${filePath}`
|
|
20279
|
+
);
|
|
20280
|
+
}
|
|
20281
|
+
return {
|
|
20282
|
+
startedAt: span.startedAt,
|
|
20283
|
+
endedAt: span.endedAt,
|
|
20284
|
+
wallMs: endedMs - startedMs
|
|
20285
|
+
};
|
|
20286
|
+
}
|
|
20287
|
+
async function classifyAuditorVolume(filePath) {
|
|
20288
|
+
const rows = await readLedgerSessionJsonl(filePath);
|
|
20289
|
+
const call = extractLastAcceptedGateToolCall(rows);
|
|
20290
|
+
if (call === void 0) return void 0;
|
|
20291
|
+
const span = requireAcceptedGateSpan(rows, filePath);
|
|
20292
|
+
const status = requireAcceptedGateStatus(call.args, filePath);
|
|
20293
|
+
const findings = asStringFindings(call.args?.findings);
|
|
20294
|
+
const findingsCount = findings.length;
|
|
20295
|
+
if (DISPATCH_TOOLS.has(call.toolName)) {
|
|
20296
|
+
if (status === "incomplete") return void 0;
|
|
20297
|
+
if (status !== "dispatch") {
|
|
20298
|
+
throw new Error(
|
|
20299
|
+
`accepted dispatch receipt has non-dispatch status ${JSON.stringify(status)} in ${filePath}`
|
|
20300
|
+
);
|
|
20301
|
+
}
|
|
20302
|
+
const officer2 = normalizeOfficerArg(call.args?.officer);
|
|
20303
|
+
if (officer2 === void 0) {
|
|
20304
|
+
throw new Error(
|
|
20305
|
+
`accepted dispatch receipt missing or unknown officer in ${filePath}`
|
|
20306
|
+
);
|
|
20307
|
+
}
|
|
20308
|
+
const reason = optionalDispatchReason(call.args?.reason);
|
|
20309
|
+
return {
|
|
20310
|
+
kind: "dispatch",
|
|
20311
|
+
startedAt: span.startedAt,
|
|
20312
|
+
officer: officer2,
|
|
20313
|
+
status,
|
|
20314
|
+
...reason === void 0 ? {} : { reason }
|
|
20315
|
+
};
|
|
20316
|
+
}
|
|
20317
|
+
const officer = OFFICER_TOOL_TO_FACE[call.toolName];
|
|
20318
|
+
if (officer === void 0) {
|
|
20319
|
+
throw new Error(
|
|
20320
|
+
`accepted gate receipt has unknown officer tool ${call.toolName} in ${filePath}`
|
|
20321
|
+
);
|
|
20322
|
+
}
|
|
20323
|
+
return {
|
|
20324
|
+
kind: "officer",
|
|
20325
|
+
startedAt: span.startedAt,
|
|
20326
|
+
endedAt: span.endedAt,
|
|
20327
|
+
officer,
|
|
20328
|
+
status,
|
|
20329
|
+
findings,
|
|
20330
|
+
findingsCount,
|
|
20331
|
+
officerWallMs: span.wallMs
|
|
20332
|
+
};
|
|
20333
|
+
}
|
|
20334
|
+
function pairGateRounds(volumes) {
|
|
20335
|
+
const ordered = [...volumes].sort((a, b) => {
|
|
20336
|
+
if (a.startedAt !== b.startedAt) return a.startedAt.localeCompare(b.startedAt);
|
|
20337
|
+
if (a.kind !== b.kind) return a.kind === "dispatch" ? -1 : 1;
|
|
20338
|
+
return 0;
|
|
20339
|
+
});
|
|
20340
|
+
const usedOfficerIdx = /* @__PURE__ */ new Set();
|
|
20341
|
+
const rounds = [];
|
|
20342
|
+
for (let i = 0; i < ordered.length; i += 1) {
|
|
20343
|
+
const vol = ordered[i];
|
|
20344
|
+
if (vol.kind !== "dispatch") continue;
|
|
20345
|
+
let match;
|
|
20346
|
+
for (let j = i + 1; j < ordered.length; j += 1) {
|
|
20347
|
+
if (usedOfficerIdx.has(j)) continue;
|
|
20348
|
+
const candidate = ordered[j];
|
|
20349
|
+
if (candidate.kind !== "officer") continue;
|
|
20350
|
+
if (candidate.officer !== vol.officer) continue;
|
|
20351
|
+
match = { index: j, officer: candidate };
|
|
20352
|
+
break;
|
|
20353
|
+
}
|
|
20354
|
+
if (match === void 0) continue;
|
|
20355
|
+
usedOfficerIdx.add(match.index);
|
|
20356
|
+
rounds.push({
|
|
20357
|
+
roundIndex: rounds.length + 1,
|
|
20358
|
+
officer: match.officer.officer,
|
|
20359
|
+
status: match.officer.status,
|
|
20360
|
+
officerWallMs: match.officer.officerWallMs,
|
|
20361
|
+
officerStartedAt: match.officer.startedAt,
|
|
20362
|
+
officerEndedAt: match.officer.endedAt,
|
|
20363
|
+
findings: match.officer.findings,
|
|
20364
|
+
findingsCount: match.officer.findingsCount,
|
|
20365
|
+
dispatchStatus: vol.status,
|
|
20366
|
+
...vol.reason === void 0 ? {} : { dispatchReason: vol.reason }
|
|
20367
|
+
});
|
|
20368
|
+
}
|
|
20369
|
+
return rounds;
|
|
20370
|
+
}
|
|
20371
|
+
async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory) {
|
|
20372
|
+
let names;
|
|
20373
|
+
try {
|
|
20374
|
+
const entries = await readdir3(auditorRolesDirectory, { withFileTypes: true });
|
|
20375
|
+
names = entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => e.name).sort();
|
|
20376
|
+
} catch (error) {
|
|
20377
|
+
if (isMissingDirectoryError(error)) return [];
|
|
20378
|
+
throw error;
|
|
20379
|
+
}
|
|
20380
|
+
const volumes = [];
|
|
20381
|
+
for (const name of names) {
|
|
20382
|
+
const classified = await classifyAuditorVolume(join12(auditorRolesDirectory, name));
|
|
20383
|
+
if (classified !== void 0) volumes.push(classified);
|
|
20384
|
+
}
|
|
20385
|
+
return pairGateRounds(volumes);
|
|
20386
|
+
}
|
|
20387
|
+
var DISPATCH_TOOLS, OFFICER_TOOL_TO_FACE, OFFICER_ARG_ALIASES;
|
|
20388
|
+
var init_analyst_gate_cycles_read = __esm({
|
|
20389
|
+
"src/analyst-gate-cycles-read.ts"() {
|
|
20390
|
+
"use strict";
|
|
20391
|
+
init_ledger_session_read();
|
|
20392
|
+
DISPATCH_TOOLS = /* @__PURE__ */ new Set(["ak_menxia_output", "ak_gatekeeper_output"]);
|
|
20393
|
+
OFFICER_TOOL_TO_FACE = {
|
|
20394
|
+
ak_jishizhong_output: "inspector",
|
|
20395
|
+
ak_inspector_output: "inspector",
|
|
20396
|
+
ak_fubaolang_output: "notary",
|
|
20397
|
+
ak_notary_output: "notary"
|
|
20398
|
+
};
|
|
20399
|
+
OFFICER_ARG_ALIASES = {
|
|
20400
|
+
jishizhong: "inspector",
|
|
20401
|
+
inspector: "inspector",
|
|
20402
|
+
fubaolang: "notary",
|
|
20403
|
+
notary: "notary"
|
|
20404
|
+
};
|
|
20405
|
+
}
|
|
20406
|
+
});
|
|
20407
|
+
|
|
20031
20408
|
// src/session-opening-materials.ts
|
|
20032
20409
|
var packageRootUrl;
|
|
20033
20410
|
var init_session_opening_materials = __esm({
|
|
@@ -20080,11 +20457,11 @@ var init_engine_detour_tool = __esm({
|
|
|
20080
20457
|
});
|
|
20081
20458
|
|
|
20082
20459
|
// src/receipt-delivery-policy.ts
|
|
20083
|
-
function
|
|
20460
|
+
function isRecord7(value) {
|
|
20084
20461
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20085
20462
|
}
|
|
20086
20463
|
function parseNoReceiptLifecycleFacts(input) {
|
|
20087
|
-
if (!
|
|
20464
|
+
if (!isRecord7(input) || typeof input.terminalToolCalled !== "boolean" || input.deliveryTurns !== RECEIPT_DELIVERY_TURN_LIMIT || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord7(item) && typeof item.reason === "string")) {
|
|
20088
20465
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
20089
20466
|
}
|
|
20090
20467
|
return {
|
|
@@ -20429,8 +20806,8 @@ var init_navigator_invocation_identity = __esm({
|
|
|
20429
20806
|
// src/public-cli/settlement.ts
|
|
20430
20807
|
import { randomUUID } from "node:crypto";
|
|
20431
20808
|
import { constants as fsConstants } from "node:fs";
|
|
20432
|
-
import { appendFile, lstat as lstat4, mkdir as mkdir3, open as open2, readFile as
|
|
20433
|
-
import { dirname as dirname7, join as
|
|
20809
|
+
import { appendFile, lstat as lstat4, mkdir as mkdir3, open as open2, readFile as readFile10, readdir as readdir4, writeFile as writeFile5 } from "node:fs/promises";
|
|
20810
|
+
import { dirname as dirname7, join as join13 } from "node:path";
|
|
20434
20811
|
function isChildDiagnosticFloodLine(line2) {
|
|
20435
20812
|
if (/^at\s+/.test(line2)) return true;
|
|
20436
20813
|
if (line2.startsWith("event:")) return true;
|
|
@@ -20490,7 +20867,7 @@ function presentControlledFailure(failure, io) {
|
|
|
20490
20867
|
}
|
|
20491
20868
|
async function inspectJudgeSession(sessionFile) {
|
|
20492
20869
|
try {
|
|
20493
|
-
await
|
|
20870
|
+
await readFile10(sessionFile, "utf8");
|
|
20494
20871
|
return { state: "present" };
|
|
20495
20872
|
} catch (error) {
|
|
20496
20873
|
if (isMissingPathError2(error)) return { state: "missing" };
|
|
@@ -20632,7 +21009,7 @@ function sessionReadFailure(error, fallbackMessage) {
|
|
|
20632
21009
|
return failed;
|
|
20633
21010
|
}
|
|
20634
21011
|
async function readBoundSessionEntries(sessionFile) {
|
|
20635
|
-
const text = await
|
|
21012
|
+
const text = await readFile10(sessionFile, "utf8");
|
|
20636
21013
|
const entries = [];
|
|
20637
21014
|
for (const line2 of text.trim().split("\n").filter(Boolean)) {
|
|
20638
21015
|
try {
|
|
@@ -20680,7 +21057,7 @@ function extractSessionProviderStop(entries) {
|
|
|
20680
21057
|
for (let i = entries.length - 1; i >= attemptStart; i -= 1) {
|
|
20681
21058
|
const entry = entries[i];
|
|
20682
21059
|
if (entry?.type !== "custom" || entry.customType !== COMPLIANCE_RESPONSE_ENTRY_TYPE) continue;
|
|
20683
|
-
const response =
|
|
21060
|
+
const response = isRecord8(entry.data) && isRecord8(entry.data.response) ? entry.data.response : void 0;
|
|
20684
21061
|
const stop = sessionProviderStopFromAssistant(response);
|
|
20685
21062
|
if (stop !== void 0) return stop;
|
|
20686
21063
|
break;
|
|
@@ -20703,10 +21080,10 @@ async function readSessionProviderStop(sessionFile) {
|
|
|
20703
21080
|
}
|
|
20704
21081
|
}
|
|
20705
21082
|
async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
20706
|
-
const childDirectory =
|
|
21083
|
+
const childDirectory = join13(dirname7(sessionFile), "evidence-children");
|
|
20707
21084
|
let names;
|
|
20708
21085
|
try {
|
|
20709
|
-
names = await
|
|
21086
|
+
names = await readdir4(childDirectory);
|
|
20710
21087
|
} catch (error) {
|
|
20711
21088
|
if (isMissingPathError2(error)) return void 0;
|
|
20712
21089
|
throw sessionReadFailure(error, "failed to read bound evidence-child session directory");
|
|
@@ -20714,12 +21091,12 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
|
20714
21091
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
20715
21092
|
let entries;
|
|
20716
21093
|
try {
|
|
20717
|
-
entries = await readBoundSessionEntries(
|
|
21094
|
+
entries = await readBoundSessionEntries(join13(childDirectory, file));
|
|
20718
21095
|
} catch (error) {
|
|
20719
21096
|
throw sessionReadFailure(error, "failed to read discovered evidence-child session");
|
|
20720
21097
|
}
|
|
20721
21098
|
const header = entries.find((entry) => entry.type === "session");
|
|
20722
|
-
if (!
|
|
21099
|
+
if (!isRecord8(header) || header.parentSession !== sessionFile) continue;
|
|
20723
21100
|
const stop = extractSessionProviderStop(entries);
|
|
20724
21101
|
if (stop === void 0) continue;
|
|
20725
21102
|
const primary = knownFailureFromProviderStop(stop);
|
|
@@ -20745,12 +21122,12 @@ async function readBoundAuditorKnownFailure(sessionFile) {
|
|
|
20745
21122
|
if (parentId === void 0) return void 0;
|
|
20746
21123
|
const RESUME_ENVELOPE = RESUME_TRANSPORT_ENVELOPE;
|
|
20747
21124
|
const isResumeEnvelope = (msg) => {
|
|
20748
|
-
if (!
|
|
21125
|
+
if (!isRecord8(msg) || msg.role !== "user") return false;
|
|
20749
21126
|
const text = typeof msg.text === "string" ? msg.text : typeof msg.content === "string" ? msg.content : void 0;
|
|
20750
21127
|
if (text === RESUME_ENVELOPE) return true;
|
|
20751
21128
|
const content = msg.content;
|
|
20752
21129
|
if (Array.isArray(content)) {
|
|
20753
|
-
return content.some((p) =>
|
|
21130
|
+
return content.some((p) => isRecord8(p) && (p.text === RESUME_ENVELOPE || p.content === RESUME_ENVELOPE));
|
|
20754
21131
|
}
|
|
20755
21132
|
return false;
|
|
20756
21133
|
};
|
|
@@ -20762,10 +21139,10 @@ async function readBoundAuditorKnownFailure(sessionFile) {
|
|
|
20762
21139
|
latestParentUserIndex = i;
|
|
20763
21140
|
break;
|
|
20764
21141
|
}
|
|
20765
|
-
const childDirectory =
|
|
21142
|
+
const childDirectory = join13(dirname7(sessionFile), "auditor-roles");
|
|
20766
21143
|
let names;
|
|
20767
21144
|
try {
|
|
20768
|
-
names = await
|
|
21145
|
+
names = await readdir4(childDirectory);
|
|
20769
21146
|
} catch (error) {
|
|
20770
21147
|
if (isMissingPathError2(error)) return void 0;
|
|
20771
21148
|
throw sessionReadFailure(error, "failed to read bound auditor session directory");
|
|
@@ -20774,14 +21151,14 @@ async function readBoundAuditorKnownFailure(sessionFile) {
|
|
|
20774
21151
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
20775
21152
|
let entries;
|
|
20776
21153
|
try {
|
|
20777
|
-
entries = await readBoundSessionEntries(
|
|
21154
|
+
entries = await readBoundSessionEntries(join13(childDirectory, file));
|
|
20778
21155
|
} catch (error) {
|
|
20779
21156
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
20780
21157
|
}
|
|
20781
21158
|
const header = entries.find((entry) => entry.type === "session");
|
|
20782
|
-
if (!
|
|
21159
|
+
if (!isRecord8(header) || header.parentSession !== sessionFile) continue;
|
|
20783
21160
|
const bindingEntry = entries.find((entry) => entry.type === "custom" && entry.customType === AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE);
|
|
20784
|
-
const bindingParent =
|
|
21161
|
+
const bindingParent = isRecord8(bindingEntry?.data) && isRecord8(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
20785
21162
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
20786
21163
|
const attemptEntryIndex = attemptEntryId === void 0 ? -1 : parentEntries.findIndex((entry) => entry.id === attemptEntryId);
|
|
20787
21164
|
if (bindingParent?.sessionId !== parentId || bindingParent.sessionFile !== sessionFile || attemptEntryIndex < latestParentUserIndex) continue;
|
|
@@ -20792,11 +21169,11 @@ async function readBoundAuditorKnownFailure(sessionFile) {
|
|
|
20792
21169
|
if (stop === void 0) continue;
|
|
20793
21170
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
20794
21171
|
const entry = entries[i];
|
|
20795
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
20796
|
-
const parent =
|
|
20797
|
-
const failure =
|
|
21172
|
+
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord8(entry.data)) continue;
|
|
21173
|
+
const parent = isRecord8(entry.data.parent) ? entry.data.parent : void 0;
|
|
21174
|
+
const failure = isRecord8(entry.data.failure) ? entry.data.failure : void 0;
|
|
20798
21175
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId || failure?.cause !== "provider" && failure?.cause !== "unrecognized") continue;
|
|
20799
|
-
const identity =
|
|
21176
|
+
const identity = isRecord8(failure.identity) ? failure.identity : void 0;
|
|
20800
21177
|
return {
|
|
20801
21178
|
cause: failure.cause === "provider" ? "provider" : "unrecognized",
|
|
20802
21179
|
...identity === void 0 ? {} : { identity: {
|
|
@@ -20804,7 +21181,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
|
|
|
20804
21181
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
20805
21182
|
} },
|
|
20806
21183
|
...typeof failure.diagnostic === "string" ? { diagnostic: failure.diagnostic } : {},
|
|
20807
|
-
...
|
|
21184
|
+
...isRecord8(failure.details) ? { details: failure.details } : {}
|
|
20808
21185
|
};
|
|
20809
21186
|
}
|
|
20810
21187
|
}
|
|
@@ -20838,8 +21215,8 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
20838
21215
|
if (classification.kind !== "infrastructure") continue;
|
|
20839
21216
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
20840
21217
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
20841
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
20842
|
-
const diagnostic =
|
|
21218
|
+
const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord8(part) && part.type === "text" && typeof part.text === "string") : void 0;
|
|
21219
|
+
const diagnostic = isRecord8(textPart) ? textPart.text : void 0;
|
|
20843
21220
|
return {
|
|
20844
21221
|
cause: "output",
|
|
20845
21222
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -20989,7 +21366,7 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
20989
21366
|
} : {}
|
|
20990
21367
|
};
|
|
20991
21368
|
}
|
|
20992
|
-
function
|
|
21369
|
+
function isRecord8(value) {
|
|
20993
21370
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20994
21371
|
}
|
|
20995
21372
|
function safelyRead(object, key) {
|
|
@@ -21018,7 +21395,7 @@ function judgeDecisiveFacts(verdict, judgeStatus) {
|
|
|
21018
21395
|
const statusBase = seatFallbackBaseStatus(judgeStatus);
|
|
21019
21396
|
if (statusBase === "continue") {
|
|
21020
21397
|
const fix = safelyRead(verdict, "fix");
|
|
21021
|
-
if (fix.readable &&
|
|
21398
|
+
if (fix.readable && isRecord8(fix.value)) {
|
|
21022
21399
|
const summary = safelyRead(fix.value, "summary");
|
|
21023
21400
|
if (summary.readable && typeof summary.value === "string") {
|
|
21024
21401
|
facts.fixSummary = summary.value;
|
|
@@ -21028,7 +21405,7 @@ function judgeDecisiveFacts(verdict, judgeStatus) {
|
|
|
21028
21405
|
if (classes.readable && Array.isArray(classes.value)) {
|
|
21029
21406
|
try {
|
|
21030
21407
|
facts.classes = classes.value.map((entry) => {
|
|
21031
|
-
if (!
|
|
21408
|
+
if (!isRecord8(entry)) throw new Error("unreadable Judge class");
|
|
21032
21409
|
return {
|
|
21033
21410
|
name: entry.name,
|
|
21034
21411
|
owner: entry.owner,
|
|
@@ -21043,7 +21420,7 @@ function judgeDecisiveFacts(verdict, judgeStatus) {
|
|
|
21043
21420
|
}
|
|
21044
21421
|
if (statusBase === "escalate") {
|
|
21045
21422
|
const gate = safelyRead(verdict, "decisionGate");
|
|
21046
|
-
if (gate.readable &&
|
|
21423
|
+
if (gate.readable && isRecord8(gate.value)) {
|
|
21047
21424
|
const question = safelyRead(gate.value, "question");
|
|
21048
21425
|
const options = safelyRead(gate.value, "options");
|
|
21049
21426
|
if (question.readable && typeof question.value === "string") {
|
|
@@ -21089,7 +21466,7 @@ function fixerDecisiveFacts(output) {
|
|
|
21089
21466
|
facts.reason = reason.value;
|
|
21090
21467
|
}
|
|
21091
21468
|
const blockerRead = safelyRead(candidate, "blocker");
|
|
21092
|
-
if (statusBase === "refused" && blockerRead.readable &&
|
|
21469
|
+
if (statusBase === "refused" && blockerRead.readable && isRecord8(blockerRead.value)) {
|
|
21093
21470
|
const cause = safelyRead(blockerRead.value, "cause");
|
|
21094
21471
|
if (cause.readable && typeof cause.value === "string") facts.blockerCause = cause.value;
|
|
21095
21472
|
const prerequisiteId = safelyRead(blockerRead.value, "prerequisiteId");
|
|
@@ -21101,13 +21478,13 @@ function fixerDecisiveFacts(output) {
|
|
|
21101
21478
|
const blockers = [];
|
|
21102
21479
|
try {
|
|
21103
21480
|
for (const entry of classResults.value) {
|
|
21104
|
-
if (!
|
|
21481
|
+
if (!isRecord8(entry)) throw new Error("unreadable class result");
|
|
21105
21482
|
const name = safelyRead(entry, "name");
|
|
21106
21483
|
const disposition = safelyRead(entry, "disposition");
|
|
21107
21484
|
if (!name.readable || !disposition.readable) throw new Error("unreadable class result");
|
|
21108
21485
|
rows.push({ name: name.value, disposition: disposition.value });
|
|
21109
21486
|
const blocker = safelyRead(entry, "blocker");
|
|
21110
|
-
if (disposition.value === "refused" && blocker.readable &&
|
|
21487
|
+
if (disposition.value === "refused" && blocker.readable && isRecord8(blocker.value)) blockers.push(blocker.value);
|
|
21111
21488
|
}
|
|
21112
21489
|
facts.classResultCount = rows.length;
|
|
21113
21490
|
facts.classDispositions = rows;
|
|
@@ -21140,7 +21517,7 @@ function collectorDecisiveFacts(receipt) {
|
|
|
21140
21517
|
if (groups.readable && Array.isArray(groups.value)) {
|
|
21141
21518
|
try {
|
|
21142
21519
|
facts.groups = groups.value.map((group) => {
|
|
21143
|
-
if (!
|
|
21520
|
+
if (!isRecord8(group)) throw new Error("unreadable Collector group");
|
|
21144
21521
|
const identity = safelyRead(group, "identity");
|
|
21145
21522
|
const attendance = safelyRead(group, "attendance");
|
|
21146
21523
|
const materials = safelyRead(group, "materials");
|
|
@@ -21174,7 +21551,7 @@ function doctorDecisiveFacts(output) {
|
|
|
21174
21551
|
return facts;
|
|
21175
21552
|
}
|
|
21176
21553
|
const caseValue = safelyRead(candidate, "case");
|
|
21177
|
-
if (caseValue.readable &&
|
|
21554
|
+
if (caseValue.readable && isRecord8(caseValue.value)) {
|
|
21178
21555
|
const issueNumber = safelyRead(caseValue.value, "issueNumber");
|
|
21179
21556
|
const runsPath = safelyRead(caseValue.value, "runsPath");
|
|
21180
21557
|
if (issueNumber.readable && issueNumber.value !== void 0) facts.issueNumber = issueNumber.value;
|
|
@@ -21185,7 +21562,7 @@ function doctorDecisiveFacts(output) {
|
|
|
21185
21562
|
return facts;
|
|
21186
21563
|
}
|
|
21187
21564
|
function reviewerAxes(value) {
|
|
21188
|
-
if (!
|
|
21565
|
+
if (!isRecord8(value)) return [];
|
|
21189
21566
|
return ["standards", "spec"].filter((axis) => {
|
|
21190
21567
|
const projected = safelyRead(value, axis);
|
|
21191
21568
|
return projected.readable && projected.value !== void 0;
|
|
@@ -21303,9 +21680,9 @@ function assertCollectorReceiptMatchesAdmitted(receipt, admitted) {
|
|
|
21303
21680
|
}
|
|
21304
21681
|
}
|
|
21305
21682
|
function isComplianceAuditIncomplete(value) {
|
|
21306
|
-
if (!
|
|
21683
|
+
if (!isRecord8(value) || value.status !== "audit-incomplete") return false;
|
|
21307
21684
|
const observation = value.observation;
|
|
21308
|
-
if (!
|
|
21685
|
+
if (!isRecord8(observation)) return false;
|
|
21309
21686
|
if (observation.kind === "missing-dossier") return true;
|
|
21310
21687
|
if (observation.kind === "missing-subject") {
|
|
21311
21688
|
return typeof observation.subject === "string" && observation.subject.length > 0;
|
|
@@ -21355,7 +21732,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
21355
21732
|
const candidateMessage = entries[index]?.message;
|
|
21356
21733
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
21357
21734
|
for (const part of candidateMessage.content) {
|
|
21358
|
-
if (!
|
|
21735
|
+
if (!isRecord8(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
21359
21736
|
continue;
|
|
21360
21737
|
}
|
|
21361
21738
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -21377,7 +21754,7 @@ function sameAuditValue(left, right) {
|
|
|
21377
21754
|
(value, index) => sameAuditValue(value, right[index])
|
|
21378
21755
|
);
|
|
21379
21756
|
}
|
|
21380
|
-
if (
|
|
21757
|
+
if (isRecord8(left) && isRecord8(right)) {
|
|
21381
21758
|
const leftKeys = Object.keys(left);
|
|
21382
21759
|
const rightKeys = Object.keys(right);
|
|
21383
21760
|
return leftKeys.length === rightKeys.length && leftKeys.every((key) => Object.hasOwn(right, key) && sameAuditValue(left[key], right[key]));
|
|
@@ -21415,7 +21792,7 @@ function boundAuditEscalationForResult(entries, resultIndex, message, role, outp
|
|
|
21415
21792
|
const decision = readComplianceCandidate(retained.candidate);
|
|
21416
21793
|
if (decision.status !== "escalate") return void 0;
|
|
21417
21794
|
const details = message.details;
|
|
21418
|
-
if (!isAuditEscalationResult(details) || !
|
|
21795
|
+
if (!isAuditEscalationResult(details) || !isRecord8(details)) return void 0;
|
|
21419
21796
|
const projectedDetails = snapshotAuditDetails(details);
|
|
21420
21797
|
const hasDecisionConflicts = Object.hasOwn(decision, "conflicts");
|
|
21421
21798
|
const hasDetailsConflicts = Object.hasOwn(projectedDetails, "conflicts");
|
|
@@ -21435,7 +21812,7 @@ function isUnboundAuditEscalationFace(details) {
|
|
|
21435
21812
|
if (isAuditEscalationResult(details)) return true;
|
|
21436
21813
|
} catch {
|
|
21437
21814
|
}
|
|
21438
|
-
if (!
|
|
21815
|
+
if (!isRecord8(details)) return false;
|
|
21439
21816
|
const kind = safelyRead(details, "kind");
|
|
21440
21817
|
return kind.readable && kind.value === "audit_escalation";
|
|
21441
21818
|
}
|
|
@@ -21450,11 +21827,11 @@ function boundRetainedAuditResponse(entries, callIndex, resultIndex, auditToolNa
|
|
|
21450
21827
|
if (entry?.type !== "custom" || entry.customType !== COMPLIANCE_RESPONSE_ENTRY_TYPE) {
|
|
21451
21828
|
continue;
|
|
21452
21829
|
}
|
|
21453
|
-
if (!
|
|
21830
|
+
if (!isRecord8(entry.data) || !isRecord8(entry.data.response)) continue;
|
|
21454
21831
|
const response = entry.data.response;
|
|
21455
21832
|
if (!Array.isArray(response.content)) continue;
|
|
21456
21833
|
const calls = response.content.filter(
|
|
21457
|
-
(part) =>
|
|
21834
|
+
(part) => isRecord8(part) && part.type === "toolCall"
|
|
21458
21835
|
);
|
|
21459
21836
|
if (calls.length !== 1 || calls[0]?.name !== auditToolName) continue;
|
|
21460
21837
|
matches.push({ candidate: calls[0]?.arguments });
|
|
@@ -21512,7 +21889,7 @@ function auditArtifactPublicationError(message, code) {
|
|
|
21512
21889
|
return error;
|
|
21513
21890
|
}
|
|
21514
21891
|
async function ensureAuditEvidenceDirectory(runDirectory) {
|
|
21515
|
-
const artifactsDir =
|
|
21892
|
+
const artifactsDir = join13(runDirectory, "artifacts");
|
|
21516
21893
|
const runStat = await lstat4(runDirectory);
|
|
21517
21894
|
if (runStat.isSymbolicLink() || !runStat.isDirectory()) {
|
|
21518
21895
|
throw auditArtifactPublicationError(
|
|
@@ -21584,7 +21961,7 @@ async function publishComplianceAuditIncompleteEvidence(admitted, outcome) {
|
|
|
21584
21961
|
);
|
|
21585
21962
|
}
|
|
21586
21963
|
const artifactsDir = await ensureAuditEvidenceDirectory(admitted.runDirectory);
|
|
21587
|
-
const evidencePath =
|
|
21964
|
+
const evidencePath = join13(artifactsDir, "audit-incomplete.json");
|
|
21588
21965
|
let existing;
|
|
21589
21966
|
try {
|
|
21590
21967
|
existing = await lstat4(evidencePath);
|
|
@@ -21625,7 +22002,7 @@ async function publishComplianceAuditIncompleteEvidence(admitted, outcome) {
|
|
|
21625
22002
|
}
|
|
21626
22003
|
function auditPublicationFailureTerminal(admitted, entries, outcome, error) {
|
|
21627
22004
|
const attempt = publicationAttemptFromError(
|
|
21628
|
-
|
|
22005
|
+
join13(admitted.runDirectory, "artifacts", "audit-incomplete.json"),
|
|
21629
22006
|
error
|
|
21630
22007
|
);
|
|
21631
22008
|
const diagnostic = `audit-incomplete evidence publication failed: ${attempt.diagnostic}`;
|
|
@@ -21669,20 +22046,24 @@ async function trySettleComplianceAuditIncompleteTerminalResult(admitted) {
|
|
|
21669
22046
|
outputToolName
|
|
21670
22047
|
);
|
|
21671
22048
|
if (extracted === void 0) return void 0;
|
|
22049
|
+
let evidence;
|
|
21672
22050
|
try {
|
|
21673
|
-
|
|
22051
|
+
evidence = await publishComplianceAuditIncompleteEvidence(
|
|
21674
22052
|
admitted,
|
|
21675
22053
|
extracted.outcome
|
|
21676
22054
|
);
|
|
21677
|
-
|
|
22055
|
+
} catch (error) {
|
|
22056
|
+
return auditPublicationFailureTerminal(admitted, entries, extracted.outcome, error);
|
|
22057
|
+
}
|
|
22058
|
+
return withOptionalMenxiaProjection(
|
|
22059
|
+
{
|
|
21678
22060
|
roleOutcome: extracted.outcome,
|
|
21679
22061
|
navigator: extractNavigatorFact(entries),
|
|
21680
22062
|
artifacts: [evidence],
|
|
21681
22063
|
runId: admitted.runId
|
|
21682
|
-
}
|
|
21683
|
-
|
|
21684
|
-
|
|
21685
|
-
}
|
|
22064
|
+
},
|
|
22065
|
+
admitted.sessionDirectory
|
|
22066
|
+
);
|
|
21686
22067
|
}
|
|
21687
22068
|
function extractJudgeRoleOutcome(entries) {
|
|
21688
22069
|
if (!isReceiptSettlementBindingClear(entries)) return void 0;
|
|
@@ -21710,7 +22091,7 @@ function extractJudgeRoleOutcome(entries) {
|
|
|
21710
22091
|
};
|
|
21711
22092
|
}
|
|
21712
22093
|
if (isUnboundAuditEscalationFace(details)) continue;
|
|
21713
|
-
if (!
|
|
22094
|
+
if (!isRecord8(details)) continue;
|
|
21714
22095
|
const statusRead = safelyRead(details, "judgeStatus");
|
|
21715
22096
|
if (!statusRead.readable || typeof statusRead.value !== "string") continue;
|
|
21716
22097
|
const judgeStatus = statusRead.value;
|
|
@@ -21740,7 +22121,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
21740
22121
|
const advisoryDiagnostic = typeof details.routePlaybookReadFailure === "string" ? { advisoryDiagnostic: details.routePlaybookReadFailure } : {};
|
|
21741
22122
|
if (disposition === "recommendation") {
|
|
21742
22123
|
const next = details.next;
|
|
21743
|
-
if (!
|
|
22124
|
+
if (!isRecord8(next) || typeof next.role !== "string") {
|
|
21744
22125
|
return {
|
|
21745
22126
|
disposition: "unavailable",
|
|
21746
22127
|
source: "unknown",
|
|
@@ -21748,7 +22129,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
21748
22129
|
};
|
|
21749
22130
|
}
|
|
21750
22131
|
const reason = typeof details.reason === "string" ? details.reason : "";
|
|
21751
|
-
const route = Array.isArray(details.route) ? details.route.filter(
|
|
22132
|
+
const route = Array.isArray(details.route) ? details.route.filter(isRecord8).map((target) => ({
|
|
21752
22133
|
role: String(target.role),
|
|
21753
22134
|
phase: navigatorPhaseValue(target.phase)
|
|
21754
22135
|
})) : void 0;
|
|
@@ -21783,6 +22164,41 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
21783
22164
|
reason: "Navigator attendance disposition is unparseable"
|
|
21784
22165
|
};
|
|
21785
22166
|
}
|
|
22167
|
+
function projectTerminalMenxiaFact(rounds) {
|
|
22168
|
+
if (rounds.length === 0) return void 0;
|
|
22169
|
+
const seen = /* @__PURE__ */ new Set();
|
|
22170
|
+
seen.add("gatekeeper");
|
|
22171
|
+
for (const round of rounds) seen.add(round.officer);
|
|
22172
|
+
const actualSeats = ["gatekeeper", "inspector", "notary"].filter(
|
|
22173
|
+
(seat) => seen.has(seat)
|
|
22174
|
+
);
|
|
22175
|
+
return {
|
|
22176
|
+
actualSeats,
|
|
22177
|
+
rounds: rounds.map((round) => ({
|
|
22178
|
+
roundIndex: round.roundIndex,
|
|
22179
|
+
dispatch: {
|
|
22180
|
+
status: round.dispatchStatus,
|
|
22181
|
+
officer: round.officer,
|
|
22182
|
+
...round.dispatchReason === void 0 ? {} : { reason: round.dispatchReason }
|
|
22183
|
+
},
|
|
22184
|
+
officer: {
|
|
22185
|
+
seat: round.officer,
|
|
22186
|
+
status: round.status,
|
|
22187
|
+
findings: round.findings
|
|
22188
|
+
}
|
|
22189
|
+
}))
|
|
22190
|
+
};
|
|
22191
|
+
}
|
|
22192
|
+
async function extractMenxiaFactFromSessionDirectory(sessionDirectory) {
|
|
22193
|
+
const rounds = await readAnalystGateCyclesFromAuditorRoles(
|
|
22194
|
+
join13(sessionDirectory, "auditor-roles")
|
|
22195
|
+
);
|
|
22196
|
+
return projectTerminalMenxiaFact(rounds);
|
|
22197
|
+
}
|
|
22198
|
+
async function withOptionalMenxiaProjection(base, sessionDirectory) {
|
|
22199
|
+
const menxia = await extractMenxiaFactFromSessionDirectory(sessionDirectory);
|
|
22200
|
+
return menxia === void 0 ? base : { ...base, menxia };
|
|
22201
|
+
}
|
|
21786
22202
|
function extractNavigatorFact(entries) {
|
|
21787
22203
|
const terminal = findLatestDurablePackagedRoleTerminal(entries);
|
|
21788
22204
|
if (terminal === void 0) {
|
|
@@ -21819,7 +22235,7 @@ function extractNavigatorFact(entries) {
|
|
|
21819
22235
|
const entry = entries[i];
|
|
21820
22236
|
if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
|
|
21821
22237
|
const details = entry.message?.details ?? entry.details;
|
|
21822
|
-
if (!
|
|
22238
|
+
if (!isRecord8(details)) {
|
|
21823
22239
|
return {
|
|
21824
22240
|
disposition: "unavailable",
|
|
21825
22241
|
source: "unknown",
|
|
@@ -21869,8 +22285,8 @@ async function extractNavigatorFactFromAdmittedSession(admitted) {
|
|
|
21869
22285
|
async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
|
|
21870
22286
|
await appendRunAttemptHistory(admitted, roleOutcome);
|
|
21871
22287
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
21872
|
-
const reportPath =
|
|
21873
|
-
const evidencePath =
|
|
22288
|
+
const reportPath = join13(artifactsDir, "report.json");
|
|
22289
|
+
const evidencePath = join13(artifactsDir, "evidence.json");
|
|
21874
22290
|
await writeFile5(
|
|
21875
22291
|
reportPath,
|
|
21876
22292
|
`${JSON.stringify(
|
|
@@ -21914,8 +22330,8 @@ async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
|
|
|
21914
22330
|
async function publishCoderArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
|
|
21915
22331
|
await appendRunAttemptHistory(admitted, roleOutcome);
|
|
21916
22332
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
21917
|
-
const reportPath =
|
|
21918
|
-
const evidencePath =
|
|
22333
|
+
const reportPath = join13(artifactsDir, "report.json");
|
|
22334
|
+
const evidencePath = join13(artifactsDir, "evidence.json");
|
|
21919
22335
|
await writeFile5(
|
|
21920
22336
|
reportPath,
|
|
21921
22337
|
`${JSON.stringify(
|
|
@@ -22021,12 +22437,15 @@ async function settleLawfulJudgeTerminalResult(admitted) {
|
|
|
22021
22437
|
roleOutcome,
|
|
22022
22438
|
admitted.sessionDirectory
|
|
22023
22439
|
);
|
|
22024
|
-
return
|
|
22025
|
-
|
|
22026
|
-
|
|
22027
|
-
|
|
22028
|
-
|
|
22029
|
-
|
|
22440
|
+
return withOptionalMenxiaProjection(
|
|
22441
|
+
{
|
|
22442
|
+
roleOutcome,
|
|
22443
|
+
navigator,
|
|
22444
|
+
artifacts,
|
|
22445
|
+
runId: admitted.runId
|
|
22446
|
+
},
|
|
22447
|
+
admitted.sessionDirectory
|
|
22448
|
+
);
|
|
22030
22449
|
}
|
|
22031
22450
|
async function trySettleJudgeTerminalResult(admitted) {
|
|
22032
22451
|
return settleLawfulJudgeTerminalResult(admitted);
|
|
@@ -22046,12 +22465,15 @@ async function settleLawfulCoderTerminalResult(admitted, options = {}) {
|
|
|
22046
22465
|
...options.methodProvenance === void 0 ? {} : { methodProvenance: options.methodProvenance }
|
|
22047
22466
|
}
|
|
22048
22467
|
);
|
|
22049
|
-
return
|
|
22050
|
-
|
|
22051
|
-
|
|
22052
|
-
|
|
22053
|
-
|
|
22054
|
-
|
|
22468
|
+
return withOptionalMenxiaProjection(
|
|
22469
|
+
{
|
|
22470
|
+
roleOutcome: extracted.outcome,
|
|
22471
|
+
navigator,
|
|
22472
|
+
artifacts,
|
|
22473
|
+
runId: admitted.runId
|
|
22474
|
+
},
|
|
22475
|
+
admitted.sessionDirectory
|
|
22476
|
+
);
|
|
22055
22477
|
}
|
|
22056
22478
|
function sessionMessageText(message) {
|
|
22057
22479
|
if (message === void 0) return "";
|
|
@@ -22084,8 +22506,8 @@ function extractFixerMethodInvocations(entries, options) {
|
|
|
22084
22506
|
async function publishFixerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
|
|
22085
22507
|
await appendRunAttemptHistory(admitted, roleOutcome);
|
|
22086
22508
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
22087
|
-
const reportPath =
|
|
22088
|
-
const evidencePath =
|
|
22509
|
+
const reportPath = join13(artifactsDir, "report.json");
|
|
22510
|
+
const evidencePath = join13(artifactsDir, "evidence.json");
|
|
22089
22511
|
await writeFile5(
|
|
22090
22512
|
reportPath,
|
|
22091
22513
|
`${JSON.stringify(
|
|
@@ -22186,18 +22608,21 @@ async function settleLawfulFixerTerminalResult(admitted, options) {
|
|
|
22186
22608
|
methodInvocations
|
|
22187
22609
|
}
|
|
22188
22610
|
);
|
|
22189
|
-
return
|
|
22190
|
-
|
|
22191
|
-
|
|
22192
|
-
|
|
22193
|
-
|
|
22194
|
-
|
|
22611
|
+
return withOptionalMenxiaProjection(
|
|
22612
|
+
{
|
|
22613
|
+
roleOutcome: extracted.outcome,
|
|
22614
|
+
navigator,
|
|
22615
|
+
artifacts,
|
|
22616
|
+
runId: admitted.runId
|
|
22617
|
+
},
|
|
22618
|
+
admitted.sessionDirectory
|
|
22619
|
+
);
|
|
22195
22620
|
}
|
|
22196
22621
|
async function publishCollectorArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
|
|
22197
22622
|
await appendRunAttemptHistory(admitted, roleOutcome);
|
|
22198
22623
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
22199
|
-
const reportPath =
|
|
22200
|
-
const evidencePath =
|
|
22624
|
+
const reportPath = join13(artifactsDir, "report.json");
|
|
22625
|
+
const evidencePath = join13(artifactsDir, "evidence.json");
|
|
22201
22626
|
await writeFile5(
|
|
22202
22627
|
reportPath,
|
|
22203
22628
|
`${JSON.stringify(
|
|
@@ -22278,7 +22703,7 @@ async function settleLawfulCollectorTerminalResult(admitted) {
|
|
|
22278
22703
|
const residual = boundErroredToolCandidate(entries, index, message, COLLECTOR_WAIT_TOOL);
|
|
22279
22704
|
if (residual === void 0) continue;
|
|
22280
22705
|
const candidate = residual.candidate;
|
|
22281
|
-
const duration =
|
|
22706
|
+
const duration = isRecord8(candidate) ? candidate.durationMs : void 0;
|
|
22282
22707
|
if (Number.isSafeInteger(duration) && duration >= 1 && duration <= 9e5) {
|
|
22283
22708
|
continue;
|
|
22284
22709
|
}
|
|
@@ -22303,12 +22728,15 @@ async function settleLawfulCollectorTerminalResult(admitted) {
|
|
|
22303
22728
|
admitted.sessionDirectory,
|
|
22304
22729
|
{ collectorReceipt: extracted.receipt }
|
|
22305
22730
|
);
|
|
22306
|
-
return
|
|
22307
|
-
|
|
22308
|
-
|
|
22309
|
-
|
|
22310
|
-
|
|
22311
|
-
|
|
22731
|
+
return withOptionalMenxiaProjection(
|
|
22732
|
+
{
|
|
22733
|
+
roleOutcome: extracted.outcome,
|
|
22734
|
+
navigator,
|
|
22735
|
+
artifacts,
|
|
22736
|
+
runId: admitted.runId
|
|
22737
|
+
},
|
|
22738
|
+
admitted.sessionDirectory
|
|
22739
|
+
);
|
|
22312
22740
|
}
|
|
22313
22741
|
async function trySettleCollectorTerminalResult(admitted) {
|
|
22314
22742
|
return settleLawfulCollectorTerminalResult(admitted);
|
|
@@ -22316,8 +22744,8 @@ async function trySettleCollectorTerminalResult(admitted) {
|
|
|
22316
22744
|
async function publishDoctorArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
|
|
22317
22745
|
await appendRunAttemptHistory(admitted, roleOutcome);
|
|
22318
22746
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
22319
|
-
const reportPath =
|
|
22320
|
-
const evidencePath =
|
|
22747
|
+
const reportPath = join13(artifactsDir, "report.json");
|
|
22748
|
+
const evidencePath = join13(artifactsDir, "evidence.json");
|
|
22321
22749
|
await writeFile5(
|
|
22322
22750
|
reportPath,
|
|
22323
22751
|
`${JSON.stringify(
|
|
@@ -22429,12 +22857,15 @@ async function settleLawfulDoctorTerminalResult(admitted) {
|
|
|
22429
22857
|
admitted.sessionDirectory,
|
|
22430
22858
|
extracted.output === void 0 ? {} : { doctorOutput: extracted.output }
|
|
22431
22859
|
);
|
|
22432
|
-
return
|
|
22433
|
-
|
|
22434
|
-
|
|
22435
|
-
|
|
22436
|
-
|
|
22437
|
-
|
|
22860
|
+
return withOptionalMenxiaProjection(
|
|
22861
|
+
{
|
|
22862
|
+
roleOutcome: extracted.outcome,
|
|
22863
|
+
navigator,
|
|
22864
|
+
artifacts,
|
|
22865
|
+
runId: admitted.runId
|
|
22866
|
+
},
|
|
22867
|
+
admitted.sessionDirectory
|
|
22868
|
+
);
|
|
22438
22869
|
}
|
|
22439
22870
|
async function trySettleDoctorTerminalResult(admitted) {
|
|
22440
22871
|
return settleLawfulDoctorTerminalResult(admitted);
|
|
@@ -22492,12 +22923,15 @@ async function settleLawfulNotaryTerminalResult(admitted) {
|
|
|
22492
22923
|
return void 0;
|
|
22493
22924
|
}
|
|
22494
22925
|
const navigator = extractNavigatorFact(entries);
|
|
22495
|
-
return
|
|
22496
|
-
|
|
22497
|
-
|
|
22498
|
-
|
|
22499
|
-
|
|
22500
|
-
|
|
22926
|
+
return withOptionalMenxiaProjection(
|
|
22927
|
+
{
|
|
22928
|
+
roleOutcome: extracted.outcome,
|
|
22929
|
+
navigator,
|
|
22930
|
+
artifacts: [],
|
|
22931
|
+
runId: admitted.runId
|
|
22932
|
+
},
|
|
22933
|
+
admitted.sessionDirectory
|
|
22934
|
+
);
|
|
22501
22935
|
}
|
|
22502
22936
|
async function trySettleNotaryTerminalResult(admitted) {
|
|
22503
22937
|
return settleLawfulNotaryTerminalResult(admitted);
|
|
@@ -22547,8 +22981,8 @@ function extractReviewerMethodInvocations(entries, options) {
|
|
|
22547
22981
|
async function publishReviewerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
|
|
22548
22982
|
await appendRunAttemptHistory(admitted, roleOutcome);
|
|
22549
22983
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
22550
|
-
const reportPath =
|
|
22551
|
-
const evidencePath =
|
|
22984
|
+
const reportPath = join13(artifactsDir, "report.json");
|
|
22985
|
+
const evidencePath = join13(artifactsDir, "evidence.json");
|
|
22552
22986
|
await writeFile5(
|
|
22553
22987
|
reportPath,
|
|
22554
22988
|
`${JSON.stringify(
|
|
@@ -22664,12 +23098,15 @@ async function settleLawfulReviewerTerminalResult(admitted, options) {
|
|
|
22664
23098
|
methodInvocations
|
|
22665
23099
|
}
|
|
22666
23100
|
);
|
|
22667
|
-
return
|
|
22668
|
-
|
|
22669
|
-
|
|
22670
|
-
|
|
22671
|
-
|
|
22672
|
-
|
|
23101
|
+
return withOptionalMenxiaProjection(
|
|
23102
|
+
{
|
|
23103
|
+
roleOutcome: extracted.outcome,
|
|
23104
|
+
navigator,
|
|
23105
|
+
artifacts,
|
|
23106
|
+
runId: admitted.runId
|
|
23107
|
+
},
|
|
23108
|
+
admitted.sessionDirectory
|
|
23109
|
+
);
|
|
22673
23110
|
}
|
|
22674
23111
|
async function trySettleReviewerTerminalResult(admitted, options) {
|
|
22675
23112
|
return settleLawfulReviewerTerminalResult(admitted, options);
|
|
@@ -22716,8 +23153,8 @@ function extractMergerMethodInvocations(entries, options) {
|
|
|
22716
23153
|
async function publishMergerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
|
|
22717
23154
|
await appendRunAttemptHistory(admitted, roleOutcome);
|
|
22718
23155
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
22719
|
-
const reportPath =
|
|
22720
|
-
const evidencePath =
|
|
23156
|
+
const reportPath = join13(artifactsDir, "report.json");
|
|
23157
|
+
const evidencePath = join13(artifactsDir, "evidence.json");
|
|
22721
23158
|
await writeFile5(
|
|
22722
23159
|
reportPath,
|
|
22723
23160
|
`${JSON.stringify(
|
|
@@ -22800,8 +23237,8 @@ async function settleLawfulMergerTerminalResult(admitted, options) {
|
|
|
22800
23237
|
const residual = boundErroredToolCandidate(entries, index, message, MERGER_OUTPUT_TOOL_NAME);
|
|
22801
23238
|
if (residual === void 0) continue;
|
|
22802
23239
|
const callMessage = entries[residual.callIndex]?.message;
|
|
22803
|
-
const calls = callMessage?.role === "assistant" && Array.isArray(callMessage.content) ? callMessage.content.filter((part) =>
|
|
22804
|
-
const attemptId =
|
|
23240
|
+
const calls = callMessage?.role === "assistant" && Array.isArray(callMessage.content) ? callMessage.content.filter((part) => isRecord8(part) && part.type === "toolCall") : [];
|
|
23241
|
+
const attemptId = isRecord8(residual.candidate) ? safelyRead(residual.candidate, "attemptId") : { readable: true, value: void 0 };
|
|
22805
23242
|
if (calls.length !== 1 || calls[0]?.name !== MERGER_OUTPUT_TOOL_NAME || !attemptId.readable || attemptId.value !== admitted.runId) {
|
|
22806
23243
|
continue;
|
|
22807
23244
|
}
|
|
@@ -22840,12 +23277,15 @@ async function settleLawfulMergerTerminalResult(admitted, options) {
|
|
|
22840
23277
|
methodInvocations
|
|
22841
23278
|
}
|
|
22842
23279
|
);
|
|
22843
|
-
return
|
|
22844
|
-
|
|
22845
|
-
|
|
22846
|
-
|
|
22847
|
-
|
|
22848
|
-
|
|
23280
|
+
return withOptionalMenxiaProjection(
|
|
23281
|
+
{
|
|
23282
|
+
roleOutcome: extracted.outcome,
|
|
23283
|
+
navigator,
|
|
23284
|
+
artifacts,
|
|
23285
|
+
runId: admitted.runId
|
|
23286
|
+
},
|
|
23287
|
+
admitted.sessionDirectory
|
|
23288
|
+
);
|
|
22849
23289
|
}
|
|
22850
23290
|
async function trySettleMergerTerminalResult(admitted, options) {
|
|
22851
23291
|
return settleLawfulMergerTerminalResult(admitted, options);
|
|
@@ -22885,7 +23325,7 @@ function uniqueFailureFallbackDirs(runDirectory, baseDir) {
|
|
|
22885
23325
|
return dirs;
|
|
22886
23326
|
}
|
|
22887
23327
|
async function resolveFailureArtifactsBase(runDirectory) {
|
|
22888
|
-
const artifactsDir =
|
|
23328
|
+
const artifactsDir = join13(runDirectory, "artifacts");
|
|
22889
23329
|
try {
|
|
22890
23330
|
await ensureRunArtifactsDir(runDirectory);
|
|
22891
23331
|
return { baseDir: artifactsDir };
|
|
@@ -22901,7 +23341,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
22901
23341
|
const candidates = [
|
|
22902
23342
|
...preferredCandidates,
|
|
22903
23343
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
22904
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
23344
|
+
...uniqueFallbackDirs.map((dir) => join13(dir, `${stem}.${randomUUID()}.json`))
|
|
22905
23345
|
];
|
|
22906
23346
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
22907
23347
|
const path = candidates[i];
|
|
@@ -22945,26 +23385,26 @@ async function publishFailureArtifacts(admitted, failure) {
|
|
|
22945
23385
|
} catch (error) {
|
|
22946
23386
|
priorIssues.push(publicationAttemptFromError(admitted.sessionFile, error));
|
|
22947
23387
|
}
|
|
22948
|
-
const underArtifacts = baseDir ===
|
|
23388
|
+
const underArtifacts = baseDir === join13(admitted.runDirectory, "artifacts");
|
|
22949
23389
|
const uniqueFallbackDirs = uniqueFailureFallbackDirs(
|
|
22950
23390
|
admitted.runDirectory,
|
|
22951
23391
|
baseDir
|
|
22952
23392
|
);
|
|
22953
23393
|
const errorCandidates = underArtifacts ? [
|
|
22954
|
-
|
|
22955
|
-
|
|
22956
|
-
|
|
23394
|
+
join13(baseDir, "error.json"),
|
|
23395
|
+
join13(baseDir, "error.settlement.json"),
|
|
23396
|
+
join13(admitted.runDirectory, "error.settlement.json")
|
|
22957
23397
|
] : [
|
|
22958
|
-
|
|
22959
|
-
|
|
23398
|
+
join13(baseDir, "error.settlement.json"),
|
|
23399
|
+
join13(baseDir, "error.json")
|
|
22960
23400
|
];
|
|
22961
23401
|
const evidenceCandidates = underArtifacts ? [
|
|
22962
|
-
|
|
22963
|
-
|
|
22964
|
-
|
|
23402
|
+
join13(baseDir, "evidence.json"),
|
|
23403
|
+
join13(baseDir, "evidence.settlement.json"),
|
|
23404
|
+
join13(admitted.runDirectory, "evidence.settlement.json")
|
|
22965
23405
|
] : [
|
|
22966
|
-
|
|
22967
|
-
|
|
23406
|
+
join13(baseDir, "evidence.settlement.json"),
|
|
23407
|
+
join13(baseDir, "evidence.json")
|
|
22968
23408
|
];
|
|
22969
23409
|
const errorPayloadBase = {
|
|
22970
23410
|
kind: "error",
|
|
@@ -23065,12 +23505,15 @@ async function settleFailureTerminalResult(admitted, failure, options = {}) {
|
|
|
23065
23505
|
const facts = parseNoReceiptLifecycleFacts(raw);
|
|
23066
23506
|
if (facts.runPointer === admitted.runDirectory && facts.attemptPointer === `current:${admitted.runDirectory}`) {
|
|
23067
23507
|
const decisiveFacts2 = facts;
|
|
23068
|
-
return
|
|
23069
|
-
|
|
23070
|
-
|
|
23071
|
-
|
|
23072
|
-
|
|
23073
|
-
|
|
23508
|
+
return withOptionalMenxiaProjection(
|
|
23509
|
+
{
|
|
23510
|
+
roleOutcome: { kind: "no_receipt", role: admitted.role, status: "no-accepted-receipt", ...facts, decisiveFacts: decisiveFacts2 },
|
|
23511
|
+
navigator: await extractNavigatorFactFromAdmittedSession(admitted),
|
|
23512
|
+
artifacts: [],
|
|
23513
|
+
runId: admitted.runId
|
|
23514
|
+
},
|
|
23515
|
+
admitted.sessionDirectory
|
|
23516
|
+
);
|
|
23074
23517
|
}
|
|
23075
23518
|
} catch {
|
|
23076
23519
|
}
|
|
@@ -23105,12 +23548,15 @@ async function settleFailureTerminalResult(admitted, failure, options = {}) {
|
|
|
23105
23548
|
diagnostic: publicDiagnostic,
|
|
23106
23549
|
decisiveFacts: publicFacts
|
|
23107
23550
|
};
|
|
23108
|
-
return
|
|
23109
|
-
|
|
23110
|
-
|
|
23111
|
-
|
|
23112
|
-
|
|
23113
|
-
|
|
23551
|
+
return withOptionalMenxiaProjection(
|
|
23552
|
+
{
|
|
23553
|
+
roleOutcome: roleOutcome2,
|
|
23554
|
+
navigator: redactNavigatorFactForPublicTerminal(navigator, admitted.runId),
|
|
23555
|
+
artifacts: [],
|
|
23556
|
+
resume: options.resume
|
|
23557
|
+
},
|
|
23558
|
+
admitted.sessionDirectory
|
|
23559
|
+
);
|
|
23114
23560
|
}
|
|
23115
23561
|
const roleOutcome = {
|
|
23116
23562
|
kind: "failure",
|
|
@@ -23119,12 +23565,15 @@ async function settleFailureTerminalResult(admitted, failure, options = {}) {
|
|
|
23119
23565
|
diagnostic: failure.diagnostic,
|
|
23120
23566
|
decisiveFacts
|
|
23121
23567
|
};
|
|
23122
|
-
return
|
|
23123
|
-
|
|
23124
|
-
|
|
23125
|
-
|
|
23126
|
-
|
|
23127
|
-
|
|
23568
|
+
return withOptionalMenxiaProjection(
|
|
23569
|
+
{
|
|
23570
|
+
roleOutcome,
|
|
23571
|
+
navigator,
|
|
23572
|
+
artifacts,
|
|
23573
|
+
runId: admitted.runId
|
|
23574
|
+
},
|
|
23575
|
+
admitted.sessionDirectory
|
|
23576
|
+
);
|
|
23128
23577
|
}
|
|
23129
23578
|
async function settleJudgeFailureTerminalResult(admitted, failure, options = {}) {
|
|
23130
23579
|
return settleFailureTerminalResult(admitted, failure, options);
|
|
@@ -23145,6 +23594,7 @@ var CONCISE_DIAGNOSTIC_MAX_CHARS, COLLECTOR_INFRASTRUCTURE_TOOLS, COLLECTOR_INFR
|
|
|
23145
23594
|
var init_settlement = __esm({
|
|
23146
23595
|
"src/public-cli/settlement.ts"() {
|
|
23147
23596
|
"use strict";
|
|
23597
|
+
init_analyst_gate_cycles_read();
|
|
23148
23598
|
init_audit_escalation();
|
|
23149
23599
|
init_auditor_soul();
|
|
23150
23600
|
init_doctor_auditor();
|
|
@@ -23192,8 +23642,8 @@ var init_settlement = __esm({
|
|
|
23192
23642
|
// src/public-cli/auto-resume.ts
|
|
23193
23643
|
import { constants as fsConstants2 } from "node:fs";
|
|
23194
23644
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
23195
|
-
import { appendFile as appendFile2, lstat as lstat5, mkdir as mkdir4, open as open3, readFile as
|
|
23196
|
-
import { join as
|
|
23645
|
+
import { appendFile as appendFile2, lstat as lstat5, mkdir as mkdir4, open as open3, readFile as readFile11 } from "node:fs/promises";
|
|
23646
|
+
import { join as join14 } from "node:path";
|
|
23197
23647
|
function presentTerminal(terminal, io) {
|
|
23198
23648
|
if (terminal.roleOutcome.kind === "failure" || terminal.roleOutcome.kind === "no_receipt") {
|
|
23199
23649
|
presentFailureTerminal(terminal, io);
|
|
@@ -23212,7 +23662,7 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
|
|
|
23212
23662
|
}
|
|
23213
23663
|
}
|
|
23214
23664
|
function runArtifactsDirectory(runDirectory) {
|
|
23215
|
-
return
|
|
23665
|
+
return join14(runDirectory, "artifacts");
|
|
23216
23666
|
}
|
|
23217
23667
|
async function ensureRealArtifactsDirectory(runDirectory) {
|
|
23218
23668
|
const runStat = await lstat5(runDirectory);
|
|
@@ -23295,7 +23745,7 @@ function jsonSafeReplacer() {
|
|
|
23295
23745
|
}
|
|
23296
23746
|
async function retainDispatchError(admitted, attempt, error) {
|
|
23297
23747
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
23298
|
-
const filePath =
|
|
23748
|
+
const filePath = join14(
|
|
23299
23749
|
artifactsDir,
|
|
23300
23750
|
`dispatch-error-attempt-${attempt}-${randomUUID2()}.json`
|
|
23301
23751
|
);
|
|
@@ -23330,7 +23780,7 @@ async function retainDispatchError(admitted, attempt, error) {
|
|
|
23330
23780
|
}
|
|
23331
23781
|
let pointerError;
|
|
23332
23782
|
try {
|
|
23333
|
-
const text = await
|
|
23783
|
+
const text = await readFile11(admitted.sessionFile, "utf8");
|
|
23334
23784
|
let parentId = null;
|
|
23335
23785
|
for (const line2 of text.trim().split("\n").filter(Boolean)) {
|
|
23336
23786
|
const entry = JSON.parse(line2);
|
|
@@ -23519,7 +23969,7 @@ var init_auto_resume = __esm({
|
|
|
23519
23969
|
|
|
23520
23970
|
// src/public-cli/coder-run.ts
|
|
23521
23971
|
import { writeFile as writeFile6 } from "node:fs/promises";
|
|
23522
|
-
import { join as
|
|
23972
|
+
import { join as join15 } from "node:path";
|
|
23523
23973
|
function buildCoderActivationExtraArgs(admitted, options) {
|
|
23524
23974
|
const prompt = buildCoderTransportPrompt(
|
|
23525
23975
|
admitted,
|
|
@@ -23681,7 +24131,7 @@ async function dispatchAdmittedCoder(input) {
|
|
|
23681
24131
|
}
|
|
23682
24132
|
try {
|
|
23683
24133
|
await writeFile6(
|
|
23684
|
-
|
|
24134
|
+
join15(admitted.runDirectory, "stderr.log"),
|
|
23685
24135
|
result2.stderr,
|
|
23686
24136
|
"utf8"
|
|
23687
24137
|
);
|
|
@@ -23898,7 +24348,7 @@ var init_coder_run = __esm({
|
|
|
23898
24348
|
|
|
23899
24349
|
// src/public-cli/collector-run.ts
|
|
23900
24350
|
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
23901
|
-
import { join as
|
|
24351
|
+
import { join as join16 } from "node:path";
|
|
23902
24352
|
function buildCollectorActivationExtraArgs(admitted, options = {}) {
|
|
23903
24353
|
const prompt = buildCollectorTransportPrompt(
|
|
23904
24354
|
admitted,
|
|
@@ -24003,7 +24453,7 @@ async function dispatchAdmittedCollector(input) {
|
|
|
24003
24453
|
}
|
|
24004
24454
|
try {
|
|
24005
24455
|
await writeFile7(
|
|
24006
|
-
|
|
24456
|
+
join16(admitted.runDirectory, "stderr.log"),
|
|
24007
24457
|
result2.stderr,
|
|
24008
24458
|
"utf8"
|
|
24009
24459
|
);
|
|
@@ -24134,7 +24584,7 @@ var init_collector_run = __esm({
|
|
|
24134
24584
|
|
|
24135
24585
|
// src/public-cli/one-shot-dispatch.ts
|
|
24136
24586
|
import { writeFile as writeFile8 } from "node:fs/promises";
|
|
24137
|
-
import { join as
|
|
24587
|
+
import { join as join17 } from "node:path";
|
|
24138
24588
|
async function presentControlledFailure4(admitted, failureInput, io) {
|
|
24139
24589
|
const hasThrown = Object.hasOwn(failureInput, "thrown");
|
|
24140
24590
|
const session = !hasThrown && !failureInput.timedOut && failureInput.knownFailure === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
|
|
@@ -24211,7 +24661,7 @@ async function dispatchAdmittedOneShotRole(input) {
|
|
|
24211
24661
|
}
|
|
24212
24662
|
try {
|
|
24213
24663
|
await writeFile8(
|
|
24214
|
-
|
|
24664
|
+
join17(admitted.runDirectory, "stderr.log"),
|
|
24215
24665
|
result2.stderr,
|
|
24216
24666
|
"utf8"
|
|
24217
24667
|
);
|
|
@@ -24397,7 +24847,7 @@ var init_doctor_run = __esm({
|
|
|
24397
24847
|
|
|
24398
24848
|
// src/public-cli/fixer-run.ts
|
|
24399
24849
|
import { writeFile as writeFile9 } from "node:fs/promises";
|
|
24400
|
-
import { join as
|
|
24850
|
+
import { join as join18 } from "node:path";
|
|
24401
24851
|
function buildFixerActivationExtraArgs(admitted, options) {
|
|
24402
24852
|
const prompt = buildFixerTransportPrompt(
|
|
24403
24853
|
admitted,
|
|
@@ -24568,7 +25018,7 @@ async function dispatchAdmittedFixer(input) {
|
|
|
24568
25018
|
}
|
|
24569
25019
|
try {
|
|
24570
25020
|
await writeFile9(
|
|
24571
|
-
|
|
25021
|
+
join18(admitted.runDirectory, "stderr.log"),
|
|
24572
25022
|
result2.stderr,
|
|
24573
25023
|
"utf8"
|
|
24574
25024
|
);
|
|
@@ -24869,7 +25319,7 @@ var init_notary_run = __esm({
|
|
|
24869
25319
|
|
|
24870
25320
|
// src/public-cli/judge-run.ts
|
|
24871
25321
|
import { writeFile as writeFile10 } from "node:fs/promises";
|
|
24872
|
-
import { join as
|
|
25322
|
+
import { join as join19 } from "node:path";
|
|
24873
25323
|
function buildJudgeActivationExtraArgs(admitted, options = {}) {
|
|
24874
25324
|
const prompt = buildJudgeTransportPrompt(
|
|
24875
25325
|
admitted,
|
|
@@ -25017,7 +25467,7 @@ async function dispatchAdmittedJudge(input) {
|
|
|
25017
25467
|
}
|
|
25018
25468
|
try {
|
|
25019
25469
|
await writeFile10(
|
|
25020
|
-
|
|
25470
|
+
join19(admitted.runDirectory, "stderr.log"),
|
|
25021
25471
|
result2.stderr,
|
|
25022
25472
|
"utf8"
|
|
25023
25473
|
);
|
|
@@ -25202,7 +25652,7 @@ var init_judge_run = __esm({
|
|
|
25202
25652
|
|
|
25203
25653
|
// src/public-cli/merger-run.ts
|
|
25204
25654
|
import { mkdir as mkdir5, writeFile as writeFile11 } from "node:fs/promises";
|
|
25205
|
-
import { join as
|
|
25655
|
+
import { join as join20, resolve as resolve7 } from "node:path";
|
|
25206
25656
|
function buildMergerActivationExtraArgs(admitted, options) {
|
|
25207
25657
|
const prompt = buildMergerTransportPrompt(
|
|
25208
25658
|
admitted,
|
|
@@ -25362,7 +25812,7 @@ async function dispatchAdmittedMerger(input) {
|
|
|
25362
25812
|
}
|
|
25363
25813
|
try {
|
|
25364
25814
|
await writeFile11(
|
|
25365
|
-
|
|
25815
|
+
join20(admitted.runDirectory, "stderr.log"),
|
|
25366
25816
|
result2.stderr,
|
|
25367
25817
|
"utf8"
|
|
25368
25818
|
);
|
|
@@ -25443,8 +25893,8 @@ async function admitMergerShellForActivationFailure(options) {
|
|
|
25443
25893
|
expectedConflictPaths: [],
|
|
25444
25894
|
resolutionScope: []
|
|
25445
25895
|
};
|
|
25446
|
-
const admittedRequestPath =
|
|
25447
|
-
const mergerInputPath =
|
|
25896
|
+
const admittedRequestPath = join20(runDirectory, "admitted-request.json");
|
|
25897
|
+
const mergerInputPath = join20(runDirectory, "merger-input.json");
|
|
25448
25898
|
await writeFile11(
|
|
25449
25899
|
admittedRequestPath,
|
|
25450
25900
|
`${JSON.stringify(
|
|
@@ -25660,7 +26110,7 @@ var init_merger_run = __esm({
|
|
|
25660
26110
|
|
|
25661
26111
|
// src/public-cli/reviewer-run.ts
|
|
25662
26112
|
import { writeFile as writeFile12 } from "node:fs/promises";
|
|
25663
|
-
import { join as
|
|
26113
|
+
import { join as join21 } from "node:path";
|
|
25664
26114
|
function buildReviewerTicketNumberArgs(ticketNumber) {
|
|
25665
26115
|
return ticketNumber === void 0 ? [] : ["--ak-review-ticket-number", String(ticketNumber)];
|
|
25666
26116
|
}
|
|
@@ -25829,7 +26279,7 @@ async function dispatchAdmittedReviewer(input) {
|
|
|
25829
26279
|
}
|
|
25830
26280
|
try {
|
|
25831
26281
|
await writeFile12(
|
|
25832
|
-
|
|
26282
|
+
join21(admitted.runDirectory, "stderr.log"),
|
|
25833
26283
|
result2.stderr,
|
|
25834
26284
|
"utf8"
|
|
25835
26285
|
);
|
|
@@ -26095,10 +26545,10 @@ var init_analyst_book_key = __esm({
|
|
|
26095
26545
|
// src/atomic-write.ts
|
|
26096
26546
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
26097
26547
|
import { rename, rm, writeFile as writeFile13 } from "node:fs/promises";
|
|
26098
|
-
import { dirname as dirname8, join as
|
|
26548
|
+
import { dirname as dirname8, join as join22 } from "node:path";
|
|
26099
26549
|
async function writeFileAtomically(destination, contents) {
|
|
26100
26550
|
const parent = dirname8(destination);
|
|
26101
|
-
const temporary =
|
|
26551
|
+
const temporary = join22(parent, `.atomic-write-${randomUUID3()}.tmp`);
|
|
26102
26552
|
try {
|
|
26103
26553
|
await writeFile13(temporary, contents);
|
|
26104
26554
|
await rename(temporary, destination);
|
|
@@ -26114,8 +26564,8 @@ var init_atomic_write = __esm({
|
|
|
26114
26564
|
});
|
|
26115
26565
|
|
|
26116
26566
|
// src/analyst-index.ts
|
|
26117
|
-
import { open as open4, readFile as
|
|
26118
|
-
import { dirname as dirname9, join as
|
|
26567
|
+
import { open as open4, readFile as readFile12, unlink as unlink4 } from "node:fs/promises";
|
|
26568
|
+
import { dirname as dirname9, join as join23 } from "node:path";
|
|
26119
26569
|
function sleep(ms) {
|
|
26120
26570
|
return new Promise((resolve9) => {
|
|
26121
26571
|
setTimeout(resolve9, ms);
|
|
@@ -26124,7 +26574,7 @@ function sleep(ms) {
|
|
|
26124
26574
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
26125
26575
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
26126
26576
|
ensureRealDirectoryTree(ledgerHome, dirname9(indexPath));
|
|
26127
|
-
const lockPath =
|
|
26577
|
+
const lockPath = join23(dirname9(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
26128
26578
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
26129
26579
|
const startedAt = Date.now();
|
|
26130
26580
|
while (true) {
|
|
@@ -26151,7 +26601,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
26151
26601
|
}
|
|
26152
26602
|
}
|
|
26153
26603
|
function analystLibraryIndexPath(ledgerHome) {
|
|
26154
|
-
return
|
|
26604
|
+
return join23(ledgerHome, "analyst", "library-index.json");
|
|
26155
26605
|
}
|
|
26156
26606
|
function rowFromIssueMetricsPage(page) {
|
|
26157
26607
|
return {
|
|
@@ -26242,7 +26692,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
26242
26692
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
26243
26693
|
let raw;
|
|
26244
26694
|
try {
|
|
26245
|
-
raw = await
|
|
26695
|
+
raw = await readFile12(path, "utf8");
|
|
26246
26696
|
} catch (error) {
|
|
26247
26697
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
26248
26698
|
return void 0;
|
|
@@ -26385,245 +26835,83 @@ async function aggregateGroup(index, input, ensureIssuePage) {
|
|
|
26385
26835
|
issueNumber,
|
|
26386
26836
|
status: "present",
|
|
26387
26837
|
bookKey: row.bookKey,
|
|
26388
|
-
projectRoot: row.projectRoot
|
|
26389
|
-
});
|
|
26390
|
-
const acceptance = page.acceptanceSuccessRework;
|
|
26391
|
-
if (acceptance !== void 0) {
|
|
26392
|
-
for (const roleStats of acceptance.byRole) {
|
|
26393
|
-
const accum = roleAccums.get(roleStats.role) ?? emptyRoleAccum();
|
|
26394
|
-
absorbRole(accum, roleStats);
|
|
26395
|
-
roleAccums.set(roleStats.role, accum);
|
|
26396
|
-
}
|
|
26397
|
-
reworkWallMs += acceptance.rework.reworkWallMs;
|
|
26398
|
-
totalWallMs += acceptance.rework.totalWallMs;
|
|
26399
|
-
hasReworkSample = true;
|
|
26400
|
-
}
|
|
26401
|
-
const legWallClock = page.legWallClock;
|
|
26402
|
-
if (legWallClock !== void 0) {
|
|
26403
|
-
for (const leg of legWallClock.ranking) {
|
|
26404
|
-
legWalls.push(leg.wallMs);
|
|
26405
|
-
}
|
|
26406
|
-
}
|
|
26407
|
-
const gateCycles = page.gateCycles;
|
|
26408
|
-
if (gateCycles !== void 0) {
|
|
26409
|
-
for (const summary of gateCycles.byOfficer) {
|
|
26410
|
-
const accum = gateOfficerAccums.get(summary.officer) ?? emptyGateOfficerNumeratorAccum();
|
|
26411
|
-
absorbGateOfficerSummary(accum, summary);
|
|
26412
|
-
gateOfficerAccums.set(summary.officer, accum);
|
|
26413
|
-
}
|
|
26414
|
-
}
|
|
26415
|
-
}
|
|
26416
|
-
const byRole = [...roleAccums.keys()].sort((a, b) => a.localeCompare(b)).map((role) => finishRole(role, roleAccums.get(role)));
|
|
26417
|
-
const gateCyclesByOfficer = ["inspector", "notary"].filter((officer) => gateOfficerAccums.has(officer)).map(
|
|
26418
|
-
(officer) => finishGateOfficerNumerators(officer, gateOfficerAccums.get(officer))
|
|
26419
|
-
);
|
|
26420
|
-
return {
|
|
26421
|
-
groupLabel: input.groupLabel,
|
|
26422
|
-
issues: issueEntries,
|
|
26423
|
-
byRole,
|
|
26424
|
-
reworkRatio: hasReworkSample ? rateMetric(reworkWallMs, totalWallMs) : ABSENT,
|
|
26425
|
-
medianWallMs: optionalMedian(legWalls),
|
|
26426
|
-
gateCyclesByOfficer
|
|
26427
|
-
};
|
|
26428
|
-
}
|
|
26429
|
-
async function runAnalystCohortMode(ledgerHome, input, ensureIssuePage) {
|
|
26430
|
-
const index = await readAnalystLibraryIndexPage(ledgerHome);
|
|
26431
|
-
const group0 = await aggregateGroup(index, input.groups[0], ensureIssuePage);
|
|
26432
|
-
const group1 = await aggregateGroup(index, input.groups[1], ensureIssuePage);
|
|
26433
|
-
return {
|
|
26434
|
-
mode: "cohort",
|
|
26435
|
-
groups: [group0, group1]
|
|
26436
|
-
};
|
|
26437
|
-
}
|
|
26438
|
-
var ABSENT;
|
|
26439
|
-
var init_analyst_cohort = __esm({
|
|
26440
|
-
"src/analyst-cohort.ts"() {
|
|
26441
|
-
"use strict";
|
|
26442
|
-
init_analyst_index();
|
|
26443
|
-
init_analyst_median();
|
|
26444
|
-
ABSENT = { status: "absent" };
|
|
26445
|
-
}
|
|
26446
|
-
});
|
|
26447
|
-
|
|
26448
|
-
// src/ledger-session-read.ts
|
|
26449
|
-
import { readFile as readFile12 } from "node:fs/promises";
|
|
26450
|
-
function isRecord7(value) {
|
|
26451
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26452
|
-
}
|
|
26453
|
-
async function readLedgerSessionJsonl(path) {
|
|
26454
|
-
const text = await readFile12(path, "utf8");
|
|
26455
|
-
const lines = text.split("\n");
|
|
26456
|
-
const rows = [];
|
|
26457
|
-
for (let index = 0; index < lines.length; index += 1) {
|
|
26458
|
-
const line2 = lines[index];
|
|
26459
|
-
if (!line2.trim()) continue;
|
|
26460
|
-
let row;
|
|
26461
|
-
try {
|
|
26462
|
-
row = JSON.parse(line2);
|
|
26463
|
-
} catch (error) {
|
|
26464
|
-
if (!(error instanceof SyntaxError)) throw error;
|
|
26465
|
-
const completedByTerminator = index < lines.length - 1;
|
|
26466
|
-
if (completedByTerminator) {
|
|
26467
|
-
throw new LedgerSessionJsonlError(
|
|
26468
|
-
`malformed JSONL record in ${path} at line ${index + 1}: ${error.message}`,
|
|
26469
|
-
{ path, line: index + 1, prefixRows: rows }
|
|
26470
|
-
);
|
|
26471
|
-
}
|
|
26472
|
-
break;
|
|
26473
|
-
}
|
|
26474
|
-
if (!isRecord7(row)) {
|
|
26475
|
-
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
26476
|
-
throw new LedgerSessionJsonlError(
|
|
26477
|
-
`complete non-object JSONL record in ${path} at line ${index + 1}: expected object, got ${kind}`,
|
|
26478
|
-
{ path, line: index + 1, prefixRows: rows }
|
|
26479
|
-
);
|
|
26480
|
-
}
|
|
26481
|
-
rows.push(row);
|
|
26482
|
-
}
|
|
26483
|
-
return rows;
|
|
26484
|
-
}
|
|
26485
|
-
function extractSessionTimestampSpan(rows) {
|
|
26486
|
-
let startedAt;
|
|
26487
|
-
let endedAt;
|
|
26488
|
-
for (const row of rows) {
|
|
26489
|
-
if (typeof row.timestamp !== "string" || !row.timestamp) continue;
|
|
26490
|
-
if (startedAt === void 0) startedAt = row.timestamp;
|
|
26491
|
-
endedAt = row.timestamp;
|
|
26492
|
-
}
|
|
26493
|
-
return {
|
|
26494
|
-
...startedAt !== void 0 ? { startedAt } : {},
|
|
26495
|
-
...endedAt !== void 0 ? { endedAt } : {}
|
|
26496
|
-
};
|
|
26497
|
-
}
|
|
26498
|
-
function extractSessionModelSequence(rows) {
|
|
26499
|
-
const seen = /* @__PURE__ */ new Set();
|
|
26500
|
-
const ordered = [];
|
|
26501
|
-
const push = (raw) => {
|
|
26502
|
-
const model = raw.trim();
|
|
26503
|
-
if (model === "" || seen.has(model)) return;
|
|
26504
|
-
seen.add(model);
|
|
26505
|
-
ordered.push(model);
|
|
26506
|
-
};
|
|
26507
|
-
for (const row of rows) {
|
|
26508
|
-
if (row.type === "model_change" && typeof row.modelId === "string") {
|
|
26509
|
-
push(row.modelId);
|
|
26510
|
-
}
|
|
26511
|
-
const message = isRecord7(row.message) ? row.message : void 0;
|
|
26512
|
-
if (message?.role === "assistant" && typeof message.model === "string") {
|
|
26513
|
-
push(message.model);
|
|
26514
|
-
}
|
|
26515
|
-
}
|
|
26516
|
-
return ordered;
|
|
26517
|
-
}
|
|
26518
|
-
function bashCommandFirstLine(command) {
|
|
26519
|
-
const match = /^[^\r\n]*/.exec(command);
|
|
26520
|
-
return match?.[0] ?? "";
|
|
26521
|
-
}
|
|
26522
|
-
function extractSessionToolIntervals(rows) {
|
|
26523
|
-
const order = [];
|
|
26524
|
-
const openById = /* @__PURE__ */ new Map();
|
|
26525
|
-
for (const row of rows) {
|
|
26526
|
-
const rowTimestamp = typeof row.timestamp === "string" ? row.timestamp : void 0;
|
|
26527
|
-
const message = isRecord7(row.message) ? row.message : void 0;
|
|
26528
|
-
if (message?.role === "assistant" && Array.isArray(message.content)) {
|
|
26529
|
-
const callTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
|
|
26530
|
-
for (const part of message.content) {
|
|
26531
|
-
if (!isRecord7(part) || part.type !== "toolCall") continue;
|
|
26532
|
-
if (typeof part.id !== "string" || part.id.length === 0) {
|
|
26533
|
-
throw new Error("toolCall frame missing string id");
|
|
26534
|
-
}
|
|
26535
|
-
if (typeof part.name !== "string" || part.name.length === 0) {
|
|
26536
|
-
throw new Error(`toolCall ${part.id} missing string name`);
|
|
26537
|
-
}
|
|
26538
|
-
if (callTimestamp === void 0 || callTimestamp.length === 0) {
|
|
26539
|
-
throw new Error(`toolCall ${part.id} missing timestamp`);
|
|
26540
|
-
}
|
|
26541
|
-
if (openById.has(part.id)) {
|
|
26542
|
-
throw new Error(`duplicate toolCall id ${part.id}`);
|
|
26543
|
-
}
|
|
26544
|
-
const args = isRecord7(part.arguments) ? part.arguments : void 0;
|
|
26545
|
-
const command = part.name === "bash" && args !== void 0 && typeof args.command === "string" ? bashCommandFirstLine(args.command) : void 0;
|
|
26546
|
-
const interval = {
|
|
26547
|
-
toolCallId: part.id,
|
|
26548
|
-
toolName: part.name,
|
|
26549
|
-
startedAt: callTimestamp,
|
|
26550
|
-
...command !== void 0 ? { command } : {}
|
|
26551
|
-
};
|
|
26552
|
-
order.push(interval);
|
|
26553
|
-
openById.set(part.id, interval);
|
|
26554
|
-
}
|
|
26555
|
-
}
|
|
26556
|
-
if (message?.role === "toolResult") {
|
|
26557
|
-
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) {
|
|
26558
|
-
throw new Error("toolResult frame missing string toolCallId");
|
|
26559
|
-
}
|
|
26560
|
-
const resultTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
|
|
26561
|
-
if (resultTimestamp === void 0 || resultTimestamp.length === 0) {
|
|
26562
|
-
throw new Error(`toolResult ${message.toolCallId} missing timestamp`);
|
|
26563
|
-
}
|
|
26564
|
-
const open5 = openById.get(message.toolCallId);
|
|
26565
|
-
if (open5 === void 0) {
|
|
26566
|
-
const toolName = typeof message.toolName === "string" && message.toolName.length > 0 ? message.toolName : "unknown";
|
|
26567
|
-
order.push({
|
|
26568
|
-
toolCallId: message.toolCallId,
|
|
26569
|
-
toolName,
|
|
26570
|
-
startedAt: resultTimestamp,
|
|
26571
|
-
endedAt: resultTimestamp
|
|
26572
|
-
});
|
|
26573
|
-
continue;
|
|
26838
|
+
projectRoot: row.projectRoot
|
|
26839
|
+
});
|
|
26840
|
+
const acceptance = page.acceptanceSuccessRework;
|
|
26841
|
+
if (acceptance !== void 0) {
|
|
26842
|
+
for (const roleStats of acceptance.byRole) {
|
|
26843
|
+
const accum = roleAccums.get(roleStats.role) ?? emptyRoleAccum();
|
|
26844
|
+
absorbRole(accum, roleStats);
|
|
26845
|
+
roleAccums.set(roleStats.role, accum);
|
|
26574
26846
|
}
|
|
26575
|
-
|
|
26576
|
-
|
|
26847
|
+
reworkWallMs += acceptance.rework.reworkWallMs;
|
|
26848
|
+
totalWallMs += acceptance.rework.totalWallMs;
|
|
26849
|
+
hasReworkSample = true;
|
|
26850
|
+
}
|
|
26851
|
+
const legWallClock = page.legWallClock;
|
|
26852
|
+
if (legWallClock !== void 0) {
|
|
26853
|
+
for (const leg of legWallClock.ranking) {
|
|
26854
|
+
legWalls.push(leg.wallMs);
|
|
26855
|
+
}
|
|
26856
|
+
}
|
|
26857
|
+
const gateCycles = page.gateCycles;
|
|
26858
|
+
if (gateCycles !== void 0) {
|
|
26859
|
+
for (const summary of gateCycles.byOfficer) {
|
|
26860
|
+
const accum = gateOfficerAccums.get(summary.officer) ?? emptyGateOfficerNumeratorAccum();
|
|
26861
|
+
absorbGateOfficerSummary(accum, summary);
|
|
26862
|
+
gateOfficerAccums.set(summary.officer, accum);
|
|
26577
26863
|
}
|
|
26578
|
-
open5.endedAt = resultTimestamp;
|
|
26579
26864
|
}
|
|
26580
26865
|
}
|
|
26581
|
-
|
|
26582
|
-
|
|
26583
|
-
|
|
26584
|
-
|
|
26585
|
-
|
|
26586
|
-
|
|
26587
|
-
|
|
26588
|
-
|
|
26589
|
-
|
|
26866
|
+
const byRole = [...roleAccums.keys()].sort((a, b) => a.localeCompare(b)).map((role) => finishRole(role, roleAccums.get(role)));
|
|
26867
|
+
const gateCyclesByOfficer = ["inspector", "notary"].filter((officer) => gateOfficerAccums.has(officer)).map(
|
|
26868
|
+
(officer) => finishGateOfficerNumerators(officer, gateOfficerAccums.get(officer))
|
|
26869
|
+
);
|
|
26870
|
+
return {
|
|
26871
|
+
groupLabel: input.groupLabel,
|
|
26872
|
+
issues: issueEntries,
|
|
26873
|
+
byRole,
|
|
26874
|
+
reworkRatio: hasReworkSample ? rateMetric(reworkWallMs, totalWallMs) : ABSENT,
|
|
26875
|
+
medianWallMs: optionalMedian(legWalls),
|
|
26876
|
+
gateCyclesByOfficer
|
|
26877
|
+
};
|
|
26590
26878
|
}
|
|
26591
|
-
|
|
26592
|
-
|
|
26593
|
-
|
|
26879
|
+
async function runAnalystCohortMode(ledgerHome, input, ensureIssuePage) {
|
|
26880
|
+
const index = await readAnalystLibraryIndexPage(ledgerHome);
|
|
26881
|
+
const group0 = await aggregateGroup(index, input.groups[0], ensureIssuePage);
|
|
26882
|
+
const group1 = await aggregateGroup(index, input.groups[1], ensureIssuePage);
|
|
26883
|
+
return {
|
|
26884
|
+
mode: "cohort",
|
|
26885
|
+
groups: [group0, group1]
|
|
26886
|
+
};
|
|
26887
|
+
}
|
|
26888
|
+
var ABSENT;
|
|
26889
|
+
var init_analyst_cohort = __esm({
|
|
26890
|
+
"src/analyst-cohort.ts"() {
|
|
26594
26891
|
"use strict";
|
|
26595
|
-
|
|
26596
|
-
|
|
26597
|
-
|
|
26598
|
-
prefixRows;
|
|
26599
|
-
constructor(message, init) {
|
|
26600
|
-
super(message);
|
|
26601
|
-
this.name = "LedgerSessionJsonlError";
|
|
26602
|
-
this.path = init.path;
|
|
26603
|
-
this.line = init.line;
|
|
26604
|
-
this.prefixRows = init.prefixRows;
|
|
26605
|
-
}
|
|
26606
|
-
};
|
|
26892
|
+
init_analyst_index();
|
|
26893
|
+
init_analyst_median();
|
|
26894
|
+
ABSENT = { status: "absent" };
|
|
26607
26895
|
}
|
|
26608
26896
|
});
|
|
26609
26897
|
|
|
26610
26898
|
// src/run-terminal-artifacts.ts
|
|
26611
|
-
import { readdir as
|
|
26612
|
-
import { basename as basename5, dirname as dirname10, join as
|
|
26899
|
+
import { readdir as readdir5, readFile as readFile13 } from "node:fs/promises";
|
|
26900
|
+
import { basename as basename5, dirname as dirname10, join as join24 } from "node:path";
|
|
26613
26901
|
function isMissingPathError4(error) {
|
|
26614
26902
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
26615
26903
|
}
|
|
26616
26904
|
function errorText2(error) {
|
|
26617
26905
|
return error instanceof Error ? error.message : String(error);
|
|
26618
26906
|
}
|
|
26619
|
-
function
|
|
26907
|
+
function isRecord9(value) {
|
|
26620
26908
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26621
26909
|
}
|
|
26622
26910
|
function readUsableTerminalArtifactBody(body) {
|
|
26623
26911
|
if (body === null) {
|
|
26624
26912
|
return { ok: false, reason: "terminal artifact JSON value is null" };
|
|
26625
26913
|
}
|
|
26626
|
-
if (!
|
|
26914
|
+
if (!isRecord9(body)) {
|
|
26627
26915
|
return {
|
|
26628
26916
|
ok: false,
|
|
26629
26917
|
reason: `terminal artifact JSON value is not a typed object (${Array.isArray(body) ? "array" : typeof body})`
|
|
@@ -26677,14 +26965,14 @@ async function listUniqueErrorFallbackPaths(directories) {
|
|
|
26677
26965
|
for (const dir of directories) {
|
|
26678
26966
|
let names;
|
|
26679
26967
|
try {
|
|
26680
|
-
names = await
|
|
26968
|
+
names = await readdir5(dir);
|
|
26681
26969
|
} catch (error) {
|
|
26682
26970
|
if (isMissingPathError4(error)) continue;
|
|
26683
26971
|
throw error;
|
|
26684
26972
|
}
|
|
26685
26973
|
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
26686
26974
|
if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
|
|
26687
|
-
found.push(
|
|
26975
|
+
found.push(join24(dir, name));
|
|
26688
26976
|
}
|
|
26689
26977
|
}
|
|
26690
26978
|
return found;
|
|
@@ -26700,14 +26988,14 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
|
|
|
26700
26988
|
return typeof body.runId === "string" && body.runId === expectedRunId;
|
|
26701
26989
|
}
|
|
26702
26990
|
async function readRunTerminalArtifact(runDirectory) {
|
|
26703
|
-
const artifactsDir =
|
|
26991
|
+
const artifactsDir = join24(runDirectory, "artifacts");
|
|
26704
26992
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
26705
|
-
const path =
|
|
26993
|
+
const path = join24(artifactsDir, file);
|
|
26706
26994
|
const read3 = await readTerminalArtifactAtPath(path, file);
|
|
26707
26995
|
if (read3 !== void 0) return read3;
|
|
26708
26996
|
}
|
|
26709
26997
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
26710
|
-
const path =
|
|
26998
|
+
const path = join24(runDirectory, relative3);
|
|
26711
26999
|
const read3 = await readTerminalArtifactAtPath(path, "error.json");
|
|
26712
27000
|
if (read3 !== void 0) return read3;
|
|
26713
27001
|
}
|
|
@@ -26743,194 +27031,6 @@ var init_run_terminal_artifacts = __esm({
|
|
|
26743
27031
|
}
|
|
26744
27032
|
});
|
|
26745
27033
|
|
|
26746
|
-
// src/analyst-gate-cycles-read.ts
|
|
26747
|
-
import { readdir as readdir5 } from "node:fs/promises";
|
|
26748
|
-
import { join as join24 } from "node:path";
|
|
26749
|
-
function isRecord9(value) {
|
|
26750
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26751
|
-
}
|
|
26752
|
-
function isMissingDirectoryError(error) {
|
|
26753
|
-
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
26754
|
-
}
|
|
26755
|
-
function normalizeOfficerArg(raw) {
|
|
26756
|
-
if (typeof raw !== "string") return void 0;
|
|
26757
|
-
return OFFICER_ARG_ALIASES[raw.trim()];
|
|
26758
|
-
}
|
|
26759
|
-
function isGateTerminatingToolName(toolName) {
|
|
26760
|
-
return DISPATCH_TOOLS.has(toolName) || OFFICER_TOOL_TO_FACE[toolName] !== void 0;
|
|
26761
|
-
}
|
|
26762
|
-
function acceptedGateReceiptIds(rows) {
|
|
26763
|
-
const accepted = /* @__PURE__ */ new Set();
|
|
26764
|
-
for (const row of rows) {
|
|
26765
|
-
const message = isRecord9(row.message) ? row.message : void 0;
|
|
26766
|
-
if (message?.role !== "toolResult") continue;
|
|
26767
|
-
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
|
|
26768
|
-
if (message.isError === false) accepted.add(message.toolCallId);
|
|
26769
|
-
}
|
|
26770
|
-
return accepted;
|
|
26771
|
-
}
|
|
26772
|
-
function extractLastAcceptedGateToolCall(rows) {
|
|
26773
|
-
const acceptedIds = acceptedGateReceiptIds(rows);
|
|
26774
|
-
let last;
|
|
26775
|
-
for (const row of rows) {
|
|
26776
|
-
const message = isRecord9(row.message) ? row.message : void 0;
|
|
26777
|
-
if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
26778
|
-
for (const part of message.content) {
|
|
26779
|
-
if (!isRecord9(part) || part.type !== "toolCall") continue;
|
|
26780
|
-
if (typeof part.id !== "string" || part.id.length === 0) continue;
|
|
26781
|
-
if (!acceptedIds.has(part.id)) continue;
|
|
26782
|
-
if (typeof part.name !== "string" || part.name.length === 0) continue;
|
|
26783
|
-
if (!isGateTerminatingToolName(part.name)) continue;
|
|
26784
|
-
last = {
|
|
26785
|
-
toolName: part.name,
|
|
26786
|
-
args: isRecord9(part.arguments) ? part.arguments : void 0
|
|
26787
|
-
};
|
|
26788
|
-
}
|
|
26789
|
-
}
|
|
26790
|
-
return last;
|
|
26791
|
-
}
|
|
26792
|
-
function requireAcceptedGateStatus(args, filePath) {
|
|
26793
|
-
if (args === void 0 || typeof args.status !== "string" || args.status.trim() === "") {
|
|
26794
|
-
throw new Error(
|
|
26795
|
-
`accepted gate receipt missing usable status in ${filePath}`
|
|
26796
|
-
);
|
|
26797
|
-
}
|
|
26798
|
-
return args.status.trim();
|
|
26799
|
-
}
|
|
26800
|
-
function requireAcceptedGateSpan(rows, filePath) {
|
|
26801
|
-
const span = extractSessionTimestampSpan(rows);
|
|
26802
|
-
if (span.startedAt === void 0 || span.endedAt === void 0) {
|
|
26803
|
-
throw new Error(
|
|
26804
|
-
`accepted gate volume missing session timestamp span in ${filePath}`
|
|
26805
|
-
);
|
|
26806
|
-
}
|
|
26807
|
-
const startedMs = Date.parse(span.startedAt);
|
|
26808
|
-
const endedMs = Date.parse(span.endedAt);
|
|
26809
|
-
if (!Number.isFinite(startedMs) || !Number.isFinite(endedMs) || endedMs < startedMs) {
|
|
26810
|
-
throw new Error(
|
|
26811
|
-
`accepted gate volume has unusable timestamp span in ${filePath}`
|
|
26812
|
-
);
|
|
26813
|
-
}
|
|
26814
|
-
return {
|
|
26815
|
-
startedAt: span.startedAt,
|
|
26816
|
-
endedAt: span.endedAt,
|
|
26817
|
-
wallMs: endedMs - startedMs
|
|
26818
|
-
};
|
|
26819
|
-
}
|
|
26820
|
-
async function classifyAuditorVolume(filePath) {
|
|
26821
|
-
const rows = await readLedgerSessionJsonl(filePath);
|
|
26822
|
-
const call = extractLastAcceptedGateToolCall(rows);
|
|
26823
|
-
if (call === void 0) return void 0;
|
|
26824
|
-
const span = requireAcceptedGateSpan(rows, filePath);
|
|
26825
|
-
const status = requireAcceptedGateStatus(call.args, filePath);
|
|
26826
|
-
const findings = call.args?.findings;
|
|
26827
|
-
const findingsCount = Array.isArray(findings) ? findings.length : 0;
|
|
26828
|
-
if (DISPATCH_TOOLS.has(call.toolName)) {
|
|
26829
|
-
if (status === "incomplete") return void 0;
|
|
26830
|
-
if (status !== "dispatch") {
|
|
26831
|
-
throw new Error(
|
|
26832
|
-
`accepted dispatch receipt has non-dispatch status ${JSON.stringify(status)} in ${filePath}`
|
|
26833
|
-
);
|
|
26834
|
-
}
|
|
26835
|
-
const officer2 = normalizeOfficerArg(call.args?.officer);
|
|
26836
|
-
if (officer2 === void 0) {
|
|
26837
|
-
throw new Error(
|
|
26838
|
-
`accepted dispatch receipt missing or unknown officer in ${filePath}`
|
|
26839
|
-
);
|
|
26840
|
-
}
|
|
26841
|
-
return {
|
|
26842
|
-
kind: "dispatch",
|
|
26843
|
-
startedAt: span.startedAt,
|
|
26844
|
-
officer: officer2
|
|
26845
|
-
};
|
|
26846
|
-
}
|
|
26847
|
-
const officer = OFFICER_TOOL_TO_FACE[call.toolName];
|
|
26848
|
-
if (officer === void 0) {
|
|
26849
|
-
throw new Error(
|
|
26850
|
-
`accepted gate receipt has unknown officer tool ${call.toolName} in ${filePath}`
|
|
26851
|
-
);
|
|
26852
|
-
}
|
|
26853
|
-
return {
|
|
26854
|
-
kind: "officer",
|
|
26855
|
-
startedAt: span.startedAt,
|
|
26856
|
-
endedAt: span.endedAt,
|
|
26857
|
-
officer,
|
|
26858
|
-
status,
|
|
26859
|
-
findingsCount,
|
|
26860
|
-
officerWallMs: span.wallMs
|
|
26861
|
-
};
|
|
26862
|
-
}
|
|
26863
|
-
function pairGateRounds(volumes) {
|
|
26864
|
-
const ordered = [...volumes].sort((a, b) => {
|
|
26865
|
-
if (a.startedAt !== b.startedAt) return a.startedAt.localeCompare(b.startedAt);
|
|
26866
|
-
if (a.kind !== b.kind) return a.kind === "dispatch" ? -1 : 1;
|
|
26867
|
-
return 0;
|
|
26868
|
-
});
|
|
26869
|
-
const usedOfficerIdx = /* @__PURE__ */ new Set();
|
|
26870
|
-
const rounds = [];
|
|
26871
|
-
for (let i = 0; i < ordered.length; i += 1) {
|
|
26872
|
-
const vol = ordered[i];
|
|
26873
|
-
if (vol.kind !== "dispatch") continue;
|
|
26874
|
-
let match;
|
|
26875
|
-
for (let j = i + 1; j < ordered.length; j += 1) {
|
|
26876
|
-
if (usedOfficerIdx.has(j)) continue;
|
|
26877
|
-
const candidate = ordered[j];
|
|
26878
|
-
if (candidate.kind !== "officer") continue;
|
|
26879
|
-
if (candidate.officer !== vol.officer) continue;
|
|
26880
|
-
match = { index: j, officer: candidate };
|
|
26881
|
-
break;
|
|
26882
|
-
}
|
|
26883
|
-
if (match === void 0) continue;
|
|
26884
|
-
usedOfficerIdx.add(match.index);
|
|
26885
|
-
rounds.push({
|
|
26886
|
-
roundIndex: rounds.length + 1,
|
|
26887
|
-
officer: match.officer.officer,
|
|
26888
|
-
status: match.officer.status,
|
|
26889
|
-
officerWallMs: match.officer.officerWallMs,
|
|
26890
|
-
officerStartedAt: match.officer.startedAt,
|
|
26891
|
-
officerEndedAt: match.officer.endedAt,
|
|
26892
|
-
findingsCount: match.officer.findingsCount
|
|
26893
|
-
});
|
|
26894
|
-
}
|
|
26895
|
-
return rounds;
|
|
26896
|
-
}
|
|
26897
|
-
async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory) {
|
|
26898
|
-
let names;
|
|
26899
|
-
try {
|
|
26900
|
-
const entries = await readdir5(auditorRolesDirectory, { withFileTypes: true });
|
|
26901
|
-
names = entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => e.name).sort();
|
|
26902
|
-
} catch (error) {
|
|
26903
|
-
if (isMissingDirectoryError(error)) return [];
|
|
26904
|
-
throw error;
|
|
26905
|
-
}
|
|
26906
|
-
const volumes = [];
|
|
26907
|
-
for (const name of names) {
|
|
26908
|
-
const classified = await classifyAuditorVolume(join24(auditorRolesDirectory, name));
|
|
26909
|
-
if (classified !== void 0) volumes.push(classified);
|
|
26910
|
-
}
|
|
26911
|
-
return pairGateRounds(volumes);
|
|
26912
|
-
}
|
|
26913
|
-
var DISPATCH_TOOLS, OFFICER_TOOL_TO_FACE, OFFICER_ARG_ALIASES;
|
|
26914
|
-
var init_analyst_gate_cycles_read = __esm({
|
|
26915
|
-
"src/analyst-gate-cycles-read.ts"() {
|
|
26916
|
-
"use strict";
|
|
26917
|
-
init_ledger_session_read();
|
|
26918
|
-
DISPATCH_TOOLS = /* @__PURE__ */ new Set(["ak_menxia_output", "ak_gatekeeper_output"]);
|
|
26919
|
-
OFFICER_TOOL_TO_FACE = {
|
|
26920
|
-
ak_jishizhong_output: "inspector",
|
|
26921
|
-
ak_inspector_output: "inspector",
|
|
26922
|
-
ak_fubaolang_output: "notary",
|
|
26923
|
-
ak_notary_output: "notary"
|
|
26924
|
-
};
|
|
26925
|
-
OFFICER_ARG_ALIASES = {
|
|
26926
|
-
jishizhong: "inspector",
|
|
26927
|
-
inspector: "inspector",
|
|
26928
|
-
fubaolang: "notary",
|
|
26929
|
-
notary: "notary"
|
|
26930
|
-
};
|
|
26931
|
-
}
|
|
26932
|
-
});
|
|
26933
|
-
|
|
26934
27034
|
// src/analyst-ledger.ts
|
|
26935
27035
|
import { readdir as readdir6, readFile as readFile14 } from "node:fs/promises";
|
|
26936
27036
|
import { join as join25 } from "node:path";
|