Add component-based permission system for app data#3413
Add component-based permission system for app data#3413tylerhawkes wants to merge 1 commit intomainfrom
Conversation
How to use the Graphite Merge QueueAdd the label mergequeue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Claude finished @tylerhawkes's task —— View job Code Review CompleteReview Date: 2026-04-10 00:22 UTC Overall AssessmentThis is a well-architected permission system with strong defensive programming practices. The code quality is high, test coverage is good (96.25%), and the implementation follows Rust best practices. I've identified a few areas for consideration below. Security & Design1.
Consider: Document the upgrade strategy for when IDs need to exceed u16 (perhaps in a migration guide). 2. Empty combinator policies are marked
Your choice of 3. Super-admin can bypass immutability checks but cannot bypass hardcoded checks
Verify: Is this the intended privilege hierarchy? If super-admins should be able to force-update immutable XMTP components in emergencies, the order may need adjustment. Code Quality4. QUIC variable-length encoding size calculation uses stack buffer trick
Suggestion: Add a comment like 5. Missing coverage in 42 lines (per codecov) The codecov report shows 42 lines missing coverage. Most are likely error paths (decode errors, constraint violations), which is typical. However:
Recommend: Use Performance6. Registry operations are O(n) due to TlsMap's Vec backing
Note: The PR description doesn't specify expected registry size. If this scales to hundreds of app-defined components, the O(n) updates may become a bottleneck in hot paths. Documentation7. Excellent inline documentation The module-level comments, invariant checks (line 32-50), and error messages are exemplary. The comment at Minor: Consider adding a crate-level Test Coverage8. Test-only
9. Tests thoroughly cover constraint violations and hardcoded component rejection The test suite systematically validates:
This is comprehensive. SummaryStrengths:
Action Items:
Recommendation: Approve after addressing (1) and (2). The immutability vs. super-admin question is a design decision that should be explicitly confirmed, and closing the coverage gap will strengthen the already-solid test suite. Tasks
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3413 +/- ##
==========================================
+ Coverage 83.06% 83.36% +0.29%
==========================================
Files 378 382 +4
Lines 51829 52949 +1120
==========================================
+ Hits 43054 44140 +1086
- Misses 8775 8809 +34 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a531f70 to
37e1364
Compare
c5c2bb7 to
3b72916
Compare
3b72916 to
898c1e8
Compare
ApprovabilityVerdict: Needs human review This PR introduces a new component-based permission system with security-critical authorization logic (admin/super-admin checks, immutability enforcement, policy evaluation). While the author owns all files and the code includes comprehensive tests, new permission/authorization infrastructure of this scope warrants human review to validate the security model design. You can customize Macroscope's approvability policy. Learn more. |
898c1e8 to
867dc8c
Compare
| /// existing entry — there is no audit log here because the audit trail | ||
| /// lives in the MLS commit history that produced the change. | ||
| /// | ||
| /// Rejects invalid IDs, IDs in the reserved range, hardcoded components |
There was a problem hiding this comment.
It sounds like a hardcoded component can never move to the registry, and a registry component can never become hardcoded (without a hammer release and waiting for everyone to upgrade). Not a bad thing on its own, just want to make sure I understand how to evolve from the initial state.
Would we ever introduce additional hardcoded components?
There was a problem hiding this comment.
Yeah, I went back and forth on this. The two components it is tied to is the component registry with all the permissions and the super admin list. Both of which should probably ever only be modified by super admins. Everything else is in the registry. If we enforced both of those via the registry we would still have a carve out like we do for the admin list (can only be admin or superadmin) and I think it would still be a hammer release.
There was a problem hiding this comment.
It might be possible to avoid a hammer release by letting anything proposed by a super admin go through without checks, but that has it's own set of risks.
There was a problem hiding this comment.
I'd be worried about the "anything the super admin does is correct" loophole coming to bite us on things like user-controlled data fields. Even a super-admin shouldn't be able to modify data meant to be owned by a specific group member. Also application-controlled fields, where the app developer probably isn't thinking about the super-admin having god mode powers.
Having two magic hardcoded fields that are both extremely unlikely to to have their permissions change seems fine.
5d76ea3 to
ac6aaff
Compare
Introduces a ComponentId-based permission and registry system that will replace the current fixed-field PolicySet. Key pieces: - ComponentId (u16 newtype) with XMTP/App/Immutable/Reserved ranges - ComponentRegistry (TlsMap<ComponentId, VLBytes>) storing per-component metadata: permissions (insert/update/delete) and data type - Three-layer validation: immutability -> hardcoded -> registry lookup - Hardcoded: COMPONENT_REGISTRY and SUPER_ADMIN_LIST (super admin only) - Constrained: ADMIN_LIST (must be AdminOrSuperAdmin or SuperAdmin) - Deny by default: no registry entry = write rejected Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ac6aaff to
48387e3
Compare

Introduces a ComponentId-based permission and registry system that will
replace the current fixed-field PolicySet. Key pieces:
metadata: permissions (insert/update/delete) and data type
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
Note
Add component-based permission system for app data in
xmtp_mls_commonComponentId, au16newtype with defined ID ranges (XMTP, App, Reserved, Immutable) and QUIC variable-length integer TLS encoding incomponent_id.rs.ComponentRegistry, a validated TLS-serializable map keyed byComponentIdthat enforces range rules, hardcoded exclusions, write-once immutability, and metadata completeness on set and load incomponent_registry.rs.validate_component_writeinvalidation.rs, which enforces a three-layer permission check: immutability, hardcoded super-admin rules, and registry-based policy evaluation (AND/ANY combinators with deny-by-default).component_permissionsbuilder function usingbonfor constructing insert/update/delete policies without positional mix-ups.ADMIN_LIST) only acceptAllowIfAdminorAllowIfSuperAdminpolicies; other policy kinds are rejected at write time.Macroscope summarized 48387e3.