Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

fix(logo): a text check reads a misreading once more and passes on one reading that spells the text; codex reads it on gpt-6-sol at high effort, named on the call, and every reading is in the report

Soohong Kim8dd193bd8d59
diff --git a/docs/logo.md b/docs/logo.md
index c770aed..d99cc25 100644
--- a/docs/logo.md
+++ b/docs/logo.md
@@ -8,8 +8,8 @@ as part of that world: its letterforms, materials and light come from the scene.
is made in three steps:
1. **mood** — a title screen (16:9) or poster (2:3) in the brief's style with the title
- lettered in it. The text check reads it back; a title the model dropped or misspelt is
- refused here, before the next image is bought.
+ lettered in it. The text check reads it back (a misreading is read once more); a title
+ the model dropped or misspelt is refused here, before the next image is bought.
2. **lettering** — that picture attached as the reference of an image edit that asks for
only its lettering, with the same letterforms, materials, colours, outlines, glows and
effects, on a flat chroma key.
@@ -38,7 +38,7 @@ sprite-gen logo --provider codex --text "STARFALL" --lettering logo/lettering.pn
| `--mood PATH` | start from a picture with the title already in it (a title screen you have, a candidate you picked): step 1 is not generated, its text is still read |
| `--lettering PATH` | a lettering image already on a key is cut again (after a matte change, or for a lettering drawn elsewhere): nothing is generated; the logo's text is still read |
| `--chroma-key` | `auto` (default), `magenta` or `green` — [below](#which-key) |
-| `--provider`, `--model`, `--quality`, `--resolution` | as `gen`, for both images and both text checks ([gen](gen.md)) |
+| `--provider`, `--model`, `--quality`, `--resolution` | as `gen`, for both images ([gen](gen.md)); the provider also reads both text checks, on its own reading model ([below](#the-text-check)) |
| `--out-dir`, `--report` | where the files go; the report defaults to `<out-dir>/logo.report.json` |
## Files
@@ -70,8 +70,10 @@ its text could not be checked); `refused` (with `refused_at`: `mood-check`, `mat
`visible_opaque_share`) and `key_hue_left` (visible pixels whose colour still carries the
key's hue — 0 is the aim);
- `text_check.mood` and `text_check.logo` (below);
-- `calls`: every call in order — `mood`, `mood-check`, `lettering`, `logo-check` — with its
- provider, model, `auth_source`, `transport`, `elapsed_seconds` for the images, and `route`:
+- `calls`: every call in order — `mood`, `mood-check`, `lettering`, `logo-check`, a check's
+ call once for each reading it took, with its `reading` (1, 2) and the `effort` it was read
+ at (`null` where the provider names none) — with its provider, model, `auth_source`,
+ `transport`, `elapsed_seconds` for the images, and `route`:
`subscription` (a codex ChatGPT login, a Grok login) or `per-call` (a codex API-key login,
`XAI_API_KEY`, `OPENAI_API_KEY`; each said on stderr before its request leaves, as every
metered call in sprite-gen is);
@@ -79,10 +81,10 @@ its text could not be checked); `refused` (with `refused_at`: `mood-check`, `mat
## The text check
-The provider that drew the images reads them back, once each, through the same vision call
-the facing check uses (`inspect_image`; codex `exec` read-only and ephemeral, or the xAI or
-OpenAI Responses API on the same credential). It is asked to return the lines of text as
-spelled, without being told what they should say. Both checks compare by one rule
+The provider that drew the images reads them back through the same vision call the facing
+check uses (`inspect_image`; codex `exec` read-only and ephemeral, or the xAI or OpenAI
+Responses API on the same credential). It is asked to return the lines of text as spelled,
+without being told what they should say. Both checks compare by one rule
(`logo.normalize`), what the text spells:
- **kept** — every letter and digit, and every mark written on one: an accent, a vowel
@@ -103,8 +105,31 @@ The subtitle may be read before or after the title. The verdict is one of:
| `mismatch`, `no-text` | refused: the lettering is not bought | refused: the cut is kept as `logo.rejected.png` |
| `unverified` (the call failed, or its answer was not the JSON asked for) | a warning; go on | `logo.png` is published with `status: unverified` and a warning: look at the preview |
-A model that reads stylised lettering can misread it; a refusal names what was read, so a
-person can judge, and `--mood` or `--lettering` starts again from the files already made.
+A model that reads stylised lettering can misread it, and the same picture read twice can
+come back two ways. So a reading that would refuse (`mismatch`, `no-text`) is read once
+more, up to `logo.MAX_READS` (2) readings: one that spells the text passes, and only when
+every reading differs is the image refused. Both checks decide by this one rule
+(`logo.read_text`). A call that fails is not asked again: with nothing read before it the
+check is `unverified`, and a misreading before it stands. Each check in the report keeps
+the deciding reading's verdict and `read`, `max_reads`, and `readings`: every reading in
+order with its number, verdict and what it read (or why it could not). A refusal names
+every reading, so a person can judge, and `--mood` or `--lettering` starts again from the
+files already made.
+
+A second reading can only pass a picture whose letters are wrong if the reader writes a
+stroke that is not drawn: it is never told what the text should say. Measured on a
+synthetic pixel title drawn one stroke short (쿠 drawn as 구, the middle bar of ㅋ left
+out), the codex reader below read that syllable as 구 in 10 readings of 10 and never as
+쿠, so neither one reading nor a check of two (0 of 5) could pass it.
+
+On codex the text checks read on `gpt-6-sol` at `high` reasoning effort, named on each call
+over the login's own `config.toml` (`facing_vision.CODEX_READ_MODEL` and
+`CODEX_READ_EFFORT`). A check is a gate, and its verdict should not change with the machine
+it runs on: left to each login's config, the same picture could be read on another model
+and effort on each machine, and the report could not say which. These are the model and
+effort the measurement above ran on. The report names the model and effort of every
+reading. `--model` names the images' model only; the facing check still runs on the login's
+config. The xAI and OpenAI checks read on their own fixed models, as the facing check does.
## Which key
@@ -167,10 +192,12 @@ is dense, cut the same lettering on the other key's terms by generating it again
## Cost
-Four calls a logo — two images and two text checks — on the provider named. On a
-subscription (codex ChatGPT login, Grok login) nothing is billed per call; `calls[].route`
-says which route each ran on. `--mood` saves the first image, `--lettering` both. Nothing is
-sent again on its own: a refusal is said and the run ends.
+Four to six calls a logo on the provider named: two images and two text checks, each read
+once, or twice when its first reading would refuse. On a subscription (codex ChatGPT login,
+Grok login) nothing is billed per call; `calls[].route` says which route each ran on.
+`--mood` saves the first image, `--lettering` both. Beyond a check's second reading, nothing
+is sent again on its own: a call that fails is not asked again, and a refusal is said and
+the run ends.
## Related
diff --git a/sprite_gen/gen/codex_provider.py b/sprite_gen/gen/codex_provider.py
index e3db7f6..ed7b4ef 100644
--- a/sprite_gen/gen/codex_provider.py
+++ b/sprite_gen/gen/codex_provider.py
@@ -384,8 +384,9 @@ class CodexProvider:
return codex_inspect(path, workdir)
def inspect_image(self, path: Path, workdir: Path, prompt: str, *, label: str = "vision check") -> tuple[str, dict]:
- from .facing_vision import codex_inspect
- return codex_inspect(path, workdir, prompt=prompt, label=label)
+ from .facing_vision import CODEX_READ_EFFORT, CODEX_READ_MODEL, codex_inspect
+ return codex_inspect(path, workdir, prompt=prompt, label=label, model=CODEX_READ_MODEL,
+ effort=CODEX_READ_EFFORT)
def generate(self, request: GenRequest, workdir: Path) -> ProviderRun:
# `image_gen` exposes no effort or size dial, so neither knob is carried
diff --git a/sprite_gen/gen/facing_vision.py b/sprite_gen/gen/facing_vision.py
index 1340434..4fbc486 100644
--- a/sprite_gen/gen/facing_vision.py
+++ b/sprite_gen/gen/facing_vision.py
@@ -20,6 +20,11 @@ from .facing import INSPECTION_PROMPT
OPENAI_MODEL = "gpt-4.1-mini"
GROK_MODEL = "grok-4.6"
+# What codex reads lettering on (`inspect_image`), named on the call over the login's own config, so a logo's text
+# check reads on the same model and effort on every machine (docs/logo.md, the text check). The facing check still
+# runs on the login's config.
+CODEX_READ_MODEL = "gpt-6-sol"
+CODEX_READ_EFFORT = "high"
FACING_LABEL = "facing vision check"
@@ -49,10 +54,11 @@ def response_text(status: int, reply, *, label: str = FACING_LABEL) -> tuple[str
"response_status": reply.get("status")}
-def codex_inspect(path: Path, workdir: Path, *, prompt: str = INSPECTION_PROMPT,
- label: str = FACING_LABEL) -> tuple[str, dict]:
+def codex_inspect(path: Path, workdir: Path, *, prompt: str = INSPECTION_PROMPT, label: str = FACING_LABEL,
+ model: str | None = None, effort: str | None = None) -> tuple[str, dict]:
# Isolated cwd and ephemeral session: no project instructions, no stale
- # output reuse and no persistent vision rollouts. Uses the existing login.
+ # output reuse and no persistent vision rollouts. Uses the existing login,
+ # on its config's model and effort unless the call names them.
from .codex_provider import announce_codex_billing, codex_login
login = codex_login()
if login.source is None:
@@ -61,14 +67,19 @@ def codex_inspect(path: Path, workdir: Path, *, prompt: str = INSPECTION_PROMPT,
with tempfile.TemporaryDirectory(prefix="facing-", dir=workdir) as directory:
output = Path(directory) / "answer.txt"
command = [provider_binary("codex"), "exec", "--sandbox", "read-only",
- "--skip-git-repo-check", "--ephemeral", "--color", "never",
- "-C", directory, "-i", str(path.resolve()), "-o", str(output), "-"]
+ "--skip-git-repo-check", "--ephemeral", "--color", "never", "-C", directory]
+ if model:
+ command += ["--model", model]
+ if effort:
+ command += ["-c", f'model_reasoning_effort="{effort}"']
+ command += ["-i", str(path.resolve()), "-o", str(output), "-"]
completed = subprocess.run(command, input=prompt, capture_output=True,
text=True, encoding="utf-8", env=provider_subprocess_env(),
timeout=GEN_TIMEOUT_SECONDS)
if completed.returncode:
raise SystemExit(f"{_tag(label)}: codex exited {completed.returncode}")
- return output.read_text(encoding="utf-8"), {"transport": "codex-exec", "auth_source": login.source}
+ named = {key: value for key, value in (("model", model), ("effort", effort)) if value}
+ return output.read_text(encoding="utf-8"), {"transport": "codex-exec", "auth_source": login.source, **named}
def grok_inspect(path: Path, *, credential=None, call=None, prompt: str = INSPECTION_PROMPT,
diff --git a/sprite_gen/gen/logo.py b/sprite_gen/gen/logo.py
index e7a1aaa..c521610 100644
--- a/sprite_gen/gen/logo.py
+++ b/sprite_gen/gen/logo.py
@@ -6,8 +6,8 @@ picture it belongs to (a title screen, a poster), it is drawn as part of that wo
materials and light. So a logo is made in three steps:
1. **mood** — a title screen or poster in the brief's style with the title lettered in it
- (`gen`, no reference). Its text is read back (`inspect_image`); a title the model dropped
- or misspelt is refused here, before the next image is bought.
+ (`gen`, no reference). Its text is read back (`inspect_image`, a misreading read once more);
+ a title the model dropped or misspelt is refused here, before the next image is bought.
2. **lettering** — that picture as the reference of an edit asking for only its lettering,
the same letterforms, materials and effects, on a flat chroma key (`gen --ref`). The key
is chosen from the title's colours in the mood image (the box its text check finds) unless
@@ -66,6 +66,10 @@ MOOD_READ_PROMPT = READ_PROMPT[:-1] + (
'. Add "box": [left, top, right, bottom], the box round the title lettering and its glow, each a share '
"of the image's width or height from 0 to 1."
)
+REFUSED = ("mismatch", "no-text") # the verdicts a text check refuses on
+# How many readings one text check may take: a reading that would refuse is read again, up to this many, and one
+# that spells the text passes (docs/logo.md, the text check).
+MAX_READS = 2
def _quoted(text: str) -> str:
@@ -199,10 +203,10 @@ def route_of(auth_source: str | None) -> str:
return "unknown"
-def read_text(backend, image: Path, workdir: Path, text: str, subtitle: str | None, *,
- prompt: str = READ_PROMPT) -> tuple[dict[str, Any], dict[str, Any]]:
- """Ask the provider what the image spells, once. Returns (check, call). A call that fails or an answer
- that cannot be read is `unverified` — said, never counted as a match."""
+def _read_once(backend, image: Path, workdir: Path, text: str, subtitle: str | None,
+ prompt: str) -> tuple[dict[str, Any], dict[str, Any]]:
+ """One reading: (check, call). A call that fails or an answer that cannot be read is `unverified` — said,
+ never counted as a match."""
started = time.monotonic()
try:
answer, metadata = backend.inspect_image(image, workdir, prompt, label=READ_LABEL)
@@ -211,7 +215,7 @@ def read_text(backend, image: Path, workdir: Path, text: str, subtitle: str | No
return {"verdict": "unverified", "reason": reason, "asked": [text, *([subtitle] if subtitle else [])]}, \
{"error": reason, "elapsed_seconds": time.monotonic() - started}
lines, box = parse_answer(answer)
- who = {key: metadata.get(key) for key in ("model", "auth_source", "transport")}
+ who = {key: metadata.get(key) for key in ("model", "effort", "auth_source", "transport")}
call = {**who, "elapsed_seconds": time.monotonic() - started}
if lines is None:
return {"verdict": "unverified", "reason": "invalid-vision-response",
@@ -219,10 +223,40 @@ def read_text(backend, image: Path, workdir: Path, text: str, subtitle: str | No
return {**compare_text(lines, text, subtitle), **({"box": box} if box else {}), **who}, call
+def read_text(backend, image: Path, workdir: Path, text: str, subtitle: str | None, *,
+ prompt: str = READ_PROMPT) -> tuple[dict[str, Any], list[dict[str, Any]]]:
+ """Ask the provider what the image spells, and again while what it reads would refuse, up to `MAX_READS`
+ readings: one that spells the text passes; only readings that all differ refuse. A call that fails is not
+ asked again: the check is `unverified` when nothing was read before it, and a misreading before it stands.
+ Returns (check, calls): the deciding reading's check, with every reading in order under `readings`, and a
+ call per reading. The one rule both text checks decide by."""
+ taken: list[dict[str, Any]] = []
+ calls: list[dict[str, Any]] = []
+ for number in range(1, MAX_READS + 1):
+ check, call = _read_once(backend, image, workdir, text, subtitle, prompt)
+ taken.append(check)
+ calls.append({**call, "reading": number})
+ if check["verdict"] not in REFUSED:
+ break
+ read = [check for check in taken if check["verdict"] != "unverified"]
+ deciding = next((check for check in read if check["verdict"] == "match"), read[-1] if read else taken[-1])
+ readings = [{"reading": number, **{key: check[key] for key in ("verdict", "read", "normalized_read", "box", "reason")
+ if key in check}} for number, check in enumerate(taken, 1)]
+ return {**deciding, "max_reads": MAX_READS, "readings": readings}, calls
+
+
+def _reads(check: dict[str, Any]) -> str:
+ """What a refused check's readings spelled, in order: "['IO']", or "['IO'] and then ['I0']"."""
+ return " and then ".join(repr(reading["read"]) for reading in check["readings"] if "read" in reading)
+
+
def _call(step: str, provider: str, details: dict[str, Any], elapsed: float | None = None) -> dict[str, Any]:
auth = details.get("auth_source")
entry = {"step": step, "provider": provider, "model": details.get("model"), "auth_source": auth,
"transport": details.get("transport"), "route": route_of(auth)}
+ for key in ("effort", "reading"): # a text check's reading: its number and the effort it was read at
+ if key in details:
+ entry[key] = details[key]
if elapsed is not None:
entry["elapsed_seconds"] = round(float(elapsed), 3)
if details.get("error"):
@@ -370,11 +404,11 @@ def _draw_lettering(provider: str, backend, report: dict[str, Any], files: dict[
report["calls"].append(_call("mood", result.provider, {**result.extra, "model": result.model},
result.elapsed_seconds))
report["files"]["mood"] = str(files["mood.png"])
- check, call = read_text(backend, files["mood.png"], work, text, subtitle, prompt=MOOD_READ_PROMPT)
+ check, calls = read_text(backend, files["mood.png"], work, text, subtitle, prompt=MOOD_READ_PROMPT)
report["text_check"]["mood"] = check
- report["calls"].append(_call("mood-check", provider, call, call.get("elapsed_seconds")))
- if check["verdict"] in ("mismatch", "no-text"):
- raise _Refusal("mood-check", f"logo: the mood image reads {check['read']!r}, not {check['asked']!r} — the "
+ report["calls"] += [_call("mood-check", provider, call, call.get("elapsed_seconds")) for call in calls]
+ if check["verdict"] in REFUSED:
+ raise _Refusal("mood-check", f"logo: the mood image reads {_reads(check)}, not {check['asked']!r} — the "
"model dropped or changed the title; generate the mood image again (the lettering was "
"not bought)")
if check["verdict"] == "unverified":
@@ -425,13 +459,13 @@ def _cut(files: dict[str, Path], report: dict[str, Any], work: Path, backend, ra
report["files"]["preview"] = str(files["logo.preview.png"])
reading = work / "logo-read.png"
_publish(logo_matte.reading_backdrop(logo), reading)
- check, call = read_text(backend, reading, work, text, subtitle)
+ check, calls = read_text(backend, reading, work, text, subtitle)
report["text_check"]["logo"] = check
- report["calls"].append(_call("logo-check", report["provider"], call, call.get("elapsed_seconds")))
- if check["verdict"] in ("mismatch", "no-text"):
+ report["calls"] += [_call("logo-check", report["provider"], call, call.get("elapsed_seconds")) for call in calls]
+ if check["verdict"] in REFUSED:
_publish(logo, files["logo.rejected.png"])
report["files"]["rejected"] = str(files["logo.rejected.png"])
- raise _Refusal("logo-check", f"logo: the logo reads {check['read']!r}, not {check['asked']!r} — kept aside "
+ raise _Refusal("logo-check", f"logo: the logo reads {_reads(check)}, not {check['asked']!r} — kept aside "
f"as {files['logo.rejected.png'].name}; generate the lettering again (--mood "
f"{files['mood.png']} skips the mood image)")
_publish(logo, files["logo.png"])