Feature by feature
Chapter 8 of 11
Search and models
Semantic and keyword indexes live in the schema and stay current after each write. Training exports, model features and evals read the same records under the same rules.
Running a separate vector store or search index alongside your database creates a second copy of your data that lags behind deletes and skips schema policies. Filtering top search hits in application code afterward can return an empty page when restricted records occupy the top ranks.
Try it
Because Napalm builds search indexes directly into the schema, access rules run during the scan. Send a half-remembered phrase as Ada, and you will receive matching notes ranked by semantic meaning.
curl https://notes.napalmdata.com/search \ -H "Authorization: Bearer $SESSION" \ -H "Content-Type: application/json" \ -d { "type": "Note", "query": "launch timeline and milestones", "limit": 5 }Search indexes#
Pillar at work: One typed graph
Keeping search inside the typed graph avoids maintaining a separate sync pipeline. On Note, two index lines declare meaning search and weighted keyword search across every workspace.
deferred index ext::ai::index(embedding_model := 'openai/text-embedding-3-small') on (.title ++ '\n\n' ++ .body);index fts::index on (( fts::with_options(.title, language := fts::Language.eng, weight_category := fts::Weight.A), fts::with_options(.body, language := fts::Language.eng, weight_category := fts::Weight.B)));Background-refreshed vector index
ext::ai::index refreshes embeddings in the background and scales from ten rows to tens of millions of vectors with no schema change.
Policy-filtered hybrid RRF
ext::ai::hybrid_search fuses fts::index keyword ranks with vector distance while evaluating access policy rules during scoring.
Callers reach embeddings through each Note record under that record’s access rules. An index scales from a few rows to tens of millions of vectors without schema changes. Napalm refreshes embeddings in the background through Napalm’s models or your own provider key.
Napalm evaluates access rules during candidate scoring. Asking for ten notes returns ten permitted notes, even when closer vectors belong to other companies. Deleting a note removes it from search in the same commit.
Training data#
Pillar at work: Caller-bound
To train a custom model that suggests workspace tags on new notes, store customer opt-in on Organization from Organizations and billing. One policy on Note restricts service keys carrying global role = 'service' to organizations that opted in.
type Organization { required name: str; required slug: str { constraint exclusive; }; required allows_training: bool { default := false; }; # …members and access rules} type Note { required workspace: Workspace { on target delete delete source; }; required owner: ext::auth::Identity; required title: str; required body: str; # …editors, indexes, notify and member rules access policy service_reads_consenting allow select using (global role ?= 'service' and .workspace.org.allows_training);}Policy-gated Parquet exports
Service keys carrying global role = 'service' export Parquet rows strictly from organizations where .allows_training is true.
Your pipeline exports permitted notes to Parquet and trains on your own GPUs. When a company turns allows_training off, later training runs exclude every note across that company’s workspaces without changing your export script.
Features and evals#
Pillar at work: Compiled
When Ada saves a note for live tag scoring, one saved query loads the record, workspace context, author history and the active model version in Slot together under Ada’s access.
with note := (select Note filter .id = <uuid>$note)select note { id, title, body, workspace_name := .workspace.name, author_note_count := count(( select .workspace.<workspace[is Note] filter .owner = note.owner )), model := assert_single(( select Slot filter .name = 'note-tags' )).serving.version,}Active Slot model lookup
Active model versions live as records in Slot, letting one query load live features and serving.version in a single snapshot.
CI regression eval gate
Gold test cases live in the same schema so CI blocks any candidate model version whose accuracy regresses against the serving slot.
An action from Actions, jobs and webhooks sends those inputs to your model and saves the suggested tags alongside the model version. The model serving and evals guides store known test cases as records in the same schema, so CI blocks any new model version that regresses.
Next, connect AI agents and copilots to the same project under the same rules.