Skip to content

[S4] Quantize, and emit the error bound into the generated table #40

Description

@swgiacomelli

Child of #36. Depends on S3 (#39). Was G3 in the epic's original breakdown, revised.

Blocked until v0.1.0 ships. Per #36 § Activation, no work here starts until the v0.1.0 release cycle completes per RELEASING.md.

The pattern being adopted

The epic originally proposed that the baker print an error report. ph-color does something better and this child adopts it instead: the error bound is emitted into the generated source as a const, travelling with the table it describes.

ph-color-bake's README: "It derives gamut matrices and transfer LUTs and emits Rust const tables with MAX_ERR_LSB." The emitters take the bound as an argument alongside the data — interp_lut("IDENTITY_LUT_17", lut.knots, lut.max_err_lsb), srgb_oetf("SRGB_OETF", oetf257.knots, oetf257.max_err_lsb) — so the budget cannot be separated from the artifact by a copy-paste.

A printed report is read once and lost. A const in the emitted module is visible at the consumption site, survives review, and shows up in a diff when it moves.

Work

  • Apply the caller's scale factor to produce the i32 value grid.
  • Compute deviation of the quantized surface from the supplied samples: maximum, RMS, worst-deviation coordinate, and per-knot residual.
  • Emit the maximum as a const in the generated module, named to match this crate's domain (the runtime's unit is an i32 value LSB, not a color LSB — pick the name in review, but keep the ph-color shape).
  • Keep the fuller statistics as CLI output for the operator; the const is the durable half.

Honest budgets

The bound describes deviation between the supplied samples and the table built from them. It is not a device, vendor, sensor, calibration, or measurement-accuracy claim. The wording rule in AGENTS.md § 3a applies to every figure the baker prints or emits — that rule is unaffected by this epic and stays in force verbatim. No cycle count, no timing figure, no total flash cost.

ph-color's status disclosure is the model for tone: Model conformance: N/A. Physical evidence: N/A.

Acceptance

  • The emitted bound is a const in the generated source, not only console output.
  • The emitted bound is provably an upper bound: a test evaluates the generated table against every supplied sample and asserts no deviation exceeds it.
  • Wording carries no accuracy, timing, or device claim.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions