refactor(org-db): DRY the tier-column SELECT + row type (#2826)#2922
Merged
Conversation
`applyAgentVisibility` (inner-tx tier re-read from #2822) and the seat-check path in organization-db duplicated the same SQL and row shape against a pg client. A future column that `resolveMembershipTier` needs to consider had to land in three places (the resolver's input type, both SELECTs) or silently miss one. - Export `MembershipTierRow` type + `MEMBERSHIP_TIER_COLUMNS` tuple as the single source of truth for the resolver's input shape. `resolveMembershipTier` now takes the named type. - Export `readMembershipTierFromClient(client, orgId, { forUpdate? })` that runs the SELECT with the shared column list, parses the row, and returns `MembershipTier | null`. Optional `forUpdate` for callers that need to lock the `organizations` row too. - Both inline call sites (`organization-db.ts` seat check, `member-profiles.ts` applyAgentVisibility) use the helper. No behavior change. 1920 server + 631 root unit tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Closes #2826. Follow-up to #2822/#2830 — the inner-tx membership-tier read was duplicating the SQL column list and row type that `resolveMembershipTier` already documented via its function signature. A future column that the resolver's inference needed to consider would have silently missed one of the two inline SELECTs.
What changed
Test plan
No behavior change, pure DRY refactor.
🤖 Generated with Claude Code