@akagilnc/pi-workflow-roles 0.1.4673 → 0.1.4698

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.
@@ -1378,6 +1378,7 @@ __export(run_terminal_artifacts_exports, {
1378
1378
  RUN_TERMINAL_ARTIFACT_FILES: () => RUN_TERMINAL_ARTIFACT_FILES,
1379
1379
  RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS: () => RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS,
1380
1380
  isUniqueErrorFallbackName: () => isUniqueErrorFallbackName,
1381
+ listSeamOwnedUniqueErrorFacePaths: () => listSeamOwnedUniqueErrorFacePaths,
1381
1382
  readRunTerminalArtifact: () => readRunTerminalArtifact,
1382
1383
  runIdFromRunDirectory: () => runIdFromRunDirectory
1383
1384
  });
@@ -1472,30 +1473,55 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
1472
1473
  if (expectedRunId === void 0) return false;
1473
1474
  return typeof body.runId === "string" && body.runId === expectedRunId;
1474
1475
  }
1476
+ async function listSeamOwnedUniqueErrorFacePaths(runDirectory) {
1477
+ const artifactsDir = roleRunArtifactsDirectory(runDirectory);
1478
+ const owned = await listUniqueErrorFallbackPaths([
1479
+ artifactsDir,
1480
+ runDirectory
1481
+ ]);
1482
+ const expectedRunId = runIdFromRunDirectory(runDirectory);
1483
+ for (const path of await listUniqueErrorFallbackPaths([dirname5(runDirectory)])) {
1484
+ const read = await readTerminalArtifactAtPath(path, "error.json");
1485
+ if (read === void 0 || read.status !== "present") continue;
1486
+ if (!presentUniqueFallbackBoundToRun(read.body, expectedRunId)) continue;
1487
+ owned.push(path);
1488
+ }
1489
+ return owned;
1490
+ }
1491
+ function failureClassRank(file) {
1492
+ return file === "error.json" ? 1 : 0;
1493
+ }
1475
1494
  async function readRunTerminalArtifact(runDirectory) {
1476
1495
  const artifactsDir = roleRunArtifactsDirectory(runDirectory);
1496
+ const present = [];
1497
+ const unreadable = [];
1498
+ const consider = (read) => {
1499
+ if (read === void 0 || read.status === "absent") return;
1500
+ if (read.status === "present") {
1501
+ present.push(read);
1502
+ return;
1503
+ }
1504
+ unreadable.push(read);
1505
+ };
1477
1506
  for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
1478
- const path = join8(artifactsDir, file);
1479
- const read = await readTerminalArtifactAtPath(path, file);
1480
- if (read !== void 0) return read;
1507
+ consider(await readTerminalArtifactAtPath(join8(artifactsDir, file), file));
1481
1508
  }
1482
1509
  for (const relative5 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
1483
- const path = join8(runDirectory, relative5);
1484
- const read = await readTerminalArtifactAtPath(path, "error.json");
1485
- if (read !== void 0) return read;
1510
+ consider(
1511
+ await readTerminalArtifactAtPath(join8(runDirectory, relative5), "error.json")
1512
+ );
1486
1513
  }
1487
- for (const path of await listUniqueErrorFallbackPaths([artifactsDir, runDirectory])) {
1488
- const read = await readTerminalArtifactAtPath(path, "error.json");
1489
- if (read !== void 0) return read;
1514
+ for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
1515
+ consider(await readTerminalArtifactAtPath(path, "error.json"));
1490
1516
  }
1491
- const expectedRunId = runIdFromRunDirectory(runDirectory);
1492
- for (const path of await listUniqueErrorFallbackPaths([dirname5(runDirectory)])) {
1493
- const read = await readTerminalArtifactAtPath(path, "error.json");
1494
- if (read === void 0) continue;
1495
- if (read.status === "present") {
1496
- if (!presentUniqueFallbackBoundToRun(read.body, expectedRunId)) continue;
1497
- return read;
1498
- }
1517
+ if (present.length > 0) {
1518
+ present.sort(
1519
+ (a, b) => failureClassRank(b.file) - failureClassRank(a.file)
1520
+ );
1521
+ return present[0];
1522
+ }
1523
+ if (unreadable.length > 0) {
1524
+ return unreadable[0];
1499
1525
  }
1500
1526
  return { status: "absent" };
1501
1527
  }
@@ -1578,14 +1604,9 @@ function thisCourtOfficerPayloads(terminal) {
1578
1604
  if (outcome !== void 0 && (outcome.kind === "accepted" || outcome.kind === "audit_escalation")) {
1579
1605
  if (outcome.payloads !== void 0 && outcome.payloads.length > 0) return outcome.payloads;
1580
1606
  }
1581
- if (outcome?.kind === "failure" && outcome.payloads !== void 0 && outcome.payloads.length > 0) {
1582
- return outcome.payloads;
1583
- }
1584
1607
  return [];
1585
1608
  }
1586
1609
  function officerFailurePayloads(terminal) {
1587
- const outcome = terminal?.roleOutcome;
1588
- if (outcome?.kind === "failure") return outcome.payloads ?? terminal?.submissions ?? [];
1589
1610
  return terminal?.submissions ?? [];
1590
1611
  }
1591
1612
  function projectOfficerPayloads(officer, payloads, fallbackStatus) {
@@ -3842,6 +3863,114 @@ var init_host_descriptions = __esm({
3842
3863
  }
3843
3864
  });
3844
3865
 
3866
+ // src/public-cli/terminal.ts
3867
+ function encodeTerminalField(value) {
3868
+ return JSON.stringify(value);
3869
+ }
3870
+ function isLawfulTypedTerminalOutcome(outcome) {
3871
+ return outcome.kind === "accepted" || outcome.kind === "audit_escalation" || outcome.kind === "no_receipt";
3872
+ }
3873
+ function exitCodeForTerminalOutcome(outcome) {
3874
+ return isLawfulTypedTerminalOutcome(outcome) ? 0 : 1;
3875
+ }
3876
+ function coalesceSubmissionRows(payloads, submissions) {
3877
+ if (payloads !== void 0 && payloads.length > 0) return payloads;
3878
+ if (submissions !== void 0 && submissions.length > 0) return submissions;
3879
+ return payloads ?? submissions ?? [];
3880
+ }
3881
+ function adviceNavigatorFact(input) {
3882
+ return {
3883
+ disposition: "advice",
3884
+ prose: input.prose,
3885
+ ...input.advisoryDiagnostic === void 0 ? {} : { advisoryDiagnostic: input.advisoryDiagnostic }
3886
+ };
3887
+ }
3888
+ function formatTerminalResult(result) {
3889
+ const lines = [];
3890
+ lines.push("role outcome status");
3891
+ const outcomeStatus = result.roleOutcome.kind === "failure" ? result.roleOutcome.cause ?? "" : result.roleOutcome.kind === "accepted" ? "accepted" : result.roleOutcome.status;
3892
+ lines.push(
3893
+ `${result.roleOutcome.role} ${result.roleOutcome.kind} ${encodeTerminalField(outcomeStatus)}`
3894
+ );
3895
+ if (result.roleOutcome.kind === "failure") {
3896
+ lines.push(
3897
+ `diagnostic ${encodeTerminalField(result.roleOutcome.diagnostic)}`
3898
+ );
3899
+ }
3900
+ if (result.roleOutcome.kind === "failure" || result.roleOutcome.kind === "no_receipt") {
3901
+ const facts = result.roleOutcome.decisiveFacts;
3902
+ for (const [key, value] of Object.entries(facts)) {
3903
+ if (value === void 0) continue;
3904
+ const rendered = typeof value === "string" ? value : JSON.stringify(value);
3905
+ lines.push(`fact ${encodeTerminalField(key)} ${encodeTerminalField(rendered)}`);
3906
+ }
3907
+ }
3908
+ lines.push(`navigator ${result.navigator.disposition}`);
3909
+ if (result.navigator.advisoryDiagnostic !== void 0) {
3910
+ lines.push(`navigator-advisory ${encodeTerminalField(result.navigator.advisoryDiagnostic)}`);
3911
+ }
3912
+ if (result.navigator.disposition === "advice") {
3913
+ lines.push(`prose ${encodeTerminalField(result.navigator.prose)}`);
3914
+ } else if (result.navigator.disposition === "unavailable") {
3915
+ lines.push(
3916
+ `unavailable ${result.navigator.source} ${encodeTerminalField(result.navigator.reason)}`
3917
+ );
3918
+ }
3919
+ for (const artifact of result.artifacts) {
3920
+ lines.push(`artifact ${artifact.kind} ${encodeTerminalField(artifact.path)}`);
3921
+ }
3922
+ if (result.gate !== void 0) {
3923
+ lines.push(
3924
+ `gate ${encodeTerminalField(result.gate.actualSeats.join(","))} ${result.gate.rounds.length}`
3925
+ );
3926
+ for (const round of result.gate.rounds) {
3927
+ const reason = round.dispatch.kind === "historical_dispatch" && round.dispatch.reason !== void 0 ? encodeTerminalField(round.dispatch.reason) : "";
3928
+ lines.push(
3929
+ `gate-round ${round.roundIndex} ${round.dispatch.kind} ${round.dispatch.officer} ${reason} ${round.officer.seat} ${encodeTerminalField(round.officer.status)} ${encodeTerminalField(JSON.stringify(round.officer.findings))}`
3930
+ );
3931
+ }
3932
+ }
3933
+ if (result.reviewerChildOutcomes !== void 0) {
3934
+ for (const axis of ["completeness", "correctness"]) {
3935
+ const child = result.reviewerChildOutcomes[axis];
3936
+ lines.push(`reviewer-child ${axis} ${child.exitCode}`);
3937
+ if (child.stderr !== void 0 && child.stderr !== "") {
3938
+ lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
3939
+ }
3940
+ }
3941
+ }
3942
+ if (result.resume !== void 0) {
3943
+ lines.push(`resume ${encodeTerminalField(result.resume.command)}`);
3944
+ } else if (result.runId !== void 0) {
3945
+ lines.push(`run ${encodeTerminalField(result.runId)}`);
3946
+ }
3947
+ if (result.autoResumeCount !== void 0) {
3948
+ lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
3949
+ }
3950
+ if (result.roleOutcome.kind === "failure") {
3951
+ const recorded = result.submissions ?? [];
3952
+ for (let i = recorded.length - 1; i >= 0; i -= 1) {
3953
+ const payload = recorded[i];
3954
+ const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
3955
+ lines.push(`recorded-submission ${encodeTerminalField(rendered)}`);
3956
+ }
3957
+ } else {
3958
+ const payloads = result.roleOutcome.kind === "accepted" || result.roleOutcome.kind === "audit_escalation" ? coalesceSubmissionRows(result.roleOutcome.payloads, result.submissions) : result.submissions ?? [];
3959
+ for (let i = payloads.length - 1; i >= 0; i -= 1) {
3960
+ const payload = payloads[i];
3961
+ const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
3962
+ lines.push(`submission ${encodeTerminalField(rendered)}`);
3963
+ }
3964
+ }
3965
+ return `${lines.join("\n")}
3966
+ `;
3967
+ }
3968
+ var init_terminal = __esm({
3969
+ "src/public-cli/terminal.ts"() {
3970
+ "use strict";
3971
+ }
3972
+ });
3973
+
3845
3974
  // src/compliance-transport.ts
3846
3975
  function readListField(value) {
3847
3976
  return Array.isArray(value) ? value : value === void 0 ? [] : [value];
@@ -3896,7 +4025,7 @@ async function projectAuditorTerminal(summoned) {
3896
4025
  };
3897
4026
  }
3898
4027
  if (outcome.kind === "failure") {
3899
- const rows = outcome.payloads ?? summoned.terminal?.submissions ?? [];
4028
+ const rows = summoned.terminal?.submissions ?? [];
3900
4029
  return {
3901
4030
  status: "transport_failure",
3902
4031
  diagnostic: outcome.diagnostic,
@@ -3906,7 +4035,10 @@ async function projectAuditorTerminal(summoned) {
3906
4035
  };
3907
4036
  }
3908
4037
  if (outcome.kind === "accepted") {
3909
- const rows = outcome.payloads ?? summoned.terminal?.submissions ?? [];
4038
+ const rows = coalesceSubmissionRows(
4039
+ outcome.payloads,
4040
+ summoned.terminal?.submissions
4041
+ );
3910
4042
  if (rows.length === 0) {
3911
4043
  return readComplianceCandidate({}, usage);
3912
4044
  }
@@ -3968,6 +4100,7 @@ var init_compliance_transport = __esm({
3968
4100
  "use strict";
3969
4101
  init_auditor_dossier_tool();
3970
4102
  init_gatekeeper_role();
4103
+ init_terminal();
3971
4104
  AUDITOR_DOSSIER_PROMPT = "\u5377\u5B97\u6307\u9488\uFF1A";
3972
4105
  AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
3973
4106
  AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
@@ -14723,100 +14856,6 @@ var init_receipt_delivery_policy = __esm({
14723
14856
  }
14724
14857
  });
14725
14858
 
14726
- // src/public-cli/terminal.ts
14727
- function encodeTerminalField(value) {
14728
- return JSON.stringify(value);
14729
- }
14730
- function isLawfulTypedTerminalOutcome(outcome) {
14731
- return outcome.kind === "accepted" || outcome.kind === "audit_escalation" || outcome.kind === "no_receipt";
14732
- }
14733
- function exitCodeForTerminalOutcome(outcome) {
14734
- return isLawfulTypedTerminalOutcome(outcome) ? 0 : 1;
14735
- }
14736
- function adviceNavigatorFact(input) {
14737
- return {
14738
- disposition: "advice",
14739
- prose: input.prose,
14740
- ...input.advisoryDiagnostic === void 0 ? {} : { advisoryDiagnostic: input.advisoryDiagnostic }
14741
- };
14742
- }
14743
- function formatTerminalResult(result) {
14744
- const lines = [];
14745
- lines.push("role outcome status");
14746
- const outcomeStatus = result.roleOutcome.kind === "failure" ? result.roleOutcome.cause ?? "" : result.roleOutcome.kind === "accepted" ? "accepted" : result.roleOutcome.status;
14747
- lines.push(
14748
- `${result.roleOutcome.role} ${result.roleOutcome.kind} ${encodeTerminalField(outcomeStatus)}`
14749
- );
14750
- if (result.roleOutcome.kind === "failure") {
14751
- lines.push(
14752
- `diagnostic ${encodeTerminalField(result.roleOutcome.diagnostic)}`
14753
- );
14754
- }
14755
- if (result.roleOutcome.kind === "failure" || result.roleOutcome.kind === "no_receipt") {
14756
- const facts = result.roleOutcome.decisiveFacts;
14757
- for (const [key, value] of Object.entries(facts)) {
14758
- if (value === void 0) continue;
14759
- const rendered = typeof value === "string" ? value : JSON.stringify(value);
14760
- lines.push(`fact ${encodeTerminalField(key)} ${encodeTerminalField(rendered)}`);
14761
- }
14762
- }
14763
- lines.push(`navigator ${result.navigator.disposition}`);
14764
- if (result.navigator.advisoryDiagnostic !== void 0) {
14765
- lines.push(`navigator-advisory ${encodeTerminalField(result.navigator.advisoryDiagnostic)}`);
14766
- }
14767
- if (result.navigator.disposition === "advice") {
14768
- lines.push(`prose ${encodeTerminalField(result.navigator.prose)}`);
14769
- } else if (result.navigator.disposition === "unavailable") {
14770
- lines.push(
14771
- `unavailable ${result.navigator.source} ${encodeTerminalField(result.navigator.reason)}`
14772
- );
14773
- }
14774
- for (const artifact of result.artifacts) {
14775
- lines.push(`artifact ${artifact.kind} ${encodeTerminalField(artifact.path)}`);
14776
- }
14777
- if (result.gate !== void 0) {
14778
- lines.push(
14779
- `gate ${encodeTerminalField(result.gate.actualSeats.join(","))} ${result.gate.rounds.length}`
14780
- );
14781
- for (const round of result.gate.rounds) {
14782
- const reason = round.dispatch.kind === "historical_dispatch" && round.dispatch.reason !== void 0 ? encodeTerminalField(round.dispatch.reason) : "";
14783
- lines.push(
14784
- `gate-round ${round.roundIndex} ${round.dispatch.kind} ${round.dispatch.officer} ${reason} ${round.officer.seat} ${encodeTerminalField(round.officer.status)} ${encodeTerminalField(JSON.stringify(round.officer.findings))}`
14785
- );
14786
- }
14787
- }
14788
- if (result.reviewerChildOutcomes !== void 0) {
14789
- for (const axis of ["completeness", "correctness"]) {
14790
- const child = result.reviewerChildOutcomes[axis];
14791
- lines.push(`reviewer-child ${axis} ${child.exitCode}`);
14792
- if (child.stderr !== void 0 && child.stderr !== "") {
14793
- lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
14794
- }
14795
- }
14796
- }
14797
- if (result.resume !== void 0) {
14798
- lines.push(`resume ${encodeTerminalField(result.resume.command)}`);
14799
- } else if (result.runId !== void 0) {
14800
- lines.push(`run ${encodeTerminalField(result.runId)}`);
14801
- }
14802
- if (result.autoResumeCount !== void 0) {
14803
- lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
14804
- }
14805
- const payloads = result.roleOutcome.kind === "accepted" || result.roleOutcome.kind === "audit_escalation" ? result.roleOutcome.payloads ?? result.submissions ?? [] : result.roleOutcome.kind === "failure" ? result.roleOutcome.payloads ?? result.submissions ?? [] : result.submissions ?? [];
14806
- for (let i = payloads.length - 1; i >= 0; i -= 1) {
14807
- const payload = payloads[i];
14808
- const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
14809
- lines.push(`submission ${encodeTerminalField(rendered)}`);
14810
- }
14811
- return `${lines.join("\n")}
14812
- `;
14813
- }
14814
- var init_terminal = __esm({
14815
- "src/public-cli/terminal.ts"() {
14816
- "use strict";
14817
- }
14818
- });
14819
-
14820
14859
  // src/public-cli/settlement.ts
14821
14860
  var settlement_exports = {};
14822
14861
  __export(settlement_exports, {
@@ -14898,7 +14937,7 @@ __export(settlement_exports, {
14898
14937
  withSubmissions: () => withSubmissions
14899
14938
  });
14900
14939
  import { randomUUID as randomUUID4 } from "node:crypto";
14901
- import { appendFile as appendFile2, readFile as readFile16, readdir as readdir7, writeFile as writeFile7 } from "node:fs/promises";
14940
+ import { appendFile as appendFile2, readFile as readFile16, readdir as readdir7, rm as rm3, writeFile as writeFile7 } from "node:fs/promises";
14902
14941
  import { dirname as dirname14, join as join28 } from "node:path";
14903
14942
  function sealedLedgerHome(admitted) {
14904
14943
  return homeFromRunDirectory(admitted.runDirectory);
@@ -14959,7 +14998,13 @@ async function recordedSubmissionPayloads(admitted, scope) {
14959
14998
  function withSubmissions(terminal, submissions) {
14960
14999
  if (submissions.length === 0) return terminal;
14961
15000
  const roleOutcome = terminal.roleOutcome;
14962
- const withPayloads = roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation" ? { ...roleOutcome, payloads: (roleOutcome.payloads ?? []).length > 0 ? roleOutcome.payloads : submissions } : roleOutcome.kind === "failure" ? { ...roleOutcome, payloads: roleOutcome.payloads ?? submissions } : roleOutcome;
15001
+ if (roleOutcome.kind === "failure") {
15002
+ return { ...terminal, submissions };
15003
+ }
15004
+ const withPayloads = roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation" ? {
15005
+ ...roleOutcome,
15006
+ payloads: coalesceSubmissionRows(roleOutcome.payloads, submissions)
15007
+ } : roleOutcome;
14963
15008
  return { ...terminal, roleOutcome: withPayloads, submissions };
14964
15009
  }
14965
15010
  async function attachRecordedSubmissions(admitted, terminal, scope) {
@@ -14978,6 +15023,7 @@ async function settleHostEndedNoReceipt(admitted, authority, scope) {
14978
15023
  attemptPointer: `current:${admitted.runDirectory}`
14979
15024
  });
14980
15025
  const coordinates = coordinatesFromAdmitted(authority, admitted);
15026
+ await clearOppositeTerminalArtifactFace(admitted.runDirectory);
14981
15027
  return withOptionalGateProjection(
14982
15028
  {
14983
15029
  roleOutcome: {
@@ -15248,6 +15294,9 @@ function explicitInternalKnownFailureClassificationInput(failure2) {
15248
15294
  function isMissingPathError4(error) {
15249
15295
  return error instanceof Error && "code" in error && error.code === "ENOENT";
15250
15296
  }
15297
+ function isAbsentFacePathError(error) {
15298
+ return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
15299
+ }
15251
15300
  function sessionReadFailure(error, fallbackMessage) {
15252
15301
  if (error instanceof SyntaxError) {
15253
15302
  const failed2 = new SyntaxError(
@@ -16006,43 +16055,60 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
16006
16055
  };
16007
16056
  }
16008
16057
  }
16009
- async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
16010
- await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
16011
- const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
16058
+ async function removeFaceIfPresent(path) {
16059
+ try {
16060
+ await rm3(path, { recursive: true, force: true });
16061
+ } catch (error) {
16062
+ if (isAbsentFacePathError(error)) return;
16063
+ throw error;
16064
+ }
16065
+ }
16066
+ async function clearOppositeTerminalArtifactFace(runDirectory) {
16067
+ const artifactsDir = roleRunArtifactsDirectory(runDirectory);
16068
+ for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
16069
+ await removeFaceIfPresent(join28(artifactsDir, file));
16070
+ }
16071
+ for (const relative5 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
16072
+ await removeFaceIfPresent(join28(runDirectory, relative5));
16073
+ }
16074
+ for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
16075
+ await removeFaceIfPresent(path);
16076
+ }
16077
+ }
16078
+ async function ensureTerminalArtifactFace(runDirectory) {
16079
+ const artifactsDir = await ensureRunArtifactsDir(runDirectory);
16080
+ await clearOppositeTerminalArtifactFace(runDirectory);
16081
+ return artifactsDir;
16082
+ }
16083
+ function acceptedArtifactAttachmentRefs(attachments) {
16084
+ return attachments.map((a) => ({
16085
+ provenancePath: a.provenancePath,
16086
+ frozenPath: a.frozenPath,
16087
+ sha256: a.sha256,
16088
+ byteLength: a.byteLength
16089
+ }));
16090
+ }
16091
+ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, bodies) {
16092
+ await appendRunAttemptHistory(
16093
+ {
16094
+ role: admitted.role,
16095
+ runId: admitted.runId,
16096
+ sessionFile: coordinates.sessionFile
16097
+ },
16098
+ roleOutcome
16099
+ );
16100
+ const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
16012
16101
  const reportPath = join28(artifactsDir, "report.json");
16013
16102
  const evidencePath = join28(artifactsDir, "evidence.json");
16014
16103
  await writeFile7(
16015
16104
  reportPath,
16016
- `${JSON.stringify(
16017
- {
16018
- role: "judge",
16019
- runId: admitted.runId,
16020
- outcome: roleOutcome
16021
- },
16022
- null,
16023
- 2
16024
- )}
16105
+ `${JSON.stringify(bodies.report, null, 2)}
16025
16106
  `,
16026
16107
  "utf8"
16027
16108
  );
16028
16109
  await writeFile7(
16029
16110
  evidencePath,
16030
- `${JSON.stringify(
16031
- {
16032
- runId: admitted.runId,
16033
- sessionDirectory: coordinates.sessionDirectory,
16034
- sessionFile: coordinates.sessionFile,
16035
- admittedRequestPath: admitted.admittedRequestPath,
16036
- attachments: admitted.attachments.map((a) => ({
16037
- provenancePath: a.provenancePath,
16038
- frozenPath: a.frozenPath,
16039
- sha256: a.sha256,
16040
- byteLength: a.byteLength
16041
- }))
16042
- },
16043
- null,
16044
- 2
16045
- )}
16111
+ `${JSON.stringify(bodies.evidence, null, 2)}
16046
16112
  `,
16047
16113
  "utf8"
16048
16114
  );
@@ -16051,55 +16117,42 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
16051
16117
  { kind: "evidence", path: evidencePath }
16052
16118
  ];
16053
16119
  }
16120
+ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
16121
+ return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
16122
+ report: {
16123
+ role: "judge",
16124
+ runId: admitted.runId,
16125
+ outcome: roleOutcome
16126
+ },
16127
+ evidence: {
16128
+ runId: admitted.runId,
16129
+ sessionDirectory: coordinates.sessionDirectory,
16130
+ sessionFile: coordinates.sessionFile,
16131
+ admittedRequestPath: admitted.admittedRequestPath,
16132
+ attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
16133
+ }
16134
+ });
16135
+ }
16054
16136
  async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
16055
- await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
16056
- const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
16057
- const reportPath = join28(artifactsDir, "report.json");
16058
- const evidencePath = join28(artifactsDir, "evidence.json");
16059
- await writeFile7(
16060
- reportPath,
16061
- `${JSON.stringify(
16062
- {
16063
- role: "coder",
16064
- runId: admitted.runId,
16065
- phase: admitted.phase,
16066
- outcome: roleOutcome
16067
- },
16068
- null,
16069
- 2
16070
- )}
16071
- `,
16072
- "utf8"
16073
- );
16074
- await writeFile7(
16075
- evidencePath,
16076
- `${JSON.stringify(
16077
- {
16078
- runId: admitted.runId,
16079
- role: "coder",
16080
- phase: admitted.phase,
16081
- sessionDirectory: coordinates.sessionDirectory,
16082
- sessionFile: coordinates.sessionFile,
16083
- admittedRequestPath: admitted.admittedRequestPath,
16084
- taskPath: admitted.taskPath,
16085
- attachments: admitted.attachments.map((a) => ({
16086
- provenancePath: a.provenancePath,
16087
- frozenPath: a.frozenPath,
16088
- sha256: a.sha256,
16089
- byteLength: a.byteLength
16090
- })),
16091
- ...options.methodProvenance === void 0 ? {} : { methodProvenance: options.methodProvenance }
16092
- },
16093
- null,
16094
- 2
16095
- )}
16096
- `,
16097
- "utf8"
16098
- );
16099
- return [
16100
- { kind: "report", path: reportPath },
16101
- { kind: "evidence", path: evidencePath }
16102
- ];
16137
+ return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
16138
+ report: {
16139
+ role: "coder",
16140
+ runId: admitted.runId,
16141
+ phase: admitted.phase,
16142
+ outcome: roleOutcome
16143
+ },
16144
+ evidence: {
16145
+ runId: admitted.runId,
16146
+ role: "coder",
16147
+ phase: admitted.phase,
16148
+ sessionDirectory: coordinates.sessionDirectory,
16149
+ sessionFile: coordinates.sessionFile,
16150
+ admittedRequestPath: admitted.admittedRequestPath,
16151
+ taskPath: admitted.taskPath,
16152
+ attachments: acceptedArtifactAttachmentRefs(admitted.attachments),
16153
+ ...options.methodProvenance === void 0 ? {} : { methodProvenance: options.methodProvenance }
16154
+ }
16155
+ });
16103
16156
  }
16104
16157
  async function readLawfulSettlementEntries(sessionFile) {
16105
16158
  try {
@@ -16210,59 +16263,30 @@ function extractFixerMethodInvocations(entries, options) {
16210
16263
  return Object.freeze(observed);
16211
16264
  }
16212
16265
  async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
16213
- await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
16214
- const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
16215
- const reportPath = join28(artifactsDir, "report.json");
16216
- const evidencePath = join28(artifactsDir, "evidence.json");
16217
- await writeFile7(
16218
- reportPath,
16219
- `${JSON.stringify(
16220
- {
16221
- role: "fixer",
16222
- runId: admitted.runId,
16223
- phase: admitted.phase,
16224
- outcome: roleOutcome
16225
- },
16226
- null,
16227
- 2
16228
- )}
16229
- `,
16230
- "utf8"
16231
- );
16232
- await writeFile7(
16233
- evidencePath,
16234
- `${JSON.stringify(
16235
- {
16236
- runId: admitted.runId,
16237
- role: "fixer",
16238
- phase: admitted.phase,
16239
- sessionDirectory: coordinates.sessionDirectory,
16240
- sessionFile: coordinates.sessionFile,
16241
- admittedRequestPath: admitted.admittedRequestPath,
16242
- packetPath: admitted.packetPath,
16243
- ...admitted.prerequisitesPath === void 0 ? {} : { prerequisitesPath: admitted.prerequisitesPath },
16244
- prerequisites: admitted.prerequisites,
16245
- attachments: admitted.attachments.map((a) => ({
16246
- provenancePath: a.provenancePath,
16247
- frozenPath: a.frozenPath,
16248
- sha256: a.sha256,
16249
- byteLength: a.byteLength
16250
- })),
16251
- methodProvenance: options.methodProvenance,
16252
- // Optional diagnosis: availability is package-bound; invocation only when observed.
16253
- methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
16254
- methodInvocations: options.methodInvocations ?? []
16255
- },
16256
- null,
16257
- 2
16258
- )}
16259
- `,
16260
- "utf8"
16261
- );
16262
- return [
16263
- { kind: "report", path: reportPath },
16264
- { kind: "evidence", path: evidencePath }
16265
- ];
16266
+ return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
16267
+ report: {
16268
+ role: "fixer",
16269
+ runId: admitted.runId,
16270
+ phase: admitted.phase,
16271
+ outcome: roleOutcome
16272
+ },
16273
+ evidence: {
16274
+ runId: admitted.runId,
16275
+ role: "fixer",
16276
+ phase: admitted.phase,
16277
+ sessionDirectory: coordinates.sessionDirectory,
16278
+ sessionFile: coordinates.sessionFile,
16279
+ admittedRequestPath: admitted.admittedRequestPath,
16280
+ packetPath: admitted.packetPath,
16281
+ ...admitted.prerequisitesPath === void 0 ? {} : { prerequisitesPath: admitted.prerequisitesPath },
16282
+ prerequisites: admitted.prerequisites,
16283
+ attachments: acceptedArtifactAttachmentRefs(admitted.attachments),
16284
+ methodProvenance: options.methodProvenance,
16285
+ // Optional diagnosis: availability is package-bound; invocation only when observed.
16286
+ methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
16287
+ methodInvocations: options.methodInvocations ?? []
16288
+ }
16289
+ });
16266
16290
  }
16267
16291
  async function settleLawfulFixerTerminalResult(admitted, authority, options, scope) {
16268
16292
  const ledgerOutcome = await closedLedgerOutcome(admitted, "fixer", scope);
@@ -16308,53 +16332,24 @@ async function settleFixerTerminalResult(admitted, authority, options, scope) {
16308
16332
  return settled;
16309
16333
  }
16310
16334
  async function publishCollectorArtifacts(admitted, roleOutcome, coordinates) {
16311
- await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
16312
- const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
16313
- const reportPath = join28(artifactsDir, "report.json");
16314
- const evidencePath = join28(artifactsDir, "evidence.json");
16315
- await writeFile7(
16316
- reportPath,
16317
- `${JSON.stringify(
16318
- {
16319
- role: "collector",
16320
- runId: admitted.runId,
16321
- outcome: roleOutcome
16322
- },
16323
- null,
16324
- 2
16325
- )}
16326
- `,
16327
- "utf8"
16328
- );
16329
- await writeFile7(
16330
- evidencePath,
16331
- `${JSON.stringify(
16332
- {
16333
- runId: admitted.runId,
16334
- role: "collector",
16335
- ...admitted.prNumber === void 0 ? {} : { prNumber: admitted.prNumber },
16336
- repository: admitted.repository.canonical,
16337
- manifestDigest: admitted.manifestDigest,
16338
- sessionDirectory: coordinates.sessionDirectory,
16339
- sessionFile: coordinates.sessionFile,
16340
- admittedRequestPath: admitted.admittedRequestPath,
16341
- attachments: admitted.attachments.map((a) => ({
16342
- provenancePath: a.provenancePath,
16343
- frozenPath: a.frozenPath,
16344
- sha256: a.sha256,
16345
- byteLength: a.byteLength
16346
- }))
16347
- },
16348
- null,
16349
- 2
16350
- )}
16351
- `,
16352
- "utf8"
16353
- );
16354
- return [
16355
- { kind: "report", path: reportPath },
16356
- { kind: "evidence", path: evidencePath }
16357
- ];
16335
+ return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
16336
+ report: {
16337
+ role: "collector",
16338
+ runId: admitted.runId,
16339
+ outcome: roleOutcome
16340
+ },
16341
+ evidence: {
16342
+ runId: admitted.runId,
16343
+ role: "collector",
16344
+ ...admitted.prNumber === void 0 ? {} : { prNumber: admitted.prNumber },
16345
+ repository: admitted.repository.canonical,
16346
+ manifestDigest: admitted.manifestDigest,
16347
+ sessionDirectory: coordinates.sessionDirectory,
16348
+ sessionFile: coordinates.sessionFile,
16349
+ admittedRequestPath: admitted.admittedRequestPath,
16350
+ attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
16351
+ }
16352
+ });
16358
16353
  }
16359
16354
  async function settleLawfulCollectorTerminalResult(admitted, authority, scope) {
16360
16355
  const coordinates = coordinatesFromAdmitted(authority, admitted);
@@ -16441,55 +16436,26 @@ function extractDoctorCandidateAuditNoReceiptFact(entries) {
16441
16436
  return void 0;
16442
16437
  }
16443
16438
  async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
16444
- await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
16445
- const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
16446
- const reportPath = join28(artifactsDir, "report.json");
16447
- const evidencePath = join28(artifactsDir, "evidence.json");
16448
- await writeFile7(
16449
- reportPath,
16450
- `${JSON.stringify(
16451
- {
16452
- role: "doctor",
16453
- runId: admitted.runId,
16454
- outcome: roleOutcome,
16455
- ...options.cost === void 0 ? {} : { cost: options.cost },
16456
- ...options.auditNoReceipt === void 0 ? {} : { auditNoReceipt: options.auditNoReceipt }
16457
- },
16458
- null,
16459
- 2
16460
- )}
16461
- `,
16462
- "utf8"
16463
- );
16464
- await writeFile7(
16465
- evidencePath,
16466
- `${JSON.stringify(
16467
- {
16468
- runId: admitted.runId,
16469
- role: "doctor",
16470
- issueNumber: admitted.issueNumber,
16471
- caseRunsPath: admitted.caseRunsPath,
16472
- caseIdentity: admitted.caseIdentity,
16473
- sessionDirectory: coordinates.sessionDirectory,
16474
- sessionFile: coordinates.sessionFile,
16475
- admittedRequestPath: admitted.admittedRequestPath,
16476
- attachments: admitted.attachments.map((a) => ({
16477
- provenancePath: a.provenancePath,
16478
- frozenPath: a.frozenPath,
16479
- sha256: a.sha256,
16480
- byteLength: a.byteLength
16481
- }))
16482
- },
16483
- null,
16484
- 2
16485
- )}
16486
- `,
16487
- "utf8"
16488
- );
16489
- return [
16490
- { kind: "report", path: reportPath },
16491
- { kind: "evidence", path: evidencePath }
16492
- ];
16439
+ return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
16440
+ report: {
16441
+ role: "doctor",
16442
+ runId: admitted.runId,
16443
+ outcome: roleOutcome,
16444
+ ...options.cost === void 0 ? {} : { cost: options.cost },
16445
+ ...options.auditNoReceipt === void 0 ? {} : { auditNoReceipt: options.auditNoReceipt }
16446
+ },
16447
+ evidence: {
16448
+ runId: admitted.runId,
16449
+ role: "doctor",
16450
+ issueNumber: admitted.issueNumber,
16451
+ caseRunsPath: admitted.caseRunsPath,
16452
+ caseIdentity: admitted.caseIdentity,
16453
+ sessionDirectory: coordinates.sessionDirectory,
16454
+ sessionFile: coordinates.sessionFile,
16455
+ admittedRequestPath: admitted.admittedRequestPath,
16456
+ attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
16457
+ }
16458
+ });
16493
16459
  }
16494
16460
  async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
16495
16461
  const sealed = await sealedLedgerOutcome(admitted, "doctor", scope);
@@ -16555,6 +16521,22 @@ function currentAttemptStartIndex(entries) {
16555
16521
  }
16556
16522
  return 0;
16557
16523
  }
16524
+ async function publishSeatAcceptedArtifacts(admitted, roleOutcome, coordinates) {
16525
+ return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
16526
+ report: {
16527
+ role: admitted.role,
16528
+ runId: admitted.runId,
16529
+ outcome: roleOutcome
16530
+ },
16531
+ evidence: {
16532
+ runId: admitted.runId,
16533
+ sessionDirectory: coordinates.sessionDirectory,
16534
+ sessionFile: coordinates.sessionFile,
16535
+ admittedRequestPath: admitted.admittedRequestPath,
16536
+ attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
16537
+ }
16538
+ });
16539
+ }
16558
16540
  async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec, scope) {
16559
16541
  const coordinates = coordinatesFromAdmitted(authority, admitted);
16560
16542
  const { sessionDirectory, sessionFile } = coordinates;
@@ -16585,12 +16567,17 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
16585
16567
  const roleOutcome = await closedLedgerOutcome(admitted, spec.role, scope);
16586
16568
  if (roleOutcome !== void 0 && (thisAttemptHasSeatSuccess || residual === void 0)) {
16587
16569
  const navigator = extractNavigatorFact(entries);
16570
+ const artifacts = await publishSeatAcceptedArtifacts(
16571
+ admitted,
16572
+ roleOutcome,
16573
+ coordinates
16574
+ );
16588
16575
  return withSubmissions(
16589
16576
  await withOptionalGateProjection(
16590
16577
  {
16591
16578
  roleOutcome,
16592
16579
  navigator,
16593
- artifacts: [],
16580
+ artifacts,
16594
16581
  runId: admitted.runId
16595
16582
  },
16596
16583
  sessionDirectory,
@@ -16810,58 +16797,29 @@ function extractReviewerMethodInvocations(entries, options) {
16810
16797
  return Object.freeze(observed);
16811
16798
  }
16812
16799
  async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
16813
- await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
16814
- const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
16815
- const reportPath = join28(artifactsDir, "report.json");
16816
- const evidencePath = join28(artifactsDir, "evidence.json");
16817
- await writeFile7(
16818
- reportPath,
16819
- `${JSON.stringify(
16820
- {
16821
- role: "reviewer",
16822
- runId: admitted.runId,
16823
- outcome: roleOutcome
16824
- },
16825
- null,
16826
- 2
16827
- )}
16828
- `,
16829
- "utf8"
16830
- );
16831
- await writeFile7(
16832
- evidencePath,
16833
- `${JSON.stringify(
16834
- {
16835
- runId: admitted.runId,
16836
- role: "reviewer",
16837
- sessionDirectory: coordinates.sessionDirectory,
16838
- sessionFile: coordinates.sessionFile,
16839
- admittedRequestPath: admitted.admittedRequestPath,
16840
- baseRevision: admitted.baseRevision,
16841
- lens: admitted.lens,
16842
- authorityRefs: [...admitted.authorityRefs],
16843
- ...admitted.instructionEmpty ? {} : { callerProvenance: admitted.instruction },
16844
- attachments: admitted.attachments.map((a) => ({
16845
- provenancePath: a.provenancePath,
16846
- frozenPath: a.frozenPath,
16847
- sha256: a.sha256,
16848
- byteLength: a.byteLength
16849
- })),
16850
- methodProvenance: options.methodProvenance,
16851
- // Forced package method: availability is package-bound; expansion only when observed.
16852
- methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
16853
- methodInvocations: options.methodInvocations ?? []
16854
- },
16855
- null,
16856
- 2
16857
- )}
16858
- `,
16859
- "utf8"
16860
- );
16861
- return [
16862
- { kind: "report", path: reportPath },
16863
- { kind: "evidence", path: evidencePath }
16864
- ];
16800
+ return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
16801
+ report: {
16802
+ role: "reviewer",
16803
+ runId: admitted.runId,
16804
+ outcome: roleOutcome
16805
+ },
16806
+ evidence: {
16807
+ runId: admitted.runId,
16808
+ role: "reviewer",
16809
+ sessionDirectory: coordinates.sessionDirectory,
16810
+ sessionFile: coordinates.sessionFile,
16811
+ admittedRequestPath: admitted.admittedRequestPath,
16812
+ baseRevision: admitted.baseRevision,
16813
+ lens: admitted.lens,
16814
+ authorityRefs: [...admitted.authorityRefs],
16815
+ ...admitted.instructionEmpty ? {} : { callerProvenance: admitted.instruction },
16816
+ attachments: acceptedArtifactAttachmentRefs(admitted.attachments),
16817
+ methodProvenance: options.methodProvenance,
16818
+ // Forced package method: availability is package-bound; expansion only when observed.
16819
+ methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
16820
+ methodInvocations: options.methodInvocations ?? []
16821
+ }
16822
+ });
16865
16823
  }
16866
16824
  async function settleLawfulReviewerTerminalResult(admitted, authority, options, scope) {
16867
16825
  const sealed = await sealedLedgerOutcome(admitted, "reviewer", scope);
@@ -16926,55 +16884,26 @@ function extractMergerMethodInvocations(entries, options) {
16926
16884
  return Object.freeze(observed);
16927
16885
  }
16928
16886
  async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
16929
- await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
16930
- const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
16931
- const reportPath = join28(artifactsDir, "report.json");
16932
- const evidencePath = join28(artifactsDir, "evidence.json");
16933
- await writeFile7(
16934
- reportPath,
16935
- `${JSON.stringify(
16936
- {
16937
- role: "merger",
16938
- runId: admitted.runId,
16939
- outcome: roleOutcome
16940
- },
16941
- null,
16942
- 2
16943
- )}
16944
- `,
16945
- "utf8"
16946
- );
16947
- await writeFile7(
16948
- evidencePath,
16949
- `${JSON.stringify(
16950
- {
16951
- runId: admitted.runId,
16952
- role: "merger",
16953
- sessionDirectory: coordinates.sessionDirectory,
16954
- sessionFile: coordinates.sessionFile,
16955
- admittedRequestPath: admitted.admittedRequestPath,
16956
- mergerInputPath: admitted.mergerInputPath,
16957
- derived: admitted.derived,
16958
- attachments: admitted.attachments.map((a) => ({
16959
- provenancePath: a.provenancePath,
16960
- frozenPath: a.frozenPath,
16961
- sha256: a.sha256,
16962
- byteLength: a.byteLength
16963
- })),
16964
- methodProvenance: options.methodProvenance,
16965
- methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
16966
- methodInvocations: options.methodInvocations ?? []
16967
- },
16968
- null,
16969
- 2
16970
- )}
16971
- `,
16972
- "utf8"
16973
- );
16974
- return [
16975
- { kind: "report", path: reportPath },
16976
- { kind: "evidence", path: evidencePath }
16977
- ];
16887
+ return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
16888
+ report: {
16889
+ role: "merger",
16890
+ runId: admitted.runId,
16891
+ outcome: roleOutcome
16892
+ },
16893
+ evidence: {
16894
+ runId: admitted.runId,
16895
+ role: "merger",
16896
+ sessionDirectory: coordinates.sessionDirectory,
16897
+ sessionFile: coordinates.sessionFile,
16898
+ admittedRequestPath: admitted.admittedRequestPath,
16899
+ mergerInputPath: admitted.mergerInputPath,
16900
+ derived: admitted.derived,
16901
+ attachments: acceptedArtifactAttachmentRefs(admitted.attachments),
16902
+ methodProvenance: options.methodProvenance,
16903
+ methodInvocationObserved: (options.methodInvocations ?? []).length > 0,
16904
+ methodInvocations: options.methodInvocations ?? []
16905
+ }
16906
+ });
16978
16907
  }
16979
16908
  async function settleLawfulMergerTerminalResult(admitted, authority, options, scope) {
16980
16909
  const coordinates = coordinatesFromAdmitted(authority, admitted);
@@ -17121,6 +17050,16 @@ async function publishFailureArtifacts(admitted, failure2, authority) {
17121
17050
  admitted.runDirectory
17122
17051
  );
17123
17052
  const priorIssues = baseAttempt === void 0 ? [] : [baseAttempt];
17053
+ try {
17054
+ await clearOppositeTerminalArtifactFace(admitted.runDirectory);
17055
+ } catch (error) {
17056
+ priorIssues.push(
17057
+ publicationAttemptFromError(
17058
+ roleRunArtifactsDirectory(admitted.runDirectory),
17059
+ error
17060
+ )
17061
+ );
17062
+ }
17124
17063
  try {
17125
17064
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile }, {
17126
17065
  kind: "failure",
@@ -17209,33 +17148,41 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
17209
17148
  const lifecycleEntry = entries.slice(attemptStart).reverse().find((entry) => entry.customType === NO_RECEIPT_LIFECYCLE_ENTRY_TYPE || entry.message?.customType === NO_RECEIPT_LIFECYCLE_ENTRY_TYPE);
17210
17149
  const raw = lifecycleEntry?.data ?? lifecycleEntry?.message?.details;
17211
17150
  if (raw !== void 0) {
17151
+ let facts;
17212
17152
  try {
17213
- const facts = parseNoReceiptLifecycleFacts(raw);
17214
- if (facts.runPointer === admitted.runDirectory && facts.attemptPointer === `current:${admitted.runDirectory}`) {
17215
- let decisiveFacts2 = facts;
17216
- if (admitted.role === "collector") {
17217
- const bindRejection = extractCollectorTargetBindRejection(entries.slice(attemptStart));
17218
- if (bindRejection !== void 0) {
17219
- decisiveFacts2 = {
17220
- ...facts,
17221
- targetBindRejected: true,
17222
- targetBindDiagnostic: bindRejection.diagnostic,
17223
- ...bindRejection.code === void 0 ? {} : { targetBindCode: bindRejection.code }
17224
- };
17225
- }
17153
+ facts = parseNoReceiptLifecycleFacts(raw);
17154
+ } catch {
17155
+ }
17156
+ if (facts !== void 0 && facts.runPointer === admitted.runDirectory && facts.attemptPointer === `current:${admitted.runDirectory}`) {
17157
+ let decisiveFacts2 = facts;
17158
+ if (admitted.role === "collector") {
17159
+ const bindRejection = extractCollectorTargetBindRejection(entries.slice(attemptStart));
17160
+ if (bindRejection !== void 0) {
17161
+ decisiveFacts2 = {
17162
+ ...facts,
17163
+ targetBindRejected: true,
17164
+ targetBindDiagnostic: bindRejection.diagnostic,
17165
+ ...bindRejection.code === void 0 ? {} : { targetBindCode: bindRejection.code }
17166
+ };
17226
17167
  }
17227
- return withOptionalGateProjection(
17228
- {
17229
- roleOutcome: { kind: "no_receipt", role: admitted.role, status: "no-accepted-receipt", ...facts, decisiveFacts: decisiveFacts2 },
17230
- navigator: await extractNavigatorFactFromAdmittedSession(sessionFile),
17231
- artifacts: [],
17232
- runId: admitted.runId
17233
- },
17234
- sessionDirectory,
17235
- detourGateContext(admitted, options)
17236
- );
17237
17168
  }
17238
- } catch {
17169
+ await clearOppositeTerminalArtifactFace(admitted.runDirectory);
17170
+ return withOptionalGateProjection(
17171
+ {
17172
+ roleOutcome: {
17173
+ kind: "no_receipt",
17174
+ role: admitted.role,
17175
+ status: "no-accepted-receipt",
17176
+ ...facts,
17177
+ decisiveFacts: decisiveFacts2
17178
+ },
17179
+ navigator: await extractNavigatorFactFromAdmittedSession(sessionFile),
17180
+ artifacts: [],
17181
+ runId: admitted.runId
17182
+ },
17183
+ sessionDirectory,
17184
+ detourGateContext(admitted, options)
17185
+ );
17239
17186
  }
17240
17187
  }
17241
17188
  }
@@ -17386,6 +17333,7 @@ var init_settlement = __esm({
17386
17333
  init_navigator_invocation_identity();
17387
17334
  init_receipt_delivery_policy();
17388
17335
  init_role_run_placement();
17336
+ init_run_terminal_artifacts();
17389
17337
  init_invocation();
17390
17338
  init_terminal();
17391
17339
  NAVIGATOR_POST_ROLE_GRACE_MS = 1e4;
@@ -17437,7 +17385,7 @@ var init_seat_ticket_binding = __esm({
17437
17385
  });
17438
17386
 
17439
17387
  // src/session-identity.ts
17440
- import { mkdir as mkdir3, readFile as readFile17, rename as rename2, writeFile as writeFile8 } from "node:fs/promises";
17388
+ import { mkdir as mkdir2, readFile as readFile17, rename as rename2, writeFile as writeFile8 } from "node:fs/promises";
17441
17389
  import { dirname as dirname15, join as join29 } from "node:path";
17442
17390
  function createSessionIdentityAuthority(authority, sessionBindingFile) {
17443
17391
  const bindingPath = (principal) => join29(authority.decode(principal).sessionDirectory, sessionBindingFile);
@@ -17459,7 +17407,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
17459
17407
  },
17460
17408
  async bind(principal, sessionId) {
17461
17409
  const target = bindingPath(principal);
17462
- await mkdir3(dirname15(target), { recursive: true });
17410
+ await mkdir2(dirname15(target), { recursive: true });
17463
17411
  const temporary = `${target}.${process.pid}.tmp`;
17464
17412
  await writeFile8(temporary, `${JSON.stringify({ sessionId })}
17465
17413
  `, { encoding: "utf8", mode: 384 });
@@ -18184,7 +18132,7 @@ __export(case_dossier_delivery_exports, {
18184
18132
  loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
18185
18133
  projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
18186
18134
  });
18187
- import { mkdtemp as mkdtemp3, readFile as readFile19, rm as rm3, writeFile as writeFile9 } from "node:fs/promises";
18135
+ import { mkdtemp as mkdtemp3, readFile as readFile19, rm as rm4, writeFile as writeFile9 } from "node:fs/promises";
18188
18136
  import { tmpdir as tmpdir3 } from "node:os";
18189
18137
  import { join as join31 } from "node:path";
18190
18138
  async function projectCaseDossierPointerSection(input) {
@@ -18224,7 +18172,7 @@ async function deliverCaseDossierAsAttachment(input) {
18224
18172
  CASE_DOSSIER_ATTACH_KEY
18225
18173
  );
18226
18174
  } finally {
18227
- await rm3(stagingDir, { recursive: true, force: true });
18175
+ await rm4(stagingDir, { recursive: true, force: true });
18228
18176
  }
18229
18177
  }
18230
18178
  async function loadCaseDossierReadingMaterial(runDirectory) {
@@ -18372,7 +18320,7 @@ var init_process_cancel = __esm({
18372
18320
  // src/public-cli/auto-resume.ts
18373
18321
  import { constants as fsConstants2 } from "node:fs";
18374
18322
  import { randomUUID as randomUUID5 } from "node:crypto";
18375
- import { lstat as lstat6, mkdir as mkdir4, open as open2 } from "node:fs/promises";
18323
+ import { lstat as lstat6, mkdir as mkdir3, open as open2 } from "node:fs/promises";
18376
18324
  import { join as join33 } from "node:path";
18377
18325
  async function persistReturnedRunState(admitted, authority, options) {
18378
18326
  if (options?.lawful === true) {
@@ -18421,7 +18369,7 @@ async function ensureRealArtifactsDirectory(runDirectory) {
18421
18369
  }
18422
18370
  } catch (error) {
18423
18371
  if (!isMissingPathError5(error)) throw error;
18424
- await mkdir4(artifactsDir, { recursive: true });
18372
+ await mkdir3(artifactsDir, { recursive: true });
18425
18373
  const created = await lstat6(artifactsDir);
18426
18374
  if (created.isSymbolicLink() || !created.isDirectory()) {
18427
18375
  throw new Error("run artifact retention: artifacts directory is not a real directory");
@@ -20879,9 +20827,39 @@ function buildCountersignTurnRequest(admitted, options) {
20879
20827
  options
20880
20828
  );
20881
20829
  }
20882
- function courtTicketNumbersFromOutcome(roleOutcome, principalTicket) {
20830
+ function isRecord14(value) {
20831
+ return typeof value === "object" && value !== null && !Array.isArray(value);
20832
+ }
20833
+ function isEscalatePayload(payload) {
20834
+ if (!isRecord14(payload)) return false;
20835
+ return payload.status === "escalate" || payload.countersignStatus === "escalate";
20836
+ }
20837
+ function courtDiaristPayloadRows(roleOutcome, submissions) {
20838
+ if (roleOutcome === void 0) return submissions ?? [];
20839
+ if (roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation") {
20840
+ return roleOutcome.payloads ?? [];
20841
+ }
20842
+ if (roleOutcome.kind === "failure") return submissions ?? [];
20843
+ return [];
20844
+ }
20845
+ function courtDiaristEscalateDiagnostic(roleOutcome, submissions) {
20846
+ const payloads = courtDiaristPayloadRows(roleOutcome, submissions);
20847
+ const escalatePayloads = [];
20848
+ for (const payload of payloads) {
20849
+ if (isEscalatePayload(payload)) escalatePayloads.push(payload);
20850
+ }
20851
+ if (escalatePayloads.length === 0) return "court diarist station escalated";
20852
+ if (escalatePayloads.length === 1) {
20853
+ return `court diarist station escalated: ${readableGateItem(escalatePayloads[0])}`;
20854
+ }
20855
+ return `court diarist station escalated: ${readableGateItem({
20856
+ receipts: escalatePayloads,
20857
+ currentConclusion: escalatePayloads[escalatePayloads.length - 1]
20858
+ })}`;
20859
+ }
20860
+ function courtTicketNumbersFromOutcome(roleOutcome, principalTicket, submissions) {
20883
20861
  if (roleOutcome === void 0) return void 0;
20884
- const payloads = roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation" || roleOutcome.kind === "failure" ? roleOutcome.payloads ?? [] : [];
20862
+ const payloads = courtDiaristPayloadRows(roleOutcome, submissions);
20885
20863
  let latest;
20886
20864
  for (const payload of payloads) {
20887
20865
  if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
@@ -20907,12 +20885,7 @@ function courtDiaristEscalated(roleOutcome) {
20907
20885
  if (roleOutcome === void 0) return false;
20908
20886
  if (roleOutcome.kind === "audit_escalation") return true;
20909
20887
  if (roleOutcome.kind !== "accepted") return false;
20910
- return (roleOutcome.payloads ?? []).some((payload) => {
20911
- if (typeof payload !== "object" || payload === null || Array.isArray(payload))
20912
- return false;
20913
- const record4 = payload;
20914
- return record4.status === "escalate" || record4.countersignStatus === "escalate";
20915
- });
20888
+ return (roleOutcome.payloads ?? []).some(isEscalatePayload);
20916
20889
  }
20917
20890
  async function invokeCourtDiarist(input, env, io) {
20918
20891
  const quietIo = {
@@ -20946,9 +20919,13 @@ async function invokeCourtDiarist(input, env, io) {
20946
20919
  ...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters }
20947
20920
  });
20948
20921
  const roleOutcome = result.terminal?.roleOutcome;
20922
+ const submissions = result.terminal?.submissions;
20949
20923
  if (courtDiaristEscalated(roleOutcome)) {
20950
20924
  return {
20951
- identity: { kind: "escalate" }
20925
+ identity: {
20926
+ kind: "escalate",
20927
+ diagnostic: courtDiaristEscalateDiagnostic(roleOutcome, submissions)
20928
+ }
20952
20929
  };
20953
20930
  }
20954
20931
  if (result.exitCode !== 0) {
@@ -20964,7 +20941,8 @@ async function invokeCourtDiarist(input, env, io) {
20964
20941
  if (isSafePositiveTicketNumber(asserted)) {
20965
20942
  const courtTicketNumbers = courtTicketNumbersFromOutcome(
20966
20943
  roleOutcome,
20967
- asserted
20944
+ asserted,
20945
+ submissions
20968
20946
  );
20969
20947
  return {
20970
20948
  identity: {
@@ -21009,9 +20987,7 @@ async function runCountersignCourtDiaristStation(admitted, env, io) {
21009
20987
  io
21010
20988
  );
21011
20989
  if (outcome.identity.kind === "escalate") {
21012
- throw new StationChildExhaustedError(
21013
- "court diarist station escalated (cannot identify court target)"
21014
- );
20990
+ throw new StationChildExhaustedError(outcome.identity.diagnostic);
21015
20991
  }
21016
20992
  if (outcome.failedWithoutEscalate !== void 0) {
21017
20993
  throw new StationChildExhaustedError(
@@ -21102,9 +21078,7 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
21102
21078
  timedOut: false,
21103
21079
  code: null,
21104
21080
  stderr: "",
21105
- thrown: new Error(
21106
- "court diarist station escalated (cannot identify court target)"
21107
- )
21081
+ thrown: new Error(outcome.identity.diagnostic)
21108
21082
  },
21109
21083
  countersignAdapters(),
21110
21084
  env.principalAuthority,
@@ -21329,6 +21303,7 @@ var init_countersign_run = __esm({
21329
21303
  init_engine_material();
21330
21304
  init_cli_errors();
21331
21305
  init_diarist_contracts();
21306
+ init_readable_gate_item();
21332
21307
  init_run_ticket_number();
21333
21308
  init_invocation();
21334
21309
  init_post_admission();
@@ -21675,7 +21650,7 @@ __export(public_role_summons_exports, {
21675
21650
  });
21676
21651
  import { execFile as execFile3 } from "node:child_process";
21677
21652
  import { existsSync as existsSync11 } from "node:fs";
21678
- import { mkdir as mkdir5, mkdtemp as mkdtemp4, realpath as realpath6, rm as rm4 } from "node:fs/promises";
21653
+ import { mkdir as mkdir4, mkdtemp as mkdtemp4, realpath as realpath6, rm as rm5 } from "node:fs/promises";
21679
21654
  import { tmpdir as tmpdir4 } from "node:os";
21680
21655
  import { join as join35, relative as relative3, sep as sep5 } from "node:path";
21681
21656
  import { promisify as promisify3 } from "node:util";
@@ -22074,7 +22049,7 @@ async function openEphemeralReviewerWorktree(options) {
22074
22049
  }
22075
22050
  }
22076
22051
  try {
22077
- await rm4(root, { recursive: true, force: true });
22052
+ await rm5(root, { recursive: true, force: true });
22078
22053
  } catch (error) {
22079
22054
  cleanupErrors.push(error);
22080
22055
  }
@@ -22092,7 +22067,7 @@ async function openEphemeralReviewerWorktree(options) {
22092
22067
  });
22093
22068
  registered = true;
22094
22069
  if (projectRelative !== "") {
22095
- await mkdir5(reviewerSandboxPath(worktreeRoot, projectRelative), { recursive: true });
22070
+ await mkdir4(reviewerSandboxPath(worktreeRoot, projectRelative), { recursive: true });
22096
22071
  }
22097
22072
  } catch (error) {
22098
22073
  await rollback(error);
@@ -22112,7 +22087,7 @@ async function openEphemeralReviewerWorktree(options) {
22112
22087
  cleanupErrors.push(error);
22113
22088
  }
22114
22089
  try {
22115
- await rm4(root, { recursive: true, force: true });
22090
+ await rm5(root, { recursive: true, force: true });
22116
22091
  } catch (error) {
22117
22092
  cleanupErrors.push(error);
22118
22093
  }
@@ -22204,7 +22179,7 @@ async function summonParallelReviewerLenses(options) {
22204
22179
  });
22205
22180
  created.add(path);
22206
22181
  if (projectRelative !== "") {
22207
- await mkdir5(reviewerSandboxPath(path, projectRelative), { recursive: true });
22182
+ await mkdir4(reviewerSandboxPath(path, projectRelative), { recursive: true });
22208
22183
  }
22209
22184
  })
22210
22185
  );
@@ -22299,7 +22274,7 @@ ${describeFailure(error)}`;
22299
22274
  );
22300
22275
  const cleanupFailures = cleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
22301
22276
  if (cleanupFailures.length === 0) {
22302
- const rootCleanup = await Promise.allSettled([rm4(root, { recursive: true, force: true })]);
22277
+ const rootCleanup = await Promise.allSettled([rm5(root, { recursive: true, force: true })]);
22303
22278
  cleanupFailures.push(...rootCleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []));
22304
22279
  }
22305
22280
  if (cleanupFailures.length > 0) {
@@ -22404,7 +22379,7 @@ import { randomUUID as randomUUID10 } from "node:crypto";
22404
22379
  // src/role-envelope.ts
22405
22380
  init_engine_detour();
22406
22381
  import { randomUUID as randomUUID9 } from "node:crypto";
22407
- import { appendFile as appendFile3, mkdir as mkdir7, writeFile as writeFile12 } from "node:fs/promises";
22382
+ import { appendFile as appendFile3, mkdir as mkdir6, writeFile as writeFile12 } from "node:fs/promises";
22408
22383
  import { createServer } from "node:net";
22409
22384
  import { dirname as dirname21, join as join41 } from "node:path";
22410
22385
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -22502,7 +22477,7 @@ async function requireGatekeeperPass(options) {
22502
22477
  }
22503
22478
 
22504
22479
  // src/host-native-method.ts
22505
- import { access as access4, lstat as lstat7, mkdir as mkdir6, readdir as readdir9, readFile as readFile20, readlink, realpath as realpath7, symlink } from "node:fs/promises";
22480
+ import { access as access4, lstat as lstat7, mkdir as mkdir5, readdir as readdir9, readFile as readFile20, readlink, realpath as realpath7, symlink } from "node:fs/promises";
22506
22481
  import { basename as basename9, dirname as dirname18, join as join36 } from "node:path";
22507
22482
  var packagedMethodsDir = (root) => join36(root, "resources", "methods");
22508
22483
  function hostMethodSkills(methods) {
@@ -22603,7 +22578,7 @@ async function installWorkspaceMethodSkills(cwd, packageRoot) {
22603
22578
  const detail = stat2.isSymbolicLink() ? `symlink to ${await readlink(link)}` : "non-symlink entry";
22604
22579
  throw new Error(`workspace method catalog conflict at ${link}: ${detail}`);
22605
22580
  }
22606
- await mkdir6(dirname18(link), { recursive: true });
22581
+ await mkdir5(dirname18(link), { recursive: true });
22607
22582
  try {
22608
22583
  await symlink(target, link);
22609
22584
  } catch (error) {
@@ -23046,6 +23021,7 @@ function registerEngineDetourTool(roleHost, hostActions) {
23046
23021
  }
23047
23022
 
23048
23023
  // src/role-runtime.ts
23024
+ init_readable_gate_item();
23049
23025
  init_run_terminal_artifacts();
23050
23026
  init_receipt_delivery_policy();
23051
23027
 
@@ -23060,7 +23036,7 @@ import { join as join38, sep as sep6 } from "node:path";
23060
23036
 
23061
23037
  // src/atomic-write.ts
23062
23038
  import { randomUUID as randomUUID7 } from "node:crypto";
23063
- import { rename as rename3, rm as rm5, writeFile as writeFile11 } from "node:fs/promises";
23039
+ import { rename as rename3, rm as rm6, writeFile as writeFile11 } from "node:fs/promises";
23064
23040
  import { dirname as dirname19, join as join37 } from "node:path";
23065
23041
  async function writeFileAtomically(destination, contents) {
23066
23042
  const parent = dirname19(destination);
@@ -23069,7 +23045,7 @@ async function writeFileAtomically(destination, contents) {
23069
23045
  await writeFile11(temporary, contents);
23070
23046
  await rename3(temporary, destination);
23071
23047
  } catch (error) {
23072
- await rm5(temporary, { force: true }).catch(() => void 0);
23048
+ await rm6(temporary, { force: true }).catch(() => void 0);
23073
23049
  throw error;
23074
23050
  }
23075
23051
  }
@@ -24293,15 +24269,14 @@ function projectSecretariatSummonResult(summoned) {
24293
24269
  };
24294
24270
  }
24295
24271
  if (roleOutcome.kind === "failure") {
24296
- const payloads = Array.isArray(roleOutcome.payloads) ? roleOutcome.payloads : void 0;
24272
+ const submissions = Array.isArray(terminal?.submissions) ? terminal.submissions : void 0;
24297
24273
  return {
24298
24274
  ...base,
24299
24275
  outcomeKind: "failure",
24300
24276
  diagnostic: roleOutcome.diagnostic,
24301
24277
  ...roleOutcome.cause === void 0 ? {} : { cause: roleOutcome.cause },
24302
24278
  ...roleOutcome.decisiveFacts === void 0 ? {} : { decisiveFacts: roleOutcome.decisiveFacts },
24303
- ...payloads === void 0 ? {} : { payloads },
24304
- ...latestObjectPayload(payloads) === void 0 ? {} : { receipt: latestObjectPayload(payloads) }
24279
+ ...submissions === void 0 || submissions.length === 0 ? {} : { submissions }
24305
24280
  };
24306
24281
  }
24307
24282
  return {
@@ -25628,7 +25603,7 @@ function uninstallPackageWorkerHooks(cwd) {
25628
25603
  rmOwnedDir(resolve17(gitDir, HOOKS_DIR));
25629
25604
  }
25630
25605
  }
25631
- function isRecord14(value) {
25606
+ function isRecord15(value) {
25632
25607
  return typeof value === "object" && value !== null && !Array.isArray(value);
25633
25608
  }
25634
25609
  function unfinishedReasonPresent(details) {
@@ -25644,7 +25619,7 @@ function readGateState(session) {
25644
25619
  if (entry.type !== "custom") continue;
25645
25620
  if (entry.customType === WORKER_COMMIT_BASELINE_ENTRY_TYPE) {
25646
25621
  const data = entry.data;
25647
- if (isRecord14(data) && (data.head === null || typeof data.head === "string")) {
25622
+ if (isRecord15(data) && (data.head === null || typeof data.head === "string")) {
25648
25623
  baseline = data.head;
25649
25624
  }
25650
25625
  } else if (entry.customType === WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE) {
@@ -26802,10 +26777,13 @@ function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
26802
26777
  ...dependencies.packageRoot === void 0 ? {} : { packageRoot: dependencies.packageRoot }
26803
26778
  });
26804
26779
  const details = projectSecretariatSummonResult(summoned);
26805
- const outcomeKind = typeof details.outcomeKind === "string" ? details.outcomeKind : "unknown";
26806
- const contentText = outcomeKind === "accepted" || outcomeKind === "audit_escalation" ? "\u7ED9\u4E8B\u4E2D\u56DE\u6267\u5DF2\u9001\u8FBE\u4E2D\u4E66\u7701" : outcomeKind === "failure" ? "\u7ED9\u4E8B\u4E2D\u4F20\u53EC\u5931\u8D25" : outcomeKind === "no_receipt" ? "\u7ED9\u4E8B\u4E2D\u65E0\u56DE\u6267" : "\u7ED9\u4E8B\u4E2D\u4F20\u53EC\u672A\u5F97\u7EC8\u5C40";
26807
26780
  return {
26808
- content: [{ type: "text", text: contentText }],
26781
+ content: [
26782
+ {
26783
+ type: "text",
26784
+ text: readableGateItem(details)
26785
+ }
26786
+ ],
26809
26787
  details
26810
26788
  };
26811
26789
  }
@@ -27827,9 +27805,9 @@ async function prepareRoleEnvelope(options) {
27827
27805
  let infrastructureRoundFailure;
27828
27806
  const hostAbort = new AbortController();
27829
27807
  const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
27830
- await mkdir7(request.runDirectory, { recursive: true });
27808
+ await mkdir6(request.runDirectory, { recursive: true });
27831
27809
  let sessionFile = options.sessionFile ?? join41(request.runDirectory, "session", "session.jsonl");
27832
- await mkdir7(dirname21(sessionFile), { recursive: true });
27810
+ await mkdir6(dirname21(sessionFile), { recursive: true });
27833
27811
  if (request.continuation.kind !== "resume") {
27834
27812
  try {
27835
27813
  await writeFile12(
@@ -29212,7 +29190,7 @@ function createAcpRoleTurnHost(config) {
29212
29190
 
29213
29191
  // src/acp-host/seat-profile-soul.ts
29214
29192
  import { constants as constants2 } from "node:fs";
29215
- import { access as access5, copyFile, lstat as lstat8, mkdir as mkdir8, readlink as readlink2, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
29193
+ import { access as access5, copyFile, lstat as lstat8, mkdir as mkdir7, readlink as readlink2, symlink as symlink2, unlink as unlink4 } from "node:fs/promises";
29216
29194
  import { dirname as dirname24, join as join44, relative as relative4, resolve as resolve20 } from "node:path";
29217
29195
  function seatProfileName(spec, role) {
29218
29196
  return `${spec.namePrefix}${role}`;
@@ -29240,14 +29218,14 @@ async function ensureSeatProfileSoul(options) {
29240
29218
  const hostRoot = dirname24(profilesRoot);
29241
29219
  const soulPath = join44(profileDir, spec.soulFileName);
29242
29220
  if (!await pathExists2(profileDir)) {
29243
- await mkdir8(profileDir, { recursive: true });
29221
+ await mkdir7(profileDir, { recursive: true });
29244
29222
  for (const name of ["auth.json", ".env", "config.yaml"]) {
29245
29223
  const source = join44(hostRoot, name);
29246
29224
  if (!await pathExists2(source)) continue;
29247
29225
  await copyFile(source, join44(profileDir, name));
29248
29226
  }
29249
29227
  } else {
29250
- await mkdir8(profileDir, { recursive: true });
29228
+ await mkdir7(profileDir, { recursive: true });
29251
29229
  }
29252
29230
  const desiredLink = relative4(profileDir, soulTarget);
29253
29231
  let current;
@@ -29263,7 +29241,7 @@ async function ensureSeatProfileSoul(options) {
29263
29241
  return profileName;
29264
29242
  }
29265
29243
  if (await pathExists2(soulPath) || current !== void 0) {
29266
- await unlink3(soulPath);
29244
+ await unlink4(soulPath);
29267
29245
  }
29268
29246
  await symlink2(desiredLink, soulPath);
29269
29247
  return profileName;