datasloshing append-only temporal-mesh mars-sim
We had 1,087 sol-level frames driving the Mars colony simulation. Each frame is one Mars day — 24 hours and 39 minutes of weather, hazards, and terrain data compressed into a single snapshot. The 3D RTS view cycled through them, but the transitions were abrupt. Temperature jumped. Wind shifted instantly. The colony existed in a world of discrete daily snapshots.
The question: how do you add intra-day fidelity without changing any existing frame?
The solution is borrowed from three domains simultaneously:
The core insight: sol frames are keyframes. They are immutable. Sacred. Hash-chained. They never change.
Between them, we generate sub-frames — derived entirely from the surrounding keyframes using physical interpolation. Each sub-frame is computed from the previous sub-frame and must converge back to the next keyframe.
Sub-frames are append-only. They are a separate data layer that sits alongside the sol keyframes. Delete the sub-frame layer and you still have the original simulation — perfectly intact, hash-verified, zero data loss.
This is the critical constraint: the subdivision algorithm can only create new frames by sloshing from the last sub-frame, without changing anything in the next keyframe. The boundary conditions are locked. The timeline is sacred.
If you can only append — never modify — then corruption can only happen at the tail. Truncate and you're back to known-good state.
Sub-frames aren't just linear interpolation. They encode real Mars diurnal physics:
sin(π × (hour-6)/12)Sub-frames participate in the hash chain. Within each sol, sub-frames chain from the sol keyframe hash:
Sol 1: _hash = "abc123", _prev_hash = "genesis"
Sub 1.25: _hash = "def456", _prev_hash = "abc123"
Sub 1.50: _hash = "ghi789", _prev_hash = "def456"
Sub 1.75: _hash = "jkl012", _prev_hash = "ghi789"
Sol 2: _hash = "mno345", _prev_hash = "abc123" ← chains to SOL, not sub
Corrupt a sub-frame? The client detects the chain break and falls back to sol-level data. The keyframes are always valid.
One script, one command:
node tools/subdivide-frames.js --depth 2
This generates 3,258 quarter-day sub-frames from 1,087 sol keyframes. Depth 3 would give 8,688 eighth-day sub-frames. The RTS view loads them as a progressive enhancement — if the sub-frame file isn't available, it falls back to sol-level with synthetic diurnal curves.
This pattern — immutable keyframes + derived sub-frames + hash chains + auto-rollback — is how you build data systems that can withstand corruption, grow fidelity infinitely, and never lose ground.
On actual Mars, you would never overwrite telemetry. Every reading is appended. If a sensor glitches, you roll back to the last valid reading. If you need higher temporal resolution, you interpolate between known-good points with physics constraints. The simulation should work the same way.
The colony doesn't jump between days anymore. The sun rises. The temperature climbs. The wind picks up at noon. The dust settles at dusk. And every bit of it is derived from immutable, hash-verified source data.