D68 — A graph records the packs it is built on, and what it is about¶
- Status: Accepted — amends D54 (where the title comes from), D47e (what a dataset pins) and D65 (which packs load); amended by D68b (a dataset is checked with the packs it pins)
- Date: 2026-11-15
- Origin: browsing the UK graph in Datasette: its front page was titled with the politics pack's words
- Area: schema
Decision¶
kg init --pack PACK@VERSION … --title … --about …records, in the graph's ownmetatable:packs: the packs named, with every pack they import;titleandabout.
Run again, it changes them.
- A graph loads only the packs it recorded. The CLI, the MCP server, a hosted
peer and the importers all load a graph's schema the same way
(config.graph_schema). A graph that recorded nothing loads every pack, as
before. The /data pages load them again each time they refresh, so packs
recorded while a peer runs need no restart.
- Refusals:
- An unknown pack is refused, naming the packs there are.
- Recording a set without a pack whose types the graph holds is refused,
naming the type and its pack, and nothing is recorded.
- A pack's imports: now say what it needs. datacenter@0.1 imports
politician-uk@0.1, because a permit is decided_in a committee's vote
(D62) and one of its queries reads v_vote. A graph recording the data-centre
pack therefore loads the politics types too.
- Title and about, in order:
1. the dataset's (shared by everyone working on it);
2. what the graph recorded;
3. kg.yaml's;
4. the first sentence of the packs in use (D54).
The Datasette front page, the static site and the research brief all read them
this way (views.topic).
- kg dataset init pins the packs the graph recorded, not every pack that
happens to be in the folder, and carries the title and about in the order
above: a dataset the graph already belongs to, then what the graph recorded.
- kg bundle export refuses an entity of a pack the dataset neither pins nor
imports through a pin, since a collaborator who records only the pinned
packs could not read it. The
refusal says to add the pack to packs: in dataset.yaml; everyone who then
pulls is told to load it.
- kg init --pack records the packs it is given without loading the old ones,
which may clash or be gone. A held entity is checked against the pack that
wrote it.
- Only the packs a graph records, and what they import, are read. A pack
half written elsewhere in the folder stops only the graphs that use it.
- A dataset is checked against every pack. kg bundle verify, kg rebuild
and their MCP ops load every pack, whatever the server's own graph recorded:
a dataset is not that graph.
- What each command reports:
- kg whoami and kg init say which packs the graph records.
- kg schema show says whether its list is the recorded one or every pack.
Why¶
- kg.yaml is per person, not per graph. It lives in
~/.kgand every graph on the machine shares it, so a title written there named every graph alike. - Without a title, the biggest pack named the graph. On the UK graph that meant "UK politicians", because the votes on data centres brought in 1,112 people against 317 sites.
- A graph about data centres should be able to say so, and leave out types it never uses.
- The graph is the one thing that is always present when kg reads or writes, so it is where its own schema choice belongs.
Rejected alternatives¶
- A
packs:key in kg.yaml: it is shared by every graph on the machine. - Prompting in
kg init: setting up is led by an agent (the kg skill), which asks the person and passes flags. The CLI stays scriptable. - Moving
voteinto_shared: the dependency is real and the politics pack owns the type, so declaring the import says what is true at the smallest cost.
Consequences¶
- An existing graph keeps loading every pack until someone records its packs.
kg rebuilddoes not yet record the dataset's pinned packs in the new graph, so a rebuilt graph loads every pack.Pack.importswas only a check before; now it also decides what loads with a pack.