fix(render): eliminate EnvCell identity collisions

This commit is contained in:
Erik 2026-07-24 13:44:56 +02:00
parent 999201cca7
commit b7b9aaa9dd
7 changed files with 129 additions and 23 deletions

View file

@ -21,11 +21,14 @@ bounded artifact whose size and time scale with unique geometry, not with all
1. `DatCollection` remains the only DAT reader.
2. `MeshExtractor` remains the only mesh/texture interpreter used by both the
live path and the bake.
3. Geometry identity is the already-shipped WorldBuilder calculation:
`environmentId`, then `cellStructure`, then the ordered surface IDs through
the `hash = hash * 31 + value` chain, with bit 33 set.
4. The pure identity helper moves to `AcDream.Core.Rendering.Wb`; App and Bake
call the same implementation. No second or adapted hash is allowed.
3. Geometry identity is one deterministic hash of the complete typed tuple:
`environmentId`, `cellStructure`, surface count, then the ordered surface
IDs. App and Bake call the same Core implementation.
4. The pure identity helper lives in
`AcDream.Core.Rendering.Wb.EnvCellGeometryIdentity`. It uses FNV-1a in a
dedicated high-bit namespace and retains bit 33 for compatibility with
existing synthetic-geometry diagnostics. WorldBuilder's original
`hash = hash * 31 + value` calculation remains as a conformance helper only.
5. Every EnvCell TOC key is still
`PakKey.Compose(PakAssetType.EnvCellMesh, fileId)`.
6. Aliases share `offset`, `length`, and `crc32`. The pak format and reader do
@ -42,16 +45,30 @@ bounded artifact whose size and time scale with unique geometry, not with all
11. The pak itself and raw bake logs are machine artifacts and are not
committed. A compact, path-free bake report is committed.
**Full-DAT correction (2026-07-24):** the first guarded full-catalog run proved
that the original fixed contract was impossible. Installed retail DAT cells
`0x00030175` (`environment=0x277`, structure `0`, surfaces `0x013B,0x0034`)
and `0x01BC0105` (`environment=0x276`, structure `0`, surfaces
`0x04FC,0x0034`) both produce WorldBuilder ID `0x00000002020E8C13` despite
having visibly different geometry. The difference is algebraic:
one environment step contributes `31³`, exactly canceled by the first-surface
difference `0x04FC - 0x013B = 31²`. The collision guard stopped the bake before
writing an artifact. B1 was therefore corrected at the root: the old polynomial
is retained and tested as historical evidence, while runtime and bake now share
the stronger namespaced identity. The full-catalog collision gate remains
mandatory.
## Implementation checkpoints
### B1 — One geometry identity seam
- Extract the pure WorldBuilder identity calculation from the App transaction
builder into `AcDream.Core.Rendering.Wb.EnvCellGeometryIdentity`.
- Extract one pure identity calculation from the App transaction builder into
`AcDream.Core.Rendering.Wb.EnvCellGeometryIdentity`.
- Retain the existing App entry points as delegates so production behavior and
callers do not change.
- Add Core conformance tests for empty surfaces, ordered surfaces, the bit-33
namespace, and App/Bake shared values.
- Add Core conformance tests for empty surfaces, ordered surfaces, the
dedicated namespace, App/Bake shared values, and the installed-DAT collision
in the legacy WorldBuilder polynomial.
**Gate:** existing App geometry-ID tests and new Core tests pass with the exact
same values.
@ -133,4 +150,3 @@ dotnet test AcDream.slnx -c Release
Then run the full bake from the Release binary, capture its compact report, and
validate the output with `PakReader`. No visual gate is required because this
slice changes no runtime path.