Files
accounted/supabase/migrations/20260527000000_agent_atom_registry_parent_atom_id.sql
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

30 lines
1.5 KiB
SQL

-- 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(<child id>) 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';