@akagilnc/pi-workflow-roles 0.1.6017 → 0.1.6021

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.
@@ -12864,6 +12864,51 @@ var init_host_session_record = __esm({
12864
12864
  }
12865
12865
  });
12866
12866
 
12867
+ // src/session-opening-materials.ts
12868
+ import { existsSync as existsSync2 } from "node:fs";
12869
+ import { readFile as readFile5 } from "node:fs/promises";
12870
+ import { dirname as dirname7, join as join11 } from "node:path";
12871
+ import { fileURLToPath, pathToFileURL } from "node:url";
12872
+ function resolvePackageRootDir(moduleUrl = import.meta.url) {
12873
+ let dir = dirname7(fileURLToPath(moduleUrl));
12874
+ for (let i = 0; i < 8; i += 1) {
12875
+ if (existsSync2(join11(dir, "package.json")) && existsSync2(join11(dir, "souls"))) {
12876
+ return dir;
12877
+ }
12878
+ const parent = dirname7(dir);
12879
+ if (parent === dir) break;
12880
+ dir = parent;
12881
+ }
12882
+ return fileURLToPath(new URL("..", moduleUrl));
12883
+ }
12884
+ async function readPackageMaterial(relativePath) {
12885
+ return readFile5(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
12886
+ }
12887
+ async function joinPackageMaterials(relativePaths) {
12888
+ const chunks = [];
12889
+ for (const relativePath of relativePaths) chunks.push(await readPackageMaterial(relativePath));
12890
+ return chunks.join("\n\n");
12891
+ }
12892
+ var packageRootUrl, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
12893
+ var init_session_opening_materials = __esm({
12894
+ "src/session-opening-materials.ts"() {
12895
+ "use strict";
12896
+ init_packaged_role_registry();
12897
+ packageRootUrl = pathToFileURL(resolvePackageRootDir() + "/").href;
12898
+ MAIN_ROLE_SESSION_MATERIALS = {
12899
+ ...Object.fromEntries(
12900
+ PUBLIC_ROLE_RECORDS.map((record) => [record.role, record.sessionMaterials])
12901
+ )
12902
+ };
12903
+ GATEKEEPER_SESSION_MATERIALS = {
12904
+ // #639: single authority — the public gatekeeper record owns the province list.
12905
+ gatekeeper: packagedRoleSessionMaterials("gatekeeper"),
12906
+ inspector: INSPECTOR_SESSION_MATERIALS,
12907
+ notary: NOTARY_SESSION_MATERIALS
12908
+ };
12909
+ }
12910
+ });
12911
+
12867
12912
  // src/submission-correctable-error.ts
12868
12913
  var correctableSubmissionErrorBrand, CorrectableSubmissionError;
12869
12914
  var init_submission_correctable_error = __esm({
@@ -12940,14 +12985,14 @@ var init_terminating_tools = __esm({
12940
12985
  import { spawnSync as spawnSync3 } from "node:child_process";
12941
12986
  import {
12942
12987
  appendFileSync as appendFileSync2,
12943
- existsSync as existsSync2,
12988
+ existsSync as existsSync3,
12944
12989
  mkdirSync as mkdirSync3,
12945
12990
  readFileSync as readFileSync3,
12946
12991
  readdirSync as readdirSync2,
12947
12992
  rmSync as rmSync3,
12948
12993
  writeFileSync as writeFileSync2
12949
12994
  } from "node:fs";
12950
- import { basename as basename7, dirname as dirname7, join as join11, relative as relative2, sep as sep3 } from "node:path";
12995
+ import { basename as basename7, dirname as dirname8, join as join12, relative as relative2, sep as sep3 } from "node:path";
12951
12996
  function parseProgressText(text, pathForDiagnostic) {
12952
12997
  if (text.trim() === "") return [];
12953
12998
  const { records, diagnostics } = parseSitianRecordText(text);
@@ -12967,20 +13012,20 @@ function parseProgressText(text, pathForDiagnostic) {
12967
13012
  return lines;
12968
13013
  }
12969
13014
  function readProgressFile(path) {
12970
- if (!existsSync2(path)) return [];
13015
+ if (!existsSync3(path)) return [];
12971
13016
  return parseProgressText(readFileSync3(path, "utf8"), path);
12972
13017
  }
12973
13018
  function readTicketProgressLines(subjectDirectory) {
12974
13019
  if (basename7(subjectDirectory) === "unbound") {
12975
- const runsDir = join11(subjectDirectory, "runs");
12976
- if (!existsSync2(runsDir)) return [];
13020
+ const runsDir = join12(subjectDirectory, "runs");
13021
+ if (!existsSync3(runsDir)) return [];
12977
13022
  const out = [];
12978
13023
  for (const name of readdirSync2(runsDir).sort()) {
12979
- out.push(...readProgressFile(join11(runsDir, name, LEG_PROGRESS_FILENAME)));
13024
+ out.push(...readProgressFile(join12(runsDir, name, LEG_PROGRESS_FILENAME)));
12980
13025
  }
12981
13026
  return out;
12982
13027
  }
12983
- return readProgressFile(join11(subjectDirectory, CURRENT_FILENAME));
13028
+ return readProgressFile(join12(subjectDirectory, CURRENT_FILENAME));
12984
13029
  }
12985
13030
  function roundBaseNumber(round) {
12986
13031
  if (round.trim() === "") return 0;
@@ -13003,8 +13048,8 @@ function nextRoundFromLines(lines, seat, lens) {
13003
13048
  return want === void 0 ? String(base) : `${base}.${want}`;
13004
13049
  }
13005
13050
  function nextLegReceiptIndex(runDirectory) {
13006
- const dir = join11(runDirectory, RECEIPTS_DIRNAME);
13007
- if (!existsSync2(dir)) return 1;
13051
+ const dir = join12(runDirectory, RECEIPTS_DIRNAME);
13052
+ if (!existsSync3(dir)) return 1;
13008
13053
  let max = 0;
13009
13054
  for (const name of readdirSync2(dir)) {
13010
13055
  const match = /^(\d+)\.json$/.exec(name);
@@ -13063,11 +13108,11 @@ function landTicketProgress(input) {
13063
13108
  const lens = input.lens === "completeness" || input.lens === "correctness" ? input.lens : lensFromRunDirectory(runDirectory, input.role);
13064
13109
  const leaf = basename7(runDirectory);
13065
13110
  const unbound = basename7(subjectDirectory) === "unbound";
13066
- const progressPath = unbound ? join11(runDirectory, LEG_PROGRESS_FILENAME) : join11(subjectDirectory, CURRENT_FILENAME);
13111
+ const progressPath = unbound ? join12(runDirectory, LEG_PROGRESS_FILENAME) : join12(subjectDirectory, CURRENT_FILENAME);
13067
13112
  const receiptIndex = nextLegReceiptIndex(runDirectory);
13068
13113
  const relativePath = `runs/${leaf}/${RECEIPTS_DIRNAME}/${receiptIndex}.json`;
13069
- const absolutePath = join11(subjectDirectory, relativePath);
13070
- mkdirSync3(dirname7(absolutePath), { recursive: true });
13114
+ const absolutePath = join12(subjectDirectory, relativePath);
13115
+ mkdirSync3(dirname8(absolutePath), { recursive: true });
13071
13116
  writeFileSync2(absolutePath, `${JSON.stringify(input.accepted, null, 2)}
13072
13117
  `, "utf8");
13073
13118
  if (!unbound) {
@@ -13089,7 +13134,7 @@ function landTicketProgress(input) {
13089
13134
  receipt: relativePath,
13090
13135
  session: sessionRelative
13091
13136
  };
13092
- mkdirSync3(dirname7(progressPath), { recursive: true });
13137
+ mkdirSync3(dirname8(progressPath), { recursive: true });
13093
13138
  appendFileSync2(progressPath, `${JSON.stringify(line2)}
13094
13139
  `, "utf8");
13095
13140
  if (input.sealHead.fault !== void 0) {
@@ -13102,10 +13147,10 @@ function relocateTicketProgressForLeg(input) {
13102
13147
  if (isUnboundRunDirectory(input.runDirectory)) return;
13103
13148
  const subjectDirectory = subjectDirectoryOfRun(input.runDirectory);
13104
13149
  if (subjectDirectory === void 0) return;
13105
- const stagedPath = join11(input.runDirectory, LEG_PROGRESS_FILENAME);
13150
+ const stagedPath = join12(input.runDirectory, LEG_PROGRESS_FILENAME);
13106
13151
  const mine = readProgressFile(stagedPath);
13107
13152
  if (mine.length === 0) {
13108
- if (existsSync2(stagedPath)) {
13153
+ if (existsSync3(stagedPath)) {
13109
13154
  rmSync3(stagedPath, { force: true });
13110
13155
  }
13111
13156
  return;
@@ -13130,8 +13175,8 @@ function relocateTicketProgressForLeg(input) {
13130
13175
  movedLines.push(moved);
13131
13176
  ticketLines.push(moved);
13132
13177
  }
13133
- const newCurrent = join11(subjectDirectory, CURRENT_FILENAME);
13134
- mkdirSync3(dirname7(newCurrent), { recursive: true });
13178
+ const newCurrent = join12(subjectDirectory, CURRENT_FILENAME);
13179
+ mkdirSync3(dirname8(newCurrent), { recursive: true });
13135
13180
  appendFileSync2(
13136
13181
  newCurrent,
13137
13182
  `${movedLines.map((line2) => JSON.stringify(line2)).join("\n")}
@@ -13170,8 +13215,8 @@ var init_sha256 = __esm({
13170
13215
  });
13171
13216
 
13172
13217
  // src/doctor-evidence.ts
13173
- import { readdir as readdir2, readFile as readFile5, realpath, stat } from "node:fs/promises";
13174
- import { dirname as dirname8, relative as relative3, resolve as resolve4, sep as sep4 } from "node:path";
13218
+ import { readdir as readdir2, readFile as readFile6, realpath, stat } from "node:fs/promises";
13219
+ import { dirname as dirname9, relative as relative3, resolve as resolve4, sep as sep4 } from "node:path";
13175
13220
  async function discoverCaseFiles(root) {
13176
13221
  const found = [];
13177
13222
  async function walk(dir, depth) {
@@ -13204,7 +13249,7 @@ async function stableRunsIdentity(root) {
13204
13249
  } catch (error) {
13205
13250
  if (!isMissingPathError(error)) throw error;
13206
13251
  }
13207
- const parent = dirname8(cursor);
13252
+ const parent = dirname9(cursor);
13208
13253
  if (parent === cursor) return root;
13209
13254
  cursor = parent;
13210
13255
  }
@@ -13283,7 +13328,7 @@ async function loadDoctorCase(runsPath, projectRoot) {
13283
13328
  const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
13284
13329
  for (const path of await discoverCaseFiles(root)) {
13285
13330
  const id = relative3(root, path).split(sep4).join("/");
13286
- const bytes = await readFile5(path);
13331
+ const bytes = await readFile6(path);
13287
13332
  const content = bytes.toString("utf8");
13288
13333
  const kind = id.split("/").length === 2 && id.endsWith("/log.jsonl") ? "log" : "session";
13289
13334
  evidence.push({ id, kind, byteLength: bytes.byteLength, contentLength: content.length, sha256: sha256Hex(bytes), content });
@@ -13361,7 +13406,7 @@ var init_git_object_id = __esm({
13361
13406
 
13362
13407
  // src/merger-git-state.ts
13363
13408
  import { execFile } from "node:child_process";
13364
- import { access, readFile as readFile6 } from "node:fs/promises";
13409
+ import { access, readFile as readFile7 } from "node:fs/promises";
13365
13410
  import { constants as fsConstants } from "node:fs";
13366
13411
  import { isAbsolute as isAbsolute3, resolve as resolve5 } from "node:path";
13367
13412
  import { promisify } from "node:util";
@@ -13431,7 +13476,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
13431
13476
  const mergeHeadPath = isAbsolute3(mergeHeadReported) ? mergeHeadReported : resolve5(repositoryRoot, mergeHeadReported);
13432
13477
  let sourceObjectId = "";
13433
13478
  if (await pathExists(mergeHeadPath)) {
13434
- const raw = exactUtf8(await readFile6(mergeHeadPath), "Git MERGE_HEAD");
13479
+ const raw = exactUtf8(await readFile7(mergeHeadPath), "Git MERGE_HEAD");
13435
13480
  const mergeHeads = raw.trim().split(/\r?\n/).map((row) => row.trim()).filter(Boolean);
13436
13481
  if (mergeHeads.length === 0) throw new Error("Git MERGE_HEAD is empty");
13437
13482
  if (mergeHeads.length !== 1) throw new Error("Assigned repository does not have one ordinary in-progress merge");
@@ -13574,14 +13619,14 @@ var init_session_dialogue = __esm({
13574
13619
  });
13575
13620
 
13576
13621
  // src/ticket-provenance.ts
13577
- import { readFile as readFile7 } from "node:fs/promises";
13578
- import { join as join12, resolve as resolve6 } from "node:path";
13622
+ import { readFile as readFile8 } from "node:fs/promises";
13623
+ import { join as join13, resolve as resolve6 } from "node:path";
13579
13624
  function dialogueSessionSourceRoots(home) {
13580
13625
  const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
13581
13626
  return [
13582
- join12(machineHome, ".claude", "projects"),
13583
- join12(machineHome, ".codex", "sessions"),
13584
- join12(machineHome, ".pi", "agent", "sessions")
13627
+ join13(machineHome, ".claude", "projects"),
13628
+ join13(machineHome, ".codex", "sessions"),
13629
+ join13(machineHome, ".pi", "agent", "sessions")
13585
13630
  ];
13586
13631
  }
13587
13632
  function isLedgerRoleSessionFile(absolute, home) {
@@ -13622,7 +13667,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
13622
13667
  const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
13623
13668
  let history;
13624
13669
  try {
13625
- history = await readFile7(join12(runDirectory, RUN_HISTORY_FILE), "utf8");
13670
+ history = await readFile8(join13(runDirectory, RUN_HISTORY_FILE), "utf8");
13626
13671
  } catch (error) {
13627
13672
  if (errnoCode(error) === "ENOENT") return;
13628
13673
  throw error;
@@ -13689,7 +13734,7 @@ var init_uuidv7 = __esm({
13689
13734
  });
13690
13735
 
13691
13736
  // src/notary-source-run.ts
13692
- import { dirname as dirname9, isAbsolute as isAbsolute4, join as join13, resolve as resolve7, basename as basename8 } from "node:path";
13737
+ import { dirname as dirname10, isAbsolute as isAbsolute4, join as join14, resolve as resolve7, basename as basename8 } from "node:path";
13693
13738
  import { lstat as lstat2, realpath as realpath2 } from "node:fs/promises";
13694
13739
  async function readRetainedIdentity(runDirectory) {
13695
13740
  try {
@@ -13741,16 +13786,16 @@ async function resolveNotarySourceRunLocator(options) {
13741
13786
  const ledgerHome = resolveActivationLedgerHome(options.home);
13742
13787
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
13743
13788
  const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
13744
- const bookRunsRoot = join13(bookDirectory, "runs");
13789
+ const bookRunsRoot = join14(bookDirectory, "runs");
13745
13790
  let candidate;
13746
13791
  const bare = parseRunLeaf(raw);
13747
13792
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
13748
- candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join13(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
13793
+ candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join14(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
13749
13794
  } else {
13750
13795
  candidate = isAbsolute4(raw) ? raw : resolve7(options.projectRoot, raw);
13751
13796
  const identity2 = parseRunLeaf(basename8(candidate));
13752
- const subjectDirectory = dirname9(dirname9(candidate));
13753
- const isLegacyUnboundLocator = identity2 !== void 0 && basename8(dirname9(candidate)) === "runs" && basename8(subjectDirectory) === "unbound" && resolve7(dirname9(subjectDirectory)) === resolve7(bookDirectory);
13797
+ const subjectDirectory = dirname10(dirname10(candidate));
13798
+ const isLegacyUnboundLocator = identity2 !== void 0 && basename8(dirname10(candidate)) === "runs" && basename8(subjectDirectory) === "unbound" && resolve7(dirname10(subjectDirectory)) === resolve7(bookDirectory);
13754
13799
  if (isLegacyUnboundLocator) {
13755
13800
  candidate = await resolveLiveRunDirectoryPath(candidate, options.home ?? ledgerHome, bookKey) ?? candidate;
13756
13801
  }
@@ -13758,9 +13803,9 @@ async function resolveNotarySourceRunLocator(options) {
13758
13803
  const real = await requireRunDirectory(candidate, raw);
13759
13804
  const identity = parseRunLeaf(basename8(real));
13760
13805
  const bookIdentity = physicalPathIdentity(bookDirectory);
13761
- const parentIdentity = physicalPathIdentity(dirname9(real));
13762
- const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
13763
- if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename8(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
13806
+ const parentIdentity = physicalPathIdentity(dirname10(real));
13807
+ const subjectBookIdentity = physicalPathIdentity(dirname10(dirname10(dirname10(real))));
13808
+ if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename8(dirname10(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
13764
13809
  throw new NotarySourceRunError(
13765
13810
  "notary --source-run must resolve to a retained run under the project machine-ledger book"
13766
13811
  );
@@ -14890,14 +14935,14 @@ var init_option_definitions = __esm({
14890
14935
 
14891
14936
  // src/public-cli/invocation.ts
14892
14937
  import { execFileSync as execFileSync2 } from "node:child_process";
14893
- import { existsSync as existsSync3 } from "node:fs";
14938
+ import { existsSync as existsSync4 } from "node:fs";
14894
14939
  import {
14895
- readFile as readFile8,
14940
+ readFile as readFile9,
14896
14941
  realpath as realpath3,
14897
14942
  rename,
14898
14943
  writeFile as writeFile2
14899
14944
  } from "node:fs/promises";
14900
- import { dirname as dirname10, isAbsolute as isAbsolute5, join as join14, resolve as resolve8 } from "node:path";
14945
+ import { dirname as dirname11, isAbsolute as isAbsolute5, join as join15, resolve as resolve8 } from "node:path";
14901
14946
  function admittedSourceRunPath(admitted) {
14902
14947
  if (!isRecord(admitted)) return void 0;
14903
14948
  const path = admitted.sourceRunPath;
@@ -15072,7 +15117,7 @@ async function relocateRegisteredChildDiarists(input) {
15072
15117
  runId: childRunId,
15073
15118
  role: "diarist"
15074
15119
  }).runDirectory;
15075
- if (existsSync3(unboundChildDirectory)) {
15120
+ if (existsSync4(unboundChildDirectory)) {
15076
15121
  input.authority.seal(childTarget);
15077
15122
  await bindTicketNumberOnRunDirectory(unboundChildDirectory, input.ticketNumber);
15078
15123
  await rehomeUnboundTicketProvenance(
@@ -15081,7 +15126,7 @@ async function relocateRegisteredChildDiarists(input) {
15081
15126
  input.projectRoot,
15082
15127
  homeFromRunDirectory(input.parentRunDirectory)
15083
15128
  );
15084
- ensureRoleRunDirectory(input.ledgerHome, dirname10(childTarget.runDirectory));
15129
+ ensureRoleRunDirectory(input.ledgerHome, dirname11(childTarget.runDirectory));
15085
15130
  await rename(unboundChildDirectory, childTarget.runDirectory);
15086
15131
  relocateTicketProgressForLeg({
15087
15132
  runDirectory: childTarget.runDirectory
@@ -15096,7 +15141,7 @@ async function relocateRegisteredChildDiarists(input) {
15096
15141
  }
15097
15142
  continue;
15098
15143
  }
15099
- if (existsSync3(childTarget.runDirectory)) {
15144
+ if (existsSync4(childTarget.runDirectory)) {
15100
15145
  relocateTicketProgressForLeg({
15101
15146
  runDirectory: childTarget.runDirectory
15102
15147
  });
@@ -15129,7 +15174,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
15129
15174
  runId: admitted.runId,
15130
15175
  role: admitted.role
15131
15176
  });
15132
- ensureRoleRunDirectory(ledgerHome, dirname10(target.runDirectory));
15177
+ ensureRoleRunDirectory(ledgerHome, dirname11(target.runDirectory));
15133
15178
  authority.seal(target);
15134
15179
  if (admitted.role !== "diarist") {
15135
15180
  await relocateRegisteredChildDiarists({
@@ -15194,7 +15239,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
15194
15239
  async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
15195
15240
  const rolePackageRoot = packageRoot2;
15196
15241
  const raw = JSON.parse(
15197
- await readFile8(join14(rolePackageRoot, "package.json"), "utf8")
15242
+ await readFile9(join15(rolePackageRoot, "package.json"), "utf8")
15198
15243
  );
15199
15244
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
15200
15245
  throw new Error(
@@ -15765,7 +15810,7 @@ async function admitPublicRole(role, parsed, env, override) {
15765
15810
  resolutionScope: [...derived.resolutionScope],
15766
15811
  authorizedChecks: []
15767
15812
  });
15768
- const mergerInputPath = join14(placed.runDirectory, "merger-input.json");
15813
+ const mergerInputPath = join15(placed.runDirectory, "merger-input.json");
15769
15814
  await writeFile2(
15770
15815
  mergerInputPath,
15771
15816
  `${JSON.stringify(mergerInput, null, 2)}
@@ -16033,7 +16078,7 @@ function parseDoctorIssueNumber(raw) {
16033
16078
  }
16034
16079
  async function resolveDoctorCaseRunsPath(options) {
16035
16080
  const ledgerHome = resolveActivationLedgerHome(options.home);
16036
- const defaultRuns = join14(
16081
+ const defaultRuns = join15(
16037
16082
  activationBookDirectory(ledgerHome, options.bookKey),
16038
16083
  String(options.issueNumber),
16039
16084
  "runs"
@@ -16330,7 +16375,7 @@ var init_invocation = __esm({
16330
16375
  });
16331
16376
 
16332
16377
  // src/report-ticket-tool.ts
16333
- var reportTicketArgsSchema, MISSING_TICKET_REASK_MATERIAL;
16378
+ var reportTicketArgsSchema;
16334
16379
  var init_report_ticket_tool = __esm({
16335
16380
  "src/report-ticket-tool.ts"() {
16336
16381
  "use strict";
@@ -16351,7 +16396,6 @@ var init_report_ticket_tool = __esm({
16351
16396
  },
16352
16397
  { additionalProperties: true }
16353
16398
  );
16354
- MISSING_TICKET_REASK_MATERIAL = "resources/missing-ticket-reask.md";
16355
16399
  }
16356
16400
  });
16357
16401
 
@@ -16550,6 +16594,7 @@ var init_submission_ledger = __esm({
16550
16594
  "src/submission-ledger.ts"() {
16551
16595
  "use strict";
16552
16596
  init_role_run_placement();
16597
+ init_session_opening_materials();
16553
16598
  init_activation_ledger_topology();
16554
16599
  init_host_contracts();
16555
16600
  init_run_terminal_artifacts();
@@ -16729,7 +16774,7 @@ var init_engine_detour_usage = __esm({
16729
16774
  });
16730
16775
 
16731
16776
  // src/dossier-resolution.ts
16732
- import { existsSync as existsSync4, statSync as statSync5 } from "node:fs";
16777
+ import { existsSync as existsSync5, statSync as statSync5 } from "node:fs";
16733
16778
  import { resolve as resolve9 } from "node:path";
16734
16779
  function isHostContext(value) {
16735
16780
  return "sessionManager" in value;
@@ -16749,7 +16794,7 @@ function resolveAuditDossier(source) {
16749
16794
  }
16750
16795
  const runDirectory = resolve9(raw);
16751
16796
  try {
16752
- if (!existsSync4(runDirectory) || !statSync5(runDirectory).isDirectory()) {
16797
+ if (!existsSync5(runDirectory) || !statSync5(runDirectory).isDirectory()) {
16753
16798
  return { status: "incomplete", observation: { kind: "missing-dossier" } };
16754
16799
  }
16755
16800
  } catch {
@@ -17924,7 +17969,7 @@ var init_settlement = __esm({
17924
17969
  });
17925
17970
 
17926
17971
  // src/external-host-turn-loop.ts
17927
- import { existsSync as existsSync5 } from "node:fs";
17972
+ import { existsSync as existsSync6 } from "node:fs";
17928
17973
  import { basename as basename9 } from "node:path";
17929
17974
  async function syncTurnRequestLivePlacement(request, authority) {
17930
17975
  const live = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
@@ -17941,7 +17986,7 @@ async function syncTurnRequestLivePlacement(request, authority) {
17941
17986
  }
17942
17987
  async function retainPackageFaultBesideLivePlacement(request, input) {
17943
17988
  let runDirectory = request.runDirectory;
17944
- if (!existsSync5(runDirectory)) {
17989
+ if (!existsSync6(runDirectory)) {
17945
17990
  try {
17946
17991
  const found = await resolveLiveRunDirectoryPath(request.runDirectory, request.home);
17947
17992
  if (found === void 0) {
@@ -17989,7 +18034,7 @@ var init_external_host_turn_loop = __esm({
17989
18034
  });
17990
18035
 
17991
18036
  // src/session-identity.ts
17992
- import { join as join15 } from "node:path";
18037
+ import { join as join16 } from "node:path";
17993
18038
  function createSessionIdentityAuthority(authority, hostName) {
17994
18039
  const runDirectoryOf = (principal) => runDirectoryFromSessionDirectory(authority.decode(principal).sessionDirectory);
17995
18040
  return {
@@ -17999,7 +18044,7 @@ function createSessionIdentityAuthority(authority, hostName) {
17999
18044
  },
18000
18045
  async load(principal) {
18001
18046
  const runDirectory = runDirectoryOf(principal);
18002
- const { records, diagnostics } = await readSitianRecords(join15(runDirectory, RUN_STATE_FILE));
18047
+ const { records, diagnostics } = await readSitianRecords(join16(runDirectory, RUN_STATE_FILE));
18003
18048
  if (diagnostics.length > 0) {
18004
18049
  throw new Error(
18005
18050
  `${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
@@ -18069,14 +18114,14 @@ __export(role_turn_host_exports, {
18069
18114
  });
18070
18115
  import { execFile as execFile2, spawn } from "node:child_process";
18071
18116
  import { constants as constants2 } from "node:fs";
18072
- import { existsSync as existsSync6 } from "node:fs";
18117
+ import { existsSync as existsSync7 } from "node:fs";
18073
18118
  import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
18074
- import { delimiter, dirname as dirname11, isAbsolute as isAbsolute6, join as join16, resolve as resolve10 } from "node:path";
18119
+ import { delimiter, dirname as dirname12, isAbsolute as isAbsolute6, join as join17, resolve as resolve10 } from "node:path";
18075
18120
  import { platform } from "node:process";
18076
18121
  import { promisify as promisify2 } from "node:util";
18077
18122
  import { randomUUID as randomUUID4 } from "node:crypto";
18078
18123
  function resolveInternalRoleEntrypoint(packageRoot2) {
18079
- return join16(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
18124
+ return join17(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
18080
18125
  }
18081
18126
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
18082
18127
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -18104,7 +18149,7 @@ function buildMethodArgs(methods) {
18104
18149
  const skillArgs = [];
18105
18150
  for (const method of methods) {
18106
18151
  if (method.kind === "skill") {
18107
- skillArgs.push("--skill", dirname11(method.path));
18152
+ skillArgs.push("--skill", dirname12(method.path));
18108
18153
  }
18109
18154
  }
18110
18155
  return skillArgs;
@@ -18266,7 +18311,7 @@ function createDefaultPiSpawnRunner(options) {
18266
18311
  homeFromRunDirectory(spawnDir)
18267
18312
  );
18268
18313
  } catch (resolveError) {
18269
- runDirectory = existsSync6(spawnDir) ? spawnDir : void 0;
18314
+ runDirectory = existsSync7(spawnDir) ? spawnDir : void 0;
18270
18315
  const resolveDiagnostic = `live run path resolve failed beside Pi transport fault: ${describeErrorIdentity(resolveError)}`;
18271
18316
  if (runDirectory !== void 0) {
18272
18317
  await retainPackageFault({
@@ -18555,18 +18600,18 @@ var init_navigator_lookup_host = __esm({
18555
18600
  });
18556
18601
 
18557
18602
  // src/public-cli/load-production-acp-host.ts
18558
- import { existsSync as existsSync7 } from "node:fs";
18559
- import { join as join17 } from "node:path";
18560
- import { pathToFileURL } from "node:url";
18603
+ import { existsSync as existsSync8 } from "node:fs";
18604
+ import { join as join18 } from "node:path";
18605
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
18561
18606
  async function loadProductionAcpHostFactory(packageRoot2, host) {
18562
18607
  const description = lookupHostDescription(host);
18563
18608
  if (description === void 0) {
18564
18609
  throw new Error(`unregistered host: ${host}`);
18565
18610
  }
18566
- const built = join17(packageRoot2, "dist/acp-host/production-host.js");
18567
- const source = join17(packageRoot2, "src/acp-host/production-host.ts");
18568
- const target = existsSync7(built) ? built : source;
18569
- const href = pathToFileURL(target).href;
18611
+ const built = join18(packageRoot2, "dist/acp-host/production-host.js");
18612
+ const source = join18(packageRoot2, "src/acp-host/production-host.ts");
18613
+ const target = existsSync8(built) ? built : source;
18614
+ const href = pathToFileURL2(target).href;
18570
18615
  const mod = await import(href);
18571
18616
  const create = mod.createProductionAcpRoleTurnHost;
18572
18617
  return (options) => create({ ...options, description, hostName: host });
@@ -18579,18 +18624,18 @@ var init_load_production_acp_host = __esm({
18579
18624
  });
18580
18625
 
18581
18626
  // src/public-cli/load-production-headless-host.ts
18582
- import { existsSync as existsSync8 } from "node:fs";
18583
- import { join as join18 } from "node:path";
18584
- import { pathToFileURL as pathToFileURL2 } from "node:url";
18627
+ import { existsSync as existsSync9 } from "node:fs";
18628
+ import { join as join19 } from "node:path";
18629
+ import { pathToFileURL as pathToFileURL3 } from "node:url";
18585
18630
  async function loadProductionHeadlessHostFactory(packageRoot2, host) {
18586
18631
  const description = lookupHeadlessHostDescription(host);
18587
18632
  if (description === void 0) {
18588
18633
  throw new Error(`unregistered headless host: ${host}`);
18589
18634
  }
18590
- const built = join18(packageRoot2, "dist/headless-host/production-host.js");
18591
- const source = join18(packageRoot2, "src/headless-host/production-host.ts");
18592
- const target = existsSync8(built) ? built : source;
18593
- const href = pathToFileURL2(target).href;
18635
+ const built = join19(packageRoot2, "dist/headless-host/production-host.js");
18636
+ const source = join19(packageRoot2, "src/headless-host/production-host.ts");
18637
+ const target = existsSync9(built) ? built : source;
18638
+ const href = pathToFileURL3(target).href;
18594
18639
  const mod = await import(href);
18595
18640
  const create = mod.createProductionHeadlessRoleTurnHost;
18596
18641
  return (options) => create({ ...options, description, hostName: host });
@@ -18766,51 +18811,6 @@ var init_role_seat_runtime = __esm({
18766
18811
  }
18767
18812
  });
18768
18813
 
18769
- // src/session-opening-materials.ts
18770
- import { existsSync as existsSync9 } from "node:fs";
18771
- import { readFile as readFile9 } from "node:fs/promises";
18772
- import { dirname as dirname12, join as join19 } from "node:path";
18773
- import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
18774
- function resolvePackageRootDir(moduleUrl = import.meta.url) {
18775
- let dir = dirname12(fileURLToPath(moduleUrl));
18776
- for (let i = 0; i < 8; i += 1) {
18777
- if (existsSync9(join19(dir, "package.json")) && existsSync9(join19(dir, "souls"))) {
18778
- return dir;
18779
- }
18780
- const parent = dirname12(dir);
18781
- if (parent === dir) break;
18782
- dir = parent;
18783
- }
18784
- return fileURLToPath(new URL("..", moduleUrl));
18785
- }
18786
- async function readPackageMaterial(relativePath) {
18787
- return readFile9(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
18788
- }
18789
- async function joinPackageMaterials(relativePaths) {
18790
- const chunks = [];
18791
- for (const relativePath of relativePaths) chunks.push(await readPackageMaterial(relativePath));
18792
- return chunks.join("\n\n");
18793
- }
18794
- var packageRootUrl, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
18795
- var init_session_opening_materials = __esm({
18796
- "src/session-opening-materials.ts"() {
18797
- "use strict";
18798
- init_packaged_role_registry();
18799
- packageRootUrl = pathToFileURL3(resolvePackageRootDir() + "/").href;
18800
- MAIN_ROLE_SESSION_MATERIALS = {
18801
- ...Object.fromEntries(
18802
- PUBLIC_ROLE_RECORDS.map((record) => [record.role, record.sessionMaterials])
18803
- )
18804
- };
18805
- GATEKEEPER_SESSION_MATERIALS = {
18806
- // #639: single authority — the public gatekeeper record owns the province list.
18807
- gatekeeper: packagedRoleSessionMaterials("gatekeeper"),
18808
- inspector: INSPECTOR_SESSION_MATERIALS,
18809
- notary: NOTARY_SESSION_MATERIALS
18810
- };
18811
- }
18812
- });
18813
-
18814
18814
  // src/doctor-auditor.ts
18815
18815
  function createPiDoctorAuditor() {
18816
18816
  return async (options) => {
@@ -19717,14 +19717,10 @@ function unreadablePostSubmissionStatus(admitted, terminal) {
19717
19717
  const status = receivedDiscriminator(payload, "status");
19718
19718
  return typeof status === "string" && route.statuses.has(status) ? void 0 : route.reask ?? officerConclusionReask(status);
19719
19719
  }
19720
- function withoutSoftTicketReaskTurn(env) {
19721
- const { softTicketReaskTurn: _softTicketReaskTurn, ...rest } = env;
19722
- return rest;
19723
- }
19724
19720
  function withUnreadableReask(env) {
19725
19721
  const spent = env.unreadableReasksSpent ?? 0;
19726
19722
  if (spent >= deliveryLimitFromConfig(env.autoResumeLimit)) return void 0;
19727
- return { ...withoutSoftTicketReaskTurn(env), unreadableReasksSpent: spent + 1 };
19723
+ return { ...env, unreadableReasksSpent: spent + 1 };
19728
19724
  }
19729
19725
  function isUnreadableReaskExhausted(value) {
19730
19726
  return value === UNREADABLE_REASK_EXHAUSTED;
@@ -19836,68 +19832,8 @@ async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io,
19836
19832
  io
19837
19833
  );
19838
19834
  }
19839
- async function reaskMissingTicketOnce(admitted, terminal, env, io) {
19840
- if ((env.ticketReasksSpent ?? 0) >= 1) return { kind: "none" };
19841
- if (isNavigatorSeat(admitted.role)) return { kind: "none" };
19842
- if (admitted.ticketNumber !== void 0) return { kind: "none" };
19843
- if (!isUnboundRunDirectory(admitted.runDirectory)) return { kind: "none" };
19844
- if (terminal?.roleOutcome.kind !== "accepted" && terminal?.roleOutcome.kind !== "audit_escalation") {
19845
- return { kind: "none" };
19846
- }
19847
- const payloads = terminal.roleOutcome.payloads ?? [];
19848
- if (payloads.length === 0) return { kind: "none" };
19849
- const instruction = (await readPackageMaterial(MISSING_TICKET_REASK_MATERIAL)).trim();
19850
- const softTicketReaskOwnership = { sealedSubstitute: false };
19851
- const softReaskEnv = {
19852
- ...env,
19853
- ticketReasksSpent: 1,
19854
- softTicketReaskTurn: true,
19855
- softTicketReaskOwnership
19856
- };
19857
- const result = await runPublicInstructionSeatResume(
19858
- {
19859
- runId: admitted.runId,
19860
- runDirectory: admitted.runDirectory,
19861
- message: instruction,
19862
- summons: { instructionEmpty: true }
19863
- },
19864
- softReaskEnv,
19865
- io
19866
- );
19867
- if (softTicketReaskOwnership.sealedSubstitute || terminalCarriesSealedSubmission(result.terminal)) {
19868
- return { kind: "nested_owns", result };
19869
- }
19870
- return { kind: "no_substitute", result };
19871
- }
19872
19835
  function envForCourtContinue(env) {
19873
- return { ...withoutSoftTicketReaskTurn(env), unreadableReasksSpent: 0 };
19874
- }
19875
- function terminalCarriesSealedSubmission(terminal) {
19876
- const kind = terminal?.roleOutcome.kind;
19877
- if (kind !== "accepted" && kind !== "audit_escalation") return false;
19878
- return (terminal?.roleOutcome.payloads ?? []).length > 0;
19879
- }
19880
- function projectKeptOriginalArtifactsOntoLiveAdmitted(original, kept) {
19881
- const oldRunDirectory = original.admitted?.runDirectory;
19882
- const newRunDirectory = kept.admitted?.runDirectory;
19883
- if (oldRunDirectory === void 0 || newRunDirectory === void 0 || oldRunDirectory === newRunDirectory || kept.terminal === void 0) {
19884
- return;
19885
- }
19886
- for (const artifact of kept.terminal.artifacts) {
19887
- artifact.path = rewriteRunDirectoryPathValue(
19888
- artifact.path,
19889
- oldRunDirectory,
19890
- newRunDirectory
19891
- );
19892
- }
19893
- }
19894
- function mergeMissingTicketReaskKeepOriginal(original, ticketReask) {
19895
- if (ticketReask.exitCode !== 0) return ticketReask;
19896
- const admitted = ticketReask.admitted ?? original.admitted;
19897
- if (admitted === void 0) return { ...original };
19898
- const kept = { ...original, admitted };
19899
- projectKeptOriginalArtifactsOntoLiveAdmitted(original, kept);
19900
- return kept;
19836
+ return { ...env, unreadableReasksSpent: 0 };
19901
19837
  }
19902
19838
  async function continueAfterPostSubmissionGuards(result, admittedRole, env, io, held) {
19903
19839
  const live = result.admitted;
@@ -19911,30 +19847,18 @@ async function continueAfterPostSubmissionGuards(result, admittedRole, env, io,
19911
19847
  env,
19912
19848
  io
19913
19849
  );
19914
- let afterStatus = result;
19850
+ let continued = result;
19915
19851
  if (isUnreadableReaskExhausted(unreadableReask)) {
19916
19852
  const terminal = result.terminal === void 0 ? void 0 : withUnsettledDirection(result.terminal);
19917
- afterStatus = terminal === void 0 ? { ...result, admitted: live } : { ...result, admitted: live, terminal };
19853
+ continued = terminal === void 0 ? { ...result, admitted: live } : { ...result, admitted: live, terminal };
19918
19854
  } else if (unreadableReask !== void 0) {
19919
19855
  return unreadableReask;
19920
19856
  }
19921
- const forTicket = afterStatus.admitted ?? live;
19922
- const softReask = await reaskMissingTicketOnce(
19923
- forTicket,
19924
- afterStatus.terminal ?? result.terminal,
19925
- env,
19926
- io
19927
- );
19928
- if (softReask.kind === "nested_owns") {
19929
- return softReask.result;
19930
- }
19931
- const continued = softReask.kind === "none" ? afterStatus : mergeMissingTicketReaskKeepOriginal(afterStatus, softReask.result);
19932
19857
  const continuedAdmitted = continued.admitted ?? live;
19933
- const continuedEnv = softReask.kind !== "none" ? { ...env, ticketReasksSpent: 1 } : env;
19934
19858
  if (AUDITED_ROLES.has(admittedRole) && continued.terminal?.roleOutcome.kind === "accepted") {
19935
19859
  return auditSubmittedRole(
19936
19860
  { ...continued, admitted: continuedAdmitted },
19937
- continuedEnv,
19861
+ env,
19938
19862
  io
19939
19863
  );
19940
19864
  }
@@ -20810,7 +20734,6 @@ function officerSatisfiedByLiveChild(officer, resumedOfficer, passedReceipt, cha
20810
20734
  return childIndex >= 0 && officerIndex >= 0 && officerIndex < childIndex;
20811
20735
  }
20812
20736
  async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt) {
20813
- env = withoutSoftTicketReaskTurn(env);
20814
20737
  const admitted = turn.admitted;
20815
20738
  if (admitted === void 0 || !AUDITED_ROLES.has(admitted.role) || turn.terminal?.roleOutcome.kind !== "accepted") return turn;
20816
20739
  const accepted = turn.terminal.roleOutcome.payloads?.at(-1);
@@ -21097,10 +21020,7 @@ var AUDITED_ROLES, SECRETARIAT_STATUS_REASK, WORKER_ROUTING_STATUSES, WORKER_STA
21097
21020
  var init_instruction_seat_run = __esm({
21098
21021
  "src/public-cli/instruction-seat-run.ts"() {
21099
21022
  "use strict";
21100
- init_report_ticket_tool();
21101
21023
  init_role_run_placement();
21102
- init_role_run_relocation();
21103
- init_session_opening_materials();
21104
21024
  init_doctor_auditor();
21105
21025
  init_gatekeeper_role();
21106
21026
  init_submission_errors();
@@ -23302,12 +23222,7 @@ async function dispatchPostAdmissionTurn(input) {
23302
23222
  }
23303
23223
  if (pendingSettlement !== void 0 && pendingTerminal !== void 0 && result.terminal === pendingTerminal) {
23304
23224
  try {
23305
- const softTicketReaskNoSeal = pendingSettlement !== "sealed" && env.softTicketReaskTurn === true;
23306
- const noSealScope = softTicketReaskNoSeal ? {
23307
- ...courtScope,
23308
- previewOnly: true,
23309
- recordAttemptHistory: true
23310
- } : { ...courtScope, recordAttemptHistory: true };
23225
+ const noSealScope = { ...courtScope, recordAttemptHistory: true };
23311
23226
  const terminal = pendingSettlement === "sealed" ? await adapters.trySettle(
23312
23227
  admitted,
23313
23228
  env.principalAuthority,
@@ -23324,9 +23239,6 @@ async function dispatchPostAdmissionTurn(input) {
23324
23239
  );
23325
23240
  if (terminal === void 0) throw new Error("settled host attempt vanished before publication");
23326
23241
  result = { ...result, terminal, exitCode: exitCodeForTerminalOutcome(terminal.roleOutcome) };
23327
- if (pendingSettlement === "sealed" && env.softTicketReaskTurn === true && env.softTicketReaskOwnership !== void 0) {
23328
- env.softTicketReaskOwnership.sealedSubstitute = true;
23329
- }
23330
23242
  if (pendingSettlement === "sealed" && terminal.roleOutcome.kind === "accepted" && request.courtAttemptId !== void 0 && request.courtAttemptId.length > 0) {
23331
23243
  try {
23332
23244
  await clearCurrentCourt(admitted.runDirectory, request.courtAttemptId);