Repository navigation
Conversation
…sage text conversation_stats and person_stats print top phrases from message bodies, and generate_story and generate_person_story return quotes taken from them (and an API narrative built from them), all without messagePreamble. They now open with it. get_conversation and get_person_messages_range wrote a header before the preamble; it now comes first, so every warned result starts with it. untrusted_preamble_test.go registers the MCP surface in legacy, v2-primary, client and client-v2-primary mode, seeds a store with a marker only senders wrote (bodies, a voice transcript, a WhatsApp export line), calls every registered handler, and fails when a result carries the marker without starting with the preamble, when a structured payload carries it without contains_untrusted_text, when a message-reading tool stops returning the marker, or when a registered tool has no entry in its argument table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…box paths A failing Signal Desktop export helper put its combined output in the import error, and import_messages returns errors to the model verbatim. That output is the export, every message body in it. The runner now keeps stdout (the export) apart, and the error carries only stderr, capped at 2,000 bytes. The preamble test now also registers the v2 outbox shapes (with and without v2-primary), stubs the Google transport hooks so the send and react tools reach their success results, and transcribes an incoming message instead of an outgoing one. Mutants that quote a reacted-to message, echo a transcribed message's body, or attach thread bodies to a v2 send result now fail it. Marker matching ignores case. CLAUDE.md names the six shapes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failed signal-cli receive call can print envelopes before it exits, and
the receive loop copied its whole output into lastError and the poller's
error. get_status and /api/status show lastError without the
untrusted-content warning, so an incoming body could reach the model
unwarned. The failure text now leaves out every line that starts with
'{' (an envelope, or one cut off mid-write); the envelopes are still
stored, and the account-invalid and poison matchers still read the full
output.
Answers review finding 1 on PR 298.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests that a clean helper run whose stderr carries a warning still decodes (stdout is read on its own), and that an export that does not decode yields only the parser's message, never message text from it. The existing helper-failure test now shares its setup. Answers review finding 7 on PR 298. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
get_conversation and search_messages return message bodies twice: in a text block that starts with messagePreamble, and in structured content flagged only by contains_untrusted_text. Some MCP clients, Claude Code among them, give the model the structured content and drop the text block, so the model saw bodies with no warning. A payload that sets contains_untrusted_text now also carries untrusted_content_warning (the preamble's wording), marshalled as its first field so a reader meets it before any message text. Answers review finding 2 on PR 298. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Structured content that carries message text must open with untrusted_content_warning, and a new test pins that field order. - Each tool that must succeed in a shape now has to show its success text, not just avoid an error, so an early "no messages" or an unsettled delivery no longer passes. - The v2-primary shapes read through v2read over a seeded v2 store, as production does, and each read result must come from that store. - The v2 outbox primary shape seeds v2 conversations so its native sends succeed, and has a media service whose attachment bytes carry the marker; download_media must describe them, never return them. - A seventh shape, client-live, serves a scripted running app from an in-memory handler, so the daemon-routed send, react, transcript, media and status tools reach their success results. - The client shapes use a daemon client that refuses without dialling. - Google conversation stubs return a latest-message preview carrying the marker. - Legacy send results must return only the caller's own message text, the premise of their exemption from the preamble. Answers review findings 2 to 6 on PR 298. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CLAUDE.md now says that structured payloads carrying message text open with untrusted_content_warning, that send results echoing the caller's own message need no preamble, that Signal receive and import errors keep message text out, and what the guard test seeds, which shapes it runs and where each tool must succeed. Answers review findings 3 and 4 on PR 298. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A mutation run showed a send result that quoted its thread's latest incoming message passed the guard for send_group_message, and for every send in the non-primary outbox shape: the v2 conversations those sends land in held no sender messages. The v2 group now holds one, and the non-primary outbox shape seeds its v2 store too. The fixture's remote thread IDs now equal the conversation IDs, as MirrorConversation writes them, so the mirror reuses these rows. With the mutant applied, all eight outbox send subtests fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four MCP tools returned text taken from message bodies without
messagePreamble, the untrusted-content warning that the read tools prepend. This PR adds the preamble to them. It also adds a test that calls every registered tool, so a tool that returns message text without the warning fails CI. Review found three more ways message text reached the model unwarned, and the PR fixes those too:What changes
conversation_statsperson_statsgenerate_storytruncate(m.Body, 200)), API narrative built from bodiesgenerate_person_storygenerate_storyget_conversationConversation:headerget_person_messages_rangeMessages with …headerget_conversation,search_messages(structured content)contains_untrusted_text: trueonlyuntrusted_content_warningas its first fieldget_status(Signal, after receive failures)last_error, no preamblelast_errorimport_messages(Signal, on helper failure)get_conversationandget_person_messages_rangealready carried the warning. It now comes before the header too, so every warned result starts with it. That moves the conversation name and the person-match header below the warning. The preamble wording is unchanged everywhere, including the new structured field.Structured content (
internal/tools/tools.go). When a result hasstructuredContent, Claude Code hands the model that payload as JSON and drops the result's text blocks, where the preamble lives. A reviewer found this in Claude Code 2.1.318's MCP result converter, and I confirmed it there: the converter keeps the text blocks only behind an internal feature flag that defaults to off. SostructuredResultnow addsuntrusted_content_warningto any payload that setscontains_untrusted_text, holding the preamble's text. Go marshals map keys in sorted order, which would put the flag first and the warning later, so the payload marshals with the warning as its first field. Other payloads are unchanged.Signal receive (
internal/signallive/client.go). Asignal-cli receivecall can print messages, as JSON envelope lines, before it exits non-zero. The loop stores those messages, which is correct. But after repeated failures it also copied the whole output intolastErrorand the poller's error, andget_statusand/api/statusshowlastError. The failure text now leaves out every line that starts with{, which covers an envelope and one cut off mid-write. It keeps signal-cli's own diagnostics, and the logs get the same filtered text. The account-invalid and poison matchers still read the full output (see the follow-up issue).Signal Desktop import (
internal/importer/signal_desktop.go). The helper runner now returns stdout (the JSON export) separately from stderr instead of combining them.A reviewer reproduced the old leak with the real helper. It needs an abnormal failure after the export is written, such as
db.close()throwing or the 30 s timeout firing mid-write.Tools that need no preamble.
generate_vizandrender_storyreport only the path, size, counts, names, date range and timezone. The HTML file they write holds quotes and phrases, but that goes to disk, not into the tool result.send_messageandsend_to_conversationalso return the stored outgoing copy in their structuredmessagesummary. No other sender wrote that text, and the preamble's wording ("messages from external senders") would be false on it. Exempting the caller's own text is my reading of the requirement; the test pins the premise (below).Test
internal/tools/untrusted_preamble_test.goregisters the MCP surface in seven shapes:Options.V2, the in-app shape with v2 sending on)The three v2-primary shapes read through
v2readover a seeded v2 store, as production does. In both outbox shapes the v2 conversations that sends land in hold sender messages, so a send result that quoted its thread would carry the marker.The test stubs the Google transport hooks. It seeds a marker that only senders wrote into:
It never passes the marker as an argument. Then it calls every registered handler, and fails when:
messagePreamble;contains_untrusted_text: trueand withoutuntrusted_content_warningas its first field, a check the test makes on the marshalled bytes;download_mediareturns attachment bytes instead of describing them;Which tools must succeed where:
get_status, transcript and media reach their success results in client-live.TestStructuredContentOpensWithUntrustedWarningpins the field order forget_conversationandsearch_messages. It also checks that payloads without the flag stay plain maps. Ininternal/signallive,TestFailedReceiveErrorsLeaveOutPrintedEnvelopescovers the re-pair and reconnect branches, a line cut off mid-write andApplyPollerFailure. The existing failed-receive tests now also assert that no printed body reachesLastError.Fail-first. The first version of the test (commit 5c0a696, four shapes) failed against main (d863ba6) on exactly the first six tools in the table, in every shape where each runs: 16 subtests, all on the preamble assertion. No other tool failed.
Mutation checks. Eleven mutants, run one at a time at 5d9e0fc. Each re-adds a fixed leak or weakens a fixture, and each makes a named test fail:
download_mediareturns attachment bytes (M8).generate_vizfixture names nobody, so the tool stops early (M11).M7 first got past
send_group_message, because the v2 group that send lands in held no sender message; the same held for every send in the non-primary outbox shape. Commit ea80249 seeds those conversations. Rerun against it, M7 fails all eight outbox send subtests. One existing randomized property test catches M1 only on some seeds; the two deterministic tests catch it on every run. Logs:~/reviews/om-pr298-preamble-2026-11-19/runs/r2/mutation.md.Runs. At the head,
go test ./internal/tools/ ./internal/signallive/ ./internal/importer/passes, and so doesgo vet ./internal/tools/.Not covered.
/api/sendand/api/send-mediaroutes are not exercised; their results carry IDs only.Site
openmessage.ai (#283) lists warned and unwarned tools as of v0.2.9 (
site/data/facts.js), and its test checks those lists against the release tag. The site needs no change until a release ships this fix. Releases are Max's call.Status
Draft. Max decides on merging and releasing.
~/reviews/om-pr298-preamble-2026-11-19/runs/r1.20261119-005912-om-pr298-review-ro, head 10c5fbe): REQUEST_CHANGES, with three P1s and four P2s. Each finding was checked against the code (runs/r2/verify-f*.md). All seven are answered:20261119-230102-om-pr298-review-r2, at head ea80249, is queued for the next free review lane.getAttachmentcall whose partial output can reach an error.🤖 Generated with Claude Code