Skip to main content

Crate nucleus_substrate_core

Crate nucleus_substrate_core 

Source
Expand description

§nucleus-substrate-core — the categorical core

This crate ships three things:

  1. Session — the agent-action object every projection projects from.
  2. Projection — a sealed, adjacently-tagged sum type whose variants are one-per-projection-functor (Identity, Capability, Flow, Economic, …).
  3. Receipt — the Ed25519-signed colimit envelope holding a session and any subset of its projections.

The categorical model is documented at docs/architecture/substrate.md in the repo.

§Quick example

use nucleus_substrate_core::{Session, Receipt, Projection};
use ed25519_dalek::SigningKey;

let sk = SigningKey::from_bytes(&[7u8; 32]);
let session = Session {
    session_id: "spiffe://test/agent-x".into(),
    issuer_kid: "test-kid".into(),
    issued_at_micros: 1_717_000_000_000_000,
    parent_chain: vec![],
};

let projection = Projection::Identity(serde_json::json!({
    "sub": "spiffe://test/agent-x",
    "aud": "nucleus-substrate-test",
}));

let receipt = Receipt::sign(session, vec![projection], &sk);

// Anyone with the issuer's verifying key can verify offline.
let vk: [u8; 32] = sk.verifying_key().to_bytes();
receipt.verify(&vk).expect("self-built receipt verifies");

§What’s NOT in scope here

  • The concrete types each Projection variant carries. Those live in the projection-lifter crates (nucleus-identity-projection, nucleus-flow-projection, etc.). This crate keeps them as serde_json::Value to stay dependency-light.
  • The HTTP wire (REST routes, axum) — that’s the hub.
  • The mechanism kernels (VCG, Pigouvian re-weighting) — those live in nucleus-econ-kernels etc.

Modules§

mechanism
Mechanism-design types that live inside the Economic projection.

Structs§

Receipt
The colimit envelope. Holds a session + any subset of its projections, signed with the issuer’s Ed25519 key.
Session
The unit of authorship. Every projection projects from this.

Enums§

Projection
One projection of a session into a verifiable record.
ReceiptError

Constants§

RECEIPT_VERSION

Functions§

canonical_signing_bytes
Canonical signing input for a receipt. Same function is called when building and when verifying — that’s the entire trust surface for the colimit identity.