Skip to content

Name a route's stops by their own agency - #1795

Closed
aaronbrethorst wants to merge 2 commits into
ab/stop-id-tripsfrom
ab/stop-id-routes
Closed

aaronbrethorst wants to merge 2 commits into
ab/stop-id-tripsfrom
ab/stop-id-routes

Conversation

@aaronbrethorst

Copy link
Copy Markdown
Member

Stacked on #1794. Part of the stop consolidation work (#1771–#1779). No issue filed yet.

What it does

These now carry each stop's own agency, not the route's:

  • stops-for-route: stopIds, stop group stopIds, and the stop records in references.stops
  • schedule-for-route: stopTripGroupings[].stopIds and tripsWithStopTimes[].stopTimes[].stopId

It also batches loadStopAgencyIDs through utils.QueryInBatches, because whole routes and the trips-for-location bulk loader can pass more IDs than SQLite allows in one statement.

Root cause

Both handlers prefixed every stop with the route's agency. Java OneBusAway names a stop after its feed's first agency, so a route of any other agency listed stops under IDs that don't exist.

Both now read each stop's agency through loadStopAgencyIDs:

  • stops-for-route reads it once per request, alongside the stop coordinates in routeStopSequences.
  • schedule-for-route reads it once per direction group.

processTripGroups and buildStopGroup used the route's agency only for stop IDs, so they no longer take it.

Testing

  • Test failing on main before this change: TestRouteStopIDs_UseTheStopsOwnAgency, on the two-agency fixture.
    • It requests stops-for-route/other_other-route and schedule-for-route/other_other-route.
    • Every stop ID was other_stop-N before this change and is own_stop-N now.

Response comparison

  • Java: a stop's ID is set once, from its feed (StopEntriesFactory). Production stop/29_16140 returns null even though Community Transit route 29_130 serves 1_16140.
  • Maglev before: stops-for-route/29_130 would list 29_16140.
  • Maglev after: 1_16140.

Checklist

  • This PR addresses one issue.
  • It is under ~200 changed lines, or the description says why it can't be split.
  • This PR is not a bug fix, or the new or changed test fails on main and passes on this branch.
  • Each commit is one logical change with a clear message.
  • I did not hand-edit sqlc-generated files under gtfsdb/ (db.go, models.go, query.sql.go) or testdata/openapi.yml (synced from upstream).
  • This PR changes no handler, or handlers pass r.Context() to DB/service calls, not context.Background().
  • The response comparison above is filled in, or this PR doesn't change a Java-served response.
  • This PR adds no endpoint, or each new endpoint matches testdata/openapi.yml, has an issue open on OneBusAway/sdk-config, or is outside the SDK and the description says why.
  • I read every line of this diff and can explain it if asked.

Notes for reviewers

loadStopAgencyIDs now takes whole routes and every trip near a location,
which can exceed SQLite's bind limit. Run it through QueryInBatches like
the other stop lookups.
stops-for-route and schedule-for-route prefixed every stop with the
route's agency: entry stopIds, stop groups, the stops list and the
schedule's stop times. A route of an agency other than the feed's
first showed its stops under IDs Java OneBusAway doesn't have.

Both now read each stop's agency through loadStopAgencyIDs:
stops-for-route once per request, alongside the stop coordinates in
routeStopSequences, and schedule-for-route once per direction group.
processTripGroups and buildStopGroup used the route's agency only for
stop IDs, so they no longer take it.
@coderabbitai

coderabbitai Bot commented Oct 24, 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: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 4d1c01e7-ab2e-4d09-bc44-141fc7889efb

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

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

@aaronbrethorst, the PR description does not follow the PR template:

  • No linked issue. Add Fixes #N (or Part of #N) for a triaged issue.
  • Testing: "Manual check:" is empty.
  • Response comparison: "Request URL(s):" is empty.
  • Response comparison: "Java server, feeds and date checked:" is empty.
  • Checklist item is not checked: "This PR addresses one issue." If this item doesn't apply to your PR, ask a maintainer.
  • Checklist item is not checked: "I read every line of this diff and can explain it if asked." If this item doesn't apply to your PR, ask a maintainer.

Keep this PR as Draft until these are fixed. This comment updates when the description changes.

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Performance Smoke Test Results

Status: PASSED

Metric Value
p(95) latency 2.2 ms
Error rate 0.00%
Total requests 334
Req/sec 11.0

Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%.

Full results uploaded as workflow artifact: k6-smoke-summary.

@aaronbrethorst

Copy link
Copy Markdown
Member Author

Closing as superseded. The multi-feed static GTFS spec (#1811, docs/multi-agency-static-feeds-spec.md §10) folds this stack's stop-ID rules into the per-feed default agency and the stored-ID identity model; they return as phases B and C of that plan. The Java-recorded data in testdata/java_parity and the tests on this branch will be reused there. #1806, #1807 and #1810 are not identity work and stay open to be re-cut against main.

@aaronbrethorst
aaronbrethorst deleted the ab/stop-id-routes branch November 8, 2026 18:31
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