Glossary & external refs How the multi-domain, multi-language glossary registry works. File layout, project-level overrides, disambiguation, the resolution algorithm. Multi-domain glossary architecture and how to extend it. Reference > [!TLDR] > Glossary and ext-ref entries live in per-domain files under _oku/glossary/ and _oku/extrefs/. Each project's kit.json activates a subset of domains in priority order and can add local overrides. Resolution walks active domains, falls back through preferred languages, surfaces unknowns via the forward-compat warning indicator. > > - Per-domain files — separate ACID in data-platforms from ACID in chemistry, separate RSD in adhd from RSD in radio. > - A page references an entry with a markdown link — [ACID](#g/ACID) for a glossary term, [Pagefind](#x/Pagefind) for an ext-ref. > - Per-entry multi-language variants — { "en": {...}, "tr": {...} }. The canonical link can differ per language. > - Project kit.json declares active domains + preferred language + project-local entries. Local entries always win on conflict. > - Unknown terms surface in the forward-compat warning indicator; add the entry to project kit.json or push to central. ## File layout {#layout} Central glossaries ship with the kit; projects extend via kit.json or by adding their own domain files. ```text oku/ # the kit repo ├── glossary/ │ ├── data-platforms.json │ ├── web.json │ ├── ai-llm.json │ ├── adhd.json (structural stub — populate as needed) │ ├── doc-tooling.json (structural stub) │ ├── hadith.json (structural stub) │ └── voice.json (structural stub) ├── extrefs/ │ ├── data-platforms.json │ ├── doc-tooling.json │ ├── web.json (structural stub) │ └── ai-llm.json (structural stub) └── ... your-project/ └── docs/ ├── _oku -> /path/to/oku # symlink ├── kit.json # active domains + overrides ├── page-a.html / page-a.md └── ... ``` ## Entry shape {#entry-shape} Each entry is a dict of language → { def, link }. def supports inline HTML (strong, em, br, code) because it's rendered as the tooltip body. The trust boundary is documented in chrome.js — kit-controlled files only. ```json // _oku/glossary/data-platforms.json { "$schema": "https://raw.githubusercontent.com/mmdemirbas/oku/main/kit/schema/glossary.schema.json", "domain": "data-platforms", "version": 1, "entries": { "ACID": { "en": { "def": " Atomicity, consistency, isolation, durability. Transaction guarantees.", "link": "https://en.wikipedia.org/wiki/ACID" }, "tr": { "def": "Veritabanı işlemlerinde atomiklik, tutarlılık, izolasyon, dayanıklılık garantileri." } } } } ``` > [!NEUTRAL] ext-refs use the same shape > _oku/extrefs/ .json uses identical structure — each entry has language variants with name, summary, link. Same resolution algorithm, separate registry. ## Project configuration — kit.json {#project-config} Each project's docs/kit.json declares which domains are active and in what priority order, the preferred language with fallback chain, and any local additions or overrides. ```json // docs/kit.json — Iceberg-team project { "name": "Spark+Iceberg notes", "domains": ["data-platforms", "web", "ai-llm"], "lang": "en", "lang_fallback": ["en"], "glossary": { "data-platforms": { "OurInternalTerm": { "en": { "def": "Defined in this project only." } } } } } ``` ```json // docs/kit.json — personal-notes project in Turkish { "name": "Notlar", "domains": ["adhd", "hadith", "voice"], "lang": "tr", "lang_fallback": ["en"] } ``` > [!TIP] Local entries always win on conflict > When the same term appears in both `kit.json`'s `glossary["data-platforms"]` AND in the central [`_oku/glossary/data-platforms.json`](#f/_oku/glossary/data-platforms.json), the project version is used. Merge happens after the central file loads, so a project override is never silently discarded by a later registry fetch. ## Referencing an entry from a page {#usage} A markdown page cites a registry entry with an ordinary link whose href carries a kit prefix: `#g/` for the glossary, `#x/` for ext-refs. The label is the visible text, the id after the prefix is the registry key. ```text Hover [ACID](#g/ACID) for the definition card. Powered by [Pagefind](#x/Pagefind) — click the card to open the source. ``` `renderLink` rewrites those into ` ` and ` `. Everything downstream — resolution, tooltip, the unknown-entry warning — is shared, so the two prefixes differ only in which registry they search. JSON pages carry the same reference as an inline object inside a paragraph's `content` array: ```json { "kind": "paragraph", "content": [ "Hover ", { "kind": "glossary-term", "term": "ACID", "text": "ACID" }, " for the definition card." ] } ``` The v1 shim rewrites that object to `[ACID](#g/ACID)` before the renderer walks the page, so both forms land on the same element. `{ "kind": "ext-ref", "name": "Pagefind" }` is the ext-ref counterpart. ## Disambiguation — same term, different domains {#disambiguation} When two active domains define the same term, the default is "first matching domain wins", and that is what a link-form reference asks for. Two attributes on the element qualify a single reference: `in` restricts lookup to one domain, `lang` overrides the project's preferred language for that instance — useful when one term in a TR-default project needs an English-source citation. The link form carries the id alone, so a qualified reference writes the element itself in an HTML island: ```text Two senses of the same word: ACID and ACID . ``` The `in` attribute wins over domain order — it reaches a domain that is not first in the project's domains list. ## Resolution algorithm {#resolution} Implemented in chrome.js as __okuKit.resolveGlossary and resolveExtRef. ## Adding new entries {#extending} Two paths — project-local for quick iteration, central PR when the term proves general. > [!SUCCESS] Forward-compat warning surfaces unknowns > When the AI emits a term that's not in any active domain, the warning indicator lights up with code: "unknown-glossary-term". Click to see the missing entry name. Fast feedback that an addition is overdue. ## Bundled starter content {#starter} Seven glossary domains ship with the kit. Three arrive populated with ten entries each; four are empty structural stubs ready to fill in. Ext-refs ship four domains on the same shape: `data-platforms` (7 entries) and `doc-tooling` (5) carry content; `web` and `ai-llm` are empty stubs.