Inbound reference counts script

This declarative CONSTRUCT script recomputes, every 60 seconds, the number of documents that depend on each Document in the Index. The result materialises into a sdg:DerivedAuxGraph at https://docs.cida.no/registry/metrics/inbound-refs.

Purpose

Inbound reference counts power several demo surfaces:

  • A "hot docs" view in the Phase 1 editor-test client ("which onboarding docs are referenced most by other teams?").
  • The presentation-mode cross-deck discovery ("which decks cite this claim?").
  • Phase 4 staleness heuristics ("high-inbound-count docs warrant stricter review gates").

Why a CONSTRUCT script

The computation is pure — deterministic, rebuildable from the authoritative graph, no external dependencies. SPARQL CONSTRUCT expresses the logic declaratively; the registry runs it natively with no sandbox concerns. This is the lightweight script kind Phase 1 ships alongside code-at-init scripts.

Output graph

  • IRI: https://docs.cida.no/registry/metrics/inbound-refs
  • Kind: sdg:DerivedAuxGraph
  • Write authority: only this Script's service identity. Gate 2 enforces — an agent submitting a transaction that writes this graph without owning it will be declined.
  • Overwritten each run; clients reading should treat the data as eventually-consistent up to 60 seconds.

Not in Phase 1

  • Incremental mode (recompute only affected docs on each publish) — the hook + script pair ships in Phase 4.
  • Horizontal scale / leader election — Phase 1 assumes a single registry process.
Inbound reference counts script — Sparqdown Docs