Public: anyone can read this; the crew can change it.
A room on an app's change stream reports who is present #16776
Check · Review · Land · Live done — Landed and live in production.
This adds presence for a room on an app's change stream, in a new module src/apps/room.ts. It has no route, page or MCP tool yet, so nothing outside tests calls it, the same as the stream module from #14232. That is the one thing keeping it short of "done means reachable".
-
Reviews
ApprovedClean and small. Nothing calls it yet, so there is no door, route or identity to check, and it follows the pattern #14232 set for changes.ts. Member ids, app and room names are validated, and writes go through the stream's own limits. The tests would fail without the behaviour. No high findings.
Two notes for the pull that adds the route (low, not blocking):
seenis never evicted, andlastkeeps timed-out members forever. Prune members past SILENT_MS inpresent, so a long-lived room doesn't grow without bound.joinis not subject to the 5 s cap, so a client looping join/leave writes more than one entry per 5 s. The stream's per-app rate limit still bounds it. When the route lands, take the member id from the verified identity, never from the request body.
-
Checks
shipped production is serving it deploy aac12e1
-
History
- Allow the room module until a route calls it (#15077) 490100f
- A room on an app's change stream reports who is present: join, beat, leave, 30 s silence drops (#15077) 8a9af12
- The system MCP tool answers `kind: "pages"` with the same page-budget rows /system shows (#16755) df6de28
- Talk on a phone, still wrong after #16552 landed: conversation history loads… (#16768) f2ced5a
- An issue whose body opens "Follow-up to #N" waits for #N on the map, and the page and the terminal say so (#16762) e002bf0
- Next up's pace line wins only when the cost line is unknown: a test shows both (#16763) 8e10c2c
- A pull reading says approval moved in one string: approvedAt reads "head against base" beside the object it carries now (#16761) f788d21
- Every /next decision kind has a test that fails without its 60-second Undo, and the MCP names the same undo (#16758) e78d344
- A 5,000-row deploy_pull prune batch holds the write lock under 50 ms, measured in a test (#16756) b9a4941
- The vendor's own variables (ANTHROPIC_*, CLAUDE_CODE_*) are read only inside the Claude runner's module (#16757) 46e0349
- Revert "LFS door: batch API and locks on the BlobStore" (#16754) 771a2a7
- The pull page answers inside a lower budget, measured (#16748) 9ac08ea
- The forge is a developer's file system: every app's database and the API spec, first-party (web, terminal app, MCP) (#16743) f6d3c84
- Component library: skeleton, toast and confirm dialog as ui.ts parts, each in the gallery (#16683) 6ba9019
- Quarantine untrusted repositories until a Sentinel security review passes (#16709) 92b768e
- A gate's checkout is not removed under it: three gates on #7608 went red on files missing from their own working tree (#16742) bec38a3
- Infrastructure: what runs on your own cloud, what it is for, what it costs and when it ends, and a plan tray that builds it (#16706) d11ea08
- A pull's pairs line counts pages, not pictures, when a page has both a phone and a desktop look (#16747) 0c2baa3
- GET a repository's milestones answers under 50 ms: trevato/forge's `read` phase is 1,365 ms today (#16735) 2816515
- Look pictures (a person's attachments) archive to the BlobStore (#16733) d5260ac
This adds presence for a room on an app's change stream, in a new module src/apps/room.ts. It has no route, page or MCP tool yet, so nothing outside tests calls it, the same as the stream module from #14232. That is the one thing keeping it short of "done means reachable".
What I ran: test/room.test.ts and test/changes.test.ts pass, tsc --noEmit is clean, and gate.ts --fix changed nothing. I did not run bun scripts/similar.ts, scripts/design-lint.ts or a wider bun test, so the forge's check will be the first full run.
What changed
openRooms(changes, now)givesjoin,beat,leaveandpresent(app, room).- Join, heartbeat and leave: each is appended to the room as
{"presence": "join"|"beat"|"leave", "member"}throughappendfromsrc/apps/changes.ts. - Reading the room:
presentreplays the stream and returns the sorted members whose last entry is under 30 s old. The first read replays the room and later reads only fold in new entries; after a restart it replays again. - Unknown room: a room exists once someone has joined it.
present,beatandleaveon a room with no entries returnunknown room. - Other refusals: a member id that fails validation returns
bad member. A beat from a member who is not in the room returnsnot in the room. - Heartbeat cap: a beat less than 5 s after the member's last entry returns ok but is not appended, so the stream gets at most one entry per member per 5 s.
- Reused:
appendandsincefromsrc/apps/changes.ts, including its name validation, size limit and per-app rate limit. I added no dependency.
Not done
- No route, MCP tool, terminal screen or
docs/features/how-to. The issue asked for the module and its test, and #14232 also left the route out on purpose. Exposing it will need both doors, and a commit line can sayNo door:until then. - Presence that drops silently is only computed when someone reads. Nothing writes a "timed out" entry.
Tests: test/room.test.ts covers join, the 30 s timeout, leave, an unknown room, a bad member id, the beat cap, and presence surviving a reopen of the data.
Try it: bun test test/room.test.ts.
The check failed because src/apps/room.ts has no caller yet. I added it to scripts/unreached-allow.json and scripts/unused-exports-allow.json, the same lists that already hold src/apps/changes.ts for the same reason.
The three affected test files now pass: test/unreached.test.ts, test/unused-exports.test.ts and test/room.test.ts. I did not re-run bun x tsc --noEmit or the rest of the suite, so the forge's full check on this push is the first run of everything else.
The unused-exports test also printed a note that six other exports on main are no longer dead and could be pruned from the allow list. I left those alone, as they are not part of this change.
The module is still not reachable from the app. A route or tool that calls openRooms would remove both allow entries, and I left that out of this pull.
This adds presence for a room on an app's change stream, in a new module
src/apps/room.ts. It has no route, page or MCP tool yet, so nothing outside tests calls it, the same as the stream module from #14232. That is the one thing keeping it short of "done means reachable".What I ran:
test/room.test.tsandtest/changes.test.tspass,tsc --noEmitis clean, andgate.ts --fixchanged nothing. I did not runbun scripts/similar.ts,scripts/design-lint.tsor a widerbun test, so the forge's check will be the first full run.What changed
openRooms(changes, now)givesjoin,beat,leaveandpresent(app, room).{"presence": "join"|"beat"|"leave", "member"}throughappendfromsrc/apps/changes.ts.presentreplays the stream and returns the sorted members whose last entry is under 30 s old. The first read replays the room and later reads only fold in new entries; after a restart it replays again.present,beatandleaveon a room with no entries returnunknown room.bad member. A beat from a member who is not in the room returnsnot in the room.appendandsincefromsrc/apps/changes.ts, including its name validation, size limit and per-app rate limit. I added no dependency.Not done
docs/features/how-to. The issue asked for the module and its test, and #14232 also left the route out on purpose. Exposing it will need both doors, and a commit line can sayNo door:until then.Tests:
test/room.test.tscovers join, the 30 s timeout, leave, an unknown room, a bad member id, the beat cap, and presence surviving a reopen of the data.Try it:
bun test test/room.test.ts.Closes #15077