Skip to content

Name a trip's stops by their own agency - #1794

Closed
aaronbrethorst wants to merge 1 commit into
ab/stop-id-outputfrom
ab/stop-id-trips
Closed

aaronbrethorst wants to merge 1 commit into
ab/stop-id-outputfrom
ab/stop-id-trips

Conversation

@aaronbrethorst

Copy link
Copy Markdown
Member

Stacked on #1793. 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 agency of the trip or block that visits it:

  • trip status closestStop and nextStop
  • trip schedule stopTimes[].stopId
  • block blockStopTimes[].stopTime.stopId
  • block references.stops

Root cause

These code paths prefixed stops with the trip's or block's agency. Java OneBusAway names a stop after its feed's first agency everywhere. So an interlined trip, or another agency's trip at a shared stop, produced a stop ID that doesn't exist.

They now read each stop's agency through loadStopAgencyIDs. Two helpers replace duplicated code:

  • loadTripStops returns the stops' coordinates and agencies together. It replaces three copies of "fetch the trip's stops and map their coordinates" in BuildTripSchedule, buildStopTimesList and the trips-for-location bulk loader.
  • stopIDsForStopTimes replaces the loops that collected a trip's stop IDs.

Testing

  • Test failing on main before this change: TestTripStopIDs_UseTheStopsOwnAgency, on the two-agency fixture. It uses a mock vehicle on other-trip at 10:15 UTC.
    • trip-details/other_other-trip: status closestStop/nextStop and the schedule's stop IDs were other_stop-1/other_stop-2 before this change. Now they're own_stop-1/own_stop-2.
    • block/other_other-block: same before and after.
  • Changed test: TestTripsForRouteHandler_CrossAgencyInterlinedBlock expected four stop references, each stop once per agency. It now expects two, one per stop.

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: nextStop on a Community Transit trip at that stop would be 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

  • Extra query. BuildTripStatus now runs one more small indexed query per trip to read its stops' agencies.
  • Block references. This PR changes only the stop IDs there. The block references still build stop records by hand instead of using BuildStopReferencesAndRouteIDsForStops, and they prefix every route with the block's agency. That's a separate follow-up.

Trip status closestStop and nextStop, trip schedule stop times and block
stop times prefixed each stop with the trip's or block's agency. Java
OneBusAway names a stop after its feed's first agency wherever it
appears, so another agency's trip showed the stop under an ID that
doesn't exist.

These now read each stop's agency through loadStopAgencyIDs. The three
copies of "fetch the trip's stops and map their coordinates" become
loadTripStops, which returns coordinates and agencies together, and
stopIDsForStopTimes replaces the loops that collected their IDs.

The interlined-block test expected each stop twice, once per agency; it
now expects one reference per stop.
@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: 090a2bd2-a028-4e56-adb0-b62461aca1c9

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 332
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-trips 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