Skip to content

scope connection to one registry for multi-registry tenants - #262

Open
mghent wants to merge 1 commit into
dynotx:mainfrom
involvedata:registry-scoping
Open

mghent wants to merge 1 commit into
dynotx:mainfrom
involvedata:registry-scoping

Conversation

@mghent

@mghent mghent commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes #43.

Problem

Liminal assumes a tenant has one registry. On a tenant with several:

  • Schema and dropdown lists include every registry, so system names can repeat. Our tenant has six registries, and plasmid exists in two of them.
  • EntitySchemaModel.get_one returns the first schema whose warehouse name matches, so an operation on plasmid could act on a different registry inadvertently.
  • registry_id and organization_id run a bare assert len(registries) == 1. It fires inside execute when a revision creates a dropdown or schema, after earlier operations in the revision have already run.

Change

BenchlingConnection gets an optional registry_id, resolved with GET /api/v3/registry/{id}. When it is set:

  • list_entity_schemas and list_dropdowns keep only that registry's records. Results schemas are filtered by the registry's owning organization.
  • registry_id and organization_id return that registry and its owner, so new schemas and dropdowns are created there.
  • liminal_remote needs no change. It is found through the filtered list and created with the registry's organization, so each registry gets its own revision history.

When registry_id is not set:

Tenant Behaviour
One registry Unchanged
Several registries, lookup with one match Unchanged
Several registries, lookup with several matches Raises AmbiguousRegistryError (a ValueError)
Several registries, creating a schema or dropdown Fails in validate(), before any operation runs

The asserts are replaced with ValueErrors that give the registry count and say to set registry_id.

The new helpers on BenchlingService are private. The only new public names are registry_id and AmbiguousRegistryError.

The registry is set by ID rather than name. Registry names are case sensitive but shown in capitals in the UI, so names are easy to get wrong. A connection is already per tenant, so a per-tenant ID fits there, and the registry never appears in model or revision files.

Testing

  • liminal/tests/test_registry_scoping.py covers registry resolution, list filtering, ambiguous lookups, create validation, and the unchanged single-registry path.
  • Live, read-only, against a tenant with six registries: scoped lists returned only the chosen registry's schemas and dropdowns, an unknown registry_id returned a clear 404 error, an unscoped plasmid lookup raised AmbiguousRegistryError, and generate-files followed by diff returned no operations for two registries.
  • Live writes, scoped to one registry of that tenant: a dropdown and a custom entity schema were created and read back in the chosen registry and its organization, liminal_remote was created there and its revision read back, and all three were archived afterwards. Unscoped creates of a dropdown and a schema both failed in validate() with no request sent.
  • The App needs registry admin rights on the target registry. Organization ADMIN alone returns "You do not have permission to update registry settings for this organization".

🤖 Generated with Claude Code

@mghent
mghent requested a review from ndamania00 as a code owner October 22, 2026 11:51
Adds an optional registry_id to BenchlingConnection, resolved through
GET /api/v3/registry/{id}. When set, entity schemas and dropdowns are
filtered to that registry, and results schemas to its owning
organization.

On a tenant with several registries and no registry_id, lookups that
match objects in more than one registry raise AmbiguousRegistryError,
and creating a schema or dropdown fails during validation. registry_id
and organization_id raise a clear error in place of a bare assert.

Single-registry tenants without registry_id behave as before.

Closes dynotx#43

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ndamania00

Copy link
Copy Markdown
Collaborator

Thanks for this! Let me know your thoughts on this follow up PR #274 and if you're able to manually!

This branch has not been deployed

No deployments
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.

pass in registry id if more than one

2 participants