Resolution as a service

The same resolver, behind three HTTP endpoints

tools/serve.py is a single-file FastAPI application that puts the demo’s resolver on the wire. It is the shortest way to see that the resolution priority list and the ID selection sequence are ordinary, callable behavior — not something that only makes sense inside an image-processing library.

just serve            # or: uv run tools/serve.py
# then browse http://127.0.0.1:8611/

Like the notebooks, it is a PEP 723 script: the dependencies are declared inline, so there is nothing to install first.

POST /resolve — run the read-side priority list

A JSON attribute bag (a file’s metadata) in; the priority list’s verdict and the evidence that produced it out. This is chapter 4.3 over HTTP.

curl -s localhost:8611/resolve -H 'content-type: application/json' \
     -d '{"attributes": {"chromaticities": [0.713,0.293,0.165,0.830,0.128,0.044,0.32168,0.33767]}}'
{"verdict": "...", "evidence": "which signal won"}

Pass colorInteropID, chromaticities, a CICP tuple, gamma tags — whatever a real file would carry, including combinations that disagree — and watch one ordered rule adjudicate them. When nothing in the bag survives the list, the verdict is null: no identity claim, never a guess.

POST /identify — the write-side ID selection sequence

A color-space name in (optionally with the name of an OpenColorIO built-in config); its interop ID and the method that produced it out — declared, derived, generated, or none. This is chapter 4.5 over HTTP.

curl -s localhost:8611/identify -H 'content-type: application/json' \
     -d '{"color_space": "ACEScg"}'
{"interop_id": "lin_ap1_scene", "method": "derived (transform comparison)"}

The method field is the point: an ID the config declared is a different kind of answer than one recovered by comparing what the transforms do, and the response never conflates them. A space that matches nothing comes back with no ID and "none — omitted rather than guessed".

GET /ids — the canonical list

Every interop ID the embedded studio config declares — the list this demo resolves against, exposed as data.

curl -s localhost:8611/ids
{"config": "<config name>", "count": <how many>,
 "ids": [{"interop_id": "lin_ap1_scene", "color_space": "ACEScg"}, ...]}

FastAPI generates the interactive documentation for free: with the server running, http://127.0.0.1:8611/docs gives a live request builder for all three endpoints.