fleet-kb-index: ingest, kb tools and the incremental refresh unit (nix-config#1876) #2847
No reviewers
Labels
No labels
backlog
bug
enhancement
in-progress
library
needs-rebase
review
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ymrtech/nix-config!2847
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "kb/NCFG-1876-fleet-kb-package"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
One package carrying the three verbs over the
fleet_kbstore (schema landed in #1875, host wiring is #1877):packages/fleet-kb-index/ingest.py— walks the five enumerated corpora (skill, note, config, card, event), heading-aware chunks (~600 tokens, heading path carried in the text), embeds with the packaged bge-m3 ONNX in-process, upserts bycontent_hash. Every corpus is a named root or an enumerated API source; a source's rows that are no longer produced are deleted so the store cannot drift from the text it points at.--skills-reposupplies git provenance for the (untracked) skill library; a file that repo does not carry keepscommitNULL, whichkb_stalereports rather than guesses.packages/fleet-kb-index/kb_server.py—search/get/stats/stale: pgvector cosine + english tsvector fused by RRF, metadata narrowing by jsonb containment, provenance + staleness per row. Alsofleet-kb mcp(stdio MCP server, same four verbs) so a session and an operator cannot get different answers.packages/fleet-kb-index/default.nix— one derivation with both CLIs;FLEET_KB_MODEL_DIRbaked so no caller has to know a store path.packages/fleet-kb-index/reindex.nix— the incremental refresh unit + timer, with the first-run timeout sized for the one-off full embed and a freshness report inExecStartPostthat does not red the unit.Proof (throwaway Postgres 15 + pgvector cluster, never the live store)
skipped == run1.embedded)kb search "wireguard mtu"→ that skill's anchor, both RRF arms matched, provenance/staleness renderedkb stalename the rownixos/lib/eval-config: ExecStart/ExecStartPost/timer/hardening as intendedIncremental is a property of the upsert, not a mode: an unchanged chunk keeps its row and its vector.
Not in scope
overlays/fleet-kb.nix+hosts/vpn/default.nix(pgvector extension,ensureDatabases, MCP entry, package installs) — that is nix-config#1877, which consumespackages/services.fleet-kb-indexfrom here.One package carrying the three verbs over the fleet_kb store (packages/fleet-kb-schema.sql): fleet-kb-ingest walks the five enumerated corpora (skill, note, config, card, event), chunks heading-aware (~600 tokens with the heading path in the text), embeds with the packaged bge-m3 ONNX model in-process and upserts by content_hash. Nothing is a catch-all walk: every corpus is a named root or an enumerated API source, and a source's rows that are no longer produced are deleted, so the store cannot drift from the text it points at. fleet-kb search / get / stats / stale over pgvector cosine and an english tsvector fused by RRF, metadata narrowing by jsonb containment, provenance and a staleness verdict per row, plus `fleet-kb mcp` — the same four verbs as a stdio MCP server, so a session and an operator cannot get different answers. reindex.nix the incremental refresh unit and timer. Incremental is a property of the upsert, not a mode: an unchanged chunk keeps its row and its vector, so a second run embeds zero chunks and an edited file re-embeds only its changed chunks. The skill library at /var/lib/hermes/.hermes/skills is not a git tree, so --skills-repo names the repo carrying the canonical copies and a file it does not carry keeps commit NULL — the schema's own rule for a source with no git history, which kb_stale reports rather than guesses. Verified in a throwaway Postgres 15 + pgvector cluster (never the live store): schema applied twice with no errors; all five corpora produce rows against the real sources; the wg-MTU skill's chunks embed on run 1 and run 2 embeds zero; `fleet-kb search "wireguard mtu"` returns that skill's anchor with both arms matched; a committed edit to an indexed config file makes kb_stale name the row.ba21f461aabbe54ab349