Skip to content

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

docs(video): `(HTTP n)` is a refusal line's status, not only a refused submission's

Soohong Kim838dc2403192
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a421dc4..77c2628 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,7 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the
## Unreleased
- **Fix: a poll xAI answers 429 or 5xx asks the same request again — the clip is bought once.** `video`, `video-extend` and `video-edit` ended the run on any non-2xx poll, after xAI had accepted the request and may bill it, and the line read `(HTTP 429)` — what `video-set`, and any caller that backs off on a refused submission, answers by submitting the clip again: a second clip paid for, the first never published. A poll answered `429`, `500`, `502`, `503` or `504` is now asked again on the same `request_id`, after a wait that doubles from 8 s up to 60 s while the polls are refused and goes back to 4 s on an answer; a stderr note says each, the status in plain digits. The poll timeout (`SPRITE_GEN_VIDEO_TIMEOUT_SECONDS`) still bounds the whole poll: no wait runs past it, a pending poll's last wait included, and one last poll is asked at it. A refused POST is still never sent again, and a `400`, `401` or `404` poll still ends the run with its status.
-- **Output change: a generation the poll timeout cut short is unfinished, named by its `request_id`.** Polls still pending or still refused at the timeout end the run with a line that names `request_id=<id>`, says the generation may still finish and be billed, and carries no `(HTTP <n>)` — that marks a refused submission, which a caller may send again unbilled. The pending line keeps its front (`still 'pending' after N polls — poll timeout;`). With `--report` the run leaves a `sprite-gen-video-unfinished` report there (`verb`, `auth_source`, `model`, `request_id`, `out`, `polls`, `polls_refused`, `last_poll`, `elapsed_seconds`) and prints nothing on stdout; Python callers catch `GenerationUnfinished`, a `SystemExit`. The success report gains `polls_refused`, how many of its `polls` xAI answered 429 or 5xx (docs/video.md, An unfinished generation).
+- **Output change: a generation the poll timeout cut short is unfinished, named by its `request_id`.** Polls still pending or still refused at the timeout end the run with a line that names `request_id=<id>`, says the generation may still finish and be billed, and carries no `(HTTP <n>)`, a refusal line's status — a caller that reads `(HTTP 429)` there sends the request again, unbilled only when it was refused. The pending line keeps its front (`still 'pending' after N polls — poll timeout;`). With `--report` the run leaves a `sprite-gen-video-unfinished` report there (`verb`, `auth_source`, `model`, `request_id`, `out`, `polls`, `polls_refused`, `last_poll`, `elapsed_seconds`) and prints nothing on stdout; Python callers catch `GenerationUnfinished`, a `SystemExit`. The success report gains `polls_refused`, how many of its `polls` xAI answered 429 or 5xx (docs/video.md, An unfinished generation).
- **`tests/gen/test_video.py`** scripts the polls: each of the five statuses refused twice, then pending, then done, is asked on the one request with waits 8, 16, 4 and published with `polls_refused` 2; polls refused until a 300 s timeout wait 8, 16, 32, 60 × 4 and 4, ask a ninth poll at the timeout and end unfinished with no `(HTTP n)` and no `HTTP 429` on stderr; a pending timeout names the request; a 400, 401 or 404 poll ends at once; a refused POST is sent once; the CLI leaves the unfinished report and an empty stdout. The 500-poll case of the failure table is a 404 now, the status that still ends a run.
- **Output change: an `openai` image report carries the response's rate-limit headers — `extra.rate_limit`.** The provider dropped the response headers, so what the account may spend per minute and has left could not be read off real traffic. `extra.rate_limit` now holds every `x-ratelimit-*` header the response carried, names lower-cased and values as sent, and `{}` when none came (docs/gen.md). `openai_provider.http_image` returns the response headers as a third value.
- **`tests/gen/test_openai_provider.py`** answers with headers: the report holds exactly the `x-ratelimit-*` ones among others of any case, and `{}` for a response without any.
diff --git a/docs/video.md b/docs/video.md
index 7007487..6a95c9a 100644
--- a/docs/video.md
+++ b/docs/video.md
@@ -217,9 +217,10 @@ video: generation <id> was accepted, but its polls were refused (last answer 429
video: generation <id> still 'pending' after 151 polls — poll timeout; it may still finish and be billed — ask for request_id=<id> again instead of submitting a new request; nothing was written
```
-The line carries no `(HTTP <n>)`: on a video line that marks a refused submission
-(docs/gen.md), which a caller may send again unbilled; the stderr notes before it say
-the status in plain digits for the same reason. With `--report` the run leaves a
+The line carries no `(HTTP <n>)`, the status of a refusal line (docs/gen.md): a caller
+that reads `(HTTP 429)` there sends the request again, which is unbilled only when the
+request was refused. The stderr notes before it say the status in plain digits for the
+same reason. With `--report` the run leaves a
`sprite-gen-video-unfinished` report there, and nothing on stdout:
```json
diff --git a/sprite_gen/gen/video.py b/sprite_gen/gen/video.py
index 1bd13fc..693719c 100644
--- a/sprite_gen/gen/video.py
+++ b/sprite_gen/gen/video.py
@@ -110,9 +110,9 @@ _FAILED_STATUSES = ("failed", "error", "expired")
class GenerationUnfinished(SystemExit):
"""xAI accepted the request (it may bill it) and the poll timeout came before it ended.
- The line names `request_id=<id>` and carries no `(HTTP n)`: that marks a refused submission,
- which a caller may send again unbilled; this request is asked for again by its id instead.
- `to_dict()` is the report the CLI leaves at `--report`."""
+ The line names `request_id=<id>` and carries no `(HTTP n)`, a refusal line's status: a caller
+ that reads `(HTTP 429)` there sends the request again, unbilled only when it was refused. This
+ one is asked for again by its id instead. `to_dict()` is the report the CLI leaves at `--report`."""
def __init__(self, message: str, *, verb: str, request_id: str, auth_source: str, model: Any, out: Path,
polls: int, polls_refused: int, last_http: int, last_status: Any, elapsed_seconds: float) -> None:
@@ -522,7 +522,7 @@ def _submit_poll_publish(
)
wait = min(wait, deadline - now)
if refused_in_a_row:
- # The status in plain digits: `(HTTP n)` on this stream reads as a refused submission.
+ # The status in plain digits: `(HTTP 429)` on this stream reads as a refused request to send again.
print(f"[{verb}] poll {polls} of generation {request_id} was refused ({http}); "
f"asking again in {wait:g}s", file=sys.stderr)
sleep(wait)
diff --git a/tests/gen/test_video.py b/tests/gen/test_video.py
index b29d988..79f322c 100644
--- a/tests/gen/test_video.py
+++ b/tests/gen/test_video.py
@@ -598,7 +598,7 @@ def test_polls_refused_until_the_poll_timeout_end_naming_the_request_to_ask_agai
assert message == ("video: generation req-1 was accepted, but its polls were refused (last answer 429) until the "
"poll timeout (300s, 9 polls); it may still finish and be billed — ask for request_id=req-1 "
"again instead of submitting a new request; nothing was written")
- # No `(HTTP n)`: that is a refused submission, which a caller may send again unbilled.
+ # No `(HTTP n)`, a refusal line's status: a caller reading `(HTTP 429)` sends the request again.
assert HTTP_STATUS.search(message) is None
assert "HTTP 429" not in message + capsys.readouterr().err
assert (unfinished.value.request_id, unfinished.value.last_http, unfinished.value.polls) == ("req-1", 429, 9)