@akagilnc/pi-workflow-roles 0.1.1883 → 0.1.1918

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.
@@ -14873,6 +14873,69 @@ var init_sitian_role_run_coordinates = __esm({
14873
14873
  }
14874
14874
  });
14875
14875
 
14876
+ // src/ticket-frontmatter.ts
14877
+ function parseTicketNumberFrontmatter(bytes) {
14878
+ let text;
14879
+ if (typeof bytes === "string") {
14880
+ text = bytes;
14881
+ } else {
14882
+ try {
14883
+ text = exactUtf8(bytes, "ticket face");
14884
+ } catch {
14885
+ return void 0;
14886
+ }
14887
+ }
14888
+ let cursor;
14889
+ if (text.startsWith("---\n")) {
14890
+ cursor = 4;
14891
+ } else if (text.startsWith("---\r\n")) {
14892
+ cursor = 5;
14893
+ } else {
14894
+ return void 0;
14895
+ }
14896
+ const fmLines = [];
14897
+ let closed = false;
14898
+ while (cursor < text.length) {
14899
+ const nl = text.indexOf("\n", cursor);
14900
+ const lineEnd = nl === -1 ? text.length : nl;
14901
+ let line2 = text.slice(cursor, lineEnd);
14902
+ if (line2.endsWith("\r")) line2 = line2.slice(0, -1);
14903
+ if (line2 === "---") {
14904
+ closed = true;
14905
+ break;
14906
+ }
14907
+ fmLines.push(line2);
14908
+ if (nl === -1) break;
14909
+ cursor = nl + 1;
14910
+ }
14911
+ if (!closed) return void 0;
14912
+ let found;
14913
+ for (const line2 of fmLines) {
14914
+ const match = /^[ \t]*ticketNumber[ \t]*:[ \t]*(\d+)[ \t]*$/.exec(line2);
14915
+ if (match === null) continue;
14916
+ const value = Number(match[1]);
14917
+ if (!Number.isInteger(value) || value < 1) return void 0;
14918
+ if (found !== void 0 && found !== value) return void 0;
14919
+ found = value;
14920
+ }
14921
+ return found;
14922
+ }
14923
+ function resolveTicketNumberFromAttachmentBodies(bodies) {
14924
+ const found = /* @__PURE__ */ new Set();
14925
+ for (const body of bodies) {
14926
+ const value = parseTicketNumberFrontmatter(body);
14927
+ if (value !== void 0) found.add(value);
14928
+ }
14929
+ if (found.size !== 1) return void 0;
14930
+ return found.values().next().value;
14931
+ }
14932
+ var init_ticket_frontmatter = __esm({
14933
+ "src/ticket-frontmatter.ts"() {
14934
+ "use strict";
14935
+ init_exact_utf8();
14936
+ }
14937
+ });
14938
+
14876
14939
  // src/audit-escalation.ts
14877
14940
  function isAuditEscalationResult(value) {
14878
14941
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
@@ -15338,7 +15401,9 @@ async function writeRoleInvocationLedger(source, role) {
15338
15401
  projectRoot: source.projectRoot,
15339
15402
  runDirectory: source.runDirectory,
15340
15403
  sessionDirectory: source.sessionDirectory,
15341
- sessionFile: source.sessionFile
15404
+ sessionFile: source.sessionFile,
15405
+ ...source.correlationId === void 0 ? {} : { correlationId: source.correlationId },
15406
+ ...source.ticketNumber === void 0 ? {} : { ticketNumber: source.ticketNumber }
15342
15407
  };
15343
15408
  await writeFile2(
15344
15409
  join5(source.runDirectory, "invocation.json"),
@@ -15568,13 +15633,37 @@ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
15568
15633
  const frozenPath = join5(destinationDir, name);
15569
15634
  await writeFile2(frozenPath, bytes);
15570
15635
  return {
15571
- provenancePath: absolute,
15572
- frozenPath,
15573
- byteLength: bytes.byteLength,
15574
- sha256: sha256Hex(bytes),
15575
- mediaKind: "regular-file"
15636
+ attachment: {
15637
+ provenancePath: absolute,
15638
+ frozenPath,
15639
+ byteLength: bytes.byteLength,
15640
+ sha256: sha256Hex(bytes),
15641
+ mediaKind: "regular-file"
15642
+ },
15643
+ body: bytes
15576
15644
  };
15577
15645
  }
15646
+ async function freezeAttachmentsWithTicketNumber(attachmentPaths, attachmentsDirectory) {
15647
+ const attachments = [];
15648
+ const bodies = [];
15649
+ for (let i = 0; i < attachmentPaths.length; i += 1) {
15650
+ const frozen = await freezeRegularFileAttachment(
15651
+ attachmentPaths[i],
15652
+ attachmentsDirectory,
15653
+ i
15654
+ );
15655
+ attachments.push(frozen.attachment);
15656
+ bodies.push(frozen.body);
15657
+ }
15658
+ const ticketNumber = resolveTicketNumberFromAttachmentBodies(bodies);
15659
+ return {
15660
+ attachments,
15661
+ ...ticketNumber === void 0 ? {} : { ticketNumber }
15662
+ };
15663
+ }
15664
+ function ticketAdmissionFields(ticketNumber) {
15665
+ return ticketNumber === void 0 ? {} : { ticketNumber };
15666
+ }
15578
15667
  async function admitJudgeInvocation(options) {
15579
15668
  if (options.project !== void 0) {
15580
15669
  requireOptionPath("--project", options.project);
@@ -15585,16 +15674,11 @@ async function admitJudgeInvocation(options) {
15585
15674
  const attachmentsDirectory = join5(runDirectory, "attachments");
15586
15675
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
15587
15676
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
15588
- const attachments = [];
15589
- for (let i = 0; i < options.attachmentPaths.length; i += 1) {
15590
- attachments.push(
15591
- await freezeRegularFileAttachment(
15592
- options.attachmentPaths[i],
15593
- attachmentsDirectory,
15594
- i
15595
- )
15596
- );
15597
- }
15677
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
15678
+ options.attachmentPaths,
15679
+ attachmentsDirectory
15680
+ );
15681
+ const ticketFields = ticketAdmissionFields(ticketNumber);
15598
15682
  const instruction = options.instruction;
15599
15683
  const instructionEmpty = instruction.trim() === "";
15600
15684
  const admitted = {
@@ -15605,6 +15689,7 @@ async function admitJudgeInvocation(options) {
15605
15689
  runDirectory,
15606
15690
  sessionDirectory,
15607
15691
  sessionFile,
15692
+ ...ticketFields,
15608
15693
  instruction,
15609
15694
  instructionEmpty,
15610
15695
  attachments: attachments.map((a) => ({
@@ -15630,7 +15715,8 @@ async function admitJudgeInvocation(options) {
15630
15715
  runDirectory,
15631
15716
  sessionDirectory,
15632
15717
  sessionFile,
15633
- admittedRequestPath
15718
+ admittedRequestPath,
15719
+ ...ticketFields
15634
15720
  };
15635
15721
  }
15636
15722
  function buildJudgeTransportPrompt(admitted) {
@@ -15668,16 +15754,11 @@ async function admitCoderInvocation(options) {
15668
15754
  const attachmentsDirectory = join5(runDirectory, "attachments");
15669
15755
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
15670
15756
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
15671
- const attachments = [];
15672
- for (let i = 0; i < options.attachmentPaths.length; i += 1) {
15673
- attachments.push(
15674
- await freezeRegularFileAttachment(
15675
- options.attachmentPaths[i],
15676
- attachmentsDirectory,
15677
- i
15678
- )
15679
- );
15680
- }
15757
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
15758
+ options.attachmentPaths,
15759
+ attachmentsDirectory
15760
+ );
15761
+ const ticketFields = ticketAdmissionFields(ticketNumber);
15681
15762
  const taskPath = join5(runDirectory, "task.md");
15682
15763
  await writeFile2(taskPath, instruction, "utf8");
15683
15764
  const admitted = {
@@ -15689,6 +15770,7 @@ async function admitCoderInvocation(options) {
15689
15770
  runDirectory,
15690
15771
  sessionDirectory,
15691
15772
  sessionFile,
15773
+ ...ticketFields,
15692
15774
  instruction,
15693
15775
  instructionEmpty: false,
15694
15776
  taskPath,
@@ -15717,7 +15799,8 @@ async function admitCoderInvocation(options) {
15717
15799
  sessionDirectory,
15718
15800
  sessionFile,
15719
15801
  admittedRequestPath,
15720
- taskPath
15802
+ taskPath,
15803
+ ...ticketFields
15721
15804
  };
15722
15805
  }
15723
15806
  function buildCoderTransportPrompt(admitted) {
@@ -15744,29 +15827,12 @@ async function admitFixerInvocation(options) {
15744
15827
  if (options.phase !== "plan" && options.phase !== "apply") {
15745
15828
  throw new CliUsageError("fixer phase must be plan or apply");
15746
15829
  }
15747
- const projectRoot = resolve4(options.project ?? options.cwd);
15748
- const runId = (options.createRunId ?? uuidv7)();
15749
- const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "fixer", home: options.home });
15750
- const attachmentsDirectory = join5(runDirectory, "attachments");
15751
- ensureRealDirectoryTree(ledgerHome, sessionDirectory);
15752
- ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
15753
- const attachments = [];
15754
- for (let i = 0; i < options.attachmentPaths.length; i += 1) {
15755
- attachments.push(
15756
- await freezeRegularFileAttachment(
15757
- options.attachmentPaths[i],
15758
- attachmentsDirectory,
15759
- i
15760
- )
15761
- );
15762
- }
15763
15830
  let prerequisites = Object.freeze([]);
15764
- let prerequisitesPath;
15831
+ let prerequisitesSource;
15765
15832
  if (options.prerequisitesPath !== void 0) {
15766
15833
  const absolutePrereq = isAbsolute3(options.prerequisitesPath) ? options.prerequisitesPath : resolve4(options.prerequisitesPath);
15767
- let source;
15768
15834
  try {
15769
- source = await readFile4(absolutePrereq, "utf8");
15835
+ prerequisitesSource = await readFile4(absolutePrereq, "utf8");
15770
15836
  } catch (error) {
15771
15837
  throw new CliUsageError(
15772
15838
  `fixer prerequisites path is unreadable: ${options.prerequisitesPath}`,
@@ -15774,13 +15840,27 @@ async function admitFixerInvocation(options) {
15774
15840
  );
15775
15841
  }
15776
15842
  try {
15777
- prerequisites = parseFixerPrerequisites(source);
15843
+ prerequisites = parseFixerPrerequisites(prerequisitesSource);
15778
15844
  } catch (error) {
15779
15845
  if (error instanceof FixerPacketValidationError) {
15780
15846
  throw new CliUsageError(error.message, { cause: error });
15781
15847
  }
15782
15848
  throw error;
15783
15849
  }
15850
+ }
15851
+ const projectRoot = resolve4(options.project ?? options.cwd);
15852
+ const runId = (options.createRunId ?? uuidv7)();
15853
+ const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "fixer", home: options.home });
15854
+ const attachmentsDirectory = join5(runDirectory, "attachments");
15855
+ ensureRealDirectoryTree(ledgerHome, sessionDirectory);
15856
+ ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
15857
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
15858
+ options.attachmentPaths,
15859
+ attachmentsDirectory
15860
+ );
15861
+ const ticketFields = ticketAdmissionFields(ticketNumber);
15862
+ let prerequisitesPath;
15863
+ if (prerequisitesSource !== void 0) {
15784
15864
  prerequisitesPath = join5(runDirectory, "prerequisites.json");
15785
15865
  await writeFile2(
15786
15866
  prerequisitesPath,
@@ -15800,6 +15880,7 @@ async function admitFixerInvocation(options) {
15800
15880
  runDirectory,
15801
15881
  sessionDirectory,
15802
15882
  sessionFile,
15883
+ ...ticketFields,
15803
15884
  instruction,
15804
15885
  instructionEmpty: false,
15805
15886
  packetPath,
@@ -15835,7 +15916,8 @@ async function admitFixerInvocation(options) {
15835
15916
  admittedRequestPath,
15836
15917
  packetPath,
15837
15918
  ...prerequisitesPath === void 0 ? {} : { prerequisitesPath },
15838
- prerequisites
15919
+ prerequisites,
15920
+ ...ticketFields
15839
15921
  };
15840
15922
  }
15841
15923
  function buildFixerTransportPrompt(admitted) {
@@ -16003,34 +16085,32 @@ async function admitCollectorInvocation(options) {
16003
16085
  } else {
16004
16086
  repository = resolveGitHubRemoteRepository(projectRoot);
16005
16087
  }
16006
- const runId = (options.createRunId ?? uuidv7)();
16007
- const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "collector", home: options.home });
16008
- const attachmentsDirectory = join5(runDirectory, "attachments");
16009
- ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16010
- ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16011
- const attachments = [];
16012
- const attachmentPaths = options.attachmentPaths ?? [];
16013
- for (let i = 0; i < attachmentPaths.length; i += 1) {
16014
- attachments.push(
16015
- await freezeRegularFileAttachment(
16016
- attachmentPaths[i],
16017
- attachmentsDirectory,
16018
- i
16019
- )
16020
- );
16021
- }
16022
16088
  let manifest = emptyCollectorManifest();
16023
- let requestManifestPath;
16089
+ let manifestCanonicalJson;
16024
16090
  if (options.requestManifestPath !== void 0) {
16025
16091
  try {
16026
16092
  manifest = await loadCollectorManifest(options.requestManifestPath);
16093
+ manifestCanonicalJson = manifest.canonicalJson;
16027
16094
  } catch (error) {
16028
16095
  throw new CliUsageError(error instanceof Error ? error.message : String(error), { cause: error });
16029
16096
  }
16030
- requestManifestPath = join5(runDirectory, "request-manifest.json");
16031
- await writeFile2(requestManifestPath, manifest.canonicalJson, "utf8");
16032
16097
  }
16033
16098
  const manifestDigest = manifest.digest;
16099
+ const runId = (options.createRunId ?? uuidv7)();
16100
+ const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "collector", home: options.home });
16101
+ const attachmentsDirectory = join5(runDirectory, "attachments");
16102
+ ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16103
+ ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16104
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
16105
+ options.attachmentPaths ?? [],
16106
+ attachmentsDirectory
16107
+ );
16108
+ const ticketFields = ticketAdmissionFields(ticketNumber);
16109
+ let requestManifestPath;
16110
+ if (manifestCanonicalJson !== void 0) {
16111
+ requestManifestPath = join5(runDirectory, "request-manifest.json");
16112
+ await writeFile2(requestManifestPath, manifestCanonicalJson, "utf8");
16113
+ }
16034
16114
  const instruction = options.instruction ?? "";
16035
16115
  const instructionEmpty = instruction.trim() === "";
16036
16116
  const admitted = {
@@ -16041,6 +16121,7 @@ async function admitCollectorInvocation(options) {
16041
16121
  runDirectory,
16042
16122
  sessionDirectory,
16043
16123
  sessionFile,
16124
+ ...ticketFields,
16044
16125
  instruction,
16045
16126
  instructionEmpty,
16046
16127
  prNumber,
@@ -16079,7 +16160,8 @@ async function admitCollectorInvocation(options) {
16079
16160
  prNumber,
16080
16161
  repository,
16081
16162
  ...requestManifestPath === void 0 ? {} : { requestManifestPath },
16082
- manifestDigest
16163
+ manifestDigest,
16164
+ ...ticketFields
16083
16165
  };
16084
16166
  }
16085
16167
  function buildCollectorTransportPrompt(_admitted) {
@@ -16276,17 +16358,11 @@ async function admitDoctorInvocation(options) {
16276
16358
  const attachmentsDirectory = join5(runDirectory, "attachments");
16277
16359
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16278
16360
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16279
- const attachments = [];
16280
- const attachmentPaths = options.attachmentPaths ?? [];
16281
- for (let i = 0; i < attachmentPaths.length; i += 1) {
16282
- attachments.push(
16283
- await freezeRegularFileAttachment(
16284
- attachmentPaths[i],
16285
- attachmentsDirectory,
16286
- i
16287
- )
16288
- );
16289
- }
16361
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
16362
+ options.attachmentPaths ?? [],
16363
+ attachmentsDirectory
16364
+ );
16365
+ const ticketFields = ticketAdmissionFields(ticketNumber);
16290
16366
  const instruction = options.instruction ?? "";
16291
16367
  const instructionEmpty = instruction.trim() === "";
16292
16368
  const admitted = {
@@ -16297,6 +16373,7 @@ async function admitDoctorInvocation(options) {
16297
16373
  runDirectory,
16298
16374
  sessionDirectory,
16299
16375
  sessionFile,
16376
+ ...ticketFields,
16300
16377
  instruction,
16301
16378
  instructionEmpty,
16302
16379
  issueNumber: options.issueNumber,
@@ -16332,7 +16409,8 @@ async function admitDoctorInvocation(options) {
16332
16409
  admittedRequestPath,
16333
16410
  issueNumber: options.issueNumber,
16334
16411
  caseRunsPath,
16335
- caseIdentity: caseIdentity2
16412
+ caseIdentity: caseIdentity2,
16413
+ ...ticketFields
16336
16414
  };
16337
16415
  }
16338
16416
  function buildDoctorTransportPrompt(admitted) {
@@ -16402,16 +16480,11 @@ async function admitReviewerInvocation(options) {
16402
16480
  const attachmentsDirectory = join5(runDirectory, "attachments");
16403
16481
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16404
16482
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16405
- const attachments = [];
16406
- for (let i = 0; i < options.attachmentPaths.length; i += 1) {
16407
- attachments.push(
16408
- await freezeRegularFileAttachment(
16409
- options.attachmentPaths[i],
16410
- attachmentsDirectory,
16411
- i
16412
- )
16413
- );
16414
- }
16483
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
16484
+ options.attachmentPaths,
16485
+ attachmentsDirectory
16486
+ );
16487
+ const ticketFields = ticketAdmissionFields(ticketNumber);
16415
16488
  const instruction = options.instruction;
16416
16489
  const instructionEmpty = instruction.trim() === "";
16417
16490
  const admitted = {
@@ -16422,6 +16495,7 @@ async function admitReviewerInvocation(options) {
16422
16495
  runDirectory,
16423
16496
  sessionDirectory,
16424
16497
  sessionFile,
16498
+ ...ticketFields,
16425
16499
  instruction,
16426
16500
  instructionEmpty,
16427
16501
  baseRevision: options.baseRevision,
@@ -16453,7 +16527,8 @@ async function admitReviewerInvocation(options) {
16453
16527
  sessionDirectory,
16454
16528
  sessionFile,
16455
16529
  admittedRequestPath,
16456
- baseRevision: options.baseRevision
16530
+ baseRevision: options.baseRevision,
16531
+ ...ticketFields
16457
16532
  };
16458
16533
  }
16459
16534
  function buildReviewerTransportPrompt(admitted) {
@@ -16555,16 +16630,11 @@ async function admitMergerInvocation(options) {
16555
16630
  const attachmentsDirectory = join5(runDirectory, "attachments");
16556
16631
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16557
16632
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16558
- const attachments = [];
16559
- for (let i = 0; i < options.attachmentPaths.length; i += 1) {
16560
- attachments.push(
16561
- await freezeRegularFileAttachment(
16562
- options.attachmentPaths[i],
16563
- attachmentsDirectory,
16564
- i
16565
- )
16566
- );
16567
- }
16633
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
16634
+ options.attachmentPaths,
16635
+ attachmentsDirectory
16636
+ );
16637
+ const ticketFields = ticketAdmissionFields(ticketNumber);
16568
16638
  const targetIntent = mergerMaterialFromUtf8(
16569
16639
  `Investigate primary sources for target parent ${derived.targetObjectId}. Do not invent intent.`
16570
16640
  );
@@ -16604,6 +16674,7 @@ async function admitMergerInvocation(options) {
16604
16674
  runDirectory,
16605
16675
  sessionDirectory,
16606
16676
  sessionFile,
16677
+ ...ticketFields,
16607
16678
  instruction,
16608
16679
  instructionEmpty: false,
16609
16680
  mergerInputPath,
@@ -16643,7 +16714,8 @@ async function admitMergerInvocation(options) {
16643
16714
  sessionFile,
16644
16715
  admittedRequestPath,
16645
16716
  mergerInputPath,
16646
- derived: admitted.derived
16717
+ derived: admitted.derived,
16718
+ ...ticketFields
16647
16719
  };
16648
16720
  }
16649
16721
  function buildMergerTransportPrompt(admitted) {
@@ -16666,6 +16738,7 @@ var init_invocation = __esm({
16666
16738
  init_activation_ledger_topology();
16667
16739
  init_activation_ledger_git();
16668
16740
  init_sitian_role_run_coordinates();
16741
+ init_ticket_frontmatter();
16669
16742
  init_doctor_evidence();
16670
16743
  init_collector_config();
16671
16744
  init_fixer_packet();
@@ -16779,6 +16852,27 @@ var init_reviewer_dispatch = __esm({
16779
16852
  }
16780
16853
  });
16781
16854
 
16855
+ // src/upstream-error-testimony.ts
16856
+ function isNonSuccessHttpStatus(status) {
16857
+ return typeof status === "number" && (status < 200 || status >= 300);
16858
+ }
16859
+ function hasUpstreamErrorTestimony(input) {
16860
+ if (isNonSuccessHttpStatus(input.httpStatus)) return true;
16861
+ return Array.isArray(input.diagnostics) && input.diagnostics.length > 0;
16862
+ }
16863
+ function projectConfirmedRemotePayload(input) {
16864
+ return {
16865
+ ...input.body === void 0 ? {} : { body: input.body },
16866
+ ...input.code === void 0 ? {} : { code: input.code },
16867
+ ...input.errno === void 0 ? {} : { errno: input.errno }
16868
+ };
16869
+ }
16870
+ var init_upstream_error_testimony = __esm({
16871
+ "src/upstream-error-testimony.ts"() {
16872
+ "use strict";
16873
+ }
16874
+ });
16875
+
16782
16876
  // src/public-cli/explicit-internal.ts
16783
16877
  import { execFile as execFile3, spawn } from "node:child_process";
16784
16878
  import { constants, writeFileSync } from "node:fs";
@@ -16837,21 +16931,37 @@ function resolveInternalRoleEntrypoint(packageRoot2) {
16837
16931
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
16838
16932
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
16839
16933
  }
16934
+ function nonEmptyString(value) {
16935
+ return typeof value === "string" && value.trim() !== "" ? value : void 0;
16936
+ }
16937
+ function sessionStopDetails(input) {
16938
+ const details = {};
16939
+ const errorMessage = nonEmptyString(input.errorMessage);
16940
+ if (errorMessage !== void 0) details.errorMessage = errorMessage;
16941
+ const api = nonEmptyString(input.api);
16942
+ if (api !== void 0) details.api = api;
16943
+ const rawStopReason = nonEmptyString(input.rawStopReason);
16944
+ if (rawStopReason !== void 0) details.rawStopReason = rawStopReason;
16945
+ const testimony = hasUpstreamErrorTestimony(input);
16946
+ if (testimony) {
16947
+ const provider = nonEmptyString(input.provider);
16948
+ if (provider !== void 0) details.provider = provider;
16949
+ const model = nonEmptyString(input.model);
16950
+ if (model !== void 0) details.model = model;
16951
+ }
16952
+ if (typeof input.httpStatus === "number") details.httpStatus = input.httpStatus;
16953
+ if (input.diagnostics !== void 0) details.diagnostics = input.diagnostics;
16954
+ if (testimony) Object.assign(details, projectConfirmedRemotePayload(input));
16955
+ return details;
16956
+ }
16840
16957
  function knownFailureFromProviderStop(input) {
16841
- if (input.stopReason !== "error") return void 0;
16842
- const diagnostic = typeof input.errorMessage === "string" && input.errorMessage.trim() !== "" ? input.errorMessage.trim() : "provider failure";
16843
- const identity = {
16844
- name: "ProviderStopError"
16845
- };
16846
- if (typeof input.provider === "string" && input.provider.trim() !== "") {
16847
- identity.code = input.provider;
16848
- } else if (typeof input.model === "string" && input.model.trim() !== "") {
16849
- identity.code = input.model;
16850
- }
16958
+ if (input.stopReason !== "error" && input.stopReason !== "aborted") return void 0;
16959
+ const diagnostic = nonEmptyString(input.errorMessage);
16960
+ const details = sessionStopDetails(input);
16851
16961
  return {
16852
- cause: "provider",
16853
- identity,
16854
- diagnostic
16962
+ cause: hasUpstreamErrorTestimony(input) ? "provider" : "unrecognized",
16963
+ ...diagnostic === void 0 ? {} : { diagnostic },
16964
+ ...Object.keys(details).length === 0 ? {} : { details }
16855
16965
  };
16856
16966
  }
16857
16967
  async function resolveSelectedPi(command, cwd, env) {
@@ -16915,6 +17025,8 @@ var init_explicit_internal = __esm({
16915
17025
  init_invocation();
16916
17026
  init_registry2();
16917
17027
  init_reviewer_dispatch();
17028
+ init_upstream_error_testimony();
17029
+ init_upstream_error_testimony();
16918
17030
  REVIEWER_DISPATCH_REJECTION_FILE = "typed-known-failure.json";
16919
17031
  execFileAsync3 = promisify3(execFile3);
16920
17032
  defaultExplicitInternalPiRunner = async (args, options) => {
@@ -17237,12 +17349,9 @@ var init_public_run_credentials = __esm({
17237
17349
  }
17238
17350
  });
17239
17351
 
17240
- // src/public-cli/run-lifecycle.ts
17241
- import { lstat as lstat2, open, readdir as readdir2, readFile as readFile7, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
17352
+ // src/typed-provider-http.ts
17353
+ import { readFile as readFile7, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
17242
17354
  import { join as join8 } from "node:path";
17243
- function isV1ResumableProvider(provider) {
17244
- return V1_RESUMABLE_PROVIDERS.includes(provider);
17245
- }
17246
17355
  function typedProviderHttpPath(runDirectory) {
17247
17356
  return join8(runDirectory, TYPED_HTTP_FILE);
17248
17357
  }
@@ -17256,22 +17365,49 @@ async function clearTypedProviderHttpObservation(runDirectory) {
17256
17365
  throw error;
17257
17366
  }
17258
17367
  }
17259
- async function readTypedHttp429Observation(runDirectory) {
17368
+ async function readLatestTypedProviderHttpObservation(runDirectory) {
17369
+ let text;
17260
17370
  try {
17261
- const raw = JSON.parse(
17262
- await readFile7(typedProviderHttpPath(runDirectory), "utf8")
17263
- );
17264
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
17371
+ text = await readFile7(typedProviderHttpPath(runDirectory), "utf8");
17372
+ } catch (error) {
17373
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") {
17265
17374
  return void 0;
17266
17375
  }
17267
- const record4 = raw;
17268
- if (record4.httpStatus !== 429) return void 0;
17269
- if (typeof record4.provider !== "string") return void 0;
17270
- if (!isV1ResumableProvider(record4.provider)) return void 0;
17271
- return { httpStatus: 429, provider: record4.provider };
17272
- } catch {
17273
- return void 0;
17376
+ throw error;
17377
+ }
17378
+ const raw = JSON.parse(text);
17379
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
17380
+ throw new Error("typed provider HTTP observation must be a JSON object");
17381
+ }
17382
+ const record4 = raw;
17383
+ if (typeof record4.httpStatus !== "number") {
17384
+ throw new Error("typed provider HTTP observation missing numeric httpStatus");
17385
+ }
17386
+ if (typeof record4.provider !== "string" || record4.provider.trim() === "") {
17387
+ throw new Error("typed provider HTTP observation missing non-empty provider");
17388
+ }
17389
+ return { httpStatus: record4.httpStatus, provider: record4.provider };
17390
+ }
17391
+ var TYPED_HTTP_FILE;
17392
+ var init_typed_provider_http = __esm({
17393
+ "src/typed-provider-http.ts"() {
17394
+ "use strict";
17395
+ TYPED_HTTP_FILE = "typed-provider-http.json";
17274
17396
  }
17397
+ });
17398
+
17399
+ // src/public-cli/run-lifecycle.ts
17400
+ import { lstat as lstat2, open, readdir as readdir2, readFile as readFile8, unlink as unlink3, writeFile as writeFile4 } from "node:fs/promises";
17401
+ import { join as join9 } from "node:path";
17402
+ function isV1ResumableProvider(provider) {
17403
+ return V1_RESUMABLE_PROVIDERS.includes(provider);
17404
+ }
17405
+ async function readTypedHttp429Observation(runDirectory) {
17406
+ const observation = await readLatestTypedProviderHttpObservation(runDirectory);
17407
+ if (observation === void 0) return void 0;
17408
+ if (observation.httpStatus !== 429) return void 0;
17409
+ if (!isV1ResumableProvider(observation.provider)) return void 0;
17410
+ return { httpStatus: 429, provider: observation.provider };
17275
17411
  }
17276
17412
  function isV1ResumableFailure(input) {
17277
17413
  if (input.hasLawfulTerminalResult) return false;
@@ -17282,8 +17418,8 @@ function renderResumeCommand(runId) {
17282
17418
  }
17283
17419
  async function writeRoleRunState(runDirectory, record4) {
17284
17420
  const payload = { ...record4, runDirectory };
17285
- await writeFile3(
17286
- join8(runDirectory, RUN_STATE_FILE),
17421
+ await writeFile4(
17422
+ join9(runDirectory, RUN_STATE_FILE),
17287
17423
  `${JSON.stringify(payload, null, 2)}
17288
17424
  `,
17289
17425
  "utf8"
@@ -17292,7 +17428,7 @@ async function writeRoleRunState(runDirectory, record4) {
17292
17428
  async function readRoleRunState(runDirectory) {
17293
17429
  let raw;
17294
17430
  try {
17295
- raw = JSON.parse(await readFile7(join8(runDirectory, RUN_STATE_FILE), "utf8"));
17431
+ raw = JSON.parse(await readFile8(join9(runDirectory, RUN_STATE_FILE), "utf8"));
17296
17432
  } catch {
17297
17433
  return void 0;
17298
17434
  }
@@ -17314,7 +17450,7 @@ async function readRoleRunState(runDirectory) {
17314
17450
  if (typeof record4.sessionDirectory !== "string") return void 0;
17315
17451
  if (typeof record4.admittedRequestPath !== "string") return void 0;
17316
17452
  const runDir = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : runDirectory;
17317
- const sessionFile = typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : join8(record4.sessionDirectory, "session.jsonl");
17453
+ const sessionFile = typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : join9(record4.sessionDirectory, "session.jsonl");
17318
17454
  let resumable;
17319
17455
  if (record4.resumable !== void 0 && record4.resumable !== null) {
17320
17456
  if (typeof record4.resumable === "object" && !Array.isArray(record4.resumable)) {
@@ -17407,7 +17543,7 @@ async function isSessionPrincipalAvailable(sessionFile) {
17407
17543
  }
17408
17544
  }
17409
17545
  async function acquireRunWriterLease(runDirectory) {
17410
- const lockPath = join8(runDirectory, WRITER_LOCK_FILE);
17546
+ const lockPath = join9(runDirectory, WRITER_LOCK_FILE);
17411
17547
  try {
17412
17548
  const handle = await open(lockPath, "wx");
17413
17549
  try {
@@ -17415,7 +17551,7 @@ async function acquireRunWriterLease(runDirectory) {
17415
17551
  `, "utf8");
17416
17552
  } catch (error) {
17417
17553
  await handle.close().catch(() => void 0);
17418
- await unlink2(lockPath).catch(() => void 0);
17554
+ await unlink3(lockPath).catch(() => void 0);
17419
17555
  throw error;
17420
17556
  }
17421
17557
  let released = false;
@@ -17425,7 +17561,7 @@ async function acquireRunWriterLease(runDirectory) {
17425
17561
  if (released) return;
17426
17562
  released = true;
17427
17563
  await handle.close().catch(() => void 0);
17428
- await unlink2(lockPath).catch(() => void 0);
17564
+ await unlink3(lockPath).catch(() => void 0);
17429
17565
  }
17430
17566
  };
17431
17567
  } catch (error) {
@@ -17438,7 +17574,7 @@ async function acquireRunWriterLease(runDirectory) {
17438
17574
  async function findRunDirectoryById(home, runId) {
17439
17575
  if (runId.trim() === "") return void 0;
17440
17576
  const ledgerHome = resolveActivationLedgerHome(() => home);
17441
- const booksRoot = join8(ledgerHome, "books");
17577
+ const booksRoot = join9(ledgerHome, "books");
17442
17578
  let bookKeys;
17443
17579
  try {
17444
17580
  bookKeys = await readdir2(booksRoot);
@@ -17446,7 +17582,7 @@ async function findRunDirectoryById(home, runId) {
17446
17582
  return void 0;
17447
17583
  }
17448
17584
  for (const bookKey of bookKeys) {
17449
- const runsDir = join8(activationBookDirectory(ledgerHome, bookKey), "runs");
17585
+ const runsDir = join9(activationBookDirectory(ledgerHome, bookKey), "runs");
17450
17586
  let entries;
17451
17587
  try {
17452
17588
  entries = await readdir2(runsDir);
@@ -17455,12 +17591,26 @@ async function findRunDirectoryById(home, runId) {
17455
17591
  }
17456
17592
  for (const entry of entries) {
17457
17593
  if (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) {
17458
- return join8(runsDir, entry);
17594
+ return join9(runsDir, entry);
17459
17595
  }
17460
17596
  }
17461
17597
  }
17462
17598
  return void 0;
17463
17599
  }
17600
+ function parsePersistedTicketIdentity(record4) {
17601
+ const correlationId = typeof record4.correlationId === "string" && record4.correlationId.trim() !== "" ? record4.correlationId : void 0;
17602
+ const ticketNumber = typeof record4.ticketNumber === "number" && Number.isInteger(record4.ticketNumber) && record4.ticketNumber >= 1 ? record4.ticketNumber : void 0;
17603
+ return {
17604
+ ...correlationId === void 0 ? {} : { correlationId },
17605
+ ...ticketNumber === void 0 ? {} : { ticketNumber }
17606
+ };
17607
+ }
17608
+ function restoredTicketFields(fields) {
17609
+ return {
17610
+ ...fields.correlationId === void 0 ? {} : { correlationId: fields.correlationId },
17611
+ ...fields.ticketNumber === void 0 ? {} : { ticketNumber: fields.ticketNumber }
17612
+ };
17613
+ }
17464
17614
  async function loadResumableRunRecord(home, runId) {
17465
17615
  const runDirectory = await findRunDirectoryById(home, runId);
17466
17616
  if (runDirectory === void 0) {
@@ -17492,9 +17642,11 @@ async function loadResumableRunRecord(home, runId) {
17492
17642
  let baseRevision;
17493
17643
  let mergerInputPath;
17494
17644
  let derived;
17645
+ let correlationId;
17646
+ let ticketNumber;
17495
17647
  try {
17496
17648
  const raw = JSON.parse(
17497
- await readFile7(run.admittedRequestPath, "utf8")
17649
+ await readFile8(run.admittedRequestPath, "utf8")
17498
17650
  );
17499
17651
  if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
17500
17652
  const record4 = raw;
@@ -17540,12 +17692,36 @@ async function loadResumableRunRecord(home, runId) {
17540
17692
  };
17541
17693
  }
17542
17694
  }
17695
+ const fromAdmitted = parsePersistedTicketIdentity(record4);
17696
+ correlationId = fromAdmitted.correlationId;
17697
+ ticketNumber = fromAdmitted.ticketNumber;
17543
17698
  }
17544
17699
  } catch {
17545
17700
  throw new CliUsageError(
17546
17701
  `role run admitted request is unreadable: ${runId}`
17547
17702
  );
17548
17703
  }
17704
+ if (correlationId === void 0 || ticketNumber === void 0) {
17705
+ try {
17706
+ const invocationRaw = JSON.parse(
17707
+ await readFile8(join9(run.runDirectory, "invocation.json"), "utf8")
17708
+ );
17709
+ if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
17710
+ const fromInvocation = parsePersistedTicketIdentity(
17711
+ invocationRaw
17712
+ );
17713
+ if (correlationId === void 0) correlationId = fromInvocation.correlationId;
17714
+ if (ticketNumber === void 0) ticketNumber = fromInvocation.ticketNumber;
17715
+ }
17716
+ } catch (error) {
17717
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
17718
+ throw new CliUsageError(
17719
+ `role run invocation identity is unreadable: ${runId}`,
17720
+ { cause: error }
17721
+ );
17722
+ }
17723
+ }
17724
+ }
17549
17725
  return {
17550
17726
  run,
17551
17727
  observation: run.resumable,
@@ -17560,7 +17736,9 @@ async function loadResumableRunRecord(home, runId) {
17560
17736
  ...prerequisites === void 0 ? {} : { prerequisites },
17561
17737
  ...baseRevision === void 0 ? {} : { baseRevision },
17562
17738
  ...mergerInputPath === void 0 ? {} : { mergerInputPath },
17563
- ...derived === void 0 ? {} : { derived }
17739
+ ...derived === void 0 ? {} : { derived },
17740
+ ...correlationId === void 0 ? {} : { correlationId },
17741
+ ...ticketNumber === void 0 ? {} : { ticketNumber }
17564
17742
  }
17565
17743
  };
17566
17744
  }
@@ -17582,7 +17760,8 @@ async function loadResumableJudgeRun(home, runId) {
17582
17760
  runDirectory: loaded.run.runDirectory,
17583
17761
  sessionDirectory: loaded.run.sessionDirectory,
17584
17762
  sessionFile: loaded.run.sessionFile,
17585
- admittedRequestPath: loaded.run.admittedRequestPath
17763
+ admittedRequestPath: loaded.run.admittedRequestPath,
17764
+ ...restoredTicketFields(loaded.admittedFields)
17586
17765
  };
17587
17766
  return {
17588
17767
  admitted,
@@ -17627,7 +17806,8 @@ async function loadResumableCoderRun(home, runId) {
17627
17806
  sessionDirectory: loaded.run.sessionDirectory,
17628
17807
  sessionFile: loaded.run.sessionFile,
17629
17808
  admittedRequestPath: loaded.run.admittedRequestPath,
17630
- taskPath
17809
+ taskPath,
17810
+ ...restoredTicketFields(loaded.admittedFields)
17631
17811
  };
17632
17812
  return {
17633
17813
  admitted,
@@ -17675,7 +17855,8 @@ async function loadResumableFixerRun(home, runId) {
17675
17855
  admittedRequestPath: loaded.run.admittedRequestPath,
17676
17856
  packetPath,
17677
17857
  ...loaded.admittedFields.prerequisitesPath === void 0 ? {} : { prerequisitesPath: loaded.admittedFields.prerequisitesPath },
17678
- prerequisites
17858
+ prerequisites,
17859
+ ...restoredTicketFields(loaded.admittedFields)
17679
17860
  };
17680
17861
  return {
17681
17862
  admitted,
@@ -17708,7 +17889,8 @@ async function loadResumableReviewerRun(home, runId) {
17708
17889
  sessionDirectory: loaded.run.sessionDirectory,
17709
17890
  sessionFile: loaded.run.sessionFile,
17710
17891
  admittedRequestPath: loaded.run.admittedRequestPath,
17711
- baseRevision
17892
+ baseRevision,
17893
+ ...restoredTicketFields(loaded.admittedFields)
17712
17894
  };
17713
17895
  return {
17714
17896
  admitted,
@@ -17753,7 +17935,8 @@ async function loadResumableMergerRun(home, runId) {
17753
17935
  sessionFile: loaded.run.sessionFile,
17754
17936
  admittedRequestPath: loaded.run.admittedRequestPath,
17755
17937
  mergerInputPath,
17756
- derived
17938
+ derived,
17939
+ ...restoredTicketFields(loaded.admittedFields)
17757
17940
  };
17758
17941
  return {
17759
17942
  admitted,
@@ -17767,17 +17950,18 @@ async function peekRoleRunRole(home, runId) {
17767
17950
  const run = await readRoleRunState(runDirectory);
17768
17951
  return run?.role;
17769
17952
  }
17770
- var V1_RESUMABLE_PROVIDERS, RESUME_TRANSPORT_ENVELOPE, RUN_STATE_FILE, TYPED_HTTP_FILE, WRITER_LOCK_FILE, RunWriterLeaseHeldError;
17953
+ var V1_RESUMABLE_PROVIDERS, RESUME_TRANSPORT_ENVELOPE, RUN_STATE_FILE, WRITER_LOCK_FILE, RunWriterLeaseHeldError;
17771
17954
  var init_run_lifecycle = __esm({
17772
17955
  "src/public-cli/run-lifecycle.ts"() {
17773
17956
  "use strict";
17774
17957
  init_activation_ledger_topology();
17775
17958
  init_cli_errors();
17959
+ init_typed_provider_http();
17960
+ init_typed_provider_http();
17776
17961
  init_invocation();
17777
17962
  V1_RESUMABLE_PROVIDERS = ["openai-codex", "xai"];
17778
17963
  RESUME_TRANSPORT_ENVELOPE = "[ak-role:resume-continue]";
17779
17964
  RUN_STATE_FILE = "run-state.json";
17780
- TYPED_HTTP_FILE = "typed-provider-http.json";
17781
17965
  WRITER_LOCK_FILE = "writer.lock";
17782
17966
  RunWriterLeaseHeldError = class extends Error {
17783
17967
  code = "AK_RUN_WRITER_LEASE_HELD";
@@ -17911,6 +18095,7 @@ var init_evidence_child_executor = __esm({
17911
18095
  init_package_owned_tool_idle();
17912
18096
  init_stream_idle_guard();
17913
18097
  init_receipt_delivery_policy();
18098
+ init_upstream_error_testimony();
17914
18099
  }
17915
18100
  });
17916
18101
 
@@ -18431,8 +18616,8 @@ var init_terminal = __esm({
18431
18616
 
18432
18617
  // src/public-cli/settlement.ts
18433
18618
  import { randomUUID } from "node:crypto";
18434
- import { lstat as lstat3, mkdir as mkdir3, open as open2, readFile as readFile8, readdir as readdir3, writeFile as writeFile4 } from "node:fs/promises";
18435
- import { dirname as dirname6, join as join9 } from "node:path";
18619
+ import { lstat as lstat3, mkdir as mkdir3, open as open2, readFile as readFile9, readdir as readdir3, writeFile as writeFile5 } from "node:fs/promises";
18620
+ import { dirname as dirname6, join as join10 } from "node:path";
18436
18621
  function isChildDiagnosticFloodLine(line2) {
18437
18622
  if (/^at\s+/.test(line2)) return true;
18438
18623
  if (line2.startsWith("event:")) return true;
@@ -18487,7 +18672,7 @@ function presentStructuralRejection(error, io) {
18487
18672
  }
18488
18673
  async function inspectJudgeSession(sessionFile) {
18489
18674
  try {
18490
- await readFile8(sessionFile, "utf8");
18675
+ await readFile9(sessionFile, "utf8");
18491
18676
  return { state: "present" };
18492
18677
  } catch (error) {
18493
18678
  if (isMissingPathError2(error)) return { state: "missing" };
@@ -18542,13 +18727,15 @@ function classifyPostAdmissionFailure(input) {
18542
18727
  if (input.knownCause !== void 0) {
18543
18728
  const fallback = input.knownCause === "provider" ? "provider failure" : input.knownCause === "session" ? "session unreadable" : input.knownCause === "output" ? "role run completed without a lawful typed terminal result" : `role run failed (${input.knownCause})`;
18544
18729
  const diagnostic = input.knownDiagnostic !== void 0 && input.knownDiagnostic.trim() !== "" ? input.knownDiagnostic : conciseChildDiagnostic(input.stderr, fallback);
18545
- const { code: _knownCode, timedOut: _knownTimedOut, ...knownDetails } = input.knownDetails ?? {};
18730
+ const { timedOut: _knownTimedOut, ...knownDetails } = input.knownDetails ?? {};
18731
+ const remoteCode = knownDetails.code;
18546
18732
  return {
18547
18733
  cause: input.knownCause,
18548
18734
  diagnostic,
18549
18735
  details: {
18550
18736
  ...knownDetails,
18551
- code: input.code,
18737
+ ...remoteCode === void 0 ? {} : { code: remoteCode },
18738
+ exitCode: input.code,
18552
18739
  ...input.timedOut ? { timedOut: true } : {}
18553
18740
  },
18554
18741
  ...input.knownIdentity === void 0 ? {} : { identity: input.knownIdentity }
@@ -18558,7 +18745,7 @@ function classifyPostAdmissionFailure(input) {
18558
18745
  return {
18559
18746
  cause: "timeout",
18560
18747
  diagnostic: "role run timed out",
18561
- details: { timedOut: true, code: input.code }
18748
+ details: { timedOut: true, exitCode: input.code }
18562
18749
  };
18563
18750
  }
18564
18751
  if (input.code !== 0) {
@@ -18566,27 +18753,27 @@ function classifyPostAdmissionFailure(input) {
18566
18753
  return {
18567
18754
  cause: "activation",
18568
18755
  diagnostic: conciseChildDiagnostic(input.stderr, fallback),
18569
- details: { code: input.code }
18756
+ details: { exitCode: input.code }
18570
18757
  };
18571
18758
  }
18572
18759
  if (input.session?.state === "missing") {
18573
18760
  return {
18574
18761
  cause: "session",
18575
18762
  diagnostic: "role run left no readable session transcript",
18576
- details: { code: input.code, session: "missing" }
18763
+ details: { exitCode: input.code, session: "missing" }
18577
18764
  };
18578
18765
  }
18579
18766
  if (input.session?.state === "unreadable") {
18580
18767
  return {
18581
18768
  cause: "session",
18582
18769
  diagnostic: input.session.diagnostic,
18583
- details: { code: input.code, session: "unreadable" }
18770
+ details: { exitCode: input.code, session: "unreadable" }
18584
18771
  };
18585
18772
  }
18586
18773
  return {
18587
18774
  cause: "output",
18588
18775
  diagnostic: "role run completed without a lawful typed terminal result",
18589
- details: { code: input.code }
18776
+ details: { exitCode: input.code }
18590
18777
  };
18591
18778
  }
18592
18779
  function explicitInternalKnownFailureClassificationInput(failure) {
@@ -18627,7 +18814,7 @@ function sessionReadFailure(error, fallbackMessage) {
18627
18814
  return failed;
18628
18815
  }
18629
18816
  async function readBoundSessionEntries(sessionFile) {
18630
- const text = await readFile8(sessionFile, "utf8");
18817
+ const text = await readFile9(sessionFile, "utf8");
18631
18818
  const entries = [];
18632
18819
  for (const line2 of text.trim().split("\n").filter(Boolean)) {
18633
18820
  try {
@@ -18638,6 +18825,31 @@ async function readBoundSessionEntries(sessionFile) {
18638
18825
  }
18639
18826
  return entries;
18640
18827
  }
18828
+ function typedHttpStatusFromMessage(message) {
18829
+ for (const candidate of [message.httpStatus, message.statusCode, message.status]) {
18830
+ if (typeof candidate === "number" && (candidate < 200 || candidate >= 300)) return candidate;
18831
+ }
18832
+ return void 0;
18833
+ }
18834
+ function sessionProviderStopFromAssistant(message) {
18835
+ if (message?.role !== "assistant") return void 0;
18836
+ if (message.stopReason !== "error" && message.stopReason !== "aborted") return void 0;
18837
+ const httpStatus = typedHttpStatusFromMessage(message);
18838
+ return {
18839
+ stopReason: message.stopReason,
18840
+ // Preserve held errorMessage bytes — emptiness check must not rewrite.
18841
+ ...typeof message.errorMessage === "string" && message.errorMessage.trim() !== "" ? { errorMessage: message.errorMessage } : {},
18842
+ ...typeof message.provider === "string" && message.provider.trim() !== "" ? { provider: message.provider } : {},
18843
+ ...typeof message.model === "string" && message.model.trim() !== "" ? { model: message.model } : {},
18844
+ ...typeof message.api === "string" && message.api.trim() !== "" ? { api: message.api } : {},
18845
+ ...typeof message.rawStopReason === "string" && message.rawStopReason.trim() !== "" ? { rawStopReason: message.rawStopReason } : {},
18846
+ ...message.diagnostics === void 0 ? {} : { diagnostics: message.diagnostics },
18847
+ ...httpStatus === void 0 ? {} : { httpStatus },
18848
+ ...message.body === void 0 ? {} : { body: message.body },
18849
+ ...message.code === void 0 ? {} : { code: message.code },
18850
+ ...message.errno === void 0 ? {} : { errno: message.errno }
18851
+ };
18852
+ }
18641
18853
  function extractSessionProviderStop(entries) {
18642
18854
  let attemptStart = 0;
18643
18855
  for (let i = entries.length - 1; i >= 0; i -= 1) {
@@ -18651,14 +18863,8 @@ function extractSessionProviderStop(entries) {
18651
18863
  const entry = entries[i];
18652
18864
  if (entry?.type !== "custom" || entry.customType !== COMPLIANCE_RESPONSE_ENTRY_TYPE) continue;
18653
18865
  const response = isRecord5(entry.data) && isRecord5(entry.data.response) ? entry.data.response : void 0;
18654
- if (response?.role === "assistant" && response.stopReason === "error") {
18655
- return {
18656
- stopReason: "error",
18657
- ...typeof response.errorMessage === "string" && response.errorMessage.trim() !== "" ? { errorMessage: response.errorMessage } : {},
18658
- ...typeof response.provider === "string" && response.provider.trim() !== "" ? { provider: response.provider } : {},
18659
- ...typeof response.model === "string" && response.model.trim() !== "" ? { model: response.model } : {}
18660
- };
18661
- }
18866
+ const stop = sessionProviderStopFromAssistant(response);
18867
+ if (stop !== void 0) return stop;
18662
18868
  break;
18663
18869
  }
18664
18870
  for (let i = entries.length - 1; i >= attemptStart; i -= 1) {
@@ -18666,13 +18872,7 @@ function extractSessionProviderStop(entries) {
18666
18872
  if (entry?.type !== "message") continue;
18667
18873
  const message = entry.message;
18668
18874
  if (message?.role !== "assistant") continue;
18669
- if (message.stopReason !== "error") return void 0;
18670
- return {
18671
- stopReason: "error",
18672
- ...typeof message.errorMessage === "string" && message.errorMessage.trim() !== "" ? { errorMessage: message.errorMessage } : {},
18673
- ...typeof message.provider === "string" && message.provider.trim() !== "" ? { provider: message.provider } : {},
18674
- ...typeof message.model === "string" && message.model.trim() !== "" ? { model: message.model } : {}
18675
- };
18875
+ return sessionProviderStopFromAssistant(message);
18676
18876
  }
18677
18877
  return void 0;
18678
18878
  }
@@ -18685,7 +18885,7 @@ async function readSessionProviderStop(sessionFile) {
18685
18885
  }
18686
18886
  }
18687
18887
  async function readBoundEvidenceChildKnownFailure(sessionFile) {
18688
- const childDirectory = join9(dirname6(sessionFile), "evidence-children");
18888
+ const childDirectory = join10(dirname6(sessionFile), "evidence-children");
18689
18889
  let names;
18690
18890
  try {
18691
18891
  names = await readdir3(childDirectory);
@@ -18696,7 +18896,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
18696
18896
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
18697
18897
  let entries;
18698
18898
  try {
18699
- entries = await readBoundSessionEntries(join9(childDirectory, file));
18899
+ entries = await readBoundSessionEntries(join10(childDirectory, file));
18700
18900
  } catch (error) {
18701
18901
  throw sessionReadFailure(error, "failed to read discovered evidence-child session");
18702
18902
  }
@@ -18708,8 +18908,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
18708
18908
  return {
18709
18909
  ...primary,
18710
18910
  details: {
18711
- ...stop.provider === void 0 ? {} : { provider: stop.provider },
18712
- ...stop.model === void 0 ? {} : { model: stop.model },
18911
+ ...primary.details ?? {},
18713
18912
  secondaryEvidence: "evidence-child"
18714
18913
  }
18715
18914
  };
@@ -18733,7 +18932,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
18733
18932
  break;
18734
18933
  }
18735
18934
  }
18736
- const childDirectory = join9(dirname6(sessionFile), "auditor-roles");
18935
+ const childDirectory = join10(dirname6(sessionFile), "auditor-roles");
18737
18936
  let names;
18738
18937
  try {
18739
18938
  names = await readdir3(childDirectory);
@@ -18744,7 +18943,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
18744
18943
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
18745
18944
  let entries;
18746
18945
  try {
18747
- entries = await readBoundSessionEntries(join9(childDirectory, file));
18946
+ entries = await readBoundSessionEntries(join10(childDirectory, file));
18748
18947
  } catch (error) {
18749
18948
  throw sessionReadFailure(error, "failed to read discovered auditor session");
18750
18949
  }
@@ -18762,10 +18961,10 @@ async function readBoundAuditorKnownFailure(sessionFile) {
18762
18961
  if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord5(entry.data)) continue;
18763
18962
  const parent = isRecord5(entry.data.parent) ? entry.data.parent : void 0;
18764
18963
  const failure = isRecord5(entry.data.failure) ? entry.data.failure : void 0;
18765
- if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId || failure?.cause !== "provider") continue;
18964
+ if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId || failure?.cause !== "provider" && failure?.cause !== "unrecognized") continue;
18766
18965
  const identity = isRecord5(failure.identity) ? failure.identity : void 0;
18767
18966
  return {
18768
- cause: "provider",
18967
+ cause: failure.cause === "provider" ? "provider" : "unrecognized",
18769
18968
  ...identity === void 0 ? {} : { identity: {
18770
18969
  ...typeof identity.name === "string" ? { name: identity.name } : {},
18771
18970
  ...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
@@ -18778,8 +18977,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
18778
18977
  return {
18779
18978
  ...primary,
18780
18979
  details: {
18781
- ...stop.provider === void 0 ? {} : { provider: stop.provider },
18782
- ...stop.model === void 0 ? {} : { model: stop.model },
18980
+ ...primary.details ?? {},
18783
18981
  secondaryEvidence: "unavailable"
18784
18982
  }
18785
18983
  };
@@ -18813,56 +19011,145 @@ function typedFailedTerminatingToolKnownFailure(entries) {
18813
19011
  }
18814
19012
  return void 0;
18815
19013
  }
18816
- async function resolveAuditedRunnerKnownFailure(input) {
18817
- if (input.runner !== void 0) return input.runner;
19014
+ function resolutionOf(knownFailure, typedHttp = { settled: false }) {
19015
+ return {
19016
+ ...knownFailure === void 0 ? {} : { knownFailure },
19017
+ ...typedHttp.observation === void 0 ? {} : { typedHttpObservation: typedHttp.observation },
19018
+ typedHttpObservationSettled: typedHttp.settled
19019
+ };
19020
+ }
19021
+ async function resolveAuditedRunnerFailureResolution(input) {
19022
+ if (input.runner !== void 0) return resolutionOf(input.runner);
18818
19023
  if (input.runDirectory !== void 0) {
18819
19024
  try {
18820
19025
  const rejection = await readReviewerDispatchRejection(input.runDirectory);
18821
- if (rejection !== void 0) return rejection;
19026
+ if (rejection !== void 0) return resolutionOf(rejection);
18822
19027
  } catch (error) {
18823
19028
  const failure = error instanceof Error ? error : new Error(String(error));
18824
- return {
19029
+ return resolutionOf({
18825
19030
  cause: "activation",
18826
19031
  identity: thrownIdentity(failure),
18827
19032
  diagnostic: failure.message || failure.name
18828
- };
19033
+ });
18829
19034
  }
18830
19035
  }
18831
19036
  try {
18832
19037
  const auditorFailure = await readBoundAuditorKnownFailure(input.sessionFile);
18833
- if (auditorFailure !== void 0) return auditorFailure;
19038
+ if (auditorFailure !== void 0) return resolutionOf(auditorFailure);
18834
19039
  } catch (error) {
18835
19040
  const failure = sessionReadFailure(error, "failed to recover bound auditor failure");
18836
- return {
19041
+ return resolutionOf({
18837
19042
  cause: "session",
18838
19043
  identity: thrownIdentity(failure),
18839
19044
  diagnostic: failure.message || failure.name
18840
- };
19045
+ });
18841
19046
  }
18842
19047
  try {
18843
19048
  const terminatingFailure = typedFailedTerminatingToolKnownFailure(
18844
19049
  await readBoundSessionEntries(input.sessionFile)
18845
19050
  );
18846
- if (terminatingFailure !== void 0) return terminatingFailure;
19051
+ if (terminatingFailure !== void 0) return resolutionOf(terminatingFailure);
18847
19052
  } catch (error) {
18848
19053
  if (!isMissingPathError2(error)) {
18849
19054
  const failure = sessionReadFailure(error, "failed to recover typed terminating-tool failure");
18850
- return { cause: "session", identity: thrownIdentity(failure), diagnostic: failure.message || failure.name };
19055
+ return resolutionOf({
19056
+ cause: "session",
19057
+ identity: thrownIdentity(failure),
19058
+ diagnostic: failure.message || failure.name
19059
+ });
18851
19060
  }
18852
19061
  }
18853
19062
  try {
18854
19063
  const evidenceChildFailure = await readBoundEvidenceChildKnownFailure(input.sessionFile);
18855
- if (evidenceChildFailure !== void 0) return evidenceChildFailure;
19064
+ if (evidenceChildFailure !== void 0) return resolutionOf(evidenceChildFailure);
18856
19065
  } catch (error) {
18857
19066
  const failure = sessionReadFailure(error, "failed to recover bound evidence-child failure");
18858
- return {
19067
+ return resolutionOf({
18859
19068
  cause: "session",
18860
19069
  identity: thrownIdentity(failure),
18861
19070
  diagnostic: failure.message || failure.name
18862
- };
19071
+ });
18863
19072
  }
18864
19073
  const parentStop = await readSessionProviderStop(input.sessionFile);
18865
- return parentStop === void 0 ? input.credential : knownFailureFromProviderStop(parentStop);
19074
+ let httpObservation;
19075
+ if (input.runDirectory !== void 0) {
19076
+ try {
19077
+ httpObservation = await readLatestTypedProviderHttpObservation(input.runDirectory);
19078
+ } catch (error) {
19079
+ const failure = error instanceof Error ? error : new Error(String(error));
19080
+ return resolutionOf(
19081
+ {
19082
+ cause: "session",
19083
+ identity: thrownIdentity(failure),
19084
+ diagnostic: failure.message || failure.name
19085
+ },
19086
+ { settled: true }
19087
+ );
19088
+ }
19089
+ }
19090
+ const typedHttp = {
19091
+ settled: input.runDirectory !== void 0,
19092
+ ...httpObservation === void 0 ? {} : { observation: httpObservation }
19093
+ };
19094
+ if (parentStop === void 0) {
19095
+ if (input.credential !== void 0) return resolutionOf(input.credential, typedHttp);
19096
+ if (httpObservation === void 0) return resolutionOf(void 0, typedHttp);
19097
+ return resolutionOf(
19098
+ knownFailureFromProviderStop({
19099
+ stopReason: "error",
19100
+ httpStatus: httpObservation.httpStatus,
19101
+ provider: httpObservation.provider
19102
+ }),
19103
+ typedHttp
19104
+ );
19105
+ }
19106
+ return resolutionOf(
19107
+ knownFailureFromProviderStop({
19108
+ ...parentStop,
19109
+ ...httpObservation === void 0 ? {} : {
19110
+ httpStatus: httpObservation.httpStatus,
19111
+ // Observation association outranks session-configured provider name alone.
19112
+ provider: httpObservation.provider
19113
+ }
19114
+ }),
19115
+ typedHttp
19116
+ );
19117
+ }
19118
+ async function resolveAuditedRunnerKnownFailure(input) {
19119
+ return (await resolveAuditedRunnerFailureResolution(input)).knownFailure;
19120
+ }
19121
+ async function resolveControlledFailureResumeObservation(input) {
19122
+ if (input.typedHttpObservationSettled === true) {
19123
+ const observation = input.typedHttpObservation;
19124
+ if (observation !== void 0 && observation.httpStatus === 429 && isV1ResumableProvider(observation.provider)) {
19125
+ return {
19126
+ typedHttp429: { httpStatus: 429, provider: observation.provider }
19127
+ };
19128
+ }
19129
+ return {};
19130
+ }
19131
+ try {
19132
+ const typedHttp429 = await readTypedHttp429Observation(input.runDirectory);
19133
+ return typedHttp429 === void 0 ? {} : { typedHttp429 };
19134
+ } catch (error) {
19135
+ const failure = error instanceof Error ? error : new Error(String(error));
19136
+ return {
19137
+ observationReadFailure: {
19138
+ cause: "session",
19139
+ identity: thrownIdentity(failure),
19140
+ diagnostic: failure.message || failure.name
19141
+ }
19142
+ };
19143
+ }
19144
+ }
19145
+ function controlledFailureInputFromResolution(resolution) {
19146
+ return {
19147
+ ...resolution.knownFailure === void 0 ? {} : { knownFailure: resolution.knownFailure },
19148
+ ...resolution.typedHttpObservationSettled ? {
19149
+ typedHttpObservationSettled: true,
19150
+ ...resolution.typedHttpObservation === void 0 ? {} : { typedHttpObservation: resolution.typedHttpObservation }
19151
+ } : {}
19152
+ };
18866
19153
  }
18867
19154
  function isRecord5(value) {
18868
19155
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -19358,7 +19645,7 @@ function auditArtifactPublicationError(message, code) {
19358
19645
  return error;
19359
19646
  }
19360
19647
  async function ensureAuditEvidenceDirectory(runDirectory) {
19361
- const artifactsDir = join9(runDirectory, "artifacts");
19648
+ const artifactsDir = join10(runDirectory, "artifacts");
19362
19649
  const runStat = await lstat3(runDirectory);
19363
19650
  if (runStat.isSymbolicLink() || !runStat.isDirectory()) {
19364
19651
  throw auditArtifactPublicationError(
@@ -19395,7 +19682,7 @@ async function ensureAuditEvidenceDirectory(runDirectory) {
19395
19682
  }
19396
19683
  async function publishComplianceAuditIncompleteEvidence(admitted, outcome) {
19397
19684
  const artifactsDir = await ensureAuditEvidenceDirectory(admitted.runDirectory);
19398
- const evidencePath = join9(artifactsDir, "audit-incomplete.json");
19685
+ const evidencePath = join10(artifactsDir, "audit-incomplete.json");
19399
19686
  try {
19400
19687
  const existing = await lstat3(evidencePath);
19401
19688
  throw auditArtifactPublicationError(
@@ -19417,7 +19704,7 @@ async function publishComplianceAuditIncompleteEvidence(admitted, outcome) {
19417
19704
  }
19418
19705
  function auditPublicationFailureTerminal(admitted, entries, outcome, error) {
19419
19706
  const attempt = publicationAttemptFromError(
19420
- join9(admitted.runDirectory, "artifacts", "audit-incomplete.json"),
19707
+ join10(admitted.runDirectory, "artifacts", "audit-incomplete.json"),
19421
19708
  error
19422
19709
  );
19423
19710
  const diagnostic = `audit-incomplete evidence publication failed: ${attempt.diagnostic}`;
@@ -19711,9 +19998,9 @@ async function extractNavigatorFactFromAdmittedSession(admitted) {
19711
19998
  }
19712
19999
  async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
19713
20000
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
19714
- const reportPath = join9(artifactsDir, "report.json");
19715
- const evidencePath = join9(artifactsDir, "evidence.json");
19716
- await writeFile4(
20001
+ const reportPath = join10(artifactsDir, "report.json");
20002
+ const evidencePath = join10(artifactsDir, "evidence.json");
20003
+ await writeFile5(
19717
20004
  reportPath,
19718
20005
  `${JSON.stringify(
19719
20006
  {
@@ -19727,7 +20014,7 @@ async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
19727
20014
  `,
19728
20015
  "utf8"
19729
20016
  );
19730
- await writeFile4(
20017
+ await writeFile5(
19731
20018
  evidencePath,
19732
20019
  `${JSON.stringify(
19733
20020
  {
@@ -19755,9 +20042,9 @@ async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
19755
20042
  }
19756
20043
  async function publishCoderArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
19757
20044
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
19758
- const reportPath = join9(artifactsDir, "report.json");
19759
- const evidencePath = join9(artifactsDir, "evidence.json");
19760
- await writeFile4(
20045
+ const reportPath = join10(artifactsDir, "report.json");
20046
+ const evidencePath = join10(artifactsDir, "evidence.json");
20047
+ await writeFile5(
19761
20048
  reportPath,
19762
20049
  `${JSON.stringify(
19763
20050
  {
@@ -19773,7 +20060,7 @@ async function publishCoderArtifacts(admitted, roleOutcome, sessionDirectory, op
19773
20060
  `,
19774
20061
  "utf8"
19775
20062
  );
19776
- await writeFile4(
20063
+ await writeFile5(
19777
20064
  evidencePath,
19778
20065
  `${JSON.stringify(
19779
20066
  {
@@ -19930,9 +20217,9 @@ function extractFixerMethodInvocations(entries, options) {
19930
20217
  }
19931
20218
  async function publishFixerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
19932
20219
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
19933
- const reportPath = join9(artifactsDir, "report.json");
19934
- const evidencePath = join9(artifactsDir, "evidence.json");
19935
- await writeFile4(
20220
+ const reportPath = join10(artifactsDir, "report.json");
20221
+ const evidencePath = join10(artifactsDir, "evidence.json");
20222
+ await writeFile5(
19936
20223
  reportPath,
19937
20224
  `${JSON.stringify(
19938
20225
  {
@@ -19948,7 +20235,7 @@ async function publishFixerArtifacts(admitted, roleOutcome, sessionDirectory, op
19948
20235
  `,
19949
20236
  "utf8"
19950
20237
  );
19951
- await writeFile4(
20238
+ await writeFile5(
19952
20239
  evidencePath,
19953
20240
  `${JSON.stringify(
19954
20241
  {
@@ -20044,9 +20331,9 @@ async function settleLawfulFixerTerminalResult(admitted, options) {
20044
20331
  }
20045
20332
  async function publishCollectorArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
20046
20333
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
20047
- const reportPath = join9(artifactsDir, "report.json");
20048
- const evidencePath = join9(artifactsDir, "evidence.json");
20049
- await writeFile4(
20334
+ const reportPath = join10(artifactsDir, "report.json");
20335
+ const evidencePath = join10(artifactsDir, "evidence.json");
20336
+ await writeFile5(
20050
20337
  reportPath,
20051
20338
  `${JSON.stringify(
20052
20339
  {
@@ -20061,7 +20348,7 @@ async function publishCollectorArtifacts(admitted, roleOutcome, sessionDirectory
20061
20348
  `,
20062
20349
  "utf8"
20063
20350
  );
20064
- await writeFile4(
20351
+ await writeFile5(
20065
20352
  evidencePath,
20066
20353
  `${JSON.stringify(
20067
20354
  {
@@ -20166,9 +20453,9 @@ async function trySettleCollectorTerminalResult(admitted) {
20166
20453
  }
20167
20454
  async function publishDoctorArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
20168
20455
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
20169
- const reportPath = join9(artifactsDir, "report.json");
20170
- const evidencePath = join9(artifactsDir, "evidence.json");
20171
- await writeFile4(
20456
+ const reportPath = join10(artifactsDir, "report.json");
20457
+ const evidencePath = join10(artifactsDir, "evidence.json");
20458
+ await writeFile5(
20172
20459
  reportPath,
20173
20460
  `${JSON.stringify(
20174
20461
  {
@@ -20183,7 +20470,7 @@ async function publishDoctorArtifacts(admitted, roleOutcome, sessionDirectory, o
20183
20470
  `,
20184
20471
  "utf8"
20185
20472
  );
20186
- await writeFile4(
20473
+ await writeFile5(
20187
20474
  evidencePath,
20188
20475
  `${JSON.stringify(
20189
20476
  {
@@ -20335,9 +20622,9 @@ function extractReviewerMethodInvocations(entries, options) {
20335
20622
  }
20336
20623
  async function publishReviewerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
20337
20624
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
20338
- const reportPath = join9(artifactsDir, "report.json");
20339
- const evidencePath = join9(artifactsDir, "evidence.json");
20340
- await writeFile4(
20625
+ const reportPath = join10(artifactsDir, "report.json");
20626
+ const evidencePath = join10(artifactsDir, "evidence.json");
20627
+ await writeFile5(
20341
20628
  reportPath,
20342
20629
  `${JSON.stringify(
20343
20630
  {
@@ -20352,7 +20639,7 @@ async function publishReviewerArtifacts(admitted, roleOutcome, sessionDirectory,
20352
20639
  `,
20353
20640
  "utf8"
20354
20641
  );
20355
- await writeFile4(
20642
+ await writeFile5(
20356
20643
  evidencePath,
20357
20644
  `${JSON.stringify(
20358
20645
  {
@@ -20502,9 +20789,9 @@ function extractMergerMethodInvocations(entries, options) {
20502
20789
  }
20503
20790
  async function publishMergerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
20504
20791
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
20505
- const reportPath = join9(artifactsDir, "report.json");
20506
- const evidencePath = join9(artifactsDir, "evidence.json");
20507
- await writeFile4(
20792
+ const reportPath = join10(artifactsDir, "report.json");
20793
+ const evidencePath = join10(artifactsDir, "evidence.json");
20794
+ await writeFile5(
20508
20795
  reportPath,
20509
20796
  `${JSON.stringify(
20510
20797
  {
@@ -20519,7 +20806,7 @@ async function publishMergerArtifacts(admitted, roleOutcome, sessionDirectory, o
20519
20806
  `,
20520
20807
  "utf8"
20521
20808
  );
20522
- await writeFile4(
20809
+ await writeFile5(
20523
20810
  evidencePath,
20524
20811
  `${JSON.stringify(
20525
20812
  {
@@ -20674,7 +20961,7 @@ function uniqueFailureFallbackDirs(runDirectory, baseDir) {
20674
20961
  return dirs;
20675
20962
  }
20676
20963
  async function resolveFailureArtifactsBase(runDirectory) {
20677
- const artifactsDir = join9(runDirectory, "artifacts");
20964
+ const artifactsDir = join10(runDirectory, "artifacts");
20678
20965
  try {
20679
20966
  await ensureRunArtifactsDir(runDirectory);
20680
20967
  return { baseDir: artifactsDir };
@@ -20690,13 +20977,13 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
20690
20977
  const candidates = [
20691
20978
  ...preferredCandidates,
20692
20979
  // One unique name per fallback dir — collisions on fixed names cannot exhaust this.
20693
- ...uniqueFallbackDirs.map((dir) => join9(dir, `${stem}.${randomUUID()}.json`))
20980
+ ...uniqueFallbackDirs.map((dir) => join10(dir, `${stem}.${randomUUID()}.json`))
20694
20981
  ];
20695
20982
  for (let i = 0; i < candidates.length; i += 1) {
20696
20983
  const path = candidates[i];
20697
20984
  const payload = issues.length === 0 ? basePayload : { ...basePayload, publicationIssues: issues };
20698
20985
  try {
20699
- await writeFile4(
20986
+ await writeFile5(
20700
20987
  path,
20701
20988
  `${JSON.stringify(payload, null, 2)}
20702
20989
  `,
@@ -20725,26 +21012,26 @@ async function publishFailureArtifacts(admitted, failure) {
20725
21012
  admitted.runDirectory
20726
21013
  );
20727
21014
  const priorIssues = baseAttempt === void 0 ? [] : [baseAttempt];
20728
- const underArtifacts = baseDir === join9(admitted.runDirectory, "artifacts");
21015
+ const underArtifacts = baseDir === join10(admitted.runDirectory, "artifacts");
20729
21016
  const uniqueFallbackDirs = uniqueFailureFallbackDirs(
20730
21017
  admitted.runDirectory,
20731
21018
  baseDir
20732
21019
  );
20733
21020
  const errorCandidates = underArtifacts ? [
20734
- join9(baseDir, "error.json"),
20735
- join9(baseDir, "error.settlement.json"),
20736
- join9(admitted.runDirectory, "error.settlement.json")
21021
+ join10(baseDir, "error.json"),
21022
+ join10(baseDir, "error.settlement.json"),
21023
+ join10(admitted.runDirectory, "error.settlement.json")
20737
21024
  ] : [
20738
- join9(baseDir, "error.settlement.json"),
20739
- join9(baseDir, "error.json")
21025
+ join10(baseDir, "error.settlement.json"),
21026
+ join10(baseDir, "error.json")
20740
21027
  ];
20741
21028
  const evidenceCandidates = underArtifacts ? [
20742
- join9(baseDir, "evidence.json"),
20743
- join9(baseDir, "evidence.settlement.json"),
20744
- join9(admitted.runDirectory, "evidence.settlement.json")
21029
+ join10(baseDir, "evidence.json"),
21030
+ join10(baseDir, "evidence.settlement.json"),
21031
+ join10(admitted.runDirectory, "evidence.settlement.json")
20745
21032
  ] : [
20746
- join9(baseDir, "evidence.settlement.json"),
20747
- join9(baseDir, "evidence.json")
21033
+ join10(baseDir, "evidence.settlement.json"),
21034
+ join10(baseDir, "evidence.json")
20748
21035
  ];
20749
21036
  const errorPayloadBase = {
20750
21037
  kind: "error",
@@ -20931,6 +21218,7 @@ var init_settlement = __esm({
20931
21218
  init_judge_auditor();
20932
21219
  init_reviewer_auditor();
20933
21220
  init_explicit_internal();
21221
+ init_run_lifecycle();
20934
21222
  init_compliance_transport();
20935
21223
  init_collector_ledger();
20936
21224
  init_judge_output();
@@ -20957,8 +21245,8 @@ var init_settlement = __esm({
20957
21245
  });
20958
21246
 
20959
21247
  // src/public-cli/coder-run.ts
20960
- import { writeFile as writeFile5 } from "node:fs/promises";
20961
- import { join as join10 } from "node:path";
21248
+ import { writeFile as writeFile6 } from "node:fs/promises";
21249
+ import { join as join11 } from "node:path";
20962
21250
  function buildModelArgs(model) {
20963
21251
  if (model === void 0) return [];
20964
21252
  return [
@@ -21029,20 +21317,28 @@ function buildCoderResumeActivationExtraArgs(admitted, options) {
21029
21317
  }
21030
21318
  async function presentControlledFailure(admitted, failureInput, io) {
21031
21319
  const hasThrown = Object.hasOwn(failureInput, "thrown");
21032
- const session = !hasThrown && !failureInput.timedOut && failureInput.knownFailure === void 0 && failureInput.knownCause === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
21320
+ const resumeObservation = await resolveControlledFailureResumeObservation({
21321
+ runDirectory: admitted.runDirectory,
21322
+ ...failureInput.typedHttpObservationSettled === true ? {
21323
+ typedHttpObservationSettled: true,
21324
+ ...failureInput.typedHttpObservation === void 0 ? {} : { typedHttpObservation: failureInput.typedHttpObservation }
21325
+ } : {}
21326
+ });
21327
+ const knownFailure = failureInput.knownFailure ?? resumeObservation.observationReadFailure;
21328
+ const session = !hasThrown && !failureInput.timedOut && knownFailure === void 0 && failureInput.knownCause === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
21033
21329
  const failure = classifyPostAdmissionFailure({
21034
21330
  timedOut: failureInput.timedOut,
21035
21331
  code: failureInput.code,
21036
21332
  stderr: failureInput.stderr,
21037
21333
  ...hasThrown ? { thrown: failureInput.thrown } : {},
21038
- ...explicitInternalKnownFailureClassificationInput(failureInput.knownFailure),
21334
+ ...explicitInternalKnownFailureClassificationInput(knownFailure),
21039
21335
  ...failureInput.knownCause === void 0 ? {} : { knownCause: failureInput.knownCause },
21040
21336
  ...failureInput.knownIdentity === void 0 ? {} : { knownIdentity: failureInput.knownIdentity },
21041
21337
  ...failureInput.knownDiagnostic === void 0 ? {} : { knownDiagnostic: failureInput.knownDiagnostic },
21042
21338
  ...session === void 0 ? {} : { session }
21043
21339
  });
21044
21340
  const hasLawfulTerminalResult = await hasLawfulCoderTerminalResult(admitted);
21045
- const typedHttp429 = await readTypedHttp429Observation(admitted.runDirectory);
21341
+ const typedHttp429 = resumeObservation.typedHttp429;
21046
21342
  const sessionPrincipalAvailable = await isSessionPrincipalAvailable(
21047
21343
  admitted.sessionFile
21048
21344
  );
@@ -21089,8 +21385,9 @@ async function dispatchAdmittedCoder(input) {
21089
21385
  PI_CODING_AGENT_DIR: env.agentDir,
21090
21386
  AK_ROLE_RUN_DIR: admitted.runDirectory
21091
21387
  };
21092
- if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
21093
- childEnv.AK_CORRELATION_ID = env.correlationId;
21388
+ const correlationId = admitted.correlationId ?? env.correlationId;
21389
+ if (correlationId !== void 0 && correlationId.trim() !== "") {
21390
+ childEnv.AK_CORRELATION_ID = correlationId;
21094
21391
  }
21095
21392
  let result2;
21096
21393
  try {
@@ -21117,8 +21414,8 @@ async function dispatchAdmittedCoder(input) {
21117
21414
  );
21118
21415
  }
21119
21416
  try {
21120
- await writeFile5(
21121
- join10(admitted.runDirectory, "stderr.log"),
21417
+ await writeFile6(
21418
+ join11(admitted.runDirectory, "stderr.log"),
21122
21419
  result2.stderr,
21123
21420
  "utf8"
21124
21421
  );
@@ -21155,10 +21452,11 @@ async function dispatchAdmittedCoder(input) {
21155
21452
  env.model,
21156
21453
  env.credentials
21157
21454
  );
21158
- const knownFailure = await resolveAuditedRunnerKnownFailure({
21455
+ const resolution = await resolveAuditedRunnerFailureResolution({
21159
21456
  runner: result2.knownFailure,
21160
21457
  sessionFile: admitted.sessionFile,
21161
- credential: credentialFailure
21458
+ credential: credentialFailure,
21459
+ runDirectory: admitted.runDirectory
21162
21460
  });
21163
21461
  return await presentControlledFailure(
21164
21462
  admitted,
@@ -21166,7 +21464,7 @@ async function dispatchAdmittedCoder(input) {
21166
21464
  timedOut: result2.timedOut,
21167
21465
  code: result2.code,
21168
21466
  stderr: result2.stderr,
21169
- ...knownFailure === void 0 ? {} : { knownFailure }
21467
+ ...controlledFailureInputFromResolution(resolution)
21170
21468
  },
21171
21469
  io
21172
21470
  );
@@ -21235,7 +21533,10 @@ async function runPublicCoder(argv, env, io, parseCoderArgv2) {
21235
21533
  });
21236
21534
  return await dispatchAdmittedCoder({
21237
21535
  admitted,
21238
- env,
21536
+ env: {
21537
+ ...env,
21538
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
21539
+ },
21239
21540
  io,
21240
21541
  extraArgs,
21241
21542
  lease,
@@ -21309,7 +21610,10 @@ async function runPublicCoderResume(argv, env, io) {
21309
21610
  });
21310
21611
  return await dispatchAdmittedCoder({
21311
21612
  admitted,
21312
- env,
21613
+ env: {
21614
+ ...env,
21615
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
21616
+ },
21313
21617
  io,
21314
21618
  extraArgs,
21315
21619
  lease,
@@ -21331,8 +21635,8 @@ var init_coder_run = __esm({
21331
21635
  });
21332
21636
 
21333
21637
  // src/public-cli/collector-run.ts
21334
- import { writeFile as writeFile6 } from "node:fs/promises";
21335
- import { join as join11 } from "node:path";
21638
+ import { writeFile as writeFile7 } from "node:fs/promises";
21639
+ import { join as join12 } from "node:path";
21336
21640
  function buildModelArgs2(model) {
21337
21641
  if (model === void 0) return [];
21338
21642
  return [
@@ -21414,8 +21718,9 @@ async function dispatchAdmittedCollector(input) {
21414
21718
  PI_CODING_AGENT_DIR: env.agentDir,
21415
21719
  AK_ROLE_RUN_DIR: admitted.runDirectory
21416
21720
  };
21417
- if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
21418
- childEnv.AK_CORRELATION_ID = env.correlationId;
21721
+ const correlationId = admitted.correlationId ?? env.correlationId;
21722
+ if (correlationId !== void 0 && correlationId.trim() !== "") {
21723
+ childEnv.AK_CORRELATION_ID = correlationId;
21419
21724
  }
21420
21725
  let result2;
21421
21726
  try {
@@ -21442,8 +21747,8 @@ async function dispatchAdmittedCollector(input) {
21442
21747
  );
21443
21748
  }
21444
21749
  try {
21445
- await writeFile6(
21446
- join11(admitted.runDirectory, "stderr.log"),
21750
+ await writeFile7(
21751
+ join12(admitted.runDirectory, "stderr.log"),
21447
21752
  result2.stderr,
21448
21753
  "utf8"
21449
21754
  );
@@ -21488,7 +21793,8 @@ async function dispatchAdmittedCollector(input) {
21488
21793
  ...infrastructureFailure.identity === void 0 ? {} : { identity: infrastructureFailure.identity }
21489
21794
  }),
21490
21795
  sessionFile: admitted.sessionFile,
21491
- credential: credentialFailure
21796
+ credential: credentialFailure,
21797
+ runDirectory: admitted.runDirectory
21492
21798
  });
21493
21799
  return await presentControlledFailure2(
21494
21800
  admitted,
@@ -21543,7 +21849,10 @@ async function runPublicCollector(argv, env, io, parseCollectorArgv2) {
21543
21849
  });
21544
21850
  return await dispatchAdmittedCollector({
21545
21851
  admitted,
21546
- env,
21852
+ env: {
21853
+ ...env,
21854
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
21855
+ },
21547
21856
  io,
21548
21857
  extraArgs,
21549
21858
  lease
@@ -21563,8 +21872,8 @@ var init_collector_run = __esm({
21563
21872
  });
21564
21873
 
21565
21874
  // src/public-cli/doctor-run.ts
21566
- import { writeFile as writeFile7 } from "node:fs/promises";
21567
- import { join as join12 } from "node:path";
21875
+ import { writeFile as writeFile8 } from "node:fs/promises";
21876
+ import { join as join13 } from "node:path";
21568
21877
  function buildModelArgs3(model) {
21569
21878
  if (model === void 0) return [];
21570
21879
  return [
@@ -21668,8 +21977,8 @@ async function dispatchAdmittedDoctor(input) {
21668
21977
  );
21669
21978
  }
21670
21979
  try {
21671
- await writeFile7(
21672
- join12(admitted.runDirectory, "stderr.log"),
21980
+ await writeFile8(
21981
+ join13(admitted.runDirectory, "stderr.log"),
21673
21982
  result2.stderr,
21674
21983
  "utf8"
21675
21984
  );
@@ -21721,7 +22030,8 @@ async function dispatchAdmittedDoctor(input) {
21721
22030
  const knownFailure = await resolveAuditedRunnerKnownFailure({
21722
22031
  runner: result2.knownFailure,
21723
22032
  sessionFile: admitted.sessionFile,
21724
- credential: credentialFailure
22033
+ credential: credentialFailure,
22034
+ runDirectory: admitted.runDirectory
21725
22035
  });
21726
22036
  return await presentControlledFailure3(
21727
22037
  admitted,
@@ -21795,8 +22105,8 @@ var init_doctor_run = __esm({
21795
22105
  });
21796
22106
 
21797
22107
  // src/public-cli/fixer-run.ts
21798
- import { writeFile as writeFile8 } from "node:fs/promises";
21799
- import { join as join13 } from "node:path";
22108
+ import { writeFile as writeFile9 } from "node:fs/promises";
22109
+ import { join as join14 } from "node:path";
21800
22110
  function buildModelArgs4(model) {
21801
22111
  if (model === void 0) return [];
21802
22112
  return [
@@ -21879,17 +22189,25 @@ function buildFixerResumeActivationExtraArgs(admitted, options) {
21879
22189
  }
21880
22190
  async function presentControlledFailure4(admitted, failureInput, io) {
21881
22191
  const hasThrown = Object.hasOwn(failureInput, "thrown");
21882
- const session = !hasThrown && !failureInput.timedOut && failureInput.knownFailure === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
22192
+ const resumeObservation = await resolveControlledFailureResumeObservation({
22193
+ runDirectory: admitted.runDirectory,
22194
+ ...failureInput.typedHttpObservationSettled === true ? {
22195
+ typedHttpObservationSettled: true,
22196
+ ...failureInput.typedHttpObservation === void 0 ? {} : { typedHttpObservation: failureInput.typedHttpObservation }
22197
+ } : {}
22198
+ });
22199
+ const knownFailure = failureInput.knownFailure ?? resumeObservation.observationReadFailure;
22200
+ const session = !hasThrown && !failureInput.timedOut && knownFailure === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
21883
22201
  const failure = classifyPostAdmissionFailure({
21884
22202
  timedOut: failureInput.timedOut,
21885
22203
  code: failureInput.code,
21886
22204
  stderr: failureInput.stderr,
21887
22205
  ...hasThrown ? { thrown: failureInput.thrown } : {},
21888
- ...explicitInternalKnownFailureClassificationInput(failureInput.knownFailure),
22206
+ ...explicitInternalKnownFailureClassificationInput(knownFailure),
21889
22207
  ...session === void 0 ? {} : { session }
21890
22208
  });
21891
22209
  const hasLawfulTerminalResult = await hasLawfulFixerTerminalResult(admitted);
21892
- const typedHttp429 = await readTypedHttp429Observation(admitted.runDirectory);
22210
+ const typedHttp429 = resumeObservation.typedHttp429;
21893
22211
  const sessionPrincipalAvailable = await isSessionPrincipalAvailable(
21894
22212
  admitted.sessionFile
21895
22213
  );
@@ -21936,8 +22254,9 @@ async function dispatchAdmittedFixer(input) {
21936
22254
  PI_CODING_AGENT_DIR: env.agentDir,
21937
22255
  AK_ROLE_RUN_DIR: admitted.runDirectory
21938
22256
  };
21939
- if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
21940
- childEnv.AK_CORRELATION_ID = env.correlationId;
22257
+ const correlationId = admitted.correlationId ?? env.correlationId;
22258
+ if (correlationId !== void 0 && correlationId.trim() !== "") {
22259
+ childEnv.AK_CORRELATION_ID = correlationId;
21941
22260
  }
21942
22261
  let result2;
21943
22262
  try {
@@ -21964,8 +22283,8 @@ async function dispatchAdmittedFixer(input) {
21964
22283
  );
21965
22284
  }
21966
22285
  try {
21967
- await writeFile8(
21968
- join13(admitted.runDirectory, "stderr.log"),
22286
+ await writeFile9(
22287
+ join14(admitted.runDirectory, "stderr.log"),
21969
22288
  result2.stderr,
21970
22289
  "utf8"
21971
22290
  );
@@ -22021,10 +22340,11 @@ async function dispatchAdmittedFixer(input) {
22021
22340
  env.model,
22022
22341
  env.credentials
22023
22342
  );
22024
- const knownFailure = await resolveAuditedRunnerKnownFailure({
22343
+ const resolution = await resolveAuditedRunnerFailureResolution({
22025
22344
  runner: result2.knownFailure,
22026
22345
  sessionFile: admitted.sessionFile,
22027
- credential: credentialFailure
22346
+ credential: credentialFailure,
22347
+ runDirectory: admitted.runDirectory
22028
22348
  });
22029
22349
  return await presentControlledFailure4(
22030
22350
  admitted,
@@ -22032,7 +22352,7 @@ async function dispatchAdmittedFixer(input) {
22032
22352
  timedOut: result2.timedOut,
22033
22353
  code: result2.code,
22034
22354
  stderr: result2.stderr,
22035
- ...knownFailure === void 0 ? {} : { knownFailure }
22355
+ ...controlledFailureInputFromResolution(resolution)
22036
22356
  },
22037
22357
  io
22038
22358
  );
@@ -22098,7 +22418,10 @@ async function runPublicFixer(argv, env, io, parseFixerArgv2) {
22098
22418
  });
22099
22419
  return await dispatchAdmittedFixer({
22100
22420
  admitted,
22101
- env,
22421
+ env: {
22422
+ ...env,
22423
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
22424
+ },
22102
22425
  io,
22103
22426
  extraArgs,
22104
22427
  lease,
@@ -22165,7 +22488,10 @@ async function runPublicFixerResume(argv, env, io) {
22165
22488
  });
22166
22489
  return await dispatchAdmittedFixer({
22167
22490
  admitted,
22168
- env,
22491
+ env: {
22492
+ ...env,
22493
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
22494
+ },
22169
22495
  io,
22170
22496
  extraArgs,
22171
22497
  lease,
@@ -22187,8 +22513,8 @@ var init_fixer_run = __esm({
22187
22513
  });
22188
22514
 
22189
22515
  // src/public-cli/judge-run.ts
22190
- import { writeFile as writeFile9 } from "node:fs/promises";
22191
- import { join as join14 } from "node:path";
22516
+ import { writeFile as writeFile10 } from "node:fs/promises";
22517
+ import { join as join15 } from "node:path";
22192
22518
  function buildModelArgs5(model) {
22193
22519
  if (model === void 0) return [];
22194
22520
  return [
@@ -22242,17 +22568,25 @@ function buildJudgeResumeActivationExtraArgs(admitted, options = {}) {
22242
22568
  }
22243
22569
  async function presentControlledFailure5(admitted, failureInput, io) {
22244
22570
  const hasThrown = Object.hasOwn(failureInput, "thrown");
22245
- const session = !hasThrown && !failureInput.timedOut && failureInput.knownFailure === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
22571
+ const resumeObservation = await resolveControlledFailureResumeObservation({
22572
+ runDirectory: admitted.runDirectory,
22573
+ ...failureInput.typedHttpObservationSettled === true ? {
22574
+ typedHttpObservationSettled: true,
22575
+ ...failureInput.typedHttpObservation === void 0 ? {} : { typedHttpObservation: failureInput.typedHttpObservation }
22576
+ } : {}
22577
+ });
22578
+ const knownFailure = failureInput.knownFailure ?? resumeObservation.observationReadFailure;
22579
+ const session = !hasThrown && !failureInput.timedOut && knownFailure === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
22246
22580
  const failure = classifyPostAdmissionFailure({
22247
22581
  timedOut: failureInput.timedOut,
22248
22582
  code: failureInput.code,
22249
22583
  stderr: failureInput.stderr,
22250
22584
  ...hasThrown ? { thrown: failureInput.thrown } : {},
22251
- ...explicitInternalKnownFailureClassificationInput(failureInput.knownFailure),
22585
+ ...explicitInternalKnownFailureClassificationInput(knownFailure),
22252
22586
  ...session === void 0 ? {} : { session }
22253
22587
  });
22254
22588
  const hasLawfulTerminalResult = await hasLawfulJudgeTerminalResult(admitted);
22255
- const typedHttp429 = await readTypedHttp429Observation(admitted.runDirectory);
22589
+ const typedHttp429 = resumeObservation.typedHttp429;
22256
22590
  const sessionPrincipalAvailable = await isSessionPrincipalAvailable(
22257
22591
  admitted.sessionFile
22258
22592
  );
@@ -22301,8 +22635,9 @@ async function dispatchAdmittedJudge(input) {
22301
22635
  // and role-runtime can record typed provider HTTP observations.
22302
22636
  AK_ROLE_RUN_DIR: admitted.runDirectory
22303
22637
  };
22304
- if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
22305
- childEnv.AK_CORRELATION_ID = env.correlationId;
22638
+ const correlationId = admitted.correlationId ?? env.correlationId;
22639
+ if (correlationId !== void 0 && correlationId.trim() !== "") {
22640
+ childEnv.AK_CORRELATION_ID = correlationId;
22306
22641
  }
22307
22642
  let result2;
22308
22643
  try {
@@ -22329,8 +22664,8 @@ async function dispatchAdmittedJudge(input) {
22329
22664
  );
22330
22665
  }
22331
22666
  try {
22332
- await writeFile9(
22333
- join14(admitted.runDirectory, "stderr.log"),
22667
+ await writeFile10(
22668
+ join15(admitted.runDirectory, "stderr.log"),
22334
22669
  result2.stderr,
22335
22670
  "utf8"
22336
22671
  );
@@ -22379,10 +22714,11 @@ async function dispatchAdmittedJudge(input) {
22379
22714
  env.model,
22380
22715
  env.credentials
22381
22716
  );
22382
- const knownFailure = await resolveAuditedRunnerKnownFailure({
22717
+ const resolution = await resolveAuditedRunnerFailureResolution({
22383
22718
  runner: result2.knownFailure,
22384
22719
  sessionFile: admitted.sessionFile,
22385
- credential: credentialFailure
22720
+ credential: credentialFailure,
22721
+ runDirectory: admitted.runDirectory
22386
22722
  });
22387
22723
  return await presentControlledFailure5(
22388
22724
  admitted,
@@ -22390,7 +22726,7 @@ async function dispatchAdmittedJudge(input) {
22390
22726
  timedOut: result2.timedOut,
22391
22727
  code: result2.code,
22392
22728
  stderr: result2.stderr,
22393
- ...knownFailure === void 0 ? {} : { knownFailure }
22729
+ ...controlledFailureInputFromResolution(resolution)
22394
22730
  },
22395
22731
  io
22396
22732
  );
@@ -22434,7 +22770,10 @@ async function runPublicJudge(argv, env, io, parseJudgeArgv2) {
22434
22770
  });
22435
22771
  return await dispatchAdmittedJudge({
22436
22772
  admitted,
22437
- env,
22773
+ env: {
22774
+ ...env,
22775
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
22776
+ },
22438
22777
  io,
22439
22778
  extraArgs,
22440
22779
  lease
@@ -22483,7 +22822,10 @@ async function runPublicResume(argv, env, io) {
22483
22822
  });
22484
22823
  return await dispatchAdmittedJudge({
22485
22824
  admitted,
22486
- env,
22825
+ env: {
22826
+ ...env,
22827
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
22828
+ },
22487
22829
  io,
22488
22830
  extraArgs,
22489
22831
  lease
@@ -22503,8 +22845,8 @@ var init_judge_run = __esm({
22503
22845
  });
22504
22846
 
22505
22847
  // src/public-cli/merger-run.ts
22506
- import { mkdir as mkdir4, writeFile as writeFile10 } from "node:fs/promises";
22507
- import { join as join15, resolve as resolve7 } from "node:path";
22848
+ import { mkdir as mkdir4, writeFile as writeFile11 } from "node:fs/promises";
22849
+ import { join as join16, resolve as resolve7 } from "node:path";
22508
22850
  function buildModelArgs6(model) {
22509
22851
  if (model === void 0) return [];
22510
22852
  return [
@@ -22573,20 +22915,28 @@ function buildMergerResumeActivationExtraArgs(admitted, options) {
22573
22915
  }
22574
22916
  async function presentControlledFailure6(admitted, failureInput, io) {
22575
22917
  const hasThrown = Object.hasOwn(failureInput, "thrown");
22576
- const session = !hasThrown && !failureInput.timedOut && failureInput.knownFailure === void 0 && failureInput.knownCause === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
22918
+ const resumeObservation = await resolveControlledFailureResumeObservation({
22919
+ runDirectory: admitted.runDirectory,
22920
+ ...failureInput.typedHttpObservationSettled === true ? {
22921
+ typedHttpObservationSettled: true,
22922
+ ...failureInput.typedHttpObservation === void 0 ? {} : { typedHttpObservation: failureInput.typedHttpObservation }
22923
+ } : {}
22924
+ });
22925
+ const knownFailure = failureInput.knownFailure ?? resumeObservation.observationReadFailure;
22926
+ const session = !hasThrown && !failureInput.timedOut && knownFailure === void 0 && failureInput.knownCause === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
22577
22927
  const failure = classifyPostAdmissionFailure({
22578
22928
  timedOut: failureInput.timedOut,
22579
22929
  code: failureInput.code,
22580
22930
  stderr: failureInput.stderr,
22581
22931
  ...hasThrown ? { thrown: failureInput.thrown } : {},
22582
- ...explicitInternalKnownFailureClassificationInput(failureInput.knownFailure),
22932
+ ...explicitInternalKnownFailureClassificationInput(knownFailure),
22583
22933
  ...failureInput.knownCause === void 0 ? {} : { knownCause: failureInput.knownCause },
22584
22934
  ...failureInput.knownIdentity === void 0 ? {} : { knownIdentity: failureInput.knownIdentity },
22585
22935
  ...failureInput.knownDiagnostic === void 0 ? {} : { knownDiagnostic: failureInput.knownDiagnostic },
22586
22936
  ...session === void 0 ? {} : { session }
22587
22937
  });
22588
22938
  const hasLawfulTerminalResult = await hasLawfulMergerTerminalResult(admitted);
22589
- const typedHttp429 = await readTypedHttp429Observation(admitted.runDirectory);
22939
+ const typedHttp429 = resumeObservation.typedHttp429;
22590
22940
  const sessionPrincipalAvailable = await isSessionPrincipalAvailable(
22591
22941
  admitted.sessionFile
22592
22942
  );
@@ -22633,8 +22983,9 @@ async function dispatchAdmittedMerger(input) {
22633
22983
  PI_CODING_AGENT_DIR: env.agentDir,
22634
22984
  AK_ROLE_RUN_DIR: admitted.runDirectory
22635
22985
  };
22636
- if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
22637
- childEnv.AK_CORRELATION_ID = env.correlationId;
22986
+ const correlationId = admitted.correlationId ?? env.correlationId;
22987
+ if (correlationId !== void 0 && correlationId.trim() !== "") {
22988
+ childEnv.AK_CORRELATION_ID = correlationId;
22638
22989
  }
22639
22990
  let result2;
22640
22991
  try {
@@ -22661,8 +23012,8 @@ async function dispatchAdmittedMerger(input) {
22661
23012
  );
22662
23013
  }
22663
23014
  try {
22664
- await writeFile10(
22665
- join15(admitted.runDirectory, "stderr.log"),
23015
+ await writeFile11(
23016
+ join16(admitted.runDirectory, "stderr.log"),
22666
23017
  result2.stderr,
22667
23018
  "utf8"
22668
23019
  );
@@ -22704,10 +23055,11 @@ async function dispatchAdmittedMerger(input) {
22704
23055
  env.model,
22705
23056
  env.credentials
22706
23057
  );
22707
- const knownFailure = await resolveAuditedRunnerKnownFailure({
23058
+ const resolution = await resolveAuditedRunnerFailureResolution({
22708
23059
  runner: result2.knownFailure,
22709
23060
  sessionFile: admitted.sessionFile,
22710
- credential: credentialFailure
23061
+ credential: credentialFailure,
23062
+ runDirectory: admitted.runDirectory
22711
23063
  });
22712
23064
  return await presentControlledFailure6(
22713
23065
  admitted,
@@ -22715,7 +23067,7 @@ async function dispatchAdmittedMerger(input) {
22715
23067
  timedOut: result2.timedOut,
22716
23068
  code: result2.code,
22717
23069
  stderr: result2.stderr,
22718
- ...knownFailure === void 0 ? {} : { knownFailure }
23070
+ ...controlledFailureInputFromResolution(resolution)
22719
23071
  },
22720
23072
  io
22721
23073
  );
@@ -22742,9 +23094,9 @@ async function admitMergerShellForActivationFailure(options) {
22742
23094
  expectedConflictPaths: [],
22743
23095
  resolutionScope: []
22744
23096
  };
22745
- const admittedRequestPath = join15(runDirectory, "admitted-request.json");
22746
- const mergerInputPath = join15(runDirectory, "merger-input.json");
22747
- await writeFile10(
23097
+ const admittedRequestPath = join16(runDirectory, "admitted-request.json");
23098
+ const mergerInputPath = join16(runDirectory, "merger-input.json");
23099
+ await writeFile11(
22748
23100
  admittedRequestPath,
22749
23101
  `${JSON.stringify(
22750
23102
  {
@@ -22865,7 +23217,10 @@ async function runPublicMerger(argv, env, io, parseMergerArgv2) {
22865
23217
  });
22866
23218
  return await dispatchAdmittedMerger({
22867
23219
  admitted,
22868
- env,
23220
+ env: {
23221
+ ...env,
23222
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
23223
+ },
22869
23224
  io,
22870
23225
  extraArgs,
22871
23226
  lease,
@@ -22933,7 +23288,10 @@ async function runPublicMergerResume(argv, env, io) {
22933
23288
  });
22934
23289
  return await dispatchAdmittedMerger({
22935
23290
  admitted,
22936
- env,
23291
+ env: {
23292
+ ...env,
23293
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
23294
+ },
22937
23295
  io,
22938
23296
  extraArgs,
22939
23297
  lease,
@@ -22958,8 +23316,8 @@ var init_merger_run = __esm({
22958
23316
  });
22959
23317
 
22960
23318
  // src/public-cli/reviewer-run.ts
22961
- import { writeFile as writeFile11 } from "node:fs/promises";
22962
- import { join as join16 } from "node:path";
23319
+ import { writeFile as writeFile12 } from "node:fs/promises";
23320
+ import { join as join17 } from "node:path";
22963
23321
  function buildModelArgs7(model) {
22964
23322
  if (model === void 0) return [];
22965
23323
  return [
@@ -23028,17 +23386,25 @@ function buildReviewerResumeActivationExtraArgs(admitted, options) {
23028
23386
  }
23029
23387
  async function presentControlledFailure7(admitted, failureInput, io) {
23030
23388
  const hasThrown = Object.hasOwn(failureInput, "thrown");
23031
- const session = !hasThrown && !failureInput.timedOut && failureInput.knownFailure === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
23389
+ const resumeObservation = await resolveControlledFailureResumeObservation({
23390
+ runDirectory: admitted.runDirectory,
23391
+ ...failureInput.typedHttpObservationSettled === true ? {
23392
+ typedHttpObservationSettled: true,
23393
+ ...failureInput.typedHttpObservation === void 0 ? {} : { typedHttpObservation: failureInput.typedHttpObservation }
23394
+ } : {}
23395
+ });
23396
+ const knownFailure = failureInput.knownFailure ?? resumeObservation.observationReadFailure;
23397
+ const session = !hasThrown && !failureInput.timedOut && knownFailure === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
23032
23398
  const failure = classifyPostAdmissionFailure({
23033
23399
  timedOut: failureInput.timedOut,
23034
23400
  code: failureInput.code,
23035
23401
  stderr: failureInput.stderr,
23036
23402
  ...hasThrown ? { thrown: failureInput.thrown } : {},
23037
- ...explicitInternalKnownFailureClassificationInput(failureInput.knownFailure),
23403
+ ...explicitInternalKnownFailureClassificationInput(knownFailure),
23038
23404
  ...session === void 0 ? {} : { session }
23039
23405
  });
23040
23406
  const hasLawfulTerminalResult = await hasLawfulReviewerTerminalResult(admitted);
23041
- const typedHttp429 = await readTypedHttp429Observation(admitted.runDirectory);
23407
+ const typedHttp429 = resumeObservation.typedHttp429;
23042
23408
  const sessionPrincipalAvailable = await isSessionPrincipalAvailable(
23043
23409
  admitted.sessionFile
23044
23410
  );
@@ -23086,8 +23452,9 @@ async function dispatchAdmittedReviewer(input) {
23086
23452
  PI_CODING_AGENT_DIR: env.agentDir,
23087
23453
  AK_ROLE_RUN_DIR: admitted.runDirectory
23088
23454
  };
23089
- if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
23090
- childEnv.AK_CORRELATION_ID = env.correlationId;
23455
+ const correlationId = admitted.correlationId ?? env.correlationId;
23456
+ if (correlationId !== void 0 && correlationId.trim() !== "") {
23457
+ childEnv.AK_CORRELATION_ID = correlationId;
23091
23458
  }
23092
23459
  let result2;
23093
23460
  try {
@@ -23114,8 +23481,8 @@ async function dispatchAdmittedReviewer(input) {
23114
23481
  );
23115
23482
  }
23116
23483
  try {
23117
- await writeFile11(
23118
- join16(admitted.runDirectory, "stderr.log"),
23484
+ await writeFile12(
23485
+ join17(admitted.runDirectory, "stderr.log"),
23119
23486
  result2.stderr,
23120
23487
  "utf8"
23121
23488
  );
@@ -23171,7 +23538,7 @@ async function dispatchAdmittedReviewer(input) {
23171
23538
  env.model,
23172
23539
  env.credentials
23173
23540
  );
23174
- const knownFailure = await resolveAuditedRunnerKnownFailure({
23541
+ const resolution = await resolveAuditedRunnerFailureResolution({
23175
23542
  runner: result2.knownFailure,
23176
23543
  sessionFile: admitted.sessionFile,
23177
23544
  credential: credentialFailure,
@@ -23183,7 +23550,7 @@ async function dispatchAdmittedReviewer(input) {
23183
23550
  timedOut: result2.timedOut,
23184
23551
  code: result2.code,
23185
23552
  stderr: result2.stderr,
23186
- ...knownFailure === void 0 ? {} : { knownFailure }
23553
+ ...controlledFailureInputFromResolution(resolution)
23187
23554
  },
23188
23555
  io
23189
23556
  );
@@ -23248,7 +23615,10 @@ async function runPublicReviewer(argv, env, io, parseReviewerArgv2) {
23248
23615
  });
23249
23616
  return await dispatchAdmittedReviewer({
23250
23617
  admitted,
23251
- env,
23618
+ env: {
23619
+ ...env,
23620
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
23621
+ },
23252
23622
  io,
23253
23623
  extraArgs,
23254
23624
  lease,
@@ -23315,7 +23685,10 @@ async function runPublicReviewerResume(argv, env, io) {
23315
23685
  });
23316
23686
  return await dispatchAdmittedReviewer({
23317
23687
  admitted,
23318
- env,
23688
+ env: {
23689
+ ...env,
23690
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
23691
+ },
23319
23692
  io,
23320
23693
  extraArgs,
23321
23694
  lease,
@@ -23340,6 +23713,7 @@ var init_reviewer_run = __esm({
23340
23713
  var cli_exports = {};
23341
23714
  __export(cli_exports, {
23342
23715
  CliUsageError: () => CliUsageError,
23716
+ PUBLIC_ROLE_ARGV: () => PUBLIC_ROLE_ARGV,
23343
23717
  buildExplicitInternalActivationArgs: () => buildExplicitInternalActivationArgs,
23344
23718
  helpDocument: () => helpDocument,
23345
23719
  resolveInternalRoleEntrypoint: () => resolveInternalRoleEntrypoint,
@@ -23347,7 +23721,43 @@ __export(cli_exports, {
23347
23721
  });
23348
23722
  import { realpath as realpath5 } from "node:fs/promises";
23349
23723
  import { homedir as homedir3 } from "node:os";
23350
- import { join as join17 } from "node:path";
23724
+ import { join as join18 } from "node:path";
23725
+ function takePublicGlobalFlag(argv, index) {
23726
+ const token = argv[index];
23727
+ if (token === void 0) return void 0;
23728
+ if (token === "--help" || token === "-h") {
23729
+ return { flag: "help", consume: 1 };
23730
+ }
23731
+ if (token === "--model") {
23732
+ const value = argv[index + 1];
23733
+ if (value === void 0) {
23734
+ return { flag: "model", consume: 1, value: void 0 };
23735
+ }
23736
+ return { flag: "model", consume: 2, value };
23737
+ }
23738
+ if (token.startsWith("--model=")) {
23739
+ return {
23740
+ flag: "model",
23741
+ consume: 1,
23742
+ value: token.slice("--model=".length)
23743
+ };
23744
+ }
23745
+ if (token === "--thinking") {
23746
+ const raw = argv[index + 1];
23747
+ if (raw === void 0) {
23748
+ return { flag: "thinking", consume: 1, raw: void 0 };
23749
+ }
23750
+ return { flag: "thinking", consume: 2, raw };
23751
+ }
23752
+ if (token.startsWith("--thinking=")) {
23753
+ return {
23754
+ flag: "thinking",
23755
+ consume: 1,
23756
+ raw: token.slice("--thinking=".length)
23757
+ };
23758
+ }
23759
+ return void 0;
23760
+ }
23351
23761
  function defaultIo() {
23352
23762
  return {
23353
23763
  stdout: (text) => {
@@ -23362,7 +23772,7 @@ function resolveHome(env) {
23362
23772
  return env.home ?? process.env.HOME ?? homedir3();
23363
23773
  }
23364
23774
  function resolveAgentDir(env, home) {
23365
- return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join17(home, ".pi", "agent");
23775
+ return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join18(home, ".pi", "agent");
23366
23776
  }
23367
23777
  function parseThinking(value) {
23368
23778
  if (!THINKING_LEVELS2.has(value)) {
@@ -23377,40 +23787,34 @@ function parseArgv(argv) {
23377
23787
  let help = false;
23378
23788
  const positional = [];
23379
23789
  while (args.length > 0) {
23380
- const token = args.shift();
23381
- if (token === "--") {
23790
+ if (args[0] === "--") {
23791
+ args.shift();
23382
23792
  positional.push(...args);
23383
23793
  break;
23384
23794
  }
23385
- if (token === "--help" || token === "-h") {
23386
- help = true;
23387
- continue;
23388
- }
23389
- if (token === "--model") {
23390
- const value = args.shift();
23391
- if (value === void 0) throw new CliUsageError("--model requires a value");
23392
- model = value;
23393
- continue;
23394
- }
23395
- if (token.startsWith("--model=")) {
23396
- model = token.slice("--model=".length);
23397
- continue;
23398
- }
23399
- if (token === "--thinking") {
23400
- const value = args.shift();
23401
- if (value === void 0) throw new CliUsageError("--thinking requires a value");
23402
- thinking = parseThinking(value);
23403
- continue;
23404
- }
23405
- if (token.startsWith("--thinking=")) {
23406
- thinking = parseThinking(token.slice("--thinking=".length));
23407
- continue;
23408
- }
23409
- if (token.startsWith("-") && token !== "-") {
23410
- positional.push(token);
23795
+ const taken = takePublicGlobalFlag(args, 0);
23796
+ if (taken !== void 0) {
23797
+ if (taken.flag === "help") {
23798
+ help = true;
23799
+ args.splice(0, taken.consume);
23800
+ continue;
23801
+ }
23802
+ if (taken.flag === "model") {
23803
+ if (taken.value === void 0) {
23804
+ throw new CliUsageError("--model requires a value");
23805
+ }
23806
+ model = taken.value;
23807
+ args.splice(0, taken.consume);
23808
+ continue;
23809
+ }
23810
+ if (taken.raw === void 0) {
23811
+ throw new CliUsageError("--thinking requires a value");
23812
+ }
23813
+ thinking = parseThinking(taken.raw);
23814
+ args.splice(0, taken.consume);
23411
23815
  continue;
23412
23816
  }
23413
- positional.push(token);
23817
+ positional.push(args.shift());
23414
23818
  }
23415
23819
  const [command, ...rest] = positional;
23416
23820
  return {
@@ -23743,7 +24147,7 @@ async function runAkRole(argv, env) {
23743
24147
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
23744
24148
  },
23745
24149
  io,
23746
- parseJudgeArgv
24150
+ PUBLIC_ROLE_ARGV.judge.parse
23747
24151
  );
23748
24152
  return {
23749
24153
  exitCode: result2.exitCode,
@@ -23777,7 +24181,7 @@ async function runAkRole(argv, env) {
23777
24181
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
23778
24182
  },
23779
24183
  io,
23780
- parseCoderArgv
24184
+ PUBLIC_ROLE_ARGV.coder.parse
23781
24185
  );
23782
24186
  return {
23783
24187
  exitCode: result2.exitCode,
@@ -23811,7 +24215,7 @@ async function runAkRole(argv, env) {
23811
24215
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
23812
24216
  },
23813
24217
  io,
23814
- parseFixerArgv
24218
+ PUBLIC_ROLE_ARGV.fixer.parse
23815
24219
  );
23816
24220
  return {
23817
24221
  exitCode: result2.exitCode,
@@ -23845,7 +24249,7 @@ async function runAkRole(argv, env) {
23845
24249
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
23846
24250
  },
23847
24251
  io,
23848
- parseCollectorArgv
24252
+ PUBLIC_ROLE_ARGV.collector.parse
23849
24253
  );
23850
24254
  return {
23851
24255
  exitCode: result2.exitCode,
@@ -23879,7 +24283,7 @@ async function runAkRole(argv, env) {
23879
24283
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
23880
24284
  },
23881
24285
  io,
23882
- parseReviewerArgv
24286
+ PUBLIC_ROLE_ARGV.reviewer.parse
23883
24287
  );
23884
24288
  return {
23885
24289
  exitCode: result2.exitCode,
@@ -23913,7 +24317,7 @@ async function runAkRole(argv, env) {
23913
24317
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
23914
24318
  },
23915
24319
  io,
23916
- parseDoctorArgv
24320
+ PUBLIC_ROLE_ARGV.doctor.parse
23917
24321
  );
23918
24322
  return {
23919
24323
  exitCode: result2.exitCode,
@@ -23947,7 +24351,7 @@ async function runAkRole(argv, env) {
23947
24351
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
23948
24352
  },
23949
24353
  io,
23950
- parseMergerArgv
24354
+ PUBLIC_ROLE_ARGV.merger.parse
23951
24355
  );
23952
24356
  return {
23953
24357
  exitCode: result2.exitCode,
@@ -23969,7 +24373,7 @@ async function runAkRole(argv, env) {
23969
24373
  return { exitCode: 1 };
23970
24374
  }
23971
24375
  }
23972
- var THINKING_LEVELS2;
24376
+ var PUBLIC_ROLE_ARGV, THINKING_LEVELS2;
23973
24377
  var init_cli = __esm({
23974
24378
  "src/public-cli/cli.ts"() {
23975
24379
  "use strict";
@@ -23989,6 +24393,15 @@ var init_cli = __esm({
23989
24393
  init_settlement();
23990
24394
  init_explicit_internal();
23991
24395
  init_cli_errors();
24396
+ PUBLIC_ROLE_ARGV = {
24397
+ judge: { parse: parseJudgeArgv },
24398
+ coder: { parse: parseCoderArgv },
24399
+ fixer: { parse: parseFixerArgv },
24400
+ collector: { parse: parseCollectorArgv },
24401
+ doctor: { parse: parseDoctorArgv },
24402
+ merger: { parse: parseMergerArgv },
24403
+ reviewer: { parse: parseReviewerArgv }
24404
+ };
23992
24405
  THINKING_LEVELS2 = /* @__PURE__ */ new Set([
23993
24406
  "off",
23994
24407
  "minimal",
@@ -24002,7 +24415,7 @@ var init_cli = __esm({
24002
24415
  });
24003
24416
 
24004
24417
  // src/public-cli/main.ts
24005
- import { dirname as dirname7, join as join18 } from "node:path";
24418
+ import { dirname as dirname7, join as join19 } from "node:path";
24006
24419
  import { fileURLToPath as fileURLToPath2 } from "node:url";
24007
24420
 
24008
24421
  // src/public-cli/host-pi-runtime.ts
@@ -24090,7 +24503,7 @@ function linkPackage(packageRoot2, name, targetDir) {
24090
24503
 
24091
24504
  // src/public-cli/main.ts
24092
24505
  var here = dirname7(fileURLToPath2(import.meta.url));
24093
- var packageRoot = join18(here, "..", "..");
24506
+ var packageRoot = join19(here, "..", "..");
24094
24507
  ensureHostPiRuntimeResolvable(packageRoot);
24095
24508
  var { runAkRole: runAkRole2 } = await Promise.resolve().then(() => (init_cli(), cli_exports));
24096
24509
  var result = await runAkRole2(process.argv.slice(2), { packageRoot });