@akagilnc/pi-workflow-roles 0.1.5714 → 0.1.5753

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/acp-host/production-host.js +517 -516
  2. package/dist/analyst-gate-cycles-read.js +7 -6
  3. package/dist/archivist-record-pointer.js +9 -45
  4. package/dist/auditor-soul.js +7 -5
  5. package/dist/external-host-turn-loop.js +2 -16
  6. package/dist/gatekeeper-role.js +14 -1
  7. package/dist/headless-host/production-host.js +517 -516
  8. package/dist/judge-role.js +1 -1
  9. package/dist/migrate-book-topology.js +61 -51
  10. package/dist/navigator-public-session.js +17 -8
  11. package/dist/notary-contracts.js +2 -2
  12. package/dist/notary-source-run.js +2 -2
  13. package/dist/packaged-role-registry.js +0 -10
  14. package/dist/public-cli/cli.js +13 -6
  15. package/dist/public-cli/instruction-seat-run.js +157 -138
  16. package/dist/public-cli/invocation.js +35 -0
  17. package/dist/public-cli/main.js +497 -505
  18. package/dist/public-cli/post-admission.js +11 -12
  19. package/dist/public-cli/run-lifecycle.js +56 -34
  20. package/dist/public-cli/seat-ticket-binding.js +8 -7
  21. package/dist/public-cli/settlement.js +4 -126
  22. package/dist/public-cli/terminal.js +3 -3
  23. package/dist/public-role-summons.js +14 -6
  24. package/dist/review-submission.js +47 -14
  25. package/dist/role-run-relocation.js +4 -3
  26. package/dist/role-submission-declarations.js +5 -5
  27. package/dist/run-dossier.js +6 -21
  28. package/dist/run-terminal-artifacts.js +11 -0
  29. package/dist/secretariat-contracts.js +0 -4
  30. package/dist/submission-gate.js +58 -42
  31. package/dist/submission-ledger.js +3 -2
  32. package/package.json +1 -1
  33. package/souls/notary.md +6 -5
  34. package/src/analyst-gate-cycles-read.ts +7 -6
  35. package/src/analyst-ledger.ts +2 -2
  36. package/src/archivist-record-pointer.ts +10 -64
  37. package/src/auditor-soul.ts +7 -5
  38. package/src/countersign-role.ts +5 -5
  39. package/src/external-host-turn-loop.ts +2 -23
  40. package/src/gatekeeper-role.ts +24 -3
  41. package/src/judge-role.ts +1 -1
  42. package/src/navigator-public-session.ts +22 -10
  43. package/src/notary-contracts.ts +3 -2
  44. package/src/notary-source-run.ts +2 -7
  45. package/src/packaged-role-registry.ts +0 -13
  46. package/src/public-cli/cli.ts +18 -4
  47. package/src/public-cli/instruction-seat-run.ts +213 -155
  48. package/src/public-cli/invocation.ts +39 -0
  49. package/src/public-cli/post-admission.ts +11 -9
  50. package/src/public-cli/run-lifecycle.ts +80 -33
  51. package/src/public-cli/seat-ticket-binding.ts +9 -7
  52. package/src/public-cli/settlement.ts +3 -167
  53. package/src/public-cli/terminal.ts +3 -3
  54. package/src/public-role-summons.ts +40 -12
  55. package/src/review-submission.ts +72 -21
  56. package/src/role-run-relocation.ts +4 -3
  57. package/src/role-runtime.ts +3 -3
  58. package/src/role-submission-declarations.ts +5 -5
  59. package/src/run-dossier.ts +7 -19
  60. package/src/run-terminal-artifacts.ts +13 -0
  61. package/src/secretariat-contracts.ts +0 -19
  62. package/src/submission-gate.ts +75 -62
  63. package/src/submission-ledger.ts +3 -6
@@ -6,7 +6,7 @@ import {} from "./gatekeeper-role.js";
6
6
  import { JUDGE_OUTPUT_TOOL_NAME, } from "./package-contracts/judge-output.js";
7
7
  export { JUDGE_OUTPUT_TOOL_NAME };
8
8
  /** The only judge audit order: 符宝郎, then 审刑院. */
9
- const JUDGE_GATES = [
9
+ export const JUDGE_GATES = [
10
10
  { kind: "judge_draft" },
11
11
  { kind: "judge_compliance" },
12
12
  ];
@@ -816,7 +816,7 @@ var init_role_run_path_rewrite = __esm({
816
816
  });
817
817
 
818
818
  // src/run-dossier-files.ts
819
- var RUN_CURRENT_FILE, RUN_HISTORY_FILE, RUN_LOG_FILE, RUN_STATE_FILE, RUN_HISTORY_KINDS, OFFICER_POINTER_RECORD_KIND, RUN_STATE_KINDS;
819
+ var RUN_CURRENT_FILE, RUN_HISTORY_FILE, RUN_LOG_FILE, RUN_STATE_FILE, RUN_HISTORY_KINDS, RUN_STATE_KINDS;
820
820
  var init_run_dossier_files = __esm({
821
821
  "src/run-dossier-files.ts"() {
822
822
  "use strict";
@@ -834,7 +834,6 @@ var init_run_dossier_files = __esm({
834
834
  "turn-delivery",
835
835
  "officer-pointer"
836
836
  ]);
837
- OFFICER_POINTER_RECORD_KIND = "officer-pointer";
838
837
  RUN_STATE_KINDS = /* @__PURE__ */ new Set([
839
838
  "invocation",
840
839
  "admitted-request",
@@ -1152,17 +1151,6 @@ function lastPagePayload(rows, kind, runDirectory) {
1152
1151
  }
1153
1152
  return payload;
1154
1153
  }
1155
- function latestOfficerPointersFromRecords(records) {
1156
- const latest = {};
1157
- for (const record of records) {
1158
- if (record.kind !== OFFICER_POINTER_RECORD_KIND) continue;
1159
- if (!isRecord(record.payload) || typeof record.payload.officer !== "string") {
1160
- throw new TypeError("officer-pointer payload is not a record with string officer");
1161
- }
1162
- latest[record.payload.officer] = record.payload;
1163
- }
1164
- return latest;
1165
- }
1166
1154
  function render(runDirectory, history, state, log, unreadable) {
1167
1155
  const whole = {};
1168
1156
  for (const section of ["invocation", "admitted", "runState", "terminal"]) {
@@ -1181,13 +1169,6 @@ function render(runDirectory, history, state, log, unreadable) {
1181
1169
  latest = { toolCallId: payload.toolCallId, role: payload.role, accepted: payload.accepted, at: row.timestamp };
1182
1170
  }
1183
1171
  }
1184
- let officers = {};
1185
- try {
1186
- officers = latestOfficerPointersFromRecords(history);
1187
- } catch (error) {
1188
- if (!(error instanceof TypeError)) throw error;
1189
- if (unreadable[RUN_HISTORY_FILE] === void 0) unreadable[RUN_HISTORY_FILE] = "malformed";
1190
- }
1191
1172
  const sessions = {};
1192
1173
  for (const row of state) {
1193
1174
  const payload = isRecord(row.payload) ? row.payload : void 0;
@@ -1205,7 +1186,6 @@ function render(runDirectory, history, state, log, unreadable) {
1205
1186
  if (typeof original === "string") original = join3(runDirectory, "session", basename4(original));
1206
1187
  whole.host = { sessions, ...original === void 0 ? {} : { original } };
1207
1188
  whole.submission = latest === void 0 ? {} : { latest };
1208
- whole.officers = officers;
1209
1189
  if (Object.keys(unreadable).length > 0) whole.unreadable = unreadable;
1210
1190
  return whole;
1211
1191
  }
@@ -8733,7 +8713,7 @@ var init_navigator_output = __esm({
8733
8713
  });
8734
8714
 
8735
8715
  // src/review-submission.ts
8736
- var REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, REVIEW_QUEUE_WORDS, REVIEW_QUEUE_STATUSES, reviewSubmissionSchema;
8716
+ var REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, REVIEW_QUEUE_WORDS, REVIEW_QUEUE_STATUSES, reviewStatusField, reviewNarrativeFields, reviewSubmissionSchema, courtClauseItemSchema, courtClausesField, courtReviewSubmissionSchema;
8737
8717
  var init_review_submission = __esm({
8738
8718
  "src/review-submission.ts"() {
8739
8719
  "use strict";
@@ -8742,28 +8722,62 @@ var init_review_submission = __esm({
8742
8722
  REVIEW_SUBMISSION_OUTPUT_TOOL_NAME = "ak_submission_output";
8743
8723
  REVIEW_QUEUE_WORDS = ["converged", "continue", "escalate"];
8744
8724
  REVIEW_QUEUE_STATUSES = new Set(REVIEW_QUEUE_WORDS);
8725
+ reviewStatusField = typebox_exports.Union(
8726
+ [
8727
+ typebox_exports.Literal(REVIEW_QUEUE_WORDS[0]),
8728
+ typebox_exports.Literal(REVIEW_QUEUE_WORDS[1]),
8729
+ typebox_exports.Literal(REVIEW_QUEUE_WORDS[2])
8730
+ ],
8731
+ {
8732
+ description: "\u5BA1\u6838\u5E2D\u672C\u8F6E\u88C1\u51B3\u7684\u5224\u522B\u72B6\u6001\u3002"
8733
+ }
8734
+ );
8735
+ reviewNarrativeFields = {
8736
+ findings: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u5BA1\u6838\u53D1\u73B0\uFF0C\u539F\u6837\u7559\u5B58" })),
8737
+ reason: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u4E0A\u5448\u7406\u7531" })),
8738
+ violations: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u8FDD\u89C4\u6761\u76EE" })),
8739
+ conflicts: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u5F85\u51B3\u51B2\u7A81" })),
8740
+ fix: typebox_exports.Optional(typebox_exports.Unknown({ description: "continue \u65F6\u7684\u8865\u6551\u8BF4\u660E\uFF1B\u53EF\u5199 summary \u6458\u8981\uFF0C\u5176\u4F59\u5185\u5BB9\u539F\u6837\u7559\u5B58" })),
8741
+ classes: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u5DF2\u88C1\u51B3 finding \u7C7B\uFF1B\u53EF\u8BF4\u660E name\u3001owner\u3001boundary\u3001disposition\uFF0C\u539F\u6837\u7559\u5B58" })),
8742
+ note: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u88C1\u51B3\u9644\u6CE8" })),
8743
+ evidence: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
8744
+ decisionGate: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u9700\u4EBA\u6743\u5A01\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879\uFF1B\u53EF\u8BF4\u660E question\u3001options\uFF0C\u539F\u6837\u7559\u5B58" }))
8745
+ };
8745
8746
  reviewSubmissionSchema = withTerminatingOutputDeclarations(
8746
- typebox_exports.Object({
8747
- status: typebox_exports.Union(
8748
- [
8749
- typebox_exports.Literal(REVIEW_QUEUE_WORDS[0]),
8750
- typebox_exports.Literal(REVIEW_QUEUE_WORDS[1]),
8751
- typebox_exports.Literal(REVIEW_QUEUE_WORDS[2])
8752
- ],
8753
- {
8754
- description: "\u5BA1\u6838\u5E2D\u672C\u8F6E\u88C1\u51B3\u7684\u5224\u522B\u72B6\u6001\u3002"
8755
- }
8756
- ),
8757
- findings: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u5BA1\u6838\u53D1\u73B0\uFF0C\u539F\u6837\u7559\u5B58" })),
8758
- reason: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u4E0A\u5448\u7406\u7531" })),
8759
- violations: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u8FDD\u89C4\u6761\u76EE" })),
8760
- conflicts: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u5F85\u51B3\u51B2\u7A81" })),
8761
- fix: typebox_exports.Optional(typebox_exports.Unknown({ description: "continue \u65F6\u7684\u8865\u6551\u8BF4\u660E\uFF1B\u53EF\u5199 summary \u6458\u8981\uFF0C\u5176\u4F59\u5185\u5BB9\u539F\u6837\u7559\u5B58" })),
8762
- classes: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u5DF2\u88C1\u51B3 finding \u7C7B\uFF1B\u53EF\u8BF4\u660E name\u3001owner\u3001boundary\u3001disposition\uFF0C\u539F\u6837\u7559\u5B58" })),
8763
- note: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u88C1\u51B3\u9644\u6CE8" })),
8764
- evidence: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
8765
- decisionGate: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u9700\u4EBA\u6743\u5A01\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879\uFF1B\u53EF\u8BF4\u660E question\u3001options\uFF0C\u539F\u6837\u7559\u5B58" }))
8766
- }, { additionalProperties: true })
8747
+ typebox_exports.Object(
8748
+ {
8749
+ status: reviewStatusField,
8750
+ ...reviewNarrativeFields
8751
+ },
8752
+ { additionalProperties: true }
8753
+ )
8754
+ );
8755
+ courtClauseItemSchema = typebox_exports.Object(
8756
+ {
8757
+ clause: typebox_exports.String({
8758
+ description: "\u7968\u9762\u6761\u6B3E\u539F\u6587\uFF08\u6539\u53D8\u5B9E\u9645\u884C\u4E3A\u7684\u6761\u6B3E\uFF1B\u4E0D\u5408\u5E76\u3001\u4E0D\u6539\u5199\uFF09"
8759
+ }),
8760
+ ownerUuid: typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()], {
8761
+ description: "\u63A8\u51FA\u8BE5\u6761\u7684\u965B\u4E0B\u539F\u8BDD uuid\uFF1B\u65E0\u539F\u8BDD\u5219 null"
8762
+ }),
8763
+ derivation: typebox_exports.String({
8764
+ description: "\u4E00\u53E5\u63A8\u5BFC\uFF1A\u4ECE\u539F\u8BDD\u54EA\u4E2A\u610F\u601D\u5230\u8BE5\u6761\u6B3E\u3002\u7528\u4F5C\u4E0A\u4E0B\u6587\u7684 runner \u53E5\u5148\u5199\u81F3\u5C11\u4E24\u79CD\u8BFB\u6CD5\uFF0C\u518D\u5199\u7968\u9762\u53D6\u54EA\u79CD\uFF1B\u5199\u4E0D\u51FA\u7B2C\u4E8C\u79CD\u624D\u8BB0\u65E0\u6B67\u4E49"
8765
+ })
8766
+ },
8767
+ { additionalProperties: true }
8768
+ );
8769
+ courtClausesField = typebox_exports.Array(courtClauseItemSchema, {
8770
+ description: "\u7968\u9762\u9010\u6761\u6838\u65E8\u8868\uFF1A\u6BCF\u6761\u6539\u53D8\u5B9E\u9645\u884C\u4E3A\u7684\u6761\u6B3E\u7684\u539F\u6587\u3001\u965B\u4E0B\u539F\u8BDD uuid\u3001\u63A8\u5BFC\u3002\u65E0\u539F\u8BDD\u5219 ownerUuid \u4E3A null\u3002"
8771
+ });
8772
+ courtReviewSubmissionSchema = withTerminatingOutputDeclarations(
8773
+ typebox_exports.Object(
8774
+ {
8775
+ status: reviewStatusField,
8776
+ ...reviewNarrativeFields,
8777
+ clauses: courtClausesField
8778
+ },
8779
+ { additionalProperties: true }
8780
+ )
8767
8781
  );
8768
8782
  }
8769
8783
  });
@@ -9462,8 +9476,6 @@ var init_packaged_role_registry = __esm({
9462
9476
  presentSettled: "always",
9463
9477
  summonResume: false,
9464
9478
  admission: "court-materials",
9465
- /** Durable custom entry names this officer. */
9466
- durableOfficerEntry: true,
9467
9479
  sameParent: "none",
9468
9480
  phases: [null],
9469
9481
  outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
@@ -9489,8 +9501,6 @@ var init_packaged_role_registry = __esm({
9489
9501
  phases: [null],
9490
9502
  outputTool: SECRETARIAT_OUTPUT_TOOL_NAME,
9491
9503
  settlement: "accepted",
9492
- /** Project the durable 给事中 officer entry onto the shared accepted-tool settlement. */
9493
- projectCountersignTerminal: true,
9494
9504
  activationFlags: [
9495
9505
  { field: "ticketNumber" }
9496
9506
  ],
@@ -9760,15 +9770,15 @@ var init_role_submission_declarations = __esm({
9760
9770
  },
9761
9771
  notary: {
9762
9772
  label: "\u7B26\u5B9D\u90CE\u8F93\u51FA",
9763
- description: "\u63D0\u4EA4\u5F15\u6587\u4FDD\u771F\u4E0E\u7968\u9762\u5BF9\u9F50\u7684 converged/continue/escalate \u51B3\u8BAE\u3002",
9773
+ description: "\u63D0\u4EA4\u5F15\u6587\u4FDD\u771F\u4E0E\u7968\u9762\u5BF9\u9F50\u7684 converged/continue/escalate \u51B3\u8BAE\uFF08\u542B\u9010\u6761\u6838\u65E8 clauses\uFF09\u3002",
9764
9774
  promptSnippet: "\u63D0\u4EA4\u7B26\u5B9D\u90CE\u51B3\u8BAE",
9765
- parameters: reviewSubmissionSchema
9775
+ parameters: courtReviewSubmissionSchema
9766
9776
  },
9767
9777
  countersign: {
9768
9778
  label: "\u7ED9\u4E8B\u4E2D\u8F93\u51FA",
9769
- description: "\u7ED9\u4E8B\u4E2D\u51B3\u8BAE\u3002",
9779
+ description: "\u7ED9\u4E8B\u4E2D\u51B3\u8BAE\uFF08\u542B\u9010\u6761\u6838\u65E8 clauses\uFF09\u3002",
9770
9780
  promptSnippet: "\u7ED9\u4E8B\u4E2D\u51B3\u8BAE",
9771
- parameters: reviewSubmissionSchema
9781
+ parameters: courtReviewSubmissionSchema
9772
9782
  },
9773
9783
  secretariat: {
9774
9784
  label: "\u4E2D\u4E66\u7701\u8F93\u51FA",
@@ -30,11 +30,16 @@ function runIdFromNavigatorDirectory(runDirectory) {
30
30
  if (parsed === void 0 || parsed.role !== "navigator") return void 0;
31
31
  return parsed.runId;
32
32
  }
33
- async function navigatorHostRunResumable(home, runId) {
33
+ async function navigatorHostRunResumable(home, runId, runDirectory) {
34
34
  const { piDurablePrincipalAuthority } = await import("./pi/durable-principal.js");
35
35
  const { loadResumablePublicRole } = await import("./public-cli/run-lifecycle.js");
36
36
  try {
37
- const loaded = await loadResumablePublicRole(home, runId, piDurablePrincipalAuthority);
37
+ const loaded = await loadResumablePublicRole(
38
+ home,
39
+ runId,
40
+ piDurablePrincipalAuthority,
41
+ runDirectory === void 0 ? void 0 : { runDirectory }
42
+ );
38
43
  return isNavigatorSeat(loaded.admitted.role);
39
44
  } catch (error) {
40
45
  if (error instanceof CliUsageError) return false;
@@ -48,7 +53,7 @@ function createNativeNavigatorSessionFactory(deps) {
48
53
  let noReceipt;
49
54
  let routePlaybookReadFailure;
50
55
  let disposed = false;
51
- let hostRunId;
56
+ let hostRun;
52
57
  const summon = deps?.summonPublicRole ?? (async (options) => {
53
58
  const { summonPublicRole } = await import("./public-role-summons.js");
54
59
  return summonPublicRole(options);
@@ -65,7 +70,7 @@ function createNativeNavigatorSessionFactory(deps) {
65
70
  try {
66
71
  const summonHome = await resolveNavigatorLedgerHome(context);
67
72
  if (disposed) return;
68
- const resumeRunId = hostRunId;
73
+ const resumeRunId = hostRun?.runId;
69
74
  const baseSummon = {
70
75
  role: "navigator",
71
76
  argv: [text],
@@ -82,12 +87,16 @@ function createNativeNavigatorSessionFactory(deps) {
82
87
  if (disposed) return;
83
88
  summoned = await summon(baseSummon);
84
89
  } else {
85
- const canResume = await resumable(summonHome, resumeRunId);
90
+ const canResume = await resumable(summonHome, resumeRunId, hostRun?.runDirectory);
86
91
  if (disposed) return;
87
92
  if (canResume) {
88
- summoned = await summon({ ...baseSummon, resumeRunId });
93
+ summoned = await summon({
94
+ ...baseSummon,
95
+ resumeRunId,
96
+ ...hostRun === void 0 ? {} : { resumeRunDirectory: hostRun.runDirectory }
97
+ });
89
98
  } else {
90
- hostRunId = void 0;
99
+ hostRun = void 0;
91
100
  summoned = await summon(baseSummon);
92
101
  }
93
102
  }
@@ -125,7 +134,7 @@ function createNativeNavigatorSessionFactory(deps) {
125
134
  if (typeof runDirectory === "string" && runDirectory.trim() !== "") {
126
135
  const nextRunId = runIdFromNavigatorDirectory(runDirectory);
127
136
  if (nextRunId !== void 0) {
128
- hostRunId = nextRunId;
137
+ hostRun = { runId: nextRunId, runDirectory };
129
138
  }
130
139
  }
131
140
  if (outcome.kind !== "accepted") {
@@ -1,4 +1,4 @@
1
- import { REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, reviewSubmissionSchema } from "./review-submission.js";
1
+ import { REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, courtReviewSubmissionSchema } from "./review-submission.js";
2
2
  import { isRecord } from "./unknown-value.js";
3
3
  const NOTARY_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
4
4
  const NOTARY_SOURCE_RUN_FLAG = {
@@ -15,7 +15,7 @@ const NOTARY_TICKET_FLAG = {
15
15
  type: "string"
16
16
  }
17
17
  };
18
- const notaryOutputSchema = reviewSubmissionSchema;
18
+ const notaryOutputSchema = courtReviewSubmissionSchema;
19
19
  function projectLawfulNotaryOutput(value) {
20
20
  return isRecord(value) ? value : void 0;
21
21
  }
@@ -7,7 +7,7 @@ import { dirname, isAbsolute, join, resolve, basename } from "node:path";
7
7
  import { lstat, realpath } from "node:fs/promises";
8
8
  import { resolveBookKeyFromGit } from "./activation-ledger-git.js";
9
9
  import { activationBookDirectory, physicalPathIdentity, resolveActivationLedgerHome, } from "./activation-ledger-topology.js";
10
- import { findRunDirectoryById, readRoleRunIdentity } from "./public-cli/run-lifecycle.js";
10
+ import { findRunDirectoryById, resolveLiveRunDirectoryPath, readRoleRunIdentity } from "./public-cli/run-lifecycle.js";
11
11
  import { formatRunLeaf, parseRunLeaf } from "./role-run-placement.js";
12
12
  async function readRetainedIdentity(runDirectory) {
13
13
  try {
@@ -84,7 +84,7 @@ export async function resolveNotarySourceRunLocator(options) {
84
84
  basename(subjectDirectory) === "unbound" &&
85
85
  resolve(dirname(subjectDirectory)) === resolve(bookDirectory);
86
86
  if (isLegacyUnboundLocator) {
87
- candidate = (await findRunDirectoryById(options.home, identity.runId, bookKey, identity.role)) ?? candidate;
87
+ candidate = (await resolveLiveRunDirectoryPath(candidate, options.home ?? ledgerHome, bookKey)) ?? candidate;
88
88
  }
89
89
  }
90
90
  const real = await requireRunDirectory(candidate, raw);
@@ -288,8 +288,6 @@ const PUBLIC_ROLE_RECORDS = [
288
288
  presentSettled: "always",
289
289
  summonResume: false,
290
290
  admission: "court-materials",
291
- /** Durable custom entry names this officer. */
292
- durableOfficerEntry: true,
293
291
  sameParent: "none",
294
292
  phases: [null],
295
293
  outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
@@ -315,8 +313,6 @@ const PUBLIC_ROLE_RECORDS = [
315
313
  phases: [null],
316
314
  outputTool: SECRETARIAT_OUTPUT_TOOL_NAME,
317
315
  settlement: "accepted",
318
- /** Project the durable 给事中 officer entry onto the shared accepted-tool settlement. */
319
- projectCountersignTerminal: true,
320
316
  activationFlags: [
321
317
  { field: "ticketNumber" }
322
318
  ],
@@ -566,11 +562,6 @@ function packagedAuditToolName(role) {
566
562
  if (record === void 0 || !("auditTool" in record)) return void 0;
567
563
  return record.auditTool;
568
564
  }
569
- function packagedDurableOfficerEntry(officer) {
570
- return typeof officer === "string" && PUBLIC_ROLE_RECORDS.some(
571
- (record) => "durableOfficerEntry" in record && record.durableOfficerEntry === true && record.role === officer
572
- );
573
- }
574
565
  function packagedPublicInstructionSubject(role) {
575
566
  return typeof role === "string" && PUBLIC_ROLE_RECORDS.some(
576
567
  (record) => "navigatorSubject" in record && record.navigatorSubject === "public-instruction" && record.role === role
@@ -633,7 +624,6 @@ export {
633
624
  packagedBaseIsRevision,
634
625
  packagedBindsBoardTicket,
635
626
  packagedBoardPlacement,
636
- packagedDurableOfficerEntry,
637
627
  packagedEmitsAuthorityRefs,
638
628
  packagedGateStageLabel,
639
629
  packagedGateSummon,
@@ -16,13 +16,13 @@ import { presentLocatedResumeFailure, } from "./post-admission.js";
16
16
  import { appendPiSessionCustomEntry } from "../pi/role-turn-host.js";
17
17
  import { openRoleSeatRuntime } from "./role-seat-runtime.js";
18
18
  import { formatHostSelectionFailure, HostSelectionError, } from "./role-turn-host-resolution.js";
19
- import { parseAnalystArgv, parsePublicSeatArgv, } from "./invocation.js";
19
+ import { admittedSourceRunPath, parseAnalystArgv, parsePublicSeatArgv, } from "./invocation.js";
20
20
  import { createTypedOptionConsumer, optionsForOwner, projectCommandHelp, projectOwnerOptions, PUBLIC_NAVIGATOR_HELP_NOTE, PUBLIC_ROLE_OPTION_OWNERS, renderHumanOwnerOptionLines, } from "./option-definitions.js";
21
21
  import { TurnDispatchedFailure } from "./auto-resume.js";
22
22
  import { continueParentAfterChild, runPublicInstructionSeat, runPublicInstructionSeatResume } from "./instruction-seat-run.js";
23
23
  import { latestPayloadEscalated } from "./countersign-run.js";
24
24
  import { runPublicAnalyst } from "./analyst-run.js";
25
- import { AUTO_RESUME_LIMIT, peekRoleRunRole, } from "./run-lifecycle.js";
25
+ import { AUTO_RESUME_LIMIT, findRunDirectoryById, peekRoleRunRole, } from "./run-lifecycle.js";
26
26
  import { INTERNAL_ROLE_ENTRYPOINT_RELATIVE, PUBLIC_CALLABLE_ROLES, isPublicCallableRole, isPublicCliSupportCommand, isPublicConfigurableSeat, listHelpCapabilities, } from "./registry.js";
27
27
  import { formatCliDiagnostic, formatErrorCauseDetail, presentStructuralRejection, } from "./settlement.js";
28
28
  import { errorText } from "../unknown-value.js";
@@ -822,14 +822,19 @@ export async function runAkRole(argv, env) {
822
822
  // must still exist. Seat and dispatch follow the durable admitted role.
823
823
  // #471: unique parser owns {runId, message?}; five role paths only consume it.
824
824
  if (parsed.command === "resume") {
825
- const resumeRequest = parseResumeRequest(parsed.args);
825
+ let resumeRequest = parseResumeRequest(parsed.args);
826
826
  resumeFailureContext = {
827
827
  home,
828
828
  runId: resumeRequest.runId,
829
829
  authority: env.principalAuthority ?? piDurablePrincipalAuthority,
830
830
  };
831
+ const runDirectory = await findRunDirectoryById(home, resumeRequest.runId);
832
+ if (runDirectory !== undefined) {
833
+ resumeRequest = { ...resumeRequest, runDirectory };
834
+ resumeFailureContext = { ...resumeFailureContext, runDirectory };
835
+ }
831
836
  const parts = await loadPublicRoleDispatchParts(env, home);
832
- const resumeRole = await peekRoleRunRole(home, resumeRequest.runId);
837
+ const resumeRole = await peekRoleRunRole(home, resumeRequest.runId, resumeRequest);
833
838
  // Missing durable role keeps the judge seat table. The resume entry
834
839
  // itself is one function; it reads the stored run.
835
840
  const seatRole = resumeRole ?? "judge";
@@ -849,12 +854,14 @@ export async function runAkRole(argv, env) {
849
854
  && current.terminal.roleOutcome.decisiveFacts?.directionUnsettled !== true
850
855
  && !latestPayloadEscalated(current.terminal.roleOutcome)) {
851
856
  const parentRunId = current.admitted.correlationId;
857
+ const parentSource = admittedSourceRunPath(current.admitted);
852
858
  resumeFailureContext = {
853
859
  home,
854
860
  runId: parentRunId,
861
+ ...(parentSource === undefined ? {} : { runDirectory: parentSource }),
855
862
  authority: env.principalAuthority ?? piDurablePrincipalAuthority,
856
863
  };
857
- const parentRole = await peekRoleRunRole(home, parentRunId);
864
+ const parentRole = await peekRoleRunRole(home, parentRunId, parentSource === undefined ? undefined : { runDirectory: parentSource });
858
865
  if (parentRole === undefined)
859
866
  break;
860
867
  const parentSeat = resolveEffectiveSeat(parts.config, parentRole, parts.credentials, invocationFromParsed(parsed));
@@ -895,7 +902,7 @@ export async function runAkRole(argv, env) {
895
902
  // fall through to the located-run diagnostic presenter here.
896
903
  if (resumeFailureContext !== undefined
897
904
  && !(error instanceof TurnDispatchedFailure)
898
- && await presentLocatedResumeFailure(resumeFailureContext.home, resumeFailureContext.runId, resumeFailureContext.authority, io, error)) {
905
+ && await presentLocatedResumeFailure(resumeFailureContext.home, resumeFailureContext.runId, resumeFailureContext.authority, io, error, resumeFailureContext.runDirectory)) {
899
906
  return {
900
907
  exitCode: error instanceof CliUsageError ? 2 : 1,
901
908
  ...(error instanceof HostSelectionError ? { hostFailure: error.failure } : {}),