#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PrimitiveInfo {
pub name: &'static str,
pub category: &'static str,
pub top_level: bool,
pub since: &'static str,
pub summary: &'static str,
pub doc_status: DocStatus,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DocStatus {
Documented,
Pending,
}
impl DocStatus {
pub fn as_str(self) -> &'static str {
match self {
DocStatus::Documented => "documented",
DocStatus::Pending => "pending",
}
}
}
pub const PRIMITIVE_REGISTRY: &[PrimitiveInfo] = &[
PrimitiveInfo {
name: "persona",
category: "cognition",
top_level: true,
since: "v0.1.0",
summary: "Declares the identity, expertise, and refusal posture an agent adopts when executing a flow.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "context",
category: "cognition",
top_level: true,
since: "v0.1.0",
summary: "Declares the conversational frame — memory scope, depth, max tokens, temperature — a flow operates within.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "flow",
category: "cognition",
top_level: true,
since: "v0.1.0",
summary: "The orchestration primitive — a typed, ordered composition of cognitive steps with parameters and a return type.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "anchor",
category: "cognition",
top_level: true,
since: "v0.1.0",
summary: "A typed grounding constraint — declares the conditions a flow's outputs MUST satisfy, with a structured violation policy.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "tool",
category: "cognition",
top_level: true,
since: "v0.1.0",
summary: "A declarative binding for an external capability (search, web fetch, code interpreter, …) callable from within a flow.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "intent",
category: "cognition",
top_level: true,
since: "v0.1.0",
summary: "A declarative target outcome — what the flow is trying to achieve, separately from how it gets there.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "memory",
category: "cognition",
top_level: true,
since: "v0.1.0",
summary: "Declares a typed memory store — session, persistent, vector — for cross-step state with retrieval + decay semantics.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "agent",
category: "cognition",
top_level: true,
since: "Fase 18",
summary: "An orchestrated cognitive entity — composes personas, tools, contexts under a coordination strategy.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "run",
category: "cognition",
top_level: true,
since: "v0.1.0",
summary: "Binds a flow to a persona, context, and anchors — the statement that EXECUTES a declared flow.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "step",
category: "cognition",
top_level: false,
since: "v0.1.0",
summary: "A single cognitive operation inside a flow — typed input (given), prompt (ask), and typed output.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "reason",
category: "cognition",
top_level: false,
since: "v0.1.0",
summary: "An explicit-reasoning operation — declares HOW the model should think (chain-of-thought, debate, …).",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "probe",
category: "cognition",
top_level: false,
since: "v0.1.0",
summary: "A diagnostic / probing operation inside a step — emits observations without changing the trajectory.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "validate",
category: "cognition",
top_level: false,
since: "v0.1.0",
summary: "Enforces a typed invariant on a step's output before subsequent steps consume it.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "refine",
category: "cognition",
top_level: false,
since: "v0.1.0",
summary: "Iteratively improves a candidate output via a declared refinement strategy.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "weave",
category: "cognition",
top_level: false,
since: "v0.1.0",
summary: "Multi-thread reasoning braid — composes multiple sub-derivations into a unified conclusion.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "resource",
category: "cognitive_io",
top_level: true,
since: "Fase 6",
summary: "Declares an external compute/storage resource (database, S3, ML endpoint) consumable by a flow.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "fabric",
category: "cognitive_io",
top_level: true,
since: "Fase 6",
summary: "The cloud-substrate declaration — provider, region, zones, ephemerality, bound shield.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "manifest",
category: "cognitive_io",
top_level: true,
since: "Fase 6",
summary: "Bundles resources + fabric + compliance tags into a deployable, audit-tracked unit.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "observe",
category: "cognitive_io",
top_level: true,
since: "Fase 6",
summary: "Declares an observability surface — sources, quorum, timeout, certainty floor, partition policy.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "reconcile",
category: "cognitive_io",
top_level: true,
since: "Fase 6",
summary: "A typed reconciliation loop — observes drift against a manifest and applies bounded corrections.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "lease",
category: "cognitive_io",
top_level: true,
since: "Fase 6",
summary: "Time-bounded resource acquisition with typed expiry, renewal, and revocation semantics.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "ensemble",
category: "cognitive_io",
top_level: true,
since: "Fase 6",
summary: "Coordinates multiple cognitive entities under a consensus or quorum protocol with structured tie-breaking.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "immune",
category: "cognitive_io",
top_level: true,
since: "Fase 19",
summary: "Continuous-monitoring agent that learns a baseline + emits epistemic-level signals on anomalies.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "reflex",
category: "cognitive_io",
top_level: true,
since: "Fase 19",
summary: "An automatic-response trigger bound to an immune system's level — fires structured actions on threshold breach.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "heal",
category: "cognitive_io",
top_level: true,
since: "Fase 19",
summary: "A recovery routine bound to an immune system's level — runs scoped repairs, often human-in-the-loop.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "type",
category: "data_plane",
top_level: true,
since: "v0.1.0",
summary: "Declares a structured data type with optional refinements, ranges, where clauses, and compliance tags.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "axonstore",
category: "data_plane",
top_level: true,
since: "Fase 36",
summary: "A typed, audit-chained data store — relational backend, isolation level, encryption, retention, on-breach policy.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "dataspace",
category: "data_plane",
top_level: true,
since: "Fase 36",
summary: "A named, isolated data namespace — multi-tenant by construction, with cross-tenant proof obligations.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "corpus",
category: "data_plane",
top_level: true,
since: "Fase 36",
summary: "A retrieval-ready collection of documents — backs RAG and grounded retrieval with citation provenance.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "pix",
category: "data_plane",
top_level: true,
since: "Fase 19",
summary: "Provenance Index — an append-only, hash-linked chain of every state transition with tamper-evident verification.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "transact",
category: "data_plane",
top_level: false,
since: "Fase 36",
summary: "A flow-body block that wraps multiple data-plane mutations in a single transactional unit with rollback semantics.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "session",
category: "session_types",
top_level: true,
since: "Fase 41.a (v2.3.0)",
summary: "Declares the typed bidirectional dialogue protocol a socket carries — §41 algebra (send/receive/select/branch/loop/end).",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "socket",
category: "session_types",
top_level: true,
since: "Fase 41.b (v2.3.0)",
summary: "Session-typed WebSocket transport with credit-refined backpressure, typed reconnection, and SSE-as-fragment projection.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "axonendpoint",
category: "wire",
top_level: true,
since: "Fase 32",
summary: "HTTP REST primitive — exposes a flow on a typed route with body/output schemas, transport classification, and compliance.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "axpoint",
category: "wire",
top_level: true,
since: "Fase 32",
summary: "Lightweight axonendpoint — for simple request/response flows without the full request-binding schema scaffolding.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "daemon",
category: "wire",
top_level: true,
since: "Fase 16",
summary: "A long-lived, supervised cognitive process — reacts to events on declared listeners with structured restart semantics.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "mcp",
category: "wire",
top_level: true,
since: "Fase 33+",
summary: "Declares an outbound MCP server binding — turns axon into an MCP client of another server.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "listen",
category: "wire",
top_level: false,
since: "Fase 16",
summary: "A flow/daemon-body listener — binds to an event source and dispatches typed messages downstream.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "shield",
category: "operators",
top_level: true,
since: "Fase 20",
summary: "A composable defence layer — scans inputs/outputs for declared threats with a structured on-breach policy.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "mandate",
category: "operators",
top_level: true,
since: "Fase 21",
summary: "A typed approval requirement — gates a flow's execution on a capability check + optional segregation of duties.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "compute",
category: "operators",
top_level: true,
since: "Fase 17",
summary: "Binds a flow to a specific compute backend — model selection, effort hint, parallelism, deterministic seed.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "lambda",
category: "operators",
top_level: true,
since: "Fase 15",
summary: "An anonymous, typed function bound to a flow's data plane — supports lambda apply semantics for inline composition.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "forge",
category: "operators",
top_level: false,
since: "Fase 18",
summary: "A flow-body block that constructs typed values from sub-step outputs under explicit construction discipline.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "ots",
category: "operators",
top_level: true,
since: "Fase 11",
summary: "One-shot transform — a closed-catalogue media transformation (audio, image, format) with native/ffmpeg backend dispatch.",
doc_status: DocStatus::Documented,
},
PrimitiveInfo {
name: "psyche",
category: "operators",
top_level: true,
since: "Fase 14",
summary: "Declares the psychological model a persona enacts — beliefs, desires, traits, behavioural disposition.",
doc_status: DocStatus::Documented,
},
];
pub fn find(name: &str) -> Option<&'static PrimitiveInfo> {
PRIMITIVE_REGISTRY.iter().find(|i| i.name == name)
}
pub fn by_category<'a>(category: &'a str) -> impl Iterator<Item = &'static PrimitiveInfo> + 'a {
PRIMITIVE_REGISTRY.iter().filter(move |i| i.category == category)
}
pub fn with_status(status: DocStatus) -> impl Iterator<Item = &'static PrimitiveInfo> {
PRIMITIVE_REGISTRY.iter().filter(move |i| i.doc_status == status)
}
pub fn coverage_summary() -> CoverageSummary {
let mut summary = CoverageSummary::default();
for info in PRIMITIVE_REGISTRY {
match info.doc_status {
DocStatus::Documented => summary.documented += 1,
DocStatus::Pending => summary.pending += 1,
}
}
summary.total = PRIMITIVE_REGISTRY.len();
summary
}
#[derive(Debug, Default, Clone, Copy)]
pub struct CoverageSummary {
pub total: usize,
pub documented: usize,
pub pending: usize,
}
#[cfg(test)]
mod tests {
use super::*;
use std::collections::HashSet;
const VALID_CATEGORIES: &[&str] = &[
"cognition",
"cognitive_io",
"data_plane",
"session_types",
"wire",
"operators",
];
#[test]
fn registry_contains_the_expected_count() {
assert_eq!(
PRIMITIVE_REGISTRY.len(),
45,
"PRIMITIVE_REGISTRY count drift — add/remove the primitive intentionally + update this assertion"
);
}
#[test]
fn every_entry_has_a_non_empty_name_and_summary() {
for info in PRIMITIVE_REGISTRY {
assert!(!info.name.is_empty(), "empty name in registry");
assert!(
!info.summary.is_empty(),
"primitive `{}` has an empty summary — scaffold + listings would be unhelpful",
info.name
);
assert!(
!info.since.is_empty(),
"primitive `{}` has an empty since — corpus frontmatter would be invalid",
info.name
);
}
}
#[test]
fn every_entry_has_a_valid_category() {
for info in PRIMITIVE_REGISTRY {
assert!(
VALID_CATEGORIES.contains(&info.category),
"primitive `{}` has invalid category `{}` — valid: {VALID_CATEGORIES:?}",
info.name, info.category
);
}
}
#[test]
fn primitive_names_are_unique() {
let mut seen: HashSet<&str> = HashSet::new();
for info in PRIMITIVE_REGISTRY {
assert!(
seen.insert(info.name),
"duplicate primitive name in registry: `{}`",
info.name
);
}
}
#[test]
fn documented_tier_matches_phase_6d_baseline_full_coverage() {
let documented: HashSet<&str> = with_status(DocStatus::Documented)
.map(|i| i.name)
.collect();
let expected: HashSet<&str> = [
"persona", "flow", "step", "anchor", "tool", "reason", "socket",
"context", "intent", "memory", "agent", "probe", "validate",
"refine", "weave", "type", "run",
"resource", "fabric", "manifest", "observe", "reconcile",
"lease", "ensemble", "session", "axonstore", "dataspace",
"corpus", "pix",
"axonendpoint", "axpoint", "daemon", "mcp", "listen",
"shield", "mandate", "compute", "lambda", "forge", "ots",
"psyche", "immune", "reflex", "heal", "transact",
]
.into_iter()
.collect();
assert_eq!(
documented, expected,
"Documented set drift — Fase 6.d baseline is 45 specific primitives (full coverage)"
);
}
#[test]
fn coverage_summary_is_arithmetic() {
let s = coverage_summary();
assert_eq!(s.total, 45);
assert_eq!(s.documented + s.pending, s.total);
assert_eq!(s.documented, 45);
assert_eq!(s.pending, 0);
}
#[test]
fn find_resolves_documented_and_pending_entries() {
assert_eq!(find("persona").map(|i| i.name), Some("persona"));
assert_eq!(find("axonendpoint").map(|i| i.name), Some("axonendpoint"));
assert!(find("does_not_exist").is_none());
}
#[test]
fn by_category_filters_to_the_named_family() {
let cog: Vec<&str> = by_category("cognition").map(|i| i.name).collect();
assert!(cog.contains(&"persona"));
assert!(cog.contains(&"flow"));
assert!(!cog.contains(&"socket"), "socket is session_types, not cognition");
assert!(!cog.contains(&"axonendpoint"), "axonendpoint is wire, not cognition");
}
#[test]
fn nested_primitives_carry_top_level_false() {
for nested in ["step", "reason", "probe", "validate", "refine", "weave",
"listen", "forge", "transact"] {
let info = find(nested).expect("must be in registry");
assert!(
!info.top_level,
"primitive `{}` should be nested (top_level: false)",
info.name
);
}
}
}