Skip to content

About

Unified Rust persistence for the CIRIS Trinity — signed events, time-series, runtime state. AGPL-3.0-or-later.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3,497 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CIRISPersist

CIRISPersist is the storage layer of the CIRIS federation. It is a Rust crate, also shipped as a Python wheel, that stores signed statements, presents the rows it holds to ciris-kernel, and serves the Kernel's answers over them.

Three components share the work, and persist decides the least:

  • CIRISVerify decides whether one statement is valid: its signatures, its payload and its family's form.
  • ciris-kernel decides every rule that reads more than one row: seats and rosters, audience, consent, withdrawals, MLS standing, the genesis in force. Its rules are the CIRIS Constitution's.
  • Persist keeps the bytes, indexes what each row names and what it waits on, gathers the held rows an answer needs, hands them to the Kernel and serves the answer. It also owns the stores themselves (below).

Persist runs on PostgreSQL or SQLite (a file, or in memory) and behaves the same on both, as an enforced invariant: store::parity fails the build when one backend's write door runs a gate, or an order of gates, the other does not and no declared divergence explains why.

The crate version, dependency pins and release history are in Cargo.toml and CHANGELOG.md. This file names no version numbers, so it never goes stale against them.

How it works

Everything above a storage layer produces claims: an agent's reasoning trace, a witness's assurance, a peer's replicated row, an operator's action. Each arrives as a signed statement (a COSE_Sign1 over deterministic CBOR).

One statement door. Engine::put_edition2_statement (and apply_replicated_statement for a peer's row) applies a size cap and persist's one-row checks, then asks Verify whether the statement is valid, waiting or invalid. An invalid statement is refused with a typed error. A statement that names a key record, a row or a voice this node does not yet hold is kept and answered Pending: it counts once what it waits on arrives, with no second offer. Waiting is not refusal.

Authority is answered at the read. A question such as may this key assert an age-assurance rung about someone else? or may this peer be served this row? is not settled when the row is written. Persist gathers the held, Verify-checked rows the answer needs and presents them to the Kernel, which answers over exactly those rows, or says Waiting or Undecided. No verdict is written back to a table, and nothing relies on a flag, a token or a boolean a caller passes in: there is no "trusted caller" path.

In the source, src/present/ maps a stored row onto the views the Kernel reads and decides nothing. src/ask/ holds the statement door (ask::admit), the readings that return the Kernel's answer (ask::seats, ask::audience, ask::consent, ask::root, ask::mls), and the row drafts a host signs (ask::produce).

What it provides

area what you get
Statement store and directory Hybrid (Ed25519 + ML-DSA-65) key records and signed statements, indexed by family, subject, signer and named row, append-only, with what each held row is waiting on.
Readings The genesis in force, seats and rosters, audience ("may this peer receive this row?"), consent and MLS standing, each the Kernel's answer over the rows this node holds.
Consent and erasure Consent is the Kernel's reading over signed rows, not a flag on a row. Once an admitted withdrawal is held, the bytes it covers leave the disk, not only the reads.
Bytes and sealed content Inline and replicated blobs, kept only when they hash to the row that names them; content keys wrapped to the recipients the Kernel's seat reading names.

Also in the crate: the signed reasoning-trace log with its scrubber, a hash-chained audit log (RFC 6962 Merkle), the memory graph, telemetry, secrets at rest, fountain-coded content, and the lens schemas.

Persist signs only with the composite ML-DSA-65 + Ed25519 signature. There is no classical-only signing path.

Optional parts are Cargo features (postgres, sqlite, pyo3, cirisgraph, cirisaudit, telemetry, secrets, server, tls, and others). docs/FEATURE_MATRIX.md lists them and how CI covers each combination. The Python wheel ships the feature set listed under [tool.maturin] in pyproject.toml.

Pins

Verify and the Kernel are pinned by git tag in Cargo.toml: the Verify crates at one shared tag, ciris-kernel at its own kernel-v* tag. The Python wheel requires the matching ciris-verify range. A consumer that also depends on Verify pins the same tag, or its lockfile carries two copies of the crypto crates.

When not to use it

  • You want a general-purpose database. Use PostgreSQL.
  • You want to swap the rules. With OPA or Cedar you can. Here the rules are the Kernel's, at the pinned tag.
  • You want a store that trusts what an upstream service admitted. Persist does not, by design: every statement is checked on this node.
  • You need horizontal sharding. Persist is a library, not a service.
  • You are upgrading a pre-62 store in place. A v62 node starts a fresh mesh; FSD/v62_release/ADOPTION_62.md lists each retired call and its replacement.

Standards it builds on

  • Statements: COSE (COSE_Sign1) over deterministic CBOR, as CIRISVerify defines the edition.
  • Audit log: RFC 6962 Merkle trees, from CIRISVerify.
  • Erasure coding: RFC 6330.
  • Post-quantum signatures: FIPS 204 (ML-DSA-65), paired with Ed25519.
  • Group messaging state: MLS (RFC 9420) rows, whose standing the Kernel reads.
  • Verifiable append-only state: the ground immudb, Trillian, Rekor and IETF SCITT stand on.

What is different

  1. The rules are the Constitution's, run by the Kernel. Persist decodes the vendored Constitution tables and hands them to the Kernel. It keeps no rule table of its own.
  2. A row that cannot count yet is held, not lost. It names the rows it lacks, and counts when they arrive.
  3. Consent is a reading over signed rows, not a column.
  4. Answers are scoped to what this node holds. "No grant held here" is never reported as "no grant exists".
  5. Backend parity is enforced. SQLite and PostgreSQL run the same test bodies through the real write path.

The trade-offs

  • You cannot swap the rules. A governance change arrives as a new Kernel tag or Constitution table set, adopted in a persist release.
  • Downstream cannot run a different rule set, so every tightening is a coordinated adoption across consumers. The CHANGELOG records what each release changed and what each consumer must do.
  • A check is only as good as its witnesses. The load-bearing ones are mutation-tested, but a check can still pass over a case nobody thought to test.

Validation and review

Independent conformance. CIRISConformance is a separate suite that drives the real built wheel, never a mock. Its findings have become fixes here, for example an admission bypass where a raw emit carrying only the constitutional marker skipped the single-owner gate. That is the kind of hole an in-repo suite misses: a gate that passes its author's fixtures.

In this repository. Several thousand tests across the feature matrix, each run on both backends; property tests; mutation testing of the load-bearing gates (docs/MUTATION_TESTING.md); source gates that read the code itself (docs/FROM_DISK_GATES.md); and a benchmark trend dashboard updated on every commit to main. Benchmark figures are kept on the dashboard, not in this file.

External review: none of this crate yet. Two external reviews of the CIRIS stack exist and neither examines CIRISPersist. The public one, at towards-alignment.com, is an alignment assessment, not a security audit, and covers Accord, CIRISAgent, Verify, Lens and Proxy. The other is not public and does not cover this crate either.

Treat every security property described here as a claim backed by our own tests, one independent conformance suite and a published threat model, not as audited. An adversarial reader is worth more to us than a pull request.

Using it

Rust

Add the crate from its git tag with the backend features you need. This snippet is compiled in CI as examples/readme.rs:

use ciris_persist::signing::{LocalSigner, LocalSignerConfig};
use ciris_persist::Engine;
use std::sync::Arc;

async fn open_node() -> Result<(), Box<dyn std::error::Error>> {
    let signer = Arc::new(LocalSigner::from_config(&LocalSignerConfig {
        key_id: "my-node".to_owned(),
        key_path: "/run/keys/ed25519.seed".into(),
        // Both halves are needed: persist signs only the composite.
        pqc_key_id: Some("my-node-mldsa".to_owned()),
        pqc_key_path: Some("/run/keys/ml_dsa_65.seed".into()),
    })?);

    // Migrations run as part of construction; the Engine is ready to use.
    let engine = Engine::with_signer(signer, "sqlite:///./node.db").await?;
    let _ = engine;
    Ok(())
}

Python

The wheel is an abi3 build for Python 3.10 and later. It is built by CI from each release tag (maturin build); it is not published to PyPI.

import ciris_persist as cp

engine = cp.Engine(dsn="sqlite://./agent.db", signing_key_id="agent-ed25519")
engine.register_consumer("my-adapter", ["cirisgraph"])
summary = engine.receive_and_persist(request_body_bytes)

The backend is chosen by the DSN scheme (postgres://… or sqlite://…). docs/COHABITATION.md explains how several components share one Engine in a process.

Building and testing

cargo build --features sqlite                 # SQLite only
cargo build --features postgres,sqlite        # both backends
cargo nextest run --features sqlite           # SQLite suite, no database needed

The PostgreSQL suite needs a database to itself: some tests assert on global row counts and one drops a schema. scripts/pg_test_db.sh creates a fresh single-use database, runs the command, drops the database and passes the exit code through:

scripts/pg_test_db.sh -- cargo nextest run --features postgres,sqlite
scripts/pg_test_db.sh --check     # show which suite is on which database

Within a run, each test process gets its own database cloned from an already-migrated template (CREATE DATABASE … TEMPLATE), so isolation costs less than replaying migrations.

The test cluster is disposable, so it can run without crash safety, which makes the suite much faster. scripts/pg_tune_test_cluster.sh turns off fsync, synchronous_commit, full_page_writes and JIT, and can put PGDATA on tmpfs. It refuses to run until a marker file is placed in the container, and prints the command to place it:

scripts/pg_tune_test_cluster.sh                  # tune the test cluster
scripts/pg_tune_test_cluster.sh --recreate-tmpfs # PGDATA in RAM (destroys the cluster's data)
scripts/pg_tune_test_cluster.sh --reset          # back to stock settings

scripts/certify.sh full runs every leg CI runs, locally, and its exit code is the verdict; certify.sh quick is a fast pre-push check. docs/TOOLING.md describes the local and CI tools, and docs/RELEASE.md the release procedure.

Parallel worktrees each grow a large target/. scripts/reap_worktree_targets.sh (dry run by default, --apply to act) removes target/ from linked worktrees that are merged, clean, unlocked, idle and cold for an hour.

Documentation

document contents
MISSION.md What persist is for, and the rules every change is held to
FSD/CIRIS_PERSIST.md The original functional specification. It predates v62: where it has persist deciding a rule over rows, the Kernel now decides it
docs/THREAT_MODEL.md Threat model: the AV-* attack vectors and their mitigations
docs/ADVERSARIAL_REVIEW_CHECKLIST.md Federation trust and admission for an auditor: each question tied to its CC rule, the witnesses that hold it, and the gaps
docs/PUBLIC_SCHEMA_CONTRACT.md The stable schema contract for readers of the database
docs/FEDERATION_DIRECTORY.md The federation directory: keys, attestations, trust anchors
docs/COHABITATION.md Sharing one Engine between components in a process
docs/INTEGRATION_LENS.md Integrating CIRISLens with persist
WIRE_VOCABULARY_KINDS.md The wire vocabulary's kinds and what each means
FSD/v62_release/README.md The v62 release record: the Kernel swap, the adoption list, the host surface
CHANGELOG.md Release history

For cryptographic primitives, hardware attestation and post-quantum posture, CIRISVerify is the authority. Persist uses it and pins it, and does not restate its claims.

Where it sits

CIRIS is the reference deployment, not the definition. In it, Verify owns the cryptographic primitives and the validity of one statement, ciris-kernel owns every rule over a set of rows, Edge owns transport, the agent does the reasoning, and adjudication belongs to a quorum of human authorities. Persist holds the rows, presents them and serves the answers. The substrate observes; it does not adjudicate.

License

AGPL-3.0-or-later. The persistence path is meant to be auditable line by line, and the license forbids closed-source forks, so that audit stays possible for every deployment.

About

Unified Rust persistence for the CIRIS Trinity — signed events, time-series, runtime state. AGPL-3.0-or-later.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages