@akagilnc/pi-workflow-roles 0.1.6086 → 0.1.6100

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.
@@ -39,14 +39,25 @@ export type DiaristOutput =
39
39
  readonly ticketSessions?: readonly {
40
40
  readonly ticketNumber: number;
41
41
  readonly sessions: readonly TicketProvenanceSession[];
42
+ readonly sinceLast?: DiaristSinceLast;
42
43
  }[];
44
+ /** 2026-10-30: the sweep since the last recorded line (generation-required; the package records as-is, so typed as optional). */
45
+ readonly sinceLast?: DiaristSinceLast;
43
46
  }
44
47
  | {
45
48
  /** LLM cannot sign this round normally (Soul) — escalate, never wash into 无录. */
46
49
  readonly status: "escalate";
47
50
  readonly reason: string;
51
+ /** On the escalate path the honest shape is 无法扫 (or whatever was actually swept before the failure). */
52
+ readonly sinceLast?: DiaristSinceLast;
48
53
  };
49
54
 
55
+ export type DiaristSinceLast =
56
+ | { readonly lastRecorded: string; readonly swept: readonly string[]; readonly found: "上次成录末尾到本轮之间陛下谈过本票,已划进 ranges" }
57
+ | { readonly lastRecorded: string; readonly swept: null; readonly found: "上次成录末尾到本轮之间陛下没有再谈本票" }
58
+ | { readonly lastRecorded: null; readonly swept: null; readonly found: "本卷尚无成录(本票没有起居录,或起居录里没有本卷),本轮从本卷开头收" }
59
+ | { readonly lastRecorded: null; readonly swept: null; readonly found: "无法扫:起居录或源卷读不出,本轮 status 只能是 escalate,reason 写明读不出什么" };
60
+
50
61
  export function validateRecordedDiaristOutput(value: unknown): DiaristOutput {
51
62
  if (!isRecord(value)) {
52
63
  throw new Error("Diarist output has no execution discriminator");
@@ -104,7 +115,59 @@ export const DIARIST_BOUND_ENDPOINTS =
104
115
  "起点与终点各写 id 或 line,二选一:id=会话卷里那一行 JSON 的 uuid 字段值(没有 uuid 取 id;顶层都没有再取 message 或 payload 里的 uuid / id),同一 id 出现多次时取第一次出现的那一行;line=那一行在文件里从 1 数起的行号。两端都含在区间内。" as const;
105
116
 
106
117
  const DIARIST_SESSIONS_DESCRIPTION =
107
- `对话边界。每卷含 path(会话卷绝对或可读路径)与 ranges(本卷本轮各区间)。每段区间含 from / to;${DIARIST_BOUND_ENDPOINTS}区间里只有说话人的原文进录:用户与助手消息里的文本、真人经队列的插话;思考、工具调用、工具结果和机器通知不进录,区间可以直接跨过它们,不必拆段。每次交卷的边界照投影追加进本票起居录,不去重,也不改已有的录。空列表=本轮无对话可划。端点无法指名时走 reask,不中止。` as const;
118
+ `对话边界。每卷含 path(会话卷绝对或可读路径)与 ranges(本卷本轮各区间)。每段区间含 from / to;${DIARIST_BOUND_ENDPOINTS}区间里只有说话人的原文进录:用户与助手消息里的文本、真人经队列的插话、陛下用斜杠命令带的参数(命令名是机器的,参数是陛下说的话);思考、工具调用、工具结果和机器通知不进录,区间可以直接跨过它们,不必拆段。每次交卷的边界照投影追加进本票起居录,不去重,也不改已有的录。空列表=本轮无对话可划。端点无法指名时走 reask,不中止。` as const;
119
+
120
+ /**
121
+ * 2026-10-30 (陛下: #1943 的起居录漏了整场 grill): the gap since the last recorded line is a required cell.
122
+ * Three shapes plus the escalate-only 无法扫: the owner spoke about this ticket in the gap (every such line listed and inside
123
+ * ranges), the owner did not, or this volume has no recorded line yet (new ticket or new volume). Generation-required under ADR 0057's exception;
124
+ * the package still records the receipt as-is.
125
+ */
126
+ const lastRecordedField = Type.String({
127
+ description: "本票已有起居录里、本卷上次成录的最后一行:照起居录端点写 uuid 或 line",
128
+ });
129
+ export const diaristSinceLastSchema = Type.Union(
130
+ [
131
+ Type.Object(
132
+ {
133
+ lastRecorded: lastRecordedField,
134
+ swept: Type.Array(Type.String(), {
135
+ description: "上次成录末尾到本轮之间,陛下谈本票的每一行,一行一条,照边界端点的写法(uuid,没有 uuid 的写 line);这些行都已划进 ranges",
136
+ }),
137
+ found: Type.Literal("上次成录末尾到本轮之间陛下谈过本票,已划进 ranges"),
138
+ },
139
+ { additionalProperties: true },
140
+ ),
141
+ Type.Object(
142
+ {
143
+ lastRecorded: lastRecordedField,
144
+ swept: Type.Null(),
145
+ found: Type.Literal("上次成录末尾到本轮之间陛下没有再谈本票"),
146
+ },
147
+ { additionalProperties: true },
148
+ ),
149
+ Type.Object(
150
+ {
151
+ lastRecorded: Type.Null(),
152
+ swept: Type.Null(),
153
+ found: Type.Literal("本卷尚无成录(本票没有起居录,或起居录里没有本卷),本轮从本卷开头收"),
154
+ },
155
+ { additionalProperties: true },
156
+ ),
157
+ Type.Object(
158
+ {
159
+ lastRecorded: Type.Null(),
160
+ swept: Type.Null(),
161
+ found: Type.Literal("无法扫:起居录或源卷读不出,本轮 status 只能是 escalate,reason 写明读不出什么"),
162
+ },
163
+ { additionalProperties: true },
164
+ ),
165
+ ],
166
+ {
167
+ description:
168
+ "上次成录以来的扫段:先打开本票已有的起居录,找出本卷上次成录的最后一行,从它的下一行起一直扫到本轮(那一行已在录里,不再划),陛下关于本票说过的每一句都划进 ranges——传召点名的 uuid 只是起点,不是候选集合。四种答法:谈过(逐行列 uuid 或 line)/没有再谈/本卷尚无成录/无法扫(只配 status escalate,不得用来免扫)。多票庭这里填主票,其余各票的扫段各写进 ticketSessions 那一票的 sinceLast。",
169
+ },
170
+ );
108
171
 
109
172
  export const diaristOutputSchema = withTerminatingOutputDeclarations(
110
173
  openToolObject(
@@ -125,8 +188,11 @@ export const diaristOutputSchema = withTerminatingOutputDeclarations(
125
188
  description: `仅单票庭时填对话边界;没有就填 null。${DIARIST_SESSIONS_DESCRIPTION}`,
126
189
  })),
127
190
  ticketSessions: Type.Unknown({
128
- description: `仅多票庭时填逐票对话边界;没有就填 null。每票含 ticketNumber(本条边界所归票号,正整数)与 sessions(${DIARIST_SESSIONS_DESCRIPTION})。一次交卷各票各自分录。`,
191
+ description: `仅多票庭时填逐票对话边界;没有就填 null。每票含 ticketNumber(本条边界所归票号,正整数)、sessions(${DIARIST_SESSIONS_DESCRIPTION})与该票自己的 sinceLast(形状同顶层 sinceLast)。一次交卷各票各自分录。`,
129
192
  }),
193
+ sinceLast: diaristSinceLastSchema,
130
194
  }),
131
195
  ),
132
196
  );
197
+ // #1134 emptied the required set; sinceLast is the one generation-required cell (ADR 0057 exception; the package still records as-is).
198
+ (diaristOutputSchema as unknown as { required: string[] }).required = ["sinceLast"];
@@ -239,6 +239,95 @@ const clauseRowBase = {
239
239
  const CLAUSE_LABELS = { without: "不要:示范不带这一层也处理得了", carries: "要:示范本身就为同一关切带同样的层", evidenceField: "makes" } as const;
240
240
  export const clauseExistenceRowSchema = existenceRowUnion(clauseRowBase, CLAUSE_LABELS);
241
241
 
242
+ /**
243
+ * 架构归位表 (architecture table) rows, shared by 中书省 and 给事中. Two duties, two row kinds:
244
+ * 遵循 — one row per thing the draft puts into code, placed into a layer of the established architecture
245
+ * (the layer table and rules in docs/adr or the ticket-named 法源); 核架构 — one row per clause of that
246
+ * architecture, checked against how the chosen framework's official docs and recognized references
247
+ * handle the same concern. The literal cells leave no third answer; the package records the rows as-is.
248
+ */
249
+ const ARCH_FIT_RULE = "既有架构=docs/adr 里的层表与规矩,或票面点名的法源里的层表与规矩;分层配置(import-linter 一类)与代码现状是要核对的对象,不是法源";
250
+ const archFitBase = {
251
+ kind: Type.Literal("遵循:稿里一样进代码的东西归到既有架构的层里"),
252
+ item: Type.String({ description: "稿里那样东西的原句(照抄):模块、类、表、调用路径、入口、分层配置里的一档" }),
253
+ layer: Type.String({ description: `它该属的那一层:法源(docs/adr 文件名或票面票号)+那层分工的原句(照抄);层表里没有能放它的层,写「法源无此层」。${ARCH_FIT_RULE}` }),
254
+ today: Type.String({ description: "打开代码:这层现在装着什么、这件事现在由谁承担(模块或路径);没有就写没有" }),
255
+ } as const;
256
+ const archVerifyBase = {
257
+ kind: Type.Literal("核架构:既有架构的一条条款对照外界做法"),
258
+ clause: Type.String({ description: "既有架构的一条条款原句(层表一行或一条规矩,照抄)+法源" }),
259
+ reference: Type.String({ description: "联网查到的参照:所选框架官方文档、公认架构资料里承担同一关切的做法——链接+原句;查不到写搜了什么、在哪搜" }),
260
+ } as const;
261
+ export const architectureRowSchema = Type.Union(
262
+ [
263
+ Type.Object(
264
+ {
265
+ ...archFitBase,
266
+ fit: Type.Union(
267
+ [Type.Literal("合:同层复用——现状已有的那样东西承担,不新建"), Type.Literal("合:同层新增——新建,但在这层法源写的分工之内")],
268
+ { description: "归到法源层表里的某一层、且在那层分工之内,才是合" },
269
+ ),
270
+ },
271
+ { additionalProperties: true },
272
+ ),
273
+ Type.Object(
274
+ {
275
+ ...archFitBase,
276
+ fit: Type.Union(
277
+ [
278
+ Type.Literal("不合:新开一层或一档——法源的层表里没有这一层;写在两层之间、「不是第 N 个 X」、给分层配置加一档,都算"),
279
+ Type.Literal("不合:跨层或反向依赖——法源只许往下依赖,这样东西反着依赖、或越过中间那层直接碰"),
280
+ Type.Literal("不合:进了这层分工之外的事——法源写这层只许/只做什么,这件事不在其中"),
281
+ ],
282
+ { description: "三种不合,没有第四种;不合的行不由宰相或签发方答,归陛下" },
283
+ ),
284
+ rule: Type.String({ description: "被违的那条分工或规矩的原句(照抄)" }),
285
+ },
286
+ { additionalProperties: true },
287
+ ),
288
+ Type.Object(
289
+ {
290
+ ...archVerifyBase,
291
+ verdict: Type.Union(
292
+ [
293
+ Type.Literal("合理:参照里同一关切的做法与本条一致,或本条是刻意偏离且法源写了为什么"),
294
+ Type.Literal("查不到参照:reference 写明搜了什么"),
295
+ ],
296
+ { description: "没有建议要呈、也没有陛下拍过的凭据时的两种答法" },
297
+ ),
298
+ },
299
+ { additionalProperties: true },
300
+ ),
301
+ Type.Object(
302
+ {
303
+ ...archVerifyBase,
304
+ verdict: Type.Literal("已拍:陛下对这一点拍过,decidedBy 给凭据,不再呈"),
305
+ decidedBy: Type.String({
306
+ description: "拍过的凭据:起居录里陛下那句原话的 uuid,或 ADR 编号+文内拍定原句(照抄);拿不出凭据的不是已拍,按合理/查不到/可改进答",
307
+ }),
308
+ },
309
+ { additionalProperties: true },
310
+ ),
311
+ Type.Object(
312
+ {
313
+ ...archVerifyBase,
314
+ verdict: Type.Literal("可改进:参照里有更简单或更一致的做法,suggestion 一句,呈陛下"),
315
+ suggestion: Type.String({ description: "一句建议:改哪条、改成什么、参照里的依据;陛下拍不拍由陛下定" }),
316
+ },
317
+ { additionalProperties: true },
318
+ ),
319
+ ],
320
+ { description: "五种行形:遵循·合/遵循·不合(带 rule)/核架构·合理或查不到/核架构·已拍(带 decidedBy)/核架构·可改进(带 suggestion)" },
321
+ );
322
+ const ARCH_TABLE_COMMON =
323
+ "架构归位表:先盘既有架构——docs/adr 与票面点名法源里的层表与规矩,再打开分层配置与代码看每层现在装着什么、有没有法源里没有的层。遵循行:稿里每样进代码的东西各一行,归到法源的层里;核架构行:既有架构每条条款各一行,联网找所选框架官方文档与公认资料里承担同一关切的做法,附链接与原句。法源里既没有层表也没有架构规矩时才为空数组,并在 note 写明;只有规矩没有层表的,遵循行的 layer 写被核的那条规矩原句,核架构行按规矩逐条列。";
324
+ export const secretariatArchitectureField = Type.Array(architectureRowSchema, {
325
+ description: `${ARCH_TABLE_COMMON}有「不合」或「可改进」行,secretariatStatus 只能是 escalate:不合行的原文与两边(改稿归位/改架构)、可改进的建议,都列进 decisionGate 由陛下拍,不出给宰相答。`,
326
+ });
327
+ export const countersignArchitectureField = Type.Array(architectureRowSchema, {
328
+ description: `${ARCH_TABLE_COMMON}有「不合」行不得署:票面意在改架构的上呈,否则封驳退签发方归位;有「可改进」行上呈,建议附原文。`,
329
+ });
330
+
242
331
  /** Countersign generation schema: shared review face plus the 存废尺 over the current ticket's clauses (package records as-is). */
243
332
  export const countersignSubmissionSchema = withTerminatingOutputDeclarations(
244
333
  Type.Object(
@@ -249,6 +338,7 @@ export const countersignSubmissionSchema = withTerminatingOutputDeclarations(
249
338
  description:
250
339
  "存废尺:现行票面每条让机制存在的条款各一行——明写机制的,和只写结果要求、现状代码满足不了的,两类都算——到 ADR/票面点名的应用框架官方示范里看不带它时同一关切怎么处理。有「不要」行在,不得署,封驳或上呈并点名那条。票面已写、前轮判词要求过、签发方答过、陛下对别的题点过头,都不是「要」的理由;「要」只认示范里带同样的层。一条没有为空数组。",
251
340
  }),
341
+ architecture: countersignArchitectureField,
252
342
  },
253
343
  { additionalProperties: true },
254
344
  ),
