@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
@@ -728,7 +728,7 @@ var init_review_submission = __esm({
728
728
  );
729
729
  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";
730
730
  secretariatArchitectureField = Type2.Array(architectureRowSchema, {
731
- 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`
731
+ 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`
732
732
  });
733
733
  countersignArchitectureField = Type2.Array(architectureRowSchema, {
734
734
  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`
@@ -880,7 +880,6 @@ var init_gatekeeper_output = __esm({
880
880
  "use strict";
881
881
  init_open_tool_schema();
882
882
  init_terminating_infrastructure();
883
- init_unknown_value();
884
883
  GATEKEEPER_OUTPUT_TOOL_NAME = "ak_gatekeeper_output";
885
884
  gatekeeperDecisionSchema = openToolObject(
886
885
  Type5.Object({
@@ -1048,6 +1047,9 @@ var init_fixer_output = __esm({
1048
1047
  classResults: Type8.Unknown({
1049
1048
  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"
1050
1049
  }),
1050
+ for: Type8.Unknown({
1051
+ 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"
1052
+ }),
1051
1053
  diffItems: diffItemsField,
1052
1054
  testEvidence: Type8.Unknown({
1053
1055
  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"
@@ -1281,7 +1283,6 @@ var init_notary_contracts = __esm({
1281
1283
  "src/notary-contracts.ts"() {
1282
1284
  "use strict";
1283
1285
  init_review_submission();
1284
- init_unknown_value();
1285
1286
  NOTARY_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
1286
1287
  NOTARY_SOURCE_RUN_FLAG = {
1287
1288
  name: "ak-notary-source-run",
@@ -1347,7 +1348,6 @@ var init_inspector_contracts = __esm({
1347
1348
  "src/inspector-contracts.ts"() {
1348
1349
  "use strict";
1349
1350
  init_review_submission();
1350
- init_unknown_value();
1351
1351
  INSPECTOR_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
1352
1352
  INSPECTOR_SOURCE_RUN_FLAG = {
1353
1353
  name: "ak-inspector-source-run",
@@ -1365,7 +1365,6 @@ var init_auditor_output = __esm({
1365
1365
  "src/package-contracts/auditor-output.ts"() {
1366
1366
  "use strict";
1367
1367
  init_review_submission();
1368
- init_unknown_value();
1369
1368
  AUDITOR_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
1370
1369
  }
1371
1370
  });
@@ -2443,7 +2442,7 @@ var init_secretariat_contracts = __esm({
2443
2442
  secretariatVerdictSchema = withTerminatingOutputDeclarations(
2444
2443
  Type14.Object(
2445
2444
  {
2446
- secretariatStatus: Type14.Unknown({
2445
+ status: Type14.Unknown({
2447
2446
  description: "converged | escalate"
2448
2447
  }),
2449
2448
  ticketNumber: Type14.Optional(
@@ -2513,8 +2512,25 @@ __export(packaged_role_registry_exports, {
2513
2512
  packagedRolePhaseFlag: () => packagedRolePhaseFlag,
2514
2513
  packagedRoleSessionMaterials: () => packagedRoleSessionMaterials,
2515
2514
  packagedStoresSourceRunRaw: () => packagedStoresSourceRunRaw,
2516
- packagedSubjectChoices: () => packagedSubjectChoices
2515
+ packagedSubjectChoices: () => packagedSubjectChoices,
2516
+ receiptSeat: () => receiptSeat,
2517
+ receiptStatus: () => receiptStatus
2517
2518
  });
2519
+ function receiptStatus(receipt) {
2520
+ if (!isRecord(receipt)) return void 0;
2521
+ for (const key of RECEIPT_STATUS_KEYS) {
2522
+ if (Object.hasOwn(receipt, key)) return receipt[key];
2523
+ }
2524
+ return void 0;
2525
+ }
2526
+ function receiptSeat(toolName, runSeat) {
2527
+ const legacy = LEGACY_REVIEW_OUTPUT_ROLES.get(toolName);
2528
+ if (legacy !== void 0) return { seat: legacy, source: "tool" };
2529
+ const owners = PACKAGED_ROLE_REGISTRY.filter((entry) => entry.outputTool === toolName);
2530
+ if (owners.length === 1) return { seat: owners[0].role, source: "tool" };
2531
+ const seat = owners.length === 0 ? void 0 : runSeat();
2532
+ return seat === void 0 ? void 0 : { seat, source: "invocation" };
2533
+ }
2518
2534
  function packagedRoleMetadata(role) {
2519
2535
  return PACKAGED_ROLE_REGISTRY.find((entry) => entry.role === role);
2520
2536
  }
@@ -2644,7 +2660,7 @@ function packagedGateSummon(role) {
2644
2660
  if (record !== void 0 && "gateSummon" in record) return record.gateSummon;
2645
2661
  return "pointer";
2646
2662
  }
2647
- var LEGACY_REVIEW_OUTPUT_ROLES, NOTARY_SESSION_MATERIALS, INSPECTOR_SESSION_MATERIALS, AUDITOR_PUBLIC_SESSION_MATERIALS, PUBLIC_ROLE_RECORDS, PACKAGED_ROLE_REGISTRY;
2663
+ var LEGACY_REVIEW_OUTPUT_ROLES, RECEIPT_STATUS_KEYS, NOTARY_SESSION_MATERIALS, INSPECTOR_SESSION_MATERIALS, AUDITOR_PUBLIC_SESSION_MATERIALS, PUBLIC_ROLE_RECORDS, PACKAGED_ROLE_REGISTRY;
2648
2664
  var init_packaged_role_registry = __esm({
2649
2665
  "src/packaged-role-registry.ts"() {
2650
2666
  "use strict";
@@ -2664,6 +2680,7 @@ var init_packaged_role_registry = __esm({
2664
2680
  init_diarist_contracts();
2665
2681
  init_secretariat_contracts();
2666
2682
  init_judge_auditor();
2683
+ init_unknown_value();
2667
2684
  LEGACY_REVIEW_OUTPUT_ROLES = /* @__PURE__ */ new Map([
2668
2685
  ["ak_judge_output", "judge"],
2669
2686
  ["ak_notary_output", "notary"],
@@ -2671,6 +2688,7 @@ var init_packaged_role_registry = __esm({
2671
2688
  ["ak_inspector_output", "inspector"],
2672
2689
  ["ak_auditor_output", "auditor"]
2673
2690
  ]);
2691
+ RECEIPT_STATUS_KEYS = ["status", "secretariatStatus", "judgeStatus", "countersignStatus"];
2674
2692
  NOTARY_SESSION_MATERIALS = [
2675
2693
  "CLAUDE.md",
2676
2694
  "souls/notary.md",
@@ -2714,7 +2732,6 @@ var init_packaged_role_registry = __esm({
2714
2732
  /** Factory board: court until another station has started, then marshal. */
2715
2733
  boardPlacement: "judge-history",
2716
2734
  activationStage: "load-and-install",
2717
- receiptStatusKey: "status",
2718
2735
  sessionMaterials: [
2719
2736
  "CLAUDE.md",
2720
2737
  "souls/judge.md",
@@ -2942,7 +2959,6 @@ var init_packaged_role_registry = __esm({
2942
2959
  { field: "ticketNumber" }
2943
2960
  ],
2944
2961
  activationStage: "load-and-install",
2945
- receiptStatusKey: "status",
2946
2962
  // #924: 公用《票面法》三席同装
2947
2963
  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"]
2948
2964
  },
@@ -2960,7 +2976,6 @@ var init_packaged_role_registry = __esm({
2960
2976
  { field: "ticketNumber" }
2961
2977
  ],
2962
2978
  activationStage: "load-and-install",
2963
- receiptStatusKey: "secretariatStatus",
2964
2979
  // #924: owner-finalized Soul + 票面法 + 给事中/符宝郎行为指南
2965
2980
  sessionMaterials: [
2966
2981
  "CLAUDE.md",
@@ -3139,17 +3154,11 @@ function unreadableDiscriminatorNotice(field, received) {
3139
3154
  if (received === void 0) return `\u8BFB\u4E0D\u51FA ${field}`;
3140
3155
  return `\u8BFB\u4E0D\u51FA ${field}\uFF1A${readableGateItem(received)}`;
3141
3156
  }
3142
- function receivedDiscriminator(receipt, field) {
3143
- if (!isRecord(receipt)) return void 0;
3144
- if (!Object.hasOwn(receipt, field)) return void 0;
3145
- return receipt[field];
3146
- }
3147
3157
  var WorkerCommitReminderError, WorkerPrefixReminderError, WorkerUnfinishedReasonReminderError, ParentQueueReaskError;
3148
3158
  var init_submission_errors = __esm({
3149
3159
  "src/submission-errors.ts"() {
3150
3160
  "use strict";
3151
3161
  init_readable_gate_item();
3152
- init_unknown_value();
3153
3162
  WorkerCommitReminderError = class extends Error {
3154
3163
  code = "worker_commit_reminder";
3155
3164
  constructor() {
@@ -3228,10 +3237,10 @@ function validateAcceptedDetails(_toolName, details) {
3228
3237
  }
3229
3238
  function acceptedFacts(toolName, details) {
3230
3239
  const record = details;
3231
- const entry = PACKAGED_ROLE_REGISTRY.find((candidate) => candidate.outputTool === toolName);
3232
- const legacyRole = LEGACY_REVIEW_OUTPUT_ROLES.get(toolName);
3233
- const statusKey = legacyRole === "judge" || legacyRole === "countersign" ? `${legacyRole}Status` : entry !== void 0 && "receiptStatusKey" in entry ? entry.receiptStatusKey : "status";
3234
- const status = typeof record[statusKey] === "string" ? record[statusKey] : void 0;
3240
+ const received = receiptStatus(details);
3241
+ const status = typeof received === "string" ? received : void 0;
3242
+ const seat = receiptSeat(toolName, () => void 0)?.seat;
3243
+ const entry = seat === void 0 ? void 0 : packagedRoleMetadata(seat);
3235
3244
  const commitKey = entry !== void 0 && "receiptCommitKey" in entry ? entry.receiptCommitKey : void 0;
3236
3245
  const commitWhen = entry !== void 0 && "receiptCommitWhen" in entry ? entry.receiptCommitWhen : void 0;
3237
3246
  const commit = commitKey !== void 0 && status === commitWhen && typeof record[commitKey] === "string" ? record[commitKey] : void 0;
@@ -3250,14 +3259,7 @@ var init_terminating_tools = __esm({
3250
3259
  init_packaged_role_registry();
3251
3260
  init_submission_correctable_error();
3252
3261
  init_doctor_contracts();
3253
- init_gatekeeper_output();
3254
- init_navigator_output();
3255
- init_auditor_output();
3256
3262
  init_merger_contracts();
3257
- init_notary_contracts();
3258
- init_inspector_contracts();
3259
- init_diarist_contracts();
3260
- init_secretariat_contracts();
3261
3263
  init_worker_output();
3262
3264
  init_unknown_value();
3263
3265
  TERMINATING_TOOL_NAMES = [.../* @__PURE__ */ new Set([
@@ -3555,9 +3557,7 @@ function markerMatchesExpectedIdentity(marker, expected) {
3555
3557
  }
3556
3558
  function packagedRoleOutputRejectionReason(message) {
3557
3559
  if (typeof message.toolName !== "string") return void 0;
3558
- if (!PACKAGED_ROLE_OUTPUT_TOOLS.has(message.toolName) && message.toolName !== "ak_submission_output") {
3559
- return void 0;
3560
- }
3560
+ if (!isTerminatingToolName(message.toolName)) return void 0;
3561
3561
  if (message.isError !== true) return void 0;
3562
3562
  if (classifyPackagedRoleTerminalResult(message).kind !== "nonterminal") return void 0;
3563
3563
  const content = message.content;
@@ -3572,7 +3572,7 @@ function packagedRoleOutputRejectionReason(message) {
3572
3572
  }
3573
3573
  function classifyPackagedRoleTerminalResult(message) {
3574
3574
  if (typeof message.toolName !== "string") return { kind: "nonterminal" };
3575
- if (!PACKAGED_ROLE_OUTPUT_TOOLS.has(message.toolName) && message.toolName !== "ak_submission_output") return { kind: "nonterminal" };
3575
+ if (!isTerminatingToolName(message.toolName)) return { kind: "nonterminal" };
3576
3576
  const hasInfraBase = hasNavigatorInfrastructureFailureBase(message.details);
3577
3577
  const infraFact = hasInfraBase ? buildNavigatorInfrastructureFailureFact() : void 0;
3578
3578
  if (message.isError === true) {
@@ -3589,8 +3589,10 @@ function durableTerminalAt(entries, index) {
3589
3589
  const entry = entries[index];
3590
3590
  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;
3591
3591
  if (typeof message?.toolName !== "string") return void 0;
3592
- const marker = message.toolName === "ak_submission_output" ? entries.slice(0, index).reverse().find(isInvocationMarkerEntry) : void 0;
3593
- const role = message.toolName === "ak_submission_output" ? parseInvocationMarkerIdentity(marker?.data)?.role ?? "unknown" : PACKAGED_ROLE_OUTPUT_TOOLS.get(message.toolName);
3592
+ const role = receiptSeat(message.toolName, () => {
3593
+ const marker = entries.slice(0, index).reverse().find(isInvocationMarkerEntry);
3594
+ return parseInvocationMarkerIdentity(marker?.data)?.role ?? "unknown";
3595
+ })?.seat;
3594
3596
  if (role === void 0) return void 0;
3595
3597
  const classification = classifyPackagedRoleTerminalResult(message);
3596
3598
  if (classification.kind !== "accepted" && classification.kind !== "infrastructure") {
@@ -3643,10 +3645,11 @@ function resolveLifecycleInvocationPrincipal(entries, expected) {
3643
3645
  }
3644
3646
  return { invocationId: marker.invocationId, resume: true };
3645
3647
  }
3646
- var NAVIGATOR_INVOCATION_ENTRY, NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND, NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS, NAVIGATOR_INFRASTRUCTURE_FAILURE_EVIDENCE_KEYS, PACKAGED_ROLE_OUTPUT_TOOLS;
3648
+ var NAVIGATOR_INVOCATION_ENTRY, NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND, NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS, NAVIGATOR_INFRASTRUCTURE_FAILURE_EVIDENCE_KEYS;
3647
3649
  var init_navigator_invocation_identity = __esm({
3648
3650
  "src/navigator-invocation-identity.ts"() {
3649
3651
  "use strict";
3652
+ init_terminating_tools();
3650
3653
  init_packaged_role_registry();
3651
3654
  init_uuidv7();
3652
3655
  init_unknown_value();
@@ -3665,9 +3668,6 @@ var init_navigator_invocation_identity = __esm({
3665
3668
  "stage",
3666
3669
  "reason"
3667
3670
  ];
3668
- PACKAGED_ROLE_OUTPUT_TOOLS = new Map(
3669
- [...PACKAGED_ROLE_REGISTRY.filter((entry) => entry.outputTool !== "ak_submission_output").map((entry) => [entry.outputTool, entry.role]), ...LEGACY_REVIEW_OUTPUT_ROLES]
3670
- );
3671
3671
  }
3672
3672
  });
3673
3673
 
@@ -4954,8 +4954,8 @@ function reviewQueueStatus(status) {
4954
4954
  }
4955
4955
  function projectOfficerDecision(officer, decision, fallbackStatus) {
4956
4956
  const receipt = retainedReceipt(decision);
4957
- const record = isRecord(decision) ? decision : void 0;
4958
- const status = record !== void 0 && Object.hasOwn(record, "status") ? receivedDiscriminator(record, "status") : fallbackStatus;
4957
+ const received = receiptStatus(decision);
4958
+ const status = received === void 0 ? fallbackStatus : received;
4959
4959
  const queueStatus = typeof status === "string" ? reviewQueueStatus(status) : void 0;
4960
4960
  if (queueStatus === "converged") {
4961
4961
  return { status: "converged", officer, receipt };
@@ -5044,7 +5044,7 @@ function projectOfficerTerminal(officer, summoned) {
5044
5044
  status: "needs_reask",
5045
5045
  officer,
5046
5046
  receipt: receipt2,
5047
- receivedStatus: receivedDiscriminator(receipt2, "status")
5047
+ receivedStatus: receiptStatus(receipt2)
5048
5048
  },
5049
5049
  summoned
5050
5050
  );
@@ -5061,7 +5061,7 @@ function projectOfficerTerminal(officer, summoned) {
5061
5061
  officer,
5062
5062
  // This-court receipt only (#879).
5063
5063
  receipt,
5064
- receivedStatus: receivedDiscriminator(receipt, "status")
5064
+ receivedStatus: receiptStatus(receipt)
5065
5065
  },
5066
5066
  summoned
5067
5067
  );
@@ -5116,7 +5116,6 @@ var init_gatekeeper_role = __esm({
5116
5116
  init_role_submission_declarations();
5117
5117
  init_terminal();
5118
5118
  init_run_terminal_artifacts();
5119
- init_unknown_value();
5120
5119
  init_serialize_thrown_value();
5121
5120
  GATE_OFFICER_BY_SUBJECT = {
5122
5121
  worker_completion: "inspector",
@@ -6116,7 +6115,7 @@ function tryReadComplianceCandidate(arguments_, usage) {
6116
6115
  return void 0;
6117
6116
  }
6118
6117
  const args = arguments_;
6119
- const status = args.status;
6118
+ const status = receiptStatus(arguments_);
6120
6119
  if (status === "converged") return { status, receipt: arguments_, ...usage === void 0 ? {} : { usage } };
6121
6120
  if (status === "continue") return { status, violations: readListField(args.violations), receipt: arguments_, ...usage === void 0 ? {} : { usage } };
6122
6121
  if (status === "escalate") {
@@ -6220,7 +6219,7 @@ async function runComplianceAudit(options) {
6220
6219
  if (decision.status === "received") {
6221
6220
  if (reasksSpent >= reaskLimit) return decision;
6222
6221
  reasksSpent += 1;
6223
- reask = officerConclusionReask(receivedDiscriminator(decision.reply, "status"));
6222
+ reask = officerConclusionReask(receiptStatus(decision.reply));
6224
6223
  continue;
6225
6224
  }
6226
6225
  return decision;
@@ -6232,7 +6231,7 @@ var init_compliance_transport = __esm({
6232
6231
  "use strict";
6233
6232
  init_role_run_placement();
6234
6233
  init_gatekeeper_role();
6235
- init_submission_errors();
6234
+ init_packaged_role_registry();
6236
6235
  init_terminal();
6237
6236
  init_readable_gate_item();
6238
6237
  init_receipt_delivery_policy();
@@ -6301,15 +6300,11 @@ import {
6301
6300
  writeFileSync as writeFileSync2
6302
6301
  } from "node:fs";
6303
6302
  import { basename as basename7, dirname as dirname10, join as join12, relative as relative3, sep as sep4 } from "node:path";
6304
- function parseProgressText(text, pathForDiagnostic) {
6305
- if (text.trim() === "") return [];
6303
+ function decodeProgressFile(path) {
6304
+ if (!existsSync4(path)) return { lines: [], malformed: [] };
6305
+ const text = readFileSync3(path, "utf8");
6306
+ if (text.trim() === "") return { lines: [], malformed: [] };
6306
6307
  const { records, diagnostics } = parseSitianRecordText(text);
6307
- for (const diagnostic of diagnostics) {
6308
- process.stderr.write(
6309
- `[ticket-progress] ${pathForDiagnostic} has malformed row(s); keeps reachable rows and retains the diagnostic: line ${diagnostic.line}: ${diagnostic.error}
6310
- `
6311
- );
6312
- }
6313
6308
  const lines = [];
6314
6309
  for (const record of records) {
6315
6310
  const parsed = record;
@@ -6317,11 +6312,20 @@ function parseProgressText(text, pathForDiagnostic) {
6317
6312
  if (typeof parsed.seat !== "string" || typeof parsed.round !== "string") continue;
6318
6313
  lines.push(parsed);
6319
6314
  }
6320
- return lines;
6315
+ return {
6316
+ lines,
6317
+ malformed: diagnostics.map((diagnostic) => `line ${diagnostic.line}: ${diagnostic.error}`)
6318
+ };
6321
6319
  }
6322
6320
  function readProgressFile(path) {
6323
- if (!existsSync4(path)) return [];
6324
- return parseProgressText(readFileSync3(path, "utf8"), path);
6321
+ const { lines, malformed } = decodeProgressFile(path);
6322
+ for (const diagnostic of malformed) {
6323
+ process.stderr.write(
6324
+ `[ticket-progress] ${path} has malformed row(s); keeps reachable rows and retains the diagnostic: ${diagnostic}
6325
+ `
6326
+ );
6327
+ }
6328
+ return lines;
6325
6329
  }
6326
6330
  function readTicketProgressLines(subjectDirectory) {
6327
6331
  if (basename7(subjectDirectory) === "unbound") {
@@ -6367,16 +6371,36 @@ function nextLegReceiptIndex(runDirectory) {
6367
6371
  }
6368
6372
  return max + 1;
6369
6373
  }
6370
- function statusAndSummaryFromPayload(seat, payload) {
6374
+ function statusAndSummaryFromPayload(payload) {
6371
6375
  if (!isRecord(payload)) return {};
6372
- const toolName = packagedRoleOutputTool(seat);
6373
- const status = toolName !== void 0 && isTerminatingToolName(toolName) ? acceptedFacts(toolName, payload).status : void 0;
6376
+ const received = receiptStatus(payload);
6377
+ const status = typeof received === "string" ? received : void 0;
6374
6378
  const summary = typeof payload.summary === "string" ? payload.summary : void 0;
6375
6379
  return {
6376
6380
  ...status === void 0 ? {} : { status },
6377
6381
  ...summary === void 0 ? {} : { summary }
6378
6382
  };
6379
6383
  }
6384
+ function readAuditedRound(auditedRunDirectory) {
6385
+ try {
6386
+ const subjectDirectory = subjectDirectoryOfRun(auditedRunDirectory);
6387
+ if (subjectDirectory === void 0) return {};
6388
+ const path = join12(subjectDirectory, CURRENT_FILENAME);
6389
+ const { lines, malformed } = decodeProgressFile(path);
6390
+ if (malformed.length > 0) {
6391
+ throw new Error(`${path} has malformed row(s): ${malformed.join("; ")}`);
6392
+ }
6393
+ const receipts = `runs/${basename7(auditedRunDirectory)}/`;
6394
+ const latest = lines.filter((line2) => line2.receipt.startsWith(receipts)).at(-1);
6395
+ return latest === void 0 ? {} : { for: `${latest.seat}#${latest.round}` };
6396
+ } catch (error) {
6397
+ return { fault: `audited round unavailable for ${auditedRunDirectory}: ${errorText(error)}` };
6398
+ }
6399
+ }
6400
+ function forOfSealedRow(runDirectory, seat, payload) {
6401
+ const reported = packagedGateStageLabel(seat) !== void 0 ? readPageSync(runDirectory, "admitted")?.for : seat === "fixer" && isRecord(payload) ? payload.for : void 0;
6402
+ return typeof reported === "string" ? reported : void 0;
6403
+ }
6380
6404
  function captureWorktreeHead(projectRoot) {
6381
6405
  try {
6382
6406
  const result = spawnSync2("git", ["rev-parse", "HEAD"], {
@@ -6454,12 +6478,14 @@ function landTicketProgress(input) {
6454
6478
  const existing = unbound ? readProgressFile(progressPath) : readTicketProgressLines(subjectDirectory);
6455
6479
  const round = unbound ? "" : nextRoundFromLines(existing, input.role, lens);
6456
6480
  const sessionRelative = input.sessionFile === void 0 ? "" : relative3(subjectDirectory, input.sessionFile).split(sep4).join("/");
6457
- const { status, summary } = statusAndSummaryFromPayload(input.role, input.accepted);
6481
+ const { status, summary } = statusAndSummaryFromPayload(input.accepted);
6482
+ const reviewed = forOfSealedRow(runDirectory, input.role, input.accepted);
6458
6483
  const instruction = input.instruction;
6459
6484
  const line2 = {
6460
6485
  at: (/* @__PURE__ */ new Date()).toISOString(),
6461
6486
  seat: input.role,
6462
6487
  round,
6488
+ ...reviewed === void 0 ? {} : { for: reviewed },
6463
6489
  instruction,
6464
6490
  head: input.sealHead.head,
6465
6491
  ...status === void 0 ? {} : { status },
@@ -6524,7 +6550,6 @@ var init_ticket_progress = __esm({
6524
6550
  "use strict";
6525
6551
  init_host_session_record();
6526
6552
  init_host_contracts();
6527
- init_terminating_tools();
6528
6553
  init_packaged_role_registry();
6529
6554
  init_role_run_placement();
6530
6555
  init_run_dossier();
@@ -8368,22 +8393,25 @@ async function mergeInvocationIdentityPage(runDirectory, fields) {
8368
8393
  ...fields
8369
8394
  }));
8370
8395
  }
8371
- async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubject) {
8372
- if (sourceRunPath.trim() === "") {
8373
- throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
8396
+ function persistAdmittedAuditedLeg(runDirectory, audited) {
8397
+ const { sourceRunPath, auditorSubject } = audited;
8398
+ if (sourceRunPath !== void 0 && sourceRunPath.trim() === "") {
8399
+ throw new Error("persistAdmittedAuditedLeg requires a non-empty sourceRunPath");
8374
8400
  }
8375
- updateSectionSync(admitted.runDirectory, "admitted", (current) => {
8376
- if (typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
8401
+ updateSectionSync(runDirectory, "admitted", (current) => {
8402
+ if (sourceRunPath !== void 0 && typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
8377
8403
  throw new Error(
8378
- `persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
8404
+ `persistAdmittedAuditedLeg refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
8379
8405
  );
8380
8406
  }
8381
- const sameSubject = auditorSubject === void 0 || current.auditorSubject === auditorSubject;
8382
- if (current.sourceRunPath === sourceRunPath && sameSubject) return void 0;
8407
+ const unchanged = current.for === audited.for && (sourceRunPath === void 0 || current.sourceRunPath === sourceRunPath) && (auditorSubject === void 0 || current.auditorSubject === auditorSubject);
8408
+ if (unchanged) return void 0;
8409
+ const { for: _replaced, ...rest } = current;
8383
8410
  return {
8384
- ...current,
8385
- sourceRunPath,
8386
- ...auditorSubject === void 0 ? {} : { auditorSubject }
8411
+ ...rest,
8412
+ ...sourceRunPath === void 0 ? {} : { sourceRunPath },
8413
+ ...auditorSubject === void 0 ? {} : { auditorSubject },
8414
+ ...audited.for === void 0 ? {} : { for: audited.for }
8387
8415
  };
8388
8416
  });
8389
8417
  }
@@ -11104,14 +11132,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
11104
11132
  return {
11105
11133
  ...host,
11106
11134
  registerTool(tool) {
11107
- const registeredRole = outputTools.get(tool.name);
11108
- let role;
11109
- if (typeof registeredRole === "string") {
11110
- role = registeredRole;
11111
- } else if (registeredRole !== void 0) {
11112
- const activeRole = host.getFlag("ak-role");
11113
- role = typeof activeRole === "string" && registeredRole.includes(activeRole) ? activeRole : void 0;
11114
- }
11135
+ const role = outputTools.get(tool.name);
11115
11136
  if (role === void 0) return host.registerTool(tool);
11116
11137
  host.registerTool({
11117
11138
  ...tool,
@@ -13813,11 +13834,8 @@ function latestQueueStatus(terminal) {
13813
13834
  if (outcome === void 0) return void 0;
13814
13835
  if (outcome.kind === "audit_escalation") return "escalate";
13815
13836
  if (outcome.kind !== "accepted") return void 0;
13816
- const latest = outcome.payloads?.[outcome.payloads.length - 1];
13817
- if (isRecord(latest) && Object.hasOwn(latest, "status")) {
13818
- return receivedDiscriminator(latest, "status");
13819
- }
13820
- return outcome.status;
13837
+ const received = receiptStatus(outcome.payloads?.[outcome.payloads.length - 1]);
13838
+ return received === void 0 ? outcome.status : received;
13821
13839
  }
13822
13840
  function latestQueuePayload(terminal) {
13823
13841
  const outcome = terminal?.roleOutcome;
@@ -13954,9 +13972,8 @@ var init_submission_gate = __esm({
13954
13972
  init_invocation();
13955
13973
  init_run_lifecycle();
13956
13974
  init_gatekeeper_role();
13957
- init_submission_errors();
13975
+ init_packaged_role_registry();
13958
13976
  init_receipt_delivery_policy();
13959
- init_unknown_value();
13960
13977
  }
13961
13978
  });
13962
13979
 
@@ -15015,7 +15032,7 @@ async function bindDiaristAssertedTicketNumber(admitted) {
15015
15032
  );
15016
15033
  for (const row of rows) {
15017
15034
  if (row.role !== admitted.role || !isRecord(row.accepted)) continue;
15018
- if (row.accepted.status !== "completed" || !("ticketNumber" in row.accepted)) continue;
15035
+ if (receiptStatus(row.accepted) !== "completed" || !("ticketNumber" in row.accepted)) continue;
15019
15036
  const ticketNumber = parseTicketNumber(row.accepted.ticketNumber);
15020
15037
  if (ticketNumber !== void 0) {
15021
15038
  await bindAdmittedTicketNumber(admitted, ticketNumber);
@@ -15886,8 +15903,7 @@ var init_seat_ticket_binding = __esm({
15886
15903
 
15887
15904
  // src/public-cli/countersign-run.ts
15888
15905
  function isEscalatePayload(payload) {
15889
- if (!isRecord(payload)) return false;
15890
- return payload.status === "escalate";
15906
+ return receiptStatus(payload) === "escalate";
15891
15907
  }
15892
15908
  function courtDiaristEscalateDiagnostic(terminal) {
15893
15909
  const payloads = currentReplyRows(terminal);
@@ -15972,7 +15988,7 @@ var init_countersign_run = __esm({
15972
15988
  "use strict";
15973
15989
  init_readable_gate_item();
15974
15990
  init_terminal();
15975
- init_unknown_value();
15991
+ init_packaged_role_registry();
15976
15992
  }
15977
15993
  });
15978
15994
 
@@ -15993,7 +16009,7 @@ function unreadablePostSubmissionStatus(admitted, terminal) {
15993
16009
  const route = POST_SUBMISSION_ROUTING[admitted.role];
15994
16010
  if (route === void 0) return void 0;
15995
16011
  const payload = terminal.roleOutcome.payloads?.at(-1);
15996
- const status = receivedDiscriminator(payload, "status");
16012
+ const status = receiptStatus(payload);
15997
16013
  return typeof status === "string" && route.statuses.has(status) ? void 0 : route.reask ?? officerConclusionReask(status);
15998
16014
  }
15999
16015
  function withUnreadableReask(env) {
@@ -16393,6 +16409,16 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
16393
16409
  else io.stdout(formatTerminalResult(terminal));
16394
16410
  return { exitCode: failed ? 1 : 0, terminal };
16395
16411
  }
16412
+ async function pinAuditedLegAtAdmission(officerRunDirectory, auditedRunDirectory, io, source) {
16413
+ const { for: auditedRound, fault } = readAuditedRound(auditedRunDirectory);
16414
+ persistAdmittedAuditedLeg(officerRunDirectory, { for: auditedRound, ...source });
16415
+ if (fault === void 0) return;
16416
+ await retainPackageFault({
16417
+ runDirectory: officerRunDirectory,
16418
+ diagnostic: fault,
16419
+ stderr: (text) => io.stderr(text)
16420
+ });
16421
+ }
16396
16422
  function resumeSameParentInstructionSeat(input) {
16397
16423
  return tryResumeSameTicketSeatRun({
16398
16424
  home: input.env.home,
@@ -16412,7 +16438,8 @@ function resumeSameParentInstructionSeat(input) {
16412
16438
  ...materials === void 0 ? {} : { summons: materials }
16413
16439
  },
16414
16440
  input.env,
16415
- input.io
16441
+ input.io,
16442
+ input.parentRunPath
16416
16443
  );
16417
16444
  }
16418
16445
  });
@@ -16488,7 +16515,9 @@ async function runCountersignBody(parsed, env, io) {
16488
16515
  );
16489
16516
  await markRunAdmitted(admitted, env.principalAuthority);
16490
16517
  if (gateParentRunPath !== void 0) {
16491
- await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
16518
+ await pinAuditedLegAtAdmission(admitted.runDirectory, gateParentRunPath, io, {
16519
+ sourceRunPath: gateParentRunPath
16520
+ });
16492
16521
  admitted = { ...admitted, sourceRunPath: gateParentRunPath };
16493
16522
  }
16494
16523
  const turnProjection = roleTurnOptions(env, admitted, {
@@ -16697,12 +16726,21 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
16697
16726
  throw error;
16698
16727
  }
16699
16728
  if (instructionSourceRunPath !== void 0) {
16700
- await persistAdmittedSourceRunPath(admitted, instructionSourceRunPath);
16729
+ await pinAuditedLegAtAdmission(admitted.runDirectory, instructionSourceRunPath, io, {
16730
+ sourceRunPath: instructionSourceRunPath
16731
+ });
16701
16732
  admitted = { ...admitted, sourceRunPath: instructionSourceRunPath };
16702
- }
16703
- if (record.sameParent === "subject-source" && auditorSource !== void 0) {
16704
- await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
16733
+ } else if (record.sameParent === "subject-source" && auditorSource !== void 0) {
16734
+ await pinAuditedLegAtAdmission(admitted.runDirectory, auditorSource, io, {
16735
+ sourceRunPath: auditorSource,
16736
+ auditorSubject
16737
+ });
16705
16738
  admitted = { ...admitted, sourceRunPath: auditorSource };
16739
+ } else {
16740
+ const auditedRunDirectory = admittedSourceRunPath(admitted);
16741
+ if (auditedRunDirectory !== void 0) {
16742
+ await pinAuditedLegAtAdmission(admitted.runDirectory, auditedRunDirectory, io);
16743
+ }
16706
16744
  }
16707
16745
  admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
16708
16746
  const runAdmitted = async () => {
@@ -16777,7 +16815,7 @@ async function inheritKnownTicketFromSource(admitted, authority) {
16777
16815
  await relocateAdmittedRunToTicket(admitted, authority);
16778
16816
  return admitted;
16779
16817
  }
16780
- async function runPublicInstructionSeatResume(request, env, io) {
16818
+ async function runPublicInstructionSeatResume(request, env, io, resummonedFor) {
16781
16819
  let selectedRequest = request;
16782
16820
  const resume = async () => {
16783
16821
  const held = [];
@@ -16808,6 +16846,9 @@ async function runPublicInstructionSeatResume(request, env, io) {
16808
16846
  return { ...loaded, admitted };
16809
16847
  },
16810
16848
  buildTurnRequest: async (admitted, effective) => {
16849
+ if (resummonedFor !== void 0) {
16850
+ await pinAuditedLegAtAdmission(admitted.runDirectory, resummonedFor, io);
16851
+ }
16811
16852
  const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
16812
16853
  const projection = resumeTurnRequestProjectionOptions(
16813
16854
  admitted,
@@ -17017,8 +17058,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
17017
17058
  if (admitted === void 0 || !AUDITED_ROLES.has(admitted.role) || turn.terminal?.roleOutcome.kind !== "accepted") return turn;
17018
17059
  const accepted = turn.terminal.roleOutcome.payloads?.at(-1);
17019
17060
  if (accepted === void 0) throw new Error("accepted submission has no payload");
17020
- const record = isRecord(accepted) ? accepted : void 0;
17021
- const status = admitted.role === "secretariat" ? record?.secretariatStatus : record?.status;
17061
+ const status = receiptStatus(accepted);
17022
17062
  const gateOwnsStatusReask = typeof env.parentRunPath === "string" && env.parentRunPath.trim() !== "";
17023
17063
  if (admitted.role === "secretariat" && status !== "converged" && status !== "escalate") {
17024
17064
  if (gateOwnsStatusReask) return turn;
@@ -17302,7 +17342,6 @@ var init_instruction_seat_run = __esm({
17302
17342
  init_role_run_placement();
17303
17343
  init_doctor_auditor();
17304
17344
  init_gatekeeper_role();
17305
- init_submission_errors();
17306
17345
  init_review_submission();
17307
17346
  init_judge_role();
17308
17347
  init_worker_submission_contracts();
@@ -17328,9 +17367,10 @@ var init_instruction_seat_run = __esm({
17328
17367
  init_terminal();
17329
17368
  init_turn_request();
17330
17369
  init_countersign_run();
17370
+ init_ticket_progress();
17331
17371
  init_unknown_value();
17332
17372
  AUDITED_ROLES = /* @__PURE__ */ new Set(["judge", "fixer", "coder", "secretariat", "countersign", "doctor"]);
17333
- SECRETARIAT_STATUS_REASK = "secretariatStatus \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0CsecretariatStatus \u5199\u660E\u5176\u4E00\u3002";
17373
+ SECRETARIAT_STATUS_REASK = "status \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
17334
17374
  WORKER_ROUTING_STATUSES = /* @__PURE__ */ new Set([
17335
17375
  "planned",
17336
17376
  "completed",
@@ -19084,11 +19124,11 @@ function projectTerminal(facts) {
19084
19124
  }
19085
19125
  const status = extractStatus(facts.terminal.body);
19086
19126
  const classCount = readClassCount(facts.terminal.body);
19087
- const receiptStatus = status ?? "unparsed";
19127
+ const receiptStatus2 = status ?? "unparsed";
19088
19128
  if (classCount === void 0) {
19089
- return { kind: "receipt", status: receiptStatus };
19129
+ return { kind: "receipt", status: receiptStatus2 };
19090
19130
  }
19091
- return { kind: "receipt", status: receiptStatus, classCount };
19131
+ return { kind: "receipt", status: receiptStatus2, classCount };
19092
19132
  }
19093
19133
  function projectRunRow(facts) {
19094
19134
  const { startedAt, endedAt } = facts.frameSpan;
@@ -22415,7 +22455,7 @@ function fixerBashSeatbeltDenyReason(matched) {
22415
22455
  }
22416
22456
 
22417
22457
  // src/worker-role.ts
22418
- init_unknown_value();
22458
+ init_packaged_role_registry();
22419
22459
  init_worker_output();
22420
22460
  var FIXER_FLAG_DEFINITIONS = {
22421
22461
  phase: {
@@ -22431,7 +22471,8 @@ function isWorkerPhase(value) {
22431
22471
  return typeof value === "string" && FIXER_PHASES.includes(value);
22432
22472
  }
22433
22473
  function workerStatusOf(output) {
22434
- return isRecord(output) && typeof output.status === "string" ? output.status : void 0;
22474
+ const status = receiptStatus(output);
22475
+ return typeof status === "string" ? status : void 0;
22435
22476
  }
22436
22477
  function deepFreeze2(value) {
22437
22478
  if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
@@ -22847,14 +22888,6 @@ function navigatorPhase(roleHost, role) {
22847
22888
  function navigatorOutputTool(role) {
22848
22889
  return packagedRoleOutputTool(role);
22849
22890
  }
22850
- function receiptStatusFromRegistry(details) {
22851
- for (const entry of PACKAGED_ROLE_REGISTRY) {
22852
- if (!("receiptStatusKey" in entry)) continue;
22853
- const value = details[entry.receiptStatusKey];
22854
- if (typeof value === "string") return value;
22855
- }
22856
- return void 0;
22857
- }
22858
22891
  function publicNavigatorSettlement(role, phase, event) {
22859
22892
  if (event.toolName !== navigatorOutputTool(role)) return void 0;
22860
22893
  const classification = classifyPackagedRoleTerminalResult(event);
@@ -22862,9 +22895,9 @@ function publicNavigatorSettlement(role, phase, event) {
22862
22895
  if (classification.kind === "infrastructure") {
22863
22896
  return { kind: "role_infrastructure_failure", role, phase };
22864
22897
  }
22865
- const details = isRecord(event.details) ? event.details : {};
22866
- const status = typeof details.status === "string" ? details.status : receiptStatusFromRegistry(details);
22867
- if (status !== void 0 && status === "escalate") {
22898
+ const received = receiptStatus(event.details);
22899
+ const status = typeof received === "string" ? received : void 0;
22900
+ if (status === "escalate") {
22868
22901
  return { kind: "human_decision", role, phase, status };
22869
22902
  }
22870
22903
  return { kind: "accepted", role, phase, ...status === void 0 ? {} : { status } };
@@ -23040,8 +23073,7 @@ function createDiaristRoleRuntime(roleHost, dependencies, hostActions) {
23040
23073
  soulTag: "diarist",
23041
23074
  beforeAccept: async ({ toolCallId, parameters, ctx }) => {
23042
23075
  const submitted = isRecord(parameters) ? parameters : void 0;
23043
- const status = submitted?.status;
23044
- if (status !== "completed") return parameters;
23076
+ if (receiptStatus(parameters) !== "completed") return parameters;
23045
23077
  const assertion = readDiaristTicketAssertion(submitted);
23046
23078
  const ticketNumber = assertion.kind === "ticket" ? assertion.ticketNumber : void 0;
23047
23079
  try {
@@ -23130,15 +23162,15 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
23130
23162
  };
23131
23163
  const roleHost = createSubmissionLedgerHost(
23132
23164
  envelopeHost.host,
23133
- new Map(PACKAGED_ROLE_REGISTRY.reduce((entries, { role, outputTool }) => {
23134
- const existingIndex = entries.findIndex(([name]) => name === outputTool);
23135
- if (existingIndex < 0) entries.push([outputTool, role]);
23136
- else {
23137
- const previous = entries[existingIndex][1];
23138
- entries[existingIndex] = [outputTool, [...Array.isArray(previous) ? previous : [previous], role]];
23165
+ {
23166
+ get(toolName) {
23167
+ const seat = receiptSeat(toolName, () => {
23168
+ const active = envelopeHost.host.getFlag(ROLE_FLAG.name);
23169
+ return typeof active === "string" ? active : void 0;
23170
+ })?.seat;
23171
+ return seat === void 0 ? void 0 : packagedRoleMetadata(seat)?.role;
23139
23172
  }
23140
- return entries;
23141
- }, [])),
23173
+ },
23142
23174
  (error, ctx, toolCallId) => hostActions.failInfrastructure(error, ctx, toolCallId),
23143
23175
  async (closed, context, toolCallId) => projectClosedSubmission(closed, context, toolCallId)
23144
23176
  );