fix: sanitizer sweep across all generators; bound signed shifts/division/overflow at coordinate limits (L61); R31

New verify.py sanitize tier (Clang address,undefined,float-cast-overflow; GCC address,undefined;
-fno-sanitize-recover) runs 19 cases per compiler at LOD0-8 across every generator, passages and the
crossing: 0 runtime reports; a planted signed-overflow control is caught by both. A static scan fixed
INT_MIN negation in floor division, unbounded signed LOD shifts and coordinate-times-extent overflow in
VoxelClipmapDesiredTiles.h and VoxelTypes.h (plugin and standalone), and VoxelWorld.cpp, VoxelContentManager.cpp
and VoxelDensityVolume.cpp (plugin only, uncompiled here). Supported-input output unchanged (version 211).
fast/medium/full PASS. Research R31 (self-checked): far-LOD 4-8 cut plan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
This commit is contained in:
Fr0zkaandClaude Opus 5.5 committed 2026-10-26 05:19:18 +01:00
1 parent c0c204ba50
commit 135957831b
13 files changed
+760 -132

No files matched your search

@@ -0,0 +1,79 @@
# VoxelForge — R31 self-check: far-LOD work
## Measurement basis
The L55 figures below are **worker-seconds**, summed across tiles. They are not wall time or predicted savings. The L60 matrix is useful for whole-view comparisons, but it has no matching per-LOD stage breakdown for every generator.
The far LOD4–8 totals and component sums are derived from the logged rows:
| Run | Worker sum | Column evaluation | MC exclusive | Ground exclusive | Cap exclusive | Skirts | Assembly | Unassigned remainder |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| Natural SW | 7.878235 | 2.699576 | 2.248091 | 0.000440 | 0.870358 | 0.789370 | 0.025267 | 1.245133 |
| Floating Islands | 13.653194 | 2.812932 | 3.709855 | 0.000605 | 0.942610 | 0.981823 | 0.028482 | 5.176887 |
| flatField profile | 4.675822 | — | — | — | — | — | — | — |
SW sums are derived from the five LOD rows: [LOD4](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l55/timeline-static/sw.log:9560>), [LOD5](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l55/timeline-static/sw.log:9561>), [LOD6](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l55/timeline-static/sw.log:9562>), [LOD7](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l55/timeline-static/sw.log:9563>), [LOD8](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l55/timeline-static/sw.log:9564>). FI sums use [LOD4](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l55/timeline-static/fi.log:9565>), [LOD5](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l55/timeline-static/fi.log:9566>), [LOD6](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l55/timeline-static/fi.log:9567>), [LOD7](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l55/timeline-static/fi.log:9568>), [LOD8](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l55/timeline-static/fi.log:9569>). flatField’s total is derived from [LOD4](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l53/profile-cold-view-flatField-clang.log:46>) through [LOD8](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l53/profile-cold-view-flatField-clang.log:50>).
The remainder is calculated, not a named timer. It includes work the summary does not allocate to those bins. Also, R28 calls SW’s 2.699576 column total “worker-ms”; the raw rows show that it is **worker-seconds** (2,699.576 ms).
## Far-LOD inventory and visibility
`generateTile` selects the coarse cell count and step at [VoxelForgeCore.cpp:2121](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/VoxelForgeCore.cpp:2121>), then calls `GenerateMesh` at [VoxelForgeCore.cpp:2642](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/VoxelForgeCore.cpp:2642>). MC produces the sampled density surface, including terrain and passage geometry. Those surfaces can appear in the far view and horizon; generation does not establish that a particular tile is visible from the near-field camera.
- **Connector repair:** `AppendFarConnectorShells` returns below LOD6 (`if(Key.Level<6||Step<=0)return;`) and tests four radial directions ([FarShellsInternal.h:247](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/FarShellsInternal.h:247>), [lines 248–300](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/FarShellsInternal.h:248>)). It marks missing source-surface crossings and emits wall panels ([lines 369–373](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/FarShellsInternal.h:369>), [lines 567–587](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/FarShellsInternal.h:567>)). The stations are 128 voxels at LOD6 and at least 256 at LOD7–8 ([lines 314–317](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/FarShellsInternal.h:314>)). These walls can be seen through a passage or opening; the logs do not show that they are always visible from the near-field camera.
L55 gives no LOD-aggregate connector cost. Its per-tile LOD6 row reports `connector_ms=17.641` and `column_ms=15.935` ([sw.log:3779](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l55/timeline-static/sw.log:3779>)); those timers overlap. A separate L52 log records `connector_shell_ms=1334.783` and `connector_column_compute_ms=1113.385` for LOD6 ([final-surface-world.log:99](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l52/profile/final-surface-world.log:99>)). That 1.335 worker-seconds is an **inclusive historical timer**, not extra work to add to the column total or to L55.
- **Far stratum shells:** `AppendFarStratumShells` returns below LOD7, below step 4, or without a manager (`if(Key.Level<7||Step<4||!World.Manager)return;`) ([FarShellsInternal.h:1054](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/FarShellsInternal.h:1054>)). It compares source stratum crossings with mesh hits and emits subdivided patches for missing crossings ([lines 1096–1111](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/FarShellsInternal.h:1096>), [lines 1131–1180](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/FarShellsInternal.h:1131>)); `generateTile` calls it at [VoxelForgeCore.cpp:2738](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/VoxelForgeCore.cpp:2738>). The L52 log records 6.837 ms at LOD7 and 21.687 ms at LOD8 ([line 103](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l52/profile/final-surface-world.log:103>), [line 107](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l52/profile/final-surface-world.log:107>)); their 28.524 ms sum is derived and belongs to that older run. Current code can skip this repair at LOD7+ for native-surface-horizon tiles without edits or island overlap ([VoxelForgeCore.cpp:2322](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/VoxelForgeCore.cpp:2322>)). Separate boundary floor and ceiling functions still run at [VoxelForgeCore.cpp:2847](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/VoxelForgeCore.cpp:2847>).
- **Cap refinement:** `RefineFarNativeCap` applies from LOD4 when an owner generator exists ([VoxelForgeCore.cpp:697](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/VoxelForgeCore.cpp:697>)); it builds cap surfaces from the heightfield samples ([lines 728–740](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/VoxelForgeCore.cpp:728>), [lines 798–859](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/VoxelForgeCore.cpp:798>)). Caps can be seen from inside a cave or through an opening; they are not proven invisible from the exterior camera. L55’s cap-exclusive worker costs are 0.870358 SW and 0.942610 FI, derived in the table. A separate L52 log reports LOD8 `mc_grid_ms=1348.084` ([final-surface-world.log:107](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l52/profile/final-surface-world.log:107>)); that is an older-run grid cost, not the L55 total.
- **Ground refinement:** `RefineFarNativeGround` applies from LOD5 ([VoxelForgeCore.cpp:394](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/VoxelForgeCore.cpp:394>)). It reconstructs the ground profile on a grid and replaces nearby coarse upward MC faces ([lines 399–409](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/VoxelForgeCore.cpp:399>), [lines 582–588](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/VoxelForgeCore.cpp:582>)). The ground can affect the far terrain and horizon silhouette. The **ground-refinement-exclusive** L55 cost is only 0.440 ms SW and 0.605 ms FI, derived above. The much larger column-evaluation bin is shared across MC and refinement work; it is not a ground-only cost.
- **Skirts:** the mesher extrudes skirts from boundary edges, with depth based on `SkirtCells` and mesh step ([VoxelMarchingCubesMesher.cpp:2067](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Source/VoxelForge/Private/VoxelMarchingCubesMesher.cpp:2067>), [line 2072](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Source/VoxelForge/Private/VoxelMarchingCubesMesher.cpp:2072>)). The viewer marks a face visible when there is no same-LOD neighbor and filters triangles against that mask ([StandaloneViewer.cpp:132](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Source/StandaloneViewer.cpp:132>), [lines 833–836](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Source/StandaloneViewer.cpp:833>)). Only exposed faces can render; same-LOD covered faces are already hidden. L55’s skirt totals are 0.789370 SW and 0.981823 FI worker-seconds, derived above.
## Projected size at the clip radius
Linux15 uses 0.000613592 rad/px and closest display distances of 192, 384, 768, 1,536 and 3,072 m for LOD4–8 ([gate basis](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Research/WorldAssemblerM3/Linux15/REPORT.md:23>), [swap distances](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Research/WorldAssemblerM3/Linux15/REPORT.md:46>)). With the 25 cm voxel and 16 coarse cells in the owner data, the derived one-pixel footprints and lattice intervals are:
| LOD | Distance | 1 px in world | MC cell interval | Cap interval | Ground interval | Connector station |
|---:|---:|---:|---:|---:|---:|---:|
| 4 | 192 m | 0.118 m | 8 m ≈ 68 px | 4 m ≈ 34 px | — | — |
| 5 | 384 m | 0.236 m | 16 m ≈ 68 px | 32 m ≈ 136 px | 8 m ≈ 34 px | — |
| 6 | 768 m | 0.471 m | 32 m ≈ 68 px | 32 m ≈ 68 px | 16 m ≈ 34 px | 32 m ≈ 68 px |
| 7 | 1,536 m | 0.942 m | 64 m ≈ 68 px | 32 m ≈ 34 px | 32 m ≈ 34 px | 64 m ≈ 68 px |
| 8 | 3,072 m | 1.885 m | 128 m ≈ 68 px | 128 m ≈ 68 px interior; 32 m ≈ 17 px at boundary | same | 128 m ≈ 68 px |
These are **derived projected lattice intervals**, not measured geometry error or proof of visibility. Orientation, connector direction, terrain occlusion and the camera view change the projection. No component-by-component near-camera visibility capture was found. The sizes do not support calling the current grids or connector stations “subpixel” based on distance alone.
## Exact cuts
- **Reuse an identical heightfield column:** exact if the recipe, plan, context and integer XY coordinates match. The shared cache key contains recipe/plan identities and hashes plus XY, and deliberately omits LOD ([SharedColumnCache.h:35](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/include/VoxelForgeCore/SharedColumnCache.h:35>)); the cache is enabled by default and scoped during tile generation ([VoxelForgeCore.h:1743](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/include/VoxelForgeCore/VoxelForgeCore.h:1743>), [VoxelForgeCore.cpp:2013](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Core/src/VoxelForgeCore.cpp:2013>)). The invariant is the same pure column result bit-for-bit. The L55 run already had the shared cache on ([sw.log:2](</home/jahni/VoxelM/Plugins/VoxelForge/Saved/Linux/l55/timeline-static/sw.log:2>)), so only remaining misses or evictions are an opportunity.
- **Reuse coincident MC density samples:** exact for identical field identity, edits and world-space XYZ sample coordinates, if the same scalar is reused and each tile retains its existing traversal, interpolation and gradient arithmetic. The invariant is the exact sampled float. Because the clipmap tiles partition the volume, this is generally boundary or nested-lattice reuse, not a way to reuse an entire child tile for its parent. No per-generator saving is measured.
- **Skip skirt faces hidden by the active mask:** exact for the rendered mesh with that fixed mask, because the viewer already drops those triangles. The invariant is the visible index set. The mesh payload and hashes change; the mask must be part of cache identity and geometry must be regenerated when neighbor coverage changes ([StandaloneViewer.cpp:4846](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Source/StandaloneViewer.cpp:4846>)).
None of those proves it safe to remove cap, ground or connector geometry. Those surfaces can be visible in some views.
## Ranked plan and savings
The logs support opportunity ceilings and one modeled skirt estimate, **not a credible expected realized saving per generator**. Worker-seconds cannot be read as wall-time reduction.
1. **Audit and reduce exact column/sample misses.** The measured column pool is 2.699576 SW and 2.812932 FI worker-seconds. The flatField run has 4.675822 worker-seconds across the entire far pool but no reliable stage split. These are ceilings, not expected savings; the cache is already active. R14’s LOD8 overlap report recorded 32,738 repeated neighboring XY evaluations, including 30,446 cross-worker repeats ([Round14:41](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Research/WorldAssemblerM3/Round14/REPORT.md:41>)); it did not price those repeats in worker-seconds.
2. **Skip hidden skirt faces for a fixed neighbor mask.** R23 measured 87.4% hidden SW and 87.0% hidden FI skirt triangles, then modeled savings by applying those fractions to timer totals ([Research23:54](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Research/WorldAssemblerM3/Research23/REPORT.md:54>)). Applying them to the L55 far-LOD skirt timers gives a **cross-run modeled gross** of about 0.690 SW and 0.854 FI worker-seconds; actual savings will be lower because triangle share is not time share and edge scanning remains. flatField has no comparable reliable skirt timer.
3. **Test further LOD8 sampling changes or an LOD7–8 merge only as versioned geometry changes.** No saving is forecast. Round14 already moved LOD8 interior sampling to MC spacing while retaining 128-voxel boundary strips; its fresh W12 comparison reports 3.206 versus 13.534 worker-seconds for the default and step-128 control ([Round14:47](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Research/WorldAssemblerM3/Round14/REPORT.md:47>), [Round14:49](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Research/WorldAssemblerM3/Round14/REPORT.md:49>)). That gain is already harvested, not available again. Any further change needs a far-horizon silhouette gate.
4. **Do not coarsen connector stations on current evidence.** The LOD6 connector timer is an historical 1.335 worker-second inclusive ceiling from L52, not a forecast. The two-times station test failed: 1,349 holes and 1,690 floaters, with hole IDs increasing from 8 to 221 ([Linux15:53](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Research/WorldAssemblerM3/Linux15/REPORT.md:53>)). At the calculated clip distances, nominal axial station spacing is about 68 px when transverse to view; it is not generally subpixel.
5. **Defer far jobs only for perceived readiness.** Reordering can change when far tiles appear but saves **0 worker-seconds** if all tiles are still generated. L60’s whole-view wall matrix does not provide per-generator far-stage savings for periodic hills, mirrored relief, Motifs, Caves or Lattice; I would not transfer SW numbers to them.
## Gates and remaining uncertainty
For connector or refinement changes, keep the Linux15 screen-space gate: 1 px maximum normal displacement, shading delta at most 1/255, no missing surface, hole, crack or floater, and no worse adjacent-LOD swap ([Linux15:23](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Research/WorldAssemblerM3/Linux15/REPORT.md:23>)). Doubling refinement already failed badly across LOD4–8 ([Linux15:33](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Research/WorldAssemblerM3/Linux15/REPORT.md:33>)).
Retain Round14’s ground/cap agreement checks, cap-band census, 2,520/2,520 upward-ray coverage and worker-count determinism ([Round14:88](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Research/WorldAssemblerM3/Round14/REPORT.md:88>), [Round14:90](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Research/WorldAssemblerM3/Round14/REPORT.md:90>), [Round14:92](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Research/WorldAssemblerM3/Round14/REPORT.md:92>), [Round14:96](</home/jahni/VoxelM/Plugins/VoxelForge/Standalone/Research/WorldAssemblerM3/Round14/REPORT.md:96>)). Add matched 1440p horizon captures with a measured silhouette-pixel delta for any far-grid or LOD-merge change; Round14 has captures, but they are not a quantitative silhouette gate.
Assumptions: projected sizes use the Linux15 nearest-display distances and the 25 cm, 16-coarse-cell owner settings; they are not per-tile occlusion measurements. L55, L52 and L53 use different runs and tile counts, so their figures are not interchangeable. L55 aggregates connector and stratum repair poorly; the LOD6 per-tile connector timer overlaps column computation. No scripts, tests, builds, binaries or tree changes were made.