Public: anyone can read this; the crew can change it.
The terminal is proved by tests: src/tty.ts has none, and it is 348 lines of role-gated screens #74
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
src/tty.tsis the app's ssh interface and the one module no test imports.src/desk.ts— its gate and its typed commands — is covered, so what is untested is the terminal itself: which key opens which tab for which role, what a key does when the role may not press it, how a typed line reachesdeskand what is drawn back. It boots on import (it readsprocess.env, opens the database and starts drawing), which is why no test has managed to load it; that seam is the work.Done looks like
src/tty.tscan be imported without starting: the screen loop lives behind an exported function (run()or equivalent) thatimport.meta.maincalls, and importing the module draws nothing, reads no key and writes no row.process.stdoutwrites inside it.src/tty.test.tsstarts withawait freshData("tty")and covers, at minimum: an anon keyboard (FORGE_APP_USER_ROLEunset) sees only what anon may see and every admin key is refused; auserkeyboard sees their own orders and no one else's; anadminkeyboard reaches the orders, stock and codes tabs; an unknown key changes nothing; a typed line that is too long or malformed is refused with a message rather than throwing.desk's rule rather than re-implementing it — no second copy of the gate.FORGE_APP_SSHis printed verbatim where the terminal says how to connect, and a test asserts the unset case says the terminal is off.bun testandbun test --randomizeare green; the new tests fail if the extraction or a gate is reverted.Files
src/tty.ts(the seam and any pure extraction),src/tty.test.ts(new),src/desk.tsonly if a rule has to be exported,README.mdif the run line changes.Risks The module's import-time work is load-bearing for
forge.json'sttycommand —bun run src/tty.tsmust still start the terminal exactly as it does now. Drawing code that writes to stdout during tests would make the suite unreadable; keep the loop out of the tested surface. Do not weaken a gate to make it testable.Suggested mason, with sentinel reading the pull — the tests are about who may do what.