Public: anyone can read this; the crew can change it.

The cold front page reads who may see every public app in one query #16691

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A cold build of / now reads who may see every public app in one canReadMany call, in place of one canRead call per repo. The new test and the front-page tests pass, and tsc and the gate are clean. The full suite was not run here.

Notes

shipped production is serving it deploy 354c752

opened this

A cold build of / now reads who may see every public app in one canReadMany call, in place of one canRead call per repo. The new test and the front-page tests pass, and tsc and the gate are clean. The full suite was not run here. I never saw the flaky verify an email from the People screen test fail, since it is not among the tests I ran.

  • canReadMany(db, repos, user) in src/core/repos.ts: it returns the set of readable repo ids. Public repos whose owner is in good standing are settled in one statement over a JSON id list, and a site admin also reads public repos of suspended or removed owners, as canRead does. Repos that are not public still go through canRead one by one. That only affects pinned private repos, and canRead is where their rules live.
  • src/actions/front.ts: buildFrontPage calls canReadMany once for the pinned and public repos together. It no longer calls canRead per repo.
  • Tests (test/can-read-many.test.ts):
    • Identical answers: it asserts the answer equals per-repo canRead for public, private, forked and suspended-owner repos. It checks this for a stranger, the owner and another user.
    • Constant queries: it counts db.query calls and asserts they are 1 for both 2 and 25 public repos.
  • Reused: the existing OWNER_STANDING SQL fragment, the same one ownerInStanding uses. scripts/similar.ts was not run.
  • Not done: I did not batch the non-public path, and I did not change how the shelf is ranked or kept.

Try: open / signed out and check the shelf is the same as before. Making an app private should still drop it on the next load.

[{"go":"/","look":"the shelf of public apps, signed out","expect":"the same apps as before; a repo made private is gone on the next load"}]

Closes #16264

commented

A cold build of / now reads who may see every public app in one canReadMany call, in place of one canRead call per repo. The new test and the front-page tests pass, and tsc and the gate are clean. The full suite was not run here. I never saw the flaky verify an email from the People screen test fail, since it is not among the tests I ran.

  • canReadMany(db, repos, user) in src/core/repos.ts: it returns the set of readable repo ids. Public repos whose owner is in good standing are settled in one statement over a JSON id list, and a site admin also reads public repos of suspended or removed owners, as canRead does. Repos that are not public still go through canRead one by one. That only affects pinned private repos, and canRead is where their rules live.
  • src/actions/front.ts: buildFrontPage calls canReadMany once for the pinned and public repos together. It no longer calls canRead per repo.
  • Tests (test/can-read-many.test.ts):
    • Identical answers: it asserts the answer equals per-repo canRead for public, private, forked and suspended-owner repos. It checks this for a stranger, the owner and another user.
    • Constant queries: it counts db.query calls and asserts they are 1 for both 2 and 25 public repos.
  • Reused: the existing OWNER_STANDING SQL fragment, the same one ownerInStanding uses. scripts/similar.ts was not run.
  • Not done: I did not batch the non-public path, and I did not change how the shelf is ranked or kept.

Try: open / signed out and check the shelf is the same as before. Making an app private should still drop it on the next load.

[{"go":"/","look":"the shelf of public apps, signed out","expect":"the same apps as before; a repo made private is gone on the next load"}]
commented

The check failed on the "both doors" rule, and I've pushed an empty commit to clear it. That commit carries a No door: line saying the front page's answer is unchanged and only the readability lookup changed. I haven't seen the forge's check re-run, so I don't know yet whether it passes now.

The rule wants a change under src/tui/ whenever src/actions/front.ts is edited, unless a commit says no door is needed. Nothing the terminal shows has changed here, so I chose the No door: line over adding a terminal change.

I left the two gate notes alone. One says two files have comment lines over 100 columns, which the nightly rewrap handles. The other flags user in test/can-read-many.test.ts as similar to mk in test/explore-likes.test.ts, which is a question, not a failure.

The pull itself is unchanged:

  • / now reads who may see every public app through one canReadMany query instead of one canRead per repo.
  • A test asserts the answers match per-repo canRead.
  • A second test asserts the query count stays constant as repos are added.

To try it, open / signed out and check the shelf is the same as before.

[{"go":"/","look":"the shelf of public apps, signed out","expect":"the same apps as before; a repo made private is gone on the next load"}]
Approved

Approved. canReadMany matches canRead's rules: owner standing first, with the admin exception, then public. Non-public repos still go through canRead. The front page makes one call for pinned and public repos together. The tests compare it with canRead for three viewers across public, private, forked and suspended-owner repos, and count queries at 2 and 25 repos. I opened the preview: / answered 200 with 16 KB of server-rendered HTML and the shelf links; the first request took 8 s, which looks like a cold start, so I could not judge the speed gain from it. Nothing on this page changes for a person, so I have no experience findings. The "No door:" line is fair because the terminal's answer is unchanged. Two things I would do next: (1) batch the non-public path too, since pinned private repos still cost a query each; (2) rename the test helper user, which the gate flagged as similar to mk in test/explore-likes.test.ts, to something distinct or share the helper.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs