Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 86b51c772e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| user: viewer.user, | ||
| company: { id: company.id, handle: company.handle, name: company.name }, | ||
| admin: !guest && viewer.role === "admin", | ||
| guest |
There was a problem hiding this comment.
Synchronize the documented access contract with guest admission
With cross-company guests now admitted, docs/product.md:750 still explicitly says that named outsiders cannot access private patches, while the runtime description in packages/api/src/api.ts (and its generated docs/API.md) still documents me() without guest or the distinction between the viewer's home company and the patch company. This leaves the authoritative access and identity contracts contradicting production behavior, particularly for agents building patches from those docs. Update the product contract and API description, then regenerate the API documentation, as required by the AGENTS.md wire-contract and product-shape rules.
AGENTS.md reference: AGENTS.md:L73-L76
Useful? React with 👍 / 👎.
…mpany (#1108) ## What changed A private patch could only be opened by its own company. Now a company can grant one patch to someone who already has a Patchy account at another company. That **guest** opens the patch's current version as themselves, inside the patch's company, never as its admin, and reads and writes the patch's own tables and files as a colleague does. Revoking ends the grant but keeps its record, and sharing again restores it. Going public and retiring keep grants; permanent reclamation removes them. This is the first of six stacked PRs. There is no way to share yet: the share dialog and CLI arrive later in the stack, so the tests grant through the domain service. Closes #1077 ## Look at - **One extra case at both browser doors.** `GrantedGuests.viewerOf` in `packages/runtime/src/GrantedGuests.ts` is the only place someone from another company becomes a viewer, as `{ user, company: <patch's company>, admin: false, guest: true }`. - The call door (`RuntimeProduction`) and the live-query door (`StreamAdmission`) both use it, and `reauthorize`/`recheck` ask it again. - The patches adapter marks a loaded version `admitsGuests`, so admission never reloads the patch. A non-member costs one indexed grant lookup. - A guest's recheck follows the patch's current version, so their stream survives a publish the way a member's does. - **Eligibility is one function.** - `GuestGrants.unavailable(patch, version)` returns a typed `Reason`: `Retired`, `Deleted` or `Tier { tier }`. Today only tier 1 is eligible; tier 2 arrives with its handler gate. - `admitsGuests` adds "current version". The serving door and the loaded version both use it. - **Wire.** - `RuntimeMe` and the worker `viewer` gain `guest` as an optional `true`. Members' `me()` and the worker payload are unchanged byte for byte, and older stored bundles never see the key. - The SDK's `Me` type gains `guest?: true`. - **Stream control signs in before reading anything about the patch.** Documents are now keyed by patch id and document id; patch ids are global, so the company prefix was redundant. That lets control find a guest's document without loading the patch. - **Guest names in every log reader.** The portal log and its person filter, `patchy logs` and a connection's recent calls now resolve actors through `Users.names(ids)`. ``` ✓ apps/server/src/Guests.test.ts > a patch's guest > uses the patch's own table until the grant ends, and again once shared again ✓ apps/server/src/Guests.test.ts > a patch's guest > keeps a guest's live stream through a publish, as a member's ✓ packages/patches/src/GuestGrants.test.ts (3 tests) ✓ packages/patches/src/PatchesApi.test.ts > names a guest from another company who called the patch ✓ packages/portal/src/PortalPages.test.ts > names a guest from another company in the log, its filter and the card ✓ packages/integrations/src/ConnectionPages.test.ts > names a patch's guest from another company in recent calls ``` ## How it was verified - **The journey, over the whole server.** - A person at a second company gets a 404, and is granted. - They open the page and see `me()` with `guest: true`, `admin: false` and the host company. They insert into and list the patch's own table. - After a revoke they get a 404 and `access_denied`. After being shared again, they're back with their row. - The patch goes public and back, and they still read the table. - A second test opens a guest's live stream and publishes a new version: the stream gets `served` for the new version, not `access_denied`. - The three log-reader tests resolve a guest from another company. Without this change, each shows the raw id. - **Existing suites over the changed doors pass:** - Runtime: stream, production, API, admission, events. - Serving pages, portal, connection pages, PatchesApi, primitives files. - Server, stream lifecycle, members and migrations. - `pnpm check`: format, lint, typecheck and synth pass. - The offline tests had 20 failures, all in `packages/patchy` CLI stub-server suites and `packages/execution` (`LocalTaskProvider`, `Supervisor`). The CLI and `LocalTaskProvider` failures are a stray `GET /` reaching local stub servers from the dev machine, and a rerun failed a different set. - A clean `origin/main` checkout fails the same `Supervisor` test and a CLI stub test on this machine. CI is the judge here. - `pnpm verify`: format, lint, typecheck, synth, postgres-concurrency, cli-smoke, install and tier2-smoke pass. `test` failed 14 CLI stub-server tests and `LocalTaskProvider`, all on the same stray `GET /`. `browser` stopped at its first failure, a stray `/` on the test's foreign-origin server; a rerun of `pnpm test:browser` passed all 74. - **Not checked:** a guest in a real browser shell. The dev guest mount and the two-company scenario come with tier 2 later in the stack. ## Release impact Tick exactly one. - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required The change is additive: one new table, and a wire key only guests carry. Members see no difference. - **What does a revert leave behind?** The `patch_guest_grants` table, any grants written, and migration `0031` in the ledger. - **Does the release before it still work with that?** It starts, since the migrator accepts ledger ids above its own record, but it ignores grants: every guest loses access. The whole guest stack ships as one deploy and later PRs add a descriptor field older releases refuse, so this is **one-way: fix forward**. Built by Claude Opus 5.5 in Claude Code (T3 Code), rebuilding Srikar Voleti's original guest stack (#1082–#1103). Co-authored-by: Srikar Voleti <[email protected]> --------- Co-authored-by: Srikar Voleti <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
## What changed Guests could open tier 1 patches only: a tier 2 patch has handlers, and without a way to choose which ones a guest may run, letting a guest in would have let them run all of them. Now a builder marks the handlers guests may start with `guest: true`. A guest of a tier 2 patch starts those and no others, queries, mutations, actions and live queries alike. A tier 2 patch that reads another patch's shared table or store stays closed to guests. This is the second of six stacked PRs. Sharing still has no surface (that's PR 5), so the tests grant through the domain service. Closes #1079 ## Look at - **One gate, where every entry passes.** `Invocation.call` refuses a guest's top-level call to an unmarked handler, next to the agent-tool rule (`packages/runtime/src/Invocation.ts`). Browser calls, live-query reruns and agent calls all enter there; `ctx.run` inside a marked handler follows the usual rules. The mark travels from the SDK builders through the descriptor schema, the strict loader, inspection and publish's `sameHandlers`. Agent tools drop it, since they're for agents only. - **`reauthorize` now lives on the `Binding`, and it's required.** It replaces the separate parameter on `Invocation.call`, `InvocationCapabilities.Issue` and the optional field on `SubscriptionReads.Input`. Every door that builds a binding says how to ask about its viewer again. Attio's and Pidgeon's post-wait rechecks are now one helper, `viewerRecheck(binding)` in `packages/integrations/src/definition.ts`, instead of a `Directory` lookup that would have refused every guest. Most of the line count is tests building a binding with the new field. - **Eligibility.** `GuestGrants.unavailable` admits tier 2 and gains `SharedSource { kind: "table" | "store", alias }`. The member directory doesn't count against a patch. - **The member wire is unchanged.** The worker's `viewer` carries `guest` only for a guest, so bundles stored before guests keep serving members: ``` ✓ packages/runtime/src/Invocation.test.ts > Invocation > sends a member's viewer to the worker as it did before guests ``` - **The dev loop.** - `patchy dev` returns a `guestUrl`: the patch's guest from another company, with `guest: true` and no `/~dev/agent` door. - `pnpm dev up guests` seeds Harbor Works plus Jo at Pine Studio, with Site notes (tier 1) and Visit log (tier 2). Visit log has marked `list`/`create` and an unmarked `clear`. - Scenarios gain `companies` and a person's `company`. - When workerd can't start during inspection, the CLI says so and suggests `pnpm install`, keeping `invalid_manifest`. ## How it was verified The two-company journey over the whole server, with real workerd. Both tests fail with the gate removed: ``` ✓ apps/server/src/Guests.test.ts > a tier 2 patch's guest > starts only the handlers marked for guests, until the grant ends ✓ apps/server/src/Guests.test.ts > a tier 2 patch's guest > subscribes live only to the queries marked for guests ✓ packages/patchy/src/devServer.test.ts > (guest mount: guest `me`, and the agent door 404s) ``` - **The journey.** A guest's marked mutation runs as them (`by: <their id>`, the patch's company, `guest: true`) and the marked query lists the row. The unmarked query is `access_denied`. After a soft revoke, the marked query is `access_denied` too. - **The live-query test.** A marked live query answers a snapshot, and an unmarked one answers an `access_denied` error frame. - **`pnpm dev up guests`** on a local instance published both patches through the real CLI, so `guest: true` survived the build, inspection and publish. In Visit log's `patchy dev`: - The Guest URL's `me` is Dev Guest in Harbor Works with `guest: true`. - `notes.create` and `notes.list` work, signed "Dev Guest", and `notes.clear` is `access_denied`. - `/~dev/agent` answers 404, and the colleague's `notes.clear` works. The environment was taken down afterwards. - **Focused suites pass:** descriptor round-trip and `guest: false` refusal, SDK agent-area fold, inspection, eligibility, invocation, Attio and Pidgeon operations (the queued-caller recheck now uses the door's check), scenarios. - **`pnpm check`:** format, lint, typecheck and synth pass. - The offline tests fail only CLI stub-server suites (`cliPublish`, `cliLook`, `cliLifecycle`, `cliRepo`, `cli`), `LocalTaskProvider` and `RequestEvents`. All of them come from stray `GET /` requests reaching local test servers on this machine, and the set changes between runs. - `RequestEvents` and `PatchesApi` (a 5 s timeout under load) pass when rerun alone. - `pnpm verify`: format, lint, typecheck, synth, postgres-concurrency, cli-smoke, install and tier2-smoke pass. - `test` failed the same stray-`GET /` CLI suites and `Supervisor`, which fails on clean `main` here too. - `browser` stopped at `tier1.spec.ts` "hostile navigation…", where a stray `/` reached its foreign-origin server. A rerun of `pnpm test:browser` hit the same thing. CI's `browser` job passed on this commit. - **CI on `3a425bd`:** every required suite passed, `test` on Node 22/24/26 and `browser` included. - `rollback-rehearsal` can't run while Deploy run #30 waits for approval. - `attio-live` failed one live read on an `AttioUnavailable` 503 from Attio, with the other 8 passing. It's rerunning. - **Not checked:** a guest in a real browser shell against the instance, since sharing has no surface until PR 5. ## Release impact Tick exactly one. - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required New descriptor field and a new reason; members see no difference, and `patchy dev --json` only gains `guestUrl`. - **What does a revert leave behind?** Published tier 2 versions whose descriptors carry `guest: true`, and grants on tier 2 patches. - **Does the release before it still work with that?** No. Its descriptor schema refuses `guest: true`, so it can't load those versions. This is **one-way: fix forward**, and the whole guest stack ships as one deploy. Built by Claude Opus 5.5 in Claude Code (T3 Code), rebuilding Srikar Voleti's original guest stack (#1082–#1103). Co-authored-by: Srikar Voleti <[email protected]> Co-authored-by: Srikar Voleti <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
## What changed Admins had no way to keep a sensitive connection away from a patch's guests. A connection's page now has **Block guests**: only admins can use it, and members see whether it's on. While it's on, any patch whose current version declares that connection turns its guests away from their next call. Their grants stay, so they're back once the block is off or the patch stops declaring the connection. Members are unaffected. The owner and admins see why on the patch's card and in Needs attention. A publish that turns guests away still succeeds, and its `warnings` say why. Warnings only appear for a patch with active grants. This is the third of six stacked PRs. Sharing has no surface until PR 5, so the tests and screenshots write grants directly. Closes #1078 ## Look at - **One rule, one wording.** `GuestGrants.unavailable(patch, version, blocked)` gains `ConnectionBlocked { integration, handle }`. `GuestGrants.describe` is the only place a reason becomes words, and the card, Needs attention and publish all use it. - **Who pays for the block read.** - `ConnectionStore.blockingGuests(ids)` reads any number of connections' flags in one query, so `patches` never reads the `connections` table. - Only a grant holder's admission reads the flags. `GuestGrants.host` takes the version the door already holds and reads the grant, with the patch's state and current version, in one query. It goes on to the flags only when a grant is found. - Members' calls do no new reads. `LoadedVersion.admitsGuests` is gone: the runtime port asks `host(loaded, userId)` for anyone outside the company and fails with `SourceUnavailable`. - **Warnings without an N+1.** - `unavailableToGuests(companyId)` makes one query for the company's live, company-only patches with active grants and their current declarations, plus one block read. Only an owner's or admin's pages run it. - Publish uses `unavailableAfterPublish`. It's silent for a new patch, a patch without grants, or one going public. - **The control** follows the connection page's existing post buttons. Everyone sees a **Guests: Allowed / Blocked** fact. Admins also get **Block guests** or **Allow guests**, and a member's POST answers 403. ### Screenshots These follow `pnpm dev compare`'s method: full page at 1280 and 390 px, scale 2, signed in as Allison (admin) on two fresh `attio` instances, base `9f487c1` and head `27e0a14`. Compare itself can't reach this state, because the connection page is addressed by a per-instance id and the grant needs sharing (PR 5). So both sides first got the same state: a guest from Pine Studio with a grant on Deal desk, written directly. On head, `attio/crm` was then blocked through the page's own POST. **Connection page**, desktop. Head shows **Guests: Blocked** and **Allow guests**.  <details><summary>Before</summary>  </details> | Before, phone | After, phone | | --- | --- | |  |  | **Deal desk's card**, desktop.  <details><summary>Before</summary>  </details> | Before, phone | After, phone | | --- | --- | |  |  | **Needs attention**, desktop.  <details><summary>Before</summary>  </details> ## How it was verified New focused tests: ``` ✓ apps/server/src/Guests.test.ts > a tier 2 patch's guest > turns guests away while a connection the patch uses blocks them, and lets them back after ✓ packages/integrations/src/ConnectionPages.test.ts > company connection pages > lets only an admin block guests from a connection, and shows everyone which ✓ packages/portal/src/PortalPages.test.ts > warns its owner when a patch with guests uses a connection that blocks them ✓ packages/patches/src/PatchesApi.test.ts > Postgres declaration publishing > publishes a version its guests can't open, and says why only when it has guests ✓ packages/patches/src/GuestGrants.test.ts > turns guests away from a version using a connection that blocks them, and only then ``` - **The server journey** runs over the whole server with real workerd: - A guest's call to a marked handler of a tier 2 patch that declares a connection succeeds. - The admin then posts Block guests on the connection's page. The guest's next call is `access_denied`, while the admin's own call still answers. - After Allow guests, the same guest is back without being shared again. - **The publish test** checks that a publish to a patch with no guests carries no guest warning. With a guest it's still a `PublishUpdated` success, and its `warnings` hold `GuestGrants.warning(ConnectionBlocked …)`. The CLI exits 0 on a successful publish whatever its warnings say (ADR-0004). - **The migration test** now reads the connections-per-integration upgrade with today's store on today's schema. A connection made before this column reads `blockGuests: false`. - **Full suites pass** for `integrations`, `runtime`, `serving`, `patches`, `portal`, `primitives`, `mcp` and `apps/server`. - **`pnpm check`:** format, lint, typecheck and synth pass. - The offline tests fail only suites this PR doesn't touch: `cliPublish`, `cliLook`, `cliLifecycle`, `cli`, `Engine` and `RequestEvents`. They come from stray `GET /` requests reaching local test servers on this machine. - `RequestEvents` and `Engine` pass when rerun alone. - **`pnpm verify`:** postgres-concurrency, cli-smoke, install and tier2-smoke pass. - `test` failed the same stray-request CLI suites, plus `LocalTaskProvider`, a `Supervisor` timeout and `RequestEvents`, none of which this PR touches. - `browser` stopped at `tier1.spec.ts` "hostile navigation…", where a stray `/` reached its foreign-origin server, as on PR 2. - **`docs/API.md`** is unchanged: the wire doesn't change, and `blockGuests` stays off the public connections API because nothing reads it there. ## Release impact Tick exactly one. - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required The migration adds a column whose default allows guests, so every existing connection behaves as before. - **What does a revert leave behind?** The `block_guests` column (`0032_connections_block_guests`) and any blocks admins have set. - **Does the release before it still work with that?** It runs, since it never reads the column. But it would let guests back into patches whose connections an admin blocked, and the rest of the guest stack is one-way. **One-way: fix forward**, with the whole stack shipping as one deploy. Built by Claude Opus 5.5 in Claude Code (T3 Code), rebuilding Srikar Voleti's original guest stack (#1082–#1103). Co-authored-by: Srikar Voleti <[email protected]> --------- Co-authored-by: Srikar Voleti <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
## What changed A guest couldn't be the person in a `t.member()` column. Assigning them was refused, pickers never offered them and resolution returned null, so a patch like Kudos needed a text-column workaround. Now a patch's member columns and pickers take anyone who can open it: the company's members plus the patch's active guests. Resolution covers anyone holding one of the company's grants, active or ended, so another patch reading a shared table resolves them too. A guest carries `guest: true`, is never `admin`, and shows `active: false` once their grant is revoked or their account is deactivated. Rows keep their name, and sharing again makes them active. Grant changes advance the company's directory revision, so live pickers update. Kudos goes back to member columns. The handlers its page needs are marked `guest: true`, and its people handlers return only what the page shows. Taylor of Cedar Works joins the brightline scenario as the guest to be; the share step comes with PR 5's `patchy share`. This is the fourth of six stacked PRs. Sharing has no surface until PR 5, so the tests write grants through `GuestGrants`. Closes #1101 ## Look at - **`guest` is present only on guests, not `guest: boolean` on everyone.** This deviates from the plan. The host decodes handler results strictly. A required key on every member broke brightline's Spend immediately: its `requests.list` returns members through `t.object({ id, name, email, admin, active })`. It would break every published tier 2 version that does the same. With `guest?: true` (wire, `Directory.Member` and the SDK's `Member`), members are byte-identical to before, the same choice PR 1 made for `me().guest`. A result schema that passes members through whole fails only once it returns a guest, and the members skill states that fact. - **Companies never reads grants.** `Directory` takes a `Scope { companyId, guests: Map<userId, active> }` as plain data. The server's `MemberDirectory` adapter, which already bridged companies and primitives, fills it from Patches' `GuestGrants`: - pickers and assignment checks use `guests(patchId)`, so they're per patch; - resolution uses the new `holders(companyId, ids)`, so it's company-wide. - `memberOf(scope, row)` is the one rule: a guest is never admin, and is active only while both their account and a grant are. - **Live updates use the existing mechanism.** Migration `0033_guest_grants_directory` adds a trigger on `patch_guest_grants` that bumps `companies_directory` and notifies `members:<company>`, as the users trigger does. It fires when a grant starts, ends, restarts or goes with its patch. Re-sharing an active grant changes nothing, so it doesn't fire. - **Members pay almost nothing.** Each directory read adds one indexed grants read. With no guests, the users query keeps its old plan, because `sql.in` over an empty list renders `1=0`, which Postgres folds away. ### Kudos, with Taylor of Cedar Works shared on it These come from a local `pnpm dev up brightline` with Taylor's grant written directly, driven in Chromium. Taylor, the guest, thanked Priya through the guest-marked `give`. Every name on the wall resolves for them.  <details><summary>Allison's picker offers Taylor, marked Guest</summary> The picker no longer shows emails, because its handler doesn't return them.  </details> No before shots: Kudos is a scenario patch, and on the base every call Taylor made was refused. ## How it was verified New focused tests: ``` ✓ apps/server/src/Guests.test.ts > a tier 2 patch's guest > can be the person in a member column while their grant stands ✓ apps/server/src/Guests.test.ts > a tier 2 patch's guest > is resolved by another of the company's patches, through the table it shares ✓ apps/server/src/Guests.test.ts > a tier 2 patch's guest > joins and leaves a member's live picker as the grant starts and ends ✓ packages/companies/src/Directory.test.ts > company directory > offers and checks a scope's active guests, and resolves every guest in it ✓ packages/patchy/src/devMembers.test.ts > lists the local person, the colleague and the guest by name, searched by name or email prefix ``` - **The member-column journey** runs over the whole server with real workerd: - A guest claims a task through a marked mutation, and a member assigns them another. - The patch's picker lists and searches them with `guest: true` and `admin: false`. Gina is her own company's admin, which makes `admin: false` meaningful. Another patch's picker doesn't offer them. - After a revoke they resolve `active: false`, and assigning them is `invalid_row`. - After sharing again they're active and assignable. - **The shared-table test** publishes a second patch that reads the first's tasks and resolves its owners with `getMany`. - **The live test** subscribes a member to the picker query. The guest appears on grant and disappears on revoke. With the trigger disabled it times out, so it tests the trigger. - **Focused suites:** - `companies` Directory, all of `primitives`, `sdk` and `devMembers` pass. - So do these `apps/server` suites: Guests, Members, StreamLifecycle and migrations. Also `GuestGrants` and the scenario loader: 143 tests. - **Brightline:** `pnpm dev up brightline` builds and loads all three tier 2 patches. Kudos' generated repo passes its own `pnpm typecheck` and `pnpm lint`. - **`pnpm check`:** format, lint, typecheck and synth pass. - The offline tests fail only the suites that record stray `GET /` requests from this machine: `cliPublish`, `cliLifecycle`, `cliLook`, `cliRepo`, `cliRepoRecovery`, `RequestEvents` and `LocalTaskProvider`. Their logs show `{ method: 'GET', url: '/' }`. - `RequestEvents`, `LocalTaskProvider` and `devExecution` pass when rerun alone. - **`pnpm verify`:** format, lint, typecheck, synth, postgres-concurrency, cli-smoke, install and browser pass. - `tier2-smoke` failed first on this PR: the packed e2e expected the dev directory's two candidates, and the dev guest makes three. Its expectation is updated, and it passes rerun alone. - `test` failed only the stray-request suites above, plus `cli.test` and `LocalTaskProvider`. - **After rebasing onto PR 3's `b27c9bb`:** typecheck and lint pass, and the guest, directory, primitives, serving and migration suites pass (165 tests). - **`docs/API.md`** is unchanged: `render-docs` produced no diff. ## Release impact Tick exactly one. - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required Members read exactly as before, since only guests carry `guest`. The migration adds a trigger and no columns. - **What does a revert leave behind?** The `patch_guest_grants_directory_changed` trigger (`0033_guest_grants_directory`). Rows written while it ran may hold guests' ids in member columns. - **Does the release before it still work with that?** It runs, since it never writes grants, so the trigger never fires. But it would resolve those guests as null and refuse them again, and the rest of the guest stack is one-way. **One-way: fix forward**, with the whole stack shipping as one deploy. Built by Claude Opus 5.5 in Claude Code (T3 Code), rebuilding Srikar Voleti's original guest stack (#1082–#1103). Co-authored-by: Srikar Voleti <[email protected]> --------- Co-authored-by: Srikar Voleti <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
## What changed There was no way to share a patch with someone at another company: grants existed, but nothing wrote them. Now **Share…** in a patch's three-dots menu, on All patches rows, Home and the patch's own card, opens the Share dialog over the page. The owner or an admin adds a guest by email, sees and removes guests, and picks who can open the patch. The guest is in at once and finds it under **Shared with you** on their Home, where they can open it or remove it. Owners' agents do the same with `patchy share --add`, `--remove` and `--list`. This is the fifth of six stacked PRs, on #1113. Closes #1080 ## Look at The flow, on PR 4's head (left, which has no Share…) and this PR's (right): https://github.com/user-attachments/assets/4906327c-0de8-46a3-8000-8e502a33ca74 <details><summary>How to read the film</summary> As Allison, brightline's admin, on All patches: the kickoff brief's menu, then Share…. An email with no Patchy account is refused under the field; Taylor, at Cedar Works, is added. Picking Anyone on the internet asks in the dialog, and Make public applies it. </details> **The dialog, desktop.** It reuses the Final step's modal panel, and on a phone it's a bottom sheet. | Opened | Refused | With a guest, tier 2 | | --- | --- | --- | |  |  |  | | Going public | Public | | --- | --- | |  |  | **Phones.** | Menu | Refused | Going public | Public | | --- | --- | --- | --- | |  |  |  |  | <details><summary>The menu on All patches, desktop</summary>  </details> **Settings loses its sharing section.** Who can open a patch now changes in one place, the dialog. | Before | After | | --- | --- | |  |  | |  |  | **Shared with you, on Taylor's Home.** Cedar Works' own empty state and Connect your agent stay; the shelf follows them and isn't shown under search results.  <details><summary>Phone</summary>  </details> ### Decisions worth checking - **The dialog is server-drawn, with no script.** `?share=<name>` opens it over Home, All patches or a card. Each add, remove or scope change is a form post that comes back to the same page with the dialog open and its receipt inside it. A refusal re-renders that page with the dialog, the email kept and the callout under the field. Going public shows its confirmation once the radio is picked, through CSS `:has()`; Cancel is a reset button, and only Make public sends `confirm=public`. On a tier 2 patch the public choice is `disabled`, and a forged post is still `tier2_not_public`. - **Refusals are codes.** `not_on_patchy` covers both unknown and deactivated accounts, so Share never reveals another company's state. Next are `already_member` and `guests_unavailable` with `reason`. A retired or deleted patch answers `wrong_state`, through the existing owner check (`Patches.manage`, the lifecycle acts' `manageable`), never 404. - **`GuestReason` moved to `@patchy/api` and is keyed by `code`, not `_tag`.** It now rides on the wire, and wire refusals carry no `_tag`. `guestReasonText` is the one place its words come from; the CLI and the portal format from the code. - **`GuestGrants` owns the share act.** `share`, `remove` and `list` each check the actor through `Patches.manage` in one transaction, so the API and the portal can't drift. That makes `GuestGrants` depend on `Patches` and `Users`, wired in `apps/server`. `Server.layer` now exposes `GuestGrants` beside `Runtime`, so the server's guest tests use the real one. ## How it was verified New and changed tests: ``` ✓ test/browser-tier1/sharing.spec.ts › an owner shares a page from its menu, and the guest opens it from Home and removes it ✓ packages/patches/src/PatchesApi.test.ts › shares an owned patch with someone at another company, and says why it won't ✓ packages/patches/src/PatchesApi.test.ts › publishes a version its guests can't open, and says why only when it has guests ✓ packages/portal/src/PortalPages.test.ts › adds and removes guests in the Share dialog over the page it opened from ✓ packages/portal/src/PortalPages.test.ts › lists what's shared with a guest on their Home, and removes one after asking ✓ packages/portal/src/PortalPages.test.ts › asks in the Share dialog before a patch goes public, without publishing a version ✓ packages/portal/src/PortalPages.test.ts › refuses public sharing while tier 2 is served and allows it after rollback ✓ packages/patchy/src/cliPublish.test.ts › patchy share › adds, lists and removes a patch's guests, one JSON document each ✓ packages/patchy/src/cliPublish.test.ts › patchy share › keeps $code and its source when sharing is refused ✓ packages/patchy/src/cliPublish.test.ts › patchy share › rejects invalid targets, scopes or operations locally ✓ scripts/dev/src/scenario.test.ts › refuses a guest from the scenario's own company ``` - **API refusals and re-sharing:** the API test refuses an unknown email, a deactivated account, a member of the company and a non-owner, each by code. It shares, shares again unchanged, removes by email, removes again (`removed: false`), shares again with a new `grantedAt`, and gets `wrong_state` on the retired patch, which keeps its guests. The publish test adds the `guests_unavailable` refusal with `reason: { code: "connection_blocked", … }`. - **Tier 2 can't go public from the dialog:** its radio is `disabled`, there's no Make public, and both an unasked and a confirmed post answer 422. - **The scenarios:** `pnpm dev up brightline` shares Kudos with Taylor through `patchy share --add`. The environment's CLI then lists Taylor, and refuses an unknown email with exit 2. - **Rebased onto PR 4's `e5eb486`:** typecheck is clean, and the portal, `PatchesApi`, `GuestGrants` and server guest suites pass (170 tests). `docs/API.md` re-renders unchanged. - **`pnpm verify`:** format, lint, typecheck, synth, postgres-concurrency, cli-smoke, install, tier2-smoke and browser (75 specs) pass. - `test` fails only suites that record a stray `GET /` this machine's T3 app sends to local ports: the CLI stub suites, `RequestEvents` and `LocalTaskProvider`. A different test fails each run. - The two that touch sharing, `cliRepoRecovery`'s "uses the repo identity for share and delete" and `cliPublish`'s `patchy share` block, pass when rerun alone. ## Release impact Tick exactly one. - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required It adds API routes and CLI flags, and moves the portal's scope control from Settings into the Share dialog. It adds no migration and no descriptor field, so this PR on its own isn't one-way. The stack ships as one deploy and is fix-forward. - **What does a revert leave behind?** Grants made through Share, in PR 1's `patch_guest_grants`, plus agents that learned `patchy share --add`. - **Does the release before it still work with that?** Yes, with PRs 1–4 deployed: they read and admit those grants. Without Share, nothing new writes them. Built by Claude Opus 5.5 in Claude Code (T3 Code), rebuilding Srikar Voleti's original guest stack (#1082–#1103). Co-authored-by: Srikar Voleti <[email protected]> --------- Co-authored-by: Srikar Voleti <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
## What changed A company could share patches with guests one patch at a time, but nobody could see who outside the company holds which of its patches, or cut one person off everywhere at once. People now has a **Guests** tab, visible to every member once the company has guests. Each row is one person at another company with their own company, and opens to the patches shared with them, who shared each and when. Admins get **Remove from all patches…**, a confirmation page listing those patches, which ends every grant the person holds in this company and leaves their grants elsewhere alone. This is the last of six stacked PRs, on #1114. Closes #1081 ## Look at **As Ada, the admin.** The Guests tab, a row opened (`#guest-<id>` opens it), and the confirmation. Before is PR 5's head, which has no Guests tab and answers 404 for the confirmation. <!-- patchy-dev:compare:ada --> #### Before and after, as Ada Park (admin) Before is `0a524a1` (--base origin/guests/5-share-dialog) and after is `0f802ee` (guests/6-people-guests), both on the `guests` scenario, from `pnpm dev compare`. ##### `/company?show=guests` **1280px, after**  <details><summary>1280px, before</summary>  </details> | Width | Before | After | | --- | --- | --- | | 390px |  |  | ##### `/company?show=guests#guest-usr_env_pine_jo` **1280px, after**  <details><summary>1280px, before</summary>  </details> | Width | Before | After | | --- | --- | --- | | 390px |  |  | ##### `/company/guests/usr_env_pine_jo/remove` **1280px, after**  <details><summary>1280px, before</summary>  </details> | Width | Before | After | | --- | --- | --- | | 390px |  |  | - Before at 1280px answered 404; 1 browser error(s): `Failed to load resource: the server responded with a status of 404 (Not Found)`. - Before at 390px answered 404; 1 browser error(s): `Failed to load resource: the server responded with a status of 404 (Not Found)`. <!-- /patchy-dev:compare:ada --> **As Ben, a member.** The same row, without Remove. <!-- patchy-dev:compare:ben --> #### Before and after, as Ben Ortiz (member) Before is `0a524a1` (--base origin/guests/5-share-dialog) and after is `0f802ee` (guests/6-people-guests), both on the `guests` scenario, from `pnpm dev compare`. Every page answered 200 with no browser errors. ##### `/company?show=guests#guest-usr_env_pine_jo` **1280px, after**  <details><summary>1280px, before</summary>  </details> | Width | Before | After | | --- | --- | --- | | 390px |  |  | <!-- /patchy-dev:compare:ben --> ### Decisions worth checking - **Guests are People's own rows.** Guests is one more tab, and each guest is a third kind of entry in the same table, search, counts and empty state. The tab appears once the company has guests, as Invited and Deactivated do. Its table has two columns, Person and Company, so it fits a phone without scrolling. - **The shell's expandable row, not the mock's chevron.** A guest's patches open in the shell's existing `table-expand` row, a native `<details>` whose summary says "2 patches". Matching the mock's whole-row summary with a drawn chevron would have needed a component style that People's own CSS shouldn't own. People adds layout CSS only. Remove from all patches… sits inside the opened row, as in the mock. - **Companies reads grants through a port.** Companies can't depend on Patches, so `CompanyPage.Guests` (`list`, `removeAll`) is filled in `apps/server` from `GuestGrants`, as `OwnedPatches` already is. It's filled by `companyGuests`, one query decoded through a Schema class and grouped per person, and by `revokeAll`, one `UPDATE` that sets `revoked_at` for that person in that company. - **Ended grants:** someone whose grants here have all ended isn't listed at all. The records stay, so member columns still name them, inactive, and sharing again brings them back. Retired and deleted patches' active grants are listed, marked with a pill, because restoring the patch would let the guest back in, and remove-all ends those grants too. Disabled patches' grants are listed too, marked Unavailable, so they can still be removed. - **A deactivated guest account isn't marked.** Showing it would reveal another company's state, which Share also avoids. - **Remove-all ends whatever they hold when it's confirmed**, including a patch shared after the confirmation page loaded. Like Share's add and remove, it sends no analytics event. - **Members** see the tab and every row, but not Remove. A member's GET of the confirmation or POST of the form re-renders People with 403 and changes nothing. ## How it was verified New tests, in `apps/server/src/Guests.test.ts` over the whole server. Gina, from another company, holds two of the dev company's patches and one of a third company's: ``` ✓ People's guests › lists each guest's patches here to every member, with Remove for admins only ✓ People's guests › removes a guest from all of this company's patches once an admin confirms ``` - **The first test:** a member's Guests tab lists Gina's two patches here, with "Shared by" the dev admin, and not the third company's patch. It has no Remove link, which the admin's tab has. The member's GET and POST of the confirmation answer 403, and all three grants are still active. - **The second test:** the admin's confirmation lists the two patches and "Remove from 2 patches". Posting it lands back on Guests without her. Both patches lose her as a guest. Her ended grant is still a record the dev company's directory resolves, `holders` → `false`. The third company's patch is still shared with her. - **The scoping is tested.** Dropping the `company_id` filter from `revokeAll` fails the second test. - **Rebased onto PR 5's `0a524a1`:** typecheck and lint are clean. The server guest suite (11), the auth `CompanyPage` suite (24) and `GuestGrants` (5) pass. - **`pnpm check`:** format, lint, typecheck and synth pass. `test` fails only in the suites that record the stray `GET /` this machine's T3 app sends to local ports: the CLI stub suites (`cliPublish`, `cliLifecycle`, `cliLook`, `cliRepoPublish`, `cli`) and execution's `LocalTaskProvider` and `Supervisor`. None of them touches People. - **`pnpm verify`:** format, lint, typecheck, synth, postgres-concurrency, cli-smoke, install and tier2-smoke pass. - `test` fails only in the same stray-`GET /` suites, plus `cliRepo`, `cliRepoRecovery` and `RequestEvents`. - `browser` stopped after its first failure, on that stray `/` in `tier1.spec.ts` "hostile navigation" (`foreignRequests` held `"/"`). 21 specs passed and 53 didn't run. No browser spec covers People. ## Release impact Tick exactly one. - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required It adds a People tab and two routes, `GET` and `POST /company/guests/<id>/remove`. It adds no migration and no API or CLI change, so this PR alone isn't one-way. The stack ships as one deploy and is fix-forward. - **What does a revert leave behind?** Grants that remove-all ended stay ended, as if each had been removed in the Share dialog. - **Does the release before it still work with that?** Yes. PR 5 reads ended grants as it always does, and sharing again restores them. Built by Claude Opus 5.5 in Claude Code (T3 Code), rebuilding Srikar Voleti's original guest stack (#1082–#1103). Co-authored-by: Srikar Voleti <[email protected]> --------- Co-authored-by: Srikar Voleti <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
What changed
Existing accounts from another company can open an eligible private tier 1 patch when a patch-specific guest grant exists. Runtime calls and streams keep the person's real user ID, use the patch's company for its own resources, and expose
guest: truewithout granting membership or unrelated access. Grants persist through temporary access changes and cascade on permanent patch reclamation.Closes #1077
Look at
guest: truewith the patch company, then getsaccess_deniedafter revocation. Focused suite: 1 passed.How it was verified
pnpm typecheck, test typecheck,oxlint, staged Prettier, andgit diff --checkpassed.pnpm verifyrun did not pass: format scanned pre-existing untracked workspace files; the browser and tier 2 failures were caused by the worker payload and are fixed above. That broad run also reported macOS-only task-provider limitations and other local failures; CI is rerunning on the fix.Release impact
The grant table and
guestviewer field are additive. Existing members and public tier 1 pages retain their behavior.patch_guest_grantstable and any grant rows remain; reverting the code stops honoring them.Model: GPT-6; harness: Codex API.