feat(org-scoping): multi-tenant seed ownership handoff to default-org admin#2031
Merged
Conversation
Multi-tenant companion to plugin-security's single-tenant claimSeedOwnership. Seeded rows land owner_id NULL; claimOrphanOrgRows back-fills organization_id but owner_id stayed NULL, so owner-keyed UX was empty for org members. - New claimOrgSeedOwnership(ql, orgId, ownerUserId): assigns owner_id to an org's NULL-owned seed rows; org-scoped, idempotent, skips managedBy/sys_*, requires both owner_id + organization_id columns. - ensureDefaultOrganization calls it after binding the admin as the default org's owner — symmetric with the single-tenant first-admin handoff. Tests: claim-org-seed-ownership suite (+5). org-scoping 20 green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 8 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The multi-tenant companion to #2021's single-tenant
claimSeedOwnership. Completes the ownership-handoff story symmetrically across both deployment modes.Gap: seeded rows land
owner_idNULL (authors leave it unset;cel\os.user.id`resolves to NULL at seed time). In multi-tenant modeclaimOrphanOrgRowsback-fills theirorganization_id, butowner_id` stayed NULL — so "My" views, owner reports and owner notifications were empty for the org's members.Change
claimOrgSeedOwnership(ql, organizationId, ownerUserId)— assignsowner_id = ownerUserIdto an org's NULL-owned seed rows. Scoped to one org (never touches another tenant), idempotent, skipsmanagedBy/sys_*, requires bothowner_idandorganization_idcolumns.ensureDefaultOrganizationcalls it after binding the platform admin as the default org'sowner, so the default org's demo data is owned by the admin out of the box.Tests
claim-org-seed-ownership.test.ts(+5): registry-unavailable, no-op without org/owner, skip managed/sys_/missing-column, org-scoped claim (other orgs + human-owned untouched), idempotent.Follow-ups (not here)
cloneOrgSeedData) could stampowner_id= the new org's creator at clone time — the default-org case (the common one) is covered here.🤖 Generated with Claude Code