Skip to main content

Crate raiv

Crate raiv 

Source
Expand description

Pure, bounded agent checkpoint primitives.

Raiv preserves an agent’s behavioral continuity across short executions. Each accepted step becomes a small, content-addressed checkpoint: canonical DRISL/CBOR records linked by fixed-profile CIDs, so identical state always reproduces identical bytes and identifiers.

This crate is the portable no_std + alloc Core. It decodes and validates records under explicit limits, restores checkpoint closures (graph), projects bounded model context (projection), runs the RAM Activation loop (activation) and composes verified commit candidates (commit). It performs no I/O and grants no execution authority: storage, inference transport and trusted acceptance belong to the host.

Working memory is a sparse object edited by JSON-merge-style patches:

use raiv::{
    format::{DecodeLimits, ModelValue, ValueRef},
    limits::Limits,
    memory::Memory,
};

let bounds = DecodeLimits::default();
let goal = [("goal", ValueRef::Text("ship 0.0.2"))];
let mut memory = Memory::encode(&[("intents", ValueRef::Map(&goal))], &bounds)?;
let before = memory.cid();

// A model-issued patch, as canonical CBOR: add a plane, keep the rest.
let step = [("next", ValueRef::Text("write the changelog"))];
let patch = ModelValue::encode(ValueRef::Map(&[("tactics", ValueRef::Map(&step))]), &bounds)?;
memory.apply_patch(patch.as_bytes(), &Limits::default())?;

let planes = [("intents", ValueRef::Map(&goal)), ("tactics", ValueRef::Map(&step))];
assert_eq!(memory, Memory::encode(&planes, &bounds)?);
assert_ne!(memory.cid(), before); // Every accepted change has a new, reproducible CID.
assert_eq!(
    memory.json().to_string(),
    r#"{"intents":{"goal":"ship 0.0.2"},"tactics":{"next":"write the changelog"}}"#
);

Modules§

activation
Owns RAM call-count admission and tool eligibility, not the completed live lifecycle. Count ceilings/debits do not authorize inference, host effects or execution-unit spend.
boundary
Boundary checkpoint data, not graph closure, tool authorization or accepted HEAD.
budget
Budget-admission data shape, not trusted-host admission or budget enforcement.
command
Owns the immutable Command data contract, not tool planning, dispatch, or host authority.
commit
Immutable candidate checkpoint data, not authoritative HEAD, placement or dispatch.
definition
Owns Definition and descriptor schema validation, not planner execution or host authority.
episode
Episode block data and ordered references, not typed graph restoration or lifecycle history.
format
Owns DASL identifiers and canonical wire/model-value codecs; no storage or authority. Typed record schemas live with their domain owners.
graph
Owns bounded typed checkpoint inspection/restoration, not I/O or host authority.
identity
Owns the pinned domain-separated episode/action/command identities, not registration, provider IDs, transaction nonces, canonical HEAD, or execution authorization.
input
Activation-input block data, not prepared-input provenance, freshness or phase admission.
limits
Owns the complete policy-limit data contract and demo baselines, not budget accounting.
memory
Owns sparse semantic Memory blocks and atomic object patches, not host authority.
position
Normalized host coordinates, not clocks, finality evidence, or state blocks.
preparation
Owns prepared-packet data binding and borrowed preparation checks, not host provenance. No planner/inference, counters/units consumption, checkpoint or ready Activation here.
projection
Owns retained Episode/action views and transient history-fragment encoding, not activation. Views borrow validated checkpoint data; encoding is model data, not authority or a checkpoint.
receipt
Terminal executor data, not host provenance, phase admission, or execution authority.
state
AgentState root data, not restored graph consistency, authoritative HEAD or host admission.
tools
Owns Definition-bound callable registration metadata, not tool execution or host approval. Native callback purity/schema honesty is a trusted-code contract, not a sandbox proof.
usage
Usage-report data, not a complete lifetime expense ledger or budget consumption.