@akagilnc/pi-workflow-roles 0.1.6115 → 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.
Files changed (43) hide show
  1. package/README.md +3 -3
  2. package/README.zh-CN.md +3 -3
  3. package/dist/acp-host/production-host.js +354 -250
  4. package/dist/engine-detour-usage.js +2 -1
  5. package/dist/gatekeeper-role.js +3 -15
  6. package/dist/headless-host/production-host.js +339 -235
  7. package/dist/migrate-book-topology.js +39 -22
  8. package/dist/notary-source-run.js +8 -8
  9. package/dist/public-cli/auto-resume.js +3 -3
  10. package/dist/public-cli/cli.js +38 -32
  11. package/dist/public-cli/instruction-seat-run.js +2 -5
  12. package/dist/public-cli/main.js +310 -208
  13. package/dist/public-cli/option-definitions.js +22 -21
  14. package/dist/public-cli/run-lifecycle.js +27 -26
  15. package/dist/public-cli/seat-ticket-binding.js +2 -1
  16. package/dist/public-cli/settlement.js +33 -8
  17. package/dist/public-cli/terminal.js +13 -3
  18. package/dist/public-role-summons.js +1 -7
  19. package/dist/role-run-placement.js +1 -1
  20. package/dist/run-dossier-files.js +4 -2
  21. package/dist/submission-gate.js +3 -3
  22. package/dist/submission-ledger.js +29 -3
  23. package/dist/ticket-address.js +77 -0
  24. package/dist/ticket-progress.js +31 -0
  25. package/package.json +1 -1
  26. package/src/engine-detour-usage.ts +2 -1
  27. package/src/gatekeeper-role.ts +5 -18
  28. package/src/notary-source-run.ts +8 -8
  29. package/src/public-cli/auto-resume.ts +4 -3
  30. package/src/public-cli/cli.ts +53 -32
  31. package/src/public-cli/instruction-seat-run.ts +2 -5
  32. package/src/public-cli/option-definitions.ts +22 -21
  33. package/src/public-cli/run-lifecycle.ts +31 -31
  34. package/src/public-cli/seat-ticket-binding.ts +2 -1
  35. package/src/public-cli/settlement.ts +43 -7
  36. package/src/public-cli/terminal.ts +33 -14
  37. package/src/public-role-summons.ts +3 -15
  38. package/src/role-run-placement.ts +1 -1
  39. package/src/run-dossier-files.ts +5 -2
  40. package/src/submission-gate.ts +3 -2
  41. package/src/submission-ledger.ts +32 -2
  42. package/src/ticket-address.ts +91 -0
  43. package/src/ticket-progress.ts +42 -0
@@ -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 id ${runId}: ${matches.join(", ")}`);
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(
@@ -11927,6 +11929,13 @@ function currentReplyRows(terminal) {
11927
11929
  function adviceNavigatorFact(input) {
11928
11930
  return { disposition: "advice", prose: input.prose };
11929
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
+ }
11930
11939
  function formatTerminalResult(result) {
11931
11940
  const lines = [];
11932
11941
  lines.push("role outcome status");
@@ -11972,11 +11981,11 @@ function formatTerminalResult(result) {
11972
11981
  if (child.stderr !== void 0 && child.stderr !== "") {
11973
11982
  lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
11974
11983
  }
11984
+ const lens = result.reviewerChildren?.[axis];
11985
+ if (lens !== void 0) lines.push(...identityRows(lens));
11975
11986
  }
11976
11987
  }
11977
- if (result.runId !== void 0) {
11978
- lines.push(`run ${encodeTerminalField(result.runId)}`);
11979
- }
11988
+ lines.push(...identityRows(result));
11980
11989
  if (result.autoResumeCount !== void 0) {
11981
11990
  lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
11982
11991
  }
@@ -12114,15 +12123,7 @@ function projectOfficerPayloads(officer, payloads, fallbackStatus) {
12114
12123
  return projectOfficerDecision(officer, payloads[payloads.length - 1], fallbackStatus);
12115
12124
  }
12116
12125
  function officerRunIdFromSummoned(summoned) {
12117
- if (typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "") {
12118
- const fromDir = runIdFromRunDirectory(summoned.runDirectory);
12119
- if (fromDir !== void 0) return fromDir;
12120
- }
12121
- const terminal = summoned.terminal;
12122
- if (terminal !== void 0 && typeof terminal.runId === "string" && terminal.runId.trim() !== "") {
12123
- return terminal.runId;
12124
- }
12125
- return void 0;
12126
+ return summoned.runDirectory === void 0 ? void 0 : runIdFromRunDirectory(summoned.runDirectory);
12126
12127
  }
12127
12128
  function withOfficerRunId(result, summoned) {
12128
12129
  if (result.status !== "converged" && result.status !== "continue" && result.status !== "escalate" && result.status !== "needs_reask") {
@@ -13361,6 +13362,23 @@ function captureWorktreeHead(projectRoot) {
13361
13362
  return { head: "", fault: `git rev-parse HEAD threw cwd=${projectRoot}: ${message}` };
13362
13363
  }
13363
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
+ }
13364
13382
  function lensFromRunDirectory(runDirectory, role) {
13365
13383
  if (role !== "reviewer") return void 0;
13366
13384
  const lens = readPageSync(runDirectory, "admitted")?.lens;
@@ -13404,6 +13422,7 @@ function landTicketProgress(input) {
13404
13422
  mkdirSync3(dirname8(progressPath), { recursive: true });
13405
13423
  appendFileSync2(progressPath, `${JSON.stringify(line2)}
13406
13424
  `, "utf8");
13425
+ carryProgressRow(runDirectory, line2, input.call);
13407
13426
  if (input.sealHead.fault !== void 0) {
13408
13427
  process.stderr.write(`${input.sealHead.fault}
