@akagilnc/pi-workflow-roles 0.1.4802 → 0.1.4874

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 (142) hide show
  1. package/dist/acp-host/production-host.js +19434 -18218
  2. package/dist/analyst-book-key.js +63 -0
  3. package/dist/analyst-cohort.js +167 -0
  4. package/dist/analyst-entry.js +320 -0
  5. package/dist/analyst-index.js +247 -0
  6. package/dist/analyst-ledger.js +561 -0
  7. package/dist/analyst-median.js +16 -0
  8. package/dist/analyst-metric-families/acceptance-success-rework.js +249 -0
  9. package/dist/analyst-metric-families/b2-frame-buckets-actions.js +189 -0
  10. package/dist/analyst-metric-families/gate-cycles.js +77 -0
  11. package/dist/analyst-metric-families/leg-wall-clock.js +56 -0
  12. package/dist/analyst-metric-families/round-timeline.js +126 -0
  13. package/dist/analyst-metric-families.js +23 -0
  14. package/dist/analyst-metric-family.js +11 -0
  15. package/dist/analyst-model-groups.js +135 -0
  16. package/dist/analyst-page.js +182 -0
  17. package/dist/atomic-write.js +23 -0
  18. package/dist/auditor-soul.js +1 -1
  19. package/dist/countersign-contracts.js +0 -2
  20. package/dist/diarist-contracts.js +0 -1
  21. package/dist/doctor-contracts.js +2 -2
  22. package/dist/gatekeeper-role.js +15 -16
  23. package/dist/gleaner-left-contracts.js +0 -2
  24. package/dist/headless-host/production-host.js +16967 -15749
  25. package/dist/host-contracts.js +0 -4
  26. package/dist/inspector-contracts.js +0 -2
  27. package/dist/institutional-resolution.js +4 -2
  28. package/dist/merger-contracts.js +0 -2
  29. package/dist/migrate-book-topology.js +3908 -3089
  30. package/dist/navigator-public-session.js +4 -3
  31. package/dist/notary-contracts.js +0 -2
  32. package/dist/package-contracts/auditor-output.js +0 -1
  33. package/dist/package-contracts/collector-output.js +0 -2
  34. package/dist/package-contracts/fixer-output.js +0 -2
  35. package/dist/package-contracts/gatekeeper-output.js +0 -2
  36. package/dist/package-contracts/judge-output.js +0 -2
  37. package/dist/package-contracts/navigator-output.js +0 -2
  38. package/dist/package-contracts/reviewer-output.js +0 -2
  39. package/dist/package-contracts/terminating-tools.js +32 -92
  40. package/dist/package-contracts/worker-output.js +0 -4
  41. package/dist/packaged-role-registry.js +518 -36
  42. package/dist/pi/role-turn-host.js +2 -1
  43. package/dist/public-cli/analyst-run.js +185 -0
  44. package/dist/public-cli/cli.js +885 -0
  45. package/dist/public-cli/config.js +12 -9
  46. package/dist/public-cli/countersign-run.js +4 -311
  47. package/dist/public-cli/instruction-seat-run.js +628 -158
  48. package/dist/public-cli/invocation.js +806 -1550
  49. package/dist/public-cli/main.js +6962 -9882
  50. package/dist/public-cli/option-definitions.js +51 -99
  51. package/dist/public-cli/post-admission.js +30 -2
  52. package/dist/public-cli/run-lifecycle.js +234 -353
  53. package/dist/public-cli/seat-ticket-binding.js +6 -0
  54. package/dist/public-cli/settlement.js +261 -675
  55. package/dist/public-cli/turn-request.js +76 -0
  56. package/dist/public-role-summons.js +38 -112
  57. package/dist/role-activation-flags.js +23 -45
  58. package/dist/secretariat-contracts.js +0 -2
  59. package/dist/session-identity.js +17 -8
  60. package/dist/session-opening-materials.js +3 -2
  61. package/extensions/role-runtime.ts +6 -80
  62. package/package.json +1 -1
  63. package/src/acp-host/role-turn-host.ts +4 -1
  64. package/src/analyst-metric-families/acceptance-success-rework.ts +3 -2
  65. package/src/auditor-role.ts +1 -2
  66. package/src/auditor-soul.ts +1 -1
  67. package/src/collector-role.ts +2 -2
  68. package/src/countersign-contracts.ts +0 -1
  69. package/src/countersign-role.ts +1 -1
  70. package/src/diarist-contracts.ts +0 -1
  71. package/src/diarist-role.ts +0 -1
  72. package/src/doctor-auditor.ts +1 -2
  73. package/src/doctor-contracts.ts +1 -1
  74. package/src/doctor-role.ts +3 -2
  75. package/src/external-host-turn-loop.ts +1 -1
  76. package/src/factory-board.ts +10 -7
  77. package/src/gatekeeper-role.ts +16 -10
  78. package/src/gleaner-left-contracts.ts +0 -1
  79. package/src/gleaner-left-role.ts +0 -1
  80. package/src/headless-host/role-turn-host.ts +7 -1
  81. package/src/host-contracts.ts +10 -6
  82. package/src/inspector-contracts.ts +0 -1
  83. package/src/inspector-role.ts +0 -2
  84. package/src/institutional-resolution.ts +6 -4
  85. package/src/judge-role.ts +3 -3
  86. package/src/merger-contracts.ts +0 -1
  87. package/src/merger-role.ts +2 -2
  88. package/src/navigator-public-session.ts +7 -6
  89. package/src/navigator-work-context.ts +6 -8
  90. package/src/notary-contracts.ts +0 -1
  91. package/src/notary-role.ts +2 -3
  92. package/src/package-contracts/auditor-output.ts +0 -1
  93. package/src/package-contracts/collector-output.ts +0 -1
  94. package/src/package-contracts/fixer-output.ts +0 -1
  95. package/src/package-contracts/gatekeeper-output.ts +0 -1
  96. package/src/package-contracts/judge-output.ts +0 -1
  97. package/src/package-contracts/navigator-output.ts +0 -1
  98. package/src/package-contracts/reviewer-output.ts +0 -1
  99. package/src/package-contracts/terminating-tools.ts +27 -99
  100. package/src/package-contracts/worker-output.ts +0 -2
  101. package/src/packaged-role-registry.ts +604 -35
  102. package/src/pi/role-turn-host.ts +2 -1
  103. package/src/public-cli/cli.ts +64 -259
  104. package/src/public-cli/config.ts +18 -10
  105. package/src/public-cli/countersign-run.ts +14 -449
  106. package/src/public-cli/instruction-seat-run.ts +758 -277
  107. package/src/public-cli/invocation.ts +1097 -2051
  108. package/src/public-cli/option-definitions.ts +62 -127
  109. package/src/public-cli/post-admission.ts +47 -2
  110. package/src/public-cli/run-lifecycle.ts +303 -613
  111. package/src/public-cli/seat-ticket-binding.ts +6 -0
  112. package/src/public-cli/settlement.ts +399 -1185
  113. package/src/public-cli/turn-request.ts +92 -1
  114. package/src/public-role-summons.ts +44 -128
  115. package/src/reviewer-role.ts +3 -2
  116. package/src/role-activation-flags.ts +20 -41
  117. package/src/role-runtime-dependencies.ts +25 -26
  118. package/src/role-runtime.ts +121 -232
  119. package/src/secretariat-contracts.ts +0 -1
  120. package/src/secretariat-role.ts +0 -2
  121. package/src/session-identity.ts +23 -8
  122. package/src/session-opening-materials.ts +2 -1
  123. package/src/worker-role.ts +3 -4
  124. package/dist/doctor-auditor.js +0 -25
  125. package/dist/public-cli/diarist-run.js +0 -130
  126. package/dist/public-cli/doctor-run.js +0 -87
  127. package/dist/public-cli/inspector-run.js +0 -151
  128. package/dist/public-cli/judge-run.js +0 -114
  129. package/dist/public-cli/notary-run.js +0 -174
  130. package/dist/public-cli/reviewer-run.js +0 -339
  131. package/src/public-cli/coder-run.ts +0 -255
  132. package/src/public-cli/collector-run.ts +0 -189
  133. package/src/public-cli/diarist-run.ts +0 -233
  134. package/src/public-cli/doctor-run.ts +0 -167
  135. package/src/public-cli/fixer-run.ts +0 -265
  136. package/src/public-cli/gleaner-left-run.ts +0 -167
  137. package/src/public-cli/inspector-run.ts +0 -261
  138. package/src/public-cli/judge-run.ts +0 -196
  139. package/src/public-cli/merger-run.ts +0 -294
  140. package/src/public-cli/notary-run.ts +0 -279
  141. package/src/public-cli/reviewer-run.ts +0 -480
  142. package/src/public-cli/secretariat-run.ts +0 -265
@@ -1,10 +1,11 @@
1
1
  import { COLLECTOR_OUTPUT_TOOL } from "./package-contracts/collector-output.js";
2
+ import { COLLECTOR_WAIT_TOOL } from "./collector-ledger.js";
2
3
  import { GATEKEEPER_OUTPUT_TOOL_NAME } from "./package-contracts/gatekeeper-output.js";
3
4
  import { NAVIGATOR_OUTPUT_TOOL_NAME } from "./package-contracts/navigator-output.js";
4
5
  import { JUDGE_OUTPUT_TOOL_NAME } from "./package-contracts/judge-output.js";
5
6
  import { REVIEWER_OUTPUT_TOOL_NAME } from "./package-contracts/reviewer-output.js";
6
7
  import { CODER_OUTPUT_TOOL_NAME, FIXER_OUTPUT_TOOL_NAME } from "./package-contracts/worker-output.js";
7
- import { DOCTOR_OUTPUT_TOOL_NAME } from "./doctor-contracts.js";
8
+ import { DOCTOR_AUDIT_TOOL_NAME, DOCTOR_OUTPUT_TOOL_NAME } from "./doctor-contracts.js";
8
9
  import { MERGER_OUTPUT_TOOL_NAME } from "./merger-contracts.js";
9
10
  import { NOTARY_OUTPUT_TOOL_NAME } from "./notary-contracts.js";
10
11
  import { COUNTERSIGN_OUTPUT_TOOL_NAME } from "./countersign-contracts.js";
@@ -13,6 +14,7 @@ import { INSPECTOR_OUTPUT_TOOL_NAME } from "./inspector-contracts.js";
13
14
  import { AUDITOR_OUTPUT_TOOL_NAME } from "./package-contracts/auditor-output.js";
14
15
  import { DIARIST_OUTPUT_TOOL_NAME } from "./diarist-contracts.js";
15
16
  import { SECRETARIAT_OUTPUT_TOOL_NAME } from "./secretariat-contracts.js";
