Expand description
Vector Communities, on the Concord v2 (CORD) protocol in v2, plus the pieces
every layer shares: ids, epochs, images, transport, roles and moderation.
Modules§
- attachments
- Community message attachments (NIP-92
imeta). - cache
- Per-account RAM state for Community sync: the in-flight page claims. Keyed by this account’s channel ids, so it lives on the account’s session and goes when that does.
- cipher
- Raw-key NIP-44 v2 sealing with a nonce no call site can choose.
- edition
- Real-npub authority editions — the keyless model’s authorship + version carrier.
- mentions
- Role mentions (CORD-03 §3, CORD-04 §8): a
["role", "<role_id>"]tag beside an@Namein the text. The text stays readable on clients that don’t know the tag. - message_
delete - Deleting what the local user sent to a Community, from its relays.
- moderation
- Moderation authority: who may remove whose message (CORD-04 §3/§5).
- policy
- The moderation policy engine (Phase 1).
- raid
- Raid assessment: which members read as people, and which read as spawned identities.
- rank
- Rank keys (CORD-04 §3): Role order as fractional keys over
0-9A-Za-z, compared byte by byte, 1 to 32 bytes and never ending in0. Between any two keys another always exists, so moving a Role between two neighbours is one edition, on the moved Role alone. Channel and Category positions (CORD-03) use the same keys. - roles
- Concord role graph (GROUP_PROTOCOL.md).
- transport
- Transport abstraction for Community events.
- v2
- Concord v2 (the upstream CORD specs —
github.com/concord-protocol/concord). - version
- Per-entity version chain for authority editions.
Structs§
- Channel
Id - A Channel’s stable identity within a Community. Same opaque-random rule as
CommunityId; doubles as the addressable metadatad-tag. - Channel
Key - A 32-byte symmetric channel secret — the raw NIP-44 v2
ConversationKeymaterial. Zeroized on drop; never logged. - Community
Id - A Community’s stable identity = a random 32-byte opaque id (NOT a timestamp-encoding snowflake, which would leak creation time).
- Community
Image - A reference to an encrypted image blob (community logo/banner), using the same technique as NIP-17 file attachments: a fresh random AES-GCM key+nonce encrypts the image, the ciphertext is uploaded to Blossom, and this reference travels inside ServerRoot-sealed metadata. So possession of the server-root key (every member) gates the image, and there is no key reuse across images.
- Epoch
- The epoch counter — the read-access clock (“two clocks”). Bumps only on a rekey; stamped explicitly even when it is 0, so multi-channel and rotation stay additive (forward-compat hook #1).
Constants§
- CONTROL_
PK_ SCOPE - The epoch-key-archive scope for each epoch’s Control Plane address, kept so the Audit Log can read an epoch back after a Refounding has moved the plane on. Non-hex, like the above.
- CONTROL_
ROOT_ SCOPE - The epoch-key-archive scope for a v2
control_root(CORD-02 §2): non-hex on purpose, so it collides with neither a channel id nor the root sentinel. Reserves the pair beside the root at mint (retry idempotency) and archives the secret per epoch. - MAX_
COMMUNITY_ RELAYS - Protocol cap on a Community’s relay set (§ transport). More relays are needless and amplify resource + metadata-exposure cost; 5 gives redundancy without centralisation. Enforced by truncate-on-read at every Community/CommunityInvite construction boundary, so a hostile or legacy bundle degrades to ≤5 distinct relays rather than being honored or rejected.
- REALTIME_
FRESH_ WINDOW_ MS - How fresh an inner send time must be to surface as a REALTIME event (ms). Generous against sender clock skew and relay push latency; tiny against the hours-to-months staleness of a relay-to-relay backfill replay.
- SERVER_
ROOT_ SCOPE_ HEX - The all-zero hex scope id for server-root-scoped epoch keys (
RekeyScope::ServerRootuses the all-zeroid32sentinel). AChannelIdis random-32, so it can never collide with this — letting onecommunity_epoch_keystable hold both channel keys and the base/server-root key keyed by(scope_id, epoch). - SVG_
REFUSED - Community icons and banners are raster only, sent and shown, like custom emoji.
Functions§
- cap_
relays - dispatch_
inbound - Route an inbound Community event, live or a slow relay’s straggler.
- holds_
history_ from_ start - Whether this account holds the key a channel’s history began under. A member who joined after a rotation holds only the epochs since: what came before sits on the relays sealed under keys it never received, so the oldest message it can read is not the channel’s first.
- is_
realtime_ fresh - Whether an inner send time is fresh enough to surface as REALTIME. The live
subscriptions are limit-0 (never history), but a relay backfilling from a
peer ACCEPTS old events as new writes and pushes them to matching live subs
— without this gate a month-old join or mention surfaces as if it just
happened (bots welcome long-gone joiners, answer stale mentions). Gates only
the “new” surfaces (
is_new, bot events, pings); folding and persistence are NEVER gated on freshness. - reached_
history_ start - Dedupe (order-preserving) + truncate a relay set to
MAX_COMMUNITY_RELAYS. Dedup first so the cap means “up to 5 DISTINCT relays” — a bundle padding one relay 5× can’t waste the budget. Whether an older page asked frombefore_secsreached the channel’s start: the relays answered, brought nothing this device lacked, left no cursor to go on from, and nothing held lies below the cursor. Relays serve the cursor’s own second again, so a page of only held messages can still be the end.