CUBELinux's CZYX coordinate filesystem reimagines storage as a position-in-space-resolves-to-bytes substrate: every byte is addressed by a four-dimensional coordinate — a 256-bit space selector (C) plus three spatial axes (Z, Y, X, each u64) — rather than by path, hostname, or inode. The coordinate layer is implemented in the cube-core crate (no_std, forbid(unsafe_code)) and persists through pluggable backends in cube-store: an in-memory BTreeMap (MemStore), a serialized file-backed store (FileBackedStore), and a hash-based variant (HashStore). A FileHandle abstraction manages buffered I/O with configurable buffer granularity and RAII-backed file descriptor lifetimes.
This paper explores a class of neural architectures we term state-spanning neural networks — models that maintain and propagate internal state across spans of data, capturing patterns that cross both spatial and temporal dimensions — and examines how they might be applied to the CZYX filesystem. The Morton encoding at the heart of CZYX creates a natural bridge between spatial locality and sequential neural processing, making the filesystem a candidate substrate for learned access prediction, compression, anomaly detection, and adaptive caching.
The scope of this paper is architectural exploration, not implementation. We identify five application domains, propose concrete model architectures for each, describe integration points in the existing CUBELinux stack, and assess challenges. The central thesis: CZYX's structure makes neural approaches viable as optional optimizations layered on top of the deterministic storage core, not as replacements for it.
The fundamental type is Coord { space: SpaceId, point: Point }, where SpaceId is a 256-bit identifier ([u8; 32]) and Point { x: u64, y: u64, z: u64 } encodes three spatial axes. A Curve trait maps Point → Key (a 24-byte fixed-length key) and back, with three implementations:
The choice of curve is a first-class configuration decision. It determines the inductive bias of any neural model that operates on coordinate ordering: Morton and Hilbert both create locality-preserving sequences that neural models can exploit; RowMajor does not.
The Store trait abstracts over backends with operations: put(coord, Vec, get(&coord) → Option, delete, range(space, Region), entries(space), flush, and flush_count.
Curve. In-memory, suitable for transient workloads and testing.MAGIC "CUBE" | u8 version=1 | u8 curve_tag) followed by records ([SpaceId 32 bytes][Key 24 bytes][u64 len LE][value bytes]). Supports FileHandle-based I/O: opening a file descriptor, reading/writing at offsets with configurable buffers, seeking, and RAII cleanup via Drop.The FileHandle abstraction is significant for neural applications. It manages a file descriptor with methods: read_at(offset, &mut [u8]) → usize, write_at(offset, &[u8]) → usize, seek_read/current/write, len(), flush(), and set_len(). Buffered variants (BufferedFileHandle) add configurable buffer granularity. Every read and write goes through this abstraction, creating a natural instrumentation point for collecting access traces.
Sequential and spatial access patterns emerge naturally from CZYX usage: range queries over coordinate regions, sequential scans of space entries, and localized read/write clusters around hot coordinates. These patterns are exactly the kind of structured temporal data that state-spanning models can learn from.
We define a state-spanning neural network as a neural architecture that maintains an internal state representation and propagates it across a sequence or structure of inputs, where the span can be:
The key property is that the model's state captures patterns that span beyond individual data points — it learns distributions, correlations, and dynamics across the CZYX substrate.
Recurrent networks (RNN, LSTM, GRU). The simplest state-spanning models. A hidden state ht is updated at each step: ht = f(ht-1, xt). LSTMs and GRUs add gating to manage long-range dependencies. They are natural fits for temporal access sequences — each file access updates the state, and the state informs predictions about future accesses. They are lightweight, well-understood, and can run inference in a few microseconds on CPU.
State Space Models (S4, Mamba). A newer class that models sequences via a linear state space h'(t) = Ah(t) + Bx(t), with y(t) = Ch(t) + Dx(t), often with a selective parameterization that makes them efficient for long sequences. They offer O(N) inference with state sizes that can capture much longer dependencies than LSTMs. For CZYX, they could model very long access traces without the vanishing gradient issues that limit RNNs.
Graph Neural Networks (GNN). Message-passing models that operate on graph-structured data. CZYX's coordinate space is naturally a graph: each coordinate is a node, spatial proximity defines edges (neighbors in ZYX space), and the Portal type in cube-core defines explicit cross-space edges. A GNN could learn representations of coordinate regions, predict link traversals, or propagate information across the cube's association graph.
Transformers with memory. Self-attention over sequences, optionally with persistent memory banks. They excel at capturing long-range dependencies but are computationally heavier. For CZYX, they could model the relationship between distant coordinate accesses, though their quadratic (or sub-quadratic with recent variants) complexity makes lightweight deployment challenging.
Autoencoders and compressive models. Learn compact representations of data. A coordinate-conditioned autoencoder could compress record values by exploiting spatial correlations — records near each other in CZYX space are likely to be similar, and the model can exploit this.
Three properties of CZYX make state-spanning approaches viable:
FileHandle abstraction centralizes all reads and writes. Trace collection (coordinates accessed, operation type, timestamp, result size) can be added with minimal intrusion, creating the training data that state-spanning models need.Store trait and backend independence mean neural components can be added as optional layers without modifying the core storage invariants. The filesystem works identically with or without neural optimization.Problem. Access to CZYX records often exhibits spatial and temporal locality — a read at coordinate c is likely followed by reads at spatially-adjacent coordinates, or by repeated reads to recently-accessed coordinates. The filesystem currently has no mechanism to exploit this; every get is a discrete operation.
Approach. Train a sequence model (LSTM or small state space model) over sequences of accessed Morton keys. At each step, the model receives the current access (Morton key, operation type) and updates its hidden state. The state is used to predict a distribution over likely next accesses. The top-k predictions trigger asynchronous prefetches via FileHandle::read_at into a read cache.
Model details. Input: one-hot or embedded representation of the accessed Morton key (or a binned spatial region), plus operation type (read/write/delete). Hidden state: 64–256 dimensions for an LSTM; 64–128 for a small SSM. Output: probability distribution over a vocabulary of spatially-binning Morton key ranges (not individual keys — the space is too large). Prefetch triggers when the predicted probability exceeds a threshold.
Benefits. Reduced latency for workloads with predictable spatial access patterns. The Morton ordering means a simple model can capture "read at m → likely read at m ± δ" without explicit spatial reasoning.
Cost. Inference per access (target: sub-microsecond for a small LSTM on CPU). Prefetch I/O that may be unnecessary if predictions are wrong. Trace collection overhead (minimal — just logging accesses).
Problem. Record values stored at nearby coordinates may exhibit correlations — adjacent spatial regions might store related data (e.g., consecutive chunks of a file, related metadata entries). The current FileBackedStore stores each record independently, missing compression opportunities across records.
Approach. Train a coordinate-conditioned autoencoder over record values. The encoder compresses a record value into a latent representation, conditioned on the record's coordinate (or its Morton code). The decoder reconstructs the value from the latent plus coordinate context. Nearby coordinates share similar latent representations, enabling compression gains when values are correlated.
Model details. Encoder: small MLP or 1D convolution over the value bytes, with coordinate embedding concatenated as conditioning. Latent dimension: 32–128, depending on value size distribution. The coordinate embedding is a learned lookup over Morton-code bins (not individual coordinates). Training: on a sample of records from a FileBackedStore, using reconstruction loss.
Benefits. Potential storage savings for workloads with spatially-correlated data. The compression is transparent to the Store trait — it operates at the serialization layer in FileBackedStore.
Cost. Encoding/decoding latency per put/get (target: acceptable for batch or cold data, not hot path). Training data requirements (needs a representative sample). Risk of compression artifacts — CUBELinux values correctness; lossy compression must be explicitly controlled.
Problem. The filesystem should detect anomalous access patterns that may indicate corruption, unauthorized access, or system faults. Current detection is rule-based (e.g., I/O errors, invariant violations). A learned model could detect subtler anomalies — unusual access sequences, unexpected write patterns, or deviations from normal spatial access distributions.
Approach. Train a sequence model over operation traces. Each operation is represented as (timestamp, operation_type, coordinate_Morton_bin, result_size, success/failure). The model learns the normal distribution of operation sequences and flags deviations. An LSTM autoencoder trained on normal traces can detect anomalies via reconstruction error: anomalous sequences reconstruct poorly.
Model details. Input representation: a sequence of operation tokens (binned Morton ranges + operation type + outcome). Model: LSTM autoencoder (encoder compresses the sequence into a state, decoder reconstructs it). Anomaly score: mean squared reconstruction error per step, thresholded. Training: on a corpus of normal operation traces; online adaptation to evolving workloads.
Benefits. Early detection of corruption, intrusion, or hardware faults. Complements existing rule-based detection with learned normal behavior.
Cost. Continuous inference on operation streams (can be batched or sampled). False positive risk — thresholds must be calibrated. Privacy: traces never leave the host.
Problem. The range(space, Region) operation iterates over records in a coordinate region. For MemStore, this is a BTreeMap range query; for FileBackedStore, it requires scanning serialized records. Complex queries spanning non-contiguous regions or multiple spaces could benefit from learned access patterns.
Approach. A learned sparse attention or hash model that, given a query region, predicts which Morton key ranges are likely to contain relevant records. This is not a replacement for the BTreeMap — it's a prefilter that narrows the scan range for complex multi-region queries.
Model details. Input: query region specification (space ID + ZYX bounds). Output: a set of predicted Morton key sub-ranges to scan. Model: a small transformer or attention-only network trained on query-result pairs (query → which ranges actually contained results). The Morton ordering means the output is a small set of intervals in 1D Morton space.
Benefits. Faster execution of complex range queries that span multiple spatial regions. Particularly valuable for the cube-index adjacency queries that scan across linked coordinates.
Cost. Model inference per query (acceptable for non-trivial queries; not worth it for simple single-region scans). Training data from query logs. The BTreeMap remains the authoritative index; the learned component is advisory.
Problem. CUBELinux uses flush_count and dirty-flag batching for write optimization, but read caching policies are not specified. A simple LRU cache over recent get results would exploit temporal locality but not spatial locality — a spatially-adjacent access that misses the cache pays full I/O cost.
Approach. A neural cache policy that, given the current cache state and recent access history, decides which entries to evict. The policy learns to retain entries that are likely to be accessed soon, accounting for both temporal recency and spatial proximity to recent accesses.
Model details. Input: cache contents (set of Morton bins), recent access sequence (last N accesses), predicted future accesses (from the access prediction model in 4.1). Output: eviction decisions (which cache entries to remove). Model: a value network or small policy network trained via offline reinforcement learning on access traces, or a simpler heuristic-enhanced network that scores cache entries by predicted utility.
Benefits. Higher cache hit rates than LRU for spatially-structured workloads. The Morton ordering makes spatial proximity tractable for a neural policy.
Cost. Policy inference per cache miss (when eviction is needed). Cache state representation must be compact. The policy must be robust to workload changes — offline training on representative traces, with optional online adaptation.
Neural components integrate at layer boundaries in the existing CUBELinux stack, not inside storage invariants:
Trace collection. Instrument FileHandle::read_at and write_at (and their buffered variants) to emit trace events: (timestamp, operation, coordinate_or_Morton_bin, offset, bytes_transferred, result). The trace collector is a lightweight ring buffer in memory, optionally flushed to a trace file for offline training. Overhead target: <1% of I/O time.
Neural service. The neural models run as a separate component, communicating with the storage layer via a simple IPC channel (shared memory ring buffer, Unix socket, or in-process function calls for embedded models). The service receives trace events, updates model state, and returns predictions/advice. It is optional — if not present, the filesystem operates normally.
Prefetch integration. Predictions from the access prediction model (4.1) trigger FileHandle::read_at calls for predicted addresses into a prefetch buffer. The buffer is a simple LRU cache of recently-read or prefetched record values, keyed by Morton bin. On a get operation, the cache is checked first; on a hit, the value is returned without I/O.
Compression integration. The compression model (4.2) operates at the FileBackedStore serialization layer. On put, the value is compressed by the encoder before writing; on get, the decoder reconstructs it. A configuration flag controls whether compression is active, and a fallback path writes uncompressed if the encoder fails.
Offline training. Initial models are trained on representative access traces collected from a running CUBELinux instance. Traces capture a workload's spatial and temporal access patterns. Training produces model weights that are loaded by the neural service at startup.
Online adaptation. Models adapt to evolving workloads via lightweight online updates — for an LSTM, a few steps of SGD on recent trace windows; for an autoencoder, incremental updates to the latent representation. Adaptation is bounded to avoid catastrophic forgetting of previously-learned patterns.
Per-space models. The 256-bit SpaceId means there can be many distinct spaces. A single global model may not capture per-space patterns. A practical approach: a shared base model with per-space embedding adapters — small per-space parameter sets that adjust the base model's predictions for each space. This keeps the parameter count manageable while allowing space-specific behavior.
Latency. Neural inference must not add meaningful latency to the hot path (get, put). Target: sub-microsecond for embedded models (small LSTM, tiny autoencoder), a few microseconds for larger models. If inference exceeds this, the neural component is disabled for that operation and the filesystem falls back to the non-neural path.
Determinism. CUBELinux values deterministic behavior. Neural components introduce stochasticity (random initialization, stochastic gradient updates, sampling from predicted distributions). The design principle: neural components are optimistic — they suggest prefetches, cache evictions, and compression, but never block or alter the correctness of storage operations. A prefetch that never arrives is a missed optimization, not an error. A cache eviction that removes a needed entry causes a cache miss, not data loss. A decompression that fails falls back to the raw stored value.
Resource bounds. Neural components must not consume unbounded memory or CPU. Model sizes are bounded (e.g., LSTM hidden state ≤ 256 dimensions, autoencoder latent ≤ 128). Trace buffers are ring buffers with fixed capacity. The neural service can be throttled or paused if resource pressure is detected.
The CZYX space is vast: 2256 possible spaces, each with a theoretically unbounded ZYX range. No model can learn a meaningful representation of the entire space. Models must generalize from observed coordinates to unobserved ones, exploiting the locality-preserving properties of Morton and Hilbert curves. Per-space adapters help but don't fully solve this — a space with few observations provides little training signal.
Real workloads access a tiny fraction of the coordinate space, and access is often highly skewed (hot spots, sequential scans, irregular jumps). Models trained on one workload may not generalize to another. Online adaptation helps but requires a warmup period. Cold-start performance (no trace history) is no better than the non-neural baseline.
The value of neural optimization depends on the workload. A sequential scan of a large region benefits little from access prediction (the accesses are already predictable by the scan pattern). A random-access workload with no spatial locality benefits little from spatial models. The neural service should monitor its own effectiveness (prefetch hit rate, cache hit rate improvement, compression ratio) and disable components that aren't helping.
The filesystem's correctness guarantees (no data loss on flush, correct record retrieval, invariant preservation) must not depend on neural components. The design principle — neural components are optimistic — addresses this, but it must be enforced by construction: the neural service never writes data, never deletes records, and never modifies the Store state. It only advises (prefetch, cache eviction, compression) and the storage layer decides whether to act on the advice.
When a neural cache policy evicts a heavily-used entry, or a prefetch model predicts wrong, or a compression model introduces artifacts, debugging requires understanding the model's internal state. This is a known challenge for neural systems. Mitigation: log model decisions with their inputs and confidence scores, maintain a "shadow" non-neural baseline for comparison, and provide a debug mode that disables neural components and replays traces through both paths.
The neural models in 4.1, 4.4, and 4.5 depend on Morton or Hilbert ordering for their spatial locality assumptions. If a workload uses RowMajor ordering, these models lose their inductive bias and may perform no better than random. The system should detect the active curve and adapt — either by using curve-aware models or by falling back to non-spatial heuristics when RowMajor is active.
The CZYX coordinate filesystem's Morton-encoded, locality-preserving structure creates natural opportunities for state-spanning neural networks. Five application domains are viable: access pattern prediction for prefetching, coordinate-conditioned compression, anomaly detection, learned indexing for range queries, and adaptive caching. Each can be implemented as an optional optimization layer on top of the existing storage core, without compromising correctness or determinism.
The strongest near-term opportunity is access pattern prediction with prefetching. It requires only trace collection (instrumenting FileHandle I/O), a small sequence model (LSTM or SSM with ≤256 hidden dimensions), and a prefetch buffer — all implementable with modest engineering effort. The Morton ordering means even a simple model captures meaningful spatial locality, and the prefetch is purely additive — wrong predictions are harmless.
Compression and adaptive caching are intermediate-term opportunities with higher engineering cost but potentially larger impact for suitable workloads. Anomaly detection and learned indexing are longer-term, more exploratory.
The key design principle: neural components are optional, advisory, and bounded. They suggest, the filesystem decides. They adapt, but deterministically. They generalize across the vast coordinate space by exploiting the locality that Morton and Hilbert curves provide, but they acknowledge sparsity and cold starts. They add value for structured workloads and stay out of the way for everything else.
Future work: empirical evaluation of each application domain on real CUBELinux workloads, exploration of state space models (Mamba-class) for long-range access traces, per-space adapter architectures for the 256-bit space ID, and integration with the cube-index adjacency system for graph-based neural models over the coordinate association graph.