forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on main

2026-09-24

test(anamorphic): the anamorphic fixtures and the suite that pins themAhmet Kaan Gümüş · db45d3c
test(anamorphic): the anamorphic fixtures and the suite that pins them

scripts/gen_fixtures.sh grows the anamorphic block: test_anamorphic.mp4
and .mkv, one 1440x1080 setsar=4/3 source in each container (mkvmerge is
not installed; ffmpeg's own Display* output is the source of truth), and
test_anamorphic_hevc.mkv for the copy door, which only copies HEVC or
AV1 Matroska.

crates/engine/tests/anamorphic.rs pins the whole contract on them:
- the probe reads coded 1440x1080 and drawn 4/3 off both doors, the
  ratio compared reduced because the mkv carries ffmpeg's DAR spelling
  (17280/12960) where the mp4 carries the SAR itself;
- the preview hands out 1920x1080 with picture in every corner (numeric
  gate) and a measured 16:9 display aspect;
- the export re-encodes to the drawn shape, square, the same picture
  the preview showed within encode loss;
- the Matroska copy keeps the aspect beside the coded blocks (read
  back), and the mp4 Exact row refuses in the words 'a copy would lose
  the pixel aspect';
- square files still read one to one, swapped only where their matrix
  turns them.

The HEVC-door tests skip on a machine without the plugin, as
video_copy's decode-back test does.
copy(exact): the copy door keeps the pixel aspect, and an mp4 copy refuses itAhmet Kaan Gümüş · 312b13e
copy(exact): the copy door keeps the pixel aspect, and an mp4 copy refuses it

ffmpeg's own copy behaviour: the blocks are the source's coded pixels
and the aspect travels with them as container metadata. The Matroska
copy door now does that: CopyPlan compares CODED to CODED (the display
comparison would refuse every anamorphic source and then lie about the
track it wrote), declares the source's coded pair, and writes the
source's aspect as Display* elements -- unit 4, the SAR itself, the
ratio this engine's reader reproduces exactly. A square copy writes no
Display* at all, so every existing copy's header is byte-identical.

The mp4 copy cannot carry it: the sample entry this writer produces has
no pasp box, and a header that declares the coded pair while the pixels
are drawn 4/3 wide lies about its own shape. Refused by name -- 'a copy
would lose the pixel aspect' -- before the container's codec sentence,
so the export re-encodes into the square pixels the picture is drawn at
(mp4 export measured: 1920x1080, square).
fix(decode): size the stretch buffers before the resampleAhmet Kaan Gümüş · c3f9e0a
fix(decode): size the stretch buffers before the resample

scale_i420 asserts exact planes; the stretch buffers were empty
Vecs, so the first anamorphic frame died on the destination-luma
assertion instead of being stretched. Sized with the rest of the
steady-state scratch, once per worker, exactly as  is.
apply(decode): stretch the anamorphic picture once, at the single post-decode stepAhmet Kaan Gümüş · b3a5acb
apply(decode): stretch the anamorphic picture once, at the single post-decode step

ffmpeg applies the sample aspect exactly once, at the conversion to the
square-pixel raster; so does this engine now. Render::frame takes the
file's pixel_aspect beside its rotation and, only where the samples are
not square, resamples the coded picture to the displayed width with the
existing scale_i420 -- the same bilinear the canvas places through. A
square-pixel file takes the branch by a bool and not one byte is
touched: the passthrough fast path, the tonemap FNV constants and the
graded path are all exactly what they were (matrix_render and
tonemap_render green unchanged).

The export takes the same two facts through place_picture -- stretch
after turn, the order ffmpeg composes -- and an anamorphic span is
barred from the DMA fast path, whose whole premise is that no seat
touches a sample before the encoder. Dissolve's B half carries its own
file's aspect beside its own rotation.

VhMeta grows the coded pair and the aspect ratio, so the plugin ABI
answers both questions a display size may now raise: what to draw and
what the samples are stored at.
probe(demux): sample aspect ratio off the container, coded dims beside the display pairAhmet Kaan Gümüş · 66a1c40
probe(demux): sample aspect ratio off the container, coded dims beside the display pair

ffmpeg's model: the decoder keeps coded pixels and carries the SAR as
metadata. VideoMeta carries the pair now: coded_width/coded_height are
what the samples are stored at, pixel_aspect is the ratio one coded
pixel is drawn at (PixelAspect, square when nothing is stated), and
width/height stay the displayed shape their docs always promised --
stretched by the aspect, then swapped by the turn, in that order.

mkv: DisplayWidth/DisplayHeight/DisplayUnit read off the Video element
(units 3 DAR and 4 SAR; absent, or units 0/1/2, square -- measured
against ffmpeg 8.1.2, which writes a 16/9 DAR pair with unit 3 for a
setsar=4/3 source and nothing at all for a square one).
mp4: pasp (hSpacing/vSpacing) out of the visual sample entry, behind
the same fixed 78-byte header colr and hvcC sit behind, absent = square
-- measured: ffmpeg writes pasp 4/3 for setsar=4/3 and 1/1 otherwise.

VhMeta's twin fields ride along so the plugin ABI can carry the same
answer once a display size differs from the coded one.
🐛 test(subtitles): a reindex the entry carries is a step, and it round-tripsAhmet Kaan Gümüş · 4ed8c97
🐛 test(subtitles): a reindex the entry carries is a step, and it round-trips

The app lane's `remove_subtitles` snapshots before it walks the placements
down, and its `Snapshot` carries the palette beside the lanes and the
settings -- so a history step across a reindex is safe, and the old
expectation ("no step survives a reindex the snapshots do not know
about") pins exactly the defect that lane removed. It failed
deterministically on the merged tree.

The test now asserts the round trip it was reaching for: the undo puts
the removed row back and the placement goes on naming the same words,
and the redo takes it off again -- which is where the rest of the test
starts. Lane: lane-bughunt-app.

`cargo test -p engine --test subtitles -- --test-threads=1`: 22 passed.
💄 style(media): the dedupe's doc line wraps where it readsAhmet Kaan Gümüş · 87acb80
💄 style(media): the dedupe's doc line wraps where it reads

The muxer's reference to the demuxer's table made one comment line run
past the wrap every other line in the region keeps.
🐛 fix(decode): the visualizer seat masks what it declares, and floors nothingAhmet Kaan Gümüş · 9ab653d
🐛 fix(decode): the visualizer seat masks what it declares, and floors nothing

The wave lane's worker declaration carried a `.max(2)` floor under the
even mask. It kept the worker alive, but it broke the decode lane's
inherited answer for a canvas with no size: a `Composer::passthrough()`
canvases came back as a 2x2 picture instead of the empty one it asked
for, whose own test caught it on the first full run of the merged tree.

The mask alone is what both need: the declared size is the size the
planes really have, so the conversion always has the chroma plane it
indexes, while a canvas with nothing to divide still takes the painter's
empty picture (`empty_peaks_paint_the_flat_line`'s neighbour in
`visualizer_window_i420`). Witnessed at 1920x1, 1921x1081, 320x1 and
321x181 through the seat and through `set_resolution`.
🐛 fix(app,audio): merge the interaction lane into mainAhmet Kaan Gümüş · a78d43d
🐛 fix(app,audio): merge the interaction lane into main

A card no longer swallows undo, redo, save or the clipboard, a refused
split keeps the clip in hand, every edit door arms the flag only when it
wrote, the cue picture cache is keyed by the cue, and a device that dies
under an open file says so and unsays it. Lane: lane-bughunt-inter.

The one hand resolution: `Player::undo` and `Player::redo` carry both
lanes' work in one body -- the interaction lane's bool ("was there a step
to take") and its conditional selection clear, plus the app lane's
write-back of the cached rate, the two proxy switches, the palette's pick
and the plate over the picture. All of that now hangs off
`Player::step_history`, whose own answer is the gate, and the selection
still only goes when a step was taken.
🐛 fix(player,project): merge the app lane into mainAhmet Kaan Gümüş · 4d39c18
🐛 fix(player,project): merge the app lane into main

The settings and the subtitle palette ride in the history entry, a failed
waveform decode is asked again, and a visualizer byte past a byte is
refused rather than truncated. Lane: lane-bughunt-app.
🐛 fix(export): merge the export lane into mainAhmet Kaan Gümüş · c76e6c5
🐛 fix(export): merge the export lane into main

Every sample-altering edit forces an encode in one place, and the
truncation notice counts what a file could not give. Lane:
lane-bughunt-export.
✅ test(engine): the seat, the gap and the silent pin are witnessed where they can beAhmet Kaan Gümüş · 9e8397d
✅ test(engine): the seat, the gap and the silent pin are witnessed where they can be

Two witnesses and one determinism fix, from the refute-first pass on the
decode and wave lanes:

- the visualizer's declared canvas dims are masked to the even size the
  planes really have, so a one-pixel-high canvas and an odd one paint
  through the real seat instead of killing its worker. The witness drives
  `open_visualizer` at 1920x1 and 1921x1081; with the unmasked
  declaration put back it dies with the dead channel the probe saw. The
  export side already masks its own dims (`ClipDecoder::next`).
- a span whose codec has no seat at all reports `Backend::Gap`, not the
  hardware session that produced nothing: witnessed through `run_span`
  itself on a VP8 file under the `VE_SW` pin, since every public door
  refuses a plugin-only codec before a span exists.
- the audio device counter is no longer claimed absolutely in a parallel
  suite: the silent pin is asserted on the session the test owns, with
  the counter read as a delta under a module lock.

Also states the run_hw abort-path defect this box cannot reach (no
plugin): see the integration report.
🐛 fix(engine): merge the wave lane into mainAhmet Kaan Gümüş · b747d45
🐛 fix(engine): merge the wave lane into main

A film's visualizer reads a window of its envelope instead of the whole
file, a dead audio output is re-opened rather than ending the session's
sound, and the counter claims hold under a parallel runner. Lane:
lane-bughunt-wave.
🐛 fix(decode): merge the decode lane into mainAhmet Kaan Gümüş · 8a7835a
🐛 fix(decode): merge the decode lane into main

Grades survive a moved clip and a size-less canvas paints nothing. Lane:
lane-bughunt-decode.
♻️ refactor(media): one ISO 639 table, the demuxer's, for both sidesAhmet Kaan Gümüş · 737b171
♻️ refactor(media): one ISO 639 table, the demuxer's, for both sides

The mux lane had carried its own copy of the demuxer's ISO 639-1 → 639-2
table because that one was private to its module. Make the demuxer's
`pub(crate)` and have the muxer read it, so the two can no longer drift;
the copies were byte-identical, all 183 entries, so nothing is dropped.
🐛 fix(media): merge the demux lane into mainAhmet Kaan Gümüş · de38f6e
🐛 fix(media): merge the demux lane into main

The turn and the shown size a file states, the block walk's unchecked
add and the unchecked subtitle-table copy are fixed here. Lane:
lane-bughunt-demux.
🐛 fix(media): merge the mux lane into mainAhmet Kaan Gümüş · ac734bc
🐛 fix(media): merge the mux lane into main

The block-behind-cluster walk, the subtitle tag and the empty mp4 are
fixed together with the demux lane's own view of them. Lane:
lane-bughunt-mux.
🐛 demux: close the block walk's unchecked add, and one mkv conventionAhmet Kaan Gümüş · 7a52aa1
🐛 demux: close the block walk's unchecked add, and one mkv convention

Four things the re-verification left behind, each either the same class as what
this lane already fixed or a promise its new text made.

The video block walk's own timestamp -- the one a copy reads -- was still
accumulated unchecked (`cluster_ts + i64::from(block.rel)`), one step before the
scale the subtitle walk widened: a crafted cluster near the top of what an `i64`
holds overflows the add before anything could refuse the product, and the block
is taken at a time that wrapped negative. Both walks now call one `block_ticks`,
and the unit test covers the add as well as both scales.

`VideoMeta::rotation`'s doc listed a spherical projection among the turns refused
at the door, but `projection_rotation` deliberately does not refuse those -- the
pose of a spherical projection is the sphere's orientation, not the picture's --
so the sentence says that instead of claiming a refusal no code makes.

The mkv door fed the *coded* height to the 720-line rule an untagged stream's
matrix is guessed from, where the mp4 door feeds the displayed one. That was
harmless until this lane made the two differ, and then an untagged turned `.mkv`
and its `.mp4` twin landed on different matrices: 1280x640 as stored, 640x1280 as
shown, so bt601 against bt709. Both doors now feed the height the picture is
*shown* at, and `test_rotation90tall.{mp4,mkv}` (generated, untagged in both
containers) pins it -- the assertion fails with the coded height, which was
verified by putting `video.height` back and watching it fail.

And the export test runs on the mkv twin too, because a turn reaches the export
through exactly one number (the source's `Rotation` in the export's rate table),
and only a both-doors test shows a door that reads its own spelling into that
number differently.

cargo check -p engine --all-targets: 0 warnings. cargo test -p engine --test
rotation: 5 passed. subtitles: 22 passed. cargo test -p engine --lib: 392 passed,
0 failed. rustfmt --edition 2024 reports the same nine pre-existing hunks on
demux.rs as base, none in the added code, and none on the test file.
📝 docs(audio): the death writer is the wave branch's tick, not a missing halfAhmet Kaan Gümüş · 56924e8
📝 docs(audio): the death writer is the wave branch's tick, not a missing half

E1 settled by the integrator: the engine writer exists on the wave branch -- `tick`'s dead branch sets `AUDIO_LOST` and `rearm_audio` clears it -- while this lane's base engine carries neither, so the earlier wording read as an engine defect that is not owed. The three documents now say what each side is: the engine writes the reason (wave branch), this lane reads it and spells none of its words, the flip is driven through the seam here and asserted end to end on the merged tree. Nothing in either test depends on when `tick` sets it.
🐛 fix(engine): the counter claims hold under a parallel runnerAhmet Kaan Gümüş · 60c5322
🐛 fix(engine): the counter claims hold under a parallel runner

W1: `a_summary_pass_folds_the_file_once` -- and the parent revision's
`an_envelope_over_the_ceiling_is_not_held` -- asserted on process-wide counter
deltas, so under `cargo test`'s parallel default a sibling test's pass landed
inside the delta. Reproduced here before the fix: `cargo test -p engine --lib --
waveform::` (default threads) -> 2 failed of 18, both counter tests, both green
serially. Two mechanisms, one per kind of interference:

- `MEMO_DECODES` is keyed by the ask now (`memo_decodes(path, stream, bps)`): it
  is the one counter another *module* moves (the playback seat test opens a
  visualizer seat on a short fixture, which is a whole-envelope ask), and a keyed
  count makes a test's claim about *its* source -- which is always a private copy
  of a fixture, so the key is the test's alone.
- the module's tests take `counters_serial()`, because `VIZ_DECODES` and
  `VIZ_FOLDED` are still process-wide and a test that *decodes* moves what a
  reading test measures. The lock is documented with its upgrade path (keying
  those two as well) and with why it is module-wide rather than reader-only.

Evidence: three parallel `cargo test -p engine --lib -- waveform:: playback::`
runs and one serial run -> 33 passed, 0 failed, every time. FAIL-BEFORE (default
runner, before this commit): 2 failed -- `a_summary_pass_folds_the_file_once`
(`folded 1440000 frames of a 960000-frame file, 1.50x over`) and
`an_envelope_over_the_ceiling_is_not_held`.

W2: the seat test's doc now says what the parent revision actually did -- a
1920x1 canvas died in the *painter* (`decode.rs`'s zero line clamped with
`max = -1`, `min > max`) and a 321x181 one died in the conversion on the
*canvas's* chroma plane (`len is 14400 but the index is 14400`, a full plane and
not an empty one) -- and says plainly that the test is a guard, not a
reproduction: a frame still arrives on the parent, which is why the masking is
the fix.

W3: the whole-envelope painter test's comment no longer claims the painter
hard-codes `VIZ_BUCKETS_PER_SEC`; a view carries its own rate and the painter
indexes by it.

Class sweep: the other process-global counter in this crate is
`ao.rs:22 DEVICES_OPENED`, asserted absolutely by `ao.rs:362`
(`AoSession::devices_opened() == 0`) -- the same class, one file this lane does
not own, so it is named rather than fixed. The `NTH` counters in `demux.rs:3385`
and `scratch.rs:38` only generate names and are not read as claims.
📝 docs(audio): the reason's writer is the engine lane, not this oneAhmet Kaan Gümüş · a091c6d
📝 docs(audio): the reason's writer is the engine lane, not this one

The documents said the engine sets `audio_disabled_reason` on a death and clears it on its re-arm. In this tree nothing assigns that field off the death path: the only mid-session writer is `arm_audio` (`crates/engine/src/playback.rs:2687`), which assigns only when `open_audio` returned a device, so it can only clear. The app side is the *reader* of whatever reason the engine reports, and it never spells the engine's words -- a death that sets nothing stays unsaid, and that is the engine lane's half of this defect.
🐛 fix(audio): the sound watch is keyed to the session it describesAhmet Kaan Gümüş · e87ca88
🐛 fix(audio): the sound watch is keyed to the session it describes

The watch cached one reason while `sound_reason` read `active_session()`, so a preview opening or closing -- a *different* session, and the timeline's own unchanged reason restored behind it -- read as a device that came back and then died again, and the phantom line stayed on the strip. `watch_audio` now asks the pure `audio_step` about the session generation its cache describes against the one the frame serves: a swap seeds and announces nothing, and only a change on the *same* session pushes or clears. `close_preview` bumps `session_gen` like every other install and drop (it was the one door that did not), so the key holds at every swap.

Doc corrected with it: this side is the *reader* of `audio_disabled_reason`; the writer of a mid-session death is the engine's own file (nothing in this tree assigns it off the `Audio::died` route yet -- `arm_audio` can only clear it), which is the wave lane's, and no constant of it is spelled here.
✅ test(player): the write-back a history step makes is pinned, and the plate's motive said rightAhmet Kaan Gümüş · 07d3b8b
✅ test(player): the write-back a history step makes is pinned, and the plate's motive said right

The app-level half of a history step -- the three session caches, the pick, and
the drop of the plate -- lives in `Player::step_history`, which is unreachable
from this binary: `Player` needs a `TestAppContext` the test build cannot make
(gpui's own test module is behind `feature = "test-support"`, which nothing
enables). The verifier deleted the whole write-back and the suite stayed green,
so it is pinned the way this repo pins an unreachable surface: a source scan
that both keyboard doors route through `step_history` and that its body still
carries every one of those writes. Non-vacuous by the lane's own recipe --
deleting `self.proxies_on = caches.proxies_on;` turns it red by name.

`Player::sub_image` is keyed by *where* a cue sits (`(lane, start_us)`), never
by the pick, and the drop of it is conservative; three comments said the plate
"was drawn through the pick that no longer stands", which would send a reader
looking for a key that does not exist. Reworded to the real key and motive here,
at the removal door, in `sub_pick_after_removal` (which now names what actually
reads the pick: the dock's picked-row comparison, the heading and its notices),
and in the test that covers it.
🐛 fix(audio): a device that dies under an open file says so, and unsays itAhmet Kaan Gümüş · c80d1f7
🐛 fix(audio): a device that dies under an open file says so, and unsays it

The engine knows: a death sets its `audio_disabled_reason` to its lost-device word, and its own 1 s re-arm clears it again. No consumer on this side ever looked -- both `audio_notice` call sites are the *open* paths -- so a device that died mid-session played on in silence with no message at all, and the strip went on saying nothing after the sound came back.

`Player::watch_audio` is the per-frame check, run from `Player::pump` (the one place every frame passes through): one read of an `Option<&str>` and one compare, with the strings built only on the change itself. `audio_change_notice` is the queue half and reuses the existing notice path -- `push_notice` for the death, and the same line taken back off the strip when the reason clears, only that line. The two open sites seed the cache (`Player::seed_audio_watch`) so a reason unchanged across the open is not announced a second time, and a line left over from the file before comes off.
🐛 test(timeline): count the split guard's clear with matches, not splitAhmet Kaan Gümüş · ceffb92
🐛 test(timeline): count the split guard's clear with matches, not split

The guard added a moment ago counted `after.split("self.selected.clear()").count() > 1`, and `split` counts the pieces *between* matches -- one clear reads as two pieces, so the guard failed on the very fix it guards. `matches` is what counts the clear itself.

Its own trap, caught by running it: the four-filter run is green on live code and each revert mutation now fails exactly the guard it belongs to.
🐛 fix(engine): a window starts at the bucket the decode was asked forAhmet Kaan Gümüş · e5f0b93
🐛 fix(engine): a window starts at the bucket the decode was asked for

RW1, and it is the real one: `viz_window` opens the file at the bucket it is
handed, `fold_window` indexes the slice from there, so `peaks[0]` *is* absolute
bucket `first`. `view_at` labelled it `first - seek` and served the margin --
so every `view.at(abs)` of a windowed frame read the envelope's bucket
`abs + 12000`: +3 s at 4000 buckets a second, the file's tail painted silence
(slice exhausted), and a preview frame at a window grid line was not the frame
export paints from the whole envelope. The fix is the label: ask from
`first.saturating_sub(seek)` and serve what comes back, which is what the margin
was always for.

Two of my own fixtures could not see it, and that is the lesson worth writing
down: a five-second clip's first window starts at bucket 0 (where the label is a
no-op) and the 40-minute FLAC was a 440 Hz sine at 8 kHz, whose 3 s shift is
1320 whole periods -- every bucket identical. The new test is *noise* in FLAC:
buckets must be *equal*, not merely close, at the file's head, its middle, both
sides of a 30 s grid line and its last window, and the frame at each has to be
the frame `visualizer_i420` paints for the same time. FAIL-BEFORE, this tree:
`t=30.5: 8002 of 8002 windowed buckets are not the envelope's, 0 out of reach`;
PASS-AFTER: 18 waveform tests green.

RW3: the summary pass folded the ask's whole-file probe and then re-decoded the
same sound in the windows it spawned -- 1.875x a file at the eight-window
ceiling, serial, on the first look edit's critical path. The first window now
stops at the joint the next was told to start at, exactly as the envelope's own
split stops it, so the windows partition the file and a pass reads it once.
FAIL-BEFORE: `folded 1440000 frames of a 960000-frame file, 1.50x over`;
PASS-AFTER: the same test asserts within 5% of 1.00x, and the peak/length
equalities against the whole envelope still hold (`viz_summary`'s stop samples
now mirror `peaks_over`'s, so it folds the same sample set).

RW5: `VizView` carries `per_sec`, the rate its envelope was drawn at, and the
painter reads it instead of hard-coding `VIZ_BUCKETS_PER_SEC` -- the invariant is
structural now (an ask at another rate is painted at that rate) rather than
accidental. `VizView::whole` is the one place the visualizer's rate is named.

RW4b: the seat now declares the canvas masked to even dimensions and floored at
two, which is what the painter returns -- an odd `resolution 1921 1081` line used
to declare a size the planes never had. Kept as an invariant, *not* claimed as a
reproduced fix: the witness (canvases 1920x1, 1921x1081, 320x1, 321x181 through
`PlaybackSession::set_resolution` + `try_frame`) passes with the mask reverted as
well, so I could not reproduce the panic on this tree and say so in the test's
own doc. RW4a is refuted: the even-dimension mask lives in the shared painting
body (`visualizer_window_i420`, decode.rs:2199-2200), which both entry points go
through; `visualizer_i420` is a one-line wrapper over it.

Also honest-doc fixes from the same review: RW2's notice doc no longer implies a
front-end shows a mid-session death (it is fetchable through
`audio_disabled_reason`, which the app reads where a notice is *built*); and a
failed window's comment now matches the code (the seat latches it, the memo does
not).
🐛 fix(export): the truncation notice counts what a file could not giveAhmet Kaan Gümüş · ce7b65f
🐛 fix(export): the truncation notice counts what a file could not give

The D4 notice published `total - done` at the first span whose file ran out, but
that break only leaves the span's own `while`: the span loop carries on and
writes every picture the later spans have. A two-clip timeline -- a 100-picture
clip over a 60-picture file, then a whole 60-picture one -- therefore read
`· 100 frames of the edit past the last picture` for a file holding 120 of the
edit's 160 pictures, and the comment beside the publish claimed the walk ended
there, which is false for the code as written.

The walk now sums each broken span's own tail (`span.len - done_here`, which the
`while done_here < span.len` condition guarantees is positive) and publishes the
sum once, when the walk is over. `fetch_max` and not `fetch_add`, because a dead
hardware seat has the whole walk run again from its first frame: the same project
and the same picture counts, so a second run must not double a number that is
already on the line.

Measured, in the units the line claims: the two-clip repro now reads
`· 40 frames of the edit past the last picture` (was 100) while the decoded file
holds all 120 pictures the edit kept, and a healthy two-clip timeline carries no
notice at all. The repro fails on the previous bytes with `the notice counts more
than the file lost: ... 100 frames ...`; the control and the single-clip test
from the first commit stay green.

    cargo test -p engine --test export -- --test-threads=1 a_two_clip
📝 docs(keys): the arrow comment stops claiming no card consults the keymapAhmet Kaan Gümüş · dd3fe34
📝 docs(keys): the arrow comment stops claiming no card consults the keymap

The sentence said a card answers the stroke and returns before the keymap is consulted at all, which stopped being true for the six document strokes this lane made reachable (verifier finding H4). It now says the card answers its own strokes first and names the exception.
🐛 test(keys): the dispatch needle is the statement, not any lookupAhmet Kaan Gümüş · 44ab0de
🐛 test(keys): the dispatch needle is the statement, not any lookup

The needle was satisfied by the hold gate's own `this.keymap.lookup(key, ctrl)` at the top of the handler, so a dispatch that resolved the action another way kept the test green (verifier finding H3). The statement is now read on its own -- from its `if let Some(action) = ...` to its opening brace -- and must contain the `card_safe_action(` call that decides the stroke.
🐛 test(autosave): bound each history arm before asserting it armsAhmet Kaan Gümüş · 87eae13
🐛 test(autosave): bound each history arm before asserting it arms

The history check read everything after each gate, so Redo's `mark_dirty()` satisfied Undo's -- deleting Undo's own arm kept the test green (verifier finding H2). Each arm is now cut at the arm that follows it: `ActionId::Redo =>` for Undo, `ActionId::AddVideoLane =>` for Redo.
🐛 test(timeline): cut the split guard at the then-branch it meansAhmet Kaan Gümüş · 4f7f26d
🐛 test(timeline): cut the split guard at the then-branch it means

The guard's positive half read everything after `if cut {`, which the shape the fix replaced also satisfies -- the clear sat below the whole if/else, so a revert of the fix shipped green (verifier finding H1). The branch is now cut apart at its `else`: the clear has to be inside the then-branch, exactly once, and nowhere above the gate.

Revert-mutation proof: with the clear put back below the branch the test FAILS, and with it above the gate it FAILS.
⏪ demux: keep the turn, drop the display size; widen the block walk's ticksAhmet Kaan Gümüş · 9b42f9f
⏪ demux: keep the turn, drop the display size; widen the block walk's ticks

The display-size adoption is reverted: `VideoMeta.width/height` mean exactly
what they meant at base again -- the coded size with the turn applied -- and
nothing reads `pasp`, `DisplayWidth`, `DisplayHeight` or `DisplayUnit` any more.
Reading them without applying the pixel aspect anywhere in the pixel pipeline
made an anamorphic source *worse* rather than better: the canvas of a freshly
opened file is built from `meta.width/height`, while `Render::frame` only rotates
and placement is an aspect-preserving `Fit` of the coded frame, so a 1440x1080
source became a 1440-wide pillarboxed picture inside a 1920x1080 canvas with the
bars baked into the preview and the export; and `CopyPlan::of` hands those two
numbers to `CopyParams`, so an exact Matroska copy declared PixelWidth 1920 while
copying 1440x1080 blocks and dropped the source's display elements -- a file that
plays right nowhere. Anamorphic support is a feature slice (the stretch stage in
`export::place_picture` and in the decode funnel), not a container-reader fix, so
it leaves together with its fixtures and the test that asserted it.

Kept, because they are the defect this lane was chartered for: the Matroska
`Projection` roll is read as the turn it is (`rotation_of_roll`,
`projection_rotation`, with the same refusal by name for anything that is not a
quarter turn) -- now asserted for the mkv twin too, which was generated but read
by nothing before.

And the multiply the subtitle walk had is widened for the block walk a copy
reads: `coded_block`'s `ts_ns` was `block.ts * timestamp_scale` in `i64`, where a
crafted cluster timestamp overflows -- a panic in debug and a negative block time
in release, silently. One `ticks_scaled` now serves both walks, and the unit test
covers both (microseconds at `per_tick` 1_000, nanoseconds at 1).

cargo check -p engine --all-targets: 0 warnings. cargo test -p engine --test
rotation --test subtitles: 4 passed + 22 passed. cargo test -p engine --lib: 392
passed, 0 failed.
💄 style(app-tests): the commit hook's own reflow, taken as it cameAhmet Kaan Gümüş · dd8c9bb
💄 style(app-tests): the commit hook's own reflow, taken as it came

`format-staged` rewrote these two after the index was already written, so they
were left behind the last commit: import ordering and one wrapped assert, no
semantics. Accepted rather than reverted -- a hook's canonical formatting is
the file's formatting.
🐛 fix(player): a history step takes its settings and its pick back with itAhmet Kaan Gümüş · 7023001
🐛 fix(player): a history step takes its settings and its pick back with it

Four refuted claims from the bughunt review, each a thing an undo restored in
the session and left stale in everything that reads it.

Engine, the order a restored step runs in: `restored_step` reseeked inside
`edit` and adopted the entry's settings only afterwards, so the landing was
computed from the values the step had just undone -- a rate undo clamped the
playhead to the pre-undo rate's idea of the timeline's end and handed the
worker the last frame for a playhead at three seconds. The closure, then
`adopt_settings`, then the reseek; the same ordering reopens a proxy undo
through the switch that just went back.

Engine, the sweep's shape: `parts()` left the palette out, so the D4
round-trip's `parts` equality passed with `self.subtitles = prev.subtitles`
deleted outright. `SubtitleTrack` compares now and `parts` carries the
palette; the D4 test asserts the palette itself, which is the assertion that
cannot go vacuous.

App, the window's own copies: `^z`/`^y` refresh neither `self.fps` nor the two
proxy switches, so after a rate undo every cut, step and fade in this window
was counted at the rate just undone, the Settings rows showed a project the
session no longer had, and the stale switch was pushed at the next session
made. `history_step` re-reads all three off the session, which is a free
function over the session because this binary has no `TestAppContext` to build
a `Player` in -- `Player::undo` is the call plus the repaint.

App, the subtitle pick: a `^z` of a removal restores the palette and left the
pick where it was, so it named a different track than the one on screen -- the
desync `sub_pick_after_removal` prevents at the removal door. The pick follows
the track it names across the step (`sub_pick_after_restore`), the drawn
plate is dropped when the palette or the pick moved under it, and the two
docs claiming a subtitle removal is not an undo step say what it does now.
📝 docs(engine): the seat remembers a window that would not open, the memo does notAhmet Kaan Gümüş · 7cb30bf
📝 docs(engine): the seat remembers a window that would not open, the memo does not

The comment claimed the opposite of what the code does: a window that fails to
decode is latched in the seat's own handle -- as an empty slice, for as long as
it paints in that window -- precisely so a file that is not there is not asked
thirty times a second. The memo still keeps successes only, so the next window
and the next seek ask again. Comment only; no behaviour changed.
🐛 fix(engine): a dead audio output is re-opened instead of ending the session's soundAhmet Kaan Gümüş · b05e9ee
🐛 fix(engine): a dead audio output is re-opened instead of ending the session's sound

The feeder flags the output dead when a write returns `None` -- a PipeWire
daemon that restarted, or a sink node that was removed. Nothing ever cleared
that flag: `start_audio` skipped its whole body for it, `arm_audio` was a no-op
while `self.audio` was `Some`, and `tick` handed the clock to wall time without
a word. The stream's position is frozen, so it can never satisfy `played_out`
again either. The session was silent for the rest of its life, through every
seek and every pause/play, with nothing shown to the user about it.

`rearm_audio` opens the output again at the rate and channel count the dead
stream carried -- the device only, never the file: the feeder is `start_audio`'s
at the seek that follows -- and clears the flag and the clock anchor that belong
to the stream that died. A seek (or the play after a pause) attempts it with no
cooldown, because that is a person asking and the one moment the sound can come
back into step with the picture; `tick` attempts it once a second, because a tick
is a rendered frame and a device that is gone for good must not be opened sixty
times a second. `tick`'s dead branch now runs *before* its clock-source guard:
the death is what puts the clock on wall time, so a session that only polled
once more would never try the device again -- the attempt has to be inside the
branch that keeps running. While it is dead, the session says so through the
door a front-end already reads for a silent one (`audio_disabled_reason`), and a
re-arm that takes clears that line again. `arm_audio` treats a dead device as no
device, so an import replaces it instead of being turned away by it.

Evidence: `cargo test -p engine --lib -- --exact
playback::tests::a_dead_output_is_rearmed_and_the_sound_comes_back` -- ok.
The test stops the stream and flags it exactly as `feed` does, stamps the
cooldown as spent, and then asserts: the notice is up, died is still set and the
tap is empty after a tick (no open inside the cooldown, nothing feeding), and
after a play + seek the flag is clear, the notice is gone and the *tap* -- the
samples that reached the device -- has samples in it again.
🐛 fix(preview): the cue picture cache is keyed by the cue, not by its momentAhmet Kaan Gümüş · 16925fd
🐛 fix(preview): the cue picture cache is keyed by the cue, not by its moment

The cache under `Player::sub_image` was keyed by `(lane, start_us)` and served on a match, so two different bitmap cues that share a lane and a start microsecond -- lift a caption off a lane, drop another track's caption at the same frame -- painted the picture of the cue that is gone: the cue's identity was never compared, and the cache is dropped only on toggle-off, leave and open.

`SubImageKey` carries the cue's own end and the picture's own allocation (`Arc::as_ptr` of the cue's image), which is stable for as long as the cue is in the session's list, so a repaint of one cue still hits while two cues never collide. The bytes are never compared: a display set is tens of kilobytes and this test runs on every frame.
🐛 fix(autosave): every edit door arms the flag only when it wroteAhmet Kaan Gümüş · f7e750c
🐛 fix(autosave): every edit door arms the flag only when it wrote

Eight doors armed `mark_dirty()` before the call that decides whether anything happened, so a stroke that changed nothing -- a clip let go where it was picked up, a caption dragged back to its own frame or dropped on an overlap ("NOT PLACED"), one that is not there any more ("NOTHING LIFTED"), a trim, a fade or a `[`/`]` nudge released against the wall the edge already stood on -- still armed autosave, the ledger's `unsaved` ghost and `Player::close_needs_answer`: a window nobody had touched asked to be saved, and an autosave sidecar was written for it.

Each arm now rides the door's own answer, or the one reading the door's answer cannot give: a caption's own window before and after the trim, and the ramp's own value before and after the fade (`Project::trim_sub` answers `Ok` and `set_fade_*` answers `true` for an edge or a handle that never moved). The history pair left the action table's early arm for its own, since `^z` with an empty history is not a stroke that earned an autosave -- and `Player::undo`/`redo` now clear the selection only alongside the step they took, the same rule the refused split above is held to.
🐛 fix(timeline): a refused split keeps the clip in handAhmet Kaan Gümüş · e063ed4
🐛 fix(timeline): a refused split keeps the clip in hand

`self.selected.clear()` sat after the if/else in `Player::cut`, so `s` on a seam or in a gap -- the engine's own refusal, worded "NOTHING TO SPLIT — the playhead is already on a cut" -- dropped the picked clip anyway: the next Delete, `x` or menu row then acted on nothing until the user picked the clip again. The sibling `Player::regroup` has always cleared inside its own success branch.
🐛 fix(media): a block behind its cluster, a subtitle tag, an empty mp4Ahmet Kaan Gümüş · 781cdf8
🐛 fix(media): a block behind its cluster, a subtitle tag, an empty mp4

Three writer defects in one file, each with the test that proves it:

- MkvMuxer: only the forward bound of a block's distance from its own
  cluster was checked (ts - cluster_ts >= CLUSTER_MS), so a step back wider
  than the signed 16-bit relative field was truncated by `as i16` into a
  positive offset -- a block the source put at 0 s read back at 65.536 s,
  silently. Both bounds are now one cluster_holds predicate, the cast is
  i16::try_from with the distance named in the error, and put re-checks
  after the drains, where a lagging track can have opened a cluster behind
  the picture the cluster was opened for.
- Mp4Muxer: the mp4 crate's language_code masks the three UTF-16 units it is
  handed with 0x1F and drops the rest, so a pt-BR subtitle track was written
  as `ptm` and a two-letter en as `en` plus a backtick, read back off the
  file. The tag is turned into a code at the muxer boundary now
  (mp4_language): three lowercase letters pass, a BCP-47 primary subtag is
  mapped through the ISO 639-1 table, anything else is und. Matroska's own
  writer needs no change -- its Language element is raw bytes, and the same
  tag is normalised on the way in by demux::mkv_language.
- Mp4Muxer::finish: a file nobody put a picture in was written anyway, while
  the Matroska twin has always refused that by name. The mp4 refuses in its
  own container's words; the encoded export door already refuses earlier, so
  this is the container contract rather than a live-door fix.

Each is a mux.rs unit test that reads the file back: the mkv blocks through
the project's own Demuxer, the mp4 language through the mp4 reader and the
refusal by its message.
⚡️ perf(engine): a film's visualizer reads a window of its envelope, not the whole fileAhmet Kaan Gümüş · 0cf7335
⚡️ perf(engine): a film's visualizer reads a window of its envelope, not the whole file

A look drag re-opens the visualizer seat once per pointer sample, and the seat
asks for the clip's whole envelope: two hours at the visualizer's 4000 buckets a
second is 230 MB, past `PEAKS_MEMO_BUCKETS`, so the memo refuses to hold it and
every one of those asks decoded the whole file again -- six channels through
`ec-aac`, ~7 s of four cores, per pointer sample, for a picture that shows two
seconds of sound. The cap is not the bug: one entry that size is not a memo.

The seat's ask is now the shape of what it paints. `viz_envelope` answers with
the memo's own whole-file handle when it holds one, and otherwise with a
*window* of the file's envelope about each frame's own time -- 30 s of buckets,
decoded once per window per process, held under a 4M-bucket ceiling
(VIZ_WINDOW_MEMO_BUCKETS, 32 MB, ~34 windows for every source in the session).
A window is 1.5% of the film's envelope and a drag re-asks the one it is in.

Two scalars of the whole file are still needed to draw any frame of it: the
file's loudest bucket, which every column is scaled by, and its exact length,
which is where "past the end of the file" is measured. `viz_summary` reads both
off one pass that keeps no buckets -- the same windows, threads and opens
`peaks_over` decodes an envelope with, so the peak is the envelope's own -- and
the summary is kept per stream, sixteen bytes rather than 230 MB. Both routes
are memoized; a failed ask still is not.

`VizView` is what a painter is handed: either the whole envelope
(`visualizer_i420`, unchanged for export and the tests) or a window with the
file's own `total` and `peak`. A view that is a window cannot derive either from
itself, which is why they travel with it.

Also guards the sample rate that becomes samples-per-bucket: `per_bucket_of`
floors the rate at one both ways, because `sample / 0.0` is infinite, `as usize`
saturates and the fold's `resize(bucket + 1)` is then a length that does not
exist -- a panic in debug, a wrap and an out-of-bounds index in release. The
window arithmetic is written in buckets *per second* off the same helper.

Evidence (`cargo test -p engine --lib -- --test-threads=1 waveform::`):
16 passed, including a 40-minute FLAC whose envelope is 9.6M buckets (past the
real ceiling): a window's buckets are the envelope's bucket for bucket and its
frame is byte for byte the frame the whole envelope paints, the first ask decodes
a window, and the three asks after it -- a drag, a new seat each time -- decode
nothing at all.
🐛 fix(keys): a card no longer swallows undo, redo, save or the clipboardAhmet Kaan Gümüş · 35306fd
🐛 fix(keys): a card no longer swallows undo, redo, save or the clipboard

`param_card_key` answers `true` for every stroke once one of the seven param cards is open, so `ctrl+z`, `ctrl+y`, `ctrl+s`, `ctrl+c` and `ctrl+v` never reached `keymap.lookup` at all -- the equalizer card's own comment says undo was always meant to be undo's own key ("Nothing to undo: every change is already at the clip, and undo is undo's own key").

`card_safe_action` names the five chords that act on the document rather than on the card, and the root handler dispatches them ahead of the cards' own branches and ahead of the blanket modal guard. The list is asked through the keymap, so a rebind moves the chord and this follows it. Escape, the arrows, `m`, the digits and the bare card letters stay the cards' own strokes.
🐛 fix(player): a failed waveform decode is asked againAhmet Kaan Gümüş · 43e146d
🐛 fix(player): a failed waveform decode is asked again

Presence in the wave map means asked, so one transient failure -- a file imported while it was still being copied, a disk hiccup -- left a lane with no envelope for the rest of the session. The failure carries the moment it happened now and a repaint past a five second cooldown asks again, which is the engine's own rule that a failure is never memoized; a file with no audio stays an answer that is never re-asked.
💄 ui(settings): the Encoder row is the picture's ownAhmet Kaan Gümüş · 9c53bb8
💄 ui(settings): the Encoder row is the picture's own

The engine opens no encoder seat for a song, so with an audio-only format picked the settings row was a button that did nothing when pressed. The export moment mounts no such row there; this is that same rule and not a third treatment. The settings/moment parity test also walks a settings pick through undo and redo now.
🐛 fix(edith): a visualizer byte past a byte is refused, not truncatedAhmet Kaan Gümüş · ff23d47
🐛 fix(edith): a visualizer byte past a byte is refused, not truncated

A clip line naming a look of 300 loaded as 44, with the fast bit and the ink nibble both wrong, while the module's own rule is that every bad field is refused by name beside the resolution bound, the sample rate range, the tone map and the encoder seat.
🐛 fix(project,playback): the settings and the subtitle palette ride in the history entryAhmet Kaan Gümüş · 2d2933c
🐛 fix(project,playback): the settings and the subtitle palette ride in the history entry

The entry held the lane list alone, so a resolution, a rate, an encoder seat, a mix rate or a proxy switch could not be taken back by ctrl+z, and removing a subtitle column had to retire the whole stack rather than reindex under it. The entry carries a ProjectSettings value and the palette now; the session hands its own copy over at every door and takes the restored one up after an undo, where a rate step conforms the per-source lengths back within a frame the way the way out already did. The column removal takes a step of its own instead of clearing the stack.
🐛 demux: read the turn and the shown size a file states for its pictureAhmet Kaan Gümüş · 30b435d
🐛 demux: read the turn and the shown size a file states for its picture

A Matroska `Projection` roll, the `DisplayWidth`/`DisplayHeight` pair and an
mp4's `pasp` box were read by neither door, so a rotated `.mkv` played and
exported sideways, and an anamorphic source -- HDV's 1440x1080, a DVD's 720x576
with a display width -- probed, previewed and exported squashed. Neither had a
message: both were silent wrong output.

The engine could already turn a picture (`scale::rotate_i420_90s`) and already
collapsed a file's coded size into its displayed one off an mp4 `tkhd` matrix.
Both doors now do the same two steps in the same order: the size the file says
the picture is shown at, then the turn. The roll is *negated* to get the quarter
count -- it counts counter-clockwise degrees where the matrix counts clockwise
turns -- and that direction is measured, not derived: the new
`test_rotation{90,180,270}.mkv` fixtures are the same quadrant source as their
`.mp4` twins (one `ProjectionPoseRoll` of +90, +180, -90, byte-verified by
walking the header), ffmpeg reads each back as the same display matrix, and both
autorotate to the same four corners -- which is what `tests/rotation.rs` asserts
corner by corner, through the preview funnel as well as the probe.

A rectangular projection mirrored or tilted out of its own plane is refused by
name like the mp4 door refuses a 45-degree matrix: mkvmerge v95 states a mirror
with a yaw, and a picture out of plane has no rendition here. A spherical
projection's pose is left alone -- on those the same elements describe the
sphere, and a flat player shows a 360 file rather than refusing it.

The subtitle walk's tick arithmetic is widened to `i128` and made fallible: the
multiply is where a corrupt cluster timestamp overflows, a panic in debug and a
negative cue time in release, silently.

Fixtures live in `assets/`, which is gitignored and symlinked to the shared pool,
so they are generated rather than committed: `scripts/gen_fixtures.sh` writes
both the mkv turns and the anamorphic pair.

Still open, and not made worse here: the anamorphic *placement*. `Composer`
letterboxes, so a 1440x1080 picture in the 1920x1080 canvas the file states gets
bars rather than its samples stretched to the shown shape -- the stretch belongs
in `export::place_picture` after its turn, and in the decode funnel for the
preview.
🐛 fix(decode): grades survive a moved clip; a size-less canvas paints nothingAhmet Kaan Gümüş · 4826d31
🐛 fix(decode): grades survive a moved clip; a size-less canvas paints nothing

- the graded copy applied the grade under `!passthrough` while the branch
  was entered under `!skip_placement && colour`, so a clip the size of the
  project moved, scaled or turned by a transform was converted ungraded
  after the placement: the graded and ungraded previews came back
  byte-identical (0.00 mean codes) while the export side, which applies the
  grade unconditionally, showed something else (57.02 codes apart). The
  application guard now matches the entry guard; the fused graded fast path
  for an untouched passthrough clip is unchanged.
- the visualizer's zero line was indexed from the height (`h as isize - 1`),
  and `Ord::clamp(0, -1)` panics in every profile: a zero- or one-pixel-high
  canvas -- a `Composer::passthrough()` canvas is exactly `(0, 0)` -- killed
  the worker thread, closed the frame channel and left the span with no
  picture, which is what an export then aborts on. A canvas with no size now
  takes the empty picture it asked for, witnessed both directly and through
  the seat that opens one.
- the empty-peaks panic the lane was chartered on is refuted, not papered
  over: `pair_at` and both of its `peaks.len() - 1` indexes sit inside
  `if !peaks.is_empty()` in the base tree, so no column can sample a bucket
  of an empty slice. The inherited witness expected one ink row where the
  trace paints a five-row band; it now pins the band's shape and that
  full-scale peaks paint a tall picture, which is what makes the flat line a
  claim about silence rather than about a painter that draws nothing.
- a codec with no software seat that decoded nothing no longer leaves the
  backend cell claiming the hardware session that opened and produced
  nothing: that arm reports the gap it is.
- the dead ink picker (`VIZ_HUE_SHIFT`, `viz_hue`, `with_viz_hue`,
  `viz_ink_rgb`) is deleted -- no caller anywhere in the tree, and its doc
  promised a nibble the field never carried -- along with the mangled doc
  line that landed mid-sentence between the peaks sentence and the
  `visualizer_i420` link.
🐛 fix(export): every sample-altering edit forces an encode, in one placeAhmet Kaan Gümüş · 24df84c
🐛 fix(export): every sample-altering edit forces an encode, in one place

The copy-or-encode gate existed twice: `forces_encode`, which a card reads
before the button (`planned_seats`, `audio_label`), and the runtime gate inside
`copy_audio`, which decides what the file does. A fade was on the first and not
the second, so an mp4 whose lane carried a fade-in or fade-out wrote the
source's own packets with the fade nowhere -- while the card had promised a
re-encode, and the WAV, FLAC and MP3 exports of the same project applied it.
Measured on a clip with a 1.5 s fade-in: the seat line read
`SW encode (ec-h264) · AAC copy` and the first quarter second of the file sat at
0.14 of its own tail level, against `ec-aac` and a rising ramp once both gates
ask the same question.

Both gates are now `sample_altered`, asked with the lane list each caller has --
every audio lane for the card's question, the one lane the segments came off for
the copy's -- so no condition can reach one of them and miss the other again.
The class was swept with it: `CopyPlan::of` is the picture's copy gate and names
its own sample-altering states (grade, transform, speed, rotation, rate, size,
colour, dissolve, gap, packing), and every one of them still falls back.

Three more on the same path.

`picture_progress` computed a picture count times a permille in `u32`, which
overflows past 4,520,913 pictures (42 hours at 30 fps): a panic in debug inside
the export thread, which a caller reads as `export worker panicked` on a file
that was never written, and a bar that thrashed in release. Computed in `u64`,
which the straddle test pins at the boundary the old shape could not hold.

The `catch_unwind` branch in `start` never deleted `<out>.part`, though the
module promises every failure path does: the only cleanup was in the body's own
`result.is_err()` arm, which a panic never reaches, so a panicking export left a
half-written file beside the name it never took.

A source that ran out under its clip ended the span with no notice and the bar
reached its end anyway, so a truncated file read as a whole one. The frames that
never got a picture are now published on `Shared` and composed into
`ExportHandle::encoders`, where the card already renders the seat line --
composed at read time, because that line is published again on a rerun in
software behind a dead hardware seat.

Tests, all four of which fail on the pre-fix tree:
`a_faded_clip_encodes_and_the_fade_reaches_the_file` (the seat line says
`ec-aac`, and quarter-second RMS windows of the exported file rise through the
fade and reach unity past it), `a_films_frame_count_does_not_overflow_the_bar`,
`a_panicking_worker_deletes_the_part_file` (an env-gated panic point, so the
branch is reachable without a codec parser that really panics, and no export but
the one it names can match it), and
`a_clip_that_outlives_its_source_says_so_on_the_card`.

    cargo test -p engine --test export -- --test-threads=1