Commit Graph
17 Commits
Author SHA1 Message Date
timothy 666d476417 fix(732): give the frame cap a proof, fix a per-style halo bug, and correct two false claims
Round-4 review, both reviewers BLOCKED. The blocker was the same shape this branch keeps producing:
a completeness claim stated in words rather than derived.

The frame cap on the inset, added one round earlier, had NO test and NO mutation row. Disarming the
clause left the whole 2064-test suite green. The nearest candidate could not see it: its bound was
`baseline + 25_000` while the clause prevents growth of 20_000 on a 1080p frame, i.e. the assertion
was looser than the defect. Worse, the mutation record written the following commit asserted that
exactly one clause was uncovered, naming a different one - a false enumeration in the doc that exists
to prevent false enumerations. Now: a test pinning the cap, a tightened bound on the sibling, two
mutation rows, the cap documented in the geometry notes, and the "not covered" paragraph rewritten as
a claim that decays when a guard is added without its row.

`Environment.ProcessId` is 1 in every container. The image's ENTRYPOINT is exec form, so each
container is PID 1 in its own namespace and they all compute the same temp name - the mitigation was
inert in exactly the deployment the record cited for it. Two containers on one config volume could
still truncate each other's temp file and rename a partial one over the live template, which is the
outcome write-then-move exists to prevent. Random name now, record corrected.

Per-style halo was documented as working and silently discarded. The merge loop rebuilt each style
from base and overrode only font and colour, so a non-base style's halo_* inherited the base style's.
The seeded template hid it by declaring identical halos on all three styles. Three lines, symmetric
with the existing overrides, plus a differential test.

Also: an assertion on `_target + ".upgrade.tmp"` was unfalsifiable once the temp name gained a
suffix - a path the code can never create, passing with the cleanup gutted; a test named
An_Unreadable_Template actually simulates an unwritable one, renamed; a comment described the wrong
channel as cleared.

Decisions-Edit: yes
Refs: #732
2026-08-26 20:37:06 +02:00
timothy 55264660b5 fix(732): make the decision record describe what shipped, and close round-3 findings
The record was the blocker. Round 2 inverted the marker behaviour - it is now written only once the
built-in element RESOLVES - but graphics.on-now-next-on-by-default still stated the old rule in its
frontmatter and catalog row, and its rationale paragraph argued AGAINST the shipped design as "the
tempting alternative". A future session resolving that key would have been told the opposite of the
code. The XML remarks on AttachOnNowNextByDefault said the same thing. Both rewritten, catalog
regenerated.

The trade is now stated instead of asserted away. A single global marker cannot express both "never
re-add to a channel the operator cleared" and "never strand a channel that had nothing to attach".
While the backfill is armed - the built-in template is absent, so refresh has reaped its row - a
cleared channel is indistinguishable from an untouched one, and restoring the element attaches it
everywhere. That window is narrow, visible and reversible; stranding is silent and permanent, which
is why it is resolved this way. Closing it properly needs per-channel state, which is a schema change
and is not in this PR. A test now pins the accepted semantics rather than leaving them undiscovered.

The upgrade write hardened twice more: the temp name carries the process id (a fixed one is shared by
two containers on the same config volume, where one can rename it over the live template while the
other holds it open), and there is deliberately NO in-place fallback when the replace fails. A
bind-mounted single-file template cannot be renamed onto (EBUSY) and so will not be upgraded - which
needs a pinned file that is ALSO byte-identical to a shipped default, against reintroducing the
truncation on every IO fault. Recorded in the fingerprint record.

The inset is now clamped against the FRAME as well as against width_percent. Sanitize caps each field
alone, but padding and border add up, and with no width_percent nothing else bounded them - two
fat-fingered fields could allocate a bitmap far larger than the frame.

Two tests strengthened where they could not see what they claimed: the already-seeded row test
asserted only a count and a successful lookup, so dropping Name still satisfied it; and the
failed-write test faulted on the FIRST write, never reaching File.Move or the cleanup, so a
non-atomic Copy would have kept it green. A second test now faults the replace after a complete temp
write.

Decisions-Edit: yes
Refs: #732
2026-08-26 20:37:06 +02:00
timothy 56f3e593a5 fix(732): close round-2 review findings, including two in the round-1 fix itself
Both round-2 reviewers returned BLOCKED, and the sharpest findings were defects the previous fix
commit introduced rather than ones it missed.

