Status: Accepted (in force / observed constraint). Reconstructed.
Context
The ~26 admin tiers (AdminRole) each have a string name and a stable integer ID (IPRIMARY_ADMIN = 1, IHR_ADMIN = 6, IEWA_ADMIN = 157, …). The IDs are not contiguous: 1–9, then a jump to 22–31, then 157, 164–169. The gaps are not a mistake — they're the fossil record of tiers added in waves over time (core HR/payroll first, then IT/assets/performance/finance, then payments/wallet/compliance).
Decision
Treat these integer IDs as an external, append-only identifier space. New tiers take the next free int (often far from the last), and existing ids are never renumbered or reused.
Consequences
Good:
- IDs are stable references — stored role assignments, seed data, migrations, and any external system that persisted a tier id stay valid forever.
- Adding a tier is a pure append; no renumbering churn.
Bad / costs:
- The gaps look like a bug to newcomers and invite "cleanup" PRs that would corrupt existing assignments.
- The int↔name mapping isn't guessable from position; you must read
IdentityModel.cs.
Guidance
- Never renumber or reuse an ID.
- To add a tier: add both the string constant and a new int (next free value is fine — contiguity is not a goal) and wire its permission bundle.
- When persisting a tier reference, store the int ID; when displaying, resolve to the string name.
Alternatives
- Renumber to be contiguous — rejected: breaks every stored assignment and external reference.
- Drop the ints, use names only — not adopted: ints are compact, stable keys already embedded in data.
Related