KeiSeiKit-1.0/_primitives/_rust/kei-entity-store/src/lib.rs
Parfii-bot eac09a6354 feat(e1): engine improvements — TextPk + Real + TextArchiveEnum + TextPairWithMetadata
4 additive FieldKind/EdgeKeyKind variants addressing M1 dogfood +
M4/M5 flags. Backward-compat — existing schemas unchanged.

FieldKind::TextPk — TEXT PRIMARY KEY (kei-chat-store UUID sessions)
FieldKind::Real + RealDefault(f64) — REAL columns (kei-chat-store cost)
FieldKind::TextArchiveEnum — archive verb writes string sentinel instead of 1
EdgeKeyKind::TextPairWithMetadata — src_path/dst_path + id/weight/created_at/extra

Archive verb now dispatches: IntegerFlag writes 1, TextArchiveEnum writes sentinel.
Link/rank handle TextPairWithMetadata via generic weight+id propagation.
PK helpers in verbs/pk.rs abstract integer vs text primary key.

Engine decomposed to stay under 200 LOC:
- schema.rs (149) + field.rs (94, new) + ddl.rs (157, new)
- verbs/pk.rs + create_defaults.rs split from create.rs

Tests: 40/40 (was 32, +8 real_text_pk_smoke).
Sister crates verified backward-compat:
- kei-task 9/9, kei-chat-store 5/5, kei-content-store 4/4
- kei-social-store 5/5, kei-crossdomain 5/5, kei-sage 28/28

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 10:22:22 +08:00

26 lines
994 B
Rust

//! kei-entity-store — Layer A verb-template engine.
//!
//! Provides a schema-driven store that 6 sibling kei-*-store crates can
//! plug into instead of hand-rolling their own `Store::open` + CRUD
//! helpers. An `EntitySchema` declaratively describes one entity table
//! (fields, FTS columns, edge table, enabled verbs); verb modules
//! (`create`, `get`, `list`, `search`, `update`, `delete`, `link`,
//! `rank`) consume the schema and run parameterized SQL.
//!
//! Pilot target: `kei-task` (see its `schema.rs` for an example usage).
//! Follow-up waves: kei-chat-store, kei-content-store, kei-social-store,
//! kei-sage, kei-crossdomain.
//!
//! Per substrate schema v1 this crate stays library-only — no CLI, no
//! `bin`. Each sibling crate remains the user-facing binary.
pub mod ddl;
pub mod engine;
pub mod error;
pub mod field;
pub mod schema;
pub mod verbs;
pub use engine::Store;
pub use error::VerbError;
pub use schema::{EdgeKeyKind, EntitySchema, FieldDef, FieldKind};