fix(core): include role in group permission equality check - #124
Merged
Conversation
permissionEqual() compared groupId/read/write for group-access permission entries but not role, so setPermissions() judged a role-only tightening (or widening) as a no-op deep-equal set and silently skipped the write. Add role to the comparison and cover the fix with regression tests. Fixes #107
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
permissionEqual()(packages/core/src/stack.ts) comparedgroupId/read/writefor group-access permission entries but never learned about therolefield added in Group roles are decorative: admin should mean "can manage the group" #58. SinceStack.setPermissions()skips the write when the new permission set is deep-equal to the current one (One versioning rule: every record mutation bumps version and snapshots full prior state (associations and permissions included) #61), a role-only tightening (addingrole: 'admin') or widening (removing it) was judged a no-op and silently never persisted, despite the call reporting success.a.role === b.roleto the group branch of the comparator so role changes are correctly detected as a diff.Test plan
role: 'admin'to an existing group entry persists and bumpsversion.role(widening admins-only → any-member) persists and bumpsversion.role) still correctly no-ops (no spurious version bump).pnpm test,pnpm typecheck,pnpm lintall pass inpackages/core.Fixes #107
Generated by Claude Code