@@ -8,7 +8,7 @@
8
8
  import { Type, type Static } from "typebox";
9
9
 
10
10
  import { withTerminatingOutputDeclarations } from "./package-contracts/terminating-infrastructure.ts";
11
- import { clauseExistenceRowSchema } from "./review-submission.ts";
11
+ import { clauseExistenceRowSchema, secretariatArchitectureField } from "./review-submission.ts";
12
12
 
13
13
  export const SECRETARIAT_OUTPUT_TOOL_NAME = "ak_secretariat_output";
14
14
 
@@ -45,13 +45,14 @@ export const secretariatVerdictSchema = withTerminatingOutputDeclarations(
45
45
  description:
46
46
  "存废尺:稿里每条让机制存在的条款各一行——明写机制的,和只写结果要求、现状代码满足不了的,两类都算——到 ADR/票面点名的应用框架官方示范里看不带它时同一关切怎么处理。有「不要」行,这条不进票面:上呈陛下,原文列进 decisionGate;宰相答不了它。票面已写、前轮判词要求过、宰相答过、陛下对别的题点过头,都不是「要」的理由。一条没有为空数组。",
47
47
  }),
48
+ architecture: secretariatArchitectureField,
48
49
  },
49
50
  { additionalProperties: true },
50
51
  ),
51
52
  );
52
- // #1134 deleted the required set for the narrative fields; the 存废尺 table is the one generation-required field,
53
- // as it is for 给事中/台院/审刑院/大理寺 (the package still records the receipt as-is).
54
- (secretariatVerdictSchema as unknown as { required: string[] }).required = ["existence"];
53
+ // #1134 deleted the required set for the narrative fields; the 存废尺 and 架构归位表 tables are the
54
+ // generation-required fields, as they are for 给事中 (the package still records the receipt as-is).
55
+ (secretariatVerdictSchema as unknown as { required: string[] }).required = ["existence", "architecture"];
55
56
  // The type stays loose: narrative fields are unrequired (ADR 0057), additional properties stay open,
56
57
  // and the shared terminating fields are composed at runtime.
57
58
  export type SecretariatVerdict =