Skip to content

tape: thin by fire rank, not by tick index - #6

Merged
valeratrades merged 4 commits into
mainfrom
tape-fire-aware-thinning
Aug 8, 2026
Merged

valeratrades merged 4 commits into
mainfrom
tape-fire-aware-thinning

Conversation

@valeratrades

Copy link
Copy Markdown
Contributor

Tape::thin decimated by tick index: newest capacity/2 whole, plus every stride-th tick before them. At spl's 318k ticks against a 20 000 tape that stride settled on 64, so:

  • Space stepped 64 real ticks — ~35s of venue time against a 60s chart bucket.
  • n/b/c crossed 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 kept 576/64 ≈ 9 of 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 Tick carries ranks, positional with topology: 0 where the node didn't fire, else 1 + trailing_zeros of its 0-based fire ordinal. "Keep one fire in 2^k of node i" is then the single comparison ranks[i] > keep[i] — computed once, never restated, and the kept sets nest as k grows, which is what lets thin stay a monotone subset filter.

keep is per node and rises max-min fairly: count retained fires per node over the pre-tail stretch, and while the union exceeds capacity/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_zeros saturates above every keep, 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::drop and Recorder::at — shared with live — are byte-identical, including the recycled Acts buffers. That is why the rank column lands on Tick and not on Acts.

Measured on the real spl graph (--days 1, SCROLLBACK 20 000), fires reachable by step_until walking from tick 0:

node of median step
Ohlc:5m / Bar:5m 286/288 5.00 min
Ohlc:1m 1294/1440 1.00 min
Bar:1h 23/24 60.00 min

Second, independent bug

scan with no hit called park(p) with p == last, so a failed search teleported the cursor to the end of the recording. Now: park when found; park at last when unsealed and not found (there, parking forward is the resume point for the stateless re-issue, and pending already says so); on a sealed tape with no hit, leave the cursor alone. ActivationFrame::found says so on the wire — including for a step_until on a name the graph doesn't carry, which used to report success.

ActivationFrame::gap carries how many absolute ticks a retained step covered; the nav shows ×n when it is more than one, so a jump reads as a resolution the tape is admitting to.

Part 2 — capacity, measured

capacity is this crate's knob and nothing told a consumer how to pick it. Viz::bytes (the one new pub) reports retained bytes, and exec_viz/examples/capacity.rs sweeps capacity for footprint, cursor latency and per-node addressability, splicing the block into docs/.readme_assets/other.md — the viz_cost.rs → cost.json → cost.typ precedent, 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 capacity at all, footprint is linear, and cursor latency is dominated by a loopback hop until ~262k retained ticks.

TAPE_SCHEMA bumped 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 old thin) and a_scan_that_finds_nothing_stays_put.
  • cargo r --release -p exec_viz --example capacity — the sweep; docs/capacity.txt and the spliced block agree.
  • Real spl replay driven over /api/*: table above; gap reads 1 throughout the whole-kept tail and 1–78 across the thinned front.

Pairs with EV-invest/trading_data#(spl SCROLLBACK comment).

🤖 Generated with Claude Code

valeratrades and others added 4 commits August 8, 2026 18:16
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
valeratrades merged commit 7304bca into main Aug 8, 2026
24 of 29 checks passed
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>
@valeratrades
valeratrades deleted the tape-fire-aware-thinning branch August 9, 2026 00:16
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