@akagilnc/pi-workflow-roles 0.1.5079 → 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 (64) hide show
  1. package/dist/acp-host/production-host.js +348 -301
  2. package/dist/atomic-write.js +13 -19
  3. package/dist/auditor-soul.js +2 -1
  4. package/dist/doctor-contracts.js +1 -1
  5. package/dist/gatekeeper-role.js +2 -16
  6. package/dist/headless-host/production-host.js +380 -333
  7. package/dist/merger-contracts.js +1 -1
  8. package/dist/migrate-book-topology.js +18 -14
  9. package/dist/navigator-attendance.js +28 -143
  10. package/dist/navigator-invocation-identity.js +2 -0
  11. package/dist/navigator-public-session.js +13 -1
  12. package/dist/navigator-work-base.js +113 -0
  13. package/dist/notary-contracts.js +0 -2
  14. package/dist/package-contracts/fixer-output.js +1 -1
  15. package/dist/package-contracts/gatekeeper-output.js +1 -1
  16. package/dist/package-contracts/navigator-output.js +1 -1
  17. package/dist/package-contracts/terminating-infrastructure.js +3 -3
  18. package/dist/packaged-role-registry.js +9 -5
  19. package/dist/public-cli/countersign-run.js +1 -1
  20. package/dist/public-cli/invocation.js +6 -3
  21. package/dist/public-cli/main.js +46 -22
  22. package/dist/public-cli/settlement.js +20 -1
  23. package/dist/receipt-delivery-policy.js +9 -2
  24. package/dist/review-submission.js +3 -3
  25. package/docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md +9 -0
  26. package/extensions/role-runtime.ts +0 -27
  27. package/package.json +2 -1
  28. package/resources/836-deleted-machine-instruction-inventory.md +3 -3
  29. package/resources/collector-bot-handbook.md +4 -0
  30. package/resources/navigator-route-playbook.md +4 -6
  31. package/scripts/build-package.mjs +4 -0
  32. package/souls/coder-output-guide.md +1 -0
  33. package/src/auditor-soul.ts +2 -1
  34. package/src/collector-role.ts +6 -7
  35. package/src/collector-tool-schemas.ts +5 -5
  36. package/src/diarist-role.ts +2 -2
  37. package/src/doctor-contracts.ts +1 -1
  38. package/src/gatekeeper-role.ts +1 -18
  39. package/src/gleaner-left-role.ts +2 -2
  40. package/src/inspector-role.ts +1 -1
  41. package/src/judge-role.ts +1 -1
  42. package/src/merger-contracts.ts +1 -1
  43. package/src/navigator-attendance.ts +38 -164
  44. package/src/navigator-invocation-identity.ts +2 -0
  45. package/src/navigator-public-session.ts +17 -1
  46. package/src/navigator-role.ts +4 -0
  47. package/src/navigator-session-contracts.ts +2 -0
  48. package/src/navigator-work-base.ts +123 -0
  49. package/src/notary-contracts.ts +0 -4
  50. package/src/package-contracts/fixer-output.ts +1 -1
  51. package/src/package-contracts/gatekeeper-output.ts +3 -3
  52. package/src/package-contracts/navigator-output.ts +1 -1
  53. package/src/package-contracts/terminating-infrastructure.ts +3 -6
  54. package/src/packaged-role-registry.ts +5 -1
  55. package/src/public-cli/countersign-run.ts +1 -1
  56. package/src/public-cli/invocation.ts +6 -3
  57. package/src/public-cli/settlement.ts +21 -0
  58. package/src/receipt-delivery-policy.ts +9 -1
  59. package/src/review-submission.ts +3 -3
  60. package/src/reviewer-role.ts +3 -3
  61. package/src/role-runtime-dependencies.ts +1 -5
  62. package/src/role-runtime.ts +52 -38
  63. package/src/secretariat-role.ts +3 -3
  64. package/src/worker-role.ts +3 -3
@@ -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"));
@@ -2507,7 +2507,7 @@ function withTerminatingOutputDeclarations(schema) {
2507
2507
  ...baseProperties ?? {},
2508
2508
  ...baseProperties?.ticketNumber === void 0 ? {
2509
2509
  ticketNumber: Type3.Unknown({
2510
- 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"
2511
2511
  })
2512
2512
  } : {},
2513
2513
  [INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: infrastructureFailureDeclarationSchema.properties[INFRASTRUCTURE_FAILURE_DECLARATION_KEY]
@@ -2564,12 +2564,12 @@ var init_terminating_infrastructure = __esm({
2564
2564
  infrastructureFailureNested = Type3.Object(
2565
2565
  {
2566
2566
  [INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY]: Type3.Unknown({
2567
- 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"
2568
2568
  })
2569
2569
  },
2570
2570
  {
2571
2571
  additionalProperties: true,
2572
- 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"
2573
2573
  }
2574
2574
  );
2575
2575
  infrastructureFailureNested.required = [];
@@ -2594,7 +2594,7 @@ var init_gatekeeper_output = __esm({
2594
2594
  gatekeeperDecisionSchema = openToolObject(
2595
2595
  Type4.Object({
2596
2596
  status: Type4.Unknown({
2597
- description: "dispatch | pass \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
2597
+ description: "dispatch | pass"
2598
2598
  }),
2599
2599
  officer: Type4.Unknown({
2600
2600
  description: "status \u4E3A dispatch \u65F6\u4E3A inspector | notary"
@@ -2663,7 +2663,7 @@ var init_navigator_output = __esm({
2663
2663
  openToolObject(
2664
2664
  Type5.Object({
2665
2665
  prose: Type5.Unknown({
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\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"
2667
2667
  })
2668
2668
  })
2669
2669
  )
@@ -2690,7 +2690,7 @@ var init_review_submission = __esm({
2690
2690
  Type6.Literal(REVIEW_QUEUE_WORDS[2])
2691
2691
  ],
2692
2692
  {
2693
- description: "\u5BA1\u6838\u961F\u5217\u4E09\u6001\u679A\u4E3E\uFF0C\u5FC5\u586B\u3002\u5BA1\u6838\u5E2D\u4ECD\u80FD\u4EA4\u5377\u800C\u5B8C\u6210\u5BA1\u6838\u6240\u9700\u7684\u5916\u90E8\u4F9D\u8D56\u53D1\u751F\u771F\u5B9E\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u65F6\uFF0Cstatus \u53D6 escalate\uFF0C\u7EC6\u8282\u5199\u5165 infrastructureFailure\u3002\u4E0D\u5F97\u7701\u7565 status\uFF0C\u4E0D\u5F97\u7528\u53E6\u4E24\u4E2A\u679A\u4E3E\u503C\u5145\u5F53\u653E\u884C\u6216\u5C01\u9A73\u3002\u5305\u4FA7\u4E0D\u56E0\u683C\u5F0F\u62D2\u6536\u3002"
2693
+ description: "\u5BA1\u6838\u5E2D\u672C\u8F6E\u88C1\u51B3\u7684\u5224\u522B\u72B6\u6001\u3002"
2694
2694
  }
2695
2695
  ),
2696
2696
  findings: Type6.Optional(Type6.Unknown({ description: "\u5BA1\u6838\u53D1\u73B0\uFF0C\u539F\u6837\u7559\u5B58" })),
@@ -2763,7 +2763,7 @@ var init_fixer_output = __esm({
2763
2763
  });
2764
2764
  classResultSchema = Type7.Union([completedClassResultSchema, refusedClassResultSchema]);
2765
2765
  completedClassResultsSchema = Type7.Array(completedClassResultSchema);
2766
- 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";
2767
2767
  fixerOutputVariants = Type7.Union([
2768
2768
  Type7.Object({ status: Type7.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type7.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }),
2769
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" }) }),
@@ -2923,7 +2923,7 @@ var init_doctor_contracts = __esm({
2923
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 })
2924
2924
  ]);
2925
2925
  caseIdentity = Type9.Object({ issueNumber: Type9.Optional(Type9.Integer()), runsPath: nonblank }, { additionalProperties: true });
2926
- 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";
2927
2927
  doctorSubmissionVariants = Type9.Union([
2928
2928
  Type9.Object({
2929
2929
  status: Type9.Unknown({ description: DOCTOR_STATUS_DESCRIPTION }),
@@ -3049,7 +3049,7 @@ var init_merger_contracts = __esm({
3049
3049
  resolutionScope: Type10.Array(Type10.String(), { description: "\u6750\u6599\uFF1A\u89E3\u6790\u8303\u56F4\u63D0\u793A\uFF1B\u53EF\u7A7A" }),
3050
3050
  authorizedChecks: Type10.Array(checkSchema)
3051
3051
  }, { additionalProperties: false });
3052
- MERGER_STATUS_DESCRIPTION = "completed | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8";
3052
+ MERGER_STATUS_DESCRIPTION = "completed | escalate";
3053
3053
  mergerOutputVariants = Type10.Union([
3054
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 }),
3055
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 })
@@ -3070,7 +3070,7 @@ var init_merger_contracts = __esm({
3070
3070
  });
3071
3071
 
3072
3072
  // src/notary-contracts.ts
3073
- 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;
3074
3074
  var init_notary_contracts = __esm({
3075
3075
  "src/notary-contracts.ts"() {
3076
3076
  "use strict";
@@ -3090,7 +3090,6 @@ var init_notary_contracts = __esm({
3090
3090
  type: "string"
3091
3091
  }
3092
3092
  };
3093
- NOTARY_FIXED_KICKOFF = "\u7B26\u5B9D\u90CE\u6848\u5377\u5DF2\u53D7\u7406\uFF1B\u6765\u6E90 run \u5B9A\u4F4D\u89C1\u4F1A\u8BDD\u6750\u6599\u3002";
3094
3093
  notaryOutputSchema = reviewSubmissionSchema;
3095
3094
  }
3096
3095
  });
@@ -3587,21 +3586,24 @@ var init_packaged_role_registry = __esm({
3587
3586
  "souls/notary.md",
3588
3587
  "souls/audit-law.md",
3589
3588
  "souls/ticket-law.md",
3590
- "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"
3591
3591
  ];
3592
3592
  INSPECTOR_SESSION_MATERIALS = [
3593
3593
  "CLAUDE.md",
3594
3594
  "souls/inspector.md",
3595
3595
  "souls/audit-law.md",
3596
3596
  "souls/quality-law.md",
3597
- "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"
3598
3599
  ];
3599
3600
  AUDITOR_PUBLIC_SESSION_MATERIALS = [
3600
3601
  "CLAUDE.md",
3601
3602
  "souls/judge-auditor.md",
3602
3603
  "souls/doctor-auditor.md",
3603
3604
  "souls/audit-law.md",
3604
- "souls/quality-law.md"
3605
+ "souls/quality-law.md",
3606
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
3605
3607
  ];
3606
3608
  PUBLIC_ROLE_RECORDS = [
3607
3609
  {
@@ -3629,7 +3631,8 @@ var init_packaged_role_registry = __esm({
3629
3631
  "souls/judge.md",
3630
3632
  "souls/audit-law.md",
3631
3633
  "souls/quality-law.md",
3632
- "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"
3633
3636
  ]
3634
3637
  },
3635
3638
  {
@@ -3907,7 +3910,7 @@ var init_packaged_role_registry = __esm({
3907
3910
  activationStage: "load-and-install",
3908
3911
  receiptStatusKey: "status",
3909
3912
  // #924: 公用《票面法》三席同装
3910
- 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"]
3911
3914
  },
3912
3915
  {
3913
3916
  role: "secretariat",
@@ -4443,7 +4446,7 @@ var init_gatekeeper_role = __esm({
4443
4446
  GATEKEEPER_TOOL_SPEC = {
4444
4447
  name: GATEKEEPER_OUTPUT_TOOL_NAME,
4445
4448
  label: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
4446
- 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",
4447
4450
  promptSnippet: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
4448
4451
  parameters: gatekeeperOutputSchema
4449
4452
  };
@@ -4567,10 +4570,10 @@ __export(session_assistant_usage_exports, {
4567
4570
  });
4568
4571
  import { join as join6 } from "node:path";
4569
4572
  async function readAssistantUsageFromSessionFile(sessionFile) {
4570
- const { readFile: readFile25 } = await import("node:fs/promises");
4573
+ const { readFile: readFile26 } = await import("node:fs/promises");
4571
4574
  let text;
4572
4575
  try {
4573
- text = await readFile25(sessionFile, "utf8");
4576
+ text = await readFile26(sessionFile, "utf8");
4574
4577
  } catch (error) {
4575
4578
  if (error?.code === "ENOENT") return void 0;
4576
4579
  throw error;
@@ -4969,7 +4972,7 @@ async function spawnEngineDetourOnce(input) {
4969
4972
  }
4970
4973
  const command = input.argv[0];
4971
4974
  const args = input.argv.slice(1);
4972
- return await new Promise((resolve21, reject) => {
4975
+ return await new Promise((resolve22, reject) => {
4973
4976
  let settled = false;
4974
4977
  const signal = input.signal;
4975
4978
  const child = spawn2(command, args, {
@@ -4999,7 +5002,7 @@ async function spawnEngineDetourOnce(input) {
4999
5002
  if (signal !== void 0) {
5000
5003
  signal.removeEventListener("abort", onAbort);
5001
5004
  }
5002
- resolve21(result);
5005
+ resolve22(result);
5003
5006
  };
5004
5007
  const onAbort = () => {
5005
5008
  fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
@@ -11259,13 +11262,16 @@ function admittedTransportPromptKind(admitted) {
11259
11262
  function buildInstructionTransportPrompt(admitted, engineMaterial) {
11260
11263
  const kind = admittedTransportPromptKind(admitted);
11261
11264
  if (kind === "fixed-kickoff") {
11262
- 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");
11263
11269
  }
11264
11270
  if (kind === "baseline") {
11265
11271
  if (admitted.baseRevision === void 0) {
11266
11272
  throw new Error("baseline transport prompt is missing the bound revision");
11267
11273
  }
11268
- const lines2 = [`\u5DE6\u62FE\u9057\u6848\u5DF2\u53D7\u7406\u3002\u6BD4\u8F83\u57FA\u7EBF\uFF1A${admitted.baseRevision}`];
11274
+ const lines2 = [admitted.baseRevision];
11269
11275
  if (!admitted.instructionEmpty) {
11270
11276
  lines2.push("", admitted.instruction);
11271
11277
  }
@@ -12846,10 +12852,10 @@ function pairGateRounds(volumes) {
12846
12852
  return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
12847
12853
  }
12848
12854
  async function resolveOfficerSessionFromPointerFile(pointerPath) {
12849
- const { readFile: readFile25 } = await import("node:fs/promises");
12855
+ const { readFile: readFile26 } = await import("node:fs/promises");
12850
12856
  let raw;
12851
12857
  try {
12852
- raw = JSON.parse(await readFile25(pointerPath, "utf8"));
12858
+ raw = JSON.parse(await readFile26(pointerPath, "utf8"));
12853
12859
  } catch (error) {
12854
12860
  throw new Error(
12855
12861
  `direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
@@ -13604,9 +13610,10 @@ var init_auditor_soul = __esm({
13604
13610
  "CLAUDE.md",
13605
13611
  "souls/judge-auditor.md",
13606
13612
  "souls/audit-law.md",
13607
- "souls/quality-law.md"
13613
+ "souls/quality-law.md",
13614
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
13608
13615
  ],
13609
- 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"]
13610
13617
  };
13611
13618
  }
13612
13619
  });
@@ -14135,7 +14142,7 @@ function resolveLifecycleInvocationPrincipal(entries, expected) {
14135
14142
  }
14136
14143
  return { invocationId: marker.invocationId, resume: true };
14137
14144
  }
14138
- 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;
14139
14146
  var init_navigator_invocation_identity = __esm({
14140
14147
  "src/navigator-invocation-identity.ts"() {
14141
14148
  "use strict";
@@ -14143,6 +14150,7 @@ var init_navigator_invocation_identity = __esm({
14143
14150
  init_uuidv7();
14144
14151
  init_work_subject_identity();
14145
14152
  NAVIGATOR_INVOCATION_ENTRY = "ak-navigator-invocation";
14153
+ NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY = "ak-navigator-route-playbook-failure";
14146
14154
  NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND = "role_infrastructure_failure";
14147
14155
  NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS = [
14148
14156
  "kind",
@@ -14236,17 +14244,25 @@ function createReceiptDeliveryPolicy() {
14236
14244
  if (accepted) return "accepted";
14237
14245
  return deliveryTurns < RECEIPT_DELIVERY_TURN_LIMIT ? "request-delivery" : "no-receipt";
14238
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
+ },
14239
14256
  facts(binding) {
14240
14257
  return noReceiptLifecycleFacts({ terminalToolCalled, rejectedReceipts: [...rejectedReceipts], deliveryTurns, ...binding });
14241
14258
  }
14242
14259
  };
14243
14260
  }
14244
- var RECEIPT_DELIVERY_TURN_LIMIT, RECEIPT_DELIVERY_PROMPT, NO_RECEIPT_LIFECYCLE_ENTRY_TYPE;
14261
+ var RECEIPT_DELIVERY_TURN_LIMIT, NO_RECEIPT_LIFECYCLE_ENTRY_TYPE;
14245
14262
  var init_receipt_delivery_policy = __esm({
14246
14263
  "src/receipt-delivery-policy.ts"() {
14247
14264
  "use strict";
14248
14265
  RECEIPT_DELIVERY_TURN_LIMIT = 2;
14249
- RECEIPT_DELIVERY_PROMPT = "\u672C\u4F1A\u8BDD\u5C1A\u65E0\u5DF2\u63A5\u53D7\u7684 typed \u56DE\u6267\u3002";
14250
14266
  NO_RECEIPT_LIFECYCLE_ENTRY_TYPE = "ak-no-receipt-lifecycle";
14251
14267
  }
14252
14268
  });
@@ -15367,7 +15383,23 @@ async function withOptionalGateProjection(base, sessionDirectory, gateContext =
15367
15383
  }
15368
15384
  return attachEngineDetourToolUsage(next, sessionDirectory, gateContext);
15369
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
+ }
15370
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) {
15371
15403
  const terminal = findLatestDurablePackagedRoleTerminal(entries);
15372
15404
  if (terminal === void 0) {
15373
15405
  return {
@@ -16143,10 +16175,10 @@ function presentFailureTerminal(terminal, io) {
16143
16175
  }
16144
16176
  function defaultNavigatorGraceSleep() {
16145
16177
  let timer;
16146
- const sleep2 = ((ms) => new Promise((resolve21) => {
16178
+ const sleep2 = ((ms) => new Promise((resolve22) => {
16147
16179
  timer = setTimeout(() => {
16148
16180
  timer = void 0;
16149
- resolve21();
16181
+ resolve22();
16150
16182
  }, ms);
16151
16183
  }));
16152
16184
  sleep2.cancel = () => {
@@ -16158,7 +16190,7 @@ function defaultNavigatorGraceSleep() {
16158
16190
  return sleep2;
16159
16191
  }
16160
16192
  function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
16161
- return new Promise((resolve21, reject) => {
16193
+ return new Promise((resolve22, reject) => {
16162
16194
  let settled = false;
16163
16195
  const finish = (action) => {
16164
16196
  if (settled) return;
@@ -16167,11 +16199,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
16167
16199
  action();
16168
16200
  };
16169
16201
  void work.then(
16170
- (value) => finish(() => resolve21({ status: "done", value })),
16202
+ (value) => finish(() => resolve22({ status: "done", value })),
16171
16203
  (error) => finish(() => reject(error))
16172
16204
  );
16173
16205
  void sleep2(graceMs).then(() => {
16174
- finish(() => resolve21({ status: "timeout" }));
16206
+ finish(() => resolve22({ status: "timeout" }));
16175
16207
  });
16176
16208
  });
16177
16209
  }
@@ -18214,7 +18246,7 @@ async function runCountersignCourtDiaristStation(admitted, env, io, afterTicketN
18214
18246
  for (const ticketNumber of refreshTickets.slice(completedIndex + 1)) {
18215
18247
  const outcome = await invokeCourtDiarist(
18216
18248
  {
18217
- instruction: `\u6574\u7406 #${ticketNumber} \u7684\u672C\u6848\u4F9D\u636E\u3002`,
18249
+ instruction: admitted.instruction,
18218
18250
  projectRoot: admitted.projectRoot,
18219
18251
  failureLabel: `ticket #${ticketNumber}`,
18220
18252
  correlationId: admitted.runId,
@@ -18961,8 +18993,8 @@ var init_atomic_write = __esm({
18961
18993
  import { open as open3, readFile as readFile18, unlink as unlink5 } from "node:fs/promises";
18962
18994
  import { dirname as dirname18, join as join34 } from "node:path";
18963
18995
  function sleep(ms) {
18964
- return new Promise((resolve21) => {
18965
- setTimeout(resolve21, ms);
18996
+ return new Promise((resolve22) => {
18997
+ setTimeout(resolve22, ms);
18966
18998
  });
18967
18999
  }
18968
19000
  async function withAnalystLibraryIndexLock(ledgerHome, fn) {
@@ -22608,7 +22640,7 @@ var init_compliance_transport = __esm({
22608
22640
 
22609
22641
  // src/archivist-record-topology.ts
22610
22642
  import { createHash as createHash8 } from "node:crypto";
22611
- import { join as join39 } from "node:path";
22643
+ import { join as join40 } from "node:path";
22612
22644
  function resolveNavigatorWorkSubjectPlacement(input) {
22613
22645
  let ledgerHome;
22614
22646
  if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
@@ -22621,7 +22653,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
22621
22653
  const digest = createHash8("sha256").update(input.subject).digest("hex").slice(0, 32);
22622
22654
  return {
22623
22655
  ledgerHome,
22624
- sessionDir: join39(
22656
+ sessionDir: join40(
22625
22657
  activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
22626
22658
  NAVIGATOR_RECORD_KIND,
22627
22659
  digest
@@ -22639,7 +22671,7 @@ var init_archivist_record_topology = __esm({
22639
22671
  });
22640
22672
 
22641
22673
  // src/pi/record-session-host.ts
22642
- import { existsSync as existsSync10 } from "node:fs";
22674
+ import { existsSync as existsSync11 } from "node:fs";
22643
22675
  import { SessionManager } from "@earendil-works/pi-coding-agent";
22644
22676
  var piRecordSessionHost;
22645
22677
  var init_record_session_host = __esm({
@@ -22661,7 +22693,7 @@ var init_record_session_host = __esm({
22661
22693
  const sessionFile = session.getSessionFile();
22662
22694
  return {
22663
22695
  session,
22664
- resumed: sessionFile !== void 0 && existsSync10(sessionFile)
22696
+ resumed: sessionFile !== void 0 && existsSync11(sessionFile)
22665
22697
  };
22666
22698
  },
22667
22699
  inMemoryRecordSession(cwd) {
@@ -22684,20 +22716,20 @@ __export(archivist_record_entry_exports, {
22684
22716
  });
22685
22717
  import {
22686
22718
  closeSync,
22687
- existsSync as existsSync11,
22719
+ existsSync as existsSync12,
22688
22720
  mkdirSync as mkdirSync2,
22689
22721
  openSync,
22690
22722
  readdirSync as readdirSync2,
22691
22723
  readFileSync as readFileSync4,
22692
22724
  readSync,
22693
- realpathSync as realpathSync2,
22725
+ realpathSync as realpathSync3,
22694
22726
  statSync as statSync5,
22695
22727
  writeFileSync as writeFileSync2
22696
22728
  } from "node:fs";
22697
- 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";
22698
22730
  import { StringDecoder } from "node:string_decoder";
22699
22731
  function readCurrentSession(sessionDir) {
22700
- const ledger = join40(sessionDir, CURRENT_SESSION_LEDGER);
22732
+ const ledger = join41(sessionDir, CURRENT_SESSION_LEDGER);
22701
22733
  try {
22702
22734
  const value = JSON.parse(readFileSync4(ledger, "utf8"));
22703
22735
  if (typeof value !== "object" || value === null || typeof value.sessionFile !== "string" || value.sessionFile.length === 0) {
@@ -22712,7 +22744,7 @@ function readCurrentSession(sessionDir) {
22712
22744
  }
22713
22745
  }
22714
22746
  function writeCurrentSession(sessionDir, sessionFile) {
22715
- const ledger = join40(sessionDir, CURRENT_SESSION_LEDGER);
22747
+ const ledger = join41(sessionDir, CURRENT_SESSION_LEDGER);
22716
22748
  try {
22717
22749
  writeFileSync2(ledger, `${JSON.stringify({ sessionFile })}
22718
22750
  `, { flag: "wx" });
@@ -22728,7 +22760,7 @@ function isCurrentSessionClaimRace(error) {
22728
22760
  return errnoCode(error.cause) === "EEXIST";
22729
22761
  }
22730
22762
  function currentSessionLedgerPath(sessionDir) {
22731
- return join40(sessionDir, CURRENT_SESSION_LEDGER);
22763
+ return join41(sessionDir, CURRENT_SESSION_LEDGER);
22732
22764
  }
22733
22765
  function readBoundedSessionHeader(filePath) {
22734
22766
  const fd = openSync(filePath, "r");
@@ -22801,8 +22833,8 @@ function parseSessionHeaderLine(line2) {
22801
22833
  };
22802
22834
  }
22803
22835
  function mostRecentNavigatorSessionFile(sessionDir, cwd) {
22804
- const absoluteSessionDir = resolve15(sessionDir);
22805
- const absoluteCwd = resolve15(cwd);
22836
+ const absoluteSessionDir = resolve16(sessionDir);
22837
+ const absoluteCwd = resolve16(cwd);
22806
22838
  let names;
22807
22839
  try {
22808
22840
  names = readdirSync2(absoluteSessionDir);
@@ -22815,7 +22847,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
22815
22847
  const matched = [];
22816
22848
  for (const name of names) {
22817
22849
  if (!name.endsWith(".jsonl")) continue;
22818
- const filePath = join40(absoluteSessionDir, name);
22850
+ const filePath = join41(absoluteSessionDir, name);
22819
22851
  let st;
22820
22852
  try {
22821
22853
  st = statSync5(filePath);
@@ -22837,7 +22869,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
22837
22869
  }
22838
22870
  if (header === void 0) continue;
22839
22871
  if (typeof header.cwd !== "string" || header.cwd.length === 0) continue;
22840
- if (resolve15(header.cwd) !== absoluteCwd) continue;
22872
+ if (resolve16(header.cwd) !== absoluteCwd) continue;
22841
22873
  matched.push({ path: filePath, mtimeMs: st.mtimeMs });
22842
22874
  }
22843
22875
  if (matched.length === 0) return void 0;
@@ -22846,7 +22878,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
22846
22878
  }
22847
22879
  function resolveNavigatorNestContinuation(sessionDir, cwd) {
22848
22880
  const ledgerPath = currentSessionLedgerPath(sessionDir);
22849
- if (existsSync11(ledgerPath)) {
22881
+ if (existsSync12(ledgerPath)) {
22850
22882
  const recentFile = readCurrentSession(sessionDir);
22851
22883
  assertRecentFinalFileUnderSessionDir(sessionDir, recentFile);
22852
22884
  return recentFile;
@@ -22867,8 +22899,8 @@ function resolveNavigatorNestContinuation(sessionDir, cwd) {
22867
22899
  }
22868
22900
  }
22869
22901
  function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
22870
- const absoluteSessionDir = resolve15(sessionDir);
22871
- const absoluteFile = resolve15(recentFile);
22902
+ const absoluteSessionDir = resolve16(sessionDir);
22903
+ const absoluteFile = resolve16(recentFile);
22872
22904
  if (absoluteFile !== absoluteSessionDir && !pathContainedIn(absoluteSessionDir, absoluteFile)) {
22873
22905
  throw new ActivationLedgerError(
22874
22906
  `archivist record session must be under the authorized nest (${sessionDir}): ${recentFile}`
@@ -22876,7 +22908,7 @@ function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
22876
22908
  }
22877
22909
  let realSessionDir;
22878
22910
  try {
22879
- realSessionDir = realpathSync2(absoluteSessionDir);
22911
+ realSessionDir = realpathSync3(absoluteSessionDir);
22880
22912
  } catch (error) {
22881
22913
  throw new ActivationLedgerError(
22882
22914
  `archivist record sessionDir is not resolvable (${absoluteSessionDir}): ${errorText(error)}`,
@@ -22885,7 +22917,7 @@ function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
22885
22917
  }
22886
22918
  let realFile;
22887
22919
  try {
22888
- realFile = realpathSync2(absoluteFile);
22920
+ realFile = realpathSync3(absoluteFile);
22889
22921
  } catch (error) {
22890
22922
  throw new ActivationLedgerError(
22891
22923
  `archivist record session file is not resolvable (${absoluteFile}): ${errorText(error)}`,
@@ -22923,15 +22955,15 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
22923
22955
  throw new Error("Durable record ownership requires a parent session inside the ledger home");
22924
22956
  } else {
22925
22957
  ledgerHome = resolveActivationLedgerHomeForPath(parentFile);
22926
- const parentResolved = resolve15(parentFile);
22958
+ const parentResolved = resolve16(parentFile);
22927
22959
  if (!physicallyContainedIn(ledgerHome, parentResolved)) {
22928
22960
  throw new Error("Durable record ownership requires a parent session inside the ledger home");
22929
22961
  }
22930
- sessionDir = join40(dirname20(parentResolved), options.kind);
22962
+ sessionDir = join41(dirname21(parentResolved), options.kind);
22931
22963
  parentSession = parentFile;
22932
22964
  mayResumeSameNest = options.kind === WORKER_SUBMISSION_GATE_KIND;
22933
22965
  }
22934
- const nestAlreadyExists = existsSync11(sessionDir);
22966
+ const nestAlreadyExists = existsSync12(sessionDir);
22935
22967
  ensureRealDirectoryTree(ledgerHome, sessionDir);
22936
22968
  if (mayResumeSameNest && nestAlreadyExists) {
22937
22969
  if (options.kind === NAVIGATOR_RECORD_KIND) {
@@ -22956,7 +22988,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
22956
22988
  });
22957
22989
  if (session.isPersisted()) {
22958
22990
  const file = session.getSessionFile();
22959
- if (file !== void 0 && !existsSync11(file)) {
22991
+ if (file !== void 0 && !existsSync12(file)) {
22960
22992
  const header = session.getHeader();
22961
22993
  if (header !== null && header.type === "session") {
22962
22994
  writeFileSync2(file, `${JSON.stringify(header)}
@@ -22974,7 +23006,7 @@ function createRecordSession(options) {
22974
23006
  return createRecordSessionOpen(options).session;
22975
23007
  }
22976
23008
  function bookDirectOfficerRunPointer(options) {
22977
- const nest = join40(dirname20(options.parentSessionFile), "auditor-roles");
23009
+ const nest = join41(dirname21(options.parentSessionFile), "auditor-roles");
22978
23010
  mkdirSync2(nest, { recursive: true });
22979
23011
  const pointer = {
22980
23012
  version: 1,
@@ -22984,7 +23016,7 @@ function bookDirectOfficerRunPointer(options) {
22984
23016
  ...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
22985
23017
  };
22986
23018
  writeFileSync2(
22987
- join40(nest, `${options.officer}.pointer.json`),
23019
+ join41(nest, `${options.officer}.pointer.json`),
22988
23020
  `${JSON.stringify(pointer)}
22989
23021
  `,
22990
23022
  "utf8"
@@ -23012,8 +23044,8 @@ import { randomUUID as randomUUID11 } from "node:crypto";
23012
23044
 
23013
23045
  // src/role-runtime-dependencies.ts
23014
23046
  init_collector_github();
23015
- import { readFile as readFile24 } from "node:fs/promises";
23016
- import { join as join44 } from "node:path";
23047
+ import { readFile as readFile25 } from "node:fs/promises";
23048
+ import { join as join45 } from "node:path";
23017
23049
 
23018
23050
  // src/doctor-auditor.ts
23019
23051
  init_auditor_dossier_tool();
@@ -23045,13 +23077,14 @@ import { createHash as createHash9 } from "node:crypto";
23045
23077
  init_navigator_invocation_identity();
23046
23078
  init_packaged_role_registry();
23047
23079
  init_activation_ledger_topology();
23048
- import { resolve as resolve16 } from "node:path";
23080
+ import { resolve as resolve17 } from "node:path";
23049
23081
  import "@earendil-works/pi-coding-agent";
23050
23082
  import { Type as Type13 } from "typebox";
23051
23083
 
23052
23084
  // src/navigator-public-session.ts
23053
23085
  init_sitian_facade();
23054
- import { basename as basename9 } from "node:path";
23086
+ import { existsSync as existsSync13 } from "node:fs";
23087
+ import { basename as basename10 } from "node:path";
23055
23088
 
23056
23089
  // src/navigator-session-contracts.ts
23057
23090
  import { Type as Type12 } from "typebox";
@@ -23241,6 +23274,113 @@ async function resolveNavigatorSeatSelection(context) {
23241
23274
  init_host_contracts();
23242
23275
  init_cli_errors();
23243
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
23244
23384
  async function resolveNavigatorLedgerHome(context) {
23245
23385
  const { tryHomeFromAkRolesPath: tryHomeFromAkRolesPath2 } = await Promise.resolve().then(() => (init_activation_ledger_topology(), activation_ledger_topology_exports));
23246
23386
  const runDirectory = runDirectoryFromHostContext(context);
@@ -23260,7 +23400,7 @@ function exactRecord2(value) {
23260
23400
  return typeof value === "object" && value !== null && !Array.isArray(value);
23261
23401
  }
23262
23402
  function runIdFromNavigatorDirectory(runDirectory) {
23263
- const entry = basename9(runDirectory);
23403
+ const entry = basename10(runDirectory);
23264
23404
  const suffix = "@navigator";
23265
23405
  if (!entry.endsWith(suffix)) return void 0;
23266
23406
  const runId = entry.slice(0, entry.length - suffix.length);
@@ -23304,6 +23444,7 @@ function createNativeNavigatorSessionFactory(deps) {
23304
23444
  });
23305
23445
  let providerFailure;
23306
23446
  let noReceipt;
23447
+ let routePlaybookReadFailure;
23307
23448
  let disposed = false;
23308
23449
  let hostRunId = readNavigatorHostRunPointer(sessionManager.getEntries());
23309
23450
  const summon = deps?.summonPublicRole ?? (async (options) => {
@@ -23317,13 +23458,16 @@ function createNativeNavigatorSessionFactory(deps) {
23317
23458
  }
23318
23459
  providerFailure = void 0;
23319
23460
  noReceipt = void 0;
23461
+ routePlaybookReadFailure = void 0;
23320
23462
  try {
23321
23463
  const summonHome = await resolveNavigatorLedgerHome(context);
23322
23464
  if (disposed) return;
23323
23465
  const resumeRunId = hostRunId;
23466
+ const workContextPath = navigatorWorkContextFile(sessionManager.getSessionDir());
23467
+ const argvText = existsSync13(workContextPath) ? attachWorkContextPointer(text, workContextPath) : text;
23324
23468
  const baseSummon = {
23325
23469
  role: "navigator",
23326
- argv: [text],
23470
+ argv: [argvText],
23327
23471
  cwd: context.cwd,
23328
23472
  ...summonHome === void 0 ? {} : { home: summonHome },
23329
23473
  ...context.signal === void 0 ? {} : { signal: context.signal }
@@ -23344,6 +23488,8 @@ function createNativeNavigatorSessionFactory(deps) {
23344
23488
  }
23345
23489
  }
23346
23490
  if (disposed) return;
23491
+ const playbookFailure = summoned.terminal?.navigator?.advisoryDiagnostic;
23492
+ routePlaybookReadFailure = typeof playbookFailure === "string" && playbookFailure.trim() !== "" ? playbookFailure : void 0;
23347
23493
  const outcome = summoned.terminal?.roleOutcome;
23348
23494
  if (outcome === void 0) {
23349
23495
  const detail = summoned.stderr?.trim() || `exit ${summoned.exitCode}`;
@@ -23402,6 +23548,7 @@ function createNativeNavigatorSessionFactory(deps) {
23402
23548
  },
23403
23549
  providerFailure: () => providerFailure,
23404
23550
  noReceipt: () => noReceipt,
23551
+ routePlaybookReadFailure: () => routePlaybookReadFailure,
23405
23552
  appendEntry: (customType, data) => {
23406
23553
  sessionManager.appendCustomEntry(customType, data);
23407
23554
  try {
@@ -23441,7 +23588,6 @@ init_work_subject_identity();
23441
23588
  init_receipt_delivery_policy();
23442
23589
  init_navigator_output();
23443
23590
  var NAVIGATOR_EVENT_TYPE = "ak-navigator-attendance";
23444
- var NAVIGATOR_PREPARE_ACCEPTED_TEXT = "\u6E38\u5955\u4F7F\u51C6\u5907\u5DF2\u63A5\u53D7";
23445
23591
  function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
23446
23592
  if (roleInput !== void 0 && roleInput.trim() !== "") return roleInput;
23447
23593
  if (fileAuthority !== void 0 && fileAuthority.trim() !== "") return fileAuthority;
@@ -23450,10 +23596,9 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
23450
23596
  var NAVIGATOR_TARGETS = PACKAGED_ROLE_REGISTRY.map(({ role, phases }) => ({ role, phases }));
23451
23597
  var prepareSchema = Type13.Object({
23452
23598
  prose: Type13.Optional(Type13.Unknown({
23453
- 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"
23454
23600
  }))
23455
23601
  }, { additionalProperties: true });
23456
- var CONTEXT_ENTRY = "ak-navigator-context";
23457
23602
  var INVOCATION_ENTRY = NAVIGATOR_INVOCATION_ENTRY;
23458
23603
  var SETTLEMENT_ENTRY = "ak-navigator-settlement";
23459
23604
  function exactRecord3(value) {
@@ -23493,7 +23638,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
23493
23638
  }
23494
23639
  function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
23495
23640
  if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
23496
- const resolvedReference = resolve16(cwd, reference);
23641
+ const resolvedReference = resolve17(cwd, reference);
23497
23642
  const marker = "/runs/";
23498
23643
  if (resolvedReference.includes(marker)) {
23499
23644
  return subjectRoot;
@@ -23508,12 +23653,12 @@ function createNavigatorPrepareTool(onOutput) {
23508
23653
  parameters: prepareSchema,
23509
23654
  async execute(_id, value) {
23510
23655
  onOutput(value);
23511
- return { content: [{ type: "text", text: NAVIGATOR_PREPARE_ACCEPTED_TEXT }], details: value, terminate: true };
23656
+ return { content: [], details: value, terminate: true };
23512
23657
  }
23513
23658
  };
23514
23659
  }
23515
23660
  function formatNavigatorReport(report) {
23516
- const playbookFailure = report.routePlaybookReadFailure === void 0 ? [] : [`\u8DEF\u4E66\u8BFB\u53D6\u5931\u8D25\uFF1A${report.routePlaybookReadFailure}`];
23661
+ const playbookFailure = report.routePlaybookReadFailure === void 0 ? [] : [report.routePlaybookReadFailure];
23517
23662
  if (report.disposition === "no-advice") return playbookFailure.join("\n");
23518
23663
  if (report.disposition === "unavailable") {
23519
23664
  return [...playbookFailure, ...report.unavailableReason ? [report.unavailableReason] : []].join("\n");
@@ -23539,28 +23684,15 @@ function createNavigatorAttendance(options) {
23539
23684
  let settlementTail = Promise.resolve();
23540
23685
  let settlementFailure;
23541
23686
  let preparationFailure;
23542
- let routePlaybookReadFailure;
23687
+ let observedRoutePlaybookFailure;
23543
23688
  let disposed = false;
23544
23689
  let closing;
23545
23690
  const nestCancel = new AbortController();
23546
- let warmedHelp;
23547
23691
  const sessionHostContext = () => {
23548
23692
  const parentSignal = options.context.signal;
23549
23693
  const signal = parentSignal === void 0 ? nestCancel.signal : AbortSignal.any([nestCancel.signal, parentSignal]);
23550
23694
  return { ...options.context, signal };
23551
23695
  };
23552
- const loadLiveHelp = async () => {
23553
- try {
23554
- return await Promise.all(
23555
- NAVIGATOR_TARGETS.map(async ({ role }) => ({
23556
- role,
23557
- help: await options.loadRoleHelp(role)
23558
- }))
23559
- );
23560
- } catch (error) {
23561
- throw navigatorUnavailableError("transport", error);
23562
- }
23563
- };
23564
23696
  const unavailable = (invocationId, reason) => {
23565
23697
  const failure2 = reason instanceof NavigatorUnavailableError ? reason : navigatorUnavailableError("unknown", reason);
23566
23698
  return {
@@ -23570,7 +23702,6 @@ function createNavigatorAttendance(options) {
23570
23702
  unavailableCause: failure2.unavailableCause
23571
23703
  };
23572
23704
  };
23573
- let routePlaybookSettlement;
23574
23705
  let prepareBoundSettlement;
23575
23706
  const loadMaterialsAndSession = async (invocationId) => {
23576
23707
  if (contextError !== void 0) throw navigatorUnavailableError("context", contextError);
@@ -23580,30 +23711,6 @@ function createNavigatorAttendance(options) {
23580
23711
  new Error("controlling authority content was not supplied as typed work context")
23581
23712
  );
23582
23713
  }
23583
- let soul;
23584
- let modelSetting;
23585
- let help;
23586
- let routePlaybook = "";
23587
- routePlaybookReadFailure = void 0;
23588
- const soulPromise = (async () => {
23589
- try {
23590
- const text = (await options.loadSoul()).trim();
23591
- if (!text) throw new Error("Navigator soul is empty");
23592
- return text;
23593
- } catch (error) {
23594
- throw navigatorUnavailableError("context", error);
23595
- }
23596
- })();
23597
- const routePlaybookPromise = (async () => {
23598
- if (options.loadRoutePlaybook === void 0) return "";
23599
- try {
23600
- return await options.loadRoutePlaybook();
23601
- } catch (error) {
23602
- routePlaybookReadFailure = error instanceof Error ? error.message : String(error);
23603
- return "";
23604
- }
23605
- })();
23606
- routePlaybookSettlement = routePlaybookPromise.then(() => void 0);
23607
23714
  const modelPromise = (async () => {
23608
23715
  try {
23609
23716
  const resolved = await resolveNavigatorSeatSelection(options.context);
@@ -23613,23 +23720,13 @@ function createNavigatorAttendance(options) {
23613
23720
  throw navigatorUnavailableError("model", error);
23614
23721
  }
23615
23722
  })();
23616
- const helpPromise = warmedHelp ?? loadLiveHelp();
23617
- warmedHelp = void 0;
23618
- [soul, routePlaybook, modelSetting, help] = await Promise.all([
23619
- soulPromise,
23620
- routePlaybookPromise,
23621
- modelPromise,
23622
- helpPromise
23623
- ]);
23723
+ const modelSetting = await modelPromise;
23624
23724
  let model;
23625
23725
  try {
23626
23726
  model = parseNavigatorModelSetting(modelSetting);
23627
23727
  } catch (error) {
23628
23728
  throw navigatorUnavailableError("model", error);
23629
23729
  }
23630
- const helpContext = help.map(({ role, help: text }) => `<role_help role="${role}">
23631
- ${text}
23632
- </role_help>`).join("\n");
23633
23730
  const tool = createNavigatorPrepareTool((value) => {
23634
23731
  outputSink?.(value);
23635
23732
  });
@@ -23674,9 +23771,9 @@ ${text}
23674
23771
  }
23675
23772
  if (disposed) throw navigatorUnavailableError("session", new Error("Navigator attendance was disposed"));
23676
23773
  if (session === void 0) throw new Error("Navigator session was not created");
23677
- return { soul, routePlaybook, helpContext, modelSetting, model, help, activeSession: session };
23774
+ return session;
23678
23775
  };
23679
- const prepare = async (materialsBundle) => {
23776
+ const prepare = async (existingSession) => {
23680
23777
  const boundSettlement = prepareBoundSettlement;
23681
23778
  prepareBoundSettlement = void 0;
23682
23779
  const invocationId = invocationPrincipal;
@@ -23693,73 +23790,19 @@ ${text}
23693
23790
  const merged = [prior, next].filter((part) => part.trim() !== "").join("\n\n");
23694
23791
  output = { prose: merged };
23695
23792
  };
23696
- const { soul, routePlaybook, helpContext, help, activeSession } = materialsBundle ?? await loadMaterialsAndSession(invocationId);
23697
- const publicSettlementHistory = activeSession.entries().filter((entry) => exactRecord3(entry) && entry.type === "custom" && entry.customType === SETTLEMENT_ENTRY && exactRecord3(entry.data)).map((entry) => entry.data);
23698
- const projection = {
23699
- subjectKey,
23700
- subject,
23701
- authority,
23702
- currentRole: { role: options.role, phase: options.phase },
23703
- ...boundSettlement === void 0 ? {} : { currentSettlement: boundSettlement },
23704
- publicSettlementHistory,
23705
- liveRoleHelp: help
23706
- };
23707
- activeSession.appendEntry(CONTEXT_ENTRY, projection);
23708
- const request = boundSettlement === void 0 ? [
23709
- "\u672C\u8F6E\u4E3A\u5F85\u547D\u8F6E\u3002",
23710
- `<navigator_soul>
23711
- ${soul}
23712
- </navigator_soul>`,
23713
- ...routePlaybookReadFailure === void 0 ? [`<route_playbook>
23714
- ${routePlaybook}
23715
- </route_playbook>`] : ["\u53EF\u9009\u8DEF\u7EBF\u624B\u518C\u672A\u80FD\u8BFB\u53D6\u3002"],
23716
- `<work_subject>
23717
- ${subject}
23718
- </work_subject>`,
23719
- `<controlling_authority>
23720
- ${authority}
23721
- </controlling_authority>`,
23722
- `<current_role>
23723
- ${JSON.stringify({ role: options.role, phase: options.phase })}
23724
- </current_role>`,
23725
- `<public_settlement_history>
23726
- ${JSON.stringify(projection.publicSettlementHistory)}
23727
- </public_settlement_history>`,
23728
- `<live_role_help>
23729
- ${helpContext}
23730
- </live_role_help>`
23731
- ].join("\n\n") : [
23732
- "\u672C\u8F6E\u4E3A\u7ED3\u7B97\u6295\u5582\u8F6E\u3002",
23733
- `<navigator_soul>
23734
- ${soul}
23735
- </navigator_soul>`,
23736
- ...routePlaybookReadFailure === void 0 ? [`<route_playbook>
23737
- ${routePlaybook}
23738
- </route_playbook>`] : ["\u53EF\u9009\u8DEF\u7EBF\u624B\u518C\u672A\u80FD\u8BFB\u53D6\u3002"],
23739
- `<work_subject>
23740
- ${subject}
23741
- </work_subject>`,
23742
- `<controlling_authority>
23743
- ${authority}
23744
- </controlling_authority>`,
23745
- `<current_role>
23746
- ${JSON.stringify({ role: options.role, phase: options.phase })}
23747
- </current_role>`,
23748
- `<current_settlement>
23749
- ${JSON.stringify(boundSettlement)}
23750
- </current_settlement>`,
23751
- `<public_settlement_history>
23752
- ${JSON.stringify(projection.publicSettlementHistory)}
23753
- </public_settlement_history>`,
23754
- `<live_role_help>
23755
- ${helpContext}
23756
- </live_role_help>`
23757
- ].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
+ });
23758
23800
  try {
23759
23801
  try {
23760
23802
  if (disposed) throw navigatorUnavailableError("session", new Error("Navigator attendance was disposed"));
23761
23803
  const delivery = createReceiptDeliveryPolicy();
23762
23804
  const promptAllowingRejectedPrepare = async (text, deliveryRequest) => {
23805
+ await persistNavigatorWorkBase(activeSession.recordPointer(), { subject, authority });
23763
23806
  const entryStart = activeSession.entries().length;
23764
23807
  prepareBatchRejected = false;
23765
23808
  let promptFailure;
@@ -23790,7 +23833,7 @@ ${helpContext}
23790
23833
  await promptAllowingRejectedPrepare(request, false);
23791
23834
  if (boundSettlement !== void 0) {
23792
23835
  while (output === void 0 && prepareBatchRejected && delivery.nextAction() === "request-delivery") {
23793
- await promptAllowingRejectedPrepare(RECEIPT_DELIVERY_PROMPT, true);
23836
+ await promptAllowingRejectedPrepare(JSON.stringify(delivery.deliveryState()), true);
23794
23837
  }
23795
23838
  if (output === void 0 && delivery.nextAction() === "request-delivery") {
23796
23839
  while (delivery.nextAction() === "request-delivery") {
@@ -23830,6 +23873,8 @@ ${helpContext}
23830
23873
  preparedProse = normalizePrepareProse(output);
23831
23874
  return preparedProse;
23832
23875
  } finally {
23876
+ const playbookFailure = activeSession.routePlaybookReadFailure?.();
23877
+ observedRoutePlaybookFailure = typeof playbookFailure === "string" && playbookFailure.trim() !== "" ? playbookFailure : void 0;
23833
23878
  outputSink = void 0;
23834
23879
  }
23835
23880
  };
@@ -23847,16 +23892,6 @@ ${helpContext}
23847
23892
  contextError = next.contextError;
23848
23893
  return closing2;
23849
23894
  },
23850
- /**
23851
- * Start live-help subprocesses during activation without beginning full
23852
- * preparation. Next prepare() consumes the warm result; a later prepare
23853
- * reloads so live help edits remain visible.
23854
- */
23855
- warmHelp() {
23856
- if (disposed || warmedHelp !== void 0 || preparation !== void 0) return;
23857
- warmedHelp = loadLiveHelp();
23858
- void warmedHelp.catch(() => void 0);
23859
- },
23860
23895
  prepare() {
23861
23896
  if (disposed || preparation !== void 0) return;
23862
23897
  preparationFailure = void 0;
@@ -23871,9 +23906,6 @@ ${helpContext}
23871
23906
  isPreparing() {
23872
23907
  return preparationInFlight;
23873
23908
  },
23874
- knownRoutePlaybookReadFailure() {
23875
- return routePlaybookReadFailure;
23876
- },
23877
23909
  settle(settlement) {
23878
23910
  const next = settlementTail.then(() => settleOnce(settlement));
23879
23911
  settlementTail = next.catch((error) => {
@@ -23900,6 +23932,7 @@ ${helpContext}
23900
23932
  };
23901
23933
  async function settleOnce(settlement) {
23902
23934
  if (disposed) return;
23935
+ observedRoutePlaybookFailure = void 0;
23903
23936
  const invocationId = activeInvocationId ?? invocationPrincipal;
23904
23937
  let report;
23905
23938
  if (sessionReady !== void 0) {
@@ -23938,10 +23971,10 @@ ${helpContext}
23938
23971
  }
23939
23972
  } else {
23940
23973
  if (session !== void 0) preparationFailure = void 0;
23941
- let coldMaterials;
23974
+ let coldSession;
23942
23975
  if (session === void 0 && preparationFailure === void 0) {
23943
23976
  try {
23944
- coldMaterials = await loadMaterialsAndSession(invocationId);
23977
+ coldSession = await loadMaterialsAndSession(invocationId);
23945
23978
  } catch (error) {
23946
23979
  preparationFailure = error;
23947
23980
  }
@@ -23949,7 +23982,7 @@ ${helpContext}
23949
23982
  session?.appendEntry(SETTLEMENT_ENTRY, settlementFact);
23950
23983
  if (preparationFailure === void 0) {
23951
23984
  prepareBoundSettlement = settlement;
23952
- preparation = prepare(coldMaterials);
23985
+ preparation = prepare(coldSession);
23953
23986
  void preparation.catch((error) => {
23954
23987
  preparationFailure = error;
23955
23988
  });
@@ -23968,9 +24001,8 @@ ${helpContext}
23968
24001
  report = { disposition: "no-advice" };
23969
24002
  }
23970
24003
  }
23971
- await routePlaybookSettlement;
23972
- if (routePlaybookReadFailure !== void 0) {
23973
- report = { ...report, routePlaybookReadFailure };
24004
+ if (observedRoutePlaybookFailure !== void 0) {
24005
+ report = { ...report, routePlaybookReadFailure: observedRoutePlaybookFailure };
23974
24006
  }
23975
24007
  const event = {
23976
24008
  version: 1,
@@ -23997,16 +24029,14 @@ ${helpContext}
23997
24029
  sessionReady = void 0;
23998
24030
  preparedProse = void 0;
23999
24031
  preparationFailure = void 0;
24000
- routePlaybookSettlement = void 0;
24001
- routePlaybookReadFailure = void 0;
24002
24032
  }
24003
24033
  }
24004
24034
 
24005
24035
  // src/navigator-work-context.ts
24006
24036
  init_doctor_evidence();
24007
24037
  init_host_contracts();
24008
- import { readFile as readFile22 } from "node:fs/promises";
24009
- import { resolve as resolve17 } from "node:path";
24038
+ import { readFile as readFile23 } from "node:fs/promises";
24039
+ import { resolve as resolve18 } from "node:path";
24010
24040
  init_notary_source_run();
24011
24041
  init_packaged_role_registry();
24012
24042
  init_invocation();
@@ -24014,12 +24044,12 @@ function navigatorInputReference(getFlag, role) {
24014
24044
  if (getFlag === void 0) return void 0;
24015
24045
  const name = packagedRoleInputFlag(role);
24016
24046
  const value = name === void 0 ? void 0 : getFlag(name);
24017
- return typeof value === "string" && value !== "" ? resolve17(value) : void 0;
24047
+ return typeof value === "string" && value !== "" ? resolve18(value) : void 0;
24018
24048
  }
24019
24049
  async function loadNavigatorWorkContext(options) {
24020
24050
  const reference = navigatorInputReference(options.getFlag, options.role);
24021
24051
  const subjectMode = packagedNavigatorSubject(options.role);
24022
- 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");
24023
24053
  const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
24024
24054
  let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
24025
24055
  let subject = input ?? `work subject: ${subjectKey}`;
@@ -24036,7 +24066,7 @@ async function loadNavigatorWorkContext(options) {
24036
24066
  }
24037
24067
  const publicRunDir = runDirectoryFromHostContext(options.context);
24038
24068
  const currentSessionDir = options.context.sessionManager.getSessionDir();
24039
- const isBoundPublicRun = publicRunDir !== void 0 && resolve17(currentSessionDir) === resolve17(publicRunDir, "session");
24069
+ const isBoundPublicRun = publicRunDir !== void 0 && resolve18(currentSessionDir) === resolve18(publicRunDir, "session");
24040
24070
  if (subjectMode === "public-instruction" && isBoundPublicRun) {
24041
24071
  let admitted;
24042
24072
  try {
@@ -24069,14 +24099,14 @@ async function loadNavigatorWorkContext(options) {
24069
24099
  }
24070
24100
  const workRoot = subjectRoot.includes("/.ak/work/") ? subjectRoot : void 0;
24071
24101
  const authorityFiles = workRoot === void 0 ? [] : [
24072
- resolve17(workRoot, "authority.md"),
24073
- resolve17(workRoot, "authority.txt"),
24074
- 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")
24075
24105
  ];
24076
24106
  let authorityMaterial;
24077
24107
  for (const path of authorityFiles) {
24078
24108
  try {
24079
- const content = await readFile22(path, "utf8");
24109
+ const content = await readFile23(path, "utf8");
24080
24110
  if (content.trim() !== "") {
24081
24111
  authorityMaterial = content;
24082
24112
  break;
@@ -24108,7 +24138,7 @@ init_submission_ledger();
24108
24138
  init_collector_ledger();
24109
24139
  import { randomUUID as randomUUID8 } from "node:crypto";
24110
24140
  import { readFileSync as readFileSync6, writeSync as writeSync3 } from "node:fs";
24111
- import { join as join43 } from "node:path";
24141
+ import { join as join44 } from "node:path";
24112
24142
  import { Value as Value5 } from "typebox/value";
24113
24143
 
24114
24144
  // src/activation-trace.ts
@@ -24155,11 +24185,11 @@ init_activation_ledger_git();
24155
24185
  init_activation_ledger_topology();
24156
24186
  import {
24157
24187
  lstatSync as lstatSync2,
24158
- realpathSync as realpathSync3,
24188
+ realpathSync as realpathSync4,
24159
24189
  statSync as statSync6,
24160
24190
  writeFileSync as writeFileSync3
24161
24191
  } from "node:fs";
24162
- import { isAbsolute as isAbsolute11, resolve as resolve18 } from "node:path";
24192
+ import { isAbsolute as isAbsolute11, resolve as resolve19 } from "node:path";
24163
24193
  var ActivationSessionFileMissingError = class extends Error {
24164
24194
  code = "AK_ACTIVATION_SESSION_FILE_MISSING";
24165
24195
  path;
@@ -24204,7 +24234,7 @@ function durableSessionPointer(sessionManager) {
24204
24234
  `Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
24205
24235
  );
24206
24236
  }
24207
- const resolvedFile = resolve18(file);
24237
+ const resolvedFile = resolve19(file);
24208
24238
  try {
24209
24239
  lstatSync2(resolvedFile);
24210
24240
  } catch (error) {
@@ -24225,7 +24255,7 @@ function durableSessionPointer(sessionManager) {
24225
24255
  }
24226
24256
  let realFile;
24227
24257
  try {
24228
- realFile = realpathSync3(resolvedFile);
24258
+ realFile = realpathSync4(resolvedFile);
24229
24259
  } catch (error) {
24230
24260
  throw new ActivationSessionFileMissingError(resolvedFile, { cause: error });
24231
24261
  }
@@ -24254,6 +24284,9 @@ function durableSessionPointer(sessionManager) {
24254
24284
  // src/activation-ledger.ts
24255
24285
  init_activation_ledger_topology();
24256
24286
 
24287
+ // src/role-runtime.ts
24288
+ init_session_opening_materials();
24289
+
24257
24290
  // src/stderr-jsonl.ts
24258
24291
  import { writeSync } from "node:fs";
24259
24292
  var STDERR_JSONL_WRITE_RETRY_LIMIT = 100;
@@ -24540,8 +24573,8 @@ init_collector_github();
24540
24573
  // src/collector-handbook.ts
24541
24574
  init_atomic_write();
24542
24575
  init_activation_ledger_topology();
24543
- import { readFile as readFile23 } from "node:fs/promises";
24544
- 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";
24545
24578
 
24546
24579
  // src/collector-tool-schemas.ts
24547
24580
  init_open_tool_schema();
@@ -24587,10 +24620,10 @@ var collectorOpenWaitWindowArgsSchema = Type17.Object({
24587
24620
  }, { additionalProperties: true });
24588
24621
  var collectorBindTargetArgsSchema = Type17.Object({
24589
24622
  prNumber: Type17.Optional(Type17.Unknown({
24590
- 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"
24591
24624
  })),
24592
24625
  issueNumber: Type17.Optional(Type17.Unknown({
24593
- 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"
24594
24627
  }))
24595
24628
  }, { additionalProperties: true });
24596
24629
  var collectorFindingItemDeclaration = (() => {
@@ -24608,7 +24641,7 @@ var collectorFindingItemDeclaration = (() => {
24608
24641
  },
24609
24642
  {
24610
24643
  additionalProperties: true,
24611
- 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"
24612
24645
  }
24613
24646
  );
24614
24647
  item.required = [];
@@ -24619,11 +24652,11 @@ var collectorOutputBaseSchema = openToolObject(
24619
24652
  // No root type:array — host must not shape-reject non-array findings (#676 C).
24620
24653
  // Nested item declarations ride `items` for registration preservation (ADR 0057).
24621
24654
  findings: Type17.Unsafe({
24622
- 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",
24623
24656
  items: collectorFindingItemDeclaration
24624
24657
  }),
24625
24658
  unfinishedReasons: Type17.Unknown({
24626
- 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"
24627
24660
  })
24628
24661
  })
24629
24662
  );
@@ -24656,7 +24689,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
24656
24689
  throw new Error(`\u901A\u8FDB\u53F8\u624B\u518C\u62D2\u7EDD\u4E0D\u5B89\u5168 bookKey ${JSON.stringify(bookKey)}`);
24657
24690
  }
24658
24691
  const ledgerHome = resolveActivationLedgerHomeForPath(sessionPath);
24659
- const root = join42(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
24692
+ const root = join43(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
24660
24693
  return { ledgerHome, bookKey, root };
24661
24694
  }
24662
24695
  function collectorHandbookRepoFileName(repositoryCanonical) {
@@ -24668,9 +24701,9 @@ function collectorHandbookRepoFileName(repositoryCanonical) {
24668
24701
  return `${repositoryCanonical.replaceAll("/", "__")}.md`;
24669
24702
  }
24670
24703
  function createCollectorHandbookStore(input) {
24671
- const generalPath = join42(input.handbookRoot, "general.md");
24672
- const repoDir = join42(input.handbookRoot, "repos");
24673
- 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));
24674
24707
  const assertHandbookBudget = (body, label) => {
24675
24708
  const byteLength = Buffer.byteLength(body, "utf8");
24676
24709
  if (byteLength > COLLECTOR_HANDBOOK_MAX_BYTES) {
@@ -24684,7 +24717,7 @@ function createCollectorHandbookStore(input) {
24684
24717
  ensureRealDirectoryTree(input.ledgerHome, parentDir2);
24685
24718
  assertLedgerFileInsideHome(path, input.ledgerHome);
24686
24719
  try {
24687
- const body = await readFile23(path, "utf8");
24720
+ const body = await readFile24(path, "utf8");
24688
24721
  assertHandbookBudget(body, "\u6B63\u6587");
24689
24722
  return body;
24690
24723
  } catch (error) {
@@ -24938,7 +24971,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
24938
24971
  pi.registerTool({
24939
24972
  name: COLLECTOR_BIND_TARGET_TOOL,
24940
24973
  label: "\u901A\u8FDB\u53F8\u8BA4\u7968\u7ED1\u5B9A",
24941
- 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",
24942
24975
  promptSnippet: "\u7ED1\u5B9A\u89D2\u8272\u5224\u5B9A\u7684 issue/PR \u76EE\u6807",
24943
24976
  parameters: bindSchema,
24944
24977
  async execute(toolCallId, params, _signal, _onUpdate, ctx) {
@@ -25015,7 +25048,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25015
25048
  pi.registerTool({
25016
25049
  name: COLLECTOR_OBSERVE_TOOL,
25017
25050
  label: "\u901A\u8FDB\u53F8\u89C2\u5BDF",
25018
- 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",
25019
25052
  promptSnippet: "\u6293\u53D6\u914D\u7F6E\u76EE\u6807 PR \u8BC1\u636E",
25020
25053
  parameters: observeSchema,
25021
25054
  async execute(toolCallId, _params, signal, _onUpdate, ctx) {
@@ -25045,7 +25078,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25045
25078
  pi.registerTool({
25046
25079
  name: COLLECTOR_READ_TOOL,
25047
25080
  label: "\u901A\u8FDB\u53F8\u5F00\u5377",
25048
- 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",
25049
25082
  promptSnippet: "\u6309\u6307\u9488\u5F00\u5377\u8BFB\u6750\u6599",
25050
25083
  parameters: readSchema,
25051
25084
  async execute(toolCallId, params, _signal, _onUpdate, ctx) {
@@ -25075,7 +25108,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25075
25108
  pi.registerTool({
25076
25109
  name: COLLECTOR_REQUEST_TOOL,
25077
25110
  label: "\u901A\u8FDB\u53F8\u8BF7\u6C42",
25078
- 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",
25079
25112
  promptSnippet: "\u53D1\u4E00\u6B21\u8BC4\u5BA1\u8BF7\u6C42",
25080
25113
  parameters: requestSchema,
25081
25114
  async execute(toolCallId, params, signal, _onUpdate, ctx) {
@@ -25194,7 +25227,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25194
25227
  pi.registerTool({
25195
25228
  name: COLLECTOR_WAIT_TOOL,
25196
25229
  label: "\u901A\u8FDB\u53F8\u7B49\u5F85",
25197
- 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",
25198
25231
  promptSnippet: "\u7B49\u5F85\u7A97\u5185\u7B49\u5F85",
25199
25232
  parameters: waitSchema,
25200
25233
  async execute(toolCallId, params, signal, _onUpdate, ctx) {
@@ -25224,7 +25257,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25224
25257
  pi.registerTool({
25225
25258
  name: COLLECTOR_OUTPUT_TOOL,
25226
25259
  label: "\u901A\u8FDB\u53F8\u8F93\u51FA",
25227
- 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",
25228
25261
  promptSnippet: "\u63D0\u4EA4\u901A\u8FDB\u53F8\u56DE\u6267",
25229
25262
  parameters: outputSchema,
25230
25263
  async execute(toolCallId, params, _signal, _onUpdate, ctx) {
@@ -25489,7 +25522,7 @@ var gleanerLeftOutputSchema = withTerminatingOutputDeclarations(
25489
25522
  openToolObject(
25490
25523
  Type18.Object({
25491
25524
  status: Type18.Unknown({
25492
- description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
25525
+ description: "completed"
25493
25526
  }),
25494
25527
  findings: Type18.Array(
25495
25528
  Type18.Object(
@@ -25540,7 +25573,7 @@ var diaristOutputSchema = withTerminatingOutputDeclarations(
25540
25573
  openToolObject(
25541
25574
  Type19.Object({
25542
25575
  status: Type19.Unknown({
25543
- description: "completed | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
25576
+ description: "completed | escalate"
25544
25577
  }),
25545
25578
  ticketNumber: Type19.Optional(
25546
25579
  Type19.Unknown({
@@ -25626,7 +25659,7 @@ var secretariatVerdictSchema = withTerminatingOutputDeclarations(
25626
25659
  Type20.Object(
25627
25660
  {
25628
25661
  secretariatStatus: Type20.Unknown({
25629
- description: "converged | escalate\uFF08\u7EC8\u5C40\u5F62\u72B6\u6307\u5F15\uFF0C\u975E\u95F8\uFF09"
25662
+ description: "converged | escalate"
25630
25663
  }),
25631
25664
  ticketNumber: Type20.Optional(
25632
25665
  Type20.Number({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
@@ -25650,7 +25683,7 @@ secretariatVerdictSchema.required = [];
25650
25683
  var SECRETARIAT_OUTPUT_TOOL_SPEC = {
25651
25684
  name: SECRETARIAT_OUTPUT_TOOL_NAME,
25652
25685
  label: "\u4E2D\u4E66\u7701\u8F93\u51FA",
25653
- 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",
25654
25687
  promptSnippet: "\u4E2D\u4E66\u7701\u7EC8\u5C40\u56DE\u6267",
25655
25688
  parameters: secretariatVerdictSchema
25656
25689
  };
@@ -25727,7 +25760,7 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
25727
25760
  pi.registerTool({
25728
25761
  name: JUDGE_OUTPUT_TOOL_NAME,
25729
25762
  label: "\u5927\u7406\u5BFA\u8F93\u51FA",
25730
- 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",
25731
25764
  promptSnippet: "\u63D0\u4EA4\u5927\u7406\u5BFA\u7EC8\u5C40\u5224\u8BCD",
25732
25765
  parameters: judgeVerdictSchema,
25733
25766
  async execute(toolCallId, parameters, signal, _onUpdate, ctx) {
@@ -25822,9 +25855,9 @@ var reviewerAmendmentsSchema = Type21.Object({
25822
25855
  }))
25823
25856
  }, {
25824
25857
  additionalProperties: true,
25825
- 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"
25826
25859
  });
25827
- 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";
25828
25861
  var reviewerOutputVariants = Type21.Union([
25829
25862
  Type21.Object({
25830
25863
  status: Type21.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
@@ -25853,7 +25886,7 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
25853
25886
  pi.registerTool({
25854
25887
  name: REVIEWER_OUTPUT_TOOL_NAME,
25855
25888
  label: "\u5FA1\u53F2\u53F0\u8F93\u51FA",
25856
- 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",
25857
25890
  promptSnippet: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267",
25858
25891
  parameters: reviewerOutputSchema,
25859
25892
  async execute(_id, parameters) {
@@ -25893,8 +25926,8 @@ init_sitian_facade();
25893
25926
  init_submission_errors();
25894
25927
  init_submission_errors();
25895
25928
  import { execFileSync as execFileSync4 } from "node:child_process";
25896
- import { existsSync as existsSync12, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
25897
- 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";
25898
25931
  var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
25899
25932
  var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
25900
25933
  var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
@@ -25924,7 +25957,7 @@ function statusOf(error) {
25924
25957
  return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
25925
25958
  }
25926
25959
  function tryGetAll(file, key) {
25927
- if (!existsSync12(file)) return [];
25960
+ if (!existsSync14(file)) return [];
25928
25961
  try {
25929
25962
  const out = gitFile(file, ["--get-all", key]);
25930
25963
  return out.length === 0 ? [] : out.split("\n");
@@ -25934,7 +25967,7 @@ function tryGetAll(file, key) {
25934
25967
  }
25935
25968
  }
25936
25969
  function ownedHook(path) {
25937
- if (!existsSync12(path)) return false;
25970
+ if (!existsSync14(path)) return false;
25938
25971
  return readFileSync5(path, "utf8").includes(HOOK_MARKER);
25939
25972
  }
25940
25973
  function escapeGitConfigValueRegex(value) {
@@ -25943,7 +25976,7 @@ function escapeGitConfigValueRegex(value) {
25943
25976
  function unsetOwnedHooksPath(file) {
25944
25977
  const owned = [];
25945
25978
  for (const value of tryGetAll(file, "core.hooksPath")) {
25946
- if (!ownedHook(resolve19(value, HOOK_FILE))) continue;
25979
+ if (!ownedHook(resolve20(value, HOOK_FILE))) continue;
25947
25980
  try {
25948
25981
  gitFile(file, [
25949
25982
  "--unset-all",
@@ -25958,15 +25991,15 @@ function unsetOwnedHooksPath(file) {
25958
25991
  return owned;
25959
25992
  }
25960
25993
  function rmOwnedDir(dir) {
25961
- const hookPath = resolve19(dir, HOOK_FILE);
25994
+ const hookPath = resolve20(dir, HOOK_FILE);
25962
25995
  if (!ownedHook(hookPath)) return;
25963
25996
  rmSync(hookPath, { force: true });
25964
- if (existsSync12(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
25997
+ if (existsSync14(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
25965
25998
  }
25966
25999
  function linkedGitDirs(commonDir) {
25967
- const root = resolve19(commonDir, "worktrees");
25968
- if (!existsSync12(root)) return [];
25969
- 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());
25970
26003
  }
25971
26004
  function uninstallPackageWorkerHooks(cwd) {
25972
26005
  let inside;
@@ -25980,14 +26013,14 @@ function uninstallPackageWorkerHooks(cwd) {
25980
26013
  const clear = (configFile) => {
25981
26014
  for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
25982
26015
  };
25983
- clear(resolve19(commonDir, "config"));
25984
- clear(resolve19(commonDir, "config.worktree"));
25985
- rmOwnedDir(resolve19(commonDir, HOOKS_DIR));
25986
- 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);
25987
26020
  if (ownedHook(legacy)) rmSync(legacy, { force: true });
25988
26021
  for (const gitDir of linkedGitDirs(commonDir)) {
25989
- clear(resolve19(gitDir, "config.worktree"));
25990
- rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
26022
+ clear(resolve20(gitDir, "config.worktree"));
26023
+ rmOwnedDir(resolve20(gitDir, HOOKS_DIR));
25991
26024
  }
25992
26025
  }
25993
26026
  function isRecord17(value) {
@@ -26149,7 +26182,7 @@ function fixerBashSeatbeltDenyReason(matched) {
26149
26182
  }
26150
26183
 
26151
26184
  // src/worker-role.ts
26152
- 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";
26153
26186
  var coderOutputVariants = Type22.Union([
26154
26187
  Type22.Object({
26155
26188
  status: Type22.Unknown({ description: CODER_STATUS_DESCRIPTION }),
@@ -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) {
@@ -26722,25 +26755,6 @@ var ROLE_FLAG = {
26722
26755
  type: "string"
26723
26756
  }
26724
26757
  };
26725
- function formatNavigatorRoleHelp(role) {
26726
- const metadata = packagedRoleMetadata(role);
26727
- const lines = [
26728
- `Usage: ak-role ${role}`,
26729
- ROLE_FLAG.definition.description
26730
- ];
26731
- const inputFlag = packagedRoleInputFlag(role);
26732
- if (inputFlag !== void 0) {
26733
- lines.push(` --${inputFlag} <value> ${role} input material`);
26734
- }
26735
- const phaseFlag = packagedRolePhaseFlag(role);
26736
- if (phaseFlag !== void 0 && metadata !== void 0) {
26737
- lines.push(
26738
- ` --${phaseFlag} <value> ${role} phase: ${metadata.phases.filter((p) => p !== null).join(" | ")}`
26739
- );
26740
- }
26741
- lines.push(`Public next-command form: ak-role ${role}`);
26742
- return lines.join("\n");
26743
- }
26744
26758
  function abortContext(ctx) {
26745
26759
  ctx.abort();
26746
26760
  }
@@ -26901,7 +26915,7 @@ function createGatekeeperRoleRuntime(roleHost, dependencies) {
26901
26915
  );
26902
26916
  }
26903
26917
  function createNavigatorRoleRuntime(roleHost, dependencies) {
26904
- return createFiledOfficerRuntime(
26918
+ const base = createFiledOfficerRuntime(
26905
26919
  roleHost,
26906
26920
  {
26907
26921
  role: "navigator",
@@ -26910,6 +26924,42 @@ function createNavigatorRoleRuntime(roleHost, dependencies) {
26910
26924
  },
26911
26925
  dependencies
26912
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
+ };
26913
26963
  }
26914
26964
  function createAuditorRoleRuntime(roleHost, dependencies) {
26915
26965
  const base = createFiledOfficerRuntime(
@@ -26953,7 +27003,7 @@ function readDiaristTicketAssertion(submitted) {
26953
27003
  function readRoleRunCoordinates(ctx, label) {
26954
27004
  const runDirectory = runDirectoryFromHostContext(ctx);
26955
27005
  if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
26956
- const admittedPath = join43(runDirectory, "admitted-request.json");
27006
+ const admittedPath = join44(runDirectory, "admitted-request.json");
26957
27007
  const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
26958
27008
  if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
26959
27009
  throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
@@ -27293,13 +27343,11 @@ function createRoleRuntimeExtension(dependencies) {
27293
27343
  const raced = await raceNavigatorGrace(settlePromise, NAVIGATOR_POST_ROLE_GRACE_MS);
27294
27344
  if (raced.status !== "timeout") return;
27295
27345
  if (pendingNavigatorPresentation === void 0) {
27296
- const routePlaybookReadFailure = attendance.knownRoutePlaybookReadFailure?.();
27297
27346
  const report = {
27298
27347
  disposition: "unavailable",
27299
27348
  unavailableReason: "Navigator exceeded post-role delivery grace",
27300
27349
  unavailableSource: "unknown",
27301
- unavailableCause: "unknown",
27302
- ...routePlaybookReadFailure === void 0 ? {} : { routePlaybookReadFailure }
27350
+ unavailableCause: "unknown"
27303
27351
  };
27304
27352
  const event = {
27305
27353
  version: 1,
@@ -27310,8 +27358,7 @@ function createRoleRuntimeExtension(dependencies) {
27310
27358
  subjectKey: workContext?.subjectKey ?? "",
27311
27359
  unavailableReason: "Navigator exceeded post-role delivery grace",
27312
27360
  unavailableSource: "unknown",
27313
- unavailableCause: "unknown",
27314
- ...routePlaybookReadFailure === void 0 ? {} : { routePlaybookReadFailure }
27361
+ unavailableCause: "unknown"
27315
27362
  };
27316
27363
  pendingNavigatorPresentation = { event, report };
27317
27364
  }
@@ -27522,7 +27569,7 @@ function createRoleRuntimeExtension(dependencies) {
27522
27569
  }
27523
27570
  envelopeHost.sendMessage({
27524
27571
  customType: "ak-receipt-delivery-prompt",
27525
- content: RECEIPT_DELIVERY_PROMPT,
27572
+ content: JSON.stringify(receiptDelivery.deliveryState()),
27526
27573
  display: false
27527
27574
  }, { triggerTurn: true, deliverAs: "followUp" });
27528
27575
  } else if (receiptDelivery.nextAction() === "no-receipt" && !noReceiptRecorded) {
@@ -27686,7 +27733,12 @@ function createRoleRuntimeExtension(dependencies) {
27686
27733
  loadSoul: () => requireRoleSoul("gatekeeper")
27687
27734
  });
27688
27735
  const navigator = createNavigatorRoleRuntime(roleHost, {
27689
- loadSoul: () => requireRoleSoul("navigator")
27736
+ loadSoul: () => requireRoleSoul("navigator"),
27737
+ recordRoutePlaybookReadFailure: (message) => {
27738
+ envelopeHost.appendEntry(NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY, {
27739
+ message: message ?? ""
27740
+ });
27741
+ }
27690
27742
  });
27691
27743
  const auditor = createAuditorRoleRuntime(roleHost, {
27692
27744
  loadSoul: () => requireRoleSoul("auditor")
@@ -27993,7 +28045,6 @@ function createRoleRuntimeExtension(dependencies) {
27993
28045
  pendingNavigatorPresentation = { event: navigatorEvent, report };
27994
28046
  }
27995
28047
  });
27996
- navigatorAttendance.warmHelp?.();
27997
28048
  if (navigatorWorkContext.contextError === void 0 && navigatorWorkContext.subjectProvenance !== "placeholder") {
27998
28049
  navigatorAttendance.prepare();
27999
28050
  }
@@ -28035,21 +28086,20 @@ function loadRegisteredRoleSoul(role) {
28035
28086
  return usesSubjectSoul(role) ? loadAuditorSoulFromSubjectInput() : loadMainRoleSessionMaterials(role);
28036
28087
  }
28037
28088
  function createRoleRuntimeDependencies(packageRoot) {
28038
- const navigatorRoutePlaybookPath = join44(packageRoot, "resources/navigator-route-playbook.md");
28039
- const collectorHandbookSeedPath = join44(packageRoot, "resources/collector-bot-handbook.md");
28089
+ const collectorHandbookSeedPath = join45(packageRoot, "resources/collector-bot-handbook.md");
28040
28090
  const doctorAuditor = createPiDoctorAuditor();
28041
28091
  const navigatorSessionFactory = createNativeNavigatorSessionFactory();
28042
28092
  return {
28043
28093
  packageRoot,
28044
28094
  loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
28045
28095
  loadRoleSoul: loadRegisteredRoleSoul,
28046
- loadFixPacket: (path) => readFile24(path, "utf8"),
28047
- loadCoderTask: (path) => readFile24(path, "utf8"),
28048
- loadCollectorHandbookSeed: () => readFile24(collectorHandbookSeedPath, "utf8"),
28096
+ loadFixPacket: (path) => readFile25(path, "utf8"),
28097
+ loadCoderTask: (path) => readFile25(path, "utf8"),
28098
+ loadCollectorHandbookSeed: () => readFile25(collectorHandbookSeedPath, "utf8"),
28049
28099
  createCollectorTransport: () => createGhCollectorGitHubTransport(),
28050
28100
  loadDoctorCase,
28051
28101
  loadNotarySourceRun: loadNotarySourceRunLocator,
28052
- loadMergerInput: async (path) => JSON.parse(await readFile24(path, "utf8")),
28102
+ loadMergerInput: async (path) => JSON.parse(await readFile25(path, "utf8")),
28053
28103
  // #590: doctor compliance still on disposeCompliance path; judge→auditor is gate queue (#756).
28054
28104
  auditDoctorCompliance: (options) => doctorAuditor(options),
28055
28105
  loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
@@ -28065,9 +28115,6 @@ function createRoleRuntimeDependencies(packageRoot) {
28065
28115
  subject: options.subject,
28066
28116
  authority: options.authority,
28067
28117
  invocationId: options.invocationId,
28068
- loadSoul: () => loadRegisteredRoleSoul("navigator"),
28069
- loadRoutePlaybook: () => readFile24(navigatorRoutePlaybookPath, "utf8"),
28070
- loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
28071
28118
  createSession: navigatorSessionFactory,
28072
28119
  ...options.contextError === void 0 ? {} : { contextError: options.contextError },
28073
28120
  onEvent: options.onEvent
@@ -28080,7 +28127,7 @@ init_engine_detour();
28080
28127
  import { randomUUID as randomUUID9 } from "node:crypto";
28081
28128
  import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile11 } from "node:fs/promises";
28082
28129
  import { createServer } from "node:net";
28083
- import { dirname as dirname22, join as join45 } from "node:path";
28130
+ import { dirname as dirname23, join as join46 } from "node:path";
28084
28131
  import { fileURLToPath as fileURLToPath2 } from "node:url";
28085
28132
 
28086
28133
  // src/submission-gate.ts
@@ -28191,11 +28238,11 @@ init_submission_correctable_error();
28191
28238
  init_navigator_invocation_identity();
28192
28239
  init_serialize_thrown_value();
28193
28240
  async function listen(server, path) {
28194
- await new Promise((resolve21, reject) => {
28241
+ await new Promise((resolve22, reject) => {
28195
28242
  server.once("error", reject);
28196
28243
  server.listen(path, () => {
28197
28244
  server.off("error", reject);
28198
- resolve21();
28245
+ resolve22();
28199
28246
  });
28200
28247
  });
28201
28248
  }
@@ -28230,8 +28277,8 @@ async function prepareRoleEnvelope(options) {
28230
28277
  const hostAbort = new AbortController();
28231
28278
  const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
28232
28279
  await mkdir5(request.runDirectory, { recursive: true });
28233
- let sessionFile = options.sessionFile ?? join45(request.runDirectory, "session", "session.jsonl");
28234
- await mkdir5(dirname22(sessionFile), { recursive: true });
28280
+ let sessionFile = options.sessionFile ?? join46(request.runDirectory, "session", "session.jsonl");
28281
+ await mkdir5(dirname23(sessionFile), { recursive: true });
28235
28282
  if (request.continuation.kind !== "resume") {
28236
28283
  try {
28237
28284
  await writeFile11(
@@ -28281,7 +28328,7 @@ async function prepareRoleEnvelope(options) {
28281
28328
  getLeafEntry: () => sessionEntries.at(-1),
28282
28329
  getLeafId: () => runId,
28283
28330
  getEntries: () => sessionEntries,
28284
- getSessionDir: () => dirname22(sessionFile),
28331
+ getSessionDir: () => dirname23(sessionFile),
28285
28332
  getSessionFile: () => sessionFile,
28286
28333
  getHeader: () => ({ type: "session", id: runId }),
28287
28334
  setSessionFile(path) {
@@ -28639,8 +28686,8 @@ async function prepareRoleEnvelope(options) {
28639
28686
  try {
28640
28687
  const closeAll = server.closeAllConnections;
28641
28688
  if (typeof closeAll === "function") closeAll.call(server);
28642
- await new Promise((resolve21, reject) => {
28643
- server.close((error) => error ? reject(error) : resolve21());
28689
+ await new Promise((resolve22, reject) => {
28690
+ server.close((error) => error ? reject(error) : resolve22());
28644
28691
  });
28645
28692
  } catch (error) {
28646
28693
  cleanupFailures.push(error);
@@ -28772,7 +28819,7 @@ async function prepareRoleEnvelope(options) {
28772
28819
  init_session_identity();
28773
28820
 
28774
28821
  // src/headless-host/description.ts
28775
- import { join as join46 } from "node:path";
28822
+ import { join as join47 } from "node:path";
28776
28823
  function isClaudePrintDescription(description) {
28777
28824
  return description.protocol === "claude-print";
28778
28825
  }
@@ -28780,7 +28827,7 @@ function isCodexExecDescription(description) {
28780
28827
  return description.protocol === "codex-exec";
28781
28828
  }
28782
28829
  function resolveHeadlessBinary(description, operatorHome) {
28783
- return join46(operatorHome, ...description.binaryFromHome);
28830
+ return join47(operatorHome, ...description.binaryFromHome);
28784
28831
  }
28785
28832
  function headlessTurnArgs(options) {
28786
28833
  const { description } = options;
@@ -29042,9 +29089,9 @@ function headlessMcpConfigDocument(mcpServers) {
29042
29089
  // src/headless-host/role-turn-host.ts
29043
29090
  import { spawn as spawn4, spawnSync as spawnSync2 } from "node:child_process";
29044
29091
  import { randomUUID as randomUUID10 } from "node:crypto";
29045
- import { existsSync as existsSync13 } from "node:fs";
29092
+ import { existsSync as existsSync15 } from "node:fs";
29046
29093
  import { writeFile as writeFile12 } from "node:fs/promises";
29047
- 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";
29048
29095
 
29049
29096
  // src/external-host-turn-loop.ts
29050
29097
  init_packaged_role_registry();
@@ -29264,8 +29311,8 @@ function formatCodexFailurePayload(payload) {
29264
29311
  function cwdIsGitWorkTree(cwd) {
29265
29312
  let dir = cwd;
29266
29313
  for (; ; ) {
29267
- if (existsSync13(join47(dir, ".git"))) return true;
29268
- const parent = dirname23(dir);
29314
+ if (existsSync15(join48(dir, ".git"))) return true;
29315
+ const parent = dirname24(dir);
29269
29316
  if (parent === dir) return false;
29270
29317
  dir = parent;
29271
29318
  }
@@ -29293,10 +29340,10 @@ function resolveGitCommonDir(cwd) {
29293
29340
  if (raw === "") {
29294
29341
  throw new Error("git rev-parse --git-common-dir returned empty stdout");
29295
29342
  }
29296
- return isAbsolute12(raw) ? raw : resolve20(cwd, raw);
29343
+ return isAbsolute12(raw) ? raw : resolve21(cwd, raw);
29297
29344
  }
29298
29345
  function spawnHeadlessTurn(options) {
29299
- return new Promise((resolve21, reject) => {
29346
+ return new Promise((resolve22, reject) => {
29300
29347
  if (options.signal?.aborted) {
29301
29348
  reject(hostAbortedError("headless host aborted"));
29302
29349
  return;
@@ -29371,7 +29418,7 @@ function spawnHeadlessTurn(options) {
29371
29418
  reject(stdinDeliveryError);
29372
29419
  return;
29373
29420
  }
29374
- resolve21({ code, stdout: resultStdout, stderr, timedOut });
29421
+ resolve22({ code, stdout: resultStdout, stderr, timedOut });
29375
29422
  };
29376
29423
  const onAbort = () => {
29377
29424
  child.kill("SIGTERM");
@@ -29472,13 +29519,13 @@ function createHeadlessRoleTurnHost(config) {
29472
29519
  await config.sessionIdentity.bind(request.principal, sessionId);
29473
29520
  }
29474
29521
  const env = { ...process.env, ...config.env ?? {} };
29475
- const systemPromptPath = join47(request.runDirectory, "headless-system-prompt.txt");
29522
+ const systemPromptPath = join48(request.runDirectory, "headless-system-prompt.txt");
29476
29523
  await writeFile12(systemPromptPath, systemPrompt, "utf8");
29477
29524
  let mcpConfigPath;
29478
29525
  let outputSchemaPath;
29479
29526
  if (codex) {
29480
29527
  if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
29481
- outputSchemaPath = join47(request.runDirectory, "headless-output-schema.json");
29528
+ outputSchemaPath = join48(request.runDirectory, "headless-output-schema.json");
29482
29529
  await writeFile12(
29483
29530
  outputSchemaPath,
29484
29531
  `${JSON.stringify(closeJsonSchemaForCodex(prepared.jsonSchema), null, 2)}
@@ -29487,7 +29534,7 @@ function createHeadlessRoleTurnHost(config) {
29487
29534
  );
29488
29535
  }
29489
29536
  } else {
29490
- mcpConfigPath = join47(request.runDirectory, "headless-mcp-config.json");
29537
+ mcpConfigPath = join48(request.runDirectory, "headless-mcp-config.json");
29491
29538
  await writeFile12(
29492
29539
  mcpConfigPath,
29493
29540
  `${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}