dignity.js 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -142,6 +142,40 @@ await node.leavePeerGroup('feed:alice');
142
142
 
143
143
  Small collaborations (chess players, document co-editing) should keep using direct `connectToPeers` mesh. Large read-only audiences (chess spectators, public timelines) should use PeerGroup gossip. See the [docs PeerGroup section](https://jose-compu.github.io/dignity.js/#peer-groups).
144
144
 
145
+ ### CQRS tiers, domain events, and query replicas (v0.8+)
146
+
147
+ For audiences above ~5 000 subscribers per publisher, use the command/query split:
148
+
149
+ - **Command path** — publisher writes locally; signed domain events auto-publish on `create` / `update` / `remove`.
150
+ - **Live tier** — first `liveCap` subscribers (default 5 000) receive real-time gossip.
151
+ - **Bulk tier** — overflow subscribers receive batched updates via bulk relays.
152
+ - **Query path** — `DignityQueryReplica` maintains local materialized views from the event stream.
153
+
154
+ ```js
155
+ const { DignityP2P, DignityQueryReplica } = require('dignity.js');
156
+
157
+ // Publisher
158
+ await publisher.joinPeerGroup('feed:alice', {
159
+ role: 'publisher',
160
+ tiered: true,
161
+ liveCap: 5000,
162
+ domainEvents: true
163
+ });
164
+ await publisher.create('posts', { text: 'hello' }, { id: 'p1', peerGroupId: 'feed:alice' });
165
+
166
+ // Read-only replica (no command capability)
167
+ const replica = new DignityQueryReplica(reader, {
168
+ groupId: 'feed:alice',
169
+ collections: ['posts'],
170
+ publisherId: 'alice'
171
+ });
172
+ await replica.start({ bootstrapPeerIds: ['alice'] });
173
+ replica.read('posts', 'p1');
174
+ replica.verifyChain(); // hash-chain consistency
175
+ ```
176
+
177
+ Default `maxHops` is **64** (was 6), sufficient for epidemic spread at fanout 3 without per-group tuning.
178
+
145
179
  ## Room / Team Discovery
146
180
 
147
181
  Use scoped discovery to find active peers in a room (for example `main`, `team:red`, `raid-42`).