@akagilnc/pi-workflow-roles 0.1.1883 → 0.1.1893

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.
@@ -16779,6 +16779,27 @@ var init_reviewer_dispatch = __esm({
16779
16779
  }
16780
16780
  });
16781
16781
 
16782
+ // src/upstream-error-testimony.ts
16783
+ function isNonSuccessHttpStatus(status) {
16784
+ return typeof status === "number" && (status < 200 || status >= 300);
16785
+ }
16786
+ function hasUpstreamErrorTestimony(input) {
16787
+ if (isNonSuccessHttpStatus(input.httpStatus)) return true;
16788
+ return Array.isArray(input.diagnostics) && input.diagnostics.length > 0;
16789
+ }
16790
+ function projectConfirmedRemotePayload(input) {
16791
+ return {
16792
+ ...input.body === void 0 ? {} : { body: input.body },
16793
+ ...input.code === void 0 ? {} : { code: input.code },
16794
+ ...input.errno === void 0 ? {} : { errno: input.errno }
16795
+ };
16796
+ }
16797
+ var init_upstream_error_testimony = __esm({
16798
+ "src/upstream-error-testimony.ts"() {
16799
+ "use strict";
16800
+ }
16801
+ });
16802
+
16782
16803
  // src/public-cli/explicit-internal.ts
16783
16804
  import { execFile as execFile3, spawn } from "node:child_process";
16784
16805
  import { constants, writeFileSync } from "node:fs";
@@ -16837,21 +16858,37 @@ function resolveInternalRoleEntrypoint(packageRoot2) {
16837
16858
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
16838
16859
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
16839
16860
  }
16861
+ function nonEmptyString(value) {
16862
+ return typeof value === "string" && value.trim() !== "" ? value : void 0;
16863
+ }
16864
+ function sessionStopDetails(input) {
16865
+ const details = {};
16866
+ const errorMessage = nonEmptyString(input.errorMessage);
16867
+ if (errorMessage !== void 0) details.errorMessage = errorMessage;
16868
+ const api = nonEmptyString(input.api);
16869
+ if (api !== void 0) details.api = api;
16870
+ const rawStopReason = nonEmptyString(input.rawStopReason);
16871
+ if (rawStopReason !== void 0) details.rawStopReason = rawStopReason;
16872
+ const testimony = hasUpstreamErrorTestimony(input);
16873
+ if (testimony) {
16874
+ const provider = nonEmptyString(input.provider);
16875
+ if (provider !== void 0) details.provider = provider;
16876
+ const model = nonEmptyString(input.model);
16877
+ if (model !== void 0) details.model = model;
16878
+ }
16879
+ if (typeof input.httpStatus === "number") details.httpStatus = input.httpStatus;
16880
+ if (input.diagnostics !== void 0) details.diagnostics = input.diagnostics;
16881
+ if (testimony) Object.assign(details, projectConfirmedRemotePayload(input));
16882
+ return details;
16883
+ }
16840
16884
  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
- }
16885
+ if (input.stopReason !== "error" && input.stopReason !== "aborted") return void 0;
16886
+ const diagnostic = nonEmptyString(input.errorMessage);
16887
+ const details = sessionStopDetails(input);
16851
16888
  return {
16852
- cause: "provider",
16853
- identity,
16854
- diagnostic
16889
+ cause: hasUpstreamErrorTestimony(input) ? "provider" : "unrecognized",
16890
+ ...diagnostic === void 0 ? {} : { diagnostic },
16891
+ ...Object.keys(details).length === 0 ? {} : { details }
16855
16892
  };
16856
16893
  }
16857
16894
  async function resolveSelectedPi(command, cwd, env) {
@@ -16915,6 +16952,8 @@ var init_explicit_internal = __esm({
16915
16952
  init_invocation();
16916
16953
  init_registry2();
16917
16954
  init_reviewer_dispatch();
16955
+ init_upstream_error_testimony();
16956
+ init_upstream_error_testimony();
16918
16957
  REVIEWER_DISPATCH_REJECTION_FILE = "typed-known-failure.json";
16919
16958
  execFileAsync3 = promisify3(execFile3);
16920
16959
  defaultExplicitInternalPiRunner = async (args, options) => {
@@ -17237,12 +17276,9 @@ var init_public_run_credentials = __esm({
17237
17276
  }
17238
17277
  });
17239
17278
 
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";
17279
+ // src/typed-provider-http.ts
17280
+ import { readFile as readFile7, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
17242
17281
  import { join as join8 } from "node:path";
17243
- function isV1ResumableProvider(provider) {
17244
- return V1_RESUMABLE_PROVIDERS.includes(provider);
17245
- }
17246
17282
  function typedProviderHttpPath(runDirectory) {
17247
17283
  return join8(runDirectory, TYPED_HTTP_FILE);
17248
17284
  }
@@ -17256,22 +17292,49 @@ async function clearTypedProviderHttpObservation(runDirectory) {
17256
17292
  throw error;
17257
17293
  }
17258
17294
  }
17259
- async function readTypedHttp429Observation(runDirectory) {
17295
+ async function readLatestTypedProviderHttpObservation(runDirectory) {
17296
+ let text;
17260
17297
  try {
17261
- const raw = JSON.parse(
17262
- await readFile7(typedProviderHttpPath(runDirectory), "utf8")
17263
- );
17264
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
17298
+ text = await readFile7(typedProviderHttpPath(runDirectory), "utf8");
17299
+ } catch (error) {
17300
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") {
17265
17301
  return void 0;
17266
17302
  }
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;
17303
+ throw error;
17304
+ }
17305
+ const raw = JSON.parse(text);
17306
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
17307
+ throw new Error("typed provider HTTP observation must be a JSON object");
17274
17308
  }
17309
+ const record4 = raw;
17310
+ if (typeof record4.httpStatus !== "number") {
17311
+ throw new Error("typed provider HTTP observation missing numeric httpStatus");
17312
+ }
17313
+ if (typeof record4.provider !== "string" || record4.provider.trim() === "") {
17314
+ throw new Error("typed provider HTTP observation missing non-empty provider");
17315
+ }
17316
+ return { httpStatus: record4.httpStatus, provider: record4.provider };
17317
+ }
17318
+ var TYPED_HTTP_FILE;
17319
+ var init_typed_provider_http = __esm({
17320
+ "src/typed-provider-http.ts"() {
17321
+ "use strict";
17322
+ TYPED_HTTP_FILE = "typed-provider-http.json";
17323
+ }
17324
+ });
17325
+
17326
+ // src/public-cli/run-lifecycle.ts
17327
+ import { lstat as lstat2, open, readdir as readdir2, readFile as readFile8, unlink as unlink3, writeFile as writeFile4 } from "node:fs/promises";
17328
+ import { join as join9 } from "node:path";
17329
+ function isV1ResumableProvider(provider) {
17330
+ return V1_RESUMABLE_PROVIDERS.includes(provider);
17331
+ }
17332
+ async function readTypedHttp429Observation(runDirectory) {
17333
+ const observation = await readLatestTypedProviderHttpObservation(runDirectory);
17334
+ if (observation === void 0) return void 0;
17335
+ if (observation.httpStatus !== 429) return void 0;
17336
+ if (!isV1ResumableProvider(observation.provider)) return void 0;
17337
+ return { httpStatus: 429, provider: observation.provider };
17275
17338
  }
17276
17339
  function isV1ResumableFailure(input) {
17277
17340
  if (input.hasLawfulTerminalResult) return false;
@@ -17282,8 +17345,8 @@ function renderResumeCommand(runId) {
17282
17345
  }
17283
17346
  async function writeRoleRunState(runDirectory, record4) {
17284
17347
  const payload = { ...record4, runDirectory };
17285
- await writeFile3(
17286
- join8(runDirectory, RUN_STATE_FILE),
17348
+ await writeFile4(
17349
+ join9(runDirectory, RUN_STATE_FILE),
17287
17350
  `${JSON.stringify(payload, null, 2)}
17288
17351
  `,
17289
17352
  "utf8"
@@ -17292,7 +17355,7 @@ async function writeRoleRunState(runDirectory, record4) {
17292
17355
  async function readRoleRunState(runDirectory) {
17293
17356
  let raw;
17294
17357
  try {
17295
- raw = JSON.parse(await readFile7(join8(runDirectory, RUN_STATE_FILE), "utf8"));
17358
+ raw = JSON.parse(await readFile8(join9(runDirectory, RUN_STATE_FILE), "utf8"));
17296
17359
  } catch {
17297
17360
  return void 0;
17298
17361
  }
@@ -17314,7 +17377,7 @@ async function readRoleRunState(runDirectory) {
17314
17377
  if (typeof record4.sessionDirectory !== "string") return void 0;
17315
17378
  if (typeof record4.admittedRequestPath !== "string") return void 0;
17316
17379
  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");
17380
+ const sessionFile = typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : join9(record4.sessionDirectory, "session.jsonl");
17318
17381
  let resumable;
17319
17382
  if (record4.resumable !== void 0 && record4.resumable !== null) {
17320
17383
  if (typeof record4.resumable === "object" && !Array.isArray(record4.resumable)) {
@@ -17407,7 +17470,7 @@ async function isSessionPrincipalAvailable(sessionFile) {
17407
17470
  }
17408
17471
  }
17409
17472
  async function acquireRunWriterLease(runDirectory) {
17410
- const lockPath = join8(runDirectory, WRITER_LOCK_FILE);
17473
+ const lockPath = join9(runDirectory, WRITER_LOCK_FILE);
17411
17474
  try {
17412
17475
  const handle = await open(lockPath, "wx");
17413
17476
  try {
@@ -17415,7 +17478,7 @@ async function acquireRunWriterLease(runDirectory) {
17415
17478
  `, "utf8");
17416
17479
  } catch (error) {
17417
17480
  await handle.close().catch(() => void 0);
17418
- await unlink2(lockPath).catch(() => void 0);
17481
+ await unlink3(lockPath).catch(() => void 0);
17419
17482
  throw error;
17420
17483
  }
17421
17484
  let released = false;
@@ -17425,7 +17488,7 @@ async function acquireRunWriterLease(runDirectory) {
17425
17488
  if (released) return;
17426
17489
  released = true;
17427
17490
  await handle.close().catch(() => void 0);
17428
- await unlink2(lockPath).catch(() => void 0);
17491
+ await unlink3(lockPath).catch(() => void 0);
17429
17492
  }
17430
17493
  };
17431
17494
  } catch (error) {
@@ -17438,7 +17501,7 @@ async function acquireRunWriterLease(runDirectory) {
17438
17501
  async function findRunDirectoryById(home, runId) {
17439
17502
  if (runId.trim() === "") return void 0;
17440
17503
  const ledgerHome = resolveActivationLedgerHome(() => home);
17441
- const booksRoot = join8(ledgerHome, "books");
17504
+ const booksRoot = join9(ledgerHome, "books");
17442
17505
  let bookKeys;
17443
17506
  try {
17444
17507
  bookKeys = await readdir2(booksRoot);
@@ -17446,7 +17509,7 @@ async function findRunDirectoryById(home, runId) {
17446
17509
  return void 0;
17447
17510
  }
17448
17511
  for (const bookKey of bookKeys) {
17449
- const runsDir = join8(activationBookDirectory(ledgerHome, bookKey), "runs");
17512
+ const runsDir = join9(activationBookDirectory(ledgerHome, bookKey), "runs");
17450
17513
  let entries;
17451
17514
  try {
17452
17515
  entries = await readdir2(runsDir);
@@ -17455,7 +17518,7 @@ async function findRunDirectoryById(home, runId) {
17455
17518
  }
17456
17519
  for (const entry of entries) {
17457
17520
  if (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) {
17458
- return join8(runsDir, entry);
17521
+ return join9(runsDir, entry);
17459
17522
  }
17460
17523
  }
17461
17524
  }
@@ -17494,7 +17557,7 @@ async function loadResumableRunRecord(home, runId) {
17494
17557
  let derived;
17495
17558
  try {
17496
17559
  const raw = JSON.parse(
17497
- await readFile7(run.admittedRequestPath, "utf8")
17560
+ await readFile8(run.admittedRequestPath, "utf8")
17498
17561
  );
17499
17562
  if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
17500
17563
  const record4 = raw;
@@ -17767,17 +17830,18 @@ async function peekRoleRunRole(home, runId) {
17767
17830
  const run = await readRoleRunState(runDirectory);
17768
17831
  return run?.role;
17769
17832
  }
17770
- var V1_RESUMABLE_PROVIDERS, RESUME_TRANSPORT_ENVELOPE, RUN_STATE_FILE, TYPED_HTTP_FILE, WRITER_LOCK_FILE, RunWriterLeaseHeldError;
17833
+ var V1_RESUMABLE_PROVIDERS, RESUME_TRANSPORT_ENVELOPE, RUN_STATE_FILE, WRITER_LOCK_FILE, RunWriterLeaseHeldError;
17771
17834
  var init_run_lifecycle = __esm({
17772
17835
  "src/public-cli/run-lifecycle.ts"() {
17773
17836
  "use strict";
17774
17837
  init_activation_ledger_topology();
17775
17838
  init_cli_errors();
17839
+ init_typed_provider_http();
17840
+ init_typed_provider_http();
17776
17841
  init_invocation();
17777
17842
  V1_RESUMABLE_PROVIDERS = ["openai-codex", "xai"];
17778
17843
  RESUME_TRANSPORT_ENVELOPE = "[ak-role:resume-continue]";
17779
17844
  RUN_STATE_FILE = "run-state.json";
17780
- TYPED_HTTP_FILE = "typed-provider-http.json";
17781
17845
  WRITER_LOCK_FILE = "writer.lock";
17782
17846
  RunWriterLeaseHeldError = class extends Error {
17783
17847
  code = "AK_RUN_WRITER_LEASE_HELD";
@@ -17911,6 +17975,7 @@ var init_evidence_child_executor = __esm({
17911
17975
  init_package_owned_tool_idle();
17912
17976
  init_stream_idle_guard();
17913
17977
  init_receipt_delivery_policy();
17978
+ init_upstream_error_testimony();
17914
17979
  }
17915
17980
  });
17916
17981
 
@@ -18431,8 +18496,8 @@ var init_terminal = __esm({
18431
18496
 
18432
18497
  // src/public-cli/settlement.ts
18433
18498
  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";
18499
+ import { lstat as lstat3, mkdir as mkdir3, open as open2, readFile as readFile9, readdir as readdir3, writeFile as writeFile5 } from "node:fs/promises";
18500
+ import { dirname as dirname6, join as join10 } from "node:path";
18436
18501
  function isChildDiagnosticFloodLine(line2) {
18437
18502
  if (/^at\s+/.test(line2)) return true;
18438
18503
  if (line2.startsWith("event:")) return true;
@@ -18487,7 +18552,7 @@ function presentStructuralRejection(error, io) {
18487
18552
  }
18488
18553
  async function inspectJudgeSession(sessionFile) {
18489
18554
  try {
18490
- await readFile8(sessionFile, "utf8");
18555
+ await readFile9(sessionFile, "utf8");
18491
18556
  return { state: "present" };
18492
18557
  } catch (error) {
18493
18558
  if (isMissingPathError2(error)) return { state: "missing" };
@@ -18542,13 +18607,15 @@ function classifyPostAdmissionFailure(input) {
18542
18607
  if (input.knownCause !== void 0) {
18543
18608
  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
18609
  const diagnostic = input.knownDiagnostic !== void 0 && input.knownDiagnostic.trim() !== "" ? input.knownDiagnostic : conciseChildDiagnostic(input.stderr, fallback);
18545
- const { code: _knownCode, timedOut: _knownTimedOut, ...knownDetails } = input.knownDetails ?? {};
18610
+ const { timedOut: _knownTimedOut, ...knownDetails } = input.knownDetails ?? {};
18611
+ const remoteCode = knownDetails.code;
18546
18612
  return {
18547
18613
  cause: input.knownCause,
18548
18614
  diagnostic,
18549
18615
  details: {
18550
18616
  ...knownDetails,
18551
- code: input.code,
18617
+ ...remoteCode === void 0 ? {} : { code: remoteCode },
18618
+ exitCode: input.code,
18552
18619
  ...input.timedOut ? { timedOut: true } : {}
18553
18620
  },
18554
18621
  ...input.knownIdentity === void 0 ? {} : { identity: input.knownIdentity }
@@ -18558,7 +18625,7 @@ function classifyPostAdmissionFailure(input) {
18558
18625
  return {
18559
18626
  cause: "timeout",
18560
18627
  diagnostic: "role run timed out",
18561
- details: { timedOut: true, code: input.code }
18628
+ details: { timedOut: true, exitCode: input.code }
18562
18629
  };
18563
18630
  }
18564
18631
  if (input.code !== 0) {
@@ -18566,27 +18633,27 @@ function classifyPostAdmissionFailure(input) {
18566
18633
  return {
18567
18634
  cause: "activation",
18568
18635
  diagnostic: conciseChildDiagnostic(input.stderr, fallback),
18569
- details: { code: input.code }
18636
+ details: { exitCode: input.code }
18570
18637
  };
18571
18638
  }
18572
18639
  if (input.session?.state === "missing") {
18573
18640
  return {
18574
18641
  cause: "session",
18575
18642
  diagnostic: "role run left no readable session transcript",
18576
- details: { code: input.code, session: "missing" }
18643
+ details: { exitCode: input.code, session: "missing" }
18577
18644
  };
18578
18645
  }
18579
18646
  if (input.session?.state === "unreadable") {
18580
18647
  return {
18581
18648
  cause: "session",
18582
18649
  diagnostic: input.session.diagnostic,
18583
- details: { code: input.code, session: "unreadable" }
18650
+ details: { exitCode: input.code, session: "unreadable" }
18584
18651
  };
18585
18652
  }
18586
18653
  return {
18587
18654
  cause: "output",
18588
18655
  diagnostic: "role run completed without a lawful typed terminal result",
18589
- details: { code: input.code }
18656
+ details: { exitCode: input.code }
18590
18657
  };
18591
18658
  }
18592
18659
  function explicitInternalKnownFailureClassificationInput(failure) {
@@ -18627,7 +18694,7 @@ function sessionReadFailure(error, fallbackMessage) {
18627
18694
  return failed;
18628
18695
  }
18629
18696
  async function readBoundSessionEntries(sessionFile) {
18630
- const text = await readFile8(sessionFile, "utf8");
18697
+ const text = await readFile9(sessionFile, "utf8");
18631
18698
  const entries = [];
18632
18699
  for (const line2 of text.trim().split("\n").filter(Boolean)) {
18633
18700
  try {
@@ -18638,6 +18705,31 @@ async function readBoundSessionEntries(sessionFile) {
18638
18705
  }
18639
18706
  return entries;
18640
18707
  }
18708
+ function typedHttpStatusFromMessage(message) {
18709
+ for (const candidate of [message.httpStatus, message.statusCode, message.status]) {
18710
+ if (typeof candidate === "number" && (candidate < 200 || candidate >= 300)) return candidate;
18711
+ }
18712
+ return void 0;
18713
+ }
18714
+ function sessionProviderStopFromAssistant(message) {
18715
+ if (message?.role !== "assistant") return void 0;
18716
+ if (message.stopReason !== "error" && message.stopReason !== "aborted") return void 0;
18717
+ const httpStatus = typedHttpStatusFromMessage(message);
18718
+ return {
18719
+ stopReason: message.stopReason,
18720
+ // Preserve held errorMessage bytes — emptiness check must not rewrite.
18721
+ ...typeof message.errorMessage === "string" && message.errorMessage.trim() !== "" ? { errorMessage: message.errorMessage } : {},
18722
+ ...typeof message.provider === "string" && message.provider.trim() !== "" ? { provider: message.provider } : {},
18723
+ ...typeof message.model === "string" && message.model.trim() !== "" ? { model: message.model } : {},
18724
+ ...typeof message.api === "string" && message.api.trim() !== "" ? { api: message.api } : {},
18725
+ ...typeof message.rawStopReason === "string" && message.rawStopReason.trim() !== "" ? { rawStopReason: message.rawStopReason } : {},
18726
+ ...message.diagnostics === void 0 ? {} : { diagnostics: message.diagnostics },
18727
+ ...httpStatus === void 0 ? {} : { httpStatus },
18728
+ ...message.body === void 0 ? {} : { body: message.body },
18729
+ ...message.code === void 0 ? {} : { code: message.code },
18730
+ ...message.errno === void 0 ? {} : { errno: message.errno }
18731
+ };
18732
+ }
18641
18733
  function extractSessionProviderStop(entries) {
18642
18734
  let attemptStart = 0;
18643
18735
  for (let i = entries.length - 1; i >= 0; i -= 1) {
@@ -18651,14 +18743,8 @@ function extractSessionProviderStop(entries) {
18651
18743
  const entry = entries[i];
18652
18744
  if (entry?.type !== "custom" || entry.customType !== COMPLIANCE_RESPONSE_ENTRY_TYPE) continue;
18653
18745
  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
- }
18746
+ const stop = sessionProviderStopFromAssistant(response);
18747
+ if (stop !== void 0) return stop;
18662
18748
  break;
18663
18749
  }
18664
18750
  for (let i = entries.length - 1; i >= attemptStart; i -= 1) {
@@ -18666,13 +18752,7 @@ function extractSessionProviderStop(entries) {
18666
18752
  if (entry?.type !== "message") continue;
18667
18753
  const message = entry.message;
18668
18754
  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
- };
18755
+ return sessionProviderStopFromAssistant(message);
18676
18756
  }
18677
18757
  return void 0;
18678
18758
  }
@@ -18685,7 +18765,7 @@ async function readSessionProviderStop(sessionFile) {
18685
18765
  }
18686
18766
  }
18687
18767
  async function readBoundEvidenceChildKnownFailure(sessionFile) {
18688
- const childDirectory = join9(dirname6(sessionFile), "evidence-children");
18768
+ const childDirectory = join10(dirname6(sessionFile), "evidence-children");
18689
18769
  let names;
18690
18770
  try {
18691
18771
  names = await readdir3(childDirectory);
@@ -18696,7 +18776,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
18696
18776
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
18697
18777
  let entries;
18698
18778
  try {
18699
- entries = await readBoundSessionEntries(join9(childDirectory, file));
18779
+ entries = await readBoundSessionEntries(join10(childDirectory, file));
18700
18780
  } catch (error) {
18701
18781
  throw sessionReadFailure(error, "failed to read discovered evidence-child session");
18702
18782
  }
@@ -18708,8 +18788,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
18708
18788
  return {
18709
18789
  ...primary,
18710
18790
  details: {
18711
- ...stop.provider === void 0 ? {} : { provider: stop.provider },
18712
- ...stop.model === void 0 ? {} : { model: stop.model },
18791
+ ...primary.details ?? {},
18713
18792
  secondaryEvidence: "evidence-child"
18714
18793
  }
18715
18794
  };
@@ -18733,7 +18812,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
18733
18812
  break;
18734
18813
  }
18735
18814
  }
18736
- const childDirectory = join9(dirname6(sessionFile), "auditor-roles");
18815
+ const childDirectory = join10(dirname6(sessionFile), "auditor-roles");
18737
18816
  let names;
18738
18817
  try {
18739
18818
  names = await readdir3(childDirectory);
@@ -18744,7 +18823,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
18744
18823
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
18745
18824
  let entries;
18746
18825
  try {
18747
- entries = await readBoundSessionEntries(join9(childDirectory, file));
18826
+ entries = await readBoundSessionEntries(join10(childDirectory, file));
18748
18827
  } catch (error) {
18749
18828
  throw sessionReadFailure(error, "failed to read discovered auditor session");
18750
18829
  }
@@ -18762,10 +18841,10 @@ async function readBoundAuditorKnownFailure(sessionFile) {
18762
18841
  if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord5(entry.data)) continue;
18763
18842
  const parent = isRecord5(entry.data.parent) ? entry.data.parent : void 0;
18764
18843
  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;
18844
+ if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId || failure?.cause !== "provider" && failure?.cause !== "unrecognized") continue;
18766
18845
  const identity = isRecord5(failure.identity) ? failure.identity : void 0;
18767
18846
  return {
18768
- cause: "provider",
18847
+ cause: failure.cause === "provider" ? "provider" : "unrecognized",
18769
18848
  ...identity === void 0 ? {} : { identity: {
18770
18849
  ...typeof identity.name === "string" ? { name: identity.name } : {},
18771
18850
  ...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
@@ -18778,8 +18857,7 @@ async function readBoundAuditorKnownFailure(sessionFile) {
18778
18857
  return {
18779
18858
  ...primary,
18780
18859
  details: {
18781
- ...stop.provider === void 0 ? {} : { provider: stop.provider },
18782
- ...stop.model === void 0 ? {} : { model: stop.model },
18860
+ ...primary.details ?? {},
18783
18861
  secondaryEvidence: "unavailable"
18784
18862
  }
18785
18863
  };
@@ -18813,56 +18891,145 @@ function typedFailedTerminatingToolKnownFailure(entries) {
18813
18891
  }
18814
18892
  return void 0;
18815
18893
  }
18816
- async function resolveAuditedRunnerKnownFailure(input) {
18817
- if (input.runner !== void 0) return input.runner;
18894
+ function resolutionOf(knownFailure, typedHttp = { settled: false }) {
18895
+ return {
18896
+ ...knownFailure === void 0 ? {} : { knownFailure },
18897
+ ...typedHttp.observation === void 0 ? {} : { typedHttpObservation: typedHttp.observation },
18898
+ typedHttpObservationSettled: typedHttp.settled
18899
+ };
18900
+ }
18901
+ async function resolveAuditedRunnerFailureResolution(input) {
18902
+ if (input.runner !== void 0) return resolutionOf(input.runner);
18818
18903
  if (input.runDirectory !== void 0) {
18819
18904
  try {
18820
18905
  const rejection = await readReviewerDispatchRejection(input.runDirectory);
18821
- if (rejection !== void 0) return rejection;
18906
+ if (rejection !== void 0) return resolutionOf(rejection);
18822
18907
  } catch (error) {
18823
18908
  const failure = error instanceof Error ? error : new Error(String(error));
18824
- return {
18909
+ return resolutionOf({
18825
18910
  cause: "activation",
18826
18911
  identity: thrownIdentity(failure),
18827
18912
  diagnostic: failure.message || failure.name
18828
- };
18913
+ });
18829
18914
  }
18830
18915
  }
18831
18916
  try {
18832
18917
  const auditorFailure = await readBoundAuditorKnownFailure(input.sessionFile);
18833
- if (auditorFailure !== void 0) return auditorFailure;
18918
+ if (auditorFailure !== void 0) return resolutionOf(auditorFailure);
18834
18919
  } catch (error) {
18835
18920
  const failure = sessionReadFailure(error, "failed to recover bound auditor failure");
18836
- return {
18921
+ return resolutionOf({
18837
18922
  cause: "session",
18838
18923
  identity: thrownIdentity(failure),
18839
18924
  diagnostic: failure.message || failure.name
18840
- };
18925
+ });
18841
18926
  }
18842
18927
  try {
18843
18928
  const terminatingFailure = typedFailedTerminatingToolKnownFailure(
18844
18929
  await readBoundSessionEntries(input.sessionFile)
18845
18930
  );
18846
- if (terminatingFailure !== void 0) return terminatingFailure;
18931
+ if (terminatingFailure !== void 0) return resolutionOf(terminatingFailure);
18847
18932
  } catch (error) {
18848
18933
  if (!isMissingPathError2(error)) {
18849
18934
  const failure = sessionReadFailure(error, "failed to recover typed terminating-tool failure");
18850
- return { cause: "session", identity: thrownIdentity(failure), diagnostic: failure.message || failure.name };
18935
+ return resolutionOf({
18936
+ cause: "session",
18937
+ identity: thrownIdentity(failure),
18938
+ diagnostic: failure.message || failure.name
18939
+ });
18851
18940
  }
18852
18941
  }
18853
18942
  try {
18854
18943
  const evidenceChildFailure = await readBoundEvidenceChildKnownFailure(input.sessionFile);
18855
- if (evidenceChildFailure !== void 0) return evidenceChildFailure;
18944
+ if (evidenceChildFailure !== void 0) return resolutionOf(evidenceChildFailure);
18856
18945
  } catch (error) {
18857
18946
  const failure = sessionReadFailure(error, "failed to recover bound evidence-child failure");
18858
- return {
18947
+ return resolutionOf({
18859
18948
  cause: "session",
18860
18949
  identity: thrownIdentity(failure),
18861
18950
  diagnostic: failure.message || failure.name
18862
- };
18951
+ });
18863
18952
  }
18864
18953
  const parentStop = await readSessionProviderStop(input.sessionFile);
18865
- return parentStop === void 0 ? input.credential : knownFailureFromProviderStop(parentStop);
18954
+ let httpObservation;
18955
+ if (input.runDirectory !== void 0) {
18956
+ try {
18957
+ httpObservation = await readLatestTypedProviderHttpObservation(input.runDirectory);
18958
+ } catch (error) {
18959
+ const failure = error instanceof Error ? error : new Error(String(error));
18960
+ return resolutionOf(
18961
+ {
18962
+ cause: "session",
18963
+ identity: thrownIdentity(failure),
18964
+ diagnostic: failure.message || failure.name
18965
+ },
18966
+ { settled: true }
18967
+ );
18968
+ }
18969
+ }
18970
+ const typedHttp = {
18971
+ settled: input.runDirectory !== void 0,
18972
+ ...httpObservation === void 0 ? {} : { observation: httpObservation }
18973
+ };
18974
+ if (parentStop === void 0) {
18975
+ if (input.credential !== void 0) return resolutionOf(input.credential, typedHttp);
18976
+ if (httpObservation === void 0) return resolutionOf(void 0, typedHttp);
18977
+ return resolutionOf(
18978
+ knownFailureFromProviderStop({
18979
+ stopReason: "error",
18980
+ httpStatus: httpObservation.httpStatus,
18981
+ provider: httpObservation.provider
18982
+ }),
18983
+ typedHttp
18984
+ );
18985
+ }
18986
+ return resolutionOf(
18987
+ knownFailureFromProviderStop({
18988
+ ...parentStop,
18989
+ ...httpObservation === void 0 ? {} : {
18990
+ httpStatus: httpObservation.httpStatus,
18991
+ // Observation association outranks session-configured provider name alone.
18992
+ provider: httpObservation.provider
18993
+ }
18994
+ }),
18995
+ typedHttp
18996
+ );
18997
+ }
18998
+ async function resolveAuditedRunnerKnownFailure(input) {
18999
+ return (await resolveAuditedRunnerFailureResolution(input)).knownFailure;
19000
+ }
19001
+ async function resolveControlledFailureResumeObservation(input) {
19002
+ if (input.typedHttpObservationSettled === true) {
19003
+ const observation = input.typedHttpObservation;
19004
+ if (observation !== void 0 && observation.httpStatus === 429 && isV1ResumableProvider(observation.provider)) {
19005
+ return {
19006
+ typedHttp429: { httpStatus: 429, provider: observation.provider }
19007
+ };
19008
+ }
19009
+ return {};
19010
+ }
19011
+ try {
19012
+ const typedHttp429 = await readTypedHttp429Observation(input.runDirectory);
19013
+ return typedHttp429 === void 0 ? {} : { typedHttp429 };
19014
+ } catch (error) {
19015
+ const failure = error instanceof Error ? error : new Error(String(error));
19016
+ return {
19017
+ observationReadFailure: {
19018
+ cause: "session",
19019
+ identity: thrownIdentity(failure),
19020
+ diagnostic: failure.message || failure.name
19021
+ }
19022
+ };
19023
+ }
19024
+ }
19025
+ function controlledFailureInputFromResolution(resolution) {
19026
+ return {
19027
+ ...resolution.knownFailure === void 0 ? {} : { knownFailure: resolution.knownFailure },
19028
+ ...resolution.typedHttpObservationSettled ? {
19029
+ typedHttpObservationSettled: true,
19030
+ ...resolution.typedHttpObservation === void 0 ? {} : { typedHttpObservation: resolution.typedHttpObservation }
19031
+ } : {}
19032
+ };
18866
19033
  }
18867
19034
  function isRecord5(value) {
18868
19035
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -19358,7 +19525,7 @@ function auditArtifactPublicationError(message, code) {
19358
19525
  return error;
19359
19526
  }
19360
19527
  async function ensureAuditEvidenceDirectory(runDirectory) {
19361
- const artifactsDir = join9(runDirectory, "artifacts");
19528
+ const artifactsDir = join10(runDirectory, "artifacts");
19362
19529
  const runStat = await lstat3(runDirectory);
19363
19530
  if (runStat.isSymbolicLink() || !runStat.isDirectory()) {
19364
19531
  throw auditArtifactPublicationError(
@@ -19395,7 +19562,7 @@ async function ensureAuditEvidenceDirectory(runDirectory) {
19395
19562
  }
19396
19563
  async function publishComplianceAuditIncompleteEvidence(admitted, outcome) {
19397
19564
  const artifactsDir = await ensureAuditEvidenceDirectory(admitted.runDirectory);
19398
- const evidencePath = join9(artifactsDir, "audit-incomplete.json");
19565
+ const evidencePath = join10(artifactsDir, "audit-incomplete.json");
19399
19566
  try {
19400
19567
  const existing = await lstat3(evidencePath);
19401
19568
  throw auditArtifactPublicationError(
@@ -19417,7 +19584,7 @@ async function publishComplianceAuditIncompleteEvidence(admitted, outcome) {
19417
19584
  }
19418
19585
  function auditPublicationFailureTerminal(admitted, entries, outcome, error) {
19419
19586
  const attempt = publicationAttemptFromError(
19420
- join9(admitted.runDirectory, "artifacts", "audit-incomplete.json"),
19587
+ join10(admitted.runDirectory, "artifacts", "audit-incomplete.json"),
19421
19588
  error
19422
19589
  );
19423
19590
  const diagnostic = `audit-incomplete evidence publication failed: ${attempt.diagnostic}`;
@@ -19711,9 +19878,9 @@ async function extractNavigatorFactFromAdmittedSession(admitted) {
19711
19878
  }
19712
19879
  async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
19713
19880
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
19714
- const reportPath = join9(artifactsDir, "report.json");
19715
- const evidencePath = join9(artifactsDir, "evidence.json");
19716
- await writeFile4(
19881
+ const reportPath = join10(artifactsDir, "report.json");
19882
+ const evidencePath = join10(artifactsDir, "evidence.json");
19883
+ await writeFile5(
19717
19884
  reportPath,
19718
19885
  `${JSON.stringify(
19719
19886
  {
@@ -19727,7 +19894,7 @@ async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
19727
19894
  `,
19728
19895
  "utf8"
19729
19896
  );
19730
- await writeFile4(
19897
+ await writeFile5(
19731
19898
  evidencePath,
19732
19899
  `${JSON.stringify(
19733
19900
  {
@@ -19755,9 +19922,9 @@ async function publishJudgeArtifacts(admitted, roleOutcome, sessionDirectory) {
19755
19922
  }
19756
19923
  async function publishCoderArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
19757
19924
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
19758
- const reportPath = join9(artifactsDir, "report.json");
19759
- const evidencePath = join9(artifactsDir, "evidence.json");
19760
- await writeFile4(
19925
+ const reportPath = join10(artifactsDir, "report.json");
19926
+ const evidencePath = join10(artifactsDir, "evidence.json");
19927
+ await writeFile5(
19761
19928
  reportPath,
19762
19929
  `${JSON.stringify(
19763
19930
  {
@@ -19773,7 +19940,7 @@ async function publishCoderArtifacts(admitted, roleOutcome, sessionDirectory, op
19773
19940
  `,
19774
19941
  "utf8"
19775
19942
  );
19776
- await writeFile4(
19943
+ await writeFile5(
19777
19944
  evidencePath,
19778
19945
  `${JSON.stringify(
19779
19946
  {
@@ -19930,9 +20097,9 @@ function extractFixerMethodInvocations(entries, options) {
19930
20097
  }
19931
20098
  async function publishFixerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
19932
20099
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
19933
- const reportPath = join9(artifactsDir, "report.json");
19934
- const evidencePath = join9(artifactsDir, "evidence.json");
19935
- await writeFile4(
20100
+ const reportPath = join10(artifactsDir, "report.json");
20101
+ const evidencePath = join10(artifactsDir, "evidence.json");
20102
+ await writeFile5(
19936
20103
  reportPath,
19937
20104
  `${JSON.stringify(
19938
20105
  {
@@ -19948,7 +20115,7 @@ async function publishFixerArtifacts(admitted, roleOutcome, sessionDirectory, op
19948
20115
  `,
19949
20116
  "utf8"
19950
20117
  );
19951
- await writeFile4(
20118
+ await writeFile5(
19952
20119
  evidencePath,
19953
20120
  `${JSON.stringify(
19954
20121
  {
@@ -20044,9 +20211,9 @@ async function settleLawfulFixerTerminalResult(admitted, options) {
20044
20211
  }
20045
20212
  async function publishCollectorArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
20046
20213
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
20047
- const reportPath = join9(artifactsDir, "report.json");
20048
- const evidencePath = join9(artifactsDir, "evidence.json");
20049
- await writeFile4(
20214
+ const reportPath = join10(artifactsDir, "report.json");
20215
+ const evidencePath = join10(artifactsDir, "evidence.json");
20216
+ await writeFile5(
20050
20217
  reportPath,
20051
20218
  `${JSON.stringify(
20052
20219
  {
@@ -20061,7 +20228,7 @@ async function publishCollectorArtifacts(admitted, roleOutcome, sessionDirectory
20061
20228
  `,
20062
20229
  "utf8"
20063
20230
  );
20064
- await writeFile4(
20231
+ await writeFile5(
20065
20232
  evidencePath,
20066
20233
  `${JSON.stringify(
20067
20234
  {
@@ -20166,9 +20333,9 @@ async function trySettleCollectorTerminalResult(admitted) {
20166
20333
  }
20167
20334
  async function publishDoctorArtifacts(admitted, roleOutcome, sessionDirectory, options = {}) {
20168
20335
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
20169
- const reportPath = join9(artifactsDir, "report.json");
20170
- const evidencePath = join9(artifactsDir, "evidence.json");
20171
- await writeFile4(
20336
+ const reportPath = join10(artifactsDir, "report.json");
20337
+ const evidencePath = join10(artifactsDir, "evidence.json");
20338
+ await writeFile5(
20172
20339
  reportPath,
20173
20340
  `${JSON.stringify(
20174
20341
  {
@@ -20183,7 +20350,7 @@ async function publishDoctorArtifacts(admitted, roleOutcome, sessionDirectory, o
20183
20350
  `,
20184
20351
  "utf8"
20185
20352
  );
20186
- await writeFile4(
20353
+ await writeFile5(
20187
20354
  evidencePath,
20188
20355
  `${JSON.stringify(
20189
20356
  {
@@ -20335,9 +20502,9 @@ function extractReviewerMethodInvocations(entries, options) {
20335
20502
  }
20336
20503
  async function publishReviewerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
20337
20504
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
20338
- const reportPath = join9(artifactsDir, "report.json");
20339
- const evidencePath = join9(artifactsDir, "evidence.json");
20340
- await writeFile4(
20505
+ const reportPath = join10(artifactsDir, "report.json");
20506
+ const evidencePath = join10(artifactsDir, "evidence.json");
20507
+ await writeFile5(
20341
20508
  reportPath,
20342
20509
  `${JSON.stringify(
20343
20510
  {
@@ -20352,7 +20519,7 @@ async function publishReviewerArtifacts(admitted, roleOutcome, sessionDirectory,
20352
20519
  `,
20353
20520
  "utf8"
20354
20521
  );
20355
- await writeFile4(
20522
+ await writeFile5(
20356
20523
  evidencePath,
20357
20524
  `${JSON.stringify(
20358
20525
  {
@@ -20502,9 +20669,9 @@ function extractMergerMethodInvocations(entries, options) {
20502
20669
  }
20503
20670
  async function publishMergerArtifacts(admitted, roleOutcome, sessionDirectory, options) {
20504
20671
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
20505
- const reportPath = join9(artifactsDir, "report.json");
20506
- const evidencePath = join9(artifactsDir, "evidence.json");
20507
- await writeFile4(
20672
+ const reportPath = join10(artifactsDir, "report.json");
20673
+ const evidencePath = join10(artifactsDir, "evidence.json");
20674
+ await writeFile5(
20508
20675
  reportPath,
20509
20676
  `${JSON.stringify(
20510
20677
  {
@@ -20519,7 +20686,7 @@ async function publishMergerArtifacts(admitted, roleOutcome, sessionDirectory, o
20519
20686
  `,
20520
20687
  "utf8"
20521
20688
  );
20522
- await writeFile4(
20689
+ await writeFile5(
20523
20690
  evidencePath,
20524
20691
  `${JSON.stringify(
20525
20692
  {
@@ -20674,7 +20841,7 @@ function uniqueFailureFallbackDirs(runDirectory, baseDir) {
20674
20841
  return dirs;
20675
20842
  }
20676
20843
  async function resolveFailureArtifactsBase(runDirectory) {
20677
- const artifactsDir = join9(runDirectory, "artifacts");
20844
+ const artifactsDir = join10(runDirectory, "artifacts");
20678
20845
  try {
20679
20846
  await ensureRunArtifactsDir(runDirectory);
20680
20847
  return { baseDir: artifactsDir };
@@ -20690,13 +20857,13 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
20690
20857
  const candidates = [
20691
20858
  ...preferredCandidates,
20692
20859
  // One unique name per fallback dir — collisions on fixed names cannot exhaust this.
20693
- ...uniqueFallbackDirs.map((dir) => join9(dir, `${stem}.${randomUUID()}.json`))
20860
+ ...uniqueFallbackDirs.map((dir) => join10(dir, `${stem}.${randomUUID()}.json`))
20694
20861
  ];
20695
20862
  for (let i = 0; i < candidates.length; i += 1) {
20696
20863
  const path = candidates[i];
20697
20864
  const payload = issues.length === 0 ? basePayload : { ...basePayload, publicationIssues: issues };
20698
20865
  try {
20699
- await writeFile4(
20866
+ await writeFile5(
20700
20867
  path,
20701
20868
  `${JSON.stringify(payload, null, 2)}
20702
20869
  `,
@@ -20725,26 +20892,26 @@ async function publishFailureArtifacts(admitted, failure) {
20725
20892
  admitted.runDirectory
20726
20893
  );
20727
20894
  const priorIssues = baseAttempt === void 0 ? [] : [baseAttempt];
20728
- const underArtifacts = baseDir === join9(admitted.runDirectory, "artifacts");
20895
+ const underArtifacts = baseDir === join10(admitted.runDirectory, "artifacts");
20729
20896
  const uniqueFallbackDirs = uniqueFailureFallbackDirs(
20730
20897
  admitted.runDirectory,
20731
20898
  baseDir
20732
20899
  );
20733
20900
  const errorCandidates = underArtifacts ? [
20734
- join9(baseDir, "error.json"),
20735
- join9(baseDir, "error.settlement.json"),
20736
- join9(admitted.runDirectory, "error.settlement.json")
20901
+ join10(baseDir, "error.json"),
20902
+ join10(baseDir, "error.settlement.json"),
20903
+ join10(admitted.runDirectory, "error.settlement.json")
20737
20904
  ] : [
20738
- join9(baseDir, "error.settlement.json"),
20739
- join9(baseDir, "error.json")
20905
+ join10(baseDir, "error.settlement.json"),
20906
+ join10(baseDir, "error.json")
20740
20907
  ];
20741
20908
  const evidenceCandidates = underArtifacts ? [
20742
- join9(baseDir, "evidence.json"),
20743
- join9(baseDir, "evidence.settlement.json"),
20744
- join9(admitted.runDirectory, "evidence.settlement.json")
20909
+ join10(baseDir, "evidence.json"),
20910
+ join10(baseDir, "evidence.settlement.json"),
20911
+ join10(admitted.runDirectory, "evidence.settlement.json")
20745
20912
  ] : [
20746
- join9(baseDir, "evidence.settlement.json"),
20747
- join9(baseDir, "evidence.json")
20913
+ join10(baseDir, "evidence.settlement.json"),
20914
+ join10(baseDir, "evidence.json")
20748
20915
  ];
20749
20916
  const errorPayloadBase = {
20750
20917
  kind: "error",
@@ -20931,6 +21098,7 @@ var init_settlement = __esm({
20931
21098
  init_judge_auditor();
20932
21099
  init_reviewer_auditor();
20933
21100
  init_explicit_internal();
21101
+ init_run_lifecycle();
20934
21102
  init_compliance_transport();
20935
21103
  init_collector_ledger();
20936
21104
  init_judge_output();
@@ -20957,8 +21125,8 @@ var init_settlement = __esm({
20957
21125
  });
20958
21126
 
20959
21127
  // src/public-cli/coder-run.ts
20960
- import { writeFile as writeFile5 } from "node:fs/promises";
20961
- import { join as join10 } from "node:path";
21128
+ import { writeFile as writeFile6 } from "node:fs/promises";
21129
+ import { join as join11 } from "node:path";
20962
21130
  function buildModelArgs(model) {
20963
21131
  if (model === void 0) return [];
20964
21132
  return [
@@ -21029,20 +21197,28 @@ function buildCoderResumeActivationExtraArgs(admitted, options) {
21029
21197
  }
21030
21198
  async function presentControlledFailure(admitted, failureInput, io) {
21031
21199
  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;
21200
+ const resumeObservation = await resolveControlledFailureResumeObservation({
21201
+ runDirectory: admitted.runDirectory,
21202
+ ...failureInput.typedHttpObservationSettled === true ? {
21203
+ typedHttpObservationSettled: true,
21204
+ ...failureInput.typedHttpObservation === void 0 ? {} : { typedHttpObservation: failureInput.typedHttpObservation }
21205
+ } : {}
21206
+ });
21207
+ const knownFailure = failureInput.knownFailure ?? resumeObservation.observationReadFailure;
21208
+ const session = !hasThrown && !failureInput.timedOut && knownFailure === void 0 && failureInput.knownCause === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
21033
21209
  const failure = classifyPostAdmissionFailure({
21034
21210
  timedOut: failureInput.timedOut,
21035
21211
  code: failureInput.code,
21036
21212
  stderr: failureInput.stderr,
21037
21213
  ...hasThrown ? { thrown: failureInput.thrown } : {},
21038
- ...explicitInternalKnownFailureClassificationInput(failureInput.knownFailure),
21214
+ ...explicitInternalKnownFailureClassificationInput(knownFailure),
21039
21215
  ...failureInput.knownCause === void 0 ? {} : { knownCause: failureInput.knownCause },
21040
21216
  ...failureInput.knownIdentity === void 0 ? {} : { knownIdentity: failureInput.knownIdentity },
21041
21217
  ...failureInput.knownDiagnostic === void 0 ? {} : { knownDiagnostic: failureInput.knownDiagnostic },
21042
21218
  ...session === void 0 ? {} : { session }
21043
21219
  });
21044
21220
  const hasLawfulTerminalResult = await hasLawfulCoderTerminalResult(admitted);
21045
- const typedHttp429 = await readTypedHttp429Observation(admitted.runDirectory);
21221
+ const typedHttp429 = resumeObservation.typedHttp429;
21046
21222
  const sessionPrincipalAvailable = await isSessionPrincipalAvailable(
21047
21223
  admitted.sessionFile
21048
21224
  );
@@ -21117,8 +21293,8 @@ async function dispatchAdmittedCoder(input) {
21117
21293
  );
21118
21294
  }
21119
21295
  try {
21120
- await writeFile5(
21121
- join10(admitted.runDirectory, "stderr.log"),
21296
+ await writeFile6(
21297
+ join11(admitted.runDirectory, "stderr.log"),
21122
21298
  result2.stderr,
21123
21299
  "utf8"
21124
21300
  );
@@ -21155,10 +21331,11 @@ async function dispatchAdmittedCoder(input) {
21155
21331
  env.model,
21156
21332
  env.credentials
21157
21333
  );
21158
- const knownFailure = await resolveAuditedRunnerKnownFailure({
21334
+ const resolution = await resolveAuditedRunnerFailureResolution({
21159
21335
  runner: result2.knownFailure,
21160
21336
  sessionFile: admitted.sessionFile,
21161
- credential: credentialFailure
21337
+ credential: credentialFailure,
21338
+ runDirectory: admitted.runDirectory
21162
21339
  });
21163
21340
  return await presentControlledFailure(
21164
21341
  admitted,
@@ -21166,7 +21343,7 @@ async function dispatchAdmittedCoder(input) {
21166
21343
  timedOut: result2.timedOut,
21167
21344
  code: result2.code,
21168
21345
  stderr: result2.stderr,
21169
- ...knownFailure === void 0 ? {} : { knownFailure }
21346
+ ...controlledFailureInputFromResolution(resolution)
21170
21347
  },
21171
21348
  io
21172
21349
  );
@@ -21331,8 +21508,8 @@ var init_coder_run = __esm({
21331
21508
  });
21332
21509
 
21333
21510
  // src/public-cli/collector-run.ts
21334
- import { writeFile as writeFile6 } from "node:fs/promises";
21335
- import { join as join11 } from "node:path";
21511
+ import { writeFile as writeFile7 } from "node:fs/promises";
21512
+ import { join as join12 } from "node:path";
21336
21513
  function buildModelArgs2(model) {
21337
21514
  if (model === void 0) return [];
21338
21515
  return [
@@ -21442,8 +21619,8 @@ async function dispatchAdmittedCollector(input) {
21442
21619
  );
21443
21620
  }
21444
21621
  try {
21445
- await writeFile6(
21446
- join11(admitted.runDirectory, "stderr.log"),
21622
+ await writeFile7(
21623
+ join12(admitted.runDirectory, "stderr.log"),
21447
21624
  result2.stderr,
21448
21625
  "utf8"
21449
21626
  );
@@ -21488,7 +21665,8 @@ async function dispatchAdmittedCollector(input) {
21488
21665
  ...infrastructureFailure.identity === void 0 ? {} : { identity: infrastructureFailure.identity }
21489
21666
  }),
21490
21667
  sessionFile: admitted.sessionFile,
21491
- credential: credentialFailure
21668
+ credential: credentialFailure,
21669
+ runDirectory: admitted.runDirectory
21492
21670
  });
21493
21671
  return await presentControlledFailure2(
21494
21672
  admitted,
@@ -21563,8 +21741,8 @@ var init_collector_run = __esm({
21563
21741
  });
21564
21742
 
21565
21743
  // src/public-cli/doctor-run.ts
21566
- import { writeFile as writeFile7 } from "node:fs/promises";
21567
- import { join as join12 } from "node:path";
21744
+ import { writeFile as writeFile8 } from "node:fs/promises";
21745
+ import { join as join13 } from "node:path";
21568
21746
  function buildModelArgs3(model) {
21569
21747
  if (model === void 0) return [];
21570
21748
  return [
@@ -21668,8 +21846,8 @@ async function dispatchAdmittedDoctor(input) {
21668
21846
  );
21669
21847
  }
21670
21848
  try {
21671
- await writeFile7(
21672
- join12(admitted.runDirectory, "stderr.log"),
21849
+ await writeFile8(
21850
+ join13(admitted.runDirectory, "stderr.log"),
21673
21851
  result2.stderr,
21674
21852
  "utf8"
21675
21853
  );
@@ -21721,7 +21899,8 @@ async function dispatchAdmittedDoctor(input) {
21721
21899
  const knownFailure = await resolveAuditedRunnerKnownFailure({
21722
21900
  runner: result2.knownFailure,
21723
21901
  sessionFile: admitted.sessionFile,
21724
- credential: credentialFailure
21902
+ credential: credentialFailure,
21903
+ runDirectory: admitted.runDirectory
21725
21904
  });
21726
21905
  return await presentControlledFailure3(
21727
21906
  admitted,
@@ -21795,8 +21974,8 @@ var init_doctor_run = __esm({
21795
21974
  });
21796
21975
 
21797
21976
  // src/public-cli/fixer-run.ts
21798
- import { writeFile as writeFile8 } from "node:fs/promises";
21799
- import { join as join13 } from "node:path";
21977
+ import { writeFile as writeFile9 } from "node:fs/promises";
21978
+ import { join as join14 } from "node:path";
21800
21979
  function buildModelArgs4(model) {
21801
21980
  if (model === void 0) return [];
21802
21981
  return [
@@ -21879,17 +22058,25 @@ function buildFixerResumeActivationExtraArgs(admitted, options) {
21879
22058
  }
21880
22059
  async function presentControlledFailure4(admitted, failureInput, io) {
21881
22060
  const hasThrown = Object.hasOwn(failureInput, "thrown");
21882
- const session = !hasThrown && !failureInput.timedOut && failureInput.knownFailure === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
22061
+ const resumeObservation = await resolveControlledFailureResumeObservation({
22062
+ runDirectory: admitted.runDirectory,
22063
+ ...failureInput.typedHttpObservationSettled === true ? {
22064
+ typedHttpObservationSettled: true,
22065
+ ...failureInput.typedHttpObservation === void 0 ? {} : { typedHttpObservation: failureInput.typedHttpObservation }
22066
+ } : {}
22067
+ });
22068
+ const knownFailure = failureInput.knownFailure ?? resumeObservation.observationReadFailure;
22069
+ const session = !hasThrown && !failureInput.timedOut && knownFailure === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
21883
22070
  const failure = classifyPostAdmissionFailure({
21884
22071
  timedOut: failureInput.timedOut,
21885
22072
  code: failureInput.code,
21886
22073
  stderr: failureInput.stderr,
21887
22074
  ...hasThrown ? { thrown: failureInput.thrown } : {},
21888
- ...explicitInternalKnownFailureClassificationInput(failureInput.knownFailure),
22075
+ ...explicitInternalKnownFailureClassificationInput(knownFailure),
21889
22076
  ...session === void 0 ? {} : { session }
21890
22077
  });
21891
22078
  const hasLawfulTerminalResult = await hasLawfulFixerTerminalResult(admitted);
21892
- const typedHttp429 = await readTypedHttp429Observation(admitted.runDirectory);
22079
+ const typedHttp429 = resumeObservation.typedHttp429;
21893
22080
  const sessionPrincipalAvailable = await isSessionPrincipalAvailable(
21894
22081
  admitted.sessionFile
21895
22082
  );
@@ -21964,8 +22151,8 @@ async function dispatchAdmittedFixer(input) {
21964
22151
  );
21965
22152
  }
21966
22153
  try {
21967
- await writeFile8(
21968
- join13(admitted.runDirectory, "stderr.log"),
22154
+ await writeFile9(
22155
+ join14(admitted.runDirectory, "stderr.log"),
21969
22156
  result2.stderr,
21970
22157
  "utf8"
21971
22158
  );
@@ -22021,10 +22208,11 @@ async function dispatchAdmittedFixer(input) {
22021
22208
  env.model,
22022
22209
  env.credentials
22023
22210
  );
22024
- const knownFailure = await resolveAuditedRunnerKnownFailure({
22211
+ const resolution = await resolveAuditedRunnerFailureResolution({
22025
22212
  runner: result2.knownFailure,
22026
22213
  sessionFile: admitted.sessionFile,
22027
- credential: credentialFailure
22214
+ credential: credentialFailure,
22215
+ runDirectory: admitted.runDirectory
22028
22216
  });
22029
22217
  return await presentControlledFailure4(
22030
22218
  admitted,
@@ -22032,7 +22220,7 @@ async function dispatchAdmittedFixer(input) {
22032
22220
  timedOut: result2.timedOut,
22033
22221
  code: result2.code,
22034
22222
  stderr: result2.stderr,
22035
- ...knownFailure === void 0 ? {} : { knownFailure }
22223
+ ...controlledFailureInputFromResolution(resolution)
22036
22224
  },
22037
22225
  io
22038
22226
  );
@@ -22187,8 +22375,8 @@ var init_fixer_run = __esm({
22187
22375
  });
22188
22376
 
22189
22377
  // src/public-cli/judge-run.ts
22190
- import { writeFile as writeFile9 } from "node:fs/promises";
22191
- import { join as join14 } from "node:path";
22378
+ import { writeFile as writeFile10 } from "node:fs/promises";
22379
+ import { join as join15 } from "node:path";
22192
22380
  function buildModelArgs5(model) {
22193
22381
  if (model === void 0) return [];
22194
22382
  return [
@@ -22242,17 +22430,25 @@ function buildJudgeResumeActivationExtraArgs(admitted, options = {}) {
22242
22430
  }
22243
22431
  async function presentControlledFailure5(admitted, failureInput, io) {
22244
22432
  const hasThrown = Object.hasOwn(failureInput, "thrown");
22245
- const session = !hasThrown && !failureInput.timedOut && failureInput.knownFailure === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
22433
+ const resumeObservation = await resolveControlledFailureResumeObservation({
22434
+ runDirectory: admitted.runDirectory,
22435
+ ...failureInput.typedHttpObservationSettled === true ? {
22436
+ typedHttpObservationSettled: true,
22437
+ ...failureInput.typedHttpObservation === void 0 ? {} : { typedHttpObservation: failureInput.typedHttpObservation }
22438
+ } : {}
22439
+ });
22440
+ const knownFailure = failureInput.knownFailure ?? resumeObservation.observationReadFailure;
22441
+ const session = !hasThrown && !failureInput.timedOut && knownFailure === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
22246
22442
  const failure = classifyPostAdmissionFailure({
22247
22443
  timedOut: failureInput.timedOut,
22248
22444
  code: failureInput.code,
22249
22445
  stderr: failureInput.stderr,
22250
22446
  ...hasThrown ? { thrown: failureInput.thrown } : {},
22251
- ...explicitInternalKnownFailureClassificationInput(failureInput.knownFailure),
22447
+ ...explicitInternalKnownFailureClassificationInput(knownFailure),
22252
22448
  ...session === void 0 ? {} : { session }
22253
22449
  });
22254
22450
  const hasLawfulTerminalResult = await hasLawfulJudgeTerminalResult(admitted);
22255
- const typedHttp429 = await readTypedHttp429Observation(admitted.runDirectory);
22451
+ const typedHttp429 = resumeObservation.typedHttp429;
22256
22452
  const sessionPrincipalAvailable = await isSessionPrincipalAvailable(
22257
22453
  admitted.sessionFile
22258
22454
  );
@@ -22329,8 +22525,8 @@ async function dispatchAdmittedJudge(input) {
22329
22525
  );
22330
22526
  }
22331
22527
  try {
22332
- await writeFile9(
22333
- join14(admitted.runDirectory, "stderr.log"),
22528
+ await writeFile10(
22529
+ join15(admitted.runDirectory, "stderr.log"),
22334
22530
  result2.stderr,
22335
22531
  "utf8"
22336
22532
  );
@@ -22379,10 +22575,11 @@ async function dispatchAdmittedJudge(input) {
22379
22575
  env.model,
22380
22576
  env.credentials
22381
22577
  );
22382
- const knownFailure = await resolveAuditedRunnerKnownFailure({
22578
+ const resolution = await resolveAuditedRunnerFailureResolution({
22383
22579
  runner: result2.knownFailure,
22384
22580
  sessionFile: admitted.sessionFile,
22385
- credential: credentialFailure
22581
+ credential: credentialFailure,
22582
+ runDirectory: admitted.runDirectory
22386
22583
  });
22387
22584
  return await presentControlledFailure5(
22388
22585
  admitted,
@@ -22390,7 +22587,7 @@ async function dispatchAdmittedJudge(input) {
22390
22587
  timedOut: result2.timedOut,
22391
22588
  code: result2.code,
22392
22589
  stderr: result2.stderr,
22393
- ...knownFailure === void 0 ? {} : { knownFailure }
22590
+ ...controlledFailureInputFromResolution(resolution)
22394
22591
  },
22395
22592
  io
22396
22593
  );
@@ -22503,8 +22700,8 @@ var init_judge_run = __esm({
22503
22700
  });
22504
22701
 
22505
22702
  // 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";
22703
+ import { mkdir as mkdir4, writeFile as writeFile11 } from "node:fs/promises";
22704
+ import { join as join16, resolve as resolve7 } from "node:path";
22508
22705
  function buildModelArgs6(model) {
22509
22706
  if (model === void 0) return [];
22510
22707
  return [
@@ -22573,20 +22770,28 @@ function buildMergerResumeActivationExtraArgs(admitted, options) {
22573
22770
  }
22574
22771
  async function presentControlledFailure6(admitted, failureInput, io) {
22575
22772
  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;
22773
+ const resumeObservation = await resolveControlledFailureResumeObservation({
22774
+ runDirectory: admitted.runDirectory,
22775
+ ...failureInput.typedHttpObservationSettled === true ? {
22776
+ typedHttpObservationSettled: true,
22777
+ ...failureInput.typedHttpObservation === void 0 ? {} : { typedHttpObservation: failureInput.typedHttpObservation }
22778
+ } : {}
22779
+ });
22780
+ const knownFailure = failureInput.knownFailure ?? resumeObservation.observationReadFailure;
22781
+ const session = !hasThrown && !failureInput.timedOut && knownFailure === void 0 && failureInput.knownCause === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
22577
22782
  const failure = classifyPostAdmissionFailure({
22578
22783
  timedOut: failureInput.timedOut,
22579
22784
  code: failureInput.code,
22580
22785
  stderr: failureInput.stderr,
22581
22786
  ...hasThrown ? { thrown: failureInput.thrown } : {},
22582
- ...explicitInternalKnownFailureClassificationInput(failureInput.knownFailure),
22787
+ ...explicitInternalKnownFailureClassificationInput(knownFailure),
22583
22788
  ...failureInput.knownCause === void 0 ? {} : { knownCause: failureInput.knownCause },
22584
22789
  ...failureInput.knownIdentity === void 0 ? {} : { knownIdentity: failureInput.knownIdentity },
22585
22790
  ...failureInput.knownDiagnostic === void 0 ? {} : { knownDiagnostic: failureInput.knownDiagnostic },
22586
22791
  ...session === void 0 ? {} : { session }
22587
22792
  });
22588
22793
  const hasLawfulTerminalResult = await hasLawfulMergerTerminalResult(admitted);
22589
- const typedHttp429 = await readTypedHttp429Observation(admitted.runDirectory);
22794
+ const typedHttp429 = resumeObservation.typedHttp429;
22590
22795
  const sessionPrincipalAvailable = await isSessionPrincipalAvailable(
22591
22796
  admitted.sessionFile
22592
22797
  );
@@ -22661,8 +22866,8 @@ async function dispatchAdmittedMerger(input) {
22661
22866
  );
22662
22867
  }
22663
22868
  try {
22664
- await writeFile10(
22665
- join15(admitted.runDirectory, "stderr.log"),
22869
+ await writeFile11(
22870
+ join16(admitted.runDirectory, "stderr.log"),
22666
22871
  result2.stderr,
22667
22872
  "utf8"
22668
22873
  );
@@ -22704,10 +22909,11 @@ async function dispatchAdmittedMerger(input) {
22704
22909
  env.model,
22705
22910
  env.credentials
22706
22911
  );
22707
- const knownFailure = await resolveAuditedRunnerKnownFailure({
22912
+ const resolution = await resolveAuditedRunnerFailureResolution({
22708
22913
  runner: result2.knownFailure,
22709
22914
  sessionFile: admitted.sessionFile,
22710
- credential: credentialFailure
22915
+ credential: credentialFailure,
22916
+ runDirectory: admitted.runDirectory
22711
22917
  });
22712
22918
  return await presentControlledFailure6(
22713
22919
  admitted,
@@ -22715,7 +22921,7 @@ async function dispatchAdmittedMerger(input) {
22715
22921
  timedOut: result2.timedOut,
22716
22922
  code: result2.code,
22717
22923
  stderr: result2.stderr,
22718
- ...knownFailure === void 0 ? {} : { knownFailure }
22924
+ ...controlledFailureInputFromResolution(resolution)
22719
22925
  },
22720
22926
  io
22721
22927
  );
@@ -22742,9 +22948,9 @@ async function admitMergerShellForActivationFailure(options) {
22742
22948
  expectedConflictPaths: [],
22743
22949
  resolutionScope: []
22744
22950
  };
22745
- const admittedRequestPath = join15(runDirectory, "admitted-request.json");
22746
- const mergerInputPath = join15(runDirectory, "merger-input.json");
22747
- await writeFile10(
22951
+ const admittedRequestPath = join16(runDirectory, "admitted-request.json");
22952
+ const mergerInputPath = join16(runDirectory, "merger-input.json");
22953
+ await writeFile11(
22748
22954
  admittedRequestPath,
22749
22955
  `${JSON.stringify(
22750
22956
  {
@@ -22958,8 +23164,8 @@ var init_merger_run = __esm({
22958
23164
  });
22959
23165
 
22960
23166
  // src/public-cli/reviewer-run.ts
22961
- import { writeFile as writeFile11 } from "node:fs/promises";
22962
- import { join as join16 } from "node:path";
23167
+ import { writeFile as writeFile12 } from "node:fs/promises";
23168
+ import { join as join17 } from "node:path";
22963
23169
  function buildModelArgs7(model) {
22964
23170
  if (model === void 0) return [];
22965
23171
  return [
@@ -23028,17 +23234,25 @@ function buildReviewerResumeActivationExtraArgs(admitted, options) {
23028
23234
  }
23029
23235
  async function presentControlledFailure7(admitted, failureInput, io) {
23030
23236
  const hasThrown = Object.hasOwn(failureInput, "thrown");
23031
- const session = !hasThrown && !failureInput.timedOut && failureInput.knownFailure === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
23237
+ const resumeObservation = await resolveControlledFailureResumeObservation({
23238
+ runDirectory: admitted.runDirectory,
23239
+ ...failureInput.typedHttpObservationSettled === true ? {
23240
+ typedHttpObservationSettled: true,
23241
+ ...failureInput.typedHttpObservation === void 0 ? {} : { typedHttpObservation: failureInput.typedHttpObservation }
23242
+ } : {}
23243
+ });
23244
+ const knownFailure = failureInput.knownFailure ?? resumeObservation.observationReadFailure;
23245
+ const session = !hasThrown && !failureInput.timedOut && knownFailure === void 0 ? await inspectJudgeSession(admitted.sessionFile) : void 0;
23032
23246
  const failure = classifyPostAdmissionFailure({
23033
23247
  timedOut: failureInput.timedOut,
23034
23248
  code: failureInput.code,
23035
23249
  stderr: failureInput.stderr,
23036
23250
  ...hasThrown ? { thrown: failureInput.thrown } : {},
23037
- ...explicitInternalKnownFailureClassificationInput(failureInput.knownFailure),
23251
+ ...explicitInternalKnownFailureClassificationInput(knownFailure),
23038
23252
  ...session === void 0 ? {} : { session }
23039
23253
  });
23040
23254
  const hasLawfulTerminalResult = await hasLawfulReviewerTerminalResult(admitted);
23041
- const typedHttp429 = await readTypedHttp429Observation(admitted.runDirectory);
23255
+ const typedHttp429 = resumeObservation.typedHttp429;
23042
23256
  const sessionPrincipalAvailable = await isSessionPrincipalAvailable(
23043
23257
  admitted.sessionFile
23044
23258
  );
@@ -23114,8 +23328,8 @@ async function dispatchAdmittedReviewer(input) {
23114
23328
  );
23115
23329
  }
23116
23330
  try {
23117
- await writeFile11(
23118
- join16(admitted.runDirectory, "stderr.log"),
23331
+ await writeFile12(
23332
+ join17(admitted.runDirectory, "stderr.log"),
23119
23333
  result2.stderr,
23120
23334
  "utf8"
23121
23335
  );
@@ -23171,7 +23385,7 @@ async function dispatchAdmittedReviewer(input) {
23171
23385
  env.model,
23172
23386
  env.credentials
23173
23387
  );
23174
- const knownFailure = await resolveAuditedRunnerKnownFailure({
23388
+ const resolution = await resolveAuditedRunnerFailureResolution({
23175
23389
  runner: result2.knownFailure,
23176
23390
  sessionFile: admitted.sessionFile,
23177
23391
  credential: credentialFailure,
@@ -23183,7 +23397,7 @@ async function dispatchAdmittedReviewer(input) {
23183
23397
  timedOut: result2.timedOut,
23184
23398
  code: result2.code,
23185
23399
  stderr: result2.stderr,
23186
- ...knownFailure === void 0 ? {} : { knownFailure }
23400
+ ...controlledFailureInputFromResolution(resolution)
23187
23401
  },
23188
23402
  io
23189
23403
  );
@@ -23347,7 +23561,7 @@ __export(cli_exports, {
23347
23561
  });
23348
23562
  import { realpath as realpath5 } from "node:fs/promises";
23349
23563
  import { homedir as homedir3 } from "node:os";
23350
- import { join as join17 } from "node:path";
23564
+ import { join as join18 } from "node:path";
23351
23565
  function defaultIo() {
23352
23566
  return {
23353
23567
  stdout: (text) => {
@@ -23362,7 +23576,7 @@ function resolveHome(env) {
23362
23576
  return env.home ?? process.env.HOME ?? homedir3();
23363
23577
  }
23364
23578
  function resolveAgentDir(env, home) {
23365
- return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join17(home, ".pi", "agent");
23579
+ return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join18(home, ".pi", "agent");
23366
23580
  }
23367
23581
  function parseThinking(value) {
23368
23582
  if (!THINKING_LEVELS2.has(value)) {
@@ -24002,7 +24216,7 @@ var init_cli = __esm({
24002
24216
  });
24003
24217
 
24004
24218
  // src/public-cli/main.ts
24005
- import { dirname as dirname7, join as join18 } from "node:path";
24219
+ import { dirname as dirname7, join as join19 } from "node:path";
24006
24220
  import { fileURLToPath as fileURLToPath2 } from "node:url";
24007
24221
 
24008
24222
  // src/public-cli/host-pi-runtime.ts
@@ -24090,7 +24304,7 @@ function linkPackage(packageRoot2, name, targetDir) {
24090
24304
 
24091
24305
  // src/public-cli/main.ts
24092
24306
  var here = dirname7(fileURLToPath2(import.meta.url));
24093
- var packageRoot = join18(here, "..", "..");
24307
+ var packageRoot = join19(here, "..", "..");
24094
24308
  ensureHostPiRuntimeResolvable(packageRoot);
24095
24309
  var { runAkRole: runAkRole2 } = await Promise.resolve().then(() => (init_cli(), cli_exports));
24096
24310
  var result = await runAkRole2(process.argv.slice(2), { packageRoot });