@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,265 +0,0 @@
1
- /**
2
- * Public Secretariat (中书省) Role run: admit → 起居郎 typed identity → bind/relocate
3
- * → shared post-admission (dossier delivery) → settle (#924).
4
- * Instruction-seat face like Judge; nested countersign is role-tool driven.
5
- * Ticket identity reuses the court diarist seam (no prose regex; no second lifecycle).
6
- */
7
- import type { DurablePrincipalAuthority, RoleTurnRequest } from "../host-contracts.ts";
8
- import { engineSessionMaterialFromOptions, pickEngineAxis } from "../package-resources/engine-material.ts";
9
- import { CliUsageError } from "./cli-errors.ts";
10
- import {
11
- admitSecretariatInvocation,
12
- bindAdmittedTicketNumber,
13
- buildSecretariatTransportPrompt,
14
- relocateAdmittedRunToTicket,
15
- type AdmittedSecretariatInvocation,
16
- type ParseSecretariatArgvResult,
17
- } from "./invocation.ts";
18
- import {
19
- invokeCourtDiarist,
20
- type CourtDiaristSummonEnv,
21
- } from "./countersign-run.ts";
22
- import {
23
- presentControlledFailure,
24
- runPostAdmissionOneShot,
25
- type PostAdmissionEnv,
26
- runPostAdmissionSeatResume,
27
- resumeTurnRequestProjectionOptions,
28
- } from "./post-admission.ts";
29
- import {
30
- loadResumableSecretariatRun,
31
- markRunAdmitted,
32
- type PublicResumeRequest,
33
- } from "./run-lifecycle.ts";
34
- import {
35
- presentStructuralRejection,
36
- trySettleSecretariatTerminalResult,
37
- } from "./settlement.ts";
38
- import type { CliIo } from "./cli-io.ts";
39
- import type { TerminalResult } from "./terminal.ts";
40
- import {
41
- projectRoleTurnRequest,
42
- type RoleTurnRequestProjectionOptions,
43
- } from "./turn-request.ts";
44
-
45
- export type SecretariatRunEnv = PostAdmissionEnv & {
46
- principalAuthority: DurablePrincipalAuthority;
47
- createRunId?: () => string;
48
- };
49
-
50
- /** Project admitted invocation onto the host-neutral turn request. */
51
- export function buildSecretariatTurnRequest(
52
- admitted: AdmittedSecretariatInvocation,
53
- options: RoleTurnRequestProjectionOptions,
54
- ): RoleTurnRequest {
55
- return projectRoleTurnRequest(
56
- admitted,
57
- {
58
- activation: {
59
- role: "secretariat" as const,
60
- ...(admitted.ticketNumber === undefined
61
- ? {}
62
- : { ticketNumber: admitted.ticketNumber }),
63
- },
64
- },
65
- options,
66
- );
67
- }
68
-
69
- function diaristEnv(env: SecretariatRunEnv): CourtDiaristSummonEnv {
70
- return {
71
- cwd: env.cwd,
72
- home: env.home,
73
- agentDir: env.agentDir,
74
- packageRoot: env.packageRoot,
75
- ...(env.credentials === undefined ? {} : { credentials: env.credentials }),
76
- ...(env.signal === undefined ? {} : { signal: env.signal }),
77
- ...(env.hostAdapters === undefined ? {} : { hostAdapters: env.hostAdapters }),
78
- };
79
- }
80
-
81
- export async function runPublicSecretariat(
82
- argv: readonly string[],
83
- env: SecretariatRunEnv,
84
- io: CliIo,
85
- parseSecretariatArgv: (args: readonly string[]) => ParseSecretariatArgvResult,
86
- ): Promise<{
87
- exitCode: number;
88
- admitted?: AdmittedSecretariatInvocation;
89
- terminal?: TerminalResult;
90
- }> {
91
- let parsed: ParseSecretariatArgvResult;
92
- try {
93
- parsed = parseSecretariatArgv(argv);
94
- } catch (error) {
95
- if (error instanceof CliUsageError) {
96
- presentStructuralRejection(error, io);
97
- return { exitCode: 2 };
98
- }
99
- throw error;
100
- }
101
-
102
- let admitted: AdmittedSecretariatInvocation;
103
- try {
104
- admitted = await admitSecretariatInvocation({
105
- home: env.home,
106
- principalAuthority: env.principalAuthority,
107
- cwd: env.cwd,
108
- instruction: parsed.instruction,
109
- attachmentPaths: parsed.attachmentPaths,
110
- ...(parsed.project === undefined ? {} : { project: parsed.project }),
111
- ...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
112
- ...(env.model === undefined ? {} : { model: env.model }),
113
- ...(env.correlationId === undefined ? {} : { correlationId: env.correlationId }),
114
- });
115
- } catch (error) {
116
- if (error instanceof CliUsageError) {
117
- presentStructuralRejection(error, io);
118
- return { exitCode: 2 };
119
- }
120
- throw error;
121
- }
122
-
123
- await markRunAdmitted(admitted, env.principalAuthority);
124
-
125
- // #924 G3 / ADR 0075 / 0081: ticket identity is 起居郎 typed assertion — never
126
- // prose regex. escalate / real station failure → controlled failure; lawful
127
- // true-unbound continues unbound (ADR 0075 真无票→无录; 第 0 条不拒收);
128
- // ticket → bind + relocate so post-admission can deliver 起居录.
129
- const outcome = await invokeCourtDiarist(
130
- {
131
- instruction: parsed.instruction,
132
- projectRoot: admitted.projectRoot,
133
- failureLabel: "secretariat unbound summons",
134
- attachmentPaths: admitted.attachments.map((attachment) => attachment.frozenPath),
135
- correlationId: admitted.runId,
136
- },
137
- diaristEnv(env),
138
- io,
139
- );
140
-
141
- if (outcome.identity.kind === "escalate") {
142
- // Diagnostic relays diarist escalate payload facts (#953) — never invent 认不出.
143
- return await presentControlledFailure(
144
- admitted,
145
- {
146
- timedOut: false,
147
- code: null,
148
- stderr: "",
149
- thrown: new Error(outcome.identity.diagnostic),
150
- },
151
- secretariatAdapters(),
152
- env.principalAuthority,
153
- io,
154
- );
155
- }
156
-
157
- if (outcome.failedWithoutEscalate !== undefined) {
158
- return await presentControlledFailure(
159
- admitted,
160
- {
161
- timedOut: false,
162
- code: null,
163
- stderr: "",
164
- thrown: new Error(outcome.failedWithoutEscalate.diagnostic),
165
- },
166
- secretariatAdapters(),
167
- env.principalAuthority,
168
- io,
169
- );
170
- }
171
-
172
- if (outcome.identity.kind === "ticket") {
173
- try {
174
- await bindAdmittedTicketNumber(admitted, outcome.identity.ticketNumber);
175
- await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
176
- } catch (error) {
177
- return await presentControlledFailure(
178
- admitted,
179
- {
180
- timedOut: false,
181
- code: null,
182
- stderr: "",
183
- thrown: error,
184
- },
185
- secretariatAdapters(),
186
- env.principalAuthority,
187
- io,
188
- );
189
- }
190
- }
191
-
192
- const turnRequest = buildSecretariatTurnRequest(admitted, {
193
- packageRoot: env.packageRoot,
194
- home: env.home,
195
- agentDir: env.agentDir,
196
- ...(env.model === undefined ? {} : { model: env.model }),
197
- ...pickEngineAxis(env),
198
- ...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
199
- ...(env.correlationId === undefined || env.correlationId.trim() === ""
200
- ? {}
201
- : { correlationId: env.correlationId }),
202
- continuation: {
203
- kind: "initial",
204
- prompt: buildSecretariatTransportPrompt(
205
- admitted,
206
- engineSessionMaterialFromOptions({
207
- ...pickEngineAxis(env),
208
- packageRoot: env.packageRoot,
209
- }),
210
- ),
211
- },
212
- });
213
-
214
- return await runPostAdmissionOneShot({
215
- admitted,
216
- env,
217
- io,
218
- request: turnRequest,
219
- adapters: secretariatAdapters(),
220
- ...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
221
- });
222
- }
223
-
224
- function secretariatAdapters() {
225
- return {
226
- trySettle: (
227
- admitted: AdmittedSecretariatInvocation,
228
- authority: DurablePrincipalAuthority,
229
- scope?: { readonly courtAttemptId?: string },
230
- ) => trySettleSecretariatTerminalResult(admitted, authority, scope),
231
- shouldPresentSettled: () => true,
232
- };
233
- }
234
-
235
- /**
236
- * Resume a previously admitted Secretariat run (#599).
237
- */
238
- export async function runPublicSecretariatResume(
239
- request: PublicResumeRequest,
240
- env: SecretariatRunEnv,
241
- io: CliIo,
242
- ): Promise<{
243
- exitCode: number;
244
- admitted?: AdmittedSecretariatInvocation;
245
- terminal?: TerminalResult;
246
- }> {
247
- return await runPostAdmissionSeatResume({
248
- request,
249
- env,
250
- io,
251
- load: (effective) =>
252
- loadResumableSecretariatRun(
253
- env.home,
254
- effective.runId,
255
- env.principalAuthority,
256
- ),
257
- buildTurnRequest: (admitted, effective) =>
258
- buildSecretariatTurnRequest(
259
- admitted,
260
- resumeTurnRequestProjectionOptions(admitted, effective, env),
261
- ),
262
- adapters: secretariatAdapters(),
263
- ...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
264
- });
265
- }