The mechanism that fix added was untested. Deleting EnsureBuiltInElementRow from the ALREADY-SEEDED
branch left the whole 2054-test suite green - and that is the branch every install carrying #74's
marker takes on its first #732 boot, i.e. exactly the population the fix exists for. The previous
commit message claimed the marker "is only ever written against a resolved element"; that was proven
only for the fresh-seed minority. Same shape for the duplicate guard inside it: without the guard the
already-seeded branch inserts a row on every boot, RefreshGraphicsElements neither reaps nor dedupes
them, and the SPA list fills with copies. Both now have tests, and both were confirmed to redden.

That claim was also still false. With the template file absent, EnsureBuiltInElementRow returns
without creating a row and the marker was written anyway - a narrower version of the stranding bug
round 1 found. The backfill now stays armed when nothing resolves. This is safe in a way it was not
in round 1: EnsureBuiltInElementRow closed the "row appears later" window that argued against it.

The clamp only shrank insetPixels, not the box. DrawBackgroundBox kept stroking at the original
border width, centred on a rect with no room for it, so an oversized border flooded the element and
painted over its interior. The box's own fields are clamped now, border first.

The catch was over-corrected. Round 1 asked for it to be broader; everything-but-cancellation
swallows genuinely fatal failures and boots a compromised process. It is a named filesystem set
again, plus a carve-out for an OperationCanceledException raised while the token is NOT cancelled -
that one is just a faulty read, and letting it escape is the restart loop the catch exists to stop.

The template rewrite was not atomic: WriteAllTextAsync truncates first, so an interrupted write left
a partial file matching no fingerprint, which the upgrade could then never repair, on a template now
attached to every channel. Write-then-move, with the temp file cleaned up on failure.

Also: YAML doubles like 1e100 and NaN reach float/int casts, so box dimensions are sanitized at the
boundary; the built-in row is created with a Name so it does not sort into the unnamed bucket in the
SPA until the first refresh; CreateChannelHandler threads the real cancellation token.

Decisions-Edit: yes
Refs: #732
2026-08-26 20:37:06 +02:00
timothy bef3f54798 fix(732): close the review findings on the background box and the default attach
Two independent cold reviews (Codex GPT-5.6 and a worktree-isolated Opus agent) converged on the
same three serious problems; both returned BLOCKED.

Boot safety. The already-seeded branch of SeedOnNowNext used to touch the filesystem not at all,
so a template the app cannot read - one edited as root via `docker exec` while the app runs under
PUID/PGID, or a read-only /config - was harmless. Reading and rewriting it there put unguarded IO
ahead of DatabaseIsReady() in a BackgroundService whose default behavior is StopHost, i.e. a
restart loop triggered by a file permission an operator can set by hand. The upgrade is now
best-effort (broad catch, cancellation still propagates) and CreateDirectory moved back below the
already-seeded check.

Stranding. The backfill wrote its marker even when the built-in GraphicsElement row was merely
undiscovered - the row is normally created by RefreshGraphicsElements, which runs long after
startup. An install upgrading from before #74 seeds the template and backfills on the same boot,
so every pre-existing channel would have been left unattached forever, with no second chance. The
seeder now creates the row itself, so the marker is only ever written against a resolved element.
The test that asserted the old behavior is replaced by one that pins the upgrade case.

Overclaimed records. The never-re-attach guarantee holds from the marker onwards, not across the
upgrade boundary: an operator who cleared the overlay before this landed left no state that
survives, and the one-time backfill re-adds it. That is inherent to "on by default" rather than a
defect, but the record asserted otherwise. Also recorded: the upgrade is a one-way door, because
the loader rejects unknown YAML keys, so a rollback drops the overlay on every channel at once.

Smaller, all with tests: the wrap budget now subtracts the same integer inset the bitmap grows by
(a fractional padding overflowed width_percent by a pixel); an inset that cannot fit is clamped
instead of squeezing the text to 1px and letting the box grow unbounded; FitTextBlock carries halo
and line height across, which only became reachable once a box's insets could push an element into
the Scale path; the built-in lookup filters on Kind so a same-named element in another template
folder cannot win; CreateChannelHandler adds to the collection rather than assigning over it.

width_percent is documented as a budget rather than a guarantee - wrapping cannot break below one
glyph, so it overflows with or without a box. The doc also no longer claims an unparseable colour
is never substituted (true for the box, false for text_color) or that an unset background_color
means no box (a border alone draws one).

The mutation claim is now reproducible: all 19 clause mutations are listed in
docs/graphics-elements.md with the test each one reddens. Two candidate mutations produced NO test
summary because they failed to compile under warnings-as-error, which reads exactly like a pass in
a scrolled log - that is called out there too.

The new pixel tests are the first in the repo to rasterise text, so the CI image's font dependency
is now declared in docs/testing.md rather than incidental (351 fonts present in the pinned image,
measured; they arrive via playwright install --with-deps).

Decisions-Edit: yes
Refs: #732
2026-08-26 20:37:06 +02:00
timothy 0ab52ad71c feat(732): give the On Now / Next overlay a background box and turn it on by default
Part 1 - background box. TextGraphicsElement gains element-level background_color,
background_opacity_percent, background_padding, background_corner_radius, border_color and
border_width; TextElement draws a rounded rect behind the text block and insets the text into it.
Element level rather than per-style because the engine lays the whole element out as one
RichTextKit TextBlock and rasterises it into one bitmap, so one box per element is the only shape
the renderer can express. width_percent keeps bounding the visible element, so the insets are
subtracted from the text's wrap/scale budget.

The seeded on-now-next.yml adopts it. The halo drops from 2px to 1px rather than to zero, and the
box carries a low-alpha white border: rendered against real frames, a 65% black fill is legible on
bright and midtone content but vanishes entirely into dark content, which is why the issue asked
for an *outlined* box. The halo still matters because the fill is translucent.

Because #74's seeder writes the template only when absent, an already-seeded install would never
have seen any of this. GraphicsElementSeeder now keeps every default it has shipped as a verbatim
fingerprint and rewrites the file only when it still matches one (line-endings normalised), so an
untouched install upgrades and an operator-edited one is left alone. The V1 fingerprint was checked
byte-for-byte against the live install before being trusted - a fingerprint that matches nothing in
the field is a permanent silent no-op.

Part 2 - on by default. New channels get the built-in element from CreateChannelHandler (CreateChannel
carries no graphics field and the SPA's channel editor is update-only, so the server is the only
place a create-time default can live). Pre-existing channels get a one-time AttachOnNowNextByDefault
backfill. The marker is written on the first run even when nothing was attached: the tempting
alternative - stay armed until the element row exists - would fire on a later boot and re-attach the
overlay to a channel the operator had cleared in between. HLS Direct is excluded at both sites,
where the overlay cannot render at all.

Resolves the issue's open question: [vge] in a filter graph does not imply a graphics element is
bound. Watermarks fall back onto the graphics engine whenever they cannot use ffmpeg's native
overlay shortcut, so a watermark alone produces that stage.

Tests assert rendered pixels, because every failure mode here is a silent no-op that a model-level
test cannot see. 13 clause mutations were executed against them; each reddened only its own clause.

Decisions-Edit: yes
Refs: #732
2026-08-26 20:37:06 +02:00
Jason Dove 4ce87feac1 log graphics element z index (#2785) 2026-01-17 08:15:43 -06:00
Jason Dove b0b7bd17b3 respect z_index on all graphics element types (#2765) 2026-01-09 10:26:59 -06:00
Jason Dove c524bc0d7d add script graphics element (#2681)
* add script graphics element

* pass template data as json to stdin

* update changelog
2025-11-30 14:20:18 -06:00
Jason Dove 4e43817f8e add graphics engine text halo (#2528) 2025-10-14 06:41:32 -05:00
Jason Dove fb9ca8953e add text element formatting options (#2517) 2025-10-11 12:45:20 -05:00
Jason Dove c8679144c5 add text element text_fit options (#2441) 2025-09-18 14:08:24 +00:00
Jason Dove 6465c416ff motion end behavior (#2431)
* add end behavior enum and properties

* support loop end behavior

* implement end behavior hold

* update changelog
2025-09-17 03:35:49 +00:00
Jason Dove a0e0bb8753 fix motion element timing (#2430) 2025-09-17 01:09:00 +00:00
Jason Dove 9182a8ad18 cleanup graphics element loading (#2412) 2025-09-13 13:39:20 +00:00
Jason Dove 5d081ceeff fix editorconfig and run code cleanup (#2324)
* fix formatting rules

* reformat ersatztv

* reformat ersatztv.application

* reformat ersatztv.core

* refactor ersatztv.core.tests

* reformat ersatztv.ffmpeg

* reformat ersatztv.ffmpeg.tests

* reformat ersatztv.infrastructure

* cleanup infra mysql

* cleanup infra sqlite

* cleanup infra tests

* cleanup ersatztv.scanner

* cleanup ersatztv.scanner.tests

* sln cleanup

* update dependencies
2025-08-16 14:44:48 +00:00
Jason Dove d71443ef60 add subtitle graphics element (#2321) 2025-08-15 19:48:04 +00:00
Jason Dove a6b01cbe28 convert graphics engine from imagesharp to skiasharp (#2319)
* use skiasharp in graphics engine

* start to use richtextkit

* move out some template functions

* move files

* add base graphics element

* use default style in text element

* support partial styling in text element

* fix static images

* load fonts from text element definition
2025-08-15 14:27:22 +00:00