ADR-0051: In-Text Document Links (doc: Scheme)¶
- Status: accepted
- Date: 2026-07-06
- Deciders: Nicolas Burri ("use the recommended options for L-1 to L-4")
- Refines: ADR-0049 (relations — L-4 auto-sync), ADR-0050 (CM6 editor hosts the authoring support); extends the rich-content markdown policy (checkpoint C-3a; MarkdownService is the single policy seam)
Context¶
Authors need to link documents from within document text, without knowing ids by hand, stably across folder moves and title changes, inside a record format that stays human-readable and diffable forever (the frozen markdown source is the controlled record).
Decisions¶
- L-1 — Target identity: the human document id. Link form
[link text](doc:QMS-OPS-SOP-001); optional scope-qualified formdoc:SCOPE-CODE/DOC-IDfor explicit cross-scope targets. Human ids are never reissued or changed; folder moves and title renames cannot break a link. Derived copies retain their source id, so bare-id resolution is same-scope first, then the id's other visible holders (base-readability order). Row UUIDs rejected: absolute but destroys source readability/diffability. The link TEXT is authored content and freezes verbatim (no live retitling inside frozen records — determinism wins; the resolver may show the current title as a tooltip). - L-2 — Authoring support: in the CM6 editor,
[[triggers an autocompletion fed byGET /api/documents/lookup(the reference-typeahead endpoint); accepting inserts[Current Title](doc:ID). - L-3 — Rendering/navigation: the MarkdownService link policy gains the
doc:scheme — rendered as an in-app link resolving through the caller's own RLS-checked API at view time (navigate to the latest visible version; current-title tooltip). Unresolvable or invisible targets render as inert styled text: no error, no existence leak. All other schemes keep their existing policy. - L-4 — Freeze-time link→relation sync (second slice): on SUBMIT the body is scanned for
doc:links; each resolvable target is synced as a system-maintainedreferencesrelation flaggedfromText(created/removed to mirror the frozen body per round; manual relations untouched; audited like relation changes). In-text citations thereby appear in the References section, trace matrix, and completeness evaluation.
Consequences¶
- The
doc:scheme becomes part of the controlled record format — documented here, versioned by this ADR; renderers must treat unknown schemes as inert (already the DOMPurify posture). - Ambiguity policy (same-scope precedence) is deliberate and simple; the qualified form exists for the exceptional explicit case.
- L-4 extends the relationship table usage (a
fromText/origin marker) — small migration with the slice; requirements rows → v1.6 pending. - Sequencing: typeahead/lookup slice → traceability-page redesign (a–d) → L-1..L-3 → L-4.