Public: anyone can read this; the crew can change it.
An app gets an ordered change stream: rooms, presence and durable order, with no dependency #16751
Check · Review · Land · Live done — Landed and live in production.
An app that sets "sync": true in forge.json now gets an ordered change stream from the forge, reached through one documented route and one MCP tool. test/app-changes.test.ts has two clients appending to one room and both reading the same order.
-
Reviews
Changes requested — before the latest pushNo security finding: reads and writes require a signed-in identity and scope, the body is read bounded, and the room and size are validated by the store. Four things to fix in one round:
- The terminal door cannot append. The page/API/MCP can read and append; the terminal only reads
lobby. Add an append action and a room choice to the screen (viaappendChange), so a write made there reaches API readers. - No test covers the terminal screen (gate and write path). Add one: a guest or non-enterable user sees nothing, an entered user reads, and an append from the screen appears in the API read.
- Contract and docs are wrong about refusals: the rate refusal is documented as 422 and the OpenAPI
refuseslists only [401, 404] although the routes also answer 403, 422 (and 413). List them. Also the stale comment insrc/actions/app_changes.tssays MCPappswithaction: "changes"; it is thechangestool. - Unrelated churn: the pruning of unrelated entries in
scripts/unused-exports-allow.json(sweepArgvs, heldIn, startOfAccount, forgetWeek, toolNames, pageBudgetRows) is not this change; drop it. The MCPchangestool also has no test for a read-only token being refused an append; add one.
ApprovedAll four earlier asks are met. The terminal screen now appends (
a) and switches rooms (o), and it goes through the samereadChanges/appendChangegate as the API and MCP tool. A screen test covers a guest, a stranger and an entered user, and checks that an append from the terminal shows in the API read. The rate refusal is now 429 withretry-after. The allow-list churn is reduced to the oneopenChangesentry.Security reads clean on the lines that changed: both routes check scope (
rofor GET,rwfor POST), access goes throughcanEnterApp, the room name is validated, the value is capped, appends are rate limited per app, and presence is keyed on the verified username. The docs are indocs/features/sync.md, not README. The only edits since my last review are merges of main.Non-blocking: add the 403, 413, 422 and 429 cases to the openapi-errors probe so they can be listed in
refuses. - The terminal door cannot append. The page/API/MCP can read and append; the terminal only reads
-
Checks
shipped production is serving it deploy aac12e1
-
History
- Merge main into scout/10839 7713a3b
- A subscriber gives a friend a forge in one tap, and sees who came — restarted from the parked branch, in two small pulls (#16766) 94c2cbe
- Every price on /pricing, the plan row and the MCP is formatted by one function, with a test over the three (#15694) a79722d
- llms budget: raise the admin ceiling constant 44c534d
- llms budget: admin ceiling 100,800 after main grew with the changes tool 67fada4
- Merge remote-tracking branch 'origin/main' into scout/10839-an-app-gets-an-ordered-change-stream-roo 5a1b22a
- One palette across the forge and its apps — restarted from the parked branch, forge side first (#16779) e4dd828
- With the weekly window full, the forge runs a model-free measurement and /week counts it (#16783) 7bffc31
- small: The guide spine, read as a new owner, an outside agent and an owner looking up a setting, has its findings fixed (#16781) b92c2a5
- An invite to an organization lands from the closed pull #12484's branch, with the signup welcome tested (#16764) 518ce94
- forge.json validates a service app's ports and refuses a clash with another app (#16778) a4bc344
- Change stream routes: declare only the refusals the contract guard can see; the rest named in the detail b7c473c
- The platform inventory page has one primary next action and is looked at on phone and desktop widths (#16773) 721a707
- Change stream: the terminal appends and picks a room; refusals listed (429 for the rate); drop unrelated allow-list churn; tests for the screen and a read-only MCP append 8dab40d
- Admins mark which repositories are offered as templates for new forges (#16752) 577f9d8
- small: Escape leaves the tell box and keeps its draft per page (#16774) 24468de
- Merge main into scout/10839; key the change stores by app, list the new tool and route where the suite counts them 3aba620
- On a phone, one tap opens search with the keyboard up and results above it (#16749) 7238053
- A room on an app's change stream reports who is present (#16776) 98bb47d
- Port Jay Moran's demo: actions/demo, refs/demo and moveRefLeased's caller, demo routes (#16745) b346c0a
7 earlier comments
I merged main into this branch and pushed. The one conflict was in scripts/unused-exports-allow.json, and it is resolved. Only the unused-exports and app-changes tests were run: 9 pass. The broader tests scripts/fast.ts picked went to the background and I didn't wait for them. The forge's check on this push will run the whole suite.
- Conflict: I dropped our
openChangesentry becausesrc/actions/app_changes.tsnow calls it, and keptmain's newuseLookStoreentry. closeChanges: I added it to the allow list, because nothing insrccalls it and the dead-code test fails without the entry.- Stale entries: the dead-code test also failed on five allow-list entries that are no longer dead, none of them ours. They are
sweepArgvs,heldIn,startOfAccount,forgetWeekandtoolNames. I pruned them withbun scripts/unused-exports.ts --writeso the test passes. - Not run:
bun x tsc --noEmitprinted nothing; I didn't confirm its exit code. - Gate warnings:
scripts/gate.ts --fixprinted three warnings that I did not address, and the forge's check may flag them.- The "say what it replaces" rule wants a
Replaces:line in a commit message forsrc/http/mcp/tools/changes.ts. - The "both doors" rule wants a terminal screen under
src/tui/screens/or aNo door:line in a commit message. - Two duplicate-code notes, one for
storeinsrc/actions/app_changes.tsand one forrpcintest/app-changes.test.ts.
- The "say what it replaces" rule wants a
An app that declares "sync": true in forge.json gets an ordered change stream. It has rooms and presence, and you can read it from an offset. The previous check failed on the "both doors" rule: the pull had no terminal screen. This push adds one, and the gate now lists only a duplicate-functions note. bun x tsc --noEmit is clean. test/app-changes.test.ts, test/hollow.test.ts, test/doorless.test.ts and test/feature-doors.test.ts pass. I did not run the full suite; the forge runs it on this push.
What the stream does
- Any JSON value up to 8 KB can be appended to a room. The forge numbers each change in order, with no gaps within the app.
GET /api/v1/repos/:owner/:name/changes/:room?since=Nreturns the changes afterN, plusnextto send assinceafter a reconnect, andhere, the users present in the room. Each read marks the reader present.POSTto the same path with{"data": …}appends and returns the sequence number.- The MCP
changestool does the same: withdatait appends, without it reads. - Whoever may enter the app can read and append. An app that has not declared
syncgets404 not_synced. - Changes are stored in bun:sqlite under the forge's data directory, so they survive a restart. Presence is held in memory only, for 30 seconds.
- No new dependency.
What changed in this push
- Terminal door: the command palette now has "Change stream" for any app repository. It opens
src/tui/screens/app_changes.ts, which reads thelobbyroom through the samereadChangescall as the API and MCP tool.rreads again andj/kmove the cursor.docs/features/sync.mdmentions it. - Hollow rule: I removed the test-only
closeChangesexport, which nothing at runtime reached. The test no longer calls it, and its allow-list entry is gone. - Commit line: the commit carries
Replaces: nothing, the stream is new and this is its terminal screen.
Left out
- No push channel yet; clients poll with
since. - No retention and no per-room permissions.
- The terminal screen reads
lobbyonly and cannot append. Other rooms and writes go through the API or MCP. - I added no terminal test.
- I left the two duplicate-function notes (
storeagainstdestroy_reach.mod, and the test'srpchelper againsttest/app-flags.test.ts) as they are.
Try it
- Set
"sync": trueinforge.json. POST {"data":{"n":1}}to/api/v1/repos/<owner>/<app>/changes/lobby.GETthe same path with?since=0.- In the terminal, open the palette and choose "Change stream".
I merged main into the branch and pushed it. The only conflict was scripts/unreached-allow.json. I kept both sides' entries (src/apps/changes.ts from main, src/perf/page_budget_read.ts from this branch) alongside src/spawn/pod.ts.
- Checks run: the gate (
bun scripts/gate.ts --explain) shows 0 failing rules. The tests I ran after the merge pass:test/app-changes.test.ts,test/hollow.test.tsandtest/doorless.test.ts. - Not run:
bun x tsc --noEmitprinted nothing, and I did not confirm it came back clean.bun scripts/fast.tsnamed 3721 test files, which is too broad. I stopped that run and ran the three change-related files instead.- The forge's full check runs on the push.
- Cleanup:
src/apps/changes.tsis in the allow list again becausemainadded it. An earlier commit on this branch had pruned it, so the list may now carry a stale entry.test/hollow.test.tspasses either way.
The earlier pull description still stands.
I merged main into the branch, fixed the failures from the earlier red check, and pushed. I ran the failing test files locally and they pass, bun x tsc --noEmit printed nothing, and bun scripts/gate.ts --fix printed only similarity notes (below), no rule failures. I did not run the whole suite; the forge's check runs it on this push.
- Conflicts: I resolved
scripts/unreached-allow.jsonandscripts/unused-exports-allow.jsonby keepingmain'ssrc/apps/room.tsentries. I dropped thesrc/apps/changes.tsandsrc/perf/page_budget_read.tsentries (and theiropenChanges/pageBudgetRowsexport entries) because both modules are reached now. - Code:
src/actions/app_changes.tskept its change stores in a module-levelMap, whichtest/module-state.test.tsrefuses. They are now keyed by app in aWeakMap. - Tool index: I regenerated it with
bun scripts/mcp-tools.ts, sochangesis in sorted order. - Lists the tests count:
changesis inNOT_ASKEDintest/conversation-confirm.test.ts, because it only appends to an app's own stream.changesis in the tool-name list intest/mcp-forge-protocol.test.ts.room: "lobby"is added toFILLintest/open-routes-floor.test.ts.- The
/changes/:roomroute is inUNSEEDEDintest/security-floor-routes.test.ts, with its reason. MAX_UNFIXTUREDgoes from 159 to 160 intest/pages-budget.test.ts.src/apps/changes.tsis inREACHEDintest/worker-database-opens.test.ts.
- llms.txt budget: the admin budget in
test/llms-budget.test.tsgoes from 99,200 to 99,700 bytes. The admin/llms.txtwas 99,607 bytes here. That test was also red onmain, so part of the overrun may not be this pull's.
The gate printed three "one implementation?" similarity notes (store in src/actions/app_changes.ts, changesCommands, and the rpc helper in test/app-changes.test.ts). I left them as they are.
I addressed all four review points. One of them I could only do in part, because a contract test blocked it (see 3).
- Terminal door. The change-stream screen (
src/tui/screens/app_changes.ts) now hasato append andoto pick a room.aprompts for a JSON value and callsappendChange.oprompts for a room name, checked withisRoom, and reloads.rstill reads again. The screen goes through the same gate as the API. - Screen test.
test/app-changes.test.tsnow drives the screen:- A guest on a private synced app sees "No such app."
- A user who may not enter the app is refused and sees none of the changes.
- An entered user reads, and a JSON value appended from the screen shows up in the API read.
- Text that isn't JSON appends nothing, and
omoves to another room.
- Refusals and docs.
- Rate refusal: it was a 422 in the code and in
docs/features/sync.md. I made it a 429 withretry-after: 1on the API. The MCP tool answersrate_limited. The docs say 429, and also say a read-only token gets 403 and an oversize body or value gets 413 or 422. - POST
refuses: it now lists[401, 403, 404]. - GET
refuses: it stays[401, 404]. - Why not 422, 413 and 429:
test/openapi-errors.test.tsfails any declared shared refusal that its probe doesn't actually see answered, and the probe can't trigger 422, 413 or 429 (nor 403 on GET). Listing them inrefusesfailed that test, so they are named in each route'sdetailinstead. The alternative is to teach the probe those cases, which I didn't do. - Stale comment: the one in
src/actions/app_changes.tsnow names the MCPchangestool and the terminal.
- Rate refusal: it was a 422 in the code and in
- Churn.
- Allow-list: I reset
scripts/unused-exports-allow.jsonto main and removed only theopenChangesentry, which this change now uses. - MCP test: a read-only token's append through the
changestool is refused, and the room stays empty.
- Allow-list: I reset
bun x tsc --noEmit, bun scripts/design-lint.ts and the change-stream, changes-store, MCP protocol, security-floor, open-routes and OpenAPI/contract tests all pass. I didn't run the full suite. bun scripts/gate.ts --fix prints similarity notes (for example rpc and screenAs in the test resemble other test helpers); I left them as is.
Try it: on an app with "sync": true, open the palette's "Change stream", press a and type {"hi":1}, then GET /api/v1/repos/:owner/:name/changes/lobby.
🤖 Generated with Claude Code
The failing test, /llms.txt stays under its byte budget for each role, now passes locally. I haven't seen the forge's check run on the new push yet.
Main had grown since my last merge, and the admin /llms.txt reached 99,832 bytes with the changes tool. That is over the 99,700 ceiling. The signed-in text (75,992) and the anonymous text (9,036) are still under their ceilings.
I merged origin/main into the branch and raised the admin ceiling in test/llms-budget.test.ts to 100,800, about 1% above the measured size. The comment above BUDGET records the reason, as earlier raises do.
The first push of this fix changed only the comment, not the constant, so that commit still failed the test. The second commit sets the constant and the test passes.
I also ran bun x tsc --noEmit on the first commit, and it printed nothing. I did not run it again for the second. bun scripts/gate.ts --fix printed duplicate-scan notes: rpc and screenAs in test/app-changes.test.ts look similar to helpers in test/app-flags.test.ts and test/tui-new-issue.test.ts. It also stopped its scan after 8 seconds. I did not act on these.
I merged main into the branch and pushed it. The only conflict was in test/llms-budget.test.ts. The llms budget test passes and tsc --noEmit is clean. I ran nothing else, so the rest of the suite is left to the forge's check on this push.
Both sides had raised the admin byte ceiling for /llms.txt. My side set it to 100,800 and main set it to 100,700 for the profile tool's gift action. With both merged, the admin text measures 100,036 bytes, which fits under main's 100,700. I kept main's ceiling, so my 100,800 raise is dropped, and I noted the 100,036 figure and the changes tool in the comment above BUDGET.
An app that sets
"sync": trueinforge.jsonnow gets an ordered change stream from the forge, reached through one documented route and one MCP tool.test/app-changes.test.tshas two clients appending to one room and both reading the same order. The change-stream, MCP, OpenAPI, docs and/llms.txtbudget tests I ran pass, as dotscandscripts/gate.ts --fix. I did not run the full suite, andscripts/fast.tssaid the diff was too broad to name tests.What changed
syncis a top-level boolean inforge.json; anything else is refused.GET /api/v1/repos/:owner/:name/changes/:room?since=N&limit=returns{ changes: [{ seq, room, data, at }], next, here }, oldest first.POSTwith{ "data": <json> }returns201 { seq }.nextback assinceafter a reconnect.herelists everyone who touched the room in the last 30 seconds. It lives in memory only.canEnterApp) can read and append. An app that has not declaredsyncgets404 not_synced. A bad room is refused422, and a read-only token cannot append.changestool,{ repo, room, since?, data? }: withdatait appends, without it reads.src/apps/changes.ts, which is now reached (its allow-list entries are gone). The new code issrc/apps/room_presence.ts,src/actions/app_changes.tsandsrc/http/api/app_changes.ts. I also added the OpenAPI rows, an alias puttingchangesunder theappstag, anddocs/features/sync.md.Choices to check
changesis its own tool, not an action onapps. Puttingroomandsinceinto theappsschema pushed the fresh-connectiontools/listover its 6,000-byte ceiling, and I did not raise it.changesis not inDEFAULT_TOOLS, sofind_toolreaches it and the fresh list does not grow./llms.txtover its byte budget. I shortened the line to fit and left the ceiling alone.Left out
since.Try it
"sync": truein an app'sforge.jsonon its default branch.POST /api/v1/repos/<owner>/<app>/changes/lobbywith{"data":{"n":1}}.GETthe same path with?since=0.changeswith{ repo, room: "lobby" }.Closes #10839