PR: storage/sim — NativeFIH storage interface prototype with FihIo abstraction #{83}#84
Merged
Conversation
…n #{83}
Phase 1 of #83: Interface skeleton with sync core + abstract IO layer.
storage/sim/src/
io.rs — FihIo trait, WriteOp enum, FihIoBatch
sim_io.rs — SimFihIo (HashMap-backed, deterministic, failure injection)
record.rs — FactRecord, IntentRecord, HintRecord, IntentStatus enum
intent_status.rs — IntentStatus lifecycle transitions (compile-time)
store.rs — NativeFihStorage<I: FihIo> — FactCapable, IntentCapable,
HintCapable, StorageRead, EvictCapable, FilterCapable
session.rs — FihSession<I: FihIo> — hydrate/buffer/flush lifecycle
…_intent real IDs #{83}
…HintCapable + IntentCapable) #{83}
…ve unused StorageRead in blackboard test #{83}
…lude_intent #{83}
…ng, by_origin index #{83}
…filtered TimeIndex use; add cross-validation tests #{83}
Reformat the early‑return path in `read_state_filtered` so it is not swallowed by the outer `if let` block. Remove unused `FactCapable` import from the integration test.
…imeIndex; add time-travel test #{83}
…l/range/empty coverage #{83}
23 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces
storage/sim, the storage-layer simulator for the nexus FIH engine. It serves as the interface prototype forNativeFihStorage(#81) and the deterministic testbed for scenario-driven verification (#69).Architecture
Core design decisions
FihIo: single IO abstraction
Replaces
DualStorage { hot: PetgraphStorage, cold: CompositeColdStorage { MetaStore + BlobStore + ObjectStore } }with a singleFihIotrait. Every storage backend (disk, S3, SQLite, CF KV) implements this trait. The core storage logic never calls IO directly — all writes go through a pending buffer and are batch-committed byFihSession::flush().NativeFihStorage<I: FihIo>: sync core + async buffer
All FIH trait methods (
FactCapable,IntentCapable,HintCapable,StorageRead,EvictCapable,FilterCapable) are sync. They enqueueWriteOps into a pending buffer. The outerFihSessionlayer provideshydrate() → (read/write) → flush()lifecycle. TheNowtrait is injected viawith_clock()for platform-independent time (nativeSystemClock, WASMWasmClock, testFakeClock).Blackboard as aggregate trait
Blackboardis nowStorageRead + FactCapable + HintCapable + IntentCapablewith a blanket impl. Any type implementing the four capability traits automatically satisfiesBlackboard. No duplicateread_state()betweenBlackboardandStorageRead.TimeIndex: O(log N) temporal seek
Vec<(u64, String)>withpartition_pointbinary search. Append-only — FIH's monotonically increasingsubmitted_atguarantees push order equals time order. Providessince(),as_of(),range()for time-travel queries.Ref_count: O(1) orphan detection
AtomicU64per Fact. Incremented onsubmit_intent(), decremented onconclude_intent(). Orphan detection is an O(1)load()check.Changes vs existing
nextestsAll existing nex scenario tests (
d_gateway_scenarios,foundational_scenarios) were ported to run againstNativeFihStorage<SimFihIo>by changing only the storage initialization. Test logic is identical — storage is the only variable.Test results
Relationship to other issues
storage/simprovides the deterministic storage backend for attack scenario execution.gateway/nex-cfnow usesNativeFihStorage<SimFihIo>pattern (reflected inSyncOnce). The CF Worker was the stress-test vehicle that drove all wasm32 compatibility fixes.storage/simis the interface prototype forNativeFihStorage. All trait contracts verified. Production implementation (encryption, tiering, FPGA) builds on this interface.