17
+ import { JUDGE_AUDIT_TOOL_NAME } from "./judge-auditor.js";
16
18
  const NOTARY_SESSION_MATERIALS = [
17
19
  "CLAUDE.md",
18
20
  "souls/notary.md",
@@ -37,11 +39,25 @@ const AUDITOR_PUBLIC_SESSION_MATERIALS = [
37
39
  const PUBLIC_ROLE_RECORDS = [
38
40
  {
39
41
  role: "judge",
42
+ inCallAutoResume: true,
43
+ presentSettled: "default",
44
+ summonResume: false,
45
+ admission: "instruction",
46
+ /** Public argv rejects a burden selector. */
47
+ bareToken: "burden",
48
+ sameParent: "none",
40
49
  phases: [null],
41
50
  outputTool: JUDGE_OUTPUT_TOOL_NAME,
42
- inputFlag: void 0,
43
- phaseFlag: void 0,
51
+ auditTool: JUDGE_AUDIT_TOOL_NAME,
52
+ settlement: "sealed",
53
+ runnerFailure: "engine-detour-known-first",
54
+ acceptedText: "\u5927\u7406\u5BFA\u56DE\u6267\u5DF2\u63A5\u53D7",
55
+ /** Factory board: court until another station has started, then marshal. */
56
+ boardPlacement: "judge-history",
57
+ /** Navigator subject is the public admitted instruction when the run is bound. */
58
+ navigatorSubject: "public-instruction",
44
59
  activationStage: "load-and-install",
60
+ receiptStatusKey: "judgeStatus",
45
61
  sessionMaterials: [
46
62
  "CLAUDE.md",
47
63
  "souls/judge.md",
@@ -52,10 +68,35 @@ const PUBLIC_ROLE_RECORDS = [
52
68
  },
53
69
  {
54
70
  role: "fixer",
71
+ inCallAutoResume: true,
72
+ presentSettled: "default",
73
+ summonResume: false,
74
+ admission: "worker-packet",
75
+ sameParent: "none",
76
+ worker: true,
77
+ methodSkills: ["diagnosing-bugs", "tdd"],
78
+ settleMethod: "diagnosing-bugs",
55
79
  phases: ["plan", "apply"],
56
80
  outputTool: FIXER_OUTPUT_TOOL_NAME,
57
- inputFlag: "ak-fix-packet",
58
- phaseFlag: "ak-fixer-phase",
81
+ settlement: "sealed",
82
+ artifactFace: {
83
+ reportPhase: true,
84
+ evidenceRole: true,
85
+ leaves: [
86
+ { key: "phase" },
87
+ { key: "packetPath" },
88
+ { key: "prerequisitesPath", omitUndefined: true },
89
+ { key: "prerequisites" }
90
+ ],
91
+ method: "observed"
92
+ },
93
+ acceptedText: "\u4FEE\u5185\u53F8\u56DE\u6267\u5DF2\u63A5\u53D7",
94
+ boardPlacement: "marshal",
95
+ activationFlags: [
96
+ { field: "packetPath", flag: "ak-fix-packet", binds: "input" },
97
+ { field: "phase", flag: "ak-fixer-phase", binds: "phase" },
98
+ { field: "prerequisitesPath", flag: "ak-fixer-prerequisites" }
99
+ ],
59
100
  activationStage: "load-and-install",
60
101
  sessionMaterials: [
61
102
  "CLAUDE.md",
@@ -66,10 +107,33 @@ const PUBLIC_ROLE_RECORDS = [
66
107
  },
67
108
  {
68
109
  role: "coder",
110
+ inCallAutoResume: true,
111
+ presentSettled: "default",
112
+ summonResume: false,
113
+ admission: "worker-task",
114
+ sameParent: "none",
115
+ worker: true,
116
+ applyMethod: "tdd",
117
+ /** Method-material load failure keeps the activation cause (not reviewer/fixer). */
118
+ methodLoadFailureCause: "activation",
119
+ boardPlacement: "coder",
69
120
  phases: ["plan", "apply"],
70
121
  outputTool: CODER_OUTPUT_TOOL_NAME,
71
- inputFlag: "ak-coder-task",
72
- phaseFlag: "ak-coder-phase",
122
+ settlement: "sealed",
123
+ artifactFace: {
124
+ reportPhase: true,
125
+ evidenceRole: true,
126
+ leaves: [
127
+ { key: "phase" },
128
+ { key: "taskPath" }
129
+ ],
130
+ method: "optional"
131
+ },
132
+ acceptedText: "\u5C06\u4F5C\u76D1\u56DE\u6267\u5DF2\u63A5\u53D7",
133
+ activationFlags: [
134
+ { field: "taskPath", flag: "ak-coder-task", binds: "input" },
135
+ { field: "phase", flag: "ak-coder-phase", binds: "phase" }
136
+ ],
73
137
  activationStage: "load-and-install",
74
138
  sessionMaterials: [
75
139
  "CLAUDE.md",
@@ -80,11 +144,47 @@ const PUBLIC_ROLE_RECORDS = [
80
144
  },
81
145
  {
82
146
  role: "reviewer",
147
+ inCallAutoResume: true,
148
+ presentSettled: "default",
149
+ summonResume: false,
150
+ admission: "review-basis",
151
+ /** --base is a single Skill-arg token, and authority refs are always emitted. */
152
+ baseValue: "revision",
153
+ emitAuthorityRefs: true,
154
+ sameParent: "none",
155
+ methodSkills: ["ak-cross-m-review"],
156
+ settleMethod: "ak-cross-m-review",
157
+ /** Omitted public lens starts two ordinary single-axis runs (ADR 0052). */
158
+ parallelLenses: true,
159
+ /** Every turn runs in a fresh worktree; durable projectRoot stays the caller project (#946). */
160
+ freshExecutionCopy: true,
83
161
  phases: [null],
84
162
  bareCommand: false,
85
163
  outputTool: REVIEWER_OUTPUT_TOOL_NAME,
86
- inputFlag: void 0,
87
- phaseFlag: void 0,
164
+ settlement: "sealed",
165
+ /** Publish only an accepted ledger outcome; audit escalation stays unsettled here. */
166
+ sealedAcceptedOnly: true,
167
+ artifactFace: {
168
+ evidenceRole: true,
169
+ leaves: [
170
+ { key: "baseRevision" },
171
+ { key: "lens" },
172
+ { key: "authorityRefs", copyArray: true },
173
+ { key: "callerProvenance", callerProvenance: true }
174
+ ],
175
+ method: "observed"
176
+ },
177
+ /** Frozen base/lens/authority become the initial prompt; instruction follows. */
178
+ transportPrompt: "skill-args",
179
+ runnerFailure: "engine-detour-record-first",
180
+ acceptedText: "\u5FA1\u53F2\u53F0\u56DE\u6267\u5DF2\u63A5\u53D7",
181
+ boardPlacement: "marshal",
182
+ activationFlags: [
183
+ { field: "baseRevision", flag: "ak-review-base" },
184
+ { field: "lens", flag: "ak-review-lens" },
185
+ { field: "authorityRefs", flag: "ak-review-authority-refs" },
186
+ { field: "ticketNumber", flag: "ak-review-ticket-number" }
187
+ ],
88
188
  activationStage: "load-and-install",
89
189
  sessionMaterials: [
90
190
  "CLAUDE.md",
@@ -96,60 +196,189 @@ const PUBLIC_ROLE_RECORDS = [
96
196
  // ak-collector-repo is GitHub owner/repo identity, not a local material path (#438).
97
197
  {
98
198
  role: "collector",
199
+ inCallAutoResume: false,
200
+ presentSettled: "always",
201
+ summonResume: false,
202
+ admission: "collect-target",
203
+ /** Public no_receipt projects a durable bind-target rejection. */
204
+ projectTargetBindRejection: true,
205
+ sameParent: "none",
99
206
  phases: [null],
100
207
  bareCommand: false,
101
208
  outputTool: COLLECTOR_OUTPUT_TOOL,
102
- inputFlag: void 0,
103
- phaseFlag: void 0,
209
+ settlement: "residual",
210
+ /** #633: a prior wait-tool residual must not mask this attempt. */
211
+ residualScan: "current-attempt",
212
+ residualTool: COLLECTOR_WAIT_TOOL,
213
+ runnerFailure: "collector-known-first",
214
+ artifactFace: {
215
+ evidenceRole: true,
216
+ leaves: [
217
+ { key: "prNumber", omitUndefined: true },
218
+ { key: "repository", from: "repository.canonical" },
219
+ { key: "manifestDigest" }
220
+ ]
221
+ },
222
+ acceptedText: "\u901A\u8FDB\u53F8\u56DE\u6267\u5DF2\u63A5\u53D7",
223
+ boardPlacement: "collector",
224
+ /** Taishi acceptance is a typed groups array, not a status leaf. */
225
+ analystTerminal: "groups",
226
+ activationFlags: [
227
+ { field: "repo", from: "repository.display", flag: "ak-collector-repo" },
228
+ { field: "pr", from: "prNumber", text: true, flag: "ak-collector-pr" },
229
+ { field: "requestManifestPath", flag: "ak-collector-request-manifest" },
230
+ { field: "waitMs", from: "waitWindowMs", text: true, flag: "ak-collector-wait-ms" }
231
+ ],
104
232
  activationStage: "load-and-install",
105
233
  sessionMaterials: ["CLAUDE.md", "souls/collector.md"]
106
234
  },
107
235
  {
108
236
  role: "doctor",
237
+ inCallAutoResume: false,
238
+ presentSettled: "typed",
239
+ summonResume: false,
240
+ admission: "case-identity",
241
+ sameParent: "none",
109
242
  phases: [null],
110
243
  bareCommand: false,
111
244
  outputTool: DOCTOR_OUTPUT_TOOL_NAME,
112
- inputFlag: "ak-doctor-case",
113
- phaseFlag: void 0,
245
+ auditTool: DOCTOR_AUDIT_TOOL_NAME,
246
+ settlement: "sealed",
247
+ artifactFace: {
248
+ evidenceRole: true,
249
+ leaves: [
250
+ { key: "issueNumber" },
251
+ { key: "caseRunsPath" },
252
+ { key: "caseIdentity" }
253
+ ],
254
+ doctorReportFacts: true
255
+ },
256
+ acceptedText: "\u592A\u533B\u7F72\u56DE\u6267\u5DF2\u63A5\u53D7",
257
+ /** Navigator subject is the doctor case, not the case-path file bytes. */
258
+ navigatorSubject: "case",
259
+ activationFlags: [
260
+ { field: "casePath", from: "caseRunsPath", flag: "ak-doctor-case", binds: "input" }
261
+ ],
114
262
  activationStage: "load-and-install",
115
263
  sessionMaterials: ["CLAUDE.md", "souls/doctor.md"]
116
264
  },
117
265
  {
118
266
  role: "merger",
267
+ inCallAutoResume: true,
268
+ presentSettled: "typed",
269
+ summonResume: false,
270
+ admission: "merge-envelope",
271
+ /** Public argv rejects packet fields the adapter reads from Git. */
272
+ bareToken: "packet",
273
+ sameParent: "none",
274
+ methodSkills: ["resolving-merge-conflicts"],
275
+ settleMethod: "resolving-merge-conflicts",
276
+ /** Method-material load failure keeps the activation cause (not reviewer/fixer). */
277
+ methodLoadFailureCause: "activation",
119
278
  phases: [null],
120
279
  outputTool: MERGER_OUTPUT_TOOL_NAME,
121
- inputFlag: "ak-merger-input",
122
- phaseFlag: void 0,
280
+ settlement: "residual",
281
+ /** #836: residual scan stays on the whole host session. */
282
+ residualScan: "session",
283
+ residualTool: MERGER_OUTPUT_TOOL_NAME,
284
+ artifactFace: {
285
+ evidenceRole: true,
286
+ leaves: [
287
+ { key: "mergerInputPath" },
288
+ { key: "derived" }
289
+ ],
290
+ method: "observed"
291
+ },
292
+ acceptedText: "\u5408\u5E76\u56DE\u6267\u5DF2\u63A5\u53D7",
293
+ activationFlags: [
294
+ { field: "inputPath", from: "mergerInputPath", flag: "ak-merger-input", binds: "input" }
295
+ ],
123
296
  activationStage: "prepare-git-and-install",
297
+ receiptCommitKey: "mergeCommitId",
298
+ receiptCommitWhen: "completed",
124
299
  sessionMaterials: ["CLAUDE.md", "souls/merger.md"]
125
300
  },
126
301
  {
127
302
  role: "notary",
303
+ inCallAutoResume: false,
304
+ presentSettled: "always",
305
+ summonResume: false,
306
+ admission: "source-locator",
307
+ /** Public argv is only the source-run locator; stored text is not trimmed. */
308
+ bareToken: "instruction",
309
+ sourceRunStored: "raw",
310
+ argvResult: "source-run",
311
+ sameParent: "source-locator",
312
+ /** Infrastructure failure at this stage has no accepted gate cycle to project. */
313
+ skipGateOnInfrastructureStage: true,
314
+ /** 符宝郎 is a review officer and inherits the gatekeeper model. */
315
+ reviewOfficer: true,
316
+ provinceConfig: true,
317
+ modelInheritsFrom: "gatekeeper",
128
318
  phases: [null],
129
319
  bareCommand: false,
130
320
  outputTool: NOTARY_OUTPUT_TOOL_NAME,
131
- inputFlag: "ak-notary-source-run",
132
- phaseFlag: void 0,
321
+ settlement: "accepted",
322
+ /** Court reask replaces the initial prompt. Otherwise the fixed kickoff. */
323
+ reaskPrompt: true,
324
+ transportPrompt: "fixed-kickoff",
325
+ acceptedText: "\u7B26\u5B9D\u90CE\u56DE\u6267\u5DF2\u63A5\u53D7",
326
+ gateStageLabel: "\u7B26\u5B9D\u90CE",
327
+ /** Gate summon binds --source-run and keeps dialogue off the argv. */
328
+ gateSummon: "source-run",
329
+ /** Navigator subject is the source-run locator, not the path file bytes. */
330
+ navigatorSubject: "source-run",
331
+ activationFlags: [
332
+ { field: "sourceRun", from: "sourceRunPath", flag: "ak-notary-source-run", binds: "input" },
333
+ { field: "ticketNumber", flag: "ak-notary-ticket-number" }
334
+ ],
133
335
  activationStage: "load-and-install",
134
336
  sessionMaterials: NOTARY_SESSION_MATERIALS
135
337
  },
136
338
  {
137
339
  role: "countersign",
340
+ inCallAutoResume: false,
341
+ presentSettled: "always",
342
+ summonResume: false,
343
+ admission: "court-materials",
344
+ /** Durable custom entry names this officer. */
345
+ durableOfficerEntry: true,
346
+ sameParent: "none",
138
347
  phases: [null],
139
348
  outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
140
- inputFlag: void 0,
141
- phaseFlag: void 0,
349
+ settlement: "accepted",
350
+ acceptedText: "\u7ED9\u4E8B\u4E2D\u56DE\u6267\u5DF2\u63A5\u53D7",
351
+ gateStageLabel: "\u7ED9\u4E8B\u4E2D",
352
+ /** Gate queue reads countersignStatus, not the shared three-state status. */
353
+ gateDecision: "countersign-status",
354
+ /** Gate summon carries the parent payload as the instruction and a parent run id. */
355
+ gateSummon: "parent-instruction",
356
+ activationFlags: [
357
+ { field: "ticketNumber" }
358
+ ],
142
359
  activationStage: "load-and-install",
360
+ receiptStatusKey: "countersignStatus",
143
361
  // #924: 公用《票面法》三席同装
144
362
  sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md"]
145
363
  },
146
364
  {
147
365
  role: "secretariat",
366
+ inCallAutoResume: false,
367
+ presentSettled: "always",
368
+ summonResume: false,
369
+ admission: "instruction",
370
+ sameParent: "court-diarist",
148
371
  phases: [null],
149
372
  outputTool: SECRETARIAT_OUTPUT_TOOL_NAME,
150
- inputFlag: void 0,
151
- phaseFlag: void 0,
373
+ settlement: "accepted",
374
+ /** Project the durable 给事中 officer entry onto the shared accepted-tool settlement. */
375
+ projectCountersignTerminal: true,
376
+ acceptedText: "\u4E2D\u4E66\u7701\u56DE\u6267\u5DF2\u63A5\u53D7",
377
+ activationFlags: [
378
+ { field: "ticketNumber" }
379
+ ],
152
380
  activationStage: "load-and-install",
381
+ receiptStatusKey: "secretariatStatus",
153
382
  // #924: owner-finalized Soul + 票面法 + 给事中/符宝郎行为指南
154
383
  sessionMaterials: [
155
384
  "CLAUDE.md",
@@ -161,11 +390,23 @@ const PUBLIC_ROLE_RECORDS = [
161
390
  },
162
391
  {
163
392
  role: "gleaner-left",
393
+ inCallAutoResume: false,
394
+ presentSettled: "always",
395
+ summonResume: false,
396
+ admission: "gleaner",
397
+ /** Public argv keeps the instruction and drops attachment paths. */
398
+ argvResult: "instruction",
399
+ sameParent: "none",
164
400
  phases: [null],
165
401
  bareCommand: false,
166
402
  outputTool: GLEANER_LEFT_OUTPUT_TOOL_NAME,
167
- inputFlag: void 0,
168
- phaseFlag: void 0,
403
+ settlement: "accepted",
404
+ /** Bound comparison base is the initial prompt; instruction follows. */
405
+ transportPrompt: "baseline",
406
+ acceptedText: "\u5DE6\u62FE\u9057\u56DE\u6267\u5DF2\u63A5\u53D7",
407
+ activationFlags: [
408
+ { field: "baseRevision", flag: "ak-gleaner-left-base" }
409
+ ],
169
410
  activationStage: "load-and-install",
170
411
  sessionMaterials: [
171
412
  "CLAUDE.md",
@@ -175,10 +416,35 @@ const PUBLIC_ROLE_RECORDS = [
175
416
  },
176
417
  {
177
418
  role: "inspector",
419
+ inCallAutoResume: false,
420
+ presentSettled: "always",
421
+ summonResume: false,
422
+ admission: "instruction",
423
+ sameParent: "gate-pointer",
424
+ /** Resume restores an optional source-run path onto the admitted face. */
425
+ resumeSourcePath: true,
426
+ /** Infrastructure failure at this stage has no accepted gate cycle to project. */
427
+ skipGateOnInfrastructureStage: true,
428
+ /** 台院 is a review officer and inherits the gatekeeper model. */
429
+ reviewOfficer: true,
430
+ provinceConfig: true,
431
+ modelInheritsFrom: "gatekeeper",
178
432
  phases: [null],
179
433
  outputTool: INSPECTOR_OUTPUT_TOOL_NAME,
180
- inputFlag: "ak-inspector-source-run",
181
- phaseFlag: void 0,
434
+ settlement: "accepted",
435
+ /** Court reask replaces the initial prompt. */
436
+ reaskPrompt: true,
437
+ acceptedText: "\u53F0\u9662\u56DE\u6267\u5DF2\u63A5\u53D7",
438
+ gateStageLabel: "\u53F0\u9662",
439
+ activationFlags: [
440
+ {
441
+ field: "sourceRun",
442
+ from: "sourceRunPath",
443
+ fallback: "gate-pointer",
444
+ flag: "ak-inspector-source-run",
445
+ binds: "input"
446
+ }
447
+ ],
182
448
  activationStage: "load-and-install",
183
449
  sessionMaterials: INSPECTOR_SESSION_MATERIALS
184
450
  },
@@ -187,30 +453,63 @@ const PUBLIC_ROLE_RECORDS = [
187
453
  // unchanged and orthogonal to callability.
188
454
  {
189
455
  role: "gatekeeper",
456
+ inCallAutoResume: false,
457
+ presentSettled: "always",
458
+ summonResume: true,
459
+ admission: "instruction",
460
+ /** Infrastructure failure at this stage has no accepted gate cycle to project. */
461
+ skipGateOnInfrastructureStage: true,
462
+ sameParent: "none",
463
+ /** Province model root. Officers name this seat via modelInheritsFrom. */
464
+ provinceConfig: true,
190
465
  phases: [null],
191
466
  outputTool: GATEKEEPER_OUTPUT_TOOL_NAME,
192
- inputFlag: void 0,
193
- phaseFlag: void 0,
467
+ settlement: "accepted",
468
+ runnerFailure: "engine-detour-record-first",
469
+ acceptedText: "\u95E8\u4E0B\u7701\u51B3\u8BAE\u5DF2\u53D7\u7406",
194
470
  activationStage: "load-and-install",
195
471
  // Province materials; officers reuse their own public records below.
196
472
  sessionMaterials: ["CLAUDE.md", "souls/gatekeeper.md", "souls/quality-law.md", "souls/gate-output-guide.md"]
197
473
  },
198
474
  {
199
475
  role: "navigator",
476
+ inCallAutoResume: false,
477
+ presentSettled: "always",
478
+ summonResume: true,
479
+ admission: "instruction",
480
+ sameParent: "none",
200
481
  phases: [null],
201
482
  outputTool: NAVIGATOR_OUTPUT_TOOL_NAME,
202
- inputFlag: void 0,
203
- phaseFlag: void 0,
483
+ settlement: "accepted",
484
+ runnerFailure: "engine-detour-record-first",
485
+ acceptedText: "\u6E38\u5955\u4F7F\u5EFA\u8BAE\u5DF2\u53D7\u7406",
204
486
  activationStage: "load-and-install",
205
487
  sessionMaterials: ["CLAUDE.md", "souls/navigator.md"]
206
488
  },
207
489
  // #675: 审刑院 is a role like any other — public ak-role entry. (#744: evidence-child deleted)
208
490
  {
209
491
  role: "auditor",
492
+ inCallAutoResume: false,
493
+ presentSettled: "always",
494
+ summonResume: true,
495
+ admission: "instruction",
496
+ sameParent: "subject-source",
497
+ /** --subject chooses which audited seat the soul comes from. */
498
+ subjectChoices: ["judge", "doctor"],
499
+ /** 审刑院 is a review officer. Model stays on its own seat row. */
500
+ reviewOfficer: true,
501
+ /** Subject input selects the soul. The public materials list is the ship roster. */
502
+ soulSource: "subject",
210
503
  phases: [null],
211
504
  outputTool: AUDITOR_OUTPUT_TOOL_NAME,
212
- inputFlag: void 0,
213
- phaseFlag: void 0,
505
+ settlement: "accepted",
506
+ /** Court reask replaces the initial prompt. */
507
+ reaskPrompt: true,
508
+ runnerFailure: "engine-detour-record-first",
509
+ acceptedText: "\u5BA1\u5211\u9662\u56DE\u6267\u5DF2\u63A5\u53D7",
510
+ gateStageLabel: "\u5BA1\u5211\u9662",
511
+ /** Gate summon binds --subject judge and --source-run. */
512
+ gateSummon: "subject-source",
214
513
  activationStage: "load-and-install",
215
514
  sessionMaterials: AUDITOR_PUBLIC_SESSION_MATERIALS
216
515
  },
@@ -218,10 +517,15 @@ const PUBLIC_ROLE_RECORDS = [
218
517
  // No input flag — LLM finds materials itself (caller-transparent).
219
518
  {
220
519
  role: "diarist",
520
+ inCallAutoResume: false,
521
+ presentSettled: "always",
522
+ summonResume: false,
523
+ admission: "instruction",
524
+ sameParent: "board-ticket",
221
525
  phases: [null],
222
526
  outputTool: DIARIST_OUTPUT_TOOL_NAME,
223
- inputFlag: void 0,
224
- phaseFlag: void 0,
527
+ settlement: "accepted",
528
+ acceptedText: "\u8D77\u5C45\u90CE\u56DE\u6267\u5DF2\u63A5\u53D7",
225
529
  activationStage: "load-and-install",
226
530
  sessionMaterials: [
227
531
  "CLAUDE.md",
@@ -234,23 +538,201 @@ const PACKAGED_ROLE_REGISTRY = PUBLIC_ROLE_RECORDS.map(({ sessionMaterials: _omi
234
538
  function packagedRoleMetadata(role) {
235
539
  return PACKAGED_ROLE_REGISTRY.find((entry) => entry.role === role);
236
540
  }
541
+ function isOfficerReviewSeat(role) {
542
+ const record = packagedRoleMetadata(role);
543
+ return record !== void 0 && "reviewOfficer" in record && record.reviewOfficer === true;
544
+ }
545
+ function packagedProvinceConfig(role) {
546
+ const record = packagedRoleMetadata(role);
547
+ return record !== void 0 && "provinceConfig" in record && record.provinceConfig === true;
548
+ }
549
+ function packagedModelParent(role) {
550
+ const record = packagedRoleMetadata(role);
551
+ if (record === void 0 || !("modelInheritsFrom" in record)) return void 0;
552
+ return record.modelInheritsFrom;
553
+ }
554
+ function packagedRoleAcceptedOutputTool(role) {
555
+ const record = packagedRoleMetadata(role);
556
+ if (record === void 0 || !("settlement" in record) || record.settlement !== "accepted") {
557
+ return void 0;
558
+ }
559
+ return record.outputTool;
560
+ }
561
+ function packagedRoleActivationFlags(role) {
562
+ const record = packagedRoleMetadata(role);
563
+ if (record === void 0 || !("activationFlags" in record)) return [];
564
+ return record.activationFlags;
565
+ }
237
566
  function packagedRoleInputFlag(role) {
238
- return packagedRoleMetadata(role)?.inputFlag;
567
+ return packagedRoleActivationFlags(role).find((spec) => spec.binds === "input")?.flag;
239
568
  }
240
569
  function packagedRolePhaseFlag(role) {
241
- return packagedRoleMetadata(role)?.phaseFlag;
570
+ return packagedRoleActivationFlags(role).find((spec) => spec.binds === "phase")?.flag;
242
571
  }
243
572
  function packagedRoleOutputTool(role) {
244
573
  return packagedRoleMetadata(role)?.outputTool;
245
574
  }
575
+ function packagedRoleAcceptedText(role) {
576
+ const record = packagedRoleMetadata(role);
577
+ if (record === void 0) {
578
+ throw new Error(`Unsupported workflow role: ${String(role)}`);
579
+ }
580
+ return record.acceptedText;
581
+ }
582
+ function packagedMethodLoadFailureCause(role) {
583
+ const record = packagedRoleMetadata(role);
584
+ if (record === void 0 || !("methodLoadFailureCause" in record)) return void 0;
585
+ return record.methodLoadFailureCause;
586
+ }
587
+ function packagedBindsBoardTicket(role) {
588
+ const record = packagedRoleMetadata(role);
589
+ return record?.sameParent === "board-ticket";
590
+ }
591
+ function packagedRebindSourceOnResume(role) {
592
+ return packagedRoleMetadata(role)?.admission === "source-locator";
593
+ }
594
+ function packagedAdmitsCountersign(role) {
595
+ return packagedRoleMetadata(role)?.admission === "court-materials";
596
+ }
597
+ function packagedBareToken(role) {
598
+ const record = packagedRoleMetadata(role);
599
+ if (record === void 0 || !("bareToken" in record)) return void 0;
600
+ return record.bareToken;
601
+ }
602
+ function packagedArgvResult(role) {
603
+ const record = packagedRoleMetadata(role);
604
+ if (record !== void 0 && "argvResult" in record) return record.argvResult;
605
+ return "material";
606
+ }
607
+ function packagedStoresSourceRunRaw(role) {
608
+ const record = packagedRoleMetadata(role);
609
+ return record !== void 0 && "sourceRunStored" in record && record.sourceRunStored === "raw";
610
+ }
611
+ function packagedBaseIsRevision(role) {
612
+ const record = packagedRoleMetadata(role);
613
+ return record !== void 0 && "baseValue" in record && record.baseValue === "revision";
614
+ }
615
+ function packagedEmitsAuthorityRefs(role) {
616
+ const record = packagedRoleMetadata(role);
617
+ return record !== void 0 && "emitAuthorityRefs" in record && record.emitAuthorityRefs === true;
618
+ }
619
+ function packagedSubjectChoices(role) {
620
+ const record = packagedRoleMetadata(role);
621
+ if (record === void 0 || !("subjectChoices" in record)) return void 0;
622
+ return record.subjectChoices;
623
+ }
624
+ function packagedAdmittedSubject(role, value) {
625
+ const choices = packagedSubjectChoices(role);
626
+ if (choices === void 0 || !choices.includes(value)) return void 0;
627
+ const match = choices.find((choice) => choice === value);
628
+ if (match === "judge" || match === "doctor") return match;
629
+ return void 0;
630
+ }
631
+ function packagedAuditToolName(role) {
632
+ const record = packagedRoleMetadata(role);
633
+ if (record === void 0 || !("auditTool" in record)) return void 0;
634
+ return record.auditTool;
635
+ }
636
+ function packagedSkipsGateOnInfrastructureStage(stage) {
637
+ return typeof stage === "string" && PUBLIC_ROLE_RECORDS.some(
638
+ (record) => "skipGateOnInfrastructureStage" in record && record.skipGateOnInfrastructureStage === true && record.role === stage
639
+ );
640
+ }
641
+ function packagedDurableOfficerEntry(officer) {
642
+ return typeof officer === "string" && PUBLIC_ROLE_RECORDS.some(
643
+ (record) => "durableOfficerEntry" in record && record.durableOfficerEntry === true && record.role === officer
644
+ );
645
+ }
646
+ function packagedPublicInstructionSubject(role) {
647
+ return typeof role === "string" && PUBLIC_ROLE_RECORDS.some(
648
+ (record) => "navigatorSubject" in record && record.navigatorSubject === "public-instruction" && record.role === role
649
+ );
650
+ }
651
+ function packagedResumeSourcePath(role) {
652
+ const record = packagedRoleMetadata(role);
653
+ return record !== void 0 && "resumeSourcePath" in record && record.resumeSourcePath === true;
654
+ }
655
+ function packagedProjectsTargetBindRejection(role) {
656
+ const record = packagedRoleMetadata(role);
657
+ return record !== void 0 && "projectTargetBindRejection" in record && record.projectTargetBindRejection === true;
658
+ }
659
+ function packagedNavigatorSubject(role) {
660
+ const record = packagedRoleMetadata(role);
661
+ if (record !== void 0 && "navigatorSubject" in record) return record.navigatorSubject;
662
+ return "file";
663
+ }
664
+ function packagedBoardPlacement(role) {
665
+ const record = packagedRoleMetadata(role);
666
+ if (record === void 0 || !("boardPlacement" in record)) return void 0;
667
+ return record.boardPlacement;
668
+ }
669
+ function packagedAnalystTerminal(role) {
670
+ const record = packagedRoleMetadata(role);
671
+ if (record === void 0 || !("analystTerminal" in record)) return void 0;
672
+ return record.analystTerminal;
673
+ }
674
+ function packagedRoleSessionMaterials(role) {
675
+ return PUBLIC_ROLE_RECORDS.find((entry) => entry.role === role)?.sessionMaterials;
676
+ }
677
+ function isNavigatorSeat(role) {
678
+ return packagedRoleOutputTool(role) === NAVIGATOR_OUTPUT_TOOL_NAME;
679
+ }
680
+ function packagedGateStageLabel(role) {
681
+ const record = packagedRoleMetadata(role);
682
+ if (record === void 0 || !("gateStageLabel" in record)) return void 0;
683
+ return record.gateStageLabel;
684
+ }
685
+ function packagedGateSummon(role) {
686
+ const record = packagedRoleMetadata(role);
687
+ if (record !== void 0 && "gateSummon" in record) return record.gateSummon;
688
+ return "pointer";
689
+ }
690
+ function packagedGateDecision(role) {
691
+ const record = packagedRoleMetadata(role);
692
+ if (record !== void 0 && "gateDecision" in record && record.gateDecision === "countersign-status") {
693
+ return "countersign-status";
694
+ }
695
+ return "three-state";
696
+ }
246
697
  export {
247
698
  AUDITOR_PUBLIC_SESSION_MATERIALS,
248
699
  INSPECTOR_SESSION_MATERIALS,
249
700
  NOTARY_SESSION_MATERIALS,
250
701
  PACKAGED_ROLE_REGISTRY,
251
702
  PUBLIC_ROLE_RECORDS,
703
+ isNavigatorSeat,
704
+ isOfficerReviewSeat,
705
+ packagedAdmitsCountersign,
706
+ packagedAdmittedSubject,
707
+ packagedAnalystTerminal,
708
+ packagedArgvResult,
709
+ packagedAuditToolName,
710
+ packagedBareToken,
711
+ packagedBaseIsRevision,
712
+ packagedBindsBoardTicket,
713
+ packagedBoardPlacement,
714
+ packagedDurableOfficerEntry,
715
+ packagedEmitsAuthorityRefs,
716
+ packagedGateDecision,
717
+ packagedGateStageLabel,
718
+ packagedGateSummon,
719
+ packagedMethodLoadFailureCause,
720
+ packagedModelParent,
721
+ packagedNavigatorSubject,
722
+ packagedProjectsTargetBindRejection,
723
+ packagedProvinceConfig,
724
+ packagedPublicInstructionSubject,
725
+ packagedRebindSourceOnResume,
726
+ packagedResumeSourcePath,
727
+ packagedRoleAcceptedOutputTool,
728
+ packagedRoleAcceptedText,
729
+ packagedRoleActivationFlags,
252
730
  packagedRoleInputFlag,
253
731
  packagedRoleMetadata,
254
732
  packagedRoleOutputTool,
255
- packagedRolePhaseFlag
733
+ packagedRolePhaseFlag,
734
+ packagedRoleSessionMaterials,
735
+ packagedSkipsGateOnInfrastructureStage,
736
+ packagedStoresSourceRunRaw,
737
+ packagedSubjectChoices
256
738
  };