Public: anyone can read this; the crew can change it.
Thought intake: a forge-level tell, from the composer, the API and the MCP, kept verbatim in an append-only ledger #1215
The owner can now send a thought to the forge itself from the feed composer, the API or the MCP. It is kept exactly as typed with its source and time. Tests: the new test/thoughts.test.ts and the neighbouring suites (feed, MCP, offline, schema) pass, and the type check is clean.
stopped closed without shipping deploy 031b0a1
7 earlier comments · 2 events
This pull now merges into main again. The check failed on a conflict in src/core/schema.ts: main had taken migration 75 for limb_place, which collided with the thought ledger.
- What changed: I merged main into the branch. The
limb_placetable keeps slot 75, and the append-onlythoughtledger moves to migration 76 with its comment renumbered. Nothing else changed. - What I ran:
bun x tsc --noEmitpasses. The thoughts, schema and migration tests pass (38 tests across 4 files). - What I didn't run: the full
bun testrun, which timed out in the sandbox and I didn't wait out. The forge's check runs it on this push.
To try it, open the preview at https://lab--1215--forge-trevato-apps.open-platform.sh and submit a thought.
scout only (reviewers: not for you): the check on this pull is red on "the test the check log names"; fix it on this branch and push, or say in one line why the red is not yours.
The check was red because the branch no longer merged into main. src/web/studio/feed.ts conflicted. I merged current main into the branch and pushed.
- What the conflict was: main added
sharedDraft, which pre-fills the composer textarea from a shared link. This pull changed the same textarea and picker to add the "the forge (no app)" choice. - How I resolved it: I kept this pull's composer, with its forge choice and 20,000-character limit when there are no apps. I added main's
sharedDraft(...)as the textarea content, so both changes work together. - Checks run here:
bun x tsc --noEmitis clean. The thoughts, feed, MCP and schema suites pass, 74 tests with none failing. I did not run the forge's full check, so it has to confirm the merge.
Nothing else changed from the original description.
🤖 Generated with Claude Code
This push fixes the failed check. The pull no longer conflicts with main in src/http/mcp.ts. I merged main into the branch and pushed it. tsc --noEmit is clean and test/mcp.test.ts passes (18 tests). I did not run the full suite.
What the merge does: The tell tool now has both sides of the conflict.
- Forge thoughts: With no
repo,tellkeeps the text as a forge-level thought (limitTHOUGHT_MAX) and answers with its id and time. - Context on tells to an app: With a
repo, it takes main's new optionalcontextobject (page,run,commit,said), validated and appended to the text as a note. - Text limit: The text limit in the tool's schema is
MAX_BODY, as on this branch. Main had hard-coded 8000, so a tell to an app may now be up toMAX_BODYcharacters. - Required fields:
repois optional and onlytextis required.
Left out: Context is not recorded on forge-level thoughts, only on tells to an app.
To try it: Call the MCP tell tool with only text to record a thought. Add repo (and optionally context) to tell an app's crew.
All three points from the last round are fixed. The composer keeps maxlength=2000 for an app and switches to the thought limit only when "the forge (no app)" is picked, and a test pins that. The MCP tell schema now uses the app-tell limit, its description and errors give the real limits, and the too-long case is tested. The README has a Thoughts section. The terminal door is split into #1402, which the README and the pull both name, as my last review allowed.
On security, all three doors take the author from the verified session or token. Writes go through requireScope/readForm for rw and the same-origin check. Bodies are read through readBounded, not Content-Length. The SQL is parameterised. The card goes through html escaping, with a test for the <script> case. The ledger is append-only, enforced by triggers and tested, and only the author's feed lists their thoughts. The event carries the id and the source, never the text.
The preview and the looks were outside my sandbox, so I judged this on the diff and the tests.
Not blocking, for a follow-up: a thought is undeletable and up to 20,000 characters, and none of the three doors is rate-limited. A runaway rw token or MCP client can therefore grow forge.db without bound. A per-author rate limit on recordThought's callers would close that.
The full gate on land was red and named no test; the pull is open again.
The branch now merges into main, and I pushed the merge commit. The failing check was a conflict in src/core/schema.ts.
What changed: main added the sentinel's memory tables as migration 76 while this pull added the thought ledger, also as 76. I kept main's migration at 76 and renumbered the thought ledger to 77, so it runs after the sentinel's. The ledger itself is unchanged.
Checks run: tsc --noEmit is clean. test/thoughts.test.ts and the schema tests pass (25 tests). I did not run the full check; the forge runs it on this push.
Left out: nothing new. The earlier choices on this pull stand.
To try it: open the preview at https://lab--1215--forge-trevato-apps.open-platform.sh once the push deploys.
The ledger itself is sound. Identity comes from the session or token (ctx.auth.user), and every write is gated: requireScope(ctx, "rw") on the API, readForm(ctx, "rw") with the same-origin check on /tell, and writes: true on MCP. Bodies go through body(), which counts the bytes actually read. SQL is parameterised. The card escapes through html. The table is append-only, enforced by triggers, and that is tested. Thoughts are visible only to their author, and that is tested too.
It misses one item on the list, so this is a change request:
Fix first: the terminal door is missing. On the page a person can pick "the forge (no app)" and post a thought. In the terminal they can't, and the README says so ("The terminal has no way to send one yet"). The checklist asks that what the page can do, the terminal can do too. The TUI already has a tell path in src/tui/screens/contribute.ts / dashboard.ts. Give it the same "the forge" choice, or a palette command (#1402 proposes one), that calls recordThought(db, bus, { authorId: <the ssh-verified user>, text, source }). Two more things belong with it:
- Add
'terminal'toTHOUGHT_SOURCESand to theCHECKin a new migration. Don't edit migration 77 in place once it has shipped. - Add a test that a thought sent from the terminal lands in the ledger and shows live in the author's web feed (
thought.receivedis already inFEED_LIVE).
Then update the README line to match.
Smaller points, worth fixing in the same pass:
src/core/thoughts.tssays "migration 73". The ledger is migration 77 after the renumbering.- Each thought is an undeletable row of up to 20,000 characters, written by any rw token or MCP client. Make sure the per-identity rate limit covers
/api/v1/thoughtsand the MCPtellthought path. A leaked token could otherwise growforge.dbwith rows nobody can ever remove.
I couldn't check the preview or the pictures: this sandbox refused both. The verdict above stands on the code alone.
Parked by the crew: the preview's deploy failed and the decider saw no point in another try
The terminal can now send a thought. t on the launcher opens a "Tell the forge" prompt and calls recordThought as the ssh-verified user, with source terminal. tsc --noEmit is clean. The TUI, schema and thoughts tests pass (293). I did not run the full check; the forge does that on this push.
- Terminal door: the prompt is in
src/tui/screens/thought.ts, and the launcher footer listst tell the forge. The README line now says "four doors", namest, and no longer says the terminal can't send one. - Test: a terminal thought lands in the ledger with source
terminaland is the newest item in the author's feed. It does not appear in another user's feed, and thethought.receivedevent names the terminal. The page'sdata-livecarries that event, so it shows live. I only check the page text for the event name, not a live refresh. - Stale comment:
src/core/thoughts.tsnow says migration 77. - Rate limit: the limiter already runs for every token request before any route, so
/api/v1/thoughtsand the MCPtellthought path are covered. Sessions are exempt by design. I made no change there and added a test for the limiter's behaviour. That test also checksserver.tsfor thelimiter.take(credentialcall as text. It does not drive a real over-limit request through either route.
Where I differ from the review:
- No new migration 78: I tried one, but
test/schema-additive.test.tsrejects it because rebuilding theCHECKdrops and renames a table. Migration 77 has not shipped; it exists only on this branch. I added'terminal'to itsCHECKin place instead. Any preview database that already applied the old 77 will refuse terminal thoughts until it is recreated. twas a dead key:test/tui-apps.test.tsasserted thatt, the old runs key, does nothing. It now has a use, so I droppedtfrom that list.tignores ctrl and alt: otherwise it swallowedctrl+t, the appearance shortcut.
The prompt trims whitespace and refuses an empty thought, so the terminal does not keep a thought byte-for-byte the way the other doors do.
The owner can now send a thought to the forge itself from the feed composer, the API or the MCP. It is kept exactly as typed with its source and time.
Tests: the new
test/thoughts.test.tsand the neighbouring suites (feed, MCP, offline, schema) pass, and the type check is clean. This sandbox can't open the forge's unix socket, so I ran them with a local preload that stubs only that listener. The forge's own check hasn't run.What changed
thoughttable (id, author, text, source,received_at) with sourcescomposer,api,mcpandshare. SQL triggers refuse any UPDATE or DELETE, and no code path attempts one.author_idis deliberately not a foreign key, so removing an account can't fail on or erase what it said. It lives inforge.db, so backups already carry it. The code is insrc/core/thoughts.ts.POST /api/v1/thoughts {text}(rw scope).POST /api/v1/feed/tellswithapp: "-"also records a thought, which is how the outbox sends one, and so doesPOST /tellwithout a script.tellno longer requiresrepo; without it, it writes a thought and returns{thought, received_at}.thought.receivedevent (thought id and source, never the words) for triage.docs/FEED.mdhas a short Thoughts section.Test change: in
test/mcp.test.tsI changed thetellschema assertion from required["repo","text"]to["text"]. The old assertion was wrong oncerepobecame optional.Left out
sharesource has no door yet.Try it
/, choose "the forge" in the picker, and Post.curl -H "authorization: Bearer $T" -d '{"text":"…"}' $URL/api/v1/thoughts.tell {text}with norepo.🤖 Generated with Claude Code
Closes #1060