KeiSeiKit-1.0/_primitives/_rust/kei-discover/src/schema.rs
Parfii-bot 0be354a920 KeiSeiKit-public — clean state
Single-commit clean baseline after security scrub of niche-tells,
project codenames, internal jargon, and contributor-email leaks.

Contents:
- 100 Rust crates (_primitives/_rust/)
- 37 agent manifests (_manifests/) + generated specs (_generated/)
- 67 user-invocable skills (skills/)
- 33 hooks (hooks/)
- Composition blocks (_blocks/)
- Documentation (docs/, README.md)
- TS adapter packages (_ts_packages/)
- Assembler (_assembler/)
- Roles (_roles/)
- Templates (_templates/)
- Forgejo CI (.forgejo/)

Author: Denis Parfionovich <info@greendragon.info>

License: see LICENSE.
2026-05-01 12:09:03 +08:00

39 lines
1.4 KiB
Rust

//! `discover_index` EntitySchema — one row per announced primitive.
//!
//! Fields follow task.toml spec: `slug` (unique indexed), `author`,
//! `source_url`, `description`, `installed` (0/1 stored as INTEGER —
//! SQLite has no native bool), `last_seen_ts`, `created_at`,
//! `updated_at`. A UNIQUE INDEX on `slug` is emitted via
//! `custom_migrations` so duplicate registrations fail at the SQL layer
//! (mapped to `DiscoverError::DuplicateSlug` by the `register` module).
//!
//! FTS columns are `slug` + `description` — callers search by either.
use kei_entity_store::schema::{EdgeKeyKind, EntitySchema, FieldDef};
static FIELDS: &[FieldDef] = &[
FieldDef::pk("id"),
FieldDef::text_nn("slug"),
FieldDef::text_nn("author"),
FieldDef::text("source_url"),
FieldDef::text("description"),
FieldDef::integer("installed"),
FieldDef::integer("last_seen_ts"),
FieldDef::created_at(),
FieldDef::updated_at(),
];
const DDL_UNIQUE_SLUG: &str =
"CREATE UNIQUE INDEX IF NOT EXISTS ux_discover_slug ON discover_index(slug);";
pub static DISCOVER_SCHEMA: EntitySchema = EntitySchema {
name: "discover",
table: "discover_index",
fields: FIELDS,
enabled_verbs: &["create", "get", "list", "search", "update"],
fts_columns: Some(&["slug", "description"]),
edge_table: None,
edge_key_kind: EdgeKeyKind::IntegerPair,
archived_field: None,
custom_migrations: &[DDL_UNIQUE_SLUG],
};