Archived
M3(完成): interaction 与 activity-registry
interaction(L3): - 控制权按态转交:活动在跑归活动,流转/审批/终态归系统;输入侧永远归系统(单入口) - 视图区净化门:含 <script> / on* / 外部资源的模版一律拒推 —— 容器无脚本执行权 - 对话流单入口:自由输入同写任务记忆并抛人事件;SSE 单连接 + 按目标失效广播 - 前端零过程状态:对话流与视图都是服务端投影 activity-registry(L4): - 安装两审:静态审(签名/SDK/工具契约齐备/模型名已绑定/schema/悬空监听/模版无脚本/ 零环境能力/动态执行/验收等级不得谎报)+ 回放审(旧成不坏是硬门,旧败能成只入报告) - 资产与包分离版本化:包只携资产初始版,不覆盖已有更高资产版;装载 = 包版本 + 生效资产版 - 进化管线状态机:候选 → 回放 → 人放行 → 生效;回退是显式治理动作 245 个测试通过,门禁五道全绿 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
co-authored by
Claude Opus 5
parent
d96c6e6dff
commit
2850e6d4ef
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* activity-registry 的 sys schema 表(编码规范 §7 / ADR-002 / OS 11.3)。
|
||||
* **资产与包分离,各自单写者** —— 两张表、两条版本序列。
|
||||
*/
|
||||
import { sql } from 'drizzle-orm';
|
||||
import { boolean, index, integer, jsonb, primaryKey, text, timestamp, uniqueIndex } from 'drizzle-orm/pg-core';
|
||||
import { sys } from '@shared/db.ts';
|
||||
|
||||
export const activityPackageTable = sys.table(
|
||||
'activity_package',
|
||||
{
|
||||
activityId: text('activity_id').notNull(),
|
||||
version: text('version').notNull(),
|
||||
name: text('name').notNull(),
|
||||
category: text('category').notNull(),
|
||||
paradigm: text('paradigm').notNull(),
|
||||
manifest: jsonb('manifest').notNull(),
|
||||
/** .JS 产物 —— 装载时由 registry 交给范式运行器(ADR-004) */
|
||||
artifact: text('artifact').notNull(),
|
||||
state: text('state').notNull().default('active'),
|
||||
enabled: boolean('enabled').notNull().default(true),
|
||||
installedAt: timestamp('installed_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(t) => [
|
||||
primaryKey({ columns: [t.activityId, t.version] }),
|
||||
index('activity_package_category_idx').on(t.category, t.paradigm),
|
||||
],
|
||||
);
|
||||
|
||||
export const activityAssetTable = sys.table(
|
||||
'activity_asset',
|
||||
{
|
||||
activityId: text('activity_id').notNull(),
|
||||
kind: text('kind').notNull(),
|
||||
version: integer('version').notNull(),
|
||||
body: text('body').notNull(),
|
||||
effective: boolean('effective').notNull().default(false),
|
||||
source: text('source').notNull(),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(t) => [
|
||||
primaryKey({ columns: [t.activityId, t.kind, t.version] }),
|
||||
// 每个「活动 × 资产类」至多一个生效版 —— 装载时不会取到两份
|
||||
uniqueIndex('activity_asset_effective_key')
|
||||
.on(t.activityId, t.kind)
|
||||
.where(sql`${t.effective}`),
|
||||
],
|
||||
);
|
||||
|
||||
/** 候选增量:候选 → 回放中 → 已放行 / 已否决(OS 11.3) */
|
||||
export const assetIncrementTable = sys.table(
|
||||
'asset_increment',
|
||||
{
|
||||
id: text('id').primaryKey(),
|
||||
activityId: text('activity_id').notNull(),
|
||||
kind: text('kind').notNull(),
|
||||
diff: text('diff').notNull(),
|
||||
/** 证据链 —— 指回任务记忆的具体片段 */
|
||||
evidenceEntryIds: jsonb('evidence_entry_ids').notNull().default([]),
|
||||
state: text('state').notNull().default('candidate'),
|
||||
replayReport: jsonb('replay_report'),
|
||||
releasedBy: text('released_by'),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(t) => [index('asset_increment_activity_idx').on(t.activityId, t.state)],
|
||||
);
|
||||
Reference in New Issue
Block a user