urt-rs / docs /research /BSP_PLANES.md
nmarshall's picture
Recover native BSP plane node and leaf payload loading
710340d
|
Raw History Blame Contribute Delete
5.03 kB
# Native BSP planes and bounded node traversal
Reproduce with `python3 scripts/analyze_bsp_planes.py`; validate with `python3 scripts/test_bsp_planes.py`. Evidence: [bsp-planes.json](bsp-planes.json), hash-verified original files and disassembly from both Linux ELF64 engines. This extends [leaf metadata](LEAF_METADATA.md). No original executable or native callee executes.
## PLANE-001 — Axial classification (RE-317)
Plane bytes +16 and +17 select type and signbits; scalar normal occupies +0/+4/+8 and distance +12. Types 0, 1 and 2 use the corresponding box axis directly, without reading the normal. For finite fixtures:
| Condition, in order | Return |
| --- | --- |
| distance <= minimum[axis] | 1 |
| distance >= maximum[axis] | 2 |
| otherwise | 3 |
Thirty paired instruction probes cover below-minimum, minimum equality, interior, maximum equality and beyond maximum. The carry-derived `SBB/NOT/LEA` result is evaluated explicitly. Equality precedence matters for a degenerate box: minimum equality wins. Degenerate/inverted boxes are not sampled in this report.
## PLANE-002 — General corner projections (RE-318)
Types greater than two use signbits. The collector reads eight 64-bit jump targets from a uniquely file-backed ELF section and requires eight distinct destinations inside the verified function graph. It stops before indirect dispatch and explicitly resumes at the verified target; it never evaluates an arbitrary indirect jump.
All eight cases select maximum/minimum dot-product corners according to normal component signs. Native scalar multiply/add order is preserved in traces, including per-case ordering; an algebraic dot-product expression alone does not establish identical rounding for arbitrary floats. The tested integral projections are exactly representable. The return bits are:
- Bit 0: maximum projection >= distance.
- Bit 1: minimum projection < distance.
Eighty paired general probes exercise every sign combination and both projection equalities. Two extra axis-shaped general probes demonstrate that a box maximum exactly on the plane returns 3 here, while type zero returns 2 for the same bounds/distance. Rust geometry must preserve this type-dependent rule until runtime evidence establishes a different contract.
Twelve deliberately malformed signbits probes (8 and 255) bypass the table and classify zero projections: return 1 for distance <=0 and 2 otherwise. This is observed local behavior, not evidence that malformed plane records are legal or safe throughout the engine.
## PLANE-003 — Node entry and first-node order (RE-319)
The bounded traversal entry starts after the native prologue with explicitly supplied frame/register pointers. Ten paired probes distinguish negative children from nonnegative node indices. Nonnegative indices address native 16-byte records using a global node-base pointer; plane pointer is +0 and child words are +8/+12. Query minimum and maximum pointers are record +24 and +36. No local node index bounds check occurs in the sampled entry slice; valid allocation/count ownership remains unproven.
Eight paired compositions supply one node with children -6 and -10 (leaf indices 5 and 9 under `~child`). Supplied plane result 1 visits child 0 only; 2 visits child 1 only; 3 visits child 0 before child 1. Supplied invalid result 0 also selects both in this local decision. Stops occur before callback calls and before terminal tail unwind; callback effects are explicitly omitted. This composes one decision, not a complete query or recursion implementation.
The retained full traversal graph contains nine plane call sites and unrolled nested descent before recursive/tail paths. Complete path coverage remains open, including capacity/overflow/last-leaf effects when composing [CM_StoreLeafs](LEAF_METADATA.md), duplicate leaves, malformed/cyclic trees and actual BSP loading.
## Validation and next work
The report contains 124 plane classifications, ten entry slices and eight root compositions. Eight independent tests compare axial rules, all-corner projection extrema, sign dispatch, invalid-sign behavior, equality differences, node addressing/order and paired outcomes. Evaluator tests cover byte unsigned flags, carry subtraction, low-byte register preservation and indexed addresses. Unknown flags, unsupported operations and unknown memory remain errors.
RE-320: recover node/plane/leaf lump loading, allocation/count/lifetime and sign/type producers; compose all unrolled and recursive query paths with callback effects and capacity boundaries; sample real maps; recover float exceptional/MXCSR behavior and differential original-runtime/platform fixtures. No complete collision geometry, original-runtime conformance, or Rust/Bevy/Solari implementation is claimed.
Follow-up: [BSP payload loading](BSP_LOADING.md) establishes bounded +1 type/sign producers, native plane stride, node reconstruction and leaf projection. RE-320 remains open for complete loading/validation/recursive-query/runtime contracts.