Repository navigation
fix(live): epoch heartbeat, checked mode declarations, dated areas with a weekly refresh - #209
Merged
Merged
Conversation
…th a weekly refresh From the final review of #168; each with a test that fails without it. - A leader publishes the epochs of the sources it holds every coordination round (2 s), so a follower's mark stays fresh between slow polls (15-60 s) and the lower-epoch window, meant for a counter lost in a failover, never opens while the leader lives: a late publish from an older holder stays dropped. - Every source's `transitModes` must include what its adapter emits and every mode its operator's routes.txt names (`modes.test.ts`). The routes' modes are recorded by `live:areas`; providers take theirs from it. Corrected: Renfe (replacement buses), FGC (rack railways, funiculars, Vallès metro, buses), the subway feed (Staten Island Railway). - `areas.generated.ts` opens with each feed's date and SHA-256 of what it was derived from (unchanged data rewrites nothing), and a weekly workflow regenerates it, runs the area and mode tests and opens a pull request when anything changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR handles the follow-ups from the final review of #168. Each fix has a test, and I checked that the test fails without the fix.
1. Lower-epoch window lapsing between slow polls (
hub.ts,cluster.ts)epochsmessage with the epoch of each source it holds.cluster.test.ts→ "a live leader heartbeats its epoch…". It runs 40 s with no poll answered, then delivers a stale publish. The test fails with the heartbeat disabled.2. Declared transit modes match what a source emits (
modes.test.ts)Every source's
transitModesmust include:routes.txtnames. The hub gives each vehicle its route's mode, andlive:areasrecords those modes.A source neither check can reach fails the test. The test showed three catalogue declarations were too narrow, now corrected:
bus(replacement buses).subway,cableandbus(Vallès metro lines, rack railways and funiculars, connecting buses).rail(the Staten Island Railway).Providers no longer declare their modes by hand. Their
transitModesare their default mode plus every mode their routes name, so mixed feeds like Calgary's and Vancouver's can't be mis-declared.Verified failing: a deliberately wrong declaration fails both checks.
3.
areas.generated.tsis dated, fingerprinted and refreshedThe file now opens with a header listing each feed, the date its inputs last changed, and a SHA-256 of the stops' positions and route types. Re-running over unchanged data rewrites nothing, and a source whose server is down keeps its previous entry and date.
areas.test.tschecks every entry has a date and a fingerprint.New workflow:
.github/workflows/live-areas.ymlruns weekly and can be started by hand. It:The tests run inside the workflow because a pull request opened with the workflow's own token doesn't start CI.
Owner action: opening that pull request needs the repository setting "Allow GitHub Actions to create and approve pull requests". Without it the run fails visibly rather than silently.
4. CI builds
packages/contractsbefore the backend tests: checked, no change neededbun install --frozen-lockfile --ignore-scripts, then Build the contracts, then migrations and tests. The backend resolves@goway/contractsthrough itsmain(dist/index.js), so the tests always run against freshly built contracts.Checks run locally
bun run lint,bun run typecheckandcheck:openapiare clean.🤖 Generated with Claude Code