oxidecomputer / oxidecomputer/console
Centralize role comparison logic
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 228
- Forks
- 22
- Avg merge
- 19h 42m
- Merged PRs (30d)
- 32
Description
roleOrder gives each role a number where lower = stronger (admin is 0). That makes direct comparisons on it read backwards: roleOrder[a] <= roleOrder[b] means "a is at least as strong as b", the opposite of what the <= looks like it's saying.
We do role strength comparison using roleOrder inline at several call sites. I don't think call sites should be doing the order comparison directly. We already have getEffectiveRole (strongest of a list); the boolean comparisons want a helper with a name clear enough that it would be hard to use backwards — roleIsAtLeast(a, b) or a compareRoles comparator.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with app/api/roles.ts at the linked roleOrder and getEffectiveRole definitions, then search the repository for inline roleOrder comparisons. Centralize those boolean comparisons behind a clearly named helper and confirm that every affected call site preserves the intended role-strength semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- authorization
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100