@akagilnc/pi-workflow-roles 0.1.4977 → 0.1.4989

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/acp-host/production-host.js +460 -462
  2. package/dist/analyst-gate-cycles-read.js +16 -11
  3. package/dist/analyst-metric-families/gate-cycles.js +2 -2
  4. package/dist/audit-escalation.js +19 -4
  5. package/dist/compliance-transport.js +2 -2
  6. package/dist/countersign-contracts.js +6 -5
  7. package/dist/doctor-evidence.js +2 -1
  8. package/dist/gatekeeper-role.js +22 -43
  9. package/dist/headless-host/production-host.js +460 -462
  10. package/dist/inspector-contracts.js +3 -2
  11. package/dist/migrate-book-topology.js +59 -54
  12. package/dist/navigator-invocation-identity.js +6 -4
  13. package/dist/notary-contracts.js +3 -19
  14. package/dist/package-contracts/auditor-output.js +4 -19
  15. package/dist/package-contracts/judge-output.js +6 -5
  16. package/dist/package-contracts/terminating-tools.js +9 -3
  17. package/dist/packaged-role-registry.js +10 -12
  18. package/dist/public-cli/countersign-run.js +1 -1
  19. package/dist/public-cli/main.js +95 -87
  20. package/dist/public-cli/option-definitions.js +2 -2
  21. package/dist/public-cli/settlement.js +15 -12
  22. package/dist/review-submission.js +20 -0
  23. package/dist/submission-errors.js +2 -2
  24. package/dist/submission-ledger.js +16 -2
  25. package/package.json +1 -1
  26. package/souls/doctor-auditor.md +1 -1
  27. package/souls/fixer-auditor.md +4 -4
  28. package/souls/gate-output-guide.md +2 -2
  29. package/souls/inspector.md +1 -1
  30. package/souls/judge-auditor.md +2 -2
  31. package/souls/notary.md +1 -1
  32. package/souls/quality-law.md +1 -1
  33. package/src/analyst-gate-cycles-read.ts +17 -9
  34. package/src/analyst-metric-families/gate-cycles.ts +2 -2
  35. package/src/audit-escalation.ts +27 -7
  36. package/src/auditor-role.ts +1 -1
  37. package/src/compliance-transport.ts +7 -7
  38. package/src/countersign-contracts.ts +10 -8
  39. package/src/countersign-role.ts +6 -35
  40. package/src/doctor-evidence.ts +2 -1
  41. package/src/doctor-role.ts +1 -2
  42. package/src/gatekeeper-role.ts +32 -57
  43. package/src/host-contracts.ts +4 -3
  44. package/src/inspector-contracts.ts +7 -6
  45. package/src/inspector-role.ts +3 -20
  46. package/src/judge-role.ts +31 -51
  47. package/src/navigator-invocation-identity.ts +16 -4
  48. package/src/notary-contracts.ts +8 -26
  49. package/src/notary-role.ts +1 -1
  50. package/src/package-contracts/auditor-output.ts +6 -27
  51. package/src/package-contracts/judge-output.ts +10 -8
  52. package/src/package-contracts/terminating-tools.ts +9 -3
  53. package/src/packaged-role-registry.ts +12 -13
  54. package/src/pi/adapter.ts +6 -5
  55. package/src/public-cli/countersign-run.ts +1 -1
  56. package/src/public-cli/option-definitions.ts +2 -2
  57. package/src/public-cli/settlement.ts +18 -15
  58. package/src/review-submission.ts +29 -0
  59. package/src/role-envelope.ts +17 -9
  60. package/src/role-runtime.ts +32 -15
  61. package/src/submission-errors.ts +6 -6
  62. package/src/{gatekeeper-pass-envelope.ts → submission-gate.ts} +29 -16
  63. package/src/submission-ledger.ts +18 -3
  64. package/src/ticket-trajectory.ts +9 -4
  65. package/src/worker-role.ts +19 -5
@@ -1489,7 +1489,7 @@ function serializeReceipt(receipt) {
1489
1489
  return readableGateItem(receipt);
1490
1490
  }
