Ordered change stream (sync)
An app declares "sync": true at the top level of forge.json and gets a per-app ordered change stream from the forge, with no dependency. A change is any JSON value (at most 8 KB) appended to a room; the forge numbers it, gap-free within the app, so every client reads the same order.
- Read:
GET /api/v1/repos/:owner/:name/changes/:room?since=Nanswers{ changes: [{ seq, room, data, at }], next, here }, oldest first, at most 500 (limitnarrows). Sendnextassinceafter a reconnect to catch up from where you stopped. - Append:
POSTthe same path with{ "data": <json> }answers201 { seq }. Needs anrwtoken or a session. - Presence: each read marks the reader present;
herelists the usernames that touched the room in the last 30 seconds (in memory, not kept). - MCP: the
changestool,{ repo, room, since?, data? }: withdatait appends, without it reads. It is not in the short default list;find_toolreaches it.
Whoever may enter the app (canEnterApp) may read and append. An app that has not declared sync answers 404 not_synced; a room name is letters, digits, _, ., - (64); an append over the rate (100 a second per app) is refused 429 (retry-after: 1); a body or value over the size is 413/422; a read-only token is 403. Rows live in <data>/changes/<app>.sqlite (bun:sqlite) on the forge, so they survive a restart. Code: src/apps/changes.ts, src/apps/room_presence.ts, src/actions/app_changes.ts; test test/app-changes.test.ts.
In the terminal: the palette's "Change stream" opens the lobby room (src/tui/screens/app_changes.ts); o picks another room, a appends a JSON value, r reads again. It goes through the same readChanges/appendChange as the API, so what is written there is what API readers see.
Not yet: a push channel (clients poll since), retention, and per-room permissions.