feat(core): the streaming substrate — scalars, columns, type-erased edges
Cycle 0001 of the walking-skeleton milestone: the aura-core data substrate
everything streams through.
- scalar.rs: the closed four-type set — Scalar (Copy POD carrier), ScalarKind
(the kind tag), Timestamp (i64 epoch-ns newtype). No boxed Value, no dyn Any,
no heap (C7).
- column.rs: Column<T>, a fixed-capacity bounded-lookback ring pre-sized at
construction (no hot-loop realloc, C8), financial-indexed (index 0 = newest),
carrying a monotonic run_count freshness primitive (C5). Window<'_,T> is its
zero-copy read view with newest-at-0 Index. No RefCell/Rc — a sim is
single-threaded (C1), so push is &mut and read is &.
- any.rs: AnyColumn, the type-erased edge over the four Column kinds. push()
kind-checks at the edge (wiring time) and rejects a wrong-kind value with
KindMismatch, leaving the column untouched; the hot path bypasses the check
via the monomorphic as_*_mut accessors (C7).
- error.rs: KindMismatch { expected, got }, the guard error.
Sharpens the RustAst rtl/ reference (VecDeque + RefCell + boxed Value) into a
fixed ring of Copy scalars with direct dispatch. Node trait, Ctx, firing
policies, and the sim loop are deferred to subsequent cycles.
Verified independently: cargo build --workspace (0 warnings), cargo test
--workspace (14 aura-core tests green incl. ring-wrap, run_count monotonicity,
zero-copy window, and the wrong_kind_push_is_rejected guard), cargo clippy
--workspace --all-targets -D warnings (clean), and a surface-purity grep
confirming no RefCell/Rc/dyn Any on the substrate.
refs #0001-core-streaming-substrate
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
//! `KindMismatch` — the wiring-time guard error for a wrong-kind edge push (C7).
|
||||
|
||||
use crate::scalar::ScalarKind;
|
||||
|
||||
/// Returned by [`crate::AnyColumn::push`] when a `Scalar`'s kind does not match
|
||||
/// the column's kind; the column is left untouched.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct KindMismatch {
|
||||
/// The kind the column holds.
|
||||
pub expected: ScalarKind,
|
||||
/// The kind of the value that was offered.
|
||||
pub got: ScalarKind,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn kind_mismatch_is_a_plain_value() {
|
||||
let e = KindMismatch { expected: ScalarKind::I64, got: ScalarKind::F64 };
|
||||
assert_eq!(e, KindMismatch { expected: ScalarKind::I64, got: ScalarKind::F64 });
|
||||
assert_ne!(e, KindMismatch { expected: ScalarKind::F64, got: ScalarKind::I64 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user