@akagilnc/pi-workflow-roles 0.1.6111 → 0.1.6123
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/README.md +3 -3
- package/README.zh-CN.md +3 -3
- package/dist/acp-host/production-host.js +442 -279
- package/dist/engine-detour-usage.js +2 -1
- package/dist/gatekeeper-role.js +3 -15
- package/dist/headless-host/production-host.js +427 -264
- package/dist/migrate-book-topology.js +42 -22
- package/dist/notary-source-run.js +8 -8
- package/dist/package-contracts/fixer-output.js +3 -0
- package/dist/public-cli/auto-resume.js +3 -3
- package/dist/public-cli/cli.js +38 -32
- package/dist/public-cli/instruction-seat-run.js +52 -13
- package/dist/public-cli/invocation.js +22 -12
- package/dist/public-cli/main.js +398 -237
- package/dist/public-cli/option-definitions.js +22 -21
- package/dist/public-cli/run-lifecycle.js +27 -26
- package/dist/public-cli/seat-ticket-binding.js +2 -1
- package/dist/public-cli/settlement.js +33 -8
- package/dist/public-cli/terminal.js +13 -3
- package/dist/public-role-summons.js +1 -7
- package/dist/role-run-placement.js +1 -1
- package/dist/run-dossier-files.js +4 -2
- package/dist/submission-gate.js +3 -3
- package/dist/submission-ledger.js +29 -3
- package/dist/ticket-address.js +77 -0
- package/dist/ticket-progress.js +90 -14
- package/package.json +1 -1
- package/src/engine-detour-usage.ts +2 -1
- package/src/gatekeeper-role.ts +5 -18
- package/src/notary-source-run.ts +8 -8
- package/src/package-contracts/fixer-output.ts +4 -0
- package/src/public-cli/auto-resume.ts +4 -3
- package/src/public-cli/cli.ts +53 -32
- package/src/public-cli/instruction-seat-run.ts +55 -11
- package/src/public-cli/invocation.ts +31 -16
- package/src/public-cli/option-definitions.ts +22 -21
- package/src/public-cli/run-lifecycle.ts +31 -31
- package/src/public-cli/seat-ticket-binding.ts +2 -1
- package/src/public-cli/settlement.ts +43 -7
- package/src/public-cli/terminal.ts +33 -14
- package/src/public-role-summons.ts +3 -15
- package/src/role-run-placement.ts +1 -1
- package/src/run-dossier-files.ts +5 -2
- package/src/submission-gate.ts +3 -2
- package/src/submission-ledger.ts +32 -2
- package/src/ticket-address.ts +91 -0
- package/src/ticket-progress.ts +113 -15
package/dist/public-cli/main.js
CHANGED
|
@@ -969,7 +969,7 @@ var init_role_run_path_rewrite = __esm({
|
|
|
969
969
|
});
|
|
970
970
|
|
|
971
971
|
// src/run-dossier-files.ts
|
|
972
|
-
var RUN_CURRENT_FILE, RUN_HISTORY_FILE, RUN_LOG_FILE, RUN_STATE_FILE, RUN_HISTORY_KINDS, OFFICER_POINTER_RECORD_KIND, RUN_STATE_KINDS;
|
|
972
|
+
var RUN_CURRENT_FILE, RUN_HISTORY_FILE, RUN_LOG_FILE, RUN_STATE_FILE, RUN_HISTORY_KINDS, PROGRESS_RECORD_KIND, OFFICER_POINTER_RECORD_KIND, RUN_STATE_KINDS;
|
|
973
973
|
var init_run_dossier_files = __esm({
|
|
974
974
|
"src/run-dossier-files.ts"() {
|
|
975
975
|
"use strict";
|
|
@@ -985,8 +985,10 @@ var init_run_dossier_files = __esm({
|
|
|
985
985
|
"post-seal-anomaly",
|
|
986
986
|
"attempt-history",
|
|
987
987
|
"turn-delivery",
|
|
988
|
-
"officer-pointer"
|
|
988
|
+
"officer-pointer",
|
|
989
|
+
"progress"
|
|
989
990
|
]);
|
|
991
|
+
PROGRESS_RECORD_KIND = "progress";
|
|
990
992
|
OFFICER_POINTER_RECORD_KIND = "officer-pointer";
|
|
991
993
|
RUN_STATE_KINDS = /* @__PURE__ */ new Set([
|
|
992
994
|
"invocation",
|
|
@@ -1631,7 +1633,7 @@ async function findRoleRunDirectory(bookDirectories, runId, onlyRole) {
|
|
|
1631
1633
|
}
|
|
1632
1634
|
if (matches.length === 0) return void 0;
|
|
1633
1635
|
if (matches.length === 1) return matches[0];
|
|
1634
|
-
throw new Error(`ambiguous role run
|
|
1636
|
+
throw new Error(`ambiguous role run: ${matches.join(", ")}`);
|
|
1635
1637
|
}
|
|
1636
1638
|
function roleRunPlacement(ledgerHome, input) {
|
|
1637
1639
|
const subjectDirectory = "ticketNumber" in input.subject ? String(requireSafePositiveTicketNumber(
|
|
@@ -9604,6 +9606,9 @@ var init_fixer_output = __esm({
|
|
|
9604
9606
|
classResults: typebox_exports.Unknown({
|
|
9605
9607
|
description: "\u5404\u7C7B class \u7ED3\u7B97\uFF0C\u539F\u6837\u7559\u5B58\u3002\u6BCF\u7C7B\u5199 name\u3001shape\uFF08\u9519\u8BEF\u5F62\u72B6\u4E00\u53E5\uFF09\u3002\u6309\u4EE3\u7801\u5F62\u72B6\u8BA4\u7684\u7C7B\u5199 search\uFF08\u5B9E\u9645\u8DD1\u7684\u641C\u7D22\u547D\u4EE4\uFF0C\u539F\u6837\uFF09\u3001hits\uFF08\u547D\u4EE4\u8F93\u51FA\u7684\u6BCF\u4E2A\u547D\u4E2D\u4E00\u884C { where: path:line, outcome: \u5DF2\u4FEE | \u4E0D\u540C\u7C7B\uFF1A\u7406\u7531 }\uFF09\uFF1B\u6309\u60C5\u5F62\u8BA4\u7684\u7C7B\u5199 cases\uFF08\u6BCF\u79CD\u524D\u5E8F\u7ECF\u5386\u4E00\u884C { case: \u5BF9\u8C61\u5148\u7ECF\u5386\u4E86\u4EC0\u4E48, entry: \u4ECE\u771F\u5B9E\u5165\u53E3\u600E\u4E48\u8D70\u5230\u5B83, before: \u4FEE\u524D\u7ED3\u679C, after: \u4FEE\u540E\u7ED3\u679C }\uFF09\u3002\u5220\u5E76\u7C7B\u5199 files\uFF08\u672C\u7968\u8D77\u70B9\u5230 HEAD \u7684 git diff --name-status \u91CC\u6BCF\u4E2A\u6587\u4EF6\u4E00\u884C { file, hits: \u8BE5\u7C7B\u5728\u6B64\u6587\u4EF6\u7684\u547D\u4E2D path:line \u5217\u8868\uFF0C\u6CA1\u6709\u4E3A\u7A7A, outcome: \u5DF2\u4FEE | \u65E0\uFF1A\u6BD4\u5BF9\u4E86\u54EA\u51E0\u5904\u3001\u4E3A\u4EC0\u4E48\u4E0D\u7B97 | \u672A\u4FEE\uFF1A\u7406\u7531 }\uFF09\u3002\u5B8C\u6210\u9879\u7684 disposition \u4E3A completed\uFF0C\u53EF\u5199 commitSha\u3002\u62D2\u7EDD\u9879\u7684 disposition \u4E3A refused\uFF0C\u53EF\u5199 remainingScope\u3001blocker\u3002"
|
|
9606
9608
|
}),
|
|
9609
|
+
for: typebox_exports.Unknown({
|
|
9610
|
+
description: "\u4FEE\u7684\u662F\u54EA\u4EFD\u5224\u8BCD\uFF1A<\u5E2D>#<\u8F6E>\uFF0C\u5982 judge#5\uFF0C\u539F\u6837\u843D\u5230\u8FDB\u5EA6\u884C\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002"
|
|
9611
|
+
}),
|
|
9607
9612
|
diffItems: diffItemsField,
|
|
9608
9613
|
testEvidence: typebox_exports.Unknown({
|
|
9609
9614
|
description: "\u4EC5 diff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u586B\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002\u673A\u5668\u4E0D\u6838\u9A8C\u3002\u53EF\u5199 contract\uFF08\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6\uFF09\u3001minimumNecessaryCost\uFF08\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C\uFF09\u3001measuredDuration\uFF08\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F\uFF09\u3002"
|
|
@@ -11924,6 +11929,13 @@ function currentReplyRows(terminal) {
|
|
|
11924
11929
|
function adviceNavigatorFact(input) {
|
|
11925
11930
|
return { disposition: "advice", prose: input.prose };
|
|
11926
11931
|
}
|
|
11932
|
+
function identityRows(leg) {
|
|
11933
|
+
const seat = leg.roleOutcome.role;
|
|
11934
|
+
return [
|
|
11935
|
+
...leg.ticket === void 0 ? [] : [`ticket ${leg.ticket}`],
|
|
11936
|
+
...[...leg.receipts ?? []].reverse().map((filed) => `receipt ${encodeTerminalField(filed.round === void 0 ? seat : `${seat}#${filed.round}`)} ${encodeTerminalField(filed.receipt)}`)
|
|
11937
|
+
];
|
|
11938
|
+
}
|
|
11927
11939
|
function formatTerminalResult(result) {
|
|
11928
11940
|
const lines = [];
|
|
11929
11941
|
lines.push("role outcome status");
|
|
@@ -11969,11 +11981,11 @@ function formatTerminalResult(result) {
|
|
|
11969
11981
|
if (child.stderr !== void 0 && child.stderr !== "") {
|
|
11970
11982
|
lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
|
|
11971
11983
|
}
|
|
11984
|
+
const lens = result.reviewerChildren?.[axis];
|
|
11985
|
+
if (lens !== void 0) lines.push(...identityRows(lens));
|
|
11972
11986
|
}
|
|
11973
11987
|
}
|
|
11974
|
-
|
|
11975
|
-
lines.push(`run ${encodeTerminalField(result.runId)}`);
|
|
11976
|
-
}
|
|
11988
|
+
lines.push(...identityRows(result));
|
|
11977
11989
|
if (result.autoResumeCount !== void 0) {
|
|
11978
11990
|
lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
|
|
11979
11991
|
}
|
|
@@ -12111,15 +12123,7 @@ function projectOfficerPayloads(officer, payloads, fallbackStatus) {
|
|
|
12111
12123
|
return projectOfficerDecision(officer, payloads[payloads.length - 1], fallbackStatus);
|
|
12112
12124
|
}
|
|
12113
12125
|
function officerRunIdFromSummoned(summoned) {
|
|
12114
|
-
|
|
12115
|
-
const fromDir = runIdFromRunDirectory(summoned.runDirectory);
|
|
12116
|
-
if (fromDir !== void 0) return fromDir;
|
|
12117
|
-
}
|
|
12118
|
-
const terminal = summoned.terminal;
|
|
12119
|
-
if (terminal !== void 0 && typeof terminal.runId === "string" && terminal.runId.trim() !== "") {
|
|
12120
|
-
return terminal.runId;
|
|
12121
|
-
}
|
|
12122
|
-
return void 0;
|
|
12126
|
+
return summoned.runDirectory === void 0 ? void 0 : runIdFromRunDirectory(summoned.runDirectory);
|
|
12123
12127
|
}
|
|
12124
12128
|
function withOfficerRunId(result, summoned) {
|
|
12125
12129
|
if (result.status !== "converged" && result.status !== "continue" && result.status !== "escalate" && result.status !== "needs_reask") {
|
|
@@ -13230,15 +13234,11 @@ import {
|
|
|
13230
13234
|
writeFileSync as writeFileSync2
|
|
13231
13235
|
} from "node:fs";
|
|
13232
13236
|
import { basename as basename7, dirname as dirname8, join as join12, relative as relative2, sep as sep3 } from "node:path";
|
|
13233
|
-
function
|
|
13234
|
-
if (
|
|
13237
|
+
function decodeProgressFile(path) {
|
|
13238
|
+
if (!existsSync3(path)) return { lines: [], malformed: [] };
|
|
13239
|
+
const text = readFileSync3(path, "utf8");
|
|
13240
|
+
if (text.trim() === "") return { lines: [], malformed: [] };
|
|
13235
13241
|
const { records, diagnostics } = parseSitianRecordText(text);
|
|
13236
|
-
for (const diagnostic of diagnostics) {
|
|
13237
|
-
process.stderr.write(
|
|
13238
|
-
`[ticket-progress] ${pathForDiagnostic} has malformed row(s); keeps reachable rows and retains the diagnostic: line ${diagnostic.line}: ${diagnostic.error}
|
|
13239
|
-
`
|
|
13240
|
-
);
|
|
13241
|
-
}
|
|
13242
13242
|
const lines = [];
|
|
13243
13243
|
for (const record of records) {
|
|
13244
13244
|
const parsed = record;
|
|
@@ -13246,11 +13246,20 @@ function parseProgressText(text, pathForDiagnostic) {
|
|
|
13246
13246
|
if (typeof parsed.seat !== "string" || typeof parsed.round !== "string") continue;
|
|
13247
13247
|
lines.push(parsed);
|
|
13248
13248
|
}
|
|
13249
|
-
return
|
|
13249
|
+
return {
|
|
13250
|
+
lines,
|
|
13251
|
+
malformed: diagnostics.map((diagnostic) => `line ${diagnostic.line}: ${diagnostic.error}`)
|
|
13252
|
+
};
|
|
13250
13253
|
}
|
|
13251
13254
|
function readProgressFile(path) {
|
|
13252
|
-
|
|
13253
|
-
|
|
13255
|
+
const { lines, malformed } = decodeProgressFile(path);
|
|
13256
|
+
for (const diagnostic of malformed) {
|
|
13257
|
+
process.stderr.write(
|
|
13258
|
+
`[ticket-progress] ${path} has malformed row(s); keeps reachable rows and retains the diagnostic: ${diagnostic}
|
|
13259
|
+
`
|
|
13260
|
+
);
|
|
13261
|
+
}
|
|
13262
|
+
return lines;
|
|
13254
13263
|
}
|
|
13255
13264
|
function readTicketProgressLines(subjectDirectory) {
|
|
13256
13265
|
if (basename7(subjectDirectory) === "unbound") {
|
|
@@ -13306,6 +13315,26 @@ function statusAndSummaryFromPayload(payload) {
|
|
|
13306
13315
|
...summary === void 0 ? {} : { summary }
|
|
13307
13316
|
};
|
|
13308
13317
|
}
|
|
13318
|
+
function readAuditedRound(auditedRunDirectory) {
|
|
13319
|
+
try {
|
|
13320
|
+
const subjectDirectory = subjectDirectoryOfRun(auditedRunDirectory);
|
|
13321
|
+
if (subjectDirectory === void 0) return {};
|
|
13322
|
+
const path = join12(subjectDirectory, CURRENT_FILENAME);
|
|
13323
|
+
const { lines, malformed } = decodeProgressFile(path);
|
|
13324
|
+
if (malformed.length > 0) {
|
|
13325
|
+
throw new Error(`${path} has malformed row(s): ${malformed.join("; ")}`);
|
|
13326
|
+
}
|
|
13327
|
+
const receipts = `runs/${basename7(auditedRunDirectory)}/`;
|
|
13328
|
+
const latest = lines.filter((line2) => line2.receipt.startsWith(receipts)).at(-1);
|
|
13329
|
+
return latest === void 0 ? {} : { for: `${latest.seat}#${latest.round}` };
|
|
13330
|
+
} catch (error) {
|
|
13331
|
+
return { fault: `audited round unavailable for ${auditedRunDirectory}: ${errorText(error)}` };
|
|
13332
|
+
}
|
|
13333
|
+
}
|
|
13334
|
+
function forOfSealedRow(runDirectory, seat, payload) {
|
|
13335
|
+
const reported = packagedGateStageLabel(seat) !== void 0 ? readPageSync(runDirectory, "admitted")?.for : seat === "fixer" && isRecord(payload) ? payload.for : void 0;
|
|
13336
|
+
return typeof reported === "string" ? reported : void 0;
|
|
13337
|
+
}
|
|
13309
13338
|
function captureWorktreeHead(projectRoot) {
|
|
13310
13339
|
try {
|
|
13311
13340
|
const result = spawnSync3("git", ["rev-parse", "HEAD"], {
|
|
@@ -13333,6 +13362,23 @@ function captureWorktreeHead(projectRoot) {
|
|
|
13333
13362
|
return { head: "", fault: `git rev-parse HEAD threw cwd=${projectRoot}: ${message}` };
|
|
13334
13363
|
}
|
|
13335
13364
|
}
|
|
13365
|
+
function carryProgressRow(runDirectory, line2, call) {
|
|
13366
|
+
const runId = runIdFromRunDirectory(runDirectory);
|
|
13367
|
+
if (runId === void 0) return;
|
|
13368
|
+
sitianReport({
|
|
13369
|
+
level: "event",
|
|
13370
|
+
kind: PROGRESS_RECORD_KIND,
|
|
13371
|
+
subject: { runId, ...call === void 0 ? {} : { attemptId: call.attemptId } },
|
|
13372
|
+
payload: {
|
|
13373
|
+
type: PROGRESS_RECORD_KIND,
|
|
13374
|
+
...call === void 0 ? {} : { toolCallId: call.toolCallId },
|
|
13375
|
+
receipt: line2.receipt,
|
|
13376
|
+
round: line2.round
|
|
13377
|
+
},
|
|
13378
|
+
source: "ticket-progress",
|
|
13379
|
+
sessionParent: sessionFileOf(runDirectory)
|
|
13380
|
+
});
|
|
13381
|
+
}
|
|
13336
13382
|
function lensFromRunDirectory(runDirectory, role) {
|
|
13337
13383
|
if (role !== "reviewer") return void 0;
|
|
13338
13384
|
const lens = readPageSync(runDirectory, "admitted")?.lens;
|
|
@@ -13359,11 +13405,13 @@ function landTicketProgress(input) {
|
|
|
13359
13405
|
const round = unbound ? "" : nextRoundFromLines(existing, input.role, lens);
|
|
13360
13406
|
const sessionRelative = input.sessionFile === void 0 ? "" : relative2(subjectDirectory, input.sessionFile).split(sep3).join("/");
|
|
13361
13407
|
const { status, summary } = statusAndSummaryFromPayload(input.accepted);
|
|
13408
|
+
const reviewed = forOfSealedRow(runDirectory, input.role, input.accepted);
|
|
13362
13409
|
const instruction = input.instruction;
|
|
13363
13410
|
const line2 = {
|
|
13364
13411
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13365
13412
|
seat: input.role,
|
|
13366
13413
|
round,
|
|
13414
|
+
...reviewed === void 0 ? {} : { for: reviewed },
|
|
13367
13415
|
instruction,
|
|
13368
13416
|
head: input.sealHead.head,
|
|
13369
13417
|
...status === void 0 ? {} : { status },
|
|
@@ -13374,6 +13422,7 @@ function landTicketProgress(input) {
|
|
|
13374
13422
|
mkdirSync3(dirname8(progressPath), { recursive: true });
|
|
13375
13423
|
appendFileSync2(progressPath, `${JSON.stringify(line2)}
|
|
13376
13424
|
`, "utf8");
|
|
13425
|
+
carryProgressRow(runDirectory, line2, input.call);
|
|
13377
13426
|
if (input.sealHead.fault !== void 0) {
|
|
13378
13427
|
process.stderr.write(`${input.sealHead.fault}
|
|
13379
13428
|
`);
|
|
@@ -13421,6 +13470,7 @@ function relocateTicketProgressForLeg(input) {
|
|
|
13421
13470
|
"utf8"
|
|
13422
13471
|
);
|
|
13423
13472
|
rmSync3(stagedPath, { force: true });
|
|
13473
|
+
for (const moved of movedLines) carryProgressRow(input.runDirectory, moved);
|
|
13424
13474
|
}
|
|
13425
13475
|
var CURRENT_FILENAME, RECEIPTS_DIRNAME, LEG_PROGRESS_FILENAME;
|
|
13426
13476
|
var init_ticket_progress = __esm({
|
|
@@ -13431,6 +13481,9 @@ var init_ticket_progress = __esm({
|
|
|
13431
13481
|
init_packaged_role_registry();
|
|
13432
13482
|
init_role_run_placement();
|
|
13433
13483
|
init_run_dossier();
|
|
13484
|
+
init_run_dossier_files();
|
|
13485
|
+
init_run_terminal_artifacts();
|
|
13486
|
+
init_sitian_facade();
|
|
13434
13487
|
init_sitian_reader();
|
|
13435
13488
|
init_unknown_value();
|
|
13436
13489
|
CURRENT_FILENAME = "current.jsonl";
|
|
@@ -14020,8 +14073,66 @@ var init_uuidv7 = __esm({
|
|
|
14020
14073
|
}
|
|
14021
14074
|
});
|
|
14022
14075
|
|
|
14076
|
+
// src/ticket-address.ts
|
|
14077
|
+
import { existsSync as existsSync4, readdirSync as readdirSync3, statSync as statSync5 } from "node:fs";
|
|
14078
|
+
import { join as join14 } from "node:path";
|
|
14079
|
+
function parseAddressTicket(token) {
|
|
14080
|
+
return parseTicketNumber(token.startsWith("#") ? token.slice(1) : token);
|
|
14081
|
+
}
|
|
14082
|
+
function parseSeatRound(token) {
|
|
14083
|
+
const hash = token.indexOf("#");
|
|
14084
|
+
return hash === -1 ? { seat: token } : { seat: token.slice(0, hash), round: token.slice(hash + 1) };
|
|
14085
|
+
}
|
|
14086
|
+
function parseTicketLegLocator(token) {
|
|
14087
|
+
const colon = token.indexOf(":");
|
|
14088
|
+
if (colon === -1) return void 0;
|
|
14089
|
+
const ticketNumber = parseAddressTicket(token.slice(0, colon));
|
|
14090
|
+
const { seat, round } = parseSeatRound(token.slice(colon + 1));
|
|
14091
|
+
if (ticketNumber === void 0 || seat === "" || round === void 0 || round === "") {
|
|
14092
|
+
return void 0;
|
|
14093
|
+
}
|
|
14094
|
+
return { ticketNumber, seat, round };
|
|
14095
|
+
}
|
|
14096
|
+
function locateTicketLeg(bookDirectory, input) {
|
|
14097
|
+
const ticketDirectory = join14(bookDirectory, String(input.ticketNumber));
|
|
14098
|
+
if (!existsSync4(ticketDirectory)) {
|
|
14099
|
+
throw new CliUsageError(`ticket ${input.ticketNumber} has no records in this project's book: ${ticketDirectory}`);
|
|
14100
|
+
}
|
|
14101
|
+
if (input.round !== void 0) {
|
|
14102
|
+
const row = readTicketProgressLines(ticketDirectory).find((line2) => line2.seat === input.seat && line2.round === input.round);
|
|
14103
|
+
if (row === void 0) {
|
|
14104
|
+
throw new CliUsageError(
|
|
14105
|
+
`ticket ${input.ticketNumber} has no progress row ${input.seat}#${input.round}`
|
|
14106
|
+
);
|
|
14107
|
+
}
|
|
14108
|
+
return join14(ticketDirectory, ...row.receipt.split("/").slice(0, 2));
|
|
14109
|
+
}
|
|
14110
|
+
const runsDirectory = join14(ticketDirectory, "runs");
|
|
14111
|
+
let latest;
|
|
14112
|
+
for (const entry of existsSync4(runsDirectory) ? readdirSync3(runsDirectory, { withFileTypes: true }) : []) {
|
|
14113
|
+
if (!entry.isDirectory() || parseRunLeaf(entry.name)?.role !== input.seat) continue;
|
|
14114
|
+
const { mtimeMs } = statSync5(join14(runsDirectory, entry.name));
|
|
14115
|
+
if (latest === void 0 || mtimeMs > latest.mtimeMs || mtimeMs === latest.mtimeMs && entry.name > latest.leaf) {
|
|
14116
|
+
latest = { leaf: entry.name, mtimeMs };
|
|
14117
|
+
}
|
|
14118
|
+
}
|
|
14119
|
+
if (latest === void 0) {
|
|
14120
|
+
throw new CliUsageError(`ticket ${input.ticketNumber} has no ${input.seat} leg`);
|
|
14121
|
+
}
|
|
14122
|
+
return join14(runsDirectory, latest.leaf);
|
|
14123
|
+
}
|
|
14124
|
+
var init_ticket_address = __esm({
|
|
14125
|
+
"src/ticket-address.ts"() {
|
|
14126
|
+
"use strict";
|
|
14127
|
+
init_cli_errors();
|
|
14128
|
+
init_role_run_placement();
|
|
14129
|
+
init_run_ticket_number();
|
|
14130
|
+
init_ticket_progress();
|
|
14131
|
+
}
|
|
14132
|
+
});
|
|
14133
|
+
|
|
14023
14134
|
// src/notary-source-run.ts
|
|
14024
|
-
import { dirname as dirname10, isAbsolute as isAbsolute4, join as
|
|
14135
|
+
import { dirname as dirname10, isAbsolute as isAbsolute4, join as join15, resolve as resolve7, basename as basename8 } from "node:path";
|
|
14025
14136
|
import { lstat as lstat2, realpath as realpath2 } from "node:fs/promises";
|
|
14026
14137
|
async function readRetainedIdentity(runDirectory) {
|
|
14027
14138
|
try {
|
|
@@ -14073,11 +14184,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
14073
14184
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
14074
14185
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
14075
14186
|
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
14076
|
-
const bookRunsRoot =
|
|
14187
|
+
const bookRunsRoot = join15(bookDirectory, "runs");
|
|
14077
14188
|
let candidate;
|
|
14078
|
-
const
|
|
14079
|
-
if (
|
|
14080
|
-
candidate =
|
|
14189
|
+
const address = parseTicketLegLocator(raw);
|
|
14190
|
+
if (address !== void 0) {
|
|
14191
|
+
candidate = locateTicketLeg(bookDirectory, address);
|
|
14081
14192
|
} else {
|
|
14082
14193
|
candidate = isAbsolute4(raw) ? raw : resolve7(options.projectRoot, raw);
|
|
14083
14194
|
const identity2 = parseRunLeaf(basename8(candidate));
|
|
@@ -14132,6 +14243,7 @@ var init_notary_source_run = __esm({
|
|
|
14132
14243
|
init_activation_ledger_topology();
|
|
14133
14244
|
init_run_lifecycle();
|
|
14134
14245
|
init_role_run_placement();
|
|
14246
|
+
init_ticket_address();
|
|
14135
14247
|
NotarySourceRunError = class extends Error {
|
|
14136
14248
|
constructor(message, options) {
|
|
14137
14249
|
super(message, options);
|
|
@@ -14601,7 +14713,7 @@ var init_option_definitions = __esm({
|
|
|
14601
14713
|
owner: "auditor",
|
|
14602
14714
|
canonical: "--source-run",
|
|
14603
14715
|
aliases: [],
|
|
14604
|
-
valueMetavar: "
|
|
14716
|
+
valueMetavar: "ticket:seat#round|path",
|
|
14605
14717
|
required: true,
|
|
14606
14718
|
repeatable: false,
|
|
14607
14719
|
form: "option",
|
|
@@ -14779,13 +14891,13 @@ var init_option_definitions = __esm({
|
|
|
14779
14891
|
owner: "notary",
|
|
14780
14892
|
canonical: "--source-run",
|
|
14781
14893
|
aliases: [],
|
|
14782
|
-
valueMetavar: "
|
|
14894
|
+
valueMetavar: "ticket:seat#round|path",
|
|
14783
14895
|
required: true,
|
|
14784
14896
|
repeatable: false,
|
|
14785
14897
|
form: "option",
|
|
14786
14898
|
description: {
|
|
14787
|
-
en: "Required source run locator (
|
|
14788
|
-
zh: "\u5FC5\u586B\u6E90 run \u5B9A\u4F4D\u7B26\uFF08\
|
|
14899
|
+
en: "Required source run locator (<ticket>:<seat>#<round> as written on the ticket's progress row, or path to that run directory). Binds the audited identity; review dialogue is the fixed Notary dispatch (verdict stays in the ledger). Missing-ticket and unreadable-status reasks keep their existing diagnostic text.",
|
|
14900
|
+
zh: "\u5FC5\u586B\u6E90 run \u5B9A\u4F4D\u7B26\uFF08<\u7968\u53F7>:<\u5E2D>#<\u8F6E>\uFF0C\u8F6E\u7167\u8FDB\u5EA6\u884C\u4E0A\u7684\u5199\u6CD5\uFF1B\u6216\u8BE5 run \u76EE\u5F55\u8DEF\u5F84\uFF09\u3002\u7ED1\u5B9A\u53D7\u5BA1\u8EAB\u4EFD\uFF1B\u5BA1\u7A3F\u5BF9\u8BDD\u4E3A\u7B26\u5B9D\u90CE\u56FA\u5B9A\u6D3E\u5355\u6587\uFF08\u5224\u8BCD\u7559\u5728\u5377\u5B97\u81EA\u884C\u8BFB\u53D6\uFF09\u3002\u7F3A\u7968\u53F7\u4E0E\u8BFB\u4E0D\u51FA status \u7684\u91CD\u4EA4\u4ECD\u9012\u65E2\u6709\u8BCA\u65AD\u539F\u6587\u3002"
|
|
14789
14901
|
}
|
|
14790
14902
|
}
|
|
14791
14903
|
];
|
|
@@ -14796,13 +14908,13 @@ var init_option_definitions = __esm({
|
|
|
14796
14908
|
owner: "inspector",
|
|
14797
14909
|
canonical: "--source-run",
|
|
14798
14910
|
aliases: [],
|
|
14799
|
-
valueMetavar: "
|
|
14911
|
+
valueMetavar: "ticket:seat#round|path",
|
|
14800
14912
|
required: false,
|
|
14801
14913
|
repeatable: false,
|
|
14802
14914
|
form: "option",
|
|
14803
14915
|
description: {
|
|
14804
|
-
en: "Optional audited source-run locator (
|
|
14805
|
-
zh: "\u53EF\u9009\u88AB\u5BA1\u817F\u5B9A\u4F4D\u7B26\
|
|
14916
|
+
en: "Optional audited source-run locator (<ticket>:<seat>#<round> or path). Gate summons always supply it; identity rides startup materials.",
|
|
14917
|
+
zh: "\u53EF\u9009\u88AB\u5BA1\u817F\u5B9A\u4F4D\u7B26\uFF08<\u7968\u53F7>:<\u5E2D>#<\u8F6E> \u6216\u8DEF\u5F84\uFF09\u3002\u95F8\u4F20\u53EC\u5FC5\u5E26\uFF1B\u8EAB\u4EFD\u5728\u542F\u52A8\u6750\u6599\u91CC\u3002"
|
|
14806
14918
|
}
|
|
14807
14919
|
}
|
|
14808
14920
|
];
|
|
@@ -15097,10 +15209,10 @@ var init_option_definitions = __esm({
|
|
|
15097
15209
|
auditor: {
|
|
15098
15210
|
command: "auditor",
|
|
15099
15211
|
summary: "Direct Auditor (\u5BA1\u5211\u9662) compliance audit: converged, continue, or escalate.",
|
|
15100
|
-
usage: ["ak-role auditor --subject <judge|doctor> --source-run <
|
|
15212
|
+
usage: ["ak-role auditor --subject <judge|doctor> --source-run <ticket:seat#round|path> [options] [instruction]"],
|
|
15101
15213
|
examples: [
|
|
15102
|
-
'ak-role auditor --subject judge --source-run
|
|
15103
|
-
'ak-role auditor --subject doctor --source-run
|
|
15214
|
+
'ak-role auditor --subject judge --source-run 1201:judge#2 --attach ./dossier "\u5BA1\uFF1A\u672C run \u662F\u5426\u5408\u89C4\u3002"',
|
|
15215
|
+
'ak-role auditor --subject doctor --source-run 1201:doctor#1 "\u5BA1\uFF1A\u592A\u533B\u5019\u9009\u662F\u5426\u5408\u89C4\u3002"'
|
|
15104
15216
|
]
|
|
15105
15217
|
},
|
|
15106
15218
|
diarist: {
|
|
@@ -15123,10 +15235,10 @@ var init_option_definitions = __esm({
|
|
|
15123
15235
|
notary: {
|
|
15124
15236
|
command: "notary",
|
|
15125
15237
|
summary: "Direct Notary summons; duties: souls/notary.md. Review uses fixed dispatch \u2014 binds --source-run identity; does not accept caller review prompt; verdict stays in the ledger. Missing-ticket (#1171) and unreadable-status reasks deliver their existing diagnostic text on the same seat, not the review sentence.",
|
|
15126
|
-
usage: ["ak-role notary --source-run <
|
|
15238
|
+
usage: ["ak-role notary --source-run <ticket:seat#round|path> [options]"],
|
|
15127
15239
|
examples: [
|
|
15128
|
-
"ak-role notary --source-run
|
|
15129
|
-
"ak-role notary --source-run
|
|
15240
|
+
"ak-role notary --source-run 1201:judge#2",
|
|
15241
|
+
"ak-role notary --source-run 1201:countersign#1"
|
|
15130
15242
|
]
|
|
15131
15243
|
},
|
|
15132
15244
|
analyst: {
|
|
@@ -15183,14 +15295,15 @@ var init_option_definitions = __esm({
|
|
|
15183
15295
|
},
|
|
15184
15296
|
resume: {
|
|
15185
15297
|
command: "resume",
|
|
15186
|
-
summary: "Resume a
|
|
15187
|
-
usage: ["ak-role resume <
|
|
15298
|
+
summary: "Resume one leg of a ticket under the live seat table (model/host/engine); session principal must still exist. The address is the ticket number and the seat: by default the seat's most recently active leg under that ticket; <seat>#<round> (round as written on the ticket's progress row, reviewer rounds carry the lens suffix) names the leg that filed that round. A leg that has reported no ticket is not in this address. Every callable seat accepts the optional caller message and passes it through unchanged as the continuation prompt. Notary new/direct review calls use only --source-run plus the fixed review dispatch (no caller review prompt); public manual resume still passes the caller message. Global --model/--thinking/--host/--engine must be placed before <ticket> (either before `resume` or between `resume` and <ticket>); the one argv after <seat> is the opaque message, not a flag position (#471).",
|
|
15299
|
+
usage: ["ak-role resume <ticket> <seat>[#<round>] [message]"],
|
|
15188
15300
|
examples: [
|
|
15189
|
-
"ak-role resume
|
|
15190
|
-
'ak-role resume
|
|
15191
|
-
"ak-role
|
|
15192
|
-
"ak-role --
|
|
15193
|
-
|
|
15301
|
+
"ak-role resume 1201 judge",
|
|
15302
|
+
'ak-role resume 1201 judge "owner ruling"',
|
|
15303
|
+
"ak-role resume 1201 'reviewer#2.correctness'",
|
|
15304
|
+
"ak-role --host grok-build resume 1201 fixer",
|
|
15305
|
+
"ak-role --engine agy resume 1201 fixer",
|
|
15306
|
+
'ak-role resume --model xai/grok-4.5 1201 notary "owner ruling"'
|
|
15194
15307
|
]
|
|
15195
15308
|
},
|
|
15196
15309
|
new: {
|
|
@@ -15199,7 +15312,7 @@ var init_option_definitions = __esm({
|
|
|
15199
15312
|
usage: ["ak-role new <role> [options] \u2026"],
|
|
15200
15313
|
examples: [
|
|
15201
15314
|
'ak-role new countersign --attach ./ticket.md "\u88C1\uFF1A\u672C\u7968 #708 \u662F\u5426\u8DB3\u4EE5\u5F00\u5DE5\u3002"',
|
|
15202
|
-
"ak-role new notary --source-run
|
|
15315
|
+
"ak-role new notary --source-run 1201:countersign#1",
|
|
15203
15316
|
"ak-role --host grok-build new inspector --attach ./change.patch"
|
|
15204
15317
|
]
|
|
15205
15318
|
},
|
|
@@ -15222,14 +15335,14 @@ var init_option_definitions = __esm({
|
|
|
15222
15335
|
|
|
15223
15336
|
// src/public-cli/invocation.ts
|
|
15224
15337
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
15225
|
-
import { existsSync as
|
|
15338
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
15226
15339
|
import {
|
|
15227
15340
|
readFile as readFile9,
|
|
15228
15341
|
realpath as realpath3,
|
|
15229
15342
|
rename,
|
|
15230
15343
|
writeFile as writeFile2
|
|
15231
15344
|
} from "node:fs/promises";
|
|
15232
|
-
import { dirname as dirname11, isAbsolute as isAbsolute5, join as
|
|
15345
|
+
import { dirname as dirname11, isAbsolute as isAbsolute5, join as join16, resolve as resolve8 } from "node:path";
|
|
15233
15346
|
function admittedSourceRunPath(admitted) {
|
|
15234
15347
|
if (!isRecord(admitted)) return void 0;
|
|
15235
15348
|
const path = admitted.sourceRunPath;
|
|
@@ -15327,22 +15440,25 @@ async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
|
15327
15440
|
...fields
|
|
15328
15441
|
}));
|
|
15329
15442
|
}
|
|
15330
|
-
|
|
15331
|
-
|
|
15332
|
-
|
|
15443
|
+
function persistAdmittedAuditedLeg(runDirectory, audited) {
|
|
15444
|
+
const { sourceRunPath, auditorSubject } = audited;
|
|
15445
|
+
if (sourceRunPath !== void 0 && sourceRunPath.trim() === "") {
|
|
15446
|
+
throw new Error("persistAdmittedAuditedLeg requires a non-empty sourceRunPath");
|
|
15333
15447
|
}
|
|
15334
|
-
updateSectionSync(
|
|
15335
|
-
if (typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
|
|
15448
|
+
updateSectionSync(runDirectory, "admitted", (current) => {
|
|
15449
|
+
if (sourceRunPath !== void 0 && typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
|
|
15336
15450
|
throw new Error(
|
|
15337
|
-
`
|
|
15451
|
+
`persistAdmittedAuditedLeg refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
|
|
15338
15452
|
);
|
|
15339
15453
|
}
|
|
15340
|
-
const
|
|
15341
|
-
if (
|
|
15454
|
+
const unchanged = current.for === audited.for && (sourceRunPath === void 0 || current.sourceRunPath === sourceRunPath) && (auditorSubject === void 0 || current.auditorSubject === auditorSubject);
|
|
15455
|
+
if (unchanged) return void 0;
|
|
15456
|
+
const { for: _replaced, ...rest } = current;
|
|
15342
15457
|
return {
|
|
15343
|
-
...
|
|
15344
|
-
sourceRunPath,
|
|
15345
|
-
...auditorSubject === void 0 ? {} : { auditorSubject }
|
|
15458
|
+
...rest,
|
|
15459
|
+
...sourceRunPath === void 0 ? {} : { sourceRunPath },
|
|
15460
|
+
...auditorSubject === void 0 ? {} : { auditorSubject },
|
|
15461
|
+
...audited.for === void 0 ? {} : { for: audited.for }
|
|
15346
15462
|
};
|
|
15347
15463
|
});
|
|
15348
15464
|
}
|
|
@@ -15404,7 +15520,7 @@ async function relocateRegisteredChildDiarists(input) {
|
|
|
15404
15520
|
runId: childRunId,
|
|
15405
15521
|
role: "diarist"
|
|
15406
15522
|
}).runDirectory;
|
|
15407
|
-
if (
|
|
15523
|
+
if (existsSync5(unboundChildDirectory)) {
|
|
15408
15524
|
input.authority.seal(childTarget);
|
|
15409
15525
|
await bindTicketNumberOnRunDirectory(unboundChildDirectory, input.ticketNumber);
|
|
15410
15526
|
await rehomeUnboundTicketProvenance(
|
|
@@ -15428,7 +15544,7 @@ async function relocateRegisteredChildDiarists(input) {
|
|
|
15428
15544
|
}
|
|
15429
15545
|
continue;
|
|
15430
15546
|
}
|
|
15431
|
-
if (
|
|
15547
|
+
if (existsSync5(childTarget.runDirectory)) {
|
|
15432
15548
|
relocateTicketProgressForLeg({
|
|
15433
15549
|
runDirectory: childTarget.runDirectory
|
|
15434
15550
|
});
|
|
@@ -15526,7 +15642,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
15526
15642
|
async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
|
|
15527
15643
|
const rolePackageRoot = packageRoot2;
|
|
15528
15644
|
const raw = JSON.parse(
|
|
15529
|
-
await readFile9(
|
|
15645
|
+
await readFile9(join16(rolePackageRoot, "package.json"), "utf8")
|
|
15530
15646
|
);
|
|
15531
15647
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
15532
15648
|
throw new Error(
|
|
@@ -16097,7 +16213,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
16097
16213
|
resolutionScope: [...derived.resolutionScope],
|
|
16098
16214
|
authorizedChecks: []
|
|
16099
16215
|
});
|
|
16100
|
-
const mergerInputPath =
|
|
16216
|
+
const mergerInputPath = join16(placed.runDirectory, "merger-input.json");
|
|
16101
16217
|
await writeFile2(
|
|
16102
16218
|
mergerInputPath,
|
|
16103
16219
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -16365,7 +16481,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
16365
16481
|
}
|
|
16366
16482
|
async function resolveDoctorCaseRunsPath(options) {
|
|
16367
16483
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
16368
|
-
const defaultRuns =
|
|
16484
|
+
const defaultRuns = join16(
|
|
16369
16485
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
16370
16486
|
String(options.issueNumber),
|
|
16371
16487
|
"runs"
|
|
@@ -16767,8 +16883,21 @@ function rowFromPayload(kind, payload, accepted, roleFallback) {
|
|
|
16767
16883
|
...typeof payload.toolCallId === "string" && payload.toolCallId.length > 0 ? { toolCallId: payload.toolCallId } : {}
|
|
16768
16884
|
};
|
|
16769
16885
|
}
|
|
16770
|
-
function mapOwnedToSubmissionRows(owned) {
|
|
16886
|
+
function mapOwnedToSubmissionRows(owned, leg = owned) {
|
|
16771
16887
|
const scoped = owned;
|
|
16888
|
+
const receiptByCall = /* @__PURE__ */ new Map();
|
|
16889
|
+
const roundByReceipt = /* @__PURE__ */ new Map();
|
|
16890
|
+
for (const record of leg) {
|
|
16891
|
+
if (record.kind !== PROGRESS_RECORD_KIND) continue;
|
|
16892
|
+
const payload = record.payload;
|
|
16893
|
+
if (typeof payload?.receipt !== "string") continue;
|
|
16894
|
+
if (typeof payload.toolCallId === "string") {
|
|
16895
|
+
receiptByCall.set(submissionCallKey(recordAttemptId(record), payload.toolCallId), payload.receipt);
|
|
16896
|
+
}
|
|
16897
|
+
if (typeof payload.round === "string" && payload.round !== "") {
|
|
16898
|
+
roundByReceipt.set(payload.receipt, payload.round);
|
|
16899
|
+
}
|
|
16900
|
+
}
|
|
16772
16901
|
const out = [];
|
|
16773
16902
|
const indexByCall = /* @__PURE__ */ new Map();
|
|
16774
16903
|
const roleByCall = /* @__PURE__ */ new Map();
|
|
@@ -16819,7 +16948,13 @@ function mapOwnedToSubmissionRows(owned) {
|
|
|
16819
16948
|
if (kind === void 0 || original === void 0 || payload === void 0) continue;
|
|
16820
16949
|
const callKey = typeof payload.toolCallId === "string" ? submissionCallKey(recordAttemptId(record), payload.toolCallId) : void 0;
|
|
16821
16950
|
const fallback = callKey === void 0 ? void 0 : roleByCall.get(callKey);
|
|
16822
|
-
|
|
16951
|
+
const receipt = kind === "accepted" && callKey !== void 0 ? receiptByCall.get(callKey) : void 0;
|
|
16952
|
+
const round = receipt === void 0 ? void 0 : roundByReceipt.get(receipt);
|
|
16953
|
+
take({
|
|
16954
|
+
...rowFromPayload(kind, payload, original, fallback),
|
|
16955
|
+
...receipt === void 0 ? {} : { receipt },
|
|
16956
|
+
...round === void 0 ? {} : { round }
|
|
16957
|
+
}, callKey);
|
|
16823
16958
|
}
|
|
16824
16959
|
return out;
|
|
16825
16960
|
}
|
|
@@ -16832,7 +16967,7 @@ async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, homeOrScop
|
|
|
16832
16967
|
if (attemptId.length === 0) return [];
|
|
16833
16968
|
const scope = resolveReadScope(homeOrScope);
|
|
16834
16969
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
|
|
16835
|
-
return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId));
|
|
16970
|
+
return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId), owned);
|
|
16836
16971
|
}
|
|
16837
16972
|
async function readSubmissionAttemptId(cwd, runId, toolCallId, homeOrScope) {
|
|
16838
16973
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, resolveReadScope(homeOrScope));
|
|
@@ -16874,7 +17009,8 @@ function sealAcceptedSubmission(options) {
|
|
|
16874
17009
|
accepted: options.accepted,
|
|
16875
17010
|
sealHead,
|
|
16876
17011
|
sessionFile: void 0,
|
|
16877
|
-
instruction: options.instruction ?? ""
|
|
17012
|
+
instruction: options.instruction ?? "",
|
|
17013
|
+
call: { attemptId, toolCallId: options.toolCallId }
|
|
16878
17014
|
});
|
|
16879
17015
|
}
|
|
16880
17016
|
var init_submission_ledger = __esm({
|
|
@@ -16886,6 +17022,7 @@ var init_submission_ledger = __esm({
|
|
|
16886
17022
|
init_host_contracts();
|
|
16887
17023
|
init_run_terminal_artifacts();
|
|
16888
17024
|
init_sitian_facade();
|
|
17025
|
+
init_run_dossier_files();
|
|
16889
17026
|
init_run_lifecycle();
|
|
16890
17027
|
init_submission_correctable_error();
|
|
16891
17028
|
init_report_ticket_tool();
|
|
@@ -17061,7 +17198,7 @@ var init_engine_detour_usage = __esm({
|
|
|
17061
17198
|
});
|
|
17062
17199
|
|
|
17063
17200
|
// src/dossier-resolution.ts
|
|
17064
|
-
import { existsSync as
|
|
17201
|
+
import { existsSync as existsSync6, statSync as statSync6 } from "node:fs";
|
|
17065
17202
|
import { resolve as resolve9 } from "node:path";
|
|
17066
17203
|
function isHostContext(value) {
|
|
17067
17204
|
return "sessionManager" in value;
|
|
@@ -17081,7 +17218,7 @@ function resolveAuditDossier(source) {
|
|
|
17081
17218
|
}
|
|
17082
17219
|
const runDirectory = resolve9(raw);
|
|
17083
17220
|
try {
|
|
17084
|
-
if (!
|
|
17221
|
+
if (!existsSync6(runDirectory) || !statSync6(runDirectory).isDirectory()) {
|
|
17085
17222
|
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
17086
17223
|
}
|
|
17087
17224
|
} catch {
|
|
@@ -17250,6 +17387,7 @@ __export(settlement_exports, {
|
|
|
17250
17387
|
exitCodeForTerminalOutcome: () => exitCodeForTerminalOutcome,
|
|
17251
17388
|
explicitInternalKnownFailureClassificationInput: () => explicitInternalKnownFailureClassificationInput,
|
|
17252
17389
|
extractNavigatorFact: () => extractNavigatorFact,
|
|
17390
|
+
filedIdentity: () => filedIdentity,
|
|
17253
17391
|
formatCliDiagnostic: () => formatCliDiagnostic,
|
|
17254
17392
|
formatErrorCauseDetail: () => formatErrorCauseDetail,
|
|
17255
17393
|
formatFailureStderrDiagnostic: () => formatFailureStderrDiagnostic,
|
|
@@ -17271,6 +17409,7 @@ __export(settlement_exports, {
|
|
|
17271
17409
|
trySettlePublicSeat: () => trySettlePublicSeat,
|
|
17272
17410
|
withSubmissions: () => withSubmissions
|
|
17273
17411
|
});
|
|
17412
|
+
import { basename as basename9, join as join17 } from "node:path";
|
|
17274
17413
|
function sealedLedgerHome(admitted) {
|
|
17275
17414
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
17276
17415
|
}
|
|
@@ -17329,6 +17468,17 @@ function ledgerReadScope(admitted, scope) {
|
|
|
17329
17468
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
17330
17469
|
};
|
|
17331
17470
|
}
|
|
17471
|
+
function filedIdentity(runDirectory, filed = []) {
|
|
17472
|
+
const subjectDirectory = subjectDirectoryOfRun(runDirectory);
|
|
17473
|
+
if (subjectDirectory === void 0) return {};
|
|
17474
|
+
const ticket = parseTicketNumber(basename9(subjectDirectory));
|
|
17475
|
+
return {
|
|
17476
|
+
...ticket === void 0 ? {} : { ticket },
|
|
17477
|
+
...filed.length === 0 ? {} : {
|
|
17478
|
+
receipts: filed.map((row) => ({ ...row, receipt: join17(subjectDirectory, row.receipt) }))
|
|
17479
|
+
}
|
|
17480
|
+
};
|
|
17481
|
+
}
|
|
17332
17482
|
function roleOutcomeFromRows(role, rows) {
|
|
17333
17483
|
const mine = rows.filter((row) => row.role === role);
|
|
17334
17484
|
const terminal = mine.filter(
|
|
@@ -17338,7 +17488,11 @@ function roleOutcomeFromRows(role, rows) {
|
|
|
17338
17488
|
const payloads = mine.map((row) => row.accepted);
|
|
17339
17489
|
const latest = terminal[terminal.length - 1];
|
|
17340
17490
|
const submissionToolCallId = typeof latest.toolCallId === "string" && latest.toolCallId.length > 0 ? latest.toolCallId : void 0;
|
|
17341
|
-
const
|
|
17491
|
+
const filed = mine.flatMap((row) => row.receipt === void 0 ? [] : [{ receipt: row.receipt, ...row.round === void 0 ? {} : { round: row.round } }]);
|
|
17492
|
+
const belonging = {
|
|
17493
|
+
...submissionToolCallId === void 0 ? {} : { submissionToolCallId },
|
|
17494
|
+
filed
|
|
17495
|
+
};
|
|
17342
17496
|
if (latest.kind === "audit-escalation") {
|
|
17343
17497
|
return {
|
|
17344
17498
|
outcome: {
|
|
@@ -17505,7 +17659,7 @@ async function settleNoReceiptTerminal(admitted, authority, scope, facts) {
|
|
|
17505
17659
|
scope
|
|
17506
17660
|
),
|
|
17507
17661
|
artifacts: [],
|
|
17508
|
-
|
|
17662
|
+
...filedIdentity(admitted.runDirectory)
|
|
17509
17663
|
}, coordinates.sessionDirectory, detourUsageContext(admitted, scope));
|
|
17510
17664
|
}
|
|
17511
17665
|
function coordinatesFromAdmitted(authority, admitted) {
|
|
@@ -17979,16 +18133,17 @@ async function settleSealedSeat(admitted, authority, scope, options) {
|
|
|
17979
18133
|
entriesOf(read),
|
|
17980
18134
|
settled.outcome,
|
|
17981
18135
|
scope,
|
|
17982
|
-
settled.submissionToolCallId
|
|
18136
|
+
settled.submissionToolCallId,
|
|
18137
|
+
settled.filed
|
|
17983
18138
|
);
|
|
17984
18139
|
}
|
|
17985
|
-
async function finishLawfulSeat(admitted, coordinates, entries, roleOutcome, scope, submissionToolCallId) {
|
|
18140
|
+
async function finishLawfulSeat(admitted, coordinates, entries, roleOutcome, scope, submissionToolCallId, filed) {
|
|
17986
18141
|
const artifacts = scope?.previewOnly === true ? [] : await publishDeclaredSeatTerminal(admitted, roleOutcome, coordinates, entries, scope);
|
|
17987
18142
|
const terminal = await attachEngineDetourToolUsage({
|
|
17988
18143
|
roleOutcome,
|
|
17989
18144
|
navigator: isNavigatorSeat(admitted.role) ? NAVIGATOR_SEAT_OWN_FACT : extractNavigatorFact(entries),
|
|
17990
18145
|
artifacts,
|
|
17991
|
-
|
|
18146
|
+
...filedIdentity(admitted.runDirectory, filed),
|
|
17992
18147
|
...submissionToolCallId === void 0 || submissionToolCallId.length === 0 ? {} : { submissionToolCallId }
|
|
17993
18148
|
}, coordinates.sessionDirectory, detourUsageContext(admitted, scope));
|
|
17994
18149
|
return attachRecordedSubmissions(admitted, terminal, scope);
|
|
@@ -18154,7 +18309,7 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
|
|
|
18154
18309
|
decisiveFacts
|
|
18155
18310
|
};
|
|
18156
18311
|
return attachEngineDetourToolUsage(
|
|
18157
|
-
{ roleOutcome, navigator, artifacts,
|
|
18312
|
+
{ roleOutcome, navigator, artifacts, ...filedIdentity(admitted.runDirectory) },
|
|
18158
18313
|
sessionDirectory,
|
|
18159
18314
|
detourUsageContext(admitted, options)
|
|
18160
18315
|
);
|
|
@@ -18221,6 +18376,7 @@ var init_settlement = __esm({
|
|
|
18221
18376
|
"src/public-cli/settlement.ts"() {
|
|
18222
18377
|
"use strict";
|
|
18223
18378
|
init_role_run_placement();
|
|
18379
|
+
init_run_ticket_number();
|
|
18224
18380
|
init_sitian_facade();
|
|
18225
18381
|
init_run_terminal_artifacts();
|
|
18226
18382
|
init_submission_ledger();
|
|
@@ -18256,12 +18412,12 @@ var init_settlement = __esm({
|
|
|
18256
18412
|
});
|
|
18257
18413
|
|
|
18258
18414
|
// src/external-host-turn-loop.ts
|
|
18259
|
-
import { existsSync as
|
|
18260
|
-
import { basename as
|
|
18415
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
18416
|
+
import { basename as basename10 } from "node:path";
|
|
18261
18417
|
async function syncTurnRequestLivePlacement(request, authority) {
|
|
18262
18418
|
const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
18263
18419
|
if (live === void 0) {
|
|
18264
|
-
const parsed = parseRunLeaf(
|
|
18420
|
+
const parsed = parseRunLeaf(basename10(request.runDirectory));
|
|
18265
18421
|
throw new Error(
|
|
18266
18422
|
`admitted run ${parsed?.runId ?? "(unparseable)"} missing after host turn; not found under ${request.home}`
|
|
18267
18423
|
);
|
|
@@ -18273,7 +18429,7 @@ async function syncTurnRequestLivePlacement(request, authority) {
|
|
|
18273
18429
|
}
|
|
18274
18430
|
async function retainPackageFaultBesideLivePlacement(request, input) {
|
|
18275
18431
|
let runDirectory = request.runDirectory;
|
|
18276
|
-
if (!
|
|
18432
|
+
if (!existsSync7(runDirectory)) {
|
|
18277
18433
|
try {
|
|
18278
18434
|
const found = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
|
|
18279
18435
|
if (found === void 0) {
|
|
@@ -18321,7 +18477,7 @@ var init_external_host_turn_loop = __esm({
|
|
|
18321
18477
|
});
|
|
18322
18478
|
|
|
18323
18479
|
// src/session-identity.ts
|
|
18324
|
-
import { join as
|
|
18480
|
+
import { join as join18 } from "node:path";
|
|
18325
18481
|
function createSessionIdentityAuthority(authority, hostName) {
|
|
18326
18482
|
const runDirectoryOf = (principal) => runDirectoryFromSessionDirectory(authority.decode(principal).sessionDirectory);
|
|
18327
18483
|
return {
|
|
@@ -18331,7 +18487,7 @@ function createSessionIdentityAuthority(authority, hostName) {
|
|
|
18331
18487
|
},
|
|
18332
18488
|
async load(principal) {
|
|
18333
18489
|
const runDirectory = runDirectoryOf(principal);
|
|
18334
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
18490
|
+
const { records, diagnostics } = await readSitianRecords(join18(runDirectory, RUN_STATE_FILE));
|
|
18335
18491
|
if (diagnostics.length > 0) {
|
|
18336
18492
|
throw new Error(
|
|
18337
18493
|
`${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
|
|
@@ -18401,14 +18557,14 @@ __export(role_turn_host_exports, {
|
|
|
18401
18557
|
});
|
|
18402
18558
|
import { execFile as execFile2, spawn } from "node:child_process";
|
|
18403
18559
|
import { constants as constants2 } from "node:fs";
|
|
18404
|
-
import { existsSync as
|
|
18560
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
18405
18561
|
import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
|
|
18406
|
-
import { delimiter, dirname as dirname12, isAbsolute as isAbsolute6, join as
|
|
18562
|
+
import { delimiter, dirname as dirname12, isAbsolute as isAbsolute6, join as join19, resolve as resolve10 } from "node:path";
|
|
18407
18563
|
import { platform } from "node:process";
|
|
18408
18564
|
import { promisify as promisify2 } from "node:util";
|
|
18409
18565
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
18410
18566
|
function resolveInternalRoleEntrypoint(packageRoot2) {
|
|
18411
|
-
return
|
|
18567
|
+
return join19(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
|
|
18412
18568
|
}
|
|
18413
18569
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
18414
18570
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -18598,7 +18754,7 @@ function createDefaultPiSpawnRunner(options) {
|
|
|
18598
18754
|
homeFromRunDirectory(spawnDir)
|
|
18599
18755
|
);
|
|
18600
18756
|
} catch (resolveError) {
|
|
18601
|
-
runDirectory =
|
|
18757
|
+
runDirectory = existsSync8(spawnDir) ? spawnDir : void 0;
|
|
18602
18758
|
const resolveDiagnostic = `live run path resolve failed beside Pi transport fault: ${describeErrorIdentity(resolveError)}`;
|
|
18603
18759
|
if (runDirectory !== void 0) {
|
|
18604
18760
|
await retainPackageFault({
|
|
@@ -18887,17 +19043,17 @@ var init_navigator_lookup_host = __esm({
|
|
|
18887
19043
|
});
|
|
18888
19044
|
|
|
18889
19045
|
// src/public-cli/load-production-acp-host.ts
|
|
18890
|
-
import { existsSync as
|
|
18891
|
-
import { join as
|
|
19046
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
19047
|
+
import { join as join20 } from "node:path";
|
|
18892
19048
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
18893
19049
|
async function loadProductionAcpHostFactory(packageRoot2, host) {
|
|
18894
19050
|
const description = lookupHostDescription(host);
|
|
18895
19051
|
if (description === void 0) {
|
|
18896
19052
|
throw new Error(`unregistered host: ${host}`);
|
|
18897
19053
|
}
|
|
18898
|
-
const built =
|
|
18899
|
-
const source =
|
|
18900
|
-
const target =
|
|
19054
|
+
const built = join20(packageRoot2, "dist/acp-host/production-host.js");
|
|
19055
|
+
const source = join20(packageRoot2, "src/acp-host/production-host.ts");
|
|
19056
|
+
const target = existsSync9(built) ? built : source;
|
|
18901
19057
|
const href = pathToFileURL2(target).href;
|
|
18902
19058
|
const mod = await import(href);
|
|
18903
19059
|
const create = mod.createProductionAcpRoleTurnHost;
|
|
@@ -18911,17 +19067,17 @@ var init_load_production_acp_host = __esm({
|
|
|
18911
19067
|
});
|
|
18912
19068
|
|
|
18913
19069
|
// src/public-cli/load-production-headless-host.ts
|
|
18914
|
-
import { existsSync as
|
|
18915
|
-
import { join as
|
|
19070
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
19071
|
+
import { join as join21 } from "node:path";
|
|
18916
19072
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
18917
19073
|
async function loadProductionHeadlessHostFactory(packageRoot2, host) {
|
|
18918
19074
|
const description = lookupHeadlessHostDescription(host);
|
|
18919
19075
|
if (description === void 0) {
|
|
18920
19076
|
throw new Error(`unregistered headless host: ${host}`);
|
|
18921
19077
|
}
|
|
18922
|
-
const built =
|
|
18923
|
-
const source =
|
|
18924
|
-
const target =
|
|
19078
|
+
const built = join21(packageRoot2, "dist/headless-host/production-host.js");
|
|
19079
|
+
const source = join21(packageRoot2, "src/headless-host/production-host.ts");
|
|
19080
|
+
const target = existsSync10(built) ? built : source;
|
|
18925
19081
|
const href = pathToFileURL3(target).href;
|
|
18926
19082
|
const mod = await import(href);
|
|
18927
19083
|
const create = mod.createProductionHeadlessRoleTurnHost;
|
|
@@ -19335,7 +19491,7 @@ async function requireSubmissionGate(options) {
|
|
|
19335
19491
|
officer: projected.officer,
|
|
19336
19492
|
receipt: gatekeeper.submission ?? { reason: gatekeeper.reason },
|
|
19337
19493
|
reason: gatekeeper.reason,
|
|
19338
|
-
runId: projected.summoned
|
|
19494
|
+
runId: projected.summoned === void 0 ? void 0 : officerRunIdFromSummoned(projected.summoned),
|
|
19339
19495
|
runDirectory: projected.summoned?.runDirectory,
|
|
19340
19496
|
terminal: projected.summoned?.terminal
|
|
19341
19497
|
});
|
|
@@ -19355,7 +19511,7 @@ async function requireSubmissionGate(options) {
|
|
|
19355
19511
|
officer: projected.officer,
|
|
19356
19512
|
receipt: gatekeeper.facts ?? { reason: gatekeeper.reason },
|
|
19357
19513
|
reason: gatekeeper.reason,
|
|
19358
|
-
runId: projected.summoned
|
|
19514
|
+
runId: projected.summoned === void 0 ? void 0 : officerRunIdFromSummoned(projected.summoned),
|
|
19359
19515
|
runDirectory: projected.summoned?.runDirectory,
|
|
19360
19516
|
terminal: projected.summoned?.terminal
|
|
19361
19517
|
});
|
|
@@ -19387,7 +19543,7 @@ __export(auditor_soul_exports, {
|
|
|
19387
19543
|
readAuditorResumeBinding: () => readAuditorResumeBinding,
|
|
19388
19544
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
19389
19545
|
});
|
|
19390
|
-
import { basename as
|
|
19546
|
+
import { basename as basename11 } from "node:path";
|
|
19391
19547
|
function auditorSoulRelativePath(role) {
|
|
19392
19548
|
return `souls/${role}-auditor.md`;
|
|
19393
19549
|
}
|
|
@@ -19423,7 +19579,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
|
|
|
19423
19579
|
return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
|
|
19424
19580
|
}
|
|
19425
19581
|
function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
19426
|
-
const role = parseRunLeaf(
|
|
19582
|
+
const role = parseRunLeaf(basename11(sourceRunDirectory))?.role;
|
|
19427
19583
|
return isAuditorSoulRole(role) ? role : void 0;
|
|
19428
19584
|
}
|
|
19429
19585
|
async function readAuditorResumeBinding(admitted) {
|
|
@@ -19592,7 +19748,7 @@ function dispatchExceptionFailureTerminal(input) {
|
|
|
19592
19748
|
},
|
|
19593
19749
|
navigator: { disposition: "no-advice" },
|
|
19594
19750
|
artifacts,
|
|
19595
|
-
|
|
19751
|
+
...filedIdentity(input.runDirectory),
|
|
19596
19752
|
autoResumeCount: input.autoResumeAttempts
|
|
19597
19753
|
};
|
|
19598
19754
|
}
|
|
@@ -19690,7 +19846,7 @@ async function runWithAutoResumeLoop(options) {
|
|
|
19690
19846
|
options.admitted,
|
|
19691
19847
|
dispatchExceptionFailureTerminal({
|
|
19692
19848
|
role: options.admitted.role,
|
|
19693
|
-
|
|
19849
|
+
runDirectory: options.admitted.runDirectory,
|
|
19694
19850
|
causeError: lastThrownError,
|
|
19695
19851
|
errorFiles: retainedErrorFiles,
|
|
19696
19852
|
autoResumeAttempts,
|
|
@@ -19740,12 +19896,12 @@ var init_auto_resume = __esm({
|
|
|
19740
19896
|
});
|
|
19741
19897
|
|
|
19742
19898
|
// src/public-cli/seat-ticket-binding.ts
|
|
19743
|
-
import { join as
|
|
19899
|
+
import { join as join23 } from "node:path";
|
|
19744
19900
|
function resumedSessionIdMissing(result, runId) {
|
|
19745
19901
|
if (typeof result !== "object" || result === null) return false;
|
|
19746
19902
|
const terminal = result.terminal;
|
|
19747
19903
|
if (typeof terminal !== "object" || terminal === null) return false;
|
|
19748
|
-
if (
|
|
19904
|
+
if (result.admitted?.runId !== runId) return false;
|
|
19749
19905
|
const outcome = terminal.roleOutcome;
|
|
19750
19906
|
if (typeof outcome !== "object" || outcome === null) return false;
|
|
19751
19907
|
if (outcome.kind !== "failure") return false;
|
|
@@ -19754,7 +19910,7 @@ function resumedSessionIdMissing(result, runId) {
|
|
|
19754
19910
|
return facts.errorCode === SESSION_ID_MISSING;
|
|
19755
19911
|
}
|
|
19756
19912
|
async function writerLockBlocksFreshSummons(runDirectory) {
|
|
19757
|
-
const autopsy = await autopsyWriterLock(
|
|
19913
|
+
const autopsy = await autopsyWriterLock(join23(runDirectory, WRITER_LOCK_FILE));
|
|
19758
19914
|
return autopsy.verdict === "alive" || autopsy.verdict === "unknown";
|
|
19759
19915
|
}
|
|
19760
19916
|
async function tryResumeSameTicketSeatRun(input) {
|
|
@@ -20396,6 +20552,16 @@ async function runOmittedLensBatch(argv2, parsed, env, io) {
|
|
|
20396
20552
|
else io.stdout(formatTerminalResult(terminal));
|
|
20397
20553
|
return { exitCode: failed ? 1 : 0, terminal };
|
|
20398
20554
|
}
|
|
20555
|
+
async function pinAuditedLegAtAdmission(officerRunDirectory, auditedRunDirectory, io, source) {
|
|
20556
|
+
const { for: auditedRound, fault } = readAuditedRound(auditedRunDirectory);
|
|
20557
|
+
persistAdmittedAuditedLeg(officerRunDirectory, { for: auditedRound, ...source });
|
|
20558
|
+
if (fault === void 0) return;
|
|
20559
|
+
await retainPackageFault({
|
|
20560
|
+
runDirectory: officerRunDirectory,
|
|
20561
|
+
diagnostic: fault,
|
|
20562
|
+
stderr: (text) => io.stderr(text)
|
|
20563
|
+
});
|
|
20564
|
+
}
|
|
20399
20565
|
function resumeSameParentInstructionSeat(input) {
|
|
20400
20566
|
return tryResumeSameTicketSeatRun({
|
|
20401
20567
|
home: input.env.home,
|
|
@@ -20415,7 +20581,8 @@ function resumeSameParentInstructionSeat(input) {
|
|
|
20415
20581
|
...materials === void 0 ? {} : { summons: materials }
|
|
20416
20582
|
},
|
|
20417
20583
|
input.env,
|
|
20418
|
-
input.io
|
|
20584
|
+
input.io,
|
|
20585
|
+
input.parentRunPath
|
|
20419
20586
|
);
|
|
20420
20587
|
}
|
|
20421
20588
|
});
|
|
@@ -20491,7 +20658,9 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
20491
20658
|
);
|
|
20492
20659
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
20493
20660
|
if (gateParentRunPath !== void 0) {
|
|
20494
|
-
await
|
|
20661
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, gateParentRunPath, io, {
|
|
20662
|
+
sourceRunPath: gateParentRunPath
|
|
20663
|
+
});
|
|
20495
20664
|
admitted = { ...admitted, sourceRunPath: gateParentRunPath };
|
|
20496
20665
|
}
|
|
20497
20666
|
const turnProjection = roleTurnOptions(env, admitted, {
|
|
@@ -20700,12 +20869,21 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
20700
20869
|
throw error;
|
|
20701
20870
|
}
|
|
20702
20871
|
if (instructionSourceRunPath !== void 0) {
|
|
20703
|
-
await
|
|
20872
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, instructionSourceRunPath, io, {
|
|
20873
|
+
sourceRunPath: instructionSourceRunPath
|
|
20874
|
+
});
|
|
20704
20875
|
admitted = { ...admitted, sourceRunPath: instructionSourceRunPath };
|
|
20705
|
-
}
|
|
20706
|
-
|
|
20707
|
-
|
|
20876
|
+
} else if (record.sameParent === "subject-source" && auditorSource !== void 0) {
|
|
20877
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, auditorSource, io, {
|
|
20878
|
+
sourceRunPath: auditorSource,
|
|
20879
|
+
auditorSubject
|
|
20880
|
+
});
|
|
20708
20881
|
admitted = { ...admitted, sourceRunPath: auditorSource };
|
|
20882
|
+
} else {
|
|
20883
|
+
const auditedRunDirectory = admittedSourceRunPath(admitted);
|
|
20884
|
+
if (auditedRunDirectory !== void 0) {
|
|
20885
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, auditedRunDirectory, io);
|
|
20886
|
+
}
|
|
20709
20887
|
}
|
|
20710
20888
|
admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
|
|
20711
20889
|
const runAdmitted = async () => {
|
|
@@ -20780,7 +20958,7 @@ async function inheritKnownTicketFromSource(admitted, authority) {
|
|
|
20780
20958
|
await relocateAdmittedRunToTicket(admitted, authority);
|
|
20781
20959
|
return admitted;
|
|
20782
20960
|
}
|
|
20783
|
-
async function runPublicInstructionSeatResume(request, env, io) {
|
|
20961
|
+
async function runPublicInstructionSeatResume(request, env, io, resummonedFor) {
|
|
20784
20962
|
let selectedRequest = request;
|
|
20785
20963
|
const resume = async () => {
|
|
20786
20964
|
const held = [];
|
|
@@ -20811,6 +20989,9 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
20811
20989
|
return { ...loaded, admitted };
|
|
20812
20990
|
},
|
|
20813
20991
|
buildTurnRequest: async (admitted, effective) => {
|
|
20992
|
+
if (resummonedFor !== void 0) {
|
|
20993
|
+
await pinAuditedLegAtAdmission(admitted.runDirectory, resummonedFor, io);
|
|
20994
|
+
}
|
|
20814
20995
|
const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
|
|
20815
20996
|
const projection = resumeTurnRequestProjectionOptions(
|
|
20816
20997
|
admitted,
|
|
@@ -21212,7 +21393,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
21212
21393
|
const pass = chain.passes.at(-1);
|
|
21213
21394
|
const officerTerminal = pass?.terminal;
|
|
21214
21395
|
const officerRunDirectory = pass?.runDirectory;
|
|
21215
|
-
const officerRunId = pass?.runId
|
|
21396
|
+
const officerRunId = pass?.runId;
|
|
21216
21397
|
if (officerTerminal !== void 0 && officerRunId !== void 0) {
|
|
21217
21398
|
await presentAuditedOriginalVolume(turn, io);
|
|
21218
21399
|
const officer = await loadResumablePublicRole(
|
|
@@ -21251,7 +21432,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
21251
21432
|
if (chain.status === "escalate") {
|
|
21252
21433
|
const escalation = chain.passes.at(-1);
|
|
21253
21434
|
const escalatedRunDirectory = escalation?.runDirectory;
|
|
21254
|
-
const escalatedRunId = escalation?.runId
|
|
21435
|
+
const escalatedRunId = escalation?.runId;
|
|
21255
21436
|
if (escalatedRunId === void 0) {
|
|
21256
21437
|
return incompleteAuditWithoutOfficerVolume(
|
|
21257
21438
|
turn,
|
|
@@ -21329,6 +21510,7 @@ var init_instruction_seat_run = __esm({
|
|
|
21329
21510
|
init_terminal();
|
|
21330
21511
|
init_turn_request();
|
|
21331
21512
|
init_countersign_run();
|
|
21513
|
+
init_ticket_progress();
|
|
21332
21514
|
init_unknown_value();
|
|
21333
21515
|
AUDITED_ROLES = /* @__PURE__ */ new Set(["judge", "fixer", "coder", "secretariat", "countersign", "doctor"]);
|
|
21334
21516
|
SECRETARIAT_STATUS_REASK = "status \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
|
|
@@ -21395,9 +21577,9 @@ __export(public_role_summons_exports, {
|
|
|
21395
21577
|
summonPublicRole: () => summonPublicRole
|
|
21396
21578
|
});
|
|
21397
21579
|
import { execFile as execFile3 } from "node:child_process";
|
|
21398
|
-
import { existsSync as
|
|
21580
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
21399
21581
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
21400
|
-
import { join as
|
|
21582
|
+
import { join as join24 } from "node:path";
|
|
21401
21583
|
import { promisify as promisify3 } from "node:util";
|
|
21402
21584
|
function createCapturingIo() {
|
|
21403
21585
|
const chunks = [];
|
|
@@ -21421,7 +21603,7 @@ function parentDir(path) {
|
|
|
21421
21603
|
function walkPackageRoot(start) {
|
|
21422
21604
|
let dir = start;
|
|
21423
21605
|
for (let i = 0; i < 12; i += 1) {
|
|
21424
|
-
if (
|
|
21606
|
+
if (existsSync11(join24(dir, "package.json")) && existsSync11(join24(dir, "souls"))) {
|
|
21425
21607
|
return dir;
|
|
21426
21608
|
}
|
|
21427
21609
|
const parent = parentDir(dir);
|
|
@@ -21656,13 +21838,7 @@ async function summonPublicRole(options) {
|
|
|
21656
21838
|
result = stepped.ok;
|
|
21657
21839
|
}
|
|
21658
21840
|
const stderr = captured?.stderrText();
|
|
21659
|
-
|
|
21660
|
-
if (result.terminal !== void 0 && result.terminal.roleOutcome.role !== options.role && typeof result.terminal.runId === "string" && result.admitted?.runId !== result.terminal.runId) {
|
|
21661
|
-
runDirectory = await (await Promise.resolve().then(() => (init_run_lifecycle(), run_lifecycle_exports))).findRunDirectoryById(
|
|
21662
|
-
home,
|
|
21663
|
-
result.terminal.runId
|
|
21664
|
-
) ?? runDirectory;
|
|
21665
|
-
}
|
|
21841
|
+
const runDirectory = result.admitted?.runDirectory;
|
|
21666
21842
|
return {
|
|
21667
21843
|
exitCode: result.exitCode,
|
|
21668
21844
|
...result.terminal === void 0 ? {} : { terminal: result.terminal },
|
|
@@ -21964,7 +22140,7 @@ var init_compliance_transport = __esm({
|
|
|
21964
22140
|
});
|
|
21965
22141
|
|
|
21966
22142
|
// src/role-run-relocation.ts
|
|
21967
|
-
import { dirname as dirname14, join as
|
|
22143
|
+
import { dirname as dirname14, join as join25 } from "node:path";
|
|
21968
22144
|
async function retainedRunPathsMatch(recordedPath, currentPath, currentRunDirectory) {
|
|
21969
22145
|
if (recordedPath === currentPath) return true;
|
|
21970
22146
|
if (typeof recordedPath !== "string") return false;
|
|
@@ -22006,34 +22182,9 @@ var init_role_run_relocation = __esm({
|
|
|
22006
22182
|
});
|
|
22007
22183
|
|
|
22008
22184
|
// src/public-cli/run-lifecycle.ts
|
|
22009
|
-
|
|
22010
|
-
__export(run_lifecycle_exports, {
|
|
22011
|
-
AUTO_RESUME_LIMIT: () => AUTO_RESUME_LIMIT,
|
|
22012
|
-
RunWriterLeaseHeldError: () => RunWriterLeaseHeldError,
|
|
22013
|
-
WRITER_LOCK_FILE: () => WRITER_LOCK_FILE,
|
|
22014
|
-
acquireRunWriterLease: () => acquireRunWriterLease,
|
|
22015
|
-
autopsyWriterLock: () => autopsyWriterLock,
|
|
22016
|
-
clearCurrentCourt: () => clearCurrentCourt,
|
|
22017
|
-
describeErrorIdentity: () => describeErrorIdentity,
|
|
22018
|
-
findLatestRunForSeatTicket: () => findLatestRunForSeatTicket,
|
|
22019
|
-
findLatestRunIdForSeatTicket: () => findLatestRunIdForSeatTicket,
|
|
22020
|
-
findRunDirectoryById: () => findRunDirectoryById,
|
|
22021
|
-
loadResumablePublicRole: () => loadResumablePublicRole,
|
|
22022
|
-
markRunAdmitted: () => markRunAdmitted,
|
|
22023
|
-
markRunRunning: () => markRunRunning,
|
|
22024
|
-
markRunTerminal: () => markRunTerminal,
|
|
22025
|
-
peekRoleRunRole: () => peekRoleRunRole,
|
|
22026
|
-
readCurrentCourt: () => readCurrentCourt,
|
|
22027
|
-
readRoleRunIdentity: () => readRoleRunIdentity,
|
|
22028
|
-
readRoleRunState: () => readRoleRunState,
|
|
22029
|
-
readRunParentPath: () => readRunParentPath,
|
|
22030
|
-
recordCurrentCourt: () => recordCurrentCourt,
|
|
22031
|
-
resolveLiveRunDirectoryPath: () => resolveLiveRunDirectoryPath,
|
|
22032
|
-
writeRoleRunState: () => writeRoleRunState
|
|
22033
|
-
});
|
|
22034
|
-
import { existsSync as existsSync11 } from "node:fs";
|
|
22185
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
22035
22186
|
import { chmod, lstat as lstat3, open, readdir as readdir3, readFile as readFile10, unlink } from "node:fs/promises";
|
|
22036
|
-
import { basename as
|
|
22187
|
+
import { basename as basename12, join as join26 } from "node:path";
|
|
22037
22188
|
async function writeRoleRunState(runDirectory, record) {
|
|
22038
22189
|
const payload = { ...record, runDirectory };
|
|
22039
22190
|
writeSectionSync(runDirectory, "runState", { ...payload });
|
|
@@ -22328,7 +22479,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
22328
22479
|
},
|
|
22329
22480
|
relocate(nextRunDirectory) {
|
|
22330
22481
|
currentRunDirectory = nextRunDirectory;
|
|
22331
|
-
currentLockPath =
|
|
22482
|
+
currentLockPath = join26(nextRunDirectory, WRITER_LOCK_FILE);
|
|
22332
22483
|
},
|
|
22333
22484
|
async release() {
|
|
22334
22485
|
if (released) return;
|
|
@@ -22367,10 +22518,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
22367
22518
|
};
|
|
22368
22519
|
const reportReadFailure = (error) => {
|
|
22369
22520
|
reportDiagnostic(
|
|
22370
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
22521
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join26(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
22371
22522
|
);
|
|
22372
22523
|
};
|
|
22373
|
-
const lockPath =
|
|
22524
|
+
const lockPath = join26(runDirectory, WRITER_LOCK_FILE);
|
|
22374
22525
|
let lastAutopsy = { verdict: "absent" };
|
|
22375
22526
|
let lastReclaimFailure;
|
|
22376
22527
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -22426,17 +22577,17 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
22426
22577
|
}
|
|
22427
22578
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRunDirectory) {
|
|
22428
22579
|
if (typeof knownRunDirectory === "string" && knownRunDirectory.trim() !== "") {
|
|
22429
|
-
const parsed = parseRunLeaf(
|
|
22580
|
+
const parsed = parseRunLeaf(basename12(knownRunDirectory));
|
|
22430
22581
|
if (parsed === void 0 || parsed.runId !== runId) {
|
|
22431
22582
|
throw new CliUsageError(
|
|
22432
|
-
`run directory
|
|
22583
|
+
`run directory is not the expected role run: ${knownRunDirectory}`
|
|
22433
22584
|
);
|
|
22434
22585
|
}
|
|
22435
22586
|
return knownRunDirectory;
|
|
22436
22587
|
}
|
|
22437
22588
|
if (runId.trim() === "") return void 0;
|
|
22438
22589
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
22439
|
-
const booksRoot =
|
|
22590
|
+
const booksRoot = join26(ledgerHome, "books");
|
|
22440
22591
|
let bookKeys;
|
|
22441
22592
|
try {
|
|
22442
22593
|
bookKeys = await readdir3(booksRoot);
|
|
@@ -22451,8 +22602,8 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
|
|
|
22451
22602
|
);
|
|
22452
22603
|
}
|
|
22453
22604
|
async function resolveLiveRunDirectoryPath(recordedPath, home, onlyBookKey) {
|
|
22454
|
-
if (
|
|
22455
|
-
const parsed = parseRunLeaf(
|
|
22605
|
+
if (existsSync12(recordedPath)) return recordedPath;
|
|
22606
|
+
const parsed = parseRunLeaf(basename12(recordedPath));
|
|
22456
22607
|
const bookKey = onlyBookKey ?? tryBookKeyFromAkRolesPath(recordedPath);
|
|
22457
22608
|
if (parsed === void 0 || bookKey === void 0) return void 0;
|
|
22458
22609
|
return findRunDirectoryById(home, parsed.runId, bookKey, parsed.role);
|
|
@@ -22473,10 +22624,6 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
22473
22624
|
throw error;
|
|
22474
22625
|
}
|
|
22475
22626
|
}
|
|
22476
|
-
async function findLatestRunIdForSeatTicket(input) {
|
|
22477
|
-
const found = await findLatestRunForSeatTicket(input);
|
|
22478
|
-
return found?.runId;
|
|
22479
|
-
}
|
|
22480
22627
|
async function findLatestRunForSeatTicket(input) {
|
|
22481
22628
|
if (input.parentRunPath.trim() === "") {
|
|
22482
22629
|
return void 0;
|
|
@@ -22486,7 +22633,7 @@ async function findLatestRunForSeatTicket(input) {
|
|
|
22486
22633
|
let runDirectories;
|
|
22487
22634
|
try {
|
|
22488
22635
|
runDirectories = await listBookRunDirectories(
|
|
22489
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
22636
|
+
input.ticketNumber === void 0 ? bookDir : join26(bookDir, String(input.ticketNumber))
|
|
22490
22637
|
);
|
|
22491
22638
|
} catch (error) {
|
|
22492
22639
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -22494,7 +22641,7 @@ async function findLatestRunForSeatTicket(input) {
|
|
|
22494
22641
|
}
|
|
22495
22642
|
let best;
|
|
22496
22643
|
for (const runDirectory of runDirectories) {
|
|
22497
|
-
const parsed = parseRunLeaf(
|
|
22644
|
+
const parsed = parseRunLeaf(basename12(runDirectory));
|
|
22498
22645
|
if (parsed === void 0 || parsed.role !== input.role) continue;
|
|
22499
22646
|
const runId = parsed.runId;
|
|
22500
22647
|
const parentPath = await readRunParentPath(runDirectory);
|
|
@@ -22521,15 +22668,15 @@ function restoredTicketFields(fields) {
|
|
|
22521
22668
|
async function loadResumableRunRecord(home, runId, authority, knownRunDirectory) {
|
|
22522
22669
|
const runDirectory = await findRunDirectoryById(home, runId, void 0, void 0, knownRunDirectory);
|
|
22523
22670
|
if (runDirectory === void 0) {
|
|
22524
|
-
throw new CliUsageError(`unknown role run
|
|
22671
|
+
throw new CliUsageError(`unknown role run: no run directory found under ${home}`);
|
|
22525
22672
|
}
|
|
22526
22673
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
22527
22674
|
if (disk === void 0) {
|
|
22528
|
-
throw new CliUsageError(`
|
|
22675
|
+
throw new CliUsageError(`role run has no readable state: ${runDirectory}`);
|
|
22529
22676
|
}
|
|
22530
22677
|
const materialized = materializeRoleRunFromDisk(disk, authority);
|
|
22531
22678
|
if (materialized === void 0) {
|
|
22532
|
-
throw new CliUsageError(`
|
|
22679
|
+
throw new CliUsageError(`role run has no readable state: ${runDirectory}`);
|
|
22533
22680
|
}
|
|
22534
22681
|
const { run, principal } = materialized;
|
|
22535
22682
|
let instruction = "";
|
|
@@ -22655,7 +22802,7 @@ async function loadResumableRunRecord(home, runId, authority, knownRunDirectory)
|
|
|
22655
22802
|
} catch (error) {
|
|
22656
22803
|
if (error instanceof CliUsageError) throw error;
|
|
22657
22804
|
throw new CliUsageError(
|
|
22658
|
-
`role run admitted request is unreadable: ${
|
|
22805
|
+
`role run admitted request is unreadable: ${run.runDirectory}`,
|
|
22659
22806
|
{ cause: error }
|
|
22660
22807
|
);
|
|
22661
22808
|
}
|
|
@@ -22682,7 +22829,7 @@ async function loadResumableRunRecord(home, runId, authority, knownRunDirectory)
|
|
|
22682
22829
|
}
|
|
22683
22830
|
if (!isEnoent(error)) {
|
|
22684
22831
|
throw new CliUsageError(
|
|
22685
|
-
`role run invocation identity is unreadable: ${
|
|
22832
|
+
`role run invocation identity is unreadable: ${run.runDirectory}`,
|
|
22686
22833
|
{ cause: error }
|
|
22687
22834
|
);
|
|
22688
22835
|
}
|
|
@@ -22764,7 +22911,7 @@ async function loadResumablePublicRole(home, runId, authority, options) {
|
|
|
22764
22911
|
}
|
|
22765
22912
|
function admitResumedRole(loaded) {
|
|
22766
22913
|
const role = loaded.run.role;
|
|
22767
|
-
const
|
|
22914
|
+
const leg = loaded.run.runDirectory;
|
|
22768
22915
|
const record = packagedRoleMetadata(role);
|
|
22769
22916
|
if (record === void 0) {
|
|
22770
22917
|
throw new CliUsageError(`unknown role: ${role}`);
|
|
@@ -22795,10 +22942,10 @@ function admitResumedRole(loaded) {
|
|
|
22795
22942
|
return admitted;
|
|
22796
22943
|
}
|
|
22797
22944
|
case "worker-task": {
|
|
22798
|
-
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role,
|
|
22945
|
+
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, leg);
|
|
22799
22946
|
if (fields.instruction.trim() === "") {
|
|
22800
22947
|
throw new CliUsageError(
|
|
22801
|
-
`role run admitted coder task is blank: ${
|
|
22948
|
+
`role run admitted coder task is blank: ${leg}`
|
|
22802
22949
|
);
|
|
22803
22950
|
}
|
|
22804
22951
|
const admitted = {
|
|
@@ -22810,10 +22957,10 @@ function admitResumedRole(loaded) {
|
|
|
22810
22957
|
return admitted;
|
|
22811
22958
|
}
|
|
22812
22959
|
case "worker-packet": {
|
|
22813
|
-
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role,
|
|
22960
|
+
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, leg);
|
|
22814
22961
|
if (fields.instruction.trim() === "") {
|
|
22815
22962
|
throw new CliUsageError(
|
|
22816
|
-
`role run admitted fixer instruction is blank: ${
|
|
22963
|
+
`role run admitted fixer instruction is blank: ${leg}`
|
|
22817
22964
|
);
|
|
22818
22965
|
}
|
|
22819
22966
|
const admitted = {
|
|
@@ -22830,19 +22977,19 @@ function admitResumedRole(loaded) {
|
|
|
22830
22977
|
const baseFault = admittedReviewerBaseFault(rawBase);
|
|
22831
22978
|
if (baseFault !== void 0 || rawBase === void 0) {
|
|
22832
22979
|
throw new CliUsageError(
|
|
22833
|
-
baseFault === "damaged" ? `role run admitted reviewer base revision is damaged: ${
|
|
22980
|
+
baseFault === "damaged" ? `role run admitted reviewer base revision is damaged: ${leg}` : `role run admitted reviewer base revision is missing: ${leg}`
|
|
22834
22981
|
);
|
|
22835
22982
|
}
|
|
22836
22983
|
const lens = fields.lens;
|
|
22837
22984
|
if (!isReviewerLens(lens)) {
|
|
22838
22985
|
throw new CliUsageError(
|
|
22839
|
-
`role run admitted reviewer lens is missing: ${
|
|
22986
|
+
`role run admitted reviewer lens is missing: ${leg}`
|
|
22840
22987
|
);
|
|
22841
22988
|
}
|
|
22842
22989
|
const authorityRefs = Object.freeze([...fields.authorityRefs ?? []]);
|
|
22843
22990
|
if (authorityRefs.length === 0) {
|
|
22844
22991
|
throw new CliUsageError(
|
|
22845
|
-
`role run admitted reviewer authority refs are missing: ${
|
|
22992
|
+
`role run admitted reviewer authority refs are missing: ${leg}`
|
|
22846
22993
|
);
|
|
22847
22994
|
}
|
|
22848
22995
|
const admitted = {
|
|
@@ -22858,7 +23005,7 @@ function admitResumedRole(loaded) {
|
|
|
22858
23005
|
const baseRevision = fields.baseRevision;
|
|
22859
23006
|
if (baseRevision === void 0 || baseRevision.trim() === "") {
|
|
22860
23007
|
throw new CliUsageError(
|
|
22861
|
-
`role run admitted gleaner-left base revision is missing: ${
|
|
23008
|
+
`role run admitted gleaner-left base revision is missing: ${leg}`
|
|
22862
23009
|
);
|
|
22863
23010
|
}
|
|
22864
23011
|
const admitted = {
|
|
@@ -22872,18 +23019,18 @@ function admitResumedRole(loaded) {
|
|
|
22872
23019
|
const mergerInputPath = fields.mergerInputPath;
|
|
22873
23020
|
if (mergerInputPath === void 0) {
|
|
22874
23021
|
throw new CliUsageError(
|
|
22875
|
-
`role run admitted merger input path is missing: ${
|
|
23022
|
+
`role run admitted merger input path is missing: ${leg}`
|
|
22876
23023
|
);
|
|
22877
23024
|
}
|
|
22878
23025
|
const derived = fields.derived;
|
|
22879
23026
|
if (derived === void 0) {
|
|
22880
23027
|
throw new CliUsageError(
|
|
22881
|
-
`role run admitted merger envelope is missing: ${
|
|
23028
|
+
`role run admitted merger envelope is missing: ${leg}`
|
|
22882
23029
|
);
|
|
22883
23030
|
}
|
|
22884
23031
|
if (fields.instruction.trim() === "") {
|
|
22885
23032
|
throw new CliUsageError(
|
|
22886
|
-
`role run admitted merger task is blank: ${
|
|
23033
|
+
`role run admitted merger task is blank: ${leg}`
|
|
22887
23034
|
);
|
|
22888
23035
|
}
|
|
22889
23036
|
const admitted = {
|
|
@@ -22899,7 +23046,7 @@ function admitResumedRole(loaded) {
|
|
|
22899
23046
|
const { prNumber, repository, repositoryDisplay } = fields;
|
|
22900
23047
|
if (repository === void 0 || repositoryDisplay === void 0) {
|
|
22901
23048
|
throw new CliUsageError(
|
|
22902
|
-
`role run admitted collector repository identity is missing: ${
|
|
23049
|
+
`role run admitted collector repository identity is missing: ${leg}`
|
|
22903
23050
|
);
|
|
22904
23051
|
}
|
|
22905
23052
|
let parsedRepository;
|
|
@@ -22911,7 +23058,7 @@ function admitResumedRole(loaded) {
|
|
|
22911
23058
|
}
|
|
22912
23059
|
if (parsedRepository.canonical !== repository) {
|
|
22913
23060
|
throw new CliUsageError(
|
|
22914
|
-
`role run admitted collector repository does not match its canonical form: ${
|
|
23061
|
+
`role run admitted collector repository does not match its canonical form: ${leg}`
|
|
22915
23062
|
);
|
|
22916
23063
|
}
|
|
22917
23064
|
const admitted = {
|
|
@@ -22928,7 +23075,7 @@ function admitResumedRole(loaded) {
|
|
|
22928
23075
|
const { issueNumber, caseRunsPath, caseIdentity } = fields;
|
|
22929
23076
|
if (issueNumber === void 0 || caseRunsPath === void 0 || caseIdentity === void 0) {
|
|
22930
23077
|
throw new CliUsageError(
|
|
22931
|
-
`role run admitted doctor case identity is missing: ${
|
|
23078
|
+
`role run admitted doctor case identity is missing: ${leg}`
|
|
22932
23079
|
);
|
|
22933
23080
|
}
|
|
22934
23081
|
const admitted = {
|
|
@@ -22944,7 +23091,7 @@ function admitResumedRole(loaded) {
|
|
|
22944
23091
|
const { sourceRunPath, sourceRun } = fields;
|
|
22945
23092
|
if (sourceRunPath === void 0 || sourceRun === void 0) {
|
|
22946
23093
|
throw new CliUsageError(
|
|
22947
|
-
`role run admitted notary source-run locator is missing: ${
|
|
23094
|
+
`role run admitted notary source-run locator is missing: ${leg}`
|
|
22948
23095
|
);
|
|
22949
23096
|
}
|
|
22950
23097
|
const admitted = {
|
|
@@ -22957,13 +23104,13 @@ function admitResumedRole(loaded) {
|
|
|
22957
23104
|
}
|
|
22958
23105
|
}
|
|
22959
23106
|
}
|
|
22960
|
-
function resumedWorkerPhase(phase, phases, role,
|
|
23107
|
+
function resumedWorkerPhase(phase, phases, role, leg) {
|
|
22961
23108
|
if (phase === "plan" || phase === "apply") {
|
|
22962
23109
|
if (phases.some((item) => item === phase)) {
|
|
22963
23110
|
return phase;
|
|
22964
23111
|
}
|
|
22965
23112
|
}
|
|
22966
|
-
throw new CliUsageError(`role run admitted ${role} phase is missing: ${
|
|
23113
|
+
throw new CliUsageError(`role run admitted ${role} phase is missing: ${leg}`);
|
|
22967
23114
|
}
|
|
22968
23115
|
var AUTO_RESUME_LIMIT, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
|
|
22969
23116
|
var init_run_lifecycle = __esm({
|
|
@@ -30214,13 +30361,13 @@ var init_value2 = __esm({
|
|
|
30214
30361
|
});
|
|
30215
30362
|
|
|
30216
30363
|
// src/analyst-book-key.ts
|
|
30217
|
-
import { statSync as
|
|
30364
|
+
import { statSync as statSync7 } from "node:fs";
|
|
30218
30365
|
import { isAbsolute as isAbsolute8 } from "node:path";
|
|
30219
30366
|
function resolveAnalystBookKey(projectRoot) {
|
|
30220
30367
|
const identity = physicalPathIdentity(projectRoot);
|
|
30221
30368
|
let stats;
|
|
30222
30369
|
try {
|
|
30223
|
-
stats =
|
|
30370
|
+
stats = statSync7(identity);
|
|
30224
30371
|
} catch (error) {
|
|
30225
30372
|
const code = errnoCode(error);
|
|
30226
30373
|
if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
|
|
@@ -30250,10 +30397,10 @@ var init_analyst_book_key = __esm({
|
|
|
30250
30397
|
// src/atomic-write.ts
|
|
30251
30398
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
30252
30399
|
import { rename as rename2, rm, writeFile as writeFile4 } from "node:fs/promises";
|
|
30253
|
-
import { dirname as dirname15, join as
|
|
30400
|
+
import { dirname as dirname15, join as join27 } from "node:path";
|
|
30254
30401
|
async function writeFileAtomically(destination, contents, options) {
|
|
30255
30402
|
const parent = dirname15(destination);
|
|
30256
|
-
const temporary =
|
|
30403
|
+
const temporary = join27(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
30257
30404
|
try {
|
|
30258
30405
|
await writeFile4(temporary, contents, options);
|
|
30259
30406
|
await rename2(temporary, destination);
|
|
@@ -30270,12 +30417,12 @@ var init_atomic_write = __esm({
|
|
|
30270
30417
|
|
|
30271
30418
|
// src/analyst-index.ts
|
|
30272
30419
|
import { open as open2, readFile as readFile11, unlink as unlink2 } from "node:fs/promises";
|
|
30273
|
-
import { dirname as dirname16, join as
|
|
30420
|
+
import { dirname as dirname16, join as join28 } from "node:path";
|
|
30274
30421
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
30275
30422
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
30276
30423
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
30277
30424
|
ensureRealDirectoryTree(ledgerHome, dirname16(indexPath));
|
|
30278
|
-
const lockPath =
|
|
30425
|
+
const lockPath = join28(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
30279
30426
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
30280
30427
|
const startedAt = Date.now();
|
|
30281
30428
|
while (true) {
|
|
@@ -30302,7 +30449,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
30302
30449
|
}
|
|
30303
30450
|
}
|
|
30304
30451
|
function analystLibraryIndexPath(ledgerHome) {
|
|
30305
|
-
return
|
|
30452
|
+
return join28(ledgerHome, "analyst", "library-index.json");
|
|
30306
30453
|
}
|
|
30307
30454
|
function rowFromIssueMetricsPage(page) {
|
|
30308
30455
|
return {
|
|
@@ -30596,7 +30743,7 @@ var init_analyst_cohort = __esm({
|
|
|
30596
30743
|
});
|
|
30597
30744
|
|
|
30598
30745
|
// src/archivist-record-pointer.ts
|
|
30599
|
-
import { basename as
|
|
30746
|
+
import { basename as basename13, join as join29 } from "node:path";
|
|
30600
30747
|
async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
30601
30748
|
const where = `${parentRunDirectory} officers`;
|
|
30602
30749
|
if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
|
|
@@ -30609,7 +30756,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
30609
30756
|
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
30610
30757
|
let sessionFile = raw.sessionFile;
|
|
30611
30758
|
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
30612
|
-
const leaf = parseRunLeaf(
|
|
30759
|
+
const leaf = parseRunLeaf(basename13(recordedRunDirectory));
|
|
30613
30760
|
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
30614
30761
|
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
30615
30762
|
const currentRunDirectory = await resolveLiveRunDirectoryPath(
|
|
@@ -30629,7 +30776,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
30629
30776
|
};
|
|
30630
30777
|
}
|
|
30631
30778
|
async function readBookedOfficerPointers(parentRunDirectory) {
|
|
30632
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
30779
|
+
const { records, diagnostics } = await readSitianRecords(join29(parentRunDirectory, RUN_HISTORY_FILE));
|
|
30633
30780
|
if (diagnostics.length > 0) {
|
|
30634
30781
|
throw new Error(
|
|
30635
30782
|
`${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
|
|
@@ -30912,7 +31059,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
30912
31059
|
|
|
30913
31060
|
// src/analyst-ledger.ts
|
|
30914
31061
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
30915
|
-
import { basename as
|
|
31062
|
+
import { basename as basename14, join as join30 } from "node:path";
|
|
30916
31063
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
30917
31064
|
return (await readRoleRunIdentity(runDirectory))?.state;
|
|
30918
31065
|
}
|
|
@@ -30932,7 +31079,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
30932
31079
|
}
|
|
30933
31080
|
}
|
|
30934
31081
|
async function classifyGhostCandidate(input) {
|
|
30935
|
-
const autopsy = await autopsyWriterLock(
|
|
31082
|
+
const autopsy = await autopsyWriterLock(join30(input.runDirectory, "writer.lock"));
|
|
30936
31083
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
30937
31084
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
30938
31085
|
return {
|
|
@@ -31222,7 +31369,7 @@ async function classifyScopedRun(input) {
|
|
|
31222
31369
|
async function scanAnalystIssueRuns(input) {
|
|
31223
31370
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
31224
31371
|
const scopeTicketNumber = input.ticketNumber;
|
|
31225
|
-
const booksRoot =
|
|
31372
|
+
const booksRoot = join30(ledgerHome, "books");
|
|
31226
31373
|
let wholeBook = false;
|
|
31227
31374
|
let scopeRootIdentity;
|
|
31228
31375
|
let bookNames;
|
|
@@ -31255,7 +31402,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
31255
31402
|
const ghostLegs = [];
|
|
31256
31403
|
const scopeConflicts = [];
|
|
31257
31404
|
for (const book of bookNames) {
|
|
31258
|
-
const bookDir =
|
|
31405
|
+
const bookDir = join30(booksRoot, book);
|
|
31259
31406
|
let runDirectories;
|
|
31260
31407
|
try {
|
|
31261
31408
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -31264,7 +31411,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
31264
31411
|
throw error;
|
|
31265
31412
|
}
|
|
31266
31413
|
for (const runDirectory of runDirectories) {
|
|
31267
|
-
const runName =
|
|
31414
|
+
const runName = basename14(runDirectory);
|
|
31268
31415
|
const parsed = parseRunLeaf(runName);
|
|
31269
31416
|
if (parsed === void 0) continue;
|
|
31270
31417
|
let scopeFields;
|
|
@@ -32001,7 +32148,7 @@ var init_analyst_metric_family = __esm({
|
|
|
32001
32148
|
});
|
|
32002
32149
|
|
|
32003
32150
|
// src/analyst-page.ts
|
|
32004
|
-
import { dirname as dirname17, join as
|
|
32151
|
+
import { dirname as dirname17, join as join31 } from "node:path";
|
|
32005
32152
|
function analystIssuePageKey(address) {
|
|
32006
32153
|
const parts = ["book", address.bookKey];
|
|
32007
32154
|
if (address.issueNumber !== void 0) {
|
|
@@ -32012,7 +32159,7 @@ function analystIssuePageKey(address) {
|
|
|
32012
32159
|
return sha256Hex(parts.join("\0")).slice(0, 32);
|
|
32013
32160
|
}
|
|
32014
32161
|
function analystIssuePagePath(ledgerHome, address) {
|
|
32015
|
-
return
|
|
32162
|
+
return join31(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
32016
32163
|
}
|
|
32017
32164
|
function analystIssuePageAddressFromPage(page) {
|
|
32018
32165
|
return {
|
|
@@ -32858,18 +33005,22 @@ function parseArgv(argv2) {
|
|
|
32858
33005
|
help
|
|
32859
33006
|
};
|
|
32860
33007
|
}
|
|
32861
|
-
function
|
|
32862
|
-
const
|
|
32863
|
-
|
|
32864
|
-
|
|
32865
|
-
}
|
|
32866
|
-
if (args.length > 2) {
|
|
33008
|
+
function parseResumeAddress(args) {
|
|
33009
|
+
const [ticketToken, seatToken, ...rest] = args;
|
|
33010
|
+
const ticketNumber = ticketToken === void 0 ? void 0 : parseAddressTicket(ticketToken);
|
|
33011
|
+
if (ticketNumber === void 0 || seatToken === void 0 || rest.length > 1) {
|
|
32867
33012
|
throw new CliUsageError(RESUME_USAGE_ERROR);
|
|
32868
33013
|
}
|
|
32869
|
-
|
|
32870
|
-
|
|
33014
|
+
const { seat, round } = parseSeatRound(seatToken);
|
|
33015
|
+
if (!isPublicCallableRole(seat) || round === "") {
|
|
33016
|
+
throw new CliUsageError(`${RESUME_USAGE_ERROR}; not a callable seat: ${seatToken}`);
|
|
32871
33017
|
}
|
|
32872
|
-
return {
|
|
33018
|
+
return {
|
|
33019
|
+
ticketNumber,
|
|
33020
|
+
seat,
|
|
33021
|
+
...round === void 0 ? {} : { round },
|
|
33022
|
+
...rest.length === 0 ? {} : { message: rest[0] }
|
|
33023
|
+
};
|
|
32873
33024
|
}
|
|
32874
33025
|
function invocationFromParsed(parsed) {
|
|
32875
33026
|
if (parsed.model === void 0 && parsed.thinking === void 0 && parsed.engine === void 0 && parsed.host === void 0) {
|
|
@@ -32978,7 +33129,7 @@ function renderHelp() {
|
|
|
32978
33129
|
"Host providers: ~/.ak-roles/host-providers.json (owner-edited; table > unique host directory > fail)",
|
|
32979
33130
|
"Model resolution: --model \u2192 persistent seat \u2192 officer inherit (#620); still none \u2192 error (#178)",
|
|
32980
33131
|
"Host resolution: --host \u2192 persistent seat host \u2192 pi (resume uses the same order; #617)",
|
|
32981
|
-
"Resume
|
|
33132
|
+
"Resume address: ak-role resume <ticket> <seat>[#<round>] [message]; --model/--thinking/--host/--engine go before <ticket> (before `resume` or between `resume` and <ticket>); the one argv after <seat> is always the opaque message, never a flag (#471)",
|
|
32982
33133
|
"Effective seats: ak-role roles"
|
|
32983
33134
|
);
|
|
32984
33135
|
return `${lines.join("\n")}
|
|
@@ -33370,28 +33521,34 @@ async function runAkRole(argv2, env) {
|
|
|
33370
33521
|
env = { ...env, freshSummons: true };
|
|
33371
33522
|
}
|
|
33372
33523
|
if (parsed.command === "resume") {
|
|
33373
|
-
|
|
33524
|
+
const address = parseResumeAddress(parsed.args);
|
|
33525
|
+
const runDirectory = locateTicketLeg(
|
|
33526
|
+
activationBookDirectory(
|
|
33527
|
+
resolveActivationLedgerHome(home),
|
|
33528
|
+
resolveBookKeyFromGit(env.cwd ?? process.cwd())
|
|
33529
|
+
),
|
|
33530
|
+
address
|
|
33531
|
+
);
|
|
33532
|
+
const resumeRequest = {
|
|
33533
|
+
runId: runIdFromRunDirectory(runDirectory),
|
|
33534
|
+
runDirectory,
|
|
33535
|
+
...address.message === void 0 ? {} : { message: address.message }
|
|
33536
|
+
};
|
|
33374
33537
|
resumeFailureContext = {
|
|
33375
33538
|
home,
|
|
33376
33539
|
runId: resumeRequest.runId,
|
|
33540
|
+
runDirectory,
|
|
33377
33541
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
33378
33542
|
};
|
|
33379
|
-
const runDirectory = await findRunDirectoryById(home, resumeRequest.runId);
|
|
33380
|
-
if (runDirectory !== void 0) {
|
|
33381
|
-
resumeRequest = { ...resumeRequest, runDirectory };
|
|
33382
|
-
resumeFailureContext = { ...resumeFailureContext, runDirectory };
|
|
33383
|
-
}
|
|
33384
33543
|
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
33385
|
-
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId, resumeRequest);
|
|
33386
|
-
const seatRole = resumeRole ?? "judge";
|
|
33387
33544
|
const seat = resolveEffectiveSeat(
|
|
33388
33545
|
parts.config,
|
|
33389
|
-
|
|
33546
|
+
address.seat,
|
|
33390
33547
|
parts.credentials,
|
|
33391
33548
|
invocationFromParsed(parsed)
|
|
33392
33549
|
);
|
|
33393
33550
|
const resumeEnv = createRoleEnvironment(env, {
|
|
33394
|
-
role:
|
|
33551
|
+
role: address.seat,
|
|
33395
33552
|
home,
|
|
33396
33553
|
agentDir: parts.agentDir,
|
|
33397
33554
|
cwd: parts.cwd,
|
|
@@ -33525,6 +33682,10 @@ var init_cli = __esm({
|
|
|
33525
33682
|
init_instruction_seat_run();
|
|
33526
33683
|
init_countersign_run();
|
|
33527
33684
|
init_analyst_run();
|
|
33685
|
+
init_activation_ledger_git();
|
|
33686
|
+
init_activation_ledger_topology();
|
|
33687
|
+
init_run_terminal_artifacts();
|
|
33688
|
+
init_ticket_address();
|
|
33528
33689
|
init_run_lifecycle();
|
|
33529
33690
|
init_registry();
|
|
33530
33691
|
init_settlement();
|
|
@@ -33538,18 +33699,18 @@ var init_cli = __esm({
|
|
|
33538
33699
|
])
|
|
33539
33700
|
);
|
|
33540
33701
|
PUBLIC_GLOBAL_OPTIONS = optionsForOwner("global");
|
|
33541
|
-
RESUME_USAGE_ERROR = "usage: ak-role resume <
|
|
33702
|
+
RESUME_USAGE_ERROR = "usage: ak-role resume <ticket> <seat>[#<round>] [message] (ticket is the bare number; put --model/--thinking/--host/--engine before <ticket>; the one argv after <seat> is the opaque message)";
|
|
33542
33703
|
}
|
|
33543
33704
|
});
|
|
33544
33705
|
|
|
33545
33706
|
// src/public-cli/main.ts
|
|
33546
|
-
import { existsSync as
|
|
33547
|
-
import { dirname as dirname18, join as
|
|
33707
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
33708
|
+
import { dirname as dirname18, join as join32 } from "node:path";
|
|
33548
33709
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
33549
33710
|
var here = dirname18(fileURLToPath2(import.meta.url));
|
|
33550
33711
|
function resolvePackageRoot(binDir) {
|
|
33551
|
-
const canonical =
|
|
33552
|
-
if (
|
|
33712
|
+
const canonical = join32(binDir, "..", "..");
|
|
33713
|
+
if (existsSync13(join32(canonical, "package.json"))) {
|
|
33553
33714
|
return canonical;
|
|
33554
33715
|
}
|
|
33555
33716
|
return binDir;
|