Skip to content

PR: storage: Phase 3 — AsyncFihIo, FlushCapable, chain flush, ColdStorage trait, Time Machine tests #85#86

Draft
metasmile wants to merge 10 commits into
mainfrom
85-sim-phase3
Draft

PR: storage: Phase 3 — AsyncFihIo, FlushCapable, chain flush, ColdStorage trait, Time Machine tests #85#86
metasmile wants to merge 10 commits into
mainfrom
85-sim-phase3

Conversation

@metasmile

@metasmile metasmile commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

PR: storage: Phase 3 — AsyncFihIo, FlushCapable, chain flush, ColdStorage trait, Time Machine tests #85

Summary

Phase 3 completes the storage abstraction stack for NativeFihStorage. It consolidates the FIH storage prototype around a single AsyncFihIo trait, adds chain-based incremental flush (cursor_{ts}.chain), implements ColdStorage + ScanCapable + TimeRangeCapable for DualStorage compatibility, and validates the full StateSpace as a 4D time-travelable storage (Fact × Intent × Hint × time).

Changes

File Change
storage/sim/src/io.rs AsyncFihIo trait with BlockingFihIo wrapper; remove sync FihIo
storage/sim/src/sim_io.rs SimFihIo: deterministic in-memory IO, failure injection
storage/sim/src/fs_io.rs FsFihIo: filesystem-backed IO, WASI compatible
storage/sim/src/intent_status.rs IntentStatus enum state machine (try_claim/heartbeat/conclude)
storage/sim/src/record.rs FactRecord, IntentRecord, HintRecord with postcard serialization
storage/sim/src/index.rs TimeIndex: Vec+(partition_point), first_ts/last_ts
storage/sim/src/session.rs FihSession: hydrate/flush lifecycle wrapper
storage/sim/src/store.rs NativeFihStorage: 8 trait impls, type aliases, is_hotmemory_enabled, ColdStorage + ScanCapable + TimeRangeCapable + chain flush
storage/sim/src/main.rs 15-check verification runner (cargo run)
storage/sim/tests/concurrency.rs 6 concurrent access tests
storage/sim/tests/gaps.rs 6 gap coverage tests
storage/sim/tests/time_filter.rs 6 deterministic time-index filter tests
storage/sim/tests/foundational_scenarios.rs 4 SSCCS document scenario tests
storage/sim/tests/gateway_scenarios.rs 1 MockGateway round-trip test
storage/sim/tests/time_machine.rs 8 StateSpace time-travel tests (NEW)
storage/sim/tests/common/mod.rs FakeClock + Fact/Intent helpers

Key Design Decisions

  • Chain flush: Each flush writes cursor_{ts}.chain containing only delta records since the previous cursor. File count = O(flush count), not O(record count). Enables incremental replay.
  • Postcard over bincode: bincode is a discontinued project. Postcard provides the same zero-copy deserialization semantics and is actively maintained.
  • is_hotmemory_enabled: When NativeFihStorage serves as ColdStorage (DualStorage cold half), in-memory caches are skipped — all reads go directly to IO, saving memory.
  • Type aliases: FactCache, IntentCache, HintCache, RefCounts, OriginIndex isolate the concrete map type. Switching from HashMap to BTreeMap requires only 5 alias lines.

4D StateSpace (Storage Paradigm)

nexus storage is not a graph database. It is a 4D StateSpace:

Fact axis (immutable observations)    ×
Intent axis (active operations)       ×
Hint axis (ephemeral signals)         ×
Time axis (delta chain, time-travel)

Coordinate traversal (moving along axes, projecting across dimensions) IS the query mechanism. Cypher translation is optional syntactic sugar — the native API (FilterCapable + TimeIndex + by_from_fact) already provides the full coordinate algebra.

Validation

Check Result
cargo test 70/70 pass (62 + 8 time_machine)
cargo run 15/15 pass
cargo clippy -- -D warnings 0 warnings
cargo build --target wasm32-unknown-unknown OK
run.sh --core (fmt + clippy + test) All checks passed

Follow-up Issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant