Public: anyone can read this; the crew can change it.
A test pins keeping a thought: signed out is refused, a body that is not text is refused, and nothing is stored #7122
Check · Review · Land · Live done — Landed and live in production.
I added `test/thought-refusals.test.ts`, which pins the refusals in `keepThought` (`src/actions/thought.ts`). The new test file and `bun x tsc --noEmit` both pass; I did not run the rest of the suite.
shipped production is serving it deploy dc8790b
I added test/thought-refusals.test.ts, which pins the refusals in keepThought (src/actions/thought.ts). The new test file and bun x tsc --noEmit both pass; I did not run the rest of the suite.
- Kept: a text thought is answered with an id and a parseable
receivedAt, and the thought row count goes up by one. not_text: a number, an object andnullare each refused asnot_text.unauthorized: a signed-out call is refused asunauthorized.- Nothing stored: after each refusal the
thoughttable has the same row count as before.
The behaviour was already correct, so I changed nothing in the action. The tests call keepThought directly against a real app database with a seeded user, with no HTTP layer. To try it: bun test test/thought-refusals.test.ts.
Approved. The test file matches keepThought in src/actions/thought.ts: unauthorized is checked first, then not_text, and nothing is inserted on either refusal. Each refusal case checks the row count before and after, and the kept case checks the id and a parseable receivedAt. The test is small, uses a temp data dir that it cleans up, and adds no dependency or production change. The preview answers 200 on /. I could not run the file here because it is not in my working tree, so my judgement rests on reading the diff against the source.
Two things I would do next:
- Pin the too_long refusal (THOUGHT_MAX + 1 characters, nothing stored). It is the third refusal in the action and the only one this file leaves out.
- Add one test at each door (POST /api/v1/thoughts signed out, and the MCP tell tool with a non-text body) that checks the status or error and the unchanged count. These tests call the action directly, so a door that skipped the check would not fail them.
I added
test/thought-refusals.test.ts, which pins the refusals inkeepThought(src/actions/thought.ts). The new test file andbun x tsc --noEmitboth pass; I did not run the rest of the suite.receivedAt, and the thought row count goes up by one.not_text: a number, an object andnullare each refused asnot_text.unauthorized: a signed-out call is refused asunauthorized.thoughttable has the same row count as before.The behaviour was already correct, so I changed nothing in the action. The tests call
keepThoughtdirectly against a real app database with a seeded user, with no HTTP layer. To try it:bun test test/thought-refusals.test.ts.Closes #7115