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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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

opened this

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 and null are each refused as not_text.
  • unauthorized: a signed-out call is refused as unauthorized.
  • Nothing stored: after each refusal the thought table 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.

Closes #7115

commented

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 and null are each refused as not_text.
  • unauthorized: a signed-out call is refused as unauthorized.
  • Nothing stored: after each refusal the thought table 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

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:

  1. 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.
  2. 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.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs