# chrisroyse/calyx architecture

> Architecture diagram of the GitHub repository chrisroyse/calyx, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chrisroyse/calyx
- Repository: https://github.com/chrisroyse/calyx

## Overview

#### Purpose and entry points
Calyx is a Rust association-native database: inputs become multi-lens typed “constellations,” which are searched, associated, grounded, guarded, and provenance-recorded. Primary executables are the CLI at `crates/calyx-cli/src/main.rs`, daemon at `crates/calyxd/src/main.rs`, and JSON-RPC/MCP server at `crates/calyx-mcp/src/main.rs`. A separate HTTP-facing API exists at `crates/calyx-web-api/src/main.rs`.

#### Foundation: data model, storage, and provenance
`calyx-core` defines shared IDs, models, traits, temporal/security concepts, and closed errors (`crates/calyx-core/src/lib.rs`, `crates/calyx-core/src/model/mod.rs`).  
Aster is the embedded transactional storage boundary: vault commits, WAL/replay, MVCC reads/snapshots, SST/mmap structures, indexing, compaction, and GC (`crates/calyx-aster/src/vault/store.rs`, `crates/calyx-aster/src/wal/mod.rs`, `crates/calyx-aster/src/mvcc/store.rs`).  
Ledger provides append-only hash-chained provenance, checkpoints, verification, reproduction, and redaction/tombstones (`crates/calyx-ledger/src/append.rs`, `crates/calyx-ledger/src/merkle.rs`, `crates/calyx-ledger/src/verify.rs`). Storage and ledger are the durability/trust boundary for all higher stages.

#### Measurement and compute
Registry manages immutable, content-addressed lenses/panels, commissioning, persistence, backfill, and runtime adapters (`crates/calyx-registry/src/lens.rs`, `crates/calyx-registry/src/commission.rs`, `crates/calyx-registry/src/runtime/mod.rs`). It supports ONNX, Candle, algorithmic, external-command, static, and HTTP/TEI execution paths.  
Forge supplies shared numeric kernels, quantization, CPU SIMD, optional CUDA, and VRAM admission/eviction (`crates/calyx-forge/src/backend.rs`, `crates/calyx-forge/src/cuda/mod.rs`, `crates/calyx-forge/src/vram/mod.rs`). The runtime is Rust 2024; CUDA is optional and paired with CPU fallback/parity-oriented implementations.

#### Association, search, and information stages
Ingestion measures source content through registry panels and commits constellation slots into Aster; CLI orchestration is centered in `crates/calyx-cli/src/cmd/ingest/mod.rs` and `crates/calyx-cli/src/cmd/ingest/store.rs`.  
Sextant plans and executes dense, sparse/BM25, late-interaction, graph, temporal, and fused retrieval (`crates/calyx-sextant/src/query/planner.rs`, `crates/calyx-sextant/src/query/executor.rs`, `crates/calyx-sextant/src/fusion/pipeline.rs`).  
Loom derives cross-slot agreement, interaction, recurrence, and reactive associations (`crates/calyx-loom/src/agreement_graph.rs`, `crates/calyx-loom/src/cross_term.rs`, `crates/calyx-loom/src/reactive/engine.rs`).  
Assay evaluates signal contribution, redundancy, calibration, and sufficiency against outcomes (`crates/calyx-assay/src/ensemble/compute.rs`, `crates/calyx-assay/src/sufficiency/joint.rs`, `crates/calyx-assay/src/gate.rs`).

#### Grounded intelligence and safety
Lodestar converts associations into corpus kernels, discovery chains, scoped answers, hypotheses, and graph navigation (`crates/calyx-lodestar/src/kernel.rs`, `crates/calyx-lodestar/src/kernel_answer.rs`, `crates/calyx-lodestar/src/discovery_chain.rs`).  
Ward is the fail-closed per-slot trust boundary: calibrates thresholds, detects drift/novelty, and emits guard verdicts rather than allowing unsupported output (`crates/calyx-ward/src/guard.rs`, `crates/calyx-ward/src/calibrate.rs`, `crates/calyx-ward/src/verdict.rs`).  
Oracle performs evidence-bound prediction, reverse queries, recurrence/consequence analysis, and honesty gating (`crates/calyx-oracle/src/predict.rs`, `crates/calyx-oracle/src/honesty_gate.rs`, `crates/calyx-oracle/src/butterfly.rs`).

#### Adaptation, services, and domain extensions
Anneal safely tunes indexes, fusion, and related settings through shadow evaluation, tripwires, rollback, and learning feedback (`crates/calyx-anneal/src/shadow.rs`, `crates/calyx-anneal/src/tripwire.rs`, `crates/calyx-anneal/src/rollback.rs`). Changes are intended to be reversible and quality-gated before promotion.  
`calyxd` hosts HTTP/MCP, health/metrics, verification loops, CUDA probing, and learner-origin services (`crates/calyxd/src/server.rs`, `crates/calyxd/src/mcp_server.rs`, `crates/calyxd/src/verify_loop.rs`).  
`calyx-poly` is a substantial prediction-market application layer over the core: external HTTP/WebSocket, Gamma/Kalshi/CLOB/on-chain ingestion, feature/graph building, forecasting, settlement feedback, and scheduled operations (`crates/calyx-poly/src/pipeline.rs`, `crates/calyx-poly/src/raw_sources.rs`, `crates/calyx-poly/src/daily_ops_scheduler.rs`).

Main entry points: [`crates/calyx-cli/src/cmd/ingest/mod.rs`](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-cli/src/cmd/ingest/mod.rs) (Ingestion), [`crates/calyxd/src/main.rs`](https://github.com/chrisroyse/calyx/blob/main/crates/calyxd/src/main.rs) (calyxd), [`crates/calyx-aster/src/vault/store.rs`](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-aster/src/vault/store.rs) (Aster vault store), [`crates/calyx-sextant/src/query/planner.rs`](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-sextant/src/query/planner.rs) (Sextant)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry Points"]
  node_cli["Calyx CLI<br/>Rust executable<br/>[main.rs]"]
  node_daemon["calyxd<br/>daemon<br/>[main.rs]"]
  node_mcp["MCP / JSON-RPC server<br/>server executable<br/>[main.rs]"]
  node_web_api["Web API<br/>HTTP executable<br/>[main.rs]"]
end

subgraph group_foundation["Durability &amp; Compute"]
  node_core["Core model<br/>shared domain crate<br/>[mod.rs]"]
  node_aster_store[("Aster vault store<br/>transactional storage<br/>[store.rs]")]
  node_aster_wal[("WAL &amp; replay<br/>storage durability<br/>[mod.rs]")]
  node_aster_mvcc[("MVCC snapshots<br/>storage reads<br/>[store.rs]")]
  node_ledger[("Provenance ledger<br/>append-only ledger<br/>[append.rs]")]
  node_registry{{"Lens registry<br/>measurement runtime<br/>[mod.rs]"}}
  node_forge{{"Forge<br/>numeric backend<br/>[backend.rs]"}}
end

subgraph group_information["Information Pipeline"]
  node_ingestion["Ingestion<br/>constellation writer<br/>[mod.rs]"]
  node_sextant["Sextant<br/>retrieval engine<br/>[planner.rs]"]
  node_loom["Loom<br/>association engine<br/>[agreement_graph.rs]"]
  node_assay["Assay<br/>signal evaluator<br/>[compute.rs]"]
end

subgraph group_intelligence["Grounded Intelligence"]
  node_lodestar["Lodestar<br/>grounded answer engine<br/>[kernel.rs]"]
  node_ward{{"Ward<br/>trust guard<br/>[guard.rs]"}}
  node_oracle["Oracle<br/>evidence-bound prediction<br/>[predict.rs]"]
end

subgraph group_operations["Services &amp; Adaptation"]
  node_anneal["Anneal<br/>safe adaptation<br/>[shadow.rs]"]
  node_poly["Calyx Poly<br/>prediction-market app<br/>[pipeline.rs]"]
end

node_core -->|"typed records"| node_aster_store
node_aster_store -->|"durable commits"| node_aster_wal
node_aster_store -->|"snapshot reads"| node_aster_mvcc
node_registry -->|"executes kernels"| node_forge
node_cli -->|"orchestrates"| node_ingestion
node_ingestion -->|"measures sources"| node_registry
node_ingestion -->|"commits slots"| node_aster_store
node_ingestion -->|"records provenance"| node_ledger
node_sextant -->|"retrieves constellations"| node_aster_mvcc
node_sextant -->|"candidate associations"| node_loom
node_loom -->|"association signals"| node_assay
node_assay -->|"qualified evidence"| node_lodestar
node_lodestar -->|"scoped output"| node_ward
node_ward -->|"guard verdicts"| node_oracle
node_oracle -->|"records evidence trail"| node_ledger
node_anneal -.->|"quality-gated tuning"| node_sextant
node_anneal -->|"shadow evaluation"| node_assay
node_daemon -->|"serves retrieval"| node_sextant
node_daemon -->|"verification loop"| node_ledger
node_mcp -->|"service access"| node_daemon
node_web_api -->|"service access"| node_daemon
node_poly -->|"market source ingestion"| node_ingestion
node_poly -->|"market forecasting"| node_oracle
node_poly -->|"settlement feedback"| node_anneal

click node_cli "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-cli/src/main.rs"
click node_daemon "https://github.com/chrisroyse/calyx/blob/main/crates/calyxd/src/main.rs"
click node_mcp "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-mcp/src/main.rs"
click node_web_api "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-web-api/src/main.rs"
click node_core "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-core/src/model/mod.rs"
click node_aster_store "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-aster/src/vault/store.rs"
click node_aster_wal "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-aster/src/wal/mod.rs"
click node_aster_mvcc "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-aster/src/mvcc/store.rs"
click node_ledger "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-ledger/src/append.rs"
click node_registry "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-registry/src/runtime/mod.rs"
click node_forge "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-forge/src/backend.rs"
click node_ingestion "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-cli/src/cmd/ingest/mod.rs"
click node_sextant "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-sextant/src/query/planner.rs"
click node_loom "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-loom/src/agreement_graph.rs"
click node_assay "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-assay/src/ensemble/compute.rs"
click node_lodestar "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-lodestar/src/kernel.rs"
click node_ward "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-ward/src/guard.rs"
click node_oracle "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-oracle/src/predict.rs"
click node_anneal "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-anneal/src/shadow.rs"
click node_poly "https://github.com/chrisroyse/calyx/blob/main/crates/calyx-poly/src/pipeline.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_daemon,node_mcp,node_web_api toneBlue
class node_core,node_aster_store,node_aster_wal,node_aster_mvcc,node_ledger,node_registry,node_forge toneAmber
class node_ingestion,node_sextant,node_loom,node_assay toneMint
class node_lodestar,node_ward,node_oracle toneRose
class node_anneal,node_poly toneIndigo
```

## Components

### Entry Points

- [Calyx CLI](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-cli/src/main.rs): Rust executable · Primary command-line orchestration. · `crates/calyx-cli/src/main.rs`
- [calyxd](https://github.com/chrisroyse/calyx/blob/main/crates/calyxd/src/main.rs): daemon · Hosts HTTP/MCP, health, verification, and learner services. · `crates/calyxd/src/main.rs`
- [MCP / JSON-RPC server](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-mcp/src/main.rs): server executable · `crates/calyx-mcp/src/main.rs`
- [Web API](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-web-api/src/main.rs): HTTP executable · `crates/calyx-web-api/src/main.rs`

### Durability & Compute

- [Core model](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-core/src/model/mod.rs): shared domain crate · IDs, typed models, traits, temporal and security concepts. · `crates/calyx-core/src/model/mod.rs`
- [Aster vault store](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-aster/src/vault/store.rs): transactional storage · Commit boundary for constellation slots and indexes. · `crates/calyx-aster/src/vault/store.rs`
- [WAL & replay](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-aster/src/wal/mod.rs): storage durability · `crates/calyx-aster/src/wal/mod.rs`
- [MVCC snapshots](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-aster/src/mvcc/store.rs): storage reads · `crates/calyx-aster/src/mvcc/store.rs`
- [Provenance ledger](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-ledger/src/append.rs): append-only ledger · Hash-chained provenance, checkpoints, redaction, and reproduction. · `crates/calyx-ledger/src/append.rs`
- [Lens registry](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-registry/src/runtime/mod.rs): measurement runtime · Content-addressed lenses, panels, commissioning, and adapters. · `crates/calyx-registry/src/runtime/mod.rs`
- [Forge](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-forge/src/backend.rs): numeric backend · CPU SIMD kernels with optional CUDA and VRAM management. · `crates/calyx-forge/src/backend.rs`

### Information Pipeline

- [Ingestion](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-cli/src/cmd/ingest/mod.rs): constellation writer · Measures content and commits constellation slots. · `crates/calyx-cli/src/cmd/ingest/mod.rs`
- [Sextant](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-sextant/src/query/planner.rs): retrieval engine · Plans and executes dense, sparse, graph, temporal, and fused search. · `crates/calyx-sextant/src/query/planner.rs`
- [Loom](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-loom/src/agreement_graph.rs): association engine · Derives agreement, interactions, recurrence, and reactive associations. · `crates/calyx-loom/src/agreement_graph.rs`
- [Assay](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-assay/src/ensemble/compute.rs): signal evaluator · Evaluates contribution, redundancy, calibration, and sufficiency. · `crates/calyx-assay/src/ensemble/compute.rs`

### Grounded Intelligence

- [Lodestar](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-lodestar/src/kernel.rs): grounded answer engine · Builds corpus kernels, discovery chains, scoped answers, and hypotheses. · `crates/calyx-lodestar/src/kernel.rs`
- [Ward](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-ward/src/guard.rs): trust guard · Fail-closed per-slot trust verdicts for drift and novelty. · `crates/calyx-ward/src/guard.rs`
- [Oracle](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-oracle/src/predict.rs): evidence-bound prediction · Prediction, reverse queries, consequence analysis, and honesty gating. · `crates/calyx-oracle/src/predict.rs`

### Services & Adaptation

- [Anneal](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-anneal/src/shadow.rs): safe adaptation · Shadow evaluation, tripwires, rollback, and promotion feedback. · `crates/calyx-anneal/src/shadow.rs`
- [Calyx Poly](https://github.com/chrisroyse/calyx/blob/main/crates/calyx-poly/src/pipeline.rs): prediction-market app · Ingests markets, builds features, forecasts, settles, and schedules operations. · `crates/calyx-poly/src/pipeline.rs`

## Connections

- Core model → Aster vault store: typed records
- Aster vault store → WAL & replay: durable commits
- Aster vault store → MVCC snapshots: snapshot reads
- Lens registry → Forge: executes kernels
- Calyx CLI → Ingestion: orchestrates
- Ingestion → Lens registry: measures sources
- Ingestion → Aster vault store: commits slots
- Ingestion → Provenance ledger: records provenance
- Sextant → MVCC snapshots: retrieves constellations
- Sextant → Loom: candidate associations
- Loom → Assay: association signals
- Assay → Lodestar: qualified evidence
- Lodestar → Ward: scoped output
- Ward → Oracle: guard verdicts
- Oracle → Provenance ledger: records evidence trail
- Anneal → Sextant: quality-gated tuning
- Anneal → Assay: shadow evaluation
- calyxd → Sextant: serves retrieval
- calyxd → Provenance ledger: verification loop
- MCP / JSON-RPC server → calyxd: service access
- Web API → calyxd: service access
- Calyx Poly → Ingestion: market source ingestion
- Calyx Poly → Oracle: market forecasting
- Calyx Poly → Anneal: settlement feedback
