@akagilnc/pi-workflow-roles 0.1.3572 → 0.1.3621

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/acp-host/production-host.js +20239 -10556
  2. package/dist/analyst-gate-cycles-read.js +387 -0
  3. package/dist/archivist-record-entry.js +22 -1
  4. package/dist/audit-escalation.js +6 -0
  5. package/dist/auditor-soul.js +74 -0
  6. package/dist/collector-config.js +86 -0
  7. package/dist/collector-evidence.js +316 -0
  8. package/dist/collector-github.js +527 -0
  9. package/dist/collector-ledger.js +853 -0
  10. package/dist/collector-tool-schemas.js +33 -0
  11. package/dist/compliance-transport.js +104 -52
  12. package/dist/diarist-mechanical.js +411 -0
  13. package/dist/diarist-ticket-resolution.js +177 -0
  14. package/dist/diarist.js +311 -0
  15. package/dist/doctor-auditor.js +25 -0
  16. package/dist/doctor-contracts.js +2 -0
  17. package/dist/doctor-evidence.js +142 -0
  18. package/dist/gatekeeper-role.js +104 -81
  19. package/dist/host-transition-prior-native.js +78 -0
  20. package/dist/institutional-resolution.js +1 -95
  21. package/dist/judge-auditor.js +26 -0
  22. package/dist/ledger-session-read.js +227 -0
  23. package/dist/merger-git-state.js +78 -0
  24. package/dist/navigator-attendance.js +15 -7
  25. package/dist/navigator-public-session.js +170 -0
  26. package/dist/navigator-session-contracts.js +36 -40
  27. package/dist/notary-source-run.js +122 -0
  28. package/dist/package-contracts/auditor-output.js +66 -0
  29. package/dist/package-contracts/evidence-child-output.js +34 -0
  30. package/dist/package-contracts/judge-output.js +2 -0
  31. package/dist/package-contracts/terminating-tools.js +25 -2
  32. package/dist/package-resources/method-skill.js +254 -0
  33. package/dist/packaged-role-registry.js +36 -0
  34. package/dist/pi/durable-principal.js +61 -0
  35. package/dist/pi/in-process-session.js +25 -6
  36. package/dist/pi/known-failure.js +52 -0
  37. package/dist/pi/role-turn-host.js +430 -0
  38. package/dist/public-cli/auto-resume.js +414 -0
  39. package/dist/public-cli/cli-errors.js +8 -0
  40. package/dist/public-cli/cli-io.js +1 -0
  41. package/dist/public-cli/command-renderer.js +5 -0
  42. package/dist/public-cli/doctor-run.js +84 -0
  43. package/dist/public-cli/inspector-run.js +136 -0
  44. package/dist/public-cli/instruction-seat-run.js +256 -0
  45. package/dist/public-cli/invocation.js +2225 -0
  46. package/dist/public-cli/judge-run.js +118 -0
  47. package/dist/public-cli/load-production-acp-host.js +40 -0
  48. package/dist/public-cli/main.js +1140 -652
  49. package/dist/public-cli/notary-run.js +161 -0
  50. package/dist/public-cli/option-definitions.js +1192 -0
  51. package/dist/public-cli/post-admission.js +667 -0
  52. package/dist/public-cli/public-run-credentials.js +49 -0
  53. package/dist/public-cli/registry.js +4 -1
  54. package/dist/public-cli/reviewer-dispatch-rejection.js +77 -0
  55. package/dist/public-cli/run-lifecycle.js +1344 -0
  56. package/dist/public-cli/seat-ticket-binding.js +113 -0
  57. package/dist/public-cli/settlement.js +3441 -0
  58. package/dist/public-cli/terminal.js +135 -0
  59. package/dist/public-cli/turn-request.js +25 -0
  60. package/dist/public-role-summons.js +301 -0
  61. package/dist/receipt-delivery-policy.js +10 -0
  62. package/dist/reviewer-child-executor.js +80 -8
  63. package/dist/reviewer-execution-ledger.js +2 -1
  64. package/dist/run-terminal-artifacts.js +195 -0
  65. package/dist/run-ticket-number.js +40 -0
  66. package/dist/session-assistant-usage.js +107 -0
  67. package/dist/shape-unreadable-failure.js +34 -0
  68. package/dist/submission-errors.js +3 -0
  69. package/dist/submission-ledger.js +388 -0
  70. package/dist/ticket-provenance-contracts.js +115 -0
  71. package/dist/ticket-provenance.js +340 -0
  72. package/extensions/role-runtime.ts +7 -0
  73. package/package.json +1 -1
  74. package/scripts/build-package.mjs +2 -1
  75. package/souls/doctor-auditor.md +1 -0
  76. package/souls/evidence-child.md +1 -0
  77. package/src/acp-host/production-host.ts +3 -0
  78. package/src/acp-host/role-envelope.ts +2 -2
  79. package/src/acp-host/role-turn-host.ts +9 -1
  80. package/src/analyst-gate-cycles-read.ts +37 -2
  81. package/src/archivist-record-entry.ts +45 -1
  82. package/src/audit-escalation.ts +17 -0
  83. package/src/auditor-role.ts +22 -0
  84. package/src/auditor-soul.ts +42 -0
  85. package/src/compliance-transport.ts +177 -66
  86. package/src/doctor-auditor.ts +10 -14
  87. package/src/doctor-contracts.ts +1 -0
  88. package/src/doctor-role.ts +2 -2
  89. package/src/evidence-child-role.ts +22 -0
  90. package/src/gatekeeper-pass-envelope.ts +109 -0
  91. package/src/gatekeeper-role.ts +145 -104
  92. package/src/host-contracts.ts +9 -1
  93. package/src/institutional-resolution.ts +8 -163
  94. package/src/judge-auditor.ts +10 -15
  95. package/src/judge-role.ts +8 -0
  96. package/src/navigator-attendance.ts +25 -9
  97. package/src/navigator-public-session.ts +217 -0
  98. package/src/navigator-session-contracts.ts +61 -54
  99. package/src/notary-source-run.ts +3 -1
  100. package/src/package-contracts/auditor-output.ts +82 -0
  101. package/src/package-contracts/evidence-child-output.ts +51 -0
  102. package/src/package-contracts/judge-output.ts +1 -0
  103. package/src/package-contracts/reviewer-output.ts +2 -2
  104. package/src/package-contracts/terminating-tools.ts +31 -1
  105. package/src/packaged-role-registry.ts +43 -0
  106. package/src/pi/adapter.ts +2 -1
  107. package/src/pi/in-process-session.ts +38 -12
  108. package/src/pi/role-turn-host.ts +34 -0
  109. package/src/public-cli/cli.ts +14 -6
  110. package/src/public-cli/instruction-seat-run.ts +289 -50
  111. package/src/public-cli/invocation.ts +66 -25
  112. package/src/public-cli/option-definitions.ts +61 -0
  113. package/src/public-cli/post-admission.ts +7 -1
  114. package/src/public-cli/registry.ts +4 -1
  115. package/src/public-cli/run-lifecycle.ts +22 -3
  116. package/src/public-cli/settlement.ts +120 -5
  117. package/src/public-cli/terminal.ts +2 -0
  118. package/src/public-role-summons.ts +431 -0
  119. package/src/receipt-delivery-policy.ts +10 -0
  120. package/src/reviewer-agent.ts +1 -1
  121. package/src/reviewer-child-executor.ts +114 -12
  122. package/src/reviewer-execution-ledger.ts +3 -2
  123. package/src/role-runtime.ts +158 -17
  124. package/src/session-assistant-usage.ts +119 -0
  125. package/src/session-opening-materials.ts +1 -1
  126. package/src/shape-unreadable-failure.ts +49 -0
  127. package/src/submission-errors.ts +3 -0
  128. package/dist/evidence-child-executor.js +0 -829
  129. package/src/evidence-child-executor.ts +0 -1140
@@ -15023,6 +15023,113 @@ var init_inspector_contracts = __esm({
15023
15023
  }
15024
15024
  });
15025
15025
 
15026
+ // src/package-contracts/auditor-output.ts
15027
+ function isRecord6(value) {
15028
+ return typeof value === "object" && value !== null && !Array.isArray(value);
15029
+ }
15030
+ function projectLawfulAuditorOutput(value) {
15031
+ if (!isRecord6(value)) return void 0;
15032
+ if (value.status === "pass") return { status: "pass" };
15033
+ if (value.status === "revise") {
15034
+ return {
15035
+ status: "revise",
15036
+ ...Object.hasOwn(value, "violations") ? { violations: value.violations } : {}
15037
+ };
15038
+ }
15039
+ if (value.status === "escalate") {
15040
+ return {
15041
+ status: "escalate",
15042
+ ...Object.hasOwn(value, "conflicts") ? { conflicts: value.conflicts } : {},
15043
+ ...Object.hasOwn(value, "decisionGate") ? { decisionGate: value.decisionGate } : {}
15044
+ };
15045
+ }
15046
+ return void 0;
15047
+ }
15048
+ function validateRecordedAuditorOutput(value) {
15049
+ const projected = projectLawfulAuditorOutput(value);
15050
+ if (projected === void 0) {
15051
+ throw new Error("Auditor output has no recognized execution discriminator");
15052
+ }
15053
+ return projected;
15054
+ }
15055
+ function auditorDecisiveFacts(output) {
15056
+ const facts = { status: output.status };
15057
+ if (output.status === "revise" && output.violations !== void 0) {
15058
+ facts.violations = output.violations;
15059
+ }
15060
+ if (output.status === "escalate") {
15061
+ if (output.conflicts !== void 0) facts.conflicts = output.conflicts;
15062
+ if (output.decisionGate !== void 0) facts.decisionGate = output.decisionGate;
15063
+ }
15064
+ return facts;
15065
+ }
15066
+ var AUDITOR_OUTPUT_TOOL_NAME, auditorOutputSchema;
15067
+ var init_auditor_output = __esm({
15068
+ "src/package-contracts/auditor-output.ts"() {
15069
+ "use strict";
15070
+ init_build();
15071
+ init_open_tool_schema();
15072
+ init_terminating_infrastructure();
15073
+ AUDITOR_OUTPUT_TOOL_NAME = "ak_auditor_output";
15074
+ auditorOutputSchema = withInfrastructureFailureDeclaration(
15075
+ openToolObject(
15076
+ typebox_exports.Object({
15077
+ status: typebox_exports.Unknown({
15078
+ description: "pass | revise | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
15079
+ }),
15080
+ violations: typebox_exports.Optional(typebox_exports.Unknown({
15081
+ description: "status \u4E3A revise \u65F6\u7684\u8FDD\u89C4\u6761\u76EE"
15082
+ })),
15083
+ conflicts: typebox_exports.Optional(typebox_exports.Unknown({
15084
+ description: "status \u4E3A escalate \u65F6\u7684\u51B2\u7A81"
15085
+ })),
15086
+ decisionGate: typebox_exports.Optional(typebox_exports.Unknown({
15087
+ description: "status \u4E3A escalate \u65F6\u7684\u51B3\u7B56\u95F8"
15088
+ }))
15089
+ })
15090
+ )
15091
+ );
15092
+ }
15093
+ });
15094
+
15095
+ // src/package-contracts/evidence-child-output.ts
15096
+ function isRecord7(value) {
15097
+ return typeof value === "object" && value !== null && !Array.isArray(value);
15098
+ }
15099
+ function projectLawfulEvidenceChildOutput(value) {
15100
+ if (!isRecord7(value)) return void 0;
15101
+ return { report: Object.hasOwn(value, "report") ? value.report : value };
15102
+ }
15103
+ function validateRecordedEvidenceChildOutput(value) {
15104
+ const projected = projectLawfulEvidenceChildOutput(value);
15105
+ if (projected === void 0) {
15106
+ throw new Error("Evidence-child output is not an object");
15107
+ }
15108
+ return projected;
15109
+ }
15110
+ function evidenceChildDecisiveFacts(output) {
15111
+ return { report: output.report };
15112
+ }
15113
+ var EVIDENCE_CHILD_OUTPUT_TOOL_NAME, evidenceChildOutputSchema;
15114
+ var init_evidence_child_output = __esm({
15115
+ "src/package-contracts/evidence-child-output.ts"() {
15116
+ "use strict";
15117
+ init_build();
15118
+ init_open_tool_schema();
15119
+ init_terminating_infrastructure();
15120
+ EVIDENCE_CHILD_OUTPUT_TOOL_NAME = "ak_evidence_child_output";
15121
+ evidenceChildOutputSchema = withInfrastructureFailureDeclaration(
15122
+ openToolObject(
15123
+ typebox_exports.Object({
15124
+ report: typebox_exports.Unknown({
15125
+ description: "\u53D6\u8BC1\u62A5\u544A\u6B63\u6587 \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
15126
+ })
15127
+ })
15128
+ )
15129
+ );
15130
+ }
15131
+ });
15132
+
15026
15133
  // src/diarist-contracts.ts
15027
15134
  function validateRecordedDiaristOutput(value) {
15028
15135
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
@@ -15066,7 +15173,7 @@ var init_diarist_contracts = __esm({
15066
15173
  function packagedRoleMetadata(role) {
15067
15174
  return PACKAGED_ROLE_REGISTRY.find((entry) => entry.role === role);
15068
15175
  }
15069
- var NOTARY_SESSION_MATERIALS, INSPECTOR_SESSION_MATERIALS, PUBLIC_ROLE_RECORDS, PACKAGED_ROLE_REGISTRY;
15176
+ var NOTARY_SESSION_MATERIALS, INSPECTOR_SESSION_MATERIALS, AUDITOR_PUBLIC_SESSION_MATERIALS, EVIDENCE_CHILD_SESSION_MATERIALS, PUBLIC_ROLE_RECORDS, PACKAGED_ROLE_REGISTRY;
15070
15177
  var init_packaged_role_registry = __esm({
15071
15178
  "src/packaged-role-registry.ts"() {
15072
15179
  "use strict";
@@ -15082,6 +15189,8 @@ var init_packaged_role_registry = __esm({
15082
15189
  init_countersign_contracts();
15083
15190
  init_gleaner_left_contracts();
15084
15191
  init_inspector_contracts();
15192
+ init_auditor_output();
15193
+ init_evidence_child_output();
15085
15194
  init_diarist_contracts();
15086
15195
  NOTARY_SESSION_MATERIALS = [
15087
15196
  "CLAUDE.md",
@@ -15096,6 +15205,19 @@ var init_packaged_role_registry = __esm({
15096
15205
  "souls/quality-law.md",
15097
15206
  "souls/gate-output-guide.md"
15098
15207
  ];
15208
+ AUDITOR_PUBLIC_SESSION_MATERIALS = [
15209
+ "CLAUDE.md",
15210
+ "souls/judge-auditor.md",
15211
+ "souls/doctor-auditor.md",
15212
+ "souls/audit-law.md",
15213
+ "souls/quality-law.md"
15214
+ ];
15215
+ EVIDENCE_CHILD_SESSION_MATERIALS = [
15216
+ "CLAUDE.md",
15217
+ "souls/evidence-child.md",
15218
+ "souls/audit-law.md",
15219
+ "souls/quality-law.md"
15220
+ ];
15099
15221
  PUBLIC_ROLE_RECORDS = [
15100
15222
  {
15101
15223
  role: "judge",
@@ -15249,6 +15371,25 @@ var init_packaged_role_registry = __esm({
15249
15371
  activationStage: "load-and-install",
15250
15372
  sessionMaterials: ["CLAUDE.md", "souls/navigator.md"]
15251
15373
  },
15374
+ // #675: 审刑院 / evidence-child are roles like any other — public ak-role entries.
15375
+ {
15376
+ role: "auditor",
15377
+ phases: [null],
15378
+ outputTool: AUDITOR_OUTPUT_TOOL_NAME,
15379
+ inputFlag: void 0,
15380
+ phaseFlag: void 0,
15381
+ activationStage: "load-and-install",
15382
+ sessionMaterials: AUDITOR_PUBLIC_SESSION_MATERIALS
15383
+ },
15384
+ {
15385
+ role: "evidence-child",
15386
+ phases: [null],
15387
+ outputTool: EVIDENCE_CHILD_OUTPUT_TOOL_NAME,
15388
+ inputFlag: void 0,
15389
+ phaseFlag: void 0,
15390
+ activationStage: "load-and-install",
15391
+ sessionMaterials: EVIDENCE_CHILD_SESSION_MATERIALS
15392
+ },
15252
15393
  // #708 / ADR 0075 `diarist-is-role`: 起居郎 is a seat like any other. The
15253
15394
  // frozen source catalog rides the shared input-flag seam; it is absent for a
15254
15395
  // true-unbound summons (no ticket → no diary).
@@ -15369,13 +15510,16 @@ var init_registry2 = __esm({
15369
15510
  // #620: subordinate officers inherit gatekeeper; no package startup model.
15370
15511
  notary: [],
15371
15512
  // #453/#620/#639: gatekeeper callable but no package startup model — caller
15372
- // configures it or the institutional resolution applies on the province path.
15513
+ // configures it or inherits on the province path.
15373
15514
  gatekeeper: [],
15374
15515
  inspector: [],
15375
15516
  navigator: [
15376
15517
  { provider: "openai-codex", model: "gpt-5.6-luna", thinking: "medium" },
15377
15518
  { provider: "xai", model: "grok-4.5", thinking: "high" }
15378
15519
  ],
15520
+ // #675: auditor / evidence-child public seats — no package startup; caller configures.
15521
+ auditor: [],
15522
+ "evidence-child": [],
15379
15523
  // #708 `diarist-seat-default`: owner-set initial value; changed in the seat
15380
15524
  // table like any other seat. No engine axis, package-default host.
15381
15525
  diarist: [{ provider: "xai", model: "grok-4.5", thinking: "medium" }]
@@ -15385,17 +15529,6 @@ var init_registry2 = __esm({
15385
15529
  });
15386
15530
 
15387
15531
  // src/institutional-resolution.ts
15388
- import { readFile, writeFile } from "node:fs/promises";
15389
- import { join as join5 } from "node:path";
15390
- function cleanSelection(model) {
15391
- if (model === void 0) return void 0;
15392
- if (typeof model.provider !== "string" || typeof model.model !== "string") return void 0;
15393
- return {
15394
- provider: model.provider,
15395
- model: model.model,
15396
- ...model.thinking === void 0 ? {} : { thinking: model.thinking }
15397
- };
15398
- }
15399
15532
  function resolveConfiguredProvinceOfficer(config, officer) {
15400
15533
  const ownModel = seatModelOnly(config.seats[officer]);
15401
15534
  if (ownModel !== void 0) {
@@ -15410,37 +15543,10 @@ function resolveConfiguredProvinceOfficer(config, officer) {
15410
15543
  }
15411
15544
  return { source: "unconfigured" };
15412
15545
  }
15413
- function resolveInstitutionalSeatSelections(config, parentEffectiveModel) {
15414
- const parentSelection = cleanSelection(parentEffectiveModel);
15415
- const gatekeeper = resolveConfiguredProvinceOfficer(config, "gatekeeper").selection ?? parentSelection;
15416
- const inspector = resolveConfiguredProvinceOfficer(config, "inspector").selection ?? parentSelection;
15417
- const notary = resolveConfiguredProvinceOfficer(config, "notary").selection ?? parentSelection;
15418
- const auditor = parentSelection;
15419
- const evidenceChild = parentSelection;
15420
- const navigator = cleanSelection(seatModelOnly(config.seats?.navigator));
15421
- return {
15422
- version: 1,
15423
- seats: {
15424
- ...gatekeeper === void 0 ? {} : { gatekeeper },
15425
- ...inspector === void 0 ? {} : { inspector },
15426
- ...notary === void 0 ? {} : { notary },
15427
- ...auditor === void 0 ? {} : { auditor },
15428
- ...evidenceChild === void 0 ? {} : { evidenceChild },
15429
- ...navigator === void 0 ? {} : { navigator }
15430
- }
15431
- };
15432
- }
15433
- async function writeInstitutionalResolutionPage(runDirectory, page) {
15434
- const filePath = join5(runDirectory, INSTITUTIONAL_RESOLUTION_FILE);
15435
- await writeFile(filePath, `${JSON.stringify(page, null, 2)}
15436
- `, "utf8");
15437
- }
15438
- var INSTITUTIONAL_RESOLUTION_FILE;
15439
15546
  var init_institutional_resolution = __esm({
15440
15547
  "src/institutional-resolution.ts"() {
15441
15548
  "use strict";
15442
15549
  init_registry2();
15443
- INSTITUTIONAL_RESOLUTION_FILE = "institutional-resolution.json";
15444
15550
  }
15445
15551
  });
15446
15552
 
@@ -15487,8 +15593,8 @@ var init_host_descriptions = __esm({
15487
15593
  });
15488
15594
 
15489
15595
  // src/public-cli/config.ts
15490
- import { mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
15491
- import { dirname as dirname4, join as join6 } from "node:path";
15596
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
15597
+ import { dirname as dirname4, join as join5 } from "node:path";
15492
15598
  function isGateOfficerSeat(value) {
15493
15599
  return GATE_OFFICER_SEATS.includes(value);
15494
15600
  }
@@ -15496,12 +15602,12 @@ function publicCliConfigPath(home) {
15496
15602
  if (typeof home !== "string" || home.trim() === "") {
15497
15603
  throw new Error("home must be explicitly provided");
15498
15604
  }
15499
- return join6(home, ".ak-roles", "public-cli.json");
15605
+ return join5(home, ".ak-roles", "public-cli.json");
15500
15606
  }
15501
15607
  async function loadPublicCliConfig(home) {
15502
15608
  const path = publicCliConfigPath(home);
15503
15609
  try {
15504
- const raw = await readFile2(path, "utf8");
15610
+ const raw = await readFile(path, "utf8");
15505
15611
  return parsePublicCliConfig(JSON.parse(raw));
15506
15612
  } catch (error) {
15507
15613
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
@@ -15514,7 +15620,7 @@ async function savePublicCliConfig(config, home) {
15514
15620
  const path = publicCliConfigPath(home);
15515
15621
  await mkdir(dirname4(path), { recursive: true });
15516
15622
  const normalized = parsePublicCliConfig(config);
15517
- await writeFile2(
15623
+ await writeFile(
15518
15624
  path,
15519
15625
  `${JSON.stringify(serializePublicCliConfig(normalized), null, 2)}
15520
15626
  `,
@@ -15888,7 +15994,7 @@ function credentialProvidersFromAuthData(data) {
15888
15994
  }
15889
15995
  async function loadCredentialProviders(agentDir) {
15890
15996
  try {
15891
- const raw = await readFile2(join6(agentDir, "auth.json"), "utf8");
15997
+ const raw = await readFile(join5(agentDir, "auth.json"), "utf8");
15892
15998
  return credentialProvidersFromAuthData(JSON.parse(raw));
15893
15999
  } catch (error) {
15894
16000
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
@@ -15933,15 +16039,15 @@ var init_cli_errors = __esm({
15933
16039
 
15934
16040
  // src/public-cli/load-production-acp-host.ts
15935
16041
  import { existsSync as existsSync3 } from "node:fs";
15936
- import { join as join7 } from "node:path";
16042
+ import { join as join6 } from "node:path";
15937
16043
  import { pathToFileURL } from "node:url";
15938
16044
  async function loadProductionAcpHostFactory(packageRoot2, host) {
15939
16045
  const description = lookupHostDescription(host);
15940
16046
  if (description === void 0) {
15941
16047
  throw new Error(`unregistered host: ${host}`);
15942
16048
  }
15943
- const built = join7(packageRoot2, "dist/acp-host/production-host.js");
15944
- const source = join7(packageRoot2, "src/acp-host/production-host.ts");
16049
+ const built = join6(packageRoot2, "dist/acp-host/production-host.js");
16050
+ const source = join6(packageRoot2, "src/acp-host/production-host.ts");
15945
16051
  const target = existsSync3(built) ? built : source;
15946
16052
  const href = pathToFileURL(target).href;
15947
16053
  const mod = await import(href);
@@ -15981,9 +16087,9 @@ var init_host_contracts = __esm({
15981
16087
 
15982
16088
  // src/engine-detour.ts
15983
16089
  import { spawn } from "node:child_process";
15984
- import { mkdtemp, rm, writeFile as writeFile3 } from "node:fs/promises";
16090
+ import { mkdtemp, rm, writeFile as writeFile2 } from "node:fs/promises";
15985
16091
  import { tmpdir } from "node:os";
15986
- import { join as join8 } from "node:path";
16092
+ import { join as join7 } from "node:path";
15987
16093
  function applyEngineChildEnv(childEnv, engine) {
15988
16094
  delete childEnv[AK_ROLE_ENGINE_ENV];
15989
16095
  if (engine !== void 0 && engine.trim() !== "") {
@@ -16078,12 +16184,12 @@ async function runEngineDetourOnce(input) {
16078
16184
  if (input.stagedPrompt === void 0) {
16079
16185
  return spawnEngineDetourOnce(input);
16080
16186
  }
16081
- const stagingDir = await mkdtemp(join8(tmpdir(), "ak-engine-detour-"));
16082
- const stagedPath = join8(stagingDir, "prompt.txt");
16187
+ const stagingDir = await mkdtemp(join7(tmpdir(), "ak-engine-detour-"));
16188
+ const stagedPath = join7(stagingDir, "prompt.txt");
16083
16189
  let result2;
16084
16190
  let runError;
16085
16191
  try {
16086
- await writeFile3(stagedPath, input.stagedPrompt, "utf8");
16192
+ await writeFile2(stagedPath, input.stagedPrompt, "utf8");
16087
16193
  const argv = resolveArgvWithStagedPrompt(input.argv, stagedPath);
16088
16194
  result2 = await spawnEngineDetourOnce({
16089
16195
  argv,
@@ -16150,8 +16256,8 @@ import {
16150
16256
  unlinkSync,
16151
16257
  writeFileSync
16152
16258
  } from "node:fs";
16153
- import { basename as basename3, dirname as dirname5, join as join9, resolve as resolve3 } from "node:path";
16154
- function isRecord6(value) {
16259
+ import { basename as basename3, dirname as dirname5, join as join8, resolve as resolve3 } from "node:path";
16260
+ function isRecord8(value) {
16155
16261
  return typeof value === "object" && value !== null && !Array.isArray(value);
16156
16262
  }
16157
16263
  function errorCodeOf(error) {
@@ -16179,7 +16285,7 @@ function findIdentityPointer(recordFile, identity, kind, level) {
16179
16285
  if (!trimmed) continue;
16180
16286
  try {
16181
16287
  const parsed = JSON.parse(trimmed);
16182
- if (isRecord6(parsed) && parsed.identity === identity) {
16288
+ if (isRecord8(parsed) && parsed.identity === identity) {
16183
16289
  return { identity, recordFile, kind, level };
16184
16290
  }
16185
16291
  } catch {
@@ -16289,7 +16395,7 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
16289
16395
  const category = resolveSitianVolumeCategory(input.kind);
16290
16396
  let sessionDir;
16291
16397
  if (input.sessionParent !== void 0 && input.sessionParent.length > 0 && physicallyContainedIn(ledgerHome, input.sessionParent)) {
16292
- sessionDir = join9(dirname5(input.sessionParent), category);
16398
+ sessionDir = join8(dirname5(input.sessionParent), category);
16293
16399
  } else {
16294
16400
  const bookKey = safeBookKey(cwd);
16295
16401
  const bookDir = activationBookDirectory(ledgerHome, bookKey);
@@ -16303,12 +16409,12 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
16303
16409
  subjectStr = JSON.stringify(input.subject);
16304
16410
  }
16305
16411
  const digest = createHash2("sha256").update(subjectStr).digest("hex").slice(0, 32);
16306
- sessionDir = join9(bookDir, category, digest);
16412
+ sessionDir = join8(bookDir, category, digest);
16307
16413
  } else {
16308
- sessionDir = join9(bookDir, category);
16414
+ sessionDir = join8(bookDir, category);
16309
16415
  }
16310
16416
  }
16311
- const recordFile = join9(sessionDir, "records.jsonl");
16417
+ const recordFile = join8(sessionDir, "records.jsonl");
16312
16418
  return { sessionDir, recordFile, ledgerHome };
16313
16419
  }
16314
16420
  function resolveSitianRecordPath(input) {
@@ -16366,15 +16472,15 @@ var init_sitian_appender = __esm({
16366
16472
 
16367
16473
  // src/sitian-reader.ts
16368
16474
  import { existsSync as existsSync5 } from "node:fs";
16369
- import { readFile as readFile3 } from "node:fs/promises";
16370
- function isRecord7(value) {
16475
+ import { readFile as readFile2 } from "node:fs/promises";
16476
+ function isRecord9(value) {
16371
16477
  return typeof value === "object" && value !== null && !Array.isArray(value);
16372
16478
  }
16373
16479
  async function readSitianRecords(recordFile) {
16374
16480
  if (!existsSync5(recordFile)) {
16375
16481
  return { records: [], diagnostics: [] };
16376
16482
  }
16377
- const text = await readFile3(recordFile, "utf8");
16483
+ const text = await readFile2(recordFile, "utf8");
16378
16484
  const lines = text.split("\n");
16379
16485
  const records2 = [];
16380
16486
  const diagnostics = [];
@@ -16383,7 +16489,7 @@ async function readSitianRecords(recordFile) {
16383
16489
  if (!line2.trim()) continue;
16384
16490
  try {
16385
16491
  const parsed = JSON.parse(line2);
16386
- if (isRecord7(parsed)) {
16492
+ if (isRecord9(parsed)) {
16387
16493
  records2.push(parsed);
16388
16494
  } else {
16389
16495
  const typeDesc = parsed === null ? "null" : Array.isArray(parsed) ? "array" : typeof parsed;
@@ -16428,13 +16534,13 @@ var init_sitian_facade = __esm({
16428
16534
  // src/pi/role-turn-host.ts
16429
16535
  import { execFile, spawn as spawn2 } from "node:child_process";
16430
16536
  import { constants } from "node:fs";
16431
- import { access, appendFile, readFile as readFile4, realpath } from "node:fs/promises";
16432
- import { delimiter as delimiter2, isAbsolute as isAbsolute3, join as join10, resolve as resolve4 } from "node:path";
16537
+ import { access, appendFile, readFile as readFile3, realpath } from "node:fs/promises";
16538
+ import { delimiter as delimiter2, isAbsolute as isAbsolute3, join as join9, resolve as resolve4 } from "node:path";
16433
16539
  import { platform } from "node:process";
16434
16540
  import { promisify } from "node:util";
16435
16541
  import { randomUUID as randomUUID2 } from "node:crypto";
16436
16542
  function resolveInternalRoleEntrypoint(packageRoot2) {
16437
- return join10(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
16543
+ return join9(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
16438
16544
  }
16439
16545
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
16440
16546
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -16518,6 +16624,10 @@ function buildActivationFlagArgs(activation) {
16518
16624
  return ["--ak-role", "gatekeeper"];
16519
16625
  case "navigator":
16520
16626
  return ["--ak-role", "navigator"];
16627
+ case "auditor":
16628
+ return ["--ak-role", "auditor"];
16629
+ case "evidence-child":
16630
+ return ["--ak-role", "evidence-child"];
16521
16631
  case "diarist":
16522
16632
  return [
16523
16633
  "--ak-role",
@@ -16620,9 +16730,15 @@ function createDefaultPiSpawnRunner(options) {
16620
16730
  child.kill("SIGTERM");
16621
16731
  }, spawnOptions.timeoutMs);
16622
16732
  };
16733
+ const parentSignal = spawnOptions.signal;
16734
+ const terminateForParentAbort = () => {
16735
+ child.kill("SIGTERM");
16736
+ };
16737
+ parentSignal?.addEventListener("abort", terminateForParentAbort, { once: true });
16623
16738
  let identityRecorded = Promise.resolve();
16624
16739
  child.once("spawn", () => {
16625
16740
  hasSpawned = true;
16741
+ if (parentSignal?.aborted === true) terminateForParentAbort();
16626
16742
  armTimeoutAfterChildReady();
16627
16743
  const runDirectory = spawnOptions.env.AK_ROLE_RUN_DIR;
16628
16744
  if (typeof runDirectory === "string" && runDirectory !== "" && options.recordLaunchedPiIdentity !== void 0) {
@@ -16638,11 +16754,13 @@ function createDefaultPiSpawnRunner(options) {
16638
16754
  return;
16639
16755
  }
16640
16756
  if (timer !== void 0) clearTimeout(timer);
16757
+ parentSignal?.removeEventListener("abort", terminateForParentAbort);
16641
16758
  settled = true;
16642
16759
  reject(error);
16643
16760
  });
16644
16761
  child.on("close", (code) => {
16645
16762
  if (timer !== void 0) clearTimeout(timer);
16763
+ parentSignal?.removeEventListener("abort", terminateForParentAbort);
16646
16764
  void identityRecorded.then(
16647
16765
  () => {
16648
16766
  if (settled) return;
@@ -16696,11 +16814,20 @@ ${paths.join("\n")}`
16696
16814
  ...process.env,
16697
16815
  HOME: request.home,
16698
16816
  PI_CODING_AGENT_DIR: request.agentDir,
16699
- AK_ROLE_RUN_DIR: request.runDirectory
16817
+ AK_ROLE_RUN_DIR: request.runDirectory,
16818
+ // Nested public summons resolve package root without import.meta under jiti (#675).
16819
+ // Child-process scoped only — not written back onto the parent process.env.
16820
+ AK_ROLE_PACKAGE_ROOT: config.packageRoot
16700
16821
  };
16701
16822
  if (request.courtAttemptId === void 0) delete env.AK_ROLE_COURT_ATTEMPT;
16702
16823
  else env.AK_ROLE_COURT_ATTEMPT = request.courtAttemptId;
16703
16824
  applyEngineChildEnv(env, request.engine);
16825
+ if (typeof process.env.AK_ROLE_AUDITOR_SOURCE_RUN === "string" && process.env.AK_ROLE_AUDITOR_SOURCE_RUN.trim() !== "") {
16826
+ env.AK_ROLE_AUDITOR_SOURCE_RUN = process.env.AK_ROLE_AUDITOR_SOURCE_RUN;
16827
+ }
16828
+ if (typeof process.env.AK_ROLE_AUDITOR_SUBJECT === "string" && process.env.AK_ROLE_AUDITOR_SUBJECT.trim() !== "") {
16829
+ env.AK_ROLE_AUDITOR_SUBJECT = process.env.AK_ROLE_AUDITOR_SUBJECT;
16830
+ }
16704
16831
  if (request.correlationId !== void 0 && request.correlationId.trim() !== "") {
16705
16832
  env.AK_CORRELATION_ID = request.correlationId;
16706
16833
  }
@@ -16714,14 +16841,15 @@ ${paths.join("\n")}`
16714
16841
  return await spawnRunner(args, {
16715
16842
  cwd: request.cwd,
16716
16843
  env,
16717
- ...timeoutMs === void 0 ? {} : { timeoutMs }
16844
+ ...timeoutMs === void 0 ? {} : { timeoutMs },
16845
+ ...request.signal === void 0 ? {} : { signal: request.signal }
16718
16846
  });
16719
16847
  }
16720
16848
  };
16721
16849
  }
16722
16850
  async function appendPiSessionCustomEntry(authority, principal, customType, data) {
16723
16851
  const { sessionFile } = authority.decode(principal);
16724
- const text = await readFile4(sessionFile, "utf8");
16852
+ const text = await readFile3(sessionFile, "utf8");
16725
16853
  let parentId = null;
16726
16854
  for (const line2 of text.trim().split("\n").filter(Boolean)) {
16727
16855
  const entry = JSON.parse(line2);
@@ -16762,8 +16890,8 @@ var init_role_turn_host = __esm({
16762
16890
  });
16763
16891
 
16764
16892
  // src/run-ticket-number.ts
16765
- import { readFile as readFile5 } from "node:fs/promises";
16766
- import { join as join11 } from "node:path";
16893
+ import { readFile as readFile4 } from "node:fs/promises";
16894
+ import { join as join10 } from "node:path";
16767
16895
  function isEnoent(error) {
16768
16896
  return error instanceof Error && "code" in error && error.code === "ENOENT";
16769
16897
  }
@@ -16776,7 +16904,7 @@ function ticketFromRecord(record4) {
16776
16904
  }
16777
16905
  async function readPageTicketNumber(runDirectory, page) {
16778
16906
  try {
16779
- const raw = JSON.parse(await readFile5(join11(runDirectory, page), "utf8"));
16907
+ const raw = JSON.parse(await readFile4(join10(runDirectory, page), "utf8"));
16780
16908
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
16781
16909
  return void 0;
16782
16910
  }
@@ -16869,12 +16997,15 @@ function validateAcceptedDetails(toolName, details) {
16869
16997
  [INSPECTOR_OUTPUT_TOOL_NAME]: ["pass", "bounce"],
16870
16998
  [GATEKEEPER_OUTPUT_TOOL_NAME]: ["dispatch", "pass"],
16871
16999
  [NAVIGATOR_OUTPUT_TOOL_NAME]: ["advice"],
17000
+ [AUDITOR_OUTPUT_TOOL_NAME]: ["pass", "revise", "escalate"],
17001
+ [EVIDENCE_CHILD_OUTPUT_TOOL_NAME]: [],
16872
17002
  [DIARIST_OUTPUT_TOOL_NAME]: ["completed"]
16873
17003
  };
16874
17004
  const collectorDiscriminator = toolName === COLLECTOR_OUTPUT_TOOL && Array.isArray(candidate?.groups);
17005
+ const evidenceChildDiscriminator = toolName === EVIDENCE_CHILD_OUTPUT_TOOL_NAME && candidate !== null && typeof candidate === "object" && !Array.isArray(candidate);
16875
17006
  const baseDiscriminator = discriminator;
16876
17007
  const runtimeBindingMissing = toolName === DOCTOR_OUTPUT_TOOL_NAME && baseDiscriminator === "completed" && !(candidate?.cost !== null && typeof candidate?.cost === "object") || toolName === REVIEWER_OUTPUT_TOOL_NAME && candidate?.version !== 2;
16877
- if (runtimeBindingMissing || !collectorDiscriminator && (typeof discriminator !== "string" || !lawfulStatuses[toolName].includes(baseDiscriminator))) {
17008
+ if (runtimeBindingMissing || !collectorDiscriminator && !evidenceChildDiscriminator && (typeof discriminator !== "string" || !lawfulStatuses[toolName].includes(baseDiscriminator))) {
16878
17009
  throw new AcceptedDetailsContractError("terminating receipt has no recognized execution discriminator");
16879
17010
  }
16880
17011
  try {
@@ -16905,6 +17036,10 @@ function validateAcceptedDetails(toolName, details) {
16905
17036
  return validateRecordedGatekeeperOutput(details);
16906
17037
  case NAVIGATOR_OUTPUT_TOOL_NAME:
16907
17038
  return validateRecordedNavigatorOutput(details);
17039
+ case AUDITOR_OUTPUT_TOOL_NAME:
17040
+ return validateRecordedAuditorOutput(details);
17041
+ case EVIDENCE_CHILD_OUTPUT_TOOL_NAME:
17042
+ return validateRecordedEvidenceChildOutput(details);
16908
17043
  case DIARIST_OUTPUT_TOOL_NAME:
16909
17044
  return validateRecordedDiaristOutput(details);
16910
17045
  }
@@ -16924,6 +17059,10 @@ function acceptedFacts(toolName, details) {
16924
17059
  case INSPECTOR_OUTPUT_TOOL_NAME:
16925
17060
  case GATEKEEPER_OUTPUT_TOOL_NAME:
16926
17061
  case NAVIGATOR_OUTPUT_TOOL_NAME:
17062
+ case AUDITOR_OUTPUT_TOOL_NAME:
17063
+ return { status: details.status };
17064
+ case EVIDENCE_CHILD_OUTPUT_TOOL_NAME:
17065
+ return { status: "report" };
16927
17066
  case DIARIST_OUTPUT_TOOL_NAME:
16928
17067
  return { status: details.status };
16929
17068
  case JUDGE_OUTPUT_TOOL_NAME:
@@ -16951,6 +17090,8 @@ var init_terminating_tools = __esm({
16951
17090
  init_doctor_contracts();
16952
17091
  init_gatekeeper_output();
16953
17092
  init_navigator_output();
17093
+ init_auditor_output();
17094
+ init_evidence_child_output();
16954
17095
  init_merger_contracts();
16955
17096
  init_notary_contracts();
16956
17097
  init_countersign_contracts();
@@ -16972,6 +17113,8 @@ var init_terminating_tools = __esm({
16972
17113
  INSPECTOR_OUTPUT_TOOL_NAME,
16973
17114
  GATEKEEPER_OUTPUT_TOOL_NAME,
16974
17115
  NAVIGATOR_OUTPUT_TOOL_NAME,
17116
+ AUDITOR_OUTPUT_TOOL_NAME,
17117
+ EVIDENCE_CHILD_OUTPUT_TOOL_NAME,
16975
17118
  DIARIST_OUTPUT_TOOL_NAME
16976
17119
  ];
16977
17120
  AcceptedDetailsContractError = class extends CorrectableSubmissionError {
@@ -16985,7 +17128,7 @@ var init_terminating_tools = __esm({
16985
17128
  });
16986
17129
 
16987
17130
  // src/doctor-evidence.ts
16988
- import { readdir, readFile as readFile6, realpath as realpath2, stat } from "node:fs/promises";
17131
+ import { readdir, readFile as readFile5, realpath as realpath2, stat } from "node:fs/promises";
16989
17132
  import { dirname as dirname6, relative as relative2, resolve as resolve5, sep as sep2 } from "node:path";
16990
17133
  function record2(value) {
16991
17134
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -17104,7 +17247,7 @@ async function loadDoctorCase(runsPath) {
17104
17247
  const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
17105
17248
  for (const path of await discoverCaseFiles(root)) {
17106
17249
  const id = relative2(root, path).split(sep2).join("/");
17107
- const bytes = await readFile6(path);
17250
+ const bytes = await readFile5(path);
17108
17251
  const content = bytes.toString("utf8");
17109
17252
  const kind = id.endsWith(".jsonl") ? "session" : "stderr";
17110
17253
  evidence.push({ id, kind, byteLength: bytes.byteLength, contentLength: content.length, sha256: sha256Hex(bytes), content });
@@ -17134,7 +17277,7 @@ var init_doctor_evidence = __esm({
17134
17277
 
17135
17278
  // src/collector-config.ts
17136
17279
  import { createHash as createHash3 } from "node:crypto";
17137
- import { readFile as readFile7 } from "node:fs/promises";
17280
+ import { readFile as readFile6 } from "node:fs/promises";
17138
17281
  function fail3(message, cause) {
17139
17282
  throw new Error(message, cause === void 0 ? void 0 : { cause });
17140
17283
  }
@@ -17177,7 +17320,7 @@ function emptyCollectorManifest() {
17177
17320
  async function loadCollectorManifest(path) {
17178
17321
  let bytes;
17179
17322
  try {
17180
- bytes = await readFile7(path);
17323
+ bytes = await readFile6(path);
17181
17324
  } catch (error) {
17182
17325
  fail3(`Collector request manifest is unreadable at ${path}`, error);
17183
17326
  }
@@ -17312,10 +17455,10 @@ var init_uuidv7 = __esm({
17312
17455
  });
17313
17456
 
17314
17457
  // src/typed-provider-http.ts
17315
- import { readFile as readFile8, unlink, writeFile as writeFile4 } from "node:fs/promises";
17316
- import { join as join12 } from "node:path";
17458
+ import { readFile as readFile7, unlink, writeFile as writeFile3 } from "node:fs/promises";
17459
+ import { join as join11 } from "node:path";
17317
17460
  function typedProviderHttpPath(runDirectory) {
17318
- return join12(runDirectory, TYPED_HTTP_FILE);
17461
+ return join11(runDirectory, TYPED_HTTP_FILE);
17319
17462
  }
17320
17463
  async function clearTypedProviderHttpObservation(runDirectory) {
17321
17464
  try {
@@ -17330,7 +17473,7 @@ async function clearTypedProviderHttpObservation(runDirectory) {
17330
17473
  async function readLatestTypedProviderHttpObservation(runDirectory) {
17331
17474
  let text;
17332
17475
  try {
17333
- text = await readFile8(typedProviderHttpPath(runDirectory), "utf8");
17476
+ text = await readFile7(typedProviderHttpPath(runDirectory), "utf8");
17334
17477
  } catch (error) {
17335
17478
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
17336
17479
  return void 0;
@@ -17359,8 +17502,8 @@ var init_typed_provider_http = __esm({
17359
17502
  });
17360
17503
 
17361
17504
  // src/public-cli/run-lifecycle.ts
17362
- import { chmod, open, readdir as readdir2, readFile as readFile9, unlink as unlink2, writeFile as writeFile5 } from "node:fs/promises";
17363
- import { join as join13 } from "node:path";
17505
+ import { chmod, open, readdir as readdir2, readFile as readFile8, unlink as unlink2, writeFile as writeFile4 } from "node:fs/promises";
17506
+ import { join as join12 } from "node:path";
17364
17507
  function selectResumeContinuationPrompt(message, engineMaterial) {
17365
17508
  const base = message !== void 0 ? message : RESUME_TRANSPORT_ENVELOPE;
17366
17509
  return appendEngineSessionMaterial([base], engineMaterial).join("\n");
@@ -17389,8 +17532,8 @@ function renderResumeCommand(runId) {
17389
17532
  }
17390
17533
  async function writeRoleRunState(runDirectory, record4) {
17391
17534
  const payload = { ...record4, runDirectory };
17392
- await writeFile5(
17393
- join13(runDirectory, RUN_STATE_FILE),
17535
+ await writeFile4(
17536
+ join12(runDirectory, RUN_STATE_FILE),
17394
17537
  `${JSON.stringify(payload, null, 2)}
17395
17538
  `,
17396
17539
  "utf8"
@@ -17440,7 +17583,7 @@ function parseCurrentCourtState(raw) {
17440
17583
  async function readRoleRunStateDisk(runDirectory) {
17441
17584
  let raw;
17442
17585
  try {
17443
- raw = JSON.parse(await readFile9(join13(runDirectory, RUN_STATE_FILE), "utf8"));
17586
+ raw = JSON.parse(await readFile8(join12(runDirectory, RUN_STATE_FILE), "utf8"));
17444
17587
  } catch {
17445
17588
  return void 0;
17446
17589
  }
@@ -17451,7 +17594,7 @@ async function readRoleRunStateDisk(runDirectory) {
17451
17594
  if (typeof record4.runId !== "string" || record4.runId.trim() === "") {
17452
17595
  return void 0;
17453
17596
  }
17454
- if (record4.role !== "judge" && record4.role !== "coder" && record4.role !== "fixer" && record4.role !== "collector" && record4.role !== "doctor" && record4.role !== "reviewer" && record4.role !== "merger" && record4.role !== "notary" && record4.role !== "countersign" && record4.role !== "gleaner-left" && record4.role !== "inspector" && record4.role !== "gatekeeper" && record4.role !== "navigator" && record4.role !== "diarist") {
17597
+ if (record4.role !== "judge" && record4.role !== "coder" && record4.role !== "fixer" && record4.role !== "collector" && record4.role !== "doctor" && record4.role !== "reviewer" && record4.role !== "merger" && record4.role !== "notary" && record4.role !== "countersign" && record4.role !== "gleaner-left" && record4.role !== "inspector" && record4.role !== "gatekeeper" && record4.role !== "navigator" && record4.role !== "auditor" && record4.role !== "evidence-child" && record4.role !== "diarist") {
17455
17598
  return void 0;
17456
17599
  }
17457
17600
  if (record4.state !== "admitted" && record4.state !== "running" && record4.state !== "resumable" && record4.state !== "terminal") {
@@ -17506,8 +17649,8 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
17506
17649
  ...disk.resumable === void 0 ? {} : { resumable: disk.resumable },
17507
17650
  ...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
17508
17651
  };
17509
- await writeFile5(
17510
- join13(runDirectory, RUN_STATE_FILE),
17652
+ await writeFile4(
17653
+ join12(runDirectory, RUN_STATE_FILE),
17511
17654
  `${JSON.stringify(payload, null, 2)}
17512
17655
  `,
17513
17656
  "utf8"
@@ -17672,7 +17815,7 @@ function isProcessAlive(pid) {
17672
17815
  async function autopsyWriterLock(lockPath) {
17673
17816
  let content;
17674
17817
  try {
17675
- content = await readFile9(lockPath, "utf8");
17818
+ content = await readFile8(lockPath, "utf8");
17676
17819
  } catch (error) {
17677
17820
  if (errorCodeOf2(error) === "ENOENT") return { verdict: "absent" };
17678
17821
  return { verdict: "absent", readFailure: error };
@@ -17751,15 +17894,15 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
17751
17894
  };
17752
17895
  const reportCleanupFailure = (error) => {
17753
17896
  reportDiagnostic(
17754
- `writer lease lock cleanup failed (release is best-effort; residual lock left in place) at ${join13(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
17897
+ `writer lease lock cleanup failed (release is best-effort; residual lock left in place) at ${join12(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
17755
17898
  );
17756
17899
  };
17757
17900
  const reportReadFailure = (error) => {
17758
17901
  reportDiagnostic(
17759
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join13(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
17902
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join12(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
17760
17903
  );
17761
17904
  };
17762
- const lockPath = join13(runDirectory, WRITER_LOCK_FILE);
17905
+ const lockPath = join12(runDirectory, WRITER_LOCK_FILE);
17763
17906
  let lastAutopsy = { verdict: "absent" };
17764
17907
  let lastReclaimFailure;
17765
17908
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -17809,7 +17952,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
17809
17952
  async function findRunDirectoryById(home, runId) {
17810
17953
  if (runId.trim() === "") return void 0;
17811
17954
  const ledgerHome = resolveActivationLedgerHome(home);
17812
- const booksRoot = join13(ledgerHome, "books");
17955
+ const booksRoot = join12(ledgerHome, "books");
17813
17956
  let bookKeys;
17814
17957
  try {
17815
17958
  bookKeys = await readdir2(booksRoot);
@@ -17817,7 +17960,7 @@ async function findRunDirectoryById(home, runId) {
17817
17960
  return void 0;
17818
17961
  }
17819
17962
  for (const bookKey of bookKeys) {
17820
- const runsDir = join13(activationBookDirectory(ledgerHome, bookKey), "runs");
17963
+ const runsDir = join12(activationBookDirectory(ledgerHome, bookKey), "runs");
17821
17964
  let entries;
17822
17965
  try {
17823
17966
  entries = await readdir2(runsDir);
@@ -17826,7 +17969,7 @@ async function findRunDirectoryById(home, runId) {
17826
17969
  }
17827
17970
  for (const entry of entries) {
17828
17971
  if (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) {
17829
- return join13(runsDir, entry);
17972
+ return join12(runsDir, entry);
17830
17973
  }
17831
17974
  }
17832
17975
  }
@@ -17834,7 +17977,7 @@ async function findRunDirectoryById(home, runId) {
17834
17977
  }
17835
17978
  async function findLatestRunIdForSeatTicket(input) {
17836
17979
  const ledgerHome = resolveActivationLedgerHome(input.home);
17837
- const runsDir = join13(
17980
+ const runsDir = join12(
17838
17981
  activationBookDirectory(ledgerHome, input.bookKey),
17839
17982
  "runs"
17840
17983
  );
@@ -17851,7 +17994,7 @@ async function findLatestRunIdForSeatTicket(input) {
17851
17994
  if (!entry.endsWith(suffix)) continue;
17852
17995
  const runId = entry.slice(0, entry.length - suffix.length);
17853
17996
  if (runId.length === 0) continue;
17854
- const ticketNumber = await readRunTicketNumber(join13(runsDir, entry));
17997
+ const ticketNumber = await readRunTicketNumber(join12(runsDir, entry));
17855
17998
  if (ticketNumber !== input.ticketNumber) continue;
17856
17999
  if (best === void 0 || runId > best) best = runId;
17857
18000
  }
@@ -17920,7 +18063,7 @@ async function loadResumableRunRecord(home, runId, authority) {
17920
18063
  let sourceRun;
17921
18064
  try {
17922
18065
  const raw = JSON.parse(
17923
- await readFile9(run.admittedRequestPath, "utf8")
18066
+ await readFile8(run.admittedRequestPath, "utf8")
17924
18067
  );
17925
18068
  if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
17926
18069
  const record4 = raw;
@@ -18033,7 +18176,7 @@ async function loadResumableRunRecord(home, runId, authority) {
18033
18176
  let model;
18034
18177
  try {
18035
18178
  const invocationRaw = JSON.parse(
18036
- await readFile9(join13(run.runDirectory, "invocation.json"), "utf8")
18179
+ await readFile8(join12(run.runDirectory, "invocation.json"), "utf8")
18037
18180
  );
18038
18181
  if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
18039
18182
  const rec = invocationRaw;
@@ -18235,7 +18378,7 @@ async function loadResumableCountersignRun(home, runId, authority) {
18235
18378
  }
18236
18379
  async function loadResumableInstructionSeatRun(home, runId, authority) {
18237
18380
  const loaded = await loadResumableRunRecord(home, runId, authority);
18238
- if (loaded.run.role !== "gatekeeper" && loaded.run.role !== "navigator") {
18381
+ if (loaded.run.role !== "gatekeeper" && loaded.run.role !== "navigator" && loaded.run.role !== "auditor" && loaded.run.role !== "evidence-child") {
18239
18382
  throw new CliUsageError(
18240
18383
  `role run ${runId} belongs to ${loaded.run.role}, not an instruction seat`
18241
18384
  );
@@ -18438,7 +18581,13 @@ var init_run_lifecycle = __esm({
18438
18581
  });
18439
18582
 
18440
18583
  // src/notary-source-run.ts
18441
- import { dirname as dirname7, isAbsolute as isAbsolute4, join as join14, resolve as resolve6, basename as basename4 } from "node:path";
18584
+ var notary_source_run_exports = {};
18585
+ __export(notary_source_run_exports, {
18586
+ NotarySourceRunError: () => NotarySourceRunError,
18587
+ loadNotarySourceRunLocator: () => loadNotarySourceRunLocator,
18588
+ resolveNotarySourceRunLocator: () => resolveNotarySourceRunLocator
18589
+ });
18590
+ import { dirname as dirname7, isAbsolute as isAbsolute4, join as join13, resolve as resolve6, basename as basename4 } from "node:path";
18442
18591
  import { lstat as lstat2, realpath as realpath3 } from "node:fs/promises";
18443
18592
  function parseRunDirectoryName(name) {
18444
18593
  const match = RUN_DIR_NAME.exec(name);
@@ -18484,11 +18633,11 @@ async function resolveNotarySourceRunLocator(options) {
18484
18633
  }
18485
18634
  const ledgerHome = resolveActivationLedgerHome(options.home);
18486
18635
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
18487
- const bookRunsRoot = join14(activationBookDirectory(ledgerHome, bookKey), "runs");
18636
+ const bookRunsRoot = join13(activationBookDirectory(ledgerHome, bookKey), "runs");
18488
18637
  let candidate;
18489
18638
  const bare = parseRunDirectoryName(raw);
18490
18639
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
18491
- candidate = join14(bookRunsRoot, `${bare.runId}@${bare.role}`);
18640
+ candidate = join13(bookRunsRoot, `${bare.runId}@${bare.role}`);
18492
18641
  } else {
18493
18642
  candidate = isAbsolute4(raw) ? raw : resolve6(options.projectRoot, raw);
18494
18643
  }
@@ -18528,6 +18677,31 @@ async function resolveNotarySourceRunLocator(options) {
18528
18677
  role: identity.role
18529
18678
  };
18530
18679
  }
18680
+ async function loadNotarySourceRunLocator(path) {
18681
+ const real = await requireRunDirectory(path, path);
18682
+ const identity = parseRunDirectoryName(basename4(real));
18683
+ const runState = await readRoleRunIdentity(real);
18684
+ if (runState === void 0) {
18685
+ throw new NotarySourceRunError(
18686
+ "notary source-run lacks retained run-state identity"
18687
+ );
18688
+ }
18689
+ if (runState.runId !== identity.runId || runState.role !== identity.role) {
18690
+ throw new NotarySourceRunError(
18691
+ "notary source-run retained identity does not match directory name"
18692
+ );
18693
+ }
18694
+ if (physicalPathIdentity(runState.runDirectory) !== physicalPathIdentity(real)) {
18695
+ throw new NotarySourceRunError(
18696
+ "notary source-run retained runDirectory does not match locator path"
18697
+ );
18698
+ }
18699
+ return {
18700
+ runDirectory: real,
18701
+ runId: identity.runId,
18702
+ role: identity.role
18703
+ };
18704
+ }
18531
18705
  var RUN_DIR_NAME, NotarySourceRunError;
18532
18706
  var init_notary_source_run = __esm({
18533
18707
  "src/notary-source-run.ts"() {
@@ -18535,7 +18709,7 @@ var init_notary_source_run = __esm({
18535
18709
  init_activation_ledger_git();
18536
18710
  init_activation_ledger_topology();
18537
18711
  init_run_lifecycle();
18538
- RUN_DIR_NAME = /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})@([A-Za-z][A-Za-z0-9_-]*)$/i;
18712
+ RUN_DIR_NAME = /^([A-Za-z0-9][A-Za-z0-9._-]*)@([A-Za-z][A-Za-z0-9_-]*)$/;
18539
18713
  NotarySourceRunError = class extends Error {
18540
18714
  constructor(message, options) {
18541
18715
  super(message, options);
@@ -18795,7 +18969,7 @@ function renderHumanOwnerOptionLines(owner, locale2 = "en") {
18795
18969
  }
18796
18970
  return lines;
18797
18971
  }
18798
- var ANALYST_REQUIRE_ANY_OF, ANALYST_DEFAULT_MODE, REJECTED_PUBLIC_SPELLINGS, GLOBAL_OPTIONS, SHARED_PROJECT_SEMANTICS, SHARED_ATTACH_SEMANTICS, JUDGE_OPTIONS, GLEANER_LEFT_OPTIONS, INSPECTOR_OPTIONS, GATEKEEPER_OPTIONS, NAVIGATOR_OPTIONS, COUNTERSIGN_OPTIONS, DIARIST_OPTIONS, CODER_OPTIONS, FIXER_OPTIONS, REVIEWER_OPTIONS, COLLECTOR_OPTIONS, DOCTOR_OPTIONS, NOTARY_OPTIONS, MERGER_OPTIONS, ANALYST_OPTIONS, PUBLIC_OPTION_TABLE, PUBLIC_NAVIGATOR_HELP_NOTE, TOP_LEVEL_HELP, ROLE_COMMAND_HELP, SUPPORT_COMMAND_HELP, PUBLIC_COMMAND_HELP;
18972
+ var ANALYST_REQUIRE_ANY_OF, ANALYST_DEFAULT_MODE, REJECTED_PUBLIC_SPELLINGS, GLOBAL_OPTIONS, SHARED_PROJECT_SEMANTICS, SHARED_ATTACH_SEMANTICS, JUDGE_OPTIONS, GLEANER_LEFT_OPTIONS, INSPECTOR_OPTIONS, GATEKEEPER_OPTIONS, NAVIGATOR_OPTIONS, AUDITOR_OPTIONS, EVIDENCE_CHILD_OPTIONS, COUNTERSIGN_OPTIONS, DIARIST_OPTIONS, CODER_OPTIONS, FIXER_OPTIONS, REVIEWER_OPTIONS, COLLECTOR_OPTIONS, DOCTOR_OPTIONS, NOTARY_OPTIONS, MERGER_OPTIONS, ANALYST_OPTIONS, PUBLIC_OPTION_TABLE, PUBLIC_NAVIGATOR_HELP_NOTE, TOP_LEVEL_HELP, ROLE_COMMAND_HELP, SUPPORT_COMMAND_HELP, PUBLIC_COMMAND_HELP;
18799
18973
  var init_option_definitions = __esm({
18800
18974
  "src/public-cli/option-definitions.ts"() {
18801
18975
  "use strict";
@@ -18968,6 +19142,42 @@ var init_option_definitions = __esm({
18968
19142
  bindOwner("navigator", SHARED_PROJECT_SEMANTICS),
18969
19143
  bindOwner("navigator", SHARED_ATTACH_SEMANTICS)
18970
19144
  ];
19145
+ AUDITOR_OPTIONS = [
19146
+ bindOwner("auditor", SHARED_PROJECT_SEMANTICS),
19147
+ bindOwner("auditor", SHARED_ATTACH_SEMANTICS),
19148
+ {
19149
+ id: "subject",
19150
+ owner: "auditor",
19151
+ canonical: "--subject",
19152
+ aliases: [],
19153
+ valueMetavar: "judge|doctor",
19154
+ required: true,
19155
+ repeatable: false,
19156
+ form: "option",
19157
+ description: {
19158
+ en: "Required audited subject: judge or doctor (selects judge-auditor.md / doctor-auditor.md).",
19159
+ zh: "\u5FC5\u586B\u53D7\u5BA1\u5BF9\u8C61\uFF1Ajudge \u6216 doctor\uFF08\u88C5 judge-auditor.md / doctor-auditor.md\uFF09\u3002"
19160
+ }
19161
+ },
19162
+ {
19163
+ id: "source-run",
19164
+ owner: "auditor",
19165
+ canonical: "--source-run",
19166
+ aliases: [],
19167
+ valueMetavar: "runId@role|path",
19168
+ required: true,
19169
+ repeatable: false,
19170
+ form: "option",
19171
+ description: {
19172
+ en: "Required source run locator of the audited subject volume (same input for direct and nested summons).",
19173
+ zh: "\u5FC5\u586B\u53D7\u5BA1\u5377\u5B97 locator\uFF08\u76F4\u8C03\u4E0E\u4F20\u53EC\u540C\u4E00\u8F93\u5165\u9762\uFF09\u3002"
19174
+ }
19175
+ }
19176
+ ];
19177
+ EVIDENCE_CHILD_OPTIONS = [
19178
+ bindOwner("evidence-child", SHARED_PROJECT_SEMANTICS),
19179
+ bindOwner("evidence-child", SHARED_ATTACH_SEMANTICS)
19180
+ ];
18971
19181
  COUNTERSIGN_OPTIONS = [
18972
19182
  bindOwner("countersign", SHARED_PROJECT_SEMANTICS),
18973
19183
  bindOwner("countersign", SHARED_ATTACH_SEMANTICS)
@@ -19321,6 +19531,8 @@ var init_option_definitions = __esm({
19321
19531
  inspector: INSPECTOR_OPTIONS,
19322
19532
  gatekeeper: GATEKEEPER_OPTIONS,
19323
19533
  navigator: NAVIGATOR_OPTIONS,
19534
+ auditor: AUDITOR_OPTIONS,
19535
+ "evidence-child": EVIDENCE_CHILD_OPTIONS,
19324
19536
  diarist: DIARIST_OPTIONS,
19325
19537
  analyst: ANALYST_OPTIONS
19326
19538
  };
@@ -19440,6 +19652,23 @@ var init_option_definitions = __esm({
19440
19652
  'ak-role navigator "\u521A\u5B8C\u6210 coder apply \u6536\u655B\uFF0C\u4E0B\u4E00\u6B65\uFF1F"'
19441
19653
  ]
19442
19654
  },
19655
+ auditor: {
19656
+ command: "auditor",
19657
+ summary: "Direct Auditor (\u5BA1\u5211\u9662) compliance audit: pass, revise, or escalate.",
19658
+ usage: ["ak-role auditor --subject <judge|doctor> --source-run <runId@role|path> [options] [instruction]"],
19659
+ examples: [
19660
+ 'ak-role auditor --subject judge --source-run 01abc\u2026@judge --attach ./dossier "\u5BA1\uFF1A\u672C run \u662F\u5426\u5408\u89C4\u3002"',
19661
+ 'ak-role auditor --subject doctor --source-run 01abc\u2026@doctor "\u5BA1\uFF1A\u592A\u533B\u5019\u9009\u662F\u5426\u5408\u89C4\u3002"'
19662
+ ]
19663
+ },
19664
+ "evidence-child": {
19665
+ command: "evidence-child",
19666
+ summary: "Direct evidence-child fact gathering; submit one report.",
19667
+ usage: ["ak-role evidence-child [options] [instruction]"],
19668
+ examples: [
19669
+ 'ak-role evidence-child "\u67E5\uFF1A\u672C\u5DE5\u4F5C\u6811 diff \u4E0E\u7968\u9762\u662F\u5426\u4E00\u81F4\u3002"'
19670
+ ]
19671
+ },
19443
19672
  diarist: {
19444
19673
  command: "diarist",
19445
19674
  summary: "Direct Diarist (\u8D77\u5C45\u90CE) pass: gather and organize this case's decision basis into its \u8D77\u5C45\u5F55.",
@@ -19541,15 +19770,15 @@ import { execFileSync as execFileSync2 } from "node:child_process";
19541
19770
  import {
19542
19771
  lstat as lstat3,
19543
19772
  mkdir as mkdir2,
19544
- readFile as readFile10,
19773
+ readFile as readFile9,
19545
19774
  realpath as realpath4,
19546
- writeFile as writeFile6
19775
+ writeFile as writeFile5
19547
19776
  } from "node:fs/promises";
19548
- import { basename as basename5, isAbsolute as isAbsolute5, join as join15, resolve as resolve7, sep as sep3 } from "node:path";
19777
+ import { basename as basename5, isAbsolute as isAbsolute5, join as join14, resolve as resolve7, sep as sep3 } from "node:path";
19549
19778
  function issueAdmissionPlacement(authority, request) {
19550
19779
  const principal = authority.issue(request);
19551
19780
  const { sessionDirectory, sessionFile } = authority.decode(principal);
19552
- const runDirectory = join15(sessionDirectory, "..");
19781
+ const runDirectory = join14(sessionDirectory, "..");
19553
19782
  const ledgerHome = resolveActivationLedgerHome(request.home);
19554
19783
  const bookKey = resolveBookKeyFromGit(request.cwd);
19555
19784
  return {
@@ -19568,7 +19797,7 @@ async function writeAdmittedRequestPersistence(admittedRequestPath, body, coordi
19568
19797
  sessionDirectory: coordinates.sessionDirectory,
19569
19798
  sessionFile: coordinates.sessionFile
19570
19799
  };
19571
- await writeFile6(
19800
+ await writeFile5(
19572
19801
  admittedRequestPath,
19573
19802
  `${JSON.stringify(projection, null, 2)}
19574
19803
  `,
@@ -19596,20 +19825,16 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
19596
19825
  ...source.ticketNumber === void 0 ? {} : { ticketNumber: source.ticketNumber },
19597
19826
  ...effectiveModelLedgerFields(effectiveModel)
19598
19827
  };
19599
- await writeFile6(
19600
- join15(source.runDirectory, "invocation.json"),
19828
+ await writeFile5(
19829
+ join14(source.runDirectory, "invocation.json"),
19601
19830
  `${JSON.stringify(identity, null, 2)}
19602
19831
  `,
19603
19832
  "utf8"
19604
19833
  );
19605
- const home = homeFromRunDirectory(source.runDirectory);
19606
- const config = await loadPublicCliConfig(home);
19607
- const institutionalPage = resolveInstitutionalSeatSelections(config, effectiveModel);
19608
- await writeInstitutionalResolutionPage(source.runDirectory, institutionalPage);
19609
19834
  }
19610
19835
  async function recordEffectiveInvocationModel(runDirectory, model, engine, host) {
19611
- const ledgerPath = join15(runDirectory, "invocation.json");
19612
- const current = JSON.parse(await readFile10(ledgerPath, "utf8"));
19836
+ const ledgerPath = join14(runDirectory, "invocation.json");
19837
+ const current = JSON.parse(await readFile9(ledgerPath, "utf8"));
19613
19838
  const next = { ...current };
19614
19839
  if (model !== void 0) {
19615
19840
  next.provider = model.provider;
@@ -19628,26 +19853,17 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host)
19628
19853
  if (host !== void 0) {
19629
19854
  next.host = host;
19630
19855
  }
19631
- await writeFile6(
19856
+ await writeFile5(
19632
19857
  ledgerPath,
19633
19858
  `${JSON.stringify(next, null, 2)}
19634
19859
  `,
19635
19860
  "utf8"
19636
19861
  );
19637
- const effectiveModel = typeof next.provider === "string" && typeof next.model === "string" ? {
19638
- provider: next.provider,
19639
- model: next.model,
19640
- ...typeof next.thinking === "string" ? { thinking: next.thinking } : {}
19641
- } : void 0;
19642
- const home = homeFromRunDirectory(runDirectory);
19643
- const config = await loadPublicCliConfig(home);
19644
- const institutionalPage = resolveInstitutionalSeatSelections(config, effectiveModel);
19645
- await writeInstitutionalResolutionPage(runDirectory, institutionalPage);
19646
19862
  }
19647
19863
  async function mergeInvocationIdentityPage(runDirectory, fields) {
19648
- const ledgerPath = join15(runDirectory, "invocation.json");
19649
- const current = JSON.parse(await readFile10(ledgerPath, "utf8"));
19650
- await writeFile6(
19864
+ const ledgerPath = join14(runDirectory, "invocation.json");
19865
+ const current = JSON.parse(await readFile9(ledgerPath, "utf8"));
19866
+ await writeFile5(
19651
19867
  ledgerPath,
19652
19868
  `${JSON.stringify({
19653
19869
  ...current,
@@ -19675,8 +19891,8 @@ async function bindAdmittedTicketNumber(admitted, ticketNumber) {
19675
19891
  admitted.ticketNumber = ticketNumber;
19676
19892
  await mergeInvocationIdentityPage(admitted.runDirectory, { ticketNumber });
19677
19893
  const admittedPath = admitted.admittedRequestPath;
19678
- const current = JSON.parse(await readFile10(admittedPath, "utf8"));
19679
- await writeFile6(
19894
+ const current = JSON.parse(await readFile9(admittedPath, "utf8"));
19895
+ await writeFile5(
19680
19896
  admittedPath,
19681
19897
  `${JSON.stringify({ ...current, ticketNumber }, null, 2)}
19682
19898
  `,
@@ -19695,8 +19911,8 @@ async function recordTrueUnboundTicketResolution(admitted) {
19695
19911
  ticketResolution: "true-unbound"
19696
19912
  });
19697
19913
  const admittedPath = admitted.admittedRequestPath;
19698
- const current = JSON.parse(await readFile10(admittedPath, "utf8"));
19699
- await writeFile6(
19914
+ const current = JSON.parse(await readFile9(admittedPath, "utf8"));
19915
+ await writeFile5(
19700
19916
  admittedPath,
19701
19917
  `${JSON.stringify({ ...current, ticketResolution: "true-unbound" }, null, 2)}
19702
19918
  `,
@@ -19712,7 +19928,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
19712
19928
  async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
19713
19929
  const rolePackageRoot = packageRoot2;
19714
19930
  const raw = JSON.parse(
19715
- await readFile10(join15(rolePackageRoot, "package.json"), "utf8")
19931
+ await readFile9(join14(rolePackageRoot, "package.json"), "utf8")
19716
19932
  );
19717
19933
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
19718
19934
  throw new Error(
@@ -19737,6 +19953,8 @@ async function recordLaunchedRolePackageIdentity(runDirectory, identity) {
19737
19953
  function parseInstructionArgv(args, owner) {
19738
19954
  const attachmentPaths = [];
19739
19955
  let project;
19956
+ let subject;
19957
+ let sourceRun;
19740
19958
  const positional = [];
19741
19959
  const tokens = [...args];
19742
19960
  const definitions = roleOptions(owner);
@@ -19757,6 +19975,24 @@ function parseInstructionArgv(args, owner) {
19757
19975
  project = requireOptionPath(taken.def.canonical, taken.value);
19758
19976
  continue;
19759
19977
  }
19978
+ if (taken.def.id === "subject") {
19979
+ const raw = typeof taken.value === "string" ? taken.value.trim() : "";
19980
+ if (raw !== "judge" && raw !== "doctor") {
19981
+ throw new CliUsageError(
19982
+ `auditor --subject must be judge|doctor, got ${taken.value ?? "(missing)"}`
19983
+ );
19984
+ }
19985
+ subject = raw;
19986
+ continue;
19987
+ }
19988
+ if (taken.def.id === "source-run") {
19989
+ const raw = typeof taken.value === "string" ? taken.value.trim() : "";
19990
+ if (raw === "") {
19991
+ throw new CliUsageError("auditor --source-run requires a run locator");
19992
+ }
19993
+ sourceRun = raw;
19994
+ continue;
19995
+ }
19760
19996
  throw new CliUsageError(`unknown ${owner} option: ${taken.def.canonical}`);
19761
19997
  }
19762
19998
  const token = tokens.shift();
@@ -19769,7 +20005,9 @@ function parseInstructionArgv(args, owner) {
19769
20005
  return {
19770
20006
  instruction: positional.join(" "),
19771
20007
  attachmentPaths,
19772
- ...project === void 0 ? {} : { project }
20008
+ ...project === void 0 ? {} : { project },
20009
+ ...subject === void 0 ? {} : { subject },
20010
+ ...sourceRun === void 0 ? {} : { sourceRun }
19773
20011
  };
19774
20012
  }
19775
20013
  function requireOptionPath(flag, value) {
@@ -19827,6 +20065,12 @@ function parseGatekeeperArgv(args) {
19827
20065
  function parseNavigatorArgv(args) {
19828
20066
  return parseInstructionArgv(args, "navigator");
19829
20067
  }
20068
+ function parseAuditorArgv(args) {
20069
+ return parseInstructionArgv(args, "auditor");
20070
+ }
20071
+ function parseEvidenceChildArgv(args) {
20072
+ return parseInstructionArgv(args, "evidence-child");
20073
+ }
19830
20074
  function parseDiaristArgv(args) {
19831
20075
  return parseInstructionArgv(args, "diarist");
19832
20076
  }
@@ -19932,10 +20176,10 @@ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
19932
20176
  `attachment must be a regular file (not a directory or symlink): ${sourcePath}`
19933
20177
  );
19934
20178
  }
19935
- const bytes = await readFile10(absolute);
20179
+ const bytes = await readFile9(absolute);
19936
20180
  const name = `${String(index).padStart(2, "0")}-${basename5(absolute)}`;
19937
- const frozenPath = join15(destinationDir, name);
19938
- await writeFile6(frozenPath, bytes);
20181
+ const frozenPath = join14(destinationDir, name);
20182
+ await writeFile5(frozenPath, bytes);
19939
20183
  return {
19940
20184
  attachment: {
19941
20185
  provenancePath: absolute,
@@ -19962,7 +20206,7 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
19962
20206
  async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
19963
20207
  if (attachmentPaths.length === 0) return [];
19964
20208
  const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
19965
- const attachmentsDirectory = join15(runDirectory, "attachments", summonsKey);
20209
+ const attachmentsDirectory = join14(runDirectory, "attachments", summonsKey);
19966
20210
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
19967
20211
  return freezeAttachments(attachmentPaths, attachmentsDirectory);
19968
20212
  }
@@ -19988,7 +20232,7 @@ async function admitStandardMaterialInvocation(role, options) {
19988
20232
  role,
19989
20233
  home: options.home
19990
20234
  });
19991
- const attachmentsDirectory = join15(runDirectory, "attachments");
20235
+ const attachmentsDirectory = join14(runDirectory, "attachments");
19992
20236
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
19993
20237
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
19994
20238
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
@@ -20013,7 +20257,7 @@ async function admitStandardMaterialInvocation(role, options) {
20013
20257
  mediaKind: a.mediaKind
20014
20258
  }))
20015
20259
  };
20016
- const admittedRequestPath = join15(runDirectory, "admitted-request.json");
20260
+ const admittedRequestPath = join14(runDirectory, "admitted-request.json");
20017
20261
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
20018
20262
  sessionDirectory,
20019
20263
  sessionFile
@@ -20049,6 +20293,12 @@ async function admitGatekeeperInvocation(options) {
20049
20293
  async function admitNavigatorInvocation(options) {
20050
20294
  return admitStandardMaterialInvocation("navigator", options);
20051
20295
  }
20296
+ async function admitAuditorInvocation(options) {
20297
+ return admitStandardMaterialInvocation("auditor", options);
20298
+ }
20299
+ async function admitEvidenceChildInvocation(options) {
20300
+ return admitStandardMaterialInvocation("evidence-child", options);
20301
+ }
20052
20302
  async function admitDiaristInvocation(options) {
20053
20303
  return admitStandardMaterialInvocation("diarist", options);
20054
20304
  }
@@ -20088,7 +20338,7 @@ async function admitCountersignInvocation(options) {
20088
20338
  role: "countersign",
20089
20339
  home: options.home
20090
20340
  });
20091
- const attachmentsDirectory = join15(runDirectory, "attachments");
20341
+ const attachmentsDirectory = join14(runDirectory, "attachments");
20092
20342
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
20093
20343
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
20094
20344
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
@@ -20112,7 +20362,7 @@ async function admitCountersignInvocation(options) {
20112
20362
  mediaKind: a.mediaKind
20113
20363
  }))
20114
20364
  };
20115
- const admittedRequestPath = join15(runDirectory, "admitted-request.json");
20365
+ const admittedRequestPath = join14(runDirectory, "admitted-request.json");
20116
20366
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
20117
20367
  sessionDirectory,
20118
20368
  sessionFile
@@ -20136,7 +20386,7 @@ function buildCountersignTransportPrompt(admitted, engineMaterial) {
20136
20386
  return buildInstructionTransportPrompt(admitted, engineMaterial);
20137
20387
  }
20138
20388
  async function ensureRunArtifactsDir(runDirectory) {
20139
- const dir = join15(runDirectory, "artifacts");
20389
+ const dir = join14(runDirectory, "artifacts");
20140
20390
  await mkdir2(dir, { recursive: true });
20141
20391
  return dir;
20142
20392
  }
@@ -20168,12 +20418,12 @@ async function admitCoderInvocation(options) {
20168
20418
  role: "coder",
20169
20419
  home: options.home
20170
20420
  });
20171
- const attachmentsDirectory = join15(runDirectory, "attachments");
20421
+ const attachmentsDirectory = join14(runDirectory, "attachments");
20172
20422
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
20173
20423
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
20174
20424
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
20175
- const taskPath = join15(runDirectory, "task.md");
20176
- await writeFile6(taskPath, instruction, "utf8");
20425
+ const taskPath = join14(runDirectory, "task.md");
20426
+ await writeFile5(taskPath, instruction, "utf8");
20177
20427
  const admitted = {
20178
20428
  role: "coder",
20179
20429
  phase: options.phase,
@@ -20193,7 +20443,7 @@ async function admitCoderInvocation(options) {
20193
20443
  mediaKind: a.mediaKind
20194
20444
  }))
20195
20445
  };
20196
- const admittedRequestPath = join15(runDirectory, "admitted-request.json");
20446
+ const admittedRequestPath = join14(runDirectory, "admitted-request.json");
20197
20447
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
20198
20448
  sessionDirectory,
20199
20449
  sessionFile
@@ -20243,7 +20493,7 @@ async function admitFixerInvocation(options) {
20243
20493
  if (options.prerequisitesPath !== void 0) {
20244
20494
  const absolutePrereq = isAbsolute5(options.prerequisitesPath) ? options.prerequisitesPath : resolve7(options.prerequisitesPath);
20245
20495
  try {
20246
- prerequisitesSource = await readFile10(absolutePrereq, "utf8");
20496
+ prerequisitesSource = await readFile9(absolutePrereq, "utf8");
20247
20497
  } catch (error) {
20248
20498
  throw new CliUsageError(
20249
20499
  `fixer prerequisites path is unreadable: ${options.prerequisitesPath}`,
@@ -20274,22 +20524,22 @@ async function admitFixerInvocation(options) {
20274
20524
  role: "fixer",
20275
20525
  home: options.home
20276
20526
  });
20277
- const attachmentsDirectory = join15(runDirectory, "attachments");
20527
+ const attachmentsDirectory = join14(runDirectory, "attachments");
20278
20528
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
20279
20529
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
20280
20530
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
20281
20531
  let prerequisitesPath;
20282
20532
  if (prerequisitesSource !== void 0) {
20283
- prerequisitesPath = join15(runDirectory, "prerequisites.json");
20284
- await writeFile6(
20533
+ prerequisitesPath = join14(runDirectory, "prerequisites.json");
20534
+ await writeFile5(
20285
20535
  prerequisitesPath,
20286
20536
  `${JSON.stringify(prerequisites, null, 2)}
20287
20537
  `,
20288
20538
  "utf8"
20289
20539
  );
20290
20540
  }
20291
- const packetPath = join15(runDirectory, "fix-packet.md");
20292
- await writeFile6(packetPath, instruction, "utf8");
20541
+ const packetPath = join14(runDirectory, "fix-packet.md");
20542
+ await writeFile5(packetPath, instruction, "utf8");
20293
20543
  const admitted = {
20294
20544
  role: "fixer",
20295
20545
  phase: options.phase,
@@ -20314,7 +20564,7 @@ async function admitFixerInvocation(options) {
20314
20564
  mediaKind: a.mediaKind
20315
20565
  }))
20316
20566
  };
20317
- const admittedRequestPath = join15(runDirectory, "admitted-request.json");
20567
+ const admittedRequestPath = join14(runDirectory, "admitted-request.json");
20318
20568
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
20319
20569
  sessionDirectory,
20320
20570
  sessionFile
@@ -20523,14 +20773,14 @@ async function admitCollectorInvocation(options) {
20523
20773
  role: "collector",
20524
20774
  home: options.home
20525
20775
  });
20526
- const attachmentsDirectory = join15(runDirectory, "attachments");
20776
+ const attachmentsDirectory = join14(runDirectory, "attachments");
20527
20777
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
20528
20778
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
20529
20779
  const attachments = await freezeAttachments(options.attachmentPaths ?? [], attachmentsDirectory);
20530
20780
  let requestManifestPath;
20531
20781
  if (manifestCanonicalJson !== void 0) {
20532
- requestManifestPath = join15(runDirectory, "request-manifest.json");
20533
- await writeFile6(requestManifestPath, manifestCanonicalJson, "utf8");
20782
+ requestManifestPath = join14(runDirectory, "request-manifest.json");
20783
+ await writeFile5(requestManifestPath, manifestCanonicalJson, "utf8");
20534
20784
  }
20535
20785
  const instruction = options.instruction ?? "";
20536
20786
  const instructionEmpty = instruction.trim() === "";
@@ -20556,7 +20806,7 @@ async function admitCollectorInvocation(options) {
20556
20806
  mediaKind: a.mediaKind
20557
20807
  }))
20558
20808
  };
20559
- const admittedRequestPath = join15(runDirectory, "admitted-request.json");
20809
+ const admittedRequestPath = join14(runDirectory, "admitted-request.json");
20560
20810
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
20561
20811
  sessionDirectory,
20562
20812
  sessionFile
@@ -20653,7 +20903,7 @@ function parseDoctorArgv(args) {
20653
20903
  }
20654
20904
  async function resolveDoctorCaseRunsPath(options) {
20655
20905
  const ledgerHome = resolveActivationLedgerHome(options.home);
20656
- const defaultRuns = join15(
20906
+ const defaultRuns = join14(
20657
20907
  activationBookDirectory(ledgerHome, options.bookKey),
20658
20908
  "issues",
20659
20909
  String(options.issueNumber),
@@ -20760,7 +21010,7 @@ async function admitDoctorInvocation(options) {
20760
21010
  { cause: error }
20761
21011
  );
20762
21012
  }
20763
- const attachmentsDirectory = join15(runDirectory, "attachments");
21013
+ const attachmentsDirectory = join14(runDirectory, "attachments");
20764
21014
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
20765
21015
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
20766
21016
  const attachments = await freezeAttachments(options.attachmentPaths ?? [], attachmentsDirectory);
@@ -20786,7 +21036,7 @@ async function admitDoctorInvocation(options) {
20786
21036
  mediaKind: a.mediaKind
20787
21037
  }))
20788
21038
  };
20789
- const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21039
+ const admittedRequestPath = join14(runDirectory, "admitted-request.json");
20790
21040
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
20791
21041
  sessionDirectory,
20792
21042
  sessionFile
@@ -20918,7 +21168,7 @@ async function admitNotaryInvocation(options) {
20918
21168
  ...ticketFields,
20919
21169
  ...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
20920
21170
  };
20921
- const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21171
+ const admittedRequestPath = join14(runDirectory, "admitted-request.json");
20922
21172
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
20923
21173
  sessionDirectory,
20924
21174
  sessionFile
@@ -21020,7 +21270,7 @@ async function admitGleanerLeftInvocation(options) {
21020
21270
  attachments: [],
21021
21271
  ...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
21022
21272
  };
21023
- const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21273
+ const admittedRequestPath = join14(runDirectory, "admitted-request.json");
21024
21274
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21025
21275
  sessionDirectory,
21026
21276
  sessionFile
@@ -21125,7 +21375,7 @@ async function admitReviewerInvocation(options) {
21125
21375
  role: "reviewer",
21126
21376
  home: options.home
21127
21377
  });
21128
- const attachmentsDirectory = join15(runDirectory, "attachments");
21378
+ const attachmentsDirectory = join14(runDirectory, "attachments");
21129
21379
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
21130
21380
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
21131
21381
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
@@ -21150,7 +21400,7 @@ async function admitReviewerInvocation(options) {
21150
21400
  mediaKind: a.mediaKind
21151
21401
  }))
21152
21402
  };
21153
- const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21403
+ const admittedRequestPath = join14(runDirectory, "admitted-request.json");
21154
21404
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21155
21405
  sessionDirectory,
21156
21406
  sessionFile
@@ -21277,7 +21527,7 @@ async function admitMergerInvocation(options) {
21277
21527
  role: "merger",
21278
21528
  home: options.home
21279
21529
  });
21280
- const attachmentsDirectory = join15(runDirectory, "attachments");
21530
+ const attachmentsDirectory = join14(runDirectory, "attachments");
21281
21531
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
21282
21532
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
21283
21533
  const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
@@ -21305,8 +21555,8 @@ async function admitMergerInvocation(options) {
21305
21555
  // Authorized checks remain available on the assignment; default none.
21306
21556
  authorizedChecks: []
21307
21557
  });
21308
- const mergerInputPath = join15(runDirectory, "merger-input.json");
21309
- await writeFile6(
21558
+ const mergerInputPath = join14(runDirectory, "merger-input.json");
21559
+ await writeFile5(
21310
21560
  mergerInputPath,
21311
21561
  `${JSON.stringify(mergerInput, null, 2)}
21312
21562
  `,
@@ -21337,7 +21587,7 @@ async function admitMergerInvocation(options) {
21337
21587
  mediaKind: a.mediaKind
21338
21588
  }))
21339
21589
  };
21340
- const admittedRequestPath = join15(runDirectory, "admitted-request.json");
21590
+ const admittedRequestPath = join14(runDirectory, "admitted-request.json");
21341
21591
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
21342
21592
  sessionDirectory,
21343
21593
  sessionFile
@@ -21610,8 +21860,6 @@ var init_invocation = __esm({
21610
21860
  init_engine_material();
21611
21861
  init_cli_errors();
21612
21862
  init_option_definitions();
21613
- init_config2();
21614
- init_institutional_resolution();
21615
21863
  MergerEnvelopeDerivationError = class extends Error {
21616
21864
  code = "merger-envelope-derivation";
21617
21865
  /** Typed cause for #107 classifyPostAdmissionFailure (isTypedActivationError). */
@@ -21629,8 +21877,8 @@ var init_invocation = __esm({
21629
21877
 
21630
21878
  // src/package-resources/method-skill.ts
21631
21879
  import { createHash as createHash4 } from "node:crypto";
21632
- import { readFile as readFile11, realpath as realpath5 } from "node:fs/promises";
21633
- import { join as join16 } from "node:path";
21880
+ import { readFile as readFile10, realpath as realpath5 } from "node:fs/promises";
21881
+ import { join as join15 } from "node:path";
21634
21882
  function gitBlobOid(bytes) {
21635
21883
  const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
21636
21884
  const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
@@ -21647,16 +21895,16 @@ function packagedMethodSkillRelativeDirectory(name) {
21647
21895
  return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
21648
21896
  }
21649
21897
  function resolvePackagedMethodSkillRoot(packageRoot2, name) {
21650
- return join16(packageRoot2, packagedMethodSkillRelativeDirectory(name));
21898
+ return join15(packageRoot2, packagedMethodSkillRelativeDirectory(name));
21651
21899
  }
21652
21900
  function resolvePackagedMethodSkillPath(packageRoot2, name) {
21653
- return join16(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
21901
+ return join15(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
21654
21902
  }
21655
- function isRecord8(value) {
21903
+ function isRecord10(value) {
21656
21904
  return typeof value === "object" && value !== null && !Array.isArray(value);
21657
21905
  }
21658
21906
  function parseProvenance(raw, expectedName) {
21659
- if (!isRecord8(raw)) {
21907
+ if (!isRecord10(raw)) {
21660
21908
  throw new Error(`Packaged method provenance must be an object for ${expectedName}`);
21661
21909
  }
21662
21910
  if (raw.name !== expectedName) {
@@ -21670,7 +21918,7 @@ function parseProvenance(raw, expectedName) {
21670
21918
  if (typeof raw.packageAdaptation !== "string" || raw.packageAdaptation.trim() === "") {
21671
21919
  throw new Error(`Packaged method provenance packageAdaptation must be nonblank`);
21672
21920
  }
21673
- if (!isRecord8(raw.upstream)) {
21921
+ if (!isRecord10(raw.upstream)) {
21674
21922
  throw new Error(`Packaged method provenance upstream must be an object`);
21675
21923
  }
21676
21924
  const upstream = raw.upstream;
@@ -21697,12 +21945,12 @@ function parseProvenance(raw, expectedName) {
21697
21945
  `Packaged method provenance upstream must include nonblank tag or version`
21698
21946
  );
21699
21947
  }
21700
- if (!isRecord8(raw.files)) {
21948
+ if (!isRecord10(raw.files)) {
21701
21949
  throw new Error(`Packaged method provenance files must be an object`);
21702
21950
  }
21703
21951
  const files = {};
21704
21952
  for (const [rel, entry] of Object.entries(raw.files)) {
21705
- if (!isRecord8(entry)) {
21953
+ if (!isRecord10(entry)) {
21706
21954
  throw new Error(`Packaged method provenance file entry must be an object: ${rel}`);
21707
21955
  }
21708
21956
  if (typeof entry.sha256 !== "string" || !SHA256_RE.test(entry.sha256)) {
@@ -21744,11 +21992,11 @@ function parseProvenance(raw, expectedName) {
21744
21992
  }
21745
21993
  async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
21746
21994
  const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot2, name);
21747
- const skillPathConfigured = join16(rootDirectory, "SKILL.md");
21748
- const provenancePath = join16(rootDirectory, "provenance.json");
21995
+ const skillPathConfigured = join15(rootDirectory, "SKILL.md");
21996
+ const provenancePath = join15(rootDirectory, "provenance.json");
21749
21997
  let provenanceRaw;
21750
21998
  try {
21751
- provenanceRaw = await readFile11(provenancePath, "utf8");
21999
+ provenanceRaw = await readFile10(provenancePath, "utf8");
21752
22000
  } catch (error) {
21753
22001
  throw new PackagedMethodSkillUnavailableError(name, provenancePath, error);
21754
22002
  }
@@ -21762,10 +22010,10 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
21762
22010
  }
21763
22011
  const provenance = parseProvenance(provenanceJson, name);
21764
22012
  for (const [rel, expected] of Object.entries(provenance.files)) {
21765
- const absolute = join16(rootDirectory, rel);
22013
+ const absolute = join15(rootDirectory, rel);
21766
22014
  let bytes;
21767
22015
  try {
21768
- bytes = await readFile11(absolute);
22016
+ bytes = await readFile10(absolute);
21769
22017
  } catch (error) {
21770
22018
  throw new PackagedMethodSkillUnavailableError(name, absolute, error);
21771
22019
  }
@@ -21781,7 +22029,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
21781
22029
  let raw;
21782
22030
  try {
21783
22031
  skillPath = await realpath5(skillPathConfigured);
21784
- raw = await readFile11(skillPath, "utf8");
22032
+ raw = await readFile10(skillPath, "utf8");
21785
22033
  } catch (error) {
21786
22034
  throw new PackagedMethodSkillUnavailableError(name, skillPathConfigured, error);
21787
22035
  }
@@ -21861,7 +22109,7 @@ var init_method_skill = __esm({
21861
22109
 
21862
22110
  // src/collector-github.ts
21863
22111
  import { spawn as spawn3 } from "node:child_process";
21864
- function isRecord9(value) {
22112
+ function isRecord11(value) {
21865
22113
  return typeof value === "object" && value !== null && !Array.isArray(value);
21866
22114
  }
21867
22115
  function requireString(value, label) {
@@ -21902,25 +22150,25 @@ function commentFailureCause(error) {
21902
22150
  };
21903
22151
  }
21904
22152
  function requireUserLogin(raw) {
21905
- if (!isRecord9(raw) || typeof raw["login"] !== "string") {
22153
+ if (!isRecord11(raw) || typeof raw["login"] !== "string") {
21906
22154
  throw new Error("GitHub payload missing user.login");
21907
22155
  }
21908
22156
  return raw["login"];
21909
22157
  }
21910
22158
  function optionalUserLogin(raw) {
21911
22159
  if (raw === null) return null;
21912
- if (!isRecord9(raw) || typeof raw["login"] !== "string") {
22160
+ if (!isRecord11(raw) || typeof raw["login"] !== "string") {
21913
22161
  throw new Error("GitHub payload missing user.login");
21914
22162
  }
21915
22163
  return raw["login"];
21916
22164
  }
21917
22165
  function machineIdentity(raw) {
21918
22166
  const user = raw["user"];
21919
- if (!isRecord9(user) || typeof user["type"] !== "string" || typeof user["id"] !== "number") {
22167
+ if (!isRecord11(user) || typeof user["type"] !== "string" || typeof user["id"] !== "number") {
21920
22168
  return null;
21921
22169
  }
21922
22170
  const app = raw["performed_via_github_app"];
21923
- const appId = isRecord9(app) && typeof app["id"] === "number" ? app["id"] : void 0;
22171
+ const appId = isRecord11(app) && typeof app["id"] === "number" ? app["id"] : void 0;
21924
22172
  return {
21925
22173
  userType: user["type"],
21926
22174
  userId: user["id"],
@@ -21928,9 +22176,9 @@ function machineIdentity(raw) {
21928
22176
  };
21929
22177
  }
21930
22178
  function normalizePullRequest(raw) {
21931
- if (!isRecord9(raw)) throw new Error("GitHub pull request payload must be an object");
22179
+ if (!isRecord11(raw)) throw new Error("GitHub pull request payload must be an object");
21932
22180
  const head = raw["head"];
21933
- if (!isRecord9(head) || typeof head["sha"] !== "string" || head["sha"].length === 0) {
22181
+ if (!isRecord11(head) || typeof head["sha"] !== "string" || head["sha"].length === 0) {
21934
22182
  throw new Error("GitHub pull request payload missing head.sha");
21935
22183
  }
21936
22184
  const number = requireNumber(raw["number"], "number");
@@ -21946,7 +22194,7 @@ function normalizePullRequest(raw) {
21946
22194
  };
21947
22195
  }
21948
22196
  function normalizePullRequestReaction(raw) {
21949
- if (!isRecord9(raw)) throw new Error("GitHub reaction payload must be an object");
22197
+ if (!isRecord11(raw)) throw new Error("GitHub reaction payload must be an object");
21950
22198
  return {
21951
22199
  id: requireNumber(raw["id"], "reaction.id"),
21952
22200
  userLogin: optionalUserLogin(raw["user"]),
@@ -21957,7 +22205,7 @@ function normalizePullRequestReaction(raw) {
21957
22205
  };
21958
22206
  }
21959
22207
  function normalizeReview(raw) {
21960
- if (!isRecord9(raw)) throw new Error("GitHub review payload must be an object");
22208
+ if (!isRecord11(raw)) throw new Error("GitHub review payload must be an object");
21961
22209
  return {
21962
22210
  id: requireNumber(raw["id"], "review.id"),
21963
22211
  ...typeof raw["node_id"] === "string" ? { nodeId: raw["node_id"] } : {},
@@ -21972,7 +22220,7 @@ function normalizeReview(raw) {
21972
22220
  };
21973
22221
  }
21974
22222
  function normalizeIssueComment(raw) {
21975
- if (!isRecord9(raw)) throw new Error("GitHub issue comment payload must be an object");
22223
+ if (!isRecord11(raw)) throw new Error("GitHub issue comment payload must be an object");
21976
22224
  return {
21977
22225
  id: requireNumber(raw["id"], "comment.id"),
21978
22226
  userLogin: optionalUserLogin(raw["user"]),
@@ -21985,7 +22233,7 @@ function normalizeIssueComment(raw) {
21985
22233
  };
21986
22234
  }
21987
22235
  function normalizeReviewComment(raw) {
21988
- if (!isRecord9(raw)) throw new Error("GitHub review comment payload must be an object");
22236
+ if (!isRecord11(raw)) throw new Error("GitHub review comment payload must be an object");
21989
22237
  return {
21990
22238
  id: requireNumber(raw["id"], "review_comment.id"),
21991
22239
  pullRequestReviewId: typeof raw["pull_request_review_id"] === "number" ? raw["pull_request_review_id"] : null,
@@ -22294,11 +22542,11 @@ function createGhCollectorGitHubTransport(runner = createGhApiRunner()) {
22294
22542
  if (input.signal?.aborted) {
22295
22543
  throw error;
22296
22544
  }
22297
- if (isRecord9(error) && error["ambiguousGhFailure"] === true) {
22545
+ if (isRecord11(error) && error["ambiguousGhFailure"] === true) {
22298
22546
  const cause = commentFailureCause(error);
22299
22547
  return { kind: "ambiguous_loss", diagnostics: cause.message, cause };
22300
22548
  }
22301
- if (isRecord9(error) && error["name"] === "AbortError") {
22549
+ if (isRecord11(error) && error["name"] === "AbortError") {
22302
22550
  throw error;
22303
22551
  }
22304
22552
  throw error;
@@ -22316,10 +22564,10 @@ var init_collector_github = __esm({
22316
22564
 
22317
22565
  // src/diarist-ticket-resolution.ts
22318
22566
  import { existsSync as existsSync6, readFileSync as readFileSync2 } from "node:fs";
22319
- import { join as join17 } from "node:path";
22567
+ import { join as join16 } from "node:path";
22320
22568
  import { fileURLToPath } from "node:url";
22321
22569
  function resolveDiaristResolveTicketMethodPath(packageRoot2 = fileURLToPath(new URL("..", import.meta.url))) {
22322
- return join17(packageRoot2, DIARIST_RESOLVE_TICKET_METHOD_RELATIVE);
22570
+ return join16(packageRoot2, DIARIST_RESOLVE_TICKET_METHOD_RELATIVE);
22323
22571
  }
22324
22572
  function instructionContainsTicketNumber(instruction, ticketNumber) {
22325
22573
  if (!Number.isSafeInteger(ticketNumber) || ticketNumber < 1) return false;
@@ -22542,7 +22790,7 @@ var init_adr_path_refs = __esm({
22542
22790
  // src/diarist-mechanical.ts
22543
22791
  import { createHash as createHash5 } from "node:crypto";
22544
22792
  import { existsSync as existsSync7, readdirSync as readdirSync2, readFileSync as readFileSync3, realpathSync as realpathSync3, statSync as statSync2 } from "node:fs";
22545
- import { basename as basename6, join as join18, resolve as resolve8 } from "node:path";
22793
+ import { basename as basename6, join as join17, resolve as resolve8 } from "node:path";
22546
22794
  import { homedir } from "node:os";
22547
22795
  function extractCornerQuotes(text, minLength = DEFAULT_QUOTE_MIN) {
22548
22796
  const out = [];
@@ -22586,12 +22834,12 @@ function encodeClaudeProjectDir(cwd) {
22586
22834
  const abs = cwd.startsWith("/") ? cwd : `/${cwd}`;
22587
22835
  return abs.replace(/\//g, "-");
22588
22836
  }
22589
- function isRecord10(value) {
22837
+ function isRecord12(value) {
22590
22838
  return typeof value === "object" && value !== null && !Array.isArray(value);
22591
22839
  }
22592
22840
  function messageText(message) {
22593
22841
  if (typeof message === "string") return message;
22594
- if (!isRecord10(message)) return "";
22842
+ if (!isRecord12(message)) return "";
22595
22843
  const content = message.content;
22596
22844
  if (typeof content === "string") return content;
22597
22845
  if (!Array.isArray(content)) return "";
@@ -22601,7 +22849,7 @@ function messageText(message) {
22601
22849
  parts.push(part);
22602
22850
  continue;
22603
22851
  }
22604
- if (!isRecord10(part)) continue;
22852
+ if (!isRecord12(part)) continue;
22605
22853
  if (typeof part.text === "string") parts.push(part.text);
22606
22854
  else if (typeof part.content === "string") parts.push(part.content);
22607
22855
  }
@@ -22622,16 +22870,16 @@ function isNotificationRow(type, text) {
22622
22870
  return false;
22623
22871
  }
22624
22872
  function readCcSessionBlocks(options) {
22625
- const root = options.projectsRoot ?? join18(homedir(), ".claude", "projects");
22873
+ const root = options.projectsRoot ?? join17(homedir(), ".claude", "projects");
22626
22874
  if (!existsSync7(root)) return [];
22627
22875
  const blocks = [];
22628
22876
  const dirs = /* @__PURE__ */ new Set();
22629
22877
  for (const cwd of options.cwds) {
22630
- dirs.add(join18(root, encodeClaudeProjectDir(cwd)));
22878
+ dirs.add(join17(root, encodeClaudeProjectDir(cwd)));
22631
22879
  }
22632
22880
  for (const cwd of options.cwds) {
22633
22881
  if (cwd.includes("projects")) continue;
22634
- const direct = join18(root, cwd);
22882
+ const direct = join17(root, cwd);
22635
22883
  if (existsSync7(direct)) dirs.add(direct);
22636
22884
  }
22637
22885
  for (const dir of dirs) {
@@ -22660,7 +22908,7 @@ function readCcSessionBlocks(options) {
22660
22908
  );
22661
22909
  }
22662
22910
  for (const name of files) {
22663
- const sessionFile = join18(dir, name);
22911
+ const sessionFile = join17(dir, name);
22664
22912
  let text;
22665
22913
  try {
22666
22914
  text = readFileSync3(sessionFile, "utf8");
@@ -22687,9 +22935,9 @@ function readCcSessionBlocks(options) {
22687
22935
  { cause: error }
22688
22936
  );
22689
22937
  }
22690
- if (!isRecord10(parsed)) continue;
22938
+ if (!isRecord12(parsed)) continue;
22691
22939
  const type = typeof parsed.type === "string" ? parsed.type : "";
22692
- const queuedCommand = type === "attachment" && isRecord10(parsed.attachment) && parsed.attachment.type === "queued_command" && isRecord10(parsed.attachment.origin) && parsed.attachment.origin.kind === "human" && typeof parsed.attachment.prompt === "string" ? parsed.attachment.prompt : void 0;
22940
+ const queuedCommand = type === "attachment" && isRecord12(parsed.attachment) && parsed.attachment.type === "queued_command" && isRecord12(parsed.attachment.origin) && parsed.attachment.origin.kind === "human" && typeof parsed.attachment.prompt === "string" ? parsed.attachment.prompt : void 0;
22693
22941
  if (type !== "user" && type !== "assistant" && queuedCommand === void 0) {
22694
22942
  continue;
22695
22943
  }
@@ -22913,11 +23161,11 @@ var init_reviewer_pinned_git = __esm({
22913
23161
  });
22914
23162
 
22915
23163
  // src/ticket-provenance-contracts.ts
22916
- function isRecord11(value) {
23164
+ function isRecord13(value) {
22917
23165
  return typeof value === "object" && value !== null && !Array.isArray(value);
22918
23166
  }
22919
23167
  function projectTicketProvenanceDiagnostic(value) {
22920
- if (!isRecord11(value)) return void 0;
23168
+ if (!isRecord13(value)) return void 0;
22921
23169
  if (value.recordClass !== TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC) {
22922
23170
  return void 0;
22923
23171
  }
@@ -22939,18 +23187,18 @@ function projectTicketProvenanceDiagnostic(value) {
22939
23187
  };
22940
23188
  }
22941
23189
  function projectTicketProvenanceEntry(value) {
22942
- if (!isRecord11(value)) return void 0;
23190
+ if (!isRecord13(value)) return void 0;
22943
23191
  if (value.recordClass === TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC) {
22944
23192
  return void 0;
22945
23193
  }
22946
- if (!isRecord11(value.basis)) return void 0;
23194
+ if (!isRecord13(value.basis)) return void 0;
22947
23195
  if (typeof value.basis.method !== "string" || !BASIS_METHODS.has(value.basis.method)) {
22948
23196
  return void 0;
22949
23197
  }
22950
23198
  if (typeof value.sourceKind !== "string" || !SOURCE_KINDS.has(value.sourceKind)) {
22951
23199
  return void 0;
22952
23200
  }
22953
- if (!isRecord11(value.sourceRef)) return void 0;
23201
+ if (!isRecord13(value.sourceRef)) return void 0;
22954
23202
  if (typeof value.transcript !== "string" || value.transcript.length === 0) {
22955
23203
  return void 0;
22956
23204
  }
@@ -23006,7 +23254,7 @@ var init_ticket_provenance_contracts = __esm({
23006
23254
  // src/ticket-provenance.ts
23007
23255
  import { createHash as createHash6 } from "node:crypto";
23008
23256
  import { appendFileSync as appendFileSync2, existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "node:fs";
23009
- import { join as join19 } from "node:path";
23257
+ import { join as join18 } from "node:path";
23010
23258
  function ticketProvenanceSubject(ticketNumber) {
23011
23259
  if (!Number.isSafeInteger(ticketNumber) || ticketNumber < 1) {
23012
23260
  throw new Error(`ticket-provenance subject requires a positive ticket number, got ${String(ticketNumber)}`);
@@ -23040,8 +23288,8 @@ function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
23040
23288
  return {
23041
23289
  recordFile: path.recordFile,
23042
23290
  volumeDir: path.sessionDir,
23043
- humanViewFile: join19(path.sessionDir, TICKET_PROVENANCE_HUMAN_VIEW),
23044
- offeredWatermarkFile: join19(path.sessionDir, TICKET_PROVENANCE_OFFERED_WATERMARK)
23291
+ humanViewFile: join18(path.sessionDir, TICKET_PROVENANCE_HUMAN_VIEW),
23292
+ offeredWatermarkFile: join18(path.sessionDir, TICKET_PROVENANCE_OFFERED_WATERMARK)
23045
23293
  };
23046
23294
  }
23047
23295
  function readOfferedIdentities(ticketNumber, cwd, home) {
@@ -23537,195 +23785,45 @@ var init_auditor_dossier_tool = __esm({
23537
23785
  }
23538
23786
  });
23539
23787
 
23540
- // src/engine-detour-tool.ts
23541
- var engineDetourArgsSchema;
23542
- var init_engine_detour_tool = __esm({
23543
- "src/engine-detour-tool.ts"() {
23544
- "use strict";
23545
- init_build();
23546
- init_engine_detour();
23547
- engineDetourArgsSchema = typebox_exports.Object(
23548
- {
23549
- argv: typebox_exports.Array(typebox_exports.String({ minLength: 1 }), {
23550
- minItems: 1,
23551
- description: "\u9996\u9879\u4E3A PATH \u4E2D\u7684\u53EF\u6267\u884C\u6587\u4EF6\uFF0C\u5176\u4F59\u9879\u4E3A\u53C2\u6570\u3002"
23552
- })
23553
- },
23554
- { additionalProperties: false }
23555
- );
23556
- }
23557
- });
23558
-
23559
- // src/session-opening-materials.ts
23560
- import { existsSync as existsSync9 } from "node:fs";
23561
- import { dirname as dirname8, join as join20 } from "node:path";
23562
- import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "node:url";
23563
- function resolvePackageRootDir(moduleUrl = import.meta.url) {
23564
- let dir = dirname8(fileURLToPath2(moduleUrl));
23565
- for (let i = 0; i < 8; i += 1) {
23566
- if (existsSync9(join20(dir, "package.json")) && existsSync9(join20(dir, "souls"))) {
23567
- return dir;
23568
- }
23569
- const parent = dirname8(dir);
23570
- if (parent === dir) break;
23571
- dir = parent;
23572
- }
23573
- return fileURLToPath2(new URL("..", moduleUrl));
23788
+ // src/shape-unreadable-failure.ts
23789
+ function stampShapeUnreadableDetails(candidate) {
23790
+ return {
23791
+ [SHAPE_UNREADABLE_KEY]: true,
23792
+ candidate,
23793
+ acceptedReceipt: false
23794
+ };
23574
23795
  }
23575
- var packageRootUrl, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
23576
- var init_session_opening_materials = __esm({
23577
- "src/session-opening-materials.ts"() {
23796
+ var SHAPE_UNREADABLE_KEY;
23797
+ var init_shape_unreadable_failure = __esm({
23798
+ "src/shape-unreadable-failure.ts"() {
23578
23799
  "use strict";
23579
- init_packaged_role_registry();
23580
- packageRootUrl = pathToFileURL2(resolvePackageRootDir() + "/").href;
23581
- MAIN_ROLE_SESSION_MATERIALS = {
23582
- ...Object.fromEntries(
23583
- PUBLIC_ROLE_RECORDS.map((record4) => [record4.role, record4.sessionMaterials])
23584
- )
23585
- };
23586
- GATEKEEPER_SESSION_MATERIALS = {
23587
- // #639: single authority — the public gatekeeper record owns the province list.
23588
- gatekeeper: PUBLIC_ROLE_RECORDS.find((entry) => entry.role === "gatekeeper").sessionMaterials,
23589
- inspector: INSPECTOR_SESSION_MATERIALS,
23590
- notary: NOTARY_SESSION_MATERIALS
23591
- };
23800
+ SHAPE_UNREADABLE_KEY = "shapeUnreadable";
23592
23801
  }
23593
23802
  });
23594
23803
 
23595
- // src/navigator-session-contracts.ts
23596
- var navigatorProviderFailureSchema;
23597
- var init_navigator_session_contracts = __esm({
23598
- "src/navigator-session-contracts.ts"() {
23804
+ // src/compliance-transport.ts
23805
+ var nonblank2, decisionGateSchema, complianceDecisionSchema, AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE;
23806
+ var init_compliance_transport = __esm({
23807
+ "src/compliance-transport.ts"() {
23599
23808
  "use strict";
23600
23809
  init_build();
23601
- init_value2();
23602
23810
  init_auditor_dossier_tool();
23603
- init_institutional_resolution();
23604
- navigatorProviderFailureSchema = typebox_exports.Object({
23605
- source: typebox_exports.Union([
23606
- typebox_exports.Literal("context"),
23607
- typebox_exports.Literal("session"),
23608
- typebox_exports.Literal("model"),
23609
- typebox_exports.Literal("thinking"),
23610
- typebox_exports.Literal("auth"),
23611
- typebox_exports.Literal("quota"),
23612
- typebox_exports.Literal("transport"),
23613
- typebox_exports.Literal("unknown")
23614
- ]),
23615
- cause: typebox_exports.Union([
23616
- typebox_exports.Literal("context"),
23617
- typebox_exports.Literal("session"),
23618
- typebox_exports.Literal("model"),
23619
- typebox_exports.Literal("thinking"),
23620
- typebox_exports.Literal("auth"),
23621
- typebox_exports.Literal("quota"),
23622
- typebox_exports.Literal("transport"),
23623
- typebox_exports.Literal("unknown")
23624
- ])
23625
- }, { additionalProperties: false });
23811
+ init_shape_unreadable_failure();
23812
+ nonblank2 = typebox_exports.String({ minLength: 1, pattern: "\\S" });
23813
+ decisionGateSchema = typebox_exports.Object({ question: nonblank2, options: typebox_exports.Array(nonblank2, { minItems: 1 }) }, { additionalProperties: false });
23814
+ complianceDecisionSchema = typebox_exports.Object({ status: typebox_exports.Unknown({ description: "pass | revise | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), violations: typebox_exports.Array(nonblank2, { description: "\u89C2\u5BDF\u5230\u7684\u5408\u89C4\u8FDD\u89C4" }), conflicts: typebox_exports.Array(nonblank2, { description: "\u672A\u51B3\u6743\u5A01\u6216\u6267\u884C\u51B2\u7A81" }), decisionGate: typebox_exports.Union([decisionGateSchema, typebox_exports.Null()], { description: "\u5347\u7EA7\u95EE\u9898\u4E0E\u53EF\u9009\u9009\u9879" }) }, { additionalProperties: true, required: [] });
23815
+ AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
23816
+ AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
23626
23817
  }
23627
23818
  });
23628
23819
 
23629
- // src/receipt-delivery-policy.ts
23630
- function isRecord12(value) {
23631
- return typeof value === "object" && value !== null && !Array.isArray(value);
23632
- }
23633
- function parseNoReceiptLifecycleFacts(input) {
23634
- if (!isRecord12(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) => isRecord12(item) && typeof item.reason === "string")) {
23635
- throw new TypeError("malformed no-receipt lifecycle facts");
23636
- }
23637
- return {
23638
- terminalToolCalled: input.terminalToolCalled,
23639
- rejectedReceipts: input.rejectedReceipts.map((item) => ({
23640
- reason: item.reason,
23641
- diagnosticAvailable: item.reason.trim() !== ""
23642
- })),
23643
- deliveryTurns: RECEIPT_DELIVERY_TURN_LIMIT,
23644
- sessionCompletion: "settled-without-accepted-receipt",
23645
- runPointer: input.runPointer,
23646
- attemptPointer: input.attemptPointer,
23647
- acceptedReceipt: false
23648
- };
23649
- }
23650
- var RECEIPT_DELIVERY_TURN_LIMIT, NO_RECEIPT_LIFECYCLE_ENTRY_TYPE;
23651
- var init_receipt_delivery_policy = __esm({
23652
- "src/receipt-delivery-policy.ts"() {
23653
- "use strict";
23654
- RECEIPT_DELIVERY_TURN_LIMIT = 2;
23655
- NO_RECEIPT_LIFECYCLE_ENTRY_TYPE = "ak-no-receipt-lifecycle";
23656
- }
23657
- });
23658
-
23659
- // src/upstream-error-testimony.ts
23660
- function isNonSuccessHttpStatus(status) {
23661
- return typeof status === "number" && (status < 200 || status >= 300);
23662
- }
23663
- function hasUpstreamErrorTestimony(input) {
23664
- if (isNonSuccessHttpStatus(input.httpStatus)) return true;
23665
- return Array.isArray(input.diagnostics) && input.diagnostics.length > 0;
23666
- }
23667
- function projectConfirmedRemotePayload(input) {
23668
- return {
23669
- ...input.body === void 0 ? {} : { body: input.body },
23670
- ...input.code === void 0 ? {} : { code: input.code },
23671
- ...input.errno === void 0 ? {} : { errno: input.errno }
23672
- };
23673
- }
23674
- var init_upstream_error_testimony = __esm({
23675
- "src/upstream-error-testimony.ts"() {
23676
- "use strict";
23677
- }
23678
- });
23679
-
23680
- // src/evidence-child-executor.ts
23681
- var init_evidence_child_executor = __esm({
23682
- "src/evidence-child-executor.ts"() {
23683
- "use strict";
23684
- init_compliance_transport();
23685
- init_auditor_dossier_tool();
23686
- init_sitian_facade();
23687
- init_engine_detour_tool();
23688
- init_engine_detour();
23689
- init_engine_material();
23690
- init_session_opening_materials();
23691
- init_config2();
23692
- init_institutional_resolution();
23693
- init_navigator_session_contracts();
23694
- init_receipt_delivery_policy();
23695
- init_typed_provider_http();
23696
- init_upstream_error_testimony();
23697
- }
23698
- });
23699
-
23700
- // src/compliance-transport.ts
23701
- function createComplianceDecisionTool(name, description) {
23702
- return { name, description, parameters: complianceDecisionSchema, async execute(_id, params) {
23703
- return { content: [{ type: "text", text: "\u5BA1\u8BA1\u51B3\u8BAE\u5DF2\u6536" }], details: params, terminate: true };
23704
- } };
23705
- }
23706
- var nonblank2, decisionGateSchema, complianceDecisionSchema, AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE;
23707
- var init_compliance_transport = __esm({
23708
- "src/compliance-transport.ts"() {
23709
- "use strict";
23710
- init_build();
23711
- init_evidence_child_executor();
23712
- init_auditor_dossier_tool();
23713
- init_sitian_facade();
23714
- nonblank2 = typebox_exports.String({ minLength: 1, pattern: "\\S" });
23715
- decisionGateSchema = typebox_exports.Object({ question: nonblank2, options: typebox_exports.Array(nonblank2, { minItems: 1 }) }, { additionalProperties: false });
23716
- complianceDecisionSchema = typebox_exports.Object({ status: typebox_exports.Unknown({ description: "pass | revise | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), violations: typebox_exports.Array(nonblank2, { description: "\u89C2\u5BDF\u5230\u7684\u5408\u89C4\u8FDD\u89C4" }), conflicts: typebox_exports.Array(nonblank2, { description: "\u672A\u51B3\u6743\u5A01\u6216\u6267\u884C\u51B2\u7A81" }), decisionGate: typebox_exports.Union([decisionGateSchema, typebox_exports.Null()], { description: "\u5347\u7EA7\u95EE\u9898\u4E0E\u53EF\u9009\u9009\u9879" }) }, { additionalProperties: true, required: [] });
23717
- AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
23718
- AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
23719
- }
23720
- });
23721
-
23722
- // src/ledger-session-read.ts
23723
- import { readFile as readFile12 } from "node:fs/promises";
23724
- function isRecord13(value) {
23820
+ // src/ledger-session-read.ts
23821
+ import { readFile as readFile11 } from "node:fs/promises";
23822
+ function isRecord14(value) {
23725
23823
  return typeof value === "object" && value !== null && !Array.isArray(value);
23726
23824
  }
23727
23825
  async function readLedgerSessionJsonl(path) {
23728
- const text = await readFile12(path, "utf8");
23826
+ const text = await readFile11(path, "utf8");
23729
23827
  const lines = text.split("\n");
23730
23828
  const rows = [];
23731
23829
  for (let index = 0; index < lines.length; index += 1) {
@@ -23745,7 +23843,7 @@ async function readLedgerSessionJsonl(path) {
23745
23843
  }
23746
23844
  break;
23747
23845
  }
23748
- if (!isRecord13(row)) {
23846
+ if (!isRecord14(row)) {
23749
23847
  const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
23750
23848
  throw new LedgerSessionJsonlError(
23751
23849
  `complete non-object JSONL record in ${path} at line ${index + 1}: expected object, got ${kind}`,
@@ -23782,7 +23880,7 @@ function extractSessionModelSequence(rows) {
23782
23880
  if (row.type === "model_change" && typeof row.modelId === "string") {
23783
23881
  push(row.modelId);
23784
23882
  }
23785
- const message = isRecord13(row.message) ? row.message : void 0;
23883
+ const message = isRecord14(row.message) ? row.message : void 0;
23786
23884
  if (message?.role === "assistant" && typeof message.model === "string") {
23787
23885
  push(message.model);
23788
23886
  }
@@ -23798,11 +23896,11 @@ function extractSessionToolIntervals(rows) {
23798
23896
  const openById = /* @__PURE__ */ new Map();
23799
23897
  for (const row of rows) {
23800
23898
  const rowTimestamp = typeof row.timestamp === "string" ? row.timestamp : void 0;
23801
- const message = isRecord13(row.message) ? row.message : void 0;
23899
+ const message = isRecord14(row.message) ? row.message : void 0;
23802
23900
  if (message?.role === "assistant" && Array.isArray(message.content)) {
23803
23901
  const callTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
23804
23902
  for (const part of message.content) {
23805
- if (!isRecord13(part) || part.type !== "toolCall") continue;
23903
+ if (!isRecord14(part) || part.type !== "toolCall") continue;
23806
23904
  if (typeof part.id !== "string" || part.id.length === 0) {
23807
23905
  throw new Error("toolCall frame missing string id");
23808
23906
  }
@@ -23815,7 +23913,7 @@ function extractSessionToolIntervals(rows) {
23815
23913
  if (openById.has(part.id)) {
23816
23914
  throw new Error(`duplicate toolCall id ${part.id}`);
23817
23915
  }
23818
- const args = isRecord13(part.arguments) ? part.arguments : void 0;
23916
+ const args = isRecord14(part.arguments) ? part.arguments : void 0;
23819
23917
  const command = part.name === "bash" && args !== void 0 && typeof args.command === "string" ? bashCommandFirstLine(args.command) : void 0;
23820
23918
  const interval = {
23821
23919
  toolCallId: part.id,
@@ -23900,8 +23998,8 @@ var init_ledger_session_read = __esm({
23900
23998
 
23901
23999
  // src/analyst-gate-cycles-read.ts
23902
24000
  import { readdir as readdir3 } from "node:fs/promises";
23903
- import { join as join21 } from "node:path";
23904
- function isRecord14(value) {
24001
+ import { join as join19 } from "node:path";
24002
+ function isRecord15(value) {
23905
24003
  return typeof value === "object" && value !== null && !Array.isArray(value);
23906
24004
  }
23907
24005
  function isParentAttemptBindingRow(row) {
@@ -23932,7 +24030,7 @@ function isGateTerminatingToolName(toolName) {
23932
24030
  function acceptedGateReceiptIds(rows) {
23933
24031
  const accepted = /* @__PURE__ */ new Set();
23934
24032
  for (const row of rows) {
23935
- const message = isRecord14(row.message) ? row.message : void 0;
24033
+ const message = isRecord15(row.message) ? row.message : void 0;
23936
24034
  if (message?.role !== "toolResult") continue;
23937
24035
  if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
23938
24036
  if (message.isError === false) accepted.add(message.toolCallId);
@@ -23971,7 +24069,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
23971
24069
  for (let i = beforeIndex - 1; i >= 0; i -= 1) {
23972
24070
  const row = rows[i];
23973
24071
  if (!isParentAttemptBindingRow(row)) continue;
23974
- if (!isRecord14(row.data) || !isRecord14(row.data.parent)) continue;
24072
+ if (!isRecord15(row.data) || !isRecord15(row.data.parent)) continue;
23975
24073
  const id = row.data.parent.attemptEntryId;
23976
24074
  const sessionFile = row.data.parent.sessionFile;
23977
24075
  return {
@@ -23986,10 +24084,10 @@ function extractAllAcceptedGateToolCalls(rows) {
23986
24084
  const out = [];
23987
24085
  for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
23988
24086
  const row = rows[rowIndex];
23989
- const message = isRecord14(row.message) ? row.message : void 0;
24087
+ const message = isRecord15(row.message) ? row.message : void 0;
23990
24088
  if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
23991
24089
  for (const part of message.content) {
23992
- if (!isRecord14(part) || part.type !== "toolCall") continue;
24090
+ if (!isRecord15(part) || part.type !== "toolCall") continue;
23993
24091
  if (typeof part.id !== "string" || part.id.length === 0) continue;
23994
24092
  if (typeof part.name !== "string" || part.name.length === 0) continue;
23995
24093
  if (!isGateTerminatingToolName(part.name)) continue;
@@ -23997,7 +24095,7 @@ function extractAllAcceptedGateToolCalls(rows) {
23997
24095
  const binding = nearestAttemptBindingBefore(rows, rowIndex);
23998
24096
  out.push({
23999
24097
  toolName: part.name,
24000
- args: isRecord14(part.arguments) ? part.arguments : void 0,
24098
+ args: isRecord15(part.arguments) ? part.arguments : void 0,
24001
24099
  accepted: true,
24002
24100
  rowIndex,
24003
24101
  ...binding
@@ -24126,6 +24224,26 @@ function pairGateRounds(volumes) {
24126
24224
  }
24127
24225
  return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
24128
24226
  }
24227
+ async function resolveOfficerSessionFromPointerFile(pointerPath) {
24228
+ const { readFile: readFile21 } = await import("node:fs/promises");
24229
+ let raw;
24230
+ try {
24231
+ raw = JSON.parse(await readFile21(pointerPath, "utf8"));
24232
+ } catch (error) {
24233
+ throw new Error(
24234
+ `direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
24235
+ { cause: error }
24236
+ );
24237
+ }
24238
+ if (!isRecord15(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
24239
+ throw new Error(`direct officer run pointer has unknown shape in ${pointerPath}`);
24240
+ }
24241
+ const sessionFile = raw.sessionFile;
24242
+ if (typeof sessionFile !== "string" || sessionFile.trim() === "") {
24243
+ throw new Error(`direct officer run pointer missing sessionFile in ${pointerPath}`);
24244
+ }
24245
+ return sessionFile;
24246
+ }
24129
24247
  async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, options = {}) {
24130
24248
  const directories = typeof auditorRolesDirectory === "string" ? [auditorRolesDirectory] : auditorRolesDirectory;
24131
24249
  const volumes = [];
@@ -24133,13 +24251,18 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
24133
24251
  let names;
24134
24252
  try {
24135
24253
  const entries = await readdir3(directory, { withFileTypes: true });
24136
- names = entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => e.name).sort();
24254
+ names = entries.filter(
24255
+ (e) => e.isFile() && (e.name.endsWith(".jsonl") || e.name.endsWith(".pointer.json"))
24256
+ ).map((e) => e.name).sort();
24137
24257
  } catch (error) {
24138
24258
  if (isMissingDirectoryError(error)) continue;
24139
24259
  throw error;
24140
24260
  }
24141
24261
  for (const name of names) {
24142
- const classified = await classifyAuditorVolume(join21(directory, name));
24262
+ const path = join19(directory, name);
24263
+ const sessionPath = name.endsWith(".pointer.json") ? await resolveOfficerSessionFromPointerFile(path) : path;
24264
+ if (sessionPath === void 0) continue;
24265
+ const classified = await classifyAuditorVolume(sessionPath);
24143
24266
  for (const volume of classified) {
24144
24267
  if (options.parentSessionFile !== void 0 && volume.parentSessionFile !== void 0 && volume.parentSessionFile !== options.parentSessionFile) {
24145
24268
  continue;
@@ -24173,45 +24296,37 @@ var init_analyst_gate_cycles_read = __esm({
24173
24296
  });
24174
24297
 
24175
24298
  // src/gatekeeper-role.ts
24176
- var officerDecisionSchema, MISSING_ARGUMENTS_SUBMISSION;
24299
+ var MISSING_ARGUMENTS_SUBMISSION;
24177
24300
  var init_gatekeeper_role = __esm({
24178
24301
  "src/gatekeeper-role.ts"() {
24179
24302
  "use strict";
24180
- init_build();
24181
24303
  init_auditor_dossier_tool();
24182
- init_evidence_child_executor();
24183
- init_open_tool_schema();
24184
- init_session_opening_materials();
24185
24304
  init_submission_errors();
24186
24305
  init_inspector_contracts();
24187
24306
  init_gatekeeper_output();
24307
+ init_shape_unreadable_failure();
24188
24308
  init_submission_errors();
24189
- officerDecisionSchema = openToolObject(typebox_exports.Object({
24190
- status: typebox_exports.Unknown({ description: "pass | bounce | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }),
24191
- reason: typebox_exports.Optional(typebox_exports.Unknown({ description: "status \u4E3A escalate \u65F6\u7684\u7406\u7531" })),
24192
- findings: typebox_exports.Unknown({ description: "string[] findings\uFF0C\u968F pass\u3001bounce \u6216 escalate \u7559\u5B58" })
24193
- }));
24194
24309
  MISSING_ARGUMENTS_SUBMISSION = Object.freeze({ missing: "arguments" });
24195
24310
  }
24196
24311
  });
24197
24312
 
24198
24313
  // src/run-terminal-artifacts.ts
24199
- import { readdir as readdir4, readFile as readFile13 } from "node:fs/promises";
24200
- import { basename as basename7, dirname as dirname9, join as join22 } from "node:path";
24314
+ import { readdir as readdir4, readFile as readFile12 } from "node:fs/promises";
24315
+ import { basename as basename7, dirname as dirname8, join as join20 } from "node:path";
24201
24316
  function isMissingPathError2(error) {
24202
24317
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
24203
24318
  }
24204
24319
  function errorText2(error) {
24205
24320
  return error instanceof Error ? error.message : String(error);
24206
24321
  }
24207
- function isRecord15(value) {
24322
+ function isRecord16(value) {
24208
24323
  return typeof value === "object" && value !== null && !Array.isArray(value);
24209
24324
  }
24210
24325
  function readUsableTerminalArtifactBody(body) {
24211
24326
  if (body === null) {
24212
24327
  return { ok: false, reason: "terminal artifact JSON value is null" };
24213
24328
  }
24214
- if (!isRecord15(body)) {
24329
+ if (!isRecord16(body)) {
24215
24330
  return {
24216
24331
  ok: false,
24217
24332
  reason: `terminal artifact JSON value is not a typed object (${Array.isArray(body) ? "array" : typeof body})`
@@ -24228,7 +24343,7 @@ function readUsableTerminalArtifactBody(body) {
24228
24343
  async function readTerminalArtifactAtPath(path, file) {
24229
24344
  let raw;
24230
24345
  try {
24231
- raw = await readFile13(path, "utf8");
24346
+ raw = await readFile12(path, "utf8");
24232
24347
  } catch (error) {
24233
24348
  if (isMissingPathError2(error)) return void 0;
24234
24349
  return {
@@ -24272,7 +24387,7 @@ async function listUniqueErrorFallbackPaths(directories) {
24272
24387
  }
24273
24388
  for (const name of names.sort((a, b) => a.localeCompare(b))) {
24274
24389
  if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
24275
- found.push(join22(dir, name));
24390
+ found.push(join20(dir, name));
24276
24391
  }
24277
24392
  }
24278
24393
  return found;
@@ -24288,14 +24403,14 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
24288
24403
  return typeof body.runId === "string" && body.runId === expectedRunId;
24289
24404
  }
24290
24405
  async function readRunTerminalArtifact(runDirectory) {
24291
- const artifactsDir = join22(runDirectory, "artifacts");
24406
+ const artifactsDir = join20(runDirectory, "artifacts");
24292
24407
  for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
24293
- const path = join22(artifactsDir, file);
24408
+ const path = join20(artifactsDir, file);
24294
24409
  const read3 = await readTerminalArtifactAtPath(path, file);
24295
24410
  if (read3 !== void 0) return read3;
24296
24411
  }
24297
24412
  for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
24298
- const path = join22(runDirectory, relative3);
24413
+ const path = join20(runDirectory, relative3);
24299
24414
  const read3 = await readTerminalArtifactAtPath(path, "error.json");
24300
24415
  if (read3 !== void 0) return read3;
24301
24416
  }
@@ -24304,7 +24419,7 @@ async function readRunTerminalArtifact(runDirectory) {
24304
24419
  if (read3 !== void 0) return read3;
24305
24420
  }
24306
24421
  const expectedRunId = runIdFromRunDirectory(runDirectory);
24307
- for (const path of await listUniqueErrorFallbackPaths([dirname9(runDirectory)])) {
24422
+ for (const path of await listUniqueErrorFallbackPaths([dirname8(runDirectory)])) {
24308
24423
  const read3 = await readTerminalArtifactAtPath(path, "error.json");
24309
24424
  if (read3 === void 0) continue;
24310
24425
  if (read3.status === "present") {
@@ -24433,11 +24548,112 @@ var init_submission_ledger = __esm({
24433
24548
  }
24434
24549
  });
24435
24550
 
24551
+ // src/session-opening-materials.ts
24552
+ import { existsSync as existsSync9 } from "node:fs";
24553
+ import { readFile as readFile13 } from "node:fs/promises";
24554
+ import { dirname as dirname9, join as join21 } from "node:path";
24555
+ import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "node:url";
24556
+ function resolvePackageRootDir(moduleUrl = import.meta.url) {
24557
+ let dir = dirname9(fileURLToPath2(moduleUrl));
24558
+ for (let i = 0; i < 8; i += 1) {
24559
+ if (existsSync9(join21(dir, "package.json")) && existsSync9(join21(dir, "souls"))) {
24560
+ return dir;
24561
+ }
24562
+ const parent = dirname9(dir);
24563
+ if (parent === dir) break;
24564
+ dir = parent;
24565
+ }
24566
+ return fileURLToPath2(new URL("..", moduleUrl));
24567
+ }
24568
+ async function readPackageMaterial(relativePath) {
24569
+ return readFile13(fileURLToPath2(new URL(relativePath, packageRootUrl)), "utf8");
24570
+ }
24571
+ async function joinPackageMaterials(relativePaths) {
24572
+ const chunks = [];
24573
+ for (const relativePath of relativePaths) {
24574
+ chunks.push(await readPackageMaterial(relativePath));
24575
+ }
24576
+ return chunks.join("\n\n");
24577
+ }
24578
+ var packageRootUrl, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
24579
+ var init_session_opening_materials = __esm({
24580
+ "src/session-opening-materials.ts"() {
24581
+ "use strict";
24582
+ init_packaged_role_registry();
24583
+ packageRootUrl = pathToFileURL2(resolvePackageRootDir() + "/").href;
24584
+ MAIN_ROLE_SESSION_MATERIALS = {
24585
+ ...Object.fromEntries(
24586
+ PUBLIC_ROLE_RECORDS.map((record4) => [record4.role, record4.sessionMaterials])
24587
+ )
24588
+ };
24589
+ GATEKEEPER_SESSION_MATERIALS = {
24590
+ // #639: single authority — the public gatekeeper record owns the province list.
24591
+ gatekeeper: PUBLIC_ROLE_RECORDS.find((entry) => entry.role === "gatekeeper").sessionMaterials,
24592
+ inspector: INSPECTOR_SESSION_MATERIALS,
24593
+ notary: NOTARY_SESSION_MATERIALS
24594
+ };
24595
+ }
24596
+ });
24597
+
24436
24598
  // src/auditor-soul.ts
24599
+ var auditor_soul_exports = {};
24600
+ __export(auditor_soul_exports, {
24601
+ AK_ROLE_AUDITOR_SOURCE_RUN_ENV: () => AK_ROLE_AUDITOR_SOURCE_RUN_ENV,
24602
+ AK_ROLE_AUDITOR_SUBJECT_ENV: () => AK_ROLE_AUDITOR_SUBJECT_ENV,
24603
+ AUDITOR_SESSION_MATERIALS: () => AUDITOR_SESSION_MATERIALS,
24604
+ AUDITOR_SOUL_ROLES: () => AUDITOR_SOUL_ROLES,
24605
+ isAuditorSoulRole: () => isAuditorSoulRole,
24606
+ loadAuditorSoul: () => loadAuditorSoul,
24607
+ loadAuditorSoulFromSubjectInput: () => loadAuditorSoulFromSubjectInput,
24608
+ resolveAuditorSubject: () => resolveAuditorSubject
24609
+ });
24610
+ function auditorSoulRelativePath(role) {
24611
+ return `souls/${role}-auditor.md`;
24612
+ }
24613
+ function isAuditorSoulRole(value) {
24614
+ return value === "judge" || value === "doctor";
24615
+ }
24616
+ function resolveAuditorSubject(raw) {
24617
+ const value = typeof raw === "string" && raw.trim() !== "" ? raw.trim() : typeof process.env[AK_ROLE_AUDITOR_SUBJECT_ENV] === "string" ? process.env[AK_ROLE_AUDITOR_SUBJECT_ENV].trim() : "";
24618
+ if (!isAuditorSoulRole(value)) {
24619
+ throw new Error(
24620
+ `auditor subject must be judge|doctor (input --subject / ${AK_ROLE_AUDITOR_SUBJECT_ENV}), got ${value === "" ? "(missing)" : value}`
24621
+ );
24622
+ }
24623
+ return value;
24624
+ }
24625
+ async function loadAuditorSoul(role) {
24626
+ const materials = AUDITOR_SESSION_MATERIALS[role];
24627
+ const soulPath = auditorSoulRelativePath(role);
24628
+ const soul = await readPackageMaterial(soulPath);
24629
+ if (soul.trim().length === 0) {
24630
+ throw new Error(`The ${role} auditor Soul is blank`);
24631
+ }
24632
+ return joinPackageMaterials(materials);
24633
+ }
24634
+ async function loadAuditorSoulFromSubjectInput(raw) {
24635
+ return loadAuditorSoul(resolveAuditorSubject(raw));
24636
+ }
24637
+ var AUDITOR_SOUL_ROLES, AK_ROLE_AUDITOR_SUBJECT_ENV, AK_ROLE_AUDITOR_SOURCE_RUN_ENV, AUDITOR_SESSION_MATERIALS;
24437
24638
  var init_auditor_soul = __esm({
24438
24639
  "src/auditor-soul.ts"() {
24439
24640
  "use strict";
24440
24641
  init_session_opening_materials();
24642
+ AUDITOR_SOUL_ROLES = [
24643
+ "judge",
24644
+ "doctor"
24645
+ ];
24646
+ AK_ROLE_AUDITOR_SUBJECT_ENV = "AK_ROLE_AUDITOR_SUBJECT";
24647
+ AK_ROLE_AUDITOR_SOURCE_RUN_ENV = "AK_ROLE_AUDITOR_SOURCE_RUN";
24648
+ AUDITOR_SESSION_MATERIALS = {
24649
+ judge: [
24650
+ "CLAUDE.md",
24651
+ "souls/judge-auditor.md",
24652
+ "souls/audit-law.md",
24653
+ "souls/quality-law.md"
24654
+ ],
24655
+ doctor: ["CLAUDE.md", "souls/doctor-auditor.md"]
24656
+ };
24441
24657
  }
24442
24658
  });
24443
24659
 
@@ -24450,36 +24666,43 @@ var init_dossier_resolution = __esm({
24450
24666
  });
24451
24667
 
24452
24668
  // src/doctor-auditor.ts
24453
- var DOCTOR_AUDIT_TOOL_NAME, tool;
24454
24669
  var init_doctor_auditor = __esm({
24455
24670
  "src/doctor-auditor.ts"() {
24456
24671
  "use strict";
24457
24672
  init_auditor_dossier_tool();
24458
- init_auditor_soul();
24459
24673
  init_compliance_transport();
24460
24674
  init_dossier_resolution();
24461
- DOCTOR_AUDIT_TOOL_NAME = "ak_doctor_audit_decision";
24462
- tool = createComplianceDecisionTool(
24463
- DOCTOR_AUDIT_TOOL_NAME,
24464
- "\u63D0\u4EA4 typed pass/revise/escalate \u51B3\u8BAE\uFF08\u592A\u533B\u7F72\u5BA1\u5211\uFF09\u3002"
24465
- );
24466
24675
  }
24467
24676
  });
24468
24677
 
24469
24678
  // src/judge-auditor.ts
24470
- var JUDGE_AUDIT_TOOL_NAME, auditDecisionTool;
24471
24679
  var init_judge_auditor = __esm({
24472
24680
  "src/judge-auditor.ts"() {
24473
24681
  "use strict";
24474
24682
  init_compliance_transport();
24475
24683
  init_auditor_dossier_tool();
24476
- init_auditor_soul();
24477
24684
  init_dossier_resolution();
24478
- JUDGE_AUDIT_TOOL_NAME = "ak_soul_audit_decision";
24479
- auditDecisionTool = createComplianceDecisionTool(
24480
- JUDGE_AUDIT_TOOL_NAME,
24481
- "\u63D0\u4EA4 typed pass/revise/escalate \u51B3\u8BAE\uFF08\u5927\u7406\u5BFA\u5BA1\u5211\uFF09\u3002"
24482
- );
24685
+ }
24686
+ });
24687
+
24688
+ // src/upstream-error-testimony.ts
24689
+ function isNonSuccessHttpStatus(status) {
24690
+ return typeof status === "number" && (status < 200 || status >= 300);
24691
+ }
24692
+ function hasUpstreamErrorTestimony(input) {
24693
+ if (isNonSuccessHttpStatus(input.httpStatus)) return true;
24694
+ return Array.isArray(input.diagnostics) && input.diagnostics.length > 0;
24695
+ }
24696
+ function projectConfirmedRemotePayload(input) {
24697
+ return {
24698
+ ...input.body === void 0 ? {} : { body: input.body },
24699
+ ...input.code === void 0 ? {} : { code: input.code },
24700
+ ...input.errno === void 0 ? {} : { errno: input.errno }
24701
+ };
24702
+ }
24703
+ var init_upstream_error_testimony = __esm({
24704
+ "src/upstream-error-testimony.ts"() {
24705
+ "use strict";
24483
24706
  }
24484
24707
  });
24485
24708
 
@@ -24582,12 +24805,12 @@ var init_reviewer_dispatch = __esm({
24582
24805
 
24583
24806
  // src/public-cli/reviewer-dispatch-rejection.ts
24584
24807
  import { readFile as readFile14, unlink as unlink3 } from "node:fs/promises";
24585
- import { join as join23 } from "node:path";
24808
+ import { join as join22 } from "node:path";
24586
24809
  function isReviewerPreflightViolation(value) {
24587
24810
  return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
24588
24811
  }
24589
24812
  function reviewerDispatchRejectionPath(runDirectory) {
24590
- return join23(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
24813
+ return join22(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
24591
24814
  }
24592
24815
  async function clearReviewerDispatchRejection(runDirectory) {
24593
24816
  try {
@@ -24808,6 +25031,36 @@ var init_navigator_invocation_identity = __esm({
24808
25031
  }
24809
25032
  });
24810
25033
 
25034
+ // src/receipt-delivery-policy.ts
25035
+ function isRecord17(value) {
25036
+ return typeof value === "object" && value !== null && !Array.isArray(value);
25037
+ }
25038
+ function parseNoReceiptLifecycleFacts(input) {
25039
+ if (!isRecord17(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) => isRecord17(item) && typeof item.reason === "string")) {
25040
+ throw new TypeError("malformed no-receipt lifecycle facts");
25041
+ }
25042
+ return {
25043
+ terminalToolCalled: input.terminalToolCalled,
25044
+ rejectedReceipts: input.rejectedReceipts.map((item) => ({
25045
+ reason: item.reason,
25046
+ diagnosticAvailable: item.reason.trim() !== ""
25047
+ })),
25048
+ deliveryTurns: RECEIPT_DELIVERY_TURN_LIMIT,
25049
+ sessionCompletion: "settled-without-accepted-receipt",
25050
+ runPointer: input.runPointer,
25051
+ attemptPointer: input.attemptPointer,
25052
+ acceptedReceipt: false
25053
+ };
25054
+ }
25055
+ var RECEIPT_DELIVERY_TURN_LIMIT, NO_RECEIPT_LIFECYCLE_ENTRY_TYPE;
25056
+ var init_receipt_delivery_policy = __esm({
25057
+ "src/receipt-delivery-policy.ts"() {
25058
+ "use strict";
25059
+ RECEIPT_DELIVERY_TURN_LIMIT = 2;
25060
+ NO_RECEIPT_LIFECYCLE_ENTRY_TYPE = "ak-no-receipt-lifecycle";
25061
+ }
25062
+ });
25063
+
24811
25064
  // src/public-command-renderer.ts
24812
25065
  function isPublicCallableRole2(role) {
24813
25066
  return PUBLIC_CALLABLE_ROLES3.has(role);
@@ -24968,8 +25221,8 @@ var init_terminal = __esm({
24968
25221
 
24969
25222
  // src/public-cli/settlement.ts
24970
25223
  import { randomUUID as randomUUID3 } from "node:crypto";
24971
- import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, writeFile as writeFile7 } from "node:fs/promises";
24972
- import { dirname as dirname10, join as join24 } from "node:path";
25224
+ import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, writeFile as writeFile6 } from "node:fs/promises";
25225
+ import { dirname as dirname10, join as join23 } from "node:path";
24973
25226
  function sealedLedgerHome(admitted) {
24974
25227
  return homeFromRunDirectory(admitted.runDirectory);
24975
25228
  }
@@ -25349,7 +25602,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
25349
25602
  const { records: records2 } = await readSitianRecords(recordFile);
25350
25603
  for (let i = records2.length - 1; i >= 0; i -= 1) {
25351
25604
  const payload = records2[i]?.payload;
25352
- if (!isRecord16(payload) || !isRecord16(payload.response)) continue;
25605
+ if (!isRecord18(payload) || !isRecord18(payload.response)) continue;
25353
25606
  if (typeof payload.type === "string") continue;
25354
25607
  const stop = sessionProviderStopFromAssistant(payload.response);
25355
25608
  if (stop !== void 0) return stop;
@@ -25370,7 +25623,7 @@ async function readSessionProviderStop(sessionFile) {
25370
25623
  }
25371
25624
  }
25372
25625
  async function readBoundEvidenceChildKnownFailure(sessionFile) {
25373
- const childDirectory = join24(dirname10(sessionFile), "evidence-children");
25626
+ const childDirectory = join23(dirname10(sessionFile), "evidence-children");
25374
25627
  let names;
25375
25628
  try {
25376
25629
  names = await readdir5(childDirectory);
@@ -25381,12 +25634,12 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
25381
25634
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
25382
25635
  let entries;
25383
25636
  try {
25384
- entries = await readBoundSessionEntries(join24(childDirectory, file));
25637
+ entries = await readBoundSessionEntries(join23(childDirectory, file));
25385
25638
  } catch (error) {
25386
25639
  throw sessionReadFailure(error, "failed to read discovered evidence-child session");
25387
25640
  }
25388
25641
  const header = entries.find((entry) => entry.type === "session");
25389
- if (!isRecord16(header) || header.parentSession !== sessionFile) continue;
25642
+ if (!isRecord18(header) || header.parentSession !== sessionFile) continue;
25390
25643
  const stop = extractSessionProviderStop(entries);
25391
25644
  if (stop === void 0) continue;
25392
25645
  const primary = knownFailureFromProviderStop(stop);
@@ -25418,12 +25671,12 @@ async function loadBoundAuditorVolumes(sessionFile) {
25418
25671
  return firstLine === RESUME_ENVELOPE;
25419
25672
  };
25420
25673
  const isResumeEnvelope = (msg) => {
25421
- if (!isRecord16(msg) || msg.role !== "user") return false;
25674
+ if (!isRecord18(msg) || msg.role !== "user") return false;
25422
25675
  const text = typeof msg.text === "string" ? msg.text : typeof msg.content === "string" ? msg.content : void 0;
25423
25676
  if (isResumeEnvelopeBytes(text)) return true;
25424
25677
  const content = msg.content;
25425
25678
  if (Array.isArray(content)) {
25426
- return content.some((p) => isRecord16(p) && (isResumeEnvelopeBytes(p.text) || isResumeEnvelopeBytes(p.content)));
25679
+ return content.some((p) => isRecord18(p) && (isResumeEnvelopeBytes(p.text) || isResumeEnvelopeBytes(p.content)));
25427
25680
  }
25428
25681
  return false;
25429
25682
  };
@@ -25435,7 +25688,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
25435
25688
  latestParentUserIndex = i;
25436
25689
  break;
25437
25690
  }
25438
- const childDirectories = [join24(dirname10(sessionFile), "auditor-roles")];
25691
+ const childDirectories = [join23(dirname10(sessionFile), "auditor-roles")];
25439
25692
  const valid = [];
25440
25693
  let sawAnyDirectory = false;
25441
25694
  for (const childDirectory of childDirectories) {
@@ -25450,12 +25703,12 @@ async function loadBoundAuditorVolumes(sessionFile) {
25450
25703
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
25451
25704
  let entries;
25452
25705
  try {
25453
- entries = await readBoundSessionEntries(join24(childDirectory, file));
25706
+ entries = await readBoundSessionEntries(join23(childDirectory, file));
25454
25707
  } catch (error) {
25455
25708
  throw sessionReadFailure(error, "failed to read discovered auditor session");
25456
25709
  }
25457
25710
  const header = entries.find((entry) => entry.type === "session");
25458
- if (!isRecord16(header)) continue;
25711
+ if (!isRecord18(header)) continue;
25459
25712
  const bindingIndexes = [];
25460
25713
  for (let i = 0; i < entries.length; i += 1) {
25461
25714
  const entry = entries[i];
@@ -25469,7 +25722,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
25469
25722
  end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
25470
25723
  })) : [{ entry: void 0, start: 0, end: entries.length }];
25471
25724
  for (const { entry: bindingEntry, start, end } of bindingPasses) {
25472
- const bindingParent = bindingEntry !== void 0 && isRecord16(bindingEntry.data) && isRecord16(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
25725
+ const bindingParent = bindingEntry !== void 0 && isRecord18(bindingEntry.data) && isRecord18(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
25473
25726
  const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
25474
25727
  const attemptEntryIndex = attemptEntryId === void 0 ? -1 : parentEntries.findIndex((entry) => entry.id === attemptEntryId);
25475
25728
  const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
@@ -25496,11 +25749,11 @@ function complianceFailureFromAuditorVolumes(volumes) {
25496
25749
  if (stop === void 0) continue;
25497
25750
  for (let i = entries.length - 1; i >= 0; i -= 1) {
25498
25751
  const entry = entries[i];
25499
- if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord16(entry.data)) continue;
25500
- const parent = isRecord16(entry.data.parent) ? entry.data.parent : void 0;
25501
- const failure = isRecord16(entry.data.failure) ? entry.data.failure : void 0;
25752
+ if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord18(entry.data)) continue;
25753
+ const parent = isRecord18(entry.data.parent) ? entry.data.parent : void 0;
25754
+ const failure = isRecord18(entry.data.failure) ? entry.data.failure : void 0;
25502
25755
  if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId || failure?.cause !== "provider" && failure?.cause !== "unrecognized") continue;
25503
- const identity = isRecord16(failure.identity) ? failure.identity : void 0;
25756
+ const identity = isRecord18(failure.identity) ? failure.identity : void 0;
25504
25757
  return {
25505
25758
  cause: failure.cause === "provider" ? "provider" : "unrecognized",
25506
25759
  ...identity === void 0 ? {} : { identity: {
@@ -25508,7 +25761,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
25508
25761
  ...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
25509
25762
  } },
25510
25763
  ...typeof failure.diagnostic === "string" ? { diagnostic: failure.diagnostic } : {},
25511
- ...isRecord16(failure.details) ? { details: failure.details } : {}
25764
+ ...isRecord18(failure.details) ? { details: failure.details } : {}
25512
25765
  };
25513
25766
  }
25514
25767
  }
@@ -25555,11 +25808,11 @@ function typedFailedTerminatingToolKnownFailure(entries) {
25555
25808
  if (classification.kind !== "infrastructure") continue;
25556
25809
  if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
25557
25810
  if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
25558
- const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord16(part) && part.type === "text" && typeof part.text === "string") : void 0;
25559
- const diagnostic = isRecord16(textPart) ? textPart.text : void 0;
25560
- const details = isRecord16(message.details) ? message.details : classification.fact;
25811
+ const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord18(part) && part.type === "text" && typeof part.text === "string") : void 0;
25812
+ const diagnostic = isRecord18(textPart) ? textPart.text : void 0;
25813
+ const details = isRecord18(message.details) ? message.details : classification.fact;
25561
25814
  return {
25562
- cause: "output",
25815
+ cause: "activation",
25563
25816
  identity: { name: message.toolName, code: message.toolCallId },
25564
25817
  ...typeof diagnostic === "string" && diagnostic.trim() !== "" ? { diagnostic } : {},
25565
25818
  details
@@ -25715,7 +25968,7 @@ function controlledFailureInputFromResolution(resolution) {
25715
25968
  } : {}
25716
25969
  };
25717
25970
  }
25718
- function isRecord16(value) {
25971
+ function isRecord18(value) {
25719
25972
  return typeof value === "object" && value !== null && !Array.isArray(value);
25720
25973
  }
25721
25974
  function safelyRead(object, key) {
@@ -25734,11 +25987,19 @@ function auditNoReceiptDecisiveFact(candidate) {
25734
25987
  return {};
25735
25988
  }
25736
25989
  }
25990
+ function auditUnreadableDecisiveFact(candidate) {
25991
+ const projected = safelyRead(candidate, "auditUnreadable");
25992
+ if (!projected.readable || projected.value === void 0) return {};
25993
+ if (typeof projected.value !== "object" || projected.value === null || Array.isArray(projected.value)) {
25994
+ return { auditUnreadable: projected.value };
25995
+ }
25996
+ return { auditUnreadable: projected.value };
25997
+ }
25737
25998
  function countersignDecisiveFacts(verdict, countersignStatus) {
25738
25999
  const facts = { countersignStatus };
25739
26000
  if (countersignStatus === "continue") {
25740
26001
  const fix = safelyRead(verdict, "fix");
25741
- if (fix.readable && isRecord16(fix.value)) {
26002
+ if (fix.readable && isRecord18(fix.value)) {
25742
26003
  const summary = safelyRead(fix.value, "summary");
25743
26004
  if (summary.readable && typeof summary.value === "string") {
25744
26005
  facts.fixSummary = summary.value;
@@ -25747,7 +26008,7 @@ function countersignDecisiveFacts(verdict, countersignStatus) {
25747
26008
  }
25748
26009
  if (countersignStatus === "escalate") {
25749
26010
  const gate = safelyRead(verdict, "decisionGate");
25750
- if (gate.readable && isRecord16(gate.value)) {
26011
+ if (gate.readable && isRecord18(gate.value)) {
25751
26012
  const question = safelyRead(gate.value, "question");
25752
26013
  const options = safelyRead(gate.value, "options");
25753
26014
  if (question.readable && typeof question.value === "string") {
@@ -25767,12 +26028,13 @@ function countersignDecisiveFacts(verdict, countersignStatus) {
25767
26028
  function judgeDecisiveFacts(verdict, judgeStatus) {
25768
26029
  const facts = {
25769
26030
  judgeStatus,
25770
- ...auditNoReceiptDecisiveFact(verdict)
26031
+ ...auditNoReceiptDecisiveFact(verdict),
26032
+ ...auditUnreadableDecisiveFact(verdict)
25771
26033
  };
25772
26034
  const statusBase = judgeStatus;
25773
26035
  if (statusBase === "continue") {
25774
26036
  const fix = safelyRead(verdict, "fix");
25775
- if (fix.readable && isRecord16(fix.value)) {
26037
+ if (fix.readable && isRecord18(fix.value)) {
25776
26038
  const summary = safelyRead(fix.value, "summary");
25777
26039
  if (summary.readable && typeof summary.value === "string") {
25778
26040
  facts.fixSummary = summary.value;
@@ -25782,7 +26044,7 @@ function judgeDecisiveFacts(verdict, judgeStatus) {
25782
26044
  if (classes.readable && Array.isArray(classes.value)) {
25783
26045
  try {
25784
26046
  facts.classes = classes.value.map((entry) => {
25785
- if (!isRecord16(entry)) throw new Error("unreadable Judge class");
26047
+ if (!isRecord18(entry)) throw new Error("unreadable Judge class");
25786
26048
  return {
25787
26049
  name: entry.name,
25788
26050
  owner: entry.owner,
@@ -25797,7 +26059,7 @@ function judgeDecisiveFacts(verdict, judgeStatus) {
25797
26059
  }
25798
26060
  if (statusBase === "escalate") {
25799
26061
  const gate = safelyRead(verdict, "decisionGate");
25800
- if (gate.readable && isRecord16(gate.value)) {
26062
+ if (gate.readable && isRecord18(gate.value)) {
25801
26063
  const question = safelyRead(gate.value, "question");
25802
26064
  const options = safelyRead(gate.value, "options");
25803
26065
  if (question.readable && typeof question.value === "string") {
@@ -25843,7 +26105,7 @@ function fixerDecisiveFacts(output) {
25843
26105
  facts.reason = reason.value;
25844
26106
  }
25845
26107
  const blockerRead = safelyRead(candidate, "blocker");
25846
- if (statusBase === "refused" && blockerRead.readable && isRecord16(blockerRead.value)) {
26108
+ if (statusBase === "refused" && blockerRead.readable && isRecord18(blockerRead.value)) {
25847
26109
  const cause = safelyRead(blockerRead.value, "cause");
25848
26110
  if (cause.readable && typeof cause.value === "string") facts.blockerCause = cause.value;
25849
26111
  const prerequisiteId = safelyRead(blockerRead.value, "prerequisiteId");
@@ -25855,13 +26117,13 @@ function fixerDecisiveFacts(output) {
25855
26117
  const blockers = [];
25856
26118
  try {
25857
26119
  for (const entry of classResults.value) {
25858
- if (!isRecord16(entry)) throw new Error("unreadable class result");
26120
+ if (!isRecord18(entry)) throw new Error("unreadable class result");
25859
26121
  const name = safelyRead(entry, "name");
25860
26122
  const disposition = safelyRead(entry, "disposition");
25861
26123
  if (!name.readable || !disposition.readable) throw new Error("unreadable class result");
25862
26124
  rows.push({ name: name.value, disposition: disposition.value });
25863
26125
  const blocker = safelyRead(entry, "blocker");
25864
- if (disposition.value === "refused" && blocker.readable && isRecord16(blocker.value)) blockers.push(blocker.value);
26126
+ if (disposition.value === "refused" && blocker.readable && isRecord18(blocker.value)) blockers.push(blocker.value);
25865
26127
  }
25866
26128
  facts.classResultCount = rows.length;
25867
26129
  facts.classDispositions = rows;
@@ -25894,7 +26156,7 @@ function collectorDecisiveFacts(receipt) {
25894
26156
  if (groups.readable && Array.isArray(groups.value)) {
25895
26157
  try {
25896
26158
  facts.groups = groups.value.map((group) => {
25897
- if (!isRecord16(group)) throw new Error("unreadable Collector group");
26159
+ if (!isRecord18(group)) throw new Error("unreadable Collector group");
25898
26160
  const identity = safelyRead(group, "identity");
25899
26161
  const attendance = safelyRead(group, "attendance");
25900
26162
  const materials = safelyRead(group, "materials");
@@ -25917,7 +26179,10 @@ function collectorDecisiveFacts(receipt) {
25917
26179
  function doctorDecisiveFacts(output) {
25918
26180
  const candidate = output;
25919
26181
  const status = safelyRead(candidate, "status");
25920
- const facts = { ...auditNoReceiptDecisiveFact(candidate) };
26182
+ const facts = {
26183
+ ...auditNoReceiptDecisiveFact(candidate),
26184
+ ...auditUnreadableDecisiveFact(candidate)
26185
+ };
25921
26186
  if (status.readable && typeof status.value === "string") facts.doctorStatus = status.value;
25922
26187
  const statusBase = status.readable && typeof status.value === "string" ? status.value : void 0;
25923
26188
  if (statusBase === "refused") {
@@ -25928,7 +26193,7 @@ function doctorDecisiveFacts(output) {
25928
26193
  return facts;
25929
26194
  }
25930
26195
  const caseValue = safelyRead(candidate, "case");
25931
- if (caseValue.readable && isRecord16(caseValue.value)) {
26196
+ if (caseValue.readable && isRecord18(caseValue.value)) {
25932
26197
  const issueNumber = safelyRead(caseValue.value, "issueNumber");
25933
26198
  const runsPath = safelyRead(caseValue.value, "runsPath");
25934
26199
  if (issueNumber.readable && issueNumber.value !== void 0) facts.issueNumber = issueNumber.value;
@@ -25939,7 +26204,7 @@ function doctorDecisiveFacts(output) {
25939
26204
  return facts;
25940
26205
  }
25941
26206
  function reviewerAxes(value) {
25942
- if (!isRecord16(value)) return [];
26207
+ if (!isRecord18(value)) return [];
25943
26208
  return ["standards", "spec"].filter((axis) => {
25944
26209
  const projected = safelyRead(value, axis);
25945
26210
  return projected.readable && projected.value !== void 0;
@@ -26073,7 +26338,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
26073
26338
  const candidateMessage = entries[index]?.message;
26074
26339
  if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
26075
26340
  for (const part of candidateMessage.content) {
26076
- if (!isRecord16(part) || part.type !== "toolCall" || part.id !== callId) {
26341
+ if (!isRecord18(part) || part.type !== "toolCall" || part.id !== callId) {
26077
26342
  continue;
26078
26343
  }
26079
26344
  if (part.name !== outputToolName) return void 0;
@@ -26145,7 +26410,7 @@ function parseNavigatorAttendanceDetails(details) {
26145
26410
  const advisoryDiagnostic = typeof details.routePlaybookReadFailure === "string" ? { advisoryDiagnostic: details.routePlaybookReadFailure } : {};
26146
26411
  if (disposition === "recommendation") {
26147
26412
  const next = details.next;
26148
- if (!isRecord16(next) || typeof next.role !== "string") {
26413
+ if (!isRecord18(next) || typeof next.role !== "string") {
26149
26414
  return {
26150
26415
  disposition: "unavailable",
26151
26416
  source: "unknown",
@@ -26153,7 +26418,7 @@ function parseNavigatorAttendanceDetails(details) {
26153
26418
  };
26154
26419
  }
26155
26420
  const reason = typeof details.reason === "string" ? details.reason : "";
26156
- const route = Array.isArray(details.route) ? details.route.filter(isRecord16).map((target) => ({
26421
+ const route = Array.isArray(details.route) ? details.route.filter(isRecord18).map((target) => ({
26157
26422
  role: String(target.role),
26158
26423
  phase: navigatorPhaseValue(target.phase)
26159
26424
  })) : void 0;
@@ -26216,8 +26481,8 @@ function projectTerminalGateFact(rounds) {
26216
26481
  };
26217
26482
  }
26218
26483
  async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
26219
- const directories = [join24(sessionDirectory, "auditor-roles")];
26220
- const parentSessionFile = options.parentSessionFile ?? join24(sessionDirectory, "session.jsonl");
26484
+ const directories = [join23(sessionDirectory, "auditor-roles")];
26485
+ const parentSessionFile = options.parentSessionFile ?? join23(sessionDirectory, "session.jsonl");
26221
26486
  const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
26222
26487
  parentSessionFile
26223
26488
  });
@@ -26225,7 +26490,7 @@ async function extractGateFactFromSessionDirectory(sessionDirectory, options = {
26225
26490
  }
26226
26491
  async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
26227
26492
  const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
26228
- if (isRecord16(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && (secondaryEvidence.stage === "gatekeeper" || secondaryEvidence.stage === "inspector" || secondaryEvidence.stage === "notary")) return base;
26493
+ if (isRecord18(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && (secondaryEvidence.stage === "gatekeeper" || secondaryEvidence.stage === "inspector" || secondaryEvidence.stage === "notary")) return base;
26229
26494
  const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
26230
26495
  return gate === void 0 ? base : { ...base, gate };
26231
26496
  }
@@ -26265,7 +26530,7 @@ function extractNavigatorFact(entries) {
26265
26530
  const entry = entries[i];
26266
26531
  if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
26267
26532
  const details = entry.message?.details ?? entry.details;
26268
- if (!isRecord16(details)) {
26533
+ if (!isRecord18(details)) {
26269
26534
  return {
26270
26535
  disposition: "unavailable",
26271
26536
  source: "unknown",
@@ -26315,9 +26580,9 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
26315
26580
  async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
26316
26581
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26317
26582
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26318
- const reportPath = join24(artifactsDir, "report.json");
26319
- const evidencePath = join24(artifactsDir, "evidence.json");
26320
- await writeFile7(
26583
+ const reportPath = join23(artifactsDir, "report.json");
26584
+ const evidencePath = join23(artifactsDir, "evidence.json");
26585
+ await writeFile6(
26321
26586
  reportPath,
26322
26587
  `${JSON.stringify(
26323
26588
  {
@@ -26331,7 +26596,7 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
26331
26596
  `,
26332
26597
  "utf8"
26333
26598
  );
26334
- await writeFile7(
26599
+ await writeFile6(
26335
26600
  evidencePath,
26336
26601
  `${JSON.stringify(
26337
26602
  {
@@ -26360,9 +26625,9 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
26360
26625
  async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
26361
26626
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26362
26627
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26363
- const reportPath = join24(artifactsDir, "report.json");
26364
- const evidencePath = join24(artifactsDir, "evidence.json");
26365
- await writeFile7(
26628
+ const reportPath = join23(artifactsDir, "report.json");
26629
+ const evidencePath = join23(artifactsDir, "evidence.json");
26630
+ await writeFile6(
26366
26631
  reportPath,
26367
26632
  `${JSON.stringify(
26368
26633
  {
@@ -26378,7 +26643,7 @@ async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options
26378
26643
  `,
26379
26644
  "utf8"
26380
26645
  );
26381
- await writeFile7(
26646
+ await writeFile6(
26382
26647
  evidencePath,
26383
26648
  `${JSON.stringify(
26384
26649
  {
@@ -26520,9 +26785,9 @@ function extractFixerMethodInvocations(entries, options) {
26520
26785
  async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
26521
26786
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26522
26787
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26523
- const reportPath = join24(artifactsDir, "report.json");
26524
- const evidencePath = join24(artifactsDir, "evidence.json");
26525
- await writeFile7(
26788
+ const reportPath = join23(artifactsDir, "report.json");
26789
+ const evidencePath = join23(artifactsDir, "evidence.json");
26790
+ await writeFile6(
26526
26791
  reportPath,
26527
26792
  `${JSON.stringify(
26528
26793
  {
@@ -26538,7 +26803,7 @@ async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options
26538
26803
  `,
26539
26804
  "utf8"
26540
26805
  );
26541
- await writeFile7(
26806
+ await writeFile6(
26542
26807
  evidencePath,
26543
26808
  `${JSON.stringify(
26544
26809
  {
@@ -26620,9 +26885,9 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options) {
26620
26885
  async function publishCollectorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
26621
26886
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26622
26887
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26623
- const reportPath = join24(artifactsDir, "report.json");
26624
- const evidencePath = join24(artifactsDir, "evidence.json");
26625
- await writeFile7(
26888
+ const reportPath = join23(artifactsDir, "report.json");
26889
+ const evidencePath = join23(artifactsDir, "evidence.json");
26890
+ await writeFile6(
26626
26891
  reportPath,
26627
26892
  `${JSON.stringify(
26628
26893
  {
@@ -26637,7 +26902,7 @@ async function publishCollectorArtifacts(admitted, roleOutcome, coordinates, opt
26637
26902
  `,
26638
26903
  "utf8"
26639
26904
  );
26640
- await writeFile7(
26905
+ await writeFile6(
26641
26906
  evidencePath,
26642
26907
  `${JSON.stringify(
26643
26908
  {
@@ -26680,7 +26945,7 @@ async function settleLawfulCollectorTerminalResult(admitted, authority) {
26680
26945
  const residual = boundErroredToolCandidate(entries, index, message, COLLECTOR_WAIT_TOOL);
26681
26946
  if (residual === void 0) continue;
26682
26947
  const candidate = residual.candidate;
26683
- const duration = isRecord16(candidate) ? candidate.durationMs : void 0;
26948
+ const duration = isRecord18(candidate) ? candidate.durationMs : void 0;
26684
26949
  if (Number.isSafeInteger(duration) && duration >= 1 && duration <= 9e5) {
26685
26950
  continue;
26686
26951
  }
@@ -26728,9 +26993,9 @@ async function trySettleCollectorTerminalResult(admitted, authority) {
26728
26993
  async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
26729
26994
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26730
26995
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
26731
- const reportPath = join24(artifactsDir, "report.json");
26732
- const evidencePath = join24(artifactsDir, "evidence.json");
26733
- await writeFile7(
26996
+ const reportPath = join23(artifactsDir, "report.json");
26997
+ const evidencePath = join23(artifactsDir, "evidence.json");
26998
+ await writeFile6(
26734
26999
  reportPath,
26735
27000
  `${JSON.stringify(
26736
27001
  {
@@ -26745,7 +27010,7 @@ async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, option
26745
27010
  `,
26746
27011
  "utf8"
26747
27012
  );
26748
- await writeFile7(
27013
+ await writeFile6(
26749
27014
  evidencePath,
26750
27015
  `${JSON.stringify(
26751
27016
  {
@@ -26874,7 +27139,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
26874
27139
  return settleFailureTerminalResult(admitted, {
26875
27140
  cause: "output",
26876
27141
  diagnostic: residual.diagnostic,
26877
- details: { candidate: residual.candidate, acceptedReceipt: false }
27142
+ details: stampShapeUnreadableDetails(residual.candidate)
26878
27143
  }, authority);
26879
27144
  }
26880
27145
  if (acceptedNonUsable === void 0 && message.toolName === spec.toolName && isAcceptedPackagedRoleTerminalResult(message)) {
@@ -26887,7 +27152,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
26887
27152
  return settleFailureTerminalResult(admitted, {
26888
27153
  cause: "output",
26889
27154
  diagnostic: spec.nonUsableDiagnostic,
26890
- details: { candidate: acceptedNonUsable, acceptedReceipt: false }
27155
+ details: stampShapeUnreadableDetails(acceptedNonUsable)
26891
27156
  }, authority);
26892
27157
  }
26893
27158
  return void 0;
@@ -26898,7 +27163,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
26898
27163
  {
26899
27164
  cause: "output",
26900
27165
  diagnostic: spec.nonUsableDiagnostic,
26901
- details: { candidate: roleOutcome.decisiveFacts, acceptedReceipt: false }
27166
+ details: stampShapeUnreadableDetails(roleOutcome.decisiveFacts)
26902
27167
  },
26903
27168
  authority
26904
27169
  );
@@ -27072,6 +27337,53 @@ async function settleLawfulNavigatorTerminalResult(admitted, authority, scope) {
27072
27337
  async function trySettleNavigatorTerminalResult(admitted, authority, scope) {
27073
27338
  return settleLawfulNavigatorTerminalResult(admitted, authority, scope);
27074
27339
  }
27340
+ async function settleLawfulAuditorTerminalResult(admitted, authority, scope) {
27341
+ return settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
27342
+ role: "auditor",
27343
+ toolName: AUDITOR_OUTPUT_TOOL_NAME,
27344
+ nonUsableDiagnostic: "\u5BA1\u5211\u9662\u56DE\u6267\u65E0\u663E\u5F0F pass/revise/escalate",
27345
+ // Only pass/revise/escalate are lawful releases. Unreadable mystery status
27346
+ // fails closed with candidate retained for parent ComplianceCandidateUnreadableError.
27347
+ tryAcceptDetails: (details) => projectLawfulAuditorOutput(details) !== void 0,
27348
+ projectAccepted: (sealed) => {
27349
+ const lawful = projectLawfulAuditorOutput(sealed.decisiveFacts);
27350
+ if (lawful === void 0) {
27351
+ throw new Error("auditor projectAccepted requires lawful pass/revise/escalate");
27352
+ }
27353
+ const accepted = {
27354
+ kind: "accepted",
27355
+ role: "auditor",
27356
+ status: lawful.status,
27357
+ decisiveFacts: auditorDecisiveFacts(lawful)
27358
+ };
27359
+ return accepted;
27360
+ }
27361
+ }, scope);
27362
+ }
27363
+ async function trySettleAuditorTerminalResult(admitted, authority, scope) {
27364
+ return settleLawfulAuditorTerminalResult(admitted, authority, scope);
27365
+ }
27366
+ async function settleLawfulEvidenceChildTerminalResult(admitted, authority, scope) {
27367
+ return settleLawfulSeatAcceptedTerminalResult(admitted, authority, {
27368
+ role: "evidence-child",
27369
+ toolName: EVIDENCE_CHILD_OUTPUT_TOOL_NAME,
27370
+ nonUsableDiagnostic: "\u53D6\u8BC1\u56DE\u6267\u65E0\u62A5\u544A\u6B63\u6587",
27371
+ tryAcceptDetails: tryAcceptWithValidator(validateRecordedEvidenceChildOutput),
27372
+ projectAccepted: (sealed) => {
27373
+ const output = validateRecordedEvidenceChildOutput(sealed.decisiveFacts);
27374
+ const accepted = {
27375
+ kind: "accepted",
27376
+ role: "evidence-child",
27377
+ status: "report",
27378
+ decisiveFacts: evidenceChildDecisiveFacts(output)
27379
+ };
27380
+ return accepted;
27381
+ }
27382
+ }, scope);
27383
+ }
27384
+ async function trySettleEvidenceChildTerminalResult(admitted, authority, scope) {
27385
+ return settleLawfulEvidenceChildTerminalResult(admitted, authority, scope);
27386
+ }
27075
27387
  async function trySettleCoderTerminalResult(admitted, authority, options = {}) {
27076
27388
  return settleLawfulCoderTerminalResult(admitted, authority, options);
27077
27389
  }
@@ -27097,9 +27409,9 @@ function extractReviewerMethodInvocations(entries, options) {
27097
27409
  async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
27098
27410
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
27099
27411
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
27100
- const reportPath = join24(artifactsDir, "report.json");
27101
- const evidencePath = join24(artifactsDir, "evidence.json");
27102
- await writeFile7(
27412
+ const reportPath = join23(artifactsDir, "report.json");
27413
+ const evidencePath = join23(artifactsDir, "evidence.json");
27414
+ await writeFile6(
27103
27415
  reportPath,
27104
27416
  `${JSON.stringify(
27105
27417
  {
@@ -27114,7 +27426,7 @@ async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, opti
27114
27426
  `,
27115
27427
  "utf8"
27116
27428
  );
27117
- await writeFile7(
27429
+ await writeFile6(
27118
27430
  evidencePath,
27119
27431
  `${JSON.stringify(
27120
27432
  {
@@ -27225,9 +27537,9 @@ function extractMergerMethodInvocations(entries, options) {
27225
27537
  async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
27226
27538
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
27227
27539
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
27228
- const reportPath = join24(artifactsDir, "report.json");
27229
- const evidencePath = join24(artifactsDir, "evidence.json");
27230
- await writeFile7(
27540
+ const reportPath = join23(artifactsDir, "report.json");
27541
+ const evidencePath = join23(artifactsDir, "evidence.json");
27542
+ await writeFile6(
27231
27543
  reportPath,
27232
27544
  `${JSON.stringify(
27233
27545
  {
@@ -27242,7 +27554,7 @@ async function publishMergerArtifacts(admitted, roleOutcome, coordinates, option
27242
27554
  `,
27243
27555
  "utf8"
27244
27556
  );
27245
- await writeFile7(
27557
+ await writeFile6(
27246
27558
  evidencePath,
27247
27559
  `${JSON.stringify(
27248
27560
  {
@@ -27293,7 +27605,7 @@ async function settleLawfulMergerTerminalResult(admitted, authority, options) {
27293
27605
  if (message?.role !== "toolResult") continue;
27294
27606
  const residual = boundErroredToolCandidate(entries, index, message, MERGER_OUTPUT_TOOL_NAME);
27295
27607
  if (residual === void 0) continue;
27296
- const attemptId = isRecord16(residual.candidate) ? safelyRead(residual.candidate, "attemptId") : { readable: true, value: void 0 };
27608
+ const attemptId = isRecord18(residual.candidate) ? safelyRead(residual.candidate, "attemptId") : { readable: true, value: void 0 };
27297
27609
  if (!attemptId.readable || attemptId.value !== admitted.runId) continue;
27298
27610
  try {
27299
27611
  validateMergerOutput(residual.candidate, admitted.runId);
@@ -27375,7 +27687,7 @@ function uniqueFailureFallbackDirs(runDirectory, baseDir) {
27375
27687
  return dirs;
27376
27688
  }
27377
27689
  async function resolveFailureArtifactsBase(runDirectory) {
27378
- const artifactsDir = join24(runDirectory, "artifacts");
27690
+ const artifactsDir = join23(runDirectory, "artifacts");
27379
27691
  try {
27380
27692
  await ensureRunArtifactsDir(runDirectory);
27381
27693
  return { baseDir: artifactsDir };
@@ -27391,13 +27703,13 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
27391
27703
  const candidates = [
27392
27704
  ...preferredCandidates,
27393
27705
  // One unique name per fallback dir — collisions on fixed names cannot exhaust this.
27394
- ...uniqueFallbackDirs.map((dir) => join24(dir, `${stem}.${randomUUID3()}.json`))
27706
+ ...uniqueFallbackDirs.map((dir) => join23(dir, `${stem}.${randomUUID3()}.json`))
27395
27707
  ];
27396
27708
  for (let i = 0; i < candidates.length; i += 1) {
27397
27709
  const path = candidates[i];
27398
27710
  const payload = issues.length === 0 ? basePayload : { ...basePayload, publicationIssues: issues };
27399
27711
  try {
27400
- await writeFile7(
27712
+ await writeFile6(
27401
27713
  path,
27402
27714
  `${JSON.stringify(payload, null, 2)}
27403
27715
  `,
@@ -27436,26 +27748,26 @@ async function publishFailureArtifacts(admitted, failure, authority) {
27436
27748
  } catch (error) {
27437
27749
  priorIssues.push(publicationAttemptFromError(sessionFile, error));
27438
27750
  }
27439
- const underArtifacts = baseDir === join24(admitted.runDirectory, "artifacts");
27751
+ const underArtifacts = baseDir === join23(admitted.runDirectory, "artifacts");
27440
27752
  const uniqueFallbackDirs = uniqueFailureFallbackDirs(
27441
27753
  admitted.runDirectory,
27442
27754
  baseDir
27443
27755
  );
27444
27756
  const errorCandidates = underArtifacts ? [
27445
- join24(baseDir, "error.json"),
27446
- join24(baseDir, "error.settlement.json"),
27447
- join24(admitted.runDirectory, "error.settlement.json")
27757
+ join23(baseDir, "error.json"),
27758
+ join23(baseDir, "error.settlement.json"),
27759
+ join23(admitted.runDirectory, "error.settlement.json")
27448
27760
  ] : [
27449
- join24(baseDir, "error.settlement.json"),
27450
- join24(baseDir, "error.json")
27761
+ join23(baseDir, "error.settlement.json"),
27762
+ join23(baseDir, "error.json")
27451
27763
  ];
27452
27764
  const evidenceCandidates = underArtifacts ? [
27453
- join24(baseDir, "evidence.json"),
27454
- join24(baseDir, "evidence.settlement.json"),
27455
- join24(admitted.runDirectory, "evidence.settlement.json")
27765
+ join23(baseDir, "evidence.json"),
27766
+ join23(baseDir, "evidence.settlement.json"),
27767
+ join23(admitted.runDirectory, "evidence.settlement.json")
27456
27768
  ] : [
27457
- join24(baseDir, "evidence.settlement.json"),
27458
- join24(baseDir, "evidence.json")
27769
+ join23(baseDir, "evidence.settlement.json"),
27770
+ join23(baseDir, "evidence.json")
27459
27771
  ];
27460
27772
  const errorPayloadBase = {
27461
27773
  kind: "error",
@@ -27651,6 +27963,7 @@ var init_settlement = __esm({
27651
27963
  init_auditor_soul();
27652
27964
  init_doctor_auditor();
27653
27965
  init_judge_auditor();
27966
+ init_shape_unreadable_failure();
27654
27967
  init_known_failure();
27655
27968
  init_reviewer_dispatch_rejection();
27656
27969
  init_run_lifecycle();
@@ -27671,6 +27984,8 @@ var init_settlement = __esm({
27671
27984
  init_inspector_contracts();
27672
27985
  init_gatekeeper_output();
27673
27986
  init_navigator_output();
27987
+ init_auditor_output();
27988
+ init_evidence_child_output();
27674
27989
  init_method_skill();
27675
27990
  init_navigator_invocation_identity();
27676
27991
  init_receipt_delivery_policy();
@@ -27728,7 +28043,7 @@ var init_turn_request = __esm({
27728
28043
 
27729
28044
  // src/host-transition-prior-native.ts
27730
28045
  import { access as access2, readdir as readdir6 } from "node:fs/promises";
27731
- import { dirname as dirname11, join as join25 } from "node:path";
28046
+ import { dirname as dirname11, join as join24 } from "node:path";
27732
28047
  function isEnoent2(error) {
27733
28048
  return typeof error === "object" && error !== null && error.code === "ENOENT";
27734
28049
  }
@@ -27753,7 +28068,7 @@ async function listSitianRecordPaths(sessionParent) {
27753
28068
  const recordPaths = [];
27754
28069
  for (const entry of entries) {
27755
28070
  if (!entry.isDirectory()) continue;
27756
- const recordFile = join25(sessionRoot, entry.name, "records.jsonl");
28071
+ const recordFile = join24(sessionRoot, entry.name, "records.jsonl");
27757
28072
  try {
27758
28073
  await access2(recordFile);
27759
28074
  recordPaths.push(recordFile);
@@ -27823,7 +28138,7 @@ var init_public_run_credentials = __esm({
27823
28138
  import { constants as fsConstants } from "node:fs";
27824
28139
  import { randomUUID as randomUUID4 } from "node:crypto";
27825
28140
  import { lstat as lstat5, mkdir as mkdir4, open as open2 } from "node:fs/promises";
27826
- import { join as join26 } from "node:path";
28141
+ import { join as join25 } from "node:path";
27827
28142
  function presentTerminal(terminal, io) {
27828
28143
  if (terminal.roleOutcome.kind === "failure" || terminal.roleOutcome.kind === "no_receipt") {
27829
28144
  presentFailureTerminal(terminal, io);
@@ -27842,7 +28157,7 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
27842
28157
  }
27843
28158
  }
27844
28159
  function runArtifactsDirectory(runDirectory) {
27845
- return join26(runDirectory, "artifacts");
28160
+ return join25(runDirectory, "artifacts");
27846
28161
  }
27847
28162
  async function ensureRealArtifactsDirectory(runDirectory) {
27848
28163
  const runStat = await lstat5(runDirectory);
@@ -27925,7 +28240,7 @@ function jsonSafeReplacer() {
27925
28240
  }
27926
28241
  async function retainDispatchError(admitted, principalAuthority, sessionAppender, attempt, error) {
27927
28242
  const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
27928
- const filePath = join26(
28243
+ const filePath = join25(
27929
28244
  artifactsDir,
27930
28245
  `dispatch-error-attempt-${attempt}-${randomUUID4()}.json`
27931
28246
  );
@@ -28173,11 +28488,11 @@ var init_auto_resume = __esm({
28173
28488
 
28174
28489
  // src/public-cli/post-admission.ts
28175
28490
  import { randomUUID as randomUUID5 } from "node:crypto";
28176
- import { readFile as readFile16, writeFile as writeFile8 } from "node:fs/promises";
28177
- import { isAbsolute as isAbsolute6, join as join27, resolve as resolve9 } from "node:path";
28491
+ import { readFile as readFile16, writeFile as writeFile7 } from "node:fs/promises";
28492
+ import { isAbsolute as isAbsolute6, join as join26, resolve as resolve9 } from "node:path";
28178
28493
  async function readInvocationHost(runDirectory) {
28179
28494
  try {
28180
- const raw = JSON.parse(await readFile16(join27(runDirectory, "invocation.json"), "utf8"));
28495
+ const raw = JSON.parse(await readFile16(join26(runDirectory, "invocation.json"), "utf8"));
28181
28496
  return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host : void 0;
28182
28497
  } catch (error) {
28183
28498
  if (error.code === "ENOENT") return void 0;
@@ -28260,7 +28575,7 @@ async function dispatchPostAdmissionTurn(input) {
28260
28575
  liveHost,
28261
28576
  piSessionFile: principalCoordinates.sessionFile
28262
28577
  }) : void 0;
28263
- turnRequest = request;
28578
+ turnRequest = env.signal === void 0 ? request : { ...request, signal: env.signal };
28264
28579
  if (hostTransition !== void 0) {
28265
28580
  turnRequest = { ...turnRequest, hostTransition };
28266
28581
  }
@@ -28316,8 +28631,8 @@ async function dispatchPostAdmissionTurn(input) {
28316
28631
  );
28317
28632
  }
28318
28633
  try {
28319
- await writeFile8(
28320
- join27(admitted.runDirectory, "stderr.log"),
28634
+ await writeFile7(
28635
+ join26(admitted.runDirectory, "stderr.log"),
28321
28636
  result2.stderr,
28322
28637
  "utf8"
28323
28638
  );
@@ -28429,7 +28744,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
28429
28744
  }
28430
28745
  function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
28431
28746
  const absolute = isAbsolute6(attachmentPath) ? attachmentPath : resolve9(attachmentPath);
28432
- return pathContainedIn(join27(runDirectory, "attachments"), absolute);
28747
+ return pathContainedIn(join26(runDirectory, "attachments"), absolute);
28433
28748
  }
28434
28749
  async function prepareSummonsResumeMaterials(runDirectory, summons) {
28435
28750
  if (summons === void 0) return void 0;
@@ -28929,13 +29244,50 @@ function buildInstructionSeatTurnRequest(admitted, options) {
28929
29244
  options
28930
29245
  );
28931
29246
  }
28932
- function instructionSeatAdapters() {
29247
+ function instructionSeatAdapters(options) {
28933
29248
  return {
28934
- trySettle: (admitted, authority, scope) => admitted.role === "gatekeeper" ? trySettleGatekeeperTerminalResult(admitted, authority, scope) : trySettleNavigatorTerminalResult(admitted, authority, scope),
29249
+ trySettle: (admitted, authority, scope) => {
29250
+ switch (admitted.role) {
29251
+ case "gatekeeper":
29252
+ return trySettleGatekeeperTerminalResult(admitted, authority, scope);
29253
+ case "navigator":
29254
+ return trySettleNavigatorTerminalResult(admitted, authority, scope);
29255
+ case "auditor":
29256
+ return trySettleAuditorTerminalResult(admitted, authority, scope);
29257
+ case "evidence-child":
29258
+ return trySettleEvidenceChildTerminalResult(admitted, authority, scope);
29259
+ }
29260
+ },
28935
29261
  // Accepted receipts and failure terminals both present via shared path.
28936
- shouldPresentSettled: () => true
29262
+ shouldPresentSettled: () => true,
29263
+ // #675 / #357 T2: failInfrastructure abort after engine-detour tool failure must not
29264
+ // wash the durable toolResult diagnostic (same seam as reviewer-run / judge-run).
29265
+ resolveRunnerKnownFailure: async ({
29266
+ result: result2,
29267
+ sessionFile
29268
+ }) => {
29269
+ const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
29270
+ return infrastructureFailure === void 0 ? result2.knownFailure : {
29271
+ cause: infrastructureFailure.cause,
29272
+ diagnostic: infrastructureFailure.diagnostic,
29273
+ ...infrastructureFailure.identity === void 0 ? {} : { identity: infrastructureFailure.identity }
29274
+ };
29275
+ },
29276
+ ...options?.beforeDispatch === void 0 ? {} : { beforeDispatch: options.beforeDispatch }
28937
29277
  };
28938
29278
  }
29279
+ async function admitInstructionSeat(role, options) {
29280
+ switch (role) {
29281
+ case "gatekeeper":
29282
+ return admitGatekeeperInvocation(options);
29283
+ case "navigator":
29284
+ return admitNavigatorInvocation(options);
29285
+ case "auditor":
29286
+ return admitAuditorInvocation(options);
29287
+ case "evidence-child":
29288
+ return admitEvidenceChildInvocation(options);
29289
+ }
29290
+ }
28939
29291
  async function runPublicInstructionSeatResume(request, env, io) {
28940
29292
  return await runPostAdmissionSeatResume({
28941
29293
  request,
@@ -28946,19 +29298,136 @@ async function runPublicInstructionSeatResume(request, env, io) {
28946
29298
  effective.runId,
28947
29299
  env.principalAuthority
28948
29300
  ),
28949
- buildTurnRequest: (admitted, effective) => buildInstructionSeatTurnRequest(
28950
- admitted,
28951
- resumeTurnRequestProjectionOptions(admitted, effective, env)
28952
- ),
29301
+ buildTurnRequest: async (admitted, effective) => {
29302
+ const summonsPrepared = await prepareSummonsResumeMaterials(
29303
+ admitted.runDirectory,
29304
+ effective.summons
29305
+ );
29306
+ return buildInstructionSeatTurnRequest(
29307
+ admitted,
29308
+ resumeTurnRequestProjectionOptions(
29309
+ admitted,
29310
+ effective,
29311
+ env,
29312
+ summonsPrepared
29313
+ )
29314
+ );
29315
+ },
28953
29316
  adapters: instructionSeatAdapters(),
28954
29317
  ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
28955
29318
  });
28956
29319
  }
29320
+ async function withAuditorSoulEnv(options) {
29321
+ if (options.subject === void 0 && options.sourceRunDirectory === void 0) {
29322
+ return options.run();
29323
+ }
29324
+ const { AK_ROLE_AUDITOR_SUBJECT_ENV: AK_ROLE_AUDITOR_SUBJECT_ENV2, AK_ROLE_AUDITOR_SOURCE_RUN_ENV: AK_ROLE_AUDITOR_SOURCE_RUN_ENV2 } = await Promise.resolve().then(() => (init_auditor_soul(), auditor_soul_exports));
29325
+ const priorSubject = process.env[AK_ROLE_AUDITOR_SUBJECT_ENV2];
29326
+ const priorSource = process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV2];
29327
+ if (options.subject !== void 0) {
29328
+ process.env[AK_ROLE_AUDITOR_SUBJECT_ENV2] = options.subject;
29329
+ }
29330
+ if (options.sourceRunDirectory !== void 0) {
29331
+ process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV2] = options.sourceRunDirectory;
29332
+ }
29333
+ try {
29334
+ return await options.run();
29335
+ } finally {
29336
+ if (options.subject !== void 0) {
29337
+ if (priorSubject === void 0) delete process.env[AK_ROLE_AUDITOR_SUBJECT_ENV2];
29338
+ else process.env[AK_ROLE_AUDITOR_SUBJECT_ENV2] = priorSubject;
29339
+ }
29340
+ if (options.sourceRunDirectory !== void 0) {
29341
+ if (priorSource === void 0) delete process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV2];
29342
+ else process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV2] = priorSource;
29343
+ }
29344
+ }
29345
+ }
28957
29346
  async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
29347
+ let parsed;
29348
+ try {
29349
+ parsed = parseArgv2(argv);
29350
+ } catch (error) {
29351
+ if (error instanceof CliUsageError) {
29352
+ presentStructuralRejection(error, io);
29353
+ return { exitCode: 2 };
29354
+ }
29355
+ throw error;
29356
+ }
29357
+ let auditorSubject;
29358
+ let auditorSourceRun;
29359
+ let auditorSourceTicket;
29360
+ let ticketProbe;
29361
+ const projectRoot = parsed.project ?? env.cwd;
29362
+ if (role === "auditor") {
29363
+ if (parsed.subject !== "judge" && parsed.subject !== "doctor") {
29364
+ presentStructuralRejection(
29365
+ new CliUsageError("auditor --subject requires judge|doctor"),
29366
+ io
29367
+ );
29368
+ return { exitCode: 2 };
29369
+ }
29370
+ auditorSubject = parsed.subject;
29371
+ const source = typeof parsed.sourceRun === "string" ? parsed.sourceRun.trim() : "";
29372
+ if (source === "") {
29373
+ presentStructuralRejection(
29374
+ new CliUsageError("auditor --source-run requires a run locator"),
29375
+ io
29376
+ );
29377
+ return { exitCode: 2 };
29378
+ }
29379
+ try {
29380
+ const { resolveNotarySourceRunLocator: resolveNotarySourceRunLocator2 } = await Promise.resolve().then(() => (init_notary_source_run(), notary_source_run_exports));
29381
+ const resolved = await resolveNotarySourceRunLocator2({
29382
+ projectRoot,
29383
+ sourceRun: source,
29384
+ home: env.home
29385
+ });
29386
+ auditorSourceRun = resolved.runDirectory;
29387
+ auditorSourceTicket = await readRunTicketNumber(resolved.runDirectory);
29388
+ } catch (error) {
29389
+ presentStructuralRejection(
29390
+ new CliUsageError(error instanceof Error ? error.message : String(error)),
29391
+ io
29392
+ );
29393
+ return { exitCode: 2 };
29394
+ }
29395
+ } else {
29396
+ ticketProbe = await probeInstructionTicket(
29397
+ parsed.instruction,
29398
+ projectRoot,
29399
+ env
29400
+ );
29401
+ }
29402
+ const probedTicketNumber = auditorSourceTicket ?? (ticketProbe === void 0 ? void 0 : ticketNumberFromProbe(ticketProbe));
29403
+ if (probedTicketNumber !== void 0) {
29404
+ const summons = {
29405
+ instruction: parsed.instruction,
29406
+ instructionEmpty: parsed.instruction.trim() === "",
29407
+ attachmentPaths: parsed.attachmentPaths
29408
+ };
29409
+ const resumed = await withAuditorSoulEnv({
29410
+ ...auditorSubject === void 0 ? {} : { subject: auditorSubject },
29411
+ ...auditorSourceRun === void 0 ? {} : { sourceRunDirectory: auditorSourceRun },
29412
+ run: () => tryResumeSameTicketSeatRun({
29413
+ home: env.home,
29414
+ projectRoot,
29415
+ role,
29416
+ ticketNumber: probedTicketNumber,
29417
+ freshSummons: env.freshSummons,
29418
+ summons,
29419
+ resume: (runId, materials) => runPublicInstructionSeatResume(
29420
+ { runId, ...materials === void 0 ? {} : { summons: materials } },
29421
+ env,
29422
+ io
29423
+ )
29424
+ })
29425
+ });
29426
+ if (resumed !== void 0) return resumed;
29427
+ }
28958
29428
  let admitted;
28959
29429
  try {
28960
- const parsed = parseArgv2(argv);
28961
- const options = {
29430
+ admitted = await admitInstructionSeat(role, {
28962
29431
  home: env.home,
28963
29432
  principalAuthority: env.principalAuthority,
28964
29433
  cwd: env.cwd,
@@ -28968,8 +29437,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
28968
29437
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId },
28969
29438
  ...env.model === void 0 ? {} : { model: env.model },
28970
29439
  ...env.correlationId === void 0 ? {} : { correlationId: env.correlationId }
28971
- };
28972
- admitted = role === "gatekeeper" ? await admitGatekeeperInvocation(options) : await admitNavigatorInvocation(options);
29440
+ });
28973
29441
  } catch (error) {
28974
29442
  if (error instanceof CliUsageError) {
28975
29443
  presentStructuralRejection(error, io);
@@ -28977,43 +29445,59 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
28977
29445
  }
28978
29446
  throw error;
28979
29447
  }
28980
- await markRunAdmitted(admitted, env.principalAuthority);
28981
- const turnRequest = buildInstructionSeatTurnRequest(admitted, {
28982
- packageRoot: env.packageRoot,
28983
- home: env.home,
28984
- agentDir: env.agentDir,
28985
- ...env.model === void 0 ? {} : { model: env.model },
28986
- ...env.engine === void 0 ? {} : { engine: env.engine },
28987
- ...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
28988
- ...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
28989
- continuation: {
28990
- kind: "initial",
28991
- prompt: buildInstructionTransportPrompt(
29448
+ return await withAuditorSoulEnv({
29449
+ ...auditorSubject === void 0 ? {} : { subject: auditorSubject },
29450
+ ...auditorSourceRun === void 0 ? {} : { sourceRunDirectory: auditorSourceRun },
29451
+ run: async () => {
29452
+ await markRunAdmitted(admitted, env.principalAuthority);
29453
+ const turnRequest = buildInstructionSeatTurnRequest(admitted, {
29454
+ packageRoot: env.packageRoot,
29455
+ home: env.home,
29456
+ agentDir: env.agentDir,
29457
+ ...env.model === void 0 ? {} : { model: env.model },
29458
+ ...env.engine === void 0 ? {} : { engine: env.engine },
29459
+ ...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
29460
+ ...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
29461
+ continuation: {
29462
+ kind: "initial",
29463
+ prompt: buildInstructionTransportPrompt(
29464
+ admitted,
29465
+ engineSessionMaterialFromOptions({
29466
+ ...env.engine === void 0 ? {} : { engine: env.engine },
29467
+ packageRoot: env.packageRoot
29468
+ })
29469
+ )
29470
+ }
29471
+ });
29472
+ return await runPostAdmissionOneShot({
28992
29473
  admitted,
28993
- engineSessionMaterialFromOptions({
28994
- ...env.engine === void 0 ? {} : { engine: env.engine },
28995
- packageRoot: env.packageRoot
28996
- })
28997
- )
29474
+ env,
29475
+ io,
29476
+ request: turnRequest,
29477
+ adapters: instructionSeatAdapters({
29478
+ beforeDispatch: async (admittedSeat) => {
29479
+ if (auditorSourceTicket !== void 0) {
29480
+ await bindAdmittedTicketNumber(admittedSeat, auditorSourceTicket);
29481
+ } else if (ticketProbe !== void 0) {
29482
+ await applyInstructionTicketProbe(admittedSeat, ticketProbe);
29483
+ }
29484
+ }
29485
+ }),
29486
+ ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
29487
+ });
28998
29488
  }
28999
29489
  });
29000
- return await runPostAdmissionOneShot({
29001
- admitted,
29002
- env,
29003
- io,
29004
- request: turnRequest,
29005
- adapters: instructionSeatAdapters(),
29006
- ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
29007
- });
29008
29490
  }
29009
29491
  var init_instruction_seat_run = __esm({
29010
29492
  "src/public-cli/instruction-seat-run.ts"() {
29011
29493
  "use strict";
29012
29494
  init_engine_material();
29495
+ init_run_ticket_number();
29013
29496
  init_cli_errors();
29014
29497
  init_invocation();
29015
29498
  init_post_admission();
29016
29499
  init_run_lifecycle();
29500
+ init_seat_ticket_binding();
29017
29501
  init_settlement();
29018
29502
  init_turn_request();
29019
29503
  }
@@ -29290,8 +29774,8 @@ var init_countersign_run = __esm({
29290
29774
 
29291
29775
  // src/public-cli/diarist-run.ts
29292
29776
  import { existsSync as existsSync10 } from "node:fs";
29293
- import { writeFile as writeFile9 } from "node:fs/promises";
29294
- import { join as join28 } from "node:path";
29777
+ import { writeFile as writeFile8 } from "node:fs/promises";
29778
+ import { join as join27 } from "node:path";
29295
29779
  function withDiaristCatalogPath(prompt, sourcesPath) {
29296
29780
  if (sourcesPath === void 0 || sourcesPath.trim() === "") return prompt;
29297
29781
  return `${prompt}
@@ -29317,7 +29801,7 @@ function buildDiaristTurnRequest(admitted, options, sourcesPath) {
29317
29801
  }
29318
29802
  async function freezeDiaristSourceCatalog(admitted, env) {
29319
29803
  if (admitted.ticketNumber === void 0) return void 0;
29320
- const path = join28(admitted.runDirectory, DIARIST_SOURCE_CATALOG_FILE);
29804
+ const path = join27(admitted.runDirectory, DIARIST_SOURCE_CATALOG_FILE);
29321
29805
  if (existsSync10(path)) {
29322
29806
  const identity = await readRoleRunIdentity(admitted.runDirectory);
29323
29807
  if (identity !== void 0 && identity.state !== "terminal") return path;
@@ -29334,7 +29818,7 @@ async function freezeDiaristSourceCatalog(admitted, env) {
29334
29818
  issueFace,
29335
29819
  sessionCwds: [admitted.projectRoot, env.cwd]
29336
29820
  });
29337
- await writeFile9(path, serializeDiaristSourceCatalog(catalog), "utf8");
29821
+ await writeFile8(path, serializeDiaristSourceCatalog(catalog), "utf8");
29338
29822
  return path;
29339
29823
  }
29340
29824
  function diaristAdapters(options) {
@@ -30299,8 +30783,8 @@ var init_judge_run = __esm({
30299
30783
  });
30300
30784
 
30301
30785
  // src/public-cli/merger-run.ts
30302
- import { mkdir as mkdir5, writeFile as writeFile10 } from "node:fs/promises";
30303
- import { join as join29, resolve as resolve10 } from "node:path";
30786
+ import { mkdir as mkdir5, writeFile as writeFile9 } from "node:fs/promises";
30787
+ import { join as join28, resolve as resolve10 } from "node:path";
30304
30788
  function mergerMethods(packageRoot2) {
30305
30789
  return [
30306
30790
  {
@@ -30366,9 +30850,9 @@ async function admitMergerShellForActivationFailure(options) {
30366
30850
  expectedConflictPaths: [],
30367
30851
  resolutionScope: []
30368
30852
  };
30369
- const admittedRequestPath = join29(runDirectory, "admitted-request.json");
30370
- const mergerInputPath = join29(runDirectory, "merger-input.json");
30371
- await writeFile10(
30853
+ const admittedRequestPath = join28(runDirectory, "admitted-request.json");
30854
+ const mergerInputPath = join28(runDirectory, "merger-input.json");
30855
+ await writeFile9(
30372
30856
  admittedRequestPath,
30373
30857
  `${JSON.stringify(
30374
30858
  {
@@ -30806,13 +31290,13 @@ var init_analyst_book_key = __esm({
30806
31290
 
30807
31291
  // src/atomic-write.ts
30808
31292
  import { randomUUID as randomUUID6 } from "node:crypto";
30809
- import { rename, rm as rm2, writeFile as writeFile11 } from "node:fs/promises";
30810
- import { dirname as dirname12, join as join30 } from "node:path";
31293
+ import { rename, rm as rm2, writeFile as writeFile10 } from "node:fs/promises";
31294
+ import { dirname as dirname12, join as join29 } from "node:path";
30811
31295
  async function writeFileAtomically(destination, contents) {
30812
31296
  const parent = dirname12(destination);
30813
- const temporary = join30(parent, `.atomic-write-${randomUUID6()}.tmp`);
31297
+ const temporary = join29(parent, `.atomic-write-${randomUUID6()}.tmp`);
30814
31298
  try {
30815
- await writeFile11(temporary, contents);
31299
+ await writeFile10(temporary, contents);
30816
31300
  await rename(temporary, destination);
30817
31301
  } catch (error) {
30818
31302
  await rm2(temporary, { force: true }).catch(() => void 0);
@@ -30827,7 +31311,7 @@ var init_atomic_write = __esm({
30827
31311
 
30828
31312
  // src/analyst-index.ts
30829
31313
  import { open as open3, readFile as readFile17, unlink as unlink4 } from "node:fs/promises";
30830
- import { dirname as dirname13, join as join31 } from "node:path";
31314
+ import { dirname as dirname13, join as join30 } from "node:path";
30831
31315
  function sleep(ms) {
30832
31316
  return new Promise((resolve12) => {
30833
31317
  setTimeout(resolve12, ms);
@@ -30836,7 +31320,7 @@ function sleep(ms) {
30836
31320
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
30837
31321
  const indexPath = analystLibraryIndexPath(ledgerHome);
30838
31322
  ensureRealDirectoryTree(ledgerHome, dirname13(indexPath));
30839
- const lockPath = join31(dirname13(indexPath), LIBRARY_INDEX_LOCK_NAME);
31323
+ const lockPath = join30(dirname13(indexPath), LIBRARY_INDEX_LOCK_NAME);
30840
31324
  assertLedgerFileInsideHome(lockPath, ledgerHome);
30841
31325
  const startedAt = Date.now();
30842
31326
  while (true) {
@@ -30863,7 +31347,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
30863
31347
  }
30864
31348
  }
30865
31349
  function analystLibraryIndexPath(ledgerHome) {
30866
- return join31(ledgerHome, "analyst", "library-index.json");
31350
+ return join30(ledgerHome, "analyst", "library-index.json");
30867
31351
  }
30868
31352
  function rowFromIssueMetricsPage(page) {
30869
31353
  return {
@@ -31159,22 +31643,22 @@ var init_analyst_cohort = __esm({
31159
31643
 
31160
31644
  // src/analyst-ledger.ts
31161
31645
  import { readdir as readdir7, readFile as readFile18 } from "node:fs/promises";
31162
- import { join as join32 } from "node:path";
31646
+ import { join as join31 } from "node:path";
31163
31647
  function isMissingPathError5(error) {
31164
31648
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
31165
31649
  }
31166
31650
  function errorText3(error) {
31167
31651
  return error instanceof Error ? error.message : String(error);
31168
31652
  }
31169
- function isRecord17(value) {
31653
+ function isRecord19(value) {
31170
31654
  return typeof value === "object" && value !== null && !Array.isArray(value);
31171
31655
  }
31172
31656
  async function readExistingRunLifecycleState(runDirectory) {
31173
31657
  try {
31174
31658
  const raw = JSON.parse(
31175
- await readFile18(join32(runDirectory, "run-state.json"), "utf8")
31659
+ await readFile18(join31(runDirectory, "run-state.json"), "utf8")
31176
31660
  );
31177
- if (!isRecord17(raw) || typeof raw.state !== "string") return void 0;
31661
+ if (!isRecord19(raw) || typeof raw.state !== "string") return void 0;
31178
31662
  return raw.state;
31179
31663
  } catch {
31180
31664
  return void 0;
@@ -31204,13 +31688,13 @@ async function listLedgerBookNames(booksRoot) {
31204
31688
  async function readInvocationScopeFields(runDirectory) {
31205
31689
  let raw;
31206
31690
  try {
31207
- raw = await readFile18(join32(runDirectory, "invocation.json"), "utf8");
31691
+ raw = await readFile18(join31(runDirectory, "invocation.json"), "utf8");
31208
31692
  } catch (error) {
31209
31693
  if (isMissingPathError5(error)) return void 0;
31210
31694
  throw error;
31211
31695
  }
31212
31696
  const parsed = JSON.parse(raw);
31213
- if (!isRecord17(parsed)) return void 0;
31697
+ if (!isRecord19(parsed)) return void 0;
31214
31698
  if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
31215
31699
  return void 0;
31216
31700
  }
@@ -31236,15 +31720,15 @@ function decideIssueScope(input) {
31236
31720
  }
31237
31721
  async function resolveSessionFile(runDirectory) {
31238
31722
  try {
31239
- const raw = await readFile18(join32(runDirectory, "invocation.json"), "utf8");
31723
+ const raw = await readFile18(join31(runDirectory, "invocation.json"), "utf8");
31240
31724
  const parsed = JSON.parse(raw);
31241
- if (isRecord17(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
31725
+ if (isRecord19(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
31242
31726
  return parsed.sessionFile;
31243
31727
  }
31244
31728
  } catch (error) {
31245
31729
  if (!isMissingPathError5(error)) throw error;
31246
31730
  }
31247
- return join32(runDirectory, "session", "session.jsonl");
31731
+ return join31(runDirectory, "session", "session.jsonl");
31248
31732
  }
31249
31733
  function attributeSessionRowsForRun(input) {
31250
31734
  if (pathContainedIn(input.runDirectory, input.sessionFile)) {
@@ -31416,9 +31900,9 @@ async function classifyScopedRun(input) {
31416
31900
  }
31417
31901
  let gateCycles;
31418
31902
  try {
31419
- const parentSessionFile = join32(input.runDirectory, "session", "session.jsonl");
31903
+ const parentSessionFile = join31(input.runDirectory, "session", "session.jsonl");
31420
31904
  gateCycles = await readAnalystGateCyclesFromAuditorRoles(
31421
- join32(input.runDirectory, "session", "auditor-roles"),
31905
+ join31(input.runDirectory, "session", "auditor-roles"),
31422
31906
  { parentSessionFile }
31423
31907
  );
31424
31908
  } catch (error) {
@@ -31451,7 +31935,7 @@ async function classifyScopedRun(input) {
31451
31935
  async function scanAnalystIssueRuns(input) {
31452
31936
  const ledgerHome = resolveActivationLedgerHome(input.home);
31453
31937
  const scopeTicketNumber = input.ticketNumber;
31454
- const booksRoot = join32(ledgerHome, "books");
31938
+ const booksRoot = join31(ledgerHome, "books");
31455
31939
  let wholeBook = false;
31456
31940
  let scopeRootIdentity;
31457
31941
  let bookNames;
@@ -31483,7 +31967,7 @@ async function scanAnalystIssueRuns(input) {
31483
31967
  const unreadable = [];
31484
31968
  const scopeConflicts = [];
31485
31969
  for (const book of bookNames) {
31486
- const runsDir = join32(booksRoot, book, "runs");
31970
+ const runsDir = join31(booksRoot, book, "runs");
31487
31971
  let runNames;
31488
31972
  try {
31489
31973
  const entries = await readdir7(runsDir, { withFileTypes: true });
@@ -31495,7 +31979,7 @@ async function scanAnalystIssueRuns(input) {
31495
31979
  for (const runName of runNames) {
31496
31980
  const parsed = parseRunDirectoryName2(runName);
31497
31981
  if (parsed === void 0) continue;
31498
- const runDirectory = join32(runsDir, runName);
31982
+ const runDirectory = join31(runsDir, runName);
31499
31983
  let scopeFields;
31500
31984
  try {
31501
31985
  scopeFields = await readInvocationScopeFields(runDirectory);
@@ -31543,7 +32027,7 @@ var init_analyst_ledger = __esm({
31543
32027
  });
31544
32028
 
31545
32029
  // src/analyst-metric-families/acceptance-success-rework.ts
31546
- function isRecord18(value) {
32030
+ function isRecord20(value) {
31547
32031
  return typeof value === "object" && value !== null && !Array.isArray(value);
31548
32032
  }
31549
32033
  function wallMsFromSpan(span) {
@@ -31552,21 +32036,21 @@ function wallMsFromSpan(span) {
31552
32036
  function findCollectorGroups(body) {
31553
32037
  if (Array.isArray(body.groups)) return body.groups;
31554
32038
  const receipt = body.receipt;
31555
- if (isRecord18(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
32039
+ if (isRecord20(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
31556
32040
  const outcome = body.outcome;
31557
- if (isRecord18(outcome)) {
32041
+ if (isRecord20(outcome)) {
31558
32042
  const facts = outcome.decisiveFacts;
31559
- if (isRecord18(facts) && Array.isArray(facts.groups)) return facts.groups;
32043
+ if (isRecord20(facts) && Array.isArray(facts.groups)) return facts.groups;
31560
32044
  }
31561
32045
  return void 0;
31562
32046
  }
31563
32047
  function extractStatus(body) {
31564
32048
  const outcome = body.outcome;
31565
- if (isRecord18(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
32049
+ if (isRecord20(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
31566
32050
  return outcome.status;
31567
32051
  }
31568
32052
  const receipt = body.receipt;
31569
- if (isRecord18(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
32053
+ if (isRecord20(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
31570
32054
  return receipt.status;
31571
32055
  }
31572
32056
  if (typeof body.status === "string" && body.status.trim() !== "") {
@@ -31923,18 +32407,18 @@ function closedTools(intervals) {
31923
32407
  function clipToolsToFrame(tools, frameStartMs, frameEndMs) {
31924
32408
  if (frameEndMs <= frameStartMs) return [];
31925
32409
  const out = [];
31926
- for (const tool2 of tools) {
31927
- const startMs = Math.max(tool2.startMs, frameStartMs);
31928
- const endMs = Math.min(tool2.endMs, frameEndMs);
32410
+ for (const tool of tools) {
32411
+ const startMs = Math.max(tool.startMs, frameStartMs);
32412
+ const endMs = Math.min(tool.endMs, frameEndMs);
31929
32413
  if (endMs <= startMs) continue;
31930
32414
  out.push({
31931
- toolCallId: tool2.toolCallId,
31932
- toolName: tool2.toolName,
32415
+ toolCallId: tool.toolCallId,
32416
+ toolName: tool.toolName,
31933
32417
  startMs,
31934
32418
  endMs,
31935
- startedAt: startMs === tool2.startMs ? tool2.startedAt : toIso(startMs),
31936
- endedAt: endMs === tool2.endMs ? tool2.endedAt : toIso(endMs),
31937
- ...tool2.command !== void 0 ? { command: tool2.command } : {}
32419
+ startedAt: startMs === tool.startMs ? tool.startedAt : toIso(startMs),
32420
+ endedAt: endMs === tool.endMs ? tool.endedAt : toIso(endMs),
32421
+ ...tool.command !== void 0 ? { command: tool.command } : {}
31938
32422
  });
31939
32423
  }
31940
32424
  return out;
@@ -31973,19 +32457,19 @@ function modelMaximalIntervals(frameStartMs, frameEndMs, toolUnion) {
31973
32457
  }
31974
32458
  return gaps;
31975
32459
  }
31976
- function toolAction(tool2) {
32460
+ function toolAction(tool) {
31977
32461
  const action = {
31978
32462
  kind: "tool",
31979
- toolCallId: tool2.toolCallId,
31980
- toolName: tool2.toolName,
31981
- durationMs: tool2.endMs - tool2.startMs,
31982
- startedAt: tool2.startedAt,
31983
- endedAt: tool2.endedAt
32463
+ toolCallId: tool.toolCallId,
32464
+ toolName: tool.toolName,
32465
+ durationMs: tool.endMs - tool.startMs,
32466
+ startedAt: tool.startedAt,
32467
+ endedAt: tool.endedAt
31984
32468
  };
31985
- if (tool2.toolName === "bash" && tool2.command !== void 0) {
32469
+ if (tool.toolName === "bash" && tool.command !== void 0) {
31986
32470
  return {
31987
32471
  ...action,
31988
- commandSummary: tool2.command
32472
+ commandSummary: tool.command
31989
32473
  };
31990
32474
  }
31991
32475
  return action;
@@ -32191,21 +32675,21 @@ var init_leg_wall_clock = __esm({
32191
32675
  });
32192
32676
 
32193
32677
  // src/analyst-metric-families/round-timeline.ts
32194
- function isRecord19(value) {
32678
+ function isRecord21(value) {
32195
32679
  return typeof value === "object" && value !== null && !Array.isArray(value);
32196
32680
  }
32197
32681
  function wallMsFromSpan2(startedAt, endedAt) {
32198
32682
  return Date.parse(endedAt) - Date.parse(startedAt);
32199
32683
  }
32200
32684
  function readOutcomeStatus(body) {
32201
- if (!isRecord19(body.outcome)) return void 0;
32685
+ if (!isRecord21(body.outcome)) return void 0;
32202
32686
  const status = body.outcome.status;
32203
32687
  if (typeof status !== "string" || status.trim() === "") return void 0;
32204
32688
  return status;
32205
32689
  }
32206
32690
  function readClassCount(body) {
32207
- if (!isRecord19(body.outcome)) return void 0;
32208
- if (!isRecord19(body.outcome.decisiveFacts)) return void 0;
32691
+ if (!isRecord21(body.outcome)) return void 0;
32692
+ if (!isRecord21(body.outcome.decisiveFacts)) return void 0;
32209
32693
  const classCount = body.outcome.decisiveFacts.classCount;
32210
32694
  if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
32211
32695
  return void 0;
@@ -32349,7 +32833,7 @@ var init_analyst_metric_family = __esm({
32349
32833
 
32350
32834
  // src/analyst-page.ts
32351
32835
  import { createHash as createHash7 } from "node:crypto";
32352
- import { dirname as dirname14, join as join33 } from "node:path";
32836
+ import { dirname as dirname14, join as join32 } from "node:path";
32353
32837
  function analystIssuePageKey(address) {
32354
32838
  const parts = ["book", address.bookKey];
32355
32839
  if (address.issueNumber !== void 0) {
@@ -32360,7 +32844,7 @@ function analystIssuePageKey(address) {
32360
32844
  return createHash7("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
32361
32845
  }
32362
32846
  function analystIssuePagePath(ledgerHome, address) {
32363
- return join33(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
32847
+ return join32(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
32364
32848
  }
32365
32849
  function analystIssuePageAddressFromPage(page) {
32366
32850
  return {
@@ -32893,7 +33377,7 @@ __export(cli_exports, {
32893
33377
  runAkRole: () => runAkRole
32894
33378
  });
32895
33379
  import { realpath as realpath6 } from "node:fs/promises";
32896
- import { join as join34 } from "node:path";
33380
+ import { join as join33 } from "node:path";
32897
33381
  function takePublicGlobalFlag(argv, index, options) {
32898
33382
  const tokens = argv.slice(index);
32899
33383
  const taken = options.takeDashed(tokens);
@@ -33025,7 +33509,7 @@ function resolveHome(env) {
33025
33509
  return env.home ?? packageMachineHome();
33026
33510
  }
33027
33511
  function resolveAgentDir(env, home) {
33028
- return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join34(home, ".pi", "agent");
33512
+ return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join33(home, ".pi", "agent");
33029
33513
  }
33030
33514
  function parseThinking(value) {
33031
33515
  return value;
@@ -33845,7 +34329,7 @@ async function runAkRole(argv, env) {
33845
34329
  ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
33846
34330
  };
33847
34331
  }
33848
- if (parsed.command === "gatekeeper" || parsed.command === "navigator") {
34332
+ if (parsed.command === "gatekeeper" || parsed.command === "navigator" || parsed.command === "auditor" || parsed.command === "evidence-child") {
33849
34333
  const agentDir = resolveAgentDir(env, home);
33850
34334
  const cwd = env.cwd ?? process.cwd();
33851
34335
  const config = await loadAndValidateConfig(home, env.packageRoot);
@@ -33861,7 +34345,7 @@ async function runAkRole(argv, env) {
33861
34345
  createRoleEnvironment(env, { role: parsed.command, home, agentDir, cwd, credentials, seat, config }),
33862
34346
  io,
33863
34347
  parsed.command,
33864
- parsed.command === "gatekeeper" ? PUBLIC_ROLE_ARGV.gatekeeper.parse : PUBLIC_ROLE_ARGV.navigator.parse
34348
+ PUBLIC_ROLE_ARGV[parsed.command].parse
33865
34349
  );
33866
34350
  return {
33867
34351
  exitCode: result2.exitCode,
@@ -33946,6 +34430,8 @@ var init_cli = __esm({
33946
34430
  inspector: { seat: "inspector", run: runPublicInspectorResume },
33947
34431
  gatekeeper: { seat: "gatekeeper", run: runPublicInstructionSeatResume },
33948
34432
  navigator: { seat: "navigator", run: runPublicInstructionSeatResume },
34433
+ auditor: { seat: "auditor", run: runPublicInstructionSeatResume },
34434
+ "evidence-child": { seat: "evidence-child", run: runPublicInstructionSeatResume },
33949
34435
  diarist: { seat: "diarist", run: runPublicDiaristResume }
33950
34436
  };
33951
34437
  PUBLIC_ROLE_ARGV = {
@@ -33962,6 +34448,8 @@ var init_cli = __esm({
33962
34448
  reviewer: { parse: parseReviewerArgv, options: optionsForOwner("reviewer") },
33963
34449
  gatekeeper: { parse: parseGatekeeperArgv, options: optionsForOwner("gatekeeper") },
33964
34450
  navigator: { parse: parseNavigatorArgv, options: optionsForOwner("navigator") },
34451
+ auditor: { parse: parseAuditorArgv, options: optionsForOwner("auditor") },
34452
+ "evidence-child": { parse: parseEvidenceChildArgv, options: optionsForOwner("evidence-child") },
33965
34453
  diarist: { parse: parseDiaristArgv, options: optionsForOwner("diarist") },
33966
34454
  /** Deterministic analysis seat (#336) — argv parse only; no LLM admission. */
33967
34455
  analyst: { parse: parseAnalystArgv, options: optionsForOwner("analyst") }
@@ -33979,7 +34467,7 @@ var init_cli = __esm({
33979
34467
 
33980
34468
  // src/public-cli/main.ts
33981
34469
  import { existsSync as existsSync11 } from "node:fs";
33982
- import { dirname as dirname15, join as join35 } from "node:path";
34470
+ import { dirname as dirname15, join as join34 } from "node:path";
33983
34471
  import { fileURLToPath as fileURLToPath3 } from "node:url";
33984
34472
 
33985
34473
  // src/public-cli/host-pi-runtime.ts
@@ -34068,8 +34556,8 @@ function linkPackage(packageRoot2, name, targetDir) {
34068
34556
  // src/public-cli/main.ts
34069
34557
  var here = dirname15(fileURLToPath3(import.meta.url));
34070
34558
  function resolvePackageRoot(binDir) {
34071
- const canonical = join35(binDir, "..", "..");
34072
- if (existsSync11(join35(canonical, "package.json"))) {
34559
+ const canonical = join34(binDir, "..", "..");
34560
+ if (existsSync11(join34(canonical, "package.json"))) {
34073
34561
  return canonical;
34074
34562
  }
34075
34563
  return binDir;