Skip to content

Collapse the six shipped-value-guarded media registry upgraders into one declarative chain #6056

Description

@atomantic

Problem

server/lib/mediaModels.js now carries at least six registry upgraders that all
share one shape — (id, shippedRepo, priorShippedValue) -> newValue, applied to
a persisted entry only when it still matches what PortOS itself shipped:

  • upgradeMiniMaxH3OutputControls (and its nested upgradeMiniMaxH3DenoisingCount)
  • upgradeLtx25AudioControls
  • upgradeLtx25CudaMemoryFloor
  • upgradeLegacyCudaLtxRuntime
  • upgradeFastMetalDownloadSizes (added in FastMetal display names understate their download by 3-4x #5871)
  • backfillRuntime / dropRetiredEntries at the ends of the same chain

They are composed by hand in normalizeRegistry's videoEntries, which is now
four parens deep and gains a nesting level with every addition:

const normalized = backfillRuntime(upgradeFastMetalDownloadSizes(upgradeLtx25AudioControls(
  upgradeMiniMaxH3OutputControls(dropRetiredEntries(entries)),
)));

The ordering is load-bearing in places (an upgrader must run before
applyVideoDisclosures, which only fills an ABSENT disclosure) but that
constraint is invisible in the expression — it reads as arbitrary nesting.

Work

Introduce an ordered REGISTRY_UPGRADES array reduced in one place, so adding
the seventh upgrader is appending a row rather than adding a paren level. Keep
each upgrader's own guard logic where it is; this is about the composition, not
the rules.

Where an upgrader is a pure (id, shippedRepo, oldValue) -> newValue profile
rewrite (FastMetal and the LTX-2.5 audio backfill both are), consider expressing
it as data plus one shared applier rather than a bespoke function.

Acceptance

  • videoEntries composes upgraders from one ordered list, not nested calls.
  • Any ordering constraint relative to the apply* decorators is stated in the
    list rather than implied by nesting.
  • No behavior change: the existing registry, migration, and disclosure suites
    pass unmodified.

Notes

Raised in review of #5871, which added the sixth upgrader. Deliberately NOT done
in that PR — it touches every upgrader and would have buried a user-facing
download-size fix under a cross-cutting refactor.

Related to #5871

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions