@akagilnc/pi-workflow-roles 0.1.4631 → 0.1.4641

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.
@@ -926,6 +926,15 @@ var init_archivist_record_entry = __esm({
926
926
  });
927
927
 
928
928
  // src/run-ticket-number.ts
929
+ var run_ticket_number_exports = {};
930
+ __export(run_ticket_number_exports, {
931
+ MIGRATION_TICKET_DERIVATION_PAGE: () => MIGRATION_TICKET_DERIVATION_PAGE,
932
+ isSafePositiveTicketNumber: () => isSafePositiveTicketNumber,
933
+ readBoardTicketNumber: () => readBoardTicketNumber,
934
+ readMigrationDerivedTicketNumber: () => readMigrationDerivedTicketNumber,
935
+ readRunTicketNumber: () => readRunTicketNumber,
936
+ requireSafePositiveTicketNumber: () => requireSafePositiveTicketNumber
937
+ });
929
938
  import { readFile } from "node:fs/promises";
930
939
  import { join as join5 } from "node:path";
931
940
  function isEnoent(error) {
@@ -965,9 +974,22 @@ async function readBoardPageTicketNumber(runDirectory, page) {
965
974
  async function readBoardTicketNumber(runDirectory) {
966
975
  return await readBoardPageTicketNumber(runDirectory, "admitted-request.json") ?? await readBoardPageTicketNumber(runDirectory, "invocation.json");
967
976
  }
977
+ async function readMigrationDerivedTicketNumber(runDirectory) {
978
+ const record4 = await readJsonObject(
979
+ join5(runDirectory, MIGRATION_TICKET_DERIVATION_PAGE)
980
+ );
981
+ if (record4 === void 0) return void 0;
982
+ if (record4.derivation !== "worktree-path-basename") return void 0;
983
+ return ticketFromRecord(record4);
984
+ }
985
+ async function readRunTicketNumber(runDirectory) {
986
+ return await readBoardTicketNumber(runDirectory) ?? await readMigrationDerivedTicketNumber(runDirectory);
987
+ }
988
+ var MIGRATION_TICKET_DERIVATION_PAGE;
968
989
  var init_run_ticket_number = __esm({
969
990
  "src/run-ticket-number.ts"() {
970
991
  "use strict";
992
+ MIGRATION_TICKET_DERIVATION_PAGE = "migration-ticket-derivation.json";
971
993
  }
972
994
  });
973
995
 
@@ -1350,15 +1372,165 @@ var init_gatekeeper_output = __esm({
1350
1372
  }
1351
1373
  });
1352
1374
 
1375
+ // src/run-terminal-artifacts.ts
1376
+ var run_terminal_artifacts_exports = {};
1377
+ __export(run_terminal_artifacts_exports, {
1378
+ RUN_TERMINAL_ARTIFACT_FILES: () => RUN_TERMINAL_ARTIFACT_FILES,
1379
+ RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS: () => RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS,
1380
+ isUniqueErrorFallbackName: () => isUniqueErrorFallbackName,
1381
+ readRunTerminalArtifact: () => readRunTerminalArtifact,
1382
+ runIdFromRunDirectory: () => runIdFromRunDirectory
1383
+ });
1384
+ import { readdir as readdir2, readFile as readFile2 } from "node:fs/promises";
1385
+ import { basename as basename3, dirname as dirname5, join as join8 } from "node:path";
1386
+ function isMissingPathError2(error) {
1387
+ return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
1388
+ }
1389
+ function errorText2(error) {
1390
+ return error instanceof Error ? error.message : String(error);
1391
+ }
1392
+ function isRecord(value) {
1393
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1394
+ }
1395
+ function readUsableTerminalArtifactBody(body) {
1396
+ if (body === null) {
1397
+ return { ok: false, reason: "terminal artifact JSON value is null" };
1398
+ }
1399
+ if (!isRecord(body)) {
1400
+ return {
1401
+ ok: false,
1402
+ reason: `terminal artifact JSON value is not a typed object (${Array.isArray(body) ? "array" : typeof body})`
1403
+ };
1404
+ }
1405
+ if (typeof body.role !== "string" || body.role.trim() === "") {
1406
+ return {
1407
+ ok: false,
1408
+ reason: "terminal artifact missing nonblank producer-owned role field"
1409
+ };
1410
+ }
1411
+ return { ok: true, body };
1412
+ }
1413
+ async function readTerminalArtifactAtPath(path, file) {
1414
+ let raw;
1415
+ try {
1416
+ raw = await readFile2(path, "utf8");
1417
+ } catch (error) {
1418
+ if (isMissingPathError2(error)) return void 0;
1419
+ return {
1420
+ status: "unreadable",
1421
+ file,
1422
+ path,
1423
+ reason: errorText2(error)
1424
+ };
1425
+ }
1426
+ let parsed;
1427
+ try {
1428
+ parsed = JSON.parse(raw);
1429
+ } catch (error) {
1430
+ return {
1431
+ status: "unreadable",
1432
+ file,
1433
+ path,
1434
+ reason: error instanceof Error ? error.message : `terminal artifact JSON parse failed: ${String(error)}`
1435
+ };
1436
+ }
1437
+ const usable = readUsableTerminalArtifactBody(parsed);
1438
+ if (!usable.ok) {
1439
+ return {
1440
+ status: "unreadable",
1441
+ file,
1442
+ path,
1443
+ reason: usable.reason
1444
+ };
1445
+ }
1446
+ return { status: "present", file, path, body: usable.body };
1447
+ }
1448
+ async function listUniqueErrorFallbackPaths(directories) {
1449
+ const found = [];
1450
+ for (const dir of directories) {
1451
+ let names;
1452
+ try {
1453
+ names = await readdir2(dir);
1454
+ } catch (error) {
1455
+ if (isMissingPathError2(error)) continue;
1456
+ throw error;
1457
+ }
1458
+ for (const name of names.sort((a, b) => a.localeCompare(b))) {
1459
+ if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
1460
+ found.push(join8(dir, name));
1461
+ }
1462
+ }
1463
+ return found;
1464
+ }
1465
+ function runIdFromRunDirectory(runDirectory) {
1466
+ const name = basename3(runDirectory);
1467
+ const at = name.lastIndexOf("@");
1468
+ if (at <= 0 || at === name.length - 1) return void 0;
1469
+ return name.slice(0, at);
1470
+ }
1471
+ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
1472
+ if (expectedRunId === void 0) return false;
1473
+ return typeof body.runId === "string" && body.runId === expectedRunId;
1474
+ }
1475
+ async function readRunTerminalArtifact(runDirectory) {
1476
+ const artifactsDir = roleRunArtifactsDirectory(runDirectory);
1477
+ for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
1478
+ const path = join8(artifactsDir, file);
1479
+ const read = await readTerminalArtifactAtPath(path, file);
1480
+ if (read !== void 0) return read;
1481
+ }
1482
+ for (const relative5 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
1483
+ const path = join8(runDirectory, relative5);
1484
+ const read = await readTerminalArtifactAtPath(path, "error.json");
1485
+ if (read !== void 0) return read;
1486
+ }
1487
+ for (const path of await listUniqueErrorFallbackPaths([artifactsDir, runDirectory])) {
1488
+ const read = await readTerminalArtifactAtPath(path, "error.json");
1489
+ if (read !== void 0) return read;
1490
+ }
1491
+ const expectedRunId = runIdFromRunDirectory(runDirectory);
1492
+ for (const path of await listUniqueErrorFallbackPaths([dirname5(runDirectory)])) {
1493
+ const read = await readTerminalArtifactAtPath(path, "error.json");
1494
+ if (read === void 0) continue;
1495
+ if (read.status === "present") {
1496
+ if (!presentUniqueFallbackBoundToRun(read.body, expectedRunId)) continue;
1497
+ return read;
1498
+ }
1499
+ }
1500
+ return { status: "absent" };
1501
+ }
1502
+ function isUniqueErrorFallbackName(name) {
1503
+ return UNIQUE_ERROR_FALLBACK_NAME.test(basename3(name));
1504
+ }
1505
+ var RUN_TERMINAL_ARTIFACT_FILES, RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS, UNIQUE_ERROR_FALLBACK_NAME;
1506
+ var init_run_terminal_artifacts = __esm({
1507
+ "src/run-terminal-artifacts.ts"() {
1508
+ "use strict";
1509
+ init_role_run_placement();
1510
+ RUN_TERMINAL_ARTIFACT_FILES = [
1511
+ "report.json",
1512
+ "error.json",
1513
+ "audit-incomplete.json"
1514
+ ];
1515
+ RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS = [
1516
+ "artifacts/error.settlement.json",
1517
+ "error.settlement.json"
1518
+ ];
1519
+ UNIQUE_ERROR_FALLBACK_NAME = /^error\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.json$/i;
1520
+ }
1521
+ });
1522
+
1353
1523
  // src/gatekeeper-role.ts
1354
1524
  function gateSeatLabel(stage) {
1355
1525
  if (stage === "inspector") return "\u53F0\u9662";
1356
1526
  if (stage === "auditor") return "\u5BA1\u5211\u9662";
1527
+ if (stage === "countersign") return "\u7ED9\u4E8B\u4E2D";
1357
1528
  return "\u7B26\u5B9D\u90CE";
1358
1529
  }
1359
1530
  function gateOfficerForSubject(subject) {
1360
1531
  if (subject.kind === "worker_completion") return "inspector";
1361
1532
  if (subject.kind === "judge_compliance") return "auditor";
1533
+ if (subject.kind === "secretariat_verdict") return "countersign";
1362
1534
  return "notary";
1363
1535
  }
1364
1536
  function failureReason(error) {
@@ -1372,9 +1544,26 @@ function readRecord(value) {
1372
1544
  if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
1373
1545
  return value;
1374
1546
  }
1547
+ function gateStatusFromCountersign(status) {
1548
+ if (status === "converged") return "pass";
1549
+ if (status === "continue") return "bounce";
1550
+ if (status === "escalate") return "escalate";
1551
+ return void 0;
1552
+ }
1375
1553
  function projectOfficerDecision(officer, decision, fallbackStatus) {
1376
1554
  const receipt = retainedReceipt(decision);
1377
1555
  const record4 = readRecord(decision);
1556
+ if (officer === "countersign") {
1557
+ const countersignStatus = record4 !== void 0 && typeof record4.countersignStatus === "string" ? record4.countersignStatus : void 0;
1558
+ const status2 = typeof countersignStatus === "string" ? gateStatusFromCountersign(countersignStatus) : void 0;
1559
+ if (status2 === "pass") {
1560
+ return { status: "pass", officer, receipt };
1561
+ }
1562
+ if (status2 === "bounce" || status2 === "escalate") {
1563
+ return { status: status2, officer, receipt };
1564
+ }
1565
+ return { status: "needs_reask", officer, receipt };
1566
+ }
1378
1567
  const status = (record4 !== void 0 && typeof record4.status === "string" ? record4.status : void 0) ?? fallbackStatus;
1379
1568
  if (status === "pass") {
1380
1569
  return { status: "pass", officer, receipt };
@@ -1405,6 +1594,26 @@ function projectOfficerPayloads(officer, payloads, fallbackStatus) {
1405
1594
  }
1406
1595
  return projectOfficerDecision(officer, payloads[payloads.length - 1], fallbackStatus);
1407
1596
  }
1597
+ function officerRunIdFromSummoned(summoned) {
1598
+ if (typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "") {
1599
+ const fromDir = runIdFromRunDirectory(summoned.runDirectory);
1600
+ if (fromDir !== void 0) return fromDir;
1601
+ }
1602
+ const terminal = summoned.terminal;
1603
+ if (terminal !== void 0 && typeof terminal.runId === "string" && terminal.runId.trim() !== "") {
1604
+ return terminal.runId;
1605
+ }
1606
+ return void 0;
1607
+ }
1608
+ function withOfficerRunId(result, summoned) {
1609
+ if (result.status !== "pass" && result.status !== "bounce" && result.status !== "escalate" && result.status !== "needs_reask") {
1610
+ return result;
1611
+ }
1612
+ if (typeof result.runId === "string" && result.runId.trim() !== "") return result;
1613
+ const runId = officerRunIdFromSummoned(summoned);
1614
+ if (runId === void 0) return result;
1615
+ return { ...result, runId };
1616
+ }
1408
1617
  function projectOfficerTerminal(officer, summoned) {
1409
1618
  const terminal = summoned.terminal;
1410
1619
  const outcome = terminal?.roleOutcome;
@@ -1437,22 +1646,34 @@ function projectOfficerTerminal(officer, summoned) {
1437
1646
  };
1438
1647
  }
1439
1648
  if (outcome.kind === "audit_escalation") {
1440
- return {
1441
- status: "escalate",
1442
- officer,
1443
- // This-court receipt only (#879) — historical rows remain on terminal.submissions.
1444
- receipt: thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome)
1445
- };
1649
+ return withOfficerRunId(
1650
+ {
1651
+ status: "escalate",
1652
+ officer,
1653
+ // This-court receipt only (#879) historical rows remain on terminal.submissions.
1654
+ receipt: thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome)
1655
+ },
1656
+ summoned
1657
+ );
1446
1658
  }
1447
1659
  if (outcome.kind === "accepted") {
1448
- return projectOfficerPayloads(officer, thisCourt, outcome.status);
1660
+ return withOfficerRunId(
1661
+ projectOfficerPayloads(officer, thisCourt, outcome.status),
1662
+ summoned
1663
+ );
1449
1664
  }
1450
- return {
1451
- status: "needs_reask",
1452
- officer,
1453
- // This-court receipt only (#879).
1454
- receipt: thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome)
1455
- };
1665
+ return withOfficerRunId(
1666
+ {
1667
+ status: "needs_reask",
1668
+ officer,
1669
+ // This-court receipt only (#879).
1670
+ receipt: thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome)
1671
+ },
1672
+ summoned
1673
+ );
1674
+ }
1675
+ function officerConclusionReask(officer) {
1676
+ return officer === "countersign" ? COUNTERSIGN_CONCLUSION_REASK : OFFICER_CONCLUSION_REASK;
1456
1677
  }
1457
1678
  async function projectGatekeeperRun(options) {
1458
1679
  const officer = gateOfficerForSubject(options.subject);
@@ -1488,7 +1709,7 @@ async function projectGatekeeperRun(options) {
1488
1709
  summoned
1489
1710
  };
1490
1711
  }
1491
- var GATEKEEPER_TOOL_SPEC, OFFICER_CONCLUSION_REASK;
1712
+ var GATEKEEPER_TOOL_SPEC, OFFICER_CONCLUSION_REASK, COUNTERSIGN_CONCLUSION_REASK;
1492
1713
  var init_gatekeeper_role = __esm({
1493
1714
  "src/gatekeeper-role.ts"() {
1494
1715
  "use strict";
@@ -1496,6 +1717,7 @@ var init_gatekeeper_role = __esm({
1496
1717
  init_submission_errors();
1497
1718
  init_inspector_contracts();
1498
1719
  init_gatekeeper_output();
1720
+ init_run_terminal_artifacts();
1499
1721
  init_submission_errors();
1500
1722
  GATEKEEPER_TOOL_SPEC = {
1501
1723
  name: GATEKEEPER_OUTPUT_TOOL_NAME,
@@ -1505,6 +1727,7 @@ var init_gatekeeper_role = __esm({
1505
1727
  parameters: gatekeeperOutputSchema
1506
1728
  };
1507
1729
  OFFICER_CONCLUSION_REASK = "\u4E0A\u6B21\u4EA4\u5377\u7684\u7ED3\u8BBA\u4E0D\u662F pass\u3001bounce\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u8F93\u51FA\uFF0C\u7ED3\u8BBA\u5B57\u6BB5\u5199\u660E\u5176\u4E00\uFF1B\u6253\u56DE\u6216\u4E0A\u5448\u7684\u8BDD\u5C31\u662F\u7ED9\u5BF9\u65B9\u770B\u7684\u539F\u6587\u3002";
1730
+ COUNTERSIGN_CONCLUSION_REASK = "\u4E0A\u6B21\u4EA4\u5377\u7684 countersignStatus \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u8F93\u51FA\uFF0CcountersignStatus \u5199\u660E\u5176\u4E00\uFF1B\u5C01\u9A73\u6216\u4E0A\u5448\u7684\u8BDD\u5C31\u662F\u7ED9\u5BF9\u65B9\u770B\u7684\u539F\u6587\u3002";
1508
1731
  }
1509
1732
  });
1510
1733
 
@@ -1515,12 +1738,12 @@ __export(session_assistant_usage_exports, {
1515
1738
  sessionFileFromPublicSummon: () => sessionFileFromPublicSummon,
1516
1739
  usageFromPublicSummon: () => usageFromPublicSummon
1517
1740
  });
1518
- import { join as join8 } from "node:path";
1741
+ import { join as join9 } from "node:path";
1519
1742
  async function readAssistantUsageFromSessionFile(sessionFile) {
1520
- const { readFile: readFile23 } = await import("node:fs/promises");
1743
+ const { readFile: readFile24 } = await import("node:fs/promises");
1521
1744
  let text;
1522
1745
  try {
1523
- text = await readFile23(sessionFile, "utf8");
1746
+ text = await readFile24(sessionFile, "utf8");
1524
1747
  } catch (error) {
1525
1748
  if (error?.code === "ENOENT") return void 0;
1526
1749
  throw error;
@@ -1585,7 +1808,7 @@ async function readAssistantUsageFromSessionFile(sessionFile) {
1585
1808
  }
1586
1809
  function sessionFileFromPublicSummon(summoned) {
1587
1810
  if (typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "") {
1588
- return join8(summoned.runDirectory, "session", "session.jsonl");
1811
+ return join9(summoned.runDirectory, "session", "session.jsonl");
1589
1812
  }
1590
1813
  const fromArtifacts = summoned.terminal?.artifacts?.map((a) => a.path).find((p) => typeof p === "string" && p.endsWith("session.jsonl"));
1591
1814
  if (fromArtifacts !== void 0) return fromArtifacts;
@@ -1594,7 +1817,7 @@ function sessionFileFromPublicSummon(summoned) {
1594
1817
  const facts = outcome.decisiveFacts;
1595
1818
  const pointer = facts?.runPointer;
1596
1819
  if (typeof pointer === "string" && pointer.trim() !== "") {
1597
- return join8(pointer, "session", "session.jsonl");
1820
+ return join9(pointer, "session", "session.jsonl");
1598
1821
  }
1599
1822
  return void 0;
1600
1823
  }
@@ -1611,7 +1834,7 @@ var init_session_assistant_usage = __esm({
1611
1834
 
1612
1835
  // src/package-resources/engine-material.ts
1613
1836
  import { existsSync as existsSync2, readdirSync as readdirSync2 } from "node:fs";
1614
- import { join as join9 } from "node:path";
1837
+ import { join as join10 } from "node:path";
1615
1838
  function pickEngineAxis(source) {
1616
1839
  return {
1617
1840
  ...source.engine === void 0 ? {} : { engine: source.engine },
@@ -1632,11 +1855,11 @@ function isEngineNameSyntax(name) {
1632
1855
  return true;
1633
1856
  }
1634
1857
  function resolveEngineMaterialDirectory(packageRoot) {
1635
- return join9(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
1858
+ return join10(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
1636
1859
  }
1637
1860
  function resolveEngineMaterialPath(packageRoot, name) {
1638
1861
  const legal = assertLegalEngineName(name);
1639
- return join9(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
1862
+ return join10(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
1640
1863
  }
1641
1864
  function assertLegalEngineName(name) {
1642
1865
  if (!isEngineNameSyntax(name)) {
@@ -1694,7 +1917,7 @@ __export(durable_principal_exports, {
1694
1917
  piDurablePrincipalAuthority: () => piDurablePrincipalAuthority
1695
1918
  });
1696
1919
  import { lstat } from "node:fs/promises";
1697
- import { join as join10 } from "node:path";
1920
+ import { join as join11 } from "node:path";
1698
1921
  function encode(coordinates) {
1699
1922
  return coordinates;
1700
1923
  }
@@ -1744,7 +1967,7 @@ var init_durable_principal = __esm({
1744
1967
  }
1745
1968
  return {
1746
1969
  sessionDirectory: record4.sessionDirectory,
1747
- sessionFile: typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : join10(record4.sessionDirectory, "session.jsonl")
1970
+ sessionFile: typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : join11(record4.sessionDirectory, "session.jsonl")
1748
1971
  };
1749
1972
  },
1750
1973
  async isAvailable(principal) {
@@ -2350,7 +2573,7 @@ var init_auditor_output = __esm({
2350
2573
  });
2351
2574
 
2352
2575
  // src/ticket-provenance-contracts.ts
2353
- function isRecord(value) {
2576
+ function isRecord2(value) {
2354
2577
  return typeof value === "object" && value !== null && !Array.isArray(value);
2355
2578
  }
2356
2579
  function positiveInteger(value) {
@@ -2373,7 +2596,7 @@ function projectSpeaker(value) {
2373
2596
  return value === "owner" || value === "runner" ? value : void 0;
2374
2597
  }
2375
2598
  function projectBound(value) {
2376
- if (!isRecord(value)) return void 0;
2599
+ if (!isRecord2(value)) return void 0;
2377
2600
  const id = typeof value.id === "string" && value.id !== "" ? value.id : void 0;
2378
2601
  const line2 = positiveInteger(value.line);
2379
2602
  if (id === void 0 && line2 === void 0) return void 0;
@@ -2384,13 +2607,13 @@ function projectTicketProvenanceSessions(value) {
2384
2607
  if (value.length === 0) return [];
2385
2608
  const sessions = [];
2386
2609
  for (const raw of value) {
2387
- if (!isRecord(raw)) return void 0;
2610
+ if (!isRecord2(raw)) return void 0;
2388
2611
  const path = raw.path;
2389
2612
  if (typeof path !== "string" || path.trim() === "") return void 0;
2390
2613
  if (!Array.isArray(raw.ranges) || raw.ranges.length === 0) return void 0;
2391
2614
  const ranges = [];
2392
2615
  for (const rawRange of raw.ranges) {
2393
- if (!isRecord(rawRange)) return void 0;
2616
+ if (!isRecord2(rawRange)) return void 0;
2394
2617
  const from = projectBound(rawRange.from);
2395
2618
  const to = projectBound(rawRange.to);
2396
2619
  if (from === void 0 || to === void 0) return void 0;
@@ -2401,7 +2624,7 @@ function projectTicketProvenanceSessions(value) {
2401
2624
  return sessions;
2402
2625
  }
2403
2626
  function projectTicketProvenanceHeader(value) {
2404
- if (!isRecord(value)) return void 0;
2627
+ if (!isRecord2(value)) return void 0;
2405
2628
  const ticket = positiveInteger(value.ticket);
2406
2629
  if (ticket === void 0) return void 0;
2407
2630
  if (typeof value.repo !== "string") return void 0;
@@ -2419,7 +2642,7 @@ function projectTicketProvenanceHeader(value) {
2419
2642
  };
2420
2643
  }
2421
2644
  function projectTicketProvenanceLine(value) {
2422
- if (!isRecord(value)) return void 0;
2645
+ if (!isRecord2(value)) return void 0;
2423
2646
  const speaker = projectSpeaker(value.speaker);
2424
2647
  const s = nonNegativeInteger(value.s);
2425
2648
  if (speaker === void 0 || s === void 0) return void 0;
@@ -2535,13 +2758,23 @@ var init_diarist_contracts = __esm({
2535
2758
  });
2536
2759
 
2537
2760
  // src/secretariat-contracts.ts
2538
- var SECRETARIAT_OUTPUT_TOOL_NAME, SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME, SECRETARIAT_ACCEPTED_TEXT;
2761
+ var secretariat_contracts_exports = {};
2762
+ __export(secretariat_contracts_exports, {
2763
+ SECRETARIAT_ACCEPTED_TEXT: () => SECRETARIAT_ACCEPTED_TEXT,
2764
+ SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY: () => SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY,
2765
+ SECRETARIAT_GATE_OFFICER_ENTRY_TYPE: () => SECRETARIAT_GATE_OFFICER_ENTRY_TYPE,
2766
+ SECRETARIAT_OUTPUT_TOOL_NAME: () => SECRETARIAT_OUTPUT_TOOL_NAME,
2767
+ SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME: () => SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME
2768
+ });
2769
+ var SECRETARIAT_OUTPUT_TOOL_NAME, SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME, SECRETARIAT_ACCEPTED_TEXT, SECRETARIAT_GATE_OFFICER_ENTRY_TYPE, SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY;
2539
2770
  var init_secretariat_contracts = __esm({
2540
2771
  "src/secretariat-contracts.ts"() {
2541
2772
  "use strict";
2542
2773
  SECRETARIAT_OUTPUT_TOOL_NAME = "ak_secretariat_output";
2543
2774
  SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME = "ak_secretariat_summon_countersign";
2544
2775
  SECRETARIAT_ACCEPTED_TEXT = "\u4E2D\u4E66\u7701\u56DE\u6267\u5DF2\u63A5\u53D7";
2776
+ SECRETARIAT_GATE_OFFICER_ENTRY_TYPE = "ak-secretariat-gate-officer";
2777
+ SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY = "countersignTerminal";
2545
2778
  }
2546
2779
  });
2547
2780
 
@@ -2888,8 +3121,8 @@ import {
2888
3121
  unlinkSync,
2889
3122
  writeFileSync as writeFileSync2
2890
3123
  } from "node:fs";
2891
- import { dirname as dirname5, join as join11 } from "node:path";
2892
- function isRecord2(value) {
3124
+ import { dirname as dirname6, join as join12 } from "node:path";
3125
+ function isRecord3(value) {
2893
3126
  return typeof value === "object" && value !== null && !Array.isArray(value);
2894
3127
  }
2895
3128
  function errorCodeOf(error) {
@@ -2917,7 +3150,7 @@ function findIdentityPointer(recordFile, identity, kind, level) {
2917
3150
  if (!trimmed) continue;
2918
3151
  try {
2919
3152
  const parsed = JSON.parse(trimmed);
2920
- if (isRecord2(parsed) && parsed.identity === identity) {
3153
+ if (isRecord3(parsed) && parsed.identity === identity) {
2921
3154
  return { identity, recordFile, kind, level };
2922
3155
  }
2923
3156
  } catch {
@@ -3016,8 +3249,8 @@ function resolveSitianVolumeCategory(kind) {
3016
3249
  return kind;
3017
3250
  }
3018
3251
  function ticketProvenanceUnderBookPaths(ledgerHome, bookKey, ticketId) {
3019
- const sessionDir = join11(activationBookDirectory(ledgerHome, bookKey), ticketId);
3020
- return { sessionDir, recordFile: join11(sessionDir, SITIAN_RECORDS_LEAF) };
3252
+ const sessionDir = join12(activationBookDirectory(ledgerHome, bookKey), ticketId);
3253
+ return { sessionDir, recordFile: join12(sessionDir, SITIAN_RECORDS_LEAF) };
3021
3254
  }
3022
3255
  function resolveSitianRecordPathInLedger(input, ledgerHome) {
3023
3256
  const category = resolveSitianVolumeCategory(input.kind);
@@ -3036,14 +3269,14 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
3036
3269
  if (input.sessionParent === void 0 || input.sessionParent.length === 0 || !physicallyContainedIn(ledgerHome, input.sessionParent)) {
3037
3270
  throw new Error("Sitian record ownership requires a parent session inside the ledger home");
3038
3271
  }
3039
- sessionDir = join11(dirname5(input.sessionParent), category);
3040
- recordFile = join11(sessionDir, SITIAN_RECORDS_LEAF);
3272
+ sessionDir = join12(dirname6(input.sessionParent), category);
3273
+ recordFile = join12(sessionDir, SITIAN_RECORDS_LEAF);
3041
3274
  }
3042
3275
  return { sessionDir, recordFile, ledgerHome };
3043
3276
  }
3044
3277
  function projectTicketRecordsPathShape() {
3045
3278
  const { recordFile } = ticketProvenanceUnderBookPaths(
3046
- join11("~", ".ak-roles"),
3279
+ join12("~", ".ak-roles"),
3047
3280
  "<\u7C3F>",
3048
3281
  "<\u7968\u53F7>"
3049
3282
  );
@@ -3105,15 +3338,15 @@ var init_sitian_appender = __esm({
3105
3338
 
3106
3339
  // src/sitian-reader.ts
3107
3340
  import { existsSync as existsSync4 } from "node:fs";
3108
- import { readFile as readFile2 } from "node:fs/promises";
3109
- function isRecord3(value) {
3341
+ import { readFile as readFile3 } from "node:fs/promises";
3342
+ function isRecord4(value) {
3110
3343
  return typeof value === "object" && value !== null && !Array.isArray(value);
3111
3344
  }
3112
3345
  async function readSitianRecords(recordFile) {
3113
3346
  if (!existsSync4(recordFile)) {
3114
3347
  return { records: [], diagnostics: [] };
3115
3348
  }
3116
- const text = await readFile2(recordFile, "utf8");
3349
+ const text = await readFile3(recordFile, "utf8");
3117
3350
  const lines = text.split("\n");
3118
3351
  const records = [];
3119
3352
  const diagnostics = [];
@@ -3122,7 +3355,7 @@ async function readSitianRecords(recordFile) {
3122
3355
  if (!line2.trim()) continue;
3123
3356
  try {
3124
3357
  const parsed = JSON.parse(line2);
3125
- if (isRecord3(parsed)) {
3358
+ if (isRecord4(parsed)) {
3126
3359
  records.push(parsed);
3127
3360
  } else {
3128
3361
  const typeDesc = parsed === null ? "null" : Array.isArray(parsed) ? "array" : typeof parsed;
@@ -3178,13 +3411,13 @@ __export(role_turn_host_exports, {
3178
3411
  });
3179
3412
  import { execFile, spawn as spawn2 } from "node:child_process";
3180
3413
  import { constants } from "node:fs";
3181
- import { access, appendFile, readFile as readFile3, realpath } from "node:fs/promises";
3182
- import { basename as basename3, delimiter, dirname as dirname6, isAbsolute as isAbsolute3, join as join12, resolve as resolve5 } from "node:path";
3414
+ import { access, appendFile, readFile as readFile4, realpath } from "node:fs/promises";
3415
+ import { basename as basename4, delimiter, dirname as dirname7, isAbsolute as isAbsolute3, join as join13, resolve as resolve5 } from "node:path";
3183
3416
  import { platform } from "node:process";
3184
3417
  import { promisify } from "node:util";
3185
3418
  import { randomUUID as randomUUID2 } from "node:crypto";
3186
3419
  function resolveInternalRoleEntrypoint(packageRoot) {
3187
- return join12(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE);
3420
+ return join13(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE);
3188
3421
  }
3189
3422
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
3190
3423
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -3220,7 +3453,7 @@ function buildMethodArgs(methods) {
3220
3453
  function applyPiNativeSkillInvocation(methods, prompt) {
3221
3454
  const skills = methods.filter((method) => method.kind === "skill");
3222
3455
  if (skills.length !== 1) return prompt;
3223
- const name = basename3(dirname6(skills[0].path));
3456
+ const name = basename4(dirname7(skills[0].path));
3224
3457
  if (name.length === 0) return prompt;
3225
3458
  const token = `/skill:${name}`;
3226
3459
  const trimmed = prompt.trimStart();
@@ -3458,7 +3691,7 @@ ${paths.join("\n")}`
3458
3691
  }
3459
3692
  async function appendPiSessionCustomEntry(authority, principal, customType, data) {
3460
3693
  const { sessionFile } = authority.decode(principal);
3461
- const text = await readFile3(sessionFile, "utf8");
3694
+ const text = await readFile4(sessionFile, "utf8");
3462
3695
  let parentId = null;
3463
3696
  for (const line2 of text.trim().split("\n").filter(Boolean)) {
3464
3697
  const entry = JSON.parse(line2);
@@ -3749,8 +3982,8 @@ var init_compliance_transport = __esm({
3749
3982
 
3750
3983
  // src/role-run-relocation.ts
3751
3984
  import { existsSync as existsSync5 } from "node:fs";
3752
- import { readdir as readdir2, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
3753
- import { join as join13, sep as sep2 } from "node:path";
3985
+ import { readdir as readdir3, readFile as readFile5, writeFile as writeFile2 } from "node:fs/promises";
3986
+ import { join as join14, sep as sep2 } from "node:path";
3754
3987
  function isEnoent2(error) {
3755
3988
  return error instanceof Error && "code" in error && error.code === "ENOENT";
3756
3989
  }
@@ -3839,7 +4072,7 @@ function rewriteSummonsMaterials(value, rewrites) {
3839
4072
  }
3840
4073
  async function rewriteJsonObjectFile(path, fields, rewrites) {
3841
4074
  if (!existsSync5(path)) return;
3842
- const page = JSON.parse(await readFile4(path, "utf8"));
4075
+ const page = JSON.parse(await readFile5(path, "utf8"));
3843
4076
  if (!isPlainObject(page)) return;
3844
4077
  rewriteRunDirectoryPathFieldsAgainstRewrites(page, fields, rewrites);
3845
4078
  await writeFile2(path, `${JSON.stringify(page, null, 2)}
@@ -3847,7 +4080,7 @@ async function rewriteJsonObjectFile(path, fields, rewrites) {
3847
4080
  }
3848
4081
  async function rewriteOfficerPointerFile(path, rewrites) {
3849
4082
  if (!existsSync5(path)) return;
3850
- const page = JSON.parse(await readFile4(path, "utf8"));
4083
+ const page = JSON.parse(await readFile5(path, "utf8"));
3851
4084
  if (!isPlainObject(page)) return;
3852
4085
  if (page.kind !== "direct-officer-run-pointer") return;
3853
4086
  rewriteRunDirectoryPathFieldsAgainstRewrites(
@@ -3860,7 +4093,7 @@ async function rewriteOfficerPointerFile(path, rewrites) {
3860
4093
  }
3861
4094
  async function rewriteSitianRecordsJsonl(path, rewrites) {
3862
4095
  if (!existsSync5(path)) return;
3863
- const raw = await readFile4(path, "utf8");
4096
+ const raw = await readFile5(path, "utf8");
3864
4097
  if (raw.length === 0) return;
3865
4098
  const endsWithNewline = raw.endsWith("\n");
3866
4099
  const lines = raw.split("\n");
@@ -3911,7 +4144,7 @@ async function rewriteSitianRecordsJsonl(path, rewrites) {
3911
4144
  }
3912
4145
  async function rewriteSessionTranscriptBindings(path, rewrites) {
3913
4146
  if (!existsSync5(path)) return;
3914
- const raw = await readFile4(path, "utf8");
4147
+ const raw = await readFile5(path, "utf8");
3915
4148
  if (raw.length === 0) return;
3916
4149
  const endsWithNewline = raw.endsWith("\n");
3917
4150
  const lines = raw.split("\n");
@@ -3970,17 +4203,17 @@ async function rewriteSessionTranscriptBindings(path, rewrites) {
3970
4203
  );
3971
4204
  }
3972
4205
  async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
3973
- const sessionRoot = join13(pagesDirectory, "session");
4206
+ const sessionRoot = join14(pagesDirectory, "session");
3974
4207
  async function walk(directory) {
3975
4208
  let entries;
3976
4209
  try {
3977
- entries = await readdir2(directory, { withFileTypes: true });
4210
+ entries = await readdir3(directory, { withFileTypes: true });
3978
4211
  } catch (error) {
3979
4212
  if (isEnoent2(error)) return;
3980
4213
  throw error;
3981
4214
  }
3982
4215
  for (const entry of entries) {
3983
- const path = join13(directory, entry.name);
4216
+ const path = join14(directory, entry.name);
3984
4217
  if (entry.isDirectory()) {
3985
4218
  await walk(path);
3986
4219
  continue;
@@ -4002,9 +4235,9 @@ async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
4002
4235
  async function rewriteRoleRunDurablePages(input) {
4003
4236
  const { pagesDirectory } = input;
4004
4237
  const rewrites = collectRewrites(input);
4005
- const admittedPath = join13(pagesDirectory, "admitted-request.json");
4238
+ const admittedPath = join14(pagesDirectory, "admitted-request.json");
4006
4239
  if (existsSync5(admittedPath)) {
4007
- const page = JSON.parse(await readFile4(admittedPath, "utf8"));
4240
+ const page = JSON.parse(await readFile5(admittedPath, "utf8"));
4008
4241
  rewriteRunDirectoryPathFieldsAgainstRewrites(
4009
4242
  page,
4010
4243
  ADMITTED_PAGE_FIELDS,
@@ -4032,9 +4265,9 @@ async function rewriteRoleRunDurablePages(input) {
4032
4265
  await writeFile2(admittedPath, `${JSON.stringify(page, null, 2)}
4033
4266
  `, "utf8");
4034
4267
  }
4035
- const invocationPath = join13(pagesDirectory, "invocation.json");
4268
+ const invocationPath = join14(pagesDirectory, "invocation.json");
4036
4269
  if (existsSync5(invocationPath)) {
4037
- const page = JSON.parse(await readFile4(invocationPath, "utf8"));
4270
+ const page = JSON.parse(await readFile5(invocationPath, "utf8"));
4038
4271
  rewriteRunDirectoryPathFieldsAgainstRewrites(
4039
4272
  page,
4040
4273
  INVOCATION_PAGE_FIELDS,
@@ -4047,9 +4280,9 @@ async function rewriteRoleRunDurablePages(input) {
4047
4280
  "utf8"
4048
4281
  );
4049
4282
  }
4050
- const statePath = join13(pagesDirectory, "run-state.json");
4283
+ const statePath = join14(pagesDirectory, "run-state.json");
4051
4284
  if (existsSync5(statePath)) {
4052
- const page = JSON.parse(await readFile4(statePath, "utf8"));
4285
+ const page = JSON.parse(await readFile5(statePath, "utf8"));
4053
4286
  rewriteRunDirectoryPathFieldsAgainstRewrites(
4054
4287
  page,
4055
4288
  RUN_STATE_PAGE_FIELDS,
@@ -4237,15 +4470,15 @@ var init_terminating_tools = __esm({
4237
4470
  });
4238
4471
 
4239
4472
  // src/doctor-evidence.ts
4240
- import { readdir as readdir3, readFile as readFile5, realpath as realpath2, stat } from "node:fs/promises";
4241
- import { dirname as dirname7, relative as relative2, resolve as resolve6, sep as sep3 } from "node:path";
4473
+ import { readdir as readdir4, readFile as readFile6, realpath as realpath2, stat } from "node:fs/promises";
4474
+ import { dirname as dirname8, relative as relative2, resolve as resolve6, sep as sep3 } from "node:path";
4242
4475
  function record2(value) {
4243
4476
  return typeof value === "object" && value !== null && !Array.isArray(value);
4244
4477
  }
4245
4478
  async function discoverCaseFiles(root) {
4246
4479
  const found = [];
4247
4480
  async function walk(dir, depth) {
4248
- for (const item of await readdir3(dir, { withFileTypes: true })) {
4481
+ for (const item of await readdir4(dir, { withFileTypes: true })) {
4249
4482
  const path = resolve6(dir, item.name);
4250
4483
  if (item.isDirectory()) {
4251
4484
  await walk(path, depth + 1);
@@ -4265,7 +4498,7 @@ function accumulate(metric, value, source) {
4265
4498
  function timestamp(row) {
4266
4499
  return typeof row.timestamp === "string" && Number.isFinite(Date.parse(row.timestamp)) ? row.timestamp : void 0;
4267
4500
  }
4268
- function isMissingPathError2(error) {
4501
+ function isMissingPathError3(error) {
4269
4502
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
4270
4503
  }
4271
4504
  async function stableRunsIdentity(root) {
@@ -4275,9 +4508,9 @@ async function stableRunsIdentity(root) {
4275
4508
  const git3 = await stat(resolve6(cursor, ".git"));
4276
4509
  if (git3.isDirectory() || git3.isFile()) return relative2(cursor, root).split(sep3).join("/");
4277
4510
  } catch (error) {
4278
- if (!isMissingPathError2(error)) throw error;
4511
+ if (!isMissingPathError3(error)) throw error;
4279
4512
  }
4280
- const parent = dirname7(cursor);
4513
+ const parent = dirname8(cursor);
4281
4514
  if (parent === cursor) return root;
4282
4515
  cursor = parent;
4283
4516
  }
@@ -4353,7 +4586,7 @@ async function loadDoctorCase(runsPath) {
4353
4586
  const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
4354
4587
  for (const path of await discoverCaseFiles(root)) {
4355
4588
  const id = relative2(root, path).split(sep3).join("/");
4356
- const bytes = await readFile5(path);
4589
+ const bytes = await readFile6(path);
4357
4590
  const content = bytes.toString("utf8");
4358
4591
  const kind = id.endsWith(".jsonl") ? "session" : "stderr";
4359
4592
  evidence.push({ id, kind, byteLength: bytes.byteLength, contentLength: content.length, sha256: sha256Hex(bytes), content });
@@ -4366,7 +4599,7 @@ async function loadDoctorCase(runsPath) {
4366
4599
  accumulate(calls, result.calls, id);
4367
4600
  accumulate(tokens, result.tokens, id);
4368
4601
  }
4369
- const runDirs = (await readdir3(root, { withFileTypes: true })).filter((item) => item.isDirectory()).map((item) => item.name).sort();
4602
+ const runDirs = (await readdir4(root, { withFileTypes: true })).filter((item) => item.isDirectory()).map((item) => item.name).sort();
4370
4603
  const legs = evidence.filter((entry) => entry.kind === "session").map((entry) => entry.id);
4371
4604
  const retryDirs = runDirs.filter((name) => /(?:^|[-_])retry(?:[-_]|$)/i.test(name));
4372
4605
  const rawBytes = evidence.filter((entry) => entry.kind === "session").reduce((sum, entry) => sum + entry.byteLength, 0);
@@ -4383,7 +4616,7 @@ var init_doctor_evidence = __esm({
4383
4616
 
4384
4617
  // src/collector-config.ts
4385
4618
  import { createHash as createHash4 } from "node:crypto";
4386
- import { readFile as readFile6 } from "node:fs/promises";
4619
+ import { readFile as readFile7 } from "node:fs/promises";
4387
4620
  function fail3(message, cause) {
4388
4621
  throw new Error(message, cause === void 0 ? void 0 : { cause });
4389
4622
  }
@@ -4426,7 +4659,7 @@ function emptyCollectorManifest() {
4426
4659
  async function loadCollectorManifest(path) {
4427
4660
  let bytes;
4428
4661
  try {
4429
- bytes = await readFile6(path);
4662
+ bytes = await readFile7(path);
4430
4663
  } catch (error) {
4431
4664
  fail3(`Collector request manifest is unreadable at ${path}`, error);
4432
4665
  }
@@ -4462,7 +4695,7 @@ var init_collector_config = __esm({
4462
4695
  // src/collector-github.ts
4463
4696
  import { spawn as spawn3 } from "node:child_process";
4464
4697
  import { createHash as createHash5 } from "node:crypto";
4465
- function isRecord4(value) {
4698
+ function isRecord5(value) {
4466
4699
  return typeof value === "object" && value !== null && !Array.isArray(value);
4467
4700
  }
4468
4701
  function requireString(value, label) {
@@ -4501,7 +4734,7 @@ function parsePullRequestNumberList(raw, label) {
4501
4734
  }
4502
4735
  const numbers = [];
4503
4736
  for (const item of raw) {
4504
- if (!isRecord4(item)) {
4737
+ if (!isRecord5(item)) {
4505
4738
  throw new Error(`GitHub ${label} payload contains a non-object pull request entry`);
4506
4739
  }
4507
4740
  try {
@@ -4569,7 +4802,7 @@ async function listPullRequestNumbersByTicket(runner, input) {
4569
4802
  });
4570
4803
  }
4571
4804
  const issueRaw = parseJson(issueResponse.bodyText, issuePath);
4572
- if (!isRecord4(issueRaw)) {
4805
+ if (!isRecord5(issueRaw)) {
4573
4806
  throw new Error(`GitHub ${issuePath} payload is not an object`);
4574
4807
  }
4575
4808
  if (Object.hasOwn(issueRaw, "pull_request")) {
@@ -4628,7 +4861,7 @@ async function listPullRequestNumbersByTicket(runner, input) {
4628
4861
  } catch (error) {
4629
4862
  throw new Error("GitHub GraphQL issue\u2192PR returned malformed JSON", { cause: error });
4630
4863
  }
4631
- if (!isRecord4(payload)) {
4864
+ if (!isRecord5(payload)) {
4632
4865
  throw new Error("GitHub GraphQL issue\u2192PR payload is not an object");
4633
4866
  }
4634
4867
  if (payload.errors !== void 0) {
@@ -4637,30 +4870,30 @@ async function listPullRequestNumbersByTicket(runner, input) {
4637
4870
  });
4638
4871
  }
4639
4872
  const data = payload.data;
4640
- if (!isRecord4(data)) return [];
4873
+ if (!isRecord5(data)) return [];
4641
4874
  const repository = data["repository"];
4642
- if (!isRecord4(repository)) return [];
4875
+ if (!isRecord5(repository)) return [];
4643
4876
  const issue = repository["issue"];
4644
- if (!isRecord4(issue)) return [];
4877
+ if (!isRecord5(issue)) return [];
4645
4878
  const numbers = [];
4646
4879
  const closedBy = issue["closedByPullRequestsReferences"];
4647
- if (isRecord4(closedBy) && Array.isArray(closedBy["nodes"])) {
4880
+ if (isRecord5(closedBy) && Array.isArray(closedBy["nodes"])) {
4648
4881
  for (const node of closedBy["nodes"]) {
4649
- if (isRecord4(node) && typeof node["number"] === "number") {
4882
+ if (isRecord5(node) && typeof node["number"] === "number") {
4650
4883
  numbers.push(parseCollectorPrNumber(node["number"]));
4651
4884
  }
4652
4885
  }
4653
4886
  }
4654
4887
  const timeline = issue["timelineItems"];
4655
- if (isRecord4(timeline) && Array.isArray(timeline["nodes"])) {
4888
+ if (isRecord5(timeline) && Array.isArray(timeline["nodes"])) {
4656
4889
  for (const node of timeline["nodes"]) {
4657
- if (!isRecord4(node)) continue;
4890
+ if (!isRecord5(node)) continue;
4658
4891
  const source = node["source"];
4659
- if (isRecord4(source) && typeof source["number"] === "number") {
4892
+ if (isRecord5(source) && typeof source["number"] === "number") {
4660
4893
  numbers.push(parseCollectorPrNumber(source["number"]));
4661
4894
  }
4662
4895
  const subject = node["subject"];
4663
- if (isRecord4(subject) && typeof subject["number"] === "number") {
4896
+ if (isRecord5(subject) && typeof subject["number"] === "number") {
4664
4897
  numbers.push(parseCollectorPrNumber(subject["number"]));
4665
4898
  }
4666
4899
  }
@@ -4675,25 +4908,25 @@ function commentFailureCause(error) {
4675
4908
  };
4676
4909
  }
4677
4910
  function requireUserLogin(raw) {
4678
- if (!isRecord4(raw) || typeof raw["login"] !== "string") {
4911
+ if (!isRecord5(raw) || typeof raw["login"] !== "string") {
4679
4912
  throw new Error("GitHub payload missing user.login");
4680
4913
  }
4681
4914
  return raw["login"];
4682
4915
  }
4683
4916
  function optionalUserLogin(raw) {
4684
4917
  if (raw === null) return null;
4685
- if (!isRecord4(raw) || typeof raw["login"] !== "string") {
4918
+ if (!isRecord5(raw) || typeof raw["login"] !== "string") {
4686
4919
  throw new Error("GitHub payload missing user.login");
4687
4920
  }
4688
4921
  return raw["login"];
4689
4922
  }
4690
4923
  function machineIdentity(raw) {
4691
4924
  const user = raw["user"];
4692
- if (!isRecord4(user) || typeof user["type"] !== "string" || typeof user["id"] !== "number") {
4925
+ if (!isRecord5(user) || typeof user["type"] !== "string" || typeof user["id"] !== "number") {
4693
4926
  return null;
4694
4927
  }
4695
4928
  const app = raw["performed_via_github_app"];
4696
- const appId = isRecord4(app) && typeof app["id"] === "number" ? app["id"] : void 0;
4929
+ const appId = isRecord5(app) && typeof app["id"] === "number" ? app["id"] : void 0;
4697
4930
  return {
4698
4931
  userType: user["type"],
4699
4932
  userId: user["id"],
@@ -4701,9 +4934,9 @@ function machineIdentity(raw) {
4701
4934
  };
4702
4935
  }
4703
4936
  function normalizePullRequest(raw) {
4704
- if (!isRecord4(raw)) throw new Error("GitHub pull request payload must be an object");
4937
+ if (!isRecord5(raw)) throw new Error("GitHub pull request payload must be an object");
4705
4938
  const head = raw["head"];
4706
- if (!isRecord4(head) || typeof head["sha"] !== "string" || head["sha"].length === 0) {
4939
+ if (!isRecord5(head) || typeof head["sha"] !== "string" || head["sha"].length === 0) {
4707
4940
  throw new Error("GitHub pull request payload missing head.sha");
4708
4941
  }
4709
4942
  const number = requireNumber(raw["number"], "number");
@@ -4722,7 +4955,7 @@ function normalizePullRequest(raw) {
4722
4955
  };
4723
4956
  }
4724
4957
  function normalizePullRequestReaction(raw) {
4725
- if (!isRecord4(raw)) throw new Error("GitHub reaction payload must be an object");
4958
+ if (!isRecord5(raw)) throw new Error("GitHub reaction payload must be an object");
4726
4959
  return {
4727
4960
  id: requireNumber(raw["id"], "reaction.id"),
4728
4961
  userLogin: optionalUserLogin(raw["user"]),
@@ -4733,7 +4966,7 @@ function normalizePullRequestReaction(raw) {
4733
4966
  };
4734
4967
  }
4735
4968
  function normalizeReview(raw) {
4736
- if (!isRecord4(raw)) throw new Error("GitHub review payload must be an object");
4969
+ if (!isRecord5(raw)) throw new Error("GitHub review payload must be an object");
4737
4970
  return {
4738
4971
  id: requireNumber(raw["id"], "review.id"),
4739
4972
  ...typeof raw["node_id"] === "string" ? { nodeId: raw["node_id"] } : {},
@@ -4748,7 +4981,7 @@ function normalizeReview(raw) {
4748
4981
  };
4749
4982
  }
4750
4983
  function normalizeIssueComment(raw) {
4751
- if (!isRecord4(raw)) throw new Error("GitHub issue comment payload must be an object");
4984
+ if (!isRecord5(raw)) throw new Error("GitHub issue comment payload must be an object");
4752
4985
  return {
4753
4986
  id: requireNumber(raw["id"], "comment.id"),
4754
4987
  userLogin: optionalUserLogin(raw["user"]),
@@ -4761,7 +4994,7 @@ function normalizeIssueComment(raw) {
4761
4994
  };
4762
4995
  }
4763
4996
  function normalizeReviewComment(raw) {
4764
- if (!isRecord4(raw)) throw new Error("GitHub review comment payload must be an object");
4997
+ if (!isRecord5(raw)) throw new Error("GitHub review comment payload must be an object");
4765
4998
  return {
4766
4999
  id: requireNumber(raw["id"], "review_comment.id"),
4767
5000
  pullRequestReviewId: typeof raw["pull_request_review_id"] === "number" ? raw["pull_request_review_id"] : null,
@@ -5020,11 +5253,11 @@ function createGhCollectorGitHubTransport(runner = createGhApiRunner()) {
5020
5253
  if (input.signal?.aborted) {
5021
5254
  throw error;
5022
5255
  }
5023
- if (isRecord4(error) && error["ambiguousGhFailure"] === true) {
5256
+ if (isRecord5(error) && error["ambiguousGhFailure"] === true) {
5024
5257
  const cause = commentFailureCause(error);
5025
5258
  return { kind: "ambiguous_loss", diagnostics: cause.message, cause };
5026
5259
  }
5027
- if (isRecord4(error) && error["name"] === "AbortError") {
5260
+ if (isRecord5(error) && error["name"] === "AbortError") {
5028
5261
  throw error;
5029
5262
  }
5030
5263
  throw error;
@@ -5266,7 +5499,7 @@ var init_git_object_id = __esm({
5266
5499
 
5267
5500
  // src/merger-git-state.ts
5268
5501
  import { execFile as execFile2 } from "node:child_process";
5269
- import { access as access2, readFile as readFile7 } from "node:fs/promises";
5502
+ import { access as access2, readFile as readFile8 } from "node:fs/promises";
5270
5503
  import { constants as fsConstants } from "node:fs";
5271
5504
  import { isAbsolute as isAbsolute4, resolve as resolve7 } from "node:path";
5272
5505
  import { promisify as promisify2 } from "node:util";
@@ -5336,7 +5569,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
5336
5569
  const mergeHeadPath = isAbsolute4(mergeHeadReported) ? mergeHeadReported : resolve7(repositoryRoot, mergeHeadReported);
5337
5570
  let sourceObjectId = "";
5338
5571
  if (await pathExists(mergeHeadPath)) {
5339
- const raw = exactUtf8(await readFile7(mergeHeadPath), "Git MERGE_HEAD");
5572
+ const raw = exactUtf8(await readFile8(mergeHeadPath), "Git MERGE_HEAD");
5340
5573
  const mergeHeads = raw.trim().split(/\r?\n/).map((row) => row.trim()).filter(Boolean);
5341
5574
  if (mergeHeads.length === 0) throw new Error("Git MERGE_HEAD is empty");
5342
5575
  if (mergeHeads.length !== 1) throw new Error("Assigned repository does not have one ordinary in-progress merge");
@@ -5388,10 +5621,10 @@ var init_uuidv7 = __esm({
5388
5621
  });
5389
5622
 
5390
5623
  // src/typed-provider-http.ts
5391
- import { readFile as readFile8, unlink, writeFile as writeFile3 } from "node:fs/promises";
5392
- import { join as join14 } from "node:path";
5624
+ import { readFile as readFile9, unlink, writeFile as writeFile3 } from "node:fs/promises";
5625
+ import { join as join15 } from "node:path";
5393
5626
  function typedProviderHttpPath(runDirectory) {
5394
- return join14(runDirectory, TYPED_HTTP_FILE);
5627
+ return join15(runDirectory, TYPED_HTTP_FILE);
5395
5628
  }
5396
5629
  async function clearTypedProviderHttpObservation(runDirectory) {
5397
5630
  try {
@@ -5422,7 +5655,7 @@ async function recordTypedProviderHttpStatus(runDirectory, observation) {
5422
5655
  async function readLatestTypedProviderHttpObservation(runDirectory) {
5423
5656
  let text;
5424
5657
  try {
5425
- text = await readFile8(typedProviderHttpPath(runDirectory), "utf8");
5658
+ text = await readFile9(typedProviderHttpPath(runDirectory), "utf8");
5426
5659
  } catch (error) {
5427
5660
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
5428
5661
  return void 0;
@@ -5501,8 +5734,8 @@ __export(run_lifecycle_exports, {
5501
5734
  selectResumeContinuationPrompt: () => selectResumeContinuationPrompt,
5502
5735
  writeRoleRunState: () => writeRoleRunState
5503
5736
  });
5504
- import { chmod, lstat as lstat2, open, readdir as readdir4, readFile as readFile9, unlink as unlink2, writeFile as writeFile4 } from "node:fs/promises";
5505
- import { basename as basename4, join as join15 } from "node:path";
5737
+ import { chmod, lstat as lstat2, open, readdir as readdir5, readFile as readFile10, unlink as unlink2, writeFile as writeFile4 } from "node:fs/promises";
5738
+ import { basename as basename5, join as join16 } from "node:path";
5506
5739
  function selectResumeContinuationPrompt(message, engineMaterial) {
5507
5740
  const lines = message !== void 0 ? [message] : [];
5508
5741
  return appendEngineSessionMaterial(lines, engineMaterial).join("\n");
@@ -5541,7 +5774,7 @@ function renderResumeCommand(runId) {
5541
5774
  async function writeRoleRunState(runDirectory, record4) {
5542
5775
  const payload = { ...record4, runDirectory };
5543
5776
  await writeFile4(
5544
- join15(runDirectory, RUN_STATE_FILE),
5777
+ join16(runDirectory, RUN_STATE_FILE),
5545
5778
  `${JSON.stringify(payload, null, 2)}
5546
5779
  `,
5547
5780
  "utf8"
@@ -5591,7 +5824,7 @@ function parseCurrentCourtState(raw) {
5591
5824
  async function readRoleRunStateDisk(runDirectory) {
5592
5825
  let raw;
5593
5826
  try {
5594
- raw = JSON.parse(await readFile9(join15(runDirectory, RUN_STATE_FILE), "utf8"));
5827
+ raw = JSON.parse(await readFile10(join16(runDirectory, RUN_STATE_FILE), "utf8"));
5595
5828
  } catch (error) {
5596
5829
  if (errorCodeOf2(error) === "ENOENT") return void 0;
5597
5830
  throw error;
@@ -5659,7 +5892,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
5659
5892
  ...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
5660
5893
  };
5661
5894
  await writeFile4(
5662
- join15(runDirectory, RUN_STATE_FILE),
5895
+ join16(runDirectory, RUN_STATE_FILE),
5663
5896
  `${JSON.stringify(payload, null, 2)}
5664
5897
  `,
5665
5898
  "utf8"
@@ -5831,7 +6064,7 @@ function isProcessAlive(pid) {
5831
6064
  async function autopsyWriterLock(lockPath) {
5832
6065
  let content;
5833
6066
  try {
5834
- content = await readFile9(lockPath, "utf8");
6067
+ content = await readFile10(lockPath, "utf8");
5835
6068
  } catch (error) {
5836
6069
  if (errorCodeOf2(error) === "ENOENT") return { verdict: "absent" };
5837
6070
  return { verdict: "unknown", reason: "unreadable", readFailure: error };
@@ -5890,7 +6123,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
5890
6123
  },
5891
6124
  relocate(nextRunDirectory) {
5892
6125
  currentRunDirectory = nextRunDirectory;
5893
- currentLockPath = join15(nextRunDirectory, WRITER_LOCK_FILE);
6126
+ currentLockPath = join16(nextRunDirectory, WRITER_LOCK_FILE);
5894
6127
  },
5895
6128
  async release() {
5896
6129
  if (released) return;
@@ -5929,10 +6162,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
5929
6162
  };
5930
6163
  const reportReadFailure = (error) => {
5931
6164
  reportDiagnostic(
5932
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join15(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
6165
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join16(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
5933
6166
  );
5934
6167
  };
5935
- const lockPath = join15(runDirectory, WRITER_LOCK_FILE);
6168
+ const lockPath = join16(runDirectory, WRITER_LOCK_FILE);
5936
6169
  let lastAutopsy = { verdict: "absent" };
5937
6170
  let lastReclaimFailure;
5938
6171
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -5987,10 +6220,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
5987
6220
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
5988
6221
  if (runId.trim() === "") return void 0;
5989
6222
  const ledgerHome = resolveActivationLedgerHome(home);
5990
- const booksRoot = join15(ledgerHome, "books");
6223
+ const booksRoot = join16(ledgerHome, "books");
5991
6224
  let bookKeys;
5992
6225
  try {
5993
- bookKeys = await readdir4(booksRoot);
6226
+ bookKeys = await readdir5(booksRoot);
5994
6227
  } catch (error) {
5995
6228
  if (errorCodeOf2(error) === "ENOENT") return void 0;
5996
6229
  throw error;
@@ -6007,7 +6240,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
6007
6240
  throw error;
6008
6241
  }
6009
6242
  for (const runDirectory of runDirectories) {
6010
- const entry = basename4(runDirectory);
6243
+ const entry = basename5(runDirectory);
6011
6244
  if (onlyRole === void 0 && (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) || entry === `${runId}@${onlyRole}`) {
6012
6245
  matches.push(runDirectory);
6013
6246
  }
@@ -6028,7 +6261,7 @@ async function readRunParentPath(runDirectory) {
6028
6261
  let raw;
6029
6262
  try {
6030
6263
  raw = JSON.parse(
6031
- await readFile9(join15(runDirectory, "admitted-request.json"), "utf8")
6264
+ await readFile10(join16(runDirectory, "admitted-request.json"), "utf8")
6032
6265
  );
6033
6266
  } catch (error) {
6034
6267
  if (errorCodeOf2(error) === "ENOENT") return void 0;
@@ -6049,7 +6282,7 @@ async function readRunParentPath(runDirectory) {
6049
6282
  async function runHasFormedSessionPrincipal(runDirectory) {
6050
6283
  const disk = await readRoleRunStateDisk(runDirectory);
6051
6284
  if (disk === void 0) return false;
6052
- const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join15(disk.principalWire.sessionDirectory, "session.jsonl");
6285
+ const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join16(disk.principalWire.sessionDirectory, "session.jsonl");
6053
6286
  try {
6054
6287
  const stat2 = await lstat2(sessionFile);
6055
6288
  return stat2.isFile() && !stat2.isSymbolicLink();
@@ -6074,7 +6307,7 @@ async function findLatestRunIdForSeatTicket(input) {
6074
6307
  const suffix = `@${input.role}`;
6075
6308
  let best;
6076
6309
  for (const runDirectory of runDirectories) {
6077
- const entry = basename4(runDirectory);
6310
+ const entry = basename5(runDirectory);
6078
6311
  if (!entry.endsWith(suffix)) continue;
6079
6312
  const runId = entry.slice(0, entry.length - suffix.length);
6080
6313
  if (runId.length === 0) continue;
@@ -6197,7 +6430,7 @@ async function loadResumableRunRecord(home, runId, authority) {
6197
6430
  let sourceRun;
6198
6431
  try {
6199
6432
  const raw = JSON.parse(
6200
- await readFile9(run.admittedRequestPath, "utf8")
6433
+ await readFile10(run.admittedRequestPath, "utf8")
6201
6434
  );
6202
6435
  if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
6203
6436
  const record4 = raw;
@@ -6315,7 +6548,7 @@ async function loadResumableRunRecord(home, runId, authority) {
6315
6548
  let model;
6316
6549
  try {
6317
6550
  const invocationRaw = JSON.parse(
6318
- await readFile9(join15(run.runDirectory, "invocation.json"), "utf8")
6551
+ await readFile10(join16(run.runDirectory, "invocation.json"), "utf8")
6319
6552
  );
6320
6553
  if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
6321
6554
  const rec = invocationRaw;
@@ -6784,7 +7017,7 @@ __export(notary_source_run_exports, {
6784
7017
  loadNotarySourceRunLocator: () => loadNotarySourceRunLocator,
6785
7018
  resolveNotarySourceRunLocator: () => resolveNotarySourceRunLocator
6786
7019
  });
6787
- import { dirname as dirname8, isAbsolute as isAbsolute6, join as join16, resolve as resolve8, basename as basename5 } from "node:path";
7020
+ import { dirname as dirname9, isAbsolute as isAbsolute6, join as join17, resolve as resolve8, basename as basename6 } from "node:path";
6788
7021
  import { lstat as lstat3, realpath as realpath3 } from "node:fs/promises";
6789
7022
  function parseRunDirectoryName(name) {
6790
7023
  const match = RUN_DIR_NAME.exec(name);
@@ -6815,10 +7048,10 @@ async function requireRunDirectory(candidate, display) {
6815
7048
  `notary --source-run must be a run directory: ${display}`
6816
7049
  );
6817
7050
  }
6818
- const identity = parseRunDirectoryName(basename5(real));
7051
+ const identity = parseRunDirectoryName(basename6(real));
6819
7052
  if (identity === void 0) {
6820
7053
  throw new NotarySourceRunError(
6821
- `notary --source-run must be named <runId>@<role>: ${basename5(real)}`
7054
+ `notary --source-run must be named <runId>@<role>: ${basename6(real)}`
6822
7055
  );
6823
7056
  }
6824
7057
  return real;
@@ -6830,20 +7063,20 @@ async function resolveNotarySourceRunLocator(options) {
6830
7063
  }
6831
7064
  const ledgerHome = resolveActivationLedgerHome(options.home);
6832
7065
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
6833
- const bookRunsRoot = join16(activationBookDirectory(ledgerHome, bookKey), "runs");
7066
+ const bookRunsRoot = join17(activationBookDirectory(ledgerHome, bookKey), "runs");
6834
7067
  let candidate;
6835
7068
  const bare = parseRunDirectoryName(raw);
6836
7069
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
6837
- candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join16(bookRunsRoot, `${bare.runId}@${bare.role}`);
7070
+ candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join17(bookRunsRoot, `${bare.runId}@${bare.role}`);
6838
7071
  } else {
6839
7072
  candidate = isAbsolute6(raw) ? raw : resolve8(options.projectRoot, raw);
6840
7073
  }
6841
7074
  const real = await requireRunDirectory(candidate, raw);
6842
- const identity = parseRunDirectoryName(basename5(real));
7075
+ const identity = parseRunDirectoryName(basename6(real));
6843
7076
  const bookIdentity = physicalPathIdentity(activationBookDirectory(ledgerHome, bookKey));
6844
- const parentIdentity = physicalPathIdentity(dirname8(real));
6845
- const subjectBookIdentity = physicalPathIdentity(dirname8(dirname8(dirname8(real))));
6846
- if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename5(dirname8(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
7077
+ const parentIdentity = physicalPathIdentity(dirname9(real));
7078
+ const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
7079
+ if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename6(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
6847
7080
  throw new NotarySourceRunError(
6848
7081
  "notary --source-run must resolve to a retained run under the project machine-ledger book"
6849
7082
  );
@@ -6877,7 +7110,7 @@ async function resolveNotarySourceRunLocator(options) {
6877
7110
  }
6878
7111
  async function loadNotarySourceRunLocator(path) {
6879
7112
  const real = await requireRunDirectory(path, path);
6880
- const identity = parseRunDirectoryName(basename5(real));
7113
+ const identity = parseRunDirectoryName(basename6(real));
6881
7114
  const runState = await readRoleRunIdentity(real);
6882
7115
  if (runState === void 0) {
6883
7116
  throw new NotarySourceRunError(
@@ -8026,14 +8259,14 @@ import { existsSync as existsSync6 } from "node:fs";
8026
8259
  import {
8027
8260
  lstat as lstat4,
8028
8261
  mkdtemp as mkdtemp2,
8029
- readFile as readFile10,
8262
+ readFile as readFile11,
8030
8263
  realpath as realpath4,
8031
8264
  rename,
8032
8265
  rm as rm2,
8033
8266
  writeFile as writeFile5
8034
8267
  } from "node:fs/promises";
8035
8268
  import { tmpdir as tmpdir2 } from "node:os";
8036
- import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute7, join as join17, resolve as resolve9, sep as sep4 } from "node:path";
8269
+ import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute7, join as join18, resolve as resolve9, sep as sep4 } from "node:path";
8037
8270
  function issueAdmissionPlacement(authority, request) {
8038
8271
  const ledgerHome = resolveActivationLedgerHome(request.home);
8039
8272
  const bookKey = resolveBookKeyFromGit(request.cwd);
@@ -8087,15 +8320,15 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
8087
8320
  ...effectiveModelLedgerFields(effectiveModel)
8088
8321
  };
8089
8322
  await writeFile5(
8090
- join17(source.runDirectory, "invocation.json"),
8323
+ join18(source.runDirectory, "invocation.json"),
8091
8324
  `${JSON.stringify(identity, null, 2)}
8092
8325
  `,
8093
8326
  "utf8"
8094
8327
  );
8095
8328
  }
8096
8329
  async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
8097
- const ledgerPath = join17(runDirectory, "invocation.json");
8098
- const current = JSON.parse(await readFile10(ledgerPath, "utf8"));
8330
+ const ledgerPath = join18(runDirectory, "invocation.json");
8331
+ const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
8099
8332
  const next = { ...current };
8100
8333
  if (model !== void 0) {
8101
8334
  next.provider = model.provider;
@@ -8127,8 +8360,8 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
8127
8360
  );
8128
8361
  }
8129
8362
  async function mergeInvocationIdentityPage(runDirectory, fields) {
8130
- const ledgerPath = join17(runDirectory, "invocation.json");
8131
- const current = JSON.parse(await readFile10(ledgerPath, "utf8"));
8363
+ const ledgerPath = join18(runDirectory, "invocation.json");
8364
+ const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
8132
8365
  await writeFile5(
8133
8366
  ledgerPath,
8134
8367
  `${JSON.stringify({
@@ -8144,7 +8377,7 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath) {
8144
8377
  throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
8145
8378
  }
8146
8379
  const admittedPath = admitted.admittedRequestPath;
8147
- const current = JSON.parse(await readFile10(admittedPath, "utf8"));
8380
+ const current = JSON.parse(await readFile11(admittedPath, "utf8"));
8148
8381
  if (typeof current.sourceRunPath === "string") {
8149
8382
  if (current.sourceRunPath === sourceRunPath) return;
8150
8383
  throw new Error(
@@ -8170,7 +8403,7 @@ async function bindAdmittedTicketNumber(admitted, ticketNumber) {
8170
8403
  }
8171
8404
  async function recordAdmittedCorrelation(admitted, correlationId) {
8172
8405
  const current = JSON.parse(
8173
- await readFile10(admitted.admittedRequestPath, "utf8")
8406
+ await readFile11(admitted.admittedRequestPath, "utf8")
8174
8407
  );
8175
8408
  const prior = [
8176
8409
  ...Array.isArray(current.correlationIds) ? current.correlationIds.filter(
@@ -8218,7 +8451,7 @@ async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
8218
8451
  }
8219
8452
  const frozen = Object.freeze([...projected]);
8220
8453
  const admittedPath = admitted.admittedRequestPath;
8221
- const current = JSON.parse(await readFile10(admittedPath, "utf8"));
8454
+ const current = JSON.parse(await readFile11(admittedPath, "utf8"));
8222
8455
  await writeFile5(
8223
8456
  admittedPath,
8224
8457
  `${JSON.stringify({ ...current, courtTicketNumbers: frozen }, null, 2)}
@@ -8240,7 +8473,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
8240
8473
  runId: admitted.runId,
8241
8474
  role: admitted.role
8242
8475
  });
8243
- ensureRoleRunDirectory(ledgerHome, dirname9(target.runDirectory));
8476
+ ensureRoleRunDirectory(ledgerHome, dirname10(target.runDirectory));
8244
8477
  await rename(oldRunDirectory, target.runDirectory);
8245
8478
  heldLease?.relocate(target.runDirectory);
8246
8479
  const admittedRecord = admitted;
@@ -8278,9 +8511,9 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
8278
8511
  ticketNumber,
8279
8512
  "bindTicketNumberOnRunDirectory"
8280
8513
  );
8281
- const admittedPath = join17(runDirectory, "admitted-request.json");
8282
- const invocationPath = join17(runDirectory, "invocation.json");
8283
- const admitted = JSON.parse(await readFile10(admittedPath, "utf8"));
8514
+ const admittedPath = join18(runDirectory, "admitted-request.json");
8515
+ const invocationPath = join18(runDirectory, "invocation.json");
8516
+ const admitted = JSON.parse(await readFile11(admittedPath, "utf8"));
8284
8517
  const existing = admitted.ticketNumber;
8285
8518
  if (typeof existing === "number") {
8286
8519
  if (existing === ticketNumber) return;
@@ -8290,7 +8523,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
8290
8523
  }
8291
8524
  if (existsSync6(invocationPath)) {
8292
8525
  const invocation = JSON.parse(
8293
- await readFile10(invocationPath, "utf8")
8526
+ await readFile11(invocationPath, "utf8")
8294
8527
  );
8295
8528
  if (typeof invocation.ticketNumber === "number" && invocation.ticketNumber !== ticketNumber) {
8296
8529
  throw new Error(
@@ -8315,7 +8548,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
8315
8548
  async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
8316
8549
  const rolePackageRoot = packageRoot;
8317
8550
  const raw = JSON.parse(
8318
- await readFile10(join17(rolePackageRoot, "package.json"), "utf8")
8551
+ await readFile11(join18(rolePackageRoot, "package.json"), "utf8")
8319
8552
  );
8320
8553
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
8321
8554
  throw new Error(
@@ -8600,7 +8833,7 @@ async function readRegularFileAttachment(sourcePath) {
8600
8833
  );
8601
8834
  }
8602
8835
  try {
8603
- return { absolute, bytes: await readFile10(absolute) };
8836
+ return { absolute, bytes: await readFile11(absolute) };
8604
8837
  } catch (error) {
8605
8838
  throw new CliUsageError(
8606
8839
  `attachment is not a readable regular file: ${sourcePath}`,
@@ -8613,13 +8846,13 @@ async function removePreparedAttachmentDirectory(stagingDirectory) {
8613
8846
  }
8614
8847
  async function withPreparedAttachments(attachmentPaths, use) {
8615
8848
  if (attachmentPaths.length === 0) return await use([]);
8616
- const stagingDirectory = await mkdtemp2(join17(tmpdir2(), "ak-role-attachments-"));
8849
+ const stagingDirectory = await mkdtemp2(join18(tmpdir2(), "ak-role-attachments-"));
8617
8850
  const prepared = [];
8618
8851
  let result;
8619
8852
  try {
8620
8853
  for (let index = 0; index < attachmentPaths.length; index += 1) {
8621
8854
  const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
8622
- const snapshotPath = join17(stagingDirectory, String(index).padStart(6, "0"));
8855
+ const snapshotPath = join18(stagingDirectory, String(index).padStart(6, "0"));
8623
8856
  await writeFile5(snapshotPath, bytes);
8624
8857
  prepared.push({ absolute, snapshotPath });
8625
8858
  }
@@ -8640,9 +8873,9 @@ async function withPreparedAttachments(attachmentPaths, use) {
8640
8873
  return result;
8641
8874
  }
8642
8875
  async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
8643
- const frozenPath = join17(
8876
+ const frozenPath = join18(
8644
8877
  destinationDir,
8645
- `${String(index).padStart(2, "0")}-${basename6(provenancePath)}`
8878
+ `${String(index).padStart(2, "0")}-${basename7(provenancePath)}`
8646
8879
  );
8647
8880
  await writeFile5(frozenPath, bytes);
8648
8881
  return {
@@ -8656,7 +8889,7 @@ async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, inde
8656
8889
  async function freezePreparedAttachment(prepared, destinationDir, index) {
8657
8890
  return freezeAttachmentBytes(
8658
8891
  prepared.absolute,
8659
- await readFile10(prepared.snapshotPath),
8892
+ await readFile11(prepared.snapshotPath),
8660
8893
  destinationDir,
8661
8894
  index
8662
8895
  );
@@ -8683,14 +8916,14 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
8683
8916
  async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
8684
8917
  if (attachmentPaths.length === 0) return [];
8685
8918
  const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
8686
- const attachmentsDirectory = join17(runDirectory, "attachments", summonsKey);
8919
+ const attachmentsDirectory = join18(runDirectory, "attachments", summonsKey);
8687
8920
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
8688
8921
  return freezeAttachments(attachmentPaths, attachmentsDirectory);
8689
8922
  }
8690
8923
  async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
8691
8924
  if (prepared.length === 0) return [];
8692
8925
  const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
8693
- const attachmentsDirectory = summonsKey === void 0 ? join17(runDirectory, "attachments") : join17(runDirectory, "attachments", summonsKey);
8926
+ const attachmentsDirectory = summonsKey === void 0 ? join18(runDirectory, "attachments") : join18(runDirectory, "attachments", summonsKey);
8694
8927
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
8695
8928
  const attachments = [];
8696
8929
  for (let index = 0; index < prepared.length; index += 1) {
@@ -8752,7 +8985,7 @@ async function admitStandardMaterialInvocation(role, options) {
8752
8985
  })),
8753
8986
  ...ticketFields
8754
8987
  };
8755
- const admittedRequestPath = join17(runDirectory, "admitted-request.json");
8988
+ const admittedRequestPath = join18(runDirectory, "admitted-request.json");
8756
8989
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
8757
8990
  sessionDirectory,
8758
8991
  sessionFile
@@ -8861,7 +9094,7 @@ async function admitCountersignInvocation(options) {
8861
9094
  mediaKind: a.mediaKind
8862
9095
  }))
8863
9096
  };
8864
- const admittedRequestPath = join17(runDirectory, "admitted-request.json");
9097
+ const admittedRequestPath = join18(runDirectory, "admitted-request.json");
8865
9098
  if (options.deferPersistence !== true) {
8866
9099
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
8867
9100
  sessionDirectory,
@@ -8912,7 +9145,7 @@ function buildCountersignTransportPrompt(admitted, engineMaterial) {
8912
9145
  async function loadAdmittedJudgeRequest(runDirectory) {
8913
9146
  try {
8914
9147
  const raw = JSON.parse(
8915
- await readFile10(join17(runDirectory, "admitted-request.json"), "utf8")
9148
+ await readFile11(join18(runDirectory, "admitted-request.json"), "utf8")
8916
9149
  );
8917
9150
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
8918
9151
  const record4 = raw;
@@ -8967,7 +9200,7 @@ async function admitCoderInvocation(options) {
8967
9200
  home: options.home
8968
9201
  });
8969
9202
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
8970
- const taskPath = join17(runDirectory, "task.md");
9203
+ const taskPath = join18(runDirectory, "task.md");
8971
9204
  await writeFile5(taskPath, instruction, "utf8");
8972
9205
  const admitted = {
8973
9206
  role: "coder",
@@ -8988,7 +9221,7 @@ async function admitCoderInvocation(options) {
8988
9221
  mediaKind: a.mediaKind
8989
9222
  }))
8990
9223
  };
8991
- const admittedRequestPath = join17(runDirectory, "admitted-request.json");
9224
+ const admittedRequestPath = join18(runDirectory, "admitted-request.json");
8992
9225
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
8993
9226
  sessionDirectory,
8994
9227
  sessionFile
@@ -9038,7 +9271,7 @@ async function admitFixerInvocation(options) {
9038
9271
  if (options.prerequisitesPath !== void 0) {
9039
9272
  const absolutePrereq = isAbsolute7(options.prerequisitesPath) ? options.prerequisitesPath : resolve9(options.prerequisitesPath);
9040
9273
  try {
9041
- prerequisitesSource = await readFile10(absolutePrereq, "utf8");
9274
+ prerequisitesSource = await readFile11(absolutePrereq, "utf8");
9042
9275
  } catch (error) {
9043
9276
  throw new CliUsageError(
9044
9277
  `fixer prerequisites path is unreadable: ${options.prerequisitesPath}`,
@@ -9074,7 +9307,7 @@ async function admitFixerInvocation(options) {
9074
9307
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
9075
9308
  let prerequisitesPath;
9076
9309
  if (prerequisitesSource !== void 0) {
9077
- prerequisitesPath = join17(runDirectory, "prerequisites.json");
9310
+ prerequisitesPath = join18(runDirectory, "prerequisites.json");
9078
9311
  await writeFile5(
9079
9312
  prerequisitesPath,
9080
9313
  `${JSON.stringify(prerequisites, null, 2)}
@@ -9082,7 +9315,7 @@ async function admitFixerInvocation(options) {
9082
9315
  "utf8"
9083
9316
  );
9084
9317
  }
9085
- const packetPath = join17(runDirectory, "fix-packet.md");
9318
+ const packetPath = join18(runDirectory, "fix-packet.md");
9086
9319
  await writeFile5(packetPath, instruction, "utf8");
9087
9320
  const admitted = {
9088
9321
  role: "fixer",
@@ -9108,7 +9341,7 @@ async function admitFixerInvocation(options) {
9108
9341
  mediaKind: a.mediaKind
9109
9342
  }))
9110
9343
  };
9111
- const admittedRequestPath = join17(runDirectory, "admitted-request.json");
9344
+ const admittedRequestPath = join18(runDirectory, "admitted-request.json");
9112
9345
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
9113
9346
  sessionDirectory,
9114
9347
  sessionFile
@@ -9328,7 +9561,7 @@ async function admitCollectorInvocation(options) {
9328
9561
  const prNumber = target.kind === "bound" ? target.prNumber : void 0;
9329
9562
  let requestManifestPath;
9330
9563
  if (manifestCanonicalJson !== void 0) {
9331
- requestManifestPath = join17(runDirectory, "request-manifest.json");
9564
+ requestManifestPath = join18(runDirectory, "request-manifest.json");
9332
9565
  await writeFile5(requestManifestPath, manifestCanonicalJson, "utf8");
9333
9566
  }
9334
9567
  const admitted = {
@@ -9354,7 +9587,7 @@ async function admitCollectorInvocation(options) {
9354
9587
  mediaKind: a.mediaKind
9355
9588
  }))
9356
9589
  };
9357
- const admittedRequestPath = join17(runDirectory, "admitted-request.json");
9590
+ const admittedRequestPath = join18(runDirectory, "admitted-request.json");
9358
9591
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
9359
9592
  sessionDirectory,
9360
9593
  sessionFile
@@ -9452,7 +9685,7 @@ function parseDoctorArgv(args) {
9452
9685
  }
9453
9686
  async function resolveDoctorCaseRunsPath(options) {
9454
9687
  const ledgerHome = resolveActivationLedgerHome(options.home);
9455
- const defaultRuns = join17(
9688
+ const defaultRuns = join18(
9456
9689
  activationBookDirectory(ledgerHome, options.bookKey),
9457
9690
  String(options.issueNumber),
9458
9691
  "runs"
@@ -9583,7 +9816,7 @@ async function admitDoctorInvocation(options) {
9583
9816
  mediaKind: a.mediaKind
9584
9817
  }))
9585
9818
  };
9586
- const admittedRequestPath = join17(runDirectory, "admitted-request.json");
9819
+ const admittedRequestPath = join18(runDirectory, "admitted-request.json");
9587
9820
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
9588
9821
  sessionDirectory,
9589
9822
  sessionFile
@@ -9715,7 +9948,7 @@ async function admitNotaryInvocation(options) {
9715
9948
  ...ticketFields,
9716
9949
  ...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
9717
9950
  };
9718
- const admittedRequestPath = join17(runDirectory, "admitted-request.json");
9951
+ const admittedRequestPath = join18(runDirectory, "admitted-request.json");
9719
9952
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
9720
9953
  sessionDirectory,
9721
9954
  sessionFile
@@ -9818,7 +10051,7 @@ async function admitGleanerLeftInvocation(options) {
9818
10051
  attachments: [],
9819
10052
  ...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
9820
10053
  };
9821
- const admittedRequestPath = join17(runDirectory, "admitted-request.json");
10054
+ const admittedRequestPath = join18(runDirectory, "admitted-request.json");
9822
10055
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
9823
10056
  sessionDirectory,
9824
10057
  sessionFile
@@ -9957,7 +10190,7 @@ async function admitReviewerInvocation(options) {
9957
10190
  mediaKind: a.mediaKind
9958
10191
  }))
9959
10192
  };
9960
- const admittedRequestPath = join17(runDirectory, "admitted-request.json");
10193
+ const admittedRequestPath = join18(runDirectory, "admitted-request.json");
9961
10194
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
9962
10195
  sessionDirectory,
9963
10196
  sessionFile
@@ -10109,7 +10342,7 @@ async function admitMergerInvocation(options) {
10109
10342
  resolutionScope: [...derived.resolutionScope],
10110
10343
  authorizedChecks: []
10111
10344
  });
10112
- const mergerInputPath = join17(runDirectory, "merger-input.json");
10345
+ const mergerInputPath = join18(runDirectory, "merger-input.json");
10113
10346
  await writeFile5(
10114
10347
  mergerInputPath,
10115
10348
  `${JSON.stringify(mergerInput, null, 2)}
@@ -10140,7 +10373,7 @@ async function admitMergerInvocation(options) {
10140
10373
  mediaKind: a.mediaKind
10141
10374
  }))
10142
10375
  };
10143
- const admittedRequestPath = join17(runDirectory, "admitted-request.json");
10376
+ const admittedRequestPath = join18(runDirectory, "admitted-request.json");
10144
10377
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
10145
10378
  sessionDirectory,
10146
10379
  sessionFile
@@ -10424,15 +10657,15 @@ var init_invocation = __esm({
10424
10657
 
10425
10658
  // src/public-cli/load-production-acp-host.ts
10426
10659
  import { existsSync as existsSync7 } from "node:fs";
10427
- import { join as join18 } from "node:path";
10660
+ import { join as join19 } from "node:path";
10428
10661
  import { pathToFileURL } from "node:url";
10429
10662
  async function loadProductionAcpHostFactory(packageRoot, host) {
10430
10663
  const description = lookupHostDescription(host);
10431
10664
  if (description === void 0) {
10432
10665
  throw new Error(`unregistered host: ${host}`);
10433
10666
  }
10434
- const built = join18(packageRoot, "dist/acp-host/production-host.js");
10435
- const source = join18(packageRoot, "src/acp-host/production-host.ts");
10667
+ const built = join19(packageRoot, "dist/acp-host/production-host.js");
10668
+ const source = join19(packageRoot, "src/acp-host/production-host.ts");
10436
10669
  const target = existsSync7(built) ? built : source;
10437
10670
  const href = pathToFileURL(target).href;
10438
10671
  const mod = await import(href);
@@ -10448,15 +10681,15 @@ var init_load_production_acp_host = __esm({
10448
10681
 
10449
10682
  // src/public-cli/load-production-headless-host.ts
10450
10683
  import { existsSync as existsSync8 } from "node:fs";
10451
- import { join as join19 } from "node:path";
10684
+ import { join as join20 } from "node:path";
10452
10685
  import { pathToFileURL as pathToFileURL2 } from "node:url";
10453
10686
  async function loadProductionHeadlessHostFactory(packageRoot, host) {
10454
10687
  const description = lookupHeadlessHostDescription(host);
10455
10688
  if (description === void 0) {
10456
10689
  throw new Error(`unregistered headless host: ${host}`);
10457
10690
  }
10458
- const built = join19(packageRoot, "dist/headless-host/production-host.js");
10459
- const source = join19(packageRoot, "src/headless-host/production-host.ts");
10691
+ const built = join20(packageRoot, "dist/headless-host/production-host.js");
10692
+ const source = join20(packageRoot, "src/headless-host/production-host.ts");
10460
10693
  const target = existsSync8(built) ? built : source;
10461
10694
  const href = pathToFileURL2(target).href;
10462
10695
  const mod = await import(href);
@@ -10705,8 +10938,8 @@ __export(config_exports, {
10705
10938
  setPersistentSeatHost: () => setPersistentSeatHost,
10706
10939
  validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
10707
10940
  });
10708
- import { mkdir, readFile as readFile11, writeFile as writeFile6 } from "node:fs/promises";
10709
- import { dirname as dirname10, join as join20 } from "node:path";
10941
+ import { mkdir, readFile as readFile12, writeFile as writeFile6 } from "node:fs/promises";
10942
+ import { dirname as dirname11, join as join21 } from "node:path";
10710
10943
  function isGateOfficerSeat(value) {
10711
10944
  return GATE_OFFICER_SEATS.includes(value);
10712
10945
  }
@@ -10714,12 +10947,12 @@ function publicCliConfigPath(home) {
10714
10947
  if (typeof home !== "string" || home.trim() === "") {
10715
10948
  throw new Error("home must be explicitly provided");
10716
10949
  }
10717
- return join20(home, ".ak-roles", "public-cli.json");
10950
+ return join21(home, ".ak-roles", "public-cli.json");
10718
10951
  }
10719
10952
  async function loadPublicCliConfig(home) {
10720
10953
  const path = publicCliConfigPath(home);
10721
10954
  try {
10722
- const raw = await readFile11(path, "utf8");
10955
+ const raw = await readFile12(path, "utf8");
10723
10956
  return parsePublicCliConfig(JSON.parse(raw));
10724
10957
  } catch (error) {
10725
10958
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
@@ -10730,7 +10963,7 @@ async function loadPublicCliConfig(home) {
10730
10963
  }
10731
10964
  async function savePublicCliConfig(config, home) {
10732
10965
  const path = publicCliConfigPath(home);
10733
- await mkdir(dirname10(path), { recursive: true });
10966
+ await mkdir(dirname11(path), { recursive: true });
10734
10967
  const normalized = parsePublicCliConfig(config);
10735
10968
  await writeFile6(
10736
10969
  path,
@@ -11177,7 +11410,7 @@ function credentialProvidersFromAuthData(data) {
11177
11410
  }
11178
11411
  async function loadCredentialProviders(agentDir) {
11179
11412
  try {
11180
- const raw = await readFile11(join20(agentDir, "auth.json"), "utf8");
11413
+ const raw = await readFile12(join21(agentDir, "auth.json"), "utf8");
11181
11414
  return credentialProvidersFromAuthData(JSON.parse(raw));
11182
11415
  } catch (error) {
11183
11416
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
@@ -11216,15 +11449,15 @@ __export(host_providers_exports, {
11216
11449
  renderHostProvidersTable: () => renderHostProvidersTable
11217
11450
  });
11218
11451
  import { readFileSync as readFileSync3 } from "node:fs";
11219
- import { join as join21 } from "node:path";
11452
+ import { join as join22 } from "node:path";
11220
11453
  function hostProvidersPath(home) {
11221
11454
  if (typeof home !== "string" || home.trim() === "") {
11222
11455
  throw new Error("home must be explicitly provided");
11223
11456
  }
11224
- return join21(home, ".ak-roles", "host-providers.json");
11457
+ return join22(home, ".ak-roles", "host-providers.json");
11225
11458
  }
11226
11459
  function hermesProviderModelsCachePath(home) {
11227
- return join21(home, ".hermes", "provider_models_cache.json");
11460
+ return join22(home, ".hermes", "provider_models_cache.json");
11228
11461
  }
11229
11462
  function parseHostProvidersTable(value) {
11230
11463
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
@@ -11379,12 +11612,12 @@ var init_host_providers = __esm({
11379
11612
  });
11380
11613
 
11381
11614
  // src/ledger-session-read.ts
11382
- import { readFile as readFile12 } from "node:fs/promises";
11383
- function isRecord5(value) {
11615
+ import { readFile as readFile13 } from "node:fs/promises";
11616
+ function isRecord6(value) {
11384
11617
  return typeof value === "object" && value !== null && !Array.isArray(value);
11385
11618
  }
11386
11619
  async function readLedgerSessionJsonlLines(path) {
11387
- const text = await readFile12(path, "utf8");
11620
+ const text = await readFile13(path, "utf8");
11388
11621
  const lines = text.split("\n");
11389
11622
  const out = [];
11390
11623
  for (let index = 0; index < lines.length; index += 1) {
@@ -11405,7 +11638,7 @@ async function readLedgerSessionJsonlLines(path) {
11405
11638
  });
11406
11639
  continue;
11407
11640
  }
11408
- if (!isRecord5(row)) {
11641
+ if (!isRecord6(row)) {
11409
11642
  const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
11410
11643
  out.push({
11411
11644
  line: lineNumber,
@@ -11482,9 +11715,9 @@ var init_ledger_session_read = __esm({
11482
11715
  });
11483
11716
 
11484
11717
  // src/analyst-gate-cycles-read.ts
11485
- import { readdir as readdir5 } from "node:fs/promises";
11486
- import { join as join22 } from "node:path";
11487
- function isRecord6(value) {
11718
+ import { readdir as readdir6 } from "node:fs/promises";
11719
+ import { join as join23 } from "node:path";
11720
+ function isRecord7(value) {
11488
11721
  return typeof value === "object" && value !== null && !Array.isArray(value);
11489
11722
  }
11490
11723
  function isParentAttemptBindingRow(row) {
@@ -11514,7 +11747,7 @@ function isGateTerminatingToolName(toolName) {
11514
11747
  function acceptedGateReceiptIds(rows) {
11515
11748
  const accepted = /* @__PURE__ */ new Set();
11516
11749
  for (const row of rows) {
11517
- const message = isRecord6(row.message) ? row.message : void 0;
11750
+ const message = isRecord7(row.message) ? row.message : void 0;
11518
11751
  if (message?.role !== "toolResult") continue;
11519
11752
  if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
11520
11753
  if (message.isError === false) accepted.add(message.toolCallId);
@@ -11549,7 +11782,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
11549
11782
  for (let i = beforeIndex - 1; i >= 0; i -= 1) {
11550
11783
  const row = rows[i];
11551
11784
  if (!isParentAttemptBindingRow(row)) continue;
11552
- if (!isRecord6(row.data) || !isRecord6(row.data.parent)) continue;
11785
+ if (!isRecord7(row.data) || !isRecord7(row.data.parent)) continue;
11553
11786
  const id = row.data.parent.attemptEntryId;
11554
11787
  const sessionFile = row.data.parent.sessionFile;
11555
11788
  return {
@@ -11564,10 +11797,10 @@ function extractAllAcceptedGateToolCalls(rows) {
11564
11797
  const out = [];
11565
11798
  for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
11566
11799
  const row = rows[rowIndex];
11567
- const message = isRecord6(row.message) ? row.message : void 0;
11800
+ const message = isRecord7(row.message) ? row.message : void 0;
11568
11801
  if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
11569
11802
  for (const part of message.content) {
11570
- if (!isRecord6(part) || part.type !== "toolCall") continue;
11803
+ if (!isRecord7(part) || part.type !== "toolCall") continue;
11571
11804
  if (typeof part.id !== "string" || part.id.length === 0) continue;
11572
11805
  if (typeof part.name !== "string" || part.name.length === 0) continue;
11573
11806
  if (!isGateTerminatingToolName(part.name)) continue;
@@ -11575,7 +11808,7 @@ function extractAllAcceptedGateToolCalls(rows) {
11575
11808
  const binding = nearestAttemptBindingBefore(rows, rowIndex);
11576
11809
  out.push({
11577
11810
  toolName: part.name,
11578
- args: isRecord6(part.arguments) ? part.arguments : void 0,
11811
+ args: isRecord7(part.arguments) ? part.arguments : void 0,
11579
11812
  accepted: true,
11580
11813
  rowIndex,
11581
11814
  ...binding
@@ -11698,17 +11931,17 @@ function pairGateRounds(volumes) {
11698
11931
  return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
11699
11932
  }
11700
11933
  async function resolveOfficerSessionFromPointerFile(pointerPath) {
11701
- const { readFile: readFile23 } = await import("node:fs/promises");
11934
+ const { readFile: readFile24 } = await import("node:fs/promises");
11702
11935
  let raw;
11703
11936
  try {
11704
- raw = JSON.parse(await readFile23(pointerPath, "utf8"));
11937
+ raw = JSON.parse(await readFile24(pointerPath, "utf8"));
11705
11938
  } catch (error) {
11706
11939
  throw new Error(
11707
11940
  `direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
11708
11941
  { cause: error }
11709
11942
  );
11710
11943
  }
11711
- if (!isRecord6(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
11944
+ if (!isRecord7(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
11712
11945
  throw new Error(`direct officer run pointer has unknown shape in ${pointerPath}`);
11713
11946
  }
11714
11947
  const sessionFile = raw.sessionFile;
@@ -11724,7 +11957,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
11724
11957
  for (const directory of directories) {
11725
11958
  let names;
11726
11959
  try {
11727
- const entries = await readdir5(directory, { withFileTypes: true });
11960
+ const entries = await readdir6(directory, { withFileTypes: true });
11728
11961
  names = entries.filter(
11729
11962
  (e) => e.isFile() && (e.name.endsWith(".jsonl") || e.name.endsWith(".pointer.json"))
11730
11963
  ).map((e) => e.name).sort();
@@ -11733,7 +11966,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
11733
11966
  throw error;
11734
11967
  }
11735
11968
  for (const name of names) {
11736
- const path = join22(directory, name);
11969
+ const path = join23(directory, name);
11737
11970
  const fromPointer = name.endsWith(".pointer.json");
11738
11971
  const sessionPath = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : path;
11739
11972
  if (sessionPath === void 0) continue;
@@ -11775,6 +12008,15 @@ var init_analyst_gate_cycles_read = __esm({
11775
12008
  });
11776
12009
 
11777
12010
  // src/audit-escalation.ts
12011
+ var audit_escalation_exports = {};
12012
+ __export(audit_escalation_exports, {
12013
+ AUDIT_ESCALATION_KIND: () => AUDIT_ESCALATION_KIND,
12014
+ buildAuditEscalationResult: () => buildAuditEscalationResult,
12015
+ disposeComplianceDecision: () => disposeComplianceDecision,
12016
+ isAuditEscalationProjection: () => isAuditEscalationProjection,
12017
+ isAuditEscalationResult: () => isAuditEscalationResult,
12018
+ projectAuditEscalation: () => projectAuditEscalation
12019
+ });
11778
12020
  function buildAuditEscalationResult(decision, deliveredOutput) {
11779
12021
  const auditOwned = {
11780
12022
  kind: AUDIT_ESCALATION_KIND
@@ -11871,21 +12113,6 @@ var init_audit_escalation = __esm({
11871
12113
  }
11872
12114
  });
11873
12115
 
11874
- // src/run-terminal-artifacts.ts
11875
- import { basename as basename7, dirname as dirname11, join as join23 } from "node:path";
11876
- function runIdFromRunDirectory(runDirectory) {
11877
- const name = basename7(runDirectory);
11878
- const at = name.lastIndexOf("@");
11879
- if (at <= 0 || at === name.length - 1) return void 0;
11880
- return name.slice(0, at);
11881
- }
11882
- var init_run_terminal_artifacts = __esm({
11883
- "src/run-terminal-artifacts.ts"() {
11884
- "use strict";
11885
- init_role_run_placement();
11886
- }
11887
- });
11888
-
11889
12116
  // src/submission-ledger.ts
11890
12117
  import { join as join24 } from "node:path";
11891
12118
  function runIdentity(context) {
@@ -12309,7 +12536,7 @@ var init_submission_ledger = __esm({
12309
12536
 
12310
12537
  // src/session-opening-materials.ts
12311
12538
  import { existsSync as existsSync9 } from "node:fs";
12312
- import { readFile as readFile13 } from "node:fs/promises";
12539
+ import { readFile as readFile14 } from "node:fs/promises";
12313
12540
  import { dirname as dirname12, join as join25 } from "node:path";
12314
12541
  import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
12315
12542
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
@@ -12325,7 +12552,7 @@ function resolvePackageRootDir(moduleUrl = import.meta.url) {
12325
12552
  return fileURLToPath(new URL("..", moduleUrl));
12326
12553
  }
12327
12554
  async function readPackageMaterial(relativePath) {
12328
- return readFile13(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
12555
+ return readFile14(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
12329
12556
  }
12330
12557
  async function joinPackageMaterials(relativePaths) {
12331
12558
  const chunks = [];
@@ -12471,13 +12698,13 @@ function resolveAuditDossier(source) {
12471
12698
  }
12472
12699
  return { status: "ok", runDirectory };
12473
12700
  }
12474
- function isRecord7(value) {
12701
+ function isRecord8(value) {
12475
12702
  return typeof value === "object" && value !== null && !Array.isArray(value);
12476
12703
  }
12477
12704
  function readDoctorAuditSubjects(context) {
12478
12705
  const entries = context.sessionManager.getEntries?.() ?? [];
12479
12706
  for (const entry of entries) {
12480
- if (isRecord7(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
12707
+ if (isRecord8(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
12481
12708
  return { status: "ok" };
12482
12709
  }
12483
12710
  }
@@ -13818,11 +14045,11 @@ function reportEngineDetourCall(input) {
13818
14045
  recordPointer: pointer
13819
14046
  };
13820
14047
  }
13821
- function isRecord8(value) {
14048
+ function isRecord9(value) {
13822
14049
  return typeof value === "object" && value !== null && !Array.isArray(value);
13823
14050
  }
13824
14051
  function callFactFromSitianPayload(payload, pointer) {
13825
- if (!isRecord8(payload)) return void 0;
14052
+ if (!isRecord9(payload)) return void 0;
13826
14053
  if (payload.tool !== ENGINE_DETOUR_TOOL_NAME) return void 0;
13827
14054
  if (typeof payload.toolCallId !== "string" || payload.toolCallId.length === 0) {
13828
14055
  return void 0;
@@ -13839,11 +14066,11 @@ function callFactFromSitianPayload(payload, pointer) {
13839
14066
  };
13840
14067
  }
13841
14068
  function invocationScopeIdOfRecord(record4) {
13842
- if (isRecord8(record4.subject)) {
14069
+ if (isRecord9(record4.subject)) {
13843
14070
  const fromSubject = record4.subject.invocationScopeId;
13844
14071
  if (typeof fromSubject === "string" && fromSubject.length > 0) return fromSubject;
13845
14072
  }
13846
- if (isRecord8(record4.payload)) {
14073
+ if (isRecord9(record4.payload)) {
13847
14074
  const fromPayload = record4.payload.invocationScopeId;
13848
14075
  if (typeof fromPayload === "string" && fromPayload.length > 0) return fromPayload;
13849
14076
  }
@@ -13903,7 +14130,7 @@ function readInvocationRecord(runDirectory) {
13903
14130
  const raw = JSON.parse(
13904
14131
  readFileSync4(join26(runDirectory, "invocation.json"), "utf8")
13905
14132
  );
13906
- return isRecord8(raw) ? raw : void 0;
14133
+ return isRecord9(raw) ? raw : void 0;
13907
14134
  } catch (error) {
13908
14135
  if (error?.code === "ENOENT") return void 0;
13909
14136
  throw error;
@@ -13921,7 +14148,7 @@ function readInvocationSelectedHost(runDirectory) {
13921
14148
  }
13922
14149
  function withEngineDetourToolUsageFact(outcome, usage) {
13923
14150
  if (usage === void 0) return outcome;
13924
- const prior = isRecord8(outcome.decisiveFacts) ? outcome.decisiveFacts : {};
14151
+ const prior = isRecord9(outcome.decisiveFacts) ? outcome.decisiveFacts : {};
13925
14152
  return {
13926
14153
  ...outcome,
13927
14154
  decisiveFacts: {
@@ -13964,7 +14191,7 @@ var init_engine_detour_usage = __esm({
13964
14191
 
13965
14192
  // src/package-resources/method-skill.ts
13966
14193
  import { createHash as createHash7 } from "node:crypto";
13967
- import { readFile as readFile14, realpath as realpath5 } from "node:fs/promises";
14194
+ import { readFile as readFile15, realpath as realpath5 } from "node:fs/promises";
13968
14195
  import { join as join27 } from "node:path";
13969
14196
  function gitBlobOid(bytes) {
13970
14197
  const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
@@ -13987,11 +14214,11 @@ function resolvePackagedMethodSkillRoot(packageRoot, name) {
13987
14214
  function resolvePackagedMethodSkillPath(packageRoot, name) {
13988
14215
  return join27(resolvePackagedMethodSkillRoot(packageRoot, name), "SKILL.md");
13989
14216
  }
13990
- function isRecord9(value) {
14217
+ function isRecord10(value) {
13991
14218
  return typeof value === "object" && value !== null && !Array.isArray(value);
13992
14219
  }
13993
14220
  function parseProvenance(raw, expectedName) {
13994
- if (!isRecord9(raw)) {
14221
+ if (!isRecord10(raw)) {
13995
14222
  throw new Error(`Packaged method provenance must be an object for ${expectedName}`);
13996
14223
  }
13997
14224
  if (raw.name !== expectedName) {
@@ -14005,7 +14232,7 @@ function parseProvenance(raw, expectedName) {
14005
14232
  if (typeof raw.packageAdaptation !== "string" || raw.packageAdaptation.trim() === "") {
14006
14233
  throw new Error(`Packaged method provenance packageAdaptation must be nonblank`);
14007
14234
  }
14008
- if (!isRecord9(raw.upstream)) {
14235
+ if (!isRecord10(raw.upstream)) {
14009
14236
  throw new Error(`Packaged method provenance upstream must be an object`);
14010
14237
  }
14011
14238
  const upstream = raw.upstream;
@@ -14032,12 +14259,12 @@ function parseProvenance(raw, expectedName) {
14032
14259
  `Packaged method provenance upstream must include nonblank tag or version`
14033
14260
  );
14034
14261
  }
14035
- if (!isRecord9(raw.files)) {
14262
+ if (!isRecord10(raw.files)) {
14036
14263
  throw new Error(`Packaged method provenance files must be an object`);
14037
14264
  }
14038
14265
  const files = {};
14039
14266
  for (const [rel, entry] of Object.entries(raw.files)) {
14040
- if (!isRecord9(entry)) {
14267
+ if (!isRecord10(entry)) {
14041
14268
  throw new Error(`Packaged method provenance file entry must be an object: ${rel}`);
14042
14269
  }
14043
14270
  if (typeof entry.sha256 !== "string" || !SHA256_RE.test(entry.sha256)) {
@@ -14083,7 +14310,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
14083
14310
  const provenancePath = join27(rootDirectory, "provenance.json");
14084
14311
  let provenanceRaw;
14085
14312
  try {
14086
- provenanceRaw = await readFile14(provenancePath, "utf8");
14313
+ provenanceRaw = await readFile15(provenancePath, "utf8");
14087
14314
  } catch (error) {
14088
14315
  throw new PackagedMethodSkillUnavailableError(name, provenancePath, error);
14089
14316
  }
@@ -14100,7 +14327,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
14100
14327
  const absolute = join27(rootDirectory, rel);
14101
14328
  let bytes;
14102
14329
  try {
14103
- bytes = await readFile14(absolute);
14330
+ bytes = await readFile15(absolute);
14104
14331
  } catch (error) {
14105
14332
  throw new PackagedMethodSkillUnavailableError(name, absolute, error);
14106
14333
  }
@@ -14116,7 +14343,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
14116
14343
  let raw;
14117
14344
  try {
14118
14345
  skillPath = await realpath5(skillPathConfigured);
14119
- raw = await readFile14(skillPath, "utf8");
14346
+ raw = await readFile15(skillPath, "utf8");
14120
14347
  } catch (error) {
14121
14348
  throw new PackagedMethodSkillUnavailableError(name, skillPathConfigured, error);
14122
14349
  }
@@ -14408,11 +14635,11 @@ var init_navigator_invocation_identity = __esm({
14408
14635
  });
14409
14636
 
14410
14637
  // src/receipt-delivery-policy.ts
14411
- function isRecord10(value) {
14638
+ function isRecord11(value) {
14412
14639
  return typeof value === "object" && value !== null && !Array.isArray(value);
14413
14640
  }
14414
14641
  function parseNoReceiptLifecycleFacts(input) {
14415
- if (!isRecord10(input) || typeof input.terminalToolCalled !== "boolean" || input.deliveryTurns !== RECEIPT_DELIVERY_TURN_LIMIT || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord10(item) && typeof item.reason === "string")) {
14642
+ if (!isRecord11(input) || typeof input.terminalToolCalled !== "boolean" || input.deliveryTurns !== RECEIPT_DELIVERY_TURN_LIMIT || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord11(item) && typeof item.reason === "string")) {
14416
14643
  throw new TypeError("malformed no-receipt lifecycle facts");
14417
14644
  }
14418
14645
  return {
@@ -14671,7 +14898,7 @@ __export(settlement_exports, {
14671
14898
  withSubmissions: () => withSubmissions
14672
14899
  });
14673
14900
  import { randomUUID as randomUUID4 } from "node:crypto";
14674
- import { appendFile as appendFile2, readFile as readFile15, readdir as readdir6, writeFile as writeFile7 } from "node:fs/promises";
14901
+ import { appendFile as appendFile2, readFile as readFile16, readdir as readdir7, writeFile as writeFile7 } from "node:fs/promises";
14675
14902
  import { dirname as dirname14, join as join28 } from "node:path";
14676
14903
  function sealedLedgerHome(admitted) {
14677
14904
  return homeFromRunDirectory(admitted.runDirectory);
@@ -14815,10 +15042,10 @@ function presentControlledFailure(failure2, io) {
14815
15042
  }
14816
15043
  async function inspectJudgeSession(sessionFile) {
14817
15044
  try {
14818
- await readFile15(sessionFile, "utf8");
15045
+ await readFile16(sessionFile, "utf8");
14819
15046
  return { state: "present" };
14820
15047
  } catch (error) {
14821
- if (isMissingPathError3(error)) return { state: "missing" };
15048
+ if (isMissingPathError4(error)) return { state: "missing" };
14822
15049
  return {
14823
15050
  state: "unreadable",
14824
15051
  diagnostic: error instanceof Error ? error.message || error.name : String(error)
@@ -15018,7 +15245,7 @@ function explicitInternalKnownFailureClassificationInput(failure2) {
15018
15245
  ...failure2.details === void 0 ? {} : { knownDetails: failure2.details }
15019
15246
  };
15020
15247
  }
15021
- function isMissingPathError3(error) {
15248
+ function isMissingPathError4(error) {
15022
15249
  return error instanceof Error && "code" in error && error.code === "ENOENT";
15023
15250
  }
15024
15251
  function sessionReadFailure(error, fallbackMessage) {
@@ -15047,7 +15274,7 @@ function sessionReadFailure(error, fallbackMessage) {
15047
15274
  return failed;
15048
15275
  }
15049
15276
  async function readBoundSessionEntries(sessionFile) {
15050
- const text = await readFile15(sessionFile, "utf8");
15277
+ const text = await readFile16(sessionFile, "utf8");
15051
15278
  const entries = [];
15052
15279
  for (const line2 of text.trim().split("\n").filter(Boolean)) {
15053
15280
  try {
@@ -15113,7 +15340,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
15113
15340
  const { records } = await readSitianRecords(recordFile);
15114
15341
  for (let i = records.length - 1; i >= 0; i -= 1) {
15115
15342
  const payload = records[i]?.payload;
15116
- if (!isRecord11(payload) || !isRecord11(payload.response)) continue;
15343
+ if (!isRecord12(payload) || !isRecord12(payload.response)) continue;
15117
15344
  if (typeof payload.type === "string") continue;
15118
15345
  const stop = sessionProviderStopFromAssistant(payload.response);
15119
15346
  if (stop !== void 0) return stop;
@@ -15138,7 +15365,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
15138
15365
  try {
15139
15366
  parentEntries = await readBoundSessionEntries(sessionFile);
15140
15367
  } catch (error) {
15141
- if (isMissingPathError3(error)) return void 0;
15368
+ if (isMissingPathError4(error)) return void 0;
15142
15369
  throw sessionReadFailure(error, "failed to read parent session for auditor binding");
15143
15370
  }
15144
15371
  const parentId = parentEntries.find((entry) => entry.type === "session")?.id;
@@ -15149,10 +15376,10 @@ async function loadBoundAuditorVolumes(sessionFile) {
15149
15376
  for (const childDirectory of childDirectories) {
15150
15377
  let names;
15151
15378
  try {
15152
- names = await readdir6(childDirectory);
15379
+ names = await readdir7(childDirectory);
15153
15380
  sawAnyDirectory = true;
15154
15381
  } catch (error) {
15155
- if (isMissingPathError3(error)) continue;
15382
+ if (isMissingPathError4(error)) continue;
15156
15383
  throw sessionReadFailure(error, "failed to read bound auditor session directory");
15157
15384
  }
15158
15385
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
@@ -15163,7 +15390,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
15163
15390
  throw sessionReadFailure(error, "failed to read discovered auditor session");
15164
15391
  }
15165
15392
  const header = entries.find((entry) => entry.type === "session");
15166
- if (!isRecord11(header)) continue;
15393
+ if (!isRecord12(header)) continue;
15167
15394
  const bindingIndexes = [];
15168
15395
  for (let i = 0; i < entries.length; i += 1) {
15169
15396
  const entry = entries[i];
@@ -15177,7 +15404,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
15177
15404
  end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
15178
15405
  })) : [{ entry: void 0, start: 0, end: entries.length }];
15179
15406
  for (const { entry: bindingEntry, start, end } of bindingPasses) {
15180
- const bindingParent = bindingEntry !== void 0 && isRecord11(bindingEntry.data) && isRecord11(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
15407
+ const bindingParent = bindingEntry !== void 0 && isRecord12(bindingEntry.data) && isRecord12(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
15181
15408
  const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
15182
15409
  const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
15183
15410
  if (boundSessionFile !== sessionFile) continue;
@@ -15201,12 +15428,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
15201
15428
  if (stop === void 0) continue;
15202
15429
  for (let i = entries.length - 1; i >= 0; i -= 1) {
15203
15430
  const entry = entries[i];
15204
- if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord11(entry.data)) continue;
15205
- const parent = isRecord11(entry.data.parent) ? entry.data.parent : void 0;
15206
- const failure2 = isRecord11(entry.data.failure) ? entry.data.failure : void 0;
15431
+ if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord12(entry.data)) continue;
15432
+ const parent = isRecord12(entry.data.parent) ? entry.data.parent : void 0;
15433
+ const failure2 = isRecord12(entry.data.failure) ? entry.data.failure : void 0;
15207
15434
  if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
15208
15435
  if (failure2 === void 0) continue;
15209
- const identity = isRecord11(failure2.identity) ? failure2.identity : void 0;
15436
+ const identity = isRecord12(failure2.identity) ? failure2.identity : void 0;
15210
15437
  const typedCause = failure2.cause === "provider" || failure2.cause === "activation" || failure2.cause === "session" || failure2.cause === "output" || failure2.cause === "timeout" ? failure2.cause : void 0;
15211
15438
  return {
15212
15439
  ...typedCause === void 0 ? {} : { cause: typedCause },
@@ -15215,7 +15442,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
15215
15442
  ...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
15216
15443
  } },
15217
15444
  ...typeof failure2.diagnostic === "string" ? { diagnostic: failure2.diagnostic } : {},
15218
- ...isRecord11(failure2.details) ? { details: failure2.details } : {}
15445
+ ...isRecord12(failure2.details) ? { details: failure2.details } : {}
15219
15446
  };
15220
15447
  }
15221
15448
  }
@@ -15262,9 +15489,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
15262
15489
  if (classification.kind !== "infrastructure") continue;
15263
15490
  if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
15264
15491
  if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
15265
- const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord11(part) && part.type === "text" && typeof part.text === "string") : void 0;
15266
- const diagnostic = isRecord11(textPart) ? textPart.text : void 0;
15267
- const details = isRecord11(message.details) ? message.details : classification.fact;
15492
+ const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord12(part) && part.type === "text" && typeof part.text === "string") : void 0;
15493
+ const diagnostic = isRecord12(textPart) ? textPart.text : void 0;
15494
+ const details = isRecord12(message.details) ? message.details : classification.fact;
15268
15495
  return {
15269
15496
  cause: "activation",
15270
15497
  identity: { name: message.toolName, code: message.toolCallId },
@@ -15300,7 +15527,7 @@ async function resolveAuditedRunnerFailureResolution(input) {
15300
15527
  );
15301
15528
  if (terminatingFailure !== void 0) return resolutionOf(terminatingFailure);
15302
15529
  } catch (error) {
15303
- if (!isMissingPathError3(error)) {
15530
+ if (!isMissingPathError4(error)) {
15304
15531
  const failure2 = sessionReadFailure(error, "failed to recover typed terminating-tool failure");
15305
15532
  return resolutionOf({
15306
15533
  cause: "session",
@@ -15401,7 +15628,7 @@ function controlledFailureInputFromResolution(resolution) {
15401
15628
  } : {}
15402
15629
  };
15403
15630
  }
15404
- function isRecord11(value) {
15631
+ function isRecord12(value) {
15405
15632
  return typeof value === "object" && value !== null && !Array.isArray(value);
15406
15633
  }
15407
15634
  function toolResultText(message) {
@@ -15426,7 +15653,7 @@ function extractCollectorTargetBindRejection(entries) {
15426
15653
  const diagnostic = toolResultText(message);
15427
15654
  if (diagnostic.length === 0) return void 0;
15428
15655
  const details = message.details;
15429
- const code = isRecord11(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
15656
+ const code = isRecord12(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
15430
15657
  return code === void 0 ? { diagnostic } : { diagnostic, code };
15431
15658
  }
15432
15659
  return void 0;
@@ -15508,7 +15735,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
15508
15735
  const candidateMessage = entries[index]?.message;
15509
15736
  if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
15510
15737
  for (const part of candidateMessage.content) {
15511
- if (!isRecord11(part) || part.type !== "toolCall" || part.id !== callId) {
15738
+ if (!isRecord12(part) || part.type !== "toolCall" || part.id !== callId) {
15512
15739
  continue;
15513
15740
  }
15514
15741
  if (part.name !== outputToolName) return void 0;
@@ -15579,7 +15806,7 @@ function parseNavigatorAttendanceDetails(details) {
15579
15806
  if (typeof details.prose === "string" && details.prose.trim() !== "") {
15580
15807
  prose = details.prose;
15581
15808
  } else {
15582
- const next = isRecord11(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
15809
+ const next = isRecord12(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
15583
15810
  const reason = typeof details.reason === "string" && details.reason.trim() !== "" ? details.reason : void 0;
15584
15811
  const command = typeof details.command === "string" && details.command.trim() !== "" ? details.command : void 0;
15585
15812
  if (reason !== void 0 && next !== void 0) {
@@ -15688,7 +15915,7 @@ function detourGateContext(admitted, scope) {
15688
15915
  }
15689
15916
  async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
15690
15917
  const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
15691
- const skipGate = isRecord11(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && (secondaryEvidence.stage === "gatekeeper" || secondaryEvidence.stage === "inspector" || secondaryEvidence.stage === "notary");
15918
+ const skipGate = isRecord12(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && (secondaryEvidence.stage === "gatekeeper" || secondaryEvidence.stage === "inspector" || secondaryEvidence.stage === "notary");
15692
15919
  let next = base;
15693
15920
  if (!skipGate) {
15694
15921
  const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
@@ -15732,7 +15959,7 @@ function extractNavigatorFact(entries) {
15732
15959
  const entry = entries[i];
15733
15960
  if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
15734
15961
  const details = entry.message?.details ?? entry.details;
15735
- if (!isRecord11(details)) {
15962
+ if (!isRecord12(details)) {
15736
15963
  return {
15737
15964
  disposition: "unavailable",
15738
15965
  source: "unknown",
@@ -15765,7 +15992,7 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
15765
15992
  const entries = await readBoundSessionEntries(sessionFile);
15766
15993
  return extractNavigatorFact(entries);
15767
15994
  } catch (error) {
15768
- if (isMissingPathError3(error)) {
15995
+ if (isMissingPathError4(error)) {
15769
15996
  return {
15770
15997
  disposition: "unavailable",
15771
15998
  source: "unknown",
@@ -15878,7 +16105,7 @@ async function readLawfulSettlementEntries(sessionFile) {
15878
16105
  try {
15879
16106
  return await readBoundSessionEntries(sessionFile);
15880
16107
  } catch (error) {
15881
- if (isMissingPathError3(error)) return void 0;
16108
+ if (isMissingPathError4(error)) return void 0;
15882
16109
  throw error instanceof Error && error.knownCause === "session" ? error : sessionReadFailure(error, "session unreadable");
15883
16110
  }
15884
16111
  }
@@ -16142,7 +16369,7 @@ async function settleLawfulCollectorTerminalResult(admitted, authority, scope) {
16142
16369
  const residual = boundErroredToolCandidate(entries, index, message, COLLECTOR_WAIT_TOOL);
16143
16370
  if (residual === void 0) continue;
16144
16371
  const candidate = residual.candidate;
16145
- const details = isRecord11(candidate) ? candidate : { candidate };
16372
+ const details = isRecord12(candidate) ? candidate : { candidate };
16146
16373
  const failed = await settleFailureTerminalResult(
16147
16374
  admitted,
16148
16375
  {
@@ -16197,7 +16424,7 @@ function extractDoctorCandidateCostFact(entries) {
16197
16424
  const entry = entries[i];
16198
16425
  if (entry?.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
16199
16426
  const data = entry.data;
16200
- return isRecord11(data) ? data.cost : void 0;
16427
+ return isRecord12(data) ? data.cost : void 0;
16201
16428
  }
16202
16429
  }
16203
16430
  return void 0;
@@ -16208,7 +16435,7 @@ function extractDoctorCandidateAuditNoReceiptFact(entries) {
16208
16435
  const entry = entries[i];
16209
16436
  if (entry?.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
16210
16437
  const data = entry.data;
16211
- return isRecord11(data) ? data.auditNoReceipt : void 0;
16438
+ return isRecord12(data) ? data.auditNoReceipt : void 0;
16212
16439
  }
16213
16440
  }
16214
16441
  return void 0;
@@ -16373,7 +16600,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
16373
16600
  );
16374
16601
  }
16375
16602
  if (residual !== void 0) {
16376
- const details = isRecord11(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
16603
+ const details = isRecord12(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
16377
16604
  const failed = await settleFailureTerminalResult(
16378
16605
  admitted,
16379
16606
  {
@@ -16451,11 +16678,75 @@ async function settleLawfulDiaristTerminalResult(admitted, authority, scope) {
16451
16678
  async function trySettleDiaristTerminalResult(admitted, authority, scope) {
16452
16679
  return settleLawfulDiaristTerminalResult(admitted, authority, scope);
16453
16680
  }
16681
+ function countersignTerminalFromEntries(entries) {
16682
+ for (let index = entries.length - 1; index >= 0; index -= 1) {
16683
+ const entry = entries[index];
16684
+ if (entry?.type !== "custom") continue;
16685
+ if (entry.customType !== SECRETARIAT_GATE_OFFICER_ENTRY_TYPE) continue;
16686
+ const data = entry.data !== null && typeof entry.data === "object" && !Array.isArray(entry.data) ? entry.data : void 0;
16687
+ if (data?.officer !== "countersign") continue;
16688
+ if (data.receipt === void 0) continue;
16689
+ const runId = typeof data.runId === "string" && data.runId.trim() !== "" ? data.runId : void 0;
16690
+ return {
16691
+ receipt: data.receipt,
16692
+ ...runId === void 0 ? {} : { runId }
16693
+ };
16694
+ }
16695
+ return void 0;
16696
+ }
16697
+ function withCountersignTerminalFact(roleOutcome, officer) {
16698
+ const prior = roleOutcome.decisiveFacts !== void 0 && isRecord12(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
16699
+ return {
16700
+ ...roleOutcome,
16701
+ decisiveFacts: {
16702
+ ...prior,
16703
+ [SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY]: officer
16704
+ }
16705
+ };
16706
+ }
16707
+ function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
16708
+ const payloads = roleOutcome.payloads ?? [];
16709
+ for (let index = payloads.length - 1; index >= 0; index -= 1) {
16710
+ const payload = payloads[index];
16711
+ if (!isRecord12(payload)) continue;
16712
+ const status = payload.secretariatStatus;
16713
+ if (typeof status !== "string") continue;
16714
+ return status === "converged";
16715
+ }
16716
+ return false;
16717
+ }
16454
16718
  async function settleLawfulSecretariatTerminalResult(admitted, authority, scope) {
16455
- return settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
16719
+ const settled = await settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
16456
16720
  role: "secretariat",
16457
16721
  toolName: SECRETARIAT_OUTPUT_TOOL_NAME
16458
16722
  }, scope);
16723
+ if (settled === void 0) return void 0;
16724
+ const coordinates = coordinatesFromAdmitted(authority, admitted);
16725
+ const entries = await readLawfulSettlementEntries(coordinates.sessionFile) ?? [];
16726
+ const officer = countersignTerminalFromEntries(entries);
16727
+ if (officer === void 0) return settled;
16728
+ if (settled.roleOutcome.kind === "audit_escalation") {
16729
+ return {
16730
+ ...settled,
16731
+ roleOutcome: withCountersignTerminalFact(
16732
+ {
16733
+ ...settled.roleOutcome,
16734
+ payloads: [officer.receipt]
16735
+ },
16736
+ officer
16737
+ )
16738
+ };
16739
+ }
16740
+ if (settled.roleOutcome.kind === "accepted") {
16741
+ if (!acceptedSecretariatDefinesOfficerProjection(settled.roleOutcome)) {
16742
+ return settled;
16743
+ }
16744
+ return {
16745
+ ...settled,
16746
+ roleOutcome: withCountersignTerminalFact(settled.roleOutcome, officer)
16747
+ };
16748
+ }
16749
+ return settled;
16459
16750
  }
16460
16751
  async function trySettleSecretariatTerminalResult(admitted, authority, scope) {
16461
16752
  return settleLawfulSecretariatTerminalResult(admitted, authority, scope);
@@ -16697,7 +16988,7 @@ async function settleLawfulMergerTerminalResult(admitted, authority, options, sc
16697
16988
  const residual = boundErroredToolCandidate(entries, index, message, MERGER_OUTPUT_TOOL_NAME);
16698
16989
  if (residual === void 0) continue;
16699
16990
  const candidate = residual.candidate;
16700
- const details = isRecord11(candidate) ? candidate : { candidate };
16991
+ const details = isRecord12(candidate) ? candidate : { candidate };
16701
16992
  const failed = await settleFailureTerminalResult(
16702
16993
  admitted,
16703
16994
  {
@@ -17146,7 +17437,7 @@ var init_seat_ticket_binding = __esm({
17146
17437
  });
17147
17438
 
17148
17439
  // src/session-identity.ts
17149
- import { mkdir as mkdir3, readFile as readFile16, rename as rename2, writeFile as writeFile8 } from "node:fs/promises";
17440
+ import { mkdir as mkdir3, readFile as readFile17, rename as rename2, writeFile as writeFile8 } from "node:fs/promises";
17150
17441
  import { dirname as dirname15, join as join29 } from "node:path";
17151
17442
  function createSessionIdentityAuthority(authority, sessionBindingFile) {
17152
17443
  const bindingPath = (principal) => join29(authority.decode(principal).sessionDirectory, sessionBindingFile);
@@ -17156,7 +17447,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
17156
17447
  },
17157
17448
  async load(principal) {
17158
17449
  try {
17159
- const value = JSON.parse(await readFile16(bindingPath(principal), "utf8"));
17450
+ const value = JSON.parse(await readFile17(bindingPath(principal), "utf8"));
17160
17451
  if (typeof value !== "object" || value === null || typeof value.sessionId !== "string") {
17161
17452
  throw new Error("durable session binding is invalid");
17162
17453
  }
@@ -17195,7 +17486,7 @@ var init_session_identity = __esm({
17195
17486
  });
17196
17487
 
17197
17488
  // src/session-dialogue.ts
17198
- function isRecord12(value) {
17489
+ function isRecord13(value) {
17199
17490
  return typeof value === "object" && value !== null && !Array.isArray(value);
17200
17491
  }
17201
17492
  function nativeEventId(row) {
@@ -17205,7 +17496,7 @@ function nativeEventId(row) {
17205
17496
  }
17206
17497
  for (const nestKey of ["message", "payload"]) {
17207
17498
  const nested = row[nestKey];
17208
- if (!isRecord12(nested)) continue;
17499
+ if (!isRecord13(nested)) continue;
17209
17500
  for (const key of ["uuid", "id"]) {
17210
17501
  const value = nested[key];
17211
17502
  if (typeof value === "string" && value !== "") return value;
@@ -17218,19 +17509,19 @@ function textParts(content) {
17218
17509
  if (!Array.isArray(content)) return [];
17219
17510
  const out = [];
17220
17511
  for (const part of content) {
17221
- if (!isRecord12(part) || !SPEAKER_TEXT_PART_TYPES.has(String(part.type))) continue;
17512
+ if (!isRecord13(part) || !SPEAKER_TEXT_PART_TYPES.has(String(part.type))) continue;
17222
17513
  const text = part.text;
17223
17514
  if (typeof text === "string" && text !== "") out.push(text);
17224
17515
  }
17225
17516
  return out;
17226
17517
  }
17227
17518
  function responseItemMessage(row) {
17228
- if (row.type !== "response_item" || !isRecord12(row.payload)) return void 0;
17519
+ if (row.type !== "response_item" || !isRecord13(row.payload)) return void 0;
17229
17520
  if (row.payload.type !== "message") return void 0;
17230
17521
  return row.payload;
17231
17522
  }
17232
17523
  function messageBody(row) {
17233
- if (isRecord12(row.message)) return row.message;
17524
+ if (isRecord13(row.message)) return row.message;
17234
17525
  return responseItemMessage(row);
17235
17526
  }
17236
17527
  function speakerOf(message) {
@@ -17240,7 +17531,7 @@ function speakerOf(message) {
17240
17531
  }
17241
17532
  function codexContentItemKinds(message) {
17242
17533
  const pass = message.internal_chat_message_metadata_passthrough;
17243
- if (!isRecord12(pass) || !Array.isArray(pass.content_item_kinds)) return void 0;
17534
+ if (!isRecord13(pass) || !Array.isArray(pass.content_item_kinds)) return void 0;
17244
17535
  const kinds = [];
17245
17536
  for (const kind of pass.content_item_kinds) {
17246
17537
  if (typeof kind === "string" && kind !== "") kinds.push(kind);
@@ -17269,7 +17560,7 @@ function isFixedNonOwnerEnqueueShape(content) {
17269
17560
  return hasFixedOpenTagPrefix(content, TASK_NOTIFICATION_OPEN_TAG);
17270
17561
  }
17271
17562
  function materializationOriginKind(row) {
17272
- if (!isRecord12(row.origin)) return void 0;
17563
+ if (!isRecord13(row.origin)) return void 0;
17273
17564
  const kind = row.origin.kind;
17274
17565
  return typeof kind === "string" && kind !== "" ? kind : void 0;
17275
17566
  }
@@ -17317,7 +17608,7 @@ var init_session_dialogue = __esm({
17317
17608
 
17318
17609
  // src/ticket-provenance.ts
17319
17610
  import { createHash as createHash8 } from "node:crypto";
17320
- import { readFile as readFile17 } from "node:fs/promises";
17611
+ import { readFile as readFile18 } from "node:fs/promises";
17321
17612
  import { basename as basename8, dirname as dirname16, join as join30, resolve as resolve12 } from "node:path";
17322
17613
  function dialogueSessionSourceRoots(home) {
17323
17614
  const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
@@ -17413,7 +17704,7 @@ async function readTicketProvenance(ticketNumber, cwd, home) {
17413
17704
  const { recordFile } = resolveTicketProvenanceVolume(ticketNumber, cwd, home);
17414
17705
  let text;
17415
17706
  try {
17416
- text = await readFile17(recordFile, "utf8");
17707
+ text = await readFile18(recordFile, "utf8");
17417
17708
  } catch (error) {
17418
17709
  if (error.code === "ENOENT") {
17419
17710
  return {
@@ -17893,7 +18184,7 @@ __export(case_dossier_delivery_exports, {
17893
18184
  loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
17894
18185
  projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
17895
18186
  });
17896
- import { mkdtemp as mkdtemp3, readFile as readFile18, rm as rm3, writeFile as writeFile9 } from "node:fs/promises";
18187
+ import { mkdtemp as mkdtemp3, readFile as readFile19, rm as rm3, writeFile as writeFile9 } from "node:fs/promises";
17897
18188
  import { tmpdir as tmpdir3 } from "node:os";
17898
18189
  import { join as join31 } from "node:path";
17899
18190
  async function projectCaseDossierPointerSection(input) {
@@ -17945,7 +18236,7 @@ async function loadCaseDossierReadingMaterial(runDirectory) {
17945
18236
  );
17946
18237
  let section;
17947
18238
  try {
17948
- section = await readFile18(frozenPath, "utf8");
18239
+ section = await readFile19(frozenPath, "utf8");
17949
18240
  } catch (error) {
17950
18241
  if (error.code === "ENOENT") return void 0;
17951
18242
  throw error;
@@ -17968,7 +18259,7 @@ var init_case_dossier_delivery = __esm({
17968
18259
  });
17969
18260
 
17970
18261
  // src/host-transition-prior-native.ts
17971
- import { access as access3, readdir as readdir7 } from "node:fs/promises";
18262
+ import { access as access3, readdir as readdir8 } from "node:fs/promises";
17972
18263
  import { dirname as dirname17, join as join32 } from "node:path";
17973
18264
  function isEnoent3(error) {
17974
18265
  return typeof error === "object" && error !== null && error.code === "ENOENT";
@@ -17986,7 +18277,7 @@ async function listSitianRecordPaths(sessionParent) {
17986
18277
  const sessionRoot = dirname17(sessionParent);
17987
18278
  let entries;
17988
18279
  try {
17989
- entries = await readdir7(sessionRoot, { withFileTypes: true });
18280
+ entries = await readdir8(sessionRoot, { withFileTypes: true });
17990
18281
  } catch (error) {
17991
18282
  if (isEnoent3(error)) return [];
17992
18283
  throw error;
@@ -18129,7 +18420,7 @@ async function ensureRealArtifactsDirectory(runDirectory) {
18129
18420
  throw new Error("run artifact retention: artifacts path is not a real directory");
18130
18421
  }
18131
18422
  } catch (error) {
18132
- if (!isMissingPathError4(error)) throw error;
18423
+ if (!isMissingPathError5(error)) throw error;
18133
18424
  await mkdir4(artifactsDir, { recursive: true });
18134
18425
  const created = await lstat6(artifactsDir);
18135
18426
  if (created.isSymbolicLink() || !created.isDirectory()) {
@@ -18161,7 +18452,7 @@ function serializeThrownValue(value, depth = 0, seen = /* @__PURE__ */ new WeakS
18161
18452
  }
18162
18453
  return value;
18163
18454
  }
18164
- function isMissingPathError4(error) {
18455
+ function isMissingPathError5(error) {
18165
18456
  return error instanceof Error && "code" in error && error.code === "ENOENT";
18166
18457
  }
18167
18458
  function transferNestedValue(value, depth, seen) {
@@ -20783,7 +21074,9 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
20783
21074
  {
20784
21075
  instruction: parsed.instruction,
20785
21076
  projectRoot: admitted.projectRoot,
20786
- failureLabel: "unbound summons"
21077
+ failureLabel: "unbound summons",
21078
+ // #969: parent durable ticket is the resume/bind key (ADR 0079).
21079
+ ...env.boundTicketNumber === void 0 ? {} : { boundTicketNumber: env.boundTicketNumber }
20787
21080
  },
20788
21081
  env,
20789
21082
  io
@@ -20835,12 +21128,16 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
20835
21128
  );
20836
21129
  }
20837
21130
  if (outcome.identity.kind === "ticket") {
20838
- const assertedTicket = outcome.identity.ticketNumber;
20839
- typedTicket = assertedTicket;
21131
+ typedTicket = isSafePositiveTicketNumber(env.boundTicketNumber) ? env.boundTicketNumber : outcome.identity.ticketNumber;
20840
21132
  typedCourtTicketNumbers = outcome.identity.courtTicketNumbers;
21133
+ } else if (isSafePositiveTicketNumber(env.boundTicketNumber)) {
21134
+ typedTicket = env.boundTicketNumber;
21135
+ }
21136
+ if (typedTicket !== void 0) {
21137
+ const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction ?? parsed.instruction;
20841
21138
  const summons = {
20842
- instruction: parsed.instruction,
20843
- instructionEmpty: parsed.instruction.trim() === ""
21139
+ instruction: resumeInstruction,
21140
+ instructionEmpty: resumeInstruction.trim() === ""
20844
21141
  };
20845
21142
  const resumed = await tryResumeSameTicketSeatRun({
20846
21143
  home: env.home,
@@ -20922,7 +21219,9 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
20922
21219
  ...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
20923
21220
  continuation: {
20924
21221
  kind: "initial",
20925
- prompt: buildCountersignTransportPrompt(
21222
+ // #969/#879: gate path first mint carries parent payload as dialogue content;
21223
+ // ordinary public entry keeps package transport prompt.
21224
+ prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildCountersignTransportPrompt(
20926
21225
  admitted,
20927
21226
  engineSessionMaterialFromOptions({
20928
21227
  ...pickEngineAxis(env),
@@ -22064,6 +22363,25 @@ async function summonGateOfficer(options) {
22064
22363
  ...common
22065
22364
  });
22066
22365
  }
22366
+ if (options.officer === "countersign") {
22367
+ const { runIdFromRunDirectory: runIdFromRunDirectory2 } = await Promise.resolve().then(() => (init_run_terminal_artifacts(), run_terminal_artifacts_exports));
22368
+ const correlationId = runIdFromRunDirectory2(options.sourceRunDirectory);
22369
+ if (correlationId === void 0 || correlationId.trim() === "") {
22370
+ throw new Error(
22371
+ `countersign gate summon requires parent runId from sourceRunDirectory: ${options.sourceRunDirectory}`
22372
+ );
22373
+ }
22374
+ const { readBoardTicketNumber: readBoardTicketNumber2 } = await Promise.resolve().then(() => (init_run_ticket_number(), run_ticket_number_exports));
22375
+ const parentTicket = await readBoardTicketNumber2(options.sourceRunDirectory);
22376
+ const instruction = options.reask ?? gateReviewInstruction ?? "";
22377
+ return summonPublicRole({
22378
+ role: "countersign",
22379
+ argv: ["--project", options.cwd, "--", instruction],
22380
+ ...common,
22381
+ correlationId,
22382
+ ...parentTicket === void 0 ? {} : { boundTicketNumber: parentTicket }
22383
+ });
22384
+ }
22067
22385
  return summonPublicRole({
22068
22386
  role: "inspector",
22069
22387
  argv: [`\u5377\u5B97\u6307\u9488\uFF1A${options.sourceRunDirectory}`],
@@ -22108,6 +22426,7 @@ function createDefaultGateOfficerSummon(options) {
22108
22426
  ...options.home === void 0 ? {} : { home: options.home },
22109
22427
  ...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
22110
22428
  ...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
22429
+ ...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
22111
22430
  ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
22112
22431
  });
22113
22432
  };
@@ -22156,9 +22475,15 @@ async function requireGatekeeperPass(options) {
22156
22475
  options.hostActions.failInfrastructure(error, options.context, options.toolCallId);
22157
22476
  }
22158
22477
  }
22159
- if (gatekeeper.status === "pass") return;
22478
+ if (gatekeeper.status === "pass") {
22479
+ return {
22480
+ officer: projected.officer,
22481
+ receipt: gatekeeper.receipt,
22482
+ ...typeof gatekeeper.runId === "string" && gatekeeper.runId.trim() !== "" ? { runId: gatekeeper.runId } : {}
22483
+ };
22484
+ }
22160
22485
  if (gatekeeper.status === "needs_reask") {
22161
- reask = OFFICER_CONCLUSION_REASK;
22486
+ reask = officerConclusionReask(projected.officer);
22162
22487
  continue;
22163
22488
  }
22164
22489
  if (gatekeeper.status === "transport_failure") {
@@ -22168,6 +22493,9 @@ async function requireGatekeeperPass(options) {
22168
22493
  });
22169
22494
  options.hostActions.failInfrastructure(failure2, options.context, options.toolCallId);
22170
22495
  }
22496
+ if (gatekeeper.status === "escalate" && options.subject.kind === "secretariat_verdict") {
22497
+ throw new GatekeeperDecisionError(gatekeeper);
22498
+ }
22171
22499
  options.hostActions.bindSubmissionNonPass(options.toolCallId, gatekeeper);
22172
22500
  throw new GatekeeperDecisionError(gatekeeper);
22173
22501
  }
@@ -22649,7 +22977,7 @@ init_collector_evidence();
22649
22977
  init_collector_github();
22650
22978
 
22651
22979
  // src/collector-handbook.ts
22652
- import { readFile as readFile19 } from "node:fs/promises";
22980
+ import { readFile as readFile20 } from "node:fs/promises";
22653
22981
  import { join as join38, sep as sep6 } from "node:path";
22654
22982
 
22655
22983
  // src/atomic-write.ts
@@ -22812,7 +23140,7 @@ function createCollectorHandbookStore(input) {
22812
23140
  ensureRealDirectoryTree(input.ledgerHome, parentDir2);
22813
23141
  assertLedgerFileInsideHome(path, input.ledgerHome);
22814
23142
  try {
22815
- const body = await readFile19(path, "utf8");
23143
+ const body = await readFile20(path, "utf8");
22816
23144
  assertHandbookBudget(body, "\u6B63\u6587");
22817
23145
  return body;
22818
23146
  } catch (error) {
@@ -25207,7 +25535,7 @@ function uninstallPackageWorkerHooks(cwd) {
25207
25535
  rmOwnedDir(resolve17(gitDir, HOOKS_DIR));
25208
25536
  }
25209
25537
  }
25210
- function isRecord13(value) {
25538
+ function isRecord14(value) {
25211
25539
  return typeof value === "object" && value !== null && !Array.isArray(value);
25212
25540
  }
25213
25541
  function unfinishedReasonPresent(details) {
@@ -25223,7 +25551,7 @@ function readGateState(session) {
25223
25551
  if (entry.type !== "custom") continue;
25224
25552
  if (entry.customType === WORKER_COMMIT_BASELINE_ENTRY_TYPE) {
25225
25553
  const data = entry.data;
25226
- if (isRecord13(data) && (data.head === null || typeof data.head === "string")) {
25554
+ if (isRecord14(data) && (data.head === null || typeof data.head === "string")) {
25227
25555
  baseline = data.head;
25228
25556
  }
25229
25557
  } else if (entry.customType === WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE) {
@@ -25774,7 +26102,6 @@ ${JSON.stringify(admitted)}
25774
26102
  // src/role-runtime.ts
25775
26103
  init_navigator_invocation_identity();
25776
26104
  init_gatekeeper_role();
25777
- init_gatekeeper_role();
25778
26105
  init_submission_errors();
25779
26106
  init_doctor_contracts();
25780
26107
  init_doctor_evidence();
@@ -26257,15 +26584,80 @@ ${error.message}`
26257
26584
  }
26258
26585
  var COUNTERSIGN_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "continue", "escalate"]);
26259
26586
  var COUNTERSIGN_STATUS_REASK = "countersignStatus \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
26260
- function createSecretariatRoleRuntime(roleHost, dependencies) {
26587
+ var SECRETARIAT_SUBMISSION_GATE_HOSTS = /* @__PURE__ */ new Set(["codex", "claude", "grok-build"]);
26588
+ var SECRETARIAT_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "escalate"]);
26589
+ var SECRETARIAT_STATUS_REASK = "secretariatStatus \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
26590
+ function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
26261
26591
  let parentInstruction = "";
26592
+ const beforeAccept = hostActions !== void 0 && roleHost.requireGatekeeperPass !== void 0 ? async ({ toolCallId, parameters, signal, ctx }) => {
26593
+ const host = typeof ctx.host === "string" && ctx.host.trim() !== "" ? ctx.host.trim() : void 0;
26594
+ if (host === void 0 || !SECRETARIAT_SUBMISSION_GATE_HOSTS.has(host)) {
26595
+ return void 0;
26596
+ }
26597
+ const record4 = parameters !== null && typeof parameters === "object" && !Array.isArray(parameters) ? parameters : void 0;
26598
+ const status = record4 !== void 0 && typeof record4.secretariatStatus === "string" ? record4.secretariatStatus : void 0;
26599
+ if (status === void 0 || !SECRETARIAT_QUEUE_STATUSES.has(status)) {
26600
+ throw new ParentQueueReaskError(SECRETARIAT_STATUS_REASK);
26601
+ }
26602
+ if (status === "escalate") {
26603
+ return void 0;
26604
+ }
26605
+ try {
26606
+ const pass = await roleHost.requireGatekeeperPass({
26607
+ context: ctx,
26608
+ subject: { kind: "secretariat_verdict" },
26609
+ ...signal === void 0 ? {} : { signal },
26610
+ hostActions,
26611
+ toolCallId,
26612
+ // #879: this-turn typed payload — identity-bound at submit site.
26613
+ submission: parameters
26614
+ });
26615
+ if (pass !== void 0 && pass !== null && typeof pass === "object" && "receipt" in pass) {
26616
+ const {
26617
+ SECRETARIAT_GATE_OFFICER_ENTRY_TYPE: SECRETARIAT_GATE_OFFICER_ENTRY_TYPE2
26618
+ } = await Promise.resolve().then(() => (init_secretariat_contracts(), secretariat_contracts_exports));
26619
+ const runId = typeof pass.runId === "string" && pass.runId.trim() !== "" ? pass.runId : void 0;
26620
+ ctx.sessionManager.appendCustomEntry?.(SECRETARIAT_GATE_OFFICER_ENTRY_TYPE2, {
26621
+ officer: "countersign",
26622
+ receipt: pass.receipt,
26623
+ ...runId === void 0 ? {} : { runId }
26624
+ });
26625
+ }
26626
+ return void 0;
26627
+ } catch (error) {
26628
+ if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
26629
+ const receipt = error.result.receipt;
26630
+ const receiptRecord = receipt !== null && typeof receipt === "object" && !Array.isArray(receipt) ? receipt : void 0;
26631
+ const runId = typeof error.result.runId === "string" && error.result.runId.trim() !== "" ? error.result.runId : void 0;
26632
+ const {
26633
+ SECRETARIAT_GATE_OFFICER_ENTRY_TYPE: SECRETARIAT_GATE_OFFICER_ENTRY_TYPE2
26634
+ } = await Promise.resolve().then(() => (init_secretariat_contracts(), secretariat_contracts_exports));
26635
+ ctx.sessionManager.appendCustomEntry?.(SECRETARIAT_GATE_OFFICER_ENTRY_TYPE2, {
26636
+ officer: "countersign",
26637
+ receipt,
26638
+ ...runId === void 0 ? {} : { runId }
26639
+ });
26640
+ const { buildAuditEscalationResult: buildAuditEscalationResult2 } = await Promise.resolve().then(() => (init_audit_escalation(), audit_escalation_exports));
26641
+ return buildAuditEscalationResult2(
26642
+ {
26643
+ status: "escalate",
26644
+ officer: "countersign",
26645
+ ...receiptRecord !== void 0 && Object.prototype.hasOwnProperty.call(receiptRecord, "decisionGate") ? { decisionGate: receiptRecord.decisionGate } : {}
26646
+ },
26647
+ receipt
26648
+ );
26649
+ }
26650
+ throw error;
26651
+ }
26652
+ } : void 0;
26262
26653
  const base = createFiledOfficerRuntime(
26263
26654
  roleHost,
26264
26655
  {
26265
26656
  role: "secretariat",
26266
26657
  tool: SECRETARIAT_OUTPUT_TOOL_SPEC,
26267
26658
  acceptedText: SECRETARIAT_ACCEPTED_TEXT,
26268
- soulTag: "secretariat"
26659
+ soulTag: "secretariat",
26660
+ ...beforeAccept === void 0 ? {} : { beforeAccept }
26269
26661
  },
26270
26662
  dependencies
26271
26663
  );
@@ -26947,8 +27339,9 @@ function createRoleRuntimeExtension(dependencies) {
26947
27339
  if (!dependencies.loadSecretariatSoul) throw new Error("Secretariat runtime dependencies are not configured");
26948
27340
  return dependencies.loadSecretariatSoul();
26949
27341
  },
26950
- ...dependencies.packageRoot === void 0 ? {} : { packageRoot: dependencies.packageRoot }
26951
- });
27342
+ ...dependencies.packageRoot === void 0 ? {} : { packageRoot: dependencies.packageRoot },
27343
+ ...dependencies.hostAdapters === void 0 ? {} : { hostAdapters: dependencies.hostAdapters }
27344
+ }, hostActions);
26952
27345
  const merger = createMergerRoleRuntime(roleHost, {
26953
27346
  async loadSoul() {
26954
27347
  if (!dependencies.loadMergerSoul) throw new Error("Merger runtime dependencies are not configured");
@@ -27444,17 +27837,26 @@ async function prepareRoleEnvelope(options) {
27444
27837
  getActiveTools() {
27445
27838
  return [...preferredTools];
27446
27839
  },
27447
- async requireGatekeeperPass(options2) {
27448
- await requireGatekeeperPass({
27449
- context: options2.context,
27450
- subject: options2.subject,
27451
- ...options2.signal === void 0 ? {} : { signal: options2.signal },
27840
+ async requireGatekeeperPass(gateOptions) {
27841
+ const packageRoot = typeof options.dependencies.packageRoot === "string" ? options.dependencies.packageRoot : void 0;
27842
+ return requireGatekeeperPass({
27843
+ context: gateOptions.context,
27844
+ subject: gateOptions.subject,
27845
+ ...gateOptions.signal === void 0 ? {} : { signal: gateOptions.signal },
27452
27846
  hostActions: {
27453
- failInfrastructure: (error, _context, toolCallId) => options2.hostActions.failInfrastructure(error, options2.context, toolCallId),
27454
- bindSubmissionNonPass: options2.hostActions.bindSubmissionNonPass
27847
+ failInfrastructure: (error, _context, toolCallId) => gateOptions.hostActions.failInfrastructure(error, gateOptions.context, toolCallId),
27848
+ bindSubmissionNonPass: gateOptions.hostActions.bindSubmissionNonPass
27455
27849
  },
27456
- toolCallId: options2.toolCallId,
27457
- ...options2.submission === void 0 ? {} : { submission: options2.submission }
27850
+ toolCallId: gateOptions.toolCallId,
27851
+ ...gateOptions.submission === void 0 ? {} : { submission: gateOptions.submission },
27852
+ // #969: package root + home reach nested 给事中/符宝郎 summons.
27853
+ // hostAdapters (when set on deps) forward nested seat selection — production unset.
27854
+ summonOfficer: createDefaultGateOfficerSummon({
27855
+ cwd: gateOptions.context.cwd ?? request.cwd,
27856
+ home: request.home,
27857
+ ...packageRoot === void 0 ? {} : { packageRoot },
27858
+ ...options.dependencies.hostAdapters === void 0 ? {} : { hostAdapters: options.dependencies.hostAdapters }
27859
+ })
27458
27860
  });
27459
27861
  },
27460
27862
  on(...registration) {
@@ -27864,11 +28266,11 @@ async function prepareRoleEnvelope(options) {
27864
28266
  }
27865
28267
 
27866
28268
  // src/role-runtime-dependencies.ts
27867
- import { readFile as readFile22 } from "node:fs/promises";
28269
+ import { readFile as readFile23 } from "node:fs/promises";
27868
28270
  import { join as join42 } from "node:path";
27869
28271
 
27870
28272
  // src/canonical-skill-binding.ts
27871
- import { readFile as readFile20, realpath as realpath8 } from "node:fs/promises";
28273
+ import { readFile as readFile21, realpath as realpath8 } from "node:fs/promises";
27872
28274
  import { homedir } from "node:os";
27873
28275
  import { dirname as dirname22, resolve as resolve18 } from "node:path";
27874
28276
  import { stripFrontmatter } from "@earendil-works/pi-coding-agent";
@@ -27901,7 +28303,7 @@ async function loadCanonicalSkillBinding(name) {
27901
28303
  let raw;
27902
28304
  try {
27903
28305
  path = await realpath8(configuredPath);
27904
- raw = await readFile20(path, "utf8");
28306
+ raw = await readFile21(path, "utf8");
27905
28307
  } catch (error) {
27906
28308
  throw new CanonicalSkillUnavailableError(name, configuredPath, error);
27907
28309
  }
@@ -27940,7 +28342,7 @@ init_doctor_evidence();
27940
28342
  // src/navigator-work-context.ts
27941
28343
  init_doctor_evidence();
27942
28344
  init_host_contracts();
27943
- import { readFile as readFile21 } from "node:fs/promises";
28345
+ import { readFile as readFile22 } from "node:fs/promises";
27944
28346
  import { resolve as resolve19 } from "node:path";
27945
28347
  init_notary_source_run();
27946
28348
  init_packaged_role_registry();
@@ -27953,7 +28355,7 @@ function navigatorInputReference(getFlag, role) {
27953
28355
  }
27954
28356
  async function loadNavigatorWorkContext(options) {
27955
28357
  const reference = navigatorInputReference(options.getFlag, options.role);
27956
- const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await readFile21(reference, "utf8");
28358
+ const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await readFile22(reference, "utf8");
27957
28359
  const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
27958
28360
  let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
27959
28361
  let subject = input ?? `work subject: ${subjectKey}`;
@@ -28010,7 +28412,7 @@ async function loadNavigatorWorkContext(options) {
28010
28412
  let authorityMaterial;
28011
28413
  for (const path of authorityFiles) {
28012
28414
  try {
28013
- const content = await readFile21(path, "utf8");
28415
+ const content = await readFile22(path, "utf8");
28014
28416
  if (content.trim() !== "") {
28015
28417
  authorityMaterial = content;
28016
28418
  break;
@@ -28079,12 +28481,12 @@ function createRoleRuntimeDependencies(packageRoot) {
28079
28481
  loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
28080
28482
  loadJudgeSoul: () => loadMainRoleSessionMaterials("judge"),
28081
28483
  loadFixerSoul: () => loadMainRoleSessionMaterials("fixer"),
28082
- loadFixPacket: (path) => readFile22(path, "utf8"),
28484
+ loadFixPacket: (path) => readFile23(path, "utf8"),
28083
28485
  loadCoderSoul: () => loadMainRoleSessionMaterials("coder"),
28084
- loadCoderTask: (path) => readFile22(path, "utf8"),
28486
+ loadCoderTask: (path) => readFile23(path, "utf8"),
28085
28487
  loadReviewerSoul: () => loadMainRoleSessionMaterials("reviewer"),
28086
28488
  loadCollectorSoul: () => loadMainRoleSessionMaterials("collector"),
28087
- loadCollectorHandbookSeed: () => readFile22(collectorHandbookSeedPath, "utf8"),
28489
+ loadCollectorHandbookSeed: () => readFile23(collectorHandbookSeedPath, "utf8"),
28088
28490
  createCollectorTransport: () => createGhCollectorGitHubTransport(),
28089
28491
  loadDoctorSoul: () => loadMainRoleSessionMaterials("doctor"),
28090
28492
  loadDoctorCase,
@@ -28099,7 +28501,7 @@ function createRoleRuntimeDependencies(packageRoot) {
28099
28501
  loadSecretariatSoul: () => loadMainRoleSessionMaterials("secretariat"),
28100
28502
  loadNotarySourceRun: loadNotarySourceRunLocator,
28101
28503
  loadMergerSoul: () => loadMainRoleSessionMaterials("merger"),
28102
- loadMergerInput: async (path) => JSON.parse(await readFile22(path, "utf8")),
28504
+ loadMergerInput: async (path) => JSON.parse(await readFile23(path, "utf8")),
28103
28505
  async loadCanonicalSkillBinding(name) {
28104
28506
  if (name === "tdd") {
28105
28507
  return loadPackagedCanonicalSkillBinding(packageRoot, "tdd");
@@ -28125,7 +28527,7 @@ function createRoleRuntimeDependencies(packageRoot) {
28125
28527
  authority: options.authority,
28126
28528
  invocationId: options.invocationId,
28127
28529
  loadSoul: () => loadMainRoleSessionMaterials("navigator"),
28128
- loadRoutePlaybook: () => readFile22(navigatorRoutePlaybookPath, "utf8"),
28530
+ loadRoutePlaybook: () => readFile23(navigatorRoutePlaybookPath, "utf8"),
28129
28531
  loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
28130
28532
  createSession: navigatorSessionFactory,
28131
28533
  ...options.contextError === void 0 ? {} : { contextError: options.contextError },