Skip to content

fix(bake): bake output is nondeterministic without a pinned PYTHONHASHSEED #438

Description

@nigel-hall-codes

Discovered while V-BAKE-verifying #423 (child of #417).

Symptom: baking the same inputs twice in separate processes produces different .bin files (and some _parked.json sidecars). Two baseline bakes of chunks (5–6)×(3–4) differed; the same bakes with PYTHONHASHSEED=0 were byte-identical.

Cause: set/dict iteration order (hash-seed-dependent) leaks into the order meshes and/or parked cars are emitted, so the serialized byte order varies run-to-run even though the geometry is equivalent.

Why it matters:

  • The determinism contract referenced in serialize.py / data-model.md §6 ('a re-bake of the same inputs produces a byte-identical file') does not actually hold across processes.
  • The audit's 'V-BAKE byte-identical rebake' verification protocol (used to check the refactor: codebase organization audit #417 refactor PRs) only holds under a fixed seed — reviewers must pin PYTHONHASHSEED or the check is meaningless.

Fix direction: make emission order deterministic — sort meshes and parked cars by a stable key (e.g. (mesh_type, osm_id), parked cars by source_id) before serialization, the same way buildings are already sorted by osm_id. Then a re-bake is byte-identical regardless of hash seed.

Verify: two bakes of the same inputs in separate processes (no PYTHONHASHSEED set) produce byte-identical .bin + sidecars.

Context: found in PR #437 (#423). Not part of the #417 reorg plan — filed standalone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions