feat: M1 lumen-core (FEC/crypto/packet/session + C ABI) and workspace scaffold
Ground-up low-latency streaming stack per docs/implementation-plan.md. M1 is
complete and tested; Linux host backends are cfg-gated stubs to be filled in on
real hardware (M0/M2).
lumen-core (built + tested on macOS/aarch64 — 21 tests):
- fec: ErasureCoder over GF(2^8) (reed-solomon-erasure, Moonlight-compatible)
and GF(2^16) Leopard-RS (reed-solomon-simd, the >1 Gbps wall-breaker); proptested
- packet: zero-copy #[repr(C)] framing, multi-block, FEC-aware reassembly
- crypto: AES-128-GCM with per-direction nonce salts + sequence-as-AAD
- session: host submit / client poll hot paths + input; loopback & UDP transports
- abi: opaque handles, versioned LumenConfig, panic guards; cbindgen-generated header
- acceptance: Rust loopback+proptest and a C harness that links the staticlib
Scaffold (compiles green on all platforms): lumen-host (vdisplay/capture/encode/
inject/web/pipeline seams under cfg(linux)), lumen-client-rs, tools/{loss-harness,
latency-probe}, Apple/Android client stubs, Gitea CI, docs.
Hardened against a multi-agent adversarial review (13 verified findings fixed,
regression-tested): reassembler memory-DoS bounds + block-consistency validation,
GCM nonce-reuse direction separation, ABI struct_size guard + range checks, FEC
shard-length guards, shard_payload datagram bound, key zeroization + Debug redaction.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
//! Error type and the stable C ABI status codes it maps to.
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
/// The core's internal error type. Crosses the C ABI as a [`LumenStatus`] code.
|
||||
#[derive(Debug, Error)]
|
||||
pub enum LumenError {
|
||||
#[error("invalid argument: {0}")]
|
||||
InvalidArg(&'static str),
|
||||
#[error("fec error: {0}")]
|
||||
Fec(#[from] crate::fec::FecError),
|
||||
#[error("crypto seal/open failed")]
|
||||
Crypto,
|
||||
#[error("malformed packet")]
|
||||
BadPacket,
|
||||
#[error("no complete frame available yet")]
|
||||
NoFrame,
|
||||
#[error("unsupported: {0}")]
|
||||
Unsupported(&'static str),
|
||||
#[error("io error: {0}")]
|
||||
Io(#[from] std::io::Error),
|
||||
}
|
||||
|
||||
pub type Result<T> = core::result::Result<T, LumenError>;
|
||||
|
||||
/// Stable C ABI status codes. `Ok` is 0; all errors are negative so callers can
|
||||
/// test `rc < 0`. Do not renumber existing variants — only append.
|
||||
#[repr(i32)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum LumenStatus {
|
||||
Ok = 0,
|
||||
InvalidArg = -1,
|
||||
Fec = -2,
|
||||
Crypto = -3,
|
||||
BadPacket = -4,
|
||||
NoFrame = -5,
|
||||
Unsupported = -6,
|
||||
Io = -7,
|
||||
NullPointer = -8,
|
||||
Panic = -99,
|
||||
}
|
||||
|
||||
impl LumenError {
|
||||
/// Map to the C ABI status code.
|
||||
pub fn status(&self) -> LumenStatus {
|
||||
match self {
|
||||
LumenError::InvalidArg(_) => LumenStatus::InvalidArg,
|
||||
LumenError::Fec(_) => LumenStatus::Fec,
|
||||
LumenError::Crypto => LumenStatus::Crypto,
|
||||
LumenError::BadPacket => LumenStatus::BadPacket,
|
||||
LumenError::NoFrame => LumenStatus::NoFrame,
|
||||
LumenError::Unsupported(_) => LumenStatus::Unsupported,
|
||||
LumenError::Io(_) => LumenStatus::Io,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user