OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-rooms commits / 5407108

Add README
Quick start, schema shape, and pointer to canonical Pattern B writer flow in hypercore-kb autobase skill. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
54071081a8bb072d18b09c31d9f3fa541255d1d7
by plankatron <fleeky@gmail.com> · 2026-05-02T21:03:53.000Z

Changed files (1) +83 -0

README.md +83 -0
……@@ -0,0 +1,83 @@
1# hyper-rooms
2
3Multi-writer "rooms" built on Autobase + Hyperbee view, with pluggable
4schemas. The substrate under `hyper-issues`, `hyper-orgs`, and any other
5"one autobase per namespace" use case in the hyper-fleeky stack.
6
7## What you get
8
9- One Autobase per room (keet-pattern config: `optimistic: true,
10 ackInterval: 1000, ackThreshold: 4`).
11- Hyperbee view, schema-driven apply.
12- Generic `addWriter` / `removeWriter` / `listWriters` / `ackWriter` API.
13- Pattern B writer registration (no pinned keyPair — corestore-derived
14 per-namespace local writer; `addWriter` takes the peer's `localKeyHex`).
15
16## Install
17
18```bash
19npm install hyper-rooms
20```
21
22## Usage
23
24```js
25import { Room } from 'hyper-rooms'
26
27const room = new Room(corestore, {
28 schema: todosSchema, // { encodeOp, decodeOp, validateOp, apply }
29 namespace: 'todos-alice',
30 bootstrapKey: null // null = create new; or pass another room's key
31})
32await room.ready()
33
34// Append a domain op
35await room.append({ type: 'create-todo', id: 1, text: 'milk' })
36
37// Read the view
38const todo = await room.view.get('todo:1')
39
40// Add a peer as a writer (you obtain their localKeyHex out-of-band)
41await room.addWriter('bob', { writerKey: bobLocalKeyHex, role: 'owner' })
42
43// Replicate
44swarm.on('connection', (conn) => room.corestore.replicate(conn))
45```
46
47`role: 'owner'` registers the peer as an autobase indexer. Plain
48`'writer'` is the default — works because the keet-pattern config above
49acks plain writers without manual `forceAck()`.
50
51## Schema shape
52
53```js
54const schema = {
55 encodeOp(op) { return JSON.stringify(op) },
56 decodeOp(buf) { return JSON.parse(buf.toString()) },
57 validateOp(op) { /* throw on invalid */ },
58 apply(batch, op, host) {
59 // batch: hyperbee batch (put / del / get)
60 // host: { addWriter, removeWriter, ackWriter, interrupt }
61 }
62}
63```
64
65See `examples/cli.js` for a runnable todos example.
66
67## Tests
68
69```bash
70npm test
71```
72
73`test/room.test.js` covers the canonical Pattern B flow:
74roomA creates → roomB joins via `bootstrapKey` → A.addWriter('bob',
75{writerKey: B.localKeyHex}) → both rooms converge.
76
77## Related
78
79- `pear-git-v3` — uses this for orgs and per-repo issue trackers.
80- `hyper-identity` — does NOT use this (identity uses pinned keyPair +
81 pre-computed addWriter — different pattern).
82- `.claude/skills/autobase/SKILL.md` in hypercore-kb — Pattern A vs B,
83 keet-pattern config.