@akagilnc/pi-workflow-roles 0.1.4980 → 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 +438 -456
  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 +4 -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 +20 -41
  9. package/dist/headless-host/production-host.js +438 -456
  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 +90 -86
  20. package/dist/public-cli/option-definitions.js +2 -2
  21. package/dist/public-cli/settlement.js +11 -11
  22. package/dist/review-submission.js +20 -0
  23. package/dist/submission-errors.js +2 -2
  24. package/dist/submission-ledger.js +14 -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 +8 -8
  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 +30 -55
  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 +29 -49
  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 +13 -14
  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 +13 -3
  64. package/src/ticket-trajectory.ts +9 -4
  65. package/src/worker-role.ts +16 -2
@@ -1,4 +1,5 @@
1
- const INSPECTOR_OUTPUT_TOOL_NAME = "ak_inspector_output";
1
+ import { REVIEW_SUBMISSION_OUTPUT_TOOL_NAME } from "./review-submission.js";
2
+ const INSPECTOR_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
2
3
  const INSPECTOR_SOURCE_RUN_FLAG = {
3
4
  name: "ak-inspector-source-run",
4
5
  definition: {
@@ -16,7 +17,7 @@ function validateRecordedInspectorOutput(value) {
16
17
  } catch {
17
18
  throw new Error("Inspector output has no execution discriminator");
18
19
  }
19
- if (status === "pass" || status === "bounce" || status === "escalate") {
20
+ if (status === "converged" || status === "continue" || status === "escalate") {
20
21
  return value;
21
22
  }
22
23
  throw new Error("Inspector output has no execution discriminator");
@@ -8282,12 +8282,43 @@ var init_navigator_output = __esm({
8282
8282
  }
8283
8283
  });
8284
8284
 
8285
+ // src/review-submission.ts
8286
+ var REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, reviewSubmissionSchema;
8287
+ var init_review_submission = __esm({
8288
+ "src/review-submission.ts"() {
8289
+ "use strict";
8290
+ init_build();
8291
+ init_open_tool_schema();
8292
+ init_terminating_infrastructure();
8293
+ REVIEW_SUBMISSION_OUTPUT_TOOL_NAME = "ak_submission_output";
8294
+ reviewSubmissionSchema = withTerminatingOutputDeclarations(
8295
+ openToolObject(
8296
+ typebox_exports.Object({
8297
+ status: typebox_exports.Optional(typebox_exports.Unknown({
8298
+ description: "converged | continue | escalate \u2014 \u975E\u4E09\u6001\u65F6\u8BF7\u91CD\u8BFB\u540E\u91CD\u4EA4\uFF0C\u52FF\u6539\u6807\u3002"
8299
+ })),
8300
+ findings: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u5BA1\u6838\u53D1\u73B0\uFF0C\u539F\u6837\u7559\u5B58" })),
8301
+ reason: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u4E0A\u5448\u7406\u7531" })),
8302
+ violations: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u8FDD\u89C4\u6761\u76EE" })),
8303
+ conflicts: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u5F85\u51B3\u51B2\u7A81" })),
8304
+ fix: typebox_exports.Optional(typebox_exports.Unknown({ description: "continue \u65F6\u7684\u8865\u6551\u8BF4\u660E\uFF1B\u53EF\u5199 summary \u6458\u8981\uFF0C\u5176\u4F59\u5185\u5BB9\u539F\u6837\u7559\u5B58" })),
8305
+ classes: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u5DF2\u88C1\u51B3 finding \u7C7B\uFF1B\u53EF\u8BF4\u660E name\u3001owner\u3001boundary\u3001disposition\uFF0C\u539F\u6837\u7559\u5B58" })),
8306
+ note: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u88C1\u51B3\u9644\u6CE8" })),
8307
+ evidence: typebox_exports.Optional(typebox_exports.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
8308
+ decisionGate: typebox_exports.Optional(typebox_exports.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" }))
8309
+ })
8310
+ )
8311
+ );
8312
+ }
8313
+ });
8314
+
8285
8315
  // src/package-contracts/judge-output.ts
8286
8316
  var JUDGE_OUTPUT_TOOL_NAME;
8287
8317
  var init_judge_output = __esm({
8288
8318
  "src/package-contracts/judge-output.ts"() {
8289
8319
  "use strict";
8290
- JUDGE_OUTPUT_TOOL_NAME = "ak_judge_output";
8320
+ init_review_submission();
8321
+ JUDGE_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
8291
8322
  }
8292
8323
  });
8293
8324
 
@@ -13854,29 +13885,12 @@ var init_merger_contracts = __esm({
13854
13885
  });
13855
13886
 
13856
13887
  // src/notary-contracts.ts
13857
- var NOTARY_OUTPUT_TOOL_NAME, notaryOutputSchema;
13888
+ var NOTARY_OUTPUT_TOOL_NAME;
13858
13889
  var init_notary_contracts = __esm({
13859
13890
  "src/notary-contracts.ts"() {
13860
13891
  "use strict";
13861
- init_build();
13862
- init_open_tool_schema();
13863
- init_terminating_infrastructure();
13864
- NOTARY_OUTPUT_TOOL_NAME = "ak_notary_output";
13865
- notaryOutputSchema = withTerminatingOutputDeclarations(
13866
- openToolObject(
13867
- typebox_exports.Object({
13868
- status: typebox_exports.Unknown({
13869
- description: "pass | bounce | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
13870
- }),
13871
- findings: typebox_exports.Unknown({
13872
- description: "string[] findings\uFF0C\u968F pass\u3001bounce \u6216 escalate \u7559\u5B58"
13873
- }),
13874
- reason: typebox_exports.Optional(typebox_exports.Unknown({
13875
- description: "status \u4E3A escalate \u65F6\u7684\u4E0A\u5448\u7406\u7531"
13876
- }))
13877
- })
13878
- )
13879
- );
13892
+ init_review_submission();
13893
+ NOTARY_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
13880
13894
  }
13881
13895
  });
13882
13896
 
@@ -13885,7 +13899,8 @@ var COUNTERSIGN_OUTPUT_TOOL_NAME;
13885
13899
  var init_countersign_contracts = __esm({
13886
13900
  "src/countersign-contracts.ts"() {
13887
13901
  "use strict";
13888
- COUNTERSIGN_OUTPUT_TOOL_NAME = "ak_countersign_output";
13902
+ init_review_submission();
13903
+ COUNTERSIGN_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
13889
13904
  }
13890
13905
  });
13891
13906
 
@@ -13903,37 +13918,18 @@ var INSPECTOR_OUTPUT_TOOL_NAME;
13903
13918
  var init_inspector_contracts = __esm({
13904
13919
  "src/inspector-contracts.ts"() {
13905
13920
  "use strict";
13906
- INSPECTOR_OUTPUT_TOOL_NAME = "ak_inspector_output";
13921
+ init_review_submission();
13922
+ INSPECTOR_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
13907
13923
  }
13908
13924
  });
13909
13925
 
13910
13926
  // src/package-contracts/auditor-output.ts
13911
- var AUDITOR_OUTPUT_TOOL_NAME, auditorOutputSchema;
13927
+ var AUDITOR_OUTPUT_TOOL_NAME;
13912
13928
  var init_auditor_output = __esm({
13913
13929
  "src/package-contracts/auditor-output.ts"() {
13914
13930
  "use strict";
13915
- init_build();
13916
- init_open_tool_schema();
13917
- init_terminating_infrastructure();
13918
- AUDITOR_OUTPUT_TOOL_NAME = "ak_auditor_output";
13919
- auditorOutputSchema = withTerminatingOutputDeclarations(
13920
- openToolObject(
13921
- typebox_exports.Object({
13922
- status: typebox_exports.Unknown({
13923
- description: "pass | bounce | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
13924
- }),
13925
- violations: typebox_exports.Optional(typebox_exports.Unknown({
13926
- description: "status \u4E3A bounce \u65F6\u7684\u8FDD\u89C4\u6761\u76EE"
13927
- })),
13928
- conflicts: typebox_exports.Optional(typebox_exports.Unknown({
13929
- description: "status \u4E3A escalate \u65F6\u7684\u51B2\u7A81"
13930
- })),
13931
- decisionGate: typebox_exports.Optional(typebox_exports.Unknown({
13932
- description: "status \u4E3A escalate \u65F6\u7684\u51B3\u7B56\u95F8"
13933
- }))
13934
- })
13935
- )
13936
- );
13931
+ init_review_submission();
13932
+ AUDITOR_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
13937
13933
  }
13938
13934
  });
13939
13935
 
@@ -13956,7 +13952,7 @@ var init_judge_auditor = __esm({
13956
13952
  });
13957
13953
 
13958
13954
  // src/packaged-role-registry.ts
13959
- var NOTARY_SESSION_MATERIALS, INSPECTOR_SESSION_MATERIALS, AUDITOR_PUBLIC_SESSION_MATERIALS, PUBLIC_ROLE_RECORDS, PACKAGED_ROLE_REGISTRY;
13955
+ var LEGACY_REVIEW_OUTPUT_ROLES, NOTARY_SESSION_MATERIALS, INSPECTOR_SESSION_MATERIALS, AUDITOR_PUBLIC_SESSION_MATERIALS, PUBLIC_ROLE_RECORDS, PACKAGED_ROLE_REGISTRY;
13960
13956
  var init_packaged_role_registry = __esm({
13961
13957
  "src/packaged-role-registry.ts"() {
13962
13958
  "use strict";
@@ -13977,6 +13973,13 @@ var init_packaged_role_registry = __esm({
13977
13973
  init_diarist_contracts();
13978
13974
  init_secretariat_contracts();
13979
13975
  init_judge_auditor();
13976
+ LEGACY_REVIEW_OUTPUT_ROLES = /* @__PURE__ */ new Map([
13977
+ ["ak_judge_output", "judge"],
13978
+ ["ak_notary_output", "notary"],
13979
+ ["ak_countersign_output", "countersign"],
13980
+ ["ak_inspector_output", "inspector"],
13981
+ ["ak_auditor_output", "auditor"]
13982
+ ]);
13980
13983
  NOTARY_SESSION_MATERIALS = [
13981
13984
  "CLAUDE.md",
13982
13985
  "souls/notary.md",
@@ -14018,7 +14021,7 @@ var init_packaged_role_registry = __esm({
14018
14021
  /** Navigator subject is the public admitted instruction when the run is bound. */
14019
14022
  navigatorSubject: "public-instruction",
14020
14023
  activationStage: "load-and-install",
14021
- receiptStatusKey: "judgeStatus",
14024
+ receiptStatusKey: "status",
14022
14025
  sessionMaterials: [
14023
14026
  "CLAUDE.md",
14024
14027
  "souls/judge.md",
@@ -14300,15 +14303,13 @@ var init_packaged_role_registry = __esm({
14300
14303
  outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
14301
14304
  settlement: "accepted",
14302
14305
  gateStageLabel: "\u7ED9\u4E8B\u4E2D",
14303
- /** Gate queue reads countersignStatus, not the shared three-state status. */
14304
- gateDecision: "countersign-status",
14305
14306
  /** Gate summon carries the parent payload as the instruction and a parent run id. */
14306
14307
  gateSummon: "parent-instruction",
14307
14308
  activationFlags: [
14308
14309
  { field: "ticketNumber" }
14309
14310
  ],
14310
14311
  activationStage: "load-and-install",
14311
- receiptStatusKey: "countersignStatus",
14312
+ receiptStatusKey: "status",
14312
14313
  // #924: 公用《票面法》三席同装
14313
14314
  sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md"]
14314
14315
  },
@@ -14498,6 +14499,7 @@ var init_gatekeeper_role = __esm({
14498
14499
  init_packaged_role_registry();
14499
14500
  init_submission_errors();
14500
14501
  init_inspector_contracts();
14502
+ init_review_submission();
14501
14503
  init_gatekeeper_output();
14502
14504
  init_run_terminal_artifacts();
14503
14505
  init_submission_errors();
@@ -14911,7 +14913,10 @@ var init_terminating_tools = __esm({
14911
14913
  init_diarist_contracts();
14912
14914
  init_secretariat_contracts();
14913
14915
  init_worker_output();
14914
- TERMINATING_TOOL_NAMES = PACKAGED_ROLE_REGISTRY.map((entry) => entry.outputTool);
14916
+ TERMINATING_TOOL_NAMES = [.../* @__PURE__ */ new Set([
14917
+ ...PACKAGED_ROLE_REGISTRY.map((entry) => entry.outputTool),
14918
+ ...LEGACY_REVIEW_OUTPUT_ROLES.keys()
14919
+ ])];
14915
14920
  }
14916
14921
  });
14917
14922
 
@@ -15690,7 +15695,7 @@ var init_option_definitions = __esm({
15690
15695
  },
15691
15696
  inspector: {
15692
15697
  command: "inspector",
15693
- summary: "Direct Inspector (\u53F0\u9662) complexity and test-quality check; pass or bounce.",
15698
+ summary: "Direct Inspector (\u53F0\u9662) complexity and test-quality check; converged, continue, or escalate.",
15694
15699
  usage: ["ak-role inspector [options] [instruction]"],
15695
15700
  examples: [
15696
15701
  'ak-role inspector --attach ./change.patch "Review this material."'
@@ -15714,7 +15719,7 @@ var init_option_definitions = __esm({
15714
15719
  },
15715
15720
  auditor: {
15716
15721
  command: "auditor",
15717
- summary: "Direct Auditor (\u5BA1\u5211\u9662) compliance audit: pass, bounce, or escalate.",
15722
+ summary: "Direct Auditor (\u5BA1\u5211\u9662) compliance audit: converged, continue, or escalate.",
15718
15723
  usage: ["ak-role auditor --subject <judge|doctor> --source-run <runId@role|path> [options] [instruction]"],
15719
15724
  examples: [
15720
15725
  'ak-role auditor --subject judge --source-run 01abc\u2026@judge --attach ./dossier "\u5BA1\uFF1A\u672C run \u662F\u5426\u5408\u89C4\u3002"',
@@ -1,4 +1,4 @@
1
- import { PACKAGED_ROLE_REGISTRY } from "./packaged-role-registry.js";
1
+ import { LEGACY_REVIEW_OUTPUT_ROLES, PACKAGED_ROLE_REGISTRY } from "./packaged-role-registry.js";
2
2
  import { isUuidV7, uuidv7 } from "./uuidv7.js";
3
3
  import { workSubjectKeysEqual } from "./work-subject-identity.js";
4
4
  const NAVIGATOR_INVOCATION_ENTRY = "ak-navigator-invocation";
@@ -45,7 +45,7 @@ function isNavigatorInfrastructureFailureFact(value) {
45
45
  return Object.keys(value).length === NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS.length;
46
46
  }
47
47
  const PACKAGED_ROLE_OUTPUT_TOOLS = new Map(
48
- PACKAGED_ROLE_REGISTRY.map((entry) => [entry.outputTool, entry.role])
48
+ [...PACKAGED_ROLE_REGISTRY.filter((entry) => entry.outputTool !== "ak_submission_output").map((entry) => [entry.outputTool, entry.role]), ...LEGACY_REVIEW_OUTPUT_ROLES]
49
49
  );
50
50
  function mintNavigatorInvocationId() {
51
51
  return uuidv7();
@@ -86,7 +86,7 @@ function markerMatchesExpectedIdentity(marker, expected) {
86
86
  }
87
87
  function classifyPackagedRoleTerminalResult(message) {
88
88
  if (typeof message.toolName !== "string") return { kind: "nonterminal" };
89
- if (!PACKAGED_ROLE_OUTPUT_TOOLS.has(message.toolName)) return { kind: "nonterminal" };
89
+ if (!PACKAGED_ROLE_OUTPUT_TOOLS.has(message.toolName) && message.toolName !== "ak_submission_output") return { kind: "nonterminal" };
90
90
  const hasInfraBase = hasNavigatorInfrastructureFailureBase(message.details);
91
91
  const infraFact = hasInfraBase ? buildNavigatorInfrastructureFailureFact() : void 0;
92
92
  if (message.isError === true) {
@@ -110,12 +110,14 @@ function durableTerminalAt(entries, index) {
110
110
  const entry = entries[index];
111
111
  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;
112
112
  if (typeof message?.toolName !== "string") return void 0;
113
- const role = PACKAGED_ROLE_OUTPUT_TOOLS.get(message.toolName);
113
+ const marker = message.toolName === "ak_submission_output" ? entries.slice(0, index).reverse().find(isInvocationMarkerEntry) : void 0;
114
+ const role = message.toolName === "ak_submission_output" ? parseInvocationMarkerIdentity(marker?.data)?.role ?? "unknown" : PACKAGED_ROLE_OUTPUT_TOOLS.get(message.toolName);
114
115
  if (role === void 0) return void 0;
115
116
  const classification = classifyPackagedRoleTerminalResult(message);
116
117
  if (classification.kind !== "accepted" && classification.kind !== "infrastructure") {
117
118
  return void 0;
118
119
  }
120
+ if (entry?.type === "message" && classification.kind === "accepted" && !LEGACY_REVIEW_OUTPUT_ROLES.has(message.toolName)) return void 0;
119
121
  return {
120
122
  index,
121
123
  role,
@@ -1,7 +1,5 @@
1
- import { Type } from "typebox";
2
- import { openToolObject } from "./open-tool-schema.js";
3
- import { withTerminatingOutputDeclarations } from "./package-contracts/terminating-infrastructure.js";
4
- const NOTARY_OUTPUT_TOOL_NAME = "ak_notary_output";
1
+ import { REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, reviewSubmissionSchema } from "./review-submission.js";
2
+ const NOTARY_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
5
3
  const NOTARY_SOURCE_RUN_FLAG = {
6
4
  name: "ak-notary-source-run",
7
5
  definition: {
@@ -17,21 +15,7 @@ const NOTARY_TICKET_FLAG = {
17
15
  }
18
16
  };
19
17
  const NOTARY_FIXED_KICKOFF = "\u7B26\u5B9D\u90CE\u6848\u5377\u5DF2\u53D7\u7406\uFF1B\u6765\u6E90 run \u5B9A\u4F4D\u89C1\u4F1A\u8BDD\u6750\u6599\u3002";
20
- const notaryOutputSchema = withTerminatingOutputDeclarations(
21
- openToolObject(
22
- Type.Object({
23
- status: Type.Unknown({
24
- description: "pass | bounce | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
25
- }),
26
- findings: Type.Unknown({
27
- description: "string[] findings\uFF0C\u968F pass\u3001bounce \u6216 escalate \u7559\u5B58"
28
- }),
29
- reason: Type.Optional(Type.Unknown({
30
- description: "status \u4E3A escalate \u65F6\u7684\u4E0A\u5448\u7406\u7531"
31
- }))
32
- })
33
- )
34
- );
18
+ const notaryOutputSchema = reviewSubmissionSchema;
35
19
  function isRecord(value) {
36
20
  return typeof value === "object" && value !== null && !Array.isArray(value);
37
21
  }
@@ -1,25 +1,10 @@
1
1
  /**
2
2
  * Public Auditor (审刑院) terminating receipt contracts (#675 / #754).
3
- * Lawful explicit releases: pass | bounce | escalate.
3
+ * Lawful explicit releases: converged | continue | escalate.
4
4
  */
5
- import { Type } from "typebox";
6
- import { openToolObject } from "../open-tool-schema.js";
7
- import { withTerminatingOutputDeclarations } from "./terminating-infrastructure.js";
8
- export const AUDITOR_OUTPUT_TOOL_NAME = "ak_auditor_output";
9
- export const auditorOutputSchema = withTerminatingOutputDeclarations(openToolObject(Type.Object({
10
- status: Type.Unknown({
11
- description: "pass | bounce | escalate — 形状指引,非 schema 闸",
12
- }),
13
- violations: Type.Optional(Type.Unknown({
14
- description: "status 为 bounce 时的违规条目",
15
- })),
16
- conflicts: Type.Optional(Type.Unknown({
17
- description: "status 为 escalate 时的冲突",
18
- })),
19
- decisionGate: Type.Optional(Type.Unknown({
20
- description: "status 为 escalate 时的决策闸",
21
- })),
22
- })));
5
+ import { REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, reviewSubmissionSchema } from "../review-submission.js";
6
+ export const AUDITOR_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
7
+ export const auditorOutputSchema = reviewSubmissionSchema;
23
8
  function isRecord(value) {
24
9
  return typeof value === "object" && value !== null && !Array.isArray(value);
25
10
  }
@@ -1,16 +1,17 @@
1
- const JUDGE_OUTPUT_TOOL_NAME = "ak_judge_output";
1
+ import { REVIEW_SUBMISSION_OUTPUT_TOOL_NAME } from "../review-submission.js";
2
+ const JUDGE_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
2
3
  function validateAcceptedJudgeDetails(verdict) {
3
4
  if (verdict === null || typeof verdict !== "object" || Array.isArray(verdict)) throw new Error("Judge verdict has no execution discriminator");
4
- let judgeStatus;
5
+ let status;
5
6
  try {
6
- judgeStatus = verdict.judgeStatus;
7
+ status = verdict.status;
7
8
  } catch {
8
9
  throw new Error("Judge verdict has no execution discriminator");
9
10
  }
10
- if (typeof judgeStatus !== "string") {
11
+ if (typeof status !== "string") {
11
12
  throw new Error("Judge verdict has no execution discriminator");
12
13
  }
13
- if (["converged", "continue", "escalate"].includes(judgeStatus)) {
14
+ if (["converged", "continue", "escalate"].includes(status)) {
14
15
  return verdict;
15
16
  }
16
17
  throw new Error("Judge verdict has no execution discriminator");
@@ -5,7 +5,7 @@
5
5
  import { COLLECTOR_OUTPUT_TOOL, validateAcceptedCollectorReceipt, } from "./collector-output.js";
6
6
  import { JUDGE_OUTPUT_TOOL_NAME, validateAcceptedJudgeDetails, } from "./judge-output.js";
7
7
  import { REVIEWER_OUTPUT_TOOL_NAME, validateReviewerIntent, } from "./reviewer-output.js";
8
- import { PACKAGED_ROLE_REGISTRY } from "../packaged-role-registry.js";
8
+ import { LEGACY_REVIEW_OUTPUT_ROLES, PACKAGED_ROLE_REGISTRY } from "../packaged-role-registry.js";
9
9
  import { CorrectableSubmissionError } from "../submission-correctable-error.js";
10
10
  import { DOCTOR_OUTPUT_TOOL_NAME, validateDoctorSubmissionShape, validateRecordedDoctorOutput } from "../doctor-contracts.js";
11
11
  import { GATEKEEPER_OUTPUT_TOOL_NAME, validateRecordedGatekeeperOutput } from "./gatekeeper-output.js";
@@ -20,7 +20,10 @@ import { DIARIST_OUTPUT_TOOL_NAME, validateRecordedDiaristOutput } from "../diar
20
20
  import { SECRETARIAT_OUTPUT_TOOL_NAME } from "../secretariat-contracts.js";
21
21
  import { CODER_OUTPUT_TOOL_NAME, FIXER_OUTPUT_TOOL_NAME, validateAcceptedWorkerDetails, } from "./worker-output.js";
22
22
  export { CODER_OUTPUT_TOOL_NAME, COLLECTOR_OUTPUT_TOOL, FIXER_OUTPUT_TOOL_NAME, JUDGE_OUTPUT_TOOL_NAME, REVIEWER_OUTPUT_TOOL_NAME, MERGER_OUTPUT_TOOL_NAME, validateAcceptedCollectorReceipt, validateAcceptedJudgeDetails, validateReviewerIntent, validateAcceptedWorkerDetails, validateDoctorSubmissionShape, validateRecordedDoctorOutput, validateMergerOutput, validateRecordedNotaryOutput, validateRecordedCountersignOutput, validateRecordedGleanerLeftOutput, validateRecordedInspectorOutput, validateRecordedGatekeeperOutput, validateRecordedNavigatorOutput, validateRecordedAuditorOutput, validateRecordedDiaristOutput, };
23
- export const TERMINATING_TOOL_NAMES = PACKAGED_ROLE_REGISTRY.map((entry) => entry.outputTool);
23
+ export const TERMINATING_TOOL_NAMES = [...new Set([
24
+ ...PACKAGED_ROLE_REGISTRY.map((entry) => entry.outputTool),
25
+ ...LEGACY_REVIEW_OUTPUT_ROLES.keys(),
26
+ ])];
24
27
  export function isTerminatingToolName(name) {
25
28
  return TERMINATING_TOOL_NAMES.includes(name);
26
29
  }
@@ -52,7 +55,10 @@ export function validateAcceptedLifecycle(toolName, _argumentsValue, detailsValu
52
55
  export function acceptedFacts(toolName, details) {
53
56
  const record = details;
54
57
  const entry = PACKAGED_ROLE_REGISTRY.find((candidate) => candidate.outputTool === toolName);
55
- const statusKey = entry !== undefined && "receiptStatusKey" in entry ? entry.receiptStatusKey : "status";
58
+ const legacyRole = LEGACY_REVIEW_OUTPUT_ROLES.get(toolName);
59
+ const statusKey = legacyRole === "judge" || legacyRole === "countersign"
60
+ ? `${legacyRole}Status`
61
+ : entry !== undefined && "receiptStatusKey" in entry ? entry.receiptStatusKey : "status";
56
62
  const status = typeof record[statusKey] === "string" ? record[statusKey] : undefined;
57
63
  const commitKey = entry !== undefined && "receiptCommitKey" in entry ? entry.receiptCommitKey : undefined;
58
64
  const commitWhen = entry !== undefined && "receiptCommitWhen" in entry ? entry.receiptCommitWhen : undefined;
@@ -15,6 +15,13 @@ import { AUDITOR_OUTPUT_TOOL_NAME } from "./package-contracts/auditor-output.js"
15
15
  import { DIARIST_OUTPUT_TOOL_NAME } from "./diarist-contracts.js";
16
16
  import { SECRETARIAT_OUTPUT_TOOL_NAME } from "./secretariat-contracts.js";
17
17
  import { JUDGE_AUDIT_TOOL_NAME } from "./judge-auditor.js";
18
+ const LEGACY_REVIEW_OUTPUT_ROLES = /* @__PURE__ */ new Map([
19
+ ["ak_judge_output", "judge"],
20
+ ["ak_notary_output", "notary"],
21
+ ["ak_countersign_output", "countersign"],
22
+ ["ak_inspector_output", "inspector"],
23
+ ["ak_auditor_output", "auditor"]
24
+ ]);
18
25
  const NOTARY_SESSION_MATERIALS = [
19
26
  "CLAUDE.md",
20
27
  "souls/notary.md",
@@ -56,7 +63,7 @@ const PUBLIC_ROLE_RECORDS = [
56
63
  /** Navigator subject is the public admitted instruction when the run is bound. */
57
64
  navigatorSubject: "public-instruction",
58
65
  activationStage: "load-and-install",
59
- receiptStatusKey: "judgeStatus",
66
+ receiptStatusKey: "status",
60
67
  sessionMaterials: [
61
68
  "CLAUDE.md",
62
69
  "souls/judge.md",
@@ -338,15 +345,13 @@ const PUBLIC_ROLE_RECORDS = [
338
345
  outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
339
346
  settlement: "accepted",
340
347
  gateStageLabel: "\u7ED9\u4E8B\u4E2D",
341
- /** Gate queue reads countersignStatus, not the shared three-state status. */
342
- gateDecision: "countersign-status",
343
348
  /** Gate summon carries the parent payload as the instruction and a parent run id. */
344
349
  gateSummon: "parent-instruction",
345
350
  activationFlags: [
346
351
  { field: "ticketNumber" }
347
352
  ],
348
353
  activationStage: "load-and-install",
349
- receiptStatusKey: "countersignStatus",
354
+ receiptStatusKey: "status",
350
355
  // #924: 公用《票面法》三席同装
351
356
  sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md"]
352
357
  },
@@ -662,16 +667,10 @@ function packagedGateSummon(role) {
662
667
  if (record !== void 0 && "gateSummon" in record) return record.gateSummon;
663
668
  return "pointer";
664
669
  }
665
- function packagedGateDecision(role) {
666
- const record = packagedRoleMetadata(role);
667
- if (record !== void 0 && "gateDecision" in record && record.gateDecision === "countersign-status") {
668
- return "countersign-status";
669
- }
670
- return "three-state";
671
- }
672
670
  export {
673
671
  AUDITOR_PUBLIC_SESSION_MATERIALS,
674
672
  INSPECTOR_SESSION_MATERIALS,
673
+ LEGACY_REVIEW_OUTPUT_ROLES,
675
674
  NOTARY_SESSION_MATERIALS,
676
675
  PACKAGED_ROLE_REGISTRY,
677
676
  PUBLIC_ROLE_RECORDS,
@@ -688,7 +687,6 @@ export {
688
687
  packagedBoardPlacement,
689
688
  packagedDurableOfficerEntry,
690
689
  packagedEmitsAuthorityRefs,
691
- packagedGateDecision,
692
690
  packagedGateStageLabel,
693
691
  packagedGateSummon,
694
692
  packagedMethodLoadFailureCause,
@@ -8,7 +8,7 @@ function isRecord(value) {
8
8
  function isEscalatePayload(payload) {
9
9
  if (!isRecord(payload))
10
10
  return false;
11
- return (payload.status === "escalate" || payload.countersignStatus === "escalate");
11
+ return (payload.status === "escalate");
12
12
  }
13
13
  /**
14
14
  * Rows a parent may read from a nested diarist terminal (#836 / #953).