13409
13428
  `);
@@ -13451,6 +13470,7 @@ function relocateTicketProgressForLeg(input) {
13451
13470
  "utf8"
13452
13471
  );
13453
13472
  rmSync3(stagedPath, { force: true });
13473
+ for (const moved of movedLines) carryProgressRow(input.runDirectory, moved);
13454
13474
  }
13455
13475
  var CURRENT_FILENAME, RECEIPTS_DIRNAME, LEG_PROGRESS_FILENAME;
13456
13476
  var init_ticket_progress = __esm({
@@ -13461,6 +13481,9 @@ var init_ticket_progress = __esm({
13461
13481
  init_packaged_role_registry();
13462
13482
  init_role_run_placement();
13463
13483
  init_run_dossier();
13484
+ init_run_dossier_files();
13485
+ init_run_terminal_artifacts();
13486
+ init_sitian_facade();
13464
13487
  init_sitian_reader();
13465
13488
  init_unknown_value();
13466
13489
  CURRENT_FILENAME = "current.jsonl";
@@ -14050,8 +14073,66 @@ var init_uuidv7 = __esm({
14050
14073
  }
14051
14074
  });
14052
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
+
14053
14134
  // src/notary-source-run.ts
14054
- import { dirname as dirname10, isAbsolute as isAbsolute4, join as join14, resolve as resolve7, basename as basename8 } from "node:path";
14135
+ import { dirname as dirname10, isAbsolute as isAbsolute4, join as join15, resolve as resolve7, basename as basename8 } from "node:path";
14055
14136
  import { lstat as lstat2, realpath as realpath2 } from "node:fs/promises";
14056
14137
  async function readRetainedIdentity(runDirectory) {
14057
14138
  try {
@@ -14103,11 +14184,11 @@ async function resolveNotarySourceRunLocator(options) {
14103
14184
  const ledgerHome = resolveActivationLedgerHome(options.home);
14104
14185
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
14105
14186
  const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
14106
- const bookRunsRoot = join14(bookDirectory, "runs");
14187
+ const bookRunsRoot = join15(bookDirectory, "runs");
14107
14188
  let candidate;
14108
- const bare = parseRunLeaf(raw);
14109
- if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
14110
- candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join14(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
14189
+ const address = parseTicketLegLocator(raw);
14190
+ if (address !== void 0) {
14191
+ candidate = locateTicketLeg(bookDirectory, address);
14111
14192
  } else {
14112
14193
  candidate = isAbsolute4(raw) ? raw : resolve7(options.projectRoot, raw);
14113
14194
  const identity2 = parseRunLeaf(basename8(candidate));
@@ -14162,6 +14243,7 @@ var init_notary_source_run = __esm({
14162
14243
  init_activation_ledger_topology();
14163
14244
  init_run_lifecycle();
14164
14245
  init_role_run_placement();
14246
+ init_ticket_address();
14165
14247
  NotarySourceRunError = class extends Error {
14166
14248
  constructor(message, options) {
14167
14249
  super(message, options);
@@ -14631,7 +14713,7 @@ var init_option_definitions = __esm({
14631
14713
  owner: "auditor",
14632
14714
  canonical: "--source-run",
14633
14715
  aliases: [],
14634
- valueMetavar: "runId@role|path",
14716
+ valueMetavar: "ticket:seat#round|path",
14635
14717
  required: true,
14636
14718
  repeatable: false,
14637
14719
  form: "option",
@@ -14809,13 +14891,13 @@ var init_option_definitions = __esm({
14809
14891
  owner: "notary",
14810
14892
  canonical: "--source-run",
14811
14893
  aliases: [],
14812
- valueMetavar: "runId@role|path",
14894
+ valueMetavar: "ticket:seat#round|path",
14813
14895
  required: true,
14814
14896
  repeatable: false,
14815
14897
  form: "option",
14816
14898
  description: {
14817
- en: "Required source run locator (runId@role under the book home, 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.",
14818
- zh: "\u5FC5\u586B\u6E90 run \u5B9A\u4F4D\u7B26\uFF08\u7C3F\u5185 runId@role\uFF0C\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"
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"
14819
14901
  }
14820
14902
  }
14821
14903
  ];
@@ -14826,13 +14908,13 @@ var init_option_definitions = __esm({
14826
14908
  owner: "inspector",
14827
14909
  canonical: "--source-run",
14828
14910
  aliases: [],
14829
- valueMetavar: "runId@role|path",
14911
+ valueMetavar: "ticket:seat#round|path",
14830
14912
  required: false,
14831
14913
  repeatable: false,
14832
14914
  form: "option",
14833
14915
  description: {
14834
- en: "Optional audited source-run locator (runId@role or path). Gate summons always supply it; identity rides startup materials.",
14835
- zh: "\u53EF\u9009\u88AB\u5BA1\u817F\u5B9A\u4F4D\u7B26\uFF08runId@role \u6216\u8DEF\u5F84\uFF09\u3002\u95F8\u4F20\u53EC\u5FC5\u5E26\uFF1B\u8EAB\u4EFD\u5728\u542F\u52A8\u6750\u6599\u91CC\u3002"
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"
14836
14918
  }
14837
14919
  }
14838
14920
  ];
@@ -15127,10 +15209,10 @@ var init_option_definitions = __esm({
15127
15209
  auditor: {
15128
15210
  command: "auditor",
15129
15211
  summary: "Direct Auditor (\u5BA1\u5211\u9662) compliance audit: converged, continue, or escalate.",
15130
- usage: ["ak-role auditor --subject <judge|doctor> --source-run <runId@role|path> [options] [instruction]"],
15212
+ usage: ["ak-role auditor --subject <judge|doctor> --source-run <ticket:seat#round|path> [options] [instruction]"],
15131
15213
  examples: [
15132
- 'ak-role auditor --subject judge --source-run 01abc\u2026@judge --attach ./dossier "\u5BA1\uFF1A\u672C run \u662F\u5426\u5408\u89C4\u3002"',
15133
- 'ak-role auditor --subject doctor --source-run 01abc\u2026@doctor "\u5BA1\uFF1A\u592A\u533B\u5019\u9009\u662F\u5426\u5408\u89C4\u3002"'
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"'
15134
15216
  ]
15135
15217
  },
15136
15218
  diarist: {
@@ -15153,10 +15235,10 @@ var init_option_definitions = __esm({
15153
15235
  notary: {
15154
15236
  command: "notary",
15155
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.",
15156
- usage: ["ak-role notary --source-run <runId@role|path> [options]"],
15238
+ usage: ["ak-role notary --source-run <ticket:seat#round|path> [options]"],
15157
15239
  examples: [
15158
- "ak-role notary --source-run 01a034f1-75bf-71a6-bcf5-d1299145b1a5@judge",
15159
- "ak-role notary --source-run 01a034f1-75bf-71a6-bcf5-d1299145b1a5@countersign"
15240
+ "ak-role notary --source-run 1201:judge#2",
15241
+ "ak-role notary --source-run 1201:countersign#1"
15160
15242
  ]
15161
15243
  },
15162
15244
  analyst: {
@@ -15213,14 +15295,15 @@ var init_option_definitions = __esm({
15213
15295
  },
15214
15296
  resume: {
15215
15297
  command: "resume",
15216
- summary: "Resume a role run under the live seat table (model/host/engine); session principal must still exist. 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 <runId> (either before `resume` or between `resume` and <runId>); the one argv after <runId> is the opaque message, not a flag position (#471).",
15217
- usage: ["ak-role resume <runId> [message]"],
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]"],
15218
15300
  examples: [
15219
- "ak-role resume 01abc\u2026",
15220
- 'ak-role resume 01abc\u2026 "owner ruling"',
15221
- "ak-role --host grok-build resume 01abc\u2026",
15222
- "ak-role --engine agy resume 01abc\u2026",
15223
- 'ak-role resume --model xai/grok-4.5 01abc\u2026 "owner ruling"'
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"'
15224
15307
  ]
15225
15308
  },
15226
15309
  new: {
@@ -15229,7 +15312,7 @@ var init_option_definitions = __esm({
15229
15312
  usage: ["ak-role new <role> [options] \u2026"],
15230
15313
  examples: [
15231
15314
  'ak-role new countersign --attach ./ticket.md "\u88C1\uFF1A\u672C\u7968 #708 \u662F\u5426\u8DB3\u4EE5\u5F00\u5DE5\u3002"',
15232
- "ak-role new notary --source-run 01abc\u2026@countersign",
15315
+ "ak-role new notary --source-run 1201:countersign#1",
15233
15316
  "ak-role --host grok-build new inspector --attach ./change.patch"
15234
15317
  ]
15235
15318
  },
@@ -15252,14 +15335,14 @@ var init_option_definitions = __esm({
15252
15335
 
15253
15336
  // src/public-cli/invocation.ts
15254
15337
  import { execFileSync as execFileSync2 } from "node:child_process";
15255
- import { existsSync as existsSync4 } from "node:fs";
15338
+ import { existsSync as existsSync5 } from "node:fs";
15256
15339
  import {
15257
15340
  readFile as readFile9,
15258
15341
  realpath as realpath3,
15259
15342
  rename,
15260
15343
  writeFile as writeFile2
15261
15344
  } from "node:fs/promises";
15262
- import { dirname as dirname11, isAbsolute as isAbsolute5, join as join15, resolve as resolve8 } from "node:path";
15345
+ import { dirname as dirname11, isAbsolute as isAbsolute5, join as join16, resolve as resolve8 } from "node:path";
15263
15346
  function admittedSourceRunPath(admitted) {
15264
15347
  if (!isRecord(admitted)) return void 0;
15265
15348
  const path = admitted.sourceRunPath;
@@ -15437,7 +15520,7 @@ async function relocateRegisteredChildDiarists(input) {
15437
15520
  runId: childRunId,
15438
15521
  role: "diarist"
15439
15522
  }).runDirectory;
15440
- if (existsSync4(unboundChildDirectory)) {
15523
+ if (existsSync5(unboundChildDirectory)) {
15441
15524
  input.authority.seal(childTarget);
15442
15525
  await bindTicketNumberOnRunDirectory(unboundChildDirectory, input.ticketNumber);
15443
15526
  await rehomeUnboundTicketProvenance(
@@ -15461,7 +15544,7 @@ async function relocateRegisteredChildDiarists(input) {
15461
15544
  }
15462
15545
  continue;
15463
15546
  }
15464
- if (existsSync4(childTarget.runDirectory)) {
15547
+ if (existsSync5(childTarget.runDirectory)) {
15465
15548
  relocateTicketProgressForLeg({
15466
15549
  runDirectory: childTarget.runDirectory
15467
15550
  });
@@ -15559,7 +15642,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
15559
15642
  async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
15560
15643
  const rolePackageRoot = packageRoot2;
15561
15644
  const raw = JSON.parse(
15562
- await readFile9(join15(rolePackageRoot, "package.json"), "utf8")
15645
+ await readFile9(join16(rolePackageRoot, "package.json"), "utf8")
15563
15646
  );
15564
15647
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
15565
15648
  throw new Error(
@@ -16130,7 +16213,7 @@ async function admitPublicRole(role, parsed, env, override) {
16130
16213
  resolutionScope: [...derived.resolutionScope],
16131
16214
  authorizedChecks: []
16132
16215
  });
16133
- const mergerInputPath = join15(placed.runDirectory, "merger-input.json");
16216
+ const mergerInputPath = join16(placed.runDirectory, "merger-input.json");
16134
16217
  await writeFile2(
16135
16218
  mergerInputPath,
16136
16219
  `${JSON.stringify(mergerInput, null, 2)}
@@ -16398,7 +16481,7 @@ function parseDoctorIssueNumber(raw) {
16398
16481
  }
