Expand description
CORD-04 Roles: v2 wire content for the Role (vsk 1), Grant (vsk 3), and Banlist (vsk 4) control entities.
The authority ALGEBRA is shared, not copied: these types convert to/from
crate::community::roles’s Role/MemberGrant/Permissions, and the fold
feeds the shared authorize_delegation + is_authorized. Only the SERIALIZATION
is v2-native, because CORD-04 §3 rides permissions as a decimal STRING (the
shared Permissions serializes as a bare u64 for v1’s storage), and a reader
MUST accept either form (a number from an older edition, a string henceforth) and
always write the string.
Structs§
- Grant
Content - CORD-04 §2 Grant content (vsk 3),
eid == grant_locator(community_id, member). Emptyrole_idsis a revoke. - Role
Content - CORD-04 §2 Role content (vsk 1),
eid == role_id.permissionsrides as a decimal string (§3); unknown fields round-trip (CORD-02 §6).
Constants§
- MAX_
BANLIST - MAX_
ROLES_ PER_ COMMUNITY - MAX_
ROLES_ PER_ MEMBER - A member holds at most this many Roles (CORD-04 §2); a Community folds at most
MAX_ROLES_PER_COMMUNITYRoles (the lowest role_ids win, the same deterministic cap the member list uses). A Banlist edition holds at mostMAX_BANLISTnpubs (the practical NIP-44-envelope ceiling, CORD-04 §4). - MAX_
ROLE_ NAME_ BYTES - A role
nameshares the protocol-wide 64-byte cap (CORD-04 §2/§3).
Functions§
- banlist_
content_ json - Serialize a banlist to its CORD-04 §4 wire JSON (a flat array of lowercase-hex npubs, replaced entire on every edit).
- grant_
content_ json - Serialize a Grant’s content to its CORD-04 §2 wire JSON.
- parse_
banlist_ content - Parse a vsk-4 edition’s content into the banned set (lowercase hex). Non-array or
malformed content yields
None(dropped, never a partial ban). - parse_
grant_ content - Parse a vsk-3 edition’s content into a shared
MemberGrant. - parse_
role_ content - Parse a vsk-1 edition’s content into a shared
Role. Accepts permissions as a string or a legacy number. - role_
content_ json - Serialize a Role’s content to its CORD-04 §2 wire JSON (permissions as a string).
- validate_
banlist - A Banlist edition fits its ceiling (CORD-04 §4): refuse an over-cap edit rather than publish one a strict reader drops.
- validate_
role - A Role’s content byte-fits its cap discipline: name ≤ 64 bytes. (The 100-per- community and 64-per-member caps are fold-side, applied on read.)