Add Gjallar affordance lane to Rust core

This commit is contained in:
Meta Vens 2026-06-04 20:57:02 +01:00
commit fbd93f362b
6 changed files with 143 additions and 20 deletions

View file

@ -18,7 +18,9 @@ CultNet document registries, and lower interface state through Eve/CultUI.
The first Rust core lives in `crates/odin-core` and already separates typed
documents, ingest ports, normalization, and repository persistence so unit tests
can use mocked inputs and pipeline smokes can prove typed handoff without
booting the whole daemon.
booting the whole daemon. Gjallar is part of that spine as a typed
`gjallar.affordance.v1` lane: it transmits Odin-owned sight into agent-ready
affordance records without owning discovery truth.
## Gjallar

View file

@ -6,6 +6,7 @@ pub const ODIN_SERVICE_SCHEMA: &str = "odin.service.v1";
pub const ODIN_INTERFACE_SCHEMA: &str = "odin.interface.v1";
pub const ODIN_OBSERVATION_STREAM_SCHEMA: &str = "odin.observation_stream.v1";
pub const ODIN_TRANSLATION_ROUTE_SCHEMA: &str = "odin.translation_route.v1";
pub const GJALLAR_AFFORDANCE_SCHEMA: &str = "gjallar.affordance.v1";
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(type = "odin.snapshot", schema = "odin.snapshot.v1")]
@ -124,6 +125,29 @@ pub struct OdinTranslationRouteRecord {
pub notes: String,
}
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(type = "gjallar.affordance", schema = "gjallar.affordance.v1")]
pub struct GjallarAffordanceRecord {
#[cultcache(key = 0)]
pub affordance_id: String,
#[cultcache(key = 1)]
pub source_record: String,
#[cultcache(key = 2)]
pub verse_id: Option<String>,
#[cultcache(key = 3)]
pub surface_kind: String,
#[cultcache(key = 4)]
pub action: String,
#[cultcache(key = 5)]
pub authority: String,
#[cultcache(key = 6)]
pub status: String,
#[cultcache(key = 7)]
pub provenance: String,
#[cultcache(key = 8)]
pub observed_at: String,
}
cultmesh_rs::cultmesh_documents!(OdinDocuments {
OdinSnapshotRecord => ODIN_SNAPSHOT_SCHEMA,
OdinVerseRecord => ODIN_VERSE_SCHEMA,
@ -131,6 +155,7 @@ cultmesh_rs::cultmesh_documents!(OdinDocuments {
OdinInterfaceRecord => ODIN_INTERFACE_SCHEMA,
OdinObservationStreamRecord => ODIN_OBSERVATION_STREAM_SCHEMA,
OdinTranslationRouteRecord => ODIN_TRANSLATION_ROUTE_SCHEMA,
GjallarAffordanceRecord => GJALLAR_AFFORDANCE_SCHEMA,
});
#[derive(Clone, Debug, Default, PartialEq, Eq)]
@ -141,4 +166,5 @@ pub struct OdinRecords {
pub interfaces: Vec<OdinInterfaceRecord>,
pub observation_streams: Vec<OdinObservationStreamRecord>,
pub translation_routes: Vec<OdinTranslationRouteRecord>,
pub gjallar_affordances: Vec<GjallarAffordanceRecord>,
}

View file

@ -1,29 +1,31 @@
use crate::documents::{
OdinInterfaceRecord, OdinObservationStreamRecord, OdinRecords, OdinServiceRecord,
OdinSnapshotRecord, OdinTranslationRouteRecord, OdinVerseRecord,
GjallarAffordanceRecord, OdinInterfaceRecord, OdinObservationStreamRecord, OdinRecords,
OdinServiceRecord, OdinSnapshotRecord, OdinTranslationRouteRecord, OdinVerseRecord,
};
use crate::ports::{
Clock, InterfaceIngest, ObservationStreamIngest, OdinInputBatch, ServiceIngest,
TranslationRouteIngest, VerseIngest,
Clock, GjallarAffordanceIngest, InterfaceIngest, ObservationStreamIngest, OdinInputBatch,
ServiceIngest, TranslationRouteIngest, VerseIngest,
};
use anyhow::Result;
pub struct OdinIngestPipeline<V, S, I, O, T, C> {
pub struct OdinIngestPipeline<V, S, I, O, T, G, C> {
verses: V,
services: S,
interfaces: I,
streams: O,
translations: T,
gjallar: G,
clock: C,
}
impl<V, S, I, O, T, C> OdinIngestPipeline<V, S, I, O, T, C>
impl<V, S, I, O, T, G, C> OdinIngestPipeline<V, S, I, O, T, G, C>
where
V: VerseIngest,
S: ServiceIngest,
I: InterfaceIngest,
O: ObservationStreamIngest,
T: TranslationRouteIngest,
G: GjallarAffordanceIngest,
C: Clock,
{
pub fn new(
@ -32,6 +34,7 @@ where
interfaces: I,
streams: O,
translations: T,
gjallar: G,
clock: C,
) -> Self {
Self {
@ -40,6 +43,7 @@ where
interfaces,
streams,
translations,
gjallar,
clock,
}
}
@ -53,6 +57,7 @@ where
interfaces: self.interfaces.observe_interfaces()?,
observation_streams: self.streams.observe_streams()?,
translation_routes: self.translations.observe_translation_routes()?,
gjallar_affordances: self.gjallar.observe_gjallar_affordances()?,
})
}
}
@ -134,6 +139,23 @@ pub fn normalize_odin_records(input: OdinInputBatch) -> OdinRecords {
})
.collect::<Vec<_>>();
let gjallar_affordances = input
.gjallar_affordances
.into_iter()
.enumerate()
.map(|(index, entry)| GjallarAffordanceRecord {
affordance_id: format!("gjallar:{}:{}", entry.source_record, index),
source_record: entry.source_record,
verse_id: entry.verse_id,
surface_kind: entry.surface_kind,
action: entry.action,
authority: entry.authority,
status: entry.status,
provenance: entry.provenance,
observed_at: input.observed_at.clone(),
})
.collect::<Vec<_>>();
let snapshot = OdinSnapshotRecord {
snapshot_id: "latest".to_string(),
observed_at: input.observed_at,
@ -151,6 +173,7 @@ pub fn normalize_odin_records(input: OdinInputBatch) -> OdinRecords {
interfaces,
observation_streams,
translation_routes,
gjallar_affordances,
}
}
@ -158,8 +181,9 @@ pub fn normalize_odin_records(input: OdinInputBatch) -> OdinRecords {
mod tests {
use super::*;
use crate::ports::{
FixedClock, InterfaceObservation, ObservationStreamObservation, ServiceObservation,
TranslationRouteObservation, VerseObservation,
FixedClock, GjallarAffordanceObservation, InterfaceObservation,
ObservationStreamObservation, ServiceObservation, TranslationRouteObservation,
VerseObservation,
};
use anyhow::Result;
use pretty_assertions::assert_eq;
@ -231,6 +255,20 @@ mod tests {
}
}
impl GjallarAffordanceIngest for MockIngest {
fn observe_gjallar_affordances(&self) -> Result<Vec<GjallarAffordanceObservation>> {
Ok(vec![GjallarAffordanceObservation {
source_record: "odin.service:odin".to_string(),
verse_id: Some("starfire.local".to_string()),
surface_kind: "service".to_string(),
action: "inspect".to_string(),
authority: "odin".to_string(),
status: "available".to_string(),
provenance: "unit-test".to_string(),
}])
}
}
#[test]
fn pipeline_collects_from_injected_ports() -> Result<()> {
let pipeline = OdinIngestPipeline::new(
@ -239,6 +277,7 @@ mod tests {
MockIngest,
MockIngest,
MockIngest,
MockIngest,
FixedClock::new("2026-06-03T00:00:00Z"),
);
@ -255,6 +294,10 @@ mod tests {
records.translation_routes[0].route_id,
"mimir.eve_sensor_observation.v1=>odin.observation_stream.v1"
);
assert_eq!(
records.gjallar_affordances[0].affordance_id,
"gjallar:odin.service:odin:0"
);
Ok(())
}
}

View file

@ -49,6 +49,17 @@ pub struct TranslationRouteObservation {
pub notes: String,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct GjallarAffordanceObservation {
pub source_record: String,
pub verse_id: Option<String>,
pub surface_kind: String,
pub action: String,
pub authority: String,
pub status: String,
pub provenance: String,
}
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct OdinInputBatch {
pub observed_at: String,
@ -58,6 +69,7 @@ pub struct OdinInputBatch {
pub interfaces: Vec<InterfaceObservation>,
pub observation_streams: Vec<ObservationStreamObservation>,
pub translation_routes: Vec<TranslationRouteObservation>,
pub gjallar_affordances: Vec<GjallarAffordanceObservation>,
}
pub trait VerseIngest {
@ -80,6 +92,10 @@ pub trait TranslationRouteIngest {
fn observe_translation_routes(&self) -> Result<Vec<TranslationRouteObservation>>;
}
pub trait GjallarAffordanceIngest {
fn observe_gjallar_affordances(&self) -> Result<Vec<GjallarAffordanceObservation>>;
}
pub trait Clock {
fn now(&self) -> String;
}

View file

@ -1,5 +1,6 @@
use crate::documents::{
OdinDocuments, OdinRecords, OdinServiceRecord, OdinSnapshotRecord, OdinVerseRecord,
GjallarAffordanceRecord, OdinDocuments, OdinRecords, OdinServiceRecord, OdinSnapshotRecord,
OdinVerseRecord,
};
use anyhow::Result;
use cultmesh_rs::{CultMesh, CultMeshNode, CultMeshNodeOptions};
@ -38,6 +39,13 @@ impl CultMeshOdinRepository {
self.node.get::<OdinVerseRecord>(verse_id)
}
pub fn get_gjallar_affordance(
&self,
affordance_id: &str,
) -> Result<Option<GjallarAffordanceRecord>> {
self.node.get::<GjallarAffordanceRecord>(affordance_id)
}
pub fn document_binding_version(&self, document_type: &str) -> Option<String> {
self.node
.documents()
@ -66,6 +74,9 @@ impl OdinRepository for CultMeshOdinRepository {
for route in &records.translation_routes {
self.node.put(&route.route_id, route)?;
}
for affordance in &records.gjallar_affordances {
self.node.put(&affordance.affordance_id, affordance)?;
}
Ok(())
}
}
@ -96,8 +107,8 @@ mod tests {
use crate::documents::ODIN_SERVICE_SCHEMA;
use crate::pipeline::normalize_odin_records;
use crate::ports::{
InterfaceObservation, ObservationStreamObservation, OdinInputBatch, ServiceObservation,
TranslationRouteObservation, VerseObservation,
GjallarAffordanceObservation, InterfaceObservation, ObservationStreamObservation,
OdinInputBatch, ServiceObservation, TranslationRouteObservation, VerseObservation,
};
use pretty_assertions::assert_eq;
@ -144,6 +155,15 @@ mod tests {
version: "v1".to_string(),
notes: "test".to_string(),
}],
gjallar_affordances: vec![GjallarAffordanceObservation {
source_record: "odin.service:odin".to_string(),
verse_id: Some("starfire.local".to_string()),
surface_kind: "service".to_string(),
action: "inspect".to_string(),
authority: "odin".to_string(),
status: "available".to_string(),
provenance: "unit-test".to_string(),
}],
})
}
@ -180,6 +200,13 @@ mod tests {
reloaded.get_verse("starfire.local")?.unwrap().capabilities,
vec!["cultmesh".to_string()]
);
assert_eq!(
reloaded
.get_gjallar_affordance("gjallar:odin.service:odin:0")?
.unwrap()
.action,
"inspect"
);
Ok(())
}
}

View file

@ -32,6 +32,7 @@ Verse / host / device / provider inputs
-> ingest ports
-> normalization
-> typed Odin records
-> Gjallar affordance records
-> CultMesh node
-> CultCache .cc persistence
-> CultNet/CultMesh document registry
@ -41,9 +42,12 @@ Verse / host / device / provider inputs
The first Rust core lives in `crates/odin-core`:
- `documents.rs`: typed Odin records and the CultMesh document set.
- `ports.rs`: narrow ingest traits plus clock injection for deterministic tests.
- `pipeline.rs`: collection and normalization from input observations to typed records.
- `repository.rs`: `OdinRepository` abstraction, in-memory mock repository, and CultMesh-backed repository.
- `ports.rs`: narrow ingest traits, Gjallar affordance input, plus clock
injection for deterministic tests.
- `pipeline.rs`: collection and normalization from input observations to typed
records, including `gjallar.affordance.v1`.
- `repository.rs`: `OdinRepository` abstraction, in-memory mock repository, and
CultMesh-backed repository.
The Rust spine owns the future architecture. The CommonJS daemon remains the
legacy operational body until each organ crosses this typed boundary.
@ -53,9 +57,10 @@ legacy operational body until each organ crosses this typed boundary.
Odin's executable body is split by ownership:
- `crates/odin-core`: Rust target core. Owns typed Odin documents, ingest
ports, normalization, and CultMesh/CultCache repository boundaries. This is
the replacement spine; JavaScript remains legacy runtime/probe scaffolding
until each organ has crossed the typed boundary.
ports, Gjallar affordance records, normalization, and CultMesh/CultCache
repository boundaries. This is the replacement spine; JavaScript remains
legacy runtime/probe scaffolding until each organ has crossed the typed
boundary.
- `src/odin-coordinator.cjs`: process lifecycle, refresh loop, persistence, health, and transport wiring.
- `src/odin/config.cjs`: runtime paths, seed deck URLs, intervals, and CultLib module path setup.
- `src/odin/documents.cjs`: CultCache/CultMesh document definitions accepted by Odin.
@ -69,7 +74,9 @@ Odin's executable body is split by ownership:
The entrypoint is not allowed to grow new probe, surface, provider, layout, or renderer policy. If a new owner is needed, name the owner and its invariant before adding code.
Gjallar is the named herald organ for agent-context transmission. Its
Gjallar is the named herald organ for agent-context transmission. In the Rust
spine, Gjallar has a typed `gjallar.affordance.v1` record and an injected
affordance ingest port. Its
current package lives in `docs/gjallar.md`, `personas/gjallar.persona_state.cc`,
`src/Gjallar/Gjallar.csproj`, `assets/personas/gjallar-avatar.png`, and
`assets/personas/gjallar-avatar-pixel-256.png`. When it becomes executable, it
@ -136,7 +143,9 @@ Current Rust verification:
- `pipeline_collects_from_injected_ports`: proves ingest ports and clock injection.
- `memory_repository_supports_fast_unit_tests`: proves repository consumers can test without CultMesh.
- `cultmesh_repository_round_trips_typed_records`: proves typed records persist through CultMesh/CultCache and reload from `.cc`.
- `cultmesh_repository_round_trips_typed_records`: proves typed records,
including Gjallar affordances, persist through CultMesh/CultCache and reload
from `.cc`.
## Service Architecture Contract