Skip to content

Add a codebase map to docs/ - #1646

Open
dev-aditya-hub wants to merge 1 commit into
OneBusAway:mainfrom
dev-aditya-hub:docs/codebase-scan-report
Open

dev-aditya-hub wants to merge 1 commit into
OneBusAway:mainfrom
dev-aditya-hub:docs/codebase-scan-report

Conversation

@dev-aditya-hub

@dev-aditya-hub dev-aditya-hub commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1647

What it does

Adds one file, docs/codebase-scan-report.md: a map of the codebase on main. Package layout, the dependency graph, how the static import and GTFS-RT paths actually flow, the route table with middleware order, where config gets read, what the tests cover. Every claim cites a file:line, so you can check it rather than trust it.

No code, no behaviour change, no test changes.

Root cause

Not a bug fix. I wrote this for myself while working on the location-arrivals handlers, because I kept losing the same half hour: nearly every real-time endpoint funnels through BuildTripStatus, arrivals_core.go, scheduled_block_helper.go and reference_utils.go, and the reasoning behind them — the Java-parity calls especially — lives only in comments beside the code. Writing it down stopped me rebuilding that model from scratch each time.

Opening it in case it's useful to anyone else. #1644 fell out of it.

Testing

One Markdown file, so nothing to test. The references are checkable though, and I checked them:

220 file:line claims → all resolve, none past the end of its file
(scripted sweep, re-run after rebasing onto main)

$ CGO_ENABLED=0 go vet -mod=readonly -tags purego ./...
(clean, whole module)
  • Test failing on main before this change: n/a, docs only.
  • Manual check: the sweep above, plus spot-reading cited sections against the symbols they name.

I could not run the full suite — no C compiler on this machine, so CGO mode is unavailable. Section L says that outright rather than implying coverage I don't have. Nothing in the diff touches code.

Checklist

  • This PR addresses one issue.
  • It is under ~200 changed lines, or the description says why it can't be split.
  • For a bug fix, 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 gtfsdb/ (sqlc-generated) or testdata/openapi.yml (synced from upstream).
  • 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.
  • Any new endpoint matches testdata/openapi.yml, or an issue asking for it is open on OneBusAway/sdk-config.
  • I read every line of this diff and can explain it if asked.

On the size box: 1,514 lines, and it won't split usefully because half a map is worse than none. It's additive and touches nothing else, so the review question is "do we want this, and is it accurate" rather than a diff read.

#1647 is where I've put the actual question — whether this belongs in the repo, on the wiki, or nowhere. It isn't triaged yet, so if the answer is "nowhere", say so there and I'll close this without complaint.

Notes for reviewers

Whether it belongs here at all is the real question, and I don't know the answer. docs/README.md says the wiki is canonical and that docs/ holds historical artifacts, so this is either a wiki page, a dated snapshot, or nothing. Happy to move it or close this.

Two offers. Sections L and M describe my machine and what I did and didn't read, not the project — glad to cut both. And line numbers drift, so someone has to re-verify them now and then; if that's maintenance you don't want, that's a fair no.

Section K.4 is where I'd start if you're short on time: eleven doc-vs-code divergences with evidence. #1645 fixes four of them.

Record a structural survey of the repository as it stands on main: the
package layout and dependency graph, the startup/shutdown and
background-worker lifecycle, the static-import and GTFS-RT data flows
with their unit and timezone conventions, the full route table with
middleware ordering, the configuration surface and its consumers, and
the test and CI topology. References are given as file:line so the
document can be checked against the tree rather than trusted.

The motivation is onboarding cost. Behaviour here is concentrated in a
few large shared engines (BuildTripStatus, arrivals_core,
scheduled_block_helper, trip_updates_helper, reference_utils) that every
real-time endpoint routes through, and the Java-parity reasoning for
much of it lives only in code comments. Having the map written down
means that context does not have to be rebuilt from scratch each time.

Writing it also surfaced eleven places where the contributor guides
describe behaviour the code does not implement: rate limiting is one
shared bucket rather than per-key, CONTRIBUTING.md names two helper
files that do not exist, CLAUDE.md still documents the gtfsData
in-memory structures that were removed, and the README documents a
HEALTH_CHECK_KEY variable nothing reads. Those are recorded here as
neutral observations with evidence; they are raised separately in OneBusAway#1644
and fixed in OneBusAway#1645 rather than in this document.

Section M states coverage honestly: every tracked file has a status,
every non-test source file was opened, and roughly 85% of non-test
source lines were read line by line, with the unread remainder
enumerated. The full test suite was not run - this machine has no C
compiler, so the default CGO mode is unavailable; go vet and a subset
of packages pass under -tags purego, which is noted as not establishing
CGO-specific coverage.

Per docs/README.md the wiki remains canonical for specifications. This
is a point-in-time artifact rather than a spec, so it has no wiki
mirror and docs/AGENTS.md needs no new row.
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes: 1
  • docs/codebase-scan-report.md
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 48c17777-d42a-4d82-9493-7a017895d418
📥 Commits

Reviewing files that changed from the base of the PR and between b0ad9a1 and e2e9f04.

📒 Files selected for processing: 1
  • docs/codebase-scan-report.md

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.

@sonarqubecloud

Copy link
Copy Markdown

@dev-aditya-hub
dev-aditya-hub marked this pull request as ready for review October 19, 2026 05:52

@aaronbrethorst aaronbrethorst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together, @dev-aditya-hub. It's obvious you put real care into it, and #1644/#1645 are useful things to have come out of it. I don't want to merge it in its current form, though. Here's why:

It's already out of date on main. The branch sits on d07c60a, and main has moved since then. For example:

  • About 55 of the ~240 file:line references now point at the wrong line, among them BuildTripStatus (trips_helper.go:50, now :51) and pollFeed (realtime.go:981, now :1006).
  • D.4 says arrivals are sorted by scheduled arrival. Since #1576 they're sorted by best arrival time (predicted, else scheduled) after buildArrival.
  • C.4 and H.4 describe docker-publish.yml and GHCR. Both were removed in #1609.
  • The H.1 version pins are stale too.

A doc made of line numbers goes stale with every merge, and nobody is going to keep 220 of them current.

Some claims were wrong even at d07c60a:

  • The doc says "27 registered routes" in several places, and K.4 #3 builds on that number. SetRoutes registers 34 /api routes, and your own F.1 table lists 34.
  • H.1 says golang.org/x/sync has no non-test import. advanced_direction_calculator.go:15 imports singleflight.
  • E.3 says there are 17 base tables. schema.sql creates 16.

Where it lives. docs/ is for historical artifacts, and the wiki is canonical. Sections A.1, I.4, L and M describe your machine (/mnt/c/Users/..., /home/...) and your process, not the project.

If you'd like to keep going, I'd take a much shorter "Architecture overview" wiki page: the package map, the startup and realtime flows, the middleware order, and the shared engines. Cite files and symbols, not line numbers, and leave out the scan ledger. Otherwise I'm fine closing this. I'll answer on #1647 too.

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.

Is a codebase map worth keeping in the repo?

2 participants