@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.
Files changed (47) hide show
  1. package/README.md +3 -3
  2. package/README.zh-CN.md +3 -3
  3. package/dist/acp-host/production-host.js +442 -279
  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 +427 -264
  7. package/dist/migrate-book-topology.js +42 -22
  8. package/dist/notary-source-run.js +8 -8
  9. package/dist/package-contracts/fixer-output.js +3 -0
  10. package/dist/public-cli/auto-resume.js +3 -3
  11. package/dist/public-cli/cli.js +38 -32
  12. package/dist/public-cli/instruction-seat-run.js +52 -13
  13. package/dist/public-cli/invocation.js +22 -12
  14. package/dist/public-cli/main.js +398 -237
  15. package/dist/public-cli/option-definitions.js +22 -21
  16. package/dist/public-cli/run-lifecycle.js +27 -26
  17. package/dist/public-cli/seat-ticket-binding.js +2 -1
  18. package/dist/public-cli/settlement.js +33 -8
  19. package/dist/public-cli/terminal.js +13 -3
  20. package/dist/public-role-summons.js +1 -7
  21. package/dist/role-run-placement.js +1 -1
  22. package/dist/run-dossier-files.js +4 -2
  23. package/dist/submission-gate.js +3 -3
  24. package/dist/submission-ledger.js +29 -3
  25. package/dist/ticket-address.js +77 -0
  26. package/dist/ticket-progress.js +90 -14
  27. package/package.json +1 -1
  28. package/src/engine-detour-usage.ts +2 -1
  29. package/src/gatekeeper-role.ts +5 -18
  30. package/src/notary-source-run.ts +8 -8
  31. package/src/package-contracts/fixer-output.ts +4 -0
  32. package/src/public-cli/auto-resume.ts +4 -3
  33. package/src/public-cli/cli.ts +53 -32
  34. package/src/public-cli/instruction-seat-run.ts +55 -11
  35. package/src/public-cli/invocation.ts +31 -16
  36. package/src/public-cli/option-definitions.ts +22 -21
  37. package/src/public-cli/run-lifecycle.ts +31 -31
  38. package/src/public-cli/seat-ticket-binding.ts +2 -1
  39. package/src/public-cli/settlement.ts +43 -7
  40. package/src/public-cli/terminal.ts +33 -14
  41. package/src/public-role-summons.ts +3 -15
  42. package/src/role-run-placement.ts +1 -1
  43. package/src/run-dossier-files.ts +5 -2
  44. package/src/submission-gate.ts +3 -2
  45. package/src/submission-ledger.ts +32 -2
  46. package/src/ticket-address.ts +91 -0
  47. package/src/ticket-progress.ts +113 -15
@@ -554,7 +554,7 @@ var init_role_run_path_rewrite = __esm({
554
554
  });
555
555
 
556
556
  // src/run-dossier-files.ts