16399
16482
  async function resolveDoctorCaseRunsPath(options) {
16400
16483
  const ledgerHome = resolveActivationLedgerHome(options.home);
16401
- const defaultRuns = join15(
16484
+ const defaultRuns = join16(
16402
16485
  activationBookDirectory(ledgerHome, options.bookKey),
16403
16486
  String(options.issueNumber),
16404
16487
  "runs"
@@ -16800,8 +16883,21 @@ function rowFromPayload(kind, payload, accepted, roleFallback) {
16800
16883
  ...typeof payload.toolCallId === "string" && payload.toolCallId.length > 0 ? { toolCallId: payload.toolCallId } : {}
16801
16884
  };
16802
16885
  }
16803
- function mapOwnedToSubmissionRows(owned) {
16886
+ function mapOwnedToSubmissionRows(owned, leg = owned) {
16804
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
+ }
16805
16901
  const out = [];
16806
16902
  const indexByCall = /* @__PURE__ */ new Map();
16807
16903
  const roleByCall = /* @__PURE__ */ new Map();
@@ -16852,7 +16948,13 @@ function mapOwnedToSubmissionRows(owned) {
16852
16948
  if (kind === void 0 || original === void 0 || payload === void 0) continue;
16853
16949
  const callKey = typeof payload.toolCallId === "string" ? submissionCallKey(recordAttemptId(record), payload.toolCallId) : void 0;
16854
16950
  const fallback = callKey === void 0 ? void 0 : roleByCall.get(callKey);
16855
- take(rowFromPayload(kind, payload, original, fallback), callKey);
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);
16856
16958
  }
16857
16959
  return out;
16858
16960
  }
@@ -16865,7 +16967,7 @@ async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, homeOrScop
16865
16967
  if (attemptId.length === 0) return [];
16866
16968
  const scope = resolveReadScope(homeOrScope);
16867
16969
  const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
16868
- return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId));
16970
+ return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId), owned);
16869
16971
  }
16870
16972
  async function readSubmissionAttemptId(cwd, runId, toolCallId, homeOrScope) {
16871
16973
  const { owned } = await readOwnedSubmissionRecords(cwd, runId, resolveReadScope(homeOrScope));
@@ -16907,7 +17009,8 @@ function sealAcceptedSubmission(options) {
16907
17009
  accepted: options.accepted,
16908
17010
  sealHead,
16909
17011
  sessionFile: void 0,
16910
- instruction: options.instruction ?? ""
17012
+ instruction: options.instruction ?? "",
17013
+ call: { attemptId, toolCallId: options.toolCallId }
16911
17014
  });
16912
17015
  }
