13 / 14 · certificates

Blend Safety Certificate

The verified convex core of the sRGB gamut in Oklab, inside which any linear blend of colors stays in gamut.

figure generated by the instrument itself. hover to let the light in.

The problem

Display gamuts are non-convex in perceptual spaces. The description literature knows this well: convex hulls overestimate gamut volume, and alpha-shapes exist precisely to trace the concavities. But a description is not a guarantee, and every UI gradient, palette interpolation, and crossfade silently assumes the property the descriptions say fails: that the straight line between two legal colors stays legal. Nobody built the object that makes the assumption checkable.

The method

The tool maps the faces of the RGB cube through Oklab to sample the gamut boundary densely, computes the in-gamut centroid, and binary-searches a shrink factor s toward it. At each candidate scale it verifies that every scaled boundary point, and the midpoint of every sampled boundary pair, maps back inside the gamut; midpoints of far-apart boundary points are where concavities bite first, so they are the working test set. The certified core is the gamut scaled by s about the centroid: within it, linear blends of members are verified safe at the stated sampling density. If the full gamut passes at s equal to 1, the verdict says the gamut behaved convex as far as this grid can see; otherwise the worst sampled concavity, the boundary pair whose midpoint escaped furthest, is returned as a concrete counterexample.

What it promises

  • The certificate carries its own density: boundary sample count and midpoint pairs checked are reported in the verification block, so the strength of the claim is inspectable.
  • Failures are constructive: the worst concavity comes back as an explicit boundary pair with its midpoint's escape magnitude, a counterexample you can render.
  • The verdict never overreaches: at full scale it claims convex behavior only as far as the grid can see, and below full scale it states plainly that blends between the core and the boundary can leave the gamut.

Calling it

{
  "tool": "certify_blend_safety",
  "arguments": {
    "boundary_steps": 12
  }
}

Clone the maryslab repo, run cd mcp && npm install && npm run build, then claude mcp add maryslab -- node mcp/dist/server.js

A worked example

How far toward the sRGB boundary can gradient endpoints sit before a blend leaves the gamut?

what was asked

{
  "boundary_steps": 7
}

what the engine answered

{
  "safe_scale": 0.767578125,
  "centroid_oklab": [
    0.6694669284488033,
    0.004196485826243501,
    -0.0020015800525522622
  ],
  "worst_concavity": {
    "a": [
      0.627986958946293,
      0.2248403874430512,
      0.12579890615227085
    ],
    "b": [
      0.7864537688651059,
      0.18113548162596305,
      -0.1159944505581556
    ],
    "midpointEscape": 0
  },
  "verification": {
    "boundary_samples": 294,
    "pairs_checked": 76212
  },
  "verdict": "Convex blending is verified safe inside the core scaled 0.768 toward the centroid. Between the core and the boundary, linear blends can leave the gamut — the worst sampled concavity is reported. Sampled certificate: density is steps=7 per cube face.",
  "meta": {
    "engine_version": "0.4.1",
    "engine_backend": "reference-ts",
    "dataset_snapshot": "usgs-splib07a-1",
    "compute_device": "cpu"
  }
}

how to read it

safe_scale is the shrink factor. The verification block states how many boundary points and midpoint pairs backed the claim — that density is part of the certificate.

Produced by running certify_blend_safety at build time (63 ms). Long arrays are truncated for reading; nothing else is edited.

Known limits

  • This is a sampled certificate: safety is verified on a finite boundary grid and strided midpoint pairs, so a concavity thinner than the sampling can slip through, and boundary_steps is part of the claim.
  • Midpoints are the test set because concavities bite them first; general convex combinations are covered by that geometric reasoning plus sampling, not each verified individually.
  • The certificate is specific to the sRGB gamut in Oklab as this engine computes them; a different display gamut or working space needs its own certificate.