Skip to main content

vector_core/community/v2/
mod.rs

1//! Concord v2 (the upstream CORD specs — `github.com/concord-protocol/concord`).
2//!
3//! Vector's second-generation community protocol, carried ALONGSIDE v1 (the
4//! sibling `community::` modules) for a migration window. v2 keeps v1's control
5//! plane engine verbatim — the edition hash, fold, roster, and authority algebra
6//! are shared by import, not copied — and replaces the envelope (CORD-01 Private
7//! Streams: group-key-signed kind-1059 wraps addressed by `authors`), the owner
8//! anchor (a self-certifying `community_id`), the invite system (CORD-05), and
9//! adds the Guestbook plane (CORD-02 §5).
10//!
11//! Nothing in here touches v1 state: a `Community` is one protocol or the other
12//! (`protocol` discriminator), and the two stacks share only pure logic.
13//!
14//! Frozen wire constants live in two places: the derivation labels in
15//! [`derive`], and the kind registry below (CORD-02 Appendix B). A retired
16//! number is burned forever, never reused.
17
18pub mod chat;
19pub mod community;
20pub mod control;
21pub mod derive;
22pub mod dissolution;
23pub mod guestbook;
24pub mod inbound;
25pub mod invite;
26pub mod list;
27pub mod pin_keys;
28pub mod pins;
29pub mod realtime;
30pub mod volley;
31pub mod rekey;
32pub mod roles;
33pub mod service;
34pub mod stream;
35pub mod streamauth;
36
37/// Inner rumor kinds (CORD-02 Appendix B). The *outer* event is always a wrap
38/// ([`stream::KIND_WRAP`] / [`stream::KIND_WRAP_EPHEMERAL`]); these ride inside.
39pub mod kind {
40    /// Chat message (NIP-C7 shape: content = text; a `q` tag = an INLINE quote).
41    pub const MESSAGE: u16 = 9;
42    /// Threaded reply (NIP-22 comment, CORD-03 §3): uppercase `K`/`E`/`P` pin the
43    /// thread root, lowercase `k`/`e`/`p` the immediate parent — all rumor ids.
44    /// Deliberately distinct from a kind-9 inline quote.
45    pub const COMMENT: u16 = 1111;
46    /// Reaction (NIP-25 shape: `e`/`p`/`k` tags name the target — `k` is the
47    /// target's kind, `9` or `1111`).
48    pub const REACTION: u16 = 7;
49    /// Delete (NIP-09 shape: `e` names the author's own rumor id).
50    pub const DELETE: u16 = 5;
51    /// Message edit (fields unpinned upstream; Vector: `e` = own message rumor id,
52    /// content = replacement text).
53    pub const EDIT: u16 = 3302;
54    /// Rekey blobs (CORD-06).
55    pub const REKEY: u16 = 3303;
56    /// Guestbook join/leave (content = the verb).
57    pub const JOIN_LEAVE: u16 = 3306;
58    /// Control edition, sub-kinded by `vsk` (shared grammar with v1 — `community::edition`).
59    pub const CONTROL: u16 = 3308;
60    /// Guestbook kick (admin-signed, `p` target, `vac` citation).
61    pub const KICK: u16 = 3309;
62    /// WebXDC peer signal (payload opaque to the protocol).
63    pub const WEBXDC: u16 = 3310;
64    /// Guestbook snapshot (refounder-signed, chunked 400/event).
65    pub const SNAPSHOT: u16 = 3312;
66    /// Direct invite rumor — rides a STANDARD NIP-59 giftwrap to a person,
67    /// never a stream wrap (CORD-05 §6).
68    pub const DIRECT_INVITE: u16 = 3313;
69    /// Typing indicator (ephemeral tier — 21059 wrap, never stored).
70    pub const TYPING: u16 = 23311;
71    /// Voice presence heartbeat (ephemeral tier; CORD-07 — deferred in Vector,
72    /// constant reserved so nothing else claims it).
73    pub const VOICE_PRESENCE: u16 = 23313;
74    /// Public invite bundle — bare addressable event signed by the per-link
75    /// keypair at an empty `d` (CORD-05 §2). Outside the wrap.
76    pub const INVITE_BUNDLE: u16 = 33301;
77    /// A member's self-encrypted Community List (replaceable). Outside the wrap.
78    pub const COMMUNITY_LIST: u16 = 13302;
79    /// A creator's self-encrypted Invite List (replaceable). Outside the wrap.
80    pub const INVITE_LIST: u16 = 13303;
81}
82
83/// Control-plane `vsk` sub-kinds (CORD-02 Appendix B). Identical numbering to
84/// v1 (`community::roster`) — that is deliberate, the registry is shared. 7 is
85/// retired upstream (the v1 owner attestation, obsoleted by the self-certifying
86/// community id); 11 is claimed by Vector for the v1-side migration pointer and
87/// never appears on the v2 wire.
88pub mod vsk {
89    pub const COMMUNITY_METADATA: &str = "0";
90    pub const ROLE: &str = "1";
91    pub const CHANNEL_METADATA: &str = "2";
92    pub const GRANT: &str = "3";
93    pub const BANLIST: &str = "4";
94    // "5" reserved (role ordering), "6"/"9" claimed by the 33301 invite marker,
95    // "7" retired, "8" = invite-link registry, "10" = dissolved tombstone.
96    pub const INVITE_LINKS: &str = "8";
97    pub const INVITE_LIVE: &str = "6";
98    pub const INVITE_REVOKED: &str = "9";
99    pub const DISSOLVED: &str = "10";
100    /// One Pin List per Channel at `pins_locator` (CORD-04 §7).
101    pub const PINS: &str = "11";
102}