Skip to content

ground plan GP12.4 step 1: tunnel rules A and B in the bake's levels (no pixel change) - #3488

Merged
timohueser merged 5 commits into
ground-planfrom
claude/gp12-4-levels-rules
Nov 15, 2026
Merged

timohueser merged 5 commits into
ground-planfrom
claude/gp12-4-levels-rules

Conversation

@timohueser

@timohueser timohueser commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Tunnel step 1 of GP12.4 (#3345): two rules in the levels that the feature bake computes for tunnels. No device
behaviour changes, and no pixel changes.

The two rules

  • Rule A. Within open_max_m (30 m, plan.json structures: the longest open cut of the crossing design) of a
    tag end, a tunnel station that has too little cover is OPEN, also where its floor lies over the terrain model.
    The way goes on as a ground way, on its bank, until the cover holds. There is the portal line. Before, such a
    station was HIDDEN when its floor lay more than snap_height_m over the terrain.
  • Rule B. A paved stroke is a way on top of a tunnel station only where its surface lies more than the at-grade
    band over the floor: the lower snap_height_m of the two ways (0.5 m in every class row of roads.json), the
    same band as at a crossing. A lower way beside the mouth, or a path that crosses at the floor's height, does not
    hide the tunnel any more.

The 1 m lift on free ground (lift_max_m) still reads every paved stroke: a paved face never moves, so the ground
there cannot be lifted, whatever its height.

Both values are in the rule tables and in the options of the bake step already (structures, and snap_height_m
in the graph fields of level_rows), so a change of them bakes again. The code of the levels changed, so
planner/trailview-features takes revision 21 and the fixture is baked again. The spec
(specs/trailview-features.md, Structures) now says how a tunnel station gets B, O or H (after the
review: O before the first B from its nearer tag end, as the code reads it).

The census: closed mouths of test box B

The probe of the diagnosis, over all 1,014 portals, on one tile set: the zoom-13 tiles of a box B bake of this head,
with the zoom-13 and zoom-12 terrain of the checkpoint 5 grid (the terrain that the bake reads). Before: the base
code (67092ce). After: this head. A mouth is closed when, from the tag end on its own tunnel way, the levels hide
the way before any portal line, or when a closed line lies less than 5 m behind its first portal line. The reason is
the one the probe gives at the base.

Reason at the base Before After Stay closed
no cover within open_max_m 8 8 P0005, P0075, P0171, P0172, P0501, P0539, P0820, P1006
floor over the terrain model 27 2 P0623, P0727
a paved stroke over the station 14 4 P0134, P0193, P0205, P0215
closed line < 5 m behind the portal line 5 5 P0282, P0295, P0622, P0692, P0726
step 3 under a way on top 1 1 P0306
All 55 20

No mouth closes that was open. Of the 1,013 portals with a way end (one has none in the data), 958 mouths are open
before and 993 after. 35 open: 25 by rule A (the floor over the terrain model), 10 by rule B (a lower way beside the
mouth, or a way at the floor's height).

Why 20 and not the 19 of the diagnosis:

  1. The diagnosis counted 58 on its own census folder, which holds only zoom-12 terrain. With the terrain that the
    bake reads, the base closes 55: 19 mouths of the 58 are open there, and 16 others are closed.
  2. Three mouths that the diagnosis expected to open stay closed for a cause that is not rule A or B. The levels see
    no tag end at their portal, so their stations there lie "more than 30 m" from a tag end:
    • P0134 and P0215 (Acheregg): the tunnel way runs through a junction farther in (a road starts on it). The node
      map of the levels (Ctx::nodes, one entry per way and direction) takes that junction for the way's end node.
      The tunnel then seems to go on at its portal.
    • P0205: two tunnel ways and a bridge meet at one node at the portal, so a tunnel goes on there.
  3. Two mouths that the diagnosis counted as height faults open by rule B (P0433, P0797: a footway or steps at the
    floor's height).

The 20 that stay closed:

Cause Portals Next
No cover within 30 m: open to 30 m, then hidden until the cover holds P0005, P0075, P0171, P0172, P0501, P0539, P0623, P0727, P0820, P1006 Heights (#3349)
A way on top with too little room at the mouth (0.8 to 1.5 m over the floor) P0193, P0295 Heights (#3349)
A path at the floor's height 1.6 m inside a bore that holds only by the lift P0692 Heights (#3349)
A station subway under a platform P0282, P0306 A door is right
The levels see no tag end at the portal (see 2) P0134, P0205, P0215 A rule of the tag end, proposed on #3345
Other, as in the diagnosis P0622, P0726 A door for now

Proofs

  • No pixel change. The 256 fixture cells, base on the old fixture against this head on the new fixture, through
    cell::build_storeys, mesh_cell and mesh_storeys: the records with the storeys' records, the faces, the far
    block, the rim, the mesh, and in the 47 cells with storeys the storey mesh, its ways and its ground ends are
    byte-equal in 256 of 256 cells. The way graph of the device (the level of each way, and its levels) is equal too.
    The device reads a tunnel way's levels tag nowhere yet (level_tags::split keeps a tunnel way's level).
  • The tiles. The fixture rebake changes 2 of its 9 zoom-13 tiles. Of 5,105 features, 5,103 are equal. The 2
    copies of one tunnel feature (a funicular) change their levels only: a hidden tail after its portal is now open.
  • Bridges do not change. On the fixture, every deck feature is equal. On box B, the bake's merge of the levels
    of every zoom-16 cell (10,752 cells), base against head on the same tiles: the levels, storey and slab of
    all 2,739 deck features and of the 57 other features with level tags are equal; 38 of 651 tunnel features change.
    So no deck changes, also where a deck meets a tunnel. The head's merge equals the tags that the bake wrote, for
    all 3,447 features.
  • Determinism. Two fixture bakes give the same bytes (sha256 c59ab33b8f98...).
  • Unit tests on a built graph, one per rule (graph/tests.rs). Each fails on the base rule. The terrain helper
    plane moves from the heights tests to the shared test module, unchanged; no existing test changes.
    • a_tunnel_that_comes_in_over_the_terrain_is_open_from_its_tag_end_up_to_open_max_m: a tunnel 3 m over flat
      terrain into a ridge. On a steep ridge it is open from each tag end to its portal at the cover's line (10.6 m in);
      on a gentle one it is open to 30 m, then hidden until the cover holds.
    • a_paved_stroke_hides_a_tunnel_station_only_where_it_lies_on_top: a road beside a tunnel, its stroke over the
      tunnel's middle line, at 2 m under, 0.5 m over and 0.55 m over the floor: only the last hides the tunnel.

Bake time

Box B on 4 cores (taskset -c 0-3, 5 GB cap): wall 136.2 s, peak 3.6 GB, levels 16.5 s for 10,752 cells, 3,616
ways tagged. The rules add no read; the levels pass of an earlier bake of the same box on 4 cores took 15.6 s. No
base bake in this session, so the difference is not measured.

WASM

No device behaviour changes; the bridge's CI size moved by 4 B raw (118 B gzipped) and is recorded as the guard
says. CI on b135e2c measured 806,965 B gzipped against the recorded 806,847 B, and 2,087,266 B raw; 674d660
recorded it, and the next run showed +0 B. After the merge of ground-plan with the passage rule (#3489, 681070b),
CI measured 808,099 B gzipped (-172 B against #3489's recorded 808,271 B) and 2,090,936 B raw (+0 B); 22c58ae
records it.

Checks

  • obc test -p obc-ground-plan: 137 of 137 pass (the fixture test the_tiles_carry_the_levels_of_each_cell on
    the rebaked fixture).
  • obc test -p obc-trailview-features: 122 of 122 pass.
  • obc test -p obc-data-steps: 80 of 80 pass. In the new worktree, builder/web had no node_modules, so the
    first run failed in the verify step (no Node MVT reader). It passed with the main checkout's node_modules linked.
  • obc exec cargo clippy -p obc-ground-plan -p obc-trailview-features -p obc-data-steps --all-targets -- -D warnings:
    clean.
  • cargo fmt --all, obc suites check, obc prose --check: pass.
  • Left out: the viewer's tests (no viewer change), a local WASM build (no device behaviour changes; CI measures the
    bridge), obc test affected, obc test full, pictures (no pixel changes).

Deviations from the brief and the diagnosis

  1. classify does not read tunnel=yes on the ground kinds in this step. It cannot come without a pixel
    change. On the device, classify gives the part its level. A shallow tunnel (a road, path or railway with the
    tag) would become a tunnel way, level_tags::split keeps a tunnel way's level, and storey 0 draws only ground
    ways: the shallow tunnels would go from the plan. The fixture holds 6 of them (11 copies), the census tiles of
    box B 191 copies. Measured: with the reading alone, 11 of the 256 fixture cells change what the viewer reads.
    Proposal: this reading comes in step 2, with the split of tunnel ways by their states, so that
    the OPEN stretches of a shallow tunnel stay on the ground. 11 census portals have a shallow tunnel at their end;
    their counts can move then.
  2. Rule B does not change the lift. The diagnosis says that only a way on top forbids the 1 m lift. Here every
    paved stroke forbids it, as before: the cover face cannot lift a paved face. The census effect is that of the
    diagnosis's simulation, which did not change the lift either. With the lift read as the diagnosis says, P0692
    would open with a path at the floor's height inside its bore (from a trace of its stations, not built).
  3. Two faults of the tag end are not fixed here (P0134, P0215, P0205 above); both are outside rules A and B.
    General forms, not built: enter an arm in the node map only at its way's end station; a way end is a tag end
    where a way of another kind (not water) meets it. Measured on box B for the first (not in this pull request): it
    opens P0134 and P0215 and closes none, but it changes the levels of 6 deck features (deck_ends reads the same
    map), so it needs its own proof on bridges.

Public docs: unchanged. The spec specs/trailview-features.md (a contract) says the tunnel states.

Mode: change #3345
Requirements: none

🤖 Generated with Claude Code

…r, and only a way on top hides it

Two rules in the levels that the feature bake computes for tunnels:

- Within open_max_m of a tag end, a tunnel station with too little
  cover is OPEN also where its floor lies over the terrain model: the
  way goes on as a ground way on its bank until the cover holds.
- A paved stroke hides a tunnel station only where its surface lies
  more than the at-grade band (the lower snap_height_m of the two ways)
  over the floor. The lift on free ground still reads every paved
  stroke: a paved face never moves.

The features take revision 21 and the fixture is baked again: one
tunnel feature changes its levels tag. The spec says how a tunnel
station gets its state. The device code does not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4830fa59-c3e2-4d2f-8f74-dd95a8f24c12

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…ls rules

The bridge's code does not change; CI measured 806,965 B gzipped (+118 B)
and 2,087,266 B raw (+4 B) on the head with the rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@timohueser

Copy link
Copy Markdown
Owner Author

Review of pull request #3488 (GP12.4 tunnel step 1: rules A and B in the bake's levels)

Head 674d660, base ground-plan 67092ce. Reviewer: a fresh agent. I changed no code, pushed nothing, merged
nothing, posted nothing.

Verdict: MERGE. No blocking finding. One small spec fix (N1) is recommended in this pull request, because it is
one phrase in a contract. It does not change bytes.

Blocking findings

None. I looked for each block reason of the brief:

  • Pixel change: none, by construction and by measurement (S1).
  • A bridge that moves: none, by construction in all data, not only in box B (S3).
  • A rule that is not general: both rules are one test each with no case distinction (S2).
  • A bake and a device that can disagree: the device reads no tunnel levels tag yet; the rule values are step options;
    revision 21; the fixture test ties the tags to the crate (S4).
  • A hidden test weakening: none (S5).

Non-blocking findings

N1. The new spec sentence does not say which tag end the OPEN rule reads. specs/trailview-features.md (new
text): "O within open_max_m (30 m) of a tag end and before the first B from that end". The code reads the
NEARER tag end: open_rule (graph/levels.rs:941-951) and runs::state_at (:968-972) set
back = t.tag.0 + m <= t.tag.1 + len - m, then look for a BORE only on that side.
Scenario: a lone tunnel of 55 m, BORE from 10 to 20 m, no cover from 20 to 55 m. The station at 25 m lies within
30 m of both ends. The spec gives O (it lies before the first B from the far end). The code gives H (the nearer
end is the start, and a BORE lies between). The result is BORE 10–20, HIDDEN 20–27.5, OPEN 27.5–55: a closed line in
the open approach from the far end, not a portal at 20 m.
Smallest fix: the spec says "from its nearer tag end". The behaviour itself is older than this pull request
(open_rule is unchanged), but rule A makes more stations raw OPEN in short tunnels. A general form for step 2:
OPEN where no BORE lies between the station and a tag end within open_max_m (either end). That changes bytes, so it
is not for this pull request.

N2. Rule A can leave an OPEN stretch that ends in a HIDDEN one with the floor over the terrain. Example on box B:
P0623 is OPEN from its tag end to 30.97 m, then HIDDEN to 72 m with the floor 3.0 m over the terrain model, then BORE
(logs/census-head.json). In step 2 and GP12.5 this is a road on a 3 m bank that ends at a closed door in the air.
The base had the same fault at the tag end (HIDDEN from 0 m), so this is not a regression, and the author lists
P0623 under heights (#3349). Tell the door step (GP12.5) that a closed line can lie with its floor over the terrain.
On the box B tags, OPEN-then-HIDDEN at a tag end occurs 8 times on the base and 6 times on the head (my count on
tags-boxb-*.tsv), so rule A does not make this pattern more frequent.

N3. The node-map fault is a bridge bug too, and it has no issue of its own. Ctx::new (graph/levels.rs:262-270)
writes nodes[2 * way + dir] for every arm of every junction. A junction that a way runs through overwrites that
way's real end entries. The author measured that the fix opens P0134 and P0215 and changes the levels of 6 deck
features on box B (logs/census-nodefix.json, logs/tags-boxb-nodefix.tsv). Those 6 decks are probably wrong today.
Keeping the fix out of this pull request is right (the step must not move a bridge). But the fault is only in the
#3345 body. File it as its own sub-issue with the 6 deck features as its proof list.

N4. Rule B's "on top" test and the crossing's ladder read the heights at different points. tunnel_state reads
the paved stroke at the tunnel station's centre only (ground(a.p, w), :491). ladder reads the minimum over
five corner pairs (:629-635). Both use the same band (the lower snap_height_m, symmetric by min). On a banked or
sloped road within a few centimetres of the band, the ladder can say AT GRADE while the station is HIDDEN, or the
reverse. This is a small edge, not a fault of the rule. No action now; note it for step 2, where both decide what
draws.

N5. The 1 m lift still reads every paved stroke (documented deviation 2). The reason ("a paved face never moves")
is sound and the spec text matches the code. Effect: a lower road beside a mouth, or a path at the floor's height,
still forbids the lift, so P0692 stays closed. This is a decision for #3349, where the author listed P0692.

N6. The pull request body says "no device code", but the bridge's bytes moved. I read the wasm-bridges job of
#3486 (a212e7c, the same bridge source as the base): it measured exactly 806,847 B gzipped and 2,087,262 B raw
(+0 B). So the +118 B gzipped and +4 B raw on b135e2c come from this pull request's source change. Nothing on the
device path calls graph::levels (no caller in cell.rs, faces/, transport.rs or the bridge's lib.rs), and
the 256 cell digests are equal. So the move is code layout, not behaviour. Recording it is the right use of the
guard: the crate is the bridge's code (GOVERNS holds host/obc-ground-plan/**), and the recorded size must be the
newest CI build so that the margin stays for toolchain noise. Better words in the body: "no device behaviour changes;
the bridge's CI size moved by 4 B raw, recorded as the guard says".

N7. Spec style. The new sentence ends on a very long line that also holds the next sentence ("Else it is H. The
A lines of one deck group …"). Reflow it. The spec repeats the value "(30 m)" of plan.json; it can go stale.

N8. For step 2 (not this pull request). When split stops skipping tunnel parts, the fixture test
the_tiles_carry_the_levels_of_each_cell must stop skipping them too (tests/graph.rs: if part.level == Level::Tunnel ... continue). If classify reads tunnel=yes on ground kinds without the split, the shallow
tunnels vanish from the plan (author's measurement: 11 of 256 fixture cells change). No test guards against that; the
two changes must land together, as the #3345 deviations say.

What I checked and found sound

S1. No pixel change. level_tags::split skips every part whose level is Tunnel
(level_tags.rs:303), so the device never reads a tunnel way's levels tag. The viewer reads no levels tag
(grep of builder/web/src/lib/trailview). The device graph does not run levels (cell.rs:107-140). The author's
cell digests (logs/digests-base.txt, digests-head.txt): records with storeys, faces, far, rim, mesh, storey mesh,
ways, ends and the device graph's levels are equal in 256 of 256 cells (diff gives 0 lines). What reads the tunnel
states in step 2: split (OPEN to Level::Ground, BORE to the tunnel level, HIDDEN dropped), then
ground_junctions, storey 0 and storey −1.

S2. The rules as built.

  • Rule A (tunnel_state, :490-499): BORE if the bore test holds; else HIDDEN if tag_m > open_max_m or a way lies
    on top; else OPEN, then open_rule. The terrain test is gone. One rule, no case.
  • Tag end (onward, :503-523): the first node where no tunnel way goes on, read through a chain of tunnel ways up
    to open_max_m; infinite where the graph holds no point. A tunnel shorter than 60 m is within 30 m of a tag end at
    every station, so with no cover and nothing on top it is OPEN on its whole length (box B: one feature, 1663, a
    short floating tunnel of steps, H H H to O). A tunnel that starts at a junction or right after a bridge has its tag
    end there (a deck is not a tunnel way). A road under real cover that the terrain model lacks: rule A changes only
    stations that fail the bore test, so it never turns a BORE into an OPEN.
  • Rule B (ground, :432-452): the highest paved stroke over q, less min(snap_height_m of it, of the tunnel). The
    tunnel is HIDDEN only where that lies over its floor a.z. Both heights are the road solver's sample heights in the
    tiles (the tunnel's curve at the station, the other way's surface at its foot with its bank). The band is the
    crossing's band (ladder, :647), symmetric. All 28 class rows of roads.json hold 0.5 m. A real road on top
    with a nominal 0.4 m from a height fault: if the graph has a crossing, the ladder already says AT GRADE (or CLOSED
    or INVERTED, and step 3 then hides the tunnel over that road's body, :817-829), so the station is now OPEN as the
    ladder says. Before, the levels hid it against the ladder.
  • bore() is unchanged in value: paved.is_none() is true exactly where the old paved was false (past <= 0.0).

S3. Bridges. By construction: ladder, deck_ends, place_a, clear, merge_a, over and the step-3
marking read neither tunnel_state nor the second value of ground. The only changed reads are in tunnel_state,
which runs only on tunnel tracks (ctx.tunnel(w)). A feature cannot be both deck and tunnel. So no DECK run, A
line, ladder, storey or slab can change in any data, also where a deck meets a tunnel mouth. By measurement: I
compared tags-boxb-base.tsv and tags-boxb-head.tsv myself (the computed column): 2,739 deck and 57 other
features equal (all tags: levels, storey, slab), 38 of 651 tunnel features change, and only in levels. The
head's merge equals the carried tags for 3,447 of 3,447 features.

S4. Bake and device. The rule values are step options: kinds::level_rows holds structures of plan.json
and GRAPH_FIELDS (with snap_height_m), fill and reach. Revision 20 to 21 (planner.rs:71). The fixture is
rebaked (2 tiles); the fixture test still compares the carried tags of every feature, tunnel features included, with
level_tags::merge. The order is unchanged (tags sorts runs and lines; jobs merge in tile order). Two fixture bakes
give the same bytes. The spec matches the code except N1.

S5. Tests. git diff 67092ce88 674d66049 -- '*tests*': plane moves from faces/heights/tests.rs to
faces/tests.rs unchanged; graph_of becomes graph_with with the same body (both still assert check and
check_levels at 0 faults); two new tests; no assertion of an existing test changes. The two tests are real
invariants (rule A at the cover line and at open_max_m, with the metres derived from the rule values; rule B at
−2, +0.5 and +0.55 m, the band boundary). The base log (logs/unit-base.log) shows both fail on the base rule for
the right reason (HIDDEN at the tag end; HIDDEN beside a lower road). Comments state present behaviour, with no
dates, issue numbers or past measurements.

S6. The census. From census-base.json and census-head.json with the probe's own definition (first change from
the tag end is HIDDEN, or a closed line less than 5 m behind the first portal line): 55 closed before, 20 after, none
newly closed. 35 open: 33 now start with a BORE, 2 are open over the whole chain. The 20 and their reasons match the
pull request's table. The probe recomputes the levels per cell with the bake's code on the head tiles; the tags dump
shows that this equals the carried tags. The terrain explanation of 58 against 55 holds: the diagnosis folder
cp5-notes/fx-boxb/terrain holds only zoom 12, the step's folder holds 12 and 13, and Terrain::wanted reads page
levels 14 and 13, that is tiles of zooms 13 and 12 (terrain.rs:17, 42-44). At the 19 mouths that only the diagnosis
closes, the terrain under the stations differs by 1.6 to 27 m between the two runs, while the floor differs by at
most 0.55 m. The 55 and 20 are the truth for a real bake.

S7. The deviations. classify left for step 2: sound (S1, N8). P0134 and P0215: the census shows a junction that
the tunnel way runs through (through_junctions 1), and the node-map fix opens both, so the explanation holds (N3).
P0205: two tunnel ways (244, 317) both end at the portal node with a bridge (210); onward reads 317 as "a tunnel goes
on", so there is no tag end. The 20 closed mouths are on #3346 and #3349 (comments 6894219808, 6894220132), and the
deviations are in the #3345 body.

S8. The WASM guard. See N6. Recording 806,965 B and 2,087,266 B is right.

What I could not check

  • Why the bridge's bytes moved by 4 B raw: I have no local bridge build (the local toolchain differs from CI's).
    Nothing on the device path calls the changed code, and the outputs are equal, so I take it as code layout.
  • I did not rerun the census, the box B bake, the fixture bake, the digests or the unit tests on the base. I read the
    author's logs and recomputed the counts and tag comparisons from the author's data files.
  • A count of 58 with the base code on zoom-12-only terrain: not run. The terrain differences above support the
    explanation, but they do not prove it portal by portal.
  • Whether the N1 scenario (a short tunnel with an off-centre bore) occurs in box B: not searched.
  • No pictures: the pull request claims no pixel change, and the digests are the proof.

Generated by Claude Code

… tag end

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
timohueser and others added 2 commits November 15, 2026 14:10
The bridge's recorded size takes ground-plan's for now; this branch
records its own CI size on the merged base next.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ls rules on the passage rule

CI on 681070b measured 808,099 B gzipped (-172 B) and 2,090,936 B raw
(+0 B); the bridge's behaviour does not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@timohueser
timohueser merged commit 8a399ce into ground-plan Nov 15, 2026
45 of 47 checks passed
@timohueser
timohueser deleted the claude/gp12-4-levels-rules branch November 15, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant