ReactiveDag.Attestation.Scope (reactive_dag v0.16.0)

Copy Markdown View Source

WHAT an attestation is about — one row, or the set a filter selects.

{:key, key}          an assertion about one row of a cell (per-grain)
{:filter, key_scope} an assertion about the SET a filter currently
                     selects (a `t:ReactiveDag.Tuple.key_scope/0`)

The filter form is what carries set-level claims — "these are ALL of my machines" is about the subset an owner == me filter selects and its boundary, which no per-member mechanism can express (a member nobody entered has no row to be missing from).

Canonical serialization

A scope is stored on the record as text, and that text is load-bearing twice: it is the IDENTITY of what was signed (stances group by it), and for a filter it is re-parsed at evaluation time to re-select the current set. So the serialization must be canonical — same scope, same text, always — and carries a version segment so a format change is DETECTABLE. This build accepts only v1: parse/1 raises on any other version (deliberately — a scope that cannot be re-selected must not silently mis-group). Cross-version tolerance lives one level down, in ReactiveDag.Attestation.Basis, where an unknown digest version degrades to re-ask rather than an error.

Fields are joined with the unit separator (0x1F), which the spine's key grammar has no business containing — unlike | or :, which hosts routinely use inside keys.

Summary

Functions

Parse canonical text back to a scope. Raises on an unknown form.

The rows a scope selects from rows (spine-row maps with :key). This is the in-memory selection the evaluation uses; select_db/2 is its SQL twin.

Read the rows a scope selects for cell_id straight from the spine.

Serialize a scope to its canonical, versioned text form.

Types

t()

@type t() :: {:key, String.t()} | {:filter, ReactiveDag.Tuple.key_scope()}

Functions

parse(other)

@spec parse(String.t()) :: t()

Parse canonical text back to a scope. Raises on an unknown form.

select(arg, rows)

@spec select(t(), [map()]) :: [map()]

The rows a scope selects from rows (spine-row maps with :key). This is the in-memory selection the evaluation uses; select_db/2 is its SQL twin.

select_db(arg, cell_id)

@spec select_db(t(), String.t()) :: [map()]

Read the rows a scope selects for cell_id straight from the spine.

serialize(arg)

@spec serialize(t()) :: String.t()

Serialize a scope to its canonical, versioned text form.