557
- var RUN_CURRENT_FILE, RUN_HISTORY_FILE, RUN_LOG_FILE, RUN_STATE_FILE, RUN_HISTORY_KINDS, OFFICER_POINTER_RECORD_KIND, RUN_STATE_KINDS;
557
+ 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;
558
558
  var init_run_dossier_files = __esm({
559
559
  "src/run-dossier-files.ts"() {
560
560
  "use strict";
@@ -570,8 +570,10 @@ var init_run_dossier_files = __esm({
570
570
  "post-seal-anomaly",
571
571
  "attempt-history",
572
572
  "turn-delivery",
573
- "officer-pointer"
573
+ "officer-pointer",
574
+ "progress"
574
575
  ]);
576
+ PROGRESS_RECORD_KIND = "progress";
575
577
  OFFICER_POINTER_RECORD_KIND = "officer-pointer";
576
578
  RUN_STATE_KINDS = /* @__PURE__ */ new Set([
577
579
  "invocation",
@@ -1297,7 +1299,7 @@ async function findRoleRunDirectory(bookDirectories, runId, onlyRole) {
1297
1299
  }
1298
1300
  if (matches.length === 0) return void 0;
1299
1301
  if (matches.length === 1) return matches[0];
1300
- throw new Error(`ambiguous role run id ${runId}: ${matches.join(", ")}`);
1302
+ throw new Error(`ambiguous role run: ${matches.join(", ")}`);
1301
1303
  }
1302
1304
  function roleRunPlacement(ledgerHome, input) {
1303
1305
  const subjectDirectory = "ticketNumber" in input.subject ? String(requireSafePositiveTicketNumber(
@@ -2091,6 +2093,9 @@ var init_fixer_output = __esm({
2091
2093
  classResults: Type8.Unknown({
2092
2094
  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"
2093
2095
  }),
2096
+ for: Type8.Unknown({
2097
+ 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"
2098
+ }),
2094
2099
  diffItems: diffItemsField,
2095
2100
  testEvidence: Type8.Unknown({
2096
2101
  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"
@@ -3566,6 +3571,13 @@ function currentReplyRows(terminal) {
3566
3571
  function adviceNavigatorFact(input) {
3567
3572
  return { disposition: "advice", prose: input.prose };
3568
3573
  }
3574
+ function identityRows(leg) {
3575
+ const seat = leg.roleOutcome.role;
3576
+ return [
3577
+ ...leg.ticket === void 0 ? [] : [`ticket ${leg.ticket}`],
3578
+ ...[...leg.receipts ?? []].reverse().map((filed) => `receipt ${encodeTerminalField(filed.round === void 0 ? seat : `${seat}#${filed.round}`)} ${encodeTerminalField(filed.receipt)}`)
3579
+ ];
3580
+ }
3569
3581
  function formatTerminalResult(result) {
3570
3582
  const lines = [];
3571
3583
  lines.push("role outcome status");
@@ -3611,11 +3623,11 @@ function formatTerminalResult(result) {
3611
3623
  if (child.stderr !== void 0 && child.stderr !== "") {
3612
3624
  lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
3613
3625
  }
3626
+ const lens = result.reviewerChildren?.[axis];
3627
+ if (lens !== void 0) lines.push(...identityRows(lens));
3614
3628
  }
3615
3629
  }
3616
- if (result.runId !== void 0) {
3617
- lines.push(`run ${encodeTerminalField(result.runId)}`);
3618
- }
3630
+ lines.push(...identityRows(result));
3619
3631
  if (result.autoResumeCount !== void 0) {
3620
3632
  lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
3621
3633
  }
@@ -3753,15 +3765,7 @@ function projectOfficerPayloads(officer, payloads, fallbackStatus) {
3753
3765
  return projectOfficerDecision(officer, payloads[payloads.length - 1], fallbackStatus);
3754
3766
  }
3755
3767
  function officerRunIdFromSummoned(summoned) {
3756
- if (typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "") {
3757
- const fromDir = runIdFromRunDirectory(summoned.runDirectory);
3758
- if (fromDir !== void 0) return fromDir;
3759
- }
3760
- const terminal = summoned.terminal;
3761
- if (terminal !== void 0 && typeof terminal.runId === "string" && terminal.runId.trim() !== "") {
3762
- return terminal.runId;
3763
- }
3764
- return void 0;
3768
+ return summoned.runDirectory === void 0 ? void 0 : runIdFromRunDirectory(summoned.runDirectory);
3765
3769
  }
3766
3770
  function withOfficerRunId(result, summoned) {
3767
3771
  if (result.status !== "converged" && result.status !== "continue" && result.status !== "escalate" && result.status !== "needs_reask") {
@@ -4777,15 +4781,11 @@ import {
4777
4781
  writeFileSync as writeFileSync2
4778
4782
  } from "node:fs";
4779
4783
  import { basename as basename7, dirname as dirname7, join as join9, relative as relative2, sep as sep3 } from "node:path";
4780
- function parseProgressText(text, pathForDiagnostic) {
4781
- if (text.trim() === "") return [];
4784
+ function decodeProgressFile(path) {
4785
+ if (!existsSync3(path)) return { lines: [], malformed: [] };
4786
+ const text = readFileSync2(path, "utf8");
4787
+ if (text.trim() === "") return { lines: [], malformed: [] };
4782
4788
  const { records, diagnostics } = parseSitianRecordText(text);
4783
- for (const diagnostic of diagnostics) {
4784
- process.stderr.write(
4785
- `[ticket-progress] ${pathForDiagnostic} has malformed row(s); keeps reachable rows and retains the diagnostic: line ${diagnostic.line}: ${diagnostic.error}
4786
- `
4787
- );
4788
- }
4789
4789
  const lines = [];
4790
4790
  for (const record of records) {
4791
4791
  const parsed = record;
@@ -4793,11 +4793,20 @@ function parseProgressText(text, pathForDiagnostic) {
4793
4793
  if (typeof parsed.seat !== "string" || typeof parsed.round !== "string") continue;
4794
4794
  lines.push(parsed);
4795
4795
  }
4796
- return lines;
4796
+ return {
4797
+ lines,
4798
+ malformed: diagnostics.map((diagnostic) => `line ${diagnostic.line}: ${diagnostic.error}`)
4799
+ };
4797
4800
  }
4798
4801
  function readProgressFile(path) {
4799
- if (!existsSync3(path)) return [];
4800
- return parseProgressText(readFileSync2(path, "utf8"), path);
4802
+ const { lines, malformed } = decodeProgressFile(path);
4803
+ for (const diagnostic of malformed) {
4804
+ process.stderr.write(
4805
+ `[ticket-progress] ${path} has malformed row(s); keeps reachable rows and retains the diagnostic: ${diagnostic}
4806
+ `
4807
+ );
4808
+ }
4809
+ return lines;
4801
4810
  }
4802
4811
  function readTicketProgressLines(subjectDirectory) {
4803
4812
  if (basename7(subjectDirectory) === "unbound") {
@@ -4853,6 +4862,26 @@ function statusAndSummaryFromPayload(payload) {
4853
4862
  ...summary === void 0 ? {} : { summary }
4854
4863
  };
4855
4864
  }
4865
+ function readAuditedRound(auditedRunDirectory) {
4866
+ try {
4867
+ const subjectDirectory = subjectDirectoryOfRun(auditedRunDirectory);
4868
+ if (subjectDirectory === void 0) return {};
4869
+ const path = join9(subjectDirectory, CURRENT_FILENAME);
4870
+ const { lines, malformed } = decodeProgressFile(path);
4871
+ if (malformed.length > 0) {
4872
+ throw new Error(`${path} has malformed row(s): ${malformed.join("; ")}`);
4873
+ }
4874
+ const receipts = `runs/${basename7(auditedRunDirectory)}/`;
4875
+ const latest = lines.filter((line2) => line2.receipt.startsWith(receipts)).at(-1);
4876
+ return latest === void 0 ? {} : { for: `${latest.seat}#${latest.round}` };
4877
+ } catch (error) {
4878
+ return { fault: `audited round unavailable for ${auditedRunDirectory}: ${errorText(error)}` };
4879
+ }
4880
+ }
4881
+ function forOfSealedRow(runDirectory, seat, payload) {
4882
+ const reported = packagedGateStageLabel(seat) !== void 0 ? readPageSync(runDirectory, "admitted")?.for : seat === "fixer" && isRecord(payload) ? payload.for : void 0;
4883
+ return typeof reported === "string" ? reported : void 0;
4884
+ }
4856
4885
  function captureWorktreeHead(projectRoot) {
4857
4886
  try {
4858
4887
  const result = spawnSync2("git", ["rev-parse", "HEAD"], {
@@ -4880,6 +4909,23 @@ function captureWorktreeHead(projectRoot) {
4880
4909
  return { head: "", fault: `git rev-parse HEAD threw cwd=${projectRoot}: ${message}` };
4881
4910
  }
4882
4911
  }
4912
+ function carryProgressRow(runDirectory, line2, call) {
4913
+ const runId = runIdFromRunDirectory(runDirectory);
4914
+ if (runId === void 0) return;
4915
+ sitianReport({
4916
+ level: "event",
4917
+ kind: PROGRESS_RECORD_KIND,
4918
+ subject: { runId, ...call === void 0 ? {} : { attemptId: call.attemptId } },
4919
+ payload: {
4920
+ type: PROGRESS_RECORD_KIND,
4921
+ ...call === void 0 ? {} : { toolCallId: call.toolCallId },
4922
+ receipt: line2.receipt,
4923
+ round: line2.round
4924
+ },
4925
+ source: "ticket-progress",
4926
+ sessionParent: sessionFileOf(runDirectory)
4927
+ });
4928
+ }
4883
4929
  function progressSessionAbsolute(runDirectory, context) {
4884
4930
  const host = typeof context.host === "string" ? context.host.trim() : "";
4885
4931
  const sessionDirectory = sessionDirectoryOf(runDirectory);
@@ -4905,6 +4951,7 @@ function landTicketProgressForSealedSubmission(input) {
4905
4951
  role: input.role,
4906
4952
  accepted: input.accepted,
4907
4953
  sealHead: input.sealHead,
4954
+ call: input.call,
4908
4955
  ...input.lens === void 0 ? {} : { lens: input.lens },
4909
4956
  sessionFile: progressSessionAbsolute(runDirectory, input.context),
4910
4957
  instruction: typeof input.context.summonsInstruction === "string" ? input.context.summonsInstruction : ""
@@ -4931,11 +4978,13 @@ function landTicketProgress(input) {
4931
4978
  const round = unbound ? "" : nextRoundFromLines(existing, input.role, lens);
4932
4979
  const sessionRelative = input.sessionFile === void 0 ? "" : relative2(subjectDirectory, input.sessionFile).split(sep3).join("/");
4933
4980
  const { status, summary } = statusAndSummaryFromPayload(input.accepted);
4981
+ const reviewed = forOfSealedRow(runDirectory, input.role, input.accepted);
4934
4982
  const instruction = input.instruction;
4935
4983
  const line2 = {
4936
4984
  at: (/* @__PURE__ */ new Date()).toISOString(),
4937
4985
  seat: input.role,
4938
4986
  round,
4987
+ ...reviewed === void 0 ? {} : { for: reviewed },
4939
4988
  instruction,
4940
4989
  head: input.sealHead.head,
4941
4990
  ...status === void 0 ? {} : { status },
@@ -4946,6 +4995,7 @@ function landTicketProgress(input) {
4946
4995
  mkdirSync3(dirname7(progressPath), { recursive: true });
4947
4996
  appendFileSync2(progressPath, `${JSON.stringify(line2)}
4948
4997
  `, "utf8");
4998
+ carryProgressRow(runDirectory, line2, input.call);
4949
4999
  if (input.sealHead.fault !== void 0) {
4950
5000
  process.stderr.write(`${input.sealHead.fault}
4951
5001
  `);
@@ -4993,6 +5043,7 @@ function relocateTicketProgressForLeg(input) {
4993
5043
  "utf8"
4994
5044
  );
4995
5045
  rmSync3(stagedPath, { force: true });
5046
+ for (const moved of movedLines) carryProgressRow(input.runDirectory, moved);
4996
5047
  }
4997
5048
  var CURRENT_FILENAME, RECEIPTS_DIRNAME, LEG_PROGRESS_FILENAME;
4998
5049
  var init_ticket_progress = __esm({
@@ -5003,6 +5054,9 @@ var init_ticket_progress = __esm({
5003
5054
  init_packaged_role_registry();
5004
5055
  init_role_run_placement();
5005
5056
  init_run_dossier();
5057
+ init_run_dossier_files();
5058
+ init_run_terminal_artifacts();
5059
+ init_sitian_facade();
5006
5060
  init_sitian_reader();
5007
5061
  init_unknown_value();
5008
5062
  CURRENT_FILENAME = "current.jsonl";
@@ -5742,8 +5796,66 @@ var init_uuidv7 = __esm({
5742
5796
  }
5743
5797
  });
5744
5798
 
5799
+ // src/ticket-address.ts
5800
+ import { existsSync as existsSync4, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
5801
+ import { join as join11 } from "node:path";
5802
+ function parseAddressTicket(token) {
5803
+ return parseTicketNumber(token.startsWith("#") ? token.slice(1) : token);
5804
+ }
5805
+ function parseSeatRound(token) {
5806
+ const hash = token.indexOf("#");
5807
+ return hash === -1 ? { seat: token } : { seat: token.slice(0, hash), round: token.slice(hash + 1) };
5808
+ }
5809
+ function parseTicketLegLocator(token) {
5810
+ const colon = token.indexOf(":");
5811
+ if (colon === -1) return void 0;
5812
+ const ticketNumber = parseAddressTicket(token.slice(0, colon));
5813
+ const { seat, round } = parseSeatRound(token.slice(colon + 1));
5814
+ if (ticketNumber === void 0 || seat === "" || round === void 0 || round === "") {
5815
+ return void 0;
5816
+ }
5817
+ return { ticketNumber, seat, round };
5818
+ }
5819
+ function locateTicketLeg(bookDirectory, input) {
5820
+ const ticketDirectory = join11(bookDirectory, String(input.ticketNumber));
5821
+ if (!existsSync4(ticketDirectory)) {
5822
+ throw new CliUsageError(`ticket ${input.ticketNumber} has no records in this project's book: ${ticketDirectory}`);
5823
+ }
5824
+ if (input.round !== void 0) {
5825
+ const row = readTicketProgressLines(ticketDirectory).find((line2) => line2.seat === input.seat && line2.round === input.round);
5826
+ if (row === void 0) {
5827
+ throw new CliUsageError(
5828
+ `ticket ${input.ticketNumber} has no progress row ${input.seat}#${input.round}`
5829
+ );
5830
+ }
5831
+ return join11(ticketDirectory, ...row.receipt.split("/").slice(0, 2));
5832
+ }
5833
+ const runsDirectory = join11(ticketDirectory, "runs");
5834
+ let latest;
5835
+ for (const entry of existsSync4(runsDirectory) ? readdirSync3(runsDirectory, { withFileTypes: true }) : []) {
5836
+ if (!entry.isDirectory() || parseRunLeaf(entry.name)?.role !== input.seat) continue;
5837
+ const { mtimeMs } = statSync4(join11(runsDirectory, entry.name));
5838
+ if (latest === void 0 || mtimeMs > latest.mtimeMs || mtimeMs === latest.mtimeMs && entry.name > latest.leaf) {
5839
+ latest = { leaf: entry.name, mtimeMs };
5840
+ }
5841
+ }
5842
+ if (latest === void 0) {
5843
+ throw new CliUsageError(`ticket ${input.ticketNumber} has no ${input.seat} leg`);
5844
+ }
5845
+ return join11(runsDirectory, latest.leaf);
5846
+ }
5847
+ var init_ticket_address = __esm({
5848
+ "src/ticket-address.ts"() {
5849
+ "use strict";
5850
+ init_cli_errors();
5851
+ init_role_run_placement();
5852
+ init_run_ticket_number();
5853
+ init_ticket_progress();
5854
+ }
5855
+ });
5856
+
5745
5857
  // src/notary-source-run.ts
5746
- import { dirname as dirname9, isAbsolute as isAbsolute4, join as join11, resolve as resolve7, basename as basename8 } from "node:path";
5858
+ import { dirname as dirname9, isAbsolute as isAbsolute4, join as join12, resolve as resolve7, basename as basename8 } from "node:path";
5747
5859
  import { lstat, realpath as realpath2 } from "node:fs/promises";
5748
5860
  async function readRetainedIdentity(runDirectory) {
5749
5861
  try {
@@ -5795,11 +5907,11 @@ async function resolveNotarySourceRunLocator(options) {
5795
5907
  const ledgerHome = resolveActivationLedgerHome(options.home);
5796
5908
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
5797
5909
  const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
5798
- const bookRunsRoot = join11(bookDirectory, "runs");
5910
+ const bookRunsRoot = join12(bookDirectory, "runs");
5799
5911
  let candidate;
5800
- const bare = parseRunLeaf(raw);
5801
- if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
5802
- candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join11(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
5912
+ const address = parseTicketLegLocator(raw);
5913
+ if (address !== void 0) {
5914
+ candidate = locateTicketLeg(bookDirectory, address);
5803
5915
  } else {
5804
5916
  candidate = isAbsolute4(raw) ? raw : resolve7(options.projectRoot, raw);
5805
5917
  const identity2 = parseRunLeaf(basename8(candidate));
@@ -5879,6 +5991,7 @@ var init_notary_source_run = __esm({
5879
5991
  init_activation_ledger_topology();
5880
5992
  init_run_lifecycle();
5881
5993
  init_role_run_placement();
5994
+ init_ticket_address();
5882
5995
  NotarySourceRunError = class extends Error {
5883
5996
  constructor(message, options) {
5884
5997
  super(message, options);
@@ -6410,7 +6523,7 @@ var init_option_definitions = __esm({
6410
6523
  owner: "auditor",
6411
6524
  canonical: "--source-run",
6412
6525
  aliases: [],
6413
- valueMetavar: "runId@role|path",
6526
+ valueMetavar: "ticket:seat#round|path",
6414
6527
  required: true,
6415
6528
  repeatable: false,
6416
6529
  form: "option",
@@ -6588,13 +6701,13 @@ var init_option_definitions = __esm({
6588
6701
  owner: "notary",
6589
6702
  canonical: "--source-run",
6590
6703
  aliases: [],
6591
- valueMetavar: "runId@role|path",
6704
+ valueMetavar: "ticket:seat#round|path",
6592
6705
  required: true,
6593
6706
  repeatable: false,
6594
6707
  form: "option",
6595
6708
  description: {
6596
- 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.",
6597
- 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"
6709
+ 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.",
6710
+ 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"
6598
6711
  }
6599
6712
  }
6600
6713
  ];
@@ -6605,13 +6718,13 @@ var init_option_definitions = __esm({
6605
6718
  owner: "inspector",
6606
6719
  canonical: "--source-run",
6607
6720
  aliases: [],
6608
- valueMetavar: "runId@role|path",
6721
+ valueMetavar: "ticket:seat#round|path",
6609
6722
  required: false,
6610
6723
  repeatable: false,
6611
6724
  form: "option",
6612
6725
  description: {
6613
- en: "Optional audited source-run locator (runId@role or path). Gate summons always supply it; identity rides startup materials.",
6614
- 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"
6726
+ en: "Optional audited source-run locator (<ticket>:<seat>#<round> or path). Gate summons always supply it; identity rides startup materials.",
6727
+ 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"
6615
6728
  }
6616
6729
  }
6617
6730
  ];
@@ -6906,10 +7019,10 @@ var init_option_definitions = __esm({
6906
7019
  auditor: {
6907
7020
  command: "auditor",
6908
7021
  summary: "Direct Auditor (\u5BA1\u5211\u9662) compliance audit: converged, continue, or escalate.",
6909
- usage: ["ak-role auditor --subject <judge|doctor> --source-run <runId@role|path> [options] [instruction]"],
7022
+ usage: ["ak-role auditor --subject <judge|doctor> --source-run <ticket:seat#round|path> [options] [instruction]"],
6910
7023
  examples: [
6911
- 'ak-role auditor --subject judge --source-run 01abc\u2026@judge --attach ./dossier "\u5BA1\uFF1A\u672C run \u662F\u5426\u5408\u89C4\u3002"',
6912
- 'ak-role auditor --subject doctor --source-run 01abc\u2026@doctor "\u5BA1\uFF1A\u592A\u533B\u5019\u9009\u662F\u5426\u5408\u89C4\u3002"'
7024
+ 'ak-role auditor --subject judge --source-run 1201:judge#2 --attach ./dossier "\u5BA1\uFF1A\u672C run \u662F\u5426\u5408\u89C4\u3002"',
7025
+ 'ak-role auditor --subject doctor --source-run 1201:doctor#1 "\u5BA1\uFF1A\u592A\u533B\u5019\u9009\u662F\u5426\u5408\u89C4\u3002"'
6913
7026
  ]
6914
7027
  },
6915
7028
  diarist: {
@@ -6932,10 +7045,10 @@ var init_option_definitions = __esm({
6932
7045
  notary: {
6933
7046
  command: "notary",
6934
7047
  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.",
6935
- usage: ["ak-role notary --source-run <runId@role|path> [options]"],
7048
+ usage: ["ak-role notary --source-run <ticket:seat#round|path> [options]"],
6936
7049
  examples: [
6937
- "ak-role notary --source-run 01a034f1-75bf-71a6-bcf5-d1299145b1a5@judge",
6938
- "ak-role notary --source-run 01a034f1-75bf-71a6-bcf5-d1299145b1a5@countersign"
7050
+ "ak-role notary --source-run 1201:judge#2",
7051
+ "ak-role notary --source-run 1201:countersign#1"
6939
7052
  ]
6940
7053
  },
6941
7054
  analyst: {
@@ -6992,14 +7105,15 @@ var init_option_definitions = __esm({
6992
7105
  },
6993
7106
  resume: {
6994
7107
  command: "resume",
6995
- 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).",
6996
- usage: ["ak-role resume <runId> [message]"],
7108
+ 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).",
7109
+ usage: ["ak-role resume <ticket> <seat>[#<round>] [message]"],
6997
7110
  examples: [
6998
- "ak-role resume 01abc\u2026",
6999
- 'ak-role resume 01abc\u2026 "owner ruling"',
7000
- "ak-role --host grok-build resume 01abc\u2026",
7001
- "ak-role --engine agy resume 01abc\u2026",
7002
- 'ak-role resume --model xai/grok-4.5 01abc\u2026 "owner ruling"'
7111
+ "ak-role resume 1201 judge",
7112
+ 'ak-role resume 1201 judge "owner ruling"',
7113
+ "ak-role resume 1201 'reviewer#2.correctness'",
7114
+ "ak-role --host grok-build resume 1201 fixer",
7115
+ "ak-role --engine agy resume 1201 fixer",
7116
+ 'ak-role resume --model xai/grok-4.5 1201 notary "owner ruling"'
7003
7117
  ]
7004
7118
  },
7005
7119
  new: {
@@ -7008,7 +7122,7 @@ var init_option_definitions = __esm({
7008
7122
  usage: ["ak-role new <role> [options] \u2026"],
7009
7123
  examples: [
7010
7124
  'ak-role new countersign --attach ./ticket.md "\u88C1\uFF1A\u672C\u7968 #708 \u662F\u5426\u8DB3\u4EE5\u5F00\u5DE5\u3002"',
7011
- "ak-role new notary --source-run 01abc\u2026@countersign",
7125
+ "ak-role new notary --source-run 1201:countersign#1",
7012
7126
  "ak-role --host grok-build new inspector --attach ./change.patch"
7013
7127
  ]
7014
7128
  },
@@ -7031,14 +7145,14 @@ var init_option_definitions = __esm({
7031
7145
 
7032
7146
  // src/public-cli/invocation.ts
7033
7147
  import { execFileSync as execFileSync2 } from "node:child_process";
7034
- import { existsSync as existsSync4 } from "node:fs";
7148
+ import { existsSync as existsSync5 } from "node:fs";
7035
7149
  import {
7036
7150
  readFile as readFile8,
7037
7151
  realpath as realpath3,
7038
7152
  rename,
7039
7153
  writeFile
7040
7154
  } from "node:fs/promises";
7041
- import { dirname as dirname10, isAbsolute as isAbsolute5, join as join12, resolve as resolve8 } from "node:path";
7155
+ import { dirname as dirname10, isAbsolute as isAbsolute5, join as join13, resolve as resolve8 } from "node:path";
7042
7156
  function admittedSourceRunPath(admitted) {
7043
7157
  if (!isRecord(admitted)) return void 0;
7044
7158
  const path = admitted.sourceRunPath;
@@ -7136,22 +7250,25 @@ async function mergeInvocationIdentityPage(runDirectory, fields) {
7136
7250
  ...fields
7137
7251
  }));
7138
7252
  }
7139
- async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubject) {
7140
- if (sourceRunPath.trim() === "") {
7141
- throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
7253
+ function persistAdmittedAuditedLeg(runDirectory, audited) {
7254
+ const { sourceRunPath, auditorSubject } = audited;
7255
+ if (sourceRunPath !== void 0 && sourceRunPath.trim() === "") {
7256
+ throw new Error("persistAdmittedAuditedLeg requires a non-empty sourceRunPath");
7142
7257
  }
7143
- updateSectionSync(admitted.runDirectory, "admitted", (current) => {
7144
- if (typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
7258
+ updateSectionSync(runDirectory, "admitted", (current) => {
7259
+ if (sourceRunPath !== void 0 && typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
7145
7260
  throw new Error(
7146
- `persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
7261
+ `persistAdmittedAuditedLeg refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
7147
7262
  );
7148
7263
  }
7149
- const sameSubject = auditorSubject === void 0 || current.auditorSubject === auditorSubject;
7150
- if (current.sourceRunPath === sourceRunPath && sameSubject) return void 0;
7264
+ const unchanged = current.for === audited.for && (sourceRunPath === void 0 || current.sourceRunPath === sourceRunPath) && (auditorSubject === void 0 || current.auditorSubject === auditorSubject);
7265
+ if (unchanged) return void 0;
7266
+ const { for: _replaced, ...rest } = current;
7151
7267
  return {
7152
- ...current,
7153
- sourceRunPath,
7154
- ...auditorSubject === void 0 ? {} : { auditorSubject }
7268
+ ...rest,
7269
+ ...sourceRunPath === void 0 ? {} : { sourceRunPath },
7270
+ ...auditorSubject === void 0 ? {} : { auditorSubject },
7271
+ ...audited.for === void 0 ? {} : { for: audited.for }
7155
7272
  };
7156
7273
  });
7157
7274
  }
@@ -7213,7 +7330,7 @@ async function relocateRegisteredChildDiarists(input) {
7213
7330
  runId: childRunId,
7214
7331
  role: "diarist"
7215
7332
  }).runDirectory;
7216
- if (existsSync4(unboundChildDirectory)) {
7333
+ if (existsSync5(unboundChildDirectory)) {
7217
7334
  input.authority.seal(childTarget);
7218
7335
  await bindTicketNumberOnRunDirectory(unboundChildDirectory, input.ticketNumber);
7219
7336
  await rehomeUnboundTicketProvenance(
@@ -7237,7 +7354,7 @@ async function relocateRegisteredChildDiarists(input) {
7237
7354
  }
7238
7355
  continue;
7239
7356
  }
7240
- if (existsSync4(childTarget.runDirectory)) {
7357
+ if (existsSync5(childTarget.runDirectory)) {
7241
7358
  relocateTicketProgressForLeg({
7242
7359
  runDirectory: childTarget.runDirectory
7243
7360
  });
@@ -7335,7 +7452,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
7335
7452
  async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
7336
7453
  const rolePackageRoot = packageRoot;
7337
7454
  const raw = JSON.parse(
7338
- await readFile8(join12(rolePackageRoot, "package.json"), "utf8")
7455
+ await readFile8(join13(rolePackageRoot, "package.json"), "utf8")
7339
7456
  );
7340
7457
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
7341
7458
  throw new Error(
@@ -7906,7 +8023,7 @@ async function admitPublicRole(role, parsed, env, override) {
7906
8023
  resolutionScope: [...derived.resolutionScope],
7907
8024
  authorizedChecks: []
7908
8025
  });
7909
- const mergerInputPath = join12(placed.runDirectory, "merger-input.json");
8026
+ const mergerInputPath = join13(placed.runDirectory, "merger-input.json");
7910
8027
  await writeFile(
7911
8028
  mergerInputPath,
7912
8029
  `${JSON.stringify(mergerInput, null, 2)}
@@ -8174,7 +8291,7 @@ function parseDoctorIssueNumber(raw) {
8174
8291
  }
8175
8292
  async function resolveDoctorCaseRunsPath(options) {
8176
8293
  const ledgerHome = resolveActivationLedgerHome(options.home);
8177
- const defaultRuns = join12(
8294
+ const defaultRuns = join13(
8178
8295
  activationBookDirectory(ledgerHome, options.bookKey),
8179
8296
  String(options.issueNumber),
8180
8297
  "runs"
@@ -8472,7 +8589,7 @@ var init_invocation = __esm({
8472
8589
 
8473
8590
  // src/report-ticket-tool.ts
8474
8591
  import { Type as Type16 } from "typebox";
8475
- import { existsSync as existsSync5 } from "node:fs";
8592
+ import { existsSync as existsSync6 } from "node:fs";
8476
8593
  function pageString(page, key) {
8477
8594
  const value = page?.[key];
8478
8595
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
@@ -8510,7 +8627,7 @@ async function reportTicketFromHostContext(context, ticketNumber, authority = pi
8510
8627
  if (runDirectory === void 0) {
8511
8628
  throw new Error("ak_report_ticket requires a per-turn run directory");
8512
8629
  }
8513
- if (!existsSync5(runDirectory)) {
8630
+ if (!existsSync6(runDirectory)) {
8514
8631
  throw new Error(`ak_report_ticket run directory missing: ${runDirectory}`);
8515
8632
  }
8516
8633
  const admitted = admittedForLiveTicketReport(runDirectory, authority);
@@ -8688,8 +8805,21 @@ function rowFromPayload(kind, payload, accepted, roleFallback) {
8688
8805
  ...typeof payload.toolCallId === "string" && payload.toolCallId.length > 0 ? { toolCallId: payload.toolCallId } : {}
8689
8806
  };
8690
8807
  }
8691
- function mapOwnedToSubmissionRows(owned) {
8808
+ function mapOwnedToSubmissionRows(owned, leg = owned) {
8692
8809
  const scoped = owned;
8810
+ const receiptByCall = /* @__PURE__ */ new Map();
8811
+ const roundByReceipt = /* @__PURE__ */ new Map();
8812
+ for (const record of leg) {
8813
+ if (record.kind !== PROGRESS_RECORD_KIND) continue;
8814
+ const payload = record.payload;
8815
+ if (typeof payload?.receipt !== "string") continue;
8816
+ if (typeof payload.toolCallId === "string") {
8817
+ receiptByCall.set(submissionCallKey(recordAttemptId(record), payload.toolCallId), payload.receipt);
8818
+ }
8819
+ if (typeof payload.round === "string" && payload.round !== "") {
8820
+ roundByReceipt.set(payload.receipt, payload.round);
8821
+ }
8822
+ }
8693
8823
  const out = [];
8694
8824
  const indexByCall = /* @__PURE__ */ new Map();
8695
8825
  const roleByCall = /* @__PURE__ */ new Map();
@@ -8740,7 +8870,13 @@ function mapOwnedToSubmissionRows(owned) {
8740
8870
  if (kind === void 0 || original === void 0 || payload === void 0) continue;
8741
8871
  const callKey = typeof payload.toolCallId === "string" ? submissionCallKey(recordAttemptId(record), payload.toolCallId) : void 0;
8742
8872
  const fallback = callKey === void 0 ? void 0 : roleByCall.get(callKey);
8743
- take(rowFromPayload(kind, payload, original, fallback), callKey);
8873
+ const receipt = kind === "accepted" && callKey !== void 0 ? receiptByCall.get(callKey) : void 0;
8874
+ const round = receipt === void 0 ? void 0 : roundByReceipt.get(receipt);
8875
+ take({
8876
+ ...rowFromPayload(kind, payload, original, fallback),
8877
+ ...receipt === void 0 ? {} : { receipt },
8878
+ ...round === void 0 ? {} : { round }
8879
+ }, callKey);
8744
8880
  }
8745
8881
  return out;
8746
8882
  }
@@ -8753,7 +8889,7 @@ async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, homeOrScop
8753
8889
  if (attemptId.length === 0) return [];
8754
8890
  const scope = resolveReadScope(homeOrScope);
8755
8891
  const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
8756
- return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId));
8892
+ return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId), owned);
8757
8893
  }
8758
8894
  async function readSubmissionAttemptId(cwd, runId, toolCallId, homeOrScope) {
8759
8895
  const { owned } = await readOwnedSubmissionRecords(cwd, runId, resolveReadScope(homeOrScope));
@@ -8829,7 +8965,8 @@ function sealAcceptedSubmission(options) {
8829
8965
  accepted: options.accepted,
8830
8966
  sealHead,
8831
8967
  sessionFile: void 0,
8832
- instruction: options.instruction ?? ""
8968
+ instruction: options.instruction ?? "",
8969
+ call: { attemptId, toolCallId: options.toolCallId }
8833
8970
  });
8834
8971
  }
8835
8972
  function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (error) => {
@@ -8951,7 +9088,8 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
8951
9088
  role,
8952
9089
  accepted: params,
8953
9090
  sealHead,
8954
- ...rawLens === "completeness" || rawLens === "correctness" ? { lens: rawLens } : {}
9091
+ ...rawLens === "completeness" || rawLens === "correctness" ? { lens: rawLens } : {},
9092
+ call: { attemptId, toolCallId }
8955
9093
  });
8956
9094
  const runDirectory = runDirectoryFromHostContext(context);
8957
9095
  if (context.host !== "claude" && context.host !== "codex" && runDirectory !== void 0 && isUnboundRunDirectory(runDirectory)) {
@@ -8984,6 +9122,7 @@ var init_submission_ledger = __esm({
8984
9122
  init_host_contracts();
8985
9123
  init_run_terminal_artifacts();
8986
9124
  init_sitian_facade();
9125
+ init_run_dossier_files();
8987
9126
  init_run_lifecycle();
8988
9127
  init_submission_correctable_error();
8989
9128
  init_report_ticket_tool();
@@ -9175,7 +9314,7 @@ var init_engine_detour_usage = __esm({
9175
9314
  });
9176
9315
 
9177
9316
  // src/dossier-resolution.ts
9178
- import { existsSync as existsSync6, statSync as statSync4 } from "node:fs";
9317
+ import { existsSync as existsSync7, statSync as statSync5 } from "node:fs";
9179
9318
  import { resolve as resolve9 } from "node:path";
9180
9319
  function isHostContext(value) {
9181
9320
  return "sessionManager" in value;
@@ -9195,7 +9334,7 @@ function resolveAuditDossier(source) {
9195
9334
  }
9196
9335
  const runDirectory = resolve9(raw);
9197
9336
  try {
9198
- if (!existsSync6(runDirectory) || !statSync4(runDirectory).isDirectory()) {
9337
+ if (!existsSync7(runDirectory) || !statSync5(runDirectory).isDirectory()) {
9199
9338
  return { status: "incomplete", observation: { kind: "missing-dossier" } };
9200
9339
  }
9201
9340
  } catch {
@@ -9478,6 +9617,7 @@ __export(settlement_exports, {
9478
9617
  exitCodeForTerminalOutcome: () => exitCodeForTerminalOutcome,
9479
9618
  explicitInternalKnownFailureClassificationInput: () => explicitInternalKnownFailureClassificationInput,
9480
9619
  extractNavigatorFact: () => extractNavigatorFact,
9620
+ filedIdentity: () => filedIdentity,
9481
9621
  formatCliDiagnostic: () => formatCliDiagnostic,
9482
9622
  formatErrorCauseDetail: () => formatErrorCauseDetail,
9483
9623
  formatFailureStderrDiagnostic: () => formatFailureStderrDiagnostic,
@@ -9499,6 +9639,7 @@ __export(settlement_exports, {
9499
9639
  trySettlePublicSeat: () => trySettlePublicSeat,
9500
9640
  withSubmissions: () => withSubmissions
9501
9641
  });
9642
+ import { basename as basename9, join as join14 } from "node:path";
9502
9643
  function sealedLedgerHome(admitted) {
9503
9644
  return homeFromRunDirectory(admitted.runDirectory);
9504
9645
  }
@@ -9557,6 +9698,17 @@ function ledgerReadScope(admitted, scope) {
9557
9698
  ...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
9558
9699
  };
9559
9700
  }
9701
+ function filedIdentity(runDirectory, filed = []) {
9702
+ const subjectDirectory = subjectDirectoryOfRun(runDirectory);
9703
+ if (subjectDirectory === void 0) return {};
9704
+ const ticket = parseTicketNumber(basename9(subjectDirectory));
9705
+ return {
9706
+ ...ticket === void 0 ? {} : { ticket },
9707
+ ...filed.length === 0 ? {} : {
9708
+ receipts: filed.map((row) => ({ ...row, receipt: join14(subjectDirectory, row.receipt) }))
9709
+ }
9710
+ };
9711
+ }
9560
9712
  function roleOutcomeFromRows(role, rows) {
9561
9713
  const mine = rows.filter((row) => row.role === role);
9562
9714
  const terminal = mine.filter(
@@ -9566,7 +9718,11 @@ function roleOutcomeFromRows(role, rows) {
9566
9718
  const payloads = mine.map((row) => row.accepted);
9567
9719
  const latest = terminal[terminal.length - 1];
9568
9720
  const submissionToolCallId = typeof latest.toolCallId === "string" && latest.toolCallId.length > 0 ? latest.toolCallId : void 0;
9569
- const belonging = submissionToolCallId === void 0 ? {} : { submissionToolCallId };
9721
+ const filed = mine.flatMap((row) => row.receipt === void 0 ? [] : [{ receipt: row.receipt, ...row.round === void 0 ? {} : { round: row.round } }]);
9722
+ const belonging = {
9723
+ ...submissionToolCallId === void 0 ? {} : { submissionToolCallId },
9724
+ filed
9725
+ };
9570
9726
  if (latest.kind === "audit-escalation") {
9571
9727
  return {
9572
9728
  outcome: {
@@ -9733,7 +9889,7 @@ async function settleNoReceiptTerminal(admitted, authority, scope, facts) {
9733
9889
  scope
9734
9890
  ),
9735
9891
  artifacts: [],
9736
- runId: admitted.runId
9892
+ ...filedIdentity(admitted.runDirectory)
9737
9893
  }, coordinates.sessionDirectory, detourUsageContext(admitted, scope));
9738
9894
  }
9739
9895
  function coordinatesFromAdmitted(authority, admitted) {
@@ -10207,16 +10363,17 @@ async function settleSealedSeat(admitted, authority, scope, options) {
10207
10363
  entriesOf(read),
10208
10364
  settled.outcome,
10209
10365
  scope,
10210
- settled.submissionToolCallId
10366
+ settled.submissionToolCallId,
10367
+ settled.filed
10211
10368
  );
10212
10369
  }
10213
- async function finishLawfulSeat(admitted, coordinates, entries, roleOutcome, scope, submissionToolCallId) {
10370
+ async function finishLawfulSeat(admitted, coordinates, entries, roleOutcome, scope, submissionToolCallId, filed) {
10214
10371
  const artifacts = scope?.previewOnly === true ? [] : await publishDeclaredSeatTerminal(admitted, roleOutcome, coordinates, entries, scope);
10215
10372
  const terminal = await attachEngineDetourToolUsage({
10216
10373
  roleOutcome,
10217
10374
  navigator: isNavigatorSeat(admitted.role) ? NAVIGATOR_SEAT_OWN_FACT : extractNavigatorFact(entries),
10218
10375
  artifacts,
10219
- runId: admitted.runId,
10376
+ ...filedIdentity(admitted.runDirectory, filed),
10220
10377
  ...submissionToolCallId === void 0 || submissionToolCallId.length === 0 ? {} : { submissionToolCallId }
10221
10378
  }, coordinates.sessionDirectory, detourUsageContext(admitted, scope));
10222
10379
  return attachRecordedSubmissions(admitted, terminal, scope);
@@ -10382,7 +10539,7 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
10382
10539
  decisiveFacts
10383
10540
  };
10384
10541
  return attachEngineDetourToolUsage(
10385
- { roleOutcome, navigator, artifacts, runId: admitted.runId },
10542
+ { roleOutcome, navigator, artifacts, ...filedIdentity(admitted.runDirectory) },
10386
10543
  sessionDirectory,
10387
10544
  detourUsageContext(admitted, options)
10388
10545
  );
@@ -10449,6 +10606,7 @@ var init_settlement = __esm({
10449
10606
  "src/public-cli/settlement.ts"() {
10450
10607
  "use strict";
10451
10608
  init_role_run_placement();
10609
+ init_run_ticket_number();
10452
10610
  init_sitian_facade();
10453
10611
  init_run_terminal_artifacts();
10454
10612
  init_submission_ledger();
@@ -10484,12 +10642,12 @@ var init_settlement = __esm({
10484
10642
  });
10485
10643
 
10486
10644
  // src/external-host-turn-loop.ts
10487
- import { existsSync as existsSync7 } from "node:fs";
10488
- import { basename as basename9 } from "node:path";
10645
+ import { existsSync as existsSync8 } from "node:fs";
10646
+ import { basename as basename10 } from "node:path";
10489
10647
  async function syncTurnRequestLivePlacement(request, authority) {
10490
10648
  const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
10491
10649
  if (live === void 0) {
10492
- const parsed = parseRunLeaf(basename9(request.runDirectory));
10650
+ const parsed = parseRunLeaf(basename10(request.runDirectory));
10493
10651
  throw new Error(
10494
10652
  `admitted run ${parsed?.runId ?? "(unparseable)"} missing after host turn; not found under ${request.home}`
10495
10653
  );
@@ -10508,7 +10666,7 @@ async function trySyncTurnRequestLivePlacement(request, authority) {
10508
10666
  }
10509
10667
  async function retainPackageFaultBesideLivePlacement(request, input) {
10510
10668
  let runDirectory = request.runDirectory;
10511
- if (!existsSync7(runDirectory)) {
10669
+ if (!existsSync8(runDirectory)) {
10512
10670
  try {
10513
10671
  const found = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
10514
10672
  if (found === void 0) {
@@ -10722,7 +10880,7 @@ var init_external_host_turn_loop = __esm({
10722
10880
  });
10723
10881
 
10724
10882
  // src/session-identity.ts
10725
- import { join as join13 } from "node:path";
10883
+ import { join as join15 } from "node:path";
10726
10884
  function createSessionIdentityAuthority(authority, hostName) {
10727
10885
  const runDirectoryOf = (principal) => runDirectoryFromSessionDirectory(authority.decode(principal).sessionDirectory);
10728
10886
  return {
@@ -10732,7 +10890,7 @@ function createSessionIdentityAuthority(authority, hostName) {
10732
10890
  },
10733
10891
  async load(principal) {
10734
10892
  const runDirectory = runDirectoryOf(principal);
10735
- const { records, diagnostics } = await readSitianRecords(join13(runDirectory, RUN_STATE_FILE));
10893
+ const { records, diagnostics } = await readSitianRecords(join15(runDirectory, RUN_STATE_FILE));
10736
10894
  if (diagnostics.length > 0) {
10737
10895
  throw new Error(
10738
10896
  `${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
@@ -10802,14 +10960,14 @@ __export(role_turn_host_exports, {
10802
10960
  });
10803
10961
  import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
10804
10962
  import { constants } from "node:fs";
10805
- import { existsSync as existsSync8 } from "node:fs";
10963
+ import { existsSync as existsSync9 } from "node:fs";
10806
10964
  import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
10807
- import { delimiter, dirname as dirname11, isAbsolute as isAbsolute6, join as join14, resolve as resolve11 } from "node:path";
10965
+ import { delimiter, dirname as dirname11, isAbsolute as isAbsolute6, join as join16, resolve as resolve11 } from "node:path";
10808
10966
  import { platform } from "node:process";
10809
10967
  import { promisify as promisify2 } from "node:util";
10810
10968
  import { randomUUID as randomUUID4 } from "node:crypto";
10811
10969
  function resolveInternalRoleEntrypoint(packageRoot) {
10812
- return join14(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
10970
+ return join16(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
10813
10971
  }
10814
10972
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
10815
10973
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -10999,7 +11157,7 @@ function createDefaultPiSpawnRunner(options) {
10999
11157
  homeFromRunDirectory(spawnDir)
11000
11158
  );
11001
11159
  } catch (resolveError) {
11002
- runDirectory = existsSync8(spawnDir) ? spawnDir : void 0;
11160
+ runDirectory = existsSync9(spawnDir) ? spawnDir : void 0;
11003
11161
  const resolveDiagnostic = `live run path resolve failed beside Pi transport fault: ${describeErrorIdentity(resolveError)}`;
11004
11162
  if (runDirectory !== void 0) {
11005
11163
  await retainPackageFault({
@@ -11201,8 +11359,8 @@ var init_role_turn_host = __esm({
11201
11359
  });
11202
11360
 
11203
11361
  // src/package-resources/engine-material.ts
11204
- import { existsSync as existsSync9, readFileSync as readFileSync3 } from "node:fs";
11205
- import { join as join15 } from "node:path";
11362
+ import { existsSync as existsSync10, readFileSync as readFileSync3 } from "node:fs";
11363
+ import { join as join17 } from "node:path";
11206
11364
  function pickEngineAxis(source) {
11207
11365
  return {
11208
11366
  ...source.engine === void 0 ? {} : { engine: source.engine },
@@ -11223,14 +11381,14 @@ function isEngineNameSyntax(name) {
11223
11381
  return true;
11224
11382
  }
11225
11383
  function resolveEngineMaterialDirectory(packageRoot) {
11226
- return join15(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
11384
+ return join17(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
11227
11385
  }
11228
11386
  function resolveEngineDispatchMaterialPath(packageRoot) {
11229
- return join15(packageRoot, ENGINE_DISPATCH_RELATIVE_PATH);
11387
+ return join17(packageRoot, ENGINE_DISPATCH_RELATIVE_PATH);
11230
11388
  }
11231
11389
  function resolveEngineMaterialPath(packageRoot, name) {
11232
11390
  const legal = assertLegalEngineName(name);
11233
- return join15(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
11391
+ return join17(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
11234
11392
  }
11235
11393
  function assertLegalEngineName(name) {
11236
11394
  if (!isEngineNameSyntax(name)) {
@@ -11247,12 +11405,12 @@ function engineSessionMaterialFromOptions(options) {
11247
11405
  const model = options.engineModel === void 0 ? void 0 : assertLegalEngineModel(options.engineModel);
11248
11406
  const materialPath = resolveEngineMaterialPath(options.packageRoot, name);
11249
11407
  const modelField = model === void 0 ? {} : { model };
11250
- if (!existsSync9(materialPath)) {
11408
+ if (!existsSync10(materialPath)) {
11251
11409
  return Object.freeze({ name, ...modelField });
11252
11410
  }
11253
11411
  const handbook = readFileSync3(materialPath, "utf8");
11254
11412
  const dispatchPath = resolveEngineDispatchMaterialPath(options.packageRoot);
11255
- const dispatchField = existsSync9(dispatchPath) ? { dispatchHandbook: readFileSync3(dispatchPath, "utf8") } : {};
11413
+ const dispatchField = existsSync10(dispatchPath) ? { dispatchHandbook: readFileSync3(dispatchPath, "utf8") } : {};
11256
11414
  return Object.freeze({ name, handbook, ...dispatchField, ...modelField });
11257
11415
  }
11258
11416
  function engineSessionReadingMaterial(engineMaterial) {
@@ -11415,7 +11573,7 @@ __export(config_exports, {
11415
11573
  validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
11416
11574
  });
11417
11575
  import { mkdir, readFile as readFile9, writeFile as writeFile2 } from "node:fs/promises";
11418
- import { dirname as dirname12, join as join16 } from "node:path";
11576
+ import { dirname as dirname12, join as join18 } from "node:path";
11419
11577
  function isGateOfficerSeat(value) {
11420
11578
  return packagedProvinceConfig(value);
11421
11579
  }
@@ -11423,7 +11581,7 @@ function publicCliConfigPath(home) {
11423
11581
  if (typeof home !== "string" || home.trim() === "") {
11424
11582
  throw new Error("home must be explicitly provided");
11425
11583
  }
11426
- return join16(home, ".ak-roles", "public-cli.json");
11584
+ return join18(home, ".ak-roles", "public-cli.json");
11427
11585
  }
11428
11586
  async function loadPublicCliConfig(home) {
11429
11587
  const path = publicCliConfigPath(home);
@@ -11883,11 +12041,11 @@ function credentialProvidersFromAuthData(data) {
11883
12041
  };
11884
12042
  }
11885
12043
  function resolvePublicAgentDir(explicit, home) {
11886
- return explicit ?? process.env.PI_CODING_AGENT_DIR ?? join16(home, ".pi", "agent");
12044
+ return explicit ?? process.env.PI_CODING_AGENT_DIR ?? join18(home, ".pi", "agent");
11887
12045
  }
11888
12046
  async function loadCredentialProviders(agentDir) {
11889
12047
  try {
11890
- const raw = await readFile9(join16(agentDir, "auth.json"), "utf8");
12048
+ const raw = await readFile9(join18(agentDir, "auth.json"), "utf8");
11891
12049
  return credentialProvidersFromAuthData(JSON.parse(raw));
11892
12050
  } catch (error) {
11893
12051
  if (isEnoent(error)) return { "openai-codex": false, xai: false };
@@ -11908,15 +12066,15 @@ var init_config = __esm({
11908
12066
 
11909
12067
  // src/public-cli/host-providers.ts
11910
12068
  import { readFileSync as readFileSync4 } from "node:fs";
11911
- import { join as join17 } from "node:path";
12069
+ import { join as join19 } from "node:path";
11912
12070
  function hostProvidersPath(home) {
11913
12071
  if (typeof home !== "string" || home.trim() === "") {
11914
12072
  throw new Error("home must be explicitly provided");
11915
12073
  }
11916
- return join17(home, ".ak-roles", "host-providers.json");
12074
+ return join19(home, ".ak-roles", "host-providers.json");
11917
12075
  }
11918
12076
  function hermesProviderModelsCachePath(home) {
11919
- return join17(home, ".hermes", "provider_models_cache.json");
12077
+ return join19(home, ".hermes", "provider_models_cache.json");
11920
12078
  }
11921
12079
  function parseHostProvidersTable(value) {
11922
12080
  if (!isRecord(value)) {
@@ -12066,17 +12224,17 @@ var init_host_providers = __esm({
12066
12224
  });
12067
12225
 
12068
12226
  // src/public-cli/load-production-acp-host.ts
12069
- import { existsSync as existsSync10 } from "node:fs";
12070
- import { join as join18 } from "node:path";
12227
+ import { existsSync as existsSync11 } from "node:fs";
12228
+ import { join as join20 } from "node:path";
12071
12229
  import { pathToFileURL as pathToFileURL2 } from "node:url";
12072
12230
  async function loadProductionAcpHostFactory(packageRoot, host) {
12073
12231
  const description = lookupHostDescription(host);
12074
12232
  if (description === void 0) {
12075
12233
  throw new Error(`unregistered host: ${host}`);
12076
12234
  }
12077
- const built = join18(packageRoot, "dist/acp-host/production-host.js");
12078
- const source = join18(packageRoot, "src/acp-host/production-host.ts");
12079
- const target = existsSync10(built) ? built : source;
12235
+ const built = join20(packageRoot, "dist/acp-host/production-host.js");
12236
+ const source = join20(packageRoot, "src/acp-host/production-host.ts");
12237
+ const target = existsSync11(built) ? built : source;
12080
12238
  const href = pathToFileURL2(target).href;
12081
12239
  const mod = await import(href);
12082
12240
  const create = mod.createProductionAcpRoleTurnHost;
@@ -12090,17 +12248,17 @@ var init_load_production_acp_host = __esm({
12090
12248
  });
12091
12249
 
12092
12250
  // src/public-cli/load-production-headless-host.ts
12093
- import { existsSync as existsSync11 } from "node:fs";
12094
- import { join as join19 } from "node:path";
12251
+ import { existsSync as existsSync12 } from "node:fs";
12252
+ import { join as join21 } from "node:path";
12095
12253
  import { pathToFileURL as pathToFileURL3 } from "node:url";
12096
12254
  async function loadProductionHeadlessHostFactory(packageRoot, host) {
12097
12255
  const description = lookupHeadlessHostDescription(host);
12098
12256
  if (description === void 0) {
12099
12257
  throw new Error(`unregistered headless host: ${host}`);
12100
12258
  }
12101
- const built = join19(packageRoot, "dist/headless-host/production-host.js");
12102
- const source = join19(packageRoot, "src/headless-host/production-host.ts");
12103
- const target = existsSync11(built) ? built : source;
12259
+ const built = join21(packageRoot, "dist/headless-host/production-host.js");
12260
+ const source = join21(packageRoot, "src/headless-host/production-host.ts");
12261
+ const target = existsSync12(built) ? built : source;
12104
12262
  const href = pathToFileURL3(target).href;
12105
12263
  const mod = await import(href);
12106
12264
  const create = mod.createProductionHeadlessRoleTurnHost;
@@ -12559,7 +12717,7 @@ async function requireSubmissionGate(options) {
12559
12717
  officer: projected.officer,
12560
12718
  receipt: gatekeeper.submission ?? { reason: gatekeeper.reason },
12561
12719
  reason: gatekeeper.reason,
12562
- runId: projected.summoned?.terminal?.runId,
12720
+ runId: projected.summoned === void 0 ? void 0 : officerRunIdFromSummoned(projected.summoned),
12563
12721
  runDirectory: projected.summoned?.runDirectory,
12564
12722
  terminal: projected.summoned?.terminal
12565
12723
  });
@@ -12579,7 +12737,7 @@ async function requireSubmissionGate(options) {
12579
12737
  officer: projected.officer,
12580
12738
  receipt: gatekeeper.facts ?? { reason: gatekeeper.reason },
12581
12739
  reason: gatekeeper.reason,
12582
- runId: projected.summoned?.terminal?.runId,
12740
+ runId: projected.summoned === void 0 ? void 0 : officerRunIdFromSummoned(projected.summoned),
12583
12741
  runDirectory: projected.summoned?.runDirectory,
12584
12742
  terminal: projected.summoned?.terminal
12585
12743
  });
@@ -12611,7 +12769,7 @@ __export(auditor_soul_exports, {
12611
12769
  readAuditorResumeBinding: () => readAuditorResumeBinding,
12612
12770
  resolveAuditorSubject: () => resolveAuditorSubject
12613
12771
  });
12614
- import { basename as basename10 } from "node:path";
12772
+ import { basename as basename11 } from "node:path";
12615
12773
  function auditorSoulRelativePath(role) {
12616
12774
  return `souls/${role}-auditor.md`;
12617
12775
  }
@@ -12647,7 +12805,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
12647
12805
  return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
12648
12806
  }
12649
12807
  function subjectFromSourceDirectory(sourceRunDirectory) {
12650
- const role = parseRunLeaf(basename10(sourceRunDirectory))?.role;
12808
+ const role = parseRunLeaf(basename11(sourceRunDirectory))?.role;
12651
12809
  return isAuditorSoulRole(role) ? role : void 0;
12652
12810
  }
12653
12811
  async function readAuditorResumeBinding(admitted) {
@@ -12689,20 +12847,20 @@ var init_auditor_soul = __esm({
12689
12847
  });
12690
12848
 
12691
12849
  // src/public-cli/machine-method-skills.ts
12692
- import { accessSync, constants as constants2, statSync as statSync5 } from "node:fs";
12850
+ import { accessSync, constants as constants2, statSync as statSync6 } from "node:fs";
12693
12851
  import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
12694
- import { join as join21 } from "node:path";
12852
+ import { join as join23 } from "node:path";
12695
12853
  import { spawnSync as spawnSync3 } from "node:child_process";
12696
12854
  function skillRoot(home) {
12697
- return join21(home, ".agents/skills");
12855
+ return join23(home, ".agents/skills");
12698
12856
  }
12699
12857
  function installedMethodSkillPath(home, name) {
12700
12858
  return installedSkillPath(skillRoot(home), name);
12701
12859
  }
12702
12860
  function installedSkillPath(root, name) {
12703
- const path = join21(root, name, "SKILL.md");
12861
+ const path = join23(root, name, "SKILL.md");
12704
12862
  try {
12705
- if (!statSync5(path).isFile()) return void 0;
12863
+ if (!statSync6(path).isFile()) return void 0;
12706
12864
  accessSync(path, constants2.R_OK);
12707
12865
  return path;
12708
12866
  } catch (error) {
@@ -12713,9 +12871,9 @@ function installedSkillPath(root, name) {
12713
12871
  }
12714
12872
  function linkedSkillRoot(home, host) {
12715
12873
  if (host === "claude" || host === "claude-code") {
12716
- return join21(process.env.CLAUDE_CONFIG_DIR?.trim() || join21(home, ".claude"), "skills");
12874
+ return join23(process.env.CLAUDE_CONFIG_DIR?.trim() || join23(home, ".claude"), "skills");
12717
12875
  }
12718
- if (host === "hermes") return join21(home, ".hermes/skills");
12876
+ if (host === "hermes") return join23(home, ".hermes/skills");
12719
12877
  return void 0;
12720
12878
  }
12721
12879
  async function occupied(path) {
@@ -12772,7 +12930,7 @@ async function runMachineSkillSetup(home, stdout) {
12772
12930
  const missingBySource = /* @__PURE__ */ new Map();
12773
12931
  let unsourced = false;
12774
12932
  for (const name of packagedMethodSkillNames()) {
12775
- const path = join21(canonical, name);
12933
+ const path = join23(canonical, name);
12776
12934
  if (await occupied(path)) {
12777
12935
  warnOccupied(path, stdout);
12778
12936
  continue;
@@ -12802,9 +12960,9 @@ async function runMachineSkillSetup(home, stdout) {
12802
12960
  throw error;
12803
12961
  }
12804
12962
  for (const name of packagedMethodSkillNames()) {
12805
- const target = join21(canonical, name);
12963
+ const target = join23(canonical, name);
12806
12964
  if (installedMethodSkillPath(home, name) === void 0) continue;
12807
- const link = join21(root, name);
12965
+ const link = join23(root, name);
12808
12966
  if (await occupied(link)) {
12809
12967
  warnOccupied(link, stdout);
12810
12968
  continue;
@@ -13063,7 +13221,7 @@ function dispatchExceptionFailureTerminal(input) {
13063
13221
  },
13064
13222
  navigator: { disposition: "no-advice" },
13065
13223
  artifacts,
13066
- runId: input.runId,
13224
+ ...filedIdentity(input.runDirectory),
13067
13225
  autoResumeCount: input.autoResumeAttempts
13068
13226
  };
13069
13227
  }
@@ -13161,7 +13319,7 @@ async function runWithAutoResumeLoop(options) {
13161
13319
  options.admitted,
13162
13320
  dispatchExceptionFailureTerminal({
13163
13321
  role: options.admitted.role,
13164
- runId: options.admitted.runId,
13322
+ runDirectory: options.admitted.runDirectory,
13165
13323
  causeError: lastThrownError,
13166
13324
  errorFiles: retainedErrorFiles,
13167
13325
  autoResumeAttempts,
@@ -14475,12 +14633,12 @@ var init_post_admission = __esm({
14475
14633
  });
14476
14634
 
14477
14635
  // src/public-cli/seat-ticket-binding.ts
14478
- import { join as join22 } from "node:path";
14636
+ import { join as join24 } from "node:path";
14479
14637
  function resumedSessionIdMissing(result, runId) {
14480
14638
  if (typeof result !== "object" || result === null) return false;
14481
14639
  const terminal = result.terminal;
14482
14640
  if (typeof terminal !== "object" || terminal === null) return false;
14483
- if (terminal.runId !== runId) return false;
14641
+ if (result.admitted?.runId !== runId) return false;
14484
14642
  const outcome = terminal.roleOutcome;
14485
14643
  if (typeof outcome !== "object" || outcome === null) return false;
14486
14644
  if (outcome.kind !== "failure") return false;
@@ -14489,7 +14647,7 @@ function resumedSessionIdMissing(result, runId) {
14489
14647
  return facts.errorCode === SESSION_ID_MISSING;
14490
14648
  }
14491
14649
  async function writerLockBlocksFreshSummons(runDirectory) {
14492
- const autopsy = await autopsyWriterLock(join22(runDirectory, WRITER_LOCK_FILE));
14650
+ const autopsy = await autopsyWriterLock(join24(runDirectory, WRITER_LOCK_FILE));
14493
14651
  return autopsy.verdict === "alive" || autopsy.verdict === "unknown";
14494
14652
  }
14495
14653
  async function tryResumeSameTicketSeatRun(input) {
@@ -15028,6 +15186,16 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
15028
15186
  else io.stdout(formatTerminalResult(terminal));
15029
15187
  return { exitCode: failed ? 1 : 0, terminal };
15030
15188
  }
15189
+ async function pinAuditedLegAtAdmission(officerRunDirectory, auditedRunDirectory, io, source) {
15190
+ const { for: auditedRound, fault } = readAuditedRound(auditedRunDirectory);
15191
+ persistAdmittedAuditedLeg(officerRunDirectory, { for: auditedRound, ...source });
15192
+ if (fault === void 0) return;
15193
+ await retainPackageFault({
15194
+ runDirectory: officerRunDirectory,
15195
+ diagnostic: fault,
15196
+ stderr: (text) => io.stderr(text)
15197
+ });
15198
+ }
15031
15199
  function resumeSameParentInstructionSeat(input) {
15032
15200
  return tryResumeSameTicketSeatRun({
15033
15201
  home: input.env.home,
@@ -15047,7 +15215,8 @@ function resumeSameParentInstructionSeat(input) {
15047
15215
  ...materials === void 0 ? {} : { summons: materials }
15048
15216
  },
15049
15217
  input.env,
15050
- input.io
15218
+ input.io,
15219
+ input.parentRunPath
15051
15220
  );
15052
15221
  }
15053
15222
  });
@@ -15123,7 +15292,9 @@ async function runCountersignBody(parsed, env, io) {
15123
15292
  );
15124
15293
  await markRunAdmitted(admitted, env.principalAuthority);
15125
15294
  if (gateParentRunPath !== void 0) {
15126
- await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
15295
+ await pinAuditedLegAtAdmission(admitted.runDirectory, gateParentRunPath, io, {
15296
+ sourceRunPath: gateParentRunPath
15297
+ });
15127
15298
  admitted = { ...admitted, sourceRunPath: gateParentRunPath };
15128
15299
  }
15129
15300
  const turnProjection = roleTurnOptions(env, admitted, {
@@ -15332,12 +15503,21 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
15332
15503
  throw error;
15333
15504
  }
15334
15505
  if (instructionSourceRunPath !== void 0) {
15335
- await persistAdmittedSourceRunPath(admitted, instructionSourceRunPath);
15506
+ await pinAuditedLegAtAdmission(admitted.runDirectory, instructionSourceRunPath, io, {
15507
+ sourceRunPath: instructionSourceRunPath
15508
+ });
15336
15509
  admitted = { ...admitted, sourceRunPath: instructionSourceRunPath };
15337
- }
15338
- if (record.sameParent === "subject-source" && auditorSource !== void 0) {
15339
- await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
15510
+ } else if (record.sameParent === "subject-source" && auditorSource !== void 0) {
15511
+ await pinAuditedLegAtAdmission(admitted.runDirectory, auditorSource, io, {
15512
+ sourceRunPath: auditorSource,
15513
+ auditorSubject
15514
+ });
15340
15515
  admitted = { ...admitted, sourceRunPath: auditorSource };
15516
+ } else {
15517
+ const auditedRunDirectory = admittedSourceRunPath(admitted);
15518
+ if (auditedRunDirectory !== void 0) {
15519
+ await pinAuditedLegAtAdmission(admitted.runDirectory, auditedRunDirectory, io);
15520
+ }
15341
15521
  }
15342
15522
  admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
15343
15523
  const runAdmitted = async () => {
@@ -15412,7 +15592,7 @@ async function inheritKnownTicketFromSource(admitted, authority) {
15412
15592
  await relocateAdmittedRunToTicket(admitted, authority);
15413
15593
  return admitted;
15414
15594
  }
15415
- async function runPublicInstructionSeatResume(request, env, io) {
15595
+ async function runPublicInstructionSeatResume(request, env, io, resummonedFor) {
15416
15596
  let selectedRequest = request;
15417
15597
  const resume = async () => {
15418
15598
  const held = [];
@@ -15443,6 +15623,9 @@ async function runPublicInstructionSeatResume(request, env, io) {
15443
15623
  return { ...loaded, admitted };
15444
15624
  },
15445
15625
  buildTurnRequest: async (admitted, effective) => {
15626
+ if (resummonedFor !== void 0) {
15627
+ await pinAuditedLegAtAdmission(admitted.runDirectory, resummonedFor, io);
15628
+ }
15446
15629
  const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
15447
15630
  const projection = resumeTurnRequestProjectionOptions(
15448
15631
  admitted,
@@ -15844,7 +16027,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
15844
16027
  const pass = chain.passes.at(-1);
15845
16028
  const officerTerminal = pass?.terminal;
15846
16029
  const officerRunDirectory = pass?.runDirectory;
15847
- const officerRunId = pass?.runId ?? (officerRunDirectory === void 0 ? void 0 : runIdFromRunDirectory(officerRunDirectory));
16030
+ const officerRunId = pass?.runId;
15848
16031
  if (officerTerminal !== void 0 && officerRunId !== void 0) {
15849
16032
  await presentAuditedOriginalVolume(turn, io);
15850
16033
  const officer = await loadResumablePublicRole(
@@ -15883,7 +16066,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
15883
16066
  if (chain.status === "escalate") {
15884
16067
  const escalation = chain.passes.at(-1);
15885
16068
  const escalatedRunDirectory = escalation?.runDirectory;
15886
- const escalatedRunId = escalation?.runId ?? (escalatedRunDirectory === void 0 ? void 0 : runIdFromRunDirectory(escalatedRunDirectory));
16069
+ const escalatedRunId = escalation?.runId;
15887
16070
  if (escalatedRunId === void 0) {
15888
16071
  return incompleteAuditWithoutOfficerVolume(
15889
16072
  turn,
@@ -15961,6 +16144,7 @@ var init_instruction_seat_run = __esm({
15961
16144
  init_terminal();
15962
16145
  init_turn_request();
15963
16146
  init_countersign_run();
16147
+ init_ticket_progress();
15964
16148
  init_unknown_value();
15965
16149
  AUDITED_ROLES = /* @__PURE__ */ new Set(["judge", "fixer", "coder", "secretariat", "countersign", "doctor"]);
15966
16150
  SECRETARIAT_STATUS_REASK = "status \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
@@ -16056,13 +16240,13 @@ var init_dialogue_command = __esm({
16056
16240
  });
16057
16241
 
16058
16242
  // src/analyst-book-key.ts
16059
- import { statSync as statSync6 } from "node:fs";
16243
+ import { statSync as statSync7 } from "node:fs";
16060
16244
  import { isAbsolute as isAbsolute7 } from "node:path";
16061
16245
  function resolveAnalystBookKey(projectRoot) {
16062
16246
  const identity = physicalPathIdentity(projectRoot);
16063
16247
  let stats;
16064
16248
  try {
16065
- stats = statSync6(identity);
16249
+ stats = statSync7(identity);
16066
16250
  } catch (error) {
16067
16251
  const code = errnoCode(error);
16068
16252
  if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
@@ -16092,10 +16276,10 @@ var init_analyst_book_key = __esm({
16092
16276
  // src/atomic-write.ts
16093
16277
  import { randomUUID as randomUUID7 } from "node:crypto";
16094
16278
  import { rename as rename2, rm, writeFile as writeFile3 } from "node:fs/promises";
16095
- import { dirname as dirname14, join as join23 } from "node:path";
16279
+ import { dirname as dirname14, join as join25 } from "node:path";
16096
16280
  async function writeFileAtomically(destination, contents, options) {
16097
16281
  const parent = dirname14(destination);
16098
- const temporary = join23(parent, `.atomic-write-${randomUUID7()}.tmp`);
16282
+ const temporary = join25(parent, `.atomic-write-${randomUUID7()}.tmp`);
16099
16283
  try {
16100
16284
  await writeFile3(temporary, contents, options);
16101
16285
  await rename2(temporary, destination);
@@ -16112,12 +16296,12 @@ var init_atomic_write = __esm({
16112
16296
 
16113
16297
  // src/analyst-index.ts
16114
16298
  import { open, readFile as readFile10, unlink } from "node:fs/promises";
16115
- import { dirname as dirname15, join as join24 } from "node:path";
16299
+ import { dirname as dirname15, join as join26 } from "node:path";
16116
16300
  import { setTimeout as sleep } from "node:timers/promises";
16117
16301
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
16118
16302
  const indexPath = analystLibraryIndexPath(ledgerHome);
16119
16303
  ensureRealDirectoryTree(ledgerHome, dirname15(indexPath));
16120
- const lockPath = join24(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
16304
+ const lockPath = join26(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
16121
16305
  assertLedgerFileInsideHome(lockPath, ledgerHome);
16122
16306
  const startedAt = Date.now();
16123
16307
  while (true) {
@@ -16144,7 +16328,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
16144
16328
  }
16145
16329
  }
16146
16330
  function analystLibraryIndexPath(ledgerHome) {
16147
- return join24(ledgerHome, "analyst", "library-index.json");
16331
+ return join26(ledgerHome, "analyst", "library-index.json");
16148
16332
  }
16149
16333
  function rowFromIssueMetricsPage(page) {
16150
16334
  return {
@@ -16438,7 +16622,7 @@ var init_analyst_cohort = __esm({
16438
16622
  });
16439
16623
 
16440
16624
  // src/archivist-record-pointer.ts
16441
- import { basename as basename11, join as join25 } from "node:path";
16625
+ import { basename as basename12, join as join27 } from "node:path";
16442
16626
  async function resolveOfficerPointer(raw, parentRunDirectory) {
16443
16627
  const where = `${parentRunDirectory} officers`;
16444
16628
  if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
@@ -16451,7 +16635,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
16451
16635
  let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
16452
16636
  let sessionFile = raw.sessionFile;
16453
16637
  const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
16454
- const leaf = parseRunLeaf(basename11(recordedRunDirectory));
16638
+ const leaf = parseRunLeaf(basename12(recordedRunDirectory));
16455
16639
  const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
16456
16640
  if (leaf !== void 0 && parentIdentity !== void 0) {
16457
16641
  const currentRunDirectory = await resolveLiveRunDirectoryPath(
@@ -16471,7 +16655,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
16471
16655
  };
16472
16656
  }
16473
16657
  async function readBookedOfficerPointers(parentRunDirectory) {
16474
- const { records, diagnostics } = await readSitianRecords(join25(parentRunDirectory, RUN_HISTORY_FILE));
16658
+ const { records, diagnostics } = await readSitianRecords(join27(parentRunDirectory, RUN_HISTORY_FILE));
16475
16659
  if (diagnostics.length > 0) {
16476
16660
  throw new Error(
16477
16661
  `${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
@@ -16754,7 +16938,7 @@ var init_analyst_gate_cycles_read = __esm({
16754
16938
 
16755
16939
  // src/analyst-ledger.ts
16756
16940
  import { readdir as readdir3 } from "node:fs/promises";
16757
- import { basename as basename12, join as join26 } from "node:path";
16941
+ import { basename as basename13, join as join28 } from "node:path";
16758
16942
  async function readExistingRunLifecycleState(runDirectory) {
16759
16943
  return (await readRoleRunIdentity(runDirectory))?.state;
16760
16944
  }
@@ -16774,7 +16958,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
16774
16958
  }
16775
16959
  }
16776
16960
  async function classifyGhostCandidate(input) {
16777
- const autopsy = await autopsyWriterLock(join26(input.runDirectory, "writer.lock"));
16961
+ const autopsy = await autopsyWriterLock(join28(input.runDirectory, "writer.lock"));
16778
16962
  const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
16779
16963
  if (leaseCheck === void 0) return { kind: "live" };
16780
16964
  return {
@@ -17064,7 +17248,7 @@ async function classifyScopedRun(input) {
17064
17248
  async function scanAnalystIssueRuns(input) {
17065
17249
  const ledgerHome = resolveActivationLedgerHome(input.home);
17066
17250
  const scopeTicketNumber = input.ticketNumber;
17067
- const booksRoot = join26(ledgerHome, "books");
17251
+ const booksRoot = join28(ledgerHome, "books");
17068
17252
  let wholeBook = false;
17069
17253
  let scopeRootIdentity;
17070
17254
  let bookNames;
@@ -17097,7 +17281,7 @@ async function scanAnalystIssueRuns(input) {
17097
17281
  const ghostLegs = [];
17098
17282
  const scopeConflicts = [];
17099
17283
  for (const book of bookNames) {
17100
- const bookDir = join26(booksRoot, book);
17284
+ const bookDir = join28(booksRoot, book);
17101
17285
  let runDirectories;
17102
17286
  try {
17103
17287
  runDirectories = await listBookRunDirectories(bookDir);
@@ -17106,7 +17290,7 @@ async function scanAnalystIssueRuns(input) {
17106
17290
  throw error;
17107
17291
  }
17108
17292
  for (const runDirectory of runDirectories) {
17109
- const runName = basename12(runDirectory);
17293
+ const runName = basename13(runDirectory);
17110
17294
  const parsed = parseRunLeaf(runName);
17111
17295
  if (parsed === void 0) continue;
17112
17296
  let scopeFields;
@@ -17843,7 +18027,7 @@ var init_analyst_metric_family = __esm({
17843
18027
  });
17844
18028
 
17845
18029
  // src/analyst-page.ts
17846
- import { dirname as dirname16, join as join27 } from "node:path";
18030
+ import { dirname as dirname16, join as join29 } from "node:path";
17847
18031
  function analystIssuePageKey(address) {
17848
18032
  const parts = ["book", address.bookKey];
17849
18033
  if (address.issueNumber !== void 0) {
@@ -17854,7 +18038,7 @@ function analystIssuePageKey(address) {
17854
18038
  return sha256Hex(parts.join("\0")).slice(0, 32);
17855
18039
  }
17856
18040
  function analystIssuePagePath(ledgerHome, address) {
17857
- return join27(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
18041
+ return join29(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
17858
18042
  }
17859
18043
  function analystIssuePageAddressFromPage(page) {
17860
18044
  return {
@@ -18700,18 +18884,22 @@ function parseArgv(argv) {
18700
18884
  help
18701
18885
  };
18702
18886
  }
18703
- function parseResumeRequest(args) {
18704
- const runId = args[0];
18705
- if (runId === void 0 || runId.trim() === "" || runId.startsWith("-")) {
18706
- throw new CliUsageError(RESUME_USAGE_ERROR);
18707
- }
18708
- if (args.length > 2) {
18887
+ function parseResumeAddress(args) {
18888
+ const [ticketToken, seatToken, ...rest] = args;
18889
+ const ticketNumber = ticketToken === void 0 ? void 0 : parseAddressTicket(ticketToken);
18890
+ if (ticketNumber === void 0 || seatToken === void 0 || rest.length > 1) {
18709
18891
  throw new CliUsageError(RESUME_USAGE_ERROR);
18710
18892
  }
18711
- if (args.length === 2) {
18712
- return { runId, message: args[1] };
18893
+ const { seat, round } = parseSeatRound(seatToken);
18894
+ if (!isPublicCallableRole(seat) || round === "") {
18895
+ throw new CliUsageError(`${RESUME_USAGE_ERROR}; not a callable seat: ${seatToken}`);
18713
18896
  }
18714
- return { runId };
18897
+ return {
18898
+ ticketNumber,
18899
+ seat,
18900
+ ...round === void 0 ? {} : { round },
18901
+ ...rest.length === 0 ? {} : { message: rest[0] }
18902
+ };
18715
18903
  }
18716
18904
  function invocationFromParsed(parsed) {
18717
18905
  if (parsed.model === void 0 && parsed.thinking === void 0 && parsed.engine === void 0 && parsed.host === void 0) {
@@ -18820,7 +19008,7 @@ function renderHelp() {
18820
19008
  "Host providers: ~/.ak-roles/host-providers.json (owner-edited; table > unique host directory > fail)",
18821
19009
  "Model resolution: --model \u2192 persistent seat \u2192 officer inherit (#620); still none \u2192 error (#178)",
18822
19010
  "Host resolution: --host \u2192 persistent seat host \u2192 pi (resume uses the same order; #617)",
18823
- "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)",
19011
+ "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)",
18824
19012
  "Effective seats: ak-role roles"
18825
19013
  );
18826
19014
  return `${lines.join("\n")}
@@ -19212,28 +19400,34 @@ async function runAkRole(argv, env) {
19212
19400
  env = { ...env, freshSummons: true };
19213
19401
  }
19214
19402
  if (parsed.command === "resume") {
19215
- let resumeRequest = parseResumeRequest(parsed.args);
19403
+ const address = parseResumeAddress(parsed.args);
19404
+ const runDirectory = locateTicketLeg(
19405
+ activationBookDirectory(
19406
+ resolveActivationLedgerHome(home),
19407
+ resolveBookKeyFromGit(env.cwd ?? process.cwd())
19408
+ ),
19409
+ address
19410
+ );
19411
+ const resumeRequest = {
19412
+ runId: runIdFromRunDirectory(runDirectory),
19413
+ runDirectory,
19414
+ ...address.message === void 0 ? {} : { message: address.message }
19415
+ };
19216
19416
  resumeFailureContext = {
19217
19417
  home,
19218
19418
  runId: resumeRequest.runId,
19419
+ runDirectory,
19219
19420
  authority: env.principalAuthority ?? piDurablePrincipalAuthority
19220
19421
  };
19221
- const runDirectory = await findRunDirectoryById(home, resumeRequest.runId);
19222
- if (runDirectory !== void 0) {
19223
- resumeRequest = { ...resumeRequest, runDirectory };
19224
- resumeFailureContext = { ...resumeFailureContext, runDirectory };
19225
- }
19226
19422
  const parts = await loadPublicRoleDispatchParts(env, home);
19227
- const resumeRole = await peekRoleRunRole(home, resumeRequest.runId, resumeRequest);
19228
- const seatRole = resumeRole ?? "judge";
19229
19423
  const seat = resolveEffectiveSeat(
19230
19424
  parts.config,
19231
- seatRole,
19425
+ address.seat,
19232
19426
  parts.credentials,
19233
19427
  invocationFromParsed(parsed)
19234
19428
  );
19235
19429
  const resumeEnv = createRoleEnvironment(env, {
19236
- role: seatRole,
19430
+ role: address.seat,
19237
19431
  home,
19238
19432
  agentDir: parts.agentDir,
19239
19433
  cwd: parts.cwd,
@@ -19367,6 +19561,10 @@ var init_cli = __esm({
19367
19561
  init_instruction_seat_run();
19368
19562
  init_countersign_run();
19369
19563
  init_analyst_run();
19564
+ init_activation_ledger_git();
19565
+ init_activation_ledger_topology();
19566
+ init_run_terminal_artifacts();
19567
+ init_ticket_address();
19370
19568
  init_run_lifecycle();
19371
19569
  init_registry();
19372
19570
  init_settlement();
@@ -19380,7 +19578,7 @@ var init_cli = __esm({
19380
19578
  ])
19381
19579
  );
19382
19580
  PUBLIC_GLOBAL_OPTIONS = optionsForOwner("global");
19383
- 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)";
19581
+ 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)";
19384
19582
  }
19385
19583
  });
19386
19584
 
@@ -19394,9 +19592,9 @@ __export(public_role_summons_exports, {
19394
19592
  summonPublicRole: () => summonPublicRole
19395
19593
  });
19396
19594
  import { execFile as execFile3 } from "node:child_process";
19397
- import { existsSync as existsSync12 } from "node:fs";
19595
+ import { existsSync as existsSync13 } from "node:fs";
19398
19596
  import { realpath as realpath6 } from "node:fs/promises";
19399
- import { join as join28 } from "node:path";
19597
+ import { join as join30 } from "node:path";
19400
19598
  import { promisify as promisify3 } from "node:util";
19401
19599
  function createCapturingIo() {
19402
19600
  const chunks = [];
@@ -19420,7 +19618,7 @@ function parentDir(path) {
19420
19618
  function walkPackageRoot(start) {
19421
19619
  let dir = start;
19422
19620
  for (let i = 0; i < 12; i += 1) {
19423
- if (existsSync12(join28(dir, "package.json")) && existsSync12(join28(dir, "souls"))) {
19621
+ if (existsSync13(join30(dir, "package.json")) && existsSync13(join30(dir, "souls"))) {
19424
19622
  return dir;
19425
19623
  }
19426
19624
  const parent = parentDir(dir);
@@ -19655,13 +19853,7 @@ async function summonPublicRole(options) {
19655
19853
  result = stepped.ok;
19656
19854
  }
19657
19855
  const stderr = captured?.stderrText();
19658
- let runDirectory = result.admitted?.runDirectory;
19659
- if (result.terminal !== void 0 && result.terminal.roleOutcome.role !== options.role && typeof result.terminal.runId === "string" && result.admitted?.runId !== result.terminal.runId) {
19660
- runDirectory = await (await Promise.resolve().then(() => (init_run_lifecycle(), run_lifecycle_exports))).findRunDirectoryById(
19661
- home,
19662
- result.terminal.runId
19663
- ) ?? runDirectory;
19664
- }
19856
+ const runDirectory = result.admitted?.runDirectory;
19665
19857
  return {
19666
19858
  exitCode: result.exitCode,
19667
19859
  ...result.terminal === void 0 ? {} : { terminal: result.terminal },
@@ -19969,7 +20161,7 @@ var init_compliance_transport = __esm({
19969
20161
  });
19970
20162
 
19971
20163
  // src/role-run-relocation.ts
19972
- import { dirname as dirname17, join as join29 } from "node:path";
20164
+ import { dirname as dirname17, join as join31 } from "node:path";
19973
20165
  async function retainedRunPathsMatch(recordedPath, currentPath, currentRunDirectory) {
19974
20166
  if (recordedPath === currentPath) return true;
19975
20167
  if (typeof recordedPath !== "string") return false;
@@ -20011,34 +20203,9 @@ var init_role_run_relocation = __esm({
20011
20203
  });
20012
20204
 
20013
20205
  // src/public-cli/run-lifecycle.ts
20014
- var run_lifecycle_exports = {};
20015
- __export(run_lifecycle_exports, {
20016
- AUTO_RESUME_LIMIT: () => AUTO_RESUME_LIMIT,
20017
- RunWriterLeaseHeldError: () => RunWriterLeaseHeldError,
20018
- WRITER_LOCK_FILE: () => WRITER_LOCK_FILE,
20019
- acquireRunWriterLease: () => acquireRunWriterLease,
20020
- autopsyWriterLock: () => autopsyWriterLock,
20021
- clearCurrentCourt: () => clearCurrentCourt,
20022
- describeErrorIdentity: () => describeErrorIdentity,
20023
- findLatestRunForSeatTicket: () => findLatestRunForSeatTicket,
20024
- findLatestRunIdForSeatTicket: () => findLatestRunIdForSeatTicket,
20025
- findRunDirectoryById: () => findRunDirectoryById,
20026
- loadResumablePublicRole: () => loadResumablePublicRole,
20027
- markRunAdmitted: () => markRunAdmitted,
20028
- markRunRunning: () => markRunRunning,
20029
- markRunTerminal: () => markRunTerminal,
20030
- peekRoleRunRole: () => peekRoleRunRole,
20031
- readCurrentCourt: () => readCurrentCourt,
20032
- readRoleRunIdentity: () => readRoleRunIdentity,
20033
- readRoleRunState: () => readRoleRunState,
20034
- readRunParentPath: () => readRunParentPath,
20035
- recordCurrentCourt: () => recordCurrentCourt,
20036
- resolveLiveRunDirectoryPath: () => resolveLiveRunDirectoryPath,
20037
- writeRoleRunState: () => writeRoleRunState
20038
- });
20039
- import { existsSync as existsSync13 } from "node:fs";
20206
+ import { existsSync as existsSync14 } from "node:fs";
20040
20207
  import { chmod, lstat as lstat3, open as open2, readdir as readdir4, readFile as readFile14, unlink as unlink2 } from "node:fs/promises";
20041
- import { basename as basename13, join as join30 } from "node:path";
20208
+ import { basename as basename14, join as join32 } from "node:path";
20042
20209
  async function writeRoleRunState(runDirectory, record) {
20043
20210
  const payload = { ...record, runDirectory };
20044
20211
  writeSectionSync(runDirectory, "runState", { ...payload });
@@ -20333,7 +20500,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
20333
20500
  },
20334
20501
  relocate(nextRunDirectory) {
20335
20502
  currentRunDirectory = nextRunDirectory;
20336
- currentLockPath = join30(nextRunDirectory, WRITER_LOCK_FILE);
20503
+ currentLockPath = join32(nextRunDirectory, WRITER_LOCK_FILE);
20337
20504
  },
20338
20505
  async release() {
20339
20506
  if (released) return;
@@ -20372,10 +20539,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
20372
20539
  };
20373
20540
  const reportReadFailure = (error) => {
20374
20541
  reportDiagnostic(
20375
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join30(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
20542
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join32(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
20376
20543
  );
20377
20544
  };
20378
- const lockPath = join30(runDirectory, WRITER_LOCK_FILE);
20545
+ const lockPath = join32(runDirectory, WRITER_LOCK_FILE);
20379
20546
  let lastAutopsy = { verdict: "absent" };
20380
20547
  let lastReclaimFailure;
20381
20548
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -20431,17 +20598,17 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
20431
20598
  }
20432
20599
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRunDirectory) {
20433
20600
  if (typeof knownRunDirectory === "string" && knownRunDirectory.trim() !== "") {
20434
- const parsed = parseRunLeaf(basename13(knownRunDirectory));
20601
+ const parsed = parseRunLeaf(basename14(knownRunDirectory));
20435
20602
  if (parsed === void 0 || parsed.runId !== runId) {
20436
20603
  throw new CliUsageError(
20437
- `run directory does not match run id ${runId}: ${knownRunDirectory}`
20604
+ `run directory is not the expected role run: ${knownRunDirectory}`
20438
20605
  );
20439
20606
  }
20440
20607
  return knownRunDirectory;
20441
20608
  }
20442
20609
  if (runId.trim() === "") return void 0;
20443
20610
  const ledgerHome = resolveActivationLedgerHome(home);
20444
- const booksRoot = join30(ledgerHome, "books");
20611
+ const booksRoot = join32(ledgerHome, "books");
20445
20612
  let bookKeys;
20446
20613
  try {
20447
20614
  bookKeys = await readdir4(booksRoot);
@@ -20456,8 +20623,8 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
20456
20623
  );
20457
20624
  }
20458
20625
  async function resolveLiveRunDirectoryPath(recordedPath, home, onlyBookKey) {
20459
- if (existsSync13(recordedPath)) return recordedPath;
20460
- const parsed = parseRunLeaf(basename13(recordedPath));
20626
+ if (existsSync14(recordedPath)) return recordedPath;
20627
+ const parsed = parseRunLeaf(basename14(recordedPath));
20461
20628
  const bookKey = onlyBookKey ?? tryBookKeyFromAkRolesPath(recordedPath);
20462
20629
  if (parsed === void 0 || bookKey === void 0) return void 0;
20463
20630
  return findRunDirectoryById(home, parsed.runId, bookKey, parsed.role);
@@ -20478,10 +20645,6 @@ async function runHasFormedSessionPrincipal(runDirectory) {
20478
20645
  throw error;
20479
20646
  }
20480
20647
  }
20481
- async function findLatestRunIdForSeatTicket(input) {
20482
- const found = await findLatestRunForSeatTicket(input);
20483
- return found?.runId;
20484
- }
20485
20648
  async function findLatestRunForSeatTicket(input) {
20486
20649
  if (input.parentRunPath.trim() === "") {
20487
20650
  return void 0;
@@ -20491,7 +20654,7 @@ async function findLatestRunForSeatTicket(input) {
20491
20654
  let runDirectories;
20492
20655
  try {
20493
20656
  runDirectories = await listBookRunDirectories(
20494
- input.ticketNumber === void 0 ? bookDir : join30(bookDir, String(input.ticketNumber))
20657
+ input.ticketNumber === void 0 ? bookDir : join32(bookDir, String(input.ticketNumber))
20495
20658
  );
20496
20659
  } catch (error) {
20497
20660
  if (errorCodeOf(error) === "ENOENT") return void 0;
@@ -20499,7 +20662,7 @@ async function findLatestRunForSeatTicket(input) {
20499
20662
  }
20500
20663
  let best;
20501
20664
  for (const runDirectory of runDirectories) {
20502
- const parsed = parseRunLeaf(basename13(runDirectory));
20665
+ const parsed = parseRunLeaf(basename14(runDirectory));
20503
20666
  if (parsed === void 0 || parsed.role !== input.role) continue;
20504
20667
  const runId = parsed.runId;
20505
20668
  const parentPath = await readRunParentPath(runDirectory);
@@ -20526,15 +20689,15 @@ function restoredTicketFields(fields) {
20526
20689
  async function loadResumableRunRecord(home, runId, authority, knownRunDirectory) {
20527
20690
  const runDirectory = await findRunDirectoryById(home, runId, void 0, void 0, knownRunDirectory);
20528
20691
  if (runDirectory === void 0) {
20529
- throw new CliUsageError(`unknown role run id: ${runId}`);
20692
+ throw new CliUsageError(`unknown role run: no run directory found under ${home}`);
20530
20693
  }
20531
20694
  const disk = await readRoleRunStateDisk(runDirectory);
20532
20695
  if (disk === void 0) {
20533
- throw new CliUsageError(`unknown role run id: ${runId}`);
20696
+ throw new CliUsageError(`role run has no readable state: ${runDirectory}`);
20534
20697
  }
20535
20698
  const materialized = materializeRoleRunFromDisk(disk, authority);
20536
20699
  if (materialized === void 0) {
20537
- throw new CliUsageError(`unknown role run id: ${runId}`);
20700
+ throw new CliUsageError(`role run has no readable state: ${runDirectory}`);
20538
20701
  }
20539
20702
  const { run, principal } = materialized;
20540
20703
  let instruction = "";
@@ -20660,7 +20823,7 @@ async function loadResumableRunRecord(home, runId, authority, knownRunDirectory)
20660
20823
  } catch (error) {
20661
20824
  if (error instanceof CliUsageError) throw error;
20662
20825
  throw new CliUsageError(
20663
- `role run admitted request is unreadable: ${runId}`,
20826
+ `role run admitted request is unreadable: ${run.runDirectory}`,
20664
20827
  { cause: error }
20665
20828
  );
20666
20829
  }
@@ -20687,7 +20850,7 @@ async function loadResumableRunRecord(home, runId, authority, knownRunDirectory)
20687
20850
  }
20688
20851
  if (!isEnoent(error)) {
20689
20852
  throw new CliUsageError(
20690
- `role run invocation identity is unreadable: ${runId}`,
20853
+ `role run invocation identity is unreadable: ${run.runDirectory}`,
20691
20854
  { cause: error }
20692
20855
  );
20693
20856
  }
@@ -20769,7 +20932,7 @@ async function loadResumablePublicRole(home, runId, authority, options) {
20769
20932
  }
20770
20933
  function admitResumedRole(loaded) {
20771
20934
  const role = loaded.run.role;
20772
- const runId = loaded.run.runId;
20935
+ const leg = loaded.run.runDirectory;
20773
20936
  const record = packagedRoleMetadata(role);
20774
20937
  if (record === void 0) {
20775
20938
  throw new CliUsageError(`unknown role: ${role}`);
@@ -20800,10 +20963,10 @@ function admitResumedRole(loaded) {
20800
20963
  return admitted;
20801
20964
  }
20802
20965
  case "worker-task": {
20803
- const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, runId);
20966
+ const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, leg);
20804
20967
  if (fields.instruction.trim() === "") {
20805
20968
  throw new CliUsageError(
20806
- `role run admitted coder task is blank: ${runId}`
20969
+ `role run admitted coder task is blank: ${leg}`
20807
20970
  );
20808
20971
  }
20809
20972
  const admitted = {
@@ -20815,10 +20978,10 @@ function admitResumedRole(loaded) {
20815
20978
  return admitted;
20816
20979
  }
20817
20980
  case "worker-packet": {
20818
- const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, runId);
20981
+ const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, leg);
20819
20982
  if (fields.instruction.trim() === "") {
20820
20983
  throw new CliUsageError(
20821
- `role run admitted fixer instruction is blank: ${runId}`
20984
+ `role run admitted fixer instruction is blank: ${leg}`
20822
20985
  );
20823
20986
  }
20824
20987
  const admitted = {
@@ -20835,19 +20998,19 @@ function admitResumedRole(loaded) {
20835
20998
  const baseFault = admittedReviewerBaseFault(rawBase);
20836
20999
  if (baseFault !== void 0 || rawBase === void 0) {
20837
21000
  throw new CliUsageError(
20838
- baseFault === "damaged" ? `role run admitted reviewer base revision is damaged: ${runId}` : `role run admitted reviewer base revision is missing: ${runId}`
21001
+ baseFault === "damaged" ? `role run admitted reviewer base revision is damaged: ${leg}` : `role run admitted reviewer base revision is missing: ${leg}`
20839
21002
  );
20840
21003
  }
20841
21004
  const lens = fields.lens;
20842
21005
  if (!isReviewerLens(lens)) {
20843
21006
  throw new CliUsageError(
20844
- `role run admitted reviewer lens is missing: ${runId}`
21007
+ `role run admitted reviewer lens is missing: ${leg}`
20845
21008
  );
20846
21009
  }
20847
21010
  const authorityRefs = Object.freeze([...fields.authorityRefs ?? []]);
20848
21011
  if (authorityRefs.length === 0) {
20849
21012
  throw new CliUsageError(
20850
- `role run admitted reviewer authority refs are missing: ${runId}`
21013
+ `role run admitted reviewer authority refs are missing: ${leg}`
20851
21014
  );
20852
21015
  }
20853
21016
  const admitted = {
@@ -20863,7 +21026,7 @@ function admitResumedRole(loaded) {
20863
21026
  const baseRevision = fields.baseRevision;
20864
21027
  if (baseRevision === void 0 || baseRevision.trim() === "") {
20865
21028
  throw new CliUsageError(
20866
- `role run admitted gleaner-left base revision is missing: ${runId}`
21029
+ `role run admitted gleaner-left base revision is missing: ${leg}`
20867
21030
  );
20868
21031
  }
20869
21032
  const admitted = {
@@ -20877,18 +21040,18 @@ function admitResumedRole(loaded) {
20877
21040
  const mergerInputPath = fields.mergerInputPath;
20878
21041
  if (mergerInputPath === void 0) {
20879
21042
  throw new CliUsageError(
20880
- `role run admitted merger input path is missing: ${runId}`
21043
+ `role run admitted merger input path is missing: ${leg}`
20881
21044
  );
20882
21045
  }
20883
21046
  const derived = fields.derived;
20884
21047
  if (derived === void 0) {
20885
21048
  throw new CliUsageError(
20886
- `role run admitted merger envelope is missing: ${runId}`
21049
+ `role run admitted merger envelope is missing: ${leg}`
20887
21050
  );
20888
21051
  }
20889
21052
  if (fields.instruction.trim() === "") {
20890
21053
  throw new CliUsageError(
20891
- `role run admitted merger task is blank: ${runId}`
21054
+ `role run admitted merger task is blank: ${leg}`
20892
21055
  );
20893
21056
  }
20894
21057
  const admitted = {
@@ -20904,7 +21067,7 @@ function admitResumedRole(loaded) {
20904
21067
  const { prNumber, repository, repositoryDisplay } = fields;
20905
21068
  if (repository === void 0 || repositoryDisplay === void 0) {
20906
21069
  throw new CliUsageError(
20907
- `role run admitted collector repository identity is missing: ${runId}`
21070
+ `role run admitted collector repository identity is missing: ${leg}`
20908
21071
  );
20909
21072
  }
20910
21073
  let parsedRepository;
@@ -20916,7 +21079,7 @@ function admitResumedRole(loaded) {
20916
21079
  }
20917
21080
  if (parsedRepository.canonical !== repository) {
20918
21081
  throw new CliUsageError(
20919
- `role run admitted collector repository does not match its canonical form: ${runId}`
21082
+ `role run admitted collector repository does not match its canonical form: ${leg}`
20920
21083
  );
20921
21084
  }
20922
21085
  const admitted = {
@@ -20933,7 +21096,7 @@ function admitResumedRole(loaded) {
20933
21096
  const { issueNumber, caseRunsPath, caseIdentity } = fields;
20934
21097
  if (issueNumber === void 0 || caseRunsPath === void 0 || caseIdentity === void 0) {
20935
21098
  throw new CliUsageError(
20936
- `role run admitted doctor case identity is missing: ${runId}`
21099
+ `role run admitted doctor case identity is missing: ${leg}`
20937
21100
  );
20938
21101
  }
20939
21102
  const admitted = {
@@ -20949,7 +21112,7 @@ function admitResumedRole(loaded) {
20949
21112
  const { sourceRunPath, sourceRun } = fields;
20950
21113
  if (sourceRunPath === void 0 || sourceRun === void 0) {
20951
21114
  throw new CliUsageError(
20952
- `role run admitted notary source-run locator is missing: ${runId}`
21115
+ `role run admitted notary source-run locator is missing: ${leg}`
20953
21116
  );
20954
21117
  }
20955
21118
  const admitted = {
@@ -20962,13 +21125,13 @@ function admitResumedRole(loaded) {
20962
21125
  }
20963
21126
  }
20964
21127
  }
20965
- function resumedWorkerPhase(phase, phases, role, runId) {
21128
+ function resumedWorkerPhase(phase, phases, role, leg) {
20966
21129
  if (phase === "plan" || phase === "apply") {
20967
21130
  if (phases.some((item) => item === phase)) {
20968
21131
  return phase;
20969
21132
  }
20970
21133
  }
20971
- throw new CliUsageError(`role run admitted ${role} phase is missing: ${runId}`);
21134
+ throw new CliUsageError(`role run admitted ${role} phase is missing: ${leg}`);
20972
21135
  }
20973
21136
  var AUTO_RESUME_LIMIT, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
20974
21137
  var init_run_lifecycle = __esm({
@@ -21230,7 +21393,7 @@ init_submission_ledger();
21230
21393
  init_filed_submission();
21231
21394
  init_report_ticket_tool();
21232
21395
  import { writeSync as writeSync2 } from "node:fs";
21233
- import { join as join31 } from "node:path";
21396
+ import { join as join33 } from "node:path";
21234
21397
  import { Value as Value2 } from "typebox/value";
21235
21398
 
21236
21399
  // src/activation-trace.ts
@@ -21279,7 +21442,7 @@ init_activation_ledger_topology();
21279
21442
  import {
21280
21443
  lstatSync as lstatSync2,
21281
21444
  realpathSync as realpathSync2,
21282
- statSync as statSync7,
21445
+ statSync as statSync8,
21283
21446
  writeFileSync as writeFileSync3
21284
21447
  } from "node:fs";
21285
21448
  import { isAbsolute as isAbsolute10, resolve as resolve14 } from "node:path";
@@ -21354,7 +21517,7 @@ function durableSessionPointer(sessionManager) {
21354
21517
  }
21355
21518
  let info;
21356
21519
  try {
21357
- info = statSync7(realFile);
21520
+ info = statSync8(realFile);
21358
21521
  } catch (error) {
21359
21522
  throw new Error(
21360
21523
  `Workflow role activation failed to stat durable session file (${realFile}): ${errorText(error)}`,
@@ -21748,10 +21911,10 @@ init_run_ticket_number();
21748
21911
 
21749
21912
  // src/audited-run-identity.ts
21750
21913
  init_role_run_placement();
21751
- import { basename as basename14 } from "node:path";
21914
+ import { basename as basename15 } from "node:path";
21752
21915
  var AUDITED_RUN_IDENTITY_KIND = "audited-run";
21753
21916
  function auditedRunIdentityFromDirectory(runDirectory) {
21754
- const parsed = parseRunLeaf(basename14(runDirectory));
21917
+ const parsed = parseRunLeaf(basename15(runDirectory));
21755
21918
  if (parsed === void 0) return void 0;
21756
21919
  return formatRunLeaf(parsed.runId, parsed.role);
21757
21920
  }
@@ -22155,7 +22318,7 @@ init_unknown_value();
22155
22318
  init_submission_errors();
22156
22319
  init_worker_submission_contracts();
22157
22320
  import { execFileSync as execFileSync3 } from "node:child_process";
22158
- import { existsSync as existsSync14, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync4 } from "node:fs";
22321
+ import { existsSync as existsSync15, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync4 } from "node:fs";
22159
22322
  import { resolve as resolve15 } from "node:path";
22160
22323
  var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
22161
22324
  var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
@@ -22185,7 +22348,7 @@ function statusOf(error) {
22185
22348
  return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
22186
22349
  }
22187
22350
  function tryGetAll(file, key) {
22188
- if (!existsSync14(file)) return [];
22351
+ if (!existsSync15(file)) return [];
22189
22352
  try {
22190
22353
  const out = gitFile(file, ["--get-all", key]);
22191
22354
  return out.length === 0 ? [] : out.split("\n");
@@ -22195,7 +22358,7 @@ function tryGetAll(file, key) {
22195
22358
  }
22196
22359
  }
22197
22360
  function ownedHook(path) {
22198
- if (!existsSync14(path)) return false;
22361
+ if (!existsSync15(path)) return false;
22199
22362
  return readFileSync5(path, "utf8").includes(HOOK_MARKER);
22200
22363
  }
22201
22364
  function escapeGitConfigValueRegex(value) {
@@ -22222,12 +22385,12 @@ function rmOwnedDir(dir) {
22222
22385
  const hookPath = resolve15(dir, HOOK_FILE);
22223
22386
  if (!ownedHook(hookPath)) return;
22224
22387
  rmSync4(hookPath, { force: true });
22225
- if (existsSync14(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
22388
+ if (existsSync15(dir) && readdirSync4(dir).length === 0) rmdirSync(dir);
22226
22389
  }
22227
22390
  function linkedGitDirs(commonDir) {
22228
22391
  const root = resolve15(commonDir, "worktrees");
22229
- if (!existsSync14(root)) return [];
22230
- return readdirSync3(root).map((name) => resolve15(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
22392
+ if (!existsSync15(root)) return [];
22393
+ return readdirSync4(root).map((name) => resolve15(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
22231
22394
  }
22232
22395
  function uninstallPackageWorkerHooks(cwd) {
22233
22396
  let inside;
@@ -23018,7 +23181,7 @@ function readRoleRunCoordinates(ctx, label) {
23018
23181
  if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
23019
23182
  const admitted = readPageSync(runDirectory, "admitted");
23020
23183
  if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
23021
- throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join31(runDirectory, RUN_STATE_FILE)})`);
23184
+ throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join33(runDirectory, RUN_STATE_FILE)})`);
23022
23185
  }
23023
23186
  return {
23024
23187
  runDirectory,
@@ -24784,12 +24947,12 @@ function createAcpRoleTurnHost(config) {
24784
24947
  // src/acp-host/seat-profile-soul.ts
24785
24948
  import { constants as constants3 } from "node:fs";
24786
24949
  import { access as access3, copyFile, lstat as lstat4, mkdir as mkdir4, readlink, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
24787
- import { dirname as dirname19, join as join32, relative as relative4, resolve as resolve16 } from "node:path";
24950
+ import { dirname as dirname19, join as join34, relative as relative4, resolve as resolve16 } from "node:path";
24788
24951
  function seatProfileName(spec, role) {
24789
24952
  return `${spec.namePrefix}${role}`;
24790
24953
  }
24791
24954
  function packageRoleSoulPath(packageRoot, role) {
24792
- return join32(packageRoot, "souls", `${role}.md`);
24955
+ return join34(packageRoot, "souls", `${role}.md`);
24793
24956
  }
24794
24957
  async function pathExists2(path) {
24795
24958
  try {
@@ -24806,16 +24969,16 @@ async function ensureSeatProfileSoul(options) {
24806
24969
  if (!await pathExists2(soulTarget)) {
24807
24970
  throw new Error(`packaged role soul missing: ${soulTarget}`);
24808
24971
  }
24809
- const profilesRoot = join32(operatorHome, ...spec.profilesRootFromHome);
24810
- const profileDir = join32(profilesRoot, profileName);
24972
+ const profilesRoot = join34(operatorHome, ...spec.profilesRootFromHome);
24973
+ const profileDir = join34(profilesRoot, profileName);
24811
24974
  const hostRoot = dirname19(profilesRoot);
24812
- const soulPath = join32(profileDir, spec.soulFileName);
24975
+ const soulPath = join34(profileDir, spec.soulFileName);
24813
24976
  if (!await pathExists2(profileDir)) {
24814
24977
  await mkdir4(profileDir, { recursive: true });
24815
24978
  for (const name of ["auth.json", ".env", "config.yaml"]) {
24816
- const source = join32(hostRoot, name);
24979
+ const source = join34(hostRoot, name);
24817
24980
  if (!await pathExists2(source)) continue;
24818
- await copyFile(source, join32(profileDir, name));
24981
+ await copyFile(source, join34(profileDir, name));
24819
24982
  }
24820
24983
  } else {
24821
24984
  await mkdir4(profileDir, { recursive: true });