Repository navigation
tape: thin by fire rank, not by tick index - #6
Merged
Merged
Conversation
The recording was the storage and the storage was memory, so a run was only ever lookable-at while the process that made it was alive. `Viz::save` writes the tape down and `Viz::load` reads one back, sealed — a run recorded today is scrubbable next week, and whether a UI was attached while it ran is now a separate question from whether it was recorded. What made this awkward is that the one recorder is usually swallowed by whatever the app hands it to, leaving nobody holding a `seal` to wait on. So the tape thread's join moves onto `Viz`, where the read side can reach it; `Recorder::seal` is now that same wait behind a dropped handoff, and means what it always did. msgpack behind a magic + a `TAPE_SCHEMA` that refuses a layout this build does not read. Not JSON — a 20k-tick tape is tens of thousands of f64 columns — and not parquet, which is a far heavier dependency than a study-tool snapshot warrants. Not bincode either: it cannot decode `FidelityOut`'s internally tagged enum, which needs a self-describing format. `web_dir` becomes askable rather than fatal, so a driver can decide whether to serve instead of hardcoding this crate's env var name on its side of the wall.
Thinning decimated by tick index, so what survived a long run was whatever happened to sit at a multiple of the stride. At spl's 318k ticks against a 20 000 tape that stride settled on 64, and a 5-minute bar that fired 576 times over the window kept nine of them — `n` crossed five hours a press, and Space stepped 64 real ticks. Proximity to the buffer is not proximity to the problem. What a scrub is for is the rare event, and an index-blind stride destroys precisely those. So the unit of decimation is now the fire: each tick carries `ranks`, the `trailing_zeros` of each firing node's ordinal, and "keep one fire in 2^k" is `ranks[i] > k`. `keep` rises max-min fairly — raise the greediest node's exponent until the backbone fits — so the book flood absorbs the whole squeeze and a node that never dominates never loses a fire. The ordinal is 0-based, so its first fire saturates above every k and the front of the recording stays addressable. The column rides on `Tick` and not on `Acts`: those buffers are the graph thread's, recycled across the handoff, and the leg shared with live is untouched. Also, a scan that walks a sealed recording to its end without a hit no longer parks at that end — a failed search kept its answer and threw away where the user was reading. `found` says so on the wire; `gap` says how many absolute ticks a retained step covered, which the nav shows. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`step_until` on a name absent from the topology took the non-scan path and so reported `found: true` — pressing `c` before a run has a `Classify` read as a key that worked. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
valeratrades
added a commit
that referenced
this pull request
Aug 8, 2026
* feat(tape): a tape you can write down and reopen The recording was the storage and the storage was memory, so a run was only ever lookable-at while the process that made it was alive. `Viz::save` writes the tape down and `Viz::load` reads one back, sealed — a run recorded today is scrubbable next week, and whether a UI was attached while it ran is now a separate question from whether it was recorded. What made this awkward is that the one recorder is usually swallowed by whatever the app hands it to, leaving nobody holding a `seal` to wait on. So the tape thread's join moves onto `Viz`, where the read side can reach it; `Recorder::seal` is now that same wait behind a dropped handoff, and means what it always did. msgpack behind a magic + a `TAPE_SCHEMA` that refuses a layout this build does not read. Not JSON — a 20k-tick tape is tens of thousands of f64 columns — and not parquet, which is a far heavier dependency than a study-tool snapshot warrants. Not bincode either: it cannot decode `FidelityOut`'s internally tagged enum, which needs a self-describing format. `web_dir` becomes askable rather than fatal, so a driver can decide whether to serve instead of hardcoding this crate's env var name on its side of the wall. * tape/ a stride keeps what is near, not what is rare Thinning decimated by tick index, so what survived a long run was whatever happened to sit at a multiple of the stride. At spl's 318k ticks against a 20 000 tape that stride settled on 64, and a 5-minute bar that fired 576 times over the window kept nine of them — `n` crossed five hours a press, and Space stepped 64 real ticks. Proximity to the buffer is not proximity to the problem. What a scrub is for is the rare event, and an index-blind stride destroys precisely those. So the unit of decimation is now the fire: each tick carries `ranks`, the `trailing_zeros` of each firing node's ordinal, and "keep one fire in 2^k" is `ranks[i] > k`. `keep` rises max-min fairly — raise the greediest node's exponent until the backbone fits — so the book flood absorbs the whole squeeze and a node that never dominates never loses a fire. The ordinal is 0-based, so its first fire saturates above every k and the front of the recording stays addressable. The column rides on `Tick` and not on `Acts`: those buffers are the graph thread's, recycled across the handoff, and the leg shared with live is untouched. Also, a scan that walks a sealed recording to its end without a hit no longer parks at that end — a failed search kept its answer and threw away where the user was reading. `found` says so on the wire; `gap` says how many absolute ticks a retained step covered, which the nav shows. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fixup: a name the graph does not carry is a search that reached nothing `step_until` on a name absent from the topology took the non-scan path and so reported `found: true` — pressing `c` before a run has a `Classify` read as a key that worked. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fmt/ codestyle and treefmt over the new example Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Tape::thindecimated by tick index: newestcapacity/2whole, plus everystride-th tick before them. At spl's 318k ticks against a 20 000 tape that stride settled on 64, so:n/b/ccrossed five hours a press.scan's hit test needs the node to have fired on the exact retained tick, and thinning keeps ticks at fixed absolute positions. A 5-minute bar firing 576 times over the window kept576/64 ≈ 9of them.Proximity to the buffer is not proximity to the problem. What a human scrubs a tape for is the rare event, and an index-blind stride destroys precisely those.
The unit of decimation is now the fire
Each
Tickcarriesranks, positional withtopology:0where the node didn't fire, else1 + trailing_zerosof its 0-based fire ordinal. "Keep one fire in2^kof nodei" is then the single comparisonranks[i] > keep[i]— computed once, never restated, and the kept sets nest askgrows, which is what letsthinstay a monotone subset filter.keepis per node and rises max-min fairly: count retained fires per node over the pre-tail stretch, and while the union exceedscapacity/4, raise the greediest node's exponent. Busy nodes absorb the whole squeeze; a node that never dominates never loses a fire. The pass's guarantees are unchanged — retained ≤3/4 capacity, so it still frees between a quarter and a half of the buffer, which is what sizes the recycle channel.A node's first fire has ordinal 0, whose
trailing_zerossaturates above everykeep, so it survives every squeeze — that is what keeps the front of a long recording addressable now that no index is privileged.The graph thread's leg is untouched.
Rec::on,Rec::dropandRecorder::at— shared with live — are byte-identical, including the recycledActsbuffers. That is why the rank column lands onTickand not onActs.Measured on the real spl graph (
--days 1,SCROLLBACK20 000), fires reachable bystep_untilwalking from tick 0:Ohlc:5m/Bar:5mOhlc:1mBar:1hSecond, independent bug
scanwith no hit calledpark(p)withp == last, so a failed search teleported the cursor to the end of the recording. Now: park when found; park atlastwhen unsealed and not found (there, parking forward is the resume point for the stateless re-issue, andpendingalready says so); on a sealed tape with no hit, leave the cursor alone.ActivationFrame::foundsays so on the wire — including for astep_untilon a name the graph doesn't carry, which used to report success.ActivationFrame::gapcarries how many absolute ticks a retained step covered; the nav shows×nwhen it is more than one, so a jump reads as a resolution the tape is admitting to.Part 2 —
capacity, measuredcapacityis this crate's knob and nothing told a consumer how to pick it.Viz::bytes(the one newpub) reports retained bytes, andexec_viz/examples/capacity.rssweepscapacityfor footprint, cursor latency and per-node addressability, splicing the block intodocs/.readme_assets/other.md— theviz_cost.rs→cost.json→cost.typprecedent, so the prose can say "measured" and mean it. The example drives the tape over the served API, which is the same door a consumer has.The headline it produces: recording cost doesn't move with
capacityat all, footprint is linear, and cursor latency is dominated by a loopback hop until ~262k retained ticks.TAPE_SCHEMAbumped to 2 for the rank column.Verification
cargo t -p exec_viz— 9/9, including two new:a_rare_node_keeps_its_fires_past_the_capacity(fails against the oldthin) anda_scan_that_finds_nothing_stays_put.cargo r --release -p exec_viz --example capacity— the sweep;docs/capacity.txtand the spliced block agree./api/*: table above;gapreads1throughout the whole-kept tail and 1–78 across the thinned front.Pairs with EV-invest/trading_data#(spl
SCROLLBACKcomment).🤖 Generated with Claude Code