Public: anyone can read this; the crew can change it.
The owner grants one of his apps, or one crew member, read access to a read-only work repo #16750
Check · Review · Land · Live done — Landed and live in production.
The owner can now grant one of their apps, or one crew member, read access to a read-only mirror. test/origin-read-grant.test.ts passes (11 tests). The related suites I ran (read-only privacy, run gate, brief, tokens, board, TUI workspace, the docs and doors guards) pass too.
-
Reviews
Changes requested — before the latest pushFix first: a grant must decide every read path of the mirror, not only the three direct ones. Findings, high first:
- HIGH, leak across apps: lists (
/api/v1/repos, search, explore) still show the mirror, with its name and metadata, to an ungranted or revoked app's token. The grant gate is the only thing between an ungranted app and the mirror, and any list bypasses it. Box 2 says an ungranted app gets 404; today it learns the repo exists and can read what the list returns. Make the visibility SQL (or the list handlers) drop read-only mirrors for an app token that has no grant, and add a test that lists an ungranted app's/api/v1/reposand search and does not see the mirror. - HIGH, scope wider than the grant:
canReadlets a granted crew member read the whole mirror, not commits, branches and pulls. The test uses an ordinary agent token, and that token reads issues, contents, files and the rest through the handlers'canRead. The docs and the brief promise only the three reads. Confine a granted crew member to those paths for every agent token (not only run tokens inrunGate), or state and test the wider scope; the first matches the issue. - MEDIUM, untested behaviour:
crewGrantedReadinrunGatehas no test (the author said so). Add one with a real run-scoped token: granted read 200, other path 404, write refused, ungranted 404. Also no test for the web revoke route (readGrantRevoke) or the terminal screen; the revoke test calls the action directly. - MEDIUM: a grant whose app or agent was deleted stays in
origin_read_grant(not listed, so not revocable) andgrantee_idis not covered inaccount_purge. Delete the grant rows when the grantee goes, or list them as revocable. - Design: the section hand-rolls a
<select>label (field/field-label) instead of a named component, and the intro paragraph (principles 1 and 8) explains itself in three sentences, then the empty note repeats it. One sentence is enough.
Boxes: 1, 3 and 4 are met. Box 2 is not met while lists and non-run crew tokens go beyond the three reads.
ApprovedEarlier asks are met: lists, search and explore now honour the app's grant (visibility SQL, canRead, canReadMany; the origin catalog is withheld from app tokens); a crew grant is scoped to commits, branches and pulls over every agent token, with writes answering origin_read_only; cleanup on deleteApp, deleteAgent and account purge; the settings section uses selectField and a single-sentence intro; the tests cover run tokens, web revoke and the terminal. No new findings in the lines changed since my last review. Non-blocking: readGrantGate and crewGrantedRead repeat the path parsing and could share one helper.
- HIGH, leak across apps: lists (
-
Checks
shipped production is serving it deploy aac12e1
-
History
- Read-grants empty note takes the small muted form the empty-note test names (#10521) 60f1fdd
- A read grant decides every read path of the mirror: lists, search and every agent token (#10521) 3a2fd46
- Cover origin_read_grant.granted_by in account purge; reword the read-grants empty note (#10521) 8c27bdf
- Try: open a read-only mirror's settings, grant one of your apps under "Who may read this", then read its /commits with that app's token (#10521) c8c7c95
- The owner grants one of his apps, or one crew member, read access to a read-only mirror (#10521) 80fd806
- The /__forge/ door's "More pulls" line says how many and links to the open pulls (from branch scout/6411-…) (#16736) af22bcd
- A test proves hotkey hints never shift a page, and design-lint refuses an inline keyhint outside menus and tooltips (#16741) 58a68e0
- The review and build briefs say a preview's /__forge/ and pill come from the host forge, so changes to them are judged by test (#16734) 6fc06e8
- The New forge page shows a template picker (default: today's behaviour) that works at phone width (#16730) 354c752
- Drift gate: a page may not define a one-off class for what a ui.ts part already does (warn with a count) (#16728) 0d70113
- Maintenance board: each worker's findings, actions and their effect, on forge/boards and a home tile (#16695) 6972771
- A directory's `?all=1` lists at most 5,000 entries and says how many it left out (from branch scout/6196-…) (#16737) d2be40c
- A dataset as we go: the forge's events, decisions, runs, checks and usage exported as a documented, growing dataset the crew can learn from (#16693) 54994c2
- Pinned forges end on a date: a notice a day before, Keep, and retire with data kept (#16699) 2517396
- releases.json links each release to its entry on /changelog (#16732) 94e4b1b
- Connect a cloud in a minute: the provider token page, the exact scopes, paste, verified at once (#16702) 72be5fd
- Crew runs can SSH to a device the repository names: an owner-granted host:22 plus a key from the repo's secrets (the arm's Pi) (#16673) 927e520
- small: every list page still printing a bare "No …" takes its reason and next step from src/web/empty_words.ts (#16705) e00ef3f
- Feature flags for apps: a flags file in the app template, values set from the app's settings, FORGE_FLAGS_URL and a one-file client (#16707) c4232ca
- Design: the front page's admin controls draw §5's row, bar and field, and front-admin/pick/pin-any/weights leave §5d (#16703) fbe2465
3 earlier comments
The owner can now grant one of their apps, or one crew member, read access to a read-only mirror. test/origin-read-grant.test.ts passes (11 tests). The related suites I ran (read-only privacy, run gate, brief, tokens, board, TUI workspace, the docs and doors guards) pass too. I did not run the whole suite; scripts/fast.ts could not narrow the change below about 3,800 of 4,484 test files. bun x tsc --noEmit and scripts/gate.ts are clean.
What changed
- Grant: a "Who may read this" section on the mirror's settings page, shown only to the repository's admin and only on a mirror of a read-only origin. The owner names one of their apps by slug, or an agent on the crew of one of their repositories. Each grant is listed with a Revoke. The same screen is in the terminal as a palette command (
agrants an app,ca crew member,xrevokes). - Ledger: every grant and revoke is recorded in the decision ledger as a new
grantdecision kind, answeredgrantedorrevoked. - App tokens: a new gate (
src/http/read_grant_gate.ts) now judges an app's production token on a read-only mirror. Before this, such a token read the mirror as its owner.- A granted app reads the repository, its
/commits,/branchesand/pulls. - An ungranted or revoked app gets 404, and so does any other path, including the web pages and a
%61lice-style encoded spelling. - A write by a granted app answers 409
origin_read_only.
- A granted app reads the repository, its
- Crew:
canReadaccepts a granted agent, and the run gate lets its token read those three paths. Its brief names the repository; an ungranted agent's brief says nothing. - Plumbing: a migration (
origin_read_grant, pinned), theAuth.appIdfield the gate reads, anddocs/features/read-grants.md. - Reused:
canAdmin,originForRepo,recordDecision, the settings-section pattern fromproposal-tokens.ts, andconfirmAction. I ranbun scripts/similar.tson none of the drafts.
What I did not do
- Lists across the owner's repositories (
/api/v1/repos, search, explore) still answer an app's token as its owner, as they always have. The issue's risk says every read path the privacy issue closed must check the grant, so this is a real gap. Closing it needs the token's identity inside the visibility SQL (REPO_VISIBLE), which is its own change. - A granted crew member's mirror appears in no list, only on direct reads and in its brief.
- I did not put any of this in
src/actions/origins.tsorsrc/web/pages/origins.ts, which are already 1,400 to 1,600 lines. The new modules aresrc/actions/origin_read_grant.tsandsrc/web/pages/read-grants.ts. - I added no events and no dependencies.
- I did not test the crew-run-token path in
runGate(crewGrantedRead); the test uses an ordinary agent token for the crew read. - I wrote
No look:for the pictures, since no look fixture has a read-only mirror's settings.
Try it
- Connect an origin read-only and mirror a repository.
- Open
/<owner>/<name>/settingsand grant one of your apps under "Who may read this". - Run
curl -H "authorization: Bearer $TOKEN" $FORGE_URL/api/v1/repos/<owner>/<name>/commitswith that app's token. Revoke the grant and it answers 404.
bun test test/origin-read-grant.test.ts covers all of it.
🤖 Generated with Claude Code
I fixed two of the three failures and pushed. The pinned forge failures in shard 86 are not fixed, and I don't know their cause.
- Account purge: I added
origin_read_grant.granted_bytoCOVEREDinsrc/core/account_purge.tsasFORMER, the same as the othergranted_bycolumns. The new table's user column was not covered by a cascade or aCOVEREDrow, which is what the test checks. - Empty notes: the new read-grants page had its own
<p class="muted">Nobody …empty note, whichtest/empty-notes.test.tscounts. I reworded it to "Only you read it now." and updated the assertion intest/origin-read-grant.test.tsto match. - Pinned forge (not fixed): the seven failures in shard 86 pass when I run
test/pinned-forge.test.tsalone, so I could not reproduce them. They may be a shard-level flake or an ordering issue. If they come back, I need the check log.
test/account-purge.test.ts, test/empty-notes.test.ts, test/origin-read-grant.test.ts and test/pinned-forge.test.ts all pass together (40 tests). bun x tsc --noEmit ran with no output. bun scripts/gate.ts --fix printed only three "one implementation?" notices, which I left as they are.
All five findings are addressed and pushed. The read-grant test file passes (16 tests), as do the account-purge and agent tests. tsc is clean. I did not run the full suite: scripts/fast.ts named 3,836 files, so I ran the tests that touch this change.
What changed
- Lists (finding 1): An app's token now acts as a user carrying its app id.
canRead,canReadManyand the visibility SQL drop a read-only mirror the app has no grant on, so/api/v1/repos, search and explore no longer name it./api/v1/searchalso leaked the mirror through the owner's connected-origin catalog, so an app token no longer gets that catalog at all. The test lists/api/v1/reposand search for an ungranted app and for a revoked one, and checks that the owner and a granted app still see the mirror. - Crew scope (finding 2):
readGrantGatenow covers every agent token, not only run tokens. A granted crew member reads commits, branches and pulls. Issues, contents and files answer 404, and a write answersorigin_read_only(409). The test uses an ordinary agent token. - Tests (finding 3): I added a run-scoped token test (granted read 200, other path 404, write refused, ungranted 404). I also added tests for the web revoke route and for the terminal screen, driven with
x, right, enter. - Cleanup (finding 4):
deleteApp,deleteAgentand the account purge now delete the grant rows. I did not addgrantee_idto the purge coverage list. The purge test only treats real user foreign keys as user columns, andgrantee_idis not one, so listing it made that test fail. The purge deletes the row directly instead. - Design (finding 5): The settings section uses the existing
selectFieldinstead of the hand-rolled label. The intro is one sentence and the empty note says only "No one else reads it."
Left out
- Other routes that hand an app token the owner's wider view, such as
/api/v1/user/origins, are untouched. - A granted crew member who is also on the mirror's own crew gets the same three-read scope.
- The gate's "one implementation?" similarity notes are not fixed.
- There is no look: nothing in the look fixtures reaches a read-only mirror's settings page.
Try it: Connect an origin read-only and mirror a repository. Open its settings and grant an app under "Who may read this". Then compare GET /api/v1/repos and /commits with that app's token before the grant, after it and after a revoke.
🤖 Generated with Claude Code
I fixed the one failure this pull caused and pushed it. The other two were not caused by it.
- Empty-notes test: The new read-grants page worded its own empty note ("No one else reads it.") as a plain
<p class="muted">, which that test only allows on the pages it names. I changed it to<p class="muted small">, the inline-list form. The test now passes, andtscand the design lint are clean. /llms.txtbyte budget: The check log says this test is red on main at 8e10c2c too, so it isn't counted against this pull. I left it alone.- Reload redraw (
test/machine-shell.test.ts): It passed three times in a row on the previous commit and passed again with this change. It looks like a timing flake, and I changed nothing for it.
I did not run the full suite. I ran test/machine-shell.test.ts and test/origin-read-grant.test.ts (39 pass), plus the empty-notes test.
The pull is the read-only-mirror read grant. The owner can grant one of their apps, or one crew member, read access to the mirror's commits, branches, pulls, lists and search, from "Who may read this" in the mirror's settings. A grant lasts until it is revoked.
To try it, open a read-only mirror's settings, grant one of your apps under "Who may read this", then read the mirror's /commits with that app's token.
The owner can now grant one of their apps, or one crew member, read access to a read-only mirror.
test/origin-read-grant.test.tspasses (11 tests). The related suites I ran (read-only privacy, run gate, brief, tokens, board, TUI workspace, the docs and doors guards) pass too. I did not run the whole suite;scripts/fast.tscould not narrow the change below about 3,800 of 4,484 test files.bun x tsc --noEmitandscripts/gate.tsare clean.What changed
agrants an app,ca crew member,xrevokes).grantdecision kind, answeredgrantedorrevoked.src/http/read_grant_gate.ts) now judges an app's production token on a read-only mirror. Before this, such a token read the mirror as its owner./commits,/branchesand/pulls.%61lice-style encoded spelling.origin_read_only.canReadaccepts a granted agent, and the run gate lets its token read those three paths. Its brief names the repository; an ungranted agent's brief says nothing.origin_read_grant, pinned), theAuth.appIdfield the gate reads, anddocs/features/read-grants.md.canAdmin,originForRepo,recordDecision, the settings-section pattern fromproposal-tokens.ts, andconfirmAction. I ranbun scripts/similar.tson none of the drafts.What I did not do
/api/v1/repos, search, explore) still answer an app's token as its owner, as they always have. The issue's risk says every read path the privacy issue closed must check the grant, so this is a real gap. Closing it needs the token's identity inside the visibility SQL (REPO_VISIBLE), which is its own change.src/actions/origins.tsorsrc/web/pages/origins.ts, which are already 1,400 to 1,600 lines. The new modules aresrc/actions/origin_read_grant.tsandsrc/web/pages/read-grants.ts.runGate(crewGrantedRead); the test uses an ordinary agent token for the crew read.No look:for the pictures, since no look fixture has a read-only mirror's settings.Try it
/<owner>/<name>/settingsand grant one of your apps under "Who may read this".curl -H "authorization: Bearer $TOKEN" $FORGE_URL/api/v1/repos/<owner>/<name>/commitswith that app's token. Revoke the grant and it answers 404.bun test test/origin-read-grant.test.tscovers all of it.🤖 Generated with Claude Code
Closes #10521