Cruxible architecture¶
Cruxible separates accepted authority from storage, projections, and high-rate exhaust. That separation is the core invariant.
Components¶
| Component | Role | Authoritative? |
|---|---|---|
| Git ledger | Accepted envelopes, principal state, proposals, approvals, generations | Yes |
| Content-addressed storage | Exact immutable body and artifact bytes referenced by digest | For those bytes only |
| SQLite | Query indexes, operational metadata, rebuildable projections | No |
| Source systems | Databases, APIs, files, and services Cruxible references | Yes, for their own records |
| Event/exhaust stream | High-rate observations, actions, and processing exhaust | Evidence/input, not accepted state |
| Compiler | Deterministically turns accepted envelopes and source bundles into semantic projections | Pinned interpreter |
A source database does not become subordinate to Cruxible. Cruxible may accept a Claim about a row, pin a source coordinate, or record an attestation concerning it without copying the table or claiming authority over the source record.
Accepted coordinates¶
Every accepted generation is addressed by a four-part coordinate:
- Git OID identifies the exact ledger tree.
- Semantic root commits to governed meaning.
- Generation root commits to the accepted generation.
- Compiler digest commits to the deterministic interpretation.
New accepted generations carry a cruxible-accepting-admission Git header
with a canonical playbill-accepting-admission-v1 record naming the admission
id and digest. The daemon signature and Git OID cover this fact, which travels
with the ledger without changing frozen change-set receipt formats. History,
why, and floor changes read reasons from that exact admission. Headerless
historical generations retain their original candidate-and-actor resolution.
A read that omits this context is presentation, not a portable proof of state.
Mutation path¶
bytes/source references
│
▼
inert CAS or client-compiled source bundle
│
▼
authenticated proposal
│
▼
deterministic candidate + law evidence
│
▼
review + coordinate-bound signed approvals
│
▼
activation checks parent and settlement base
│
▼
accepted Git generation
│
├──> rebuildable projections
├──> history
└──> get (why, history, proof)
Proposal creation never mutates accepted state. Approval signs a frozen challenge. Activation independently re-verifies the candidate and advances by compare-and-set, so concurrent settlement cannot silently overwrite a newer generation.
Surfaces¶
The daemon (cruxible server start) is the only process that touches
accepted state. It serves an HTTP API over a Unix socket or TCP. The CLI, the
MCP server (cruxible mcp) and the Python SDK (cruxible-client) are all
clients of that API; none of them holds state of its own. Work that needs the
client's files happens on the client and sends the daemon bytes, never paths:
compiling catalogued files, quoting a cited passage, stamping projection
blocks, and signing approvals with a private key.
Background work runs inside the daemon as consumers driven by Triggers:
delivering the floor to a registered workspace after each accepted generation,
the next findings worker, and running enabled Lines.
Keys and credentials¶
Runtime bearer credentials authenticate transport and cap what a caller may do with a tier. Cruxible principals represent governance authority. Their Ed25519 private keys stay with the client; the ledger stores public keys and key history. A separate daemon key signs ledger mechanics. Recovery authority can repair principal state but cannot approve ordinary content. See Principals and credentials.
Integrity and isolation¶
On-disk integrity checks (content hashes, read-back verification on store, a
periodic evidence sweep) protect against accidents: crashes, partial writes,
media errors and stray edits. get, query, orient, coverage and write
previews take body presence from the landing index at the read's recorded
position. They do not stat or hash body files to decide availability. Capture
metadata is parsed from verified bytes once per content id; later metadata
reads reuse it while the index says the body is available. When updating a
changed Claim, the facts worker checks its consulted bodies' file identities
and verifies those that differ from their last verified identities before
persisting sweep baselines. Missing or corrupt bodies receive sequenced damage
records even when availability or metadata was reused from memory. Preview-generated
bodies are held in memory and are available to that preview. Persistent
preflight, proposal admission, generation preparation and recovery use live
operational positions even when invoked inside a read; returning restores the
enclosing read's positions. A body found
missing or damaged is recorded, and reads report the evidence that depends on it as unavailable rather than failing;
reading the damaged bytes themselves still refuses. These checks are not a
security boundary, since a process running as the daemon's user can rewrite its
files. Security against agents comes from isolation (agents talk to the daemon,
never to its state directory) and from the API: authenticated transport,
permission tiers and signed governance authority.
Semantic families¶
The ledger holds typed artifacts, each checked by its own law at acceptance:
- Subjects, ClaimTypes and Claims: the typed values, their vocabulary, and attestations that support, contradict or hold them unsure without silently changing them;
- Documents: whole files governed by exact bytes, with bodies in content-addressed storage and a small envelope in the ledger;
- CaptureContracts and Captures: what retained evidence must look like, and the evidence itself;
- QueryDefinitions: named queries;
- Contracts and capabilities: immutable data shapes, and the versioned kinds of call a Procedure slot names;
- Procedures and Providers: deterministic graphs whose slots name capabilities, and the installed provider builds whose operations serve them, each carrying its own copies of the shapes it accepts and returns;
- Lines, Triggers and ProcedureMandates: when Procedures run and what they may propose or settle;
- ResolutionContracts (predictions), the approval policy, the Procedure runtime policy, source acquisition policies, and principals.
Hot and cold paths¶
High-rate activity (Procedure runs, attempts, intermediate results) is retained as operational exhaust, outside the ledger. Procedures and Lines select from it and propose governed objects to the ledger. The exhaust records what happened; the ledger records what has been accepted. Neither is a shadow copy of the other.
Indexes, search engines or graph databases that accelerate reads are projections of accepted state and can be rebuilt from it.
Each write or Line request owns an artifact carrier across lowering, evaluation and projection. Every parser keys it by parser, exact bytes and path; nested stages join the outer request. It retains oversized and evicted process memo entries until that request exits, so LRU budgets do not cause repeated parsing within a large change. Sealed models are shared; unsealable parses stay detached. Refusals are never retained. Request memory grows with the artifacts this request touches, and all of it is released at outer scope exit.
Graph-format Procedure authoring resolves references with exact canonical-path reads at the intent base and in the staged ChangeSet. Only referenced artifacts are parsed, including a named acquisition policy; unrelated Claims, Subjects and Document bodies add no reference-resolution work. Pins and typed refusals use the same artifact parsers as accepted-tree reconstruction.
The write pipeline shares each Claim's sealed member: exact bytes, strict parsed model, digests and normalized intrinsic projection facts. The bounded cache keys all of these by path and exact bytes. Changed bytes derive a new member. Generation-dependent revisions, verdicts and explanation proofs are compiled for the accepting coordinate. Carried rows are checked against fresh derivation in tests; cold reconstruction remains the projection oracle. An accepting record's proof, governance basis and approval values are normalized once per law and accepting coordinate inside the request. Final member rows compose these owned immutable subtrees without traversing them again; standalone reconstruction returns detached rows. Mutable record copies take the cold path. Evidence admission similarly carries only eligible answers, keyed by the complete policy bytes and all derived admission inputs. A changed policy, role, subject binding, attestation grade or derivation input asks a new question; refused answers are evaluated again. Dependency proofs and query bindings share only their complete scalar values, and all request derivations expire together.
A successful activation also carries the evaluator's semantic-manifest and dependency proof tries to the exact accepted Git OID. The next write updates those roots for its own changed paths; it does not finish deferred proof work for the previous change. Only a winning verified publication installs them, compiler adoption stays cold, and physical and card-free snapshots share the same immutable semantic proof roots.
Within a Capture verification request, a run's immutable journal proof closure is checked once at each CAS landing-log head. A recorded landing, erase or damage invalidates that proof. A separately opened verification context checks the retained proof bodies afresh.
Retention¶
One setting (RetentionSettings: 64 generations, 14 days) bounds what is kept
of rebuildable and raw operational state; nothing a signed or authoritative
record references is deleted under it.
- Projection pieces. Each accepted generation's projection is a full SQLite
piece. The serving head and the last 64 accepted generations are kept (an
open proposal is evaluated at the head, so its base is among them), and so
is any piece a reader holds open in any process. Each activation evicts the
generation that left the window, and the daemon's open evicts the backlog,
each manifest before its piece. A piece skipped because a reader in the
daemon held it is evicted by the pass after that reader closes it; one
another process held then waits for the daemon's next open. Binding an
evicted coordinate (
--at, a pinned read, a stale proposal's base) rebuilds it from the ledger and the body store, including when the coordinate is evicted while the bind is reading it and another reader rebuilds it before that read's failure is classified. - Accepted proposals' candidates and approvals. An accepted proposal's
change-set record carries every field of its candidate and the approvals
settlement verified, so after activation the candidate file and the
approval files the record holds byte for byte are deleted, and
proposal inspect, review, status and the proposal index read them from the record; an approval submitted later is read beside the record's. Withdrawn, rejected and refused proposals' evidence, and any approval the record does not hold, are kept. - Consumption receipts. Raw receipts are kept 14 days, then fold into counters (touches per artifact and operation, and the audit's distinct reader keys) that remember every receipt they counted, so a read served again is never counted twice; only folded receipts are removed. Folds run one at a time and each lands only if no other fold landed since it chose its receipts.
- Line coverage. An idle Line's coverage that moved only in time advances the dispatch projection and is not journaled.
- The ledger. Every ref, note and archived proposal is kept. Objects are
staged in one in-process request pack/index pair. Proposal refs and notes
publish in authority order without a durable flush. Acceptance prepares the
generation note objects and durably seals the complete pair before publishing
main, importing the target's pending pack when preparation used an earlier
request, then publishes the note ref after the winning main CAS. Changed refs
are durable before releasing the activation lock. Retention objects are
prepared in that pack before acceptance; their refs
still publish in retirement order. Interrupted
pre-acceptance publications are advisory and may need re-proposal. Commit signatures use Ed25519 SSHSIG compatible with
git verify-commit; ref leases use Git's files-backend lockfile protocol. Publishing a ref, packed-refs or config lock consumes its pathname; cleanup closes the original descriptor without unlinking a successor's lock. Reads support loose objects and Git's delta-compressed packs. Published pack names are immutable and derived from their contents. Each replacement publishes its pending/keep protections first, its complete pack next, and its matching index last before retiring the superseded pair. Identical pairs are reused without rewriting; acceptance synchronizes their bytes and directory before main. An older durable pair is retired only after its replacement is durable; an advisory append to a reused durable pair leaves that older pair for Git compaction. Unreachable-commit inspection holds the in-process pack store lock throughgit fsck, excluding publication and targeted loser removal, which can delete objects being inventoried. Independent Git readers use the immutable publication protocol. The scan visits the whole object store. Recovery runs it only for unsettled generation markers or a missing initial cleanup baseline; clean recovery skips it. Warm workspace advertisement carries the tree writer's changed-child frontier and visits it only after checking the destination or current transfer batch has its baseline, including when a refresh coalesces generations. Cold attachment, missing baselines and evicted frontiers use full reachable-object traversal. Every 64 accepted generations the daemon consolidates packs (repack -a -d), packs refs and writes the commit-graph, off the acceptance path, and at start, before serving, it also prunes unreachable loose objects, the one step that is safe only while no writer is in flight.
Repository ownership¶
The daemon implementation lives directly under src/cruxible_core/, grouped by
responsibility. ledger/ owns Git publication and accepted generations;
compiler/ owns deterministic compilation; indexes/ owns rebuildable SQLite
read models. Claims, evidence, documents, procedures, providers, governance,
and coverage each have their own package (curation/ is kept in the tree but
not served in this release).
service/<domain>/ is the single home for served orchestration. CLI, HTTP, MCP,
and SDK-facing runtime adapters delegate there. runtime/ owns instance
lifecycle and process configuration; derived/ coordinates derived reads;
exhaust/ retains operational records; storage/ contains body storage and
staging primitives. The separately packaged SDK and typed contracts remain in
packages/cruxible-client/.
Tests follow the same ownership under tests/test_<domain>/; shared fixtures
live in tests/core_support/. Frozen format fixtures remain in tests/goldens/.
Internal package relocation does not rename wire operations, managed-state
paths, or signed format identifiers.
Operational journal publication¶
A terminal journals its items' dependency closures as one item_dependencies
record (playbill-terminal-items-v1) that cites run-free bodies: the shared set
(the Captures and reads the whole terminal consumed), one body per item
(playbill-procedure-item-dependencies-v3, what that item consumed beyond the
shared set and its folded facts) and chunks of up to 64
(item_key, body digest, manifest digest) entries. No body names the run, its
time or a journal position, and an item's manifest
(playbill-terminal-item-dependencies-v2) binds no run, so an item whose
closure did not change stores nothing new; the citing record carries the run
binding. Reads join each item body with the shared set into the exact manifest
and check its digest. The per-item records of earlier builds (v1 inline, v2
citing a shared set) stay readable. A Procedure's Query read stores its result
body without its evaluation instant, in a small record that names the body and
keeps the instant and result digest, so an identical read stores almost
nothing new; replay restores the exact view and checks the result digest.
A reservation sidecar names a record's CAS payload before it is written; the
sidecar is removed only after the record is appended and indexed.
The journal remains authoritative and its SQLite indexes are rebuildable.
Operational journal frames, payload bodies and reservation sidecars are
best-effort exhaust: they have no per-item fsync. A crash can lose recent
payloads while their authenticated journal records remain. Service reads classify
those records as unavailable; run reads return replay_material_unavailable,
reading inspection reports an incremental unavailable_reading_count and at
most the requested page size of representative unavailable_payloads, and affected measurement results
say unavailable. Recovery preserves leases and does not re-drive an effect
whose completion may have been lost. A retained admission still blocks another
admission when its binding payload is lost; an unknown event binding refuses
with replay_material_unavailable. An incomplete inbox stops before dependent
transitions and refuses reads and dispositions with cruxible.inbox.unavailable;
next reports its unknown volume as a repair. Restore its payload and rebuild
the inbox projection to resume. Direct body-byte reads still refuse.
Before advancing main, acceptance flushes the changed artifacts' transitive CAS
citation closure (including Capture material and promoted payloads) and namespace
parents. Linux uses one syncfs on the instance filesystem; other platforms
flush each not-yet-durable cited body and touched directory once, alongside the
existing Git-object flushes. A failed barrier leaves main unmoved. The process
remembers durable bodies so repeated citations do not repeat body fsyncs. A new
publication of a lost body clears that digest's durability under the barrier
lock, so the recreated inode acquires durability again. This
work follows changed members and their citations, never the stored population.
After repairing missing exhaust, rebuild its incomplete derived partition index
(or restart) to restore that partition's readings and resolution view.
Accepted query reads narrow their facts through the projection's Subject identity
and scalar Claim value indexes. Matching Subjects retain every competing Claim
of the requested predicates. Bound entry paths constrain subsequent filters;
conjunctions apply identity restrictions before value and kind selections, and
each disjunction branch receives the same incoming candidates. Plain named reads
apply their result budget before loading facts, while maintained per-kind counts
preserve truncation totals. Kind counts update only when a Subject row changes.
Predicate-scoped Claim, ClaimType, and attestation reads explicitly select
claims_by_predicate, keeping their seek stable beside the scalar value indexes.
Absence, negation, traversals,
includes, and filters whose refusal or verdict accounting cannot be preserved
use the full-load evaluator. Projection storage schema 19 rebuilds older derived
indexes once; accepted ledger formats and query result bytes are unchanged.
Ontology reads count from maintained counters too. Each live Claim's insert,
delete or move (lifecycle, predicate, Subject) adjusts a per-(predicate, Subject)
refcount and the per-(Subject kind, predicate) live Claim and Subjects-with-a-value
counts, and each cited Capture's insert or delete one Capture counter, all by SQL
trigger in the same transaction. orient(kind=K), the get ClaimType: and
get SubjectKind: cards and the default map's Capture count read those rows
by key and never recount. Projection storage schema 20 adds them and rebuilds
each projection once on first bind; accepted ledger formats are unchanged.
The unit index (claim_units) holds each live Claim of a ClaimType that
declares an inverse, with its unit (the slot, the object, or the object
Subject's key value) and its polarity (a value or a none). An accepted
generation recomputes only the rows of the Claims it writes, of the values
pointing at a Subject whose key Claim it writes, and of a ClaimType whose
inverse key it changes. The candidate boundary reads those rows for the units a
change touches, with bounded seeks (a written value seeks the unit's nones, a
written none its first few values; a unit's own polarity is never enumerated),
and refuses a change set that would leave a unit holding both a value and a
none (cruxible.claim.polarity_conflict), more than one none
(cruxible.claim.inverse_duplicate), an object_key flip that leaves its unit
(cruxible.claim.flip_unit_moved), or a retirement riding along with a flip
that does not end superseded (cruxible.claim.flip_retirement_reason). A
one-valued field under conflict_result: unresolved may hold a value and a
none in dispute only deliberately: each Claim the change writes into the
dispute must be one its write declared a contend for (seeing the opposite in
the base is not that declaration), and stands against opposites live in the
change's own base, the ones its writer read; one that landed meanwhile
refuses. No write carries that declaration to the boundary before the none
verb (slice I3), so until then every new value-beside-none dispute refuses. Admission and settlement both
judge there, at the head the change lands on. A none Claim's row carries its
of only in none_of, never in the object or literal columns, and ordinary
value reads select object_kind <> 'none', so a none never reads as a null.
Projection storage schema 21 adds the index and rebuilds each projection once
on first bind.