Skip to main content

Module schema

Module schema 

Source
Expand description

Schema 管理(对应 JS src/schema.js)

与 JS 版的差异:注册表由模块级全局 _schemas 改为显式 Registry 实例。

文件组织:数据结构与字段规范化在 [definition],注册/定位/配置在 [registry]。 对外 API(Registry / Schema / FieldDef / RelationDef / ComputeDef / map_of) 由本模块统一再导出,拆分不改语义。

Structs§

ComputeDef
FieldDef
LinkDecl
一条链路声明(store.config.json 的 links[<schema>] 一项)。
LoadConfig
装载配置(store.config.json 的 sources + defs + links)
Location
落点:定义之外,由「目录语义 + 连接配置」解析得到(设计 §5.2)。 落点维度 = source + database + schema(schema 仅 PostgreSQL); role / priority 为链路声明附着的可选属性(缺省 None)。
PolicyOverrides
策略覆盖项(派生视图的差分输入):None = 继承来源视图; rbac 的 Some(None) = 显式清除(其余字段无「清除」语义)。
ReadLinks
读链路解析结果:已排序链路 + 跳过/降级声明(随 plan.degraded 透出,禁静默)。
Registry
Schema 注册表:共享目录快照(Arc<Catalog>)+ 策略束(PolicyBundle)。
RelationDef
Schema
SourceDecl
一个连接声明(store.config.json 的 sources 一项)
TriggerDef

Enums§

Profile
查询档位:判决唯一在 core(照 Registry::require_context 既有范式)。
Role
链路角色:读解析时决定链路的优先级层级(Primary 最高)。 仅在 store.config.json 的 links 声明中出现,禁写入 schema 定义文件。
TriggerBody

Constants§

EVENTS
事件名(insert / update / remove / schedule;其余键注册期 Err)。 schedule 仅注册期接受 —— 写链永不 expand(“schedule”),由宿主定时任务插件 经 [crate::command::triggers::expand_schedule_triggers] 枚举执行。
MAX_VECTOR_DIM
向量维度统一上限:与 pgvector vector 类型上限一致,保证同一 schema 可跨源迁移。 数值源唯一:05 的 capability::APPLICATION_MAX_DIM 引用本常量,禁止出现第二个 16000 字面量。
OPS
命令式触发支持的 op 白名单(首批不含 upsert)

Functions§

depth_layered
语义层级深度:PG=2(L2=schema),Mongo/MySQL/SQLite=1(L2+ 打平)。 kind 非法 ⇒ Err(禁回落默认)。
locate
由「db 目录以下的相对路径」算落点(设计 §5.2 固定语义,D3):
map_of
便捷构造:Map from [(&str, Value)]
parse_triggers
解析并校验 schema 顶层的 triggers;任一项非法 → Err(零静默)。
plan_load
纯批次规划(设计 §5.2 伪码 + §5.3 主从): files: [(rel_from_defs_root, defn)](rel 首段 = db 目录名)。
validate_cron
5 段 cron(分 时 日 月 周)校验:段内仅 * , - / 与数字;数字范围分校验;步进须为正整数。

Type Aliases§

Triggers
triggers = 事件名 → 触发列表