Reducers

Three reference implementations of the Vela state-transition function, kept at equal weight.

Three reducers, one protocol. Each compiles the same canonical event into the same state mutation. Conformance is the share of the public test-vector suite a reducer currently passes at protocol version v0.48.0. The Rust crate is the normative reference; the Python and TypeScript reducers track it.

Specimens Three reducers · one transition function

  1. Reference implementation

    vela-rs

    Rust

    100 % conformance
    
                  use vela::{StateEvent, Status, Reducer};
    
    let event = StateEvent::accepted_transition()
        .frontier("alzheimers.neurovascular.bbb")
        .finding("vf_06cfcbe7c449d86a")
        .from(Status::Contested)
        .to(Status::Replicated)
        .evidence(["ev_perturb_441", "ev_cohort_118"])
        .sign(&keypair)?;
    
    state.apply(&event)?;
                

    package vela

    The normative reference. Test vectors are derived from this implementation; other reducers track it.

    Source
  2. Researcher binding

    vela-py

    Python

    96 .4 % conformance
    
                  from vela import StateEvent, Status, apply
    
    event = StateEvent.accepted_transition(
        frontier="alzheimers.neurovascular.bbb",
        finding="vf_06cfcbe7c449d86a",
        from_=Status.CONTESTED,
        to=Status.REPLICATED,
        evidence=["ev_perturb_441", "ev_cohort_118"],
    ).sign(keypair)
    
    apply(state, event)
                

    package vela-py

    PyO3 bindings on top of vela-rs plus pure-Python ergonomics for notebooks and pipelines.

    Source
  3. Read-side reducer

    vela-ts

    TypeScript

    81 .2 % conformance
    
                  import { StateEvent, Status, verify } from "@vela/core";
    
    const event = StateEvent.acceptedTransition({
      frontier: "alzheimers.neurovascular.bbb",
      finding: "vf_06cfcbe7c449d86a",
      from: Status.Contested,
      to: Status.Replicated,
      evidence: ["ev_perturb_441", "ev_cohort_118"],
    });
    
    verify(state, event); // read-side reducer
                

    package @vela/core

    Read-only verifier and event reducer for browser, edge, and Node. Suitable for atlases and viewers, not yet for canonical commit.

    Source

Install

Pick a reducer for your environment. The Rust crate is the canonical commit path: anyone applying state transitions for a frontier should run vela-rs (directly or via the Python binding). The TypeScript reducer is read-only and is suitable for atlases, viewers, and verification at the edge.

  1. vela-rs Rust

    Cargo
    # Cargo.toml
    [dependencies]
    vela = "0.48.0"
    
    # or from source
    cargo add vela@0.48.0
    Source on GitHub
  2. vela-py Python

    uv / pip
    # uv (recommended)
    uv add vela
    
    # pip
    pip install vela==0.48.0
    Source on GitHub
  3. vela-ts TypeScript

    npm / pnpm / bun
    pnpm add @vela/core@0.48.0
    
    # or
    npm install @vela/core@0.48.0
    bun add @vela/core@0.48.0
    Source on GitHub

Conformance

The public test-vector suite at vela-science/vela/test-vectors is the single source of truth for what "passes" means. Each test vector pairs a canonical event with the state mutation a conforming reducer must produce. The Rust reducer passes the whole suite by construction; the Python and TypeScript reducers report their pass rate against the same vectors at every release.

Reducer Conformance Vectors Version
vela-rs Rust 100.0% 1480 / 1480 v0.48.0
vela-py Python 96.4% 1427 / 1480 v0.48.0
vela-ts TypeScript 81.2% 1202 / 1480 v0.48.0

Test-vector counts taken from the suite tagged vectors/v0.48.0. The number grows monotonically with each protocol version; reducers must pass every prior version's vectors plus the new ones.

Anchor copied