Skip to content

audit F1 [tech-debt]: materialize.rs governance dispatch split across 3 match sites #568

@intendednull

Description

@intendednull

File: crates/state/src/materialize.rs:99-185
Severity: tech-debt
Obvious? no

check_permission (lines 99-138) hand-rolls three independent permission tiers: governance match (Propose/Vote/CreateServer), an admin-only matches! block (GrantPermission/RevokePermission/RenameServer/SetServerDescription), and the required_permission() table. apply_event then re-matches a near-identical governance subset (lines 151-182) before delegating to apply_mutation. Three separate match/matches! constructs over the same enum, none exhaustive, each maintained independently — recipe for permission/dispatch drift when adding a new admin-only or governance variant. Per docs/specs/2026-04-12-state-authority-and-mutations.md the table is meant to be a single source of truth; here it is three.

Fix: collapse into one exhaustive classifier function (fn classify(kind: &EventKind) -> EventClass { Governance | AdminOnly | Permissioned(Permission) | Membership | Unrestricted }) called by both check_permission and apply_event.


Filed by /general-audit @ 6404719 (2026-05-03). master: #567.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions