Skip to content

review (in depth): strobe-shadertoy, strobe-autocontrol and strobe-forge - #156

Open
lnorton89 wants to merge 20 commits into
masterfrom
claude/nice-gauss-9dvqhj
Open

lnorton89 wants to merge 20 commits into
masterfrom
claude/nice-gauss-9dvqhj

Conversation

@lnorton89

Copy link
Copy Markdown
Owner

Summary

An in-depth, line-by-line review of every source file in strobe-shadertoy, strobe-autocontrol and strobe-forge. It goes past the hot paths an earlier pass covered.

It found 21 issues. 20 are fixed here and 1 is left open, with reasons below.

Every behaviour fix has a test that failed before the fix and passes after. I ran each one both ways; the "Before" lines below quote the failure output. No network calls were made: shadertoy.com and the LLM providers are tested only through canned bodies and test doubles. deny.toml and CHANGELOG.md are untouched. No decision record was needed.

Findings

strobe-forge

  1. make treated a dialect that was not checked as a compile error.

    • Where: crates/strobe-forge/src/check.rs:245
    • Bug: DialectResult::not_checked puts its reason in error, and compile_errors() collected every error. With --no-dialect, no ANGLE, or the 240 s child timeout, each round ran the whole repair loop: 3 paid requests telling the model its working scene "does not compile: not asked for". The child's unbounded stderr also went to the provider in the repair prompt.
    • Fix: only Status::Failed counts.
    • Test: check::tests::a_dialect_not_checked_is_not_a_compile_error
    • Before: FAILED. After: ok.
  2. An empty "successful" answer was kept in the history.

    • Where: anthropic.rs:168, google.rs:163, openai.rs:135
    • Bug: {"content":[],"stop_reason":"end_turn"}, Gemini finishReason: OTHER with no parts, a thinking-only answer, or OpenAI content: null returned Ok(""). That empty turn was appended as the assistant's. Anthropic refuses an empty assistant turn, so the next request was a 400 and the run ended with repairs unused.
    • Fix: an answer with no text is an error, so send takes the user turn back.
    • Test: new cases in the three errors_* tests
    • Before: all 3 FAILED. After: ok.
  3. The frozen gate compared only the green channel.

    • Where: gate.rs:237
    • Bug: a hue cycle with green held at 0 read as "does not move", which is a hard failure.
    • Fix: use the largest channel difference per pixel. site/src/lib/play/image/gate.ts changes the same way to keep the two gates in step (D562).
    • Tests:
      • gate::tests::motion_in_red_and_blue_alone_is_not_frozen
      • vitest counts motion in red and blue alone as motion, run against the old gate.ts and the new one
    • Before: both FAILED. After: ok.
  4. Round 0's log said "the previous scene stands" when there was none.

    • Where: forge.rs:172
    • Fix: the note depends on whether a scene stands.
    • Test: forge::tests::answers_that_never_parse_end_without_a_scene (extended)
    • Before: FAILED. After: ok.
  5. A Markdown fence inside a <file> block cost a paid repair.

    • Where: reply.rs:113
    • Bug: "glsl" does not compile, and "json" is not JSON.
    • Fix: one surrounding fence is dropped (CRLF too). The module doc says so.
    • Test: reply::tests::a_markdown_fence_inside_a_block_is_dropped
    • Before: FAILED. After: ok.
  6. A provider's error and refusal text went to the log and stdout whole.

    • Where: http.rs:82; openai.rs refusal
    • Bug: ureq allows a body up to 10 MB.
    • Fix: http::bounded cuts it to 500 characters and says how long it was.
    • Test: http::tests::a_provider_error_message_is_bounded
    • Before: FAILED, "carries 400036 bytes". After: ok.

Checked and fine:

  • Keys: all three providers send the key only in a header. Google uses x-goog-api-key, not ?key=, and the model id in the URL path is validated.
  • Loops and timeouts:
    • repairs and rounds are bounded;
    • a failed request pops its user turn on every provider;
    • the HTTP timeout is 20 min and the dialect child's is 240 s.
  • Gates: the thresholds and the 75th-percentile flash rule match gate.ts.

strobe-shadertoy

  1. #define iTime (iTime * 0.5) did not compile.

    • Where: convert/shim.rs:187
    • Bug: on Shadertoy iTime is a uniform, so redefining it as a macro is legal. The shim's own #define iTime strobe_iTime made it a "Redefinition of macro". The same applies to iResolution, iMouse and the other scalars.
    • Fix: when the author defines the name, the shim declares a variable under the bare name and sets it in strobe_begin(). It cannot be initialised where it is declared: on ES the hoisted initialiser lands in main, below the author's macro.
    • Test: render test a_shadertoy_uniform_the_author_redefines_as_a_macro_still_works, both dialects
    • Before: FAILED with the preprocessor error. After: ok.
  2. Any mention of gl_FragColor turned a pass black.

    • Where: convert/shim.rs:474
    • Bug: a mention even inside #if 0, or in an unused helper, made renderMain return the legacy variable. That variable stayed black when only mainImage's output was written.
    • Fix: the legacy variable starts at a sentinel (-65504, which survives mediump), and mainImage's output is used while the sentinel is still there.
    • Tests:
      • render test gl_fragcolor_in_code_that_never_runs_does_not_blacken_the_pass (it also checks the legacy fixture still draws);
      • the legacy golden and its convert assertion are updated.
    • Before: FAILED with (0, 0). After: ok.
  3. The generated st_keyboard.png counted as a found texture.

    • Where: import.rs:268
    • Fix: exclude every generated image name, i.e. names::is_generated_image.
    • Test: import::tests::the_generated_keyboard_image_is_not_counted_as_a_texture
    • Before: FAILED with 1 ≠ 0. After: ok.
  4. A URL with a port was refused.

    • Where: id.rs:81
    • Bug: https://www.shadertoy.com:443/view/XsXXDn was rejected with WrongHost.
    • Fix: a numeric port is dropped before the host is compared. shadertoy.com:x and example.com:443 are still refused.
    • Test: cases added to every_accepted_form_gives_the_same_id and bad_input_says_what_is_wrong
    • Before: FAILED. After: ok.
  5. A client trickling its request could hold a listener slot for hours.

    • Where: listener/mod.rs:487
    • Bug: io_timeout limits each read, not the whole request. One byte every 9 s kept a slot open, and four such clients made every import a 503. The module doc claimed a stalled client could not hold the listener.
    • Fix: a Deadline reader bounds head and body together. ListenerConfig::request_deadline defaults to 30 s, and the doc is corrected.
    • Test: a_client_trickling_its_request_is_cut_off
    • Before: FAILED, the connection was held for 10.2 s, the whole test window. After: ok.
  6. The invalid-key message said "letters and digits", but _ and - are accepted too.

    • Where: acquire/key.rs:58
    • Fix: message only; no test.

Checked and fine:

  • Comments, strings and renames: comments, identifiers that merely contain a renamed name, line continuations and line-number preservation are all handled.

  • Channels: cube, black-cube, audio and keyboard bindings, iChannelResolution and iChannelTime.

  • Assets and paths:

    • asset URLs refuse look-alike hosts, .. and file:;
    • cache and file names cannot traverse paths;
    • every read is capped (REST 4 MiB, texture 16 MiB, body 2 MiB, head 16 KiB and 64 headers).
  • Listener:

    • it binds loopback only;
    • Host must match exactly;
    • the token compare is constant time and happens before the body is read;
    • there are no CORS headers.

    There is no Origin check. None is needed with the token, the custom header and the exact Host check, so there is no prefix, suffix or null-Origin weakness.

  • Attribution: CREDIT, DESCRIPTION and SOURCE (id, url, author, name, licence note, tags) are written on every successful path, including when textures fail.

strobe-autocontrol

  1. A named loop bound that also bounds an array-indexing loop became a slider.

    • Where: analyze/mod.rs:159
    • Bug: #define N 8 with for (i < N) w[i] = ... and a second for (j < N) gave N the range 2..16. The scorer's own nudge then read past w[8].
    • Fix: any loop that indexes with its variable vetoes the name, as for a literal bound.
    • Test: a_name_that_bounds_any_array_indexing_loop_is_never_a_candidate
    • Before: FAILED. After: ok.
  2. rewrite_chosen wrote any range it was given.

    • Where: generate.rs:195

    • Bug: the app's inspector, or a page passing JSON through, could set a loop count's max to 1e6, past LOOP_CAP (the 2012-iGPU hang guard), or its min below 1. A range that left out the default also had the scene clamp the verified default.

    • Fix: reviewed_range:

      • a loop count stays in 1..=LOOP_CAP.max(default);
      • every range is widened to hold the default;
      • a non-finite or empty range keeps the measured one.

      The doc comment is corrected.

    • Test: a_reviewed_loop_range_keeps_the_hang_cap_and_the_default (no GL)

    • Before: FAILED, "-5..1000000 must stay inside 1..256". After: ok.

  3. A non-integer float loop bound was treated as a count.

    • Where: analyze/expr.rs:221, analyze/mod.rs:240
    • Bug: floor(n + 0.5) changes the loop at its default: 6.2832 becomes 6, which leaves a gap in a ring, and 10.5 becomes 11, an extra step. Count is documented as integer-valued.
    • Fix: a count must be a whole number.
    • Tests: cases in loop_traps_are_left_alone, and a_named_bound_that_is_not_a_whole_number_is_not_a_count
    • Before: both FAILED. After: ok.
  4. A huge time factor aborted the whole generation.

    • Where: analyze/expr.rs:208
    • Bug: TIME * 2e38 or TIME / 1e-39 wrote "MAX": inf into scene.json, and with_controls failed for the whole scene.
    • Fix: speed_ok requires a finite speed under 1e5, the same bound as scale_value_ok, in both the code and the #define-body scanners.
    • Tests: cases in time_traps_are_left_alone and a_speed_inside_a_define_body_is_found
    • Before: both FAILED. After: ok.
  5. A constant used inside parentheses at global scope was offered as safe.

    • Where: analyze/consts.rs:466
    • Bug: float g = sqrt(S); contradicts the module doc. The rewrite is a non-constant global initialiser and fails to compile, which cost a combined compile plus a lone search.
    • Fix: any use at brace depth 0 is unsafe.
    • Test: a case in uses_that_need_a_constant_make_it_unsafe
    • Before: FAILED. After: ok.
  6. A const shadowed by a parameter was rewritten into a broken signature.

    • Where: same line as 17
    • Bug: const float K alongside float f(float K) became #define K (k), which pastes into float f(float (k)).
    • Fix: the change for 17 covers it, since the parameter list is at brace depth 0.
    • Test: a separate case in the same test. I ran it alone against the old code: it FAILED there and passes now.
  7. A bare speed macro divided by inside another macro was still offered.

    • Where: analyze/expr.rs:983
    • Bug: #define T TIME * 0.3 with #define U (1.0 / T). The guard scanned only code tokens, so the paste changed the maths.
    • Fix: #define bodies are lexed as well.
    • Test: a case in a_speed_inside_a_define_body_is_found
    • Before: FAILED. After: ok.
  8. Comments that contradicted the code.

    • lib.rs, consts.rs and naming.rs said the tokenizer was strobe-shadertoy's. It is strobe_scene::glsl; strobe-shadertoy is only a dev-dependency.
    • The doc fixes for findings 14 and 15 are covered above.

Checked and fine:

  • Number parsing: every GLSL spelling is handled.
  • Comment trivia: literals inside comments are skipped.
  • Contexts that need a constant: #if, case, array sizes and const initialisers are guarded.
  • Naming: keywords, collisions and uniqueness across passes.
  • Scoring: sorts use total_cmp, frames are u8, and there are no divide-by-zero paths.
  • JSON quoting.

Left, and why

  1. The shader page URL from the listener is not used as an attribution fallback.
    • Where: listener/mod.rs, Submission::page_url
    • What: a submission whose JSON has no info.id would get no SOURCE id or url, although pageUrl holds them.
    • Why left: it matters only if the userscript ever sends JSON without an id. That cannot be checked without the live site (Q19), and the fix needs a new ImportOptions field that the app has to fill in.

Smaller gaps I also left:

  • Other names the author may #define. An author #define of iChannel0–3, iChannelTime, iChannelResolution or iSampleRate still collides with the shim's own #define. Fix 7 covers the scalar uniforms, which is the common idiom (#define iTime (iTime*…)). Redefining a sampler name like this has no meaning to keep.
  • Quality floats in a review. A reviewed range for a Quality float (a draw distance) can still go to 0 or below (D259). Its default is now always inside the range. Picking a floor for each kind of float is a design choice, not a bug fix.
  • The dialect child's stderr is unbounded. After fix 1 it reaches only the report's warnings, never a prompt.
  • strobe-autocontrol --out inside the source folder copies the staging folder into itself. It is reachable only by a user mistake.

Test plan

All of this ran on Linux in a cloud container: Mesa llvmpipe, STROBE_REQUIRE_HEADLESS_GL=1. There was no real GPU and no Windows machine.

Command Result
cargo test -p strobe-shadertoy -p strobe-autocontrol -p strobe-forge 308 passed, 0 failed (297 before; 11 new tests, plus 10 existing tests with new cases)
cargo clippy -p strobe-shadertoy -p strobe-autocontrol -p strobe-forge --all-targets --all-features -- -D warnings clean
cargo clippy -p strobe-shadertoy --no-default-features --all-targets -- -D warnings clean
cargo clippy -p strobe-forge --no-default-features --all-targets -- -D warnings clean
cargo fmt --all -- --check clean
cargo test -p strobe-conventions 65 passed
RUSTDOCFLAGS="-D warnings -A rustdoc::private_intra_doc_links" cargo doc --no-deps --all-features --document-private-items (CI's step, for the three crates) clean
npx eslint, npx tsc --noEmit and npx vitest run tests/unit/from-image.test.ts in site/ clean, 34 passed
cargo check -p strobe-app not run to completion: alsa-sys needs ALSA headers this container lacks. ListenerConfig is built only with ::new, which fills the new field.
cargo xtask changelog --check fails on master too in this shallow clone ("v0.2.0, v0.1.0 point at a commit no branch can reach"); environment only, so tags and CHANGELOG.md are left alone

Not run here:

  • the Windows cross-check;
  • the full cargo test --workspace;
  • the full cargo clippy --workspace.

CI covers all three.

Checklist

  • cargo fmt --all -- --check passes
  • clippy passes for the three crates, with all features and without defaults (workspace: CI)
  • tests pass for the three crates and conventions (workspace: CI)
  • Windows cross-check: CI
  • No new unwrap / expect / panic!
  • No new files; banners unchanged
  • No new unsafe
  • Per-frame path: unchanged. The shim adds one assignment in strobe_begin only for a redefined uniform, and one comparison per pixel only in legacy gl_FragColor passes.
  • No UI change
  • No ROADMAP item finished; no new decision needed
  • Commit subjects use conventional prefixes
  • CHANGELOG.md not hand-edited

Generated by Claude Code

make sent every round through the repair loop when the second dialect
was skipped (--no-dialect, no ANGLE, the child timing out), telling the
model its working scene did not compile.
An empty assistant turn kept in the history made the next request fail
(Anthropic refuses empty content), which ended the run with repairs
unused.
A hue cycle with green held read as frozen and failed the check. The
website's gate changes with it (D562).
…ompiles

`#define iTime (iTime * 0.5)` is legal on Shadertoy, where iTime is a
uniform; the shim's own #define made it a macro redefinition.
…ns a pass

Any mention of gl_FragColor (an #if 0 block, an unused helper) made the
pass return the legacy variable, which stayed black when only
mainImage's output was written.
A local client sending a byte every few seconds stayed inside the
per-read timeout and could hold a connection slot for hours; four of
them made the listener answer every import with 503.
…efault

rewrite_chosen wrote any min < max it was given, so a loop count could
be dragged past LOOP_CAP (the iGPU hang guard) or below one iteration,
and a range that left out the default had the scene clamp it.
floor(n + 0.5) moved a bound like 6.2832 or 10.5 at its default, so the
control started on a different picture (a gap in a ring, an extra step).
…trol

TIME * 2e38 or TIME / 1e-39 wrote an infinite MAX into scene.json, which
failed the whole generation instead of dropping one candidate.
… unsafe

A use inside parentheses at global scope (float g = sqrt(S);) or a
parameter of the same name (float f(float K)) was offered as safe, and
its rewrite cannot compile.
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @lnorton89's task in 26s —— View job


Review of PR #156

I read the listener Deadline reader and the gl_FragColor sentinel change in shim.rs. I did not read every file in the diff. I didn't run any tests either: the checkout is shallow, so git diff origin/master...HEAD has no merge base. I found no correctness bugs, no new unsafe, and no new unwrap, expect or panic!.

Listener Deadline (listener/mod.rs:487)

  • It bounds the head and body reads together, as the PR describes.
  • It is checked before each read, so one blocked read can overrun the deadline by up to io_timeout. A trickling client therefore holds a slot for roughly request_deadline + io_timeout, not exactly 30 s. That is acceptable and may be worth a line in the doc comment.

Legacy gl_FragColor sentinel (convert/shim.rs:473)

  • strobe_gl_FragColor.x == -65504.0 is a sound "was it written" test. A shader that writes only some channels still changes x or leaves the sentinel, so the output is right either way.
  • The only miss is a shader that deliberately writes exactly -65504 to .x, which can be ignored.
  • The one comparison per pixel applies only to legacy passes, so the per-frame path is otherwise unchanged.

House rules

  • CHANGELOG.md is untouched.
  • The PR says no ROADMAP item is finished and no new decision is needed. That is reasonable for a bug-fix review.
  • The gate.ts change keeps the Rust and TS gates in step (D562).

Nothing blocking. The "Left, and why" list in the PR body is a fair account of the open items.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant