-- Migration: agent_atom_registry — add parent_atom_id (reference children) -- -- A skill's deep material (.claude/skills/**/references/*.md) is now ingested as -- hidden child rows: one row per reference file, parent_atom_id pointing at the -- owning SKILL.md atom. NULL = a top-level skill; set = a reference belonging to -- that skill. -- -- Children are excluded from every catalog (the chat metadata index, the MCP -- skill list, the composer atom index, the /settings/agent-skills panel) via a -- `parent_atom_id IS NULL` filter. They reach the model only through an explicit -- gnubok_load_skill() call, made after the parent SKILL.md is loaded -- and its "Loadable references" footer is visible — progressive disclosure that -- keeps reference bytes out of context until a question actually needs them. -- -- Bodies for both parents and children are (re)seeded by the next migration, -- generated by scripts/generate-skill-bodies.ts. RLS is unchanged: the column -- lives on an already-protected table (read-only to authenticated, service-role -- writes), so it inherits the existing policies. ALTER TABLE public.agent_atom_registry ADD COLUMN IF NOT EXISTS parent_atom_id text REFERENCES public.agent_atom_registry(id) ON DELETE CASCADE; -- Serves both access patterns: catalog reads (`parent_atom_id IS NULL`) and -- "load the references for skill X" (equality on parent_atom_id). CREATE INDEX IF NOT EXISTS idx_agent_atom_registry_parent ON public.agent_atom_registry (parent_atom_id); NOTIFY pgrst, 'reload schema';