M6(3/n): minute 与 report —— L8 两个模块补齐

minute(纪要):工作台五要素里唯一的主动动作。
  纪要本身不产生责任,唯一通往责任的路是决议经登记触发起单 —— 登记人即来源。
  正文可续、决议只增;同一决议不重复起单(起单一刻已有一条带来源的流在跑)。

report(汇报):日/周/月/年对任务日志的聚合投影,零手工汇报。
  未提交的草案每次取回都重算 —— 汇报是投影不是账本,提交那刻才固定为事实快照。
  度量八指标落在这里(§4 注:度量是只读投影,不设独立模块):
  自主率 / 纠正率 / 有效自主率 / 打扰率 / 断点率 / DMN 覆盖率 / 单位成本 / 终态分布。
  口径全部挂归侧标签与事件流,零埋点;单位成本的分母只认放行通过。
  周窗口以周一为首日,按 UTC 切分(单组织单时区)。

FactSource 只读 memory 与 task,一行都不另记 —— 五要素同源。

gates: tsc / eslint / depcruise(305 模块)/ api-report / 377 测试 全绿
日报已在真实系统上由 A1 任务日志聚合出来,含治理干预两行

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
2026-07-27 03:39:10 +08:00
co-authored by Claude Opus 5
parent a9cd6d10c7
commit a60acb2e02
37 changed files with 5495 additions and 2 deletions
+51
View File
@@ -0,0 +1,51 @@
/**
* module: minute —— 对外类型(编码规范 §10.1;语义出处 OS 2.1 / 3.1)。
*
* 纪要是工作台五要素里**唯一的主动动作**:团队主动维护上传的沉淀(会议纪要等)。
* 它本身不产生责任;责任的产生只有一条路——**决议经登记触发转为工作流的启动**,
* 「登记人即来源」。所以本模块的写面很薄,重头在「决议 → 登记起单」这一跳。
*/
import type { StaffId } from '@contracts';
import type { Minute, MinuteResolution, ResolutionState } from './internal/domain/minute.ts';
export type { Minute, MinuteResolution, ResolutionState };
export declare class MinuteNotFoundError extends Error {
readonly minuteId: string;
constructor(minuteId: string);
}
export declare class ResolutionAlreadyRegisteredError extends Error {
readonly resolutionId: string;
readonly workflowId: string;
constructor(resolutionId: string, workflowId: string);
}
export type CreateMinuteInput = {
readonly title: string;
readonly body: string;
readonly authorId: StaffId;
/** 与会/相关人 —— 仅作沉淀标注,不产生责任 */
readonly participants?: readonly StaffId[];
readonly occurredOn: string;
readonly resolutions?: ReadonlyArray<{
text: string;
ownerId?: StaffId | undefined;
}>;
};
export type RegisterInput = {
readonly resolutionId: string;
/** 登记人 —— 凡单必有来源,登记触发的来源就是他 */
readonly byId: StaffId;
readonly processPackageId: string;
/** 按调用接口 schema 填写的输入(表单由 schema 自动渲染) */
readonly data: Record<string, unknown>;
};
export type MinuteService = {
list(limit?: number): Promise<Minute[]>;
get(minuteId: string): Promise<Minute>;
create(input: CreateMinuteInput): Promise<Minute>;
/** 只增不改的编辑:正文可续,决议只增 —— 纪要是沉淀,不是可覆写的文档 */
appendResolution(minuteId: string, text: string, ownerId?: StaffId): Promise<Minute>;
/** 决议 → 登记起单:登记人即来源;同一决议只起一次单 */
register(input: RegisterInput): Promise<{
workflowId: string;
resolutionId: string;
}>;
};
+7
View File
@@ -0,0 +1,7 @@
/** module: minute —— 唯一出口(编码规范 §10.1):纯再导出,不含实现。 */
export type { CreateMinuteInput, Minute, MinuteResolution, MinuteService, RegisterInput, ResolutionState, } from './contract.ts';
export { MinuteNotFoundError, ResolutionAlreadyRegisteredError } from './contract.ts';
export { createMinuteService } from './internal/usecase/minute-service.ts';
export { createMinuteStore } from './internal/adapter/minute-store.ts';
export { minutes, minuteResolutions } from './internal/adapter/minute-schema.ts';
export { newMinute, addResolution, markRegistered } from './internal/domain/minute.ts';
+33
View File
@@ -0,0 +1,33 @@
/**
* module: minute 的外部所需(编码规范 §10.1)。
* 「port 声明本模块需要外界提供什么」—— 由 app 层注入,模块自己不认实现。
*/
import type { StaffId } from '@contracts';
import type { Minute } from './internal/domain/minute.ts';
export type MinuteStore = {
list(limit: number): Promise<Minute[]>;
get(minuteId: string): Promise<Minute | undefined>;
save(minute: Minute): Promise<void>;
};
/** 登记起单 —— app 注入 `process`(L7):经调用接口调起流程包,不碰流程内部 */
export type RegistrationGateway = {
start(input: {
processPackageId: string;
subject: string;
data: Record<string, unknown>;
/** 来源:登记人 */
byId: StaffId;
}): Promise<{
workflowId: string;
}>;
};
export type MinuteDeps = {
readonly store: MinuteStore;
readonly registration: RegistrationGateway;
readonly ids: {
next(): string;
};
readonly clock: {
now(): Date;
};
};
+41
View File
@@ -0,0 +1,41 @@
/**
* module: report —— 对外类型(编码规范 §10.1;语义出处 OS 2.1 / 8.1 / 8.3)。
*
* 汇报是**系统代劳的自动产出**:由本人各任务的任务日志聚合生成,确认即提交,零手工汇报。
* 度量八指标是任务日志与终态之上的**只读投影**,不设独立模块(§4 注)。
*/
import type { StaffId } from '@contracts';
import type { Metrics, ReportDraft, ReportSection } from './internal/domain/aggregate.ts';
import type { ReportPeriod, Window } from './internal/domain/period.ts';
export type { Metrics, ReportDraft, ReportPeriod, ReportSection, Window };
export declare class ReportNotFoundError extends Error {
readonly reportId: string;
constructor(reportId: string);
}
export declare class ReportAlreadySubmittedError extends Error {
readonly reportId: string;
constructor(reportId: string);
}
/** 汇报单:草案由系统生成,员工确认即提交 */
export type Report = {
readonly id: string;
readonly staffId: StaffId;
readonly period: ReportPeriod;
readonly title: string;
readonly window: Window;
readonly draft: ReportDraft;
/** 员工可在确认前补一段话 —— 唯一的手工位 */
readonly note?: string | undefined;
readonly submittedAt?: string | undefined;
readonly generatedAt: string;
};
export type ReportService = {
/** 生成(或取回)某人某周期的汇报草案 —— 未提交的重取即重算,提交后固定 */
draft(staffId: StaffId, period: ReportPeriod, anchor?: Date): Promise<Report>;
list(staffId: StaffId, limit?: number): Promise<Report[]>;
get(reportId: string): Promise<Report>;
/** 确认即提交 */
submit(reportId: string, note?: string): Promise<Report>;
/** 度量八指标 —— 治理台记忆区的仪表读数,同源同口径 */
metrics(staffId: StaffId | undefined, period: ReportPeriod, anchor?: Date): Promise<Metrics>;
};
+10
View File
@@ -0,0 +1,10 @@
/** module: report —— 唯一出口(编码规范 §10.1):纯再导出,不含实现。 */
export type { Metrics, Report, ReportDraft, ReportPeriod, ReportSection, ReportService, Window } from './contract.ts';
export { ReportAlreadySubmittedError, ReportNotFoundError } from './contract.ts';
export type { FactSource, ReportStore, ReportDeps } from './port.ts';
export type { LogFact, TaskFact } from './internal/domain/aggregate.ts';
export { computeMetrics, draftReport } from './internal/domain/aggregate.ts';
export { REPORT_PERIODS, periodLabel, windowOf } from './internal/domain/period.ts';
export { createReportService } from './internal/usecase/report-service.ts';
export { createReportStore } from './internal/adapter/report-store.ts';
export { reports } from './internal/adapter/report-schema.ts';
+29
View File
@@ -0,0 +1,29 @@
/**
* module: report 的外部所需(编码规范 §10.1)。
* 汇报**不自己记账**:事实全部来自 memory(任务日志)与 task(终态 / 预算 / 纠正信号)。
*/
import type { StaffId } from '@contracts';
import type { Report } from './contract.ts';
import type { LogFact, TaskFact } from './internal/domain/aggregate.ts';
export type ReportStore = {
list(staffId: StaffId, limit: number): Promise<Report[]>;
get(reportId: string): Promise<Report | undefined>;
findOpen(staffId: StaffId, period: string, windowFrom: string): Promise<Report | undefined>;
save(report: Report): Promise<void>;
};
/** 事实源 —— app 注入 `memory`(L2)与 `task`(L6);report 在 L8,只读不写 */
export type FactSource = {
/** 某人(或全员)在窗口内的归侧日志行 */
logsOf(staffId: StaffId | undefined, from: string, to: string): Promise<LogFact[]>;
tasksOf(staffId: StaffId | undefined): Promise<TaskFact[]>;
};
export type ReportDeps = {
readonly store: ReportStore;
readonly facts: FactSource;
readonly ids: {
next(): string;
};
readonly clock: {
now(): Date;
};
};
+2 -1
View File
@@ -56,7 +56,8 @@ export type ParadigmEngine = {
export type MemoryRecorder = {
append(input: {
taskId: TaskId;
kind: 'engine-transition' | 'terminal' | 'observation';
/** control = 治理干预(叫停 / 恢复 / 改派):人对过程的裁断,归人裁决侧 */
kind: 'engine-transition' | 'terminal' | 'observation' | 'control';
title: string;
detail?: Record<string, unknown>;
}): Promise<void>;
+379
View File
@@ -2024,3 +2024,382 @@ export declare const listMessagesRoute: {
}, z.core.$strip>>;
}, z.core.$strip>;
};
export declare const minuteResolutionSchema: z.ZodObject<{
id: z.ZodString;
text: z.ZodString;
ownerId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
state: z.ZodEnum<{
open: "open";
registered: "registered";
}>;
workflowId: z.ZodOptional<z.ZodString>;
registeredById: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
registeredAt: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
export declare const minuteSchema: z.ZodObject<{
id: z.ZodString;
title: z.ZodString;
body: z.ZodString;
authorId: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
authorName: z.ZodString;
participants: z.ZodArray<z.ZodString>;
occurredOn: z.ZodString;
resolutions: z.ZodArray<z.ZodObject<{
id: z.ZodString;
text: z.ZodString;
ownerId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
state: z.ZodEnum<{
open: "open";
registered: "registered";
}>;
workflowId: z.ZodOptional<z.ZodString>;
registeredById: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
registeredAt: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>;
createdAt: z.ZodString;
updatedAt: z.ZodString;
}, z.core.$strip>;
export type MinuteView = z.infer<typeof minuteSchema>;
export declare const listMinutesRoute: {
readonly method: "GET";
readonly path: "/api/minutes";
readonly output: z.ZodObject<{
minutes: z.ZodArray<z.ZodObject<{
id: z.ZodString;
title: z.ZodString;
body: z.ZodString;
authorId: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
authorName: z.ZodString;
participants: z.ZodArray<z.ZodString>;
occurredOn: z.ZodString;
resolutions: z.ZodArray<z.ZodObject<{
id: z.ZodString;
text: z.ZodString;
ownerId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
state: z.ZodEnum<{
open: "open";
registered: "registered";
}>;
workflowId: z.ZodOptional<z.ZodString>;
registeredById: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
registeredAt: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>;
createdAt: z.ZodString;
updatedAt: z.ZodString;
}, z.core.$strip>>;
}, z.core.$strip>;
};
export declare const createMinuteRoute: {
readonly method: "POST";
readonly path: "/api/minutes";
readonly body: z.ZodObject<{
title: z.ZodString;
body: z.ZodString;
occurredOn: z.ZodString;
participants: z.ZodDefault<z.ZodArray<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>>;
resolutions: z.ZodDefault<z.ZodArray<z.ZodObject<{
text: z.ZodString;
ownerId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
}, z.core.$strip>>>;
}, z.core.$strip>;
readonly output: z.ZodObject<{
id: z.ZodString;
title: z.ZodString;
body: z.ZodString;
authorId: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
authorName: z.ZodString;
participants: z.ZodArray<z.ZodString>;
occurredOn: z.ZodString;
resolutions: z.ZodArray<z.ZodObject<{
id: z.ZodString;
text: z.ZodString;
ownerId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
state: z.ZodEnum<{
open: "open";
registered: "registered";
}>;
workflowId: z.ZodOptional<z.ZodString>;
registeredById: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
registeredAt: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>;
createdAt: z.ZodString;
updatedAt: z.ZodString;
}, z.core.$strip>;
};
export declare const appendResolutionRoute: {
readonly method: "POST";
readonly path: "/api/minutes/:minuteId/resolutions";
readonly params: z.ZodObject<{
minuteId: z.ZodString;
}, z.core.$strip>;
readonly body: z.ZodObject<{
text: z.ZodString;
ownerId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
}, z.core.$strip>;
readonly output: z.ZodObject<{
id: z.ZodString;
title: z.ZodString;
body: z.ZodString;
authorId: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
authorName: z.ZodString;
participants: z.ZodArray<z.ZodString>;
occurredOn: z.ZodString;
resolutions: z.ZodArray<z.ZodObject<{
id: z.ZodString;
text: z.ZodString;
ownerId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
state: z.ZodEnum<{
open: "open";
registered: "registered";
}>;
workflowId: z.ZodOptional<z.ZodString>;
registeredById: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
registeredAt: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>;
createdAt: z.ZodString;
updatedAt: z.ZodString;
}, z.core.$strip>;
};
/** 决议 → 登记起单:登记人即来源 */
export declare const registerResolutionRoute: {
readonly method: "POST";
readonly path: "/api/minutes/resolutions/:resolutionId/register";
readonly params: z.ZodObject<{
resolutionId: z.ZodString;
}, z.core.$strip>;
readonly body: z.ZodObject<{
processPackageId: z.ZodString;
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
}, z.core.$strip>;
readonly output: z.ZodObject<{
workflowId: z.ZodString;
resolutionId: z.ZodString;
}, z.core.$strip>;
};
export declare const reportPeriodSchema: z.ZodEnum<{
day: "day";
week: "week";
month: "month";
year: "year";
}>;
export type ReportPeriodName = z.infer<typeof reportPeriodSchema>;
export declare const REPORT_PERIOD_LABEL: Readonly<Record<ReportPeriodName, string>>;
export declare const reportMetricsSchema: z.ZodObject<{
autonomy: z.ZodNumber;
correction: z.ZodNumber;
effectiveAutonomy: z.ZodNumber;
interruption: z.ZodNumber;
breakpoint: z.ZodNumber;
dmnCoverage: z.ZodNumber;
unitCost: z.ZodObject<{
tokens: z.ZodNumber;
minutes: z.ZodNumber;
humanCalls: z.ZodNumber;
}, z.core.$strip>;
terminalMix: z.ZodRecord<z.ZodString, z.ZodNumber>;
}, z.core.$strip>;
export declare const reportSchema: z.ZodObject<{
id: z.ZodString;
period: z.ZodEnum<{
day: "day";
week: "week";
month: "month";
year: "year";
}>;
title: z.ZodString;
window: z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strip>;
sections: z.ZodArray<z.ZodObject<{
taskId: z.ZodString;
title: z.ZodString;
activityId: z.ZodString;
terminalLabel: z.ZodOptional<z.ZodString>;
lines: z.ZodArray<z.ZodString>;
}, z.core.$strip>>;
metrics: z.ZodObject<{
autonomy: z.ZodNumber;
correction: z.ZodNumber;
effectiveAutonomy: z.ZodNumber;
interruption: z.ZodNumber;
breakpoint: z.ZodNumber;
dmnCoverage: z.ZodNumber;
unitCost: z.ZodObject<{
tokens: z.ZodNumber;
minutes: z.ZodNumber;
humanCalls: z.ZodNumber;
}, z.core.$strip>;
terminalMix: z.ZodRecord<z.ZodString, z.ZodNumber>;
}, z.core.$strip>;
counts: z.ZodObject<{
touched: z.ZodNumber;
released: z.ZodNumber;
logLines: z.ZodNumber;
}, z.core.$strip>;
note: z.ZodOptional<z.ZodString>;
submittedAt: z.ZodOptional<z.ZodString>;
generatedAt: z.ZodString;
}, z.core.$strip>;
export type ReportView = z.infer<typeof reportSchema>;
/** 未提交的草案每次取回都重算 —— 汇报是投影,不是账本 */
export declare const draftReportRoute: {
readonly method: "GET";
readonly path: "/api/reports/:period";
readonly params: z.ZodObject<{
period: z.ZodEnum<{
day: "day";
week: "week";
month: "month";
year: "year";
}>;
}, z.core.$strip>;
readonly output: z.ZodObject<{
id: z.ZodString;
period: z.ZodEnum<{
day: "day";
week: "week";
month: "month";
year: "year";
}>;
title: z.ZodString;
window: z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strip>;
sections: z.ZodArray<z.ZodObject<{
taskId: z.ZodString;
title: z.ZodString;
activityId: z.ZodString;
terminalLabel: z.ZodOptional<z.ZodString>;
lines: z.ZodArray<z.ZodString>;
}, z.core.$strip>>;
metrics: z.ZodObject<{
autonomy: z.ZodNumber;
correction: z.ZodNumber;
effectiveAutonomy: z.ZodNumber;
interruption: z.ZodNumber;
breakpoint: z.ZodNumber;
dmnCoverage: z.ZodNumber;
unitCost: z.ZodObject<{
tokens: z.ZodNumber;
minutes: z.ZodNumber;
humanCalls: z.ZodNumber;
}, z.core.$strip>;
terminalMix: z.ZodRecord<z.ZodString, z.ZodNumber>;
}, z.core.$strip>;
counts: z.ZodObject<{
touched: z.ZodNumber;
released: z.ZodNumber;
logLines: z.ZodNumber;
}, z.core.$strip>;
note: z.ZodOptional<z.ZodString>;
submittedAt: z.ZodOptional<z.ZodString>;
generatedAt: z.ZodString;
}, z.core.$strip>;
};
export declare const listReportsRoute: {
readonly method: "GET";
readonly path: "/api/reports";
readonly output: z.ZodObject<{
reports: z.ZodArray<z.ZodObject<{
id: z.ZodString;
period: z.ZodEnum<{
day: "day";
week: "week";
month: "month";
year: "year";
}>;
title: z.ZodString;
window: z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strip>;
sections: z.ZodArray<z.ZodObject<{
taskId: z.ZodString;
title: z.ZodString;
activityId: z.ZodString;
terminalLabel: z.ZodOptional<z.ZodString>;
lines: z.ZodArray<z.ZodString>;
}, z.core.$strip>>;
metrics: z.ZodObject<{
autonomy: z.ZodNumber;
correction: z.ZodNumber;
effectiveAutonomy: z.ZodNumber;
interruption: z.ZodNumber;
breakpoint: z.ZodNumber;
dmnCoverage: z.ZodNumber;
unitCost: z.ZodObject<{
tokens: z.ZodNumber;
minutes: z.ZodNumber;
humanCalls: z.ZodNumber;
}, z.core.$strip>;
terminalMix: z.ZodRecord<z.ZodString, z.ZodNumber>;
}, z.core.$strip>;
counts: z.ZodObject<{
touched: z.ZodNumber;
released: z.ZodNumber;
logLines: z.ZodNumber;
}, z.core.$strip>;
note: z.ZodOptional<z.ZodString>;
submittedAt: z.ZodOptional<z.ZodString>;
generatedAt: z.ZodString;
}, z.core.$strip>>;
}, z.core.$strip>;
};
/** 确认即提交,提交后不再改 */
export declare const submitReportRoute: {
readonly method: "POST";
readonly path: "/api/reports/:reportId/submit";
readonly params: z.ZodObject<{
reportId: z.ZodString;
}, z.core.$strip>;
readonly body: z.ZodObject<{
note: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
readonly output: z.ZodObject<{
id: z.ZodString;
period: z.ZodEnum<{
day: "day";
week: "week";
month: "month";
year: "year";
}>;
title: z.ZodString;
window: z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strip>;
sections: z.ZodArray<z.ZodObject<{
taskId: z.ZodString;
title: z.ZodString;
activityId: z.ZodString;
terminalLabel: z.ZodOptional<z.ZodString>;
lines: z.ZodArray<z.ZodString>;
}, z.core.$strip>>;
metrics: z.ZodObject<{
autonomy: z.ZodNumber;
correction: z.ZodNumber;
effectiveAutonomy: z.ZodNumber;
interruption: z.ZodNumber;
breakpoint: z.ZodNumber;
dmnCoverage: z.ZodNumber;
unitCost: z.ZodObject<{
tokens: z.ZodNumber;
minutes: z.ZodNumber;
humanCalls: z.ZodNumber;
}, z.core.$strip>;
terminalMix: z.ZodRecord<z.ZodString, z.ZodNumber>;
}, z.core.$strip>;
counts: z.ZodObject<{
touched: z.ZodNumber;
released: z.ZodNumber;
logLines: z.ZodNumber;
}, z.core.$strip>;
note: z.ZodOptional<z.ZodString>;
submittedAt: z.ZodOptional<z.ZodString>;
generatedAt: z.ZodString;
}, z.core.$strip>;
};
export type ListMinutesOutput = z.infer<typeof listMinutesRoute.output>;
export type ListReportsOutput = z.infer<typeof listReportsRoute.output>;