forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on eb3f5714f3bcbc3ced3e7380eaab6959c04115b3

2026-09-30

fix(engine): make the caption-window bound structural, not per-armAhmet Kaan Gümüş · eb3f571
fix(engine): make the caption-window bound structural, not per-arm

Three rounds of review each found one more composer a per-arm check had
missed, and the third is the one that ends the sequence: the fix is not
another arm, it is the invariant's shape.

`grow_window` was not, in fact, the single writer of a window.

**A rejoin SUMS two legal halves.** `Project::regroup` keeps the left
half's `in_us` and takes the right half's `out_us` -- and `sub_joinable`
has just established that the halves are consecutive in the *source*,
so the joined width is the sum of two widths that each passed their own
door. Neither half is illegal; the whole is. Two 20-day windows and one
undo-a-split keystroke gave 40 days, which `save_project` wrote and
`open_project` refused. My sweep had disposed of this as "takes the
neighbour's own out_us" -- true, and beside the point: the ceiling bounds
a SUBTRACTION, not its operands.

**A head drag grows the width too.** The ceiling bounds a difference, so
falling `in_us` makes the window wider exactly as growing `out_us`
does. The Start arms clamped `in_us` from above (`in_us <= out_us - 1`),
which says nothing at all about the ceiling: a caption a year into its
source, dragged back 200 days, was 200 days wide with `out_us` never
moving.

So the bound is now one function every writer routes through:

    set_window(&mut SubClip, in_us, out_us)
    // 0 <= in_us < out_us  &&  out_us - in_us <= MAX_WINDOW_US

and `grow_window` is gone -- it was a helper around one arm, which is
what made the other arms look exempt. Everything goes through
`set_window` now: `trim_sub` both edges, `write_sub_edge` both edges,
`regroup`'s join, and the four halves `sub_clear` and `sub_open_room`
build. The doors still REFUSE on entry (parse, `with_subs`, `place_sub`)
and `set_window` still CLAMPS on composition, because that asymmetry is
the point: a door sees a value nobody was mid-gesture on, a composer is
an edit a person is watching happen.

**The closed set is now proved, not argued.** Reasoning about arms does
not scale to an unknown number of them, so
`project::tests::every_window_write_goes_through_set_window` reads both
files and fails if `in_us`/`out_us` is written anywhere outside
`set_window` and the parser's two door lines. It is deliberately a
source scan rather than a `debug_assert!`, because a `debug_assert!`
only fires on a path some test happens to walk.

That scan was vacuous the first two times and the test says so:
cutting at the first `#[cfg(test)]` scanned 160 lines of a 10,800-line
file (a smuggled writer in `write_sub_edge` sailed through), and
cutting at the last one landed inside the scan's own test module. It now
cuts at the test module and asserts how many lines it read, because a
guard that reads nothing is worse than no guard -- it reads as one.

**The ceiling's stated reason was wrong and is now right.** I had claimed
`window_at` needed the ceiling below 2^53 for f64 exactness. It does not:
it is pure i64 with a `saturating_mul`, so the f64 argument never
applied. The real arithmetic: `window_us() * into` with `into` up to
4.29e9 saturates for any window above `i64::MAX / u32::MAX` = 2.1e9us
(~35 minutes), so 30 days is 1200x past the point where the proportion
stops being exact -- which is the actual precision cost, and the reason
this is not "unlimited". f64 exactness IS the right argument for
`sub_lane_cues`'s cue mapping, where 30 days is ~3.5 orders inside
2^53. Nothing else derives anything from a window, so a wider value
costs no memory: the ceiling is a claim about meaning, not resource.

Witnesses, each with its own mutation:

- `a_rejoin_of_two_legal_windows_stays_inside_the_ceiling` -- two 20-day
  halves, one rejoin. Un-routed: "the rejoin summed two 1296000000000us
  windows into 3456000000000us, past the 2592000000000us ceiling".
- `a_head_drag_no_further_than_the_ceiling` -- a year-deep caption, one
  head drag to the offered room. Start arm reverted to a raw `in_us`
  assignment: "gave a 3000030000000us window".
- `every_window_write_goes_through_set_window` -- passes clean; fails on
  a smuggled writer in `write_sub_edge`, on on a smuggled writer in
  `edith.rs`, and on `regroup`'s two lines moved out of `set_window`.
- Loosening `set_window` itself (dropping the ceiling clamp) reds all
  four caption witnesses at once, which is the property a per-arm fix
  does not have.

UX note, recorded as the verifier found it and left unchanged: a drag
that reaches the ceiling stops silently. That is consistent with every
other trim wall here -- `trim_to` drops the snap cue, `commit_trim`
toasts only on `Err` -- so the ceiling behaves like a wall, not like an
error.
fix(engine): clamp a caption window on GROWTH, and raise the ceilingAhmet Kaan Gümüş · f23dd8f
fix(engine): clamp a caption window on GROWTH, and raise the ceiling

A ceiling is only half an invariant. Every door -- the parse,
`with_subs`, `place_sub` -- sees a window on the way IN, so on its own it
left two holes, both of which cost a user their saved work.

**The app could write a file it refused to open.** `trim_sub`'s End arm
GROWS `out_us`, and it grew past the ceiling: a caption trimmed out to
the room the engine itself offered reached 25 hours, `save_project`
wrote `sub 1 0 3240000 0 0 90039000000`, and `open_project` refused
that file with "past the 86400000000us a caption can hold". The trim is
committed and undo does not survive a restart, so there is no in-app way
back -- the editor wrote work it then could not reopen. The `saturating_add`
that killed the overflow panic did not keep the value inside the bound.

**The ceiling was below real use.** A caption's window is a window into
SOURCE media, so its width is the length of the recording it was cut
from, and that is not bounded by a day. A 25-hour conference stream or a
lecture archive measures its own palette row in tens of hours, so the
ceiling refused the user's own media back at them, at `place_sub`, with
nothing placed. "A window this wide is a number nobody meant" holds for
i64::MAX; it does not hold for a long recording.

So:

- `MAX_WINDOW_US` is 30 days, and the reason is arithmetic rather than
  editorial. `SubClip::window_at`'s proportion cut saturates rather than
  wrapping, so the ceiling is about PRECISION: f64 holds an integer
  exactly to 2^53, and 30 days is 2.6e12 -- nine orders of magnitude
  inside it, so the cut is exact rather than merely finite. It is 3.5e6x
  below i64::MAX, and exact in `sub_lane_cues`'s cue mapping for the same
  reason. No real recording reaches it; a typed number does not survive it.

- `grow_window` is the growth law, and is now the single function that may
  write `out_us`. `trim_sub`'s End arm and the group-follow
  `write_sub_edge` both go through it. Growth CLAMPS and entry REFUSES,
  and the asymmetry is the point: a trim is a continuous gesture whose
  every intermediate frame the user sees, so clamping is a drag that
  stops -- exactly like the frame walls `trim_sub` already applies. A
  value arriving from a file or a foreign caller is not mid-gesture, so
  it is named and refused rather than quietly changed.

- `trim_sub_room` is walled by the same number. A front-end asks it to
  draw the drag and then trims to whatever it is told, so an engine that
  offers a trim its own `trim_sub` would clamp is a drag that snaps back
  at the end of the gesture. The room and the trim now agree by
  construction.

Witnesses, each with its own mutation (saveload.rs):

- `a_trim_grown_to_the_offered_room_saves_and_reopens` -- 40-day track,
  trim to the offered room, save, reopen. Clamp removed: "gave a
  2592027000000us window, past the 2592000000000us ceiling".
- `a_group_trim_carries_its_sibling_no_further_than_the_ceiling` --
  `follow_group` SKIPS the dragged member, so a primary-trim-only fix
  misses this entirely: the route is a sibling on a second lane, placed
  20 days into the track so the same delta overshoots. Clamp removed:
  "the group carried the sibling to a 25919974080030us window" -- 10x the
  ceiling.
- `a_caption_over_a_day_of_track_places_and_round_trips` -- a 25-hour
  track placed exactly as `Player::sub_of_track` builds it. Ceiling
  lowered to a day: refused at `place_sub`, nothing placed.

Swept every other writer of `in_us`/`out_us`, all now inside the bound:

- `sub_clear` (both halves) and `sub_open_room` (both halves): the values
  are `window_at` results, which `SubClip::window_at` already clamps into
  the window -- a split cannot widen what it splits.
- `Project::close_gaps`-style join: takes the neighbour's own `out_us`.
- `trim_sub` Start and `write_sub_edge` Start: `in_us` is clamped to
  `out_us - 1`, which is below the ceiling.
- `app`'s `trimmed_sub`: moves `frames` only, never a clock.
- `Project::sub_lane_cues`: reads the window, writes nothing.
fix(engine): bound a clip's transform position, and sweep the loader classAhmet Kaan Gümüş · d964f6c
fix(engine): bound a clip's transform position, and sweep the loader class

The third of the class "a number read out of a file a hand can edit,
used in arithmetic without a bound", and the last one the sweep found.

`transformed_dst_rect` caps `scale` at 1024 canvas widths for exactly
this reason -- the comment at the cap says so -- and `pos_x`/`pos_y`
multiply the canvas and are *added* to the placement's centre with no
bound at all. `float()` in the parser refuses only inf/NaN, so
`transform 3e38 0 1 0 0 0 0 0` is a legal line. `f64 as i64` saturates,
so the value arrived as `i64::MAX` and the ADD is what overflowed: a
panic on the compositing thread in a debug build, a silently wrapped
position in a release one. Clamped to the same +/-1024 canvas fractions
`scale` already gets, with saturating adds, so a position past the point
where the picture is long gone gives the two empty rects the function
already answers with.

The sweep, over every numeric field the `.edith` parser reads and every
config file the app reads. Two rules decide a site: a value is safe
either because the parse bounds it by name, or because a consumer clamps
it unconditionally before the arithmetic -- and only the second kind is
silent about a value the file actually stated.

The parser's four helpers (`number`, `number64`, `micros`, `float`) bound
nothing; the bound is always in the branch or in a consumer.

SAFE (bounded at the parse): resolution (`is_resolution`), fps
(0 < f <= 1000), samplerate (1k..384k), limiter.ceiling_db
(`with_ceiling` at the parse itself), clip geometry (`check()`'s
`start + frames`), clip.speed, the three fade/transition counts
(`.min(frames)`), clip.visualizer (`u8::try_from`), every table index
(`table_index` re-checks), sub.start/frames (`checked_add`), sub.track
(must name a palette row the file has), sub.link (saturating counter).

SAFE (clamped by a consumer, wherever the value came from): eq/color/
transform floats, gain.db (`with_mix`), color.* (`Lut::new`),
transform.scale/rotate/crop_* (`cap_w`, `nearest_90_steps`, the crop
clamp), playhead (`landing`), source.audio_stream (no arithmetic; every
consumer `.get()`s).

KNOWN, NOT A FAULT: clip.viz_paint is an unbounded u64, but every
accessor in `decode.rs` is a bit mask, so there is no overflow -- the
glow byte is read unclamped where the writer clamps it to 16, so a
hand-written file can ask for more work than the UI can produce. A cost,
not a wrong answer. Left alone deliberately.

The app's own config: eight files, only two carry a number. The
stance-splits loader (I-2) is safe because `split_size` re-clamps every
seam on every frame and `Player::split_px` is its only reader -- the
loader stores a value the frame loop then bounds. The subtitle size is
range-checked at the parse, and `RangeInclusive::contains` being a
partial comparison is what makes NaN/inf fall back rather than survive.
The keymap reads no number at all; the rest are whole-file tokens
resolving to a bool or an enum.
fix(engine): clamp a band's gain, the one field Coeffs::new left openAhmet Kaan Gümüş · 1b0fbe8
fix(engine): clamp a band's gain, the one field Coeffs::new left open

`Band`'s doc states the invariant for the whole struct: out-of-range
values are clamped when coefficients are built, so a deserializer can
hand this over unchecked. `Coeffs::new` clamped three of the four
fields -- `fs`, `f0`, `q` -- and computed `a = 10^(gain_db/40)` from the
fourth with nothing at all.

That is not a magnitude, it is a pole placement. For a peaking section
`|pole| = sqrt(a2/a0)` walks toward 1 as `a` grows: at 200 dB the radius
is 0.9999993 and the section rings for ~32 seconds, and past a few
hundred dB the f32 rounding puts the poles *exactly* on the unit circle.
Nothing upstream stops it -- `edith.rs`'s `band()` takes any parseable
field, its `float()` refuses only inf/NaN, `Project::set_eq` refuses
only `!finite`, and the UI's 12 dB is a card decision rather than a
project guarantee. The device clamp and the export's own [-1, 1] then
turn the result into a hard-clipped full-scale square for the whole
clip, in monitoring and in the exported file alike, and with the limiter
on the overflow is folded into its gain and colours every later sample.

