@akagilnc/pi-workflow-roles 0.1.5598 → 0.1.5614

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/acp-host/production-host.js +406 -366
  2. package/dist/compliance-transport.js +2 -5
  3. package/dist/doctor-auditor.js +1 -1
  4. package/dist/gatekeeper-role.js +1 -1
  5. package/dist/headless-host/production-host.js +370 -330
  6. package/dist/migrate-book-topology.js +301 -291
  7. package/dist/navigator-public-session.js +4 -4
  8. package/dist/navigator-work-base.js +5 -30
  9. package/dist/packaged-role-registry.js +4 -2
  10. package/dist/pi/role-turn-host.js +10 -1
  11. package/dist/public-cli/instruction-seat-run.js +133 -38
  12. package/dist/public-cli/invocation.js +23 -26
  13. package/dist/public-cli/main.js +250 -179
  14. package/dist/public-cli/option-definitions.js +19 -0
  15. package/dist/public-cli/post-admission.js +23 -22
  16. package/dist/public-cli/run-lifecycle.js +2 -14
  17. package/dist/public-cli/turn-request.js +4 -9
  18. package/dist/public-role-summons.js +5 -3
  19. package/dist/role-run-placement.js +7 -1
  20. package/package.json +1 -1
  21. package/scripts/build-package.mjs +2 -3
  22. package/src/audited-run-identity.ts +30 -0
  23. package/src/compliance-transport.ts +1 -4
  24. package/src/doctor-auditor.ts +1 -1
  25. package/src/gatekeeper-role.ts +1 -1
  26. package/src/host-contracts.ts +6 -1
  27. package/src/navigator-public-session.ts +9 -5
  28. package/src/navigator-work-base.ts +19 -34
  29. package/src/notary-role.ts +12 -21
  30. package/src/packaged-role-registry.ts +4 -4
  31. package/src/pi/role-turn-host.ts +11 -1
  32. package/src/public-cli/instruction-seat-run.ts +162 -42
  33. package/src/public-cli/invocation.ts +35 -26
  34. package/src/public-cli/option-definitions.ts +20 -0
  35. package/src/public-cli/post-admission.ts +28 -22
  36. package/src/public-cli/run-lifecycle.ts +2 -17
  37. package/src/public-cli/turn-request.ts +9 -8
  38. package/src/public-role-summons.ts +17 -6
  39. package/src/role-envelope.ts +4 -0
  40. package/src/role-run-placement.ts +10 -1
  41. package/src/role-runtime.ts +54 -31
  42. package/dist/auditor-dossier-tool.js +0 -47
  43. package/src/auditor-dossier-tool.ts +0 -63
@@ -1392,7 +1392,7 @@ var init_run_ticket_number = __esm({
1392
1392
 
1393
1393
  // src/role-run-placement.ts
1394
1394
  import { readdir } from "node:fs/promises";
1395
- import { basename as basename5, dirname as dirname5, join as join6 } from "node:path";
1395
+ import { basename as basename5, dirname as dirname5, join as join6, resolve as resolve3 } from "node:path";
1396
1396
  function formatRunLeaf(runId, role) {
1397
1397
  return `${runId}@${role}`;
1398
1398
  }
@@ -1413,6 +1413,11 @@ function sessionFileOf(runDirectory) {
1413
1413
  function runDirectoryOfSessionFile(sessionFile) {
1414
1414
  return dirname5(dirname5(sessionFile));
1415
1415
  }
1416
+ function auditorRunDirectory(context) {
1417
+ const sessionFile = context.sessionManager?.getSessionFile?.();
1418
+ if (sessionFile === void 0) return void 0;
1419
+ return resolve3(runDirectoryOfSessionFile(sessionFile));
1420
+ }
1416
1421
  function runDirectoryFromSessionDirectory(sessionDirectory) {
1417
1422
  return dirname5(sessionDirectory);
1418
1423
  }
@@ -10019,7 +10024,8 @@ var init_packaged_role_registry = __esm({
10019
10024
  presentSettled: "always",
10020
10025
  summonResume: false,
10021
10026
  admission: "instruction",
10022
- sameParent: "gate-pointer",
10027
+ /** Structured --source-run only; instruction stays opaque caller/peer bytes (#1166). */
10028
+ sameParent: "source-run",
10023
10029
  /** Resume restores an optional source-run path onto the admitted face. */
10024
10030
  resumeSourcePath: true,
10025
10031
  /** 台院 is a review officer and inherits the gatekeeper model. */
@@ -10032,11 +10038,12 @@ var init_packaged_role_registry = __esm({
10032
10038
  /** Court reask replaces the initial prompt. */
10033
10039
  reaskPrompt: true,
10034
10040
  gateStageLabel: "\u53F0\u9662",
10041
+ /** Gate summon binds --source-run; identity is startup material (#1166). */
10042
+ gateSummon: "source-run",
10035
10043
  activationFlags: [
10036
10044
  {
10037
10045
  field: "sourceRun",
10038
10046
  from: "sourceRunPath",
10039
- fallback: "gate-pointer",
10040
10047
  flag: "ak-inspector-source-run",
10041
10048
  binds: "input"
10042
10049
  }
@@ -11203,22 +11210,6 @@ var init_collector_config = __esm({
11203
11210
  }
11204
11211
  });
11205
11212
 
11206
- // src/auditor-dossier-tool.ts
11207
- import { join as join11, resolve as resolve3 } from "node:path";
11208
- function auditorRunDirectory(context) {
11209
- const sessionFile = context.sessionManager?.getSessionFile?.();
11210
- if (sessionFile === void 0) return void 0;
11211
- return resolve3(runDirectoryOfSessionFile(sessionFile));
11212
- }
11213
- var init_auditor_dossier_tool = __esm({
11214
- "src/auditor-dossier-tool.ts"() {
11215
- "use strict";
11216
- init_run_dossier();
11217
- init_role_run_placement();
11218
- init_build();
11219
- }
11220
- });
11221
-
11222
11213
  // src/readable-gate-item.ts
11223
11214
  var readable_gate_item_exports = {};
11224
11215
  __export(readable_gate_item_exports, {
@@ -11777,7 +11768,7 @@ var GATE_OFFICER_BY_SUBJECT, GATEKEEPER_TOOL_SPEC;
11777
11768
  var init_gatekeeper_role = __esm({
11778
11769
  "src/gatekeeper-role.ts"() {
11779
11770
  "use strict";
11780
- init_auditor_dossier_tool();
11771
+ init_role_run_placement();
11781
11772
  init_packaged_role_registry();
11782
11773
  init_submission_errors();
11783
11774
  init_inspector_contracts();
@@ -12449,7 +12440,7 @@ import {
12449
12440
  statSync as statSync4
12450
12441
  } from "node:fs";
12451
12442
  import { homedir } from "node:os";
12452
- import { dirname as dirname7, join as join12 } from "node:path";
12443
+ import { dirname as dirname7, join as join11 } from "node:path";
12453
12444
  function declareHostSessionFailure(error) {
12454
12445
  const message = error instanceof Error ? error.stack || error.message : String(error);
12455
12446
  process.stderr.write(`[host-session] Dossier record failure: ${message}
@@ -12474,7 +12465,7 @@ function findCodexRollout(sessionsDir, sessionId) {
12474
12465
  throw error;
12475
12466
  }
12476
12467
  for (const entry of entries) {
12477
- const fullPath = join12(dir, entry.name);
12468
+ const fullPath = join11(dir, entry.name);
12478
12469
  if (entry.isDirectory()) {
12479
12470
  scan(fullPath, depth + 1);
12480
12471
  } else if (entry.isFile() && entry.name.endsWith(".jsonl") && entry.name.includes(sessionId)) {
@@ -12504,24 +12495,24 @@ function sanitizeClaudeCwd(cwd) {
12504
12495
  function resolveNativeSessionPath(options) {
12505
12496
  const home = options.home || homedir();
12506
12497
  if (options.host === "claude") {
12507
- const configDir = process.env.CLAUDE_CONFIG_DIR || join12(home, ".claude");
12498
+ const configDir = process.env.CLAUDE_CONFIG_DIR || join11(home, ".claude");
12508
12499
  const sanitizedCwd = sanitizeClaudeCwd(options.cwd);
12509
- return join12(configDir, "projects", sanitizedCwd, `${options.sessionId}.jsonl`);
12500
+ return join11(configDir, "projects", sanitizedCwd, `${options.sessionId}.jsonl`);
12510
12501
  }
12511
12502
  if (options.host === "codex") {
12512
12503
  return findCodexRollout(codexSessionsDirectory(home), options.sessionId);
12513
12504
  }
12514
12505
  if (options.host === "grok-build") {
12515
- const grokHome = process.env.GROK_HOME || join12(home, ".grok");
12516
- return join12(grokHome, "sessions", encodeURIComponent(options.cwd), options.sessionId);
12506
+ const grokHome = process.env.GROK_HOME || join11(home, ".grok");
12507
+ return join11(grokHome, "sessions", encodeURIComponent(options.cwd), options.sessionId);
12517
12508
  }
12518
12509
  return void 0;
12519
12510
  }
12520
12511
  function codexSessionsDirectory(home) {
12521
- return join12(process.env.CODEX_HOME || join12(home || homedir(), ".codex"), "sessions");
12512
+ return join11(process.env.CODEX_HOME || join11(home || homedir(), ".codex"), "sessions");
12522
12513
  }
12523
12514
  function resolveHostDossierLandingPath(options) {
12524
- return options.host === "grok-build" ? join12(options.sessionDirectory, options.host) : join12(options.sessionDirectory, `${options.host}.jsonl`);
12515
+ return options.host === "grok-build" ? join11(options.sessionDirectory, options.host) : join11(options.sessionDirectory, `${options.host}.jsonl`);
12525
12516
  }
12526
12517
  function copyFileCloneOrFallback(src, dest) {
12527
12518
  try {
@@ -12533,8 +12524,8 @@ function copyFileCloneOrFallback(src, dest) {
12533
12524
  }
12534
12525
  function copyGrokDossier(srcDir, destDir) {
12535
12526
  mkdirSync3(destDir, { recursive: true });
12536
- copyFileCloneOrFallback(join12(srcDir, "chat_history.jsonl"), join12(destDir, "chat_history.jsonl"));
12537
- copyFileCloneOrFallback(join12(srcDir, "usage.json"), join12(destDir, "usage.json"));
12527
+ copyFileCloneOrFallback(join11(srcDir, "chat_history.jsonl"), join11(destDir, "chat_history.jsonl"));
12528
+ copyFileCloneOrFallback(join11(srcDir, "usage.json"), join11(destDir, "usage.json"));
12538
12529
  }
12539
12530
  function copyAndRecordHostDossier(options) {
12540
12531
  if (options.host === "hermes") {
@@ -13500,7 +13491,7 @@ var init_session_dialogue = __esm({
13500
13491
 
13501
13492
  // src/ticket-provenance.ts
13502
13493
  import { readFile as readFile7 } from "node:fs/promises";
13503
- import { join as join13, resolve as resolve7 } from "node:path";
13494
+ import { join as join12, resolve as resolve7 } from "node:path";
13504
13495
  function ticketProvenanceSubject(ticketNumber) {
13505
13496
  if (!isSafePositiveTicketNumber(ticketNumber)) {
13506
13497
  throw new Error(
@@ -13523,7 +13514,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
13523
13514
  const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
13524
13515
  let history;
13525
13516
  try {
13526
- history = await readFile7(join13(runDirectory, RUN_HISTORY_FILE), "utf8");
13517
+ history = await readFile7(join12(runDirectory, RUN_HISTORY_FILE), "utf8");
13527
13518
  } catch (error) {
13528
13519
  if (errnoCode(error) === "ENOENT") return;
13529
13520
  throw error;
@@ -13579,7 +13570,7 @@ var init_uuidv7 = __esm({
13579
13570
  });
13580
13571
 
13581
13572
  // src/notary-source-run.ts
13582
- import { dirname as dirname9, isAbsolute as isAbsolute4, join as join14, resolve as resolve8, basename as basename7 } from "node:path";
13573
+ import { dirname as dirname9, isAbsolute as isAbsolute4, join as join13, resolve as resolve8, basename as basename7 } from "node:path";
13583
13574
  import { lstat as lstat2, realpath as realpath2 } from "node:fs/promises";
13584
13575
  async function readRetainedIdentity(runDirectory) {
13585
13576
  try {
@@ -13631,11 +13622,11 @@ async function resolveNotarySourceRunLocator(options) {
13631
13622
  const ledgerHome = resolveActivationLedgerHome(options.home);
13632
13623
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
13633
13624
  const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
13634
- const bookRunsRoot = join14(bookDirectory, "runs");
13625
+ const bookRunsRoot = join13(bookDirectory, "runs");
13635
13626
  let candidate;
13636
13627
  const bare = parseRunLeaf(raw);
13637
13628
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
13638
- candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join14(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
13629
+ candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join13(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
13639
13630
  } else {
13640
13631
  candidate = isAbsolute4(raw) ? raw : resolve8(options.projectRoot, raw);
13641
13632
  const identity2 = parseRunLeaf(basename7(candidate));
@@ -13970,7 +13961,7 @@ function renderHumanOwnerOptionLines(owner, locale2 = "en") {
13970
13961
  }
13971
13962
  return lines;
13972
13963
  }
13973
- var ANALYST_REQUIRE_ANY_OF, ANALYST_DEFAULT_MODE, REJECTED_PUBLIC_SPELLINGS, GLOBAL_OPTIONS, SHARED_PROJECT_SEMANTICS, SHARED_ATTACH_SEMANTICS, SHARED_PHASE_SEMANTICS, GLEANER_LEFT_OPTIONS, AUDITOR_OPTIONS, CODER_OPTIONS, FIXER_OPTIONS, REVIEWER_OPTIONS, COLLECTOR_OPTIONS, DOCTOR_OPTIONS, NOTARY_OPTIONS, MERGER_OPTIONS, ANALYST_OPTIONS, SEAT_OPTION_ROWS, PUBLIC_OPTION_TABLE, PUBLIC_ROLE_OPTION_OWNERS, PUBLIC_NAVIGATOR_HELP_NOTE, TOP_LEVEL_HELP, ROLE_COMMAND_HELP, SUPPORT_COMMAND_HELP, PUBLIC_COMMAND_HELP;
13964
+ var ANALYST_REQUIRE_ANY_OF, ANALYST_DEFAULT_MODE, REJECTED_PUBLIC_SPELLINGS, GLOBAL_OPTIONS, SHARED_PROJECT_SEMANTICS, SHARED_ATTACH_SEMANTICS, SHARED_PHASE_SEMANTICS, GLEANER_LEFT_OPTIONS, AUDITOR_OPTIONS, CODER_OPTIONS, FIXER_OPTIONS, REVIEWER_OPTIONS, COLLECTOR_OPTIONS, DOCTOR_OPTIONS, NOTARY_OPTIONS, INSPECTOR_OPTIONS, MERGER_OPTIONS, ANALYST_OPTIONS, SEAT_OPTION_ROWS, PUBLIC_OPTION_TABLE, PUBLIC_ROLE_OPTION_OWNERS, PUBLIC_NAVIGATOR_HELP_NOTE, TOP_LEVEL_HELP, ROLE_COMMAND_HELP, SUPPORT_COMMAND_HELP, PUBLIC_COMMAND_HELP;
13974
13965
  var init_option_definitions = __esm({
13975
13966
  "src/public-cli/option-definitions.ts"() {
13976
13967
  "use strict";
@@ -14335,6 +14326,23 @@ var init_option_definitions = __esm({
14335
14326
  }
14336
14327
  }
14337
14328
  ];
14329
+ INSPECTOR_OPTIONS = [
14330
+ ...projectAndAttach("inspector"),
14331
+ {
14332
+ id: "source-run",
14333
+ owner: "inspector",
14334
+ canonical: "--source-run",
14335
+ aliases: [],
14336
+ valueMetavar: "runId@role|path",
14337
+ required: false,
14338
+ repeatable: false,
14339
+ form: "option",
14340
+ description: {
14341
+ en: "Optional audited source-run locator (runId@role or path). Gate summons always supply it; identity rides startup materials.",
14342
+ 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"
14343
+ }
14344
+ }
14345
+ ];
14338
14346
  MERGER_OPTIONS = [
14339
14347
  // Merger project face: worktree whose Git materials are handed to the role.
14340
14348
  {
@@ -14493,7 +14501,8 @@ var init_option_definitions = __esm({
14493
14501
  doctor: DOCTOR_OPTIONS,
14494
14502
  merger: MERGER_OPTIONS,
14495
14503
  notary: NOTARY_OPTIONS,
14496
- auditor: AUDITOR_OPTIONS
14504
+ auditor: AUDITOR_OPTIONS,
14505
+ inspector: INSPECTOR_OPTIONS
14497
14506
  };
14498
14507
  PUBLIC_OPTION_TABLE = publicOptionTable();
14499
14508
  PUBLIC_ROLE_OPTION_OWNERS = [
@@ -14747,7 +14756,7 @@ import {
14747
14756
  rename,
14748
14757
  writeFile as writeFile2
14749
14758
  } from "node:fs/promises";
14750
- import { dirname as dirname10, isAbsolute as isAbsolute5, join as join15, resolve as resolve9 } from "node:path";
14759
+ import { dirname as dirname10, isAbsolute as isAbsolute5, join as join14, resolve as resolve9 } from "node:path";
14751
14760
  function normalizeAdmittedAttachment(raw) {
14752
14761
  if (typeof raw !== "object" || raw === null) return void 0;
14753
14762
  const record = raw;
@@ -14900,7 +14909,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
14900
14909
  const childRunIds = readPageSync(oldRunDirectory, "admitted")?.childDiaristRunIds;
14901
14910
  for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
14902
14911
  if (typeof childRunId !== "string") continue;
14903
- const childDirectory = join15(dirname10(oldRunDirectory), formatRunLeaf(childRunId, "diarist"));
14912
+ const childDirectory = join14(dirname10(oldRunDirectory), formatRunLeaf(childRunId, "diarist"));
14904
14913
  if (!existsSync4(childDirectory)) continue;
14905
14914
  const childTarget = roleRunPlacement(ledgerHome, {
14906
14915
  bookKey: admitted.bookKey,
@@ -14974,7 +14983,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
14974
14983
  async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
14975
14984
  const rolePackageRoot = packageRoot2;
14976
14985
  const raw = JSON.parse(
14977
- await readFile8(join15(rolePackageRoot, "package.json"), "utf8")
14986
+ await readFile8(join14(rolePackageRoot, "package.json"), "utf8")
14978
14987
  );
14979
14988
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
14980
14989
  throw new Error(
@@ -15532,7 +15541,7 @@ async function admitPublicRole(role, parsed, env, override) {
15532
15541
  resolutionScope: [...derived.resolutionScope],
15533
15542
  authorizedChecks: []
15534
15543
  });
15535
- const mergerInputPath = join15(placed.runDirectory, "merger-input.json");
15544
+ const mergerInputPath = join14(placed.runDirectory, "merger-input.json");
15536
15545
  await writeFile2(
15537
15546
  mergerInputPath,
15538
15547
  `${JSON.stringify(mergerInput, null, 2)}
@@ -15670,52 +15679,50 @@ function admittedTransportPromptKind(admitted) {
15670
15679
  if (record !== void 0 && "transportPrompt" in record) return record.transportPrompt;
15671
15680
  return "instruction";
15672
15681
  }
15682
+ function appendCallerFileFlagPaths(body, attachments, requestManifestPath, prerequisitesPath) {
15683
+ const flaggedPaths = [
15684
+ ...attachments.map((attachment) => `--attach ${attachment.path}`),
15685
+ ...requestManifestPath === void 0 ? [] : [`--request-manifest ${requestManifestPath}`],
15686
+ ...prerequisitesPath === void 0 ? [] : [`--prerequisites ${prerequisitesPath}`]
15687
+ ];
15688
+ if (flaggedPaths.length === 0) return body;
15689
+ return [body, "", ...flaggedPaths].join("\n");
15690
+ }
15673
15691
  function buildInstructionTransportPrompt(admitted) {
15674
15692
  const kind = admittedTransportPromptKind(admitted);
15675
15693
  if (kind === "fixed-kickoff") {
15676
- if (admitted.sourceRunPath === void 0 || admitted.sourceRunPath.trim() === "") {
15677
- throw new Error("fixed-kickoff transport prompt is missing the source run pointer");
15678
- }
15679
- return admitted.sourceRunPath;
15694
+ return "";
15680
15695
  }
15681
15696
  if (kind === "baseline") {
15682
15697
  if (admitted.baseRevision === void 0) {
15683
15698
  throw new Error("baseline transport prompt is missing the bound revision");
15684
15699
  }
15685
- const lines2 = [admitted.baseRevision];
15700
+ const lines = [admitted.baseRevision];
15686
15701
  if (admitted.instruction.length > 0) {
15687
- lines2.push("", admitted.instruction);
15702
+ lines.push("", admitted.instruction);
15688
15703
  }
15689
- return lines2.join("\n");
15704
+ return lines.join("\n");
15690
15705
  }
15691
15706
  if (kind === "skill-args") {
15692
15707
  if (admitted.baseRevision === void 0 || admitted.lens === void 0 || admitted.authorityRefs === void 0) {
15693
15708
  throw new Error("skill-args transport prompt is missing frozen skill args");
15694
15709
  }
15695
- const lines2 = [buildReviewerSkillArgProjection({
15710
+ const lines = [buildReviewerSkillArgProjection({
15696
15711
  baseRevision: admitted.baseRevision,
15697
15712
  lens: admitted.lens,
15698
15713
  authorityRefs: admitted.authorityRefs
15699
15714
  })];
15700
15715
  if (admitted.instruction.length > 0) {
15701
- lines2.push("", admitted.instruction);
15702
- }
15703
- return lines2.join("\n");
15704
- }
15705
- const lines = [admitted.instruction];
15706
- const flaggedPaths = [
15707
- ...admitted.attachments.map((attachment) => `--attach ${attachment.path}`),
15708
- ...admitted.requestManifestPath === void 0 ? [] : [`--request-manifest ${admitted.requestManifestPath}`],
15709
- ...admitted.prerequisitesPath === void 0 ? [] : [`--prerequisites ${admitted.prerequisitesPath}`]
15710
- ];
15711
- if (flaggedPaths.length > 0) {
15712
- lines.push("");
15713
- lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\uFF1A");
15714
- for (const entry of flaggedPaths) {
15715
- lines.push(`- ${entry}`);
15716
+ lines.push("", admitted.instruction);
15716
15717
  }
15718
+ return lines.join("\n");
15717
15719
  }
15718
- return lines.join("\n");
15720
+ return appendCallerFileFlagPaths(
15721
+ admitted.instruction,
15722
+ admitted.attachments,
15723
+ admitted.requestManifestPath,
15724
+ admitted.prerequisitesPath
15725
+ );
15719
15726
  }
15720
15727
  async function materializeCountersignInvocation(admitted, options) {
15721
15728
  const placed = await placeRoleAdmission({
@@ -15807,7 +15814,7 @@ function parseDoctorIssueNumber(raw) {
15807
15814
  }
15808
15815
  async function resolveDoctorCaseRunsPath(options) {
15809
15816
  const ledgerHome = resolveActivationLedgerHome(options.home);
15810
- const defaultRuns = join15(
15817
+ const defaultRuns = join14(
15811
15818
  activationBookDirectory(ledgerHome, options.bookKey),
15812
15819
  String(options.issueNumber),
15813
15820
  "runs"
@@ -17335,7 +17342,7 @@ var init_settlement = __esm({
17335
17342
  });
17336
17343
 
17337
17344
  // src/session-identity.ts
17338
- import { dirname as dirname11, join as join16 } from "node:path";
17345
+ import { dirname as dirname11, join as join15 } from "node:path";
17339
17346
  function createSessionIdentityAuthority(authority, hostName) {
17340
17347
  const runDirectoryOf = (principal) => dirname11(authority.decode(principal).sessionDirectory);
17341
17348
  return {
@@ -17344,7 +17351,7 @@ function createSessionIdentityAuthority(authority, hostName) {
17344
17351
  },
17345
17352
  async load(principal) {
17346
17353
  const runDirectory = runDirectoryOf(principal);
17347
- const { records, diagnostics } = await readSitianRecords(join16(runDirectory, RUN_STATE_FILE));
17354
+ const { records, diagnostics } = await readSitianRecords(join15(runDirectory, RUN_STATE_FILE));
17348
17355
  if (diagnostics.length > 0) {
17349
17356
  throw new Error(
17350
17357
  `${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
@@ -17414,12 +17421,12 @@ __export(role_turn_host_exports, {
17414
17421
  import { execFile as execFile2, spawn } from "node:child_process";
17415
17422
  import { constants as constants2 } from "node:fs";
17416
17423
  import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
17417
- import { delimiter as delimiter2, dirname as dirname12, isAbsolute as isAbsolute6, join as join17, resolve as resolve10 } from "node:path";
17424
+ import { delimiter as delimiter2, dirname as dirname12, isAbsolute as isAbsolute6, join as join16, resolve as resolve10 } from "node:path";
17418
17425
  import { platform } from "node:process";
17419
17426
  import { promisify as promisify2 } from "node:util";
17420
17427
  import { randomUUID as randomUUID4 } from "node:crypto";
17421
17428
  function resolveInternalRoleEntrypoint(packageRoot2) {
17422
- return join17(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
17429
+ return join16(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
17423
17430
  }
17424
17431
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
17425
17432
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -17660,6 +17667,11 @@ function createPiRoleTurnHost(config) {
17660
17667
  if (typeof process.env.AK_ROLE_AUDITOR_SUBJECT === "string" && process.env.AK_ROLE_AUDITOR_SUBJECT.trim() !== "") {
17661
17668
  env.AK_ROLE_AUDITOR_SUBJECT = process.env.AK_ROLE_AUDITOR_SUBJECT;
17662
17669
  }
17670
+ if (typeof request.navigatorWorkContextPath === "string" && request.navigatorWorkContextPath.trim() !== "") {
17671
+ env.AK_ROLE_NAVIGATOR_WORK_CONTEXT = request.navigatorWorkContextPath.trim();
17672
+ } else {
17673
+ delete env.AK_ROLE_NAVIGATOR_WORK_CONTEXT;
17674
+ }
17663
17675
  if (config.recordLaunchedRolePackageIdentity !== void 0 && config.observeLaunchedRolePackageIdentity !== void 0) {
17664
17676
  await config.recordLaunchedRolePackageIdentity(
17665
17677
  request.runDirectory,
@@ -17782,15 +17794,15 @@ var init_role_turn_host = __esm({
17782
17794
 
17783
17795
  // src/public-cli/load-production-acp-host.ts
17784
17796
  import { existsSync as existsSync5 } from "node:fs";
17785
- import { join as join18 } from "node:path";
17797
+ import { join as join17 } from "node:path";
17786
17798
  import { pathToFileURL } from "node:url";
17787
17799
  async function loadProductionAcpHostFactory(packageRoot2, host) {
17788
17800
  const description = lookupHostDescription(host);
17789
17801
  if (description === void 0) {
17790
17802
  throw new Error(`unregistered host: ${host}`);
17791
17803
  }
17792
- const built = join18(packageRoot2, "dist/acp-host/production-host.js");
17793
- const source = join18(packageRoot2, "src/acp-host/production-host.ts");
17804
+ const built = join17(packageRoot2, "dist/acp-host/production-host.js");
17805
+ const source = join17(packageRoot2, "src/acp-host/production-host.ts");
17794
17806
  const target = existsSync5(built) ? built : source;
17795
17807
  const href = pathToFileURL(target).href;
17796
17808
  const mod = await import(href);
@@ -17806,15 +17818,15 @@ var init_load_production_acp_host = __esm({
17806
17818
 
17807
17819
  // src/public-cli/load-production-headless-host.ts
17808
17820
  import { existsSync as existsSync6 } from "node:fs";
17809
- import { join as join19 } from "node:path";
17821
+ import { join as join18 } from "node:path";
17810
17822
  import { pathToFileURL as pathToFileURL2 } from "node:url";
17811
17823
  async function loadProductionHeadlessHostFactory(packageRoot2, host) {
17812
17824
  const description = lookupHeadlessHostDescription(host);
17813
17825
  if (description === void 0) {
17814
17826
  throw new Error(`unregistered headless host: ${host}`);
17815
17827
  }
17816
- const built = join19(packageRoot2, "dist/headless-host/production-host.js");
17817
- const source = join19(packageRoot2, "src/headless-host/production-host.ts");
17828
+ const built = join18(packageRoot2, "dist/headless-host/production-host.js");
17829
+ const source = join18(packageRoot2, "src/headless-host/production-host.ts");
17818
17830
  const target = existsSync6(built) ? built : source;
17819
17831
  const href = pathToFileURL2(target).href;
17820
17832
  const mod = await import(href);
@@ -17982,7 +17994,7 @@ var init_role_seat_runtime = __esm({
17982
17994
  });
17983
17995
 
17984
17996
  // src/archivist-record-pointer.ts
17985
- import { basename as basename8, join as join20 } from "node:path";
17997
+ import { basename as basename8, join as join19 } from "node:path";
17986
17998
  function bookDirectOfficerRunPointer(options) {
17987
17999
  const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
17988
18000
  const pointer = {
@@ -18031,7 +18043,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
18031
18043
  };
18032
18044
  }
18033
18045
  async function readBookedOfficerPointers(parentRunDirectory) {
18034
- const { records, diagnostics } = await readSitianRecords(join20(parentRunDirectory, RUN_HISTORY_FILE));
18046
+ const { records, diagnostics } = await readSitianRecords(join19(parentRunDirectory, RUN_HISTORY_FILE));
18035
18047
  if (diagnostics.length > 0) {
18036
18048
  throw new Error(
18037
18049
  `${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
@@ -18095,7 +18107,7 @@ function createPiDoctorAuditor() {
18095
18107
  var init_doctor_auditor = __esm({
18096
18108
  "src/doctor-auditor.ts"() {
18097
18109
  "use strict";
18098
- init_auditor_dossier_tool();
18110
+ init_role_run_placement();
18099
18111
  init_compliance_transport();
18100
18112
  init_dossier_resolution();
18101
18113
  init_doctor_contracts();
@@ -18325,12 +18337,12 @@ var init_submission_gate = __esm({
18325
18337
  // src/session-opening-materials.ts
18326
18338
  import { existsSync as existsSync7 } from "node:fs";
18327
18339
  import { readFile as readFile9 } from "node:fs/promises";
18328
- import { dirname as dirname13, join as join21 } from "node:path";
18340
+ import { dirname as dirname13, join as join20 } from "node:path";
18329
18341
  import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
18330
18342
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
18331
18343
  let dir = dirname13(fileURLToPath(moduleUrl));
18332
18344
  for (let i = 0; i < 8; i += 1) {
18333
- if (existsSync7(join21(dir, "package.json")) && existsSync7(join21(dir, "souls"))) {
18345
+ if (existsSync7(join20(dir, "package.json")) && existsSync7(join20(dir, "souls"))) {
18334
18346
  return dir;
18335
18347
  }
18336
18348
  const parent = dirname13(dir);
@@ -18784,7 +18796,8 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
18784
18796
  ...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId },
18785
18797
  ...options.invocationScopeId === void 0 || options.invocationScopeId.length === 0 ? {} : { invocationScopeId: options.invocationScopeId },
18786
18798
  ...options.stationChild === void 0 ? {} : { stationChild: options.stationChild },
18787
- ...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit }
18799
+ ...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit },
18800
+ ...options.navigatorWorkContextPath === void 0 || options.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: options.navigatorWorkContextPath }
18788
18801
  };
18789
18802
  }
18790
18803
  function packagedSettleSkill(admitted) {
@@ -18811,11 +18824,6 @@ function activationForAdmitted(admitted) {
18811
18824
  const activation = { role: admitted.role };
18812
18825
  for (const spec of packagedRoleActivationFlags(admitted.role)) {
18813
18826
  let value = readAdmittedPath(admitted, spec.from ?? spec.field);
18814
- if (spec.fallback === "gate-pointer") {
18815
- const trimmed = typeof value === "string" ? value.trim() : "";
18816
- value = trimmed !== "" ? trimmed : parentRunPathFromGatePointerInstruction(admitted.instruction);
18817
- if (typeof value !== "string" || value === "") continue;
18818
- }
18819
18827
  if (value === void 0) continue;
18820
18828
  if (spec.text === true) {
18821
18829
  if (typeof value !== "number") continue;
@@ -18857,7 +18865,6 @@ var init_turn_request = __esm({
18857
18865
  init_engine_material();
18858
18866
  init_packaged_role_registry();
18859
18867
  init_machine_method_skills();
18860
- init_run_lifecycle();
18861
18868
  }
18862
18869
  });
18863
18870
 
@@ -19046,11 +19053,44 @@ function buildInstructionSeatTurnRequest(admitted, options) {
19046
19053
  options
19047
19054
  );
19048
19055
  }
19049
- function initialPrompt(admitted, env) {
19056
+ async function loadLedgerPeerBody(sourceRunDirectory, projectRoot, home) {
19057
+ const runId = runIdFromRunDirectory(sourceRunDirectory);
19058
+ if (runId === void 0) return void 0;
19059
+ const rows = await readRecordedSubmissionRows(projectRoot, runId, {
19060
+ home,
19061
+ sessionParent: sessionFileOf(sourceRunDirectory)
19062
+ });
19063
+ const latest = rows.at(-1);
19064
+ if (latest === void 0) return void 0;
19065
+ return readableGateItem(latest.accepted);
19066
+ }
19067
+ async function resolveReviewSeatDialogueBody(input) {
19068
+ const reask = input.reask;
19069
+ if (reask !== void 0 && reask.length > 0) return reask;
19070
+ const caller = input.callerInstruction ?? "";
19071
+ if (caller.length > 0) return caller;
19072
+ const sourceRunPath = input.sourceRunPath?.trim() ?? "";
19073
+ if (sourceRunPath === "") return void 0;
19074
+ return await loadLedgerPeerBody(sourceRunPath, input.projectRoot, input.home);
19075
+ }
19076
+ function admittedSourceRunPath(admitted) {
19077
+ return "sourceRunPath" in admitted && typeof admitted.sourceRunPath === "string" ? admitted.sourceRunPath.trim() : "";
19078
+ }
19079
+ async function resolveInitialPrompt(admitted, env) {
19050
19080
  const record = roleRecord(admitted.role);
19051
- const reask = env.reviewReask ?? env.gateReviewInstruction;
19052
- if (reask !== void 0 && "reaskPrompt" in record && record.reaskPrompt === true) {
19053
- return reask;
19081
+ if ("reaskPrompt" in record && record.reaskPrompt === true) {
19082
+ const sourceRunPath = admittedSourceRunPath(admitted);
19083
+ const reask = env.reviewReask ?? env.gateReviewInstruction;
19084
+ const body = await resolveReviewSeatDialogueBody({
19085
+ ...reask === void 0 ? {} : { reask },
19086
+ callerInstruction: admitted.instruction,
19087
+ ...sourceRunPath === "" ? {} : { sourceRunPath },
19088
+ projectRoot: admitted.projectRoot,
19089
+ home: env.home
19090
+ });
19091
+ if (body !== void 0) {
19092
+ return appendCallerFileFlagPaths(body, admitted.attachments);
19093
+ }
19054
19094
  }
19055
19095
  return buildInstructionTransportPrompt(admitted);
19056
19096
  }
@@ -19132,6 +19172,7 @@ async function dispatchAdmitted(admitted, env, io) {
19132
19172
  if (activeEnv.correlationId !== void 0 && activeEnv.correlationId.trim() !== "") {
19133
19173
  await recordAdmittedCorrelation(admitted, activeEnv.correlationId);
19134
19174
  }
19175
+ const initialPromptText = await resolveInitialPrompt(admitted, activeEnv);
19135
19176
  const auto = "inCallAutoResume" in record && record.inCallAutoResume === true;
19136
19177
  if (auto) {
19137
19178
  return await runPostAdmissionResumable({
@@ -19140,7 +19181,10 @@ async function dispatchAdmitted(admitted, env, io) {
19140
19181
  io: turnIo,
19141
19182
  buildInitialRequest: () => buildInstructionSeatTurnRequest(
19142
19183
  admitted,
19143
- roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })
19184
+ roleTurnOptions(activeEnv, admitted, {
19185
+ kind: "initial",
19186
+ prompt: initialPromptText
19187
+ })
19144
19188
  ),
19145
19189
  buildResumeRequest: () => buildInstructionSeatTurnRequest(
19146
19190
  admitted,
@@ -19159,7 +19203,10 @@ async function dispatchAdmitted(admitted, env, io) {
19159
19203
  io: turnIo,
19160
19204
  request: buildInstructionSeatTurnRequest(
19161
19205
  admitted,
19162
- roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })
19206
+ roleTurnOptions(activeEnv, admitted, {
19207
+ kind: "initial",
19208
+ prompt: initialPromptText
19209
+ })
19163
19210
  ),
19164
19211
  adapters,
19165
19212
  ...activeEnv.engine === void 0 ? {} : { effectiveEngine: activeEnv.engine }
@@ -19259,10 +19306,19 @@ function resumeSameParentInstructionSeat(input) {
19259
19306
  )
19260
19307
  });
19261
19308
  }
19262
- function sameParentInstruction(env, fallback) {
19263
- const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
19264
- if (resumeInstruction === void 0) return fallback;
19265
- return { instruction: resumeInstruction, instructionEmpty: false };
19309
+ async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot) {
19310
+ const reask = env.reviewReask ?? env.gateReviewInstruction;
19311
+ const body = await resolveReviewSeatDialogueBody({
19312
+ ...reask === void 0 ? {} : { reask },
19313
+ callerInstruction: fallback.instruction,
19314
+ sourceRunPath,
19315
+ projectRoot,
19316
+ home: env.home
19317
+ });
19318
+ if (body !== void 0) {
19319
+ return { instruction: body, instructionEmpty: false };
19320
+ }
19321
+ return fallback;
19266
19322
  }
19267
19323
  async function runCountersignBody(parsed, env, io) {
19268
19324
  const gateParentRunPath = typeof env.parentRunPath === "string" && env.parentRunPath.trim() !== "" ? env.parentRunPath : void 0;
@@ -19278,7 +19334,10 @@ async function runCountersignBody(parsed, env, io) {
19278
19334
  summons: {
19279
19335
  sourceRunPath: gateParentRunPath,
19280
19336
  instruction: resumeInstruction,
19281
- instructionEmpty: resumeInstruction.length === 0
19337
+ instructionEmpty: resumeInstruction.length === 0,
19338
+ // #1166 J11: same-parent resume delivers this call's file-flag paths
19339
+ // through the shared summons → appendCallerFileFlagPaths rule.
19340
+ attachmentPaths: parsed.attachmentPaths ?? []
19282
19341
  }
19283
19342
  });
19284
19343
  if (resumed != null) return resumed;
@@ -19310,9 +19369,10 @@ async function runCountersignBody(parsed, env, io) {
19310
19369
  await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
19311
19370
  admitted = { ...admitted, sourceRunPath: gateParentRunPath };
19312
19371
  }
19372
+ const reviewBody = env.reviewReask ?? env.gateReviewInstruction;
19313
19373
  const turnProjection = roleTurnOptions(env, admitted, {
19314
19374
  kind: "initial",
19315
- prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInstructionTransportPrompt(admitted)
19375
+ prompt: reviewBody !== void 0 ? appendCallerFileFlagPaths(reviewBody, admitted.attachments) : buildInstructionTransportPrompt(admitted)
19316
19376
  });
19317
19377
  const turnRequest = buildInstructionSeatTurnRequest(admitted, turnProjection);
19318
19378
  const result = await runPostAdmissionOneShot({
@@ -19395,10 +19455,15 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
19395
19455
  if (auditorSource === void 0) return { exitCode: 2 };
19396
19456
  const sourceDirectory = auditorSource;
19397
19457
  const summons = {
19398
- ...sameParentInstruction(env, {
19399
- instruction: parsed.instruction ?? "",
19400
- instructionEmpty: (parsed.instruction ?? "").length === 0
19401
- }),
19458
+ ...await sameParentDialogue(
19459
+ env,
19460
+ {
19461
+ instruction: parsed.instruction ?? "",
19462
+ instructionEmpty: (parsed.instruction ?? "").length === 0
19463
+ },
19464
+ sourceDirectory,
19465
+ projectRoot
19466
+ ),
19402
19467
  attachmentPaths: parsed.attachmentPaths ?? []
19403
19468
  };
19404
19469
  const resumed = await withAuditorSoulEnv({
@@ -19415,15 +19480,33 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
19415
19480
  });
19416
19481
  if (resumed != null) return resumed;
19417
19482
  }
19418
- if (record.sameParent === "gate-pointer") {
19419
- const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction ?? "");
19420
- if (parentRunPath !== void 0) {
19483
+ if (record.sameParent === "source-run") {
19484
+ if (parsed.sourceRun !== void 0) {
19485
+ let parentRunPath;
19486
+ try {
19487
+ parentRunPath = (await resolveNotarySourceRunLocator({
19488
+ projectRoot,
19489
+ sourceRun: parsed.sourceRun,
19490
+ home: env.home
19491
+ })).runDirectory;
19492
+ } catch (error) {
19493
+ if (error instanceof NotarySourceRunError) {
19494
+ presentStructuralRejection(new CliUsageError(error.message, { cause: error }), io);
19495
+ return { exitCode: 2 };
19496
+ }
19497
+ throw error;
19498
+ }
19421
19499
  const summons = {
19422
19500
  sourceRunPath: parentRunPath,
19423
- ...sameParentInstruction(env, {
19424
- instruction: parsed.instruction ?? "",
19425
- instructionEmpty: (parsed.instruction ?? "").length === 0
19426
- }),
19501
+ ...await sameParentDialogue(
19502
+ env,
19503
+ {
19504
+ instruction: parsed.instruction ?? "",
19505
+ instructionEmpty: (parsed.instruction ?? "").length === 0
19506
+ },
19507
+ parentRunPath,
19508
+ projectRoot
19509
+ ),
19427
19510
  attachmentPaths: parsed.attachmentPaths ?? []
19428
19511
  };
19429
19512
  const resumed = await resumeSameParentInstructionSeat({
@@ -19452,11 +19535,15 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
19452
19535
  }
19453
19536
  throw error;
19454
19537
  }
19455
- const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
19456
19538
  const summons = {
19457
19539
  sourceRunPath: source.runDirectory,
19458
19540
  sourceRun: source,
19459
- ...resumeInstruction === void 0 ? {} : { instruction: resumeInstruction, instructionEmpty: false }
19541
+ ...await sameParentDialogue(
19542
+ env,
19543
+ { instruction: "", instructionEmpty: true },
19544
+ source.runDirectory,
19545
+ projectRoot
19546
+ )
19460
19547
  };
19461
19548
  resolvedNotarySource = source;
19462
19549
  const resumed = await resumeSameParentInstructionSeat({
@@ -19486,16 +19573,18 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
19486
19573
  if (rejected !== void 0) return rejected;
19487
19574
  throw error;
19488
19575
  }
19489
- if (record.sameParent === "gate-pointer") {
19490
- const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction ?? "");
19491
- if (parentRunPath !== void 0) {
19492
- await persistAdmittedSourceRunPath(admitted, parentRunPath);
19493
- const sourcePatch = { sourceRunPath: parentRunPath };
19494
- admitted = { ...admitted, ...sourcePatch };
19495
- }
19576
+ if (record.sameParent === "source-run" && parsed.sourceRun !== void 0) {
19577
+ const parentRunPath = (await resolveNotarySourceRunLocator({
19578
+ projectRoot,
19579
+ sourceRun: parsed.sourceRun,
19580
+ home: env.home
19581
+ })).runDirectory;
19582
+ await persistAdmittedSourceRunPath(admitted, parentRunPath);
19583
+ admitted = { ...admitted, sourceRunPath: parentRunPath };
19496
19584
  }
19497
19585
  if (record.sameParent === "subject-source" && auditorSource !== void 0) {
19498
19586
  await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
19587
+ admitted = { ...admitted, sourceRunPath: auditorSource };
19499
19588
  }
19500
19589
  const runAdmitted = async () => {
19501
19590
  await markRunAdmitted(admitted, env.principalAuthority);
@@ -19824,13 +19913,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
19824
19913
  summonAuditor: async (subject, sourceRunDirectory, signal, reask, submission) => {
19825
19914
  const summoned = await summonPublicRole({
19826
19915
  role: "auditor",
19827
- argv: [
19828
- "--subject",
19829
- subject,
19830
- "--source-run",
19831
- sourceRunDirectory,
19832
- `${AUDITOR_DOSSIER_PROMPT}${sourceRunDirectory}`
19833
- ],
19916
+ argv: ["--subject", subject, "--source-run", sourceRunDirectory],
19834
19917
  cwd: admitted.projectRoot,
19835
19918
  home: env.home,
19836
19919
  packageRoot: env.packageRoot,
@@ -19990,7 +20073,6 @@ var init_instruction_seat_run = __esm({
19990
20073
  "src/public-cli/instruction-seat-run.ts"() {
19991
20074
  "use strict";
19992
20075
  init_role_run_placement();
19993
- init_compliance_transport();
19994
20076
  init_archivist_record_pointer();
19995
20077
  init_doctor_auditor();
19996
20078
  init_gatekeeper_role();
@@ -20075,7 +20157,7 @@ __export(public_role_summons_exports, {
20075
20157
  import { execFile as execFile3 } from "node:child_process";
20076
20158
  import { existsSync as existsSync8 } from "node:fs";
20077
20159
  import { realpath as realpath5 } from "node:fs/promises";
20078
- import { join as join23 } from "node:path";
20160
+ import { join as join22 } from "node:path";
20079
20161
  import { promisify as promisify3 } from "node:util";
20080
20162
  function createCapturingIo() {
20081
20163
  const chunks = [];
@@ -20099,7 +20181,7 @@ function parentDir(path) {
20099
20181
  function walkPackageRoot(start) {
20100
20182
  let dir = start;
20101
20183
  for (let i = 0; i < 12; i += 1) {
20102
- if (existsSync8(join23(dir, "package.json")) && existsSync8(join23(dir, "souls"))) {
20184
+ if (existsSync8(join22(dir, "package.json")) && existsSync8(join22(dir, "souls"))) {
20103
20185
  return dir;
20104
20186
  }
20105
20187
  const parent = parentDir(dir);
@@ -20267,7 +20349,8 @@ async function summonPublicRole(options) {
20267
20349
  ...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
20268
20350
  ...options.parentRunPath === void 0 || options.parentRunPath.trim() === "" ? {} : { parentRunPath: options.parentRunPath },
20269
20351
  ...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
20270
- ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
20352
+ ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
20353
+ ...options.navigatorWorkContextPath === void 0 || options.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: options.navigatorWorkContextPath }
20271
20354
  }
20272
20355
  };
20273
20356
  } catch (error) {
@@ -20524,7 +20607,8 @@ async function summonGateOfficer(options) {
20524
20607
  "judge",
20525
20608
  "--source-run",
20526
20609
  options.sourceRunDirectory,
20527
- `\u5377\u5B97\u6307\u9488\uFF1A${options.sourceRunDirectory}`
20610
+ "--project",
20611
+ options.cwd
20528
20612
  ],
20529
20613
  ...common
20530
20614
  });
@@ -20552,7 +20636,7 @@ async function summonGateOfficer(options) {
20552
20636
  }
20553
20637
  return summonPublicRole({
20554
20638
  role: options.officer,
20555
- argv: [`\u5377\u5B97\u6307\u9488\uFF1A${options.sourceRunDirectory}`],
20639
+ argv: ["--source-run", options.sourceRunDirectory, "--project", options.cwd],
20556
20640
  ...common
20557
20641
  });
20558
20642
  }
@@ -20660,8 +20744,7 @@ async function runComplianceAudit(options) {
20660
20744
  "--subject",
20661
20745
  auditSubject,
20662
20746
  "--source-run",
20663
- sourceRunDirectory,
20664
- `${AUDITOR_DOSSIER_PROMPT}${sourceRunDirectory}`
20747
+ sourceRunDirectory
20665
20748
  ],
20666
20749
  cwd: options.context.cwd ?? process.cwd(),
20667
20750
  home,
@@ -20685,24 +20768,23 @@ async function runComplianceAudit(options) {
20685
20768
  return decision;
20686
20769
  }
20687
20770
  }
20688
- var AUDITOR_DOSSIER_PROMPT, AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE;
20771
+ var AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE;
20689
20772
  var init_compliance_transport = __esm({
20690
20773
  "src/compliance-transport.ts"() {
20691
20774
  "use strict";
20692
- init_auditor_dossier_tool();
20775
+ init_role_run_placement();
20693
20776
  init_gatekeeper_role();
20694
20777
  init_submission_errors();
20695
20778
  init_terminal();
20696
20779
  init_readable_gate_item();
20697
20780
  init_receipt_delivery_policy();
20698
20781
  init_unknown_value();
20699
- AUDITOR_DOSSIER_PROMPT = "\u5377\u5B97\u6307\u9488\uFF1A";
20700
20782
  AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
20701
20783
  }
20702
20784
  });
20703
20785
 
20704
20786
  // src/role-run-relocation.ts
20705
- import { dirname as dirname15, join as join24, sep as sep4 } from "node:path";
20787
+ import { dirname as dirname15, join as join23, sep as sep4 } from "node:path";
20706
20788
  function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
20707
20789
  if (typeof value !== "string") return value;
20708
20790
  if (value === oldRunDirectory) return newRunDirectory;
@@ -20820,7 +20902,6 @@ var init_role_run_relocation = __esm({
20820
20902
  var run_lifecycle_exports = {};
20821
20903
  __export(run_lifecycle_exports, {
20822
20904
  AUTO_RESUME_LIMIT: () => AUTO_RESUME_LIMIT,
20823
- GATE_DOSSIER_POINTER_PREFIX: () => GATE_DOSSIER_POINTER_PREFIX,
20824
20905
  RESUME_TRANSPORT_ENVELOPE: () => RESUME_TRANSPORT_ENVELOPE,
20825
20906
  RunWriterLeaseHeldError: () => RunWriterLeaseHeldError,
20826
20907
  acquireRunWriterLease: () => acquireRunWriterLease,
@@ -20834,7 +20915,6 @@ __export(run_lifecycle_exports, {
20834
20915
  markRunAdmitted: () => markRunAdmitted,
20835
20916
  markRunRunning: () => markRunRunning,
20836
20917
  markRunTerminal: () => markRunTerminal,
20837
- parentRunPathFromGatePointerInstruction: () => parentRunPathFromGatePointerInstruction,
20838
20918
  peekRoleRunRole: () => peekRoleRunRole,
20839
20919
  readCurrentCourt: () => readCurrentCourt,
20840
20920
  readRoleRunIdentity: () => readRoleRunIdentity,
@@ -20844,7 +20924,7 @@ __export(run_lifecycle_exports, {
20844
20924
  writeRoleRunState: () => writeRoleRunState
20845
20925
  });
20846
20926
  import { chmod, lstat as lstat3, open, readdir as readdir3, readFile as readFile10, unlink } from "node:fs/promises";
20847
- import { basename as basename10, join as join25 } from "node:path";
20927
+ import { basename as basename10, join as join24 } from "node:path";
20848
20928
  function buildAutoResumeContinuationPrompt() {
20849
20929
  return RESUME_TRANSPORT_ENVELOPE;
20850
20930
  }
@@ -21141,7 +21221,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
21141
21221
  },
21142
21222
  relocate(nextRunDirectory) {
21143
21223
  currentRunDirectory = nextRunDirectory;
21144
- currentLockPath = join25(nextRunDirectory, WRITER_LOCK_FILE);
21224
+ currentLockPath = join24(nextRunDirectory, WRITER_LOCK_FILE);
21145
21225
  },
21146
21226
  async release() {
21147
21227
  if (released) return;
@@ -21180,10 +21260,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
21180
21260
  };
21181
21261
  const reportReadFailure = (error) => {
21182
21262
  reportDiagnostic(
21183
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join25(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
21263
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join24(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
21184
21264
  );
21185
21265
  };
21186
- const lockPath = join25(runDirectory, WRITER_LOCK_FILE);
21266
+ const lockPath = join24(runDirectory, WRITER_LOCK_FILE);
21187
21267
  let lastAutopsy = { verdict: "absent" };
21188
21268
  let lastReclaimFailure;
21189
21269
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -21240,7 +21320,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
21240
21320
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
21241
21321
  if (runId.trim() === "") return void 0;
21242
21322
  const ledgerHome = resolveActivationLedgerHome(home);
21243
- const booksRoot = join25(ledgerHome, "books");
21323
+ const booksRoot = join24(ledgerHome, "books");
21244
21324
  let bookKeys;
21245
21325
  try {
21246
21326
  bookKeys = await readdir3(booksRoot);
@@ -21254,20 +21334,12 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
21254
21334
  onlyRole
21255
21335
  );
21256
21336
  }
21257
- function parentRunPathFromGatePointerInstruction(instruction) {
21258
- if (!instruction.startsWith(GATE_DOSSIER_POINTER_PREFIX)) return void 0;
21259
- const path = instruction.slice(GATE_DOSSIER_POINTER_PREFIX.length).trim();
21260
- return path === "" ? void 0 : path;
21261
- }
21262
21337
  async function readRunParentPath(runDirectory) {
21263
21338
  const record = readPageSync(runDirectory, "admitted");
21264
21339
  if (record === void 0) return void 0;
21265
21340
  if (typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "") {
21266
21341
  return record.sourceRunPath;
21267
21342
  }
21268
- if (typeof record.instruction === "string") {
21269
- return parentRunPathFromGatePointerInstruction(record.instruction);
21270
- }
21271
21343
  return void 0;
21272
21344
  }
21273
21345
  async function runHasFormedSessionPrincipal(runDirectory) {
@@ -21291,7 +21363,7 @@ async function findLatestRunIdForSeatTicket(input) {
21291
21363
  let runDirectories;
21292
21364
  try {
21293
21365
  runDirectories = await listBookRunDirectories(
21294
- input.ticketNumber === void 0 ? bookDir : join25(bookDir, String(input.ticketNumber))
21366
+ input.ticketNumber === void 0 ? bookDir : join24(bookDir, String(input.ticketNumber))
21295
21367
  );
21296
21368
  } catch (error) {
21297
21369
  if (errorCodeOf(error) === "ENOENT") return void 0;
@@ -21773,7 +21845,7 @@ function resumedWorkerPhase(phase, phases, role, runId) {
21773
21845
  }
21774
21846
  throw new CliUsageError(`role run admitted ${role} phase is missing: ${runId}`);
21775
21847
  }
21776
- var AUTO_RESUME_LIMIT, RESUME_TRANSPORT_ENVELOPE, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS, GATE_DOSSIER_POINTER_PREFIX;
21848
+ var AUTO_RESUME_LIMIT, RESUME_TRANSPORT_ENVELOPE, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
21777
21849
  var init_run_lifecycle = __esm({
21778
21850
  "src/public-cli/run-lifecycle.ts"() {
21779
21851
  "use strict";
@@ -21806,7 +21878,6 @@ var init_run_lifecycle = __esm({
21806
21878
  }
21807
21879
  };
21808
21880
  WRITER_LEASE_RECLAIM_ROUNDS = 3;
21809
- GATE_DOSSIER_POINTER_PREFIX = "\u5377\u5B97\u6307\u9488\uFF1A";
21810
21881
  }
21811
21882
  });
21812
21883
 
@@ -22552,21 +22623,19 @@ async function dispatchPostAdmissionTurn(input) {
22552
22623
  }
22553
22624
  function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepared) {
22554
22625
  const officerDialogue = isStationChildOfficerDialogue(admitted.role, env);
22626
+ const fileFlags = summonsPrepared?.attachments ?? [];
22555
22627
  let prompt;
22556
22628
  if (request.message !== void 0) {
22557
22629
  if (summonsPrepared !== void 0) {
22558
- prompt = officerDialogue ? request.message : buildInstructionTransportPrompt({
22559
- instruction: request.message,
22560
- instructionEmpty: false,
22561
- attachments: summonsPrepared.attachments
22562
- });
22630
+ prompt = officerDialogue && fileFlags.length === 0 ? request.message : appendCallerFileFlagPaths(request.message, fileFlags);
22563
22631
  } else if (request.summons !== void 0) {
22564
22632
  prompt = request.message;
22565
22633
  } else {
22566
22634
  prompt = request.message;
22567
22635
  }
22568
22636
  } else if (summonsPrepared !== void 0) {
22569
- prompt = officerDialogue ? summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
22637
+ const body = summonsPrepared.instruction;
22638
+ prompt = officerDialogue && fileFlags.length === 0 ? body : appendCallerFileFlagPaths(body, fileFlags);
22570
22639
  } else if (request.summons !== void 0) {
22571
22640
  prompt = "";
22572
22641
  } else {
@@ -22582,7 +22651,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
22582
22651
  },
22583
22652
  ...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
22584
22653
  // #1132: one configured ceiling, already resolved by the caller (#422).
22585
- deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
22654
+ deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit),
22655
+ ...env.navigatorWorkContextPath === void 0 || env.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: env.navigatorWorkContextPath }
22586
22656
  };
22587
22657
  }
22588
22658
  function roleTurnOptions(env, admitted, continuation) {
@@ -22594,7 +22664,8 @@ function roleTurnOptions(env, admitted, continuation) {
22594
22664
  continuation,
22595
22665
  ...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
22596
22666
  // #1132: one configured ceiling, already resolved by the caller (#422).
22597
- deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
22667
+ deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit),
22668
+ ...env.navigatorWorkContextPath === void 0 || env.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: env.navigatorWorkContextPath }
22598
22669
  };
22599
22670
  }
22600
22671
  async function dispatchAfterWriterLease(input) {
@@ -28917,10 +28988,10 @@ var init_analyst_book_key = __esm({
28917
28988
  // src/atomic-write.ts
28918
28989
  import { randomUUID as randomUUID6 } from "node:crypto";
28919
28990
  import { rename as rename2, rm, writeFile as writeFile4 } from "node:fs/promises";
28920
- import { dirname as dirname16, join as join26 } from "node:path";
28991
+ import { dirname as dirname16, join as join25 } from "node:path";
28921
28992
  async function writeFileAtomically(destination, contents, options) {
28922
28993
  const parent = dirname16(destination);
28923
- const temporary = join26(parent, `.atomic-write-${randomUUID6()}.tmp`);
28994
+ const temporary = join25(parent, `.atomic-write-${randomUUID6()}.tmp`);
28924
28995
  try {
28925
28996
  await writeFile4(temporary, contents, options);
28926
28997
  await rename2(temporary, destination);
@@ -28937,12 +29008,12 @@ var init_atomic_write = __esm({
28937
29008
 
28938
29009
  // src/analyst-index.ts
28939
29010
  import { open as open2, readFile as readFile11, unlink as unlink2 } from "node:fs/promises";
28940
- import { dirname as dirname17, join as join27 } from "node:path";
29011
+ import { dirname as dirname17, join as join26 } from "node:path";
28941
29012
  import { setTimeout as sleep } from "node:timers/promises";
28942
29013
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
28943
29014
  const indexPath = analystLibraryIndexPath(ledgerHome);
28944
29015
  ensureRealDirectoryTree(ledgerHome, dirname17(indexPath));
28945
- const lockPath = join27(dirname17(indexPath), LIBRARY_INDEX_LOCK_NAME);
29016
+ const lockPath = join26(dirname17(indexPath), LIBRARY_INDEX_LOCK_NAME);
28946
29017
  assertLedgerFileInsideHome(lockPath, ledgerHome);
28947
29018
  const startedAt = Date.now();
28948
29019
  while (true) {
@@ -28969,7 +29040,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
28969
29040
  }
28970
29041
  }
28971
29042
  function analystLibraryIndexPath(ledgerHome) {
28972
- return join27(ledgerHome, "analyst", "library-index.json");
29043
+ return join26(ledgerHome, "analyst", "library-index.json");
28973
29044
  }
28974
29045
  function rowFromIssueMetricsPage(page) {
28975
29046
  return {
@@ -29515,7 +29586,7 @@ var init_analyst_gate_cycles_read = __esm({
29515
29586
 
29516
29587
  // src/analyst-ledger.ts
29517
29588
  import { readdir as readdir4 } from "node:fs/promises";
29518
- import { basename as basename11, join as join28 } from "node:path";
29589
+ import { basename as basename11, join as join27 } from "node:path";
29519
29590
  async function readExistingRunLifecycleState(runDirectory) {
29520
29591
  return (await readRoleRunIdentity(runDirectory))?.state;
29521
29592
  }
@@ -29535,7 +29606,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
29535
29606
  }
29536
29607
  }
29537
29608
  async function classifyGhostCandidate(input) {
29538
- const autopsy = await autopsyWriterLock(join28(input.runDirectory, "writer.lock"));
29609
+ const autopsy = await autopsyWriterLock(join27(input.runDirectory, "writer.lock"));
29539
29610
  const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
29540
29611
  if (leaseCheck === void 0) return { kind: "live" };
29541
29612
  return {
@@ -29825,7 +29896,7 @@ async function classifyScopedRun(input) {
29825
29896
  async function scanAnalystIssueRuns(input) {
29826
29897
  const ledgerHome = resolveActivationLedgerHome(input.home);
29827
29898
  const scopeTicketNumber = input.ticketNumber;
29828
- const booksRoot = join28(ledgerHome, "books");
29899
+ const booksRoot = join27(ledgerHome, "books");
29829
29900
  let wholeBook = false;
29830
29901
  let scopeRootIdentity;
29831
29902
  let bookNames;
@@ -29858,7 +29929,7 @@ async function scanAnalystIssueRuns(input) {
29858
29929
  const ghostLegs = [];
29859
29930
  const scopeConflicts = [];
29860
29931
  for (const book of bookNames) {
29861
- const bookDir = join28(booksRoot, book);
29932
+ const bookDir = join27(booksRoot, book);
29862
29933
  let runDirectories;
29863
29934
  try {
29864
29935
  runDirectories = await listBookRunDirectories(bookDir);
@@ -30604,7 +30675,7 @@ var init_analyst_metric_family = __esm({
30604
30675
  });
30605
30676
 
30606
30677
  // src/analyst-page.ts
30607
- import { dirname as dirname18, join as join29 } from "node:path";
30678
+ import { dirname as dirname18, join as join28 } from "node:path";
30608
30679
  function analystIssuePageKey(address) {
30609
30680
  const parts = ["book", address.bookKey];
30610
30681
  if (address.issueNumber !== void 0) {
@@ -30615,7 +30686,7 @@ function analystIssuePageKey(address) {
30615
30686
  return sha256Hex(parts.join("\0")).slice(0, 32);
30616
30687
  }
30617
30688
  function analystIssuePagePath(ledgerHome, address) {
30618
- return join29(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
30689
+ return join28(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
30619
30690
  }
30620
30691
  function analystIssuePageAddressFromPage(page) {
30621
30692
  return {
@@ -32151,7 +32222,7 @@ var init_cli = __esm({
32151
32222
 
32152
32223
  // src/public-cli/main.ts
32153
32224
  import { existsSync as existsSync9 } from "node:fs";
32154
- import { dirname as dirname19, join as join30 } from "node:path";
32225
+ import { dirname as dirname19, join as join29 } from "node:path";
32155
32226
  import { fileURLToPath as fileURLToPath2 } from "node:url";
32156
32227
 
32157
32228
  // src/public-cli/host-pi-runtime.ts
@@ -32240,8 +32311,8 @@ function linkPackage(packageRoot2, name, targetDir) {
32240
32311
  // src/public-cli/main.ts
32241
32312
  var here = dirname19(fileURLToPath2(import.meta.url));
32242
32313
  function resolvePackageRoot(binDir) {
32243
- const canonical = join30(binDir, "..", "..");
32244
- if (existsSync9(join30(canonical, "package.json"))) {
32314
+ const canonical = join29(binDir, "..", "..");
32315
+ if (existsSync9(join29(canonical, "package.json"))) {
32245
32316
  return canonical;
32246
32317
  }
32247
32318
  return binDir;