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 #1633

Closed opened this
Closed without merging

A thought the owner types to the forge is now kept verbatim, with time and source, in an append-only ledger. I merged current main into this branch to refresh the earlier work, and the merge needed no conflict fixes. Type check is clean; thoughts, mcp, tui-apps, limits, feed and snapshot tests pass.

Notes

stopped closed without shipping deploy 28e814b

opened this

A thought the owner types to the forge is now kept verbatim, with time and source, in an append-only ledger. I merged current main into this branch to refresh the earlier work, and the merge needed no conflict fixes. Type check is clean; thoughts, mcp, tui-apps, limits, feed and snapshot tests pass. I did not run the whole suite or the impact-driven gate.

I did not look into why the preview deploy failed last time, so I can't say that cause is gone. The only thing I changed is the merge with the latest main.

What changed

  • Ledger: migration 77 adds a thought table: id, author, verbatim text, source (composer, api, mcp, share, terminal) and received_at. Triggers abort any UPDATE or DELETE, so no code path can rewrite a thought. The ledger is in src/core/thoughts.ts.
  • Intake:
    • The feed composer's app picker now offers "the forge", meaning no repository.
    • POST /api/v1/thoughts {text} needs rw access.
    • MCP tell without repo writes a thought and returns its id.
    • In the terminal, t on the launcher tells the forge.
  • Feed: each thought shows as a "received" post in the owner's feed, verbatim and escaped. A thought.received event goes onto the outbox for the triage issue.
  • Nothing dropped: empty and duplicate text are still stored. Spotting repeats is left to the repeats issue.
  • Docs and tests: README.md and docs/FEED.md describe it. test/thoughts.test.ts covers the verbatim round-trip, append-only behaviour, and each source.

Left out

  • Triage, which routes a thought on to where it belongs, is the next issue.
  • The share source exists in the ledger, but nothing writes it yet.
  • No new screen or dependency.

To try it

  1. Open the feed and choose "the forge" in the composer. Send a thought and it appears at the top.
  2. Or curl -X POST -d '{"text":"…"}' /api/v1/thoughts.
  3. Or call MCP tell {text} with no repo.

🤖 Generated with Claude Code

Closes #1060

2 earlier comments · 1 event
commented

I couldn't reproduce the six failing asks tests, so I can't say they're fixed; I moved my migration to 78 and pushed.

The asks tests pass here: asks, asked and planner-declined pass on their own and together with thoughts, and I ran a six-way shard split of the gate with no failures. I didn't see the failing assertions or error text, so I don't know why they failed in the forge's run. Shards 2 and 4 in that run were killed (exit 143), which may mean the machine was overloaded. If the check goes red on the asks tests again, I need the assertion message from its log.

The one real problem I found was that main moved on and took migration 77 for OpenID Connect. I merged main again, kept OIDC as 77, and renumbered the thought ledger to 78 in src/core/schema.ts and the comment in src/core/thoughts.ts. I ran tsc --noEmit and these tests, which all pass: thoughts, asks, mcp, schema, migrate, snapshot, tui-apps. I did not run the whole suite.

The push is fd89de3c, so the forge will run its check on it.

🤖 Generated with Claude Code

Changes requested — before the latest push

The ledger, the triggers, the API, the MCP and terminal doors, and the escaped feed card are all sound. Identity comes from the session, token or SSH user. Bodies go through body(), which caps on bytes read, so an oversized body becomes {} and gets a 422. Writes need rw, SQL is parameterised, and the terminal write reaches web viewers through thought.received in FEED_LIVE.

High, fix first: the main door does not keep the thought verbatim. With JavaScript on, which is how almost every composer post is sent, the submit handler in src/web/studio/feed.ts:315 runs var text = box ? box.value.trim() : ''; and queues the trimmed text to /api/v1/feed/tells. A thought typed as " idea\n\n" is stored as "idea". That breaks the promise in the issue, the README and docs/FEED.md ("kept exactly as typed … not trimmed"). The test misses it because it calls the API directly with composer, json and never goes through the page's script. Fix: when app.value === '-', send box.value untrimmed (still skip an empty box). Keep the trim for app tells. Add a test that would fail on the current code, for example one that checks the composer script sends the raw value for the forge choice.

Low, fix while you're there:

  • The MCP tell schema now says text.maxLength: MAX_BODY (65,536). A thought allows only 20,000, so a client that trusts the schema sends 20,001 to 65,536 characters and gets invalid_text. Say so in the schema, or drop the shared maxLength and let the description state both limits.
  • README: the "A token's requests…" sentence was left as an over-long line inside a wrapped paragraph. Re-wrap it.
  • test/thoughts.test.ts: the rate-limit test only greps server.ts for a string, so it tests nothing about thoughts. Either make it hit /api/v1/thoughts past a small limit, or drop it.

I couldn't check the preview or the screenshots from my sandbox: the preview host and /data/looks are both denied. This verdict comes from reading the diff at fd89de3c.

commented

I've fixed all four of sentinel's points and pushed the branch. The type check, test/thoughts.test.ts and the MCP tests pass; I didn't run the rest of the suite.

  • Composer trimming (high): the composer's submit handler (src/web/studio/feed.ts) now sends box.value untrimmed when the choice is the forge ('-'). App tells are still trimmed, and an all-whitespace box is still skipped. The new test in test/thoughts.test.ts checks that the served page carries that line. It would fail on the old code. It checks the script text, not a browser run, so I haven't confirmed the behaviour in a real browser.
  • MCP schema: I dropped maxLength: MAX_BODY from the tell text property in src/http/mcp.ts. The description already states both limits: a thought allows 20,000 characters and a tell to an app 65,536.
  • README: I re-wrapped the "A token's requests…" sentence.
  • Rate-limit test: I deleted the test that only grepped server.ts. I didn't replace it with one that hits /api/v1/thoughts past a small limit, so a token's thoughts and MCP tells are no longer covered by any thought-specific test of the limit.

To try it, sign in, pick "the forge (no app)" in the home composer, and post " idea\n\n" with JavaScript on. The stored thought keeps the spaces and newlines.

🤖 Generated with Claude Code

commented

Parked by the crew: the check failed ("asks that earn their place > five rows by default, the rest one tap away; a phone shows two (#883)") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs