Public: anyone can read this; the crew can change it.
The cold front page build is slow: batch the per-repo canRead queries and the runtime status scan #6139
A cold build of / now asks the owner-standing question once for all repos and reads each app's production status directly. The new test and test/front.test.ts pass. I didn't run the full bun test, and I didn't time a cold build, so the under-10 ms target isn't measured.
stopped parked by the crew deploy c70fa2a
7 earlier comments
A cold build of / now asks the owner-standing question once for all repos and reads each app's production status directly. The new test and test/front.test.ts pass. I didn't run the full bun test, and I didn't time a cold build, so the under-10 ms target isn't measured. bun x tsc --noEmit couldn't run here: the bun types are missing from the sandbox.
canReadbatching:strangerReadable(db, repos)insrc/core/repos.tsis new. It checks owner standing for every repo in one query per 400 ids. A public repo with an owner in good standing is readable without another query. Only non-public repos get the fullcanRead(db, repo, undefined), so the two always agree.frontPageinsrc/actions/front.tsuses it for the pinned and public repos together.- Status scan:
frontPagenow callsruntime.envStatus(record, "production"), which is a map lookup. Before, it scanned every environment of every app withruntime.status. No change was needed insrc/apps/runtime.ts. - Test:
test/stranger-readable.test.tschecksstrangerReadableagainstcanReadfor a public repo, a private repo and a suspended owner's repo.
I left the per-owner isActive check as it was, since owners already load in one query.
To try it, run bun test test/stranger-readable.test.ts test/front.test.ts.
The cold front-page build now asks once, for all repos, whether the viewer owns them. It no longer runs a canRead query per repo. It also reads production status directly instead of scanning runtime status. This was already committed and pushed on the branch (ced8a733), so this run added no new commits.
- Code: the change is in
src/actions/front.tsand a new helper insrc/core/repos.ts. - Test:
test/stranger-readable.test.tsis new for the batched standing read. - Checks: that test file passes and
tsc --noEmitis clean. I did not get a finished fullbun testrun. The forge runs the whole check on the push. - Not done: I took no timings, so the speed-up is not measured. I did not touch the signed-out shelf or the issues-list batching, which landed separately in #6133 and #6135.
- To try it: load
/cold on the preview and compare it with production.
I made no changes this run. The feedback request had no new comment, review or instruction on #6139. The branch is clean and ced8a733 is already pushed.
I re-ran bun test test/stranger-readable.test.ts test/front.test.ts and all 15 tests pass. I did not run the full bun test, the type check, or a timing of a cold build.
What the pull does:
- Owner standing:
strangerReadable(db, repos)insrc/core/repos.tsis a new helper. It asks once for all repos whether the owner is in good standing, in batches of 400 ids, instead of runningcanReadper repo. Only non-public repos fall back to the fullcanRead(db, repo, undefined), so the two always agree. - Front page:
frontPageinsrc/actions/front.tsuses it for the pinned and public repos together. - Production status:
frontPagenow callsruntime.envStatus(record, "production"), a map lookup. Before, it scanned every environment of every app withruntime.status. - Test:
test/stranger-readable.test.tsis new. It comparesstrangerReadablewithcanReadfor a public repo, a private repo and a suspended owner's repo.
Left out: I took no timings, so the speed-up is not measured. I left the per-owner isActive check as it was, since owners already load in one query.
To try it: run bun test test/stranger-readable.test.ts test/front.test.ts, or load / cold on the preview and compare it with production.
🤖 Generated with Claude Code
A cold build of / now asks "which repos can this owner read?" once for all of an owner's repos, instead of once per repo. I haven't done the same for the runtime status scan. The change is on the branch and already pushed, and nothing new was needed this run. I checked it by running the four front-page test files, which pass. The full bun test run hit the 120 s limit, so I haven't seen it finish. I never ran the type check or scripts/design-lint.ts.
- Batched reads:
src/core/repos.tsgets a helper that works out an owner's standing once and applies it to every repo.src/actions/front.tsuses it, so the per-repo queries (twice over owners) are gone. - Production status:
src/actions/front.tsreads the production status directly (per the commit message) rather than callingruntime.status, which scans every env of every app. I did not changesrc/apps/runtime.tsitself. - Tests:
test/stranger-readable.test.tshas 61 new lines covering the batched read. - Not done: I never measured the cold-build time against the issue's 10 ms target.
To try it: run bun test test/stranger-readable.test.ts, then load / right after a database write and time the response.
Parked by the crew: the check failed ("verify an email from the People screen > an admin verifies the person under the cursor and the row changes") and the decider saw no point in another try try 1: src/actions/front.ts, src/core/repos.ts, test/stranger-readable.test.ts
The three failing studio tests are fixed and pushed as 0c10612a. The front page now reads production status through envStatus, and the test helper only faked status. So no app looked live and the "Apps, live." shelf rendered empty.
The fix is in test/helpers/studio.ts: serving now fakes envStatus as well as status. This is a test-only change. The test was wrong, not the front-page code.
test/studio-changes.test.ts and test/stranger-readable.test.ts pass (27 tests), and test/front.test.ts passes (14). tsc is clean. I did not run the full suite; the forge runs it on this push.
test/front.test.ts also fakes status, but it passes unchanged, so I left it alone.
The three test/front-speed.test.ts failures are fixed and pushed as c70fa2a1. After the push I did not wait for the forge's check, so whether it passes is still open.
Cause: test/front-speed.test.ts landed on main after I branched. The front page now reads production status through envStatus, and that test faked only status. With nothing reading as live, the shelf came back empty and the three tests failed.
Fix: I merged origin/main into the branch, then made the test fake envStatus as well as status. This is a test-only change; the test was wrong, not the front-page code.
Locally, front-speed, front and studio-changes all pass (46 tests) and tsc is clean. I did not run the full suite.
Parked by the crew: the check stayed red through 2 automatic tries
A cold build of
/now asks the owner-standing question once for all repos and reads each app's production status directly. The new test andtest/front.test.tspass. I didn't run the fullbun test, and I didn't time a cold build, so the under-10 ms target isn't measured.bun x tsc --noEmitcouldn't run here: thebuntypes are missing from the sandbox.canReadbatching:strangerReadable(db, repos)insrc/core/repos.tsis new. It checks owner standing for every repo in one query per 400 ids. A public repo with an owner in good standing is readable without another query. Only non-public repos get the fullcanRead(db, repo, undefined), so the two always agree.frontPageinsrc/actions/front.tsuses it for the pinned and public repos together.frontPagenow callsruntime.envStatus(record, "production"), which is a map lookup. Before, it scanned every environment of every app withruntime.status. No change was needed insrc/apps/runtime.ts.test/stranger-readable.test.tschecksstrangerReadableagainstcanReadfor a public repo, a private repo and a suspended owner's repo.I left the per-owner
isActivecheck as it was, since owners already load in one query.To try it, run
bun test test/stranger-readable.test.ts test/front.test.ts.Closes #6136