@akagilnc/pi-workflow-roles 0.1.6108 → 0.1.6115

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 (65) hide show
  1. package/dist/acp-host/production-host.js +209 -177
  2. package/dist/compliance-transport.js +3 -3
  3. package/dist/diarist-contracts.js +0 -16
  4. package/dist/diarist-role.js +1 -2
  5. package/dist/doctor-contracts.js +1 -5
  6. package/dist/gatekeeper-role.js +6 -9
  7. package/dist/headless-host/production-host.js +162 -130
  8. package/dist/inspector-contracts.js +2 -22
  9. package/dist/inspector-role.js +1 -2
  10. package/dist/merger-contracts.js +1 -5
  11. package/dist/migrate-book-topology.js +32 -45
  12. package/dist/navigator-invocation-identity.js +8 -10
  13. package/dist/notary-contracts.js +1 -9
  14. package/dist/package-contracts/auditor-output.js +0 -10
  15. package/dist/package-contracts/fixer-output.js +3 -0
  16. package/dist/package-contracts/gatekeeper-output.js +1 -7
  17. package/dist/package-contracts/navigator-output.js +1 -25
  18. package/dist/package-contracts/reviewer-output.js +1 -5
  19. package/dist/package-contracts/terminating-tools.js +10 -24
  20. package/dist/packaged-role-registry.js +20 -4
  21. package/dist/public-cli/countersign-run.js +2 -4
  22. package/dist/public-cli/instruction-seat-run.js +55 -16
  23. package/dist/public-cli/invocation.js +22 -12
  24. package/dist/public-cli/main.js +192 -143
  25. package/dist/public-cli/post-admission.js +2 -2
  26. package/dist/review-submission.js +1 -1
  27. package/dist/role-runtime.js +15 -32
  28. package/dist/secretariat-contracts.js +1 -1
  29. package/dist/submission-errors.js +0 -9
  30. package/dist/submission-gate.js +3 -7
  31. package/dist/submission-ledger.js +4 -12
  32. package/dist/ticket-progress.js +64 -28
  33. package/dist/ticket-trajectory.js +6 -17
  34. package/dist/worker-role.js +3 -4
  35. package/package.json +1 -1
  36. package/src/compliance-transport.ts +3 -3
  37. package/src/diarist-contracts.ts +0 -16
  38. package/src/diarist-role.ts +0 -2
  39. package/src/doctor-contracts.ts +0 -4
  40. package/src/gatekeeper-role.ts +6 -9
  41. package/src/inspector-contracts.ts +1 -21
  42. package/src/inspector-role.ts +0 -2
  43. package/src/merger-contracts.ts +0 -4
  44. package/src/navigator-invocation-identity.ts +9 -16
  45. package/src/notary-contracts.ts +0 -13
  46. package/src/package-contracts/auditor-output.ts +0 -12
  47. package/src/package-contracts/fixer-output.ts +4 -0
  48. package/src/package-contracts/gatekeeper-output.ts +0 -9
  49. package/src/package-contracts/navigator-output.ts +0 -34
  50. package/src/package-contracts/reviewer-output.ts +0 -4
  51. package/src/package-contracts/terminating-tools.ts +21 -37
  52. package/src/packaged-role-registry.ts +33 -3
  53. package/src/public-cli/countersign-run.ts +2 -5
  54. package/src/public-cli/instruction-seat-run.ts +58 -13
  55. package/src/public-cli/invocation.ts +31 -16
  56. package/src/public-cli/post-admission.ts +2 -2
  57. package/src/review-submission.ts +1 -1
  58. package/src/role-runtime.ts +16 -29
  59. package/src/secretariat-contracts.ts +2 -3
  60. package/src/submission-errors.ts +0 -8
  61. package/src/submission-gate.ts +3 -7
  62. package/src/submission-ledger.ts +3 -11
  63. package/src/ticket-progress.ts +76 -33
  64. package/src/ticket-trajectory.ts +5 -18
  65. package/src/worker-role.ts +3 -4
@@ -1554,7 +1554,6 @@ var init_gatekeeper_output = __esm({
1554
1554
  "use strict";
1555
1555
  init_open_tool_schema();
1556
1556
  init_terminating_infrastructure();
1557
- init_unknown_value();
1558
1557
  GATEKEEPER_OUTPUT_TOOL_NAME = "ak_gatekeeper_output";
1559
1558
  gatekeeperDecisionSchema = openToolObject(
1560
1559
  Type3.Object({
@@ -1929,7 +1928,7 @@ var init_review_submission = __esm({
1929
1928
  );
1930
1929
  ARCH_TABLE_COMMON = "\u67B6\u6784\u5F52\u4F4D\u8868\uFF1A\u5148\u76D8\u65E2\u6709\u67B6\u6784\u2014\u2014docs/adr \u4E0E\u7968\u9762\u70B9\u540D\u6CD5\u6E90\u91CC\u7684\u5C42\u8868\u4E0E\u89C4\u77E9\uFF0C\u518D\u6253\u5F00\u5206\u5C42\u914D\u7F6E\u4E0E\u4EE3\u7801\u770B\u6BCF\u5C42\u73B0\u5728\u88C5\u7740\u4EC0\u4E48\u3001\u6709\u6CA1\u6709\u6CD5\u6E90\u91CC\u6CA1\u6709\u7684\u5C42\u3002\u9075\u5FAA\u884C\uFF1A\u7A3F\u91CC\u6BCF\u6837\u8FDB\u4EE3\u7801\u7684\u4E1C\u897F\u5404\u4E00\u884C\uFF0C\u5F52\u5230\u6CD5\u6E90\u7684\u5C42\u91CC\uFF1B\u6838\u67B6\u6784\u884C\uFF1A\u65E2\u6709\u67B6\u6784\u6BCF\u6761\u6761\u6B3E\u5404\u4E00\u884C\uFF0C\u8054\u7F51\u627E\u6240\u9009\u6846\u67B6\u5B98\u65B9\u6587\u6863\u4E0E\u516C\u8BA4\u8D44\u6599\u91CC\u627F\u62C5\u540C\u4E00\u5173\u5207\u7684\u505A\u6CD5\uFF0C\u9644\u94FE\u63A5\u4E0E\u539F\u53E5\u3002\u6CD5\u6E90\u91CC\u65E2\u6CA1\u6709\u5C42\u8868\u4E5F\u6CA1\u6709\u67B6\u6784\u89C4\u77E9\u65F6\u624D\u4E3A\u7A7A\u6570\u7EC4\uFF0C\u5E76\u5728 note \u5199\u660E\uFF1B\u53EA\u6709\u89C4\u77E9\u6CA1\u6709\u5C42\u8868\u7684\uFF0C\u9075\u5FAA\u884C\u7684 layer \u5199\u88AB\u6838\u7684\u90A3\u6761\u89C4\u77E9\u539F\u53E5\uFF0C\u6838\u67B6\u6784\u884C\u6309\u89C4\u77E9\u9010\u6761\u5217\u3002";
1931
1930
  secretariatArchitectureField = Type5.Array(architectureRowSchema, {
1932
- description: `${ARCH_TABLE_COMMON}\u6709\u300C\u4E0D\u5408\u300D\u6216\u300C\u53EF\u6539\u8FDB\u300D\u884C\uFF0CsecretariatStatus \u53EA\u80FD\u662F escalate\uFF1A\u4E0D\u5408\u884C\u7684\u539F\u6587\u4E0E\u4E24\u8FB9\uFF08\u6539\u7A3F\u5F52\u4F4D\uFF0F\u6539\u67B6\u6784\uFF09\u3001\u53EF\u6539\u8FDB\u7684\u5EFA\u8BAE\uFF0C\u90FD\u5217\u8FDB decisionGate \u7531\u965B\u4E0B\u62CD\uFF0C\u4E0D\u51FA\u7ED9\u5BB0\u76F8\u7B54\u3002`
1931
+ description: `${ARCH_TABLE_COMMON}\u6709\u300C\u4E0D\u5408\u300D\u6216\u300C\u53EF\u6539\u8FDB\u300D\u884C\uFF0Cstatus \u53EA\u80FD\u662F escalate\uFF1A\u4E0D\u5408\u884C\u7684\u539F\u6587\u4E0E\u4E24\u8FB9\uFF08\u6539\u7A3F\u5F52\u4F4D\uFF0F\u6539\u67B6\u6784\uFF09\u3001\u53EF\u6539\u8FDB\u7684\u5EFA\u8BAE\uFF0C\u90FD\u5217\u8FDB decisionGate \u7531\u965B\u4E0B\u62CD\uFF0C\u4E0D\u51FA\u7ED9\u5BB0\u76F8\u7B54\u3002`
1933
1932
  });
1934
1933
  countersignArchitectureField = Type5.Array(architectureRowSchema, {
1935
1934
  description: `${ARCH_TABLE_COMMON}\u6709\u300C\u4E0D\u5408\u300D\u884C\u4E0D\u5F97\u7F72\uFF1A\u7968\u9762\u610F\u5728\u6539\u67B6\u6784\u7684\u4E0A\u5448\uFF0C\u5426\u5219\u5C01\u9A73\u9000\u7B7E\u53D1\u65B9\u5F52\u4F4D\uFF1B\u6709\u300C\u53EF\u6539\u8FDB\u300D\u884C\u4E0A\u5448\uFF0C\u5EFA\u8BAE\u9644\u539F\u6587\u3002`
@@ -2092,6 +2091,9 @@ var init_fixer_output = __esm({
2092
2091
  classResults: Type8.Unknown({
2093
2092
  description: "\u5404\u7C7B class \u7ED3\u7B97\uFF0C\u539F\u6837\u7559\u5B58\u3002\u6BCF\u7C7B\u5199 name\u3001shape\uFF08\u9519\u8BEF\u5F62\u72B6\u4E00\u53E5\uFF09\u3002\u6309\u4EE3\u7801\u5F62\u72B6\u8BA4\u7684\u7C7B\u5199 search\uFF08\u5B9E\u9645\u8DD1\u7684\u641C\u7D22\u547D\u4EE4\uFF0C\u539F\u6837\uFF09\u3001hits\uFF08\u547D\u4EE4\u8F93\u51FA\u7684\u6BCF\u4E2A\u547D\u4E2D\u4E00\u884C { where: path:line, outcome: \u5DF2\u4FEE | \u4E0D\u540C\u7C7B\uFF1A\u7406\u7531 }\uFF09\uFF1B\u6309\u60C5\u5F62\u8BA4\u7684\u7C7B\u5199 cases\uFF08\u6BCF\u79CD\u524D\u5E8F\u7ECF\u5386\u4E00\u884C { case: \u5BF9\u8C61\u5148\u7ECF\u5386\u4E86\u4EC0\u4E48, entry: \u4ECE\u771F\u5B9E\u5165\u53E3\u600E\u4E48\u8D70\u5230\u5B83, before: \u4FEE\u524D\u7ED3\u679C, after: \u4FEE\u540E\u7ED3\u679C }\uFF09\u3002\u5220\u5E76\u7C7B\u5199 files\uFF08\u672C\u7968\u8D77\u70B9\u5230 HEAD \u7684 git diff --name-status \u91CC\u6BCF\u4E2A\u6587\u4EF6\u4E00\u884C { file, hits: \u8BE5\u7C7B\u5728\u6B64\u6587\u4EF6\u7684\u547D\u4E2D path:line \u5217\u8868\uFF0C\u6CA1\u6709\u4E3A\u7A7A, outcome: \u5DF2\u4FEE | \u65E0\uFF1A\u6BD4\u5BF9\u4E86\u54EA\u51E0\u5904\u3001\u4E3A\u4EC0\u4E48\u4E0D\u7B97 | \u672A\u4FEE\uFF1A\u7406\u7531 }\uFF09\u3002\u5B8C\u6210\u9879\u7684 disposition \u4E3A completed\uFF0C\u53EF\u5199 commitSha\u3002\u62D2\u7EDD\u9879\u7684 disposition \u4E3A refused\uFF0C\u53EF\u5199 remainingScope\u3001blocker\u3002"
2094
2093
  }),
2094
+ for: Type8.Unknown({
2095
+ description: "\u4FEE\u7684\u662F\u54EA\u4EFD\u5224\u8BCD\uFF1A<\u5E2D>#<\u8F6E>\uFF0C\u5982 judge#5\uFF0C\u539F\u6837\u843D\u5230\u8FDB\u5EA6\u884C\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002"
2096
+ }),
2095
2097
  diffItems: diffItemsField,
2096
2098
  testEvidence: Type8.Unknown({
2097
2099
  description: "\u4EC5 diff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u586B\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002\u673A\u5668\u4E0D\u6838\u9A8C\u3002\u53EF\u5199 contract\uFF08\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6\uFF09\u3001minimumNecessaryCost\uFF08\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C\uFF09\u3001measuredDuration\uFF08\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F\uFF09\u3002"
@@ -2325,7 +2327,6 @@ var init_notary_contracts = __esm({
2325
2327
  "src/notary-contracts.ts"() {
2326
2328
  "use strict";
2327
2329
  init_review_submission();
2328
- init_unknown_value();
2329
2330
  NOTARY_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
2330
2331
  NOTARY_SOURCE_RUN_FLAG = {
2331
2332
  name: "ak-notary-source-run",
@@ -2391,7 +2392,6 @@ var init_inspector_contracts = __esm({
2391
2392
  "src/inspector-contracts.ts"() {
2392
2393
  "use strict";
2393
2394
  init_review_submission();
2394
- init_unknown_value();
2395
2395
  INSPECTOR_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
2396
2396
  INSPECTOR_SOURCE_RUN_FLAG = {
2397
2397
  name: "ak-inspector-source-run",
@@ -2409,7 +2409,6 @@ var init_auditor_output = __esm({
2409
2409
  "src/package-contracts/auditor-output.ts"() {
2410
2410
  "use strict";
2411
2411
  init_review_submission();
2412
- init_unknown_value();
2413
2412
  AUDITOR_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
2414
2413
  }
2415
2414
  });
@@ -2573,7 +2572,7 @@ var init_secretariat_contracts = __esm({
2573
2572
  secretariatVerdictSchema = withTerminatingOutputDeclarations(
2574
2573
  Type14.Object(
2575
2574
  {
2576
- secretariatStatus: Type14.Unknown({
2575
+ status: Type14.Unknown({
2577
2576
  description: "converged | escalate"
2578
2577
  }),
2579
2578
  ticketNumber: Type14.Optional(
@@ -2643,8 +2642,25 @@ __export(packaged_role_registry_exports, {
2643
2642
  packagedRolePhaseFlag: () => packagedRolePhaseFlag,
2644
2643
  packagedRoleSessionMaterials: () => packagedRoleSessionMaterials,
2645
2644
  packagedStoresSourceRunRaw: () => packagedStoresSourceRunRaw,
2646
- packagedSubjectChoices: () => packagedSubjectChoices
2645
+ packagedSubjectChoices: () => packagedSubjectChoices,
2646
+ receiptSeat: () => receiptSeat,
2647
+ receiptStatus: () => receiptStatus
2647
2648
  });
2649
+ function receiptStatus(receipt) {
2650
+ if (!isRecord(receipt)) return void 0;
2651
+ for (const key of RECEIPT_STATUS_KEYS) {
2652
+ if (Object.hasOwn(receipt, key)) return receipt[key];
2653
+ }
2654
+ return void 0;
2655
+ }
2656
+ function receiptSeat(toolName, runSeat) {
2657
+ const legacy = LEGACY_REVIEW_OUTPUT_ROLES.get(toolName);
2658
+ if (legacy !== void 0) return { seat: legacy, source: "tool" };
2659
+ const owners = PACKAGED_ROLE_REGISTRY.filter((entry) => entry.outputTool === toolName);
2660
+ if (owners.length === 1) return { seat: owners[0].role, source: "tool" };
2661
+ const seat = owners.length === 0 ? void 0 : runSeat();
2662
+ return seat === void 0 ? void 0 : { seat, source: "invocation" };
2663
+ }
2648
2664
  function packagedRoleMetadata(role) {
2649
2665
  return PACKAGED_ROLE_REGISTRY.find((entry) => entry.role === role);
2650
2666
  }
@@ -2774,7 +2790,7 @@ function packagedGateSummon(role) {
2774
2790
  if (record !== void 0 && "gateSummon" in record) return record.gateSummon;
2775
2791
  return "pointer";
2776
2792
  }
2777
- var LEGACY_REVIEW_OUTPUT_ROLES, NOTARY_SESSION_MATERIALS, INSPECTOR_SESSION_MATERIALS, AUDITOR_PUBLIC_SESSION_MATERIALS, PUBLIC_ROLE_RECORDS, PACKAGED_ROLE_REGISTRY;
2793
+ var LEGACY_REVIEW_OUTPUT_ROLES, RECEIPT_STATUS_KEYS, NOTARY_SESSION_MATERIALS, INSPECTOR_SESSION_MATERIALS, AUDITOR_PUBLIC_SESSION_MATERIALS, PUBLIC_ROLE_RECORDS, PACKAGED_ROLE_REGISTRY;
2778
2794
  var init_packaged_role_registry = __esm({
2779
2795
  "src/packaged-role-registry.ts"() {
2780
2796
  "use strict";
@@ -2794,6 +2810,7 @@ var init_packaged_role_registry = __esm({
2794
2810
  init_diarist_contracts();
2795
2811
  init_secretariat_contracts();
2796
2812
  init_judge_auditor();
2813
+ init_unknown_value();
2797
2814
  LEGACY_REVIEW_OUTPUT_ROLES = /* @__PURE__ */ new Map([
2798
2815
  ["ak_judge_output", "judge"],
2799
2816
  ["ak_notary_output", "notary"],
@@ -2801,6 +2818,7 @@ var init_packaged_role_registry = __esm({
2801
2818
  ["ak_inspector_output", "inspector"],
2802
2819
  ["ak_auditor_output", "auditor"]
2803
2820
  ]);
2821
+ RECEIPT_STATUS_KEYS = ["status", "secretariatStatus", "judgeStatus", "countersignStatus"];
2804
2822
  NOTARY_SESSION_MATERIALS = [
2805
2823
  "CLAUDE.md",
2806
2824
  "souls/notary.md",
@@ -2844,7 +2862,6 @@ var init_packaged_role_registry = __esm({
2844
2862
  /** Factory board: court until another station has started, then marshal. */
2845
2863
  boardPlacement: "judge-history",
2846
2864
  activationStage: "load-and-install",
2847
- receiptStatusKey: "status",
2848
2865
  sessionMaterials: [
2849
2866
  "CLAUDE.md",
2850
2867
  "souls/judge.md",
@@ -3072,7 +3089,6 @@ var init_packaged_role_registry = __esm({
3072
3089
  { field: "ticketNumber" }
3073
3090
  ],
3074
3091
  activationStage: "load-and-install",
3075
- receiptStatusKey: "status",
3076
3092
  // #924: 公用《票面法》三席同装
3077
3093
  sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md", "souls/design-law.md", "souls/audit-law.md", "souls/quality-law.md", "resources/countersign-ticket-issue.md", "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"]
3078
3094
  },
@@ -3090,7 +3106,6 @@ var init_packaged_role_registry = __esm({
3090
3106
  { field: "ticketNumber" }
3091
3107
  ],
3092
3108
  activationStage: "load-and-install",
3093
- receiptStatusKey: "secretariatStatus",
3094
3109
  // #924: owner-finalized Soul + 票面法 + 给事中/符宝郎行为指南
3095
3110
  sessionMaterials: [
3096
3111
  "CLAUDE.md",
@@ -3329,17 +3344,11 @@ function unreadableDiscriminatorNotice(field, received) {
3329
3344
  if (received === void 0) return `\u8BFB\u4E0D\u51FA ${field}`;
3330
3345
  return `\u8BFB\u4E0D\u51FA ${field}\uFF1A${readableGateItem(received)}`;
3331
3346
  }
3332
- function receivedDiscriminator(receipt, field) {
3333
- if (!isRecord(receipt)) return void 0;
3334
- if (!Object.hasOwn(receipt, field)) return void 0;
3335
- return receipt[field];
3336
- }
3337
3347
  var WorkerCommitReminderError, WorkerPrefixReminderError, WorkerUnfinishedReasonReminderError, ParentQueueReaskError;
3338
3348
  var init_submission_errors = __esm({
3339
3349
  "src/submission-errors.ts"() {
3340
3350
  "use strict";
3341
3351
  init_readable_gate_item();
3342
- init_unknown_value();
3343
3352
  WorkerCommitReminderError = class extends Error {
3344
3353
  code = "worker_commit_reminder";
3345
3354
  constructor() {
@@ -3726,8 +3735,8 @@ function reviewQueueStatus(status) {
3726
3735
  }
3727
3736
  function projectOfficerDecision(officer, decision, fallbackStatus) {
3728
3737
  const receipt = retainedReceipt(decision);
3729
- const record = isRecord(decision) ? decision : void 0;
3730
- const status = record !== void 0 && Object.hasOwn(record, "status") ? receivedDiscriminator(record, "status") : fallbackStatus;
3738
+ const received = receiptStatus(decision);
3739
+ const status = received === void 0 ? fallbackStatus : received;
3731
3740
  const queueStatus = typeof status === "string" ? reviewQueueStatus(status) : void 0;
3732
3741
  if (queueStatus === "converged") {
3733
3742
  return { status: "converged", officer, receipt };
@@ -3816,7 +3825,7 @@ function projectOfficerTerminal(officer, summoned) {
3816
3825
  status: "needs_reask",
3817
3826
  officer,
3818
3827
  receipt: receipt2,
3819
- receivedStatus: receivedDiscriminator(receipt2, "status")
3828
+ receivedStatus: receiptStatus(receipt2)
3820
3829
  },
3821
3830
  summoned
3822
3831
  );
@@ -3833,7 +3842,7 @@ function projectOfficerTerminal(officer, summoned) {
3833
3842
  officer,
3834
3843
  // This-court receipt only (#879).
3835
3844
  receipt,
3836
- receivedStatus: receivedDiscriminator(receipt, "status")
3845
+ receivedStatus: receiptStatus(receipt)
3837
3846
  },
3838
3847
  summoned
3839
3848
  );
@@ -3888,7 +3897,6 @@ var init_gatekeeper_role = __esm({
3888
3897
  init_role_submission_declarations();
3889
3898
  init_terminal();
3890
3899
  init_run_terminal_artifacts();
3891
- init_unknown_value();
3892
3900
  init_serialize_thrown_value();
3893
3901
  GATE_OFFICER_BY_SUBJECT = {
3894
3902
  worker_completion: "inspector",
@@ -4760,64 +4768,6 @@ var init_submission_correctable_error = __esm({
4760
4768
  }
4761
4769
  });
4762
4770
 
4763
- // src/package-contracts/terminating-tools.ts
4764
- function isTerminatingToolName(name) {
4765
- return TERMINATING_TOOL_NAMES.includes(name);
4766
- }
4767
- function validateAcceptedDetails(_toolName, details) {
4768
- if (isRecord(details)) {
4769
- return details;
4770
- }
4771
- return {};
4772
- }
4773
- function acceptedFacts(toolName, details) {
4774
- const record = details;
4775
- const entry = PACKAGED_ROLE_REGISTRY.find((candidate) => candidate.outputTool === toolName);
4776
- const legacyRole = LEGACY_REVIEW_OUTPUT_ROLES.get(toolName);
4777
- const statusKey = legacyRole === "judge" || legacyRole === "countersign" ? `${legacyRole}Status` : entry !== void 0 && "receiptStatusKey" in entry ? entry.receiptStatusKey : "status";
4778
- const status = typeof record[statusKey] === "string" ? record[statusKey] : void 0;
4779
- const commitKey = entry !== void 0 && "receiptCommitKey" in entry ? entry.receiptCommitKey : void 0;
4780
- const commitWhen = entry !== void 0 && "receiptCommitWhen" in entry ? entry.receiptCommitWhen : void 0;
4781
- const commit = commitKey !== void 0 && status === commitWhen && typeof record[commitKey] === "string" ? record[commitKey] : void 0;
4782
- return {
4783
- ...status === void 0 ? {} : { status },
4784
- ...commit === void 0 ? {} : { commit }
4785
- };
4786
- }
4787
- var TERMINATING_TOOL_NAMES, AcceptedDetailsContractError;
4788
- var init_terminating_tools = __esm({
4789
- "src/package-contracts/terminating-tools.ts"() {
4790
- "use strict";
4791
- init_collector_output();
4792
- init_judge_output();
4793
- init_reviewer_output();
4794
- init_packaged_role_registry();
4795
- init_submission_correctable_error();
4796
- init_doctor_contracts();
4797
- init_gatekeeper_output();
4798
- init_navigator_output();
4799
- init_auditor_output();
4800
- init_merger_contracts();
4801
- init_notary_contracts();
4802
- init_inspector_contracts();
4803
- init_diarist_contracts();
4804
- init_secretariat_contracts();
4805
- init_worker_output();
4806
- init_unknown_value();
4807
- TERMINATING_TOOL_NAMES = [.../* @__PURE__ */ new Set([
4808
- ...PACKAGED_ROLE_REGISTRY.map((entry) => entry.outputTool),
4809
- ...LEGACY_REVIEW_OUTPUT_ROLES.keys()
4810
- ])];
4811
- AcceptedDetailsContractError = class extends CorrectableSubmissionError {
4812
- code = "accepted_details_contract";
4813
- constructor(message, options) {
4814
- super(message, options);
4815
- this.name = "AcceptedDetailsContractError";
4816
- }
4817
- };
4818
- }
4819
- });
4820
-
4821
4771
  // src/ticket-progress.ts
4822
4772
  import { spawnSync as spawnSync2 } from "node:child_process";
4823
4773
  import {
@@ -4830,15 +4780,11 @@ import {
4830
4780
  writeFileSync as writeFileSync2
4831
4781
  } from "node:fs";
4832
4782
  import { basename as basename7, dirname as dirname7, join as join9, relative as relative2, sep as sep3 } from "node:path";
4833
- function parseProgressText(text, pathForDiagnostic) {
4834
- if (text.trim() === "") return [];
4783
+ function decodeProgressFile(path) {
4784
+ if (!existsSync3(path)) return { lines: [], malformed: [] };
4785
+ const text = readFileSync2(path, "utf8");
4786
+ if (text.trim() === "") return { lines: [], malformed: [] };
4835
4787
  const { records, diagnostics } = parseSitianRecordText(text);
4836
- for (const diagnostic of diagnostics) {
4837
- process.stderr.write(
4838
- `[ticket-progress] ${pathForDiagnostic} has malformed row(s); keeps reachable rows and retains the diagnostic: line ${diagnostic.line}: ${diagnostic.error}
4839
- `
4840
- );
4841
- }
4842
4788
  const lines = [];
4843
4789
  for (const record of records) {
4844
4790
  const parsed = record;
@@ -4846,11 +4792,20 @@ function parseProgressText(text, pathForDiagnostic) {
4846
4792
  if (typeof parsed.seat !== "string" || typeof parsed.round !== "string") continue;
4847
4793
  lines.push(parsed);
4848
4794
  }
4849
- return lines;
4795
+ return {
4796
+ lines,
4797
+ malformed: diagnostics.map((diagnostic) => `line ${diagnostic.line}: ${diagnostic.error}`)
4798
+ };
4850
4799
  }
4851
4800
  function readProgressFile(path) {
4852
- if (!existsSync3(path)) return [];
4853
- return parseProgressText(readFileSync2(path, "utf8"), path);
4801
+ const { lines, malformed } = decodeProgressFile(path);
4802
+ for (const diagnostic of malformed) {
4803
+ process.stderr.write(
4804
+ `[ticket-progress] ${path} has malformed row(s); keeps reachable rows and retains the diagnostic: ${diagnostic}
4805
+ `
4806
+ );
4807
+ }
4808
+ return lines;
4854
4809
  }
4855
4810
  function readTicketProgressLines(subjectDirectory) {
4856
4811
  if (basename7(subjectDirectory) === "unbound") {
@@ -4896,16 +4851,36 @@ function nextLegReceiptIndex(runDirectory) {
4896
4851
  }
4897
4852
  return max + 1;
4898
4853
  }
4899
- function statusAndSummaryFromPayload(seat, payload) {
4854
+ function statusAndSummaryFromPayload(payload) {
4900
4855
  if (!isRecord(payload)) return {};
4901
- const toolName = packagedRoleOutputTool(seat);
4902
- const status = toolName !== void 0 && isTerminatingToolName(toolName) ? acceptedFacts(toolName, payload).status : void 0;
4856
+ const received = receiptStatus(payload);
4857
+ const status = typeof received === "string" ? received : void 0;
4903
4858
  const summary = typeof payload.summary === "string" ? payload.summary : void 0;
4904
4859
  return {
4905
4860
  ...status === void 0 ? {} : { status },
4906
4861
  ...summary === void 0 ? {} : { summary }
4907
4862
  };
4908
4863
  }
4864
+ function readAuditedRound(auditedRunDirectory) {
4865
+ try {
4866
+ const subjectDirectory = subjectDirectoryOfRun(auditedRunDirectory);
4867
+ if (subjectDirectory === void 0) return {};
4868
+ const path = join9(subjectDirectory, CURRENT_FILENAME);
4869
+ const { lines, malformed } = decodeProgressFile(path);
4870
+ if (malformed.length > 0) {
4871
+ throw new Error(`${path} has malformed row(s): ${malformed.join("; ")}`);
4872
+ }
4873
+ const receipts = `runs/${basename7(auditedRunDirectory)}/`;
4874
+ const latest = lines.filter((line2) => line2.receipt.startsWith(receipts)).at(-1);
4875
+ return latest === void 0 ? {} : { for: `${latest.seat}#${latest.round}` };
4876
+ } catch (error) {
4877
+ return { fault: `audited round unavailable for ${auditedRunDirectory}: ${errorText(error)}` };
4878
+ }
4879
+ }
4880
+ function forOfSealedRow(runDirectory, seat, payload) {
4881
+ const reported = packagedGateStageLabel(seat) !== void 0 ? readPageSync(runDirectory, "admitted")?.for : seat === "fixer" && isRecord(payload) ? payload.for : void 0;
4882
+ return typeof reported === "string" ? reported : void 0;
4883
+ }
4909
4884
  function captureWorktreeHead(projectRoot) {
4910
4885
  try {
4911
4886
  const result = spawnSync2("git", ["rev-parse", "HEAD"], {
@@ -4983,12 +4958,14 @@ function landTicketProgress(input) {
4983
4958
  const existing = unbound ? readProgressFile(progressPath) : readTicketProgressLines(subjectDirectory);
4984
4959
  const round = unbound ? "" : nextRoundFromLines(existing, input.role, lens);
4985
4960
  const sessionRelative = input.sessionFile === void 0 ? "" : relative2(subjectDirectory, input.sessionFile).split(sep3).join("/");
4986
- const { status, summary } = statusAndSummaryFromPayload(input.role, input.accepted);
4961
+ const { status, summary } = statusAndSummaryFromPayload(input.accepted);
4962
+ const reviewed = forOfSealedRow(runDirectory, input.role, input.accepted);
4987
4963
  const instruction = input.instruction;
4988
4964
  const line2 = {
4989
4965
  at: (/* @__PURE__ */ new Date()).toISOString(),
4990
4966
  seat: input.role,
4991
4967
  round,
4968
+ ...reviewed === void 0 ? {} : { for: reviewed },
4992
4969
  instruction,
4993
4970
  head: input.sealHead.head,
4994
4971
  ...status === void 0 ? {} : { status },
@@ -5053,7 +5030,6 @@ var init_ticket_progress = __esm({
5053
5030
  "use strict";
5054
5031
  init_host_session_record();
5055
5032
  init_host_contracts();
5056
- init_terminating_tools();
5057
5033
  init_packaged_role_registry();
5058
5034
  init_role_run_placement();
5059
5035
  init_run_dossier();
@@ -5076,6 +5052,57 @@ var init_sha256 = __esm({
5076
5052
  }
5077
5053
  });
5078
5054
 
5055
+ // src/package-contracts/terminating-tools.ts
5056
+ function isTerminatingToolName(name) {
5057
+ return TERMINATING_TOOL_NAMES.includes(name);
5058
+ }
5059
+ function validateAcceptedDetails(_toolName, details) {
5060
+ if (isRecord(details)) {
5061
+ return details;
5062
+ }
5063
+ return {};
5064
+ }
5065
+ function acceptedFacts(toolName, details) {
5066
+ const record = details;
5067
+ const received = receiptStatus(details);
5068
+ const status = typeof received === "string" ? received : void 0;
5069
+ const seat = receiptSeat(toolName, () => void 0)?.seat;
5070
+ const entry = seat === void 0 ? void 0 : packagedRoleMetadata(seat);
5071
+ const commitKey = entry !== void 0 && "receiptCommitKey" in entry ? entry.receiptCommitKey : void 0;
5072
+ const commitWhen = entry !== void 0 && "receiptCommitWhen" in entry ? entry.receiptCommitWhen : void 0;
5073
+ const commit = commitKey !== void 0 && status === commitWhen && typeof record[commitKey] === "string" ? record[commitKey] : void 0;
5074
+ return {
5075
+ ...status === void 0 ? {} : { status },
5076
+ ...commit === void 0 ? {} : { commit }
5077
+ };
5078
+ }
5079
+ var TERMINATING_TOOL_NAMES, AcceptedDetailsContractError;
5080
+ var init_terminating_tools = __esm({
5081
+ "src/package-contracts/terminating-tools.ts"() {
5082
+ "use strict";
5083
+ init_collector_output();
5084
+ init_judge_output();
5085
+ init_reviewer_output();
5086
+ init_packaged_role_registry();
5087
+ init_submission_correctable_error();
5088
+ init_doctor_contracts();
5089
+ init_merger_contracts();
5090
+ init_worker_output();
5091
+ init_unknown_value();
5092
+ TERMINATING_TOOL_NAMES = [.../* @__PURE__ */ new Set([
5093
+ ...PACKAGED_ROLE_REGISTRY.map((entry) => entry.outputTool),
5094
+ ...LEGACY_REVIEW_OUTPUT_ROLES.keys()
5095
+ ])];
5096
+ AcceptedDetailsContractError = class extends CorrectableSubmissionError {
5097
+ code = "accepted_details_contract";
5098
+ constructor(message, options) {
5099
+ super(message, options);
5100
+ this.name = "AcceptedDetailsContractError";
5101
+ }
5102
+ };
5103
+ }
5104
+ });
5105
+
5079
5106
  // src/doctor-evidence.ts
5080
5107
  import { readdir as readdir2, readFile as readFile5, realpath, stat } from "node:fs/promises";
5081
5108
  import { dirname as dirname8, relative as relative3, resolve as resolve4, sep as sep4 } from "node:path";
@@ -7139,22 +7166,25 @@ async function mergeInvocationIdentityPage(runDirectory, fields) {
7139
7166
  ...fields
7140
7167
  }));
7141
7168
  }
7142
- async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubject) {
7143
- if (sourceRunPath.trim() === "") {
7144
- throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
7169
+ function persistAdmittedAuditedLeg(runDirectory, audited) {
7170
+ const { sourceRunPath, auditorSubject } = audited;
7171
+ if (sourceRunPath !== void 0 && sourceRunPath.trim() === "") {
7172
+ throw new Error("persistAdmittedAuditedLeg requires a non-empty sourceRunPath");
7145
7173
  }
7146
- updateSectionSync(admitted.runDirectory, "admitted", (current) => {
7147
- if (typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
7174
+ updateSectionSync(runDirectory, "admitted", (current) => {
7175
+ if (sourceRunPath !== void 0 && typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
7148
7176
  throw new Error(
7149
- `persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
7177
+ `persistAdmittedAuditedLeg refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
7150
7178
  );
7151
7179
  }
7152
- const sameSubject = auditorSubject === void 0 || current.auditorSubject === auditorSubject;
7153
- if (current.sourceRunPath === sourceRunPath && sameSubject) return void 0;
7180
+ const unchanged = current.for === audited.for && (sourceRunPath === void 0 || current.sourceRunPath === sourceRunPath) && (auditorSubject === void 0 || current.auditorSubject === auditorSubject);
7181
+ if (unchanged) return void 0;
7182
+ const { for: _replaced, ...rest } = current;
7154
7183
  return {
7155
- ...current,
7156
- sourceRunPath,
7157
- ...auditorSubject === void 0 ? {} : { auditorSubject }
7184
+ ...rest,
7185
+ ...sourceRunPath === void 0 ? {} : { sourceRunPath },
7186
+ ...auditorSubject === void 0 ? {} : { auditorSubject },
7187
+ ...audited.for === void 0 ? {} : { for: audited.for }
7158
7188
  };
7159
7189
  });
7160
7190
  }
@@ -8880,14 +8910,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
8880
8910
  return {
8881
8911
  ...host,
8882
8912
  registerTool(tool) {
8883
- const registeredRole = outputTools.get(tool.name);
8884
- let role;
8885
- if (typeof registeredRole === "string") {
8886
- role = registeredRole;
8887
- } else if (registeredRole !== void 0) {
8888
- const activeRole = host.getFlag("ak-role");
8889
- role = typeof activeRole === "string" && registeredRole.includes(activeRole) ? activeRole : void 0;
8890
- }
8913
+ const role = outputTools.get(tool.name);
8891
8914
  if (role === void 0) return host.registerTool(tool);
8892
8915
  host.registerTool({
8893
8916
  ...tool,
@@ -9361,9 +9384,7 @@ function markerMatchesExpectedIdentity(marker, expected) {
9361
9384
  }
9362
9385
  function packagedRoleOutputRejectionReason(message) {
9363
9386
  if (typeof message.toolName !== "string") return void 0;
9364
- if (!PACKAGED_ROLE_OUTPUT_TOOLS.has(message.toolName) && message.toolName !== "ak_submission_output") {
9365
- return void 0;
9366
- }
9387
+ if (!isTerminatingToolName(message.toolName)) return void 0;
9367
9388
  if (message.isError !== true) return void 0;
9368
9389
  if (classifyPackagedRoleTerminalResult(message).kind !== "nonterminal") return void 0;
9369
9390
  const content = message.content;
@@ -9378,7 +9399,7 @@ function packagedRoleOutputRejectionReason(message) {
9378
9399
  }
9379
9400
  function classifyPackagedRoleTerminalResult(message) {
9380
9401
  if (typeof message.toolName !== "string") return { kind: "nonterminal" };
9381
- if (!PACKAGED_ROLE_OUTPUT_TOOLS.has(message.toolName) && message.toolName !== "ak_submission_output") return { kind: "nonterminal" };
9402
+ if (!isTerminatingToolName(message.toolName)) return { kind: "nonterminal" };
9382
9403
  const hasInfraBase = hasNavigatorInfrastructureFailureBase(message.details);
9383
9404
  const infraFact = hasInfraBase ? buildNavigatorInfrastructureFailureFact() : void 0;
9384
9405
  if (message.isError === true) {
@@ -9395,8 +9416,10 @@ function durableTerminalAt(entries, index) {
9395
9416
  const entry = entries[index];
9396
9417
  const message = entry?.type === "custom" && entry.customType === "ak-role-submission-closure" ? typeof entry.data === "object" && entry.data !== null ? entry.data : void 0 : entry?.type === "message" && entry.message?.role === "toolResult" ? entry.message : void 0;
9397
9418
  if (typeof message?.toolName !== "string") return void 0;
9398
- const marker = message.toolName === "ak_submission_output" ? entries.slice(0, index).reverse().find(isInvocationMarkerEntry) : void 0;
9399
- const role = message.toolName === "ak_submission_output" ? parseInvocationMarkerIdentity(marker?.data)?.role ?? "unknown" : PACKAGED_ROLE_OUTPUT_TOOLS.get(message.toolName);
9419
+ const role = receiptSeat(message.toolName, () => {
9420
+ const marker = entries.slice(0, index).reverse().find(isInvocationMarkerEntry);
9421
+ return parseInvocationMarkerIdentity(marker?.data)?.role ?? "unknown";
9422
+ })?.seat;
9400
9423
  if (role === void 0) return void 0;
9401
9424
  const classification = classifyPackagedRoleTerminalResult(message);
9402
9425
  if (classification.kind !== "accepted" && classification.kind !== "infrastructure") {
@@ -9449,10 +9472,11 @@ function resolveLifecycleInvocationPrincipal(entries, expected) {
9449
9472
  }
9450
9473
  return { invocationId: marker.invocationId, resume: true };
9451
9474
  }
9452
- var NAVIGATOR_INVOCATION_ENTRY, NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND, NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS, NAVIGATOR_INFRASTRUCTURE_FAILURE_EVIDENCE_KEYS, PACKAGED_ROLE_OUTPUT_TOOLS;
9475
+ var NAVIGATOR_INVOCATION_ENTRY, NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND, NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS, NAVIGATOR_INFRASTRUCTURE_FAILURE_EVIDENCE_KEYS;
9453
9476
  var init_navigator_invocation_identity = __esm({
9454
9477
  "src/navigator-invocation-identity.ts"() {
9455
9478
  "use strict";
9479
+ init_terminating_tools();
9456
9480
  init_packaged_role_registry();
9457
9481
  init_uuidv7();
9458
9482
  init_unknown_value();
@@ -9471,9 +9495,6 @@ var init_navigator_invocation_identity = __esm({
9471
9495
  "stage",
9472
9496
  "reason"
9473
9497
  ];
9474
- PACKAGED_ROLE_OUTPUT_TOOLS = new Map(
9475
- [...PACKAGED_ROLE_REGISTRY.filter((entry) => entry.outputTool !== "ak_submission_output").map((entry) => [entry.outputTool, entry.role]), ...LEGACY_REVIEW_OUTPUT_ROLES]
9476
- );
9477
9498
  }
9478
9499
  });
9479
9500
 
@@ -12465,11 +12486,8 @@ function latestQueueStatus(terminal) {
12465
12486
  if (outcome === void 0) return void 0;
12466
12487
  if (outcome.kind === "audit_escalation") return "escalate";
12467
12488
  if (outcome.kind !== "accepted") return void 0;
12468
- const latest = outcome.payloads?.[outcome.payloads.length - 1];
12469
- if (isRecord(latest) && Object.hasOwn(latest, "status")) {
12470
- return receivedDiscriminator(latest, "status");
12471
- }
12472
- return outcome.status;
12489
+ const received = receiptStatus(outcome.payloads?.[outcome.payloads.length - 1]);
12490
+ return received === void 0 ? outcome.status : received;
12473
12491
  }
12474
12492
  function latestQueuePayload(terminal) {
12475
12493
  const outcome = terminal?.roleOutcome;
@@ -12606,9 +12624,8 @@ var init_submission_gate = __esm({
12606
12624
  init_invocation();
12607
12625
  init_run_lifecycle();
12608
12626
  init_gatekeeper_role();
12609
- init_submission_errors();
12627
+ init_packaged_role_registry();
12610
12628
  init_receipt_delivery_policy();
12611
- init_unknown_value();
12612
12629
  }
12613
12630
  });
12614
12631
 
@@ -13667,7 +13684,7 @@ async function bindDiaristAssertedTicketNumber(admitted) {
13667
13684
  );
13668
13685
  for (const row of rows) {
13669
13686
  if (row.role !== admitted.role || !isRecord(row.accepted)) continue;
13670
- if (row.accepted.status !== "completed" || !("ticketNumber" in row.accepted)) continue;
13687
+ if (receiptStatus(row.accepted) !== "completed" || !("ticketNumber" in row.accepted)) continue;
13671
13688
  const ticketNumber = parseTicketNumber(row.accepted.ticketNumber);
13672
13689
  if (ticketNumber !== void 0) {
13673
13690
  await bindAdmittedTicketNumber(admitted, ticketNumber);
@@ -14538,8 +14555,7 @@ var init_seat_ticket_binding = __esm({
14538
14555
 
14539
14556
  // src/public-cli/countersign-run.ts
14540
14557
  function isEscalatePayload(payload) {
14541
- if (!isRecord(payload)) return false;
14542
- return payload.status === "escalate";
14558
+ return receiptStatus(payload) === "escalate";
14543
14559
  }
14544
14560
  function courtDiaristEscalateDiagnostic(terminal) {
14545
14561
  const payloads = currentReplyRows(terminal);
@@ -14624,7 +14640,7 @@ var init_countersign_run = __esm({
14624
14640
  "use strict";
14625
14641
  init_readable_gate_item();
14626
14642
  init_terminal();
14627
- init_unknown_value();
14643
+ init_packaged_role_registry();
14628
14644
  }
14629
14645
  });
14630
14646
 
@@ -14645,7 +14661,7 @@ function unreadablePostSubmissionStatus(admitted, terminal) {
14645
14661
  const route = POST_SUBMISSION_ROUTING[admitted.role];
14646
14662
  if (route === void 0) return void 0;
14647
14663
  const payload = terminal.roleOutcome.payloads?.at(-1);
14648
- const status = receivedDiscriminator(payload, "status");
14664
+ const status = receiptStatus(payload);
14649
14665
  return typeof status === "string" && route.statuses.has(status) ? void 0 : route.reask ?? officerConclusionReask(status);
14650
14666
  }
14651
14667
  function withUnreadableReask(env) {
@@ -15045,6 +15061,16 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
15045
15061
  else io.stdout(formatTerminalResult(terminal));
15046
15062
  return { exitCode: failed ? 1 : 0, terminal };
15047
15063
  }
15064
+ async function pinAuditedLegAtAdmission(officerRunDirectory, auditedRunDirectory, io, source) {
15065
+ const { for: auditedRound, fault } = readAuditedRound(auditedRunDirectory);
15066
+ persistAdmittedAuditedLeg(officerRunDirectory, { for: auditedRound, ...source });
15067
+ if (fault === void 0) return;
15068
+ await retainPackageFault({
15069
+ runDirectory: officerRunDirectory,
15070
+ diagnostic: fault,
15071
+ stderr: (text) => io.stderr(text)
15072
+ });
15073
+ }
15048
15074
  function resumeSameParentInstructionSeat(input) {
15049
15075
  return tryResumeSameTicketSeatRun({
15050
15076
  home: input.env.home,
@@ -15064,7 +15090,8 @@ function resumeSameParentInstructionSeat(input) {
15064
15090
  ...materials === void 0 ? {} : { summons: materials }
15065
15091
  },
15066
15092
  input.env,
15067
- input.io
15093
+ input.io,
15094
+ input.parentRunPath
15068
15095
  );
15069
15096
  }
15070
15097
  });
@@ -15140,7 +15167,9 @@ async function runCountersignBody(parsed, env, io) {
15140
15167
  );
15141
15168
  await markRunAdmitted(admitted, env.principalAuthority);
15142
15169
  if (gateParentRunPath !== void 0) {
15143
- await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
15170
+ await pinAuditedLegAtAdmission(admitted.runDirectory, gateParentRunPath, io, {
15171
+ sourceRunPath: gateParentRunPath
15172
+ });
15144
15173
  admitted = { ...admitted, sourceRunPath: gateParentRunPath };
15145
15174
  }
15146
15175
  const turnProjection = roleTurnOptions(env, admitted, {
@@ -15349,12 +15378,21 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
15349
15378
  throw error;
15350
15379
  }
15351
15380
  if (instructionSourceRunPath !== void 0) {
15352
- await persistAdmittedSourceRunPath(admitted, instructionSourceRunPath);
15381
+ await pinAuditedLegAtAdmission(admitted.runDirectory, instructionSourceRunPath, io, {
15382
+ sourceRunPath: instructionSourceRunPath
15383
+ });
15353
15384
  admitted = { ...admitted, sourceRunPath: instructionSourceRunPath };
15354
- }
15355
- if (record.sameParent === "subject-source" && auditorSource !== void 0) {
15356
- await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
15385
+ } else if (record.sameParent === "subject-source" && auditorSource !== void 0) {
15386
+ await pinAuditedLegAtAdmission(admitted.runDirectory, auditorSource, io, {
15387
+ sourceRunPath: auditorSource,
15388
+ auditorSubject
15389
+ });
15357
15390
  admitted = { ...admitted, sourceRunPath: auditorSource };
15391
+ } else {
15392
+ const auditedRunDirectory = admittedSourceRunPath(admitted);
15393
+ if (auditedRunDirectory !== void 0) {
15394
+ await pinAuditedLegAtAdmission(admitted.runDirectory, auditedRunDirectory, io);
15395
+ }
15358
15396
  }
15359
15397
  admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
15360
15398
  const runAdmitted = async () => {
@@ -15429,7 +15467,7 @@ async function inheritKnownTicketFromSource(admitted, authority) {
15429
15467
  await relocateAdmittedRunToTicket(admitted, authority);
15430
15468
  return admitted;
15431
15469
  }
15432
- async function runPublicInstructionSeatResume(request, env, io) {
15470
+ async function runPublicInstructionSeatResume(request, env, io, resummonedFor) {
15433
15471
  let selectedRequest = request;
15434
15472
  const resume = async () => {
15435
15473
  const held = [];
@@ -15460,6 +15498,9 @@ async function runPublicInstructionSeatResume(request, env, io) {
15460
15498
  return { ...loaded, admitted };
15461
15499
  },
15462
15500
  buildTurnRequest: async (admitted, effective) => {
15501
+ if (resummonedFor !== void 0) {
15502
+ await pinAuditedLegAtAdmission(admitted.runDirectory, resummonedFor, io);
15503
+ }
15463
15504
  const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
15464
15505
  const projection = resumeTurnRequestProjectionOptions(
15465
15506
  admitted,
@@ -15669,8 +15710,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
15669
15710
  if (admitted === void 0 || !AUDITED_ROLES.has(admitted.role) || turn.terminal?.roleOutcome.kind !== "accepted") return turn;
15670
15711
  const accepted = turn.terminal.roleOutcome.payloads?.at(-1);
15671
15712
  if (accepted === void 0) throw new Error("accepted submission has no payload");
15672
- const record = isRecord(accepted) ? accepted : void 0;
15673
- const status = admitted.role === "secretariat" ? record?.secretariatStatus : record?.status;
15713
+ const status = receiptStatus(accepted);
15674
15714
  const gateOwnsStatusReask = typeof env.parentRunPath === "string" && env.parentRunPath.trim() !== "";
15675
15715
  if (admitted.role === "secretariat" && status !== "converged" && status !== "escalate") {
15676
15716
  if (gateOwnsStatusReask) return turn;
@@ -15954,7 +15994,6 @@ var init_instruction_seat_run = __esm({
15954
15994
  init_role_run_placement();
15955
15995
  init_doctor_auditor();
15956
15996
  init_gatekeeper_role();
15957
- init_submission_errors();
15958
15997
  init_review_submission();
15959
15998
  init_judge_role();
15960
15999
  init_worker_submission_contracts();
@@ -15980,9 +16019,10 @@ var init_instruction_seat_run = __esm({
15980
16019
  init_terminal();
15981
16020
  init_turn_request();
15982
16021
  init_countersign_run();
16022
+ init_ticket_progress();
15983
16023
  init_unknown_value();
15984
16024
  AUDITED_ROLES = /* @__PURE__ */ new Set(["judge", "fixer", "coder", "secretariat", "countersign", "doctor"]);
15985
- SECRETARIAT_STATUS_REASK = "secretariatStatus \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0CsecretariatStatus \u5199\u660E\u5176\u4E00\u3002";
16025
+ SECRETARIAT_STATUS_REASK = "status \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
15986
16026
  WORKER_ROUTING_STATUSES = /* @__PURE__ */ new Set([
15987
16027
  "planned",
15988
16028
  "completed",
@@ -17736,11 +17776,11 @@ function projectTerminal(facts) {
17736
17776
  }
17737
17777
  const status = extractStatus(facts.terminal.body);
17738
17778
  const classCount = readClassCount(facts.terminal.body);
17739
- const receiptStatus = status ?? "unparsed";
17779
+ const receiptStatus2 = status ?? "unparsed";
17740
17780
  if (classCount === void 0) {
17741
- return { kind: "receipt", status: receiptStatus };
17781
+ return { kind: "receipt", status: receiptStatus2 };
17742
17782
  }
17743
- return { kind: "receipt", status: receiptStatus, classCount };
17783
+ return { kind: "receipt", status: receiptStatus2, classCount };
17744
17784
  }
17745
17785
  function projectRunRow(facts) {
17746
17786
  const { startedAt, endedAt } = facts.frameSpan;
@@ -19856,7 +19896,7 @@ function tryReadComplianceCandidate(arguments_, usage) {
19856
19896
  return void 0;
19857
19897
  }
19858
19898
  const args = arguments_;
19859
- const status = args.status;
19899
+ const status = receiptStatus(arguments_);
19860
19900
  if (status === "converged") return { status, receipt: arguments_, ...usage === void 0 ? {} : { usage } };
19861
19901
  if (status === "continue") return { status, violations: readListField(args.violations), receipt: arguments_, ...usage === void 0 ? {} : { usage } };
19862
19902
  if (status === "escalate") {
@@ -19960,7 +20000,7 @@ async function runComplianceAudit(options) {
19960
20000
  if (decision.status === "received") {
19961
20001
  if (reasksSpent >= reaskLimit) return decision;
19962
20002
  reasksSpent += 1;
19963
- reask = officerConclusionReask(receivedDiscriminator(decision.reply, "status"));
20003
+ reask = officerConclusionReask(receiptStatus(decision.reply));
19964
20004
  continue;
19965
20005
  }
19966
20006
  return decision;
@@ -19972,7 +20012,7 @@ var init_compliance_transport = __esm({
19972
20012
  "use strict";
19973
20013
  init_role_run_placement();
19974
20014
  init_gatekeeper_role();
19975
- init_submission_errors();
20015
+ init_packaged_role_registry();
19976
20016
  init_terminal();
19977
20017
  init_readable_gate_item();
19978
20018
  init_receipt_delivery_policy();
@@ -22448,7 +22488,7 @@ function fixerBashSeatbeltDenyReason(matched) {
22448
22488
  }
22449
22489
 
22450
22490
  // src/worker-role.ts
22451
- init_unknown_value();
22491
+ init_packaged_role_registry();
22452
22492
  init_worker_output();
22453
22493
  var FIXER_FLAG_DEFINITIONS = {
22454
22494
  phase: {
@@ -22464,7 +22504,8 @@ function isWorkerPhase(value) {
22464
22504
  return typeof value === "string" && FIXER_PHASES.includes(value);
22465
22505
  }
22466
22506
  function workerStatusOf(output) {
22467
- return isRecord(output) && typeof output.status === "string" ? output.status : void 0;
22507
+ const status = receiptStatus(output);
22508
+ return typeof status === "string" ? status : void 0;
22468
22509
  }
22469
22510
  function deepFreeze2(value) {
22470
22511
  if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
@@ -22880,14 +22921,6 @@ function navigatorPhase(roleHost, role) {
22880
22921
  function navigatorOutputTool(role) {
22881
22922
  return packagedRoleOutputTool(role);
22882
22923
  }
22883
- function receiptStatusFromRegistry(details) {
22884
- for (const entry of PACKAGED_ROLE_REGISTRY) {
22885
- if (!("receiptStatusKey" in entry)) continue;
22886
- const value = details[entry.receiptStatusKey];
22887
- if (typeof value === "string") return value;
22888
- }
22889
- return void 0;
22890
- }
22891
22924
  function publicNavigatorSettlement(role, phase, event) {
22892
22925
  if (event.toolName !== navigatorOutputTool(role)) return void 0;
22893
22926
  const classification = classifyPackagedRoleTerminalResult(event);
@@ -22895,9 +22928,9 @@ function publicNavigatorSettlement(role, phase, event) {
22895
22928
  if (classification.kind === "infrastructure") {
22896
22929
  return { kind: "role_infrastructure_failure", role, phase };
22897
22930
  }
22898
- const details = isRecord(event.details) ? event.details : {};
22899
- const status = typeof details.status === "string" ? details.status : receiptStatusFromRegistry(details);
22900
- if (status !== void 0 && status === "escalate") {
22931
+ const received = receiptStatus(event.details);
22932
+ const status = typeof received === "string" ? received : void 0;
22933
+ if (status === "escalate") {
22901
22934
  return { kind: "human_decision", role, phase, status };
22902
22935
  }
22903
22936
  return { kind: "accepted", role, phase, ...status === void 0 ? {} : { status } };
@@ -23073,8 +23106,7 @@ function createDiaristRoleRuntime(roleHost, dependencies, hostActions) {
23073
23106
  soulTag: "diarist",
23074
23107
  beforeAccept: async ({ toolCallId, parameters, ctx }) => {
23075
23108
  const submitted = isRecord(parameters) ? parameters : void 0;
23076
- const status = submitted?.status;
23077
- if (status !== "completed") return parameters;
23109
+ if (receiptStatus(parameters) !== "completed") return parameters;
23078
23110
  const assertion = readDiaristTicketAssertion(submitted);
23079
23111
  const ticketNumber = assertion.kind === "ticket" ? assertion.ticketNumber : void 0;
23080
23112
  try {
@@ -23163,15 +23195,15 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23163
23195
  };
23164
23196
  const roleHost = createSubmissionLedgerHost(
23165
23197
  envelopeHost.host,
23166
- new Map(PACKAGED_ROLE_REGISTRY.reduce((entries, { role, outputTool }) => {
23167
- const existingIndex = entries.findIndex(([name]) => name === outputTool);
23168
- if (existingIndex < 0) entries.push([outputTool, role]);
23169
- else {
23170
- const previous = entries[existingIndex][1];
23171
- entries[existingIndex] = [outputTool, [...Array.isArray(previous) ? previous : [previous], role]];
23198
+ {
23199
+ get(toolName) {
23200
+ const seat = receiptSeat(toolName, () => {
23201
+ const active = envelopeHost.host.getFlag(ROLE_FLAG.name);
23202
+ return typeof active === "string" ? active : void 0;
23203
+ })?.seat;
23204
+ return seat === void 0 ? void 0 : packagedRoleMetadata(seat)?.role;
23172
23205
  }
23173
- return entries;
23174
- }, [])),
23206
+ },
23175
23207
  (error, ctx, toolCallId) => hostActions.failInfrastructure(error, ctx, toolCallId),
23176
23208
  async (closed, context, toolCallId) => projectClosedSubmission(closed, context, toolCallId)
23177
23209
  );