Skip to content

Store membership gates and cross-owner reads; the #843 proof runs on store (#863) - #865

Merged
jimhoyd merged 1 commit into
mainfrom
claude/store-membership-gate
Sep 28, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/store-membership-gate

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Addresses #863 item 1 and completes the proof conversion that #835 asked for: "replace the ad hoc SQL rather than grow it". Permissions stay application data keyed by the auth user id, and auth gets no roles.

Design (docs/STORE.md: "Membership gates and cross-owner reads")

  • Membership collections. membership: true plus a key makes one record per member; key values must be valid principal ids.
    • A membership collection has no mount and no HTTP API, so nobody can add themselves or list members.
    • Operators maintain it with addMember, removeMember and listMembers, or trusted code with StoreExports.
    • Membership is one lookup on the existing unique key index. No schema migration.
  • Gated transitions. transitions.<name>.members: reviewers.
    • Check order: principal (401), then membership (403 membership_required), then the retry key, then the record.
    • A non-member gets the same 403 for existing and missing ids.
    • A removed member's retry is refused, not replayed.
    • by: others still refuses the owner, even when the owner is a member.
  • Cross-owner reads. readers: {mount, members} on an owned collection gives members read-only list and get across owners, with the existing filters, sort and cursors.
    • Membership is checked before the query is parsed.
    • Ownerless records are excluded, and the owner is never exposed.
    • Other methods get 405.
  • Activation refusals: an unknown or non-membership members, readers on a shared collection, unguarded or conflicting mounts, and incompatible options on a membership collection.

Proof conversion (proofs/private-requests)

  • Removed: app/lib/requests.mjs and all five functions, 127 lines of application server code, 0 added. The app database binding and its grant are also gone.
  • Routes: 6, down from 8. /api/me is replaced by Better Auth's get-session.
  • Security assertions: every one still passes, including owner privacy, exactly one approval winning a race, non-reviewer 403, cross-origin refusal, revoked-cookie replay, throttling, sandbox refusal, audit and MCP. Added: a non-member gets the same 403 for a missing id.
  • Statuses that now follow the store's contract: 400 instead of 422 for invalid bodies, 404 instead of 400 for a non-UUID id, 415 for POST with no body. ownerId is no longer returned.

Evidence (macOS, Node 26)

  • npm run verify passes end to end on the branch rebased onto main.
  • The agent's runs: store 120, form-records 23, test:addons 6, test:proof 12, test:package passing.
  • New membership.test.ts (6 tests):
    • member, non-member and owner on transitions and on reads;
    • the same 403 for existing and missing ids;
    • membership changes apply immediately;
    • concurrent approvals give exactly one 200, in one process and across worker-thread connections;
    • the audit actor.
  • The store package budget rises to 80/315 KiB (measured 75,895 / 308,658) because of the membership and readers code.

Follow-ups

Filed separately:

  • a urlcode-store members CLI
  • auditing membership changes
  • reassign does not rewrite membership keys
  • enum filter values are not validated
  • reviewers cannot see who made a request

🤖 Generated with Claude Code

…uns on store (#863)

A collection declared `membership: true` lists principal ids, has no HTTP
surface and is maintained by operator functions (addMember/removeMember/
listMembers) or trusted StoreExports. Transitions may require `members:`, and
an owned collection may give members a read-only `readers` mount across owners.
Principal and membership are checked before any record is read, so a non-member
gets one 403 for existing and missing ids alike.

The private-requests proof now uses store transitions and membership instead of
its own SQLite code: 127 lines of application server code removed, none added.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant