M1: 底座 —— @contracts 首版 + event / ledger / org / llm

@contracts 首版(§8.1 九个文件):
- id 品牌 ID / terminal 终态五名与归侧四标签 / envelope 信封六字段与四类事件
- card 工单两模式 + 对话卡族(形状对齐 2026-07-26 原型定稿)
- contract7 契约七件 / ledger 三级寻址与写三分 / process-package 流程包 DSL 与触发器三类
- manifest 活动包清单六区(含 CMMN·DMN·步序声明的资产形状)/ org / api 路由契约

模块(L1):
- event   信封存储、归属解析三级短路、投递五诺、监听注册表、三级消费裁定
- ledger  schema 自生长(最大化合并/最宽类型/只增不破坏)、任务视图叠加、写三分、冲突检查
- org     岗位授权(客体三类×动作三种)、停用前置检查、会话、种子播种
- llm     四元绑定、ModelGateway 三模式(live/record/replay)—— 两缝之一

app 装配:Hono 服务 + 鉴权中间件 + 治理台/工作台路由;drizzle 迁移;AES-256-GCM 凭证密封

ADR-007 工具链与门禁 · ADR-008 投递队列 · ADR-009 凭证加密
(ADR 编号自 007 续:编码规范 §14 已用到 006,README 写「从 005 续」是笔误)

门禁五道全绿;96 个测试通过,含对真实 PG 的 ledger 集成测试

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
JCAI Main Agent
2026-07-27 00:59:14 +08:00
co-authored by Claude Opus 5
parent 7cd664af3a
commit 14d4fa046a
120 changed files with 15236 additions and 78 deletions
+83
View File
@@ -0,0 +1,83 @@
/**
* 终态五名与非终态注记(编码规范 §8.1;语义出处 OS 4.3 / AM 1.3)。
*
* 终态由**系统**裁定,封闭枚举,活动与模型不得增删。
*/
import { z } from 'zod';
/** 终态五名 —— 唯一成功终态是 released(放行通过且落地收敛,输出口已发射) */
export declare const TERMINAL_STATES: readonly ["released", "blocked", "stalled", "exhausted", "terminated"];
export declare const terminalStateSchema: z.ZodEnum<{
released: "released";
blocked: "blocked";
stalled: "stalled";
exhausted: "exhausted";
terminated: "terminated";
}>;
export type TerminalState = z.infer<typeof terminalStateSchema>;
export declare const TERMINAL_STATE_LABEL: Readonly<Record<TerminalState, string>>;
/** 触发者 —— OS 4.3 的第三列 */
export declare const TERMINAL_STATE_TRIGGER: Readonly<Record<TerminalState, string>>;
export declare function isSuccessTerminal(state: TerminalState): boolean;
/** 驳回:放行卡的环内回转,任务继续 —— redo 按原要求重做 / revise 带意见迭代 */
export declare const REJECTION_KINDS: readonly ["redo", "revise"];
export declare const rejectionKindSchema: z.ZodEnum<{
redo: "redo";
revise: "revise";
}>;
export type RejectionKind = z.infer<typeof rejectionKindSchema>;
export declare const REJECTION_KIND_LABEL: Readonly<Record<RejectionKind, string>>;
/** 控制三语义(OS 06):暂停 = 可恢复冻结 · 叫停 = 负责人紧急中断 · 终止 = 不可恢复关闭 */
export declare const CONTROL_SEMANTICS: readonly ["pause", "halt", "terminate"];
export declare const controlSemanticSchema: z.ZodEnum<{
pause: "pause";
halt: "halt";
terminate: "terminate";
}>;
export type ControlSemantic = z.infer<typeof controlSemanticSchema>;
export declare const CONTROL_SEMANTIC_LABEL: Readonly<Record<ControlSemantic, string>>;
/**
* 任务运行态 —— 与终态分层:终态是收场名,运行态是「此刻在干嘛」。
* landing-blocked(落地受阻)是运行态不是终态,处置后仍收敛于终态名录(OS 7.3)。
*/
export declare const TASK_RUNTIME_STATES: readonly ["running", "awaiting-human", "awaiting-event", "suspended", "landing-blocked", "terminal"];
export declare const taskRuntimeStateSchema: z.ZodEnum<{
running: "running";
"awaiting-human": "awaiting-human";
"awaiting-event": "awaiting-event";
suspended: "suspended";
"landing-blocked": "landing-blocked";
terminal: "terminal";
}>;
export type TaskRuntimeState = z.infer<typeof taskRuntimeStateSchema>;
export declare const TASK_RUNTIME_STATE_LABEL: Readonly<Record<TaskRuntimeState, string>>;
export declare const WORKFLOW_STATES: readonly ["running", "waiting", "completed", "terminated", "abnormal"];
export declare const workflowStateSchema: z.ZodEnum<{
terminated: "terminated";
running: "running";
waiting: "waiting";
completed: "completed";
abnormal: "abnormal";
}>;
export type WorkflowState = z.infer<typeof workflowStateSchema>;
export declare const WORKFLOW_STATE_LABEL: Readonly<Record<WorkflowState, string>>;
export declare const ATTRIBUTION_SIDES: readonly ["machine", "human", "human-verdict", "world-wait"];
export declare const attributionSideSchema: z.ZodEnum<{
machine: "machine";
human: "human";
"human-verdict": "human-verdict";
"world-wait": "world-wait";
}>;
export type AttributionSide = z.infer<typeof attributionSideSchema>;
export declare const ATTRIBUTION_SIDE_LABEL: Readonly<Record<AttributionSide, string>>;
export declare const ACCEPTANCE_LEVELS: readonly ["L1", "L2", "L3", "L4", "L5"];
export declare const acceptanceLevelSchema: z.ZodEnum<{
L1: "L1";
L2: "L2";
L3: "L3";
L4: "L4";
L5: "L5";
}>;
export type AcceptanceLevel = z.infer<typeof acceptanceLevelSchema>;
export declare const ACCEPTANCE_LEVEL_LABEL: Readonly<Record<AcceptanceLevel, string>>;
/** L1–L4 是质量关,L5 是责任关 —— 判据全绿只是可提交,完成只出自放行通过 */
export declare function isResponsibilityGate(level: AcceptanceLevel): boolean;