fleet-kb: ship the fleet_kb chunk-table DDL as an idempotent package (nix-config#1875) #2832

Merged
hermes merged 1 commit from kb/NCFG-1875-fleet-kb-ddl into main 2026-11-21 03:34:01 -06:00
Collaborator

Kanban nix-config#1875 (child 1 of Objectives#1824).

Deliverable The fleet_kb store DDL exists as an idempotent, packaged schema — not hand-run psql — so a re-apply is a no-op and a fresh host converges.

  • packages/fleet-kb-schema.sql — the chunk table: corpus, source, anchor, body, commit, indexed_at, content_hash, GENERATED tsv, vector(1024), jsonb meta; natural key (corpus, source, anchor); tsv GIN, embedding HNSW, meta GIN, (corpus, source) and indexed_at btree; corpus vocabulary + sha256 shape as named CHECKs added by pg_catalog probe (Postgres has no ADD CONSTRAINT IF NOT EXISTS).
  • packages/fleet-kb-schema.nix — store path $out/share/fleet-kb/schema.sql, same directory-output shape as packages/yan-rag-schema.nix.

Host wiring (overlays/fleet-kb.nix, hosts/vpn/default.nix, extensions, ensureDatabases) is #1877 and is untouched here; ingest/tools are #1876.

Proved on vpn against a real postgresql_15 + pgvector 0.8.6 cluster started from the store, using the PACKAGED file: applies cleanly 3x in a row (rc 0; rows 2 -> 2 -> 2 across applies 2 and 3), \d chunk lists all 11 columns + the tsv GIN and embedding HNSW indexes, both CHECKs reject a bad corpus and a truncated hash, and EXPLAIN takes the tsv GIN, the meta GIN (containment) and the HNSW index paths. Full log in the card.

Kanban nix-config#1875 (child 1 of Objectives#1824). **Deliverable** The fleet_kb store DDL exists as an idempotent, packaged schema — not hand-run psql — so a re-apply is a no-op and a fresh host converges. - `packages/fleet-kb-schema.sql` — the `chunk` table: corpus, source, anchor, body, commit, indexed_at, content_hash, GENERATED tsv, `vector(1024)`, jsonb `meta`; natural key `(corpus, source, anchor)`; tsv GIN, embedding HNSW, meta GIN, (corpus, source) and indexed_at btree; corpus vocabulary + sha256 shape as named CHECKs added by pg_catalog probe (Postgres has no ADD CONSTRAINT IF NOT EXISTS). - `packages/fleet-kb-schema.nix` — store path `$out/share/fleet-kb/schema.sql`, same directory-output shape as `packages/yan-rag-schema.nix`. Host wiring (`overlays/fleet-kb.nix`, `hosts/vpn/default.nix`, `extensions`, `ensureDatabases`) is #1877 and is untouched here; ingest/tools are #1876. **Proved on vpn** against a real postgresql_15 + pgvector 0.8.6 cluster started from the store, using the PACKAGED file: applies cleanly 3x in a row (rc 0; rows 2 -> 2 -> 2 across applies 2 and 3), `\d chunk` lists all 11 columns + the tsv GIN and embedding HNSW indexes, both CHECKs reject a bad corpus and a truncated hash, and EXPLAIN takes the tsv GIN, the meta GIN (containment) and the HNSW index paths. Full log in the card.
fleet-kb: ship the fleet_kb chunk-table DDL as an idempotent package
All checks were successful
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 4s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 14s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 4s
Secret Scan / gitleaks scan (pull_request) Successful in 14s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 8s
PR base guard / Base drift / conflict check (pull_request) Successful in 29s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 6s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 9s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m10s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m13s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 5s
foremerge intent (advisory) all 2 changed path(s) covered by a live foremerge intent
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 53s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 23s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 2m46s
NixOS Build Check / Gate summary (pull_request) Successful in 2s
Repo Gates / Repo gates (script-only battery) (pull_request) Successful in 3m57s
20ea750615
The fleet_kb store (#1875, child 1 of Objectives#1824) needs its schema to
exist as a packaged artifact before the ingest (#1876) and the host wiring
(#1877) can reference it, and a re-apply on every switch must be a no-op.

packages/fleet-kb-schema.sql is that DDL: one `chunk` row per indexed chunk
across the five corpora (skill, note, card, config, event), natural key
(corpus, source, anchor) for the ingest's upsert, a GENERATED tsv so the
lexical index cannot drift from `body`, vector(1024) for bge-m3, and jsonb
`meta` for the per-corpus filter fields. Every statement is conditional —
IF NOT EXISTS, or a pg_catalog probe for the two named CHECK constraints,
which Postgres cannot create conditionally. The corpus vocabulary and the
sha256 shape are constraints, not comments, so a typo cannot create a sixth
corpus or a truncated hash that defeats the skip-if-unchanged path.

packages/fleet-kb-schema.nix ships it as a directory output
($out/share/fleet-kb/schema.sql), the same shape as packages/yan-rag-schema.nix
and for the same reason: pkgs.buildEnv cannot merge a bare file.

Proved on vpn against a real postgresql_15 + pgvector 0.8.6 cluster started
from the store: the shipped file applies cleanly three times in a row (rc 0,
row count 2 -> 2 -> 2 across the 2nd and 3rd applies), \d chunk lists all
eleven columns and both the tsv GIN and the embedding HNSW indexes, the
corpus/hash CHECKs reject a bad row, and EXPLAIN takes the GIN, GIN-contains
and HNSW paths respectively.
hermes force-pushed kb/NCFG-1875-fleet-kb-ddl from 20ea750615
All checks were successful
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 4s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 14s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 4s
Secret Scan / gitleaks scan (pull_request) Successful in 14s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 8s
PR base guard / Base drift / conflict check (pull_request) Successful in 29s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 6s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 9s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m10s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m13s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 5s
foremerge intent (advisory) all 2 changed path(s) covered by a live foremerge intent
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 53s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 23s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 2m46s
NixOS Build Check / Gate summary (pull_request) Successful in 2s
Repo Gates / Repo gates (script-only battery) (pull_request) Successful in 3m57s
to 16e3c1bd50
All checks were successful
PR base guard / Base drift / conflict check (pull_request) Successful in 7s
Secret Scan / gitleaks scan (pull_request) Successful in 13s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 34s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 5s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m6s
foremerge intent (advisory) all 2 changed path(s) covered by a live foremerge intent
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 2m29s
NixOS Build Check / Gate summary (pull_request) Successful in 1s
Giga Build Check / Build giga target closure (pull_request) Successful in 51s
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 6s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 3s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 4s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 4s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 5s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m13s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 6s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 56s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 21s
Repo Gates / Repo gates (script-only battery) (pull_request) Successful in 3m45s
2026-11-21 03:21:01 -06:00
Compare
hermes merged commit db624a728b into main 2026-11-21 03:34:01 -06:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ymrtech/nix-config!2832
No description provided.