Skip to content

BUILD-1078: validate First Light frame dimensions - #3798

Open
Hanioe2 wants to merge 4 commits into
ItsNotRexed:mainfrom
Hanioe2:fix/first-light-dimensions
Open

Hanioe2 wants to merge 4 commits into
ItsNotRexed:mainfrom
Hanioe2:fix/first-light-dimensions

Conversation

@Hanioe2

@Hanioe2 Hanioe2 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

BUILD-1078 was claimed in the coordination issue. #3574

What changed

First Light validates --width and --height before preparing the draw, using the signed int range accepted by vk_harness. Rechecking a saved manifest validates both dimensions before looking for a harness or removing an existing image.raw. Invalid manifest dimensions report the path and field and preserve the previous readback.

Validation

  • Windows, CPython 3.14.7. Both First Light test files passed 19 tests, with three package-gated tests skipped. The two regressions exercise 20 invalid inputs.
  • A separate CLI smoke test with an invalid manifest and no harness reported the dimension error and preserved the old readback. py_compile and git diff --check passed.
  • Checked against upstream main 4c52ce2 after incorporating the textured draw option changes. The First Light suite passed 30 tests with four skips on Windows.
  • Synthetic files only.

AI-assisted.

@evilclanker9000

Copy link
Copy Markdown
Contributor

Independent Windows Python check of 1b900b3 against parent f847748. With a stub harness writing two RGBA32F pixels, the parent accepted a Boolean width of true as 1. This head rejected it before invoking the harness and preserved the old readback bytes. A 2x3 manifest with only 80 of the expected 96 bytes was rejected on both revisions. The matching 96-byte control passed on both and produced a PPM. A raw readback carries pixel bytes only, so different shapes with the same pixel count cannot be distinguished from length alone. All 11 focused tests passed on this head.

AI-assisted.

@tupacfan04

Copy link
Copy Markdown
Contributor

Tested at the head on Windows 11 / Python 3.13.0: 22 tests (3 skipped), compileall clean, merge clean (one commit atop f847748c). Negative control: all 16 new subcases fail on main.

Validation is right: run_draw (tools/first_light.py:383-387) rejects 0, -1, 4.0, 4.5, True, "4" and None with one clean line and exit 1 naming the path and field, and it runs before image.raw is deleted (:388), so the readback survives. The CLI rejects 0/-1 with ap.error (exit 2, :543-545) before ensure_carve, and non-integers are caught by argparse.

Two nits:

  1. :382 calls find_harness before the dimension check, so without a harness an invalid manifest reports "vk_harness not found" instead of the dimension error; the test mocks find_harness, which hides it.
  2. No upper bound: 10**18 is accepted and handed to the harness (:383-387), where a C int would overflow. The PR only claims nonpositive, but a sane cap (or <= INT_MAX) would close it.

Approve. AI-assisted review, no game files, no GPU.

@Hanioe2

Hanioe2 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @tupacfan04 for catching both. 480a2d8 validates the saved dimensions before looking for a harness and applies the harness's signed int upper bound to the CLI and manifest. The CLI check without a harness reported the invalid dimension and preserved the old readback. The First Light suite passed 19 tests with three package-gated skips. AI-assisted.

@kacper-serewis

Copy link
Copy Markdown
Contributor

BUILD-1078 at 480a2d8 resolves both prior findings across 72 synthetic Windows CLI cases on parent and head. Signed-int maximum reached the next dependency; max+1 failed early. Fractional and boolean manifest dimensions identified the field even without a harness. All eight invalid cases preserved the prior image on head. 19 unit tests passed, three skipped. CPU only. AI-assisted.

@Hanioe2

Hanioe2 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Synced this branch with upstream main at 4c52ce2 in 9f7af7c. The sync retains the textured draw option check and the size validation before carving and harness lookup. Compared with current main, the PR still changes only the dimension checks and their tests. The First Light suite on Windows passed 30 tests with four skips. AI-assisted.

@Hanioe2

Hanioe2 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Synced this PR with upstream main at 98fa503f in c90319a4. The conflict was in run_draw, which now retains the upstream check for an OBJ with faces and validates saved dimensions before harness lookup or readback removal. The diff against main is still limited to the dimension checks and their regression tests.

Native Windows 11 / CPython 3.14.7 ran 47 First Light tests with eight skips. The four junction cases ran and passed. The skips were four symlink subcases on this machine, three cases requiring prepared First Light output, and one case requiring a built vk_harness. compileall and git diff --check passed.

Synthetic inputs only. AI-assisted.

@limittox

Copy link
Copy Markdown

Tested c90319a4 on Windows 11, Python 3.13 (CPU only, no game files): pass

  • The run_draw conflict resolution in the merge of 98fa503f keeps both sides: main's "requires an OBJ with faces" check runs first, then the dimension check (checked with git show --remerge-diff c90319a4).
  • python -I tests/test_first_light_bad_json.py: 11/11 OK. With main's tools/first_light.py swapped in, the two new tests fail on 20 sub-cases (0, -1, 4.0, True, "4", None, 2³¹ in the manifest; "0", "-1", "2147483648" on the command line, for both width and height), so they cover the change.
  • test_first_light.py (4 skipped: no harness), test_first_light_harness_paths.py, test_first_light_mesh_draw.py, test_first_light_stale_mesh.py: OK.
  • Merging today's main (d974c88a) into the head is clean, and the tests still pass there.

AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Contributor

Tested c90319a merged with main 98fa503 on Linux (Python 3.12.16): pass. test_first_light.py, test_first_light_bad_json.py, test_first_light_harness_paths.py, test_first_light_mesh_draw.py and 1 more 5/5 ok. Negative control with main's tools/first_light.py: test_first_light_bad_json.py fails.

@bobcatchris

Copy link
Copy Markdown
Contributor

Independent code read and macOS check at head c90319a (Apple M2, macOS 26.4, Python 3.13.18). No game data; the CLI smoke test uses a synthetic manifest.

Code read: main() validates a.width/a.height with ap.error after the argument checks and before ensure_carve(), so a bad dimension is a usage error at exit 2 rather than reaching fit(). run_draw() repeats the check on the saved manifest with type(size) is not int and the same inclusive 1..MAX_FRAME_DIMENSION range, and it does so before find_harness() and before unlinking image.raw. That ordering is the point of the change: a bad saved manifest cannot reach the draw after the previous readback has been removed. The error names the manifest path and the field.

  • pytest -q tests/test_first_light.py tests/test_first_light_bad_json.py: 35 passed, 4 skipped, 28 subtests passed, 0 failed.
  • Synthetic --check smoke test: a manifest with width: 0 and a pre-existing image.raw. This head prints one line — the first-light manifest <path> requires an integer from 1 to 214 for width — exits 1, and leaves image.raw untouched. Current main d974c88a with the same files instead stops at vk_harness not found, confirming the dimension check now runs before the harness lookup.

No issues found in the diff. No code changes of my own.

AI-assisted.

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.

7 participants