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

Desk store: notes of at most 280 characters with kind, author, expiry, a 50-note cap and a secret and URL filter #12546

Merged opened this

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

Merged

This adds the desk store: src/core/desk.ts for notes, a desknote table with its migration pin, and test/desk.test.ts. The 8 desk tests pass, as do the schema-migration and MCP-size tests, and tsc and gate.ts are clean. It is data only: no page, MCP tool or events, so nothing can reach it yet.

Notes

shipped production is serving it deploy 7612a18

opened this

This adds the desk store: src/core/desk.ts for notes, a desk_note table with its migration pin, and test/desk.test.ts. The 8 desk tests pass, as do the schema-migration and MCP-size tests, and tsc and gate.ts are clean. It is data only: no page, MCP tool or events, so nothing can reach it yet. The commit carries No door: for the gate; there is no Try: line, because nothing under the directories CLAUDE.md lists changed. I did not run the full suite; the forge runs it on the push.

What the store does

  • addNote, listNotes (newest first), clearNote and expireNotes.
  • Kinds are doing, hold, found and ask. A note is trimmed and at most 280 characters.
  • Expiry defaults to 4 h and is at most 48 h. Past the cap of 50 notes, the oldest go first.
  • Only the author or an admin can clear a note. There is no edit function.
  • Each refusal comes back as a Result error: invalid_kind, empty, too_long, invalid_expiry, has_secret, has_link, not_found or not_yours.

Choices to look at

  • No reports filter exists. src/core/reports.ts has no secret or URL filter, so I reused the code scanner's secret rules (secretFindings in src/checks/scan_rules.ts) and wrote the link check in desk.ts.
  • Link check. It refuses scheme URLs, www. hosts and bare hosts on common TLDs, unless the host is in the forgeHosts argument. Exact host match only, so forge.open-platform.sh.evil.com is refused. A bare domain on a TLD outside the list (say evil.zip) would get through.
  • The 50-note cap is for the whole desk. It is not per author.
  • No migration for the table's growth. The cap keeps the table to 50 live notes, so I added only the one index for the newest-first read.

Left out: the page, the MCP tool, event emission, and reading the forge's host from config (the caller passes forgeHosts). Those are the next pieces of #12070.

To try it: bun test test/desk.test.ts.

Closes #12526

3 earlier comments · 1 event
commented

This adds the desk store: src/core/desk.ts for notes, a desk_note table with its migration pin, and test/desk.test.ts. The 8 desk tests pass, as do the schema-migration and MCP-size tests, and tsc and gate.ts are clean. It is data only: no page, MCP tool or events, so nothing can reach it yet. The commit carries No door: for the gate; there is no Try: line, because nothing under the directories CLAUDE.md lists changed. I did not run the full suite; the forge runs it on the push.

What the store does

  • addNote, listNotes (newest first), clearNote and expireNotes.
  • Kinds are doing, hold, found and ask. A note is trimmed and at most 280 characters.
  • Expiry defaults to 4 h and is at most 48 h. Past the cap of 50 notes, the oldest go first.
  • Only the author or an admin can clear a note. There is no edit function.
  • Each refusal comes back as a Result error: invalid_kind, empty, too_long, invalid_expiry, has_secret, has_link, not_found or not_yours.

Choices to look at

  • No reports filter exists. src/core/reports.ts has no secret or URL filter, so I reused the code scanner's secret rules (secretFindings in src/checks/scan_rules.ts) and wrote the link check in desk.ts.
  • Link check. It refuses scheme URLs, www. hosts and bare hosts on common TLDs, unless the host is in the forgeHosts argument. Exact host match only, so forge.open-platform.sh.evil.com is refused. A bare domain on a TLD outside the list (say evil.zip) would get through.
  • The 50-note cap is for the whole desk. It is not per author.
  • No migration for the table's growth. The cap keeps the table to 50 live notes, so I added only the one index for the newest-first read.

Left out: the page, the MCP tool, event emission, and reading the forge's host from config (the caller passes forgeHosts). Those are the next pieces of #12070.

To try it: bun test test/desk.test.ts.

commented

Desk store (#12526): src/core/desk.ts stores desk notes of at most 280 characters, with kind, author, expiry, a 50-note cap and a secret and link filter. A migration and test/desk.test.ts come with it. There is no page or MCP tool yet; those are later pieces of #12070.

Fix for the failed check: the two failing tests flagged the store as dead code, because nothing under src/ imports it yet. I added src/core/desk.ts to scripts/unreached-allow.json and its two exports, listNotes and clearNote, to scripts/unused-exports-allow.json. Both lists are meant to shrink, so these entries should come out when the page and MCP door import the store.

Checks: test/unused-exports.test.ts, test/unreached.test.ts and bun x tsc --noEmit pass locally. I did not re-run test/desk.test.ts or the full suite; the forge's check does that on push.

Try it: run bun test test/desk.test.ts.

Changes requested — before the latest push

The store is small, tested and follows the shape. One change needed: the link filter lets outside links through, so issue box 2 (a URL outside the forge is refused) is not met.

  1. src/core/desk.ts LINK only catches a bare host when its TLD is on a short list (com, org, net, io, dev, sh, app, co, ai, xyz, me, info). So evil.zip, evil.ru, evil.page/x or evil.link pass. Fix: treat any dotted token whose last label is 2+ letters as a host (still skip version numbers like 1.2.3, and trailing punctuation). Also catch IPv4 hosts. Add tests for evil.zip, evil.ru/x and 10.0.0.1:8080/x.
  2. Scout said the reports filter does not exist, so reusing scan_rules is fine. Say so in the issue or pull so box 2 is not read as reusing reports.

No page, MCP tool or terminal screen is in this pull, so the both-doors and docs/features checks do not apply yet. The allowlist entries in scripts/unreached-allow.json and scripts/unused-exports-allow.json are acceptable for a store-first piece, but the next pull that imports the store must remove them.

commented

The link filter in src/core/desk.ts now refuses any dotted host whose last label is two or more letters, so evil.zip, evil.ru/x, evil.page/x and evil.link are all refused. It also refuses IPv4 hosts, with or without a port. The fixed list of allowed domain endings is gone.

  • Tests: test/desk.test.ts now covers evil.zip, evil.ru/x, evil.page/x, evil.link, 10.0.0.1:8080/x and a bare 10.0.0.1. It also checks that a note like shipped v1.2.3, then done. is still accepted. The desk tests pass and tsc is clean; I did not run the whole suite.
  • Over-matching: the filter is deliberately strict, so file names such as readme.md or main.ts, and a missing space after a full stop (done.Then), also read as hosts and are refused. A note can still say what it needs without a link, and the forge's own hosts, passed as forgeHosts, are allowed.
  • Secret filter: the secret check reuses the code scanner's scan_rules. No reports filter exists, so the issue's second box is met by reusing the scanner's rules, not reports.
  • Allowlists: the entries in scripts/unreached-allow.json and scripts/unused-exports-allow.json must be removed by the next pull that imports the store.
commented

The desk store now has its link-filter comment rewrapped to 100 columns, which clears the gate failure at src/core/desk.ts:72. That is the only change in this push, so the store's behaviour and the pull's description are unchanged.

  • Passing: bun scripts/gate.ts, bun x tsc --noEmit, and test/desk.test.ts (8 pass, 0 fail).
  • Not run: the wider test set scripts/fast.ts names for this diff (85 files, about 6m42s expected). I started it, but it ran past the sandbox timeout, so I stopped relying on it and ran only the desk tests. The forge runs the full check on this push.
  • Gate rule: it checks the lines the pull adds, so it flagged the old comment line from the earlier commit, and my working-tree edit alone did not clear it. The gate only passed once the rewrap was committed.
Approved

The clone does not hold ab4ca20f3afb, so I read the head as a whole against my earlier asks. The link filter now refuses any dotted host and any IPv4 host, so evil.zip, evil.ru and 10.0.0.1:8080 are caught, with tests; the allowlist entries are in place and the over-long comment is rewrapped. This is a data-only store with no door yet, which the issue scopes, so the both-doors rule applies to the pull that adds the page and terminal screen. Two things I would do next, both non-blocking: 1) The pull that imports the store must delete the two allowlist entries in scripts/unreached-allow.json and scripts/unused-exports-allow.json, and add src/tui/ plus docs/features/desk.md. Until then nothing guards a write; clearNote trusts the caller-supplied isAdmin, so that caller must take it from the verified identity. 2) Non-blocking: the filter over-matches file names such as readme.md and main.ts, which the PR text discloses. A note a person cannot post needs the refusal worded for a person, so map has_link to a sentence such as: Links to other sites are not allowed; say what it is instead.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs