vector_core/community/v2/mod.rs
1//! Concord v2 (the upstream CORD specs — `github.com/concord-protocol/concord`).
2//!
3//! Vector's community protocol. The control-plane engine (the edition hash, fold,
4//! roster, and authority algebra) lives in the sibling `community::` modules; this
5//! one carries the envelope (CORD-01 Private Streams: group-key-signed kind-1059
6//! wraps addressed by `authors`), the owner anchor (a self-certifying
7//! `community_id`), the invite system (CORD-05), and the Guestbook plane (CORD-02 §5).
8//!
9//! Frozen wire constants live in two places: the derivation labels in
10//! [`derive`](mod@derive), and the kind registry below (CORD-02 Appendix B). A retired
11//! number is burned forever, never reused.
12
13#[cfg(feature = "bench")]
14pub mod bench;
15pub mod changes;
16pub mod chat;
17pub mod community;
18pub mod control;
19pub mod derive;
20pub mod dissolution;
21pub mod guestbook;
22pub mod inbound;
23pub mod invite;
24pub mod list;
25pub mod list_frag;
26pub mod pin_keys;
27pub mod pins;
28pub mod realtime;
29pub mod volley;
30pub mod voice;
31pub mod rekey;
32pub mod roles;
33pub mod seal;
34pub mod service;
35pub mod stream;
36pub mod streamauth;
37pub mod writers;
38
39/// Inner rumor kinds (CORD-02 Appendix B). The *outer* event is always a wrap
40/// ([`stream::KIND_WRAP`] / [`stream::KIND_WRAP_EPHEMERAL`]); these ride inside.
41pub mod kind {
42 /// Chat message (NIP-C7 shape: content = text; a `q` tag = an INLINE quote).
43 pub const MESSAGE: u16 = 9;
44 /// Threaded reply (NIP-22 comment, CORD-03 §3): uppercase `K`/`E`/`P` pin the
45 /// thread root, lowercase `k`/`e`/`p` the immediate parent — all rumor ids.
46 /// Deliberately distinct from a kind-9 inline quote.
47 pub const COMMENT: u16 = 1111;
48 /// Reaction (NIP-25 shape: `e`/`p`/`k` tags name the target — `k` is the
49 /// target's kind, `9` or `1111`).
50 pub const REACTION: u16 = 7;
51 /// Delete (NIP-09 shape: `e` names the author's own rumor id).
52 pub const DELETE: u16 = 5;
53 /// Message edit (fields unpinned upstream; Vector: `e` = own message rumor id,
54 /// content = replacement text).
55 pub const EDIT: u16 = 3302;
56 /// Rekey blobs (CORD-06).
57 pub const REKEY: u16 = 3303;
58 /// Guestbook join/leave (content = the verb).
59 pub const JOIN_LEAVE: u16 = 3306;
60 /// Control edition, sub-kinded by `vsk` (grammar in `community::edition`).
61 pub const CONTROL: u16 = 3308;
62 /// Guestbook kick (admin-signed, `p` target, `vac` citation).
63 pub const KICK: u16 = 3309;
64 /// WebXDC peer signal (payload opaque to the protocol).
65 pub const WEBXDC: u16 = 3310;
66 /// Guestbook snapshot (refounder-signed, chunked 400/event).
67 pub const SNAPSHOT: u16 = 3312;
68 /// A Timeout (CORD-04 §8): `["p", target]`, `["until", "<unix seconds>"]`, the signer's `vac`.
69 pub const TIMEOUT: u16 = 3314;
70 /// A Nickname (CORD-04 §10): `["p", target]`, the nickname as content, `""` clearing it.
71 pub const NICKNAME: u16 = 3315;
72 /// One page of a Locked Channel's sealed history (CORD-03 §1), at its writer address.
73 pub const SEAL_PAGE: u16 = 3321;
74 /// Direct invite rumor — rides a STANDARD NIP-59 giftwrap to a person,
75 /// never a stream wrap (CORD-05 §6).
76 pub const DIRECT_INVITE: u16 = 3313;
77 /// Typing indicator (ephemeral tier — 21059 wrap, never stored).
78 pub const TYPING: u16 = 23311;
79 /// Voice presence heartbeat (ephemeral tier; CORD-07 §4).
80 pub const VOICE_PRESENCE: u16 = 23313;
81 /// A moderator's voice directive (ephemeral tier; CORD-07 §7): `["p", target]`, `["do", …]`.
82 pub const VOICE_DIRECTIVE: u16 = 23314;
83 /// Public invite bundle — bare addressable event signed by the per-link
84 /// keypair at an empty `d` (CORD-05 §2). Outside the wrap.
85 pub const INVITE_BUNDLE: u16 = 33301;
86 /// A member's self-encrypted Community List (replaceable). Outside the wrap.
87 /// RETIRED by the fragmented form below — a replaceable kind holds one event
88 /// per pubkey, so it cannot shard, and the List outgrew what relays accept.
89 pub const COMMUNITY_LIST: u16 = 13302;
90 /// The fragmented Community List (CORD-02 §8): addressable, one event per
91 /// fragment at `d` = the fragment index in decimal. Outside the wrap.
92 pub const COMMUNITY_LIST_FRAG: u16 = 33302;
93 /// A creator's self-encrypted Invite List (replaceable). Outside the wrap.
94 pub const INVITE_LIST: u16 = 13303;
95}
96
97/// Control-plane `vsk` sub-kinds (CORD-02 Appendix B). 7 is retired upstream (an
98/// owner attestation, obsoleted by the self-certifying community id).
99pub mod vsk {
100 pub const COMMUNITY_METADATA: &str = "0";
101 pub const ROLE: &str = "1";
102 pub const CHANNEL_METADATA: &str = "2";
103 pub const GRANT: &str = "3";
104 pub const BANLIST: &str = "4";
105 // "5" reserved (role ordering), "6"/"9" claimed by the 33301 invite marker,
106 // "7" retired, "8" = invite-link registry, "10" = dissolved tombstone.
107 pub const INVITE_LINKS: &str = "8";
108 pub const INVITE_LIVE: &str = "6";
109 pub const INVITE_REVOKED: &str = "9";
110 pub const DISSOLVED: &str = "10";
111 /// One Pin List per Channel at `pins_locator` (CORD-04 §7).
112 pub const PINS: &str = "11";
113 /// Roles v2 and `@everyone` (CORD-04 §2), replacing vsk 1 once a Community activates it.
114 pub const ROLE_V2: &str = "13";
115 /// A Channel or Category permission overwrite (CORD-04 §8).
116 pub const CHANNEL_ACL: &str = "14";
117 /// A Category (CORD-03 §4).
118 pub const CATEGORY: &str = "15";
119 /// A member's Tenure (CORD-04 §9).
120 pub const TENURE: &str = "16";
121 /// A Channel's sync to its Category's overwrites (CORD-04 §8).
122 pub const CHANNEL_SYNC: &str = "17";
123 /// A restricted Channel's Writers ledger (CORD-03 §1).
124 pub const WRITERS: &str = "18";
125}