Skip to content

feat(scope-access): members, invitations, profiles, files and workspaces for any membership scope - #64

Merged
yyyyaaa merged 17 commits into
mainfrom
feat/scope-access-adapter
Nov 15, 2026
Merged

yyyyaaa merged 17 commits into
mainfrom
feat/scope-access-adapter

Conversation

@yyyyaaa

@yyyyaaa yyyyaaa commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Lets an app built on any blueprint manage members, invitations, profiles and files for every membership scope its database has: the app, an organization, and entity types such as a data room. Constructive Desktop opts an app into these screens from its AppSpec; nothing here names a blueprint or a scope.

flowchart LR
  T[membershipTypes: app, org, data_room, ...] --> N[scopeNames: dataRoomMemberships, createDataRoomInvite, ...]
  N --> L[loadScopeAccess / loadScopeFiles]
  L --> P[ScopeAccessPanel / ScopeFilesPanel]
  W[WorkspaceProvider + switcher] -->|active entity| P
Loading
  • One access core for every scope (scope-access): scopeNames(scope) derives each scope's GraphQL names, so the same code reads and writes appMemberships, orgMemberships and dataRoomMemberships. Console Kit's app users adapter now delegates to it.
  • Panels (scope-panels): ScopeAccessPanel (members, invitations, profiles, capabilities, defaults) and ScopeFilesPanel (an entity's buckets and files: upload, download, delete, and "New bucket" when the entity has none) for any scope, with PendingInvites for the signed-in user across scopes (sender names read with an in filter, a new option of executeConstructiveConnectionQuery).
  • Workspaces (workspace-switcher): the personal workspace and the user's organizations, kept per user in a store a data layer can read (activeWorkspaceId('org')), with "New organization". The new organization's users-row type comes from its scope's membership type.
  • Users pack: copy names the scope ("Invite a data room member"), Viewer, Editor and Admin profile presets (offered when the scope has every capability a preset names), and no "Unverified" status for scopes without a verified flag.
  • Members lists: an entity that is a users row (an organization holds an app membership) is left off, by the scope tree's hasUsersTableEntry types.
  • Storage Browser: the footer leaves the file total out when a bucket's count is unknown, and the scope panel counts the open bucket from its files.
  • Resource Kit: a record page can carry sections below its related lists, for the panels.
Before After
Files footer: "0 files in 1 bucket" after an upload "1 file in 1 bucket"
An organization listed as an app member, "Pending approval" Left off the list
Org and data room owners: "Unverified" "Active"
A custom entity type's files: "No buckets yet. Create your first one…" with no way to create one "New bucket", then upload

Registry items: scope-access, scope-panels, workspace-switcher (new); feature-pack-users gains users-scope-noun.ts and users-profile-presets.tsx.

🤖 Generated with Claude Code

https://claude.ai/code/session_017WbsGACCtSUb8SqXaydeYJ

App access now runs on a scope-parameterized core: given a membership
scope (app, org, or an entity type such as data_room), it derives the
scope's GraphQL names, limits an entity scope's reads to one entity, and
writes the entity's id into every create. The Console Kit users adapter is
the core on the app scope. The GraphQL helpers and pure value helpers no
longer need Console Kit's runtime, so hosts without Console Kit can use
them.
UsersFeaturePack takes a noun (application by default) so the same view
serves an organization's or a data room's members.
A scope with storage capabilities offers presets built from the platform's
capability names; a preset creates its profile with the combined mask.
… scope

For apps without Console Kit: a provider that builds the runtime from the
app's endpoints and session, a members panel on any scope, the user's
pending invitations in every scope with in-app accept, a workspace switcher
(personal plus the user's organizations, with organization create), and an
entity's files with upload, download and delete through the storage
plugin's per-scope mutations.
…cher

constructive-graphql becomes its own lib item, so the scope blocks reuse the
GraphQL helpers without Console Kit; console-module-users builds on
scope-access. The files view ships with scope-panels, so App access still
installs no storage pack.
…d lists

RecordDetail renders its children under the related lists once the record
has loaded, so an app can add an entity's members and files to its page.
…ds it has

An app invitation's record names no entity, so a fixed selection with
entityId failed the whole query on the app scope. The selection now comes
from the scope's record type in the schema.
… per page

The workspace switcher, on every page of an app that has one, now reads
only rows. A members panel introspects the admin and auth schemas, a files
panel the app's, and each schema is kept for the page per endpoint and
user, so moving between pages doesn't introspect again.
…is unknown

The footer added up every bucket's count and read a missing one as 0, so a
host that knows only some counts showed "0 files in 1 bucket". When any
count is unknown, the footer now names the buckets alone.
…entity add a bucket

- Members: an organization is a users row too, so it holds an app
  membership. A member whose user type is the id of a membership type with
  hasUsersTableEntry is left off the list (membership-types.ts reads the
  admin API's membershipTypes; no type number is assumed).
- Status: org and entity memberships have no verified flag, so
  `lifecycle.verified` is optional and absent there, and those members no
  longer read as "Unverified".
- Files: the open bucket's count comes from its loaded files. An entity type
  made without buckets offers "New bucket" when the API has the scope's
  create mutation; RLS decides who may use it.
- A new organization's users-row type comes from its scope's membership
  type, not a fixed number.

Structure: the runtime, schema and target types live in scope-runtime.ts;
supportsScopeObject/supportsScopePatch and scopeMutationDocument's payload
selection in scope-names.ts serve every scope write; useScopeView loads
both panels; loadScopeAccess reads rows, then maps them in a pure step; the
users pack's noun helpers and profile presets have their own modules.
@luxor-code-review

luxor-code-review Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Review complete. 🟠 1 high · 🟡 2 medium

💬 Inline comments (3)

🧹 Nitpicks (2) — 🟢 2 low
  • 🟢 ScopeHost doc says files use storage, code uses data (scope-runtime.ts:46) — The ScopeHost.endpoints JSDoc tells hosts to pass "storage for files", but loadScopeFiles reads the data endpoint exclusively — loadScopeSchemas(runtime, ['data']) and every executeConstructiveGraphQL(runtime, 'data', ...) call in scope-files.ts (apps/blocks/src/blocks/scope-access/scope-runtime.ts:46).
  • 🟢 Profile presets silently drop missing capabilities (users-profile-presets.tsx:65) — ProfilePresets maps each preset's hard-coded capability names through the scope's catalog with idByName.get(name) ?? [], silently omitting any name the scope does not expose, while only read_files gates rendering (apps/blocks/src/blocks/feature-packs/users/users-profile-presets.tsx:65).

The change introduces a generalized scope-access block (provider, runtime, panel, store, and tests) and rewrites the Console Kit users adapter onto it, extracting GraphQL document construction into constructive-graphql and value mapping into constructive-values. The users feature pack gains a configurable scope noun, and RecordDetail and the storage browser get small contract fixes in packages/ui.

Files Change
apps/blocks/src/blocks/scope-access/* New block: capability-mask scope authorization with provider, workspace switcher, panels, loaders, and tests
apps/blocks/src/blocks/console-kit/constructive/* Users adapter refactored onto scope-access, with helpers extracted to constructive-graphql and constructive-values
apps/blocks/src/blocks/feature-packs/users/*, apps/blocks/src/lib/* Feature-pack scope noun parametrization, profile presets, and feature-pack/registry metadata updates
packages/ui/src/components/resource-kit/record-detail.tsx, packages/ui/src/components/storage/storage-browser.tsx Component contract tweaks: RecordDetail children rendering and StorageBucket.objectCount optionality
apps/blocks/registry.json Registry edges for the new scope-access, workspace-switcher, and constructive-graphql components

Reviewed commit: 36a0adc

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR refactors the Console Kit users adapter and adds a scope-access registry block with capability-mask authorization, a workspace switcher, and cross-scope pending-invite loading.

Key findings

Comment on lines +118 to +121
flushSync(() => setLoaded((current) => current && {
...current,
workspaces: orderedWorkspaces([...current.workspaces.filter((w) => w.id !== created.id), created])
}));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 bug · medium

Create during initial load stores false as loaded

The create action's flushSync updater setLoaded((current) => current && {...}) returns the boolean false — not null — when the initial list is still loading, corrupting the loaded state shape (apps/blocks/src/blocks/scope-access/workspace.tsx:118-121). Downstream, loading: loaded === null flips to false and workspaces falls back to NO_WORKSPACES, so the switcher renders an empty list until the setVersion reload re-fetches. The dialog is usable while the very first load is pending (slow backend, retry backoff), so the path is reachable in normal use.

📋 Prompt for AI Agents

In apps/blocks/src/blocks/scope-access/workspace.tsx lines 118-121, change the flushSync updater from setLoaded((current) => current && {...}) to a ternary that returns current unchanged when it is null: setLoaded((current) => current ? { ...current, workspaces: orderedWorkspaces([...current.workspaces.filter((w) => w.id !== created.id), created]) } : current), so creating an organization before the initial list loads does not store the boolean false in the loaded state.

An installed app type-checks the registry files under noImplicitAny, where
a `.catch(() => [])` or `?? []` fallback reads as an implied any.
…scope can grant in full

- Pending invitations asked for every user to name a few senders; the
  connection query now takes an `in` filter, and the lookup asks for the
  senders' ids only.
- The invite dialog names the scope with the right article ("Invite a data
  room member") and says what access it grants.
- A profile preset shows only when the scope has every capability it
  names, so an Editor never lacks write_files.
- ScopeHost's doc names `data` as the files endpoint.
@yyyyaaa

yyyyaaa commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Both nitpicks from the Tenki review summary are fixed in f4adcfb:

  • ScopeHost doc: endpoints now says data (the app API) is the files endpoint, which is the one loadScopeFiles reads.
  • Profile presets: a preset shows only when the scope has every capability it names. So an Editor profile always gets write_files, and a scope without it offers no Editor preset.

@yyyyaaa
yyyyaaa merged commit f88e5a1 into main Nov 15, 2026
6 checks passed
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