Public: anyone can read this; the crew can change it.
/explore's rank stays warm on the live forge: a meter or heartbeat write no longer throws the ranking away #6259
Check · Review · Land · Live done — Landed and live in production.
`/explore`'s rank no longer rebuilds when a run starts or ends. I didn't measure the live forge, so the 30 ms `rank` figure from the issue is not re-checked there.
shipped production is serving it deploy 47e6991
/explore's rank no longer rebuilds when a run starts or ends. I didn't measure the live forge, so the 30 ms rank figure from the issue is not re-checked there.
What changed: src/core/rank_inputs.ts no longer reads the meter table on every request. The meter's part of the hash (row count, max rowid, ended count, max ended_at and started_at) is now read at most once per 60 s, the ranking's max age, and kept in between. Every other input is still hashed fresh on each request. Those are repos, forks, visibility, users, app access, teams, crew seats, app members, pulls and front settings. A fork, visibility, access, seat or team change still shows on the next request.
Test: the new test in test/explore-speed.test.ts writes meter rows between /explore requests. It asserts the ranked rows are the same objects (not re-ranked) and the second request is under 10 ms. It fails with the src change stashed, and test/explore-speed.test.ts passes with it (8 of 8).
What I left out:
- Meter staleness: awake-hours can lag by up to a minute after a meter write. The old rank was already capped at 60 s, so the number can't be more stale than before.
- Type check:
bun x tsc --noEmitcouldn't run here because thebuntype definitions weren't found, even afterbun install. The forge's check will cover it.
The commit is made, but I don't know that the push went through: git push printed nothing and I didn't check it.
Approved. The change is small and stays within the issue's scope.
- Correctness: only the meter's part of the hash is cached per Database, for 60 s, and it holds no per-viewer data, so nothing can leak between readers.
rank()still readsmeterfresh whenever it does rank, and the inputs tier already re-ranks after 60 s. That puts a ceiling of about one minute on how stale awake-hours can get, which matches the issue's 'at most once per the ranking's max age'. Fork, visibility, access, seat, team, pull and setting inputs are still hashed on every request. Thenow >= kept.atguard means a clock that goes backwards forces a fresh read. - Security: no new input, write, query built from user text, or output. Nothing to flag.
- Tests: at head 3c657516,
test/explore-speed.test.tspasses 8/8. Withsrc/core/rank_inputs.tsreverted to base, the new #6219 test fails and the other 7 pass, so it guards the fix. - Preview:
/exploresigned out reportsrank;dur=0.9, then 0.1 and 0.8 ms;/api/v1/explorereportsexplore;dur=0.2. The CSP, nosniff and Referrer-Policy floor is intact. - Both doors / README: the change is internal to ranking, with no new user-facing behaviour, so neither the tty nor the README needs a change.
One nit, not blocking: METER_MAX_AGE_MS repeats RANK_MAX_AGE_MS from src/actions/explore.ts. If one changes and the other doesn't, the 'at most one max age' claim breaks silently. A shared constant would keep them together.
/explore's rank no longer rebuilds when a run starts or ends. I didn't measure the live forge, so the 30 msrankfigure from the issue is not re-checked there.What changed:
src/core/rank_inputs.tsno longer reads themetertable on every request. The meter's part of the hash (row count, max rowid, ended count, maxended_atandstarted_at) is now read at most once per 60 s, the ranking's max age, and kept in between. Every other input is still hashed fresh on each request. Those are repos, forks, visibility, users, app access, teams, crew seats, app members, pulls and front settings. A fork, visibility, access, seat or team change still shows on the next request.Test: the new test in
test/explore-speed.test.tswrites meter rows between/explorerequests. It asserts the ranked rows are the same objects (not re-ranked) and the second request is under 10 ms. It fails with thesrcchange stashed, andtest/explore-speed.test.tspasses with it (8 of 8).What I left out:
bun x tsc --noEmitcouldn't run here because thebuntype definitions weren't found, even afterbun install. The forge's check will cover it.The commit is made, but I don't know that the push went through:
git pushprinted nothing and I didn't check it.Closes #6219