16913
17016
  var init_submission_ledger = __esm({
@@ -16919,6 +17022,7 @@ var init_submission_ledger = __esm({
16919
17022
  init_host_contracts();
16920
17023
  init_run_terminal_artifacts();
16921
17024
  init_sitian_facade();
17025
+ init_run_dossier_files();
16922
17026
  init_run_lifecycle();
16923
17027
  init_submission_correctable_error();
16924
17028
  init_report_ticket_tool();
@@ -17094,7 +17198,7 @@ var init_engine_detour_usage = __esm({
17094
17198
  });
17095
17199
 
17096
17200
  // src/dossier-resolution.ts
17097
- import { existsSync as existsSync5, statSync as statSync5 } from "node:fs";
17201
+ import { existsSync as existsSync6, statSync as statSync6 } from "node:fs";
17098
17202
  import { resolve as resolve9 } from "node:path";
17099
17203
  function isHostContext(value) {
17100
17204
  return "sessionManager" in value;
@@ -17114,7 +17218,7 @@ function resolveAuditDossier(source) {
17114
17218
  }
17115
17219
  const runDirectory = resolve9(raw);
17116
17220
  try {
17117
- if (!existsSync5(runDirectory) || !statSync5(runDirectory).isDirectory()) {
17221
+ if (!existsSync6(runDirectory) || !statSync6(runDirectory).isDirectory()) {
17118
17222
  return { status: "incomplete", observation: { kind: "missing-dossier" } };
17119
17223
  }
17120
17224
  } catch {
@@ -17283,6 +17387,7 @@ __export(settlement_exports, {
17283
17387
  exitCodeForTerminalOutcome: () => exitCodeForTerminalOutcome,
17284
17388
  explicitInternalKnownFailureClassificationInput: () => explicitInternalKnownFailureClassificationInput,
17285
17389
  extractNavigatorFact: () => extractNavigatorFact,
17390
+ filedIdentity: () => filedIdentity,
17286
17391
  formatCliDiagnostic: () => formatCliDiagnostic,
17287
17392
  formatErrorCauseDetail: () => formatErrorCauseDetail,
17288
17393
  formatFailureStderrDiagnostic: () => formatFailureStderrDiagnostic,
@@ -17304,6 +17409,7 @@ __export(settlement_exports, {
17304
17409
  trySettlePublicSeat: () => trySettlePublicSeat,
17305
17410
  withSubmissions: () => withSubmissions
17306
17411
  });
17412
+ import { basename as basename9, join as join17 } from "node:path";
17307
17413
  function sealedLedgerHome(admitted) {
17308
17414
  return homeFromRunDirectory(admitted.runDirectory);
17309
17415
  }
@@ -17362,6 +17468,17 @@ function ledgerReadScope(admitted, scope) {
17362
17468
  ...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
17363
17469
  };
17364
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
+ }
17365
17482
  function roleOutcomeFromRows(role, rows) {
17366
17483
  const mine = rows.filter((row) => row.role === role);
17367
17484
  const terminal = mine.filter(
@@ -17371,7 +17488,11 @@ function roleOutcomeFromRows(role, rows) {
17371
17488
  const payloads = mine.map((row) => row.accepted);
17372
17489
  const latest = terminal[terminal.length - 1];
17373
17490
  const submissionToolCallId = typeof latest.toolCallId === "string" && latest.toolCallId.length > 0 ? latest.toolCallId : void 0;
17374
- const belonging = submissionToolCallId === void 0 ? {} : { submissionToolCallId };
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
+ };
17375
17496
  if (latest.kind === "audit-escalation") {
17376
17497
  return {
17377
17498
  outcome: {
@@ -17538,7 +17659,7 @@ async function settleNoReceiptTerminal(admitted, authority, scope, facts) {
17538
17659
  scope
17539
17660
  ),
17540
17661
  artifacts: [],
17541
- runId: admitted.runId
17662
+ ...filedIdentity(admitted.runDirectory)
17542
17663
  }, coordinates.sessionDirectory, detourUsageContext(admitted, scope));
17543
17664
  }
17544
17665
  function coordinatesFromAdmitted(authority, admitted) {
@@ -18012,16 +18133,17 @@ async function settleSealedSeat(admitted, authority, scope, options) {
18012
18133
  entriesOf(read),
18013
18134
  settled.outcome,
18014
18135
  scope,
18015
- settled.submissionToolCallId
18136
+ settled.submissionToolCallId,
18137
+ settled.filed
18016
18138
  );
18017
18139
  }
18018
- async function finishLawfulSeat(admitted, coordinates, entries, roleOutcome, scope, submissionToolCallId) {
18140
+ async function finishLawfulSeat(admitted, coordinates, entries, roleOutcome, scope, submissionToolCallId, filed) {
18019
18141
  const artifacts = scope?.previewOnly === true ? [] : await publishDeclaredSeatTerminal(admitted, roleOutcome, coordinates, entries, scope);
18020
18142
  const terminal = await attachEngineDetourToolUsage({
18021
18143
  roleOutcome,
18022
18144
  navigator: isNavigatorSeat(admitted.role) ? NAVIGATOR_SEAT_OWN_FACT : extractNavigatorFact(entries),
18023
18145
  artifacts,
18024
- runId: admitted.runId,
18146
+ ...filedIdentity(admitted.runDirectory, filed),
18025
18147
  ...submissionToolCallId === void 0 || submissionToolCallId.length === 0 ? {} : { submissionToolCallId }
18026
18148
  }, coordinates.sessionDirectory, detourUsageContext(admitted, scope));
18027
18149
  return attachRecordedSubmissions(admitted, terminal, scope);
@@ -18187,7 +18309,7 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
18187
18309
  decisiveFacts
18188
18310
  };
18189
18311
  return attachEngineDetourToolUsage(
18190
- { roleOutcome, navigator, artifacts, runId: admitted.runId },
18312
+ { roleOutcome, navigator, artifacts, ...filedIdentity(admitted.runDirectory) },
18191
18313
  sessionDirectory,
18192
18314
  detourUsageContext(admitted, options)
18193
18315
  );
@@ -18254,6 +18376,7 @@ var init_settlement = __esm({
18254
18376
  "src/public-cli/settlement.ts"() {
18255
18377
  "use strict";
18256
18378
  init_role_run_placement();
18379
+ init_run_ticket_number();
18257
18380
  init_sitian_facade();
18258
18381
  init_run_terminal_artifacts();
18259
18382
  init_submission_ledger();
@@ -18289,12 +18412,12 @@ var init_settlement = __esm({
18289
18412
  });
18290
18413
 
18291
18414
  // src/external-host-turn-loop.ts
18292
- import { existsSync as existsSync6 } from "node:fs";
18293
- import { basename as basename9 } from "node:path";
18415
+ import { existsSync as existsSync7 } from "node:fs";
18416
+ import { basename as basename10 } from "node:path";
18294
18417
  async function syncTurnRequestLivePlacement(request, authority) {
18295
18418
  const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
18296
18419
  if (live === void 0) {
18297
- const parsed = parseRunLeaf(basename9(request.runDirectory));
18420
+ const parsed = parseRunLeaf(basename10(request.runDirectory));
18298
18421
  throw new Error(
18299
18422
  `admitted run ${parsed?.runId ?? "(unparseable)"} missing after host turn; not found under ${request.home}`
18300
18423
  );
@@ -18306,7 +18429,7 @@ async function syncTurnRequestLivePlacement(request, authority) {
18306
18429
  }
18307
18430
  async function retainPackageFaultBesideLivePlacement(request, input) {
18308
18431
  let runDirectory = request.runDirectory;
18309
- if (!existsSync6(runDirectory)) {
18432
+ if (!existsSync7(runDirectory)) {
18310
18433
  try {
18311
18434
  const found = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
18312
18435
  if (found === void 0) {
@@ -18354,7 +18477,7 @@ var init_external_host_turn_loop = __esm({
18354
18477
  });
18355
18478
 
18356
18479
  // src/session-identity.ts
18357
- import { join as join16 } from "node:path";
18480
+ import { join as join18 } from "node:path";
18358
18481
  function createSessionIdentityAuthority(authority, hostName) {
18359
18482
  const runDirectoryOf = (principal) => runDirectoryFromSessionDirectory(authority.decode(principal).sessionDirectory);
18360
18483
  return {
@@ -18364,7 +18487,7 @@ function createSessionIdentityAuthority(authority, hostName) {
18364
18487
  },
18365
18488
  async load(principal) {
18366
18489
  const runDirectory = runDirectoryOf(principal);
18367
- const { records, diagnostics } = await readSitianRecords(join16(runDirectory, RUN_STATE_FILE));
18490
+ const { records, diagnostics } = await readSitianRecords(join18(runDirectory, RUN_STATE_FILE));
18368
18491
  if (diagnostics.length > 0) {
18369
18492
  throw new Error(
18370
18493
  `${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
@@ -18434,14 +18557,14 @@ __export(role_turn_host_exports, {
18434
18557
  });
18435
18558
  import { execFile as execFile2, spawn } from "node:child_process";
18436
18559
  import { constants as constants2 } from "node:fs";
18437
- import { existsSync as existsSync7 } from "node:fs";
18560
+ import { existsSync as existsSync8 } from "node:fs";
18438
18561
  import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
18439
- import { delimiter, dirname as dirname12, isAbsolute as isAbsolute6, join as join17, resolve as resolve10 } from "node:path";
18562
+ import { delimiter, dirname as dirname12, isAbsolute as isAbsolute6, join as join19, resolve as resolve10 } from "node:path";
18440
18563
  import { platform } from "node:process";
18441
18564
  import { promisify as promisify2 } from "node:util";
18442
18565
  import { randomUUID as randomUUID4 } from "node:crypto";
18443
18566
  function resolveInternalRoleEntrypoint(packageRoot2) {
18444
- return join17(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
18567
+ return join19(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
18445
18568
  }
18446
18569
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
18447
18570
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -18631,7 +18754,7 @@ function createDefaultPiSpawnRunner(options) {
18631
18754
  homeFromRunDirectory(spawnDir)
18632
18755
  );
18633
18756
  } catch (resolveError) {
18634
- runDirectory = existsSync7(spawnDir) ? spawnDir : void 0;
18757
+ runDirectory = existsSync8(spawnDir) ? spawnDir : void 0;
18635
18758
  const resolveDiagnostic = `live run path resolve failed beside Pi transport fault: ${describeErrorIdentity(resolveError)}`;
18636
18759
  if (runDirectory !== void 0) {
18637
18760
  await retainPackageFault({
@@ -18920,17 +19043,17 @@ var init_navigator_lookup_host = __esm({
18920
19043
  });
18921
19044
 
18922
19045
  // src/public-cli/load-production-acp-host.ts
18923
- import { existsSync as existsSync8 } from "node:fs";
18924
- import { join as join18 } from "node:path";
19046
+ import { existsSync as existsSync9 } from "node:fs";
19047
+ import { join as join20 } from "node:path";
18925
19048
  import { pathToFileURL as pathToFileURL2 } from "node:url";
18926
19049
  async function loadProductionAcpHostFactory(packageRoot2, host) {
18927
19050
  const description = lookupHostDescription(host);
18928
19051
  if (description === void 0) {
18929
19052
  throw new Error(`unregistered host: ${host}`);
18930
19053
  }
18931
- const built = join18(packageRoot2, "dist/acp-host/production-host.js");
18932
- const source = join18(packageRoot2, "src/acp-host/production-host.ts");
18933
- const target = existsSync8(built) ? built : source;
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;
18934
19057
  const href = pathToFileURL2(target).href;
18935
19058
  const mod = await import(href);
18936
19059
  const create = mod.createProductionAcpRoleTurnHost;
@@ -18944,17 +19067,17 @@ var init_load_production_acp_host = __esm({
18944
19067
  });
18945
19068
 
18946
19069
  // src/public-cli/load-production-headless-host.ts
18947
- import { existsSync as existsSync9 } from "node:fs";
18948
- import { join as join19 } from "node:path";
19070
+ import { existsSync as existsSync10 } from "node:fs";
19071
+ import { join as join21 } from "node:path";
18949
19072
  import { pathToFileURL as pathToFileURL3 } from "node:url";
18950
19073
  async function loadProductionHeadlessHostFactory(packageRoot2, host) {
18951
19074
  const description = lookupHeadlessHostDescription(host);
18952
19075
  if (description === void 0) {
18953
19076
  throw new Error(`unregistered headless host: ${host}`);
18954
19077
  }
18955
- const built = join19(packageRoot2, "dist/headless-host/production-host.js");
18956
- const source = join19(packageRoot2, "src/headless-host/production-host.ts");
18957
- const target = existsSync9(built) ? built : source;
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;
18958
19081
  const href = pathToFileURL3(target).href;
18959
19082
  const mod = await import(href);
18960
19083
  const create = mod.createProductionHeadlessRoleTurnHost;
@@ -19368,7 +19491,7 @@ async function requireSubmissionGate(options) {
19368
19491
  officer: projected.officer,
19369
19492
  receipt: gatekeeper.submission ?? { reason: gatekeeper.reason },
19370
19493
  reason: gatekeeper.reason,
19371
- runId: projected.summoned?.terminal?.runId,
19494
+ runId: projected.summoned === void 0 ? void 0 : officerRunIdFromSummoned(projected.summoned),
19372
19495
  runDirectory: projected.summoned?.runDirectory,
19373
19496
  terminal: projected.summoned?.terminal
19374
19497
  });
@@ -19388,7 +19511,7 @@ async function requireSubmissionGate(options) {
19388
19511
  officer: projected.officer,
19389
19512
  receipt: gatekeeper.facts ?? { reason: gatekeeper.reason },
19390
19513
  reason: gatekeeper.reason,
19391
- runId: projected.summoned?.terminal?.runId,
19514
+ runId: projected.summoned === void 0 ? void 0 : officerRunIdFromSummoned(projected.summoned),
19392
19515
  runDirectory: projected.summoned?.runDirectory,
19393
19516
  terminal: projected.summoned?.terminal
19394
19517
  });
@@ -19420,7 +19543,7 @@ __export(auditor_soul_exports, {
19420
19543
  readAuditorResumeBinding: () => readAuditorResumeBinding,
19421
19544
  resolveAuditorSubject: () => resolveAuditorSubject
19422
19545
  });
19423
- import { basename as basename10 } from "node:path";
19546
+ import { basename as basename11 } from "node:path";
19424
19547
  function auditorSoulRelativePath(role) {
19425
19548
  return `souls/${role}-auditor.md`;
19426
19549
  }
@@ -19456,7 +19579,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
19456
19579
  return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
19457
19580
  }
19458
19581
  function subjectFromSourceDirectory(sourceRunDirectory) {
19459
- const role = parseRunLeaf(basename10(sourceRunDirectory))?.role;
19582
+ const role = parseRunLeaf(basename11(sourceRunDirectory))?.role;
19460
19583
  return isAuditorSoulRole(role) ? role : void 0;
19461
19584
  }
19462
19585
  async function readAuditorResumeBinding(admitted) {
@@ -19625,7 +19748,7 @@ function dispatchExceptionFailureTerminal(input) {
19625
19748
  },
19626
19749
  navigator: { disposition: "no-advice" },
19627
19750
  artifacts,
19628
- runId: input.runId,
19751
+ ...filedIdentity(input.runDirectory),
19629
19752
  autoResumeCount: input.autoResumeAttempts
19630
19753
  };
19631
19754
  }
@@ -19723,7 +19846,7 @@ async function runWithAutoResumeLoop(options) {
19723
19846
  options.admitted,
19724
19847
  dispatchExceptionFailureTerminal({
19725
19848
  role: options.admitted.role,
19726
- runId: options.admitted.runId,
19849
+ runDirectory: options.admitted.runDirectory,
19727
19850
  causeError: lastThrownError,
19728
19851
  errorFiles: retainedErrorFiles,
19729
19852
  autoResumeAttempts,
@@ -19773,12 +19896,12 @@ var init_auto_resume = __esm({
19773
19896
  });
19774
19897
 
19775
19898
  // src/public-cli/seat-ticket-binding.ts
19776
- import { join as join21 } from "node:path";
19899
+ import { join as join23 } from "node:path";
19777
19900
  function resumedSessionIdMissing(result, runId) {
19778
19901
  if (typeof result !== "object" || result === null) return false;
19779
19902
  const terminal = result.terminal;
19780
19903
  if (typeof terminal !== "object" || terminal === null) return false;
19781
- if (terminal.runId !== runId) return false;
19904
+ if (result.admitted?.runId !== runId) return false;
19782
19905
  const outcome = terminal.roleOutcome;
19783
19906
  if (typeof outcome !== "object" || outcome === null) return false;
19784
19907
  if (outcome.kind !== "failure") return false;
@@ -19787,7 +19910,7 @@ function resumedSessionIdMissing(result, runId) {
19787
19910
  return facts.errorCode === SESSION_ID_MISSING;
19788
19911
  }
19789
19912
  async function writerLockBlocksFreshSummons(runDirectory) {
19790
- const autopsy = await autopsyWriterLock(join21(runDirectory, WRITER_LOCK_FILE));
19913
+ const autopsy = await autopsyWriterLock(join23(runDirectory, WRITER_LOCK_FILE));
19791
19914
  return autopsy.verdict === "alive" || autopsy.verdict === "unknown";
19792
19915
  }
19793
19916
  async function tryResumeSameTicketSeatRun(input) {
@@ -21270,7 +21393,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
21270
21393
  const pass = chain.passes.at(-1);
21271
21394
  const officerTerminal = pass?.terminal;
21272
21395
  const officerRunDirectory = pass?.runDirectory;
21273
- const officerRunId = pass?.runId ?? (officerRunDirectory === void 0 ? void 0 : runIdFromRunDirectory(officerRunDirectory));
21396
+ const officerRunId = pass?.runId;
21274
21397
  if (officerTerminal !== void 0 && officerRunId !== void 0) {
21275
21398
  await presentAuditedOriginalVolume(turn, io);
21276
21399
  const officer = await loadResumablePublicRole(
@@ -21309,7 +21432,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
21309
21432
  if (chain.status === "escalate") {
21310
21433
  const escalation = chain.passes.at(-1);
21311
21434
  const escalatedRunDirectory = escalation?.runDirectory;
21312
- const escalatedRunId = escalation?.runId ?? (escalatedRunDirectory === void 0 ? void 0 : runIdFromRunDirectory(escalatedRunDirectory));
21435
+ const escalatedRunId = escalation?.runId;
21313
21436
  if (escalatedRunId === void 0) {
21314
21437
  return incompleteAuditWithoutOfficerVolume(
21315
21438
  turn,
@@ -21454,9 +21577,9 @@ __export(public_role_summons_exports, {
21454
21577
  summonPublicRole: () => summonPublicRole
21455
21578
  });
21456
21579
  import { execFile as execFile3 } from "node:child_process";
21457
- import { existsSync as existsSync10 } from "node:fs";
21580
+ import { existsSync as existsSync11 } from "node:fs";
21458
21581
  import { realpath as realpath5 } from "node:fs/promises";
21459
- import { join as join22 } from "node:path";
21582
+ import { join as join24 } from "node:path";
21460
21583
  import { promisify as promisify3 } from "node:util";
21461
21584
  function createCapturingIo() {
21462
21585
  const chunks = [];
@@ -21480,7 +21603,7 @@ function parentDir(path) {
21480
21603
  function walkPackageRoot(start) {
21481
21604
  let dir = start;
21482
21605
  for (let i = 0; i < 12; i += 1) {
21483
- if (existsSync10(join22(dir, "package.json")) && existsSync10(join22(dir, "souls"))) {
21606
+ if (existsSync11(join24(dir, "package.json")) && existsSync11(join24(dir, "souls"))) {
21484
21607
  return dir;
21485
21608
  }
21486
21609
  const parent = parentDir(dir);
@@ -21715,13 +21838,7 @@ async function summonPublicRole(options) {
21715
21838
  result = stepped.ok;
21716
21839
  }
21717
21840
  const stderr = captured?.stderrText();
21718
- let runDirectory = result.admitted?.runDirectory;
21719
- if (result.terminal !== void 0 && result.terminal.roleOutcome.role !== options.role && typeof result.terminal.runId === "string" && result.admitted?.runId !== result.terminal.runId) {
21720
- runDirectory = await (await Promise.resolve().then(() => (init_run_lifecycle(), run_lifecycle_exports))).findRunDirectoryById(
21721
- home,
21722
- result.terminal.runId
21723
- ) ?? runDirectory;
21724
- }
21841
+ const runDirectory = result.admitted?.runDirectory;
21725
21842
  return {
21726
21843
  exitCode: result.exitCode,
21727
21844
  ...result.terminal === void 0 ? {} : { terminal: result.terminal },
@@ -22023,7 +22140,7 @@ var init_compliance_transport = __esm({
22023
22140
  });
22024
22141
 
22025
22142
  // src/role-run-relocation.ts
22026
- import { dirname as dirname14, join as join23 } from "node:path";
22143
+ import { dirname as dirname14, join as join25 } from "node:path";
22027
22144
  async function retainedRunPathsMatch(recordedPath, currentPath, currentRunDirectory) {
22028
22145
  if (recordedPath === currentPath) return true;
22029
22146
  if (typeof recordedPath !== "string") return false;
@@ -22065,34 +22182,9 @@ var init_role_run_relocation = __esm({
22065
22182
  });
22066
22183
 
22067
22184
  // src/public-cli/run-lifecycle.ts
22068
- var run_lifecycle_exports = {};
22069
- __export(run_lifecycle_exports, {
22070
- AUTO_RESUME_LIMIT: () => AUTO_RESUME_LIMIT,
22071
- RunWriterLeaseHeldError: () => RunWriterLeaseHeldError,
22072
- WRITER_LOCK_FILE: () => WRITER_LOCK_FILE,
22073
- acquireRunWriterLease: () => acquireRunWriterLease,
22074
- autopsyWriterLock: () => autopsyWriterLock,
22075
- clearCurrentCourt: () => clearCurrentCourt,
22076
- describeErrorIdentity: () => describeErrorIdentity,
22077
- findLatestRunForSeatTicket: () => findLatestRunForSeatTicket,
22078
- findLatestRunIdForSeatTicket: () => findLatestRunIdForSeatTicket,
22079
- findRunDirectoryById: () => findRunDirectoryById,
22080
- loadResumablePublicRole: () => loadResumablePublicRole,
22081
- markRunAdmitted: () => markRunAdmitted,
22082
- markRunRunning: () => markRunRunning,
22083
- markRunTerminal: () => markRunTerminal,
22084
- peekRoleRunRole: () => peekRoleRunRole,
22085
- readCurrentCourt: () => readCurrentCourt,
22086
- readRoleRunIdentity: () => readRoleRunIdentity,
22087
- readRoleRunState: () => readRoleRunState,
22088
- readRunParentPath: () => readRunParentPath,
22089
- recordCurrentCourt: () => recordCurrentCourt,
22090
- resolveLiveRunDirectoryPath: () => resolveLiveRunDirectoryPath,
22091
- writeRoleRunState: () => writeRoleRunState
22092
- });
22093
- import { existsSync as existsSync11 } from "node:fs";
22185
+ import { existsSync as existsSync12 } from "node:fs";
22094
22186
  import { chmod, lstat as lstat3, open, readdir as readdir3, readFile as readFile10, unlink } from "node:fs/promises";
22095
- import { basename as basename11, join as join24 } from "node:path";
22187
+ import { basename as basename12, join as join26 } from "node:path";
22096
22188
  async function writeRoleRunState(runDirectory, record) {
22097
22189
  const payload = { ...record, runDirectory };
22098
22190
  writeSectionSync(runDirectory, "runState", { ...payload });
@@ -22387,7 +22479,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
22387
22479
  },
22388
22480
  relocate(nextRunDirectory) {
22389
22481
  currentRunDirectory = nextRunDirectory;
22390
- currentLockPath = join24(nextRunDirectory, WRITER_LOCK_FILE);
22482
+ currentLockPath = join26(nextRunDirectory, WRITER_LOCK_FILE);
22391
22483
  },
22392
22484
  async release() {
22393
22485
  if (released) return;
@@ -22426,10 +22518,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
22426
22518
  };
22427
22519
  const reportReadFailure = (error) => {
22428
22520
  reportDiagnostic(
22429
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join24(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
22521
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join26(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
22430
22522
  );
22431
22523
  };
22432
- const lockPath = join24(runDirectory, WRITER_LOCK_FILE);
22524
+ const lockPath = join26(runDirectory, WRITER_LOCK_FILE);
22433
22525
  let lastAutopsy = { verdict: "absent" };
22434
22526
  let lastReclaimFailure;
22435
22527
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -22485,17 +22577,17 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
22485
22577
  }
22486
22578
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRunDirectory) {
22487
22579
  if (typeof knownRunDirectory === "string" && knownRunDirectory.trim() !== "") {
22488
- const parsed = parseRunLeaf(basename11(knownRunDirectory));
22580
+ const parsed = parseRunLeaf(basename12(knownRunDirectory));
22489
22581
  if (parsed === void 0 || parsed.runId !== runId) {
22490
22582
  throw new CliUsageError(
22491
- `run directory does not match run id ${runId}: ${knownRunDirectory}`
22583
+ `run directory is not the expected role run: ${knownRunDirectory}`
22492
22584
  );
22493
22585
  }
22494
22586
  return knownRunDirectory;
22495
22587
  }
22496
22588
  if (runId.trim() === "") return void 0;
22497
22589
  const ledgerHome = resolveActivationLedgerHome(home);
22498
- const booksRoot = join24(ledgerHome, "books");
22590
+ const booksRoot = join26(ledgerHome, "books");
22499
22591
  let bookKeys;
22500
22592
  try {
22501
22593
  bookKeys = await readdir3(booksRoot);
@@ -22510,8 +22602,8 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
22510
22602
  );
22511
22603
  }
22512
22604
  async function resolveLiveRunDirectoryPath(recordedPath, home, onlyBookKey) {
22513
- if (existsSync11(recordedPath)) return recordedPath;
22514
- const parsed = parseRunLeaf(basename11(recordedPath));
22605
+ if (existsSync12(recordedPath)) return recordedPath;
22606
+ const parsed = parseRunLeaf(basename12(recordedPath));
22515
22607
  const bookKey = onlyBookKey ?? tryBookKeyFromAkRolesPath(recordedPath);
22516
22608
  if (parsed === void 0 || bookKey === void 0) return void 0;
22517
22609
  return findRunDirectoryById(home, parsed.runId, bookKey, parsed.role);
@@ -22532,10 +22624,6 @@ async function runHasFormedSessionPrincipal(runDirectory) {
22532
22624
  throw error;
22533
22625
  }
22534
22626
  }
22535
- async function findLatestRunIdForSeatTicket(input) {
22536
- const found = await findLatestRunForSeatTicket(input);
22537
- return found?.runId;
22538
- }
22539
22627
  async function findLatestRunForSeatTicket(input) {
22540
22628
  if (input.parentRunPath.trim() === "") {
22541
22629
  return void 0;
@@ -22545,7 +22633,7 @@ async function findLatestRunForSeatTicket(input) {
22545
22633
  let runDirectories;
22546
22634
  try {
22547
22635
  runDirectories = await listBookRunDirectories(
22548
- input.ticketNumber === void 0 ? bookDir : join24(bookDir, String(input.ticketNumber))
22636
+ input.ticketNumber === void 0 ? bookDir : join26(bookDir, String(input.ticketNumber))
22549
22637
  );
22550
22638
  } catch (error) {
22551
22639
  if (errorCodeOf(error) === "ENOENT") return void 0;
@@ -22553,7 +22641,7 @@ async function findLatestRunForSeatTicket(input) {
22553
22641
  }
22554
22642
  let best;
22555
22643
  for (const runDirectory of runDirectories) {
22556
- const parsed = parseRunLeaf(basename11(runDirectory));
22644
+ const parsed = parseRunLeaf(basename12(runDirectory));
22557
22645
  if (parsed === void 0 || parsed.role !== input.role) continue;
22558
22646
  const runId = parsed.runId;
22559
22647
  const parentPath = await readRunParentPath(runDirectory);
@@ -22580,15 +22668,15 @@ function restoredTicketFields(fields) {
22580
22668
  async function loadResumableRunRecord(home, runId, authority, knownRunDirectory) {
22581
22669
  const runDirectory = await findRunDirectoryById(home, runId, void 0, void 0, knownRunDirectory);
22582
22670
  if (runDirectory === void 0) {
22583
- throw new CliUsageError(`unknown role run id: ${runId}`);
22671
+ throw new CliUsageError(`unknown role run: no run directory found under ${home}`);
22584
22672
  }
22585
22673
  const disk = await readRoleRunStateDisk(runDirectory);
22586
22674
  if (disk === void 0) {
22587
- throw new CliUsageError(`unknown role run id: ${runId}`);
22675
+ throw new CliUsageError(`role run has no readable state: ${runDirectory}`);
22588
22676
  }
22589
22677
  const materialized = materializeRoleRunFromDisk(disk, authority);
22590
22678
  if (materialized === void 0) {
22591
- throw new CliUsageError(`unknown role run id: ${runId}`);
22679
+ throw new CliUsageError(`role run has no readable state: ${runDirectory}`);
22592
22680
  }
22593
22681
  const { run, principal } = materialized;
22594
22682
  let instruction = "";
@@ -22714,7 +22802,7 @@ async function loadResumableRunRecord(home, runId, authority, knownRunDirectory)
22714
22802
  } catch (error) {
22715
22803
  if (error instanceof CliUsageError) throw error;
22716
22804
  throw new CliUsageError(
22717
- `role run admitted request is unreadable: ${runId}`,
22805
+ `role run admitted request is unreadable: ${run.runDirectory}`,
22718
22806
  { cause: error }
22719
22807
  );
22720
22808
  }
@@ -22741,7 +22829,7 @@ async function loadResumableRunRecord(home, runId, authority, knownRunDirectory)
22741
22829
  }
22742
22830
  if (!isEnoent(error)) {
22743
22831
  throw new CliUsageError(
22744
- `role run invocation identity is unreadable: ${runId}`,
22832
+ `role run invocation identity is unreadable: ${run.runDirectory}`,
22745
22833
  { cause: error }
22746
22834
  );
22747
22835
  }
@@ -22823,7 +22911,7 @@ async function loadResumablePublicRole(home, runId, authority, options) {
22823
22911
  }
22824
22912
  function admitResumedRole(loaded) {
22825
22913
  const role = loaded.run.role;
22826
- const runId = loaded.run.runId;
22914
+ const leg = loaded.run.runDirectory;
22827
22915
  const record = packagedRoleMetadata(role);
22828
22916
  if (record === void 0) {
22829
22917
  throw new CliUsageError(`unknown role: ${role}`);
@@ -22854,10 +22942,10 @@ function admitResumedRole(loaded) {
22854
22942
  return admitted;
22855
22943
  }
22856
22944
  case "worker-task": {
22857
- const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, runId);
22945
+ const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, leg);
22858
22946
  if (fields.instruction.trim() === "") {
22859
22947
  throw new CliUsageError(
22860
- `role run admitted coder task is blank: ${runId}`
22948
+ `role run admitted coder task is blank: ${leg}`
22861
22949
  );
22862
22950
  }
22863
22951
  const admitted = {
@@ -22869,10 +22957,10 @@ function admitResumedRole(loaded) {
22869
22957
  return admitted;
22870
22958
  }
22871
22959
  case "worker-packet": {
22872
- const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, runId);
22960
+ const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, leg);
22873
22961
  if (fields.instruction.trim() === "") {
22874
22962
  throw new CliUsageError(
22875
- `role run admitted fixer instruction is blank: ${runId}`
22963
+ `role run admitted fixer instruction is blank: ${leg}`
22876
22964
  );
22877
22965
  }
22878
22966
  const admitted = {
@@ -22889,19 +22977,19 @@ function admitResumedRole(loaded) {
22889
22977
  const baseFault = admittedReviewerBaseFault(rawBase);
22890
22978
  if (baseFault !== void 0 || rawBase === void 0) {
22891
22979
  throw new CliUsageError(
22892
- baseFault === "damaged" ? `role run admitted reviewer base revision is damaged: ${runId}` : `role run admitted reviewer base revision is missing: ${runId}`
22980
+ baseFault === "damaged" ? `role run admitted reviewer base revision is damaged: ${leg}` : `role run admitted reviewer base revision is missing: ${leg}`
22893
22981
  );
22894
22982
  }
22895
22983
  const lens = fields.lens;
22896
22984
  if (!isReviewerLens(lens)) {
22897
22985
  throw new CliUsageError(
22898
- `role run admitted reviewer lens is missing: ${runId}`
22986
+ `role run admitted reviewer lens is missing: ${leg}`
22899
22987
  );
22900
22988
  }
22901
22989
  const authorityRefs = Object.freeze([...fields.authorityRefs ?? []]);
22902
22990
  if (authorityRefs.length === 0) {
22903
22991
  throw new CliUsageError(
22904
- `role run admitted reviewer authority refs are missing: ${runId}`
22992
+ `role run admitted reviewer authority refs are missing: ${leg}`
22905
22993
  );
22906
22994
  }
22907
22995
  const admitted = {
@@ -22917,7 +23005,7 @@ function admitResumedRole(loaded) {
22917
23005
  const baseRevision = fields.baseRevision;
22918
23006
  if (baseRevision === void 0 || baseRevision.trim() === "") {
22919
23007
  throw new CliUsageError(
22920
- `role run admitted gleaner-left base revision is missing: ${runId}`
23008
+ `role run admitted gleaner-left base revision is missing: ${leg}`
22921
23009
  );
22922
23010
  }
22923
23011
  const admitted = {
@@ -22931,18 +23019,18 @@ function admitResumedRole(loaded) {
22931
23019
  const mergerInputPath = fields.mergerInputPath;
22932
23020
  if (mergerInputPath === void 0) {
22933
23021
  throw new CliUsageError(
22934
- `role run admitted merger input path is missing: ${runId}`
23022
+ `role run admitted merger input path is missing: ${leg}`
22935
23023
  );
22936
23024
  }
22937
23025
  const derived = fields.derived;
22938
23026
  if (derived === void 0) {
22939
23027
  throw new CliUsageError(
22940
- `role run admitted merger envelope is missing: ${runId}`
23028
+ `role run admitted merger envelope is missing: ${leg}`
22941
23029
  );
22942
23030
  }
22943
23031
  if (fields.instruction.trim() === "") {
22944
23032
  throw new CliUsageError(
22945
- `role run admitted merger task is blank: ${runId}`
23033
+ `role run admitted merger task is blank: ${leg}`
22946
23034
  );
22947
23035
  }
22948
23036
  const admitted = {
@@ -22958,7 +23046,7 @@ function admitResumedRole(loaded) {
22958
23046
  const { prNumber, repository, repositoryDisplay } = fields;
22959
23047
  if (repository === void 0 || repositoryDisplay === void 0) {
22960
23048
  throw new CliUsageError(
22961
- `role run admitted collector repository identity is missing: ${runId}`
23049
+ `role run admitted collector repository identity is missing: ${leg}`
22962
23050
  );
22963
23051
  }
22964
23052
  let parsedRepository;
@@ -22970,7 +23058,7 @@ function admitResumedRole(loaded) {
22970
23058
  }
22971
23059
  if (parsedRepository.canonical !== repository) {
22972
23060
  throw new CliUsageError(
22973
- `role run admitted collector repository does not match its canonical form: ${runId}`
23061
+ `role run admitted collector repository does not match its canonical form: ${leg}`
22974
23062
  );
22975
23063
  }
22976
23064
  const admitted = {
@@ -22987,7 +23075,7 @@ function admitResumedRole(loaded) {
22987
23075
  const { issueNumber, caseRunsPath, caseIdentity } = fields;
22988
23076
  if (issueNumber === void 0 || caseRunsPath === void 0 || caseIdentity === void 0) {
22989
23077
  throw new CliUsageError(
22990
- `role run admitted doctor case identity is missing: ${runId}`
23078
+ `role run admitted doctor case identity is missing: ${leg}`
22991
23079
  );
22992
23080
  }
22993
23081
  const admitted = {
@@ -23003,7 +23091,7 @@ function admitResumedRole(loaded) {
23003
23091
  const { sourceRunPath, sourceRun } = fields;
23004
23092
  if (sourceRunPath === void 0 || sourceRun === void 0) {
23005
23093
  throw new CliUsageError(
23006
- `role run admitted notary source-run locator is missing: ${runId}`
23094
+ `role run admitted notary source-run locator is missing: ${leg}`
23007
23095
  );
23008
23096
  }
23009
23097
  const admitted = {
@@ -23016,13 +23104,13 @@ function admitResumedRole(loaded) {
23016
23104
  }
23017
23105
  }
23018
23106
  }
23019
- function resumedWorkerPhase(phase, phases, role, runId) {
23107
+ function resumedWorkerPhase(phase, phases, role, leg) {
23020
23108
  if (phase === "plan" || phase === "apply") {
23021
23109
  if (phases.some((item) => item === phase)) {
23022
23110
  return phase;
23023
23111
  }
23024
23112
  }
23025
- throw new CliUsageError(`role run admitted ${role} phase is missing: ${runId}`);
23113
+ throw new CliUsageError(`role run admitted ${role} phase is missing: ${leg}`);
23026
23114
  }
23027
23115
  var AUTO_RESUME_LIMIT, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
23028
23116
  var init_run_lifecycle = __esm({
@@ -30273,13 +30361,13 @@ var init_value2 = __esm({
30273
30361
  });
30274
30362
 
30275
30363
  // src/analyst-book-key.ts
30276
- import { statSync as statSync6 } from "node:fs";
30364
+ import { statSync as statSync7 } from "node:fs";
30277
30365
  import { isAbsolute as isAbsolute8 } from "node:path";
30278
30366
  function resolveAnalystBookKey(projectRoot) {
30279
30367
  const identity = physicalPathIdentity(projectRoot);
30280
30368
  let stats;
30281
30369
  try {
30282
- stats = statSync6(identity);
30370
+ stats = statSync7(identity);
30283
30371
  } catch (error) {
30284
30372
  const code = errnoCode(error);
30285
30373
  if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
@@ -30309,10 +30397,10 @@ var init_analyst_book_key = __esm({
30309
30397
  // src/atomic-write.ts
30310
30398
  import { randomUUID as randomUUID7 } from "node:crypto";
30311
30399
  import { rename as rename2, rm, writeFile as writeFile4 } from "node:fs/promises";
30312
- import { dirname as dirname15, join as join25 } from "node:path";
30400
+ import { dirname as dirname15, join as join27 } from "node:path";
30313
30401
  async function writeFileAtomically(destination, contents, options) {
30314
30402
  const parent = dirname15(destination);
30315
- const temporary = join25(parent, `.atomic-write-${randomUUID7()}.tmp`);
30403
+ const temporary = join27(parent, `.atomic-write-${randomUUID7()}.tmp`);
30316
30404
  try {
30317
30405
  await writeFile4(temporary, contents, options);
30318
30406
  await rename2(temporary, destination);
@@ -30329,12 +30417,12 @@ var init_atomic_write = __esm({
30329
30417
 
30330
30418
  // src/analyst-index.ts
30331
30419
  import { open as open2, readFile as readFile11, unlink as unlink2 } from "node:fs/promises";
30332
- import { dirname as dirname16, join as join26 } from "node:path";
30420
+ import { dirname as dirname16, join as join28 } from "node:path";
30333
30421
  import { setTimeout as sleep } from "node:timers/promises";
30334
30422
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
30335
30423
  const indexPath = analystLibraryIndexPath(ledgerHome);
30336
30424
  ensureRealDirectoryTree(ledgerHome, dirname16(indexPath));
30337
- const lockPath = join26(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
30425
+ const lockPath = join28(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
30338
30426
  assertLedgerFileInsideHome(lockPath, ledgerHome);
30339
30427
  const startedAt = Date.now();
30340
30428
  while (true) {
@@ -30361,7 +30449,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
30361
30449
  }
30362
30450
  }
30363
30451
  function analystLibraryIndexPath(ledgerHome) {
30364
- return join26(ledgerHome, "analyst", "library-index.json");
30452
+ return join28(ledgerHome, "analyst", "library-index.json");
30365
30453
  }
30366
30454
  function rowFromIssueMetricsPage(page) {
30367
30455
  return {
@@ -30655,7 +30743,7 @@ var init_analyst_cohort = __esm({
30655
30743
  });
30656
30744
 
30657
30745
  // src/archivist-record-pointer.ts
30658
- import { basename as basename12, join as join27 } from "node:path";
30746
+ import { basename as basename13, join as join29 } from "node:path";
30659
30747
  async function resolveOfficerPointer(raw, parentRunDirectory) {
30660
30748
  const where = `${parentRunDirectory} officers`;
30661
30749
  if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
@@ -30668,7 +30756,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
30668
30756
  let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
30669
30757
  let sessionFile = raw.sessionFile;
30670
30758
  const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
30671
- const leaf = parseRunLeaf(basename12(recordedRunDirectory));
30759
+ const leaf = parseRunLeaf(basename13(recordedRunDirectory));
30672
30760
  const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
30673
30761
  if (leaf !== void 0 && parentIdentity !== void 0) {
30674
30762
  const currentRunDirectory = await resolveLiveRunDirectoryPath(
@@ -30688,7 +30776,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
30688
30776
  };
30689
30777
  }
30690
30778
  async function readBookedOfficerPointers(parentRunDirectory) {
30691
- const { records, diagnostics } = await readSitianRecords(join27(parentRunDirectory, RUN_HISTORY_FILE));
30779
+ const { records, diagnostics } = await readSitianRecords(join29(parentRunDirectory, RUN_HISTORY_FILE));
30692
30780
  if (diagnostics.length > 0) {
30693
30781
  throw new Error(
30694
30782
  `${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
@@ -30971,7 +31059,7 @@ var init_analyst_gate_cycles_read = __esm({
30971
31059
 
30972
31060
  // src/analyst-ledger.ts
30973
31061
  import { readdir as readdir4 } from "node:fs/promises";
30974
- import { basename as basename13, join as join28 } from "node:path";
31062
+ import { basename as basename14, join as join30 } from "node:path";
30975
31063
  async function readExistingRunLifecycleState(runDirectory) {
30976
31064
  return (await readRoleRunIdentity(runDirectory))?.state;
30977
31065
  }
@@ -30991,7 +31079,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
30991
31079
  }
30992
31080
  }
30993
31081
  async function classifyGhostCandidate(input) {
30994
- const autopsy = await autopsyWriterLock(join28(input.runDirectory, "writer.lock"));
31082
+ const autopsy = await autopsyWriterLock(join30(input.runDirectory, "writer.lock"));
30995
31083
  const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
30996
31084
  if (leaseCheck === void 0) return { kind: "live" };
30997
31085
  return {
@@ -31281,7 +31369,7 @@ async function classifyScopedRun(input) {
31281
31369
  async function scanAnalystIssueRuns(input) {
31282
31370
  const ledgerHome = resolveActivationLedgerHome(input.home);
31283
31371
  const scopeTicketNumber = input.ticketNumber;
31284
- const booksRoot = join28(ledgerHome, "books");
31372
+ const booksRoot = join30(ledgerHome, "books");
31285
31373
  let wholeBook = false;
31286
31374
  let scopeRootIdentity;
31287
31375
  let bookNames;
@@ -31314,7 +31402,7 @@ async function scanAnalystIssueRuns(input) {
31314
31402
  const ghostLegs = [];
31315
31403
  const scopeConflicts = [];
31316
31404
  for (const book of bookNames) {
31317
- const bookDir = join28(booksRoot, book);
31405
+ const bookDir = join30(booksRoot, book);
31318
31406
  let runDirectories;
31319
31407
  try {
31320
31408
  runDirectories = await listBookRunDirectories(bookDir);
@@ -31323,7 +31411,7 @@ async function scanAnalystIssueRuns(input) {
31323
31411
  throw error;
31324
31412
  }
31325
31413
  for (const runDirectory of runDirectories) {
31326
- const runName = basename13(runDirectory);
31414
+ const runName = basename14(runDirectory);
31327
31415
  const parsed = parseRunLeaf(runName);
31328
31416
  if (parsed === void 0) continue;
31329
31417
  let scopeFields;
@@ -32060,7 +32148,7 @@ var init_analyst_metric_family = __esm({
32060
32148
  });
32061
32149
 
32062
32150
  // src/analyst-page.ts
32063
- import { dirname as dirname17, join as join29 } from "node:path";
32151
+ import { dirname as dirname17, join as join31 } from "node:path";
32064
32152
  function analystIssuePageKey(address) {
32065
32153
  const parts = ["book", address.bookKey];
32066
32154
  if (address.issueNumber !== void 0) {
@@ -32071,7 +32159,7 @@ function analystIssuePageKey(address) {
32071
32159
  return sha256Hex(parts.join("\0")).slice(0, 32);
32072
32160
  }
32073
32161
  function analystIssuePagePath(ledgerHome, address) {
32074
- return join29(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
32162
+ return join31(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
32075
32163
  }
32076
32164
  function analystIssuePageAddressFromPage(page) {
32077
32165
  return {
@@ -32917,18 +33005,22 @@ function parseArgv(argv2) {
32917
33005
  help
32918
33006
  };
32919
33007
  }
32920
- function parseResumeRequest(args) {
32921
- const runId = args[0];
32922
- if (runId === void 0 || runId.trim() === "" || runId.startsWith("-")) {
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) {
32923
33012
  throw new CliUsageError(RESUME_USAGE_ERROR);
32924
33013
  }
32925
- if (args.length > 2) {
32926
- throw new CliUsageError(RESUME_USAGE_ERROR);
32927
- }
32928
- if (args.length === 2) {
32929
- return { runId, message: args[1] };
33014
+ const { seat, round } = parseSeatRound(seatToken);
33015
+ if (!isPublicCallableRole(seat) || round === "") {
33016
+ throw new CliUsageError(`${RESUME_USAGE_ERROR}; not a callable seat: ${seatToken}`);
32930
33017
  }
32931
- return { runId };
33018
+ return {
33019
+ ticketNumber,
33020
+ seat,
33021
+ ...round === void 0 ? {} : { round },
33022
+ ...rest.length === 0 ? {} : { message: rest[0] }
33023
+ };
32932
33024
  }
32933
33025
  function invocationFromParsed(parsed) {
32934
33026
  if (parsed.model === void 0 && parsed.thinking === void 0 && parsed.engine === void 0 && parsed.host === void 0) {
@@ -33037,7 +33129,7 @@ function renderHelp() {
33037
33129
  "Host providers: ~/.ak-roles/host-providers.json (owner-edited; table > unique host directory > fail)",
33038
33130
  "Model resolution: --model \u2192 persistent seat \u2192 officer inherit (#620); still none \u2192 error (#178)",
33039
33131
  "Host resolution: --host \u2192 persistent seat host \u2192 pi (resume uses the same order; #617)",
33040
- "Resume flag position: --model/--thinking/--host/--engine go before <runId> (before `resume` or between `resume` and <runId>); the one argv after <runId> is always the opaque message, never a flag (#471)",
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)",
33041
33133
  "Effective seats: ak-role roles"
33042
33134
  );
33043
33135
  return `${lines.join("\n")}
@@ -33429,28 +33521,34 @@ async function runAkRole(argv2, env) {
33429
33521
  env = { ...env, freshSummons: true };
33430
33522
  }
33431
33523
  if (parsed.command === "resume") {
33432
- let resumeRequest = parseResumeRequest(parsed.args);
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
+ };
33433
33537
  resumeFailureContext = {
33434
33538
  home,
33435
33539
  runId: resumeRequest.runId,
33540
+ runDirectory,
33436
33541
  authority: env.principalAuthority ?? piDurablePrincipalAuthority
33437
33542
  };
33438
- const runDirectory = await findRunDirectoryById(home, resumeRequest.runId);
33439
- if (runDirectory !== void 0) {
33440
- resumeRequest = { ...resumeRequest, runDirectory };
33441
- resumeFailureContext = { ...resumeFailureContext, runDirectory };
33442
- }
33443
33543
  const parts = await loadPublicRoleDispatchParts(env, home);
33444
- const resumeRole = await peekRoleRunRole(home, resumeRequest.runId, resumeRequest);
33445
- const seatRole = resumeRole ?? "judge";
33446
33544
  const seat = resolveEffectiveSeat(
33447
33545
  parts.config,
33448
- seatRole,
33546
+ address.seat,
33449
33547
  parts.credentials,
33450
33548
  invocationFromParsed(parsed)
33451
33549
  );
33452
33550
  const resumeEnv = createRoleEnvironment(env, {
33453
- role: seatRole,
33551
+ role: address.seat,
33454
33552
  home,
33455
33553
  agentDir: parts.agentDir,
33456
33554
  cwd: parts.cwd,
@@ -33584,6 +33682,10 @@ var init_cli = __esm({
33584
33682
  init_instruction_seat_run();
33585
33683
  init_countersign_run();
33586
33684
  init_analyst_run();
33685
+ init_activation_ledger_git();
33686
+ init_activation_ledger_topology();
33687
+ init_run_terminal_artifacts();
33688
+ init_ticket_address();
33587
33689
  init_run_lifecycle();
33588
33690
  init_registry();
33589
33691
  init_settlement();
@@ -33597,18 +33699,18 @@ var init_cli = __esm({
33597
33699
  ])
33598
33700
  );
33599
33701
  PUBLIC_GLOBAL_OPTIONS = optionsForOwner("global");
33600
- RESUME_USAGE_ERROR = "usage: ak-role resume <runId> [message] (put --model/--thinking/--host/--engine before <runId>; the one argv after <runId> is the opaque message, #471)";
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)";
33601
33703
  }
33602
33704
  });
33603
33705
 
33604
33706
  // src/public-cli/main.ts
33605
- import { existsSync as existsSync12 } from "node:fs";
33606
- import { dirname as dirname18, join as join30 } from "node:path";
33707
+ import { existsSync as existsSync13 } from "node:fs";
33708
+ import { dirname as dirname18, join as join32 } from "node:path";
33607
33709
  import { fileURLToPath as fileURLToPath2 } from "node:url";
33608
33710
  var here = dirname18(fileURLToPath2(import.meta.url));
33609
33711
  function resolvePackageRoot(binDir) {
33610
- const canonical = join30(binDir, "..", "..");
33611
- if (existsSync12(join30(canonical, "package.json"))) {
33712
+ const canonical = join32(binDir, "..", "..");
33713
+ if (existsSync13(join32(canonical, "package.json"))) {
33612
33714
  return canonical;
33613
33715
  }
33614
33716
  return binDir;