Skip to main content

Module names

Module names 

Source
Expand description

Unknown names (spec/surface §1.5, 4.6; port of the reference’s oqx-js/names.ts). A query that projects, filters or orders by a name no row of the scope’s kind can carry — select path, target from links (links have dst_path), where preview != "" on blocks — used to run silently: an absent column in every row, a predicate true or false of every row. This pass judges every name the query reads (oqx’s references, AST.md §5b) against the VOCABULARY of the row kind it is read from, statically — before any row is read, so the verdict never depends on the query’s own filter — and either records a hint or refuses the query.

The three tiers of a name at a scope whose kind is known:

  1. an engine attribute, handle or relation of the kind — known;
  2. an authored property at least one live object of the kind in this repository carries (docs: a frontmatter or inline key — stage on three processes is enough; blocks and nodes: a key of a live row’s attrs, the bare-name read of those kinds) — known, however partial;
  3. a name no object of the kind carries — the complaint.

Severity: links has a closed row shape (no authored data reaches a link row), so a tier-3 name there is filter_invalid; docs, blocks and nodes are open — on a read the result carries one hint per offending name and the rows still come back; a write selector (the AST entry, UnknownNames::Refuse) is refused, since a name no row carries would select every row. A repository with no live object of the kind has no vocabulary: the check is skipped for that kind. The vocabulary is read once per (repository, kind) and cached on the repository’s head commit (MAX(commits.seq)), the one thing every property or attrs change moves — the cache (VocabularyCache) lives beside the store it describes (the Surface holds one; a bare query call judges with a cache of its own).

Structs§

Vocabulary
The authored vocabulary of one kind in one repository.
VocabularyCache
The vocabulary cache of one store: per repository, keyed on the head commit. Keep it beside the store it was read from.

Enums§

UnknownNames
What to do with a tier-3 name on an open kind: record it in hints (every read) or refuse the query (a write selector).

Functions§

check_names
Judge every name the query reads. Returns the hints (one per offending name of an open kind, first-reference order, deduplicated) under UnknownNames::Hint; fails with filter_invalid for a tier-3 name on a closed kind in either mode, and for one on an open kind under UnknownNames::Refuse.
edit_distance
Optimal string alignment distance (Damerau–Levenshtein with adjacent transpositions, each edit 1), over code points.
handles
The self and reach-through handles of a kind and the kind of the row each reaches (§1.2).
kind_of_scope
The kind of the rows a scope holds, from its row chain (AST.md §5b); None when the chain reaches a value no kind describes.
nearest
The nearest match of name among candidates (§1.5): case-insensitive; a candidate qualifies when its distance is ≤ 2, or when one of the two is a substring of the other and the shorter has at least three characters. One typo (distance 1) wins first; then a substring match outranks a distance-2 match (via → via_id, not id; dst_pth → dst_path, not dst); within a class the lowest distance, then the shorter candidate, then alphabetical. A name under three characters gets no suggestion (it is within distance 2 of nearly anything, and too short for the substring rule). None when nothing qualifies.
relations
The relations of a kind, in the §1.2 order, and the kind of the rows each yields.
vocabulary
The vocabulary of a kind in a repository: (present, keys) — the authored keys in key order (the SQL runs only when a name is not intrinsic).