Skip to content

ontos v0.17.0

Choose a tag to compare

@github-actions github-actions released this 11 Nov 03:12
· 30 commits to main since this release
afdec1f

ontos v0.17.0

The codec gains measure, which bounds what a shared value would cost to encode without
expanding it. The Rust core allocates less for shallow values, and TypeScript copyBytes
stores exactly the bytes it validated. The value model, structural identity, the
ontos-codec-v1 bytes, decoding and its limits are unchanged.

Codec: measure a value without expanding it

A value held as a DAG can denote a tree whose encoding is exponentially larger than the
nodes in memory. measure reports three measures of the expanded tree: its canonical
encoded length (encoded_bytes), the number of values in it (occurrences) and how deep it
is nested (height, counted as the decoder's depth limit counts it). It visits each
distinct node once, keyed on the node's identity in memory, and keeps an explicit stack, so
a value of any height can be measured.

The caller states a bound for each measure; none has a default. Each measure saturates at
its bound, so the arithmetic never wraps. If a measure exceeds its bound, the outcome is
over limit and names every exceeded measure in ascending order of the identifiers, with no
numbers. That set depends only on the value and the bounds.

face call over limit
Go codec.Measure(v, codec.MeasureBounds{MaxEncodedBytes, MaxOccurrences, MaxHeight}) *codec.MeasureError
Rust ontos_codec::measure(&value, MeasureBounds { max_encoded_bytes, max_occurrences, max_height }) Err(MeasureError)
TypeScript measure(value, { maxEncodedBytes, maxOccurrences, maxHeight }) throws MeasureError
Python measure(value, *, max_encoded_bytes, max_occurrences, max_height) raises MeasureError

A Rust Value owns its children and cannot share a subtree, so its measure is a plain
walk with the same saturation and results. The definition is
codec §10, the decision is
design record 0008, and
vectors/codec-measure.json pins 31 cases for every face,
including a doubling chain whose encoding is 5·2^64 − 2 bytes.

Rust: no work stack for atoms and atom-only tuples

Value's Clone, PartialEq and Hash handle an atom, or a tuple whose items are all
atoms, directly instead of allocating a heap work stack. The codec's encode_into writes
such values directly too. Deeper values keep the iterative walk, so stack safety is
unchanged, and bytes, equality and the Hash write sequence are identical. Cloning two
atoms and encoding a tuple of them now takes 7 allocations instead of 13.

TypeScript: copyBytes reads the caller's bytes once

copyBytes, and with it new Atom(...), stores exactly the bytes that passed validation.
A caller's getter, iterator or redefined view geometry can no longer change them. A
number[] is read once, index by index. Binary inputs are brand-checked and their geometry
is read through the built-in accessors, which run no caller code. A genuine Uint8Array
keeps a fast path, so decoding is as fast as before. The deliberate behaviour changes:

  • a cross-realm ArrayBuffer is accepted;
  • a detached or out-of-bounds view is a TypeError for every input kind;
  • a result never shares memory with a SharedArrayBuffer;
  • a Proxy reporting a non-array length gets a RangeError;
  • error messages no longer run caller code.

Upgrade together

Every published package carries version 0.17.0. Keep all ontos dependencies in one Rust
graph on the same compatible crates.io version: a 0.16 core and a 0.17 core define
different Rust Value types. See distribution for the package names
and installation examples.

The root Go tag v0.17.0 and the nested tags projection/deixis/go/v0.17.0 and
wire/go/v0.17.0 name the same release commit. The deixis projection and the Wire profile
still pin deixis 0.6.0; consumers of core, codec, data or data-json gain no deixis
dependency.

The release workflow now binds npm provenance to the certified dispatch and keeps the
checked-out release source as its own dependency, so a rehearsal can qualify the exact
archives a later publish signs.