1491
1491
  function gatekeeperNonPassMessage(result) {
1492
- if (result.status === "bounce" || result.status === "escalate") {
1492
+ if (result.status === "continue" || result.status === "escalate") {
1493
1493
  return serializeReceipt(result.receipt);
1494
1494
  }
1495
1495
  if (result.status === "transport_failure") {
@@ -2657,19 +2657,49 @@ var init_navigator_output = __esm({
2657
2657
  }
2658
2658
  });
2659
2659
 
2660
+ // src/review-submission.ts
2661
+ import { Type as Type6 } from "typebox";
2662
+ var REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, reviewSubmissionSchema;
2663
+ var init_review_submission = __esm({
2664
+ "src/review-submission.ts"() {
2665
+ "use strict";
2666
+ init_open_tool_schema();
2667
+ init_terminating_infrastructure();
2668
+ REVIEW_SUBMISSION_OUTPUT_TOOL_NAME = "ak_submission_output";
2669
+ reviewSubmissionSchema = withTerminatingOutputDeclarations(
2670
+ openToolObject(
2671
+ Type6.Object({
2672
+ status: Type6.Optional(Type6.Unknown({
2673
+ description: "converged | continue | escalate \u2014 \u975E\u4E09\u6001\u65F6\u8BF7\u91CD\u8BFB\u540E\u91CD\u4EA4\uFF0C\u52FF\u6539\u6807\u3002"
2674
+ })),
2675
+ findings: Type6.Optional(Type6.Unknown({ description: "\u5BA1\u6838\u53D1\u73B0\uFF0C\u539F\u6837\u7559\u5B58" })),
2676
+ reason: Type6.Optional(Type6.Unknown({ description: "\u4E0A\u5448\u7406\u7531" })),
2677
+ violations: Type6.Optional(Type6.Unknown({ description: "\u8FDD\u89C4\u6761\u76EE" })),
2678
+ conflicts: Type6.Optional(Type6.Unknown({ description: "\u5F85\u51B3\u51B2\u7A81" })),
2679
+ fix: Type6.Optional(Type6.Unknown({ description: "continue \u65F6\u7684\u8865\u6551\u8BF4\u660E\uFF1B\u53EF\u5199 summary \u6458\u8981\uFF0C\u5176\u4F59\u5185\u5BB9\u539F\u6837\u7559\u5B58" })),
2680
+ classes: Type6.Optional(Type6.Unknown({ description: "\u5DF2\u88C1\u51B3 finding \u7C7B\uFF1B\u53EF\u8BF4\u660E name\u3001owner\u3001boundary\u3001disposition\uFF0C\u539F\u6837\u7559\u5B58" })),
2681
+ note: Type6.Optional(Type6.Unknown({ description: "\u88C1\u51B3\u9644\u6CE8" })),
2682
+ evidence: Type6.Optional(Type6.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
2683
+ decisionGate: Type6.Optional(Type6.Unknown({ description: "\u9700\u4EBA\u6743\u5A01\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879\uFF1B\u53EF\u8BF4\u660E question\u3001options\uFF0C\u539F\u6837\u7559\u5B58" }))
2684
+ })
2685
+ )
2686
+ );
2687
+ }
2688
+ });
2689
+
2660
2690
  // src/package-contracts/judge-output.ts
2661
2691
  function validateAcceptedJudgeDetails(verdict) {
2662
2692
  if (verdict === null || typeof verdict !== "object" || Array.isArray(verdict)) throw new Error("Judge verdict has no execution discriminator");
2663
- let judgeStatus;
2693
+ let status;
2664
2694
  try {
2665
- judgeStatus = verdict.judgeStatus;
2695
+ status = verdict.status;
2666
2696
  } catch {
2667
2697
  throw new Error("Judge verdict has no execution discriminator");
2668
2698
  }
2669
- if (typeof judgeStatus !== "string") {
2699
+ if (typeof status !== "string") {
2670
2700
  throw new Error("Judge verdict has no execution discriminator");
2671
2701
  }
2672
- if (["converged", "continue", "escalate"].includes(judgeStatus)) {
2702
+ if (["converged", "continue", "escalate"].includes(status)) {
2673
2703
  return verdict;
2674
2704
  }
2675
2705
  throw new Error("Judge verdict has no execution discriminator");
@@ -2678,7 +2708,8 @@ var JUDGE_OUTPUT_TOOL_NAME;
2678
2708
  var init_judge_output = __esm({
2679
2709
  "src/package-contracts/judge-output.ts"() {
2680
2710
  "use strict";
2681
- JUDGE_OUTPUT_TOOL_NAME = "ak_judge_output";
2711
+ init_review_submission();
2712
+ JUDGE_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
2682
2713
  }
2683
2714
  });
2684
2715
 
@@ -2692,7 +2723,7 @@ var init_reviewer_output = __esm({
2692
2723
  });
2693
2724
 
2694
2725
  // src/package-contracts/fixer-output.ts
2695
- import { Type as Type6 } from "typebox";
2726
+ import { Type as Type7 } from "typebox";
2696
2727
  function validateFixerOutput(value, _phase) {
2697
2728
  return value;
2698
2729
  }
@@ -2703,39 +2734,39 @@ var init_fixer_output = __esm({
2703
2734
  init_open_tool_schema();
2704
2735
  init_terminating_infrastructure();
2705
2736
  FIXER_OUTPUT_TOOL_NAME = "ak_fixer_output";
2706
- transportString = Type6.String();
2707
- authorityBlockerSchema = Type6.Object({ cause: Type6.Optional(Type6.Literal("authority_violation")), evidence: Type6.Optional(transportString) });
2708
- prerequisiteBlockerSchema = Type6.Object({ cause: Type6.Optional(Type6.Literal("prerequisite_unmet")), prerequisiteId: Type6.Optional(transportString), evidence: Type6.Optional(transportString) });
2709
- blockerSchema = Type6.Union([authorityBlockerSchema, prerequisiteBlockerSchema]);
2710
- exceptionSchema = Type6.Object({ where: Type6.Optional(transportString), reason: Type6.Optional(transportString) });
2711
- testEvidenceSchema = Type6.Object({
2712
- contract: Type6.Optional(Type6.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6" })),
2713
- minimumNecessaryCost: Type6.Optional(Type6.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C" })),
2714
- measuredDuration: Type6.Optional(Type6.String({ description: "\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F" }))
2737
+ transportString = Type7.String();
2738
+ authorityBlockerSchema = Type7.Object({ cause: Type7.Optional(Type7.Literal("authority_violation")), evidence: Type7.Optional(transportString) });
2739
+ prerequisiteBlockerSchema = Type7.Object({ cause: Type7.Optional(Type7.Literal("prerequisite_unmet")), prerequisiteId: Type7.Optional(transportString), evidence: Type7.Optional(transportString) });
2740
+ blockerSchema = Type7.Union([authorityBlockerSchema, prerequisiteBlockerSchema]);
2741
+ exceptionSchema = Type7.Object({ where: Type7.Optional(transportString), reason: Type7.Optional(transportString) });
2742
+ testEvidenceSchema = Type7.Object({
2743
+ contract: Type7.Optional(Type7.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6" })),
2744
+ minimumNecessaryCost: Type7.Optional(Type7.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C" })),
2745
+ measuredDuration: Type7.Optional(Type7.String({ description: "\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F" }))
2715
2746
  }, { description: "\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1Bdiff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u63D0\u4EA4\uFF1B\u673A\u5668\u4E0D\u6838\u9A8C\u3002" });
2716
- completedClassResultSchema = Type6.Object({
2717
- name: Type6.Optional(transportString),
2718
- disposition: Type6.Optional(Type6.Literal("completed")),
2719
- searchScope: Type6.Optional(transportString),
2720
- exceptions: Type6.Optional(Type6.Array(exceptionSchema)),
2721
- commitSha: Type6.Optional(transportString)
2747
+ completedClassResultSchema = Type7.Object({
2748
+ name: Type7.Optional(transportString),
2749
+ disposition: Type7.Optional(Type7.Literal("completed")),
2750
+ searchScope: Type7.Optional(transportString),
2751
+ exceptions: Type7.Optional(Type7.Array(exceptionSchema)),
2752
+ commitSha: Type7.Optional(transportString)
2722
2753
  });
2723
- refusedClassResultSchema = Type6.Object({
2724
- name: Type6.Optional(transportString),
2725
- disposition: Type6.Optional(Type6.Literal("refused")),
2726
- remainingScope: Type6.Optional(transportString),
2727
- blocker: Type6.Optional(blockerSchema)
2754
+ refusedClassResultSchema = Type7.Object({
2755
+ name: Type7.Optional(transportString),
2756
+ disposition: Type7.Optional(Type7.Literal("refused")),
2757
+ remainingScope: Type7.Optional(transportString),
2758
+ blocker: Type7.Optional(blockerSchema)
2728
2759
  });
2729
- classResultSchema = Type6.Union([completedClassResultSchema, refusedClassResultSchema]);
2730
- completedClassResultsSchema = Type6.Array(completedClassResultSchema);
2760
+ classResultSchema = Type7.Union([completedClassResultSchema, refusedClassResultSchema]);
2761
+ completedClassResultsSchema = Type7.Array(completedClassResultSchema);
2731
2762
  FIXER_STATUS_DESCRIPTION = "planned | completed | refused | unfinished | partially_completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1Bunfinished \u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\uFF0C\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002";
2732
- fixerOutputVariants = Type6.Union([
2733
- Type6.Object({ status: Type6.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type6.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }),
2734
- Type6.Object({ status: Type6.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type6.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type6.String({ description: "\u4F9D\u6CD5\u4E0D\u80FD\u5B8C\u6210\u7684\u5DE5\u4F5C\u8303\u56F4" }), blocker: Type6.Unsafe({ ...blockerSchema, description: "\u5408\u6CD5\u963B\u65AD\u5B8C\u6210\u7684 blocker" }) }),
2735
- Type6.Object({ status: Type6.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type6.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type6.String({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }), reason: Type6.Optional(Type6.String({ minLength: 1, description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002" })), classResults: Type6.Optional(Type6.Unsafe({ ...completedClassResultsSchema, description: "\u672C\u5C40\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" })), testEvidence: Type6.Optional(testEvidenceSchema) }),
2736
- Type6.Object({ status: Type6.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type6.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type6.Array(classResultSchema, { description: "\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" }), testEvidence: Type6.Optional(testEvidenceSchema) }),
2737
- Type6.Object({ status: Type6.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type6.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type6.Array(classResultSchema, { description: "\u5404\u7C7B\u62D2\u7EDD\u7ED3\u7B97" }) }),
2738
- Type6.Object({ status: Type6.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type6.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type6.Array(classResultSchema, { description: "\u5404\u7C7B\u5B8C\u6210\u6216\u62D2\u7EDD\u7ED3\u7B97" }), testEvidence: Type6.Optional(testEvidenceSchema) })
2763
+ fixerOutputVariants = Type7.Union([
2764
+ Type7.Object({ status: Type7.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type7.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }),
2765
+ 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" }) }),
2766
+ Type7.Object({ status: Type7.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type7.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type7.String({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }), reason: Type7.Optional(Type7.String({ minLength: 1, description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002" })), classResults: Type7.Optional(Type7.Unsafe({ ...completedClassResultsSchema, description: "\u672C\u5C40\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" })), testEvidence: Type7.Optional(testEvidenceSchema) }),
2767
+ Type7.Object({ status: Type7.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type7.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type7.Array(classResultSchema, { description: "\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" }), testEvidence: Type7.Optional(testEvidenceSchema) }),
2768
+ Type7.Object({ status: Type7.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type7.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type7.Array(classResultSchema, { description: "\u5404\u7C7B\u62D2\u7EDD\u7ED3\u7B97" }) }),
2769
+ Type7.Object({ status: Type7.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type7.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type7.Array(classResultSchema, { description: "\u5404\u7C7B\u5B8C\u6210\u6216\u62D2\u7EDD\u7ED3\u7B97" }), testEvidence: Type7.Optional(testEvidenceSchema) })
2739
2770
  ]);
2740
2771
  fixerOutputSchema = withTerminatingOutputDeclarations(
2741
2772
  openToolObjectFromUnion(fixerOutputVariants)
@@ -2744,7 +2775,7 @@ var init_fixer_output = __esm({
2744
2775
  });
2745
2776
 
2746
2777
  // src/package-contracts/fixer-packet.ts
2747
- import { Type as Type7 } from "typebox";
2778
+ import { Type as Type8 } from "typebox";
2748
2779
  import { Value } from "typebox/value";
2749
2780
  function causeMessage(cause) {
2750
2781
  if (cause instanceof Error) return cause.message;
@@ -2804,11 +2835,11 @@ var init_fixer_packet = __esm({
2804
2835
  "src/package-contracts/fixer-packet.ts"() {
2805
2836
  "use strict";
2806
2837
  FIXER_PREREQUISITE_ID_PATTERN = "^[A-Za-z0-9][A-Za-z0-9._-]*$";
2807
- fixerPrerequisiteSchema = Type7.Object({
2808
- id: Type7.String({ pattern: FIXER_PREREQUISITE_ID_PATTERN }),
2809
- requirement: Type7.String({ pattern: "\\S" })
2838
+ fixerPrerequisiteSchema = Type8.Object({
2839
+ id: Type8.String({ pattern: FIXER_PREREQUISITE_ID_PATTERN }),
2840
+ requirement: Type8.String({ pattern: "\\S" })
2810
2841
  }, { additionalProperties: false });
2811
- fixerPrerequisitesSchema = Type7.Array(fixerPrerequisiteSchema);
2842
+ fixerPrerequisitesSchema = Type8.Array(fixerPrerequisiteSchema);
2812
2843
  FixerPacketValidationError = class extends Error {
2813
2844
  code = "AK_INVALID_FIX_PACKET";
2814
2845
  constructor(cause) {
@@ -2849,7 +2880,7 @@ var init_canonical_json = __esm({
2849
2880
  });
2850
2881
 
2851
2882
  // src/doctor-contracts.ts
2852
- import { Type as Type8 } from "typebox";
2883
+ import { Type as Type9 } from "typebox";
2853
2884
  function validateDoctorSubmissionShape(value) {
2854
2885
  return value;
2855
2886
  }
@@ -2868,43 +2899,43 @@ var init_doctor_contracts = __esm({
2868
2899
  DOCTOR_AUDIT_TOOL_NAME = "ak_doctor_audit_decision";
2869
2900
  DOCTOR_OUTPUT_TOOL_DESCRIPTION = "\u63D0\u4EA4\u552F\u4E00\u7EC8\u5C40\u5355\u6848\u8BC1\u8BCD\uFF1Bcompleted \u5141\u8BB8\u7A7A findings\u3002";
2870
2901
  DOCTOR_TARGET_KINDS = ["law", "gate", "template", "station", "seat"];
2871
- nonblank = Type8.Optional(Type8.String());
2872
- evidenceIds = Type8.Optional(Type8.Array(Type8.String()));
2873
- guardrail = Type8.Object({ answer: Type8.Optional(Type8.Boolean()), evidenceIds, explanation: nonblank }, { additionalProperties: true });
2874
- lastRealBite = Type8.Union([
2875
- Type8.Object({ kind: Type8.Optional(Type8.Literal("actual")), targetKey: nonblank, evidenceId: nonblank }, { additionalProperties: true }),
2876
- Type8.Object({ kind: Type8.Optional(Type8.Literal("noRealBite")), targetKey: nonblank, eligibleEvidenceIds: evidenceIds }, { additionalProperties: true })
2902
+ nonblank = Type9.Optional(Type9.String());
2903
+ evidenceIds = Type9.Optional(Type9.Array(Type9.String()));
2904
+ guardrail = Type9.Object({ answer: Type9.Optional(Type9.Boolean()), evidenceIds, explanation: nonblank }, { additionalProperties: true });
2905
+ lastRealBite = Type9.Union([
2906
+ Type9.Object({ kind: Type9.Optional(Type9.Literal("actual")), targetKey: nonblank, evidenceId: nonblank }, { additionalProperties: true }),
2907
+ Type9.Object({ kind: Type9.Optional(Type9.Literal("noRealBite")), targetKey: nonblank, eligibleEvidenceIds: evidenceIds }, { additionalProperties: true })
2877
2908
  ]);
2878
2909
  assetKinds = DOCTOR_TARGET_KINDS;
2879
2910
  findingBody = {
2880
2911
  evidenceIds,
2881
- disposition: Type8.Optional(Type8.Union([Type8.Literal("keep"), Type8.Literal("thin"), Type8.Literal("delete")])),
2882
- guardrails: Type8.Optional(Type8.Object({ reproducibleFailure: guardrail, owningSeamOrInvariant: guardrail, deletionOrSimplificationSuffices: guardrail }, { additionalProperties: true })),
2883
- prescription: Type8.Optional(Type8.Object({ kind: Type8.Optional(Type8.Union([Type8.Literal("retain"), Type8.Literal("delete"), Type8.Literal("simplify"), Type8.Literal("patch"), Type8.Literal("addMechanism")])), recommendation: nonblank, necessityExplanation: nonblank }, { additionalProperties: true })),
2884
- lastRealBite: Type8.Optional(lastRealBite)
2912
+ disposition: Type9.Optional(Type9.Union([Type9.Literal("keep"), Type9.Literal("thin"), Type9.Literal("delete")])),
2913
+ guardrails: Type9.Optional(Type9.Object({ reproducibleFailure: guardrail, owningSeamOrInvariant: guardrail, deletionOrSimplificationSuffices: guardrail }, { additionalProperties: true })),
2914
+ prescription: Type9.Optional(Type9.Object({ kind: Type9.Optional(Type9.Union([Type9.Literal("retain"), Type9.Literal("delete"), Type9.Literal("simplify"), Type9.Literal("patch"), Type9.Literal("addMechanism")])), recommendation: nonblank, necessityExplanation: nonblank }, { additionalProperties: true })),
2915
+ lastRealBite: Type9.Optional(lastRealBite)
2885
2916
  };
2886
- finding = Type8.Union([
2887
- Type8.Object({ targetKey: nonblank, observation: nonblank, evidenceIds }, { additionalProperties: true }),
2888
- Type8.Object({ targetKey: nonblank, targetKind: Type8.Optional(Type8.Union(assetKinds.map((kind) => Type8.Literal(kind)))), assetEvidence: Type8.Optional(Type8.Object({ targetKey: nonblank, targetKind: Type8.Optional(Type8.Union(assetKinds.map((kind) => Type8.Literal(kind)))), evidenceId: nonblank }, { additionalProperties: true })), ...findingBody }, { additionalProperties: true })
2917
+ finding = Type9.Union([
2918
+ Type9.Object({ targetKey: nonblank, observation: nonblank, evidenceIds }, { additionalProperties: true }),
2919
+ 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 })
2889
2920
  ]);
2890
- caseIdentity = Type8.Object({ issueNumber: Type8.Optional(Type8.Integer()), runsPath: nonblank }, { additionalProperties: true });
2921
+ caseIdentity = Type9.Object({ issueNumber: Type9.Optional(Type9.Integer()), runsPath: nonblank }, { additionalProperties: true });
2891
2922
  DOCTOR_STATUS_DESCRIPTION = "completed | refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1Bcompleted \u5141\u8BB8\u7A7A findings\uFF1Brefused \u4EC5\u5F53\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u6848\u8BC1\u8BCD";
2892
- doctorSubmissionVariants = Type8.Union([
2893
- Type8.Object({
2894
- status: Type8.Unknown({ description: DOCTOR_STATUS_DESCRIPTION }),
2895
- case: Type8.Unsafe({ ...caseIdentity, description: "\u7559\u5B58\u592A\u533B\u7F72\u6848\u8EAB\u4EFD" }),
2896
- findings: Type8.Array(finding, { description: "\u53EF\u7A7A\u6216\u4EC5\u542B\u975E\u5904\u65B9\u6848\u89C2\u5BDF\uFF1B\u7F3A\u53EF\u590D\u7528\u8D44\u4EA7\u6216 bounded-bite \u8BC1\u636E\u53EA\u6392\u9664\u5BF9\u5E94\u8D44\u4EA7\u5904\u65B9" })
2923
+ doctorSubmissionVariants = Type9.Union([
2924
+ Type9.Object({
2925
+ status: Type9.Unknown({ description: DOCTOR_STATUS_DESCRIPTION }),
2926
+ case: Type9.Unsafe({ ...caseIdentity, description: "\u7559\u5B58\u592A\u533B\u7F72\u6848\u8EAB\u4EFD" }),
2927
+ findings: Type9.Array(finding, { description: "\u53EF\u7A7A\u6216\u4EC5\u542B\u975E\u5904\u65B9\u6848\u89C2\u5BDF\uFF1B\u7F3A\u53EF\u590D\u7528\u8D44\u4EA7\u6216 bounded-bite \u8BC1\u636E\u53EA\u6392\u9664\u5BF9\u5E94\u8D44\u4EA7\u5904\u65B9" })
2897
2928
  }, { additionalProperties: false, description: "\u5355\u6848\u8BC1\u8BCD\uFF0C\u4E0D\u8981\u6C42\u4EFB\u4F55\u5904\u65B9\u6216\u53EF\u590D\u7528 finding" }),
2898
- Type8.Object({
2899
- status: Type8.Unknown({ description: DOCTOR_STATUS_DESCRIPTION }),
2900
- reason: Type8.String({ description: "\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u8BC1\u8BCD\u7684\u539F\u56E0" }),
2901
- missingEvidence: Type8.Array(Type8.Object({ need: nonblank, targetKeys: evidenceIds }, { additionalProperties: true }), { description: "\u5982\u5B9E\u8BC1\u8BCD\u6240\u9700\u800C\u5C1A\u7F3A\u7684\u8BC1\u636E" })
2929
+ Type9.Object({
2930
+ status: Type9.Unknown({ description: DOCTOR_STATUS_DESCRIPTION }),
2931
+ reason: Type9.String({ description: "\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u8BC1\u8BCD\u7684\u539F\u56E0" }),
2932
+ missingEvidence: Type9.Array(Type9.Object({ need: nonblank, targetKeys: evidenceIds }, { additionalProperties: true }), { description: "\u5982\u5B9E\u8BC1\u8BCD\u6240\u9700\u800C\u5C1A\u7F3A\u7684\u8BC1\u636E" })
2902
2933
  }, { additionalProperties: false, description: "\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u6848\u8BC1\u8BCD" })
2903
2934
  ]);
2904
2935
  doctorSubmissionSchema = withTerminatingOutputDeclarations(
2905
2936
  openToolObjectFromUnion(doctorSubmissionVariants)
2906
2937
  );
2907
- doctorEvidenceReadSchema = Type8.Object({ evidenceId: Type8.String({ minLength: 1, description: "\u5F85\u8BFB\u7559\u5B58\u8BC1\u636E\u6807\u8BC6" }), offset: Type8.Optional(Type8.Integer({ minimum: 0, description: "\u8D77\u59CB\u5B57\u8282\u504F\u79FB\uFF08\u4ECE 0 \u8BA1\uFF09" })), limit: Type8.Optional(Type8.Integer({ minimum: 1, description: "\u8FD4\u56DE\u5B57\u8282\u6570\uFF08\u65E0\u4E0A\u9650\uFF09" })) }, { additionalProperties: true });
2938
+ doctorEvidenceReadSchema = Type9.Object({ evidenceId: Type9.String({ minLength: 1, description: "\u5F85\u8BFB\u7559\u5B58\u8BC1\u636E\u6807\u8BC6" }), offset: Type9.Optional(Type9.Integer({ minimum: 0, description: "\u8D77\u59CB\u5B57\u8282\u504F\u79FB\uFF08\u4ECE 0 \u8BA1\uFF09" })), limit: Type9.Optional(Type9.Integer({ minimum: 1, description: "\u8FD4\u56DE\u5B57\u8282\u6570\uFF08\u65E0\u4E0A\u9650\uFF09" })) }, { additionalProperties: true });
2908
2939
  DoctorEvidenceStore = class {
2909
2940
  constructor(patient) {
2910
2941
  this.patient = patient;
@@ -2973,7 +3004,7 @@ var init_exact_utf8 = __esm({
2973
3004
  });
2974
3005
 
2975
3006
  // src/merger-contracts.ts
2976
- import { Type as Type9 } from "typebox";
3007
+ import { Type as Type10 } from "typebox";
2977
3008
  function fail3(message = "Merger input violates its exact contract") {
2978
3009
  throw new MergerInputContractError(message);
2979
3010
  }
@@ -3003,21 +3034,21 @@ var init_merger_contracts = __esm({
3003
3034
  init_exact_utf8();
3004
3035
  init_open_tool_schema();
3005
3036
  init_terminating_infrastructure();
3006
- materialSchema = Type9.Object({ bytesBase64: Type9.String(), sha256: Type9.String() }, { additionalProperties: false });
3007
- checkSchema = Type9.Object({ name: Type9.String({ minLength: 1 }), argv: Type9.Array(Type9.String({ minLength: 1 }), { minItems: 1 }) }, { additionalProperties: false });
3008
- mergerInputSchema = Type9.Object({
3009
- attemptId: Type9.String({ minLength: 1, description: "\u5BF9\u8D26 attempt \u8EAB\u4EFD\uFF08transport\uFF09" }),
3010
- targetObjectId: Type9.String({ description: "\u6750\u6599\uFF1Atarget parent OID\uFF1B\u53EF\u7A7A" }),
3011
- sourceObjectId: Type9.String({ description: "\u6750\u6599\uFF1Asource parent OID\uFF1B\u53EF\u7A7A" }),
3012
- materials: Type9.Object({ task: materialSchema, authority: materialSchema, targetIntent: materialSchema, sourceIntent: materialSchema }, { additionalProperties: false }),
3013
- expectedConflictPaths: Type9.Array(Type9.String(), { description: "\u6750\u6599\uFF1A\u5F53\u524D\u672A\u5408\u5E76\u8DEF\u5F84\uFF1B\u53EF\u7A7A" }),
3014
- resolutionScope: Type9.Array(Type9.String(), { description: "\u6750\u6599\uFF1A\u89E3\u6790\u8303\u56F4\u63D0\u793A\uFF1B\u53EF\u7A7A" }),
3015
- authorizedChecks: Type9.Array(checkSchema)
3037
+ materialSchema = Type10.Object({ bytesBase64: Type10.String(), sha256: Type10.String() }, { additionalProperties: false });
3038
+ checkSchema = Type10.Object({ name: Type10.String({ minLength: 1 }), argv: Type10.Array(Type10.String({ minLength: 1 }), { minItems: 1 }) }, { additionalProperties: false });
3039
+ mergerInputSchema = Type10.Object({
3040
+ attemptId: Type10.String({ minLength: 1, description: "\u5BF9\u8D26 attempt \u8EAB\u4EFD\uFF08transport\uFF09" }),
3041
+ targetObjectId: Type10.String({ description: "\u6750\u6599\uFF1Atarget parent OID\uFF1B\u53EF\u7A7A" }),
3042
+ sourceObjectId: Type10.String({ description: "\u6750\u6599\uFF1Asource parent OID\uFF1B\u53EF\u7A7A" }),
3043
+ materials: Type10.Object({ task: materialSchema, authority: materialSchema, targetIntent: materialSchema, sourceIntent: materialSchema }, { additionalProperties: false }),
3044
+ expectedConflictPaths: Type10.Array(Type10.String(), { description: "\u6750\u6599\uFF1A\u5F53\u524D\u672A\u5408\u5E76\u8DEF\u5F84\uFF1B\u53EF\u7A7A" }),
3045
+ resolutionScope: Type10.Array(Type10.String(), { description: "\u6750\u6599\uFF1A\u89E3\u6790\u8303\u56F4\u63D0\u793A\uFF1B\u53EF\u7A7A" }),
3046
+ authorizedChecks: Type10.Array(checkSchema)
3016
3047
  }, { additionalProperties: false });
3017
3048
  MERGER_STATUS_DESCRIPTION = "completed | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8";
3018
- mergerOutputVariants = Type9.Union([
3019
- Type9.Object({ status: Type9.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: Type9.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), report: Type9.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), mergeCommitId: Type9.String({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }) }, { additionalProperties: false }),
3020
- Type9.Object({ status: Type9.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: Type9.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), diagnosis: Type9.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: Type9.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }, { additionalProperties: false })
3049
+ mergerOutputVariants = Type10.Union([
3050
+ Type10.Object({ status: Type10.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: Type10.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), report: Type10.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), mergeCommitId: Type10.String({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }) }, { additionalProperties: false }),
3051
+ 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 })
3021
3052
  ]);
3022
3053
  mergerOutputSchema = withTerminatingOutputDeclarations(openToolObjectFromUnion(mergerOutputVariants));
3023
3054
  MERGER_OUTPUT_TOOL_NAME = "ak_merger_output";
@@ -3035,14 +3066,12 @@ var init_merger_contracts = __esm({
3035
3066
  });
3036
3067
 
3037
3068
  // src/notary-contracts.ts
3038
- import { Type as Type10 } from "typebox";
3039
3069
  var NOTARY_OUTPUT_TOOL_NAME, NOTARY_SOURCE_RUN_FLAG, NOTARY_TICKET_FLAG, NOTARY_FIXED_KICKOFF, notaryOutputSchema;
3040
3070
  var init_notary_contracts = __esm({
3041
3071
  "src/notary-contracts.ts"() {
3042
3072
  "use strict";
3043
- init_open_tool_schema();
3044
- init_terminating_infrastructure();
3045
- NOTARY_OUTPUT_TOOL_NAME = "ak_notary_output";
3073
+ init_review_submission();
3074
+ NOTARY_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
3046
3075
  NOTARY_SOURCE_RUN_FLAG = {
3047
3076
  name: "ak-notary-source-run",
3048
3077
  definition: {
@@ -3058,21 +3087,7 @@ var init_notary_contracts = __esm({
3058
3087
  }
3059
3088
  };
3060
3089
  NOTARY_FIXED_KICKOFF = "\u7B26\u5B9D\u90CE\u6848\u5377\u5DF2\u53D7\u7406\uFF1B\u6765\u6E90 run \u5B9A\u4F4D\u89C1\u4F1A\u8BDD\u6750\u6599\u3002";
3061
- notaryOutputSchema = withTerminatingOutputDeclarations(
3062
- openToolObject(
3063
- Type10.Object({
3064
- status: Type10.Unknown({
3065
- description: "pass | bounce | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
3066
- }),
3067
- findings: Type10.Unknown({
3068
- description: "string[] findings\uFF0C\u968F pass\u3001bounce \u6216 escalate \u7559\u5B58"
3069
- }),
3070
- reason: Type10.Optional(Type10.Unknown({
3071
- description: "status \u4E3A escalate \u65F6\u7684\u4E0A\u5448\u7406\u7531"
3072
- }))
3073
- })
3074
- )
3075
- );
3090
+ notaryOutputSchema = reviewSubmissionSchema;
3076
3091
  }
3077
3092
  });
3078
3093
 
@@ -3081,7 +3096,8 @@ var COUNTERSIGN_OUTPUT_TOOL_NAME;
3081
3096
  var init_countersign_contracts = __esm({
3082
3097
  "src/countersign-contracts.ts"() {
3083
3098
  "use strict";
3084
- COUNTERSIGN_OUTPUT_TOOL_NAME = "ak_countersign_output";
3099
+ init_review_submission();
3100
+ COUNTERSIGN_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
3085
3101
  }
3086
3102
  });
3087
3103
 
@@ -3106,7 +3122,8 @@ var INSPECTOR_OUTPUT_TOOL_NAME, INSPECTOR_SOURCE_RUN_FLAG;
3106
3122
  var init_inspector_contracts = __esm({
3107
3123
  "src/inspector-contracts.ts"() {
3108
3124
  "use strict";
3109
- INSPECTOR_OUTPUT_TOOL_NAME = "ak_inspector_output";
3125
+ init_review_submission();
3126
+ INSPECTOR_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
3110
3127
  INSPECTOR_SOURCE_RUN_FLAG = {
3111
3128
  name: "ak-inspector-source-run",
3112
3129
  definition: {
@@ -3118,32 +3135,13 @@ var init_inspector_contracts = __esm({
3118
3135
  });
3119
3136
 
3120
3137
  // src/package-contracts/auditor-output.ts
3121
- import { Type as Type11 } from "typebox";
3122
3138
  var AUDITOR_OUTPUT_TOOL_NAME, auditorOutputSchema;
3123
3139
  var init_auditor_output = __esm({
3124
3140
  "src/package-contracts/auditor-output.ts"() {
3125
3141
  "use strict";
3126
- init_open_tool_schema();
3127
- init_terminating_infrastructure();
3128
- AUDITOR_OUTPUT_TOOL_NAME = "ak_auditor_output";
3129
- auditorOutputSchema = withTerminatingOutputDeclarations(
3130
- openToolObject(
3131
- Type11.Object({
3132
- status: Type11.Unknown({
3133
- description: "pass | bounce | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
3134
- }),
3135
- violations: Type11.Optional(Type11.Unknown({
3136
- description: "status \u4E3A bounce \u65F6\u7684\u8FDD\u89C4\u6761\u76EE"
3137
- })),
3138
- conflicts: Type11.Optional(Type11.Unknown({
3139
- description: "status \u4E3A escalate \u65F6\u7684\u51B2\u7A81"
3140
- })),
3141
- decisionGate: Type11.Optional(Type11.Unknown({
3142
- description: "status \u4E3A escalate \u65F6\u7684\u51B3\u7B56\u95F8"
3143
- }))
3144
- })
3145
- )
3146
- );
3142
+ init_review_submission();
3143
+ AUDITOR_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
3144
+ auditorOutputSchema = reviewSubmissionSchema;
3147
3145
  }
3148
3146
  });
3149
3147
 
@@ -3362,6 +3360,7 @@ var packaged_role_registry_exports = {};
3362
3360
  __export(packaged_role_registry_exports, {
3363
3361
  AUDITOR_PUBLIC_SESSION_MATERIALS: () => AUDITOR_PUBLIC_SESSION_MATERIALS,
3364
3362
  INSPECTOR_SESSION_MATERIALS: () => INSPECTOR_SESSION_MATERIALS,
3363
+ LEGACY_REVIEW_OUTPUT_ROLES: () => LEGACY_REVIEW_OUTPUT_ROLES,
3365
3364
  NOTARY_SESSION_MATERIALS: () => NOTARY_SESSION_MATERIALS,
3366
3365
  PACKAGED_ROLE_REGISTRY: () => PACKAGED_ROLE_REGISTRY,
3367
3366
  PUBLIC_ROLE_RECORDS: () => PUBLIC_ROLE_RECORDS,
@@ -3378,7 +3377,6 @@ __export(packaged_role_registry_exports, {
3378
3377
  packagedBoardPlacement: () => packagedBoardPlacement,
3379
3378
  packagedDurableOfficerEntry: () => packagedDurableOfficerEntry,
3380
3379
  packagedEmitsAuthorityRefs: () => packagedEmitsAuthorityRefs,
3381
- packagedGateDecision: () => packagedGateDecision,
3382
3380
  packagedGateStageLabel: () => packagedGateStageLabel,
3383
3381
  packagedGateSummon: () => packagedGateSummon,
3384
3382
  packagedMethodLoadFailureCause: () => packagedMethodLoadFailureCause,
@@ -3545,14 +3543,7 @@ function packagedGateSummon(role) {
3545
3543
  if (record4 !== void 0 && "gateSummon" in record4) return record4.gateSummon;
3546
3544
  return "pointer";
3547
3545
  }
3548
- function packagedGateDecision(role) {
3549
- const record4 = packagedRoleMetadata(role);
3550
- if (record4 !== void 0 && "gateDecision" in record4 && record4.gateDecision === "countersign-status") {
3551
- return "countersign-status";
3552
- }
3553
- return "three-state";
3554
- }
3555
- var NOTARY_SESSION_MATERIALS, INSPECTOR_SESSION_MATERIALS, AUDITOR_PUBLIC_SESSION_MATERIALS, PUBLIC_ROLE_RECORDS, PACKAGED_ROLE_REGISTRY;
3546
+ var LEGACY_REVIEW_OUTPUT_ROLES, NOTARY_SESSION_MATERIALS, INSPECTOR_SESSION_MATERIALS, AUDITOR_PUBLIC_SESSION_MATERIALS, PUBLIC_ROLE_RECORDS, PACKAGED_ROLE_REGISTRY;
3556
3547
  var init_packaged_role_registry = __esm({
3557
3548
  "src/packaged-role-registry.ts"() {
3558
3549
  "use strict";
@@ -3573,6 +3564,13 @@ var init_packaged_role_registry = __esm({
3573
3564
  init_diarist_contracts();
3574
3565
  init_secretariat_contracts();
3575
3566
  init_judge_auditor();
3567
+ LEGACY_REVIEW_OUTPUT_ROLES = /* @__PURE__ */ new Map([
3568
+ ["ak_judge_output", "judge"],
3569
+ ["ak_notary_output", "notary"],
3570
+ ["ak_countersign_output", "countersign"],
3571
+ ["ak_inspector_output", "inspector"],
3572
+ ["ak_auditor_output", "auditor"]
3573
+ ]);
3576
3574
  NOTARY_SESSION_MATERIALS = [
3577
3575
  "CLAUDE.md",
3578
3576
  "souls/notary.md",
@@ -3614,7 +3612,7 @@ var init_packaged_role_registry = __esm({
3614
3612
  /** Navigator subject is the public admitted instruction when the run is bound. */
3615
3613
  navigatorSubject: "public-instruction",
3616
3614
  activationStage: "load-and-install",
3617
- receiptStatusKey: "judgeStatus",
3615
+ receiptStatusKey: "status",
3618
3616
  sessionMaterials: [
3619
3617
  "CLAUDE.md",
3620
3618
  "souls/judge.md",
@@ -3896,15 +3894,13 @@ var init_packaged_role_registry = __esm({
3896
3894
  outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
3897
3895
  settlement: "accepted",
3898
3896
  gateStageLabel: "\u7ED9\u4E8B\u4E2D",
3899
- /** Gate queue reads countersignStatus, not the shared three-state status. */
3900
- gateDecision: "countersign-status",
3901
3897
  /** Gate summon carries the parent payload as the instruction and a parent run id. */
3902
3898
  gateSummon: "parent-instruction",
3903
3899
  activationFlags: [
3904
3900
  { field: "ticketNumber" }
3905
3901
  ],
3906
3902
  activationStage: "load-and-install",
3907
- receiptStatusKey: "countersignStatus",
3903
+ receiptStatusKey: "status",
3908
3904
  // #924: 公用《票面法》三席同装
3909
3905
  sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md"]
3910
3906
  },
@@ -4270,32 +4266,22 @@ function readRecord(value) {
4270
4266
  if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
4271
4267
  return value;
4272
4268
  }
4273
- function gateStatusFromCountersign(status) {
4274
- if (status === "converged") return "pass";
4275
- if (status === "continue") return "bounce";
4269
+ function reviewQueueStatus(status) {
4270
+ if (status === "converged") return "converged";
4271
+ if (status === "continue") return "continue";
4276
4272
  if (status === "escalate") return "escalate";
4277
4273
  return void 0;
4278
4274
  }
4279
4275
  function projectOfficerDecision(officer, decision, fallbackStatus) {
4280
4276
  const receipt = retainedReceipt(decision);
4281
4277
  const record4 = readRecord(decision);
4282
- if (packagedGateDecision(officer) === "countersign-status") {
4283
- const countersignStatus = record4 !== void 0 && typeof record4.countersignStatus === "string" ? record4.countersignStatus : void 0;
4284
- const status2 = typeof countersignStatus === "string" ? gateStatusFromCountersign(countersignStatus) : void 0;
4285
- if (status2 === "pass") {
4286
- return { status: "pass", officer, receipt };
4287
- }
4288
- if (status2 === "bounce" || status2 === "escalate") {
4289
- return { status: status2, officer, receipt };
4290
- }
4291
- return { status: "needs_reask", officer, receipt };
4292
- }
4293
4278
  const status = (record4 !== void 0 && typeof record4.status === "string" ? record4.status : void 0) ?? fallbackStatus;
4294
- if (status === "pass") {
4295
- return { status: "pass", officer, receipt };
4279
+ const queueStatus = typeof status === "string" ? reviewQueueStatus(status) : void 0;
4280
+ if (queueStatus === "converged") {
4281
+ return { status: "converged", officer, receipt };
4296
4282
  }
4297
- if (status === "bounce" || status === "escalate") {
4298
- return { status, officer, receipt };
4283
+ if (queueStatus === "continue" || queueStatus === "escalate") {
4284
+ return { status: queueStatus, officer, receipt };
4299
4285
  }
4300
4286
  return { status: "needs_reask", officer, receipt };
4301
4287
  }
@@ -4327,7 +4313,7 @@ function officerRunIdFromSummoned(summoned) {
4327
4313
  return void 0;
4328
4314
  }
4329
4315
  function withOfficerRunId(result, summoned) {
4330
- if (result.status !== "pass" && result.status !== "bounce" && result.status !== "escalate" && result.status !== "needs_reask") {
4316
+ if (result.status !== "converged" && result.status !== "continue" && result.status !== "escalate" && result.status !== "needs_reask") {
4331
4317
  return result;
4332
4318
  }
4333
4319
  if (typeof result.runId === "string" && result.runId.trim() !== "") return result;
@@ -4394,7 +4380,7 @@ function projectOfficerTerminal(officer, summoned) {
4394
4380
  );
4395
4381
  }
4396
4382
  function officerConclusionReask(officer) {
4397
- return packagedGateDecision(officer) === "countersign-status" ? COUNTERSIGN_CONCLUSION_REASK : OFFICER_CONCLUSION_REASK;
4383
+ return OFFICER_CONCLUSION_REASK;
4398
4384
  }
4399
4385
  async function projectGatekeeperRun(options) {
4400
4386
  const officer = gateOfficerForSubject(options.subject);
@@ -4430,7 +4416,7 @@ async function projectGatekeeperRun(options) {
4430
4416
  summoned
4431
4417
  };
4432
4418
  }
4433
- var GATE_OFFICER_BY_SUBJECT, GATEKEEPER_TOOL_SPEC, OFFICER_CONCLUSION_REASK, COUNTERSIGN_CONCLUSION_REASK;
4419
+ var GATE_OFFICER_BY_SUBJECT, GATEKEEPER_TOOL_SPEC, OFFICER_CONCLUSION_REASK;
4434
4420
  var init_gatekeeper_role = __esm({
4435
4421
  "src/gatekeeper-role.ts"() {
4436
4422
  "use strict";
@@ -4438,6 +4424,7 @@ var init_gatekeeper_role = __esm({
4438
4424
  init_packaged_role_registry();
4439
4425
  init_submission_errors();
4440
4426
  init_inspector_contracts();
4427
+ init_review_submission();
4441
4428
  init_gatekeeper_output();
4442
4429
  init_run_terminal_artifacts();
4443
4430
  init_submission_errors();
@@ -4455,8 +4442,7 @@ var init_gatekeeper_role = __esm({
4455
4442
  promptSnippet: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
4456
4443
  parameters: gatekeeperOutputSchema
4457
4444
  };
4458
- OFFICER_CONCLUSION_REASK = "\u4E0A\u6B21\u4EA4\u5377\u7684\u7ED3\u8BBA\u4E0D\u662F pass\u3001bounce\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u8F93\u51FA\uFF0C\u7ED3\u8BBA\u5B57\u6BB5\u5199\u660E\u5176\u4E00\uFF1B\u6253\u56DE\u6216\u4E0A\u5448\u7684\u8BDD\u5C31\u662F\u7ED9\u5BF9\u65B9\u770B\u7684\u539F\u6587\u3002";
4459
- COUNTERSIGN_CONCLUSION_REASK = "\u4E0A\u6B21\u4EA4\u5377\u7684 countersignStatus \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u8F93\u51FA\uFF0CcountersignStatus \u5199\u660E\u5176\u4E00\uFF1B\u5C01\u9A73\u6216\u4E0A\u5448\u7684\u8BDD\u5C31\u662F\u7ED9\u5BF9\u65B9\u770B\u7684\u539F\u6587\u3002";
4445
+ OFFICER_CONCLUSION_REASK = "\u4E0A\u6B21\u4EA4\u5377\u7684 status \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u8F93\u51FA\uFF0Cstatus \u5199\u660E\u5176\u4E00\uFF1Bcontinue \u6216 escalate \u7684\u8BDD\u5C31\u662F\u7ED9\u5BF9\u65B9\u770B\u7684\u539F\u6587\u3002";
4460
4446
  }
4461
4447
  });
4462
4448
 
@@ -6061,7 +6047,8 @@ function validateAcceptedDetails(_toolName, details) {
6061
6047
  function acceptedFacts(toolName, details) {
6062
6048
  const record4 = details;
6063
6049
  const entry = PACKAGED_ROLE_REGISTRY.find((candidate) => candidate.outputTool === toolName);
6064
- const statusKey = entry !== void 0 && "receiptStatusKey" in entry ? entry.receiptStatusKey : "status";
6050
+ const legacyRole = LEGACY_REVIEW_OUTPUT_ROLES.get(toolName);
6051
+ const statusKey = legacyRole === "judge" || legacyRole === "countersign" ? `${legacyRole}Status` : entry !== void 0 && "receiptStatusKey" in entry ? entry.receiptStatusKey : "status";
6065
6052
  const status = typeof record4[statusKey] === "string" ? record4[statusKey] : void 0;
6066
6053
  const commitKey = entry !== void 0 && "receiptCommitKey" in entry ? entry.receiptCommitKey : void 0;
6067
6054
  const commitWhen = entry !== void 0 && "receiptCommitWhen" in entry ? entry.receiptCommitWhen : void 0;
@@ -6092,7 +6079,10 @@ var init_terminating_tools = __esm({
6092
6079
  init_diarist_contracts();
6093
6080
  init_secretariat_contracts();
6094
6081
  init_worker_output();
6095
- TERMINATING_TOOL_NAMES = PACKAGED_ROLE_REGISTRY.map((entry) => entry.outputTool);
6082
+ TERMINATING_TOOL_NAMES = [.../* @__PURE__ */ new Set([
6083
+ ...PACKAGED_ROLE_REGISTRY.map((entry) => entry.outputTool),
6084
+ ...LEGACY_REVIEW_OUTPUT_ROLES.keys()
6085
+ ])];
6096
6086
  AcceptedDetailsContractError = class extends CorrectableSubmissionError {
6097
6087
  code = "accepted_details_contract";
6098
6088
  constructor(message, options) {
@@ -6174,6 +6164,7 @@ function deriveSession(content, id) {
6174
6164
  let accepted, observedCommit, turns = 0, calls = 0, tokens = 0;
6175
6165
  const statuses = [], commits = [];
6176
6166
  for (const row of rows) {
6167
+ if (row.type === "custom" && row.customType === "ak-role-submission-closure" && record3(row.data) && row.data.isError === false && typeof row.data.toolName === "string" && isTerminatingToolName(row.data.toolName)) accepted = row;
6177
6168
  const message = record3(row.message) ? row.message : void 0;
6178
6169
  if (message?.role === "assistant") {
6179
6170
  for (const part of Array.isArray(message.content) ? message.content : []) if (record3(part) && part.type === "toolCall") calls++;
@@ -6191,7 +6182,6 @@ function deriveSession(content, id) {
6191
6182
  if (error instanceof AcceptedDetailsContractError) continue;
6192
6183
  throw error;
6193
6184
  }
6194
- accepted = row;
6195
6185
  const facts = acceptedFacts(message.toolName, details);
6196
6186
  if (facts.commit && facts.commit !== observedCommit) {
6197
6187
  commits.push({ source: id, commit: facts.commit });
@@ -9907,7 +9897,7 @@ var init_option_definitions = __esm({
9907
9897
  },
9908
9898
  inspector: {
9909
9899
  command: "inspector",
9910
- summary: "Direct Inspector (\u53F0\u9662) complexity and test-quality check; pass or bounce.",
9900
+ summary: "Direct Inspector (\u53F0\u9662) complexity and test-quality check; converged, continue, or escalate.",
9911
9901
  usage: ["ak-role inspector [options] [instruction]"],
9912
9902
  examples: [
9913
9903
  'ak-role inspector --attach ./change.patch "Review this material."'
@@ -9931,7 +9921,7 @@ var init_option_definitions = __esm({
9931
9921
  },
9932
9922
  auditor: {
9933
9923
  command: "auditor",
9934
- summary: "Direct Auditor (\u5BA1\u5211\u9662) compliance audit: pass, bounce, or escalate.",
9924
+ summary: "Direct Auditor (\u5BA1\u5211\u9662) compliance audit: converged, continue, or escalate.",
9935
9925
  usage: ["ak-role auditor --subject <judge|doctor> --source-run <runId@role|path> [options] [instruction]"],
9936
9926
  examples: [
9937
9927
  'ak-role auditor --subject judge --source-run 01abc\u2026@judge --attach ./dossier "\u5BA1\uFF1A\u672C run \u662F\u5426\u5408\u89C4\u3002"',
@@ -12682,7 +12672,7 @@ function optionalDispatchReason(raw) {
12682
12672
  return raw;
12683
12673
  }
12684
12674
  function isGateTerminatingToolName(toolName) {
12685
- return DISPATCH_TOOLS.has(toolName) || OFFICER_TOOL_TO_FACE[toolName] !== void 0;
12675
+ return toolName === "ak_submission_output" || DISPATCH_TOOLS.has(toolName) || OFFICER_TOOL_TO_FACE[toolName] !== void 0;
12686
12676
  }
12687
12677
  function acceptedGateReceiptIds(rows) {
12688
12678
  const accepted = /* @__PURE__ */ new Set();
@@ -12757,7 +12747,7 @@ function extractAllAcceptedGateToolCalls(rows) {
12757
12747
  }
12758
12748
  return out;
12759
12749
  }
12760
- function projectAcceptedGateCall(filePath, rows, call) {
12750
+ function projectAcceptedGateCall(filePath, rows, call, pointerOfficer) {
12761
12751
  const span = requireAcceptedGateSpan(intervalRowsForGateCall(rows, call.rowIndex), filePath);
12762
12752
  const status = readAcceptedGateStatus(call.args);
12763
12753
  const findings = asFindings(call.args?.findings);
@@ -12784,7 +12774,7 @@ function projectAcceptedGateCall(filePath, rows, call) {
12784
12774
  ...bindingFields
12785
12775
  };
12786
12776
  }
12787
- const officer = OFFICER_TOOL_TO_FACE[call.toolName];
12777
+ const officer = call.toolName === "ak_submission_output" ? pointerOfficer : OFFICER_TOOL_TO_FACE[call.toolName];
12788
12778
  if (officer === void 0) {
12789
12779
  throw new Error(
12790
12780
  `accepted gate receipt has unknown officer tool ${call.toolName} in ${filePath}`
@@ -12802,13 +12792,13 @@ function projectAcceptedGateCall(filePath, rows, call) {
12802
12792
  ...bindingFields
12803
12793
  };
12804
12794
  }
12805
- async function classifyAuditorVolume(filePath) {
12795
+ async function classifyAuditorVolume(filePath, pointerOfficer) {
12806
12796
  const rows = await readLedgerSessionJsonl(filePath);
12807
12797
  const accepted = extractAllAcceptedGateToolCalls(rows);
12808
12798
  if (accepted.length === 0) return [];
12809
12799
  const volumes = [];
12810
12800
  for (const call of accepted) {
12811
- const projected = projectAcceptedGateCall(filePath, rows, call);
12801
+ const projected = call.toolName === "ak_submission_output" && pointerOfficer === void 0 ? void 0 : projectAcceptedGateCall(filePath, rows, call, pointerOfficer);
12812
12802
  if (projected !== void 0) volumes.push(projected);
12813
12803
  }
12814
12804
  return volumes;
@@ -12888,7 +12878,8 @@ async function resolveOfficerSessionFromPointerFile(pointerPath) {
12888
12878
  if (typeof sessionFile !== "string" || sessionFile.trim() === "") {
12889
12879
  throw new Error(`direct officer run pointer missing sessionFile in ${pointerPath}`);
12890
12880
  }
12891
- return sessionFile;
12881
+ const officer = raw.officer === "inspector" || raw.officer === "notary" ? raw.officer : void 0;
12882
+ return { sessionFile, ...officer === void 0 ? {} : { officer } };
12892
12883
  }
12893
12884
  async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, options = {}) {
12894
12885
  const directories = typeof auditorRolesDirectory === "string" ? [auditorRolesDirectory] : auditorRolesDirectory;
@@ -12908,13 +12899,13 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
12908
12899
  for (const name of names) {
12909
12900
  const path = join22(directory, name);
12910
12901
  const fromPointer = name.endsWith(".pointer.json");
12911
- const sessionPath = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : path;
12912
- if (sessionPath === void 0) continue;
12902
+ const pointer = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : void 0;
12903
+ const sessionPath = pointer?.sessionFile ?? path;
12913
12904
  if (fromPointer) {
12914
12905
  if (classifiedOfficerSessions.has(sessionPath)) continue;
12915
12906
  classifiedOfficerSessions.add(sessionPath);
12916
12907
  }
12917
- const classified = await classifyAuditorVolume(sessionPath);
12908
+ const classified = await classifyAuditorVolume(sessionPath, pointer?.officer);
12918
12909
  for (const volume of classified) {
12919
12910
  if (options.parentSessionFile !== void 0 && volume.parentSessionFile !== void 0 && volume.parentSessionFile !== options.parentSessionFile) {
12920
12911
  continue;
@@ -12955,7 +12946,8 @@ __export(audit_escalation_exports, {
12955
12946
  disposeComplianceDecision: () => disposeComplianceDecision,
12956
12947
  isAuditEscalationProjection: () => isAuditEscalationProjection,
12957
12948
  isAuditEscalationResult: () => isAuditEscalationResult,
12958
- projectAuditEscalation: () => projectAuditEscalation
12949
+ projectAuditEscalation: () => projectAuditEscalation,
12950
+ projectGatekeeperEscalation: () => projectGatekeeperEscalation
12959
12951
  });
12960
12952
  function buildAuditEscalationResult(decision, deliveredOutput) {
12961
12953
  const auditOwned = {
@@ -13000,6 +12992,16 @@ function projectAuditEscalation(decision, deliveredOutput) {
13000
12992
  ...decision.usage === void 0 ? {} : { usage: decision.usage }
13001
12993
  };
13002
12994
  }
12995
+ function projectGatekeeperEscalation(result, deliveredOutput) {
12996
+ const receipt = result.receipt;
12997
+ const record4 = receipt !== null && typeof receipt === "object" && !Array.isArray(receipt) ? receipt : void 0;
12998
+ return projectAuditEscalation({
12999
+ status: "escalate",
13000
+ officer: result.officer,
13001
+ conflicts: receipt,
13002
+ ...record4 !== void 0 && Object.hasOwn(record4, "decisionGate") ? { decisionGate: record4.decisionGate } : {}
13003
+ }, deliveredOutput);
13004
+ }
13003
13005
  function isAuditEscalationResult(value) {
13004
13006
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
13005
13007
  return false;
@@ -13008,8 +13010,8 @@ function isAuditEscalationResult(value) {
13008
13010
  }
13009
13011
  async function disposeComplianceDecision(decision, handlers, deliveredOutput) {
13010
13012
  switch (decision.status) {
13011
- case "pass":
13012
- return await handlers.pass(decision.usage);
13013
+ case "converged":
13014
+ return await handlers.converged(decision.usage);
13013
13015
  case "no-receipt":
13014
13016
  if (handlers.noReceipt === void 0) {
13015
13017
  throw new Error("Compliance no-receipt projection handler is unavailable");
@@ -13026,8 +13028,8 @@ async function disposeComplianceDecision(decision, handlers, deliveredOutput) {
13026
13028
  decision,
13027
13029
  decision.usage === void 0 ? {} : { usage: decision.usage }
13028
13030
  );
13029
- case "bounce":
13030
- return await handlers.bounce(decision.violations);
13031
+ case "continue":
13032
+ return await handlers.continue(decision.violations);
13031
13033
  case "escalate":
13032
13034
  return await handlers.escalate(
13033
13035
  projectAuditEscalation(decision, deliveredOutput)
@@ -13163,6 +13165,7 @@ function rowFromPayload(kind, payload, accepted, roleFallback) {
13163
13165
  kind,
13164
13166
  accepted,
13165
13167
  ...Object.hasOwn(payload, "auditReceipt") ? { auditReceipt: payload.auditReceipt } : {},
13168
+ ...Object.hasOwn(payload, "auditOfficer") ? { auditOfficer: payload.auditOfficer } : {},
13166
13169
  ...typeof payload.toolCallId === "string" && payload.toolCallId.length > 0 ? { toolCallId: payload.toolCallId } : {}
13167
13170
  };
13168
13171
  }
@@ -13368,7 +13371,14 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
13368
13371
  return {
13369
13372
  ...host,
13370
13373
  registerTool(tool) {
13371
- const role = outputTools.get(tool.name);
13374
+ const registeredRole = outputTools.get(tool.name);
13375
+ let role;
13376
+ if (typeof registeredRole === "string") {
13377
+ role = registeredRole;
13378
+ } else if (registeredRole !== void 0) {
13379
+ const activeRole = host.getFlag("ak-role");
13380
+ role = typeof activeRole === "string" && registeredRole.includes(activeRole) ? activeRole : void 0;
13381
+ }
13372
13382
  if (role === void 0) return host.registerTool(tool);
13373
13383
  host.registerTool({
13374
13384
  ...tool,
@@ -13440,11 +13450,13 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
13440
13450
  outcome: "audit-escalation",
13441
13451
  role,
13442
13452
  accepted: params,
13443
- ...audit !== void 0 && (Object.hasOwn(audit, "receipt") || Object.hasOwn(audit, "conflicts")) ? { auditReceipt: Object.hasOwn(audit, "receipt") ? audit.receipt : audit.conflicts } : {}
13453
+ ...audit !== void 0 && (Object.hasOwn(audit, "receipt") || Object.hasOwn(audit, "conflicts")) ? { auditReceipt: Object.hasOwn(audit, "receipt") ? audit.receipt : audit.conflicts } : {},
13454
+ ...audit !== void 0 && Object.hasOwn(audit, "officer") ? { auditOfficer: audit.officer } : {}
13444
13455
  });
13445
13456
  await projectClosure(closed2, context);
13446
13457
  return result;
13447
13458
  }
13459
+ if (result.terminate === false) return result;
13448
13460
  const closed = {
13449
13461
  role,
13450
13462
  kind: "accepted",
@@ -14300,7 +14312,7 @@ function markerMatchesExpectedIdentity(marker, expected) {
14300
14312
  }
14301
14313
  function classifyPackagedRoleTerminalResult(message) {
14302
14314
  if (typeof message.toolName !== "string") return { kind: "nonterminal" };
14303
- if (!PACKAGED_ROLE_OUTPUT_TOOLS.has(message.toolName)) return { kind: "nonterminal" };
14315
+ if (!PACKAGED_ROLE_OUTPUT_TOOLS.has(message.toolName) && message.toolName !== "ak_submission_output") return { kind: "nonterminal" };
14304
14316
  const hasInfraBase = hasNavigatorInfrastructureFailureBase(message.details);
14305
14317
  const infraFact = hasInfraBase ? buildNavigatorInfrastructureFailureFact() : void 0;
14306
14318
  if (message.isError === true) {
@@ -14317,12 +14329,14 @@ function durableTerminalAt(entries, index) {
14317
14329
  const entry = entries[index];
14318
14330
  const message = entry?.type === "custom" && entry.customType === "ak-role-submission-closure" ? typeof entry.data === "object" && entry.data !== null ? entry.data : void 0 : entry?.type === "message" && entry.message?.role === "toolResult" ? entry.message : void 0;
14319
14331
  if (typeof message?.toolName !== "string") return void 0;
14320
- const role = PACKAGED_ROLE_OUTPUT_TOOLS.get(message.toolName);
14332
+ const marker = message.toolName === "ak_submission_output" ? entries.slice(0, index).reverse().find(isInvocationMarkerEntry) : void 0;
14333
+ const role = message.toolName === "ak_submission_output" ? parseInvocationMarkerIdentity(marker?.data)?.role ?? "unknown" : PACKAGED_ROLE_OUTPUT_TOOLS.get(message.toolName);
14321
14334
  if (role === void 0) return void 0;
14322
14335
  const classification = classifyPackagedRoleTerminalResult(message);
14323
14336
  if (classification.kind !== "accepted" && classification.kind !== "infrastructure") {
14324
14337
  return void 0;
14325
14338
  }
14339
+ if (entry?.type === "message" && classification.kind === "accepted" && !LEGACY_REVIEW_OUTPUT_ROLES.has(message.toolName)) return void 0;
14326
14340
  return {
14327
14341
  index,
14328
14342
  role,
@@ -14391,7 +14405,7 @@ var init_navigator_invocation_identity = __esm({
14391
14405
  "reason"
14392
14406
  ];
14393
14407
  PACKAGED_ROLE_OUTPUT_TOOLS = new Map(
14394
- PACKAGED_ROLE_REGISTRY.map((entry) => [entry.outputTool, entry.role])
14408
+ [...PACKAGED_ROLE_REGISTRY.filter((entry) => entry.outputTool !== "ak_submission_output").map((entry) => [entry.outputTool, entry.role]), ...LEGACY_REVIEW_OUTPUT_ROLES]
14395
14409
  );
14396
14410
  }
14397
14411
  });
@@ -14562,7 +14576,10 @@ function roleOutcomeFromRows(role, rows) {
14562
14576
  role,
14563
14577
  status: "audit_escalation",
14564
14578
  payloads,
14565
- ...audited === void 0 ? {} : { decisiveFacts: { auditEscalationReceipt: audited.auditReceipt } }
14579
+ ...audited === void 0 ? {} : { decisiveFacts: {
14580
+ auditEscalationReceipt: audited.auditReceipt,
14581
+ ...Object.hasOwn(audited, "auditOfficer") ? { auditEscalationOfficer: audited.auditOfficer } : {}
14582
+ } }
14566
14583
  };
14567
14584
  }
14568
14585
  return { kind: "accepted", role, payloads };
@@ -15999,15 +16016,14 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
15999
16016
  let thisAttemptHasSeatSuccess = false;
16000
16017
  let residual;
16001
16018
  for (let index = entries.length - 1; index >= scanStart; index -= 1) {
16019
+ const entry = entries[index];
16020
+ if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" && isRecord13(entry.data) && entry.data.toolName === spec.toolName && classifyPackagedRoleTerminalResult(entry.data).kind === "accepted") {
16021
+ thisAttemptHasSeatSuccess = true;
16022
+ }
16002
16023
  const message = entries[index]?.message;
16003
16024
  if (message?.role !== "toolResult") continue;
16004
16025
  if (message.toolName !== spec.toolName) continue;
16005
- if (message.isError === false) {
16006
- if (boundRoleToolCallForResult(entries, index, message, spec.toolName) !== void 0) {
16007
- thisAttemptHasSeatSuccess = true;
16008
- }
16009
- continue;
16010
- }
16026
+ if (message.isError === false) continue;
16011
16027
  if (residual === void 0) {
16012
16028
  residual = boundErroredToolCandidate(
16013
16029
  entries,
@@ -16018,7 +16034,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
16018
16034
  }
16019
16035
  }
16020
16036
  const roleOutcome = await sealedLedgerOutcome(admitted, spec.role, scope);
16021
- if (roleOutcome !== void 0 && (thisAttemptHasSeatSuccess || residual === void 0)) {
16037
+ if (roleOutcome !== void 0 && (thisAttemptHasSeatSuccess || residual === void 0 || scope?.courtAttemptId !== void 0 && scope.courtAttemptId.length > 0)) {
16022
16038
  const navigator = extractNavigatorFact(entries);
16023
16039
  const artifacts = await publishDeclaredSeatArtifacts(
16024
16040
  admitted,
@@ -18227,7 +18243,7 @@ function isRecord14(value) {
18227
18243
  }
18228
18244
  function isEscalatePayload(payload) {
18229
18245
  if (!isRecord14(payload)) return false;
18230
- return payload.status === "escalate" || payload.countersignStatus === "escalate";
18246
+ return payload.status === "escalate";
18231
18247
  }
18232
18248
  function courtDiaristPayloadRows(roleOutcome, submissions) {
18233
18249
  if (roleOutcome === void 0) return submissions ?? [];
@@ -20459,8 +20475,8 @@ function emptyAccum() {
20459
20475
  function absorbRound(accum, round) {
20460
20476
  accum.rounds += 1;
20461
20477
  accum.wallSum += round.officerWallMs;
20462
- if (round.status === "bounce") accum.bounceCount += 1;
20463
- if (round.status === "pass") accum.passCount += 1;
20478
+ if (round.status === "bounce" || round.status === "continue") accum.bounceCount += 1;
20479
+ if (round.status === "pass" || round.status === "converged") accum.passCount += 1;
20464
20480
  }
20465
20481
  function finishOfficer(officer, accum) {
20466
20482
  return {
@@ -20862,7 +20878,7 @@ var init_analyst_page = __esm({
20862
20878
 
20863
20879
  // src/analyst-entry.ts
20864
20880
  import { readFile as readFile21 } from "node:fs/promises";
20865
- import { Type as Type12 } from "typebox";
20881
+ import { Type as Type11 } from "typebox";
20866
20882
  function isMissingPathError7(error) {
20867
20883
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
20868
20884
  }
@@ -21069,16 +21085,16 @@ var init_analyst_entry = __esm({
21069
21085
  }
21070
21086
  }
21071
21087
  };
21072
- analystSweepModeInputSchema = Type12.Object(
21088
+ analystSweepModeInputSchema = Type11.Object(
21073
21089
  {
21074
- mode: Type12.Literal("sweep"),
21075
- mergedPullRequests: Type12.Array(
21076
- Type12.Object(
21090
+ mode: Type11.Literal("sweep"),
21091
+ mergedPullRequests: Type11.Array(
21092
+ Type11.Object(
21077
21093
  {
21078
- projectRoot: Type12.String(),
21094
+ projectRoot: Type11.String(),
21079
21095
  /** 排除后改动行数 — omit or 0 → typed 空缺; finite ≥ 0 only. */
21080
- changedLines: Type12.Optional(
21081
- Type12.Number({ minimum: 0, maximum: Number.MAX_VALUE })
21096
+ changedLines: Type11.Optional(
21097
+ Type11.Number({ minimum: 0, maximum: Number.MAX_VALUE })
21082
21098
  )
21083
21099
  },
21084
21100
  { additionalProperties: false }
@@ -22638,8 +22654,8 @@ function tryReadComplianceCandidate(arguments_, usage) {
22638
22654
  }
22639
22655
  const args = arguments_;
22640
22656
  const status = args.status;
22641
- if (status === "pass") return { status, receipt: arguments_, ...usage === void 0 ? {} : { usage } };
22642
- if (status === "bounce") return { status, violations: readListField(args.violations), receipt: arguments_, ...usage === void 0 ? {} : { usage } };
22657
+ if (status === "converged") return { status, receipt: arguments_, ...usage === void 0 ? {} : { usage } };
22658
+ if (status === "continue") return { status, violations: readListField(args.violations), receipt: arguments_, ...usage === void 0 ? {} : { usage } };
22643
22659
  if (status === "escalate") {
22644
22660
  return {
22645
22661
  status,
@@ -23206,14 +23222,14 @@ init_packaged_role_registry();
23206
23222
  init_activation_ledger_topology();
23207
23223
  import { resolve as resolve16 } from "node:path";
23208
23224
  import "@earendil-works/pi-coding-agent";
23209
- import { Type as Type14 } from "typebox";
23225
+ import { Type as Type13 } from "typebox";
23210
23226
 
23211
23227
  // src/navigator-public-session.ts
23212
23228
  init_sitian_facade();
23213
23229
  import { basename as basename10 } from "node:path";
23214
23230
 
23215
23231
  // src/navigator-session-contracts.ts
23216
- import { Type as Type13 } from "typebox";
23232
+ import { Type as Type12 } from "typebox";
23217
23233
  import { Value as Value3 } from "typebox/value";
23218
23234
  var NAVIGATOR_PREPARE_TOOL_NAME = "ak_navigator_prepare";
23219
23235
  var NAVIGATOR_UNAVAILABLE_KEYS = /* @__PURE__ */ new Set([
@@ -23321,26 +23337,26 @@ function navigatorProviderFailureFromPublicTerminal(outcome) {
23321
23337
  if (typed !== void 0) return { source: typed, cause: typed };
23322
23338
  return { source: "unknown", cause: "unknown" };
23323
23339
  }
23324
- var navigatorProviderFailureSchema = Type13.Object({
23325
- source: Type13.Union([
23326
- Type13.Literal("context"),
23327
- Type13.Literal("session"),
23328
- Type13.Literal("model"),
23329
- Type13.Literal("thinking"),
23330
- Type13.Literal("auth"),
23331
- Type13.Literal("quota"),
23332
- Type13.Literal("transport"),
23333
- Type13.Literal("unknown")
23340
+ var navigatorProviderFailureSchema = Type12.Object({
23341
+ source: Type12.Union([
23342
+ Type12.Literal("context"),
23343
+ Type12.Literal("session"),
23344
+ Type12.Literal("model"),
23345
+ Type12.Literal("thinking"),
23346
+ Type12.Literal("auth"),
23347
+ Type12.Literal("quota"),
23348
+ Type12.Literal("transport"),
23349
+ Type12.Literal("unknown")
23334
23350
  ]),
23335
- cause: Type13.Union([
23336
- Type13.Literal("context"),
23337
- Type13.Literal("session"),
23338
- Type13.Literal("model"),
23339
- Type13.Literal("thinking"),
23340
- Type13.Literal("auth"),
23341
- Type13.Literal("quota"),
23342
- Type13.Literal("transport"),
23343
- Type13.Literal("unknown")
23351
+ cause: Type12.Union([
23352
+ Type12.Literal("context"),
23353
+ Type12.Literal("session"),
23354
+ Type12.Literal("model"),
23355
+ Type12.Literal("thinking"),
23356
+ Type12.Literal("auth"),
23357
+ Type12.Literal("quota"),
23358
+ Type12.Literal("transport"),
23359
+ Type12.Literal("unknown")
23344
23360
  ])
23345
23361
  }, { additionalProperties: false });
23346
23362
  function parseNavigatorModelSetting(value) {
@@ -23607,8 +23623,8 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
23607
23623
  return void 0;
23608
23624
  }
23609
23625
  var NAVIGATOR_TARGETS = PACKAGED_ROLE_REGISTRY.map(({ role, phases }) => ({ role, phases }));
23610
- var prepareSchema = Type14.Object({
23611
- prose: Type14.Optional(Type14.Unknown({
23626
+ var prepareSchema = Type13.Object({
23627
+ prose: Type13.Optional(Type13.Unknown({
23612
23628
  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"
23613
23629
  }))
23614
23630
  }, { additionalProperties: true });
@@ -24317,18 +24333,18 @@ import { join as join43 } from "node:path";
24317
24333
  import { Value as Value5 } from "typebox/value";
24318
24334
 
24319
24335
  // src/activation-trace.ts
24320
- import { Type as Type15 } from "typebox";
24321
- var causeSchema = Type15.Object({
24322
- identity: Type15.String({ minLength: 1 }),
24323
- name: Type15.String({ minLength: 1 }),
24324
- message: Type15.String(),
24325
- evidenceId: Type15.Optional(Type15.String({ minLength: 1 }))
24336
+ import { Type as Type14 } from "typebox";
24337
+ var causeSchema = Type14.Object({
24338
+ identity: Type14.String({ minLength: 1 }),
24339
+ name: Type14.String({ minLength: 1 }),
24340
+ message: Type14.String(),
24341
+ evidenceId: Type14.Optional(Type14.String({ minLength: 1 }))
24326
24342
  }, { additionalProperties: false });
24327
- var activationTraceRecordSchema = Type15.Object({
24328
- role: Type15.String({ minLength: 1 }),
24329
- stageId: Type15.String({ pattern: "^[a-z][a-z0-9-]*$" }),
24330
- status: Type15.Literal("failed"),
24331
- timestamp: Type15.String({ format: "date-time" }),
24343
+ var activationTraceRecordSchema = Type14.Object({
24344
+ role: Type14.String({ minLength: 1 }),
24345
+ stageId: Type14.String({ pattern: "^[a-z][a-z0-9-]*$" }),
24346
+ status: Type14.Literal("failed"),
24347
+ timestamp: Type14.String({ format: "date-time" }),
24332
24348
  cause: causeSchema
24333
24349
  }, { additionalProperties: false });
24334
24350
  var activationCauseEvidence = 0;
@@ -24483,28 +24499,28 @@ function writeStderrJsonlRecord(record4, write = writeSync) {
24483
24499
 
24484
24500
  // src/tool-execution-observation.ts
24485
24501
  import { writeSync as writeSync2 } from "node:fs";
24486
- import { Type as Type16 } from "typebox";
24502
+ import { Type as Type15 } from "typebox";
24487
24503
  import { Value as Value4 } from "typebox/value";
24488
24504
  var TOOL_EXECUTION_UPDATE_THROTTLE_MS = 3e4;
24489
24505
  var observationBase = {
24490
- role: Type16.String({ minLength: 1 }),
24491
- toolCallId: Type16.String({ minLength: 1 }),
24492
- toolName: Type16.String({ minLength: 1 }),
24493
- timestamp: Type16.String({ format: "date-time" })
24506
+ role: Type15.String({ minLength: 1 }),
24507
+ toolCallId: Type15.String({ minLength: 1 }),
24508
+ toolName: Type15.String({ minLength: 1 }),
24509
+ timestamp: Type15.String({ format: "date-time" })
24494
24510
  };
24495
- var toolExecutionObservationRecordSchema = Type16.Union([
24496
- Type16.Object({
24511
+ var toolExecutionObservationRecordSchema = Type15.Union([
24512
+ Type15.Object({
24497
24513
  ...observationBase,
24498
- event: Type16.Literal("tool_execution_start")
24514
+ event: Type15.Literal("tool_execution_start")
24499
24515
  }, { additionalProperties: true }),
24500
- Type16.Object({
24516
+ Type15.Object({
24501
24517
  ...observationBase,
24502
- event: Type16.Literal("tool_execution_update")
24518
+ event: Type15.Literal("tool_execution_update")
24503
24519
  }, { additionalProperties: true }),
24504
- Type16.Object({
24520
+ Type15.Object({
24505
24521
  ...observationBase,
24506
- event: Type16.Literal("tool_execution_end"),
24507
- isError: Type16.Boolean()
24522
+ event: Type15.Literal("tool_execution_end"),
24523
+ isError: Type15.Boolean()
24508
24524
  }, { additionalProperties: true })
24509
24525
  ]);
24510
24526
  function validateToolExecutionObservationRecord(record4) {
@@ -24601,10 +24617,10 @@ init_engine_material();
24601
24617
  init_engine_detour();
24602
24618
  init_engine_detour_usage();
24603
24619
  init_run_terminal_artifacts();
24604
- import { Type as Type17 } from "typebox";
24605
- var engineDetourArgsSchema = Type17.Object(
24620
+ import { Type as Type16 } from "typebox";
24621
+ var engineDetourArgsSchema = Type16.Object(
24606
24622
  {
24607
- argv: Type17.Array(Type17.String({ minLength: 1 }), {
24623
+ argv: Type16.Array(Type16.String({ minLength: 1 }), {
24608
24624
  minItems: 1,
24609
24625
  description: "\u9996\u9879\u4E3A PATH \u4E2D\u7684\u53EF\u6267\u884C\u6587\u4EF6\uFF0C\u5176\u4F59\u9879\u4E3A\u53C2\u6570\u3002"
24610
24626
  })
@@ -24751,63 +24767,63 @@ import { join as join42, sep as sep6 } from "node:path";
24751
24767
  // src/collector-tool-schemas.ts
24752
24768
  init_open_tool_schema();
24753
24769
  init_terminating_infrastructure();
24754
- import { Type as Type18 } from "typebox";
24755
- var collectorObserveArgsSchema = Type18.Object({}, { additionalProperties: true });
24756
- var collectorRequestArgsSchema = Type18.Object({
24757
- requestId: Type18.String({
24770
+ import { Type as Type17 } from "typebox";
24771
+ var collectorObserveArgsSchema = Type17.Object({}, { additionalProperties: true });
24772
+ var collectorRequestArgsSchema = Type17.Object({
24773
+ requestId: Type17.String({
24758
24774
  minLength: 1,
24759
24775
  description: "\u8BF7\u6C42\u8EAB\u4EFD\uFF08\u914D\u7F6E id \u6216\u89D2\u8272\u5224\u5B9A\u7684\u7A33\u5B9A id\uFF1B\u9996\u5C3E\u65E0\u7A7A\u767D\uFF09"
24760
24776
  }),
24761
- snapshotId: Type18.String({ minLength: 1, description: "\u6700\u65B0\u7559\u5B58\u89C2\u5BDF\u5FEB\u7167" }),
24777
+ snapshotId: Type17.String({ minLength: 1, description: "\u6700\u65B0\u7559\u5B58\u89C2\u5BDF\u5FEB\u7167" }),
24762
24778
  // #836 r16 class 3: body.minLength deleted — manifest-configured requestId
24763
24779
  // ignores body, and the unknown-requestId non-empty condition is a real
24764
24780
  // branch in src/collector-ledger.ts:922-951, not a provider shape gate.
24765
- body: Type18.Optional(Type18.String({
24781
+ body: Type17.Optional(Type17.String({
24766
24782
  description: "\u89D2\u8272\u5224\u5B9A\u7684\u8BF7\u6C42\u6B63\u6587\uFF1Brequest-manifest \u672A\u6536\u5F55\u8BE5 requestId \u65F6\u5FC5\u586B"
24767
24783
  }))
24768
24784
  }, { additionalProperties: true });
24769
24785
  var COLLECTOR_HANDBOOK_MAX_BYTES = 64 * 1024;
24770
- var collectorHandbookWriteArgsSchema = Type18.Object({
24771
- scope: Type18.Union([
24772
- Type18.Literal("general"),
24773
- Type18.Literal("repo")
24786
+ var collectorHandbookWriteArgsSchema = Type17.Object({
24787
+ scope: Type17.Union([
24788
+ Type17.Literal("general"),
24789
+ Type17.Literal("repo")
24774
24790
  ], { description: "general\uFF1D\u901A\u7528\u624B\u518C\uFF1Brepo\uFF1D\u5F53\u524D\u4ED3\u5E93\u5DEE\u5F02" }),
24775
- body: Type18.String({
24791
+ body: Type17.String({
24776
24792
  description: `\u624B\u518C\u5168\u6587\uFF08opaque \u5DE5\u4F5C\u8BB0\u5FC6\uFF1B\u6574\u4EFD\u66FF\u6362\uFF1BUTF-8 \u81F3\u591A ${COLLECTOR_HANDBOOK_MAX_BYTES} \u5B57\u8282\uFF09`
24777
24793
  })
24778
24794
  }, { additionalProperties: true });
24779
- var collectorReadArgsSchema = Type18.Object({
24780
- evidenceId: Type18.String({ minLength: 1, description: "observe \u8FD4\u56DE\u7684\u6750\u6599\u8BC1\u636E id\uFF08evidenceId\uFF09" })
24795
+ var collectorReadArgsSchema = Type17.Object({
24796
+ evidenceId: Type17.String({ minLength: 1, description: "observe \u8FD4\u56DE\u7684\u6750\u6599\u8BC1\u636E id\uFF08evidenceId\uFF09" })
24781
24797
  }, { additionalProperties: true });
24782
- var collectorWaitArgsSchema = Type18.Object({
24783
- durationMs: Type18.Integer({
24798
+ var collectorWaitArgsSchema = Type17.Object({
24799
+ durationMs: Type17.Integer({
24784
24800
  minimum: 1,
24785
24801
  description: "\u7B49\u5F85\u6BEB\u79D2\uFF1B\u5B9E\u9645\u7761\u7720\u4E0D\u8D85\u8FC7\u5269\u4F59\u7B49\u5F85\u7A97\uFF08#678\uFF1B\u65E0\u5305\u5185\u5355\u6B21\u4EFB\u610F\u4E0A\u9650\uFF09"
24786
24802
  })
24787
24803
  }, { additionalProperties: true });
24788
- var collectorOpenWaitWindowArgsSchema = Type18.Object({
24789
- startedAt: Type18.Optional(Type18.String({
24804
+ var collectorOpenWaitWindowArgsSchema = Type17.Object({
24805
+ startedAt: Type17.Optional(Type17.String({
24790
24806
  description: "\u7B49\u5F85\u7A97\u8D77\u70B9 ISO \u65F6\u95F4\uFF1B\u65B0\u5EFA PR \u7528\u521B\u5EFA\u6210\u529F\u65F6\u523B\uFF1B\u7701\u7565\uFF1D\u73B0\u5728\uFF08\u89E6\u53D1\u9636\u6BB5\u7ED3\u675F\uFF09"
24791
24807
  }))
24792
24808
  }, { additionalProperties: true });
24793
- var collectorBindTargetArgsSchema = Type18.Object({
24794
- prNumber: Type18.Optional(Type18.Unknown({
24809
+ var collectorBindTargetArgsSchema = Type17.Object({
24810
+ prNumber: Type17.Optional(Type17.Unknown({
24795
24811
  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"
24796
24812
  })),
24797
- issueNumber: Type18.Optional(Type18.Unknown({
24813
+ issueNumber: Type17.Optional(Type17.Unknown({
24798
24814
  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"
24799
24815
  }))
24800
24816
  }, { additionalProperties: true });
24801
24817
  var collectorFindingItemDeclaration = (() => {
24802
- const item = Type18.Object(
24818
+ const item = Type17.Object(
24803
24819
  {
24804
- evidenceId: Type18.Unknown({
24820
+ evidenceId: Type17.Unknown({
24805
24821
  description: "observe \u8FD4\u56DE\u7684\u6750\u6599\u6307\u9488\uFF08\u5FC5\u586B\u8BED\u4E49\uFF09"
24806
24822
  }),
24807
- category: Type18.Unknown({
24823
+ category: Type17.Unknown({
24808
24824
  description: "\u7B80\u77ED\u5F52\u7C7B\u6807\u7B7E\uFF0C\u4E0D\u662F\u6458\u8981"
24809
24825
  }),
24810
- summary: Type18.Unknown({
24826
+ summary: Type17.Unknown({
24811
24827
  description: "\u54EA\u4E2A bot\u3001\u4EC0\u4E48\u95EE\u9898\u7684\u6458\u8981\uFF1B\u4E0D\u8A8A\u6284\u6B63\u6587"
24812
24828
  })
24813
24829
  },
@@ -24820,14 +24836,14 @@ var collectorFindingItemDeclaration = (() => {
24820
24836
  return item;
24821
24837
  })();
24822
24838
  var collectorOutputBaseSchema = openToolObject(
24823
- Type18.Object({
24839
+ Type17.Object({
24824
24840
  // No root type:array — host must not shape-reject non-array findings (#676 C).
24825
24841
  // Nested item declarations ride `items` for registration preservation (ADR 0057).
24826
- findings: Type18.Unsafe({
24842
+ findings: Type17.Unsafe({
24827
24843
  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",
24828
24844
  items: collectorFindingItemDeclaration
24829
24845
  }),
24830
- unfinishedReasons: Type18.Unknown({
24846
+ unfinishedReasons: Type17.Unknown({
24831
24847
  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"
24832
24848
  })
24833
24849
  })
@@ -25457,7 +25473,6 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
25457
25473
  // src/doctor-role.ts
25458
25474
  init_audit_escalation();
25459
25475
  init_compliance_transport();
25460
- init_submission_errors();
25461
25476
  init_dossier_resolution();
25462
25477
  init_readable_gate_item();
25463
25478
  init_doctor_contracts();
@@ -25519,7 +25534,7 @@ function createDoctorRoleRuntime(pi, dependencies, host) {
25519
25534
  host.failInfrastructure(error, ctx, id);
25520
25535
  }
25521
25536
  const acceptedDetails = testimony;
25522
- return disposeComplianceDecision(audit, { pass: (usage) => ({ content: audit.status === "pass" && audit.receipt !== void 0 ? [{ type: "text", text: readableGateItem(audit.receipt) }] : [], details: acceptedDetails, terminate: true, ...usage === void 0 ? {} : { usage } }), noReceipt: (auditNoReceipt, usageProjection) => {
25537
+ return disposeComplianceDecision(audit, { converged: (usage) => ({ content: audit.status === "converged" && audit.receipt !== void 0 ? [{ type: "text", text: readableGateItem(audit.receipt) }] : [], details: acceptedDetails, terminate: true, ...usage === void 0 ? {} : { usage } }), noReceipt: (auditNoReceipt, usageProjection) => {
25523
25538
  try {
25524
25539
  appendCandidate(ctx, { version: 1, testimony, cost: active2.patient.cost, auditNoReceipt, readRecord: active2.store.readRecord(), patientIdentity: active2.patient.identity });
25525
25540
  } catch (error) {
@@ -25528,9 +25543,7 @@ function createDoctorRoleRuntime(pi, dependencies, host) {
25528
25543
  return { content: [], details: acceptedDetails, terminate: true, ...usageProjection };
25529
25544
  }, received: () => {
25530
25545
  throw new Error("\u5BA1\u5211\u9662\u975E\u4E09\u6001\u5E94\u4EA4 runComplianceAudit \u91CD\u95EE\u8BF4\u8BDD\u8005");
25531
- }, bounce: (violations) => {
25532
- throw new GatekeeperDecisionError({ status: "bounce", officer: "auditor", receipt: audit.status === "bounce" ? audit.receipt ?? violations : violations });
25533
- }, escalate: (result) => result, transportFailure: (facts) => {
25546
+ }, continue: (violations) => ({ content: [{ type: "text", text: readableGateItem(audit.status === "continue" ? audit.receipt ?? violations : violations) }], details: acceptedDetails, terminate: false }), escalate: (result) => result, transportFailure: (facts) => {
25534
25547
  host.failInfrastructure(Object.assign(new Error(facts.diagnostic), { name: "ComplianceTransportFailure", ...facts.submissions === void 0 && facts.terminal === void 0 ? {} : { submission: facts.submissions ?? facts.terminal } }), ctx, id);
25535
25548
  } }, acceptedDetails);
25536
25549
  } });
@@ -25628,7 +25641,7 @@ function createNotaryRoleRuntime(pi, dependencies, host) {
25628
25641
  pi.registerTool({
25629
25642
  name: NOTARY_OUTPUT_TOOL_NAME,
25630
25643
  label: "\u7B26\u5B9D\u90CE\u8F93\u51FA",
25631
- description: "\u63D0\u4EA4\u5F15\u6587\u4FDD\u771F\u4E0E\u7968\u9762\u5BF9\u9F50\u7684 typed pass/bounce/escalate \u51B3\u8BAE\u3002",
25644
+ description: "\u63D0\u4EA4\u5F15\u6587\u4FDD\u771F\u4E0E\u7968\u9762\u5BF9\u9F50\u7684 converged/continue/escalate \u51B3\u8BAE\u3002",
25632
25645
  promptSnippet: "\u63D0\u4EA4\u7B26\u5B9D\u90CE\u51B3\u8BAE",
25633
25646
  parameters: notaryOutputSchema,
25634
25647
  async execute(toolCallId, parameters, _signal, _onUpdate, ctx) {
@@ -25672,36 +25685,10 @@ function createNotaryRoleRuntime(pi, dependencies, host) {
25672
25685
  init_notary_contracts();
25673
25686
 
25674
25687
  // src/countersign-role.ts
25675
- init_terminating_infrastructure();
25688
+ init_review_submission();
25676
25689
  init_countersign_contracts();
25677
25690
  init_countersign_contracts();
25678
- import { Type as Type19 } from "typebox";
25679
- var countersignVerdictSchema = withTerminatingOutputDeclarations(
25680
- Type19.Object(
25681
- {
25682
- countersignStatus: Type19.Unknown({ description: "converged | continue | escalate\u3002\u975E\u4E09\u6001\u65F6\u8BF7\u91CD\u8BFB\u540E\u91CD\u4EA4\uFF0C\u52FF\u6539\u6807\u3002" }),
25683
- fix: Type19.Optional(
25684
- Type19.Object(
25685
- { summary: Type19.Optional(Type19.String({ description: "\u9000\u56DE\u6458\u8981" })) },
25686
- { additionalProperties: true, description: "\u9000\u56DE\u8BF4\u660E" }
25687
- )
25688
- ),
25689
- note: Type19.Optional(Type19.String({ description: "\u9644\u6CE8" })),
25690
- evidence: Type19.Optional(Type19.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
25691
- decisionGate: Type19.Optional(
25692
- Type19.Object(
25693
- {
25694
- question: Type19.Optional(Type19.String()),
25695
- options: Type19.Optional(Type19.Array(Type19.String()))
25696
- },
25697
- { additionalProperties: true, description: "\u9700\u965B\u4E0B\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879" }
25698
- )
25699
- )
25700
- },
25701
- { additionalProperties: true }
25702
- )
25703
- );
25704
- countersignVerdictSchema.required = [];
25691
+ var countersignVerdictSchema = reviewSubmissionSchema;
25705
25692
  var COUNTERSIGN_TOOL_SPEC = {
25706
25693
  name: COUNTERSIGN_OUTPUT_TOOL_NAME,
25707
25694
  label: "\u7ED9\u4E8B\u4E2D\u8F93\u51FA",
@@ -25715,18 +25702,18 @@ init_open_tool_schema();
25715
25702
  init_terminating_infrastructure();
25716
25703
  init_gleaner_left_contracts();
25717
25704
  init_gleaner_left_contracts();
25718
- import { Type as Type20 } from "typebox";
25705
+ import { Type as Type18 } from "typebox";
25719
25706
  var gleanerLeftOutputSchema = withTerminatingOutputDeclarations(
25720
25707
  openToolObject(
25721
- Type20.Object({
25722
- status: Type20.Unknown({
25708
+ Type18.Object({
25709
+ status: Type18.Unknown({
25723
25710
  description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
25724
25711
  }),
25725
- findings: Type20.Array(
25726
- Type20.Object(
25712
+ findings: Type18.Array(
25713
+ Type18.Object(
25727
25714
  {
25728
- pointer: Type20.Optional(Type20.String({ description: "\u6587\u4EF6/\u884C\u6307\u9488" })),
25729
- statement: Type20.Optional(Type20.String({ description: "\u7591\u70B9\u9648\u8FF0" }))
25715
+ pointer: Type18.Optional(Type18.String({ description: "\u6587\u4EF6/\u884C\u6307\u9488" })),
25716
+ statement: Type18.Optional(Type18.String({ description: "\u7591\u70B9\u9648\u8FF0" }))
25730
25717
  },
25731
25718
  { additionalProperties: true, description: "\u4E00\u6761\u5F39\u7AE0" }
25732
25719
  ),
@@ -25747,29 +25734,13 @@ var GLEANER_LEFT_TOOL_SPEC = {
25747
25734
  init_gleaner_left_contracts();
25748
25735
 
25749
25736
  // src/inspector-role.ts
25750
- init_open_tool_schema();
25751
- init_terminating_infrastructure();
25737
+ init_review_submission();
25752
25738
  init_inspector_contracts();
25753
- import { Type as Type21 } from "typebox";
25754
- var inspectorOutputSchema = withTerminatingOutputDeclarations(
25755
- openToolObject(
25756
- Type21.Object({
25757
- status: Type21.Unknown({
25758
- description: "pass | bounce | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
25759
- }),
25760
- findings: Type21.Unknown({
25761
- description: "\u968F\u4EA4\u5377\u7559\u5B58\u7684\u95EE\u9898\u8BB0\u5F55"
25762
- }),
25763
- reason: Type21.Optional(Type21.Unknown({
25764
- description: "status \u4E3A escalate \u65F6\u7684\u4E0A\u5448\u7406\u7531"
25765
- }))
25766
- })
25767
- )
25768
- );
25739
+ var inspectorOutputSchema = reviewSubmissionSchema;
25769
25740
  var INSPECTOR_TOOL_SPEC = {
25770
25741
  name: INSPECTOR_OUTPUT_TOOL_NAME,
25771
25742
  label: "\u53F0\u9662\u8F93\u51FA",
25772
- description: "\u53F0\u9662\u7EC8\u5C40\u56DE\u6267\uFF0C\u72B6\u6001\u4E3A pass\u3001bounce \u6216 escalate\u3002",
25743
+ description: "\u53F0\u9662\u7EC8\u5C40\u56DE\u6267\uFF0C\u72B6\u6001\u4E3A converged\u3001continue \u6216 escalate\u3002",
25773
25744
  promptSnippet: "\u53F0\u9662\u7EC8\u5C40\u56DE\u6267",
25774
25745
  parameters: inspectorOutputSchema
25775
25746
  };
@@ -25782,44 +25753,44 @@ init_open_tool_schema();
25782
25753
  init_terminating_infrastructure();
25783
25754
  init_diarist_contracts();
25784
25755
  init_diarist_contracts();
25785
- import { Type as Type22 } from "typebox";
25756
+ import { Type as Type19 } from "typebox";
25786
25757
  var diaristOutputSchema = withTerminatingOutputDeclarations(
25787
25758
  openToolObject(
25788
- Type22.Object({
25789
- status: Type22.Unknown({
25759
+ Type19.Object({
25760
+ status: Type19.Unknown({
25790
25761
  description: "completed | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
25791
25762
  }),
25792
- ticketNumber: Type22.Optional(
25793
- Type22.Unknown({
25763
+ ticketNumber: Type19.Optional(
25764
+ Type19.Unknown({
25794
25765
  description: "\u672C\u5EAD\u5BF9\u8C61\u7968\u53F7\uFF08\u6B63\u6574\u6570\uFF09\u6216 null/\u7701\u7565\uFF1D\u771F\u65E0\u7968\uFF1B\u4E0B\u6E38\u8D70 typed \u952E\uFF1B\u8BA4\u4E0D\u51FA\u7528 status=escalate\uFF0C\u4E0D\u6D17\u6210\u65E0\u5F55\u3002\u673A\u68B0\u5C42\u4E0D\u91CD\u5224\u3002"
25795
25766
  })
25796
25767
  ),
25797
- courtTicketNumbers: Type22.Optional(
25798
- Type22.Unknown({
25768
+ courtTicketNumbers: Type19.Optional(
25769
+ Type19.Unknown({
25799
25770
  description: "#871 \u672C\u6B21\u5408\u5BA1\u5E94\u5404\u81EA\u6210\u5F55\u7684\u7968\u53F7\u96C6\u5408\uFF08\u6B63\u6574\u6570\u6570\u7EC4\uFF0C\u542B\u4E3B\u7968\uFF09\uFF1B\u5355\u7968\u53EF\u7701\u7565\u3002\u673A\u68B0\u5C42\u53EA\u505A\u7C7B\u578B/\u53BB\u91CD\u6295\u5F71\uFF0C\u4E0D\u4ECE\u6563\u6587\u731C\u7968\u3002"
25800
25771
  })
25801
25772
  ),
25802
- reason: Type22.Optional(
25803
- Type22.String({
25773
+ reason: Type19.Optional(
25774
+ Type19.String({
25804
25775
  description: "status \u4E3A escalate \u65F6\uFF1A\u8BA4\u4E0D\u51FA\u672C\u5EAD\u5BF9\u8C61\u7684\u539F\u56E0"
25805
25776
  })
25806
25777
  ),
25807
- sessions: Type22.Optional(
25808
- Type22.Array(
25809
- Type22.Object(
25778
+ sessions: Type19.Optional(
25779
+ Type19.Array(
25780
+ Type19.Object(
25810
25781
  {
25811
- path: Type22.Optional(
25812
- Type22.String({ description: "\u4F1A\u8BDD\u5377\u7EDD\u5BF9\u6216\u53EF\u8BFB\u8DEF\u5F84" })
25782
+ path: Type19.Optional(
25783
+ Type19.String({ description: "\u4F1A\u8BDD\u5377\u7EDD\u5BF9\u6216\u53EF\u8BFB\u8DEF\u5F84" })
25813
25784
  ),
25814
- ranges: Type22.Optional(
25815
- Type22.Array(
25816
- Type22.Object(
25785
+ ranges: Type19.Optional(
25786
+ Type19.Array(
25787
+ Type19.Object(
25817
25788
  {
25818
- from: Type22.Optional(
25819
- Type22.Object(
25789
+ from: Type19.Optional(
25790
+ Type19.Object(
25820
25791
  {
25821
- id: Type22.Optional(Type22.String()),
25822
- line: Type22.Optional(Type22.Unknown())
25792
+ id: Type19.Optional(Type19.String()),
25793
+ line: Type19.Optional(Type19.Unknown())
25823
25794
  },
25824
25795
  {
25825
25796
  additionalProperties: true,
@@ -25827,11 +25798,11 @@ var diaristOutputSchema = withTerminatingOutputDeclarations(
25827
25798
  }
25828
25799
  )
25829
25800
  ),
25830
- to: Type22.Optional(
25831
- Type22.Object(
25801
+ to: Type19.Optional(
25802
+ Type19.Object(
25832
25803
  {
25833
- id: Type22.Optional(Type22.String()),
25834
- line: Type22.Optional(Type22.Unknown())
25804
+ id: Type19.Optional(Type19.String()),
25805
+ line: Type19.Optional(Type19.Unknown())
25835
25806
  },
25836
25807
  {
25837
25808
  additionalProperties: true,
@@ -25868,23 +25839,23 @@ var DIARIST_TOOL_SPEC = {
25868
25839
  init_terminating_infrastructure();
25869
25840
  init_secretariat_contracts();
25870
25841
  init_secretariat_contracts();
25871
- import { Type as Type23 } from "typebox";
25842
+ import { Type as Type20 } from "typebox";
25872
25843
  var secretariatVerdictSchema = withTerminatingOutputDeclarations(
25873
- Type23.Object(
25844
+ Type20.Object(
25874
25845
  {
25875
- secretariatStatus: Type23.Unknown({
25846
+ secretariatStatus: Type20.Unknown({
25876
25847
  description: "converged | escalate\uFF08\u7EC8\u5C40\u5F62\u72B6\u6307\u5F15\uFF0C\u975E\u95F8\uFF09"
25877
25848
  }),
25878
- ticketNumber: Type23.Optional(
25879
- Type23.Number({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
25849
+ ticketNumber: Type20.Optional(
25850
+ Type20.Number({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
25880
25851
  ),
25881
- note: Type23.Optional(Type23.String({ description: "\u9644\u6CE8" })),
25882
- evidence: Type23.Optional(Type23.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
25883
- decisionGate: Type23.Optional(
25884
- Type23.Object(
25852
+ note: Type20.Optional(Type20.String({ description: "\u9644\u6CE8" })),
25853
+ evidence: Type20.Optional(Type20.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
25854
+ decisionGate: Type20.Optional(
25855
+ Type20.Object(
25885
25856
  {
25886
- question: Type23.Optional(Type23.String()),
25887
- options: Type23.Optional(Type23.Array(Type23.String()))
25857
+ question: Type20.Optional(Type20.String()),
25858
+ options: Type20.Optional(Type20.Array(Type20.String()))
25888
25859
  },
25889
25860
  { additionalProperties: true, description: "\u9700\u965B\u4E0B\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879" }
25890
25861
  )
@@ -25943,7 +25914,7 @@ init_auditor_output();
25943
25914
  var AUDITOR_TOOL_SPEC = {
25944
25915
  name: AUDITOR_OUTPUT_TOOL_NAME,
25945
25916
  label: "\u5BA1\u5211\u9662\u8F93\u51FA",
25946
- description: "\u5BA1\u5211\u9662\u7EC8\u5C40\u56DE\u6267\uFF0C\u72B6\u6001\u4E3A pass\u3001bounce \u6216 escalate\u3002",
25917
+ description: "\u5BA1\u5211\u9662\u7EC8\u5C40\u56DE\u6267\uFF0Cstatus \u4E3A converged\u3001continue \u6216 escalate\u3002",
25947
25918
  promptSnippet: "\u5BA1\u5211\u9662\u7EC8\u5C40\u56DE\u6267",
25948
25919
  parameters: auditorOutputSchema
25949
25920
  };
@@ -25956,46 +25927,14 @@ init_packaged_role_registry();
25956
25927
  init_audit_escalation();
25957
25928
 
25958
25929
  // src/judge-role.ts
25959
- init_terminating_infrastructure();
25930
+ init_review_submission();
25960
25931
  init_submission_errors();
25961
25932
  init_audit_escalation();
25962
25933
  init_readable_gate_item();
25963
25934
  init_judge_output();
25964
- import { Type as Type24 } from "typebox";
25965
25935
  var JUDGE_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "continue", "escalate"]);
25966
- var JUDGE_STATUS_REASK = "judgeStatus \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
25967
- var judgeVerdictSchema = withTerminatingOutputDeclarations(
25968
- Type24.Object(
25969
- {
25970
- judgeStatus: Type24.Unknown({ description: "converged | continue | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }),
25971
- fix: Type24.Optional(
25972
- Type24.Object(
25973
- { summary: Type24.Optional(Type24.String({ description: "continue \u65F6\u7684\u8865\u6551\u6458\u8981" })) },
25974
- { additionalProperties: true, description: "continue \u65F6\u7684\u8865\u6551\u8BF4\u660E" }
25975
- )
25976
- ),
25977
- classes: Type24.Optional(Type24.Array(Type24.Object({
25978
- name: Type24.Optional(Type24.String()),
25979
- owner: Type24.Optional(Type24.String()),
25980
- boundary: Type24.Optional(Type24.String()),
25981
- disposition: Type24.Optional(Type24.String())
25982
- }, { additionalProperties: true }), { description: "\u5DF2\u88C1\u51B3 finding \u7C7B\u53CA\u5176 owner \u4E0E\u4FEE\u7406\u8FB9\u754C" })),
25983
- note: Type24.Optional(Type24.String({ description: "\u53EF\u9009\u88C1\u51B3\u9644\u6CE8" })),
25984
- evidence: Type24.Optional(Type24.Unknown({ description: "\u7559\u5B58\u7684\u88C1\u51B3\u8BC1\u636E" })),
25985
- decisionGate: Type24.Optional(
25986
- Type24.Object(
25987
- {
25988
- question: Type24.Optional(Type24.String()),
25989
- options: Type24.Optional(Type24.Array(Type24.String()))
25990
- },
25991
- { additionalProperties: true, description: "\u9700\u4EBA\u6743\u5A01\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879" }
25992
- )
25993
- )
25994
- },
25995
- { additionalProperties: true }
25996
- )
25997
- );
25998
- judgeVerdictSchema.required = [];
25936
+ var JUDGE_STATUS_REASK = "status \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
25937
+ var judgeVerdictSchema = reviewSubmissionSchema;
25999
25938
  function validateVerdict(verdict) {
26000
25939
  return validateAcceptedJudgeDetails(verdict);
26001
25940
  }
@@ -26016,7 +25955,7 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
26016
25955
  parameters: judgeVerdictSchema,
26017
25956
  async execute(toolCallId, parameters, signal, _onUpdate, ctx) {
26018
25957
  if (soul === void 0) throw new Error("\u5927\u7406\u5BFA\u804C\u5206\u672A\u88C5\u8F7D");
26019
- const rawStatus = parameters !== null && typeof parameters === "object" && !Array.isArray(parameters) && typeof parameters.judgeStatus === "string" ? parameters.judgeStatus : void 0;
25958
+ const rawStatus = parameters !== null && typeof parameters === "object" && !Array.isArray(parameters) && typeof parameters.status === "string" ? parameters.status : void 0;
26020
25959
  if (rawStatus === void 0 || !JUDGE_QUEUE_STATUSES.has(rawStatus)) {
26021
25960
  throw new ParentQueueReaskError(JUDGE_STATUS_REASK);
26022
25961
  }
@@ -26031,7 +25970,7 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
26031
25970
  const verdict = validateVerdict(parameters);
26032
25971
  let draftPass;
26033
25972
  try {
26034
- const obtainedDraftPass = await pi.requireGatekeeperPass({
25973
+ const obtainedDraftPass = await pi.requireSubmissionGate({
26035
25974
  context: ctx,
26036
25975
  subject: { kind: "judge_draft" },
26037
25976
  ...signal === void 0 ? {} : { signal },
@@ -26041,8 +25980,15 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
26041
25980
  submission: parameters
26042
25981
  });
26043
25982
  draftPass = obtainedDraftPass || void 0;
25983
+ if (draftPass?.status === "continue") {
25984
+ return {
25985
+ content: [{ type: "text", text: readableGateItem(draftPass.receipt) }],
25986
+ details: verdict,
25987
+ terminate: false
25988
+ };
25989
+ }
26044
25990
  if (draftPass !== void 0) hostActions.bindPriorGatePass(toolCallId, draftPass.receipt);
26045
- const compliancePass = await pi.requireGatekeeperPass({
25991
+ const compliancePass = await pi.requireSubmissionGate({
26046
25992
  context: ctx,
26047
25993
  subject: { kind: "judge_compliance" },
26048
25994
  ...signal === void 0 ? {} : { signal },
@@ -26051,6 +25997,13 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
26051
25997
  // #879: same parent payload for 审刑院; not recovered from session latest.
26052
25998
  submission: parameters
26053
25999
  });
26000
+ if (compliancePass?.status === "continue") {
26001
+ return {
26002
+ content: [draftPass, compliancePass].filter((pass) => pass !== void 0).map((pass) => ({ type: "text", text: readableGateItem(pass.receipt) })),
26003
+ details: verdict,
26004
+ terminate: false
26005
+ };
26006
+ }
26054
26007
  return {
26055
26008
  content: [draftPass, compliancePass].filter((pass) => pass !== void 0).map((pass) => ({ type: "text", text: readableGateItem(pass.receipt) })),
26056
26009
  details: verdict,
@@ -26058,7 +26011,7 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
26058
26011
  };
26059
26012
  } catch (error) {
26060
26013
  if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
26061
- return projectAuditEscalation({ status: "escalate", conflicts: error.result.receipt }, verdict);
26014
+ return projectGatekeeperEscalation(error.result, verdict);
26062
26015
  }
26063
26016
  throw error;
26064
26017
  }
@@ -26083,12 +26036,12 @@ ${soul}
26083
26036
  init_open_tool_schema();
26084
26037
  init_terminating_infrastructure();
26085
26038
  init_reviewer_output();
26086
- import { Type as Type25 } from "typebox";
26087
- var reviewerAmendmentsSchema = Type25.Object({
26088
- completeness: Type25.Optional(Type25.String({
26039
+ import { Type as Type21 } from "typebox";
26040
+ var reviewerAmendmentsSchema = Type21.Object({
26041
+ completeness: Type21.Optional(Type21.String({
26089
26042
  description: "completeness lens \u5B8C\u6574\u62A5\u544A\uFF1Acandidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict\uFF1B\u975E\u4EC5 verdict \u4E00\u884C\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u82E5\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u4E8E\u6B64"
26090
26043
  })),
26091
- correctness: Type25.Optional(Type25.String({
26044
+ correctness: Type21.Optional(Type21.String({
26092
26045
  description: "correctness lens \u5B8C\u6574\u62A5\u544A\uFF1Acandidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict\uFF1B\u975E\u4EC5 verdict \u4E00\u884C\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u82E5\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u4E8E\u6B64"
26093
26046
  }))
26094
26047
  }, {
@@ -26096,15 +26049,15 @@ var reviewerAmendmentsSchema = Type25.Object({
26096
26049
  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"
26097
26050
  });
26098
26051
  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";
26099
- var reviewerOutputVariants = Type25.Union([
26100
- Type25.Object({
26101
- status: Type25.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
26102
- amendments: Type25.Optional(reviewerAmendmentsSchema)
26052
+ var reviewerOutputVariants = Type21.Union([
26053
+ Type21.Object({
26054
+ status: Type21.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
26055
+ amendments: Type21.Optional(reviewerAmendmentsSchema)
26103
26056
  }, { additionalProperties: false }),
26104
- Type25.Object({
26105
- status: Type25.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
26106
- diagnostic: Type25.String({ description: "\u62D2\u7EDD\u8BCA\u65AD\u8BF4\u660E\uFF1Bhard-stop\uFF0Fusage error \u539F\u56E0\u8FDB\u6B64\u5B57\u6BB5\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u53E6\u7167\u5F55 amendments" }),
26107
- amendments: Type25.Optional(reviewerAmendmentsSchema)
26057
+ Type21.Object({
26058
+ status: Type21.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
26059
+ diagnostic: Type21.String({ description: "\u62D2\u7EDD\u8BCA\u65AD\u8BF4\u660E\uFF1Bhard-stop\uFF0Fusage error \u539F\u56E0\u8FDB\u6B64\u5B57\u6BB5\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u53E6\u7167\u5F55 amendments" }),
26060
+ amendments: Type21.Optional(reviewerAmendmentsSchema)
26108
26061
  }, { additionalProperties: false })
26109
26062
  ]);
26110
26063
  var reviewerOutputSchema = withTerminatingOutputDeclarations(
@@ -26163,7 +26116,7 @@ init_submission_errors();
26163
26116
  init_worker_output();
26164
26117
  init_fixer_output();
26165
26118
  init_fixer_packet();
26166
- import { Type as Type26 } from "typebox";
26119
+ import { Type as Type22 } from "typebox";
26167
26120
 
26168
26121
  // src/worker-submission-gates.ts
26169
26122
  init_archivist_record_entry();
@@ -26428,20 +26381,20 @@ function fixerBashSeatbeltDenyReason(matched) {
26428
26381
 
26429
26382
  // src/worker-role.ts
26430
26383
  var CODER_STATUS_DESCRIPTION = "planned | completed | refused | 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";
26431
- var coderOutputVariants = Type26.Union([
26432
- Type26.Object({
26433
- status: Type26.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26434
- report: Type26.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
26384
+ var coderOutputVariants = Type22.Union([
26385
+ Type22.Object({
26386
+ status: Type22.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26387
+ report: Type22.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
26435
26388
  }, { additionalProperties: false }),
26436
- Type26.Object({
26437
- status: Type26.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26438
- report: Type26.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
26389
+ Type22.Object({
26390
+ status: Type22.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26391
+ report: Type22.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
26439
26392
  }, { additionalProperties: false }),
26440
- Type26.Object({
26441
- status: Type26.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26442
- report: Type26.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
26443
- remainingScope: Type26.String({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }),
26444
- reason: Type26.Optional(Type26.String({
26393
+ Type22.Object({
26394
+ status: Type22.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26395
+ report: Type22.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
26396
+ remainingScope: Type22.String({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }),
26397
+ reason: Type22.Optional(Type22.String({
26445
26398
  minLength: 1,
26446
26399
  description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002"
26447
26400
  }))
@@ -26571,7 +26524,7 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
26571
26524
  );
26572
26525
  let pass;
26573
26526
  try {
26574
- pass = WORKER_DONE_STATUSES.has(workerStatusOf(output)) ? await pi.requireGatekeeperPass({
26527
+ pass = WORKER_DONE_STATUSES.has(workerStatusOf(output)) ? await pi.requireSubmissionGate({
26575
26528
  context: ctx,
26576
26529
  subject: { kind: "worker_completion" },
26577
26530
  ..._signal === void 0 ? {} : { signal: _signal },
@@ -26582,10 +26535,17 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
26582
26535
  }) : void 0;
26583
26536
  } catch (error) {
26584
26537
  if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
26585
- return projectAuditEscalation({ status: "escalate", conflicts: error.result.receipt }, output);
26538
+ return projectGatekeeperEscalation(error.result, output);
26586
26539
  }
26587
26540
  throw error;
26588
26541
  }
26542
+ if (pass?.status === "continue") {
26543
+ return {
26544
+ content: [{ type: "text", text: readableGateItem(pass.receipt) }],
26545
+ details: output,
26546
+ terminate: false
26547
+ };
26548
+ }
26589
26549
  const acceptedDetails = output;
26590
26550
  return {
26591
26551
  content: pass === void 0 ? [] : [{ type: "text", text: readableGateItem(pass.receipt) }],
@@ -26715,7 +26675,7 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
26715
26675
  );
26716
26676
  let pass;
26717
26677
  try {
26718
- pass = WORKER_DONE_STATUSES.has(workerStatusOf(output)) ? await pi.requireGatekeeperPass({
26678
+ pass = WORKER_DONE_STATUSES.has(workerStatusOf(output)) ? await pi.requireSubmissionGate({
26719
26679
  context: ctx2,
26720
26680
  subject: { kind: "worker_completion" },
26721
26681
  ..._signal === void 0 ? {} : { signal: _signal },
@@ -26726,10 +26686,17 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
26726
26686
  }) : void 0;
26727
26687
  } catch (error) {
26728
26688
  if (error instanceof GatekeeperDecisionError && error.result.status === "escalate") {
26729
- return projectAuditEscalation({ status: "escalate", conflicts: error.result.receipt }, output);
26689
+ return projectGatekeeperEscalation(error.result, output);
26730
26690
  }
26731
26691
  throw error;
26732
26692
  }
26693
+ if (pass?.status === "continue") {
26694
+ return {
26695
+ content: [{ type: "text", text: readableGateItem(pass.receipt) }],
26696
+ details: output,
26697
+ terminate: false
26698
+ };
26699
+ }
26733
26700
  const acceptedDetails = output;
26734
26701
  return {
26735
26702
  content: pass === void 0 ? [] : [{ type: "text", text: readableGateItem(pass.receipt) }],
@@ -27113,6 +27080,13 @@ function createFiledOfficerRuntime(roleHost, spec, dependencies) {
27113
27080
  if (isAuditEscalationProjection(projected)) {
27114
27081
  return { content: [], details: projected, terminate: true };
27115
27082
  }
27083
+ if (projected !== null && typeof projected === "object" && "status" in projected && projected.status === "continue" && "receipt" in projected) {
27084
+ return {
27085
+ content: [{ type: "text", text: readableGateItem(projected.receipt) }],
27086
+ details: projected,
27087
+ terminate: false
27088
+ };
27089
+ }
27116
27090
  const pass = spec.relayGatePass === true && projected !== null && typeof projected === "object" && "officer" in projected && "receipt" in projected ? projected : void 0;
27117
27091
  return {
27118
27092
  content: pass === void 0 || pass.receipt === void 0 ? [] : [{ type: "text", text: readableGateItem(pass.receipt) }],
@@ -27305,12 +27279,12 @@ ${error.message}`
27305
27279
  );
27306
27280
  }
27307
27281
  var COUNTERSIGN_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "continue", "escalate"]);
27308
- var COUNTERSIGN_STATUS_REASK = "countersignStatus \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
27282
+ var COUNTERSIGN_STATUS_REASK = "status \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
27309
27283
  var SECRETARIAT_QUEUE_STATUSES = /* @__PURE__ */ new Set(["converged", "escalate"]);
27310
27284
  var SECRETARIAT_STATUS_REASK = "secretariatStatus \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
27311
27285
  function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
27312
27286
  const beforeAccept = hostActions !== void 0 ? async ({ toolCallId, parameters, signal, ctx }) => {
27313
- if (roleHost.requireGatekeeperPass === void 0) {
27287
+ if (roleHost.requireSubmissionGate === void 0) {
27314
27288
  const error = new Error("host cannot mount the secretariat submission gate");
27315
27289
  error.name = "InfrastructureFailure";
27316
27290
  return hostActions.failInfrastructure(error, ctx, toolCallId);
@@ -27324,7 +27298,7 @@ function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
27324
27298
  return void 0;
27325
27299
  }
27326
27300
  try {
27327
- const pass = await roleHost.requireGatekeeperPass({
27301
+ const pass = await roleHost.requireSubmissionGate({
27328
27302
  context: ctx,
27329
27303
  subject: { kind: "secretariat_verdict" },
27330
27304
  ...signal === void 0 ? {} : { signal },
@@ -27333,7 +27307,7 @@ function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
27333
27307
  // #879: this-turn typed payload — identity-bound at submit site.
27334
27308
  submission: parameters
27335
27309
  });
27336
- if (pass !== void 0 && pass !== null && typeof pass === "object" && "receipt" in pass) {
27310
+ if (pass !== void 0 && pass !== null && typeof pass === "object" && pass.status === "converged" && "receipt" in pass) {
27337
27311
  const {
27338
27312
  SECRETARIAT_GATE_OFFICER_ENTRY_TYPE: SECRETARIAT_GATE_OFFICER_ENTRY_TYPE2
27339
27313
  } = await Promise.resolve().then(() => (init_secretariat_contracts(), secretariat_contracts_exports));
@@ -27411,20 +27385,20 @@ function createSecretariatRoleRuntime(roleHost, dependencies, hostActions) {
27411
27385
  function createCountersignRoleRuntime(roleHost, dependencies, hostActions) {
27412
27386
  const beforeAccept = hostActions !== void 0 ? async ({ toolCallId, parameters, signal, ctx }) => {
27413
27387
  const record4 = parameters !== null && typeof parameters === "object" && !Array.isArray(parameters) ? parameters : void 0;
27414
- const status = record4 !== void 0 && typeof record4.countersignStatus === "string" ? record4.countersignStatus : void 0;
27388
+ const status = record4 !== void 0 && typeof record4.status === "string" ? record4.status : void 0;
27415
27389
  if (status === void 0 || !COUNTERSIGN_QUEUE_STATUSES.has(status)) {
27416
27390
  throw new ParentQueueReaskError(COUNTERSIGN_STATUS_REASK);
27417
27391
  }
27418
27392
  if (status === "escalate") {
27419
27393
  return void 0;
27420
27394
  }
27421
- if (roleHost.requireGatekeeperPass === void 0) {
27395
+ if (roleHost.requireSubmissionGate === void 0) {
27422
27396
  const error = new Error("host cannot mount the countersign gate");
27423
27397
  error.name = "InfrastructureFailure";
27424
27398
  return hostActions.failInfrastructure(error, ctx, toolCallId);
27425
27399
  }
27426
27400
  try {
27427
- return await roleHost.requireGatekeeperPass({
27401
+ return await roleHost.requireSubmissionGate({
27428
27402
  context: ctx,
27429
27403
  subject: { kind: "countersign_verdict" },
27430
27404
  ...signal === void 0 ? {} : { signal },
@@ -27475,7 +27449,15 @@ function createRoleRuntimeExtension(dependencies) {
27475
27449
  };
27476
27450
  const roleHost = createSubmissionLedgerHost(
27477
27451
  envelopeHost.host,
27478
- new Map(PACKAGED_ROLE_REGISTRY.map(({ role, outputTool }) => [outputTool, role])),
27452
+ new Map(PACKAGED_ROLE_REGISTRY.reduce((entries, { role, outputTool }) => {
27453
+ const existingIndex = entries.findIndex(([name]) => name === outputTool);
27454
+ if (existingIndex < 0) entries.push([outputTool, role]);
27455
+ else {
27456
+ const previous = entries[existingIndex][1];
27457
+ entries[existingIndex] = [outputTool, [...Array.isArray(previous) ? previous : [previous], role]];
27458
+ }
27459
+ return entries;
27460
+ }, [])),
27479
27461
  failInfrastructure,
27480
27462
  async (closed, context) => projectClosedSubmission(closed, context)
27481
27463
  );
@@ -28393,7 +28375,7 @@ import { createServer } from "node:net";
28393
28375
  import { dirname as dirname25, join as join46 } from "node:path";
28394
28376
  import { fileURLToPath as fileURLToPath2 } from "node:url";
28395
28377
 
28396
- // src/gatekeeper-pass-envelope.ts
28378
+ // src/submission-gate.ts
28397
28379
  init_archivist_record_entry();
28398
28380
  init_gatekeeper_role();
28399
28381
  init_session_assistant_usage();
@@ -28416,7 +28398,7 @@ function createDefaultGateOfficerSummon(options) {
28416
28398
  };
28417
28399
  }
28418
28400
  function bookDirectOfficerPointer(context, officer, result, summoned) {
28419
- if (result.status !== "pass" && result.status !== "bounce" && result.status !== "escalate" && result.status !== "needs_reask" && result.status !== "transport_failure") {
28401
+ if (result.status !== "converged" && result.status !== "continue" && result.status !== "escalate" && result.status !== "needs_reask" && result.status !== "transport_failure") {
28420
28402
  return;
28421
28403
  }
28422
28404
  const parentFile = context.sessionManager?.getSessionFile?.();
@@ -28432,7 +28414,7 @@ function bookDirectOfficerPointer(context, officer, result, summoned) {
28432
28414
  ...typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "" ? { runDirectory: summoned.runDirectory } : {}
28433
28415
  });
28434
28416
  }
28435
- async function requireGatekeeperPass(options) {
28417
+ async function requireSubmissionGate(options) {
28436
28418
  let reask;
28437
28419
  const summonOfficer = options.summonOfficer ?? createDefaultGateOfficerSummon({
28438
28420
  cwd: options.context.cwd ?? process.cwd()
@@ -28459,8 +28441,17 @@ async function requireGatekeeperPass(options) {
28459
28441
  options.hostActions.failInfrastructure(error, options.context, options.toolCallId);
28460
28442
  }
28461
28443
  }
28462
- if (gatekeeper.status === "pass") {
28444
+ if (gatekeeper.status === "converged") {
28463
28445
  return {
28446
+ status: "converged",
28447
+ officer: projected.officer,
28448
+ receipt: gatekeeper.receipt,
28449
+ ...typeof gatekeeper.runId === "string" && gatekeeper.runId.trim() !== "" ? { runId: gatekeeper.runId } : {}
28450
+ };
28451
+ }
28452
+ if (gatekeeper.status === "continue") {
28453
+ return {
28454
+ status: "continue",
28464
28455
  officer: projected.officer,
28465
28456
  receipt: gatekeeper.receipt,
28466
28457
  ...typeof gatekeeper.runId === "string" && gatekeeper.runId.trim() !== "" ? { runId: gatekeeper.runId } : {}
@@ -28781,9 +28772,9 @@ async function prepareRoleEnvelope(options) {
28781
28772
  getActiveTools() {
28782
28773
  return [...preferredTools];
28783
28774
  },
28784
- async requireGatekeeperPass(gateOptions) {
28775
+ async requireSubmissionGate(gateOptions) {
28785
28776
  const packageRoot = typeof options.dependencies.packageRoot === "string" ? options.dependencies.packageRoot : void 0;
28786
- return requireGatekeeperPass({
28777
+ return requireSubmissionGate({
28787
28778
  context: gateOptions.context,
28788
28779
  subject: gateOptions.subject,
28789
28780
  ...gateOptions.signal === void 0 ? {} : { signal: gateOptions.signal },
@@ -28837,7 +28828,7 @@ async function prepareRoleEnvelope(options) {
28837
28828
  const record4 = details;
28838
28829
  if (record4.cause === "infrastructure") return;
28839
28830
  if (record4.kind === "role_infrastructure_failure") return;
28840
- const code = typeof record4.code === "string" && record4.code.length > 0 ? record4.code : record4.status === "bounce" || record4.status === "escalate" || record4.status === "no_receipt" ? record4.status : void 0;
28831
+ const code = typeof record4.code === "string" && record4.code.length > 0 ? record4.code : record4.status === "continue" || record4.status === "escalate" || record4.status === "no_receipt" ? record4.status : void 0;
28841
28832
  if (code === void 0) return;
28842
28833
  rejection = {
28843
28834
  code,
@@ -28846,7 +28837,7 @@ async function prepareRoleEnvelope(options) {
28846
28837
  };
28847
28838
  }
28848
28839
  function textDiagnostic(content) {
28849
- const text = content.map((part) => part.type === "text" ? part.text : "").join("");
28840
+ const text = content.filter((part) => part.type === "text").map((part) => part.text).join("\n\n");
28850
28841
  return text.trim().length > 0 ? text : void 0;
28851
28842
  }
28852
28843
  function rememberInfrastructureFailure(details, content) {
@@ -28963,6 +28954,13 @@ async function prepareRoleEnvelope(options) {
28963
28954
  details: result.details,
28964
28955
  isError: false
28965
28956
  });
28957
+ if (result.terminate === false) {
28958
+ rejection = {
28959
+ code: "continue",
28960
+ toolCallIds: [toolCallId],
28961
+ message: textDiagnostic(projected.content) ?? "continue"
28962
+ };
28963
+ }
28966
28964
  return { content: projected.content, isError: projected.isError };
28967
28965
  } catch (error) {
28968
28966
  let content;