@akagilnc/pi-workflow-roles 0.1.5068 → 0.1.5096

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 (80) hide show
  1. package/dist/acp-host/production-host.js +429 -383
  2. package/dist/atomic-write.js +13 -19
  3. package/dist/auditor-soul.js +2 -1
  4. package/dist/compliance-transport.js +3 -2
  5. package/dist/countersign-contracts.js +2 -2
  6. package/dist/doctor-contracts.js +1 -1
  7. package/dist/gatekeeper-role.js +14 -35
  8. package/dist/headless-host/production-host.js +461 -415
  9. package/dist/inspector-contracts.js +5 -2
  10. package/dist/merger-contracts.js +1 -1
  11. package/dist/migrate-book-topology.js +49 -33
  12. package/dist/navigator-attendance.js +28 -143
  13. package/dist/navigator-invocation-identity.js +2 -0
  14. package/dist/navigator-public-session.js +13 -1
  15. package/dist/navigator-work-base.js +113 -0
  16. package/dist/notary-contracts.js +0 -2
  17. package/dist/open-tool-schema.js +4 -1
  18. package/dist/package-contracts/fixer-output.js +1 -1
  19. package/dist/package-contracts/gatekeeper-output.js +1 -1
  20. package/dist/package-contracts/judge-output.js +2 -2
  21. package/dist/package-contracts/navigator-output.js +1 -1
  22. package/dist/package-contracts/terminating-infrastructure.js +7 -4
  23. package/dist/packaged-role-registry.js +9 -5
  24. package/dist/public-cli/countersign-run.js +1 -1
  25. package/dist/public-cli/invocation.js +6 -3
  26. package/dist/public-cli/main.js +78 -41
  27. package/dist/public-cli/settlement.js +20 -1
  28. package/dist/receipt-delivery-policy.js +9 -2
  29. package/dist/review-submission.js +19 -8
  30. package/dist/submission-errors.js +17 -0
  31. package/dist/submission-ledger.js +18 -6
  32. package/docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md +9 -0
  33. package/extensions/role-runtime.ts +0 -27
  34. package/package.json +2 -1
  35. package/resources/836-deleted-machine-instruction-inventory.md +3 -3
  36. package/resources/collector-bot-handbook.md +4 -0
  37. package/resources/navigator-route-playbook.md +4 -6
  38. package/scripts/build-package.mjs +4 -0
  39. package/souls/coder-output-guide.md +1 -0
  40. package/src/auditor-soul.ts +2 -1
  41. package/src/collector-role.ts +6 -7
  42. package/src/collector-tool-schemas.ts +5 -5
  43. package/src/compliance-transport.ts +3 -2
  44. package/src/countersign-contracts.ts +2 -2
  45. package/src/countersign-role.ts +3 -7
  46. package/src/diarist-role.ts +2 -2
  47. package/src/doctor-contracts.ts +1 -1
  48. package/src/gatekeeper-role.ts +15 -36
  49. package/src/gleaner-left-role.ts +2 -2
  50. package/src/inspector-contracts.ts +5 -2
  51. package/src/inspector-role.ts +1 -1
  52. package/src/judge-role.ts +14 -22
  53. package/src/merger-contracts.ts +1 -1
  54. package/src/navigator-attendance.ts +38 -164
  55. package/src/navigator-invocation-identity.ts +2 -0
  56. package/src/navigator-public-session.ts +17 -1
  57. package/src/navigator-role.ts +4 -0
  58. package/src/navigator-session-contracts.ts +2 -0
  59. package/src/navigator-work-base.ts +123 -0
  60. package/src/notary-contracts.ts +0 -4
  61. package/src/open-tool-schema.ts +9 -4
  62. package/src/package-contracts/fixer-output.ts +1 -1
  63. package/src/package-contracts/gatekeeper-output.ts +3 -3
  64. package/src/package-contracts/judge-output.ts +2 -4
  65. package/src/package-contracts/navigator-output.ts +1 -1
  66. package/src/package-contracts/terminating-infrastructure.ts +12 -10
  67. package/src/packaged-role-registry.ts +5 -1
  68. package/src/public-cli/countersign-run.ts +1 -1
  69. package/src/public-cli/invocation.ts +6 -3
  70. package/src/public-cli/settlement.ts +21 -0
  71. package/src/receipt-delivery-policy.ts +9 -1
  72. package/src/review-submission.ts +24 -10
  73. package/src/reviewer-role.ts +3 -3
  74. package/src/role-runtime-dependencies.ts +1 -5
  75. package/src/role-runtime.ts +61 -63
  76. package/src/secretariat-role.ts +3 -3
  77. package/src/submission-errors.ts +16 -0
  78. package/src/submission-gate.ts +2 -1
  79. package/src/submission-ledger.ts +23 -11
  80. package/src/worker-role.ts +7 -9
@@ -417,7 +417,7 @@ function normalizeReviewComment(raw) {
417
417
  function createGhApiRunner(options = {}) {
418
418
  const spawnImpl = options.spawnImpl ?? spawn;
419
419
  return async (args, runOptions = {}) => {
420
- return await new Promise((resolve21, reject) => {
420
+ return await new Promise((resolve22, reject) => {
421
421
  const signal = runOptions.signal;
422
422
  if (signal?.aborted) {
423
423
  reject(signal.reason ?? new Error("aborted"));
@@ -490,11 +490,11 @@ function createGhApiRunner(options = {}) {
490
490
  const value = line2.slice(idx + 1).trim();
491
491
  headers[name] = value;
492
492
  }
493
- resolve21({ status, headers, bodyText });
493
+ resolve22({ status, headers, bodyText });
494
494
  return;
495
495
  }
496
496
  if (code === 0) {
497
- resolve21({ status: 200, headers: {}, bodyText: stdout });
497
+ resolve22({ status: 200, headers: {}, bodyText: stdout });
498
498
  return;
499
499
  }
500
500
  const failure2 = new Error(
@@ -1179,12 +1179,12 @@ function createSystemCollectorClock() {
1179
1179
  return {
1180
1180
  wallNow: () => /* @__PURE__ */ new Date(),
1181
1181
  monoNow: () => Number(process.hrtime.bigint() - start) / 1e6,
1182
- sleep: (ms, signal) => new Promise((resolve21, reject) => {
1182
+ sleep: (ms, signal) => new Promise((resolve22, reject) => {
1183
1183
  if (signal?.aborted) {
1184
1184
  reject(signal.reason ?? new Error("aborted"));
1185
1185
  return;
1186
1186
  }
1187
- const timer = setTimeout(resolve21, ms);
1187
+ const timer = setTimeout(resolve22, ms);
1188
1188
  const onAbort = () => {
1189
1189
  clearTimeout(timer);
1190
1190
  reject(signal?.reason ?? new Error("aborted"));
@@ -1499,6 +1499,15 @@ ${serializeReceipt(result.submission)}`;
1499
1499
  }
1500
1500
  return `\u95E8\u4E0B\u7701 ${result.status}\uFF08${result.stage}\uFF09\uFF1A${result.reason}`;
1501
1501
  }
1502
+ function unreadableDiscriminatorNotice(field, received) {
1503
+ if (received === void 0) return `\u8BFB\u4E0D\u51FA ${field}`;
1504
+ return `\u8BFB\u4E0D\u51FA ${field}\uFF1A${readableGateItem(received)}`;
1505
+ }
1506
+ function receivedDiscriminator(receipt, field) {
1507
+ if (receipt === null || typeof receipt !== "object" || Array.isArray(receipt)) return void 0;
1508
+ if (!Object.hasOwn(receipt, field)) return void 0;
1509
+ return receipt[field];
1510
+ }
1502
1511
  var GatekeeperDecisionError, WorkerCommitReminderError, WorkerPrefixReminderError, WorkerUnfinishedReasonReminderError, ParentQueueReaskError;
1503
1512
  var init_submission_errors = __esm({
1504
1513
  "src/submission-errors.ts"() {
@@ -2475,7 +2484,10 @@ function openToolObjectFromUnion(schema) {
2475
2484
  }
2476
2485
  function openToolObject(schema) {
2477
2486
  const object = Type2.Object(
2478
- Object.fromEntries(Object.entries(schema.properties).map(([name, declaration]) => [name, Type2.Optional(described(name, declaration))])),
2487
+ Object.fromEntries(Object.entries(schema.properties).map(([name, declaration]) => [
2488
+ name,
2489
+ Type2.Optional(described(name, declaration))
2490
+ ])),
2479
2491
  { additionalProperties: true }
2480
2492
  );
2481
2493
  object.required = [];
@@ -2495,13 +2507,15 @@ function withTerminatingOutputDeclarations(schema) {
2495
2507
  ...baseProperties ?? {},
2496
2508
  ...baseProperties?.ticketNumber === void 0 ? {
2497
2509
  ticketNumber: Type3.Unknown({
2498
- description: "\u53EF\u9009\u672C\u7968\u53F7\uFF1A\u5C1A\u672A\u7ED1\u5B9A\u65F6\u7531\u89D2\u8272\u5728\u65E2\u6709\u56DE\u6267\u4E2D\u7533\u62A5\uFF1B\u673A\u68B0\u5C42\u53EA\u8BB0\u5F55\u5408\u6CD5\u6B63\u6574\u6570\uFF0C\u4E0D\u4ECE\u6563\u6587\u63A8\u5BFC\u3001\u4E0D\u9A8C\u771F\u3002\u7F3A\u5931\u6216\u9519\u5F62\u4E0D\u62D2\u6536\u3002"
2510
+ description: "\u53EF\u9009\u672C\u7968\u53F7\u3002\u5C1A\u672A\u7ED1\u5B9A\u65F6\u7531\u89D2\u8272\u5728\u65E2\u6709\u56DE\u6267\u4E2D\u7533\u62A5\u3002"
2499
2511
  })
2500
2512
  } : {},
2501
2513
  [INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: infrastructureFailureDeclarationSchema.properties[INFRASTRUCTURE_FAILURE_DECLARATION_KEY]
2502
2514
  };
2503
2515
  const object = Type3.Object(properties, { additionalProperties: true });
2504
- object.required = [];
2516
+ const incoming = schema.required;
2517
+ const preserved = Array.isArray(incoming) ? incoming.filter((key) => typeof key === "string" && Object.hasOwn(properties, key)) : [];
2518
+ object.required = preserved;
2505
2519
  return object;
2506
2520
  }
2507
2521
  function isInfrastructureFailureDeclaration(parameters) {
@@ -2550,12 +2564,12 @@ var init_terminating_infrastructure = __esm({
2550
2564
  infrastructureFailureNested = Type3.Object(
2551
2565
  {
2552
2566
  [INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY]: Type3.Unknown({
2553
- description: "\u975E\u7A7A\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u8BCA\u65AD\u5B57\u7B26\u4E32\u3002\u65E0\u5931\u8D25\u65F6\u5FC5\u987B\u7701\u7565\u6574\u4E2A infrastructureFailure\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
2567
+ description: "\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u8BCA\u65AD\u5B57\u7B26\u4E32\u3002"
2554
2568
  })
2555
2569
  },
2556
2570
  {
2557
2571
  additionalProperties: true,
2558
- description: "\u57FA\u7840\u8BBE\u65BD\u771F\u5B9E\u5931\u8D25\u58F0\u660E\uFF08\u5982\u9700\uFF09\u3002\u89C4\u8303\u5F62\uFF1A{ diagnostic: \u975E\u7A7A\u8BCA\u65AD\u5B57\u7B26\u4E32 }\uFF1B\u65E0\u5931\u8D25\u65F6\u5FC5\u987B\u7701\u7565\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
2572
+ description: "\u4EC5\u57FA\u7840\u8BBE\u65BD\u771F\u5B9E\u5931\u8D25\u65F6\u51FA\u73B0\u3002"
2559
2573
  }
2560
2574
  );
2561
2575
  infrastructureFailureNested.required = [];
@@ -2580,7 +2594,7 @@ var init_gatekeeper_output = __esm({
2580
2594
  gatekeeperDecisionSchema = openToolObject(
2581
2595
  Type4.Object({
2582
2596
  status: Type4.Unknown({
2583
- description: "dispatch | pass \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
2597
+ description: "dispatch | pass"
2584
2598
  }),
2585
2599
  officer: Type4.Unknown({
2586
2600
  description: "status \u4E3A dispatch \u65F6\u4E3A inspector | notary"
@@ -2649,7 +2663,7 @@ var init_navigator_output = __esm({
2649
2663
  openToolObject(
2650
2664
  Type5.Object({
2651
2665
  prose: Type5.Unknown({
2652
- description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7B49\u7ED3\u6784\u5316\u5B57\u6BB5\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
2666
+ description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7B49\u7ED3\u6784\u5316\u5B57\u6BB5\u3002"
2653
2667
  })
2654
2668
  })
2655
2669
  )
@@ -2659,51 +2673,41 @@ var init_navigator_output = __esm({
2659
2673
 
2660
2674
  // src/review-submission.ts
2661
2675
  import { Type as Type6 } from "typebox";
2662
- var REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, reviewSubmissionSchema;
2676
+ var REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, REVIEW_QUEUE_WORDS, REVIEW_QUEUE_STATUSES, reviewSubmissionSchema;
2663
2677
  var init_review_submission = __esm({
2664
2678
  "src/review-submission.ts"() {
2665
2679
  "use strict";
2666
- init_open_tool_schema();
2667
2680
  init_terminating_infrastructure();
2668
2681
  REVIEW_SUBMISSION_OUTPUT_TOOL_NAME = "ak_submission_output";
2682
+ REVIEW_QUEUE_WORDS = ["converged", "continue", "escalate"];
2683
+ REVIEW_QUEUE_STATUSES = new Set(REVIEW_QUEUE_WORDS);
2669
2684
  reviewSubmissionSchema = withTerminatingOutputDeclarations(
2670
- openToolObject(
2671
- Type6.Object({
2672
- status: Type6.Optional(Type6.Unknown({
2673
- description: "converged | continue | escalate \u2014 \u975E\u4E09\u6001\u65F6\u8BF7\u91CD\u8BFB\u540E\u91CD\u4EA4\uFF0C\u52FF\u6539\u6807\u3002"
2674
- })),
2675
- findings: Type6.Optional(Type6.Unknown({ description: "\u5BA1\u6838\u53D1\u73B0\uFF0C\u539F\u6837\u7559\u5B58" })),
2676
- reason: Type6.Optional(Type6.Unknown({ description: "\u4E0A\u5448\u7406\u7531" })),
2677
- violations: Type6.Optional(Type6.Unknown({ description: "\u8FDD\u89C4\u6761\u76EE" })),
2678
- conflicts: Type6.Optional(Type6.Unknown({ description: "\u5F85\u51B3\u51B2\u7A81" })),
2679
- fix: Type6.Optional(Type6.Unknown({ description: "continue \u65F6\u7684\u8865\u6551\u8BF4\u660E\uFF1B\u53EF\u5199 summary \u6458\u8981\uFF0C\u5176\u4F59\u5185\u5BB9\u539F\u6837\u7559\u5B58" })),
2680
- classes: Type6.Optional(Type6.Unknown({ description: "\u5DF2\u88C1\u51B3 finding \u7C7B\uFF1B\u53EF\u8BF4\u660E name\u3001owner\u3001boundary\u3001disposition\uFF0C\u539F\u6837\u7559\u5B58" })),
2681
- note: Type6.Optional(Type6.Unknown({ description: "\u88C1\u51B3\u9644\u6CE8" })),
2682
- evidence: Type6.Optional(Type6.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
2683
- decisionGate: Type6.Optional(Type6.Unknown({ description: "\u9700\u4EBA\u6743\u5A01\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879\uFF1B\u53EF\u8BF4\u660E question\u3001options\uFF0C\u539F\u6837\u7559\u5B58" }))
2684
- })
2685
- )
2685
+ Type6.Object({
2686
+ status: Type6.Union(
2687
+ [
2688
+ Type6.Literal(REVIEW_QUEUE_WORDS[0]),
2689
+ Type6.Literal(REVIEW_QUEUE_WORDS[1]),
2690
+ Type6.Literal(REVIEW_QUEUE_WORDS[2])
2691
+ ],
2692
+ {
2693
+ description: "\u5BA1\u6838\u5E2D\u672C\u8F6E\u88C1\u51B3\u7684\u5224\u522B\u72B6\u6001\u3002"
2694
+ }
2695
+ ),
2696
+ findings: Type6.Optional(Type6.Unknown({ description: "\u5BA1\u6838\u53D1\u73B0\uFF0C\u539F\u6837\u7559\u5B58" })),
2697
+ reason: Type6.Optional(Type6.Unknown({ description: "\u4E0A\u5448\u7406\u7531" })),
2698
+ violations: Type6.Optional(Type6.Unknown({ description: "\u8FDD\u89C4\u6761\u76EE" })),
2699
+ conflicts: Type6.Optional(Type6.Unknown({ description: "\u5F85\u51B3\u51B2\u7A81" })),
2700
+ fix: Type6.Optional(Type6.Unknown({ description: "continue \u65F6\u7684\u8865\u6551\u8BF4\u660E\uFF1B\u53EF\u5199 summary \u6458\u8981\uFF0C\u5176\u4F59\u5185\u5BB9\u539F\u6837\u7559\u5B58" })),
2701
+ classes: Type6.Optional(Type6.Unknown({ description: "\u5DF2\u88C1\u51B3 finding \u7C7B\uFF1B\u53EF\u8BF4\u660E name\u3001owner\u3001boundary\u3001disposition\uFF0C\u539F\u6837\u7559\u5B58" })),
2702
+ note: Type6.Optional(Type6.Unknown({ description: "\u88C1\u51B3\u9644\u6CE8" })),
2703
+ evidence: Type6.Optional(Type6.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
2704
+ decisionGate: Type6.Optional(Type6.Unknown({ description: "\u9700\u4EBA\u6743\u5A01\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879\uFF1B\u53EF\u8BF4\u660E question\u3001options\uFF0C\u539F\u6837\u7559\u5B58" }))
2705
+ }, { additionalProperties: true })
2686
2706
  );
2687
2707
  }
2688
2708
  });
2689
2709
 
2690
2710
  // src/package-contracts/judge-output.ts
2691
- function validateAcceptedJudgeDetails(verdict) {
2692
- if (verdict === null || typeof verdict !== "object" || Array.isArray(verdict)) throw new Error("Judge verdict has no execution discriminator");
2693
- let status;
2694
- try {
2695
- status = verdict.status;
2696
- } catch {
2697
- throw new Error("Judge verdict has no execution discriminator");
2698
- }
2699
- if (typeof status !== "string") {
2700
- throw new Error("Judge verdict has no execution discriminator");
2701
- }
2702
- if (["converged", "continue", "escalate"].includes(status)) {
2703
- return verdict;
2704
- }
2705
- throw new Error("Judge verdict has no execution discriminator");
2706
- }
2707
2711
  var JUDGE_OUTPUT_TOOL_NAME;
2708
2712
  var init_judge_output = __esm({
2709
2713
  "src/package-contracts/judge-output.ts"() {
@@ -2759,7 +2763,7 @@ var init_fixer_output = __esm({
2759
2763
  });
2760
2764
  classResultSchema = Type7.Union([completedClassResultSchema, refusedClassResultSchema]);
2761
2765
  completedClassResultsSchema = Type7.Array(completedClassResultSchema);
2762
- FIXER_STATUS_DESCRIPTION = "planned | completed | refused | unfinished | partially_completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1Bunfinished \u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\uFF0C\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002";
2766
+ FIXER_STATUS_DESCRIPTION = "planned | completed | refused | unfinished | partially_completed\u3002unfinished \u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\uFF0C\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002";
2763
2767
  fixerOutputVariants = Type7.Union([
2764
2768
  Type7.Object({ status: Type7.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type7.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }),
2765
2769
  Type7.Object({ status: Type7.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type7.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type7.String({ description: "\u4F9D\u6CD5\u4E0D\u80FD\u5B8C\u6210\u7684\u5DE5\u4F5C\u8303\u56F4" }), blocker: Type7.Unsafe({ ...blockerSchema, description: "\u5408\u6CD5\u963B\u65AD\u5B8C\u6210\u7684 blocker" }) }),
@@ -2919,7 +2923,7 @@ var init_doctor_contracts = __esm({
2919
2923
  Type9.Object({ targetKey: nonblank, targetKind: Type9.Optional(Type9.Union(assetKinds.map((kind) => Type9.Literal(kind)))), assetEvidence: Type9.Optional(Type9.Object({ targetKey: nonblank, targetKind: Type9.Optional(Type9.Union(assetKinds.map((kind) => Type9.Literal(kind)))), evidenceId: nonblank }, { additionalProperties: true })), ...findingBody }, { additionalProperties: true })
2920
2924
  ]);
2921
2925
  caseIdentity = Type9.Object({ issueNumber: Type9.Optional(Type9.Integer()), runsPath: nonblank }, { additionalProperties: true });
2922
- DOCTOR_STATUS_DESCRIPTION = "completed | refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1Bcompleted \u5141\u8BB8\u7A7A findings\uFF1Brefused \u4EC5\u5F53\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u6848\u8BC1\u8BCD";
2926
+ DOCTOR_STATUS_DESCRIPTION = "completed | refused\u3002completed \u5141\u8BB8\u7A7A findings\uFF1Brefused \u4EC5\u5F53\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u6848\u8BC1\u8BCD";
2923
2927
  doctorSubmissionVariants = Type9.Union([
2924
2928
  Type9.Object({
2925
2929
  status: Type9.Unknown({ description: DOCTOR_STATUS_DESCRIPTION }),
@@ -3045,7 +3049,7 @@ var init_merger_contracts = __esm({
3045
3049
  resolutionScope: Type10.Array(Type10.String(), { description: "\u6750\u6599\uFF1A\u89E3\u6790\u8303\u56F4\u63D0\u793A\uFF1B\u53EF\u7A7A" }),
3046
3050
  authorizedChecks: Type10.Array(checkSchema)
3047
3051
  }, { additionalProperties: false });
3048
- MERGER_STATUS_DESCRIPTION = "completed | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8";
3052
+ MERGER_STATUS_DESCRIPTION = "completed | escalate";
3049
3053
  mergerOutputVariants = Type10.Union([
3050
3054
  Type10.Object({ status: Type10.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: Type10.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), report: Type10.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), mergeCommitId: Type10.String({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }) }, { additionalProperties: false }),
3051
3055
  Type10.Object({ status: Type10.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: Type10.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), diagnosis: Type10.String({ description: "\u5408\u5E76\u65E0\u6CD5\u6216\u4E0D\u5E94\u7531\u672C\u5E2D\u5B8C\u6210\u7684\u539F\u56E0\uFF08\u542B\u65E0\u8FDB\u884C\u4E2D\u5408\u5E76\u3001\u65E0\u6D3B\u53EF\u5E72\u3001\u9700\u65B0\u7684\u4EA7\u54C1/\u6743\u529B\u51B3\u5B9A\uFF09" }), report: Type10.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }, { additionalProperties: false })
@@ -3066,7 +3070,7 @@ var init_merger_contracts = __esm({
3066
3070
  });
3067
3071
 
3068
3072
  // src/notary-contracts.ts
3069
- var NOTARY_OUTPUT_TOOL_NAME, NOTARY_SOURCE_RUN_FLAG, NOTARY_TICKET_FLAG, NOTARY_FIXED_KICKOFF, notaryOutputSchema;
3073
+ var NOTARY_OUTPUT_TOOL_NAME, NOTARY_SOURCE_RUN_FLAG, NOTARY_TICKET_FLAG, notaryOutputSchema;
3070
3074
  var init_notary_contracts = __esm({
3071
3075
  "src/notary-contracts.ts"() {
3072
3076
  "use strict";
@@ -3086,7 +3090,6 @@ var init_notary_contracts = __esm({
3086
3090
  type: "string"
3087
3091
  }
3088
3092
  };
3089
- NOTARY_FIXED_KICKOFF = "\u7B26\u5B9D\u90CE\u6848\u5377\u5DF2\u53D7\u7406\uFF1B\u6765\u6E90 run \u5B9A\u4F4D\u89C1\u4F1A\u8BDD\u6750\u6599\u3002";
3090
3093
  notaryOutputSchema = reviewSubmissionSchema;
3091
3094
  }
3092
3095
  });
@@ -3583,21 +3586,24 @@ var init_packaged_role_registry = __esm({
3583
3586
  "souls/notary.md",
3584
3587
  "souls/audit-law.md",
3585
3588
  "souls/ticket-law.md",
3586
- "souls/gate-output-guide.md"
3589
+ "souls/gate-output-guide.md",
3590
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
3587
3591
  ];
3588
3592
  INSPECTOR_SESSION_MATERIALS = [
3589
3593
  "CLAUDE.md",
3590
3594
  "souls/inspector.md",
3591
3595
  "souls/audit-law.md",
3592
3596
  "souls/quality-law.md",
3593
- "souls/gate-output-guide.md"
3597
+ "souls/gate-output-guide.md",
3598
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
3594
3599
  ];
3595
3600
  AUDITOR_PUBLIC_SESSION_MATERIALS = [
3596
3601
  "CLAUDE.md",
3597
3602
  "souls/judge-auditor.md",
3598
3603
  "souls/doctor-auditor.md",
3599
3604
  "souls/audit-law.md",
3600
- "souls/quality-law.md"
3605
+ "souls/quality-law.md",
3606
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
3601
3607
  ];
3602
3608
  PUBLIC_ROLE_RECORDS = [
3603
3609
  {
@@ -3625,7 +3631,8 @@ var init_packaged_role_registry = __esm({
3625
3631
  "souls/judge.md",
3626
3632
  "souls/audit-law.md",
3627
3633
  "souls/quality-law.md",
3628
- "souls/judge-output-guide.md"
3634
+ "souls/judge-output-guide.md",
3635
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
3629
3636
  ]
3630
3637
  },
3631
3638
  {
@@ -3903,7 +3910,7 @@ var init_packaged_role_registry = __esm({
3903
3910
  activationStage: "load-and-install",
3904
3911
  receiptStatusKey: "status",
3905
3912
  // #924: 公用《票面法》三席同装
3906
- sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md", "resources/countersign-ticket-issue.md"]
3913
+ sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md", "resources/countersign-ticket-issue.md", "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"]
3907
3914
  },
3908
3915
  {
3909
3916
  role: "secretariat",
@@ -4269,10 +4276,7 @@ function readRecord(value) {
4269
4276
  return value;
4270
4277
  }
4271
4278
  function reviewQueueStatus(status) {
4272
- if (status === "converged") return "converged";
4273
- if (status === "continue") return "continue";
4274
- if (status === "escalate") return "escalate";
4275
- return void 0;
4279
+ return REVIEW_QUEUE_STATUSES.has(status) ? status : void 0;
4276
4280
  }
4277
4281
  function projectOfficerDecision(officer, decision, fallbackStatus) {
4278
4282
  const receipt = retainedReceipt(decision);
@@ -4285,7 +4289,7 @@ function projectOfficerDecision(officer, decision, fallbackStatus) {
4285
4289
  if (queueStatus === "continue" || queueStatus === "escalate") {
4286
4290
  return { status: queueStatus, officer, receipt };
4287
4291
  }
4288
- return { status: "needs_reask", officer, receipt };
4292
+ return { status: "needs_reask", officer, receipt, receivedStatus: status };
4289
4293
  }
4290
4294
  function thisCourtOfficerPayloads(terminal) {
4291
4295
  const outcome = terminal?.roleOutcome;
@@ -4371,18 +4375,20 @@ function projectOfficerTerminal(officer, summoned) {
4371
4375
  summoned
4372
4376
  );
4373
4377
  }
4378
+ const receipt = thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome);
4374
4379
  return withOfficerRunId(
4375
4380
  {
4376
4381
  status: "needs_reask",
4377
4382
  officer,
4378
4383
  // This-court receipt only (#879).
4379
- receipt: thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome)
4384
+ receipt,
4385
+ receivedStatus: receivedDiscriminator(receipt, "status")
4380
4386
  },
4381
4387
  summoned
4382
4388
  );
4383
4389
  }
4384
- function officerConclusionReask(officer) {
4385
- return OFFICER_CONCLUSION_REASK;
4390
+ function officerConclusionReask(received) {
4391
+ return unreadableDiscriminatorNotice("status", received);
4386
4392
  }
4387
4393
  async function projectGatekeeperRun(options) {
4388
4394
  const officer = gateOfficerForSubject(options.subject);
@@ -4418,7 +4424,7 @@ async function projectGatekeeperRun(options) {
4418
4424
  summoned
4419
4425
  };
4420
4426
  }
4421
- var GATE_OFFICER_BY_SUBJECT, GATEKEEPER_TOOL_SPEC, OFFICER_CONCLUSION_REASK;
4427
+ var GATE_OFFICER_BY_SUBJECT, GATEKEEPER_TOOL_SPEC;
4422
4428
  var init_gatekeeper_role = __esm({
4423
4429
  "src/gatekeeper-role.ts"() {
4424
4430
  "use strict";
@@ -4440,11 +4446,10 @@ var init_gatekeeper_role = __esm({
4440
4446
  GATEKEEPER_TOOL_SPEC = {
4441
4447
  name: GATEKEEPER_OUTPUT_TOOL_NAME,
4442
4448
  label: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
4443
- description: "\u95E8\u4E0B\u7701\u7EC8\u5C40\u51B3\u8BAE\uFF0C\u72B6\u6001\u4E3A dispatch \u6216 pass\u3002",
4449
+ description: "\u95E8\u4E0B\u7701\u7EC8\u5C40\u51B3\u8BAE\u3002status \u4E3A dispatch \u6216 pass\u3002",
4444
4450
  promptSnippet: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
4445
4451
  parameters: gatekeeperOutputSchema
4446
4452
  };
4447
- OFFICER_CONCLUSION_REASK = "\u4E0A\u6B21\u4EA4\u5377\u7684 status \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u8F93\u51FA\uFF0Cstatus \u5199\u660E\u5176\u4E00\uFF1Bcontinue \u6216 escalate \u7684\u8BDD\u5C31\u662F\u7ED9\u5BF9\u65B9\u770B\u7684\u539F\u6587\u3002";
4448
4453
  }
4449
4454
  });
4450
4455
 
@@ -4565,10 +4570,10 @@ __export(session_assistant_usage_exports, {
4565
4570
  });
4566
4571
  import { join as join6 } from "node:path";
4567
4572
  async function readAssistantUsageFromSessionFile(sessionFile) {
4568
- const { readFile: readFile25 } = await import("node:fs/promises");
4573
+ const { readFile: readFile26 } = await import("node:fs/promises");
4569
4574
  let text;
4570
4575
  try {
4571
- text = await readFile25(sessionFile, "utf8");
4576
+ text = await readFile26(sessionFile, "utf8");
4572
4577
  } catch (error) {
4573
4578
  if (error?.code === "ENOENT") return void 0;
4574
4579
  throw error;
@@ -4967,7 +4972,7 @@ async function spawnEngineDetourOnce(input) {
4967
4972
  }
4968
4973
  const command = input.argv[0];
4969
4974
  const args = input.argv.slice(1);
4970
- return await new Promise((resolve21, reject) => {
4975
+ return await new Promise((resolve22, reject) => {
4971
4976
  let settled = false;
4972
4977
  const signal = input.signal;
4973
4978
  const child = spawn2(command, args, {
@@ -4997,7 +5002,7 @@ async function spawnEngineDetourOnce(input) {
4997
5002
  if (signal !== void 0) {
4998
5003
  signal.removeEventListener("abort", onAbort);
4999
5004
  }
5000
- resolve21(result);
5005
+ resolve22(result);
5001
5006
  };
5002
5007
  const onAbort = () => {
5003
5008
  fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
@@ -11257,13 +11262,16 @@ function admittedTransportPromptKind(admitted) {
11257
11262
  function buildInstructionTransportPrompt(admitted, engineMaterial) {
11258
11263
  const kind = admittedTransportPromptKind(admitted);
11259
11264
  if (kind === "fixed-kickoff") {
11260
- return appendEngineSessionMaterial([NOTARY_FIXED_KICKOFF], engineMaterial).join("\n");
11265
+ if (admitted.sourceRunPath === void 0 || admitted.sourceRunPath.trim() === "") {
11266
+ throw new Error("fixed-kickoff transport prompt is missing the source run pointer");
11267
+ }
11268
+ return appendEngineSessionMaterial([admitted.sourceRunPath], engineMaterial).join("\n");
11261
11269
  }
11262
11270
  if (kind === "baseline") {
11263
11271
  if (admitted.baseRevision === void 0) {
11264
11272
  throw new Error("baseline transport prompt is missing the bound revision");
11265
11273
  }
11266
- const lines2 = [`\u5DE6\u62FE\u9057\u6848\u5DF2\u53D7\u7406\u3002\u6BD4\u8F83\u57FA\u7EBF\uFF1A${admitted.baseRevision}`];
11274
+ const lines2 = [admitted.baseRevision];
11267
11275
  if (!admitted.instructionEmpty) {
11268
11276
  lines2.push("", admitted.instruction);
11269
11277
  }
@@ -12844,10 +12852,10 @@ function pairGateRounds(volumes) {
12844
12852
  return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
12845
12853
  }
12846
12854
  async function resolveOfficerSessionFromPointerFile(pointerPath) {
12847
- const { readFile: readFile25 } = await import("node:fs/promises");
12855
+ const { readFile: readFile26 } = await import("node:fs/promises");
12848
12856
  let raw;
12849
12857
  try {
12850
- raw = JSON.parse(await readFile25(pointerPath, "utf8"));
12858
+ raw = JSON.parse(await readFile26(pointerPath, "utf8"));
12851
12859
  } catch (error) {
12852
12860
  throw new Error(
12853
12861
  `direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
@@ -13381,17 +13389,20 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
13381
13389
  });
13382
13390
  let result;
13383
13391
  try {
13384
- failOnInfrastructureFailureDeclaration(
13385
- params,
13386
- {
13387
- failInfrastructure(error, ctx) {
13388
- failInfrastructure2(error, ctx);
13389
- }
13390
- },
13391
- context,
13392
- toolCallId,
13393
- tool.bounceInfrastructureDeclaration
13394
- );
13392
+ const reviewEscalate = tool.name === REVIEW_SUBMISSION_OUTPUT_TOOL_NAME && infrastructureFailureDiagnostic(params) !== void 0 && params !== null && typeof params === "object" && !Array.isArray(params) && params.status === "escalate";
13393
+ if (!reviewEscalate) {
13394
+ failOnInfrastructureFailureDeclaration(
13395
+ params,
13396
+ {
13397
+ failInfrastructure(error, ctx) {
13398
+ failInfrastructure2(error, ctx);
13399
+ }
13400
+ },
13401
+ context,
13402
+ toolCallId,
13403
+ tool.bounceInfrastructureDeclaration
13404
+ );
13405
+ }
13395
13406
  result = await tool.execute(toolCallId, params, signal, update, context);
13396
13407
  } catch (error) {
13397
13408
  if (isCorrectableExecuteError(error)) {
@@ -13470,6 +13481,7 @@ var init_submission_ledger = __esm({
13470
13481
  init_run_lifecycle();
13471
13482
  init_submission_correctable_error();
13472
13483
  init_terminating_infrastructure();
13484
+ init_review_submission();
13473
13485
  }
13474
13486
  });
13475
13487
 
@@ -13598,9 +13610,10 @@ var init_auditor_soul = __esm({
13598
13610
  "CLAUDE.md",
13599
13611
  "souls/judge-auditor.md",
13600
13612
  "souls/audit-law.md",
13601
- "souls/quality-law.md"
13613
+ "souls/quality-law.md",
13614
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
13602
13615
  ],
13603
- doctor: ["CLAUDE.md", "souls/doctor-auditor.md"]
13616
+ doctor: ["CLAUDE.md", "souls/doctor-auditor.md", "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"]
13604
13617
  };
13605
13618
  }
13606
13619
  });
@@ -14129,7 +14142,7 @@ function resolveLifecycleInvocationPrincipal(entries, expected) {
14129
14142
  }
14130
14143
  return { invocationId: marker.invocationId, resume: true };
14131
14144
  }
14132
- var NAVIGATOR_INVOCATION_ENTRY, NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND, NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS, NAVIGATOR_INFRASTRUCTURE_FAILURE_EVIDENCE_KEYS, PACKAGED_ROLE_OUTPUT_TOOLS;
14145
+ var NAVIGATOR_INVOCATION_ENTRY, NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY, NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND, NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS, NAVIGATOR_INFRASTRUCTURE_FAILURE_EVIDENCE_KEYS, PACKAGED_ROLE_OUTPUT_TOOLS;
14133
14146
  var init_navigator_invocation_identity = __esm({
14134
14147
  "src/navigator-invocation-identity.ts"() {
14135
14148
  "use strict";
@@ -14137,6 +14150,7 @@ var init_navigator_invocation_identity = __esm({
14137
14150
  init_uuidv7();
14138
14151
  init_work_subject_identity();
14139
14152
  NAVIGATOR_INVOCATION_ENTRY = "ak-navigator-invocation";
14153
+ NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY = "ak-navigator-route-playbook-failure";
14140
14154
  NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND = "role_infrastructure_failure";
14141
14155
  NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS = [
14142
14156
  "kind",
@@ -14230,17 +14244,25 @@ function createReceiptDeliveryPolicy() {
14230
14244
  if (accepted) return "accepted";
14231
14245
  return deliveryTurns < RECEIPT_DELIVERY_TURN_LIMIT ? "request-delivery" : "no-receipt";
14232
14246
  },
14247
+ /** Current typed delivery facts. No prose. */
14248
+ deliveryState() {
14249
+ return {
14250
+ terminalToolCalled,
14251
+ rejectedReceipts: rejectedReceipts.map((item) => ({ ...item })),
14252
+ deliveryTurns,
14253
+ acceptedReceipt: false
14254
+ };
14255
+ },
14233
14256
  facts(binding) {
14234
14257
  return noReceiptLifecycleFacts({ terminalToolCalled, rejectedReceipts: [...rejectedReceipts], deliveryTurns, ...binding });
14235
14258
  }
14236
14259
  };
14237
14260
  }
14238
- var RECEIPT_DELIVERY_TURN_LIMIT, RECEIPT_DELIVERY_PROMPT, NO_RECEIPT_LIFECYCLE_ENTRY_TYPE;
14261
+ var RECEIPT_DELIVERY_TURN_LIMIT, NO_RECEIPT_LIFECYCLE_ENTRY_TYPE;
14239
14262
  var init_receipt_delivery_policy = __esm({
14240
14263
  "src/receipt-delivery-policy.ts"() {
14241
14264
  "use strict";
14242
14265
  RECEIPT_DELIVERY_TURN_LIMIT = 2;
14243
- RECEIPT_DELIVERY_PROMPT = "\u672C\u4F1A\u8BDD\u5C1A\u65E0\u5DF2\u63A5\u53D7\u7684 typed \u56DE\u6267\u3002";
14244
14266
  NO_RECEIPT_LIFECYCLE_ENTRY_TYPE = "ak-no-receipt-lifecycle";
14245
14267
  }
14246
14268
  });
@@ -15361,7 +15383,23 @@ async function withOptionalGateProjection(base, sessionDirectory, gateContext =
15361
15383
  }
15362
15384
  return attachEngineDetourToolUsage(next, sessionDirectory, gateContext);
15363
15385
  }
15386
+ function routePlaybookFailureMessage(entries) {
15387
+ for (let i = entries.length - 1; i >= 0; i -= 1) {
15388
+ const entry = entries[i];
15389
+ if (entry?.type !== "custom" || entry.customType !== NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY) continue;
15390
+ const data = entry.data;
15391
+ if (!isRecord12(data) || typeof data.message !== "string" || data.message.trim() === "") return void 0;
15392
+ return data.message;
15393
+ }
15394
+ return void 0;
15395
+ }
15364
15396
  function extractNavigatorFact(entries) {
15397
+ const fact = extractNavigatorAttendanceFact(entries);
15398
+ if (fact.advisoryDiagnostic !== void 0) return fact;
15399
+ const message = routePlaybookFailureMessage(entries);
15400
+ return message === void 0 ? fact : { ...fact, advisoryDiagnostic: message };
15401
+ }
15402
+ function extractNavigatorAttendanceFact(entries) {
15365
15403
  const terminal = findLatestDurablePackagedRoleTerminal(entries);
15366
15404
  if (terminal === void 0) {
15367
15405
  return {
@@ -16137,10 +16175,10 @@ function presentFailureTerminal(terminal, io) {
16137
16175
  }
16138
16176
  function defaultNavigatorGraceSleep() {
16139
16177
  let timer;
16140
- const sleep2 = ((ms) => new Promise((resolve21) => {
16178
+ const sleep2 = ((ms) => new Promise((resolve22) => {
16141
16179
  timer = setTimeout(() => {
16142
16180
  timer = void 0;
16143
- resolve21();
16181
+ resolve22();
16144
16182
  }, ms);
16145
16183
  }));
16146
16184
  sleep2.cancel = () => {
@@ -16152,7 +16190,7 @@ function defaultNavigatorGraceSleep() {
16152
16190
  return sleep2;
16153
16191
  }
16154
16192
  function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
16155
- return new Promise((resolve21, reject) => {
16193
+ return new Promise((resolve22, reject) => {
16156
16194
  let settled = false;
16157
16195
  const finish = (action) => {
16158
16196
  if (settled) return;
@@ -16161,11 +16199,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
16161
16199
  action();
16162
16200
  };
16163
16201
  void work.then(
16164
- (value) => finish(() => resolve21({ status: "done", value })),
16202
+ (value) => finish(() => resolve22({ status: "done", value })),
16165
16203
  (error) => finish(() => reject(error))
16166
16204
  );
16167
16205
  void sleep2(graceMs).then(() => {
16168
- finish(() => resolve21({ status: "timeout" }));
16206
+ finish(() => resolve22({ status: "timeout" }));
16169
16207
  });
16170
16208
  });
16171
16209
  }
@@ -18208,7 +18246,7 @@ async function runCountersignCourtDiaristStation(admitted, env, io, afterTicketN
18208
18246
  for (const ticketNumber of refreshTickets.slice(completedIndex + 1)) {
18209
18247
  const outcome = await invokeCourtDiarist(
18210
18248
  {
18211
- instruction: `\u6574\u7406 #${ticketNumber} \u7684\u672C\u6848\u4F9D\u636E\u3002`,
18249
+ instruction: admitted.instruction,
18212
18250
  projectRoot: admitted.projectRoot,
18213
18251
  failureLabel: `ticket #${ticketNumber}`,
18214
18252
  correlationId: admitted.runId,
@@ -18955,8 +18993,8 @@ var init_atomic_write = __esm({
18955
18993
  import { open as open3, readFile as readFile18, unlink as unlink5 } from "node:fs/promises";
18956
18994
  import { dirname as dirname18, join as join34 } from "node:path";
18957
18995
  function sleep(ms) {
18958
- return new Promise((resolve21) => {
18959
- setTimeout(resolve21, ms);
18996
+ return new Promise((resolve22) => {
18997
+ setTimeout(resolve22, ms);
18960
18998
  });
18961
18999
  }
18962
19000
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
@@ -22573,7 +22611,7 @@ async function runComplianceAudit(options) {
22573
22611
  const summoned = await summon(subject, runDirectory, options.signal, reask, submission);
22574
22612
  const decision = await projectAuditorTerminal(summoned);
22575
22613
  if (decision.status === "received") {
22576
- reask = OFFICER_CONCLUSION_REASK;
22614
+ reask = officerConclusionReask(receivedDiscriminator(decision.reply, "status"));
22577
22615
  continue;
22578
22616
  }
22579
22617
  return decision;
@@ -22585,6 +22623,7 @@ var init_compliance_transport = __esm({
22585
22623
  "use strict";
22586
22624
  init_auditor_dossier_tool();
22587
22625
  init_gatekeeper_role();
22626
+ init_submission_errors();
22588
22627
  init_terminal();
22589
22628
  init_readable_gate_item();
22590
22629
  AUDITOR_DOSSIER_PROMPT = "\u5377\u5B97\u6307\u9488\uFF1A";
@@ -22601,7 +22640,7 @@ var init_compliance_transport = __esm({
22601
22640
 
22602
22641
  // src/archivist-record-topology.ts
22603
22642
  import { createHash as createHash8 } from "node:crypto";
22604
- import { join as join39 } from "node:path";
22643
+ import { join as join40 } from "node:path";
22605
22644
  function resolveNavigatorWorkSubjectPlacement(input) {
22606
22645
  let ledgerHome;
22607
22646
  if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
@@ -22614,7 +22653,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
22614
22653
  const digest = createHash8("sha256").update(input.subject).digest("hex").slice(0, 32);
22615
22654
  return {
22616
22655
  ledgerHome,
22617
- sessionDir: join39(
22656
+ sessionDir: join40(
22618
22657
  activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
22619
22658
  NAVIGATOR_RECORD_KIND,
22620
22659
  digest
@@ -22632,7 +22671,7 @@ var init_archivist_record_topology = __esm({
22632
22671
  });
22633
22672
 
22634
22673
  // src/pi/record-session-host.ts
22635
- import { existsSync as existsSync10 } from "node:fs";
22674
+ import { existsSync as existsSync11 } from "node:fs";
22636
22675
  import { SessionManager } from "@earendil-works/pi-coding-agent";
22637
22676
  var piRecordSessionHost;
22638
22677
  var init_record_session_host = __esm({
@@ -22654,7 +22693,7 @@ var init_record_session_host = __esm({
22654
22693
  const sessionFile = session.getSessionFile();
22655
22694
  return {
22656
22695
  session,
22657
- resumed: sessionFile !== void 0 && existsSync10(sessionFile)
22696
+ resumed: sessionFile !== void 0 && existsSync11(sessionFile)
22658
22697
  };
22659
22698
  },
22660
22699
  inMemoryRecordSession(cwd) {
@@ -22677,20 +22716,20 @@ __export(archivist_record_entry_exports, {
22677
22716
  });
22678
22717
  import {
22679
22718
  closeSync,
22680
- existsSync as existsSync11,
22719
+ existsSync as existsSync12,
22681
22720
  mkdirSync as mkdirSync2,
22682
22721
  openSync,
22683
22722
  readdirSync as readdirSync2,
22684
22723
  readFileSync as readFileSync4,
22685
22724
  readSync,
22686
- realpathSync as realpathSync2,
22725
+ realpathSync as realpathSync3,
22687
22726
  statSync as statSync5,
22688
22727
  writeFileSync as writeFileSync2
22689
22728
  } from "node:fs";
22690
- import { dirname as dirname20, resolve as resolve15, join as join40 } from "node:path";
22729
+ import { dirname as dirname21, resolve as resolve16, join as join41 } from "node:path";
22691
22730
  import { StringDecoder } from "node:string_decoder";
22692
22731
  function readCurrentSession(sessionDir) {
22693
- const ledger = join40(sessionDir, CURRENT_SESSION_LEDGER);
22732
+ const ledger = join41(sessionDir, CURRENT_SESSION_LEDGER);
22694
22733
  try {
22695
22734
  const value = JSON.parse(readFileSync4(ledger, "utf8"));
22696
22735
  if (typeof value !== "object" || value === null || typeof value.sessionFile !== "string" || value.sessionFile.length === 0) {
@@ -22705,7 +22744,7 @@ function readCurrentSession(sessionDir) {
22705
22744
  }
22706
22745
  }
22707
22746
  function writeCurrentSession(sessionDir, sessionFile) {
22708
- const ledger = join40(sessionDir, CURRENT_SESSION_LEDGER);
22747
+ const ledger = join41(sessionDir, CURRENT_SESSION_LEDGER);
22709
22748
  try {
22710
22749
  writeFileSync2(ledger, `${JSON.stringify({ sessionFile })}
22711
22750
  `, { flag: "wx" });
@@ -22721,7 +22760,7 @@ function isCurrentSessionClaimRace(error) {
22721
22760
  return errnoCode(error.cause) === "EEXIST";
22722
22761
  }
22723
22762
  function currentSessionLedgerPath(sessionDir) {
22724
- return join40(sessionDir, CURRENT_SESSION_LEDGER);
22763
+ return join41(sessionDir, CURRENT_SESSION_LEDGER);
22725
22764
  }
22726
22765
  function readBoundedSessionHeader(filePath) {
22727
22766
  const fd = openSync(filePath, "r");
@@ -22794,8 +22833,8 @@ function parseSessionHeaderLine(line2) {
22794
22833
  };
22795
22834
  }
22796
22835
  function mostRecentNavigatorSessionFile(sessionDir, cwd) {
22797
- const absoluteSessionDir = resolve15(sessionDir);
22798
- const absoluteCwd = resolve15(cwd);
22836
+ const absoluteSessionDir = resolve16(sessionDir);
22837
+ const absoluteCwd = resolve16(cwd);
22799
22838
  let names;
22800
22839
  try {
22801
22840
  names = readdirSync2(absoluteSessionDir);
@@ -22808,7 +22847,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
22808
22847
  const matched = [];
22809
22848
  for (const name of names) {
22810
22849
  if (!name.endsWith(".jsonl")) continue;
22811
- const filePath = join40(absoluteSessionDir, name);
22850
+ const filePath = join41(absoluteSessionDir, name);
22812
22851
  let st;
22813
22852
  try {
22814
22853
  st = statSync5(filePath);
@@ -22830,7 +22869,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
22830
22869
  }
22831
22870
  if (header === void 0) continue;
22832
22871
  if (typeof header.cwd !== "string" || header.cwd.length === 0) continue;
22833
- if (resolve15(header.cwd) !== absoluteCwd) continue;
22872
+ if (resolve16(header.cwd) !== absoluteCwd) continue;
22834
22873
  matched.push({ path: filePath, mtimeMs: st.mtimeMs });
22835
22874
  }
22836
22875
  if (matched.length === 0) return void 0;
@@ -22839,7 +22878,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
22839
22878
  }
22840
22879
  function resolveNavigatorNestContinuation(sessionDir, cwd) {
22841
22880
  const ledgerPath = currentSessionLedgerPath(sessionDir);
22842
- if (existsSync11(ledgerPath)) {
22881
+ if (existsSync12(ledgerPath)) {
22843
22882
  const recentFile = readCurrentSession(sessionDir);
22844
22883
  assertRecentFinalFileUnderSessionDir(sessionDir, recentFile);
22845
22884
  return recentFile;
@@ -22860,8 +22899,8 @@ function resolveNavigatorNestContinuation(sessionDir, cwd) {
22860
22899
  }
22861
22900
  }
22862
22901
  function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
22863
- const absoluteSessionDir = resolve15(sessionDir);
22864
- const absoluteFile = resolve15(recentFile);
22902
+ const absoluteSessionDir = resolve16(sessionDir);
22903
+ const absoluteFile = resolve16(recentFile);
22865
22904
  if (absoluteFile !== absoluteSessionDir && !pathContainedIn(absoluteSessionDir, absoluteFile)) {
22866
22905
  throw new ActivationLedgerError(
22867
22906
  `archivist record session must be under the authorized nest (${sessionDir}): ${recentFile}`
@@ -22869,7 +22908,7 @@ function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
22869
22908
  }
22870
22909
  let realSessionDir;
22871
22910
  try {
22872
- realSessionDir = realpathSync2(absoluteSessionDir);
22911
+ realSessionDir = realpathSync3(absoluteSessionDir);
22873
22912
  } catch (error) {
22874
22913
  throw new ActivationLedgerError(
22875
22914
  `archivist record sessionDir is not resolvable (${absoluteSessionDir}): ${errorText(error)}`,
@@ -22878,7 +22917,7 @@ function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
22878
22917
  }
22879
22918
  let realFile;
22880
22919
  try {
22881
- realFile = realpathSync2(absoluteFile);
22920
+ realFile = realpathSync3(absoluteFile);
22882
22921
  } catch (error) {
22883
22922
  throw new ActivationLedgerError(
22884
22923
  `archivist record session file is not resolvable (${absoluteFile}): ${errorText(error)}`,
@@ -22916,15 +22955,15 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
22916
22955
  throw new Error("Durable record ownership requires a parent session inside the ledger home");
22917
22956
  } else {
22918
22957
  ledgerHome = resolveActivationLedgerHomeForPath(parentFile);
22919
- const parentResolved = resolve15(parentFile);
22958
+ const parentResolved = resolve16(parentFile);
22920
22959
  if (!physicallyContainedIn(ledgerHome, parentResolved)) {
22921
22960
  throw new Error("Durable record ownership requires a parent session inside the ledger home");
22922
22961
  }
22923
- sessionDir = join40(dirname20(parentResolved), options.kind);
22962
+ sessionDir = join41(dirname21(parentResolved), options.kind);
22924
22963
  parentSession = parentFile;
22925
22964
  mayResumeSameNest = options.kind === WORKER_SUBMISSION_GATE_KIND;
22926
22965
  }
22927
- const nestAlreadyExists = existsSync11(sessionDir);
22966
+ const nestAlreadyExists = existsSync12(sessionDir);
22928
22967
  ensureRealDirectoryTree(ledgerHome, sessionDir);
22929
22968
  if (mayResumeSameNest && nestAlreadyExists) {
22930
22969
  if (options.kind === NAVIGATOR_RECORD_KIND) {
@@ -22949,7 +22988,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
22949
22988
  });
22950
22989
  if (session.isPersisted()) {
22951
22990
  const file = session.getSessionFile();
22952
- if (file !== void 0 && !existsSync11(file)) {
22991
+ if (file !== void 0 && !existsSync12(file)) {
22953
22992
  const header = session.getHeader();
22954
22993
  if (header !== null && header.type === "session") {
22955
22994
  writeFileSync2(file, `${JSON.stringify(header)}
@@ -22967,7 +23006,7 @@ function createRecordSession(options) {
22967
23006
  return createRecordSessionOpen(options).session;
22968
23007
  }
22969
23008
  function bookDirectOfficerRunPointer(options) {
22970
- const nest = join40(dirname20(options.parentSessionFile), "auditor-roles");
23009
+ const nest = join41(dirname21(options.parentSessionFile), "auditor-roles");
22971
23010
  mkdirSync2(nest, { recursive: true });
22972
23011
  const pointer = {
22973
23012
  version: 1,
@@ -22977,7 +23016,7 @@ function bookDirectOfficerRunPointer(options) {
22977
23016
  ...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
22978
23017
  };
22979
23018
  writeFileSync2(
22980
- join40(nest, `${options.officer}.pointer.json`),
23019
+ join41(nest, `${options.officer}.pointer.json`),
22981
23020
  `${JSON.stringify(pointer)}
22982
23021
  `,
22983
23022
  "utf8"
@@ -23005,8 +23044,8 @@ import { randomUUID as randomUUID11 } from "node:crypto";
23005
23044
 
23006
23045
  // src/role-runtime-dependencies.ts
23007
23046
  init_collector_github();
23008
- import { readFile as readFile24 } from "node:fs/promises";
23009
- import { join as join44 } from "node:path";
23047
+ import { readFile as readFile25 } from "node:fs/promises";
23048
+ import { join as join45 } from "node:path";
23010
23049
 
23011
23050
  // src/doctor-auditor.ts
23012
23051
  init_auditor_dossier_tool();
@@ -23038,13 +23077,14 @@ import { createHash as createHash9 } from "node:crypto";
23038
23077
  init_navigator_invocation_identity();
23039
23078
  init_packaged_role_registry();
23040
23079
  init_activation_ledger_topology();
23041
- import { resolve as resolve16 } from "node:path";
23080
+ import { resolve as resolve17 } from "node:path";
23042
23081
  import "@earendil-works/pi-coding-agent";
23043
23082
  import { Type as Type13 } from "typebox";
23044
23083
 
23045
23084
  // src/navigator-public-session.ts
23046
23085
  init_sitian_facade();
23047
- import { basename as basename9 } from "node:path";
23086
+ import { existsSync as existsSync13 } from "node:fs";
23087
+ import { basename as basename10 } from "node:path";
23048
23088
 
23049
23089
  // src/navigator-session-contracts.ts
23050
23090
  import { Type as Type12 } from "typebox";
@@ -23234,6 +23274,113 @@ async function resolveNavigatorSeatSelection(context) {
23234
23274
  init_host_contracts();
23235
23275
  init_cli_errors();
23236
23276
  init_packaged_role_registry();
23277
+
23278
+ // src/navigator-work-base.ts
23279
+ init_atomic_write();
23280
+ import { existsSync as existsSync10, realpathSync as realpathSync2 } from "node:fs";
23281
+ import { readFile as readFile22 } from "node:fs/promises";
23282
+ import { basename as basename9, dirname as dirname20, join as join39, resolve as resolve15 } from "node:path";
23283
+ var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
23284
+ function navigatorWorkContextFile(sessionDir) {
23285
+ return join39(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
23286
+ }
23287
+ function isNavigatorWorkContextFile(path) {
23288
+ const resolved = resolve15(path);
23289
+ if (basename9(resolved) !== NAVIGATOR_WORK_CONTEXT_BASENAME) return false;
23290
+ const nest = dirname20(resolved);
23291
+ if (!/^[0-9a-f]{32}$/.test(basename9(nest))) return false;
23292
+ return basename9(dirname20(nest)) === "navigator";
23293
+ }
23294
+ function canonicalNavigatorWorkContextFile(path) {
23295
+ if (!isNavigatorWorkContextFile(path)) return void 0;
23296
+ try {
23297
+ const real = realpathSync2(path);
23298
+ return isNavigatorWorkContextFile(real) ? real : void 0;
23299
+ } catch {
23300
+ return void 0;
23301
+ }
23302
+ }
23303
+ async function persistNavigatorWorkBase(sessionDir, body) {
23304
+ if (sessionDir.trim() === "" || !existsSync10(sessionDir)) return void 0;
23305
+ if (body.authority.trim() === "") return void 0;
23306
+ const path = navigatorWorkContextFile(sessionDir);
23307
+ const next = `${JSON.stringify({ subject: body.subject, authority: body.authority })}
23308
+ `;
23309
+ try {
23310
+ const current = await readFile22(path, "utf8");
23311
+ if (current === next) return path;
23312
+ } catch (error) {
23313
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
23314
+ throw error;
23315
+ }
23316
+ }
23317
+ await writeFileAtomically(path, next);
23318
+ return path;
23319
+ }
23320
+ async function readNavigatorWorkBase(path) {
23321
+ const canonical = canonicalNavigatorWorkContextFile(path);
23322
+ if (canonical === void 0) return void 0;
23323
+ let text;
23324
+ try {
23325
+ text = await readFile22(canonical, "utf8");
23326
+ } catch (error) {
23327
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") {
23328
+ return void 0;
23329
+ }
23330
+ throw error;
23331
+ }
23332
+ let parsed;
23333
+ try {
23334
+ parsed = JSON.parse(text);
23335
+ } catch {
23336
+ return void 0;
23337
+ }
23338
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return void 0;
23339
+ const record4 = parsed;
23340
+ if (typeof record4.subject !== "string" || typeof record4.authority !== "string") return void 0;
23341
+ if (record4.authority.trim() === "") return void 0;
23342
+ return { subject: record4.subject, authority: record4.authority };
23343
+ }
23344
+ function jsonObjectFromPrompt(prompt) {
23345
+ const head = prompt.trimStart().split("\n\n", 1)[0] ?? "";
23346
+ if (!head.startsWith("{")) return void 0;
23347
+ try {
23348
+ const parsed = JSON.parse(head);
23349
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return void 0;
23350
+ return parsed;
23351
+ } catch {
23352
+ return void 0;
23353
+ }
23354
+ }
23355
+ function workContextPathFromPrompt(prompt) {
23356
+ const record4 = jsonObjectFromPrompt(prompt);
23357
+ const path = record4?.workContextPath;
23358
+ if (typeof path !== "string" || path.trim() === "") return void 0;
23359
+ return isNavigatorWorkContextFile(path) ? path : void 0;
23360
+ }
23361
+ function attachWorkContextPointer(text, workContextPath) {
23362
+ const record4 = jsonObjectFromPrompt(text);
23363
+ if (record4 === void 0) return text;
23364
+ if (typeof record4.workContextPath === "string" && record4.workContextPath.trim() !== "") return text;
23365
+ const head = text.trimStart().split("\n\n", 1)[0] ?? "";
23366
+ const rest = text.trimStart().slice(head.length);
23367
+ return `${JSON.stringify({ ...record4, workContextPath })}${rest}`;
23368
+ }
23369
+ async function loadNavigatorWorkBaseSuffix(prompt) {
23370
+ const path = workContextPathFromPrompt(prompt);
23371
+ if (path === void 0) return void 0;
23372
+ const body = await readNavigatorWorkBase(path);
23373
+ if (body === void 0) return void 0;
23374
+ return `<work_subject>
23375
+ ${body.subject}
23376
+ </work_subject>
23377
+
23378
+ <controlling_authority>
23379
+ ${body.authority}
23380
+ </controlling_authority>`;
23381
+ }
23382
+
23383
+ // src/navigator-public-session.ts
23237
23384
  async function resolveNavigatorLedgerHome(context) {
23238
23385
  const { tryHomeFromAkRolesPath: tryHomeFromAkRolesPath2 } = await Promise.resolve().then(() => (init_activation_ledger_topology(), activation_ledger_topology_exports));
23239
23386
  const runDirectory = runDirectoryFromHostContext(context);
@@ -23253,7 +23400,7 @@ function exactRecord2(value) {
23253
23400
  return typeof value === "object" && value !== null && !Array.isArray(value);
23254
23401
  }
23255
23402
  function runIdFromNavigatorDirectory(runDirectory) {
23256
- const entry = basename9(runDirectory);
23403
+ const entry = basename10(runDirectory);
23257
23404
  const suffix = "@navigator";
23258
23405
  if (!entry.endsWith(suffix)) return void 0;
23259
23406
  const runId = entry.slice(0, entry.length - suffix.length);
@@ -23297,6 +23444,7 @@ function createNativeNavigatorSessionFactory(deps) {
23297
23444
  });
23298
23445
  let providerFailure;
23299
23446
  let noReceipt;
23447
+ let routePlaybookReadFailure;
23300
23448
  let disposed = false;
23301
23449
  let hostRunId = readNavigatorHostRunPointer(sessionManager.getEntries());
23302
23450
  const summon = deps?.summonPublicRole ?? (async (options) => {
@@ -23310,13 +23458,16 @@ function createNativeNavigatorSessionFactory(deps) {
23310
23458
  }
23311
23459
  providerFailure = void 0;
23312
23460
  noReceipt = void 0;
23461
+ routePlaybookReadFailure = void 0;
23313
23462
  try {
23314
23463
  const summonHome = await resolveNavigatorLedgerHome(context);
23315
23464
  if (disposed) return;
23316
23465
  const resumeRunId = hostRunId;
23466
+ const workContextPath = navigatorWorkContextFile(sessionManager.getSessionDir());
23467
+ const argvText = existsSync13(workContextPath) ? attachWorkContextPointer(text, workContextPath) : text;
23317
23468
  const baseSummon = {
23318
23469
  role: "navigator",
23319
- argv: [text],
23470
+ argv: [argvText],
23320
23471
  cwd: context.cwd,
23321
23472
  ...summonHome === void 0 ? {} : { home: summonHome },
23322
23473
  ...context.signal === void 0 ? {} : { signal: context.signal }
@@ -23337,6 +23488,8 @@ function createNativeNavigatorSessionFactory(deps) {
23337
23488
  }
23338
23489
  }
23339
23490
  if (disposed) return;
23491
+ const playbookFailure = summoned.terminal?.navigator?.advisoryDiagnostic;
23492
+ routePlaybookReadFailure = typeof playbookFailure === "string" && playbookFailure.trim() !== "" ? playbookFailure : void 0;
23340
23493
  const outcome = summoned.terminal?.roleOutcome;
23341
23494
  if (outcome === void 0) {
23342
23495
  const detail = summoned.stderr?.trim() || `exit ${summoned.exitCode}`;
@@ -23395,6 +23548,7 @@ function createNativeNavigatorSessionFactory(deps) {
23395
23548
  },
23396
23549
  providerFailure: () => providerFailure,
23397
23550
  noReceipt: () => noReceipt,
23551
+ routePlaybookReadFailure: () => routePlaybookReadFailure,
23398
23552
  appendEntry: (customType, data) => {
23399
23553
  sessionManager.appendCustomEntry(customType, data);
23400
23554
  try {
@@ -23434,7 +23588,6 @@ init_work_subject_identity();
23434
23588
  init_receipt_delivery_policy();
23435
23589
  init_navigator_output();
23436
23590
  var NAVIGATOR_EVENT_TYPE = "ak-navigator-attendance";
23437
- var NAVIGATOR_PREPARE_ACCEPTED_TEXT = "\u6E38\u5955\u4F7F\u51C6\u5907\u5DF2\u63A5\u53D7";
23438
23591
  function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
23439
23592
  if (roleInput !== void 0 && roleInput.trim() !== "") return roleInput;
23440
23593
  if (fileAuthority !== void 0 && fileAuthority.trim() !== "") return fileAuthority;
@@ -23443,10 +23596,9 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
23443
23596
  var NAVIGATOR_TARGETS = PACKAGED_ROLE_REGISTRY.map(({ role, phases }) => ({ role, phases }));
23444
23597
  var prepareSchema = Type13.Object({
23445
23598
  prose: Type13.Optional(Type13.Unknown({
23446
- description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7ED3\u6784\u3002\u975E\u53D7\u7406\u95F8"
23599
+ description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7ED3\u6784\u3002"
23447
23600
  }))
23448
23601
  }, { additionalProperties: true });
23449
- var CONTEXT_ENTRY = "ak-navigator-context";
23450
23602
  var INVOCATION_ENTRY = NAVIGATOR_INVOCATION_ENTRY;
23451
23603
  var SETTLEMENT_ENTRY = "ak-navigator-settlement";
23452
23604
  function exactRecord3(value) {
@@ -23486,7 +23638,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
23486
23638
  }
23487
23639
  function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
23488
23640
  if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
23489
- const resolvedReference = resolve16(cwd, reference);
23641
+ const resolvedReference = resolve17(cwd, reference);
23490
23642
  const marker = "/runs/";
23491
23643
  if (resolvedReference.includes(marker)) {
23492
23644
  return subjectRoot;
@@ -23501,12 +23653,12 @@ function createNavigatorPrepareTool(onOutput) {
23501
23653
  parameters: prepareSchema,
23502
23654
  async execute(_id, value) {
23503
23655
  onOutput(value);
23504
- return { content: [{ type: "text", text: NAVIGATOR_PREPARE_ACCEPTED_TEXT }], details: value, terminate: true };
23656
+ return { content: [], details: value, terminate: true };
23505
23657
  }
23506
23658
  };
23507
23659
  }
23508
23660
  function formatNavigatorReport(report) {
23509
- const playbookFailure = report.routePlaybookReadFailure === void 0 ? [] : [`\u8DEF\u4E66\u8BFB\u53D6\u5931\u8D25\uFF1A${report.routePlaybookReadFailure}`];
23661
+ const playbookFailure = report.routePlaybookReadFailure === void 0 ? [] : [report.routePlaybookReadFailure];
23510
23662
  if (report.disposition === "no-advice") return playbookFailure.join("\n");
23511
23663
  if (report.disposition === "unavailable") {
23512
23664
  return [...playbookFailure, ...report.unavailableReason ? [report.unavailableReason] : []].join("\n");
@@ -23532,28 +23684,15 @@ function createNavigatorAttendance(options) {
23532
23684
  let settlementTail = Promise.resolve();
23533
23685
  let settlementFailure;
23534
23686
  let preparationFailure;
23535
- let routePlaybookReadFailure;
23687
+ let observedRoutePlaybookFailure;
23536
23688
  let disposed = false;
23537
23689
  let closing;
23538
23690
  const nestCancel = new AbortController();
23539
- let warmedHelp;
23540
23691
  const sessionHostContext = () => {
23541
23692
  const parentSignal = options.context.signal;
23542
23693
  const signal = parentSignal === void 0 ? nestCancel.signal : AbortSignal.any([nestCancel.signal, parentSignal]);
23543
23694
  return { ...options.context, signal };
23544
23695
  };
23545
- const loadLiveHelp = async () => {
23546
- try {
23547
- return await Promise.all(
23548
- NAVIGATOR_TARGETS.map(async ({ role }) => ({
23549
- role,
23550
- help: await options.loadRoleHelp(role)
23551
- }))
23552
- );
23553
- } catch (error) {
23554
- throw navigatorUnavailableError("transport", error);
23555
- }
23556
- };
23557
23696
  const unavailable = (invocationId, reason) => {
23558
23697
  const failure2 = reason instanceof NavigatorUnavailableError ? reason : navigatorUnavailableError("unknown", reason);
23559
23698
  return {
@@ -23563,7 +23702,6 @@ function createNavigatorAttendance(options) {
23563
23702
  unavailableCause: failure2.unavailableCause
23564
23703
  };
23565
23704
  };
23566
- let routePlaybookSettlement;
23567
23705
  let prepareBoundSettlement;
23568
23706
  const loadMaterialsAndSession = async (invocationId) => {
23569
23707
  if (contextError !== void 0) throw navigatorUnavailableError("context", contextError);
@@ -23573,30 +23711,6 @@ function createNavigatorAttendance(options) {
23573
23711
  new Error("controlling authority content was not supplied as typed work context")
23574
23712
  );
23575
23713
  }
23576
- let soul;
23577
- let modelSetting;
23578
- let help;
23579
- let routePlaybook = "";
23580
- routePlaybookReadFailure = void 0;
23581
- const soulPromise = (async () => {
23582
- try {
23583
- const text = (await options.loadSoul()).trim();
23584
- if (!text) throw new Error("Navigator soul is empty");
23585
- return text;
23586
- } catch (error) {
23587
- throw navigatorUnavailableError("context", error);
23588
- }
23589
- })();
23590
- const routePlaybookPromise = (async () => {
23591
- if (options.loadRoutePlaybook === void 0) return "";
23592
- try {
23593
- return await options.loadRoutePlaybook();
23594
- } catch (error) {
23595
- routePlaybookReadFailure = error instanceof Error ? error.message : String(error);
23596
- return "";
23597
- }
23598
- })();
23599
- routePlaybookSettlement = routePlaybookPromise.then(() => void 0);
23600
23714
  const modelPromise = (async () => {
23601
23715
  try {
23602
23716
  const resolved = await resolveNavigatorSeatSelection(options.context);
@@ -23606,23 +23720,13 @@ function createNavigatorAttendance(options) {
23606
23720
  throw navigatorUnavailableError("model", error);
23607
23721
  }
23608
23722
  })();
23609
- const helpPromise = warmedHelp ?? loadLiveHelp();
23610
- warmedHelp = void 0;
23611
- [soul, routePlaybook, modelSetting, help] = await Promise.all([
23612
- soulPromise,
23613
- routePlaybookPromise,
23614
- modelPromise,
23615
- helpPromise
23616
- ]);
23723
+ const modelSetting = await modelPromise;
23617
23724
  let model;
23618
23725
  try {
23619
23726
  model = parseNavigatorModelSetting(modelSetting);
23620
23727
  } catch (error) {
23621
23728
  throw navigatorUnavailableError("model", error);
23622
23729
  }
23623
- const helpContext = help.map(({ role, help: text }) => `<role_help role="${role}">
23624
- ${text}
23625
- </role_help>`).join("\n");
23626
23730
  const tool = createNavigatorPrepareTool((value) => {
23627
23731
  outputSink?.(value);
23628
23732
  });
@@ -23667,9 +23771,9 @@ ${text}
23667
23771
  }
23668
23772
  if (disposed) throw navigatorUnavailableError("session", new Error("Navigator attendance was disposed"));
23669
23773
  if (session === void 0) throw new Error("Navigator session was not created");
23670
- return { soul, routePlaybook, helpContext, modelSetting, model, help, activeSession: session };
23774
+ return session;
23671
23775
  };
23672
- const prepare = async (materialsBundle) => {
23776
+ const prepare = async (existingSession) => {
23673
23777
  const boundSettlement = prepareBoundSettlement;
23674
23778
  prepareBoundSettlement = void 0;
23675
23779
  const invocationId = invocationPrincipal;
@@ -23686,73 +23790,19 @@ ${text}
23686
23790
  const merged = [prior, next].filter((part) => part.trim() !== "").join("\n\n");
23687
23791
  output = { prose: merged };
23688
23792
  };
23689
- const { soul, routePlaybook, helpContext, help, activeSession } = materialsBundle ?? await loadMaterialsAndSession(invocationId);
23690
- const publicSettlementHistory = activeSession.entries().filter((entry) => exactRecord3(entry) && entry.type === "custom" && entry.customType === SETTLEMENT_ENTRY && exactRecord3(entry.data)).map((entry) => entry.data);
23691
- const projection = {
23692
- subjectKey,
23693
- subject,
23694
- authority,
23695
- currentRole: { role: options.role, phase: options.phase },
23696
- ...boundSettlement === void 0 ? {} : { currentSettlement: boundSettlement },
23697
- publicSettlementHistory,
23698
- liveRoleHelp: help
23699
- };
23700
- activeSession.appendEntry(CONTEXT_ENTRY, projection);
23701
- const request = boundSettlement === void 0 ? [
23702
- "\u672C\u8F6E\u4E3A\u5F85\u547D\u8F6E\u3002",
23703
- `<navigator_soul>
23704
- ${soul}
23705
- </navigator_soul>`,
23706
- ...routePlaybookReadFailure === void 0 ? [`<route_playbook>
23707
- ${routePlaybook}
23708
- </route_playbook>`] : ["\u53EF\u9009\u8DEF\u7EBF\u624B\u518C\u672A\u80FD\u8BFB\u53D6\u3002"],
23709
- `<work_subject>
23710
- ${subject}
23711
- </work_subject>`,
23712
- `<controlling_authority>
23713
- ${authority}
23714
- </controlling_authority>`,
23715
- `<current_role>
23716
- ${JSON.stringify({ role: options.role, phase: options.phase })}
23717
- </current_role>`,
23718
- `<public_settlement_history>
23719
- ${JSON.stringify(projection.publicSettlementHistory)}
23720
- </public_settlement_history>`,
23721
- `<live_role_help>
23722
- ${helpContext}
23723
- </live_role_help>`
23724
- ].join("\n\n") : [
23725
- "\u672C\u8F6E\u4E3A\u7ED3\u7B97\u6295\u5582\u8F6E\u3002",
23726
- `<navigator_soul>
23727
- ${soul}
23728
- </navigator_soul>`,
23729
- ...routePlaybookReadFailure === void 0 ? [`<route_playbook>
23730
- ${routePlaybook}
23731
- </route_playbook>`] : ["\u53EF\u9009\u8DEF\u7EBF\u624B\u518C\u672A\u80FD\u8BFB\u53D6\u3002"],
23732
- `<work_subject>
23733
- ${subject}
23734
- </work_subject>`,
23735
- `<controlling_authority>
23736
- ${authority}
23737
- </controlling_authority>`,
23738
- `<current_role>
23739
- ${JSON.stringify({ role: options.role, phase: options.phase })}
23740
- </current_role>`,
23741
- `<current_settlement>
23742
- ${JSON.stringify(boundSettlement)}
23743
- </current_settlement>`,
23744
- `<public_settlement_history>
23745
- ${JSON.stringify(projection.publicSettlementHistory)}
23746
- </public_settlement_history>`,
23747
- `<live_role_help>
23748
- ${helpContext}
23749
- </live_role_help>`
23750
- ].join("\n\n");
23793
+ const activeSession = existingSession ?? await loadMaterialsAndSession(invocationId);
23794
+ if (boundSettlement === void 0) return void 0;
23795
+ const request = JSON.stringify({
23796
+ ...boundSettlement,
23797
+ invocationId,
23798
+ subjectKey
23799
+ });
23751
23800
  try {
23752
23801
  try {
23753
23802
  if (disposed) throw navigatorUnavailableError("session", new Error("Navigator attendance was disposed"));
23754
23803
  const delivery = createReceiptDeliveryPolicy();
23755
23804
  const promptAllowingRejectedPrepare = async (text, deliveryRequest) => {
23805
+ await persistNavigatorWorkBase(activeSession.recordPointer(), { subject, authority });
23756
23806
  const entryStart = activeSession.entries().length;
23757
23807
  prepareBatchRejected = false;
23758
23808
  let promptFailure;
@@ -23783,7 +23833,7 @@ ${helpContext}
23783
23833
  await promptAllowingRejectedPrepare(request, false);
23784
23834
  if (boundSettlement !== void 0) {
23785
23835
  while (output === void 0 && prepareBatchRejected && delivery.nextAction() === "request-delivery") {
23786
- await promptAllowingRejectedPrepare(RECEIPT_DELIVERY_PROMPT, true);
23836
+ await promptAllowingRejectedPrepare(JSON.stringify(delivery.deliveryState()), true);
23787
23837
  }
23788
23838
  if (output === void 0 && delivery.nextAction() === "request-delivery") {
23789
23839
  while (delivery.nextAction() === "request-delivery") {
@@ -23823,6 +23873,8 @@ ${helpContext}
23823
23873
  preparedProse = normalizePrepareProse(output);
23824
23874
  return preparedProse;
23825
23875
  } finally {
23876
+ const playbookFailure = activeSession.routePlaybookReadFailure?.();
23877
+ observedRoutePlaybookFailure = typeof playbookFailure === "string" && playbookFailure.trim() !== "" ? playbookFailure : void 0;
23826
23878
  outputSink = void 0;
23827
23879
  }
23828
23880
  };
@@ -23840,16 +23892,6 @@ ${helpContext}
23840
23892
  contextError = next.contextError;
23841
23893
  return closing2;
23842
23894
  },
23843
- /**
23844
- * Start live-help subprocesses during activation without beginning full
23845
- * preparation. Next prepare() consumes the warm result; a later prepare
23846
- * reloads so live help edits remain visible.
23847
- */
23848
- warmHelp() {
23849
- if (disposed || warmedHelp !== void 0 || preparation !== void 0) return;
23850
- warmedHelp = loadLiveHelp();
23851
- void warmedHelp.catch(() => void 0);
23852
- },
23853
23895
  prepare() {
23854
23896
  if (disposed || preparation !== void 0) return;
23855
23897
  preparationFailure = void 0;
@@ -23864,9 +23906,6 @@ ${helpContext}
23864
23906
  isPreparing() {
23865
23907
  return preparationInFlight;
23866
23908
  },
23867
- knownRoutePlaybookReadFailure() {
23868
- return routePlaybookReadFailure;
23869
- },
23870
23909
  settle(settlement) {
23871
23910
  const next = settlementTail.then(() => settleOnce(settlement));
23872
23911
  settlementTail = next.catch((error) => {
@@ -23893,6 +23932,7 @@ ${helpContext}
23893
23932
  };
23894
23933
  async function settleOnce(settlement) {
23895
23934
  if (disposed) return;
23935
+ observedRoutePlaybookFailure = void 0;
23896
23936
  const invocationId = activeInvocationId ?? invocationPrincipal;
23897
23937
  let report;
23898
23938
  if (sessionReady !== void 0) {
@@ -23931,10 +23971,10 @@ ${helpContext}
23931
23971
  }
23932
23972
  } else {
23933
23973
  if (session !== void 0) preparationFailure = void 0;
23934
- let coldMaterials;
23974
+ let coldSession;
23935
23975
  if (session === void 0 && preparationFailure === void 0) {
23936
23976
  try {
23937
- coldMaterials = await loadMaterialsAndSession(invocationId);
23977
+ coldSession = await loadMaterialsAndSession(invocationId);
23938
23978
  } catch (error) {
23939
23979
  preparationFailure = error;
23940
23980
  }
@@ -23942,7 +23982,7 @@ ${helpContext}
23942
23982
  session?.appendEntry(SETTLEMENT_ENTRY, settlementFact);
23943
23983
  if (preparationFailure === void 0) {
23944
23984
  prepareBoundSettlement = settlement;
23945
- preparation = prepare(coldMaterials);
23985
+ preparation = prepare(coldSession);
23946
23986
  void preparation.catch((error) => {
23947
23987
  preparationFailure = error;
23948
23988
  });
@@ -23961,9 +24001,8 @@ ${helpContext}
23961
24001
  report = { disposition: "no-advice" };
23962
24002
  }
23963
24003
  }
23964
- await routePlaybookSettlement;
23965
- if (routePlaybookReadFailure !== void 0) {
23966
- report = { ...report, routePlaybookReadFailure };
24004
+ if (observedRoutePlaybookFailure !== void 0) {
24005
+ report = { ...report, routePlaybookReadFailure: observedRoutePlaybookFailure };
23967
24006
  }
23968
24007
  const event = {
23969
24008
  version: 1,
@@ -23990,16 +24029,14 @@ ${helpContext}
23990
24029
  sessionReady = void 0;
23991
24030
  preparedProse = void 0;
23992
24031
  preparationFailure = void 0;
23993
- routePlaybookSettlement = void 0;
23994
- routePlaybookReadFailure = void 0;
23995
24032
  }
23996
24033
  }
23997
24034
 
23998
24035
  // src/navigator-work-context.ts
23999
24036
  init_doctor_evidence();
24000
24037
  init_host_contracts();
24001
- import { readFile as readFile22 } from "node:fs/promises";
24002
- import { resolve as resolve17 } from "node:path";
24038
+ import { readFile as readFile23 } from "node:fs/promises";
24039
+ import { resolve as resolve18 } from "node:path";
24003
24040
  init_notary_source_run();
24004
24041
  init_packaged_role_registry();
24005
24042
  init_invocation();
@@ -24007,12 +24044,12 @@ function navigatorInputReference(getFlag, role) {
24007
24044
  if (getFlag === void 0) return void 0;
24008
24045
  const name = packagedRoleInputFlag(role);
24009
24046
  const value = name === void 0 ? void 0 : getFlag(name);
24010
- return typeof value === "string" && value !== "" ? resolve17(value) : void 0;
24047
+ return typeof value === "string" && value !== "" ? resolve18(value) : void 0;
24011
24048
  }
24012
24049
  async function loadNavigatorWorkContext(options) {
24013
24050
  const reference = navigatorInputReference(options.getFlag, options.role);
24014
24051
  const subjectMode = packagedNavigatorSubject(options.role);
24015
- const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile22(reference, "utf8");
24052
+ const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile23(reference, "utf8");
24016
24053
  const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
24017
24054
  let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
24018
24055
  let subject = input ?? `work subject: ${subjectKey}`;
@@ -24029,7 +24066,7 @@ async function loadNavigatorWorkContext(options) {
24029
24066
  }
24030
24067
  const publicRunDir = runDirectoryFromHostContext(options.context);
24031
24068
  const currentSessionDir = options.context.sessionManager.getSessionDir();
24032
- const isBoundPublicRun = publicRunDir !== void 0 && resolve17(currentSessionDir) === resolve17(publicRunDir, "session");
24069
+ const isBoundPublicRun = publicRunDir !== void 0 && resolve18(currentSessionDir) === resolve18(publicRunDir, "session");
24033
24070
  if (subjectMode === "public-instruction" && isBoundPublicRun) {
24034
24071
  let admitted;
24035
24072
  try {
@@ -24062,14 +24099,14 @@ async function loadNavigatorWorkContext(options) {
24062
24099
  }
24063
24100
  const workRoot = subjectRoot.includes("/.ak/work/") ? subjectRoot : void 0;
24064
24101
  const authorityFiles = workRoot === void 0 ? [] : [
24065
- resolve17(workRoot, "authority.md"),
24066
- resolve17(workRoot, "authority.txt"),
24067
- resolve17(workRoot, "design-v2/owner-direction.md")
24102
+ resolve18(workRoot, "authority.md"),
24103
+ resolve18(workRoot, "authority.txt"),
24104
+ resolve18(workRoot, "design-v2/owner-direction.md")
24068
24105
  ];
24069
24106
  let authorityMaterial;
24070
24107
  for (const path of authorityFiles) {
24071
24108
  try {
24072
- const content = await readFile22(path, "utf8");
24109
+ const content = await readFile23(path, "utf8");
24073
24110
  if (content.trim() !== "") {
24074
24111
  authorityMaterial = content;
24075
24112
  break;
@@ -24101,7 +24138,7 @@ init_submission_ledger();
24101
24138
  init_collector_ledger();
24102
24139
  import { randomUUID as randomUUID8 } from "node:crypto";
24103
24140
  import { readFileSync as readFileSync6, writeSync as writeSync3 } from "node:fs";
24104
- import { join as join43 } from "node:path";
24141
+ import { join as join44 } from "node:path";
24105
24142
  import { Value as Value5 } from "typebox/value";
24106
24143
 
24107
24144
  // src/activation-trace.ts
@@ -24148,11 +24185,11 @@ init_activation_ledger_git();
24148
24185
  init_activation_ledger_topology();
24149
24186
  import {
24150
24187
  lstatSync as lstatSync2,
24151
- realpathSync as realpathSync3,
24188
+ realpathSync as realpathSync4,
24152
24189
  statSync as statSync6,
24153
24190
  writeFileSync as writeFileSync3
24154
24191
  } from "node:fs";
24155
- import { isAbsolute as isAbsolute11, resolve as resolve18 } from "node:path";
24192
+ import { isAbsolute as isAbsolute11, resolve as resolve19 } from "node:path";
24156
24193
  var ActivationSessionFileMissingError = class extends Error {
24157
24194
  code = "AK_ACTIVATION_SESSION_FILE_MISSING";
24158
24195
  path;
@@ -24197,7 +24234,7 @@ function durableSessionPointer(sessionManager) {
24197
24234
  `Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
24198
24235
  );
24199
24236
  }
24200
- const resolvedFile = resolve18(file);
24237
+ const resolvedFile = resolve19(file);
24201
24238
  try {
24202
24239
  lstatSync2(resolvedFile);
24203
24240
  } catch (error) {
@@ -24218,7 +24255,7 @@ function durableSessionPointer(sessionManager) {
24218
24255
  }
24219
24256
  let realFile;
24220
24257
  try {
24221
- realFile = realpathSync3(resolvedFile);
24258
+ realFile = realpathSync4(resolvedFile);
24222
24259
  } catch (error) {
24223
24260
  throw new ActivationSessionFileMissingError(resolvedFile, { cause: error });
24224
24261
  }
@@ -24247,6 +24284,9 @@ function durableSessionPointer(sessionManager) {
24247
24284
  // src/activation-ledger.ts
24248
24285
  init_activation_ledger_topology();
24249
24286
 
24287
+ // src/role-runtime.ts
24288
+ init_session_opening_materials();
24289
+
24250
24290
  // src/stderr-jsonl.ts
24251
24291
  import { writeSync } from "node:fs";
24252
24292
  var STDERR_JSONL_WRITE_RETRY_LIMIT = 100;
@@ -24533,8 +24573,8 @@ init_collector_github();
24533
24573
  // src/collector-handbook.ts
24534
24574
  init_atomic_write();
24535
24575
  init_activation_ledger_topology();
24536
- import { readFile as readFile23 } from "node:fs/promises";
24537
- import { join as join42, sep as sep6 } from "node:path";
24576
+ import { readFile as readFile24 } from "node:fs/promises";
24577
+ import { join as join43, sep as sep6 } from "node:path";
24538
24578
 
24539
24579
  // src/collector-tool-schemas.ts
24540
24580
  init_open_tool_schema();
@@ -24580,10 +24620,10 @@ var collectorOpenWaitWindowArgsSchema = Type17.Object({
24580
24620
  }, { additionalProperties: true });
24581
24621
  var collectorBindTargetArgsSchema = Type17.Object({
24582
24622
  prNumber: Type17.Optional(Type17.Unknown({
24583
- description: "\u89D2\u8272\u5224\u5B9A\u7684\u672C\u4ED3 PR \u53F7\uFF08\u6B63\u6574\u6570\uFF09\u3002\u4E0E issueNumber \u4E8C\u9009\u4E00\u6216\u540C\u6307\u552F\u4E00\u76EE\u6807\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
24623
+ description: "\u672C\u4ED3 PR \u53F7\uFF08\u6B63\u6574\u6570\uFF09\u3002"
24584
24624
  })),
24585
24625
  issueNumber: Type17.Optional(Type17.Unknown({
24586
- description: "\u89D2\u8272\u5224\u5B9A\u7684\u672C\u4ED3 issue \u53F7\uFF08\u6B63\u6574\u6570\uFF09\uFF1Bruntime \u7ECF\u7EBF\u4E0A\u5173\u8054\u89E3\u6790\u552F\u4E00 PR\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
24626
+ description: "\u672C\u4ED3 issue \u53F7\uFF08\u6B63\u6574\u6570\uFF09\u3002"
24587
24627
  }))
24588
24628
  }, { additionalProperties: true });
24589
24629
  var collectorFindingItemDeclaration = (() => {
@@ -24601,7 +24641,7 @@ var collectorFindingItemDeclaration = (() => {
24601
24641
  },
24602
24642
  {
24603
24643
  additionalProperties: true,
24604
- description: "\u5355\u6761 finding \u6307\u9488\uFF1AevidenceId + \u53EF\u9009 category/summary\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
24644
+ description: "\u5355\u6761 finding \u6307\u9488\uFF1AevidenceId\uFF0C\u4EE5\u53CA\u53EF\u9009 category\u3001summary\u3002"
24605
24645
  }
24606
24646
  );
24607
24647
  item.required = [];
@@ -24612,11 +24652,11 @@ var collectorOutputBaseSchema = openToolObject(
24612
24652
  // No root type:array — host must not shape-reject non-array findings (#676 C).
24613
24653
  // Nested item declarations ride `items` for registration preservation (ADR 0057).
24614
24654
  findings: Type17.Unsafe({
24615
- description: "\u672C\u6B21\u6536\u96C6\u5230\u7684\u9010\u6761 findings\uFF08\u6307\u9488\u6570\u7EC4\u4E3A\u89C4\u8303\u5F62\uFF09\u3002\u96F6 finding \u7684\u6A21\u677F\u901A\u77E5\u4E0D\u5F97\u8FDB\u5165\uFF1B\u6B63\u5E38\u5B8C\u5DE5\u65E0 finding \u65F6\u7701\u7565\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002",
24655
+ description: "\u672C\u6B21\u6536\u96C6\u5230\u7684\u9010\u6761 findings \u6307\u9488\u3002",
24616
24656
  items: collectorFindingItemDeclaration
24617
24657
  }),
24618
24658
  unfinishedReasons: Type17.Unknown({
24619
- description: "\u672A\u5B8C\u6210\u539F\u56E0\u5B57\u7B26\u4E32\u6570\u7EC4\uFF08\u989D\u5EA6/\u6545\u969C/\u7B49\u5F85\u5C4A\u6EE1\u7B49\u73B0\u573A\u4F9D\u636E\uFF09\uFF1B\u4E0D\u5F97\u628A\u672A\u5B8C\u6210\u8868\u8FF0\u4E3A\u65E0\u95EE\u9898\u3002\u65E0\u53EF\u62A5\u544A\u65F6\u7701\u7565\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
24659
+ description: "\u672A\u5B8C\u6210\u539F\u56E0\u3002"
24620
24660
  })
24621
24661
  })
24622
24662
  );
@@ -24649,7 +24689,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
24649
24689
  throw new Error(`\u901A\u8FDB\u53F8\u624B\u518C\u62D2\u7EDD\u4E0D\u5B89\u5168 bookKey ${JSON.stringify(bookKey)}`);
24650
24690
  }
24651
24691
  const ledgerHome = resolveActivationLedgerHomeForPath(sessionPath);
24652
- const root = join42(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
24692
+ const root = join43(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
24653
24693
  return { ledgerHome, bookKey, root };
24654
24694
  }
24655
24695
  function collectorHandbookRepoFileName(repositoryCanonical) {
@@ -24661,9 +24701,9 @@ function collectorHandbookRepoFileName(repositoryCanonical) {
24661
24701
  return `${repositoryCanonical.replaceAll("/", "__")}.md`;
24662
24702
  }
24663
24703
  function createCollectorHandbookStore(input) {
24664
- const generalPath = join42(input.handbookRoot, "general.md");
24665
- const repoDir = join42(input.handbookRoot, "repos");
24666
- const repoPath = join42(repoDir, collectorHandbookRepoFileName(input.repositoryCanonical));
24704
+ const generalPath = join43(input.handbookRoot, "general.md");
24705
+ const repoDir = join43(input.handbookRoot, "repos");
24706
+ const repoPath = join43(repoDir, collectorHandbookRepoFileName(input.repositoryCanonical));
24667
24707
  const assertHandbookBudget = (body, label) => {
24668
24708
  const byteLength = Buffer.byteLength(body, "utf8");
24669
24709
  if (byteLength > COLLECTOR_HANDBOOK_MAX_BYTES) {
@@ -24677,7 +24717,7 @@ function createCollectorHandbookStore(input) {
24677
24717
  ensureRealDirectoryTree(input.ledgerHome, parentDir2);
24678
24718
  assertLedgerFileInsideHome(path, input.ledgerHome);
24679
24719
  try {
24680
- const body = await readFile23(path, "utf8");
24720
+ const body = await readFile24(path, "utf8");
24681
24721
  assertHandbookBudget(body, "\u6B63\u6587");
24682
24722
  return body;
24683
24723
  } catch (error) {
@@ -24931,7 +24971,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
24931
24971
  pi.registerTool({
24932
24972
  name: COLLECTOR_BIND_TARGET_TOOL,
24933
24973
  label: "\u901A\u8FDB\u53F8\u8BA4\u7968\u7ED1\u5B9A",
24934
- description: "\u89D2\u8272\u5224\u5B9A\u4EFB\u52A1\u6750\u6599\u540E\u7ED1\u5B9A\u672C\u4ED3\u552F\u4E00 PR \u76EE\u6807\u3002\u53EF\u63D0\u4EA4 prNumber \u6216 issueNumber\uFF08\u7EBF\u4E0A\u5173\u8054\u552F\u4E00 PR\uFF09\uFF1B\u663E\u5F0F --pr \u5DF2\u7ED1\u5B9A\u65F6\u65E0\u9700\u518D\u8C03\u3002\u591A\u4E49\u6216\u65E0\u6CD5\u786E\u5B9A\u65F6\u4F1A\u6B63\u786E\u9A73\u56DE\uFF0C\u8981\u6C42\u8C03\u7528\u65B9\u660E\u786E --pr\u3002",
24974
+ description: "\u7ED1\u5B9A\u672C\u4ED3\u552F\u4E00 PR \u76EE\u6807\u3002",
24935
24975
  promptSnippet: "\u7ED1\u5B9A\u89D2\u8272\u5224\u5B9A\u7684 issue/PR \u76EE\u6807",
24936
24976
  parameters: bindSchema,
24937
24977
  async execute(toolCallId, params, _signal, _onUpdate, ctx) {
@@ -25008,7 +25048,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25008
25048
  pi.registerTool({
25009
25049
  name: COLLECTOR_OBSERVE_TOOL,
25010
25050
  label: "\u901A\u8FDB\u53F8\u89C2\u5BDF",
25011
- description: "\u6293\u53D6\u914D\u7F6E\u76EE\u6807\u7684\u5B8C\u6574 GitHub PR \u8BC1\u636E\uFF0C\u5B58\u4E0D\u53EF\u53D8\u5FEB\u7167\u5165\u5377\u3002\u6B63\u6587\u5728\u4E0A\u4E0B\u6587\u4E2D\u53EA\u7ED9\u5934\u90E8\u6458\u5F55\u52A0\u6307\u9488\uFF1B\u9700\u8981\u5934\u90E8\u4E4B\u5916\u7684\u6B63\u6587\u65F6\uFF0C\u7528 ak_collector_read \u6309 evidenceId \u5F00\u5377\uFF1Bfindings \u7684\u62C6\u5206\u4E0E\u5F52\u7C7B\u7531\u4F60\u5728\u4EA4\u4EF6\u65F6\u5B8C\u6210\u3002\u76EE\u6807\u672A\u7ED1\u5B9A\u524D\u987B\u5148 ak_collector_bind_target\u3002",
25051
+ description: "\u6293\u53D6\u914D\u7F6E\u76EE\u6807\u7684 GitHub PR \u8BC1\u636E\u3002",
25012
25052
  promptSnippet: "\u6293\u53D6\u914D\u7F6E\u76EE\u6807 PR \u8BC1\u636E",
25013
25053
  parameters: observeSchema,
25014
25054
  async execute(toolCallId, _params, signal, _onUpdate, ctx) {
@@ -25038,7 +25078,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25038
25078
  pi.registerTool({
25039
25079
  name: COLLECTOR_READ_TOOL,
25040
25080
  label: "\u901A\u8FDB\u53F8\u5F00\u5377",
25041
- description: "\u6309 evidenceId \u5F00\u5377\u8BFB\u53D6\u4E00\u6761\u5DF2\u89C2\u6D4B\u6750\u6599\u7684\u5168\u91CF\u6B63\u6587\u4E0E\u6307\u9488\uFF1B\u53EA\u5728\u89C2\u5BDF\u5934\u90E8\u6458\u5F55\u4E0D\u8DB3\u4EE5\u5224\u8BFB\u65F6\u8C03\u7528\u3002",
25081
+ description: "\u6309 evidenceId \u5F00\u5377\u8BFB\u53D6\u4E00\u6761\u5DF2\u89C2\u6D4B\u6750\u6599\u7684\u5168\u91CF\u6B63\u6587\u4E0E\u6307\u9488\u3002",
25042
25082
  promptSnippet: "\u6309\u6307\u9488\u5F00\u5377\u8BFB\u6750\u6599",
25043
25083
  parameters: readSchema,
25044
25084
  async execute(toolCallId, params, _signal, _onUpdate, ctx) {
@@ -25068,7 +25108,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25068
25108
  pi.registerTool({
25069
25109
  name: COLLECTOR_REQUEST_TOOL,
25070
25110
  label: "\u901A\u8FDB\u53F8\u8BF7\u6C42",
25071
- description: "\u5728\u6240\u5F15\u6700\u65B0\u5FEB\u7167 HEAD \u53D1\u4E00\u6B21\u8BF7\u6C42\u3002requestId \u53EF\u53D6\u914D\u7F6E\u6E05\u5355\uFF0C\u6216\u89D2\u8272\u4F9D\u624B\u518C/\u73B0\u573A\u5224\u5B9A\u7684\u7A33\u5B9A id\uFF1B\u540E\u8005\u987B\u540C\u65F6\u63D0\u4F9B body\u3002",
25111
+ description: "\u53D1\u4E00\u6B21\u8BF7\u6C42\u3002",
25072
25112
  promptSnippet: "\u53D1\u4E00\u6B21\u8BC4\u5BA1\u8BF7\u6C42",
25073
25113
  parameters: requestSchema,
25074
25114
  async execute(toolCallId, params, signal, _onUpdate, ctx) {
@@ -25187,7 +25227,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25187
25227
  pi.registerTool({
25188
25228
  name: COLLECTOR_WAIT_TOOL,
25189
25229
  label: "\u901A\u8FDB\u53F8\u7B49\u5F85",
25190
- description: "\u518D\u89C2\u5BDF\u524D\u7B49\u5F85\uFF1B\u5B9E\u9645\u7761\u7720\u4E0D\u8D85\u8FC7\u5269\u4F59\u7B49\u5F85\u7A97\u3002",
25230
+ description: "\u7B49\u5F85\u3002\u5B9E\u9645\u7761\u7720\u4E0D\u8D85\u8FC7\u5269\u4F59\u7B49\u5F85\u7A97\u3002",
25191
25231
  promptSnippet: "\u7B49\u5F85\u7A97\u5185\u7B49\u5F85",
25192
25232
  parameters: waitSchema,
25193
25233
  async execute(toolCallId, params, signal, _onUpdate, ctx) {
@@ -25217,7 +25257,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25217
25257
  pi.registerTool({
25218
25258
  name: COLLECTOR_OUTPUT_TOOL,
25219
25259
  label: "\u901A\u8FDB\u53F8\u8F93\u51FA",
25220
- description: "\u89C2\u5BDF\u5B8C\u6210\u540E\u63D0\u4EA4\u539F\u4EA4\u5377\u3002\u6B63\u5E38\u5B8C\u5DE5\u63D0\u4EA4\u7A7A\u5BF9\u8C61 {}\uFF08\u5982\u9700\u62A5 finding\uFF0C\u586B findings \u6307\u9488\u6570\u7EC4\uFF09\uFF1B\u4EC5\u5728\u57FA\u7840\u8BBE\u65BD\u771F\u5B9E\u5931\u8D25\u65F6\u624D\u53EF\u586B infrastructureFailure\uFF0C\u65E0\u5931\u8D25\u65F6\u5FC5\u987B\u7701\u7565\u8BE5\u5B57\u6BB5\u3002",
25260
+ description: "\u63D0\u4EA4\u901A\u8FDB\u53F8\u56DE\u6267\u3002",
25221
25261
  promptSnippet: "\u63D0\u4EA4\u901A\u8FDB\u53F8\u56DE\u6267",
25222
25262
  parameters: outputSchema,
25223
25263
  async execute(toolCallId, params, _signal, _onUpdate, ctx) {
@@ -25482,7 +25522,7 @@ var gleanerLeftOutputSchema = withTerminatingOutputDeclarations(
25482
25522
  openToolObject(
25483
25523
  Type18.Object({
25484
25524
  status: Type18.Unknown({
25485
- description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
25525
+ description: "completed"
25486
25526
  }),
25487
25527
  findings: Type18.Array(
25488
25528
  Type18.Object(
@@ -25533,7 +25573,7 @@ var diaristOutputSchema = withTerminatingOutputDeclarations(
25533
25573
  openToolObject(
25534
25574
  Type19.Object({
25535
25575
  status: Type19.Unknown({
25536
- description: "completed | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
25576
+ description: "completed | escalate"
25537
25577
  }),
25538
25578
  ticketNumber: Type19.Optional(
25539
25579
  Type19.Unknown({
@@ -25619,7 +25659,7 @@ var secretariatVerdictSchema = withTerminatingOutputDeclarations(
25619
25659
  Type20.Object(
25620
25660
  {
25621
25661
  secretariatStatus: Type20.Unknown({
25622
- description: "converged | escalate\uFF08\u7EC8\u5C40\u5F62\u72B6\u6307\u5F15\uFF0C\u975E\u95F8\uFF09"
25662
+ description: "converged | escalate"
25623
25663
  }),
25624
25664
  ticketNumber: Type20.Optional(
25625
25665
  Type20.Number({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
@@ -25643,7 +25683,7 @@ secretariatVerdictSchema.required = [];
25643
25683
  var SECRETARIAT_OUTPUT_TOOL_SPEC = {
25644
25684
  name: SECRETARIAT_OUTPUT_TOOL_NAME,
25645
25685
  label: "\u4E2D\u4E66\u7701\u8F93\u51FA",
25646
- description: "\u4E2D\u4E66\u7701\u7EC8\u5C40\u56DE\u6267\uFF08\u7F72\u6216\u4E0A\u5448\uFF09\uFF1B\u7ED9\u4E8B\u4E2D\u5C01\u9A73\u987B\u6539\u7968\u91CD\u9001\uFF0C\u4E0D\u5728\u6B64\u7EC8\u5C40\u3002",
25686
+ description: "\u4E2D\u4E66\u7701\u7EC8\u5C40\u56DE\u6267\u3002",
25647
25687
  promptSnippet: "\u4E2D\u4E66\u7701\u7EC8\u5C40\u56DE\u6267",
25648
25688
  parameters: secretariatVerdictSchema
25649
25689
  };
@@ -25707,12 +25747,7 @@ init_submission_errors();
25707
25747
  init_audit_escalation();
25708
25748
  init_readable_gate_item();
25709
25749
  init_judge_output();
25710
- var JUDGE_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "continue", "escalate"]);
25711
- var JUDGE_STATUS_REASK = "status \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
25712
25750
  var judgeVerdictSchema = reviewSubmissionSchema;
25713
- function validateVerdict(verdict) {
25714
- return validateAcceptedJudgeDetails(verdict);
25715
- }
25716
25751
  function createJudgeRoleRuntime(pi, dependencies, hostActions) {
25717
25752
  let soul;
25718
25753
  let lifecycleRegistered = false;
@@ -25725,24 +25760,23 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
25725
25760
  pi.registerTool({
25726
25761
  name: JUDGE_OUTPUT_TOOL_NAME,
25727
25762
  label: "\u5927\u7406\u5BFA\u8F93\u51FA",
25728
- description: "\u63D0\u4EA4\u5927\u7406\u5BFA\u7EC8\u5C40\u5224\u8BCD\uFF1B\u53D7\u7406\u524D\u7ECF\u7B26\u5B9D\u90CE\u5185\u95F8\u4E0E\u5BA1\u5211\u9662\u5408\u89C4\u5BA1\u6838\u3002",
25763
+ description: "\u63D0\u4EA4\u5927\u7406\u5BFA\u7EC8\u5C40\u5224\u8BCD\u3002",
25729
25764
  promptSnippet: "\u63D0\u4EA4\u5927\u7406\u5BFA\u7EC8\u5C40\u5224\u8BCD",
25730
25765
  parameters: judgeVerdictSchema,
25731
25766
  async execute(toolCallId, parameters, signal, _onUpdate, ctx) {
25732
25767
  if (soul === void 0) throw new Error("\u5927\u7406\u5BFA\u804C\u5206\u672A\u88C5\u8F7D");
25733
25768
  const rawStatus = parameters !== null && typeof parameters === "object" && !Array.isArray(parameters) && typeof parameters.status === "string" ? parameters.status : void 0;
25734
- if (rawStatus === void 0 || !JUDGE_QUEUE_STATUSES.has(rawStatus)) {
25735
- throw new ParentQueueReaskError(JUDGE_STATUS_REASK);
25769
+ if (rawStatus === void 0 || !REVIEW_QUEUE_STATUSES.has(rawStatus)) {
25770
+ const received = parameters !== null && typeof parameters === "object" && !Array.isArray(parameters) ? parameters.status : void 0;
25771
+ throw new ParentQueueReaskError(unreadableDiscriminatorNotice("status", received));
25736
25772
  }
25737
25773
  if (rawStatus === "escalate") {
25738
- const verdict2 = validateVerdict(parameters);
25739
25774
  return {
25740
25775
  content: [],
25741
- details: verdict2,
25776
+ details: parameters,
25742
25777
  terminate: true
25743
25778
  };
25744
25779
  }
25745
- const verdict = validateVerdict(parameters);
25746
25780
  let draftPass;
25747
25781
  try {
25748
25782
  const obtainedDraftPass = await pi.requireSubmissionGate({
@@ -25758,7 +25792,7 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
25758
25792
  if (draftPass?.status === "continue") {
25759
25793
  return {
25760
25794
  content: [{ type: "text", text: readableGateItem(draftPass.receipt) }],
25761
- details: verdict,
25795
+ details: parameters,
25762
25796
  terminate: false
25763
25797
  };
25764
25798
  }
@@ -25775,18 +25809,18 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
25775
25809
  if (compliancePass?.status === "continue") {
25776
25810
  return {
25777
25811
  content: [draftPass, compliancePass].filter((pass) => pass !== void 0).map((pass) => ({ type: "text", text: readableGateItem(pass.receipt) })),
25778
- details: verdict,
25812
+ details: parameters,
25779
25813
  terminate: false
25780
25814
  };
25781
25815
  }
25782
25816
  return {
25783
25817
  content: [draftPass, compliancePass].filter((pass) => pass !== void 0).map((pass) => ({ type: "text", text: readableGateItem(pass.receipt) })),
25784
- details: verdict,
25818
+ details: parameters,
25785
25819
  terminate: true
25786
25820
  };
25787
25821
  } catch (error) {
25788
25822
  if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
25789
- return projectGatekeeperEscalation(error.result, verdict);
25823
+ return projectGatekeeperEscalation(error.result, parameters);
25790
25824
  }
25791
25825
  throw error;
25792
25826
  }
@@ -25821,9 +25855,9 @@ var reviewerAmendmentsSchema = Type21.Object({
25821
25855
  }))
25822
25856
  }, {
25823
25857
  additionalProperties: true,
25824
- description: "\u5DF2\u8FD0\u884C lens \u7684 amendments \u627F\u8F7D candidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict \u7684\u5B8C\u6574\u62A5\u544A\uFF08\u975E\u4EC5 verdict \u884C\uFF09\uFF1B\u663E\u5F0F\u5355\u8F74\u65F6\u53E6\u4E00\u8F74\u53EF\u7701\u7565\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u5BF9\u5E94 lens \u5B57\u6BB5\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
25858
+ description: "\u5DF2\u8FD0\u884C lens \u7684 amendments \u627F\u8F7D candidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict \u7684\u5B8C\u6574\u62A5\u544A\uFF08\u975E\u4EC5 verdict \u884C\uFF09\uFF1B\u663E\u5F0F\u5355\u8F74\u65F6\u53E6\u4E00\u8F74\u53EF\u7701\u7565\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u5BF9\u5E94 lens \u5B57\u6BB5\u3002"
25825
25859
  });
25826
- var REVIEWER_STATUS_DESCRIPTION = "completed | refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002\u4E24\u79CD\u6B63\u5E38 lens verdict\uFF08completeness / correctness\uFF09\u5747 completed\uFF1Bhard-stop \u4E0E usage error \u4E3A refused\uFF08\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u8FDB\u6240\u9009 lens amendments\uFF09\u3002";
25860
+ var REVIEWER_STATUS_DESCRIPTION = "completed | refused\u3002\u4E24\u79CD\u6B63\u5E38 lens verdict\uFF08completeness / correctness\uFF09\u5747 completed\uFF1Bhard-stop \u4E0E usage error \u4E3A refused\uFF08\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u8FDB\u6240\u9009 lens amendments\uFF09\u3002";
25827
25861
  var reviewerOutputVariants = Type21.Union([
25828
25862
  Type21.Object({
25829
25863
  status: Type21.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
@@ -25852,7 +25886,7 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
25852
25886
  pi.registerTool({
25853
25887
  name: REVIEWER_OUTPUT_TOOL_NAME,
25854
25888
  label: "\u5FA1\u53F2\u53F0\u8F93\u51FA",
25855
- description: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267\u3002\u672C\u5E2D\u81EA\u8C03 ak-cross-m-review skill\u3002",
25889
+ description: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267\u3002",
25856
25890
  promptSnippet: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267",
25857
25891
  parameters: reviewerOutputSchema,
25858
25892
  async execute(_id, parameters) {
@@ -25892,8 +25926,8 @@ init_sitian_facade();
25892
25926
  init_submission_errors();
25893
25927
  init_submission_errors();
25894
25928
  import { execFileSync as execFileSync4 } from "node:child_process";
25895
- import { existsSync as existsSync12, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
25896
- import { resolve as resolve19 } from "node:path";
25929
+ import { existsSync as existsSync14, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
25930
+ import { resolve as resolve20 } from "node:path";
25897
25931
  var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
25898
25932
  var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
25899
25933
  var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
@@ -25923,7 +25957,7 @@ function statusOf(error) {
25923
25957
  return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
25924
25958
  }
25925
25959
  function tryGetAll(file, key) {
25926
- if (!existsSync12(file)) return [];
25960
+ if (!existsSync14(file)) return [];
25927
25961
  try {
25928
25962
  const out = gitFile(file, ["--get-all", key]);
25929
25963
  return out.length === 0 ? [] : out.split("\n");
@@ -25933,7 +25967,7 @@ function tryGetAll(file, key) {
25933
25967
  }
25934
25968
  }
25935
25969
  function ownedHook(path) {
25936
- if (!existsSync12(path)) return false;
25970
+ if (!existsSync14(path)) return false;
25937
25971
  return readFileSync5(path, "utf8").includes(HOOK_MARKER);
25938
25972
  }
25939
25973
  function escapeGitConfigValueRegex(value) {
@@ -25942,7 +25976,7 @@ function escapeGitConfigValueRegex(value) {
25942
25976
  function unsetOwnedHooksPath(file) {
25943
25977
  const owned = [];
25944
25978
  for (const value of tryGetAll(file, "core.hooksPath")) {
25945
- if (!ownedHook(resolve19(value, HOOK_FILE))) continue;
25979
+ if (!ownedHook(resolve20(value, HOOK_FILE))) continue;
25946
25980
  try {
25947
25981
  gitFile(file, [
25948
25982
  "--unset-all",
@@ -25957,15 +25991,15 @@ function unsetOwnedHooksPath(file) {
25957
25991
  return owned;
25958
25992
  }
25959
25993
  function rmOwnedDir(dir) {
25960
- const hookPath = resolve19(dir, HOOK_FILE);
25994
+ const hookPath = resolve20(dir, HOOK_FILE);
25961
25995
  if (!ownedHook(hookPath)) return;
25962
25996
  rmSync(hookPath, { force: true });
25963
- if (existsSync12(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
25997
+ if (existsSync14(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
25964
25998
  }
25965
25999
  function linkedGitDirs(commonDir) {
25966
- const root = resolve19(commonDir, "worktrees");
25967
- if (!existsSync12(root)) return [];
25968
- return readdirSync3(root).map((name) => resolve19(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
26000
+ const root = resolve20(commonDir, "worktrees");
26001
+ if (!existsSync14(root)) return [];
26002
+ return readdirSync3(root).map((name) => resolve20(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
25969
26003
  }
25970
26004
  function uninstallPackageWorkerHooks(cwd) {
25971
26005
  let inside;
@@ -25979,14 +26013,14 @@ function uninstallPackageWorkerHooks(cwd) {
25979
26013
  const clear = (configFile) => {
25980
26014
  for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
25981
26015
  };
25982
- clear(resolve19(commonDir, "config"));
25983
- clear(resolve19(commonDir, "config.worktree"));
25984
- rmOwnedDir(resolve19(commonDir, HOOKS_DIR));
25985
- const legacy = resolve19(commonDir, "hooks", HOOK_FILE);
26016
+ clear(resolve20(commonDir, "config"));
26017
+ clear(resolve20(commonDir, "config.worktree"));
26018
+ rmOwnedDir(resolve20(commonDir, HOOKS_DIR));
26019
+ const legacy = resolve20(commonDir, "hooks", HOOK_FILE);
25986
26020
  if (ownedHook(legacy)) rmSync(legacy, { force: true });
25987
26021
  for (const gitDir of linkedGitDirs(commonDir)) {
25988
- clear(resolve19(gitDir, "config.worktree"));
25989
- rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
26022
+ clear(resolve20(gitDir, "config.worktree"));
26023
+ rmOwnedDir(resolve20(gitDir, HOOKS_DIR));
25990
26024
  }
25991
26025
  }
25992
26026
  function isRecord17(value) {
@@ -26148,7 +26182,7 @@ function fixerBashSeatbeltDenyReason(matched) {
26148
26182
  }
26149
26183
 
26150
26184
  // src/worker-role.ts
26151
- var CODER_STATUS_DESCRIPTION = "planned | completed | refused | partially_completed | unfinished \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1Bcompleted \u56DE\u6267\u542B TDD\u3001\u540C\u6A21\u5F0F\u3001\u5F15\u5165\u56DE\u5F52\u3001\u884C\u4E3A\u4E8B\u5B9E\u56DB\u9879\u8BC1\u636E\uFF1Bunfinished \u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\uFF0C\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002";
26185
+ var CODER_STATUS_DESCRIPTION = "planned | completed | refused | partially_completed | unfinished\u3002unfinished\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u3002";
26152
26186
  var coderOutputVariants = Type22.Union([
26153
26187
  Type22.Object({
26154
26188
  status: Type22.Unknown({ description: CODER_STATUS_DESCRIPTION }),
@@ -26208,14 +26242,13 @@ var WORKER_ROUTING_STATUSES = /* @__PURE__ */ new Set([
26208
26242
  "partially_completed",
26209
26243
  "unfinished"
26210
26244
  ]);
26211
- var WORKER_STATUS_REASK = "status \u4E0D\u662F planned\u3001completed\u3001refused\u3001partially_completed\u3001unfinished \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
26212
26245
  function workerStatusOf(output) {
26213
26246
  return isRecord18(output) && typeof output.status === "string" ? output.status : void 0;
26214
26247
  }
26215
26248
  function requireReadableWorkerStatus(output) {
26216
26249
  const status = workerStatusOf(output);
26217
26250
  if (status === void 0 || !WORKER_ROUTING_STATUSES.has(status)) {
26218
- throw new ParentQueueReaskError(WORKER_STATUS_REASK);
26251
+ throw new ParentQueueReaskError(unreadableDiscriminatorNotice("status", isRecord18(output) ? output.status : void 0));
26219
26252
  }
26220
26253
  return status;
26221
26254
  }
@@ -26292,7 +26325,7 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
26292
26325
  pi.registerTool({
26293
26326
  name: FIXER_OUTPUT_TOOL_NAME,
26294
26327
  label: "\u4FEE\u5185\u53F8\u8F93\u51FA",
26295
- description: "\u63D0\u4EA4\u4FEE\u5185\u53F8\u7EC8\u5C40\u56DE\u6267\uFF1B\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u8D70 abort\uFF0C\u4E0D\u7ECF\u672C\u5DE5\u5177\u3002",
26328
+ description: "\u63D0\u4EA4\u4FEE\u5185\u53F8\u7EC8\u5C40\u56DE\u6267\u3002",
26296
26329
  promptSnippet: "\u63D0\u4EA4\u4FEE\u5185\u53F8\u7EC8\u5C40\u56DE\u6267",
26297
26330
  parameters: fixerOutputSchema,
26298
26331
  async execute(toolCallId, parameters, _signal, _onUpdate, ctx) {
@@ -26419,7 +26452,7 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
26419
26452
  pi.registerTool({
26420
26453
  name: CODER_OUTPUT_TOOL_NAME,
26421
26454
  label: "\u5C06\u4F5C\u76D1\u8F93\u51FA",
26422
- description: "\u63D0\u4EA4\u5C06\u4F5C\u76D1\u7EC8\u5C40\u56DE\u6267\uFF1B\u672C\u5DE5\u5177\u65E0 escalate \u901A\u9053\u3002",
26455
+ description: "\u63D0\u4EA4\u5C06\u4F5C\u76D1\u7EC8\u5C40\u56DE\u6267\u3002",
26423
26456
  promptSnippet: "\u63D0\u4EA4\u5C06\u4F5C\u76D1\u7EC8\u5C40\u56DE\u6267",
26424
26457
  parameters: coderOutputSchema,
26425
26458
  async execute(toolCallId, parameters, _signal, _onUpdate, ctx2) {
@@ -26558,6 +26591,7 @@ ${JSON.stringify(admitted)}
26558
26591
  init_navigator_invocation_identity();
26559
26592
  init_gatekeeper_role();
26560
26593
  init_submission_errors();
26594
+ init_review_submission();
26561
26595
  init_doctor_contracts();
26562
26596
  init_doctor_evidence();
26563
26597
  init_engine_detour();
@@ -26721,25 +26755,6 @@ var ROLE_FLAG = {
26721
26755
  type: "string"
26722
26756
  }
26723
26757
  };
26724
- function formatNavigatorRoleHelp(role) {
26725
- const metadata = packagedRoleMetadata(role);
26726
- const lines = [
26727
- `Usage: ak-role ${role}`,
26728
- ROLE_FLAG.definition.description
26729
- ];
26730
- const inputFlag = packagedRoleInputFlag(role);
26731
- if (inputFlag !== void 0) {
26732
- lines.push(` --${inputFlag} <value> ${role} input material`);
26733
- }
26734
- const phaseFlag = packagedRolePhaseFlag(role);
26735
- if (phaseFlag !== void 0 && metadata !== void 0) {
26736
- lines.push(
26737
- ` --${phaseFlag} <value> ${role} phase: ${metadata.phases.filter((p) => p !== null).join(" | ")}`
26738
- );
26739
- }
26740
- lines.push(`Public next-command form: ak-role ${role}`);
26741
- return lines.join("\n");
26742
- }
26743
26758
  function abortContext(ctx) {
26744
26759
  ctx.abort();
26745
26760
  }
@@ -26900,7 +26915,7 @@ function createGatekeeperRoleRuntime(roleHost, dependencies) {
26900
26915
  );
26901
26916
  }
26902
26917
  function createNavigatorRoleRuntime(roleHost, dependencies) {
26903
- return createFiledOfficerRuntime(
26918
+ const base = createFiledOfficerRuntime(
26904
26919
  roleHost,
26905
26920
  {
26906
26921
  role: "navigator",
@@ -26909,6 +26924,42 @@ function createNavigatorRoleRuntime(roleHost, dependencies) {
26909
26924
  },
26910
26925
  dependencies
26911
26926
  );
26927
+ let playbookBound = false;
26928
+ return {
26929
+ async activate() {
26930
+ await base.activate();
26931
+ if (playbookBound) return;
26932
+ playbookBound = true;
26933
+ const loadRoutePlaybook = dependencies.loadRoutePlaybook ?? (() => readPackageMaterial("resources/navigator-route-playbook.md"));
26934
+ let playbookRead;
26935
+ roleHost.on("before_agent_start", async (event) => {
26936
+ const basePrompt = typeof event.systemPrompt === "string" ? event.systemPrompt : "";
26937
+ const parts = [];
26938
+ try {
26939
+ playbookRead ??= loadRoutePlaybook();
26940
+ const content = await playbookRead;
26941
+ dependencies.recordRoutePlaybookReadFailure?.(void 0);
26942
+ if (content.trim() !== "") parts.push(content);
26943
+ } catch (error) {
26944
+ const message = error instanceof Error ? error.message : String(error);
26945
+ if (message.trim() !== "") {
26946
+ dependencies.recordRoutePlaybookReadFailure?.(message);
26947
+ parts.push(message);
26948
+ }
26949
+ }
26950
+ const prompt = typeof event.prompt === "string" ? event.prompt : "";
26951
+ const work = await loadNavigatorWorkBaseSuffix(prompt);
26952
+ if (work !== void 0 && work.trim() !== "") parts.push(work);
26953
+ if (parts.length === 0) return;
26954
+ const text = parts.join("\n\n");
26955
+ return {
26956
+ systemPrompt: basePrompt.trim() === "" ? text : `${basePrompt}
26957
+
26958
+ ${text}`
26959
+ };
26960
+ });
26961
+ }
26962
+ };
26912
26963
  }
26913
26964
  function createAuditorRoleRuntime(roleHost, dependencies) {
26914
26965
  const base = createFiledOfficerRuntime(
@@ -26952,7 +27003,7 @@ function readDiaristTicketAssertion(submitted) {
26952
27003
  function readRoleRunCoordinates(ctx, label) {
26953
27004
  const runDirectory = runDirectoryFromHostContext(ctx);
26954
27005
  if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
26955
- const admittedPath = join43(runDirectory, "admitted-request.json");
27006
+ const admittedPath = join44(runDirectory, "admitted-request.json");
26956
27007
  const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
26957
27008
  if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
26958
27009
  throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
@@ -26976,7 +27027,6 @@ function readDiaristRunCoordinates(ctx) {
26976
27027
  }
26977
27028
  var DIARIST_BOUNDS_REASK = "\u8FB9\u754C\u65E0\u6CD5\u4F7F\u7528\u3002\u8BF7\u91CD\u4EA4 sessions\uFF1A\u6BCF\u5377 path + ranges\uFF0C\u6BCF\u7AEF\u4EE5\u539F\u751F id \u6216\u672C\u8F6E\u884C\u53F7\u4E8C\u9009\u4E00\u6307\u540D\u3002";
26978
27029
  var DIARIST_ROUTING_STATUSES = /* @__PURE__ */ new Set(["completed", "escalate"]);
26979
- var DIARIST_STATUS_REASK = "status \u4E0D\u662F completed\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
26980
27030
  function createDiaristRoleRuntime(roleHost, dependencies) {
26981
27031
  return createFiledOfficerRuntime(
26982
27032
  roleHost,
@@ -26988,7 +27038,7 @@ function createDiaristRoleRuntime(roleHost, dependencies) {
26988
27038
  const submitted = parameters !== null && typeof parameters === "object" && !Array.isArray(parameters) ? parameters : void 0;
26989
27039
  const status = submitted?.status;
26990
27040
  if (typeof status !== "string" || !DIARIST_ROUTING_STATUSES.has(status)) {
26991
- throw new ParentQueueReaskError(DIARIST_STATUS_REASK);
27041
+ throw new ParentQueueReaskError(unreadableDiscriminatorNotice("status", submitted?.status));
26992
27042
  }
26993
27043
  if (status === "escalate") return parameters;
26994
27044
  const assertion = readDiaristTicketAssertion(submitted);
@@ -27028,10 +27078,7 @@ ${error.message}`
27028
27078
  dependencies
27029
27079
  );
27030
27080
  }
27031
- var COUNTERSIGN_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "continue", "escalate"]);
27032
- var COUNTERSIGN_STATUS_REASK = "status \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
27033
27081
  var SECRETARIAT_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "escalate"]);
27034
- var SECRETARIAT_STATUS_REASK = "secretariatStatus \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
27035
27082
  function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
27036
27083
  const beforeAccept = hostActions !== void 0 ? async ({ toolCallId, parameters, signal, ctx }) => {
27037
27084
  if (roleHost.requireSubmissionGate === void 0) {
@@ -27042,7 +27089,9 @@ function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
27042
27089
  const record4 = parameters !== null && typeof parameters === "object" && !Array.isArray(parameters) ? parameters : void 0;
27043
27090
  const status = record4 !== void 0 && typeof record4.secretariatStatus === "string" ? record4.secretariatStatus : void 0;
27044
27091
  if (status === void 0 || !SECRETARIAT_QUEUE_STATUSES.has(status)) {
27045
- throw new ParentQueueReaskError(SECRETARIAT_STATUS_REASK);
27092
+ throw new ParentQueueReaskError(
27093
+ unreadableDiscriminatorNotice("secretariatStatus", record4?.secretariatStatus)
27094
+ );
27046
27095
  }
27047
27096
  if (status === "escalate") {
27048
27097
  return void 0;
@@ -27136,8 +27185,8 @@ function createCountersignRoleRuntime(roleHost, dependencies, hostActions) {
27136
27185
  const beforeAccept = hostActions !== void 0 ? async ({ toolCallId, parameters, signal, ctx }) => {
27137
27186
  const record4 = parameters !== null && typeof parameters === "object" && !Array.isArray(parameters) ? parameters : void 0;
27138
27187
  const status = record4 !== void 0 && typeof record4.status === "string" ? record4.status : void 0;
27139
- if (status === void 0 || !COUNTERSIGN_QUEUE_STATUSES.has(status)) {
27140
- throw new ParentQueueReaskError(COUNTERSIGN_STATUS_REASK);
27188
+ if (status === void 0 || !REVIEW_QUEUE_STATUSES.has(status)) {
27189
+ throw new ParentQueueReaskError(unreadableDiscriminatorNotice("status", record4?.status));
27141
27190
  }
27142
27191
  if (status === "escalate") {
27143
27192
  return void 0;
@@ -27294,13 +27343,11 @@ function createRoleRuntimeExtension(dependencies) {
27294
27343
  const raced = await raceNavigatorGrace(settlePromise, NAVIGATOR_POST_ROLE_GRACE_MS);
27295
27344
  if (raced.status !== "timeout") return;
27296
27345
  if (pendingNavigatorPresentation === void 0) {
27297
- const routePlaybookReadFailure = attendance.knownRoutePlaybookReadFailure?.();
27298
27346
  const report = {
27299
27347
  disposition: "unavailable",
27300
27348
  unavailableReason: "Navigator exceeded post-role delivery grace",
27301
27349
  unavailableSource: "unknown",
27302
- unavailableCause: "unknown",
27303
- ...routePlaybookReadFailure === void 0 ? {} : { routePlaybookReadFailure }
27350
+ unavailableCause: "unknown"
27304
27351
  };
27305
27352
  const event = {
27306
27353
  version: 1,
@@ -27311,8 +27358,7 @@ function createRoleRuntimeExtension(dependencies) {
27311
27358
  subjectKey: workContext?.subjectKey ?? "",
27312
27359
  unavailableReason: "Navigator exceeded post-role delivery grace",
27313
27360
  unavailableSource: "unknown",
27314
- unavailableCause: "unknown",
27315
- ...routePlaybookReadFailure === void 0 ? {} : { routePlaybookReadFailure }
27361
+ unavailableCause: "unknown"
27316
27362
  };
27317
27363
  pendingNavigatorPresentation = { event, report };
27318
27364
  }
@@ -27523,7 +27569,7 @@ function createRoleRuntimeExtension(dependencies) {
27523
27569
  }
27524
27570
  envelopeHost.sendMessage({
27525
27571
  customType: "ak-receipt-delivery-prompt",
27526
- content: RECEIPT_DELIVERY_PROMPT,
27572
+ content: JSON.stringify(receiptDelivery.deliveryState()),
27527
27573
  display: false
27528
27574
  }, { triggerTurn: true, deliverAs: "followUp" });
27529
27575
  } else if (receiptDelivery.nextAction() === "no-receipt" && !noReceiptRecorded) {
@@ -27687,7 +27733,12 @@ function createRoleRuntimeExtension(dependencies) {
27687
27733
  loadSoul: () => requireRoleSoul("gatekeeper")
27688
27734
  });
27689
27735
  const navigator = createNavigatorRoleRuntime(roleHost, {
27690
- loadSoul: () => requireRoleSoul("navigator")
27736
+ loadSoul: () => requireRoleSoul("navigator"),
27737
+ recordRoutePlaybookReadFailure: (message) => {
27738
+ envelopeHost.appendEntry(NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY, {
27739
+ message: message ?? ""
27740
+ });
27741
+ }
27691
27742
  });
27692
27743
  const auditor = createAuditorRoleRuntime(roleHost, {
27693
27744
  loadSoul: () => requireRoleSoul("auditor")
@@ -27994,7 +28045,6 @@ function createRoleRuntimeExtension(dependencies) {
27994
28045
  pendingNavigatorPresentation = { event: navigatorEvent, report };
27995
28046
  }
27996
28047
  });
27997
- navigatorAttendance.warmHelp?.();
27998
28048
  if (navigatorWorkContext.contextError === void 0 && navigatorWorkContext.subjectProvenance !== "placeholder") {
27999
28049
  navigatorAttendance.prepare();
28000
28050
  }
@@ -28036,21 +28086,20 @@ function loadRegisteredRoleSoul(role) {
28036
28086
  return usesSubjectSoul(role) ? loadAuditorSoulFromSubjectInput() : loadMainRoleSessionMaterials(role);
28037
28087
  }
28038
28088
  function createRoleRuntimeDependencies(packageRoot) {
28039
- const navigatorRoutePlaybookPath = join44(packageRoot, "resources/navigator-route-playbook.md");
28040
- const collectorHandbookSeedPath = join44(packageRoot, "resources/collector-bot-handbook.md");
28089
+ const collectorHandbookSeedPath = join45(packageRoot, "resources/collector-bot-handbook.md");
28041
28090
  const doctorAuditor = createPiDoctorAuditor();
28042
28091
  const navigatorSessionFactory = createNativeNavigatorSessionFactory();
28043
28092
  return {
28044
28093
  packageRoot,
28045
28094
  loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
28046
28095
  loadRoleSoul: loadRegisteredRoleSoul,
28047
- loadFixPacket: (path) => readFile24(path, "utf8"),
28048
- loadCoderTask: (path) => readFile24(path, "utf8"),
28049
- loadCollectorHandbookSeed: () => readFile24(collectorHandbookSeedPath, "utf8"),
28096
+ loadFixPacket: (path) => readFile25(path, "utf8"),
28097
+ loadCoderTask: (path) => readFile25(path, "utf8"),
28098
+ loadCollectorHandbookSeed: () => readFile25(collectorHandbookSeedPath, "utf8"),
28050
28099
  createCollectorTransport: () => createGhCollectorGitHubTransport(),
28051
28100
  loadDoctorCase,
28052
28101
  loadNotarySourceRun: loadNotarySourceRunLocator,
28053
- loadMergerInput: async (path) => JSON.parse(await readFile24(path, "utf8")),
28102
+ loadMergerInput: async (path) => JSON.parse(await readFile25(path, "utf8")),
28054
28103
  // #590: doctor compliance still on disposeCompliance path; judge→auditor is gate queue (#756).
28055
28104
  auditDoctorCompliance: (options) => doctorAuditor(options),
28056
28105
  loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
@@ -28066,9 +28115,6 @@ function createRoleRuntimeDependencies(packageRoot) {
28066
28115
  subject: options.subject,
28067
28116
  authority: options.authority,
28068
28117
  invocationId: options.invocationId,
28069
- loadSoul: () => loadRegisteredRoleSoul("navigator"),
28070
- loadRoutePlaybook: () => readFile24(navigatorRoutePlaybookPath, "utf8"),
28071
- loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
28072
28118
  createSession: navigatorSessionFactory,
28073
28119
  ...options.contextError === void 0 ? {} : { contextError: options.contextError },
28074
28120
  onEvent: options.onEvent
@@ -28081,7 +28127,7 @@ init_engine_detour();
28081
28127
  import { randomUUID as randomUUID9 } from "node:crypto";
28082
28128
  import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile11 } from "node:fs/promises";
28083
28129
  import { createServer } from "node:net";
28084
- import { dirname as dirname22, join as join45 } from "node:path";
28130
+ import { dirname as dirname23, join as join46 } from "node:path";
28085
28131
  import { fileURLToPath as fileURLToPath2 } from "node:url";
28086
28132
 
28087
28133
  // src/submission-gate.ts
@@ -28167,7 +28213,7 @@ async function requireSubmissionGate(options) {
28167
28213
  };
28168
28214
  }
28169
28215
  if (gatekeeper.status === "needs_reask") {
28170
- reask = officerConclusionReask(projected.officer);
28216
+ reask = officerConclusionReask(gatekeeper.receivedStatus);
28171
28217
  continue;
28172
28218
  }
28173
28219
  if (gatekeeper.status === "transport_failure") {
@@ -28192,11 +28238,11 @@ init_submission_correctable_error();
28192
28238
  init_navigator_invocation_identity();
28193
28239
  init_serialize_thrown_value();
28194
28240
  async function listen(server, path) {
28195
- await new Promise((resolve21, reject) => {
28241
+ await new Promise((resolve22, reject) => {
28196
28242
  server.once("error", reject);
28197
28243
  server.listen(path, () => {
28198
28244
  server.off("error", reject);
28199
- resolve21();
28245
+ resolve22();
28200
28246
  });
28201
28247
  });
28202
28248
  }
@@ -28231,8 +28277,8 @@ async function prepareRoleEnvelope(options) {
28231
28277
  const hostAbort = new AbortController();
28232
28278
  const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
28233
28279
  await mkdir5(request.runDirectory, { recursive: true });
28234
- let sessionFile = options.sessionFile ?? join45(request.runDirectory, "session", "session.jsonl");
28235
- await mkdir5(dirname22(sessionFile), { recursive: true });
28280
+ let sessionFile = options.sessionFile ?? join46(request.runDirectory, "session", "session.jsonl");
28281
+ await mkdir5(dirname23(sessionFile), { recursive: true });
28236
28282
  if (request.continuation.kind !== "resume") {
28237
28283
  try {
28238
28284
  await writeFile11(
@@ -28282,7 +28328,7 @@ async function prepareRoleEnvelope(options) {
28282
28328
  getLeafEntry: () => sessionEntries.at(-1),
28283
28329
  getLeafId: () => runId,
28284
28330
  getEntries: () => sessionEntries,
28285
- getSessionDir: () => dirname22(sessionFile),
28331
+ getSessionDir: () => dirname23(sessionFile),
28286
28332
  getSessionFile: () => sessionFile,
28287
28333
  getHeader: () => ({ type: "session", id: runId }),
28288
28334
  setSessionFile(path) {
@@ -28640,8 +28686,8 @@ async function prepareRoleEnvelope(options) {
28640
28686
  try {
28641
28687
  const closeAll = server.closeAllConnections;
28642
28688
  if (typeof closeAll === "function") closeAll.call(server);
28643
- await new Promise((resolve21, reject) => {
28644
- server.close((error) => error ? reject(error) : resolve21());
28689
+ await new Promise((resolve22, reject) => {
28690
+ server.close((error) => error ? reject(error) : resolve22());
28645
28691
  });
28646
28692
  } catch (error) {
28647
28693
  cleanupFailures.push(error);
@@ -28773,7 +28819,7 @@ async function prepareRoleEnvelope(options) {
28773
28819
  init_session_identity();
28774
28820
 
28775
28821
  // src/headless-host/description.ts
28776
- import { join as join46 } from "node:path";
28822
+ import { join as join47 } from "node:path";
28777
28823
  function isClaudePrintDescription(description) {
28778
28824
  return description.protocol === "claude-print";
28779
28825
  }
@@ -28781,7 +28827,7 @@ function isCodexExecDescription(description) {
28781
28827
  return description.protocol === "codex-exec";
28782
28828
  }
28783
28829
  function resolveHeadlessBinary(description, operatorHome) {
28784
- return join46(operatorHome, ...description.binaryFromHome);
28830
+ return join47(operatorHome, ...description.binaryFromHome);
28785
28831
  }
28786
28832
  function headlessTurnArgs(options) {
28787
28833
  const { description } = options;
@@ -29043,9 +29089,9 @@ function headlessMcpConfigDocument(mcpServers) {
29043
29089
  // src/headless-host/role-turn-host.ts
29044
29090
  import { spawn as spawn4, spawnSync as spawnSync2 } from "node:child_process";
29045
29091
  import { randomUUID as randomUUID10 } from "node:crypto";
29046
- import { existsSync as existsSync13 } from "node:fs";
29092
+ import { existsSync as existsSync15 } from "node:fs";
29047
29093
  import { writeFile as writeFile12 } from "node:fs/promises";
29048
- import { dirname as dirname23, isAbsolute as isAbsolute12, join as join47, resolve as resolve20 } from "node:path";
29094
+ import { dirname as dirname24, isAbsolute as isAbsolute12, join as join48, resolve as resolve21 } from "node:path";
29049
29095
 
29050
29096
  // src/external-host-turn-loop.ts
29051
29097
  init_packaged_role_registry();
@@ -29265,8 +29311,8 @@ function formatCodexFailurePayload(payload) {
29265
29311
  function cwdIsGitWorkTree(cwd) {
29266
29312
  let dir = cwd;
29267
29313
  for (; ; ) {
29268
- if (existsSync13(join47(dir, ".git"))) return true;
29269
- const parent = dirname23(dir);
29314
+ if (existsSync15(join48(dir, ".git"))) return true;
29315
+ const parent = dirname24(dir);
29270
29316
  if (parent === dir) return false;
29271
29317
  dir = parent;
29272
29318
  }
@@ -29294,10 +29340,10 @@ function resolveGitCommonDir(cwd) {
29294
29340
  if (raw === "") {
29295
29341
  throw new Error("git rev-parse --git-common-dir returned empty stdout");
29296
29342
  }
29297
- return isAbsolute12(raw) ? raw : resolve20(cwd, raw);
29343
+ return isAbsolute12(raw) ? raw : resolve21(cwd, raw);
29298
29344
  }
29299
29345
  function spawnHeadlessTurn(options) {
29300
- return new Promise((resolve21, reject) => {
29346
+ return new Promise((resolve22, reject) => {
29301
29347
  if (options.signal?.aborted) {
29302
29348
  reject(hostAbortedError("headless host aborted"));
29303
29349
  return;
@@ -29372,7 +29418,7 @@ function spawnHeadlessTurn(options) {
29372
29418
  reject(stdinDeliveryError);
29373
29419
  return;
29374
29420
  }
29375
- resolve21({ code, stdout: resultStdout, stderr, timedOut });
29421
+ resolve22({ code, stdout: resultStdout, stderr, timedOut });
29376
29422
  };
29377
29423
  const onAbort = () => {
29378
29424
  child.kill("SIGTERM");
@@ -29473,13 +29519,13 @@ function createHeadlessRoleTurnHost(config) {
29473
29519
  await config.sessionIdentity.bind(request.principal, sessionId);
29474
29520
  }
29475
29521
  const env = { ...process.env, ...config.env ?? {} };
29476
- const systemPromptPath = join47(request.runDirectory, "headless-system-prompt.txt");
29522
+ const systemPromptPath = join48(request.runDirectory, "headless-system-prompt.txt");
29477
29523
  await writeFile12(systemPromptPath, systemPrompt, "utf8");
29478
29524
  let mcpConfigPath;
29479
29525
  let outputSchemaPath;
29480
29526
  if (codex) {
29481
29527
  if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
29482
- outputSchemaPath = join47(request.runDirectory, "headless-output-schema.json");
29528
+ outputSchemaPath = join48(request.runDirectory, "headless-output-schema.json");
29483
29529
  await writeFile12(
29484
29530
  outputSchemaPath,
29485
29531
  `${JSON.stringify(closeJsonSchemaForCodex(prepared.jsonSchema), null, 2)}
@@ -29488,7 +29534,7 @@ function createHeadlessRoleTurnHost(config) {
29488
29534
  );
29489
29535
  }
29490
29536
  } else {
29491
- mcpConfigPath = join47(request.runDirectory, "headless-mcp-config.json");
29537
+ mcpConfigPath = join48(request.runDirectory, "headless-mcp-config.json");
29492
29538
  await writeFile12(
29493
29539
  mcpConfigPath,
29494
29540
  `${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}