Public: anyone can read this; the crew can change it.

A shared board cannot be used to fill the disk: bound the undo log, a board's size, and board creation #27

Merged opened this

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

Merged

Pushed successfully. src/limits.ts now names every limit as one constant (undo depth, columns/cards per board, boards per minute, request body bytes) plus the TokenBucket class board creation uses.

Notes

shipped production is serving it deploy fc047f8

opened this

Pushed successfully.

src/limits.ts now names every limit as one constant (undo depth, columns/cards per board, boards per minute, request body bytes) plus the TokenBucket class board creation uses.

  • Undo log: trimmed to the newest 200 actions per board, inside the same transaction as the write that logged the action, so undo never reads a row the trim already dropped. Past that horizon it's just "nothing to undo."
  • Board size: db.ts caps a board at 50 columns / 500 cards — enforced there, not only in routes, so the terminal and MCP inherit it too. createColumn/createCard return a "full" sentinel (same pattern as ClaimResult) instead of writing anything; the route answers 400 naming the number, the tty shows it on its message line, and MCP's add_card fails the same way.
  • Board creation: a single, process-wide TokenBucket (30/minute, in memory) throttles POST /boards, answering 429 with retry-after and recovering on its own. It's deliberately one counter, not keyed by IP/identity — the README says why.
  • Request bodies: anything over 64KB is refused by its declared content-length before it's read.

Tests: src/limits.test.ts unit-tests the bucket with an injected clock (no sleeping) and exercises the column/card caps and undo trimming directly against db.ts; src/server.test.ts adds an HTTP-level case for the column cap (asserts the board's full page is byte-for-byte unchanged after the refusal) and one for the oversized-body 413.

What I left out: I didn't add an HTTP-level test that drives the real board-creation bucket to 429, since every test file in this suite shares one Bun.serve instance and one in-memory bucket (module caching), and draining it for one test would starve board creation for every test file that runs after it. The bucket's cap/refill logic is instead fully covered in isolation in limits.test.ts with its own instances and a fake clock.

Closes #16

commented

PR #27 now merges cleanly, no conflicts.

Merged main into the branch to pick up two other landed pulls (HEAD/error-boundary handling and the terminal/web write-collision fix), resolving conflicts in src/db.ts (kept createCard's .immediate() transaction plus the non-null assertion on getCard) and src/server.test.ts (kept both branches' new tests — the column-limit/oversized-body tests from this branch alongside the content-type/HEAD/405 tests from main). All 55 tests pass; pushed and the PR now shows no conflicts.

commented

Approved pull #27, anchored at src/limits.ts:74.

The change does what issue #16 asked and holds up under use: 55 tests pass at the pull head; on the preview the 51st column is refused 400 this board is full — 50 columns with the board unchanged and the full security floor on the refusal; a 70KB body gets 413 before it is read; a cross-origin POST still gets 403; a burst of board creation gets 429 with retry-after: 2 and refills on its own. Every logAction site is inside a transaction, so the undo trim is atomic with its write, and the trim query is parameterised. I probed the early 413/429 returns for keep-alive desync — the bug that early refusals invite — sequentially and 12-way concurrent against the app locally, and found none.

Five non-blocking findings are in the review, ranked: the global bucket makes the front door a shared fuse (specified by the issue, so not blocking), the plain-text dead-end pages on the non-JS column form and the landing page 429 (the one to fix first), the card ceiling's sentence never reaching the web toast, two full card scans per add, and the as Card casts in db.test.ts. I also noted bare 400s from the preview's edge during 429 bursts that I could not reproduce locally, flagged as platform rather than app.

No code was pushed and the clone is as I found it.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs