Skip to main content

Module cortex

Module cortex 

Source
Expand description

CortEX + RedEX + NetDb surface.

Re-exports of the core event-sourced storage layer so SDK users can open typed domain adapters (tasks, memories) without depending on the net crate directly.

§Entry points

§Example

use net_sdk::cortex::{NetDb, Redex};

let redex = Redex::new();
let db = NetDb::builder(redex)
    .origin(0xABCD_EF01)
    .with_tasks()
    .with_memories()
    .build()
    .await?;

// Drive the tasks adapter:
let seq = db.tasks().create(1, "write docs", 0)?;
db.tasks().wait_for_seq(seq).await;

// Snapshot + watch for reactive UI:
let watcher = db.tasks().watch();
let (snapshot, _stream) = db.tasks().snapshot_and_watch(watcher);
assert_eq!(snapshot.len(), 1);

§Persistence

Disk-backed files need Redex::with_persistent_dir. Pair with NetDbBuilder::persistent(true) to route every enabled model’s RedEX file through the disk segment:

let redex = Redex::new().with_persistent_dir("/var/lib/net/redex");
let db = NetDb::builder(redex)
    .origin(0xABCD_EF01)
    .persistent(true)
    .with_tasks()
    .build()
    .await?;

Structs§

EventEnvelope
A straightforward envelope pairing an EventMeta with its payload tail. Use this when CortEX’s richer envelope type is not needed (tests, simple callers, the v1 adapter wire-up).
EventMeta
Fixed 24-byte prefix on every payload appended through the CortEX adapter.
MemoriesAdapter
Typed wrapper around CortexAdapter<MemoriesState> that exposes domain-level operations (store, retag, pin, unpin, delete) and hides the EventMeta + postcard plumbing.
MemoriesFilter
Filter for find_many / count_where / exists_where over super::state::MemoriesState. All fields are optional.
MemoriesQuery
Fluent query over MemoriesState. Created via MemoriesState::query.
MemoriesState
Materialized view over the memories log.
MemoriesWatcher
Reactive filter over MemoriesState. Created via super::MemoriesAdapter::watch.
Memory
A content-addressable memory record: a piece of content plus tag metadata, source identity, and a pinned flag.
NetDb
Unified NetDB handle.
NetDbBuilder
Builder for NetDb.
NetDbSnapshot
Portable, postcard-serialisable bundle of per-model snapshots. Returned by NetDb::snapshot; consumed by NetDbBuilder::build_from_snapshot.
OrderedAppender
Single-threaded deterministic appender over a RedexFile.
Redex
Manager for a set of RedEX files bound to channel names.
RedexEvent
A materialized RedEX event: the 20-byte index record plus the payload bytes.
RedexFile
A handle to a RedEX file. Cheap to clone.
RedexFileConfig
Per-file configuration supplied at Redex::open_file time.
Task
The canonical task record held in super::state::TasksState.
TasksAdapter
Typed wrapper around CortexAdapter<TasksState> that exposes domain-level operations (create, rename, complete, delete) and hides the EventMeta + postcard plumbing.
TasksFilter
Filter for find_many / count_where / exists_where over super::state::TasksState. All fields are optional and default to “no constraint” on that axis.
TasksQuery
Fluent query over TasksState.
TasksState
Materialized view over the tasks log.
TasksWatcher
Reactive filter over TasksState. Created via super::TasksAdapter::watch.
TypedRedexFile
Typed wrapper over a RedexFile. T is the domain event type; it must be Serialize + DeserializeOwned for postcard.

Enums§

CortexAdapterError
Errors produced by super::CortexAdapter operations.
FsyncPolicy
Disk-side fsync policy for persistent RedexFiles.
MemoriesOrderBy
Ordering for query results.
NetDbError
Errors produced by super::NetDb / super::NetDbBuilder / super::NetDbSnapshot.
RedexError
Errors produced by RedEX operations.
TaskStatus
Lifecycle state of a task.
TasksOrderBy
Re-export of the tasks-module OrderBy enum. Aliased so the memories variant can coexist in this flat namespace. Ordering for query results.

Constants§

DISPATCH_TASK_COMPLETED
A task was marked completed.
DISPATCH_TASK_CREATED
A task was created.
DISPATCH_TASK_DELETED
A task was deleted.
DISPATCH_TASK_RENAMED
A task’s title was changed.
EVENT_META_SIZE
Size of an EventMeta in its wire / on-disk format.
MEMORIES_CHANNEL
Canonical channel name for the memories model.
TASKS_CHANNEL
Canonical channel name for the tasks model.

Traits§

IntoRedexPayload
Project a caller type into a RedEX payload.

Functions§

compute_checksum
Legacy tail-only checksum. The xxh3 hash of the payload bytes after the 24-byte EventMeta prefix, truncated to the low 32 bits.

Type Aliases§

MemoryId
Identifier for a memory. Opaque u64; callers derive however they want (content hash, snowflake id, sequential).
TaskId
Identifier for a task. Opaque u64; callers derive however they want (sequential, hash of title, snowflake id, etc.).