Clamped at the same site as the other three, so the documented invariant
is true. `MAX_BAND_GAIN_DB`/`MIN_BAND_GAIN_DB` are +/-40 dB: far past
any card (deliberately -- a project may be more extreme than the control
that set it) while keeping `a` a linear gain of 100, comfortably inside
f32. Clamped rather than refused, because the struct's contract is that
a deserializer may hand this over unchecked: a project saying +400 dB
gets +40 dB, not a project that will not open.

Witness (arithmetic, not an audibility claim -- nothing here says what
the filter sounds like, only that it is stable): the poles of
`z^2 + a1 z + a2` solved off the normalized coefficients, asserted
strictly inside the unit circle, plus a full-scale 1 kHz burst whose
peak stays at the ceiling's own gain. Pre-fix, +10000 dB produced
`b0: inf` and +100 dB sent a full-scale burst to 62773.
fix(engine): bound a caption's microsecond window at the doorAhmet Kaan Gümüş · 70ba4eb
fix(engine): bound a caption's microsecond window at the door

A `sub` line's `in_us`/`out_us` is the one number in the `.edith`
format with no magnitude bound: the parse asks whether the window is
*open* (`out_us > in_us`) and never how wide it is, and `micros()` is a
bare i64 parse. So `out_us = 9223372036854775807` was a legal line.

Every split, ripple and group trim re-derives the two halves of the
window by proportion -- `SubClip::window_at`, a plain
`window_us() * into` -- which overflows on the first frame inside the
caption. A hand-edited or hostile `.edith` therefore panics the editor
on the UI thread the first time a user ripple-deletes across, splits or
trims that caption, losing unsaved work, and the file re-crashes on the
next open. In a release build the same line wraps the caption's clock
negative instead: `trim_sub`'s only check on its result is a
`debug_assert!`.

Bounded at the door, by name, beside every other range check a `.edith`
line already has to pass, and the composing arithmetic made total so a
future caller cannot reintroduce the wrap:

- `project::MAX_WINDOW_US` -- a day of track, the same shape of refusal
  as `is_resolution` for a `resolution` line.
- checked at all three doors a caption comes through: the parse
  (`edith.rs`), `Project::with_subs` (a hand-built `Project`) and
  `Project::place_sub` (a dragged placement).
- `SubClip::window_at` saturates its multiply and clamps its answer into
  the window it is cutting; `SubClip::window_us` saturates its
  subtraction; `trim_sub` and `write_sub_edge` saturate their additions.

Witness (`crates/engine/tests/saveload.rs`, hand-built project file, no
`--release`): the 30-second-window control loads, splits and ripples
across; the same file with `out_us = i64::MAX` used to load and then
overflow at `project.rs:654` on both `cut_at` and `cut_regions`, and is
now refused by name at `line 7`. Non-vacuity: with the parse bound
disabled the test goes red on `with_subs`' refusal instead, and with
both disabled it loads again.

2026-09-24

fix(decode): stretch before the turn, so a rotated anamorphic file fills its canvasAhmet Kaan Gümüş · f4bc699
fix(decode): stretch before the turn, so a rotated anamorphic file fills its canvas

A 1440x1080 SAR-4/3 file with a 90-degree display matrix rendered
1440x1440: the render composed turn-then-stretch, landing the ratio on
the coded height, and the square raster sat letterboxed inside the
1080x1920 canvas the probe declares -- bars in the preview and baked
into the export. The ratio belongs to the axis that was horizontal
BEFORE the turn: the coded width is stretched by h/v and the turn then
swaps the stretched pair, which is what the probe has declared all
along. Render::frame and place_picture now both stretch first, the one
order that agrees with the probe.

The suite's rotated case had been vacuous -- the in-test fixture was a
setsar file with no display matrix, asserting nothing about the turn.
It now remuxes a real 90-degree matrix on (-display_rotation 90, the
gen_fixtures pattern), asserts the probe's swapped stretched pair
(1080x1920, not 1440x1440), and drives the render through the same
assertions; the export test grows the rotated clip with
preview-vs-export equality. Mutation witness: with the render reverted
to turn-then-stretch the new assertions fail with exactly
left (1440, 1440) / right (1080, 1920).

The demux comment now names the render's order and the failure the
other one produces, so the two can't drift again.
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.