@akagilnc/pi-workflow-roles 0.1.4291 → 0.1.4321

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.
@@ -16479,42 +16479,6 @@ var init_sitian_reader = __esm({
16479
16479
  }
16480
16480
  });
16481
16481
 
16482
- // src/atomic-write.ts
16483
- import { randomUUID as randomUUID2 } from "node:crypto";
16484
- import { rename, rm, writeFile as writeFile2 } from "node:fs/promises";
16485
- import { dirname as dirname6, join as join10 } from "node:path";
16486
- async function writeFileAtomically(destination, contents) {
16487
- const parent = dirname6(destination);
16488
- const temporary = join10(parent, `.atomic-write-${randomUUID2()}.tmp`);
16489
- try {
16490
- await writeFile2(temporary, contents);
16491
- await rename(temporary, destination);
16492
- } catch (error) {
16493
- await rm(temporary, { force: true }).catch(() => void 0);
16494
- throw error;
16495
- }
16496
- }
16497
- var init_atomic_write = __esm({
16498
- "src/atomic-write.ts"() {
16499
- "use strict";
16500
- }
16501
- });
16502
-
16503
- // src/sitian-volume.ts
16504
- function resolveSitianVolume(input) {
16505
- const path = resolveSitianRecordPath(input);
16506
- return { recordFile: path.recordFile, volumeDir: path.sessionDir };
16507
- }
16508
- var init_sitian_volume = __esm({
16509
- "src/sitian-volume.ts"() {
16510
- "use strict";
16511
- init_activation_ledger_topology();
16512
- init_atomic_write();
16513
- init_sitian_appender();
16514
- init_sitian_contracts();
16515
- }
16516
- });
16517
-
16518
16482
  // src/sitian-facade.ts
16519
16483
  function sitianReport(input) {
16520
16484
  return appendSitianRecord(input);
@@ -16526,7 +16490,6 @@ var init_sitian_facade = __esm({
16526
16490
  init_sitian_contracts();
16527
16491
  init_sitian_appender();
16528
16492
  init_sitian_reader();
16529
- init_sitian_volume();
16530
16493
  }
16531
16494
  });
16532
16495
 
@@ -16545,12 +16508,12 @@ __export(role_turn_host_exports, {
16545
16508
  import { execFile, spawn } from "node:child_process";
16546
16509
  import { constants } from "node:fs";
16547
16510
  import { access, appendFile, readFile as readFile4, realpath } from "node:fs/promises";
16548
- import { basename as basename3, delimiter as delimiter2, dirname as dirname7, isAbsolute as isAbsolute3, join as join11, resolve as resolve3 } from "node:path";
16511
+ import { basename as basename3, delimiter as delimiter2, dirname as dirname6, isAbsolute as isAbsolute3, join as join10, resolve as resolve3 } from "node:path";
16549
16512
  import { platform } from "node:process";
16550
16513
  import { promisify } from "node:util";
16551
- import { randomUUID as randomUUID3 } from "node:crypto";
16514
+ import { randomUUID as randomUUID2 } from "node:crypto";
16552
16515
  function resolveInternalRoleEntrypoint(packageRoot2) {
16553
- return join11(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
16516
+ return join10(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
16554
16517
  }
16555
16518
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
16556
16519
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -16586,7 +16549,7 @@ function buildMethodArgs(methods) {
16586
16549
  function applyPiNativeSkillInvocation(methods, prompt) {
16587
16550
  const skills = methods.filter((method) => method.kind === "skill");
16588
16551
  if (skills.length !== 1) return prompt;
16589
- const name = basename3(dirname7(skills[0].path));
16552
+ const name = basename3(dirname6(skills[0].path));
16590
16553
  if (name.length === 0) return prompt;
16591
16554
  const token = `/skill:${name}`;
16592
16555
  const trimmed = prompt.trimStart();
@@ -16838,7 +16801,7 @@ async function appendPiSessionCustomEntry(authority, principal, customType, data
16838
16801
  type: "custom",
16839
16802
  customType,
16840
16803
  data,
16841
- id: randomUUID3(),
16804
+ id: randomUUID2(),
16842
16805
  parentId,
16843
16806
  timestamp: timestamp2
16844
16807
  })}
@@ -16938,8 +16901,8 @@ var init_compliance_transport = __esm({
16938
16901
 
16939
16902
  // src/role-run-relocation.ts
16940
16903
  import { existsSync as existsSync5 } from "node:fs";
16941
- import { readdir as readdir2, readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
16942
- import { join as join12, sep as sep2 } from "node:path";
16904
+ import { readdir as readdir2, readFile as readFile5, writeFile as writeFile2 } from "node:fs/promises";
16905
+ import { join as join11, sep as sep2 } from "node:path";
16943
16906
  function isEnoent2(error) {
16944
16907
  return error instanceof Error && "code" in error && error.code === "ENOENT";
16945
16908
  }
@@ -17031,7 +16994,7 @@ async function rewriteJsonObjectFile(path, fields, rewrites) {
17031
16994
  const page = JSON.parse(await readFile5(path, "utf8"));
17032
16995
  if (!isPlainObject(page)) return;
17033
16996
  rewriteRunDirectoryPathFieldsAgainstRewrites(page, fields, rewrites);
17034
- await writeFile3(path, `${JSON.stringify(page, null, 2)}
16997
+ await writeFile2(path, `${JSON.stringify(page, null, 2)}
17035
16998
  `, "utf8");
17036
16999
  }
17037
17000
  async function rewriteOfficerPointerFile(path, rewrites) {
@@ -17044,7 +17007,7 @@ async function rewriteOfficerPointerFile(path, rewrites) {
17044
17007
  OFFICER_POINTER_FIELDS,
17045
17008
  rewrites
17046
17009
  );
17047
- await writeFile3(path, `${JSON.stringify(page)}
17010
+ await writeFile2(path, `${JSON.stringify(page)}
17048
17011
  `, "utf8");
17049
17012
  }
17050
17013
  async function rewriteSitianRecordsJsonl(path, rewrites) {
@@ -17091,7 +17054,7 @@ async function rewriteSitianRecordsJsonl(path, rewrites) {
17091
17054
  }
17092
17055
  if (!changed) return;
17093
17056
  const body = out.join("\n");
17094
- await writeFile3(
17057
+ await writeFile2(
17095
17058
  path,
17096
17059
  endsWithNewline && !body.endsWith("\n") ? `${body}
17097
17060
  ` : body,
@@ -17151,7 +17114,7 @@ async function rewriteSessionTranscriptBindings(path, rewrites) {
17151
17114
  }
17152
17115
  if (!changed) return;
17153
17116
  const body = out.join("\n");
17154
- await writeFile3(
17117
+ await writeFile2(
17155
17118
  path,
17156
17119
  endsWithNewline && !body.endsWith("\n") ? `${body}
17157
17120
  ` : body,
@@ -17159,7 +17122,7 @@ async function rewriteSessionTranscriptBindings(path, rewrites) {
17159
17122
  );
17160
17123
  }
17161
17124
  async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
17162
- const sessionRoot = join12(pagesDirectory, "session");
17125
+ const sessionRoot = join11(pagesDirectory, "session");
17163
17126
  async function walk(directory) {
17164
17127
  let entries;
17165
17128
  try {
@@ -17169,7 +17132,7 @@ async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
17169
17132
  throw error;
17170
17133
  }
17171
17134
  for (const entry of entries) {
17172
- const path = join12(directory, entry.name);
17135
+ const path = join11(directory, entry.name);
17173
17136
  if (entry.isDirectory()) {
17174
17137
  await walk(path);
17175
17138
  continue;
@@ -17191,7 +17154,7 @@ async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
17191
17154
  async function rewriteRoleRunDurablePages(input) {
17192
17155
  const { pagesDirectory } = input;
17193
17156
  const rewrites = collectRewrites(input);
17194
- const admittedPath = join12(pagesDirectory, "admitted-request.json");
17157
+ const admittedPath = join11(pagesDirectory, "admitted-request.json");
17195
17158
  if (existsSync5(admittedPath)) {
17196
17159
  const page = JSON.parse(await readFile5(admittedPath, "utf8"));
17197
17160
  rewriteRunDirectoryPathFieldsAgainstRewrites(
@@ -17218,10 +17181,10 @@ async function rewriteRoleRunDurablePages(input) {
17218
17181
  rewrites
17219
17182
  );
17220
17183
  }
17221
- await writeFile3(admittedPath, `${JSON.stringify(page, null, 2)}
17184
+ await writeFile2(admittedPath, `${JSON.stringify(page, null, 2)}
17222
17185
  `, "utf8");
17223
17186
  }
17224
- const invocationPath = join12(pagesDirectory, "invocation.json");
17187
+ const invocationPath = join11(pagesDirectory, "invocation.json");
17225
17188
  if (existsSync5(invocationPath)) {
17226
17189
  const page = JSON.parse(await readFile5(invocationPath, "utf8"));
17227
17190
  rewriteRunDirectoryPathFieldsAgainstRewrites(
@@ -17229,14 +17192,14 @@ async function rewriteRoleRunDurablePages(input) {
17229
17192
  INVOCATION_PAGE_FIELDS,
17230
17193
  rewrites
17231
17194
  );
17232
- await writeFile3(
17195
+ await writeFile2(
17233
17196
  invocationPath,
17234
17197
  `${JSON.stringify(page, null, 2)}
17235
17198
  `,
17236
17199
  "utf8"
17237
17200
  );
17238
17201
  }
17239
- const statePath = join12(pagesDirectory, "run-state.json");
17202
+ const statePath = join11(pagesDirectory, "run-state.json");
17240
17203
  if (existsSync5(statePath)) {
17241
17204
  const page = JSON.parse(await readFile5(statePath, "utf8"));
17242
17205
  rewriteRunDirectoryPathFieldsAgainstRewrites(
@@ -17254,7 +17217,7 @@ async function rewriteRoleRunDurablePages(input) {
17254
17217
  if (isPlainObject(page.currentCourt)) {
17255
17218
  rewriteSummonsMaterials(page.currentCourt.summons, rewrites);
17256
17219
  }
17257
- await writeFile3(statePath, `${JSON.stringify(page, null, 2)}
17220
+ await writeFile2(statePath, `${JSON.stringify(page, null, 2)}
17258
17221
  `, "utf8");
17259
17222
  }
17260
17223
  await rewriteNestedMachinePathPages(pagesDirectory, rewrites);
@@ -17399,7 +17362,7 @@ var init_terminating_tools = __esm({
17399
17362
 
17400
17363
  // src/doctor-evidence.ts
17401
17364
  import { readdir as readdir3, readFile as readFile6, realpath as realpath2, stat } from "node:fs/promises";
17402
- import { dirname as dirname8, relative as relative2, resolve as resolve4, sep as sep3 } from "node:path";
17365
+ import { dirname as dirname7, relative as relative2, resolve as resolve4, sep as sep3 } from "node:path";
17403
17366
  function record2(value) {
17404
17367
  return typeof value === "object" && value !== null && !Array.isArray(value);
17405
17368
  }
@@ -17438,7 +17401,7 @@ async function stableRunsIdentity(root) {
17438
17401
  } catch (error) {
17439
17402
  if (!isMissingPathError2(error)) throw error;
17440
17403
  }
17441
- const parent = dirname8(cursor);
17404
+ const parent = dirname7(cursor);
17442
17405
  if (parent === cursor) return root;
17443
17406
  cursor = parent;
17444
17407
  }
@@ -18100,10 +18063,10 @@ var init_uuidv7 = __esm({
18100
18063
  });
18101
18064
 
18102
18065
  // src/typed-provider-http.ts
18103
- import { readFile as readFile9, unlink, writeFile as writeFile4 } from "node:fs/promises";
18104
- import { join as join13 } from "node:path";
18066
+ import { readFile as readFile9, unlink, writeFile as writeFile3 } from "node:fs/promises";
18067
+ import { join as join12 } from "node:path";
18105
18068
  function typedProviderHttpPath(runDirectory) {
18106
- return join13(runDirectory, TYPED_HTTP_FILE);
18069
+ return join12(runDirectory, TYPED_HTTP_FILE);
18107
18070
  }
18108
18071
  async function clearTypedProviderHttpObservation(runDirectory) {
18109
18072
  try {
@@ -18147,8 +18110,8 @@ var init_typed_provider_http = __esm({
18147
18110
  });
18148
18111
 
18149
18112
  // src/public-cli/run-lifecycle.ts
18150
- import { chmod, lstat as lstat2, open, readdir as readdir4, readFile as readFile10, unlink as unlink2, writeFile as writeFile5 } from "node:fs/promises";
18151
- import { basename as basename4, join as join14 } from "node:path";
18113
+ import { chmod, lstat as lstat2, open, readdir as readdir4, readFile as readFile10, unlink as unlink2, writeFile as writeFile4 } from "node:fs/promises";
18114
+ import { basename as basename4, join as join13 } from "node:path";
18152
18115
  function selectResumeContinuationPrompt(message, engineMaterial) {
18153
18116
  const lines = message !== void 0 ? [message] : [];
18154
18117
  return appendEngineSessionMaterial(lines, engineMaterial).join("\n");
@@ -18177,8 +18140,8 @@ function renderResumeCommand(runId) {
18177
18140
  }
18178
18141
  async function writeRoleRunState(runDirectory, record4) {
18179
18142
  const payload = { ...record4, runDirectory };
18180
- await writeFile5(
18181
- join14(runDirectory, RUN_STATE_FILE),
18143
+ await writeFile4(
18144
+ join13(runDirectory, RUN_STATE_FILE),
18182
18145
  `${JSON.stringify(payload, null, 2)}
18183
18146
  `,
18184
18147
  "utf8"
@@ -18228,7 +18191,7 @@ function parseCurrentCourtState(raw) {
18228
18191
  async function readRoleRunStateDisk(runDirectory) {
18229
18192
  let raw;
18230
18193
  try {
18231
- raw = JSON.parse(await readFile10(join14(runDirectory, RUN_STATE_FILE), "utf8"));
18194
+ raw = JSON.parse(await readFile10(join13(runDirectory, RUN_STATE_FILE), "utf8"));
18232
18195
  } catch (error) {
18233
18196
  if (errorCodeOf2(error) === "ENOENT") return void 0;
18234
18197
  throw error;
@@ -18295,8 +18258,8 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
18295
18258
  ...disk.resumable === void 0 ? {} : { resumable: disk.resumable },
18296
18259
  ...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
18297
18260
  };
18298
- await writeFile5(
18299
- join14(runDirectory, RUN_STATE_FILE),
18261
+ await writeFile4(
18262
+ join13(runDirectory, RUN_STATE_FILE),
18300
18263
  `${JSON.stringify(payload, null, 2)}
18301
18264
  `,
18302
18265
  "utf8"
@@ -18522,7 +18485,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
18522
18485
  },
18523
18486
  relocate(nextRunDirectory) {
18524
18487
  currentRunDirectory = nextRunDirectory;
18525
- currentLockPath = join14(nextRunDirectory, WRITER_LOCK_FILE);
18488
+ currentLockPath = join13(nextRunDirectory, WRITER_LOCK_FILE);
18526
18489
  },
18527
18490
  async release() {
18528
18491
  if (released) return;
@@ -18561,10 +18524,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
18561
18524
  };
18562
18525
  const reportReadFailure = (error) => {
18563
18526
  reportDiagnostic(
18564
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join14(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
18527
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join13(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
18565
18528
  );
18566
18529
  };
18567
- const lockPath = join14(runDirectory, WRITER_LOCK_FILE);
18530
+ const lockPath = join13(runDirectory, WRITER_LOCK_FILE);
18568
18531
  let lastAutopsy = { verdict: "absent" };
18569
18532
  let lastReclaimFailure;
18570
18533
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -18619,7 +18582,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
18619
18582
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
18620
18583
  if (runId.trim() === "") return void 0;
18621
18584
  const ledgerHome = resolveActivationLedgerHome(home);
18622
- const booksRoot = join14(ledgerHome, "books");
18585
+ const booksRoot = join13(ledgerHome, "books");
18623
18586
  let bookKeys;
18624
18587
  try {
18625
18588
  bookKeys = await readdir4(booksRoot);
@@ -18660,7 +18623,7 @@ async function readRunParentPath(runDirectory) {
18660
18623
  let raw;
18661
18624
  try {
18662
18625
  raw = JSON.parse(
18663
- await readFile10(join14(runDirectory, "admitted-request.json"), "utf8")
18626
+ await readFile10(join13(runDirectory, "admitted-request.json"), "utf8")
18664
18627
  );
18665
18628
  } catch (error) {
18666
18629
  if (errorCodeOf2(error) === "ENOENT") return void 0;
@@ -18681,7 +18644,7 @@ async function readRunParentPath(runDirectory) {
18681
18644
  async function runHasFormedSessionPrincipal(runDirectory) {
18682
18645
  const disk = await readRoleRunStateDisk(runDirectory);
18683
18646
  if (disk === void 0) return false;
18684
- const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join14(disk.principalWire.sessionDirectory, "session.jsonl");
18647
+ const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join13(disk.principalWire.sessionDirectory, "session.jsonl");
18685
18648
  try {
18686
18649
  const stat2 = await lstat2(sessionFile);
18687
18650
  return stat2.isFile() && !stat2.isSymbolicLink();
@@ -18943,7 +18906,7 @@ async function loadResumableRunRecord(home, runId, authority) {
18943
18906
  let model;
18944
18907
  try {
18945
18908
  const invocationRaw = JSON.parse(
18946
- await readFile10(join14(run.runDirectory, "invocation.json"), "utf8")
18909
+ await readFile10(join13(run.runDirectory, "invocation.json"), "utf8")
18947
18910
  );
18948
18911
  if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
18949
18912
  const rec = invocationRaw;
@@ -19377,7 +19340,7 @@ __export(notary_source_run_exports, {
19377
19340
  loadNotarySourceRunLocator: () => loadNotarySourceRunLocator,
19378
19341
  resolveNotarySourceRunLocator: () => resolveNotarySourceRunLocator
19379
19342
  });
19380
- import { dirname as dirname9, isAbsolute as isAbsolute6, join as join15, resolve as resolve6, basename as basename5 } from "node:path";
19343
+ import { dirname as dirname8, isAbsolute as isAbsolute6, join as join14, resolve as resolve6, basename as basename5 } from "node:path";
19381
19344
  import { lstat as lstat3, realpath as realpath3 } from "node:fs/promises";
19382
19345
  function parseRunDirectoryName(name) {
19383
19346
  const match = RUN_DIR_NAME.exec(name);
@@ -19423,20 +19386,20 @@ async function resolveNotarySourceRunLocator(options) {
19423
19386
  }
19424
19387
  const ledgerHome = resolveActivationLedgerHome(options.home);
19425
19388
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
19426
- const bookRunsRoot = join15(activationBookDirectory(ledgerHome, bookKey), "runs");
19389
+ const bookRunsRoot = join14(activationBookDirectory(ledgerHome, bookKey), "runs");
19427
19390
  let candidate;
19428
19391
  const bare = parseRunDirectoryName(raw);
19429
19392
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
19430
- candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join15(bookRunsRoot, `${bare.runId}@${bare.role}`);
19393
+ candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join14(bookRunsRoot, `${bare.runId}@${bare.role}`);
19431
19394
  } else {
19432
19395
  candidate = isAbsolute6(raw) ? raw : resolve6(options.projectRoot, raw);
19433
19396
  }
19434
19397
  const real = await requireRunDirectory(candidate, raw);
19435
19398
  const identity = parseRunDirectoryName(basename5(real));
19436
19399
  const bookIdentity = physicalPathIdentity(activationBookDirectory(ledgerHome, bookKey));
19437
- const parentIdentity = physicalPathIdentity(dirname9(real));
19438
- const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
19439
- if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename5(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
19400
+ const parentIdentity = physicalPathIdentity(dirname8(real));
19401
+ const subjectBookIdentity = physicalPathIdentity(dirname8(dirname8(dirname8(real))));
19402
+ if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename5(dirname8(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
19440
19403
  throw new NotarySourceRunError(
19441
19404
  "notary --source-run must resolve to a retained run under the project machine-ledger book"
19442
19405
  );
@@ -20639,10 +20602,10 @@ import {
20639
20602
  lstat as lstat4,
20640
20603
  readFile as readFile11,
20641
20604
  realpath as realpath4,
20642
- rename as rename2,
20643
- writeFile as writeFile6
20605
+ rename,
20606
+ writeFile as writeFile5
20644
20607
  } from "node:fs/promises";
20645
- import { basename as basename6, dirname as dirname10, isAbsolute as isAbsolute7, join as join16, resolve as resolve7, sep as sep4 } from "node:path";
20608
+ import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute7, join as join15, resolve as resolve7, sep as sep4 } from "node:path";
20646
20609
  function issueAdmissionPlacement(authority, request) {
20647
20610
  const ledgerHome = resolveActivationLedgerHome(request.home);
20648
20611
  const bookKey = resolveBookKeyFromGit(request.cwd);
@@ -20667,7 +20630,7 @@ async function writeAdmittedRequestPersistence(admittedRequestPath, body, coordi
20667
20630
  sessionDirectory: coordinates.sessionDirectory,
20668
20631
  sessionFile: coordinates.sessionFile
20669
20632
  };
20670
- await writeFile6(
20633
+ await writeFile5(
20671
20634
  admittedRequestPath,
20672
20635
  `${JSON.stringify(projection, null, 2)}
20673
20636
  `,
@@ -20695,15 +20658,15 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
20695
20658
  ...source.ticketNumber === void 0 ? {} : { ticketNumber: source.ticketNumber },
20696
20659
  ...effectiveModelLedgerFields(effectiveModel)
20697
20660
  };
20698
- await writeFile6(
20699
- join16(source.runDirectory, "invocation.json"),
20661
+ await writeFile5(
20662
+ join15(source.runDirectory, "invocation.json"),
20700
20663
  `${JSON.stringify(identity, null, 2)}
20701
20664
  `,
20702
20665
  "utf8"
20703
20666
  );
20704
20667
  }
20705
20668
  async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
20706
- const ledgerPath = join16(runDirectory, "invocation.json");
20669
+ const ledgerPath = join15(runDirectory, "invocation.json");
20707
20670
  const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
20708
20671
  const next = { ...current };
20709
20672
  if (model !== void 0) {
@@ -20728,7 +20691,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
20728
20691
  if (host !== void 0) {
20729
20692
  next.host = host;
20730
20693
  }
20731
- await writeFile6(
20694
+ await writeFile5(
20732
20695
  ledgerPath,
20733
20696
  `${JSON.stringify(next, null, 2)}
20734
20697
  `,
@@ -20736,9 +20699,9 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
20736
20699
  );
20737
20700
  }
20738
20701
  async function mergeInvocationIdentityPage(runDirectory, fields) {
20739
- const ledgerPath = join16(runDirectory, "invocation.json");
20702
+ const ledgerPath = join15(runDirectory, "invocation.json");
20740
20703
  const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
20741
- await writeFile6(
20704
+ await writeFile5(
20742
20705
  ledgerPath,
20743
20706
  `${JSON.stringify({
20744
20707
  ...current,
@@ -20760,7 +20723,7 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath) {
20760
20723
  `persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
20761
20724
  );
20762
20725
  }
20763
- await writeFile6(
20726
+ await writeFile5(
20764
20727
  admittedPath,
20765
20728
  `${JSON.stringify({ ...current, sourceRunPath }, null, 2)}
20766
20729
  `,
@@ -20803,7 +20766,7 @@ async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
20803
20766
  const frozen = Object.freeze([...projected]);
20804
20767
  const admittedPath = admitted.admittedRequestPath;
20805
20768
  const current = JSON.parse(await readFile11(admittedPath, "utf8"));
20806
- await writeFile6(
20769
+ await writeFile5(
20807
20770
  admittedPath,
20808
20771
  `${JSON.stringify({ ...current, courtTicketNumbers: frozen }, null, 2)}
20809
20772
  `,
@@ -20824,8 +20787,8 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
20824
20787
  runId: admitted.runId,
20825
20788
  role: admitted.role
20826
20789
  });
20827
- ensureRoleRunDirectory(ledgerHome, dirname10(target.runDirectory));
20828
- await rename2(oldRunDirectory, target.runDirectory);
20790
+ ensureRoleRunDirectory(ledgerHome, dirname9(target.runDirectory));
20791
+ await rename(oldRunDirectory, target.runDirectory);
20829
20792
  heldLease?.relocate(target.runDirectory);
20830
20793
  const admittedRecord = admitted;
20831
20794
  rewriteRunDirectoryPathFields(
@@ -20862,8 +20825,8 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
20862
20825
  ticketNumber,
20863
20826
  "bindTicketNumberOnRunDirectory"
20864
20827
  );
20865
- const admittedPath = join16(runDirectory, "admitted-request.json");
20866
- const invocationPath = join16(runDirectory, "invocation.json");
20828
+ const admittedPath = join15(runDirectory, "admitted-request.json");
20829
+ const invocationPath = join15(runDirectory, "invocation.json");
20867
20830
  const admitted = JSON.parse(await readFile11(admittedPath, "utf8"));
20868
20831
  const existing = admitted.ticketNumber;
20869
20832
  if (typeof existing === "number") {
@@ -20882,7 +20845,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
20882
20845
  );
20883
20846
  }
20884
20847
  }
20885
- await writeFile6(
20848
+ await writeFile5(
20886
20849
  admittedPath,
20887
20850
  `${JSON.stringify({ ...admitted, ticketNumber }, null, 2)}
20888
20851
  `,
@@ -20899,7 +20862,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
20899
20862
  async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
20900
20863
  const rolePackageRoot = packageRoot2;
20901
20864
  const raw = JSON.parse(
20902
- await readFile11(join16(rolePackageRoot, "package.json"), "utf8")
20865
+ await readFile11(join15(rolePackageRoot, "package.json"), "utf8")
20903
20866
  );
20904
20867
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
20905
20868
  throw new Error(
@@ -21157,8 +21120,8 @@ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
21157
21120
  }
21158
21121
  const bytes = await readFile11(absolute);
21159
21122
  const name = `${String(index).padStart(2, "0")}-${basename6(absolute)}`;
21160
- const frozenPath = join16(destinationDir, name);
21161
- await writeFile6(frozenPath, bytes);
21123
+ const frozenPath = join15(destinationDir, name);
21124
+ await writeFile5(frozenPath, bytes);
21162
21125
  return {
21163
21126
  attachment: {
21164
21127
  provenancePath: absolute,
@@ -21185,7 +21148,7 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
21185
21148
  async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
21186
21149
  if (attachmentPaths.length === 0) return [];
21187
21150
  const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
21188
- const attachmentsDirectory = join16(runDirectory, "attachments", summonsKey);
21151
+ const attachmentsDirectory = join15(runDirectory, "attachments", summonsKey);
21189
21152
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
21190
21153
  return freezeAttachments(attachmentPaths, attachmentsDirectory);
21191
21154
  }
@@ -21243,7 +21206,7 @@ async function admitStandardMaterialInvocation(role, options) {
21243
21206
  })),
21244
21207
  ...ticketFields
21245
21208
  };
21246
- const admittedRequestPath = join16(runDirectory, "admitted-request.json");
21209
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21247
21210
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21248
21211
  sessionDirectory,
21249
21212
  sessionFile
@@ -21345,7 +21308,7 @@ async function admitCountersignInvocation(options) {
21345
21308
  mediaKind: a.mediaKind
21346
21309
  }))
21347
21310
  };
21348
- const admittedRequestPath = join16(runDirectory, "admitted-request.json");
21311
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21349
21312
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21350
21313
  sessionDirectory,
21351
21314
  sessionFile
@@ -21371,7 +21334,7 @@ function buildCountersignTransportPrompt(admitted, engineMaterial) {
21371
21334
  async function loadAdmittedJudgeRequest(runDirectory) {
21372
21335
  try {
21373
21336
  const raw = JSON.parse(
21374
- await readFile11(join16(runDirectory, "admitted-request.json"), "utf8")
21337
+ await readFile11(join15(runDirectory, "admitted-request.json"), "utf8")
21375
21338
  );
21376
21339
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
21377
21340
  const record4 = raw;
@@ -21426,8 +21389,8 @@ async function admitCoderInvocation(options) {
21426
21389
  home: options.home
21427
21390
  });
21428
21391
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
21429
- const taskPath = join16(runDirectory, "task.md");
21430
- await writeFile6(taskPath, instruction, "utf8");
21392
+ const taskPath = join15(runDirectory, "task.md");
21393
+ await writeFile5(taskPath, instruction, "utf8");
21431
21394
  const admitted = {
21432
21395
  role: "coder",
21433
21396
  phase: options.phase,
@@ -21447,7 +21410,7 @@ async function admitCoderInvocation(options) {
21447
21410
  mediaKind: a.mediaKind
21448
21411
  }))
21449
21412
  };
21450
- const admittedRequestPath = join16(runDirectory, "admitted-request.json");
21413
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21451
21414
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21452
21415
  sessionDirectory,
21453
21416
  sessionFile
@@ -21533,16 +21496,16 @@ async function admitFixerInvocation(options) {
21533
21496
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
21534
21497
  let prerequisitesPath;
21535
21498
  if (prerequisitesSource !== void 0) {
21536
- prerequisitesPath = join16(runDirectory, "prerequisites.json");
21537
- await writeFile6(
21499
+ prerequisitesPath = join15(runDirectory, "prerequisites.json");
21500
+ await writeFile5(
21538
21501
  prerequisitesPath,
21539
21502
  `${JSON.stringify(prerequisites, null, 2)}
21540
21503
  `,
21541
21504
  "utf8"
21542
21505
  );
21543
21506
  }
21544
- const packetPath = join16(runDirectory, "fix-packet.md");
21545
- await writeFile6(packetPath, instruction, "utf8");
21507
+ const packetPath = join15(runDirectory, "fix-packet.md");
21508
+ await writeFile5(packetPath, instruction, "utf8");
21546
21509
  const admitted = {
21547
21510
  role: "fixer",
21548
21511
  phase: options.phase,
@@ -21567,7 +21530,7 @@ async function admitFixerInvocation(options) {
21567
21530
  mediaKind: a.mediaKind
21568
21531
  }))
21569
21532
  };
21570
- const admittedRequestPath = join16(runDirectory, "admitted-request.json");
21533
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21571
21534
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21572
21535
  sessionDirectory,
21573
21536
  sessionFile
@@ -21787,8 +21750,8 @@ async function admitCollectorInvocation(options) {
21787
21750
  const prNumber = target.kind === "bound" ? target.prNumber : void 0;
21788
21751
  let requestManifestPath;
21789
21752
  if (manifestCanonicalJson !== void 0) {
21790
- requestManifestPath = join16(runDirectory, "request-manifest.json");
21791
- await writeFile6(requestManifestPath, manifestCanonicalJson, "utf8");
21753
+ requestManifestPath = join15(runDirectory, "request-manifest.json");
21754
+ await writeFile5(requestManifestPath, manifestCanonicalJson, "utf8");
21792
21755
  }
21793
21756
  const admitted = {
21794
21757
  role: "collector",
@@ -21813,7 +21776,7 @@ async function admitCollectorInvocation(options) {
21813
21776
  mediaKind: a.mediaKind
21814
21777
  }))
21815
21778
  };
21816
- const admittedRequestPath = join16(runDirectory, "admitted-request.json");
21779
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21817
21780
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21818
21781
  sessionDirectory,
21819
21782
  sessionFile
@@ -21911,7 +21874,7 @@ function parseDoctorArgv(args) {
21911
21874
  }
21912
21875
  async function resolveDoctorCaseRunsPath(options) {
21913
21876
  const ledgerHome = resolveActivationLedgerHome(options.home);
21914
- const defaultRuns = join16(
21877
+ const defaultRuns = join15(
21915
21878
  activationBookDirectory(ledgerHome, options.bookKey),
21916
21879
  String(options.issueNumber),
21917
21880
  "runs"
@@ -22042,7 +22005,7 @@ async function admitDoctorInvocation(options) {
22042
22005
  mediaKind: a.mediaKind
22043
22006
  }))
22044
22007
  };
22045
- const admittedRequestPath = join16(runDirectory, "admitted-request.json");
22008
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
22046
22009
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
22047
22010
  sessionDirectory,
22048
22011
  sessionFile
@@ -22174,7 +22137,7 @@ async function admitNotaryInvocation(options) {
22174
22137
  ...ticketFields,
22175
22138
  ...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
22176
22139
  };
22177
- const admittedRequestPath = join16(runDirectory, "admitted-request.json");
22140
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
22178
22141
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
22179
22142
  sessionDirectory,
22180
22143
  sessionFile
@@ -22277,7 +22240,7 @@ async function admitGleanerLeftInvocation(options) {
22277
22240
  attachments: [],
22278
22241
  ...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
22279
22242
  };
22280
- const admittedRequestPath = join16(runDirectory, "admitted-request.json");
22243
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
22281
22244
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
22282
22245
  sessionDirectory,
22283
22246
  sessionFile
@@ -22406,7 +22369,7 @@ async function admitReviewerInvocation(options) {
22406
22369
  mediaKind: a.mediaKind
22407
22370
  }))
22408
22371
  };
22409
- const admittedRequestPath = join16(runDirectory, "admitted-request.json");
22372
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
22410
22373
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
22411
22374
  sessionDirectory,
22412
22375
  sessionFile
@@ -22551,8 +22514,8 @@ async function admitMergerInvocation(options) {
22551
22514
  resolutionScope: [...derived.resolutionScope],
22552
22515
  authorizedChecks: []
22553
22516
  });
22554
- const mergerInputPath = join16(runDirectory, "merger-input.json");
22555
- await writeFile6(
22517
+ const mergerInputPath = join15(runDirectory, "merger-input.json");
22518
+ await writeFile5(
22556
22519
  mergerInputPath,
22557
22520
  `${JSON.stringify(mergerInput, null, 2)}
22558
22521
  `,
@@ -22582,7 +22545,7 @@ async function admitMergerInvocation(options) {
22582
22545
  mediaKind: a.mediaKind
22583
22546
  }))
22584
22547
  };
22585
- const admittedRequestPath = join16(runDirectory, "admitted-request.json");
22548
+ const admittedRequestPath = join15(runDirectory, "admitted-request.json");
22586
22549
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
22587
22550
  sessionDirectory,
22588
22551
  sessionFile
@@ -22866,15 +22829,15 @@ var init_invocation = __esm({
22866
22829
 
22867
22830
  // src/public-cli/load-production-acp-host.ts
22868
22831
  import { existsSync as existsSync7 } from "node:fs";
22869
- import { join as join17 } from "node:path";
22832
+ import { join as join16 } from "node:path";
22870
22833
  import { pathToFileURL } from "node:url";
22871
22834
  async function loadProductionAcpHostFactory(packageRoot2, host) {
22872
22835
  const description = lookupHostDescription(host);
22873
22836
  if (description === void 0) {
22874
22837
  throw new Error(`unregistered host: ${host}`);
22875
22838
  }
22876
- const built = join17(packageRoot2, "dist/acp-host/production-host.js");
22877
- const source = join17(packageRoot2, "src/acp-host/production-host.ts");
22839
+ const built = join16(packageRoot2, "dist/acp-host/production-host.js");
22840
+ const source = join16(packageRoot2, "src/acp-host/production-host.ts");
22878
22841
  const target = existsSync7(built) ? built : source;
22879
22842
  const href = pathToFileURL(target).href;
22880
22843
  const mod = await import(href);
@@ -22890,15 +22853,15 @@ var init_load_production_acp_host = __esm({
22890
22853
 
22891
22854
  // src/public-cli/load-production-headless-host.ts
22892
22855
  import { existsSync as existsSync8 } from "node:fs";
22893
- import { join as join18 } from "node:path";
22856
+ import { join as join17 } from "node:path";
22894
22857
  import { pathToFileURL as pathToFileURL2 } from "node:url";
22895
22858
  async function loadProductionHeadlessHostFactory(packageRoot2, host) {
22896
22859
  const description = lookupHeadlessHostDescription(host);
22897
22860
  if (description === void 0) {
22898
22861
  throw new Error(`unregistered headless host: ${host}`);
22899
22862
  }
22900
- const built = join18(packageRoot2, "dist/headless-host/production-host.js");
22901
- const source = join18(packageRoot2, "src/headless-host/production-host.ts");
22863
+ const built = join17(packageRoot2, "dist/headless-host/production-host.js");
22864
+ const source = join17(packageRoot2, "src/headless-host/production-host.ts");
22902
22865
  const target = existsSync8(built) ? built : source;
22903
22866
  const href = pathToFileURL2(target).href;
22904
22867
  const mod = await import(href);
@@ -23026,7 +22989,7 @@ var init_role_turn_host_resolution = __esm({
23026
22989
  // src/package-resources/method-skill.ts
23027
22990
  import { createHash as createHash4 } from "node:crypto";
23028
22991
  import { readFile as readFile12, realpath as realpath5 } from "node:fs/promises";
23029
- import { join as join19 } from "node:path";
22992
+ import { join as join18 } from "node:path";
23030
22993
  function gitBlobOid(bytes) {
23031
22994
  const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
23032
22995
  const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
@@ -23043,10 +23006,10 @@ function packagedMethodSkillRelativeDirectory(name) {
23043
23006
  return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
23044
23007
  }
23045
23008
  function resolvePackagedMethodSkillRoot(packageRoot2, name) {
23046
- return join19(packageRoot2, packagedMethodSkillRelativeDirectory(name));
23009
+ return join18(packageRoot2, packagedMethodSkillRelativeDirectory(name));
23047
23010
  }
23048
23011
  function resolvePackagedMethodSkillPath(packageRoot2, name) {
23049
- return join19(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
23012
+ return join18(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
23050
23013
  }
23051
23014
  function isRecord4(value) {
23052
23015
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -23140,8 +23103,8 @@ function parseProvenance(raw, expectedName) {
23140
23103
  }
23141
23104
  async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
23142
23105
  const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot2, name);
23143
- const skillPathConfigured = join19(rootDirectory, "SKILL.md");
23144
- const provenancePath = join19(rootDirectory, "provenance.json");
23106
+ const skillPathConfigured = join18(rootDirectory, "SKILL.md");
23107
+ const provenancePath = join18(rootDirectory, "provenance.json");
23145
23108
  let provenanceRaw;
23146
23109
  try {
23147
23110
  provenanceRaw = await readFile12(provenancePath, "utf8");
@@ -23158,7 +23121,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
23158
23121
  }
23159
23122
  const provenance = parseProvenance(provenanceJson, name);
23160
23123
  for (const [rel, expected] of Object.entries(provenance.files)) {
23161
- const absolute = join19(rootDirectory, rel);
23124
+ const absolute = join18(rootDirectory, rel);
23162
23125
  let bytes;
23163
23126
  try {
23164
23127
  bytes = await readFile12(absolute);
@@ -23453,7 +23416,7 @@ var init_ledger_session_read = __esm({
23453
23416
 
23454
23417
  // src/analyst-gate-cycles-read.ts
23455
23418
  import { readdir as readdir5 } from "node:fs/promises";
23456
- import { join as join20 } from "node:path";
23419
+ import { join as join19 } from "node:path";
23457
23420
  function isRecord6(value) {
23458
23421
  return typeof value === "object" && value !== null && !Array.isArray(value);
23459
23422
  }
@@ -23703,7 +23666,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
23703
23666
  throw error;
23704
23667
  }
23705
23668
  for (const name of names) {
23706
- const path = join20(directory, name);
23669
+ const path = join19(directory, name);
23707
23670
  const fromPointer = name.endsWith(".pointer.json");
23708
23671
  const sessionPath = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : path;
23709
23672
  if (sessionPath === void 0) continue;
@@ -23755,7 +23718,7 @@ var init_audit_escalation = __esm({
23755
23718
 
23756
23719
  // src/run-terminal-artifacts.ts
23757
23720
  import { readdir as readdir6, readFile as readFile14 } from "node:fs/promises";
23758
- import { basename as basename7, dirname as dirname11, join as join21 } from "node:path";
23721
+ import { basename as basename7, dirname as dirname10, join as join20 } from "node:path";
23759
23722
  function isMissingPathError3(error) {
23760
23723
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
23761
23724
  }
@@ -23830,7 +23793,7 @@ async function listUniqueErrorFallbackPaths(directories) {
23830
23793
  }
23831
23794
  for (const name of names.sort((a, b) => a.localeCompare(b))) {
23832
23795
  if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
23833
- found.push(join21(dir, name));
23796
+ found.push(join20(dir, name));
23834
23797
  }
23835
23798
  }
23836
23799
  return found;
@@ -23848,12 +23811,12 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
23848
23811
  async function readRunTerminalArtifact(runDirectory) {
23849
23812
  const artifactsDir = roleRunArtifactsDirectory(runDirectory);
23850
23813
  for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
23851
- const path = join21(artifactsDir, file);
23814
+ const path = join20(artifactsDir, file);
23852
23815
  const read = await readTerminalArtifactAtPath(path, file);
23853
23816
  if (read !== void 0) return read;
23854
23817
  }
23855
23818
  for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
23856
- const path = join21(runDirectory, relative3);
23819
+ const path = join20(runDirectory, relative3);
23857
23820
  const read = await readTerminalArtifactAtPath(path, "error.json");
23858
23821
  if (read !== void 0) return read;
23859
23822
  }
@@ -23862,7 +23825,7 @@ async function readRunTerminalArtifact(runDirectory) {
23862
23825
  if (read !== void 0) return read;
23863
23826
  }
23864
23827
  const expectedRunId = runIdFromRunDirectory(runDirectory);
23865
- for (const path of await listUniqueErrorFallbackPaths([dirname11(runDirectory)])) {
23828
+ for (const path of await listUniqueErrorFallbackPaths([dirname10(runDirectory)])) {
23866
23829
  const read = await readTerminalArtifactAtPath(path, "error.json");
23867
23830
  if (read === void 0) continue;
23868
23831
  if (read.status === "present") {
@@ -23891,14 +23854,14 @@ var init_run_terminal_artifacts = __esm({
23891
23854
  });
23892
23855
 
23893
23856
  // src/submission-ledger.ts
23894
- import { join as join22 } from "node:path";
23857
+ import { join as join21 } from "node:path";
23895
23858
  async function submissionRecordFile(cwd, runId, scope) {
23896
23859
  const ledgerHome = resolveActivationLedgerHome(scope.home);
23897
23860
  let sessionParent = scope.sessionParent;
23898
23861
  if (sessionParent === void 0) {
23899
23862
  const discoveredRun = await findRunDirectoryById(scope.home, runId);
23900
23863
  if (discoveredRun === void 0) return void 0;
23901
- sessionParent = join22(discoveredRun, "session", "session.jsonl");
23864
+ sessionParent = join21(discoveredRun, "session", "session.jsonl");
23902
23865
  }
23903
23866
  return resolveSitianRecordPathInLedger({
23904
23867
  level: "event",
@@ -24086,15 +24049,15 @@ var init_submission_ledger = __esm({
24086
24049
  // src/session-opening-materials.ts
24087
24050
  import { existsSync as existsSync9 } from "node:fs";
24088
24051
  import { readFile as readFile15 } from "node:fs/promises";
24089
- import { dirname as dirname12, join as join23 } from "node:path";
24052
+ import { dirname as dirname11, join as join22 } from "node:path";
24090
24053
  import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
24091
24054
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
24092
- let dir = dirname12(fileURLToPath(moduleUrl));
24055
+ let dir = dirname11(fileURLToPath(moduleUrl));
24093
24056
  for (let i = 0; i < 8; i += 1) {
24094
- if (existsSync9(join23(dir, "package.json")) && existsSync9(join23(dir, "souls"))) {
24057
+ if (existsSync9(join22(dir, "package.json")) && existsSync9(join22(dir, "souls"))) {
24095
24058
  return dir;
24096
24059
  }
24097
- const parent = dirname12(dir);
24060
+ const parent = dirname11(dir);
24098
24061
  if (parent === dir) break;
24099
24062
  dir = parent;
24100
24063
  }
@@ -24344,12 +24307,12 @@ var init_reviewer_dispatch = __esm({
24344
24307
 
24345
24308
  // src/public-cli/reviewer-dispatch-rejection.ts
24346
24309
  import { readFile as readFile16, unlink as unlink3 } from "node:fs/promises";
24347
- import { join as join24 } from "node:path";
24310
+ import { join as join23 } from "node:path";
24348
24311
  function isReviewerPreflightViolation(value) {
24349
24312
  return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
24350
24313
  }
24351
24314
  function reviewerDispatchRejectionPath(runDirectory) {
24352
- return join24(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
24315
+ return join23(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
24353
24316
  }
24354
24317
  async function clearReviewerDispatchRejection(runDirectory) {
24355
24318
  try {
@@ -24434,9 +24397,9 @@ var init_collector_ledger = __esm({
24434
24397
  });
24435
24398
 
24436
24399
  // src/engine-detour-usage.ts
24437
- import { randomUUID as randomUUID4 } from "node:crypto";
24400
+ import { randomUUID as randomUUID3 } from "node:crypto";
24438
24401
  import { readFileSync as readFileSync3 } from "node:fs";
24439
- import { dirname as dirname13, join as join25 } from "node:path";
24402
+ import { dirname as dirname12, join as join24 } from "node:path";
24440
24403
  function isRecord8(value) {
24441
24404
  return typeof value === "object" && value !== null && !Array.isArray(value);
24442
24405
  }
@@ -24520,7 +24483,7 @@ function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
24520
24483
  function readInvocationRecord(runDirectory) {
24521
24484
  try {
24522
24485
  const raw = JSON.parse(
24523
- readFileSync3(join25(runDirectory, "invocation.json"), "utf8")
24486
+ readFileSync3(join24(runDirectory, "invocation.json"), "utf8")
24524
24487
  );
24525
24488
  return isRecord8(raw) ? raw : void 0;
24526
24489
  } catch (error) {
@@ -24550,15 +24513,15 @@ function withEngineDetourToolUsageFact(outcome, usage) {
24550
24513
  };
24551
24514
  }
24552
24515
  function runDirectoryFromSessionDirectory(sessionDirectory) {
24553
- return dirname13(sessionDirectory);
24516
+ return dirname12(sessionDirectory);
24554
24517
  }
24555
24518
  function sessionFileFromSessionDirectory(sessionDirectory) {
24556
- return join25(sessionDirectory, "session.jsonl");
24519
+ return join24(sessionDirectory, "session.jsonl");
24557
24520
  }
24558
24521
  function mintEngineDetourInvocationScope(input) {
24559
24522
  const engine = input.effectiveEngine?.trim();
24560
24523
  if (engine === void 0 || engine.length === 0) return void 0;
24561
- return randomUUID4();
24524
+ return randomUUID3();
24562
24525
  }
24563
24526
  function withEngineDetourInvocationScope(request, invocationScopeId) {
24564
24527
  if (invocationScopeId === void 0 || invocationScopeId.length === 0) {
@@ -24948,16 +24911,16 @@ __export(settlement_exports, {
24948
24911
  trySettleReviewerTerminalResult: () => trySettleReviewerTerminalResult,
24949
24912
  withSubmissions: () => withSubmissions
24950
24913
  });
24951
- import { randomUUID as randomUUID5 } from "node:crypto";
24952
- import { appendFile as appendFile2, readFile as readFile17, readdir as readdir7, writeFile as writeFile7 } from "node:fs/promises";
24953
- import { dirname as dirname14, join as join26 } from "node:path";
24914
+ import { randomUUID as randomUUID4 } from "node:crypto";
24915
+ import { appendFile as appendFile2, readFile as readFile17, readdir as readdir7, writeFile as writeFile6 } from "node:fs/promises";
24916
+ import { dirname as dirname13, join as join25 } from "node:path";
24954
24917
  function sealedLedgerHome(admitted) {
24955
24918
  return homeFromRunDirectory(admitted.runDirectory);
24956
24919
  }
24957
24920
  function ledgerReadScope(admitted, scope) {
24958
24921
  return {
24959
24922
  home: sealedLedgerHome(admitted),
24960
- sessionParent: join26(admitted.runDirectory, "session", "session.jsonl"),
24923
+ sessionParent: join25(admitted.runDirectory, "session", "session.jsonl"),
24961
24924
  ...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
24962
24925
  };
24963
24926
  }
@@ -25386,7 +25349,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
25386
25349
  kind: "auditor",
25387
25350
  sessionParent: sessionFile,
25388
25351
  // Path is driven by sessionParent when under ledger home; cwd is a fallback only.
25389
- cwd: dirname14(sessionFile)
25352
+ cwd: dirname13(sessionFile)
25390
25353
  });
25391
25354
  const { records } = await readSitianRecords(recordFile);
25392
25355
  for (let i = records.length - 1; i >= 0; i -= 1) {
@@ -25412,7 +25375,7 @@ async function readSessionProviderStop(sessionFile) {
25412
25375
  }
25413
25376
  }
25414
25377
  async function readBoundEvidenceChildKnownFailure(sessionFile) {
25415
- const childDirectory = join26(dirname14(sessionFile), "evidence-children");
25378
+ const childDirectory = join25(dirname13(sessionFile), "evidence-children");
25416
25379
  let names;
25417
25380
  try {
25418
25381
  names = await readdir7(childDirectory);
@@ -25423,7 +25386,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
25423
25386
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
25424
25387
  let entries;
25425
25388
  try {
25426
- entries = await readBoundSessionEntries(join26(childDirectory, file));
25389
+ entries = await readBoundSessionEntries(join25(childDirectory, file));
25427
25390
  } catch (error) {
25428
25391
  throw sessionReadFailure(error, "failed to read discovered evidence-child session");
25429
25392
  }
@@ -25478,7 +25441,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
25478
25441
  latestParentUserIndex = i;
25479
25442
  break;
25480
25443
  }
25481
- const childDirectories = [join26(dirname14(sessionFile), "auditor-roles")];
25444
+ const childDirectories = [join25(dirname13(sessionFile), "auditor-roles")];
25482
25445
  const valid = [];
25483
25446
  let sawAnyDirectory = false;
25484
25447
  for (const childDirectory of childDirectories) {
@@ -25493,7 +25456,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
25493
25456
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
25494
25457
  let entries;
25495
25458
  try {
25496
- entries = await readBoundSessionEntries(join26(childDirectory, file));
25459
+ entries = await readBoundSessionEntries(join25(childDirectory, file));
25497
25460
  } catch (error) {
25498
25461
  throw sessionReadFailure(error, "failed to read discovered auditor session");
25499
25462
  }
@@ -25912,7 +25875,7 @@ async function appendRunAttemptHistory(source, outcome) {
25912
25875
  type: "custom",
25913
25876
  customType: ATTEMPT_HISTORY_ENTRY_TYPE,
25914
25877
  data: attemptData,
25915
- id: randomUUID5(),
25878
+ id: randomUUID4(),
25916
25879
  parentId,
25917
25880
  timestamp: timestamp2
25918
25881
  })}
@@ -26018,8 +25981,8 @@ function projectTerminalGateFact(rounds) {
26018
25981
  };
26019
25982
  }
26020
25983
  async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
26021
- const directories = [join26(sessionDirectory, "auditor-roles")];
26022
- const parentSessionFile = options.parentSessionFile ?? join26(sessionDirectory, "session.jsonl");
25984
+ const directories = [join25(sessionDirectory, "auditor-roles")];
25985
+ const parentSessionFile = options.parentSessionFile ?? join25(sessionDirectory, "session.jsonl");
26023
25986
  const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
26024
25987
  parentSessionFile
26025
25988
  });
@@ -26149,9 +26112,9 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
26149
26112
  async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
26150
26113
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26151
26114
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26152
- const reportPath = join26(artifactsDir, "report.json");
26153
- const evidencePath = join26(artifactsDir, "evidence.json");
26154
- await writeFile7(
26115
+ const reportPath = join25(artifactsDir, "report.json");
26116
+ const evidencePath = join25(artifactsDir, "evidence.json");
26117
+ await writeFile6(
26155
26118
  reportPath,
26156
26119
  `${JSON.stringify(
26157
26120
  {
@@ -26165,7 +26128,7 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
26165
26128
  `,
26166
26129
  "utf8"
26167
26130
  );
26168
- await writeFile7(
26131
+ await writeFile6(
26169
26132
  evidencePath,
26170
26133
  `${JSON.stringify(
26171
26134
  {
@@ -26194,9 +26157,9 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
26194
26157
  async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
26195
26158
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26196
26159
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26197
- const reportPath = join26(artifactsDir, "report.json");
26198
- const evidencePath = join26(artifactsDir, "evidence.json");
26199
- await writeFile7(
26160
+ const reportPath = join25(artifactsDir, "report.json");
26161
+ const evidencePath = join25(artifactsDir, "evidence.json");
26162
+ await writeFile6(
26200
26163
  reportPath,
26201
26164
  `${JSON.stringify(
26202
26165
  {
@@ -26211,7 +26174,7 @@ async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options
26211
26174
  `,
26212
26175
  "utf8"
26213
26176
  );
26214
- await writeFile7(
26177
+ await writeFile6(
26215
26178
  evidencePath,
26216
26179
  `${JSON.stringify(
26217
26180
  {
@@ -26352,9 +26315,9 @@ function extractFixerMethodInvocations(entries, options) {
26352
26315
  async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
26353
26316
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26354
26317
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26355
- const reportPath = join26(artifactsDir, "report.json");
26356
- const evidencePath = join26(artifactsDir, "evidence.json");
26357
- await writeFile7(
26318
+ const reportPath = join25(artifactsDir, "report.json");
26319
+ const evidencePath = join25(artifactsDir, "evidence.json");
26320
+ await writeFile6(
26358
26321
  reportPath,
26359
26322
  `${JSON.stringify(
26360
26323
  {
@@ -26369,7 +26332,7 @@ async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options
26369
26332
  `,
26370
26333
  "utf8"
26371
26334
  );
26372
- await writeFile7(
26335
+ await writeFile6(
26373
26336
  evidencePath,
26374
26337
  `${JSON.stringify(
26375
26338
  {
@@ -26450,9 +26413,9 @@ async function settleFixerTerminalResult(admitted, authority, options, scope) {
26450
26413
  async function publishCollectorArtifacts(admitted, roleOutcome, coordinates) {
26451
26414
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26452
26415
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26453
- const reportPath = join26(artifactsDir, "report.json");
26454
- const evidencePath = join26(artifactsDir, "evidence.json");
26455
- await writeFile7(
26416
+ const reportPath = join25(artifactsDir, "report.json");
26417
+ const evidencePath = join25(artifactsDir, "evidence.json");
26418
+ await writeFile6(
26456
26419
  reportPath,
26457
26420
  `${JSON.stringify(
26458
26421
  {
@@ -26466,7 +26429,7 @@ async function publishCollectorArtifacts(admitted, roleOutcome, coordinates) {
26466
26429
  `,
26467
26430
  "utf8"
26468
26431
  );
26469
- await writeFile7(
26432
+ await writeFile6(
26470
26433
  evidencePath,
26471
26434
  `${JSON.stringify(
26472
26435
  {
@@ -26583,9 +26546,9 @@ function extractDoctorCandidateAuditNoReceiptFact(entries) {
26583
26546
  async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
26584
26547
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26585
26548
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26586
- const reportPath = join26(artifactsDir, "report.json");
26587
- const evidencePath = join26(artifactsDir, "evidence.json");
26588
- await writeFile7(
26549
+ const reportPath = join25(artifactsDir, "report.json");
26550
+ const evidencePath = join25(artifactsDir, "evidence.json");
26551
+ await writeFile6(
26589
26552
  reportPath,
26590
26553
  `${JSON.stringify(
26591
26554
  {
@@ -26601,7 +26564,7 @@ async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, option
26601
26564
  `,
26602
26565
  "utf8"
26603
26566
  );
26604
- await writeFile7(
26567
+ await writeFile6(
26605
26568
  evidencePath,
26606
26569
  `${JSON.stringify(
26607
26570
  {
@@ -26879,9 +26842,9 @@ function extractReviewerMethodInvocations(entries, options) {
26879
26842
  async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
26880
26843
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26881
26844
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26882
- const reportPath = join26(artifactsDir, "report.json");
26883
- const evidencePath = join26(artifactsDir, "evidence.json");
26884
- await writeFile7(
26845
+ const reportPath = join25(artifactsDir, "report.json");
26846
+ const evidencePath = join25(artifactsDir, "evidence.json");
26847
+ await writeFile6(
26885
26848
  reportPath,
26886
26849
  `${JSON.stringify(
26887
26850
  {
@@ -26895,7 +26858,7 @@ async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, opti
26895
26858
  `,
26896
26859
  "utf8"
26897
26860
  );
26898
- await writeFile7(
26861
+ await writeFile6(
26899
26862
  evidencePath,
26900
26863
  `${JSON.stringify(
26901
26864
  {
@@ -26994,9 +26957,9 @@ function extractMergerMethodInvocations(entries, options) {
26994
26957
  async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
26995
26958
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26996
26959
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26997
- const reportPath = join26(artifactsDir, "report.json");
26998
- const evidencePath = join26(artifactsDir, "evidence.json");
26999
- await writeFile7(
26960
+ const reportPath = join25(artifactsDir, "report.json");
26961
+ const evidencePath = join25(artifactsDir, "evidence.json");
26962
+ await writeFile6(
27000
26963
  reportPath,
27001
26964
  `${JSON.stringify(
27002
26965
  {
@@ -27010,7 +26973,7 @@ async function publishMergerArtifacts(admitted, roleOutcome, coordinates, option
27010
26973
  `,
27011
26974
  "utf8"
27012
26975
  );
27013
- await writeFile7(
26976
+ await writeFile6(
27014
26977
  evidencePath,
27015
26978
  `${JSON.stringify(
27016
26979
  {
@@ -27129,7 +27092,7 @@ function publicationAttemptFromError(path, error) {
27129
27092
  }
27130
27093
  function uniqueFailureFallbackDirs(runDirectory, baseDir) {
27131
27094
  const dirs = [];
27132
- for (const dir of [baseDir, runDirectory, dirname14(runDirectory)]) {
27095
+ for (const dir of [baseDir, runDirectory, dirname13(runDirectory)]) {
27133
27096
  if (!dirs.includes(dir)) dirs.push(dir);
27134
27097
  }
27135
27098
  return dirs;
@@ -27151,13 +27114,13 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
27151
27114
  const candidates = [
27152
27115
  ...preferredCandidates,
27153
27116
  // One unique name per fallback dir — collisions on fixed names cannot exhaust this.
27154
- ...uniqueFallbackDirs.map((dir) => join26(dir, `${stem}.${randomUUID5()}.json`))
27117
+ ...uniqueFallbackDirs.map((dir) => join25(dir, `${stem}.${randomUUID4()}.json`))
27155
27118
  ];
27156
27119
  for (let i = 0; i < candidates.length; i += 1) {
27157
27120
  const path = candidates[i];
27158
27121
  const payload = issues.length === 0 ? basePayload : { ...basePayload, publicationIssues: issues };
27159
27122
  try {
27160
- await writeFile7(
27123
+ await writeFile6(
27161
27124
  path,
27162
27125
  `${JSON.stringify(payload, null, 2)}
27163
27126
  `,
@@ -27202,20 +27165,20 @@ async function publishFailureArtifacts(admitted, failure, authority) {
27202
27165
  baseDir
27203
27166
  );
27204
27167
  const errorCandidates = underArtifacts ? [
27205
- join26(baseDir, "error.json"),
27206
- join26(baseDir, "error.settlement.json"),
27207
- join26(admitted.runDirectory, "error.settlement.json")
27168
+ join25(baseDir, "error.json"),
27169
+ join25(baseDir, "error.settlement.json"),
27170
+ join25(admitted.runDirectory, "error.settlement.json")
27208
27171
  ] : [
27209
- join26(baseDir, "error.settlement.json"),
27210
- join26(baseDir, "error.json")
27172
+ join25(baseDir, "error.settlement.json"),
27173
+ join25(baseDir, "error.json")
27211
27174
  ];
27212
27175
  const evidenceCandidates = underArtifacts ? [
27213
- join26(baseDir, "evidence.json"),
27214
- join26(baseDir, "evidence.settlement.json"),
27215
- join26(admitted.runDirectory, "evidence.settlement.json")
27176
+ join25(baseDir, "evidence.json"),
27177
+ join25(baseDir, "evidence.settlement.json"),
27178
+ join25(admitted.runDirectory, "evidence.settlement.json")
27216
27179
  ] : [
27217
- join26(baseDir, "evidence.settlement.json"),
27218
- join26(baseDir, "evidence.json")
27180
+ join25(baseDir, "evidence.settlement.json"),
27181
+ join25(baseDir, "evidence.json")
27219
27182
  ];
27220
27183
  const errorPayloadBase = {
27221
27184
  kind: "error",
@@ -27509,10 +27472,10 @@ var init_turn_request = __esm({
27509
27472
  });
27510
27473
 
27511
27474
  // src/session-identity.ts
27512
- import { mkdir as mkdir3, readFile as readFile18, rename as rename3, writeFile as writeFile8 } from "node:fs/promises";
27513
- import { dirname as dirname15, join as join27 } from "node:path";
27475
+ import { mkdir as mkdir3, readFile as readFile18, rename as rename2, writeFile as writeFile7 } from "node:fs/promises";
27476
+ import { dirname as dirname14, join as join26 } from "node:path";
27514
27477
  function createSessionIdentityAuthority(authority, sessionBindingFile) {
27515
- const bindingPath = (principal) => join27(authority.decode(principal).sessionDirectory, sessionBindingFile);
27478
+ const bindingPath = (principal) => join26(authority.decode(principal).sessionDirectory, sessionBindingFile);
27516
27479
  return {
27517
27480
  resolveSessionFile(principal) {
27518
27481
  return authority.decode(principal).sessionFile;
@@ -27531,11 +27494,11 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
27531
27494
  },
27532
27495
  async bind(principal, sessionId) {
27533
27496
  const target = bindingPath(principal);
27534
- await mkdir3(dirname15(target), { recursive: true });
27497
+ await mkdir3(dirname14(target), { recursive: true });
27535
27498
  const temporary = `${target}.${process.pid}.tmp`;
27536
- await writeFile8(temporary, `${JSON.stringify({ sessionId })}
27499
+ await writeFile7(temporary, `${JSON.stringify({ sessionId })}
27537
27500
  `, { encoding: "utf8", mode: 384 });
27538
- await rename3(temporary, target);
27501
+ await rename2(temporary, target);
27539
27502
  }
27540
27503
  };
27541
27504
  }
@@ -27583,7 +27546,10 @@ function ticketProvenanceRecordInput(ticketNumber, cwd, home) {
27583
27546
  };
27584
27547
  }
27585
27548
  function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
27586
- return resolveSitianVolume(ticketProvenanceRecordInput(ticketNumber, cwd, home));
27549
+ const path = resolveSitianRecordPath(
27550
+ ticketProvenanceRecordInput(ticketNumber, cwd, home)
27551
+ );
27552
+ return { recordFile: path.recordFile, volumeDir: path.sessionDir };
27587
27553
  }
27588
27554
  var init_ticket_provenance = __esm({
27589
27555
  "src/ticket-provenance.ts"() {
@@ -27599,9 +27565,9 @@ var init_ticket_provenance = __esm({
27599
27565
  });
27600
27566
 
27601
27567
  // src/public-cli/case-dossier-delivery.ts
27602
- import { mkdtemp, readFile as readFile19, rm as rm2, writeFile as writeFile9 } from "node:fs/promises";
27568
+ import { mkdtemp, readFile as readFile19, rm, writeFile as writeFile8 } from "node:fs/promises";
27603
27569
  import { tmpdir } from "node:os";
27604
- import { join as join28 } from "node:path";
27570
+ import { join as join27 } from "node:path";
27605
27571
  function describeDossierFile(path) {
27606
27572
  return path;
27607
27573
  }
@@ -27626,10 +27592,10 @@ async function deliverCaseDossierAsAttachment(input) {
27626
27592
  home: input.home
27627
27593
  });
27628
27594
  if (section === void 0) return void 0;
27629
- const stagingDir = await mkdtemp(join28(tmpdir(), "ak-case-dossier-"));
27595
+ const stagingDir = await mkdtemp(join27(tmpdir(), "ak-case-dossier-"));
27630
27596
  try {
27631
- const stagingPath = join28(stagingDir, CASE_DOSSIER_ATTACH_FILE);
27632
- await writeFile9(stagingPath, `${section}
27597
+ const stagingPath = join27(stagingDir, CASE_DOSSIER_ATTACH_FILE);
27598
+ await writeFile8(stagingPath, `${section}
27633
27599
  `, "utf8");
27634
27600
  return await freezeAttachmentsIntoRun(
27635
27601
  [stagingPath],
@@ -27637,7 +27603,7 @@ async function deliverCaseDossierAsAttachment(input) {
27637
27603
  CASE_DOSSIER_ATTACH_KEY
27638
27604
  );
27639
27605
  } finally {
27640
- await rm2(stagingDir, { recursive: true, force: true });
27606
+ await rm(stagingDir, { recursive: true, force: true });
27641
27607
  }
27642
27608
  }
27643
27609
  var CASE_DOSSIER_SECTION_HEADING, CASE_DOSSIER_ATTACH_KEY, CASE_DOSSIER_ATTACH_FILE;
@@ -27654,7 +27620,7 @@ var init_case_dossier_delivery = __esm({
27654
27620
 
27655
27621
  // src/host-transition-prior-native.ts
27656
27622
  import { access as access3, readdir as readdir8 } from "node:fs/promises";
27657
- import { dirname as dirname16, join as join29 } from "node:path";
27623
+ import { dirname as dirname15, join as join28 } from "node:path";
27658
27624
  function isEnoent3(error) {
27659
27625
  return typeof error === "object" && error !== null && error.code === "ENOENT";
27660
27626
  }
@@ -27668,7 +27634,7 @@ async function listPiNativeRecordPaths(sessionFile) {
27668
27634
  }
27669
27635
  }
27670
27636
  async function listSitianRecordPaths(sessionParent) {
27671
- const sessionRoot = dirname16(sessionParent);
27637
+ const sessionRoot = dirname15(sessionParent);
27672
27638
  let entries;
27673
27639
  try {
27674
27640
  entries = await readdir8(sessionRoot, { withFileTypes: true });
@@ -27679,7 +27645,7 @@ async function listSitianRecordPaths(sessionParent) {
27679
27645
  const recordPaths = [];
27680
27646
  for (const entry of entries) {
27681
27647
  if (!entry.isDirectory()) continue;
27682
- const recordFile = join29(sessionRoot, entry.name, "records.jsonl");
27648
+ const recordFile = join28(sessionRoot, entry.name, "records.jsonl");
27683
27649
  try {
27684
27650
  await access3(recordFile);
27685
27651
  recordPaths.push(recordFile);
@@ -27747,9 +27713,9 @@ var init_public_run_credentials = __esm({
27747
27713
 
27748
27714
  // src/public-cli/auto-resume.ts
27749
27715
  import { constants as fsConstants2 } from "node:fs";
27750
- import { randomUUID as randomUUID6 } from "node:crypto";
27716
+ import { randomUUID as randomUUID5 } from "node:crypto";
27751
27717
  import { lstat as lstat6, mkdir as mkdir4, open as open2 } from "node:fs/promises";
27752
- import { join as join30 } from "node:path";
27718
+ import { join as join29 } from "node:path";
27753
27719
  async function persistReturnedRunState(admitted, authority, options) {
27754
27720
  if (options?.lawful === true) {
27755
27721
  await markRunTerminal(admitted.runDirectory);
@@ -27864,7 +27830,7 @@ function jsonSafeReplacer() {
27864
27830
  };
27865
27831
  }
27866
27832
  async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
27867
- const filePath = join30(artifactsDir, `${namePrefix}-${randomUUID6()}.json`);
27833
+ const filePath = join29(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
27868
27834
  const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
27869
27835
  `;
27870
27836
  const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
@@ -28135,9 +28101,9 @@ var init_auto_resume = __esm({
28135
28101
  });
28136
28102
 
28137
28103
  // src/public-cli/post-admission.ts
28138
- import { randomUUID as randomUUID7 } from "node:crypto";
28139
- import { writeFile as writeFile10 } from "node:fs/promises";
28140
- import { isAbsolute as isAbsolute8, join as join31, resolve as resolve8 } from "node:path";
28104
+ import { randomUUID as randomUUID6 } from "node:crypto";
28105
+ import { writeFile as writeFile9 } from "node:fs/promises";
28106
+ import { isAbsolute as isAbsolute8, join as join30, resolve as resolve8 } from "node:path";
28141
28107
  function describeCaughtError(error) {
28142
28108
  if (error instanceof Error) {
28143
28109
  const code = error.code;
@@ -28181,8 +28147,8 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
28181
28147
  } catch (appendError) {
28182
28148
  try {
28183
28149
  const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
28184
- await writeFile10(
28185
- join31(artifactsDir, `post-admission-diagnostic-${randomUUID7()}.json`),
28150
+ await writeFile9(
28151
+ join30(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
28186
28152
  `${JSON.stringify({ version: 1, ...payload }, null, 2)}
28187
28153
  `,
28188
28154
  { encoding: "utf8", flag: "wx" }
@@ -28481,8 +28447,8 @@ async function dispatchPostAdmissionTurn(input) {
28481
28447
  }
28482
28448
  let stderrLogWriteFailure;
28483
28449
  try {
28484
- await writeFile10(
28485
- join31(admitted.runDirectory, "stderr.log"),
28450
+ await writeFile9(
28451
+ join30(admitted.runDirectory, "stderr.log"),
28486
28452
  result2.stderr,
28487
28453
  "utf8"
28488
28454
  );
@@ -28714,7 +28680,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
28714
28680
  kind: "resume",
28715
28681
  prompt
28716
28682
  },
28717
- ...request.message === void 0 ? {} : { courtAttemptId: randomUUID7() },
28683
+ ...request.message === void 0 ? {} : { courtAttemptId: randomUUID6() },
28718
28684
  ...env.stationChild === void 0 ? {} : { stationChild: env.stationChild }
28719
28685
  };
28720
28686
  }
@@ -28732,7 +28698,7 @@ async function dispatchAfterWriterLease(input) {
28732
28698
  }
28733
28699
  function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
28734
28700
  const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve8(attachmentPath);
28735
- return pathContainedIn(join31(runDirectory, "attachments"), absolute);
28701
+ return pathContainedIn(join30(runDirectory, "attachments"), absolute);
28736
28702
  }
28737
28703
  async function prepareSummonsResumeMaterials(runDirectory, summons) {
28738
28704
  if (summons === void 0) return void 0;
@@ -28811,7 +28777,7 @@ async function runPostAdmissionSeatResume(input) {
28811
28777
  }
28812
28778
  let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
28813
28779
  if (openCourtAttemptId !== void 0 || request.summons !== void 0 || request.message !== void 0) {
28814
- const courtAttemptId = openCourtAttemptId ?? (turnRequest.courtAttemptId !== void 0 && turnRequest.courtAttemptId.length > 0 ? turnRequest.courtAttemptId : randomUUID7());
28780
+ const courtAttemptId = openCourtAttemptId ?? (turnRequest.courtAttemptId !== void 0 && turnRequest.courtAttemptId.length > 0 ? turnRequest.courtAttemptId : randomUUID6());
28815
28781
  turnRequest = { ...turnRequest, courtAttemptId };
28816
28782
  if (openCourtAttemptId === void 0) {
28817
28783
  const court = {
@@ -30368,7 +30334,7 @@ __export(public_role_summons_exports, {
30368
30334
  summonPublicRole: () => summonPublicRole
30369
30335
  });
30370
30336
  import { existsSync as existsSync10 } from "node:fs";
30371
- import { join as join32 } from "node:path";
30337
+ import { join as join31 } from "node:path";
30372
30338
  function createCapturingIo() {
30373
30339
  const chunks = [];
30374
30340
  return {
@@ -30391,7 +30357,7 @@ function parentDir(path) {
30391
30357
  function walkPackageRoot(start) {
30392
30358
  let dir = start;
30393
30359
  for (let i = 0; i < 12; i += 1) {
30394
- if (existsSync10(join32(dir, "package.json")) && existsSync10(join32(dir, "souls"))) {
30360
+ if (existsSync10(join31(dir, "package.json")) && existsSync10(join31(dir, "souls"))) {
30395
30361
  return dir;
30396
30362
  }
30397
30363
  const parent = parentDir(dir);
@@ -30502,7 +30468,7 @@ async function createSummonEnv(options, afterHost) {
30502
30468
  async function summonPublicRole(options) {
30503
30469
  const packageRoot2 = resolveSummonsPackageRoot(options.packageRoot);
30504
30470
  const home = await resolveSummonHome(options);
30505
- const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join32(home, ".pi", "agent");
30471
+ const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join31(home, ".pi", "agent");
30506
30472
  const {
30507
30473
  loadCredentialProviders: loadCredentialProviders2,
30508
30474
  loadPublicCliConfig: loadPublicCliConfig2,
@@ -31748,6 +31714,27 @@ var init_analyst_book_key = __esm({
31748
31714
  }
31749
31715
  });
31750
31716
 
31717
+ // src/atomic-write.ts
31718
+ import { randomUUID as randomUUID7 } from "node:crypto";
31719
+ import { rename as rename3, rm as rm2, writeFile as writeFile10 } from "node:fs/promises";
31720
+ import { dirname as dirname16, join as join32 } from "node:path";
31721
+ async function writeFileAtomically(destination, contents) {
31722
+ const parent = dirname16(destination);
31723
+ const temporary = join32(parent, `.atomic-write-${randomUUID7()}.tmp`);
31724
+ try {
31725
+ await writeFile10(temporary, contents);
31726
+ await rename3(temporary, destination);
31727
+ } catch (error) {
31728
+ await rm2(temporary, { force: true }).catch(() => void 0);
31729
+ throw error;
31730
+ }
31731
+ }
31732
+ var init_atomic_write = __esm({
31733
+ "src/atomic-write.ts"() {
31734
+ "use strict";
31735
+ }
31736
+ });
31737
+
31751
31738
  // src/analyst-index.ts
31752
31739
  import { open as open3, readFile as readFile20, unlink as unlink4 } from "node:fs/promises";
31753
31740
  import { dirname as dirname17, join as join33 } from "node:path";