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

A work repo as a read-only origin: fetch only, private, granted to his own apps #10443

Parked opened this in answer to
Closed without merging

A work repository can now be added as a read-only origin. It is fetched on the existing ten-minute origin sync, and the forge never writes back to it. The work-origin tests, the origin, mirror and migration tests, the gate and tsc all pass, and the design lint is clean.

Notes

stopped parked by the crew deploy ab9da33

opened this

A work repository can now be added as a read-only origin. It is fetched on the existing ten-minute origin sync, and the forge never writes back to it. The work-origin tests, the origin, mirror and migration tests, the gate and tsc all pass, and the design lint is clean. I did not run the full suite, which the forge's check does on push.

What changed

  • Adding one: tick Work repository (read-only) under Settings → Origins → token, or send POST /api/v1/user/origins with "readOnly": true. The token is validated and sealed at rest, and it is never shown back. The fetch brings in commits, branches, issues, merged and open pulls, and reviews where the host's API has them.
  • No way back: writesPaused now answers for a work origin, and every write path asks it: write-through, mirror pushes, carried branches, forks, contributions, migration mirror-out and webhooks. The provider adapter also refuses any request that isn't a read. test/work-origin.test.ts walks all of them and checks each refuses.
  • Private: the copy is always private and no setting makes it public. It stays out of public pages, the changelog, Talk, search for others and crew briefs. A crew member sees it only through the existing repository crew grant on the private copy.
  • App grants: the owner grants an app a scoped read with POST /api/v1/user/origins/:id/grants and {"repo": "owner/app"}. GET lists grants and DELETE .../grants/:owner/:name withdraws one.
  • Its place: the owner's profile shows work (read-only) with the last fetch time. A failed fetch is explained in one line.
  • Docs and migration: the feature is written up in docs/features/work-origin.md. The change adds one migration, 20261109200000-work-origin, and its pin.

Not done

  • App grants: the grant is recorded and can be checked with appMayReadWork, but nothing hands a running app a token to present. Apps cannot read work data yet.
  • Full test suite: scripts/fast.ts named 2023 test files, so I ran the origin, mirror and migration tests instead.

To try it: open /settings/origins, add a token with the work box ticked, then open your profile.

The first push was blocked by the pre-push hook until a commit said how to try the change, so the branch has an empty Try: commit.

Closes #10414

3 earlier comments
commented

A work repository can now be added as a read-only origin. It is fetched on the existing ten-minute origin sync, and the forge never writes back to it. The work-origin tests, the origin, mirror and migration tests, the gate and tsc all pass, and the design lint is clean. I did not run the full suite, which the forge's check does on push.

What changed

  • Adding one: tick Work repository (read-only) under Settings → Origins → token, or send POST /api/v1/user/origins with "readOnly": true. The token is validated and sealed at rest, and it is never shown back. The fetch brings in commits, branches, issues, merged and open pulls, and reviews where the host's API has them.
  • No way back: writesPaused now answers for a work origin, and every write path asks it: write-through, mirror pushes, carried branches, forks, contributions, migration mirror-out and webhooks. The provider adapter also refuses any request that isn't a read. test/work-origin.test.ts walks all of them and checks each refuses.
  • Private: the copy is always private and no setting makes it public. It stays out of public pages, the changelog, Talk, search for others and crew briefs. A crew member sees it only through the existing repository crew grant on the private copy.
  • App grants: the owner grants an app a scoped read with POST /api/v1/user/origins/:id/grants and {"repo": "owner/app"}. GET lists grants and DELETE .../grants/:owner/:name withdraws one.
  • Its place: the owner's profile shows work (read-only) with the last fetch time. A failed fetch is explained in one line.
  • Docs and migration: the feature is written up in docs/features/work-origin.md. The change adds one migration, 20261109200000-work-origin, and its pin.

Not done

  • App grants: the grant is recorded and can be checked with appMayReadWork, but nothing hands a running app a token to present. Apps cannot read work data yet.
  • Full test suite: scripts/fast.ts named 2023 test files, so I ran the origin, mirror and migration tests instead.

To try it: open /settings/origins, add a token with the work box ticked, then open your profile.

The first push was blocked by the pre-push hook until a commit said how to try the change, so the branch has an empty Try: commit.

commented

This push only fixes the failing gate rule. It adds an empty commit whose message has a "Why now:" line. I couldn't find the rule in scripts/, so I followed the wording in the failure message. The gate passes locally with no output. I didn't run tsc or bun test, because nothing in the code changed.

The "Why now" line reads: a work repo as a read-only origin is needed so his own apps can fetch private code without write access.

The pull still adds src/actions/work_origins.ts and src/web/pages/work_origins.ts. A work repository can now be an origin that is fetch-only and private, granted to his own apps.

To try it, open /settings/origins, add a token with "Work repository (read-only)" ticked, and work (read-only) appears on your profile.

commented

I fixed three of the five failures and pushed. The other two I did not change: they passed when I reran them here, so I don't know why they failed in the check. tsc, scripts/gate.ts and the touched tests were green before the push. The forge's check on this push will show whether the other two come back.

What was wrong and what I changed:

  • OpenAPI coverage: the three grant routes under /api/v1/user/origins/{id}/grants had no OpenAPI rows. I added getApiV1UserOriginsIdGrants, postApiV1UserOriginsIdGrants and deleteApiV1UserOriginsIdGrantsOwnerName, and regenerated the routes index with bun scripts/openapi-routes.ts.
  • Seed-fill list: GET /api/v1/user/origins/:id/grants needs a connected origin, which the seed never creates. I listed it under ORIGIN in test/security-floor-routes.test.ts, as the other origin routes are.
  • Hollow audit: the appMayReadWork wrapper in src/actions/work_origins.ts was exported and called by nothing except its own test. I deleted it, and test/work-origin.test.ts now calls mayRead from src/core/origin_grants.ts directly.

Not changed:

  • Build-cart test: the a pin's cart test (test/build-cart.test.ts) passed when I reran it here, and this change doesn't touch the cart code.
  • TUI transfer test: test/tui-transfer-repo.test.ts (an admin moving a repo to an org) also passed here. The check log said it fails only beside other tests, which points to ordering rather than this change.
commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs