Skip to content
verifiablyPublic

About

Vocabulary identifiers pinned to releases: the reference layer above nodes

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

refs

Vocabulary identifiers pinned to releases: the reference layer above nodes

A facet (refs/about) that lets a node carry identifiers drawn from vocabularies, with a CURIE grammar parsed against a pinned Bioregistry release and each identifier optionally pinned to a vocabulary release. Python and TypeScript over one shared format, layered above nodes and below the domain profiles. refs only parses, validates and records identifiers; resolving one is quarry's job.

Authority: docs/STANDARD.md

Part of verifiably: verifiably builds understanding of the world from small, reproducible data analyses: each one a precise question asked of real data, recorded so anyone can run it again, with the data leading and unverified claims kept out.

atoms · nodes · refs · beliefs · science · autonomy

Install

Not published to PyPI or npm yet. A consumer takes a path dependency on a checkout of this repository: python/ is the distribution verifiably-refs (import refs), ts/ is @verifiably/refs. Both depend on the sibling nodes checkout.

just setup links ../nodes when the checkout is a git worktree, installs both packages and copies registry/ into them. A fresh clone also runs git config core.hooksPath .githooks. Checkout-local .tt.toml disables automatic broad checks (just check-code, just test-fast, just test) so local just check and just gate run just check-hygiene and skip broad targets while GitHub Actions (.github/workflows/ci.yml) runs both suites and static checks on every branch push. Use just test-full (TT_FORCE=1 just test), TT_FORCE=1 just gate, or TT_FORCE=1 just check for explicit forced local verification.

Usage

Parse a CURIE against the pinned registry, then build a refs/about payload and check it with the invariant a kind carries. A prefix that declares a vocabulary (openalex.topic below) needs a release on each reference; one that does not (mesh) takes none. Python:

from nodes.core.errors import FacetError
from nodes.core.node import Node
from refs import RefsError, Registry, parse, parse_vocabularies
from refs.facet import FACET, about_facet, build_about

registry = Registry.default()
print(parse("PMID:21885717", registry))  # pubmed:21885717

try:
    parse("HGNC:KIF14", registry)  # hgnc takes the numeric id; symbols are hgnc.symbol
except RefsError as error:
    print(error.kind)  # malformed

vocabularies = parse_vocabularies(
    {"openalex.topic": {"issuer": "external", "release": "2026-06-26"}}, registry
)
check = about_facet(registry, vocabularies)

about = build_about([("openalex.topic:T10001", "2026-06-26"), ("MESH:D009101", None)], registry)
print(about)  # {'entries': [{'id': 'mesh:D009101'}, {'id': 'openalex.topic:T10001', 'release': '2026-06-26'}]}
check(Node(id="topic:t", kind="topic", title="t", facets={FACET: about}))  # passes

stale = {"entries": [{"id": "openalex.topic:T10001"}]}
try:
    check(Node(id="topic:t", kind="topic", title="t", facets={FACET: stale}))
except FacetError as error:
    print(error)  # topic:t: refs/about: 'openalex.topic:T10001': openalex.topic is a vocabulary, so a release is required

TypeScript, the same contract with a camelCase API:

import { FacetError, makeNode } from "@verifiably/nodes";
import { FACET, RefsError, Registry, aboutFacet, buildAbout, parseCurie, parseVocabularies } from "@verifiably/refs";

const registry = Registry.default();
console.log(String(parseCurie("PMID:21885717", registry))); // pubmed:21885717

try {
  parseCurie("HGNC:KIF14", registry);
} catch (error) {
  if (error instanceof RefsError) console.log(error.kind); // malformed
}

const vocabularies = parseVocabularies({ "openalex.topic": { issuer: "external", release: "2026-06-26" } }, registry);
const check = aboutFacet(registry, vocabularies);

const about = buildAbout([["openalex.topic:T10001", "2026-06-26"], ["MESH:D009101", null]], registry);
console.log(JSON.stringify(about)); // {"entries":[{"id":"mesh:D009101"},{"id":"openalex.topic:T10001","release":"2026-06-26"}]}
check(makeNode({ id: "topic:t", kind: "topic", title: "t", facets: { [FACET]: about } })); // passes

const stale = { entries: [{ id: "openalex.topic:T10001" }] };
try {
  check(makeNode({ id: "topic:t", kind: "topic", title: "t", facets: { [FACET]: stale } }));
} catch (error) {
  if (error instanceof FacetError) console.log(error.message); // topic:t: refs/about: "openalex.topic:T10001": openalex.topic is a vocabulary, so a release is required
}

A kind opts in by listing refs/about among its facets and adding the invariant; refs ships the facet and the invariant, never a kind. Self-issued vocabularies are declared with a LocalScheme (Registry.with_local); the standard has the details.

A UCUM code is checked for syntax by parse, and against a table the caller supplies by check_reference, which also checks the release. The table comes from the holder's own ucum-essence.xml; refs ships none:

from pathlib import Path

from refs import RefsError, Registry, UcumTables, check_reference, load_ucum_essence, parse_vocabularies

registry = Registry.default()
vocabularies = parse_vocabularies({"ucum": {"issuer": "external", "release": "2.2"}}, registry)
tables = UcumTables([load_ucum_essence(Path("ucum-essence.xml"))])  # version 2.2

print(check_reference("ucum:km/h", "2.2", registry, vocabularies, tables))  # ucum:km/h
try:
    check_reference("ucum:hz", "2.2", registry, vocabularies, tables)  # the symbol is Hz
except RefsError as error:
    print(error.kind, error.position)  # unknown_unit 5

What refs does not do

refs parses, validates and records identifiers, offline. It never touches the network, and it ships and holds no vocabulary's contents: it owns identifier grammars, including a grammar whose terminals are a release's table, which the caller supplies. Whether an enumerated identifier exists in a release remains the holder's check. A UCUM code is checked against a table the caller supplies; whether a qudt.unit name or an HGNC id exists in a release is the holder's check.

Not in refs Lives in
Resolving an identifier to a label, term, ancestors or record; fetching anything quarry
Checking that an enumerated identifier (a qudt.unit name, an HGNC id) exists in a held release the holder of that release (beliefs, quarry)
Joins and indexes across corpora a corpus-joining layer above the profiles (not yet built)

Consumers

  • quarry (Python): CURIE parsing, pattern checks and registry collision reporting across its scientific resource catalog.
  • lit (Python): refs/about facet validation and payload construction on paper nodes against declared vocabularies.
  • Intended consumers (not yet wired): beliefs, science and mindful.

Layout

Path Contents
docs/STANDARD.md The normative portable contract: the pattern dialect, CURIEs, the registry, vocabularies, the facet, named grammars and UCUM, the reference check.
python/ The Python distribution (verifiably-refs); imports are refs.
ts/ The TypeScript package (@verifiably/refs).
fixtures/ The shared conformance oracles both packages read.
registry/ The vendored Bioregistry snapshot in the pattern dialect, SOURCES.toml, the shared local schemes, and grammars.toml (which prefixes use a named grammar); each package carries a gitignored copy.
tools/ Files vendored from ops (see tools/README.md) and vendor_registry.py, this project's own.
.githooks/ The pre-commit and pre-push hooks.

Documentation

License

MIT, see LICENSE.

About

Vocabulary identifiers pinned to releases: the reference layer above nodes

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages