Skip to content

Reject directionally illegal route fallbacks - #104

Merged
pfeiferj merged 1 commit into
pfeiferj:mainfrom
FrogAi:codex/reject-illegal-route-fallbacks
Aug 9, 2026
Merged

Reject directionally illegal route fallbacks#104
pfeiferj merged 1 commit into
pfeiferj:mainfrom
FrogAi:codex/reject-illegal-route-fallbacks

Conversation

@FrogAi

@FrogAi FrogAi commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Establish directional legality immediately after MatchingWays.
  • Apply freeway, name, ref, curvature, and fallback heuristics only to the legal subset.
  • When the in-bounds matching set contains no legal continuation, return the existing no-way result with StartPosition at the junction.
  • Preserve the fallback that allows legal sharp turns when every candidate exceeds the curvature threshold.

Motivation

NextWay already rejected reverse one-way candidates in its preferred and generic candidate paths, but the final fallback returned raw matchingWays[0]. The audit's two-road fixture therefore returned way 2 with IsForward=false even though leaving the junction required reversing along a one-way road.

That impossible predicted path can feed recursive route prediction, upcoming speed-limit, advisory-speed, and hazard scans, curve generation, and extended path output.

Legality must be established before the soft heuristics. Filtering only the final fallback is insufficient: on freeways, an illegal preferred non-service road can make the freeway filter discard the only legal service or access alternative before fallback.

Behavior

Topology Base 68813e05 Head de30289
Illegal one-way only Returns way 2 in reverse No way; preserves junction StartPosition
Illegal first, legal straight alternative Returns legal way 3 Unchanged
Legal sharp-turn only Returns sharp way 4 through fallback Unchanged
Illegal first, legal sharp turn Returns illegal way 2 Returns legal way 4
Reverse two-way candidate Returns way 5 in reverse Unchanged
Same-ID continuation with a distinct bounding box and continuation segment Returns the continuation Unchanged
Reverse-current continuation Returns the candidate from the active junction Unchanged
True dead end No way; preserves junction StartPosition Unchanged
Freeway illegal Main plus legal Service Road Returns illegal Main Returns legal Service Road
Two legal sharp turns Returns the first legal candidate Unchanged stable order

The first row is the executed audit reproduction. The remaining rows are deterministic static source-path outcomes against Base and Head, not executed tests. Sharp-turn rows deliberately place the candidate above the active curvature threshold so they exercise the unchanged final fallback.

Validation

  • An audit-only fixture executed the baseline illegal-only reproduction: current road into junction J, sole one-way candidate encoded toward J, observed result way 2 in reverse instead of the no-way junction sentinel.
  • Static topology review covered an illegal-only junction, a legal alternative, legal sharp turns, illegal-first ordering, reverse two-way travel, same-ID continuation, reverse-current traversal, a true dead end, the freeway hidden-alternative case, and stable fallback order.
  • Static source review confirmed the filter is stable, matching errors still return before filtering, and all downstream selection heuristics operate on the legal subset.
  • Fork Build #15 passed the make build job on exact commit de30289.

Compatibility

  • No schema, settings, or offline-map format changes.
  • Reverse traversal remains allowed on two-way roads.
  • Freeway, name, ref, curvature thresholds, ranking, and fallback order are unchanged among the remaining legal candidates.
  • The no-way junction sentinel and nil-error dead-end contract are unchanged.
  • Generator one-way parsing is unchanged and remains isolated in the next F-04 PR.
  • NextWays and downstream consumer implementations and interfaces are unchanged; they now receive only legal continuations or the no-way sentinel.
  • Explicitly one-way closed ways (first node identical to last node, e.g. roundabout rings tagged oneway=yes) are rejected at their repeated endpoint by the now-universal filter for as long as IsForwardFrom classifies that match as reverse; PR #105's closed-way clause restores forward classification there. Land Preserve OSM one-way direction during generation #105's runtime change with or before this one — a trial merge of both auto-merges cleanly, builds, and passes the full test suite, with Preserve OSM one-way direction during generation #105's clause preventing this filter from discarding one-way roundabout rings.

@pfeiferj
pfeiferj merged commit d9b0bf8 into pfeiferj:main Aug 9, 2026
@FrogAi
FrogAi deleted the codex/reject-illegal-route-fallbacks branch August 10, 2026 04:19
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.

2 participants