world_grid_atlas: harden geometry, alignment, linear_fit, DDS/MHIU bounds, manifests, and strict JSON (WORLD-GRID-ATLAS-VALIDATION-HARDENING) #1506
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1506"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T02:35:18Z.
Claimed in the coordination issue as: WORLD-GRID-ATLAS-VALIDATION-HARDENING (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7150859873)
What and why
Hardens
tools/world_grid_atlas.pyagainst malformed geometry, alignment, regression-fit, DDS, MHIU, manifest, and JSON inputs:geometry(): rejectswidth <= 0,height <= 0,booldimensions/values, non-3-tuple or non-finiteorigin, and negative or non-finitezInflation(previouslywidth=0/-512passed% tileand triggeredZeroDivisionError/inverted boxes, and negativezInflationproducedz_min > z_max).cell_box(): rejectsbool/ non-intcells (previously1.5orTruesilently returned a box) and non-positive grid dimensions.fill_by_order(): rejects negative/booln_tiles, duplicate cells inorder, out-of-range/boolanchor tile indices, and anchor cells absent fromorder(raisingValueErrorinstead ofKeyErroror out-of-range placement keys).align(): rejects ragged score rows and non-finite/boolscores, and verifies backtrack indices are valid (previouslyNaN/-infscores leftarg[j] == -1, silently returning-1and indexingorder[-1]).linear_fit(): checkslen(xs) == len(ys)(previouslymy = fsum(ys) / len(xs)silently computed wrong means and regression parameters on mismatched inputs), rejects non-finite/boolpoints, and clamps Pearsonrto[-1.0, 1.0].read_image(): checkswidth > 0,height > 0, andlen(data) >= DX10_HEADERbeforestruct.unpack_from(..., 128)so a truncatedDDS/DX10file raises a cleanValueErrorinstead of an unhandledstruct.errortraceback.split_cells()/tile_step(): reject non-positiverows,columns,w,h, andpwithValueErrorinstead ofZeroDivisionError.water_fit()&run(): skip degenerate zero-span / non-finite / truncated MHIU heightmaps cleanly without divide-by-zero warnings, and runwater_fitonly onWaterSystemHeightMapitself rather than every grid sharing a dictionary set.load_manifests()&write_json(): validate JSON manifest root/items/textures structure (cleanValueErrorinstead ofAttributeError) and passallow_nan=Falsetojson.dump().Tested
python3 -I tests/test_world_grid_atlas.py: 42/42 (26 stdlib tests run and OK; 16 numpy/PIL tests skipped under-I).python3 tests/test_world_grid_atlas.py: 42/42 OK (all stdlib + numpy/PIL forward tests pass).main(3ff2a2adc): all 10 new regression tests fail (failures=19, errors=5plusRuntimeWarning: divide by zeroonwater_fit).python3 -I tests/test_text_write_line_endings.py: 3/3 OK.python3 -I scripts/check_no_game_data.py tools/world_grid_atlas.py tests/test_world_grid_atlas.py: clean.python3 -m compileall -q tools/world_grid_atlas.py tests/test_world_grid_atlas.py: clean.GPUs tested: n/a (Python atlas/analysis tool only)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — no translator rule changed)Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T02:35:30Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from ubiquitarianism/leonida. Originally posted by ytsodacan on 2026-11-25T03:36:14Z.
[KEEP]
tools/world_grid_atlas.pyreads sensibly (input validation ingeometry,cell_box,fill_by_order,align,linear_fit,read_image, manifests,allow_nan=False) and adds tests intests/test_world_grid_atlas.py.fix/world-grid-atlas-hardening, so nothing is verified by CI yet; mergeable state is clean.water_fitnow runs only forHEIGHT_GRIDinstead of anyis_heightgrid, and manifestOffset/Index/Width/Heightnow go through_whole_number, which could reject inputs that previously loaded. A maintainer should confirm both are intended.Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T20:43:27Z.
#1506 | head
6b984f2882(merged cleanly with main1bc055e6c2) |python -I tests/test_world_grid_atlas.py+numpy2.5.1 direct verification ofread_image,water_fit,split_cells, andtile_step| red on main:FAILED (failures=19, errors=3, skipped=17)(IndexErroron raggedalignrows,ZeroDivisionErroron 0-columncell_box,AttributeErroron non-dictmanifest.json,struct.erroron truncated DX10R16_UNORMDDS header, and unguarded bool/non-finite inputs) | green on PR+main:42 ran, OK (skipped=17)(25/25PlainLogicTest+ValidationHardeningTest+WriteJsonTestOK, plus3/3numpyread_image/water_fit/split_cells/tile_stepguardsOK) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yesAudited
tools/world_grid_atlas.pyandtests/test_world_grid_atlas.pyon Windows 11, verifying finite/non-bool validation acrossgeometry,cell_box,fill_by_order,align,linear_fit, andload_manifests,[-1.0, 1.0]Pearsonrclamping, truncated DX10R16_UNORMDDS headerValueErrorcheck, warning-free skipping of zero-spanMHIUwater heightmaps,allow_nan=Falseatomicwrite_jsoncleanup,tests/test_ci_registration.py(18 OK),tests/test_text_write_line_endings.py(3 OK), andscripts/check_no_game_data.py.Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:17:20Z.
Tested
6b984f288merged (no commit) withmain829530dbd: Python 3.12.4, Windows 11 10.0.26300, CPU only.check_no_game_data.pyis clean.tests/test_world_grid_atlas.py, 42 tests pass (1 skipped).tools/world_grid_atlas.pyback tomain, 19 failures and 6 errors (ValueError not raised).No blocker from my side.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T00:44:09Z.
Merged after TheGeogeo's red/green check (check) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto
main173fa8284without conflict, and its test file(s) (tests/test_world_grid_atlas.py) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.