Skip to content

feat(guests): share a private tier 1 patch with someone at another company - #1108

Merged
allisonmahmood merged 2 commits into
mainfrom
guests/1-grants-tier1
Oct 31, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
guests/1-grants-tier1

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

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
  • 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]

@allisonmahmood allisonmahmood added the one-way Rolling production back past this PR would break the release before it label Oct 30, 2026
@github-actions github-actions Bot added area:server Touches the server area area:cli Touches the cli area area:docs Touches the docs area area:primitives Patch tables and files area:integrations Company connections and integration implementations area:ui Portal and first-party browser pages, shared rendering and styles size:xl Over 1,000 changed lines; review in multiple passes labels Oct 30, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Sol review

Reviewed 57db588ddac2f3d210b737dc2fb06de4df909a55 against origin/main, the revised PR 1 brief, builder notes, and repository standards.

  1. Nit — Standards: SQL result schema convention. packages/patches/src/GuestGrants.ts:79, packages/patches/src/GuestGrants.ts:118, and packages/companies/src/Users.ts:155 introduce SqlSchema result schemas using Schema.Struct. These rows are decoded correctly, but packages/sql/README.md explicitly specifies a Schema.Class result; the inline results also put schema declarations inside make instead of above the service tag.
    Fix: Declare named Schema.Class result schemas above the service tags and reuse them in these three queries.

No blocker or should-fix findings. Spec: no findings within PR 1's scope.

  • Tier 1 only is the correct intermediate gate; tier 2 admission belongs with the handler gate in PR 2, and Block guests belongs in PR 3.
  • Omitting Disabled is safe here: serving, runtime lookup, and sharedWith exclude disabled patches before eligibility is used.
  • Removing the stream key's company prefix is safe: patch IDs are globally unique and neither key component can contain :. Registries are process-local; old replicas keep the old open/update pair, new replicas use the new pair, and requests reaching another replica already reconnect through the generation fence. No shared or persisted key needs migrating.
  • Admission/rechecks preserve member behavior, refuse deactivated users and revoked guests, restrict fresh guest admission to the current version, and let existing guest streams survive publication. Public data remains unavailable, grants survive scope changes, and members' worker payloads omit guest entirely.
  • 0031 follows main's highest migration, 0030. Soft revoke retains the row; restoration refreshes provenance; patch deletion cascades.

Validation: 253 repository tests passed, plus three additional isolated boundary probes covering old versions, deactivation, retirement/disablement, public-data refusal, revoked/deactivated open streams, and retained/restored grant rows. No tracked files changed or commits pushed. The red rollback-rehearsal job stopped because a pending deploy made the live revision uncertain; it did not reach migration execution.

Verdict: PASS with notes.

allisonmahmood and others added 2 commits October 31, 2026 16:37
…mpany

A company can now grant one patch to a person who already has a Patchy
account at another company. They open its current version as themselves in
the patch's company, never its admin, and read and write its 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;
reclamation removes them.

- patch_guest_grants (0031) and the GuestGrants domain: grant, soft revoke,
  a patch's guests, a guest's shares, and the one eligibility function with
  its typed Reason.
- Runtime's call and stream doors gain the guest case through the
  GrantedGuests port; a guest's recheck follows the current version.
- RuntimeMe and the worker viewer carry guest only when true.
- The serving door admits a granted guest to the current version.
- The portal log, patchy logs and a connection's recent calls name guests.

Co-authored-by: Srikar Voleti <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The revoke, host and names queries decode into named Schema.Class rows
declared above their service tags, as the SQL guide asks.

Co-authored-by: Srikar Voleti <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked 75b60f90e224878daffea7226d639e1089c5a81f (base 54438fa3303fe8867867f0a9b260536a033da0f6) on fresh brightline instances, by gpt-6.1-sol in Codex (T3 Code).

Done means

  • Granted cross-company tier 1 access: passed. Published the Notes starter twice. Jo Park of Pine Studio got 404 before the grant, then 200 with private, no-store; me() returned Jo, Brightline Studio, guest: true, admin: false. In Chromium Jo added “Pine visit: kiln room measured”; Allison read it and replied. Jo could reopen and read both notes.
  • Boundaries: passed. Jo got current /~v/2 200 and historical /~v/1 404; Allison got historical 200. An unrelated patch and a granted tier 2 patch returned 404. Home-account deactivation returned 403; reactivation restored 200.
  • Revoke and restore: passed. Revoking while the page was open refused the next write with access_denied and displayed “You no longer have access”. The write did not land. Regrant and reopening the patch restored its data; the ended grant row was retained.
  • Public/private and temporary lifecycle changes: passed. Anonymous access changed 200 → 401 when made private again. Jo's grant survived both changes and retire/restore (404 → 200). Permanent reclamation's cascade was checked in the migration, not exercised live.

Golden journeys

  • Sign in and share/unshare: passed; anonymous company access had the 401 sign-in door, signed-in access returned 200, public/private switches retained the expected boundaries.
  • Publish: passed; Notes v1 and v2 were built and published with the isolated environment CLI.
  • Live tools: passed in Chromium. Jordan's new Kudos appeared on Priya's open wall. Jordan moved Saltwater Hotels Lead → Discovery → Lead, and Allison's open board followed both moves. No page errors.
  • Spend: passed. Jordan's attempt to approve his own submitted request returned source: "handler", code: "own_approval", “You can't approve your own request.”
  • Main's source-retrieval boundary: passed. A machine credential for Jo could neither pull field-notes nor list field-notes: both returned kind: "rejected", “Patch not found.” No host source was downloaded.

Evidence

Focused suites: Guests, GuestGrants, PatchesApi, RuntimeProduction,
RuntimeStream, PortalPages, ConnectionPages, Pages
Test Files  8 passed (8)
Tests       246 passed (246)

Rollback answers: match the diff. Migration 0031, grants and ledger remain; an older release ignores guest access. The one-way label is present.

Not run

  • CI and rollback rehearsal were still pending when checked; pending checks are not passes. No production endpoints were contacted.
  • Permanent reclamation live, real Clerk sign-in/mail, and a guest browser stream through publish. The latter is covered by the passing server test.
  • Guest-attributed tier 2 logs are not available at this intermediate tier 1 head; later PRs enable them. Connection log naming passed in its focused suite.

Notes

  • The local instance and browser contexts were shut down. No source, PR body, branch or labels were changed.

@allisonmahmood
allisonmahmood merged commit 768b69c into main Oct 31, 2026
36 of 39 checks passed
@allisonmahmood
allisonmahmood deleted the guests/1-grants-tier1 branch October 31, 2026 17:07
allisonmahmood added a commit that referenced this pull request Oct 31, 2026
## What changed

This adds release 31's What's new entry, written from `5888411`. It
covers everything merged since release 30's `through` (`e3d50f0`). It
also sets the `patchy` release to `0.31.0` in
`packages/patchy/package.json` and `CURRENT_RELEASE`.

| Change | PRs |
| --- | --- |
| New: share a patch with someone at another company from Share… in its
menu. They open it as themselves, find it under Shared with you, can be
picked wherever the patch asks for a person, and on a server-code patch
reach only what its builder opened to guests. The company-or-internet
choice moved into the same dialog, and agents can share too | #1108,
#1110, #1113, #1114 |
| New: People has a Guests tab, with each guest's patches, and admins
can remove a guest from all of them at once | #1115 |
| New: admins can block guests from a connection, and owners see why on
the patch's card | #1112 |

#1118 is release 30's own entry.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`. The four PRs that make sharing work are
one change, since nobody can share before Share… exists.
- **Rollback safety, from the live commit `54438fa` (release 30) to
`5888411`:** the same six PRs. #1108, #1110, #1112 and #1113 are
labelled `one-way`, and their answers agree:
- #1108 adds `patch_guest_grants` (migration `0031`). Release 30 starts
with it but ignores grants, so every guest loses access.
- #1110 adds the `guest: true` handler mark to tier 2 descriptors.
Release 30's schema refuses it, so it can't load tier 2 versions
published with it.
- #1112 adds `block_guests` (`0032`), and #1113 adds a directory trigger
(`0033`). Release 30 runs with both but would ignore admins' blocks and
resolve guests picked in member columns as nobody.
  - #1114 and #1115 add no migration or descriptor field.

**Rollback line:** Rolling back past #1110 would leave tier 2 versions
published with handlers marked for guests unloadable, because release
30's descriptor schema refuses `guest: true`, and past #1108 would cut
every guest off; fix forward instead.

## How it was verified

- **Tests.** `whatsNew.test.ts`, `schemas.test.ts` and
`WhatsNewPages.test.ts` pass (21 tests), and prettier passes on the
changed files.
- **The range.** Each of the six PRs was reviewed by GPT 6.1 Sol with
every finding resolved, and got a fresh acceptance PASS with notes at
its rebased head. Each landed with all 12 required checks green,
`rollback-rehearsal` included, and its squash tree matched the accepted
head.
- **Deploy state.** The live commit, pinned from `/healthz/deep`, is
`54438fa` (release 30). The Deploy run updated last succeeded, and none
is unfinished.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

Text and version numbers only. The `0.31.0` bump tells CLIs and patch
repos installed before this deploy to upgrade, as every release does.

- **What does a revert leave behind?** Nothing.
- **Does the release before it still work with that?** Yes.

Built by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, through T3
Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli Touches the cli area area:docs Touches the docs area area:integrations Company connections and integration implementations area:primitives Patch tables and files area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles one-way Rolling production back past this PR would break the release before it size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(guests): admit existing accounts to private tier 1 patches

1 participant