Skip to main content

Module resolver

Module resolver 

Source
Expand description

Zero-allocation Lexicon Resolver.

Maps 64-bit Quin field values back to human-readable &[u8] slices for serialisation into N-Triples or JSON-LD surface syntaxes.

§Bit layout of a Quin field value

Bit 63  │ Bits 60-63   │ Bits 0-59     │ Interpretation
────────┼──────────────┼───────────────┼──────────────────────────────────────
  1     │ any          │ payload       │ did:q42 topological pointer (identifier module)
  0     │ 0b0000       │ FNV-1a hash   │ IRI / blank-node → lexicon lookup
  0     │ 0b0001       │ integer       │ Inline xsd:integer literal
  0     │ 0b0010       │ scaled × 10⁶  │ Inline xsd:decimal literal
  0     │ 0b0011       │ 0 or 1        │ Inline xsd:boolean literal
  0     │ 0b001        │ embedded hash │ SPARQL-Star embedded triple <<s p o>>
  0     │ 0b1000       │ webizen id    │ Person-controlled WebID agent identifier
  0     │ 0b0101       │ f32 bits      │ Inline xsd:float literal (computed values)
  0     │ 0b0110–0b0111│ reserved      │ Treated as IRI hash (future use)

NOTE: 0b0101 (INLINE_TAG_FLOAT) was formally allocated to inline xsd:float in 0.0.19 to resolve the float-vs-integer tag clash — computed f32 values used to squat on the 0b0001 integer tag. The Webizen VM, frame_layout, and this resolver now agree on 0b0101. See AGENTS.md §4-D and ALGEBRA_MANIFOLD_PLAN.md.

The inline-type encoding is applied by the ingest layer, which masks FNV-1a hash values to 60 bits before storing them so there is no ambiguity with the type-tag bits.

§Zero-allocation guarantee

format_ntriples_to writes directly to any impl io::Write sink and never touches the heap. Callers own the output buffer.

Structs§

Lexicon
Wraps the persistent dictionary block used for hash → IRI resolution.

Enums§

InlineLiteral
An inline-typed literal decoded from a Quin field value’s tag bits (60-62). Allocation-free; the caller formats the lexical/datatype form it needs (N-Triples surface syntax, SPARQL-Results JSON/XML, etc.).

Constants§

INLINE_TAG_BOOLEAN
INLINE_TAG_DECIMAL
INLINE_TAG_FLOAT
Inline xsd:float literal: bits 0-31 are raw IEEE-754 f32 bits. Allocated 0.0.19 to end the float-vs-integer clash (formerly squatted on INLINE_TAG_INTEGER). Canonical home for this tag; frame_layout re-exports it.
INLINE_TAG_INTEGER
INLINE_TAG_MASK
INLINE_VALUE_MASK
Mask over bits 0-59 — the value payload when an inline tag is present.
MSB_FLAG
TAG_EMBEDDED
SPARQL-Star embedded triple tag: indicates the value is a Virtual ID for <>
TAG_WEBIZEN
Webizen identity tag: indicates the value is a person-controlled WebID agent identifier Uses 0x8 prefix for instant identification without dictionary lookup

Functions§

classify_inline_literal
Classify a Quin field value as an inline-typed literal, or None if it is not one (an IRI hash / did:q42 pointer / lexicon entry).
format_nquads_to
N-Quads lines with graph context (zero-heap).
format_ntriples_star_to
RDF-Star N-Triples line (<<<...>>> subject when virtual id).
format_ntriples_to
Serialise quins as N-Triples, writing each line directly to out.
resolve_hash
Resolve a 64-bit Quin field value to its original URI bytes.