Repository navigation
Description
P6 Narrative and serializers · key
P6.03· size M
Goal
Turn lane strings and lane connectivity are stored by the build and readable per edge, so the trip leg can carry lanes and the narrative can compute active lanes for guidance.
Upstream reference (Valhalla 3.9.3)
src/mjolnir/graphbuilder.ccsrc/mjolnir/pbfgraphparser.ccsrc/mjolnir/graphenhancer.ccvalhalla/baldr/src/odin/
Scope
- Carry turn:lanes, turn:lanes:forward and turn:lanes:backward plus lane counts from the tag transform.
- Add a cold
turnlanessection (edge to encoded lane masks) and alane_connectivitysection (to edge, from way id, to-lanes and from-lanes masks). - Port turn lane mask encoding and the enhancer's handling of legal outgoing turns. Preserve authored mask positions when the mask count differs from the directed lane count.
- Reader API in
src/graph/lanes.zig:turnLanes(edge),laneConnectivity(edge). - Set the per-edge
turnlanesandlane_connpresence bits.
Out of scope
- Active lane computation for a maneuver and the active-lane pinpoint fixtures ([P6.09] Maneuvers builder III: ferries, stairs, elevators, indoor, guidance views, lane guidance #148, P6.09).
- Signs (P6.02).
Design notes
- Lift the upstream 22-bit edge index limit: our ids are dense u32.
- See docs/upstream/valhalla-architecture.md for the TurnLanes and LaneConnectivity record layouts.
Acceptance criteria
- Upstream turn lane unit tests ported and green.
- Test maps with tagged turn lanes yield identical lane masks to the oracle's trace_attributes or verbose locate output.
-
zig build testgreen.
Verification
Landed in 8cc8f66 on main. The pinned Valhalla 3.9.3 trace_attributes PBF matched the native reader on all six directed edges of the Gurka fixture, including lane counts, masks and ordered connectivity. Native tests cover the authored mask encoding, directional override and reversal, hard turn exclusions and malformed connectivity groups.
The full native suite passed, including all 86 Gurka tests. Linux x86_64 test binaries cross-compiled. The two parser fuzz targets ran clean for 60 seconds each. The full and resumed fixture builds were identical, and Utrecht bundles built with two and four workers were identical.
The Linux baseline ReleaseFast binary is 19,432,312 bytes, down 63,136, with zero search instantiations and two costing kernels. The height budget passed at 72.2 ns/point total on the tracked Utrecht corpus. A separate three-pair local Utrecht build sample had medians of 1,432.2 ms before and 1,502.7 ms with lane assembly and storage.
Existing bundles remain readable. Build checkpoints use version 6 so a resumed build includes the new metadata from the tags and enhance stages. CI run
Blocked by
- [P3.17] Cold data: way ids, shapes, name table, chunking #63
P3.17Cold data: way ids, shapes, name table, chunking - [P3.08] Tag transform: speeds, maxspeed parsing, lanes, names, refs and destination tags #54
P3.08Tag transform: speeds, maxspeed parsing, lanes, names, refs and destination tags
Rules for working on this repository are in AGENTS.md. The plan is in docs/PLAN.md.
Activity
chrisbbreuer commentedon Nov 20, 2026
Confirmed the pinned enhancer keeps authored masks separate from the directed lane count. In the original
test_turn_lanes.cc::TurnLanesfixture, Valhalla 3.9.3trace_attributesPBF returns two lanes and four masks[8, 2, 2, 64]for A→B and B→C. D→B has three lanes and masks[8, 2, 66]. B→D has one lane and no masks. This is the expected behavior for the Zig reader, so the enhancer fills or drops guidance based on the legal outgoing turns and preserves an authored mask list when its length differs from the separately stored lane count.The native test uses that fixture plus a connectivity relation. The oracle returns
from=6,from_lanes=1|2|3andto_lanes=1|2|2on both directions of the target way, which the native bundle stores as the same ordered lane lists.chrisbbreuer commentedon Nov 20, 2026
All ten CI jobs passed for
8cc8f6681c067b6b013f5e0546d18ddf08bac422. The issue graph sync also passed.