Skip to content

[P6.03] Turn lanes and lane connectivity in the build and reader #142

Closed

Description

@chrisbbreuer

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.cc
  • src/mjolnir/pbfgraphparser.cc
  • src/mjolnir/graphenhancer.cc
  • valhalla/baldr/
  • src/odin/

Scope

  • Carry turn:lanes, turn:lanes:forward and turn:lanes:backward plus lane counts from the tag transform.
  • Add a cold turnlanes section (edge to encoded lane masks) and a lane_connectivity section (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 turnlanes and lane_conn presence bits.

Out of scope

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 test green.

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


Rules for working on this repository are in AGENTS.md. The plan is in docs/PLAN.md.

Activity

  1. added
    blocked
    phase:6
    area:build
    type:port
    size:M
    on Nov 17, 2026
  2. added
    ready
    and removed
    blocked
    on Nov 19, 2026
  3. chrisbbreuer commented on Nov 20, 2026

    @chrisbbreuer
    MemberAuthor

    Confirmed the pinned enhancer keeps authored masks separate from the directed lane count. In the original test_turn_lanes.cc::TurnLanes fixture, Valhalla 3.9.3 trace_attributes PBF 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|3 and to_lanes=1|2|2 on both directions of the target way, which the native bundle stores as the same ordered lane lists.

  4. chrisbbreuer commented on Nov 20, 2026

    @chrisbbreuer
    MemberAuthor

    All ten CI jobs passed for 8cc8f6681c067b6b013f5e0546d18ddf08bac422. The issue graph sync also passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:buildphase:6readysize:Mtype:port

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions