@akagilnc/pi-workflow-roles 0.1.5762 → 0.1.5797

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 (52) hide show
  1. package/dist/acp-host/production-host.js +685 -285
  2. package/dist/external-host-turn-loop.js +3 -0
  3. package/dist/headless-host/production-host.js +658 -258
  4. package/dist/migrate-book-topology.js +70 -29
  5. package/dist/navigator-attendance.js +1 -1
  6. package/dist/packaged-role-registry.js +3 -2
  7. package/dist/pi/role-turn-host.js +6 -1
  8. package/dist/public-cli/instruction-seat-run.js +152 -60
  9. package/dist/public-cli/invocation.js +98 -46
  10. package/dist/public-cli/main.js +482 -222
  11. package/dist/public-cli/option-definitions.js +4 -4
  12. package/dist/public-cli/post-admission.js +19 -28
  13. package/dist/public-cli/run-lifecycle.js +10 -21
  14. package/dist/public-cli/turn-request.js +3 -0
  15. package/dist/public-role-summons.js +11 -8
  16. package/dist/report-ticket-tool.js +3 -3
  17. package/dist/role-run-placement.js +14 -2
  18. package/dist/role-run-relocation.js +2 -2
  19. package/dist/run-dossier.js +5 -4
  20. package/dist/run-terminal-artifacts.js +0 -7
  21. package/dist/session-identity.js +3 -2
  22. package/dist/sitian-appender.js +12 -3
  23. package/dist/submission-ledger.js +24 -0
  24. package/dist/ticket-progress.js +306 -0
  25. package/dist/user-dialogue-stdin.js +23 -17
  26. package/package.json +1 -1
  27. package/src/external-host-turn-loop.ts +7 -1
  28. package/src/host-contracts.ts +1 -1
  29. package/src/navigator-attendance.ts +2 -1
  30. package/src/packaged-role-registry.ts +3 -2
  31. package/src/pi/adapter.ts +57 -45
  32. package/src/pi/role-turn-host.ts +6 -1
  33. package/src/prepared-role-turn.ts +6 -0
  34. package/src/public-cli/instruction-seat-run.ts +166 -68
  35. package/src/public-cli/invocation.ts +120 -46
  36. package/src/public-cli/option-definitions.ts +5 -4
  37. package/src/public-cli/post-admission.ts +19 -30
  38. package/src/public-cli/run-lifecycle.ts +10 -27
  39. package/src/public-cli/turn-request.ts +3 -0
  40. package/src/public-role-summons.ts +27 -16
  41. package/src/report-ticket-tool.ts +7 -3
  42. package/src/role-envelope.ts +5 -0
  43. package/src/role-run-placement.ts +19 -2
  44. package/src/role-run-relocation.ts +2 -2
  45. package/src/role-runtime.ts +19 -2
  46. package/src/run-dossier.ts +5 -3
  47. package/src/run-terminal-artifacts.ts +0 -8
  48. package/src/session-identity.ts +3 -2
  49. package/src/sitian-appender.ts +14 -3
  50. package/src/submission-ledger.ts +27 -0
  51. package/src/ticket-progress.ts +383 -0
  52. package/src/user-dialogue-stdin.ts +21 -14
@@ -1045,6 +1045,12 @@ function appendSitianRecordBlock(input, block) {
1045
1045
  function resolveSitianVolumeCategory(kind) {
1046
1046
  return kind;
1047
1047
  }
1048
+ function runDirectoryOwningSessionParent(sessionParentDir) {
1049
+ if (basename3(sessionParentDir) !== "session") return void 0;
1050
+ const runDirectory = dirname3(sessionParentDir);
1051
+ if (parseRunLeaf(basename3(runDirectory)) === void 0) return void 0;
1052
+ return runDirectory;
1053
+ }
1048
1054
  function sitianVolumeDirectory(sessionDirectory, category) {
1049
1055
  return join2(sessionDirectory, category);
1050
1056
  }
@@ -1076,8 +1082,8 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
1076
1082
  throw new Error("Sitian record ownership requires a parent session inside the ledger home");
1077
1083
  }
1078
1084
  const sessionParentDir = dirname3(input.sessionParent);
1079
- const runDirectory = dirname3(sessionParentDir);
1080
- if (basename3(sessionParentDir) === "session" && parseRunLeaf(basename3(runDirectory)) !== void 0) {
1085
+ const runDirectory = runDirectoryOwningSessionParent(sessionParentDir);
1086
+ if (runDirectory !== void 0) {
1081
1087
  sessionDir = runDirectory;
1082
1088
  recordFile = join2(runDirectory, RUN_HISTORY_KINDS.has(input.kind) ? RUN_HISTORY_FILE : RUN_STATE_KINDS.has(input.kind) ? RUN_STATE_FILE : RUN_LOG_FILE);
1083
1089
  } else {
@@ -1310,7 +1316,9 @@ function render(runDirectory, history, state, log, unreadable) {
1310
1316
  original = payload.landingPath;
1311
1317
  }
1312
1318
  }
1313
- if (typeof original === "string") original = join3(runDirectory, "session", basename4(original));
1319
+ if (typeof original === "string") {
1320
+ original = join3(sessionDirectoryOf(runDirectory), basename4(original));
1321
+ }
1314
1322
  whole.host = { sessions, ...original === void 0 ? {} : { original } };
1315
1323
  whole.submission = latest === void 0 ? {} : { latest };
1316
1324
  if (Object.keys(unreadable).length > 0) whole.unreadable = unreadable;
@@ -1548,6 +1556,16 @@ function parseRunLeaf(name) {
1548
1556
  if (at <= 0 || at === name.length - 1) return void 0;
1549
1557
  return { runId: name.slice(0, at), role: name.slice(at + 1) };
1550
1558
  }
1559
+ function subjectDirectoryOfRun(runDirectory) {
1560
+ const runsParent = dirname4(runDirectory);
1561
+ if (basename5(runsParent) !== "runs") return void 0;
1562
+ const subjectDirectory = dirname4(runsParent);
1563
+ const subjectName = basename5(subjectDirectory);
1564
+ if (subjectName === "unbound" || /^[1-9]\d*$/.test(subjectName)) {
1565
+ return subjectDirectory;
1566
+ }
1567
+ return void 0;
1568
+ }
1551
1569
  function sessionDirectoryOf(runDirectory) {
1552
1570
  return join5(runDirectory, "session");
1553
1571
  }
@@ -1640,6 +1658,7 @@ function ensureRoleRunDirectory(ledgerHome, directory) {
1640
1658
  return ensureRealDirectoryTree(ledgerHome, directory);
1641
1659
  }
1642
1660
  function ensureRoleRunPlacement(ledgerHome, placement) {
1661
+ ensureRoleRunDirectory(ledgerHome, placement.runDirectory);
1643
1662
  ensureRoleRunDirectory(ledgerHome, placement.sessionDirectory);
1644
1663
  }
1645
1664
  var ROLE_RUN_SESSION_FILENAME;
@@ -10106,9 +10125,8 @@ var init_packaged_role_registry = __esm({
10106
10125
  bareCommand: false,
10107
10126
  outputTool: NOTARY_OUTPUT_TOOL_NAME,
10108
10127
  settlement: "accepted",
10109
- /** Court reask replaces the initial prompt. Otherwise the fixed kickoff. */
10128
+ /** Dialogue via shared resolveReviewSeatDialogueBody (review = fixed dispatch). */
10110
10129
  reaskPrompt: true,
10111
- transportPrompt: "fixed-kickoff",
10112
10130
  gateStageLabel: "\u7B26\u5B9D\u90CE",
10113
10131
  /** Gate summon binds --source-run and keeps dialogue off the argv. */
10114
10132
  gateSummon: "source-run",
@@ -10131,6 +10149,8 @@ var init_packaged_role_registry = __esm({
10131
10149
  phases: [null],
10132
10150
  outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
10133
10151
  settlement: "accepted",
10152
+ /** Same shared dialogue resolver as other review seats (#1208 C1). */
10153
+ reaskPrompt: true,
10134
10154
  gateStageLabel: "\u7ED9\u4E8B\u4E2D",
10135
10155
  /** Gate summon carries the parent payload as the instruction and a parent run id. */
10136
10156
  gateSummon: "parent-instruction",
@@ -11718,7 +11738,6 @@ var run_terminal_artifacts_exports = {};
11718
11738
  __export(run_terminal_artifacts_exports, {
11719
11739
  ATTEMPT_HISTORY_IDENTITY_FIELD: () => ATTEMPT_HISTORY_IDENTITY_FIELD,
11720
11740
  TERMINAL_COURT_ATTEMPT_FIELD: () => TERMINAL_COURT_ATTEMPT_FIELD,
11721
- isTicketCourtCountersignSource: () => isTicketCourtCountersignSource,
11722
11741
  readRunTerminal: () => readRunTerminal,
11723
11742
  roleFromRunDirectory: () => roleFromRunDirectory,
11724
11743
  runIdFromRunDirectory: () => runIdFromRunDirectory,
@@ -11779,9 +11798,6 @@ function runIdFromRunDirectory(runDirectory) {
11779
11798
  function roleFromRunDirectory(runDirectory) {
11780
11799
  return parseRunLeaf(basename6(runDirectory))?.role;
11781
11800
  }
11782
- function isTicketCourtCountersignSource(runDirectory) {
11783
- return roleFromRunDirectory(runDirectory) === "countersign";
11784
- }
11785
11801
  var ATTEMPT_HISTORY_IDENTITY_FIELD, TERMINAL_COURT_ATTEMPT_FIELD;
11786
11802
  var init_run_terminal_artifacts = __esm({
11787
11803
  "src/run-terminal-artifacts.ts"() {
@@ -12586,7 +12602,8 @@ var init_role_activation_flags = __esm({
12586
12602
 
12587
12603
  // src/user-dialogue-stdin.ts
12588
12604
  function encodeUserDialogueStdin(body) {
12589
- return JSON.stringify({ kind: USER_DIALOGUE_STDIN_KIND, body });
12605
+ const envelope = { kind: USER_DIALOGUE_STDIN_KIND, body };
12606
+ return JSON.stringify(envelope);
12590
12607
  }
12591
12608
  var USER_DIALOGUE_STDIN_KIND;
12592
12609
  var init_user_dialogue_stdin = __esm({
@@ -12916,17 +12933,6 @@ var init_submission_correctable_error = __esm({
12916
12933
  }
12917
12934
  });
12918
12935
 
12919
- // src/sha256.ts
12920
- import { createHash } from "node:crypto";
12921
- function sha256Hex(bytes) {
12922
- return createHash("sha256").update(bytes).digest("hex");
12923
- }
12924
- var init_sha256 = __esm({
12925
- "src/sha256.ts"() {
12926
- "use strict";
12927
- }
12928
- });
12929
-
12930
12936
  // src/package-contracts/terminating-tools.ts
12931
12937
  function isTerminatingToolName(name) {
12932
12938
  return TERMINATING_TOOL_NAMES.includes(name);
@@ -12987,9 +12993,149 @@ var init_terminating_tools = __esm({
12987
12993
  }
12988
12994
  });
12989
12995
 
12996
+ // src/ticket-progress.ts
12997
+ import {
12998
+ appendFileSync as appendFileSync2,
12999
+ existsSync as existsSync2,
13000
+ mkdirSync as mkdirSync3,
13001
+ readFileSync as readFileSync3,
13002
+ readdirSync as readdirSync2,
13003
+ rmSync as rmSync3,
13004
+ writeFileSync as writeFileSync2
13005
+ } from "node:fs";
13006
+ import { basename as basename7, dirname as dirname7, join as join11, relative as relative2, sep as sep3 } from "node:path";
13007
+ function parseProgressText(text, pathForDiagnostic) {
13008
+ if (text.trim() === "") return [];
13009
+ const { records, diagnostics } = parseSitianRecordText(text);
13010
+ for (const diagnostic of diagnostics) {
13011
+ process.stderr.write(
13012
+ `[ticket-progress] ${pathForDiagnostic} has malformed row(s); keeps reachable rows and retains the diagnostic: line ${diagnostic.line}: ${diagnostic.error}
13013
+ `
13014
+ );
13015
+ }
13016
+ const lines = [];
13017
+ for (const record of records) {
13018
+ const parsed = record;
13019
+ if (!isRecord(parsed)) continue;
13020
+ if (typeof parsed.seat !== "string" || typeof parsed.round !== "string") continue;
13021
+ lines.push(parsed);
13022
+ }
13023
+ return lines;
13024
+ }
13025
+ function readProgressFile(path) {
13026
+ if (!existsSync2(path)) return [];
13027
+ return parseProgressText(readFileSync3(path, "utf8"), path);
13028
+ }
13029
+ function readTicketProgressLines(subjectDirectory) {
13030
+ if (basename7(subjectDirectory) === "unbound") {
13031
+ const runsDir = join11(subjectDirectory, "runs");
13032
+ if (!existsSync2(runsDir)) return [];
13033
+ const out = [];
13034
+ for (const name of readdirSync2(runsDir).sort()) {
13035
+ out.push(...readProgressFile(join11(runsDir, name, LEG_PROGRESS_FILENAME)));
13036
+ }
13037
+ return out;
13038
+ }
13039
+ return readProgressFile(join11(subjectDirectory, CURRENT_FILENAME));
13040
+ }
13041
+ function roundBaseNumber(round) {
13042
+ if (round.trim() === "") return 0;
13043
+ const base = round.includes(".") ? round.slice(0, round.indexOf(".")) : round;
13044
+ const n = Number(base);
13045
+ return Number.isSafeInteger(n) && n > 0 ? n : 0;
13046
+ }
13047
+ function roundLens(round) {
13048
+ return round.includes(".") ? round.slice(round.indexOf(".") + 1) : void 0;
13049
+ }
13050
+ function nextRoundFromLines(lines, seat, lens) {
13051
+ const want = lens === void 0 || lens.trim() === "" ? void 0 : lens;
13052
+ let max = 0;
13053
+ for (const line2 of lines) {
13054
+ if (line2.seat !== seat) continue;
13055
+ if (roundLens(line2.round) !== want) continue;
13056
+ max = Math.max(max, roundBaseNumber(line2.round));
13057
+ }
13058
+ const base = max + 1;
13059
+ return want === void 0 ? String(base) : `${base}.${want}`;
13060
+ }
13061
+ function lensFromRunDirectory(runDirectory, role) {
13062
+ if (role !== "reviewer") return void 0;
13063
+ const lens = readPageSync(runDirectory, "admitted")?.lens;
13064
+ return lens === "completeness" || lens === "correctness" ? lens : void 0;
13065
+ }
13066
+ function relocateTicketProgressForLeg(input) {
13067
+ if (isUnboundRunDirectory(input.runDirectory)) return;
13068
+ const subjectDirectory = subjectDirectoryOfRun(input.runDirectory);
13069
+ if (subjectDirectory === void 0) return;
13070
+ const stagedPath = join11(input.runDirectory, LEG_PROGRESS_FILENAME);
13071
+ const mine = readProgressFile(stagedPath);
13072
+ if (mine.length === 0) {
13073
+ if (existsSync2(stagedPath)) {
13074
+ rmSync3(stagedPath, { force: true });
13075
+ }
13076
+ return;
13077
+ }
13078
+ const ticketLines = [...readTicketProgressLines(subjectDirectory)];
13079
+ const publishedReceipts = new Set(
13080
+ ticketLines.map((line2) => line2.receipt).filter((receipt) => typeof receipt === "string" && receipt !== "")
13081
+ );
13082
+ const pending = mine.filter((line2) => !publishedReceipts.has(line2.receipt));
13083
+ if (pending.length === 0) {
13084
+ rmSync3(stagedPath, { force: true });
13085
+ return;
13086
+ }
13087
+ const movedLines = [];
13088
+ for (const line2 of pending) {
13089
+ const lens = lensFromRunDirectory(input.runDirectory, line2.seat);
13090
+ const round = nextRoundFromLines(ticketLines, line2.seat, lens);
13091
+ const moved = {
13092
+ ...line2,
13093
+ round
13094
+ };
13095
+ movedLines.push(moved);
13096
+ ticketLines.push(moved);
13097
+ }
13098
+ const newCurrent = join11(subjectDirectory, CURRENT_FILENAME);
13099
+ mkdirSync3(dirname7(newCurrent), { recursive: true });
13100
+ appendFileSync2(
13101
+ newCurrent,
13102
+ `${movedLines.map((line2) => JSON.stringify(line2)).join("\n")}
13103
+ `,
13104
+ "utf8"
13105
+ );
13106
+ rmSync3(stagedPath, { force: true });
13107
+ }
13108
+ var CURRENT_FILENAME, LEG_PROGRESS_FILENAME;
13109
+ var init_ticket_progress = __esm({
13110
+ "src/ticket-progress.ts"() {
13111
+ "use strict";
13112
+ init_host_session_record();
13113
+ init_host_contracts();
13114
+ init_terminating_tools();
13115
+ init_packaged_role_registry();
13116
+ init_role_run_placement();
13117
+ init_run_dossier();
13118
+ init_sitian_reader();
13119
+ init_unknown_value();
13120
+ CURRENT_FILENAME = "current.jsonl";
13121
+ LEG_PROGRESS_FILENAME = "progress.jsonl";
13122
+ }
13123
+ });
13124
+
13125
+ // src/sha256.ts
13126
+ import { createHash } from "node:crypto";
13127
+ function sha256Hex(bytes) {
13128
+ return createHash("sha256").update(bytes).digest("hex");
13129
+ }
13130
+ var init_sha256 = __esm({
13131
+ "src/sha256.ts"() {
13132
+ "use strict";
13133
+ }
13134
+ });
13135
+
12990
13136
  // src/doctor-evidence.ts
12991
13137
  import { readdir as readdir2, readFile as readFile5, realpath, stat } from "node:fs/promises";
12992
- import { dirname as dirname7, relative as relative2, resolve as resolve4, sep as sep3 } from "node:path";
13138
+ import { dirname as dirname8, relative as relative3, resolve as resolve4, sep as sep4 } from "node:path";
12993
13139
  async function discoverCaseFiles(root) {
12994
13140
  const found = [];
12995
13141
  async function walk(dir, depth) {
@@ -13018,11 +13164,11 @@ async function stableRunsIdentity(root) {
13018
13164
  while (true) {
13019
13165
  try {
13020
13166
  const git2 = await stat(resolve4(cursor, ".git"));
13021
- if (git2.isDirectory() || git2.isFile()) return relative2(cursor, root).split(sep3).join("/");
13167
+ if (git2.isDirectory() || git2.isFile()) return relative3(cursor, root).split(sep4).join("/");
13022
13168
  } catch (error) {
13023
13169
  if (!isMissingPathError(error)) throw error;
13024
13170
  }
13025
- const parent = dirname7(cursor);
13171
+ const parent = dirname8(cursor);
13026
13172
  if (parent === cursor) return root;
13027
13173
  cursor = parent;
13028
13174
  }
@@ -13095,12 +13241,12 @@ async function loadDoctorCase(runsPath, projectRoot) {
13095
13241
  if (projectRoot !== void 0 && !physicallyContainedIn(projectRoot, root)) {
13096
13242
  throw new Error("doctor --runs escapes the project root");
13097
13243
  }
13098
- const match = root.split(sep3).join("/").match(/\/\.ak-roles\/books\/[^/]+\/(?:issues\/)?([1-9]\d*)\/runs$/);
13244
+ const match = root.split(sep4).join("/").match(/\/\.ak-roles\/books\/[^/]+\/(?:issues\/)?([1-9]\d*)\/runs$/);
13099
13245
  if (!match) throw new Error("Doctor case must be an .ak-roles/books/<book>/<n>/runs directory");
13100
13246
  const evidence = [], sessions = [], statuses = [], commits = [];
13101
13247
  const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
13102
13248
  for (const path of await discoverCaseFiles(root)) {
13103
- const id = relative2(root, path).split(sep3).join("/");
13249
+ const id = relative3(root, path).split(sep4).join("/");
13104
13250
  const bytes = await readFile5(path);
13105
13251
  const content = bytes.toString("utf8");
13106
13252
  const kind = id.split("/").length === 2 && id.endsWith("/log.jsonl") ? "log" : "session";
@@ -13285,7 +13431,7 @@ var init_session_dialogue = __esm({
13285
13431
 
13286
13432
  // src/ticket-provenance.ts
13287
13433
  import { readFile as readFile7 } from "node:fs/promises";
13288
- import { join as join11, resolve as resolve6 } from "node:path";
13434
+ import { join as join12, resolve as resolve6 } from "node:path";
13289
13435
  function ticketProvenanceSubject(ticketNumber) {
13290
13436
  if (!isSafePositiveTicketNumber(ticketNumber)) {
13291
13437
  throw new Error(
@@ -13308,7 +13454,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
13308
13454
  const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
13309
13455
  let history;
13310
13456
  try {
13311
- history = await readFile7(join11(runDirectory, RUN_HISTORY_FILE), "utf8");
13457
+ history = await readFile7(join12(runDirectory, RUN_HISTORY_FILE), "utf8");
13312
13458
  } catch (error) {
13313
13459
  if (errnoCode(error) === "ENOENT") return;
13314
13460
  throw error;
@@ -13364,7 +13510,7 @@ var init_uuidv7 = __esm({
13364
13510
  });
13365
13511
 
13366
13512
  // src/notary-source-run.ts
13367
- import { dirname as dirname8, isAbsolute as isAbsolute4, join as join12, resolve as resolve7, basename as basename7 } from "node:path";
13513
+ import { dirname as dirname9, isAbsolute as isAbsolute4, join as join13, resolve as resolve7, basename as basename8 } from "node:path";
13368
13514
  import { lstat as lstat2, realpath as realpath2 } from "node:fs/promises";
13369
13515
  async function readRetainedIdentity(runDirectory) {
13370
13516
  try {
@@ -13400,10 +13546,10 @@ async function requireRunDirectory(candidate, display) {
13400
13546
  `notary --source-run must be a run directory: ${display}`
13401
13547
  );
13402
13548
  }
13403
- const identity = parseRunLeaf(basename7(real));
13549
+ const identity = parseRunLeaf(basename8(real));
13404
13550
  if (identity === void 0) {
13405
13551
  throw new NotarySourceRunError(
13406
- `notary --source-run must be named <runId>@<role>: ${basename7(real)}`
13552
+ `notary --source-run must be named <runId>@<role>: ${basename8(real)}`
13407
13553
  );
13408
13554
  }
13409
13555
  return real;
@@ -13416,26 +13562,26 @@ async function resolveNotarySourceRunLocator(options) {
13416
13562
  const ledgerHome = resolveActivationLedgerHome(options.home);
13417
13563
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
13418
13564
  const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
13419
- const bookRunsRoot = join12(bookDirectory, "runs");
13565
+ const bookRunsRoot = join13(bookDirectory, "runs");
13420
13566
  let candidate;
13421
13567
  const bare = parseRunLeaf(raw);
13422
13568
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
13423
- candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join12(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
13569
+ candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join13(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
13424
13570
  } else {
13425
13571
  candidate = isAbsolute4(raw) ? raw : resolve7(options.projectRoot, raw);
13426
- const identity2 = parseRunLeaf(basename7(candidate));
13427
- const subjectDirectory = dirname8(dirname8(candidate));
13428
- const isLegacyUnboundLocator = identity2 !== void 0 && basename7(dirname8(candidate)) === "runs" && basename7(subjectDirectory) === "unbound" && resolve7(dirname8(subjectDirectory)) === resolve7(bookDirectory);
13572
+ const identity2 = parseRunLeaf(basename8(candidate));
13573
+ const subjectDirectory = dirname9(dirname9(candidate));
13574
+ const isLegacyUnboundLocator = identity2 !== void 0 && basename8(dirname9(candidate)) === "runs" && basename8(subjectDirectory) === "unbound" && resolve7(dirname9(subjectDirectory)) === resolve7(bookDirectory);
13429
13575
  if (isLegacyUnboundLocator) {
13430
13576
  candidate = await resolveLiveRunDirectoryPath(candidate, options.home ?? ledgerHome, bookKey) ?? candidate;
13431
13577
  }
13432
13578
  }
13433
13579
  const real = await requireRunDirectory(candidate, raw);
13434
- const identity = parseRunLeaf(basename7(real));
13580
+ const identity = parseRunLeaf(basename8(real));
13435
13581
  const bookIdentity = physicalPathIdentity(bookDirectory);
13436
- const parentIdentity = physicalPathIdentity(dirname8(real));
13437
- const subjectBookIdentity = physicalPathIdentity(dirname8(dirname8(dirname8(real))));
13438
- if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename7(dirname8(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
13582
+ const parentIdentity = physicalPathIdentity(dirname9(real));
13583
+ const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
13584
+ if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename8(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
13439
13585
  throw new NotarySourceRunError(
13440
13586
  "notary --source-run must resolve to a retained run under the project machine-ledger book"
13441
13587
  );
@@ -14110,8 +14256,8 @@ var init_option_definitions = __esm({
14110
14256
  repeatable: false,
14111
14257
  form: "option",
14112
14258
  description: {
14113
- en: "Required source run locator (runId@role under the book home, or path to that run directory). Zero prompt/attachment projection.",
14114
- zh: "\u5FC5\u586B\u6E90 run \u5B9A\u4F4D\u7B26\uFF08\u7C3F\u5185 runId@role\uFF0C\u6216\u8BE5 run \u76EE\u5F55\u8DEF\u5F84\uFF09\u3002\u96F6 prompt/\u9644\u4EF6\u6295\u5F71\u3002"
14259
+ 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.",
14260
+ 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"
14115
14261
  }
14116
14262
  }
14117
14263
  ];
@@ -14446,7 +14592,7 @@ var init_option_definitions = __esm({
14446
14592
  },
14447
14593
  notary: {
14448
14594
  command: "notary",
14449
- summary: "Direct Notary summons; duties: souls/notary.md. Zero prompt/attachment.",
14595
+ 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.",
14450
14596
  usage: ["ak-role notary --source-run <runId@role|path> [options]"],
14451
14597
  examples: [
14452
14598
  "ak-role notary --source-run 01a034f1-75bf-71a6-bcf5-d1299145b1a5@judge",
@@ -14507,7 +14653,7 @@ var init_option_definitions = __esm({
14507
14653
  },
14508
14654
  resume: {
14509
14655
  command: "resume",
14510
- summary: "Resume a role run under the live seat table (model/host/engine); session principal must still exist. Every callable seat, including Notary/\u7B26\u5B9D\u90CE, accepts the optional caller message and passes it through unchanged as the continuation prompt. Notary explicit new still accepts only its source-run locator, not a caller prompt. 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).",
14656
+ 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).",
14511
14657
  usage: ["ak-role resume <runId> [message]"],
14512
14658
  examples: [
14513
14659
  "ak-role resume 01abc\u2026",
@@ -14538,14 +14684,14 @@ var init_option_definitions = __esm({
14538
14684
 
14539
14685
  // src/public-cli/invocation.ts
14540
14686
  import { execFileSync as execFileSync2 } from "node:child_process";
14541
- import { existsSync as existsSync2 } from "node:fs";
14687
+ import { existsSync as existsSync3 } from "node:fs";
14542
14688
  import {
14543
14689
  readFile as readFile8,
14544
14690
  realpath as realpath3,
14545
14691
  rename,
14546
14692
  writeFile as writeFile2
14547
14693
  } from "node:fs/promises";
14548
- import { dirname as dirname9, isAbsolute as isAbsolute5, join as join13, resolve as resolve8 } from "node:path";
14694
+ import { dirname as dirname10, isAbsolute as isAbsolute5, join as join14, resolve as resolve8 } from "node:path";
14549
14695
  function admittedSourceRunPath(admitted) {
14550
14696
  if (!isRecord(admitted)) return void 0;
14551
14697
  const path = admitted.sourceRunPath;
@@ -14704,35 +14850,36 @@ async function recordAdmittedCorrelation(admitted, correlationId) {
14704
14850
  mutable.correlationId = correlationId;
14705
14851
  mutable.correlationIds = correlationIds;
14706
14852
  }
14707
- async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
14708
- if (admitted.ticketNumber === void 0 || !isUnboundRunDirectory(admitted.runDirectory)) return void 0;
14709
- const oldRunDirectory = admitted.runDirectory;
14710
- const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(oldRunDirectory));
14711
- const target = roleRunPlacement(ledgerHome, {
14712
- bookKey: admitted.bookKey,
14713
- subject: { ticketNumber: admitted.ticketNumber },
14714
- runId: admitted.runId,
14715
- role: admitted.role
14716
- });
14717
- ensureRoleRunDirectory(ledgerHome, dirname9(target.runDirectory));
14718
- const principal = authority.seal(target);
14719
- if (admitted.role !== "diarist") {
14720
- const childRunIds = readPageSync(oldRunDirectory, "admitted")?.childDiaristRunIds;
14721
- for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
14722
- if (typeof childRunId !== "string") continue;
14723
- const childDirectory = join13(dirname9(oldRunDirectory), formatRunLeaf(childRunId, "diarist"));
14724
- if (!existsSync2(childDirectory)) continue;
14725
- const childTarget = roleRunPlacement(ledgerHome, {
14726
- bookKey: admitted.bookKey,
14727
- subject: { ticketNumber: admitted.ticketNumber },
14728
- runId: childRunId,
14729
- role: "diarist"
14853
+ async function relocateRegisteredChildDiarists(input) {
14854
+ const childRunIds = readPageSync(input.parentRunDirectory, "admitted")?.childDiaristRunIds;
14855
+ for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
14856
+ if (typeof childRunId !== "string") continue;
14857
+ const childTarget = roleRunPlacement(input.ledgerHome, {
14858
+ bookKey: input.bookKey,
14859
+ subject: { ticketNumber: input.ticketNumber },
14860
+ runId: childRunId,
14861
+ role: "diarist"
14862
+ });
14863
+ const unboundChildDirectory = roleRunPlacement(input.ledgerHome, {
14864
+ bookKey: input.bookKey,
14865
+ subject: { unbound: true },
14866
+ runId: childRunId,
14867
+ role: "diarist"
14868
+ }).runDirectory;
14869
+ if (existsSync3(unboundChildDirectory)) {
14870
+ input.authority.seal(childTarget);
14871
+ await bindTicketNumberOnRunDirectory(unboundChildDirectory, input.ticketNumber);
14872
+ await rehomeUnboundTicketProvenance(
14873
+ unboundChildDirectory,
14874
+ input.ticketNumber,
14875
+ input.projectRoot,
14876
+ homeFromRunDirectory(input.parentRunDirectory)
14877
+ );
14878
+ ensureRoleRunDirectory(input.ledgerHome, dirname10(childTarget.runDirectory));
14879
+ await rename(unboundChildDirectory, childTarget.runDirectory);
14880
+ relocateTicketProgressForLeg({
14881
+ runDirectory: childTarget.runDirectory
14730
14882
  });
14731
- authority.seal(childTarget);
14732
- await bindTicketNumberOnRunDirectory(childDirectory, admitted.ticketNumber);
14733
- await rehomeUnboundTicketProvenance(childDirectory, admitted.ticketNumber, admitted.projectRoot, homeFromRunDirectory(oldRunDirectory));
14734
- ensureRoleRunDirectory(ledgerHome, dirname9(childTarget.runDirectory));
14735
- await rename(childDirectory, childTarget.runDirectory);
14736
14883
  try {
14737
14884
  renderCurrentSync(childTarget.runDirectory);
14738
14885
  } catch (error) {
@@ -14741,18 +14888,71 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
14741
14888
  `
14742
14889
  );
14743
14890
  }
14891
+ continue;
14892
+ }
14893
+ if (existsSync3(childTarget.runDirectory)) {
14894
+ relocateTicketProgressForLeg({
14895
+ runDirectory: childTarget.runDirectory
14896
+ });
14744
14897
  }
14745
14898
  }
14899
+ }
14900
+ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
14901
+ if (admitted.ticketNumber === void 0) return void 0;
14902
+ const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(admitted.runDirectory));
14903
+ if (!isUnboundRunDirectory(admitted.runDirectory)) {
14904
+ relocateTicketProgressForLeg({
14905
+ runDirectory: admitted.runDirectory
14906
+ });
14907
+ if (admitted.role !== "diarist") {
14908
+ await relocateRegisteredChildDiarists({
14909
+ parentRunDirectory: admitted.runDirectory,
14910
+ bookKey: admitted.bookKey,
14911
+ ticketNumber: admitted.ticketNumber,
14912
+ projectRoot: admitted.projectRoot,
14913
+ ledgerHome,
14914
+ authority
14915
+ });
14916
+ }
14917
+ return void 0;
14918
+ }
14919
+ const oldRunDirectory = admitted.runDirectory;
14920
+ const target = roleRunPlacement(ledgerHome, {
14921
+ bookKey: admitted.bookKey,
14922
+ subject: { ticketNumber: admitted.ticketNumber },
14923
+ runId: admitted.runId,
14924
+ role: admitted.role
14925
+ });
14926
+ ensureRoleRunDirectory(ledgerHome, dirname10(target.runDirectory));
14927
+ authority.seal(target);
14928
+ if (admitted.role !== "diarist") {
14929
+ await relocateRegisteredChildDiarists({
14930
+ parentRunDirectory: oldRunDirectory,
14931
+ bookKey: admitted.bookKey,
14932
+ ticketNumber: admitted.ticketNumber,
14933
+ projectRoot: admitted.projectRoot,
14934
+ ledgerHome,
14935
+ authority
14936
+ });
14937
+ }
14746
14938
  if (admitted.role === "diarist") {
14747
14939
  await rehomeUnboundTicketProvenance(oldRunDirectory, admitted.ticketNumber, admitted.projectRoot, homeFromRunDirectory(oldRunDirectory));
14748
14940
  }
14749
14941
  await rename(oldRunDirectory, target.runDirectory);
14750
14942
  heldLease?.relocate(target.runDirectory);
14943
+ const actualSessionDirectory = sessionDirectoryOf(target.runDirectory);
14944
+ const principal = authority.seal({
14945
+ sessionDirectory: actualSessionDirectory,
14946
+ sessionFile: sessionFileIn(actualSessionDirectory)
14947
+ });
14751
14948
  rewriteAdmittedRoleRunPage(
14752
14949
  admitted,
14753
14950
  [{ oldRunDirectory, newRunDirectory: target.runDirectory }]
14754
14951
  );
14755
14952
  admitted.principal = principal;
14953
+ relocateTicketProgressForLeg({
14954
+ runDirectory: target.runDirectory
14955
+ });
14756
14956
  renderCurrentSync(target.runDirectory);
14757
14957
  return { oldRunDirectory, newRunDirectory: target.runDirectory };
14758
14958
  }
@@ -14788,7 +14988,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
14788
14988
  async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
14789
14989
  const rolePackageRoot = packageRoot2;
14790
14990
  const raw = JSON.parse(
14791
- await readFile8(join13(rolePackageRoot, "package.json"), "utf8")
14991
+ await readFile8(join14(rolePackageRoot, "package.json"), "utf8")
14792
14992
  );
14793
14993
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
14794
14994
  throw new Error(
@@ -15346,7 +15546,7 @@ async function admitPublicRole(role, parsed, env, override) {
15346
15546
  resolutionScope: [...derived.resolutionScope],
15347
15547
  authorizedChecks: []
15348
15548
  });
15349
- const mergerInputPath = join13(placed.runDirectory, "merger-input.json");
15549
+ const mergerInputPath = join14(placed.runDirectory, "merger-input.json");
15350
15550
  await writeFile2(
15351
15551
  mergerInputPath,
15352
15552
  `${JSON.stringify(mergerInput, null, 2)}
@@ -15493,9 +15693,6 @@ function appendCallerFileFlagPaths(body, attachments, requestManifestPath, prere
15493
15693
  }
15494
15694
  function buildInstructionTransportPrompt(admitted) {
15495
15695
  const kind = admittedTransportPromptKind(admitted);
15496
- if (kind === "fixed-kickoff") {
15497
- return "";
15498
- }
15499
15696
  if (kind === "baseline") {
15500
15697
  if (admitted.baseRevision === void 0) {
15501
15698
  throw new Error("baseline transport prompt is missing the bound revision");
@@ -15617,7 +15814,7 @@ function parseDoctorIssueNumber(raw) {
15617
15814
  }
15618
15815
  async function resolveDoctorCaseRunsPath(options) {
15619
15816
  const ledgerHome = resolveActivationLedgerHome(options.home);
15620
- const defaultRuns = join13(
15817
+ const defaultRuns = join14(
15621
15818
  activationBookDirectory(ledgerHome, options.bookKey),
15622
15819
  String(options.issueNumber),
15623
15820
  "runs"
@@ -15690,11 +15887,11 @@ function parseAnalystCohortIssueToken(raw, flag) {
15690
15887
  `${flag} requires a comma-separated list of N or book:N`
15691
15888
  );
15692
15889
  }
15693
- const sep5 = trimmed.lastIndexOf(":");
15694
- if (sep5 > 0) {
15695
- const rhs = trimmed.slice(sep5 + 1);
15890
+ const sep6 = trimmed.lastIndexOf(":");
15891
+ if (sep6 > 0) {
15892
+ const rhs = trimmed.slice(sep6 + 1);
15696
15893
  if (parseTicketNumber(rhs) !== void 0) {
15697
- const bookKey = trimmed.slice(0, sep5);
15894
+ const bookKey = trimmed.slice(0, sep6);
15698
15895
  if (bookKey.trim() === "") {
15699
15896
  throw new CliUsageError(
15700
15897
  `${flag} book:N requires a non-empty book key, got ${raw}`
@@ -15891,6 +16088,7 @@ var init_invocation = __esm({
15891
16088
  init_activation_ledger_topology();
15892
16089
  init_activation_ledger_git();
15893
16090
  init_role_run_placement();
16091
+ init_ticket_progress();
15894
16092
  init_packaged_role_registry();
15895
16093
  init_run_ticket_number();
15896
16094
  init_role_run_relocation();
@@ -16102,6 +16300,7 @@ var init_submission_ledger = __esm({
16102
16300
  init_report_ticket_tool();
16103
16301
  init_review_submission();
16104
16302
  init_run_ticket_number();
16303
+ init_ticket_progress();
16105
16304
  init_unknown_value();
16106
16305
  }
16107
16306
  });
@@ -16272,7 +16471,7 @@ var init_engine_detour_usage = __esm({
16272
16471
  });
16273
16472
 
16274
16473
  // src/dossier-resolution.ts
16275
- import { existsSync as existsSync3, statSync as statSync5 } from "node:fs";
16474
+ import { existsSync as existsSync4, statSync as statSync5 } from "node:fs";
16276
16475
  import { resolve as resolve9 } from "node:path";
16277
16476
  function isHostContext(value) {
16278
16477
  return "sessionManager" in value;
@@ -16292,7 +16491,7 @@ function resolveAuditDossier(source) {
16292
16491
  }
16293
16492
  const runDirectory = resolve9(raw);
16294
16493
  try {
16295
- if (!existsSync3(runDirectory) || !statSync5(runDirectory).isDirectory()) {
16494
+ if (!existsSync4(runDirectory) || !statSync5(runDirectory).isDirectory()) {
16296
16495
  return { status: "incomplete", observation: { kind: "missing-dossier" } };
16297
16496
  }
16298
16497
  } catch {
@@ -17494,12 +17693,12 @@ var init_settlement = __esm({
17494
17693
  });
17495
17694
 
17496
17695
  // src/external-host-turn-loop.ts
17497
- import { existsSync as existsSync4 } from "node:fs";
17498
- import { basename as basename8 } from "node:path";
17696
+ import { existsSync as existsSync5 } from "node:fs";
17697
+ import { basename as basename9 } from "node:path";
17499
17698
  async function syncTurnRequestLivePlacement(request, authority) {
17500
17699
  const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
17501
17700
  if (live === void 0) {
17502
- const parsed = parseRunLeaf(basename8(request.runDirectory));
17701
+ const parsed = parseRunLeaf(basename9(request.runDirectory));
17503
17702
  throw new Error(
17504
17703
  `admitted run ${parsed?.runId ?? "(unparseable)"} missing after host turn; not found under ${request.home}`
17505
17704
  );
@@ -17511,7 +17710,7 @@ async function syncTurnRequestLivePlacement(request, authority) {
17511
17710
  }
17512
17711
  async function retainPackageFaultBesideLivePlacement(request, input) {
17513
17712
  let runDirectory = request.runDirectory;
17514
- if (!existsSync4(runDirectory)) {
17713
+ if (!existsSync5(runDirectory)) {
17515
17714
  try {
17516
17715
  const found = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
17517
17716
  if (found === void 0) {
@@ -17559,9 +17758,9 @@ var init_external_host_turn_loop = __esm({
17559
17758
  });
17560
17759
 
17561
17760
  // src/session-identity.ts
17562
- import { dirname as dirname10, join as join14 } from "node:path";
17761
+ import { join as join15 } from "node:path";
17563
17762
  function createSessionIdentityAuthority(authority, hostName) {
17564
- const runDirectoryOf = (principal) => dirname10(authority.decode(principal).sessionDirectory);
17763
+ const runDirectoryOf = (principal) => runDirectoryFromSessionDirectory(authority.decode(principal).sessionDirectory);
17565
17764
  return {
17566
17765
  principalAuthority: authority,
17567
17766
  resolveSessionFile(principal) {
@@ -17569,7 +17768,7 @@ function createSessionIdentityAuthority(authority, hostName) {
17569
17768
  },
17570
17769
  async load(principal) {
17571
17770
  const runDirectory = runDirectoryOf(principal);
17572
- const { records, diagnostics } = await readSitianRecords(join14(runDirectory, RUN_STATE_FILE));
17771
+ const { records, diagnostics } = await readSitianRecords(join15(runDirectory, RUN_STATE_FILE));
17573
17772
  if (diagnostics.length > 0) {
17574
17773
  throw new Error(
17575
17774
  `${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
@@ -17616,6 +17815,7 @@ var init_session_identity = __esm({
17616
17815
  "src/session-identity.ts"() {
17617
17816
  "use strict";
17618
17817
  init_host_descriptions();
17818
+ init_role_run_placement();
17619
17819
  init_run_dossier();
17620
17820
  init_sitian_facade();
17621
17821
  init_unknown_value();
@@ -17638,14 +17838,14 @@ __export(role_turn_host_exports, {
17638
17838
  });
17639
17839
  import { execFile as execFile2, spawn } from "node:child_process";
17640
17840
  import { constants as constants2 } from "node:fs";
17641
- import { existsSync as existsSync5 } from "node:fs";
17841
+ import { existsSync as existsSync6 } from "node:fs";
17642
17842
  import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
17643
- import { delimiter, dirname as dirname11, isAbsolute as isAbsolute6, join as join15, resolve as resolve10 } from "node:path";
17843
+ import { delimiter, dirname as dirname11, isAbsolute as isAbsolute6, join as join16, resolve as resolve10 } from "node:path";
17644
17844
  import { platform } from "node:process";
17645
17845
  import { promisify as promisify2 } from "node:util";
17646
17846
  import { randomUUID as randomUUID4 } from "node:crypto";
17647
17847
  function resolveInternalRoleEntrypoint(packageRoot2) {
17648
- return join15(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
17848
+ return join16(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
17649
17849
  }
17650
17850
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
17651
17851
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -17835,7 +18035,7 @@ function createDefaultPiSpawnRunner(options) {
17835
18035
  homeFromRunDirectory(spawnDir)
17836
18036
  );
17837
18037
  } catch (resolveError) {
17838
- runDirectory = existsSync5(spawnDir) ? spawnDir : void 0;
18038
+ runDirectory = existsSync6(spawnDir) ? spawnDir : void 0;
17839
18039
  const resolveDiagnostic = `live run path resolve failed beside Pi transport fault: ${describeErrorIdentity(resolveError)}`;
17840
18040
  if (runDirectory !== void 0) {
17841
18041
  await retainPackageFault({
@@ -17888,7 +18088,8 @@ function createPiRoleTurnHost(config) {
17888
18088
  config.extraPiArgs ?? []
17889
18089
  );
17890
18090
  const args = buildExplicitInternalActivationArgs(roleEntry, extraArgs);
17891
- const stdin = encodeUserDialogueStdin(piUserDialogueBody(turnRequest));
18091
+ const transportBody = piUserDialogueBody(turnRequest);
18092
+ const stdin = encodeUserDialogueStdin(transportBody);
17892
18093
  const env = {
17893
18094
  ...process.env,
17894
18095
  HOME: request.home,
@@ -17904,6 +18105,7 @@ function createPiRoleTurnHost(config) {
17904
18105
  else env.AK_ROLE_INVOCATION_SCOPE = request.invocationScopeId;
17905
18106
  if (request.host === void 0 || request.host.trim() === "") delete env.AK_ROLE_HOST;
17906
18107
  else env.AK_ROLE_HOST = request.host.trim();
18108
+ delete env.AK_ROLE_SUMMONS_INSTRUCTION;
17907
18109
  if (request.deliveryRequestLimit === void 0) delete env[RECEIPT_DELIVERY_LIMIT_ENV];
17908
18110
  else env[RECEIPT_DELIVERY_LIMIT_ENV] = String(request.deliveryRequestLimit);
17909
18111
  applyEngineChildEnv(env, request.engine);
@@ -18036,17 +18238,17 @@ var init_role_turn_host = __esm({
18036
18238
  });
18037
18239
 
18038
18240
  // src/public-cli/load-production-acp-host.ts
18039
- import { existsSync as existsSync6 } from "node:fs";
18040
- import { join as join16 } from "node:path";
18241
+ import { existsSync as existsSync7 } from "node:fs";
18242
+ import { join as join17 } from "node:path";
18041
18243
  import { pathToFileURL } from "node:url";
18042
18244
  async function loadProductionAcpHostFactory(packageRoot2, host) {
18043
18245
  const description = lookupHostDescription(host);
18044
18246
  if (description === void 0) {
18045
18247
  throw new Error(`unregistered host: ${host}`);
18046
18248
  }
18047
- const built = join16(packageRoot2, "dist/acp-host/production-host.js");
18048
- const source = join16(packageRoot2, "src/acp-host/production-host.ts");
18049
- const target = existsSync6(built) ? built : source;
18249
+ const built = join17(packageRoot2, "dist/acp-host/production-host.js");
18250
+ const source = join17(packageRoot2, "src/acp-host/production-host.ts");
18251
+ const target = existsSync7(built) ? built : source;
18050
18252
  const href = pathToFileURL(target).href;
18051
18253
  const mod = await import(href);
18052
18254
  const create = mod.createProductionAcpRoleTurnHost;
@@ -18060,17 +18262,17 @@ var init_load_production_acp_host = __esm({
18060
18262
  });
18061
18263
 
18062
18264
  // src/public-cli/load-production-headless-host.ts
18063
- import { existsSync as existsSync7 } from "node:fs";
18064
- import { join as join17 } from "node:path";
18265
+ import { existsSync as existsSync8 } from "node:fs";
18266
+ import { join as join18 } from "node:path";
18065
18267
  import { pathToFileURL as pathToFileURL2 } from "node:url";
18066
18268
  async function loadProductionHeadlessHostFactory(packageRoot2, host) {
18067
18269
  const description = lookupHeadlessHostDescription(host);
18068
18270
  if (description === void 0) {
18069
18271
  throw new Error(`unregistered headless host: ${host}`);
18070
18272
  }
18071
- const built = join17(packageRoot2, "dist/headless-host/production-host.js");
18072
- const source = join17(packageRoot2, "src/headless-host/production-host.ts");
18073
- const target = existsSync7(built) ? built : source;
18273
+ const built = join18(packageRoot2, "dist/headless-host/production-host.js");
18274
+ const source = join18(packageRoot2, "src/headless-host/production-host.ts");
18275
+ const target = existsSync8(built) ? built : source;
18074
18276
  const href = pathToFileURL2(target).href;
18075
18277
  const mod = await import(href);
18076
18278
  const create = mod.createProductionHeadlessRoleTurnHost;
@@ -18237,14 +18439,14 @@ var init_role_seat_runtime = __esm({
18237
18439
  });
18238
18440
 
18239
18441
  // src/session-opening-materials.ts
18240
- import { existsSync as existsSync8 } from "node:fs";
18442
+ import { existsSync as existsSync9 } from "node:fs";
18241
18443
  import { readFile as readFile9 } from "node:fs/promises";
18242
- import { dirname as dirname12, join as join18 } from "node:path";
18444
+ import { dirname as dirname12, join as join19 } from "node:path";
18243
18445
  import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
18244
18446
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
18245
18447
  let dir = dirname12(fileURLToPath(moduleUrl));
18246
18448
  for (let i = 0; i < 8; i += 1) {
18247
- if (existsSync8(join18(dir, "package.json")) && existsSync8(join18(dir, "souls"))) {
18449
+ if (existsSync9(join19(dir, "package.json")) && existsSync9(join19(dir, "souls"))) {
18248
18450
  return dir;
18249
18451
  }
18250
18452
  const parent = dirname12(dir);
@@ -18543,7 +18745,7 @@ __export(auditor_soul_exports, {
18543
18745
  readAuditorResumeBinding: () => readAuditorResumeBinding,
18544
18746
  resolveAuditorSubject: () => resolveAuditorSubject
18545
18747
  });
18546
- import { basename as basename9 } from "node:path";
18748
+ import { basename as basename10 } from "node:path";
18547
18749
  function auditorSoulRelativePath(role) {
18548
18750
  return `souls/${role}-auditor.md`;
18549
18751
  }
@@ -18579,7 +18781,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
18579
18781
  return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
18580
18782
  }
18581
18783
  function subjectFromSourceDirectory(sourceRunDirectory) {
18582
- const role = parseRunLeaf(basename9(sourceRunDirectory))?.role;
18784
+ const role = parseRunLeaf(basename10(sourceRunDirectory))?.role;
18583
18785
  return isAuditorSoulRole(role) ? role : void 0;
18584
18786
  }
18585
18787
  async function readAuditorResumeBinding(admitted) {
@@ -18948,7 +19150,8 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
18948
19150
  ...options.invocationScopeId === void 0 || options.invocationScopeId.length === 0 ? {} : { invocationScopeId: options.invocationScopeId },
18949
19151
  ...options.stationChild === void 0 ? {} : { stationChild: options.stationChild },
18950
19152
  ...options.navigatorByStatusPrepare === void 0 ? {} : { navigatorByStatusPrepare: options.navigatorByStatusPrepare },
18951
- ...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit }
19153
+ ...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit },
19154
+ ...options.host === void 0 || options.host.trim() === "" ? {} : { host: options.host.trim() }
18952
19155
  };
18953
19156
  }
18954
19157
  function packagedSettleSkill(admitted) {
@@ -19117,6 +19320,7 @@ __export(instruction_seat_run_exports, {
19117
19320
  NOTARY_FIXED_DISPATCH: () => NOTARY_FIXED_DISPATCH,
19118
19321
  buildInstructionSeatTurnRequest: () => buildInstructionSeatTurnRequest,
19119
19322
  continueParentAfterChild: () => continueParentAfterChild,
19323
+ resolveReviewSeatDialogueBody: () => resolveReviewSeatDialogueBody,
19120
19324
  runPublicInstructionSeat: () => runPublicInstructionSeat,
19121
19325
  runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
19122
19326
  });
@@ -19187,7 +19391,8 @@ async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io,
19187
19391
  {
19188
19392
  runId: admitted.runId,
19189
19393
  runDirectory: admitted.runDirectory,
19190
- summons: { instruction: message }
19394
+ message,
19395
+ summons: { instructionEmpty: true }
19191
19396
  },
19192
19397
  next,
19193
19398
  io
@@ -19214,7 +19419,8 @@ async function reaskMissingTicketOnce(admitted, terminal, env, io) {
19214
19419
  {
19215
19420
  runId: admitted.runId,
19216
19421
  runDirectory: admitted.runDirectory,
19217
- summons: { instruction }
19422
+ message: instruction,
19423
+ summons: { instructionEmpty: true }
19218
19424
  },
19219
19425
  softReaskEnv,
19220
19426
  io
@@ -19327,26 +19533,26 @@ async function loadLedgerPeerBody(sourceRunDirectory, projectRoot, home) {
19327
19533
  return readableGateItem(latest.accepted);
19328
19534
  }
19329
19535
  async function resolveReviewSeatDialogueBody(input) {
19330
- const reask = input.reask;
19331
- if (reask !== void 0 && reask.length > 0) return reask;
19536
+ if (input.role === "notary") {
19537
+ if (input.reviewReask !== void 0) return input.reviewReask;
19538
+ return NOTARY_FIXED_DISPATCH;
19539
+ }
19540
+ const preferred = input.reviewReask ?? input.gateReviewInstruction;
19541
+ if (preferred !== void 0 && preferred.length > 0) return preferred;
19332
19542
  const caller = input.callerInstruction ?? "";
19333
19543
  if (caller.length > 0) return caller;
19334
19544
  const sourceRunPath = admittedSourceRunPath(input)?.trim();
19335
19545
  if (sourceRunPath === void 0) return void 0;
19336
- if (input.role === "notary") {
19337
- const { isTicketCourtCountersignSource: isTicketCourtCountersignSource2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
19338
- if (isTicketCourtCountersignSource2(sourceRunPath)) return NOTARY_FIXED_DISPATCH;
19339
- }
19340
19546
  return await loadLedgerPeerBody(sourceRunPath, input.projectRoot, input.home);
19341
19547
  }
19342
- async function resolveInitialPrompt(admitted, env) {
19548
+ async function resolveInitialTurnPrompt(admitted, env) {
19343
19549
  const record = roleRecord(admitted.role);
19344
19550
  if ("reaskPrompt" in record && record.reaskPrompt === true) {
19345
19551
  const sourceRunPath = admittedSourceRunPath(admitted);
19346
- const reask = env.reviewReask ?? env.gateReviewInstruction;
19347
19552
  const body = await resolveReviewSeatDialogueBody({
19348
19553
  role: admitted.role,
19349
- ...reask === void 0 ? {} : { reask },
19554
+ ...env.reviewReask === void 0 ? {} : { reviewReask: env.reviewReask },
19555
+ ...env.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: env.gateReviewInstruction },
19350
19556
  callerInstruction: admitted.instruction,
19351
19557
  ...sourceRunPath === void 0 ? {} : { sourceRunPath },
19352
19558
  projectRoot: admitted.projectRoot,
@@ -19436,7 +19642,7 @@ async function dispatchAdmitted(admitted, env, io) {
19436
19642
  if (activeEnv.correlationId !== void 0 && activeEnv.correlationId.trim() !== "") {
19437
19643
  await recordAdmittedCorrelation(admitted, activeEnv.correlationId);
19438
19644
  }
19439
- const initialPromptText = await resolveInitialPrompt(admitted, activeEnv);
19645
+ const initialPrompt = await resolveInitialTurnPrompt(admitted, activeEnv);
19440
19646
  const auto = "inCallAutoResume" in record && record.inCallAutoResume === true;
19441
19647
  if (auto) {
19442
19648
  return await runPostAdmissionResumable({
@@ -19447,14 +19653,14 @@ async function dispatchAdmitted(admitted, env, io) {
19447
19653
  admitted,
19448
19654
  roleTurnOptions(activeEnv, admitted, {
19449
19655
  kind: "initial",
19450
- prompt: initialPromptText
19656
+ prompt: initialPrompt
19451
19657
  })
19452
19658
  ),
19453
19659
  buildResumeRequest: () => buildInstructionSeatTurnRequest(
19454
19660
  admitted,
19455
19661
  roleTurnOptions(activeEnv, admitted, {
19456
19662
  kind: "resume",
19457
- prompt: buildAutoResumeContinuationPrompt()
19663
+ prompt: initialPrompt
19458
19664
  })
19459
19665
  ),
19460
19666
  adapters,
@@ -19469,7 +19675,7 @@ async function dispatchAdmitted(admitted, env, io) {
19469
19675
  admitted,
19470
19676
  roleTurnOptions(activeEnv, admitted, {
19471
19677
  kind: "initial",
19472
- prompt: initialPromptText
19678
+ prompt: initialPrompt
19473
19679
  })
19474
19680
  ),
19475
19681
  adapters,
@@ -19554,22 +19760,26 @@ function resumeSameParentInstructionSeat(input) {
19554
19760
  ...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber },
19555
19761
  freshSummons: input.env.freshSummons,
19556
19762
  summons: input.summons,
19557
- resume: (runId, materials, runDirectory) => runPublicInstructionSeatResume(
19558
- {
19559
- runId,
19560
- runDirectory,
19561
- ...materials === void 0 ? {} : { summons: materials }
19562
- },
19563
- input.env,
19564
- input.io
19565
- )
19763
+ resume: (runId, materials, runDirectory) => {
19764
+ const reask = input.env.reviewReask;
19765
+ return runPublicInstructionSeatResume(
19766
+ {
19767
+ runId,
19768
+ runDirectory,
19769
+ ...reask === void 0 ? {} : { message: reask },
19770
+ ...materials === void 0 ? {} : { summons: materials }
19771
+ },
19772
+ input.env,
19773
+ input.io
19774
+ );
19775
+ }
19566
19776
  });
19567
19777
  }
19568
19778
  async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot, role) {
19569
- const reask = env.reviewReask ?? env.gateReviewInstruction;
19570
19779
  const body = await resolveReviewSeatDialogueBody({
19571
19780
  role,
19572
- ...reask === void 0 ? {} : { reask },
19781
+ ...env.reviewReask === void 0 ? {} : { reviewReask: env.reviewReask },
19782
+ ...env.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: env.gateReviewInstruction },
19573
19783
  callerInstruction: fallback.instruction,
19574
19784
  sourceRunPath,
19575
19785
  projectRoot,
@@ -19581,20 +19791,30 @@ async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot, rol
19581
19791
  return fallback;
19582
19792
  }
19583
19793
  async function runCountersignBody(parsed, env, io) {
19794
+ const projectRoot = resolve11(parsed.project ?? env.cwd);
19584
19795
  const gateParentRunPath = typeof env.parentRunPath === "string" && env.parentRunPath.trim() !== "" ? env.parentRunPath : void 0;
19585
19796
  if (gateParentRunPath !== void 0) {
19586
- const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction ?? parsed.instruction ?? "";
19797
+ const dialogue = await sameParentDialogue(
19798
+ env,
19799
+ {
19800
+ instruction: parsed.instruction ?? "",
19801
+ instructionEmpty: (parsed.instruction ?? "").length === 0
19802
+ },
19803
+ gateParentRunPath,
19804
+ projectRoot,
19805
+ "countersign"
19806
+ );
19587
19807
  const resumed = await resumeSameParentInstructionSeat({
19588
19808
  env,
19589
19809
  io,
19590
- projectRoot: resolve11(parsed.project ?? env.cwd),
19810
+ projectRoot,
19591
19811
  role: "countersign",
19592
19812
  parentRunPath: gateParentRunPath,
19593
19813
  ...isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {},
19594
19814
  summons: {
19595
19815
  sourceRunPath: gateParentRunPath,
19596
- instruction: resumeInstruction,
19597
- instructionEmpty: resumeInstruction.length === 0,
19816
+ instruction: dialogue.instruction,
19817
+ instructionEmpty: dialogue.instructionEmpty,
19598
19818
  // #1166 J11: same-parent resume delivers this call's file-flag paths
19599
19819
  // through the shared summons → appendCallerFileFlagPaths rule.
19600
19820
  attachmentPaths: parsed.attachmentPaths ?? []
@@ -19629,10 +19849,9 @@ async function runCountersignBody(parsed, env, io) {
19629
19849
  await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
19630
19850
  admitted = { ...admitted, sourceRunPath: gateParentRunPath };
19631
19851
  }
19632
- const reviewBody = env.reviewReask ?? env.gateReviewInstruction;
19633
19852
  const turnProjection = roleTurnOptions(env, admitted, {
19634
19853
  kind: "initial",
19635
- prompt: reviewBody !== void 0 ? appendCallerFileFlagPaths(reviewBody, admitted.attachments) : buildInstructionTransportPrompt(admitted)
19854
+ prompt: await resolveInitialTurnPrompt(admitted, env)
19636
19855
  });
19637
19856
  const turnRequest = buildInstructionSeatTurnRequest(admitted, turnProjection);
19638
19857
  const result = await runPostAdmissionOneShot({
@@ -19843,6 +20062,7 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
19843
20062
  await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
19844
20063
  admitted = { ...admitted, sourceRunPath: auditorSource };
19845
20064
  }
20065
+ admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
19846
20066
  const runAdmitted = async () => {
19847
20067
  await markRunAdmitted(admitted, env.principalAuthority);
19848
20068
  if (role === "secretariat") {
@@ -19905,6 +20125,16 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
19905
20125
  }
19906
20126
  return runAdmitted();
19907
20127
  }
20128
+ async function inheritKnownTicketFromSource(admitted, authority) {
20129
+ if (admitted.ticketNumber !== void 0) return admitted;
20130
+ const sourcePath = admittedSourceRunPath(admitted);
20131
+ if (sourcePath === void 0) return admitted;
20132
+ const sourceTicket = await readBoardTicketNumber(sourcePath);
20133
+ if (sourceTicket === void 0) return admitted;
20134
+ await bindAdmittedTicketNumber(admitted, sourceTicket);
20135
+ await relocateAdmittedRunToTicket(admitted, authority);
20136
+ return admitted;
20137
+ }
19908
20138
  async function runPublicInstructionSeatResume(request, env, io) {
19909
20139
  let selectedRequest = request;
19910
20140
  const resume = async () => {
@@ -19924,26 +20154,45 @@ async function runPublicInstructionSeatResume(request, env, io) {
19924
20154
  env.principalAuthority,
19925
20155
  effective.runDirectory === void 0 ? void 0 : { runDirectory: effective.runDirectory }
19926
20156
  );
19927
- if (packagedRebindSourceOnResume(loaded.admitted.role) && effective.summons?.sourceRunPath !== void 0 && effective.summons.sourceRun !== void 0) {
19928
- return {
19929
- ...loaded,
19930
- admitted: {
19931
- ...loaded.admitted,
19932
- sourceRunPath: effective.summons.sourceRunPath,
19933
- sourceRun: effective.summons.sourceRun
19934
- }
20157
+ let admitted = loaded.admitted;
20158
+ if (packagedRebindSourceOnResume(admitted.role) && effective.summons?.sourceRunPath !== void 0 && effective.summons.sourceRun !== void 0) {
20159
+ admitted = {
20160
+ ...admitted,
20161
+ sourceRunPath: effective.summons.sourceRunPath,
20162
+ sourceRun: effective.summons.sourceRun
19935
20163
  };
19936
20164
  }
19937
- return loaded;
20165
+ admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
20166
+ return { ...loaded, admitted };
19938
20167
  },
19939
20168
  buildTurnRequest: async (admitted, effective) => {
19940
20169
  const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
19941
- return buildInstructionSeatTurnRequest(
20170
+ const projection = resumeTurnRequestProjectionOptions(
19942
20171
  admitted,
19943
- {
19944
- ...resumeTurnRequestProjectionOptions(admitted, effective, env, summonsPrepared)
19945
- }
20172
+ effective,
20173
+ env,
20174
+ summonsPrepared
19946
20175
  );
20176
+ if (effective.summons === void 0 || effective.message !== void 0) {
20177
+ return buildInstructionSeatTurnRequest(admitted, { ...projection });
20178
+ }
20179
+ const sourceRunPath = admittedSourceRunPath(admitted);
20180
+ const body = await resolveReviewSeatDialogueBody({
20181
+ role: admitted.role,
20182
+ callerInstruction: summonsPrepared?.instruction ?? "",
20183
+ ...sourceRunPath === void 0 ? {} : { sourceRunPath },
20184
+ projectRoot: admitted.projectRoot,
20185
+ home: env.home
20186
+ });
20187
+ if (body === void 0) {
20188
+ return buildInstructionSeatTurnRequest(admitted, { ...projection });
20189
+ }
20190
+ const fileFlags = summonsPrepared?.attachments ?? [];
20191
+ const prompt = fileFlags.length === 0 ? body : appendCallerFileFlagPaths(body, fileFlags);
20192
+ return buildInstructionSeatTurnRequest(admitted, {
20193
+ ...projection,
20194
+ continuation: { kind: "resume", prompt }
20195
+ });
19947
20196
  },
19948
20197
  adapters: {
19949
20198
  trySettle: async () => void 0
@@ -20138,7 +20387,8 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
20138
20387
  return runPublicInstructionSeatResume({
20139
20388
  runId: admitted.runId,
20140
20389
  runDirectory: admitted.runDirectory,
20141
- summons: { instruction: SECRETARIAT_STATUS_REASK }
20390
+ message: SECRETARIAT_STATUS_REASK,
20391
+ summons: { instructionEmpty: true }
20142
20392
  }, next, io);
20143
20393
  }
20144
20394
  if (admitted.role === "countersign" && (typeof status !== "string" || !REVIEW_QUEUE_STATUSES.has(status))) {
@@ -20152,7 +20402,8 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
20152
20402
  return runPublicInstructionSeatResume({
20153
20403
  runId: admitted.runId,
20154
20404
  runDirectory: admitted.runDirectory,
20155
- summons: { instruction: officerConclusionReask(status) }
20405
+ message: officerConclusionReask(status),
20406
+ summons: { instructionEmpty: true }
20156
20407
  }, next, io);
20157
20408
  }
20158
20409
  const selfEscalationSkipsAudit = status === "escalate" && (admitted.role === "judge" || admitted.role === "secretariat" || admitted.role === "countersign");
@@ -20407,6 +20658,20 @@ var init_instruction_seat_run = __esm({
20407
20658
  judge: {
20408
20659
  statuses: REVIEW_QUEUE_STATUSES
20409
20660
  },
20661
+ // #1208 C1 / ADR 0055: every review-queue seat uses the shared
20662
+ // unreadable-status seam (officerConclusionReask). Independent public
20663
+ // entry for notary/auditor/inspector was the same miss — route here, do
20664
+ // not invent a parallel loop. Gate summons still own the outer budget
20665
+ // via nestedIncomplete when this seat exhausts unsettled.
20666
+ notary: {
20667
+ statuses: REVIEW_QUEUE_STATUSES
20668
+ },
20669
+ auditor: {
20670
+ statuses: REVIEW_QUEUE_STATUSES
20671
+ },
20672
+ inspector: {
20673
+ statuses: REVIEW_QUEUE_STATUSES
20674
+ },
20410
20675
  coder: {
20411
20676
  statuses: WORKER_ROUTING_STATUSES,
20412
20677
  reask: WORKER_STATUS_REASK
@@ -20442,9 +20707,9 @@ __export(public_role_summons_exports, {
20442
20707
  summonPublicRole: () => summonPublicRole
20443
20708
  });
20444
20709
  import { execFile as execFile3 } from "node:child_process";
20445
- import { existsSync as existsSync9 } from "node:fs";
20710
+ import { existsSync as existsSync10 } from "node:fs";
20446
20711
  import { realpath as realpath5 } from "node:fs/promises";
20447
- import { join as join20 } from "node:path";
20712
+ import { join as join21 } from "node:path";
20448
20713
  import { promisify as promisify3 } from "node:util";
20449
20714
  function createCapturingIo() {
20450
20715
  const chunks = [];
@@ -20468,7 +20733,7 @@ function parentDir(path) {
20468
20733
  function walkPackageRoot(start) {
20469
20734
  let dir = start;
20470
20735
  for (let i = 0; i < 12; i += 1) {
20471
- if (existsSync9(join20(dir, "package.json")) && existsSync9(join20(dir, "souls"))) {
20736
+ if (existsSync10(join21(dir, "package.json")) && existsSync10(join21(dir, "souls"))) {
20472
20737
  return dir;
20473
20738
  }
20474
20739
  const parent = parentDir(dir);
@@ -20790,13 +21055,9 @@ async function summonGateOfficer(options) {
20790
21055
  home = homeFromRunDirectory2(options.sourceRunDirectory);
20791
21056
  }
20792
21057
  let gateReviewInstruction;
20793
- if (options.reask === void 0 && options.submission !== void 0) {
20794
- const { isTicketCourtCountersignSource: isTicketCourtCountersignSource2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
20795
- const blindTicketCourt = options.officer === "notary" && isTicketCourtCountersignSource2(options.sourceRunDirectory);
20796
- if (!blindTicketCourt) {
20797
- const { readableGateItem: readableGateItem2 } = await Promise.resolve().then(() => (init_readable_gate_item(), readable_gate_item_exports));
20798
- gateReviewInstruction = readableGateItem2(options.submission);
20799
- }
21058
+ if (options.reask === void 0 && options.submission !== void 0 && options.officer !== "notary") {
21059
+ const { readableGateItem: readableGateItem2 } = await Promise.resolve().then(() => (init_readable_gate_item(), readable_gate_item_exports));
21060
+ gateReviewInstruction = readableGateItem2(options.submission);
20800
21061
  }
20801
21062
  const { runIdFromRunDirectory: runIdFromRunDirectory2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
20802
21063
  const parentRunId = runIdFromRunDirectory2(options.sourceRunDirectory);
@@ -20847,7 +21108,14 @@ async function summonGateOfficer(options) {
20847
21108
  const parentTicket = await readBoardTicketNumber2(options.sourceRunDirectory);
20848
21109
  const submittedTicket = isRecord(options.submission) ? options.submission.ticketNumber : void 0;
20849
21110
  const courtTicket = isSafePositiveTicketNumber3(submittedTicket) ? submittedTicket : parentTicket;
20850
- const instruction = options.reask ?? gateReviewInstruction ?? "";
21111
+ const { resolveReviewSeatDialogueBody: resolveReviewSeatDialogueBody2 } = await Promise.resolve().then(() => (init_instruction_seat_run(), instruction_seat_run_exports));
21112
+ const instruction = await resolveReviewSeatDialogueBody2({
21113
+ role: options.officer,
21114
+ ...options.reask === void 0 ? {} : { reviewReask: options.reask },
21115
+ ...gateReviewInstruction === void 0 ? {} : { gateReviewInstruction },
21116
+ projectRoot: options.cwd,
21117
+ home
21118
+ }) ?? "";
20851
21119
  return summonPublicRole({
20852
21120
  role: options.officer,
20853
21121
  argv: ["--project", options.cwd, "--", instruction],
@@ -21007,7 +21275,7 @@ var init_compliance_transport = __esm({
21007
21275
  });
21008
21276
 
21009
21277
  // src/role-run-relocation.ts
21010
- import { dirname as dirname14, join as join21 } from "node:path";
21278
+ import { dirname as dirname14, join as join22 } from "node:path";
21011
21279
  async function retainedRunPathsMatch(recordedPath, currentPath, currentRunDirectory) {
21012
21280
  if (recordedPath === currentPath) return true;
21013
21281
  if (typeof recordedPath !== "string") return false;
@@ -21052,11 +21320,9 @@ var init_role_run_relocation = __esm({
21052
21320
  var run_lifecycle_exports = {};
21053
21321
  __export(run_lifecycle_exports, {
21054
21322
  AUTO_RESUME_LIMIT: () => AUTO_RESUME_LIMIT,
21055
- RESUME_TRANSPORT_ENVELOPE: () => RESUME_TRANSPORT_ENVELOPE,
21056
21323
  RunWriterLeaseHeldError: () => RunWriterLeaseHeldError,
21057
21324
  acquireRunWriterLease: () => acquireRunWriterLease,
21058
21325
  autopsyWriterLock: () => autopsyWriterLock,
21059
- buildAutoResumeContinuationPrompt: () => buildAutoResumeContinuationPrompt,
21060
21326
  clearCurrentCourt: () => clearCurrentCourt,
21061
21327
  describeErrorIdentity: () => describeErrorIdentity,
21062
21328
  findLatestRunForSeatTicket: () => findLatestRunForSeatTicket,
@@ -21075,12 +21341,9 @@ __export(run_lifecycle_exports, {
21075
21341
  resolveLiveRunDirectoryPath: () => resolveLiveRunDirectoryPath,
21076
21342
  writeRoleRunState: () => writeRoleRunState
21077
21343
  });
21078
- import { existsSync as existsSync10 } from "node:fs";
21344
+ import { existsSync as existsSync11 } from "node:fs";
21079
21345
  import { chmod, lstat as lstat3, open, readdir as readdir3, readFile as readFile10, unlink } from "node:fs/promises";
21080
- import { basename as basename10, join as join22 } from "node:path";
21081
- function buildAutoResumeContinuationPrompt() {
21082
- return RESUME_TRANSPORT_ENVELOPE;
21083
- }
21346
+ import { basename as basename11, join as join23 } from "node:path";
21084
21347
  async function writeRoleRunState(runDirectory, record) {
21085
21348
  const payload = { ...record, runDirectory };
21086
21349
  writeSectionSync(runDirectory, "runState", { ...payload });
@@ -21162,13 +21425,14 @@ async function readRoleRunStateDisk(runDirectory) {
21162
21425
  if (typeof record.sessionDirectory !== "string") throw new TypeError("Invalid state.jsonl run-state");
21163
21426
  const storedRunDirectory = typeof record.runDirectory === "string" && record.runDirectory.trim() !== "" ? record.runDirectory : runDirectory;
21164
21427
  const runDir = runDirectory;
21428
+ const principalCoords = {
21429
+ sessionDirectory: record.sessionDirectory,
21430
+ ...typeof record.sessionFile === "string" ? { sessionFile: record.sessionFile } : {}
21431
+ };
21432
+ rewritePrincipalSessionPaths(principalCoords, storedRunDirectory, runDirectory);
21165
21433
  const principalWire = {
21166
- sessionDirectory: rewriteRunDirectoryPathValue(
21167
- record.sessionDirectory,
21168
- storedRunDirectory,
21169
- runDirectory
21170
- ),
21171
- ...typeof record.sessionFile === "string" ? { sessionFile: rewriteRunDirectoryPathValue(record.sessionFile, storedRunDirectory, runDirectory) } : {}
21434
+ sessionDirectory: principalCoords.sessionDirectory,
21435
+ ...typeof principalCoords.sessionFile === "string" ? { sessionFile: principalCoords.sessionFile } : {}
21172
21436
  };
21173
21437
  const phase = record.phase === "plan" || record.phase === "apply" ? record.phase : void 0;
21174
21438
  const currentCourt = parseCurrentCourtState(record.currentCourt);
@@ -21374,7 +21638,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
21374
21638
  },
21375
21639
  relocate(nextRunDirectory) {
21376
21640
  currentRunDirectory = nextRunDirectory;
21377
- currentLockPath = join22(nextRunDirectory, WRITER_LOCK_FILE);
21641
+ currentLockPath = join23(nextRunDirectory, WRITER_LOCK_FILE);
21378
21642
  },
21379
21643
  async release() {
21380
21644
  if (released) return;
@@ -21413,10 +21677,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
21413
21677
  };
21414
21678
  const reportReadFailure = (error) => {
21415
21679
  reportDiagnostic(
21416
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join22(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
21680
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join23(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
21417
21681
  );
21418
21682
  };
21419
- const lockPath = join22(runDirectory, WRITER_LOCK_FILE);
21683
+ const lockPath = join23(runDirectory, WRITER_LOCK_FILE);
21420
21684
  let lastAutopsy = { verdict: "absent" };
21421
21685
  let lastReclaimFailure;
21422
21686
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -21472,7 +21736,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
21472
21736
  }
21473
21737
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRunDirectory) {
21474
21738
  if (typeof knownRunDirectory === "string" && knownRunDirectory.trim() !== "") {
21475
- const parsed = parseRunLeaf(basename10(knownRunDirectory));
21739
+ const parsed = parseRunLeaf(basename11(knownRunDirectory));
21476
21740
  if (parsed === void 0 || parsed.runId !== runId) {
21477
21741
  throw new CliUsageError(
21478
21742
  `run directory does not match run id ${runId}: ${knownRunDirectory}`
@@ -21482,7 +21746,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
21482
21746
  }
21483
21747
  if (runId.trim() === "") return void 0;
21484
21748
  const ledgerHome = resolveActivationLedgerHome(home);
21485
- const booksRoot = join22(ledgerHome, "books");
21749
+ const booksRoot = join23(ledgerHome, "books");
21486
21750
  let bookKeys;
21487
21751
  try {
21488
21752
  bookKeys = await readdir3(booksRoot);
@@ -21497,8 +21761,8 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole, knownRun
21497
21761
  );
21498
21762
  }
21499
21763
  async function resolveLiveRunDirectoryPath(recordedPath, home, onlyBookKey) {
21500
- if (existsSync10(recordedPath)) return recordedPath;
21501
- const parsed = parseRunLeaf(basename10(recordedPath));
21764
+ if (existsSync11(recordedPath)) return recordedPath;
21765
+ const parsed = parseRunLeaf(basename11(recordedPath));
21502
21766
  const bookKey = onlyBookKey ?? tryBookKeyFromAkRolesPath(recordedPath);
21503
21767
  if (parsed === void 0 || bookKey === void 0) return void 0;
21504
21768
  return findRunDirectoryById(home, parsed.runId, bookKey, parsed.role);
@@ -21532,7 +21796,7 @@ async function findLatestRunForSeatTicket(input) {
21532
21796
  let runDirectories;
21533
21797
  try {
21534
21798
  runDirectories = await listBookRunDirectories(
21535
- input.ticketNumber === void 0 ? bookDir : join22(bookDir, String(input.ticketNumber))
21799
+ input.ticketNumber === void 0 ? bookDir : join23(bookDir, String(input.ticketNumber))
21536
21800
  );
21537
21801
  } catch (error) {
21538
21802
  if (errorCodeOf(error) === "ENOENT") return void 0;
@@ -21540,7 +21804,7 @@ async function findLatestRunForSeatTicket(input) {
21540
21804
  }
21541
21805
  let best;
21542
21806
  for (const runDirectory of runDirectories) {
21543
- const parsed = parseRunLeaf(basename10(runDirectory));
21807
+ const parsed = parseRunLeaf(basename11(runDirectory));
21544
21808
  if (parsed === void 0 || parsed.role !== input.role) continue;
21545
21809
  const runId = parsed.runId;
21546
21810
  const parentPath = await readRunParentPath(runDirectory);
@@ -22011,7 +22275,7 @@ function resumedWorkerPhase(phase, phases, role, runId) {
22011
22275
  }
22012
22276
  throw new CliUsageError(`role run admitted ${role} phase is missing: ${runId}`);
22013
22277
  }
22014
- var AUTO_RESUME_LIMIT, RESUME_TRANSPORT_ENVELOPE, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
22278
+ var AUTO_RESUME_LIMIT, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
22015
22279
  var init_run_lifecycle = __esm({
22016
22280
  "src/public-cli/run-lifecycle.ts"() {
22017
22281
  "use strict";
@@ -22026,7 +22290,6 @@ var init_run_lifecycle = __esm({
22026
22290
  init_run_dossier();
22027
22291
  init_unknown_value();
22028
22292
  AUTO_RESUME_LIMIT = 2;
22029
- RESUME_TRANSPORT_ENVELOPE = "\u7EE7\u7EED\u3002";
22030
22293
  WRITER_LOCK_FILE = "writer.lock";
22031
22294
  RunWriterLeaseHeldError = class extends Error {
22032
22295
  code = "AK_RUN_WRITER_LEASE_HELD";
@@ -22341,10 +22604,7 @@ function buildReceiptDeliveryRequest(input) {
22341
22604
  ...request,
22342
22605
  continuation: {
22343
22606
  kind: "resume",
22344
- prompt: JSON.stringify({
22345
- ...receiptDelivery.deliveryState(),
22346
- deliveryTurns: receiptDelivery.issuedDeliveryRequests() + 1
22347
- })
22607
+ prompt: request.continuation.prompt
22348
22608
  },
22349
22609
  deliveryRequestLimit: receiptDelivery.limit
22350
22610
  };
@@ -23107,7 +23367,7 @@ async function runPostAdmissionSeatResume(input) {
23107
23367
  ...firstTurn,
23108
23368
  continuation: {
23109
23369
  kind: "resume",
23110
- prompt: RESUME_TRANSPORT_ENVELOPE
23370
+ prompt: firstTurn.continuation.prompt
23111
23371
  }
23112
23372
  };
23113
23373
  }
@@ -23226,7 +23486,7 @@ async function runPostAdmissionOneShot(input) {
23226
23486
  ...input.request,
23227
23487
  continuation: {
23228
23488
  kind: "resume",
23229
- prompt: buildAutoResumeContinuationPrompt()
23489
+ prompt: input.request.continuation.prompt
23230
23490
  }
23231
23491
  }),
23232
23492
  adapters: input.adapters,
@@ -29275,10 +29535,10 @@ var init_analyst_book_key = __esm({
29275
29535
  // src/atomic-write.ts
29276
29536
  import { randomUUID as randomUUID6 } from "node:crypto";
29277
29537
  import { rename as rename2, rm, writeFile as writeFile4 } from "node:fs/promises";
29278
- import { dirname as dirname15, join as join23 } from "node:path";
29538
+ import { dirname as dirname15, join as join24 } from "node:path";
29279
29539
  async function writeFileAtomically(destination, contents, options) {
29280
29540
  const parent = dirname15(destination);
29281
- const temporary = join23(parent, `.atomic-write-${randomUUID6()}.tmp`);
29541
+ const temporary = join24(parent, `.atomic-write-${randomUUID6()}.tmp`);
29282
29542
  try {
29283
29543
  await writeFile4(temporary, contents, options);
29284
29544
  await rename2(temporary, destination);
@@ -29295,12 +29555,12 @@ var init_atomic_write = __esm({
29295
29555
 
29296
29556
  // src/analyst-index.ts
29297
29557
  import { open as open2, readFile as readFile11, unlink as unlink2 } from "node:fs/promises";
29298
- import { dirname as dirname16, join as join24 } from "node:path";
29558
+ import { dirname as dirname16, join as join25 } from "node:path";
29299
29559
  import { setTimeout as sleep } from "node:timers/promises";
29300
29560
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
29301
29561
  const indexPath = analystLibraryIndexPath(ledgerHome);
29302
29562
  ensureRealDirectoryTree(ledgerHome, dirname16(indexPath));
29303
- const lockPath = join24(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
29563
+ const lockPath = join25(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
29304
29564
  assertLedgerFileInsideHome(lockPath, ledgerHome);
29305
29565
  const startedAt = Date.now();
29306
29566
  while (true) {
@@ -29327,7 +29587,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
29327
29587
  }
29328
29588
  }
29329
29589
  function analystLibraryIndexPath(ledgerHome) {
29330
- return join24(ledgerHome, "analyst", "library-index.json");
29590
+ return join25(ledgerHome, "analyst", "library-index.json");
29331
29591
  }
29332
29592
  function rowFromIssueMetricsPage(page) {
29333
29593
  return {
@@ -29621,7 +29881,7 @@ var init_analyst_cohort = __esm({
29621
29881
  });
29622
29882
 
29623
29883
  // src/archivist-record-pointer.ts
29624
- import { basename as basename11, join as join25 } from "node:path";
29884
+ import { basename as basename12, join as join26 } from "node:path";
29625
29885
  async function resolveOfficerPointer(raw, parentRunDirectory) {
29626
29886
  const where = `${parentRunDirectory} officers`;
29627
29887
  if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
@@ -29634,7 +29894,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
29634
29894
  let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
29635
29895
  let sessionFile = raw.sessionFile;
29636
29896
  const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
29637
- const leaf = parseRunLeaf(basename11(recordedRunDirectory));
29897
+ const leaf = parseRunLeaf(basename12(recordedRunDirectory));
29638
29898
  const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
29639
29899
  if (leaf !== void 0 && parentIdentity !== void 0) {
29640
29900
  const currentRunDirectory = await resolveLiveRunDirectoryPath(
@@ -29654,7 +29914,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
29654
29914
  };
29655
29915
  }
29656
29916
  async function readBookedOfficerPointers(parentRunDirectory) {
29657
- const { records, diagnostics } = await readSitianRecords(join25(parentRunDirectory, RUN_HISTORY_FILE));
29917
+ const { records, diagnostics } = await readSitianRecords(join26(parentRunDirectory, RUN_HISTORY_FILE));
29658
29918
  if (diagnostics.length > 0) {
29659
29919
  throw new Error(
29660
29920
  `${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
@@ -29937,7 +30197,7 @@ var init_analyst_gate_cycles_read = __esm({
29937
30197
 
29938
30198
  // src/analyst-ledger.ts
29939
30199
  import { readdir as readdir4 } from "node:fs/promises";
29940
- import { basename as basename12, join as join26 } from "node:path";
30200
+ import { basename as basename13, join as join27 } from "node:path";
29941
30201
  async function readExistingRunLifecycleState(runDirectory) {
29942
30202
  return (await readRoleRunIdentity(runDirectory))?.state;
29943
30203
  }
@@ -29957,7 +30217,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
29957
30217
  }
29958
30218
  }
29959
30219
  async function classifyGhostCandidate(input) {
29960
- const autopsy = await autopsyWriterLock(join26(input.runDirectory, "writer.lock"));
30220
+ const autopsy = await autopsyWriterLock(join27(input.runDirectory, "writer.lock"));
29961
30221
  const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
29962
30222
  if (leaseCheck === void 0) return { kind: "live" };
29963
30223
  return {
@@ -30247,7 +30507,7 @@ async function classifyScopedRun(input) {
30247
30507
  async function scanAnalystIssueRuns(input) {
30248
30508
  const ledgerHome = resolveActivationLedgerHome(input.home);
30249
30509
  const scopeTicketNumber = input.ticketNumber;
30250
- const booksRoot = join26(ledgerHome, "books");
30510
+ const booksRoot = join27(ledgerHome, "books");
30251
30511
  let wholeBook = false;
30252
30512
  let scopeRootIdentity;
30253
30513
  let bookNames;
@@ -30280,7 +30540,7 @@ async function scanAnalystIssueRuns(input) {
30280
30540
  const ghostLegs = [];
30281
30541
  const scopeConflicts = [];
30282
30542
  for (const book of bookNames) {
30283
- const bookDir = join26(booksRoot, book);
30543
+ const bookDir = join27(booksRoot, book);
30284
30544
  let runDirectories;
30285
30545
  try {
30286
30546
  runDirectories = await listBookRunDirectories(bookDir);
@@ -30289,7 +30549,7 @@ async function scanAnalystIssueRuns(input) {
30289
30549
  throw error;
30290
30550
  }
30291
30551
  for (const runDirectory of runDirectories) {
30292
- const runName = basename12(runDirectory);
30552
+ const runName = basename13(runDirectory);
30293
30553
  const parsed = parseRunLeaf(runName);
30294
30554
  if (parsed === void 0) continue;
30295
30555
  let scopeFields;
@@ -31026,7 +31286,7 @@ var init_analyst_metric_family = __esm({
31026
31286
  });
31027
31287
 
31028
31288
  // src/analyst-page.ts
31029
- import { dirname as dirname17, join as join27 } from "node:path";
31289
+ import { dirname as dirname17, join as join28 } from "node:path";
31030
31290
  function analystIssuePageKey(address) {
31031
31291
  const parts = ["book", address.bookKey];
31032
31292
  if (address.issueNumber !== void 0) {
@@ -31037,7 +31297,7 @@ function analystIssuePageKey(address) {
31037
31297
  return sha256Hex(parts.join("\0")).slice(0, 32);
31038
31298
  }
31039
31299
  function analystIssuePagePath(ledgerHome, address) {
31040
- return join27(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
31300
+ return join28(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
31041
31301
  }
31042
31302
  function analystIssuePageAddressFromPage(page) {
31043
31303
  return {
@@ -32584,13 +32844,13 @@ var init_cli = __esm({
32584
32844
  });
32585
32845
 
32586
32846
  // src/public-cli/main.ts
32587
- import { existsSync as existsSync11 } from "node:fs";
32588
- import { dirname as dirname18, join as join28 } from "node:path";
32847
+ import { existsSync as existsSync12 } from "node:fs";
32848
+ import { dirname as dirname18, join as join29 } from "node:path";
32589
32849
  import { fileURLToPath as fileURLToPath2 } from "node:url";
32590
32850
  var here = dirname18(fileURLToPath2(import.meta.url));
32591
32851
  function resolvePackageRoot(binDir) {
32592
- const canonical = join28(binDir, "..", "..");
32593
- if (existsSync11(join28(canonical, "package.json"))) {
32852
+ const canonical = join29(binDir, "..", "..");
32853
+ if (existsSync12(join29(canonical, "package.json"))) {
32594
32854
  return canonical;
32595
32855
  }
32596
32856
  return binDir;