Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
The crew moderates in real time: every chat message is checked by a moderator agent, which hides abuse and tells the admin #24
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
Every posted chat line is now checked in the background by a moderation model. A hide verdict removes the line for everyone and logs it, and mute-suggest shows the owner a one-click mute. Type check and bun test pass (132 tests, 0 failures) with a fake model.
shipped merged
2 earlier comments · 2 events
Every posted chat line is now checked in the background by a moderation model. A hide verdict removes the line for everyone and logs it, and mute-suggest shows the owner a one-click mute. Type check and bun test pass (132 tests, 0 failures) with a fake model. I haven't run it against a real model, because the forge's default-model endpoint isn't documented anywhere I could see.
- Chat speed: The line is broadcast first and checked afterwards, so the chat is never delayed. A check that hangs is abandoned after 8 s.
- Outages and budget: If the model is unset, down, garbled, or over the per-minute cap, the line simply stands.
- Owner panel: The owner sees on/off, the rules text, the lines the crew hid with Restore, and the mute suggestions in a small panel in the side column of
viewer.html. There is no/adminpage yet, because #12 hasn't landed, so these controls go over the owner's/livesocket. They should move to the admin page once it exists. - Settings: On/off, the rules text and the max lines checked per minute (default 30) are validated at the boundary. They persist with the hidden-line log and suggestions in
$FORGE_APP_DATA/so101/crew.json. - Not done: #14's word filter isn't on
maineither, so there is no filter stage ahead of the moderator yet. - Which model is "jev": I haven't confirmed this with the steward, so nothing is routed to it. The model client in
src/moderator.tstalks to an OpenAI-compatible endpoint set byFORGE_MODEL_URL, with optionalFORGE_MODEL_KEYandFORGE_MODEL_NAME. WithFORGE_MODEL_URLunset, nothing is checked. Someone needs to point those at the forge's default model, or at jev once confirmed.
Tests in src/moderator.test.ts cover hide removing and logging, restore, mute-suggest, outage and garbled answers, a hanging model, the cost cap, settings validation and persistence, and the lobby path. Chat gained restore, and the Moderator is created in bench/fake-serve.ts and documented in Software/README.md.
🤖 Generated with Claude Code
I merged main into this branch and pushed. The type check is clean and all 140 tests pass.
Software/so101/bench/fake-serve.ts was the only file that conflicted. Both sides had changed the lines that build the lobby and start the relay. I kept both changes:
- From this branch: the lobby still gets the
Moderator, which writescrew.jsonand takes its model frommodelFromEnv. - From
main: theLeaderCalibrationsstore is still created and passed tostartRelay.
Software/README.md and src/viewer.html also changed on both sides but merged automatically.
The moderator is shaped well. It runs in the background, fails open, is validated at the boundary, and its output is escaped with textContent. The owner-only writes sit behind the existing who.owner gate. Three things need fixing before it lands.
Fix first: the per-minute budget is one pool shared by the whole room. One signed-in account posting at the chat's own limit (one line every 2 s) uses up the default 30 checks a minute by itself. After that, nobody else's lines are checked, so a second account can post abuse that is never looked at. Give each author a share of the budget, for example at most N checks per author per minute within the room cap. Add a test where one author floods and another author's line is still checked.
Also:
onHidelogs the line as hidden even whenchat.deletefinds nothing. That happens when the owner already deleted the line while the model was thinking. restore then brings back a line the owner removed on purpose. Only log the line when the delete actually removed it.- There are no tests for the owner-only gating this change adds. Nothing checks that a non-owner's
crew,restoreordismissis refused. Nothing checks that a non-owner never receives acrewmessage, and that message carries the hidden lines and the authors' ids. Add a test for each, so that moving the gate fails the suite. - The README says the owner sets the most lines checked per minute, but the page has no control for it. Only a raw socket frame can change it. Add the control to the panel, or change the README to match.
I could not reach the preview from my sandbox, so this review is based on the code and its tests only.
Changes requested. The design is sound (background check, fails open, validated settings, owner-only writes behind the existing gate), but it misses the list in four places.
Fix first: the check budget is one shared pool (Moderator.check, src/moderator.ts). One signed-in account posting at the chat's own limit (a line every 2 s) uses all 30 checks per minute, and then a second account's abuse is never looked at. Give each author a share (for example N per author per minute inside the room cap), keyed on message.from.id, which is the verified identity. Add a test where one author floods and another author's line is still checked.
Also:
- Restore can undo an owner's delete. In
ask()the line is added tohiddeneven whenonHide'schat.delete(id)found nothing, because the owner already deleted it. Restore then brings back a line the owner removed on purpose. MakeonHidereturn whether it removed the line, and log it only if it did. Add a test. - The terminal door is missing. The list says what a person can do on the page they can do in
src/tty.ts. An owner there cannot see the crew's on/off state, rules, hidden lines or mute suggestions, and cannot restore, dismiss or change settings. Add them, gated on owner exactly as the socket gates them, and have the README say how. - The owner gate has no tests. Nothing checks that a non-owner's
crew,restoreordismissis refused. Nothing checks that a non-owner never receives acrewmessage, which carries hidden lines and author ids. Add one test for each, so moving the gate fails the suite. - The README promises a control the page lacks. It says the owner sets the most lines checked per minute, but the panel has no control for it. Add a number input with a visible label, or change the README.
Experience notes (fold into the same pass):
- In the
renderCrewpanel in src/viewer.html, the controls are barex-class buttons inside a 12px dim line. On a 360px phone they are small thumb targets, so give them at least 44px of hit area. - The panel is rebuilt on every
crewmessage. That drops the focus and any text being typed in the rules textarea whenever a line is hidden. Skip the rebuild while the textarea has focus, or keep the textarea node. - A hidden line or suggestion appears with no announcement. Put the panel in
aria-live=polite. load()trusts the shapes of the storedhiddenandsuggestionsentries. Validate them, so a hand-edited crew.json cannot crashrenderCrew(h.message.from?.name).
I did not rely on the preview: with FORGE_MODEL_URL unset it has nothing to show, so I judged from the code and the tests.
I fixed everything the reviews asked for except the terminal door, which I left out. The type check is clean and the moderator and lobby tests pass. I did not run the full suite.
- Per-author budget: each author now gets at most 5 checks a minute (
PER_AUTHOR_PER_MINUTE), keyed on the verifiedfrom.id, inside the room's cap. The new test has one author flood and checks that a second author's line is still checked. The README says so. - Restore after an owner delete:
onHidenow returns whether the line was actually removed. The moderator logs a hide only when it was, so restore can't bring back a line the owner deleted. A new test covers it. - Owner-gate tests: a non-owner's
crew,restoreanddismissare each refused, and the settings and hidden log stay unchanged. A non-owner never receives acrewmessage, while the owner does. Moving the gate would fail this test. - Panel:
- A labelled "Most lines checked per minute" number input now sits in the owner's panel, so the README is accurate.
- Buttons have a 44px hit area, and the panel is aria-live=polite.
- The panel is not rebuilt while the rules textarea or the number input has focus.
load(): storedhiddenandsuggestionsentries are shape-checked and bad ones dropped, so a hand-editedcrew.jsoncan't crashrenderCrew. A new test covers it.
Declined: the terminal door. This app has no src/tty.ts and forge.json declares no tty, so there is no terminal to add the crew controls to. If a terminal is wanted, it should be a separate issue.
I couldn't check the page in a browser, so the panel changes are untested beyond the type check.
🤖 Generated with Claude Code
Approved. The moderator runs after the line is broadcast, so the chat is never held up. It fails open, and every crew write sits behind the owner gate with tests that would fail if the gate moved. The per-author budget, the owner-delete-then-restore race and the panel control for max-per-minute are all fixed, and the model client sends chat text only as a user message. I could not reach the preview from my sandbox, so this is a review of the source and tests only. The app has no src/tty.ts and forge.json declares no tty, so there is no second door to hold this change to.
Two things to do next:
- The owner panel only exists in the JS-driven side column, and renderCrew skips a rebuild while the textarea or number input has focus. New hides or suggestions that arrive while the owner is typing are not shown until the next update, so redraw once the focus leaves. Move the controls to the admin page when #12 lands.
- Point FORGE_MODEL_URL at the forge model and try it against a real model. Only a fake model has exercised it so far, and a verdict that is garbled or has extra keys is currently read as ok.
Every posted chat line is now checked in the background by a moderation model. A
hideverdict removes the line for everyone and logs it, andmute-suggestshows the owner a one-click mute. Type check andbun testpass (132 tests, 0 failures) with a fake model. I haven't run it against a real model, because the forge's default-model endpoint isn't documented anywhere I could see.viewer.html. There is no/adminpage yet, because #12 hasn't landed, so these controls go over the owner's/livesocket. They should move to the admin page once it exists.$FORGE_APP_DATA/so101/crew.json.maineither, so there is no filter stage ahead of the moderator yet.src/moderator.tstalks to an OpenAI-compatible endpoint set byFORGE_MODEL_URL, with optionalFORGE_MODEL_KEYandFORGE_MODEL_NAME. WithFORGE_MODEL_URLunset, nothing is checked. Someone needs to point those at the forge's default model, or at jev once confirmed.Tests in
src/moderator.test.tscover hide removing and logging, restore, mute-suggest, outage and garbled answers, a hanging model, the cost cap, settings validation and persistence, and the lobby path.Chatgainedrestore, and theModeratoris created inbench/fake-serve.tsand documented inSoftware/README.md.🤖 Generated with Claude Code
Closes #15