Repository navigation
Messages carry files: upload with a send, read back through the message - #4889
Merged
Merged
Conversation
…ad through their message A send (comms_user_send from a UI, comms_send from an agent) may carry files, each a name, MIME type and base64 data, 8 MiB per message in all. The list is left off the wire when empty, so a send with no files is the request an older Core decodes. MessageFiles is a carried DurableStore beside the bus: bytes once per SHA-256 and one row per message file keyed by the message's reference. Message is unchanged, so every page and message an older reader decodes is the one it decoded before (tools/old_reader_decodes_files.py runs the installed runtime's decoder over one). comms_message_files lists a page's files and comms_message_file returns one file's bytes. Both name the conversation and participant the way comms_history does, and refuse any message that conversation's display scope does not include, so a file is read only by whoever may read its message; the digest is storage, not access. An agent learns of a message's files from the line its delivery derives: the native delivered segment and a local CLI bridge's frame each name every file with the read that returns it. A remote watch frames the wire message on the session's machine, whose installed decoder knows no files, so both ends of that route frame the body alone. The connector's request body limit and the native tool socket's line limit derive from the file limit, so a send at the limit is accepted on either route. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…bridge The old-reader proof tool carries no string-keyed records and types its reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…tes files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…rd both check it A record naming a directory, only dots, a backslash or NUL never decodes, so a reader keeping a file under its name needs no check of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…lass frame() widened every route's frame to IncomingFrame, so the monitor routes lost their frame's type. Each route builds its frame from incoming_frame as before and answers files_of; a remote watch names none. A read export skips a message the bus no longer holds, as the other confirmation loops do. The wake frame no longer carries a copy of the batch's files: input_segments takes them from the reader. Comms declares messaging as the Messaging it holds. The file name rule is two checks, and the touched lines and imports are formatted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…onfirms nothing messages() returns the held messages at the given references; message() derives from it. read_export loops over what is held instead of testing for None. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
|
debt-tools at b80128b failed without a verdict line; the last lines of its stderr: |
|
debt-src at b80128b failed without a verdict line; the last lines of its stderr: |
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.
What
Messages can carry files. Toad's file picker (Android SAF, desktop dialog or path search, TUI pickers) sends them, and recipients read them back through the message.
messaging/message_files.pyholds three pieces:FileUpload: name, MIME type and base64 data, validated likeImageInput, 8 MiB per message in all.MessageFile: message reference, position, name, MIME type, size and SHA-256.MessageFiles: a carriedDurableStore(message_files.sqlite3) holding bytes once per SHA-256 and one row per message file.comms_user_send(UI) andcomms_send(agents) takefilesthrough oneSendsFilesmixin. The list is left off the wire when empty, so a file-free send is the request an older Core decodes.comms_message_files(conversation, participant, messages)lists a page's files.comms_message_file(conversation, participant, message, position)returns one file's bytes.Why
Messageis unchangedThe field codec refuses unknown fields, so a file field on
Messagewould crash every installed client: the phone APK and the installed TUI. Files are rows beside the bus keyed byMessageReference. Every page, inbox and history an older reader decodes is byte-for-byte what it decoded before.Visibility: one rule, the message's own
A file is read only through its message. There is no second check:
ServedMessageFileRead.readableasks the owner that decides which messages a conversation read returns. It builds the conversation'sHistoryViewfor the caller's viewer exactly ascomms_historydoes (CommandTarget.history_view(caller.history_viewer(participant), ...)), captures itsMessageDisplayScope, and refuses any named message whosescope.includes(message)is false. A message missing from the bus is refused the same way. Both reads, the list and the bytes, go through it. A DM's files are therefore readable only as one of its participants, and a channel's by whoever reads the channel.participantis named the waycomms_history's is, so file reads are exactly as open as history reads, no more. The digest only deduplicates storage and grants no access.Refusal test:
tests/test_message_files.py::test_a_reader_outside_the_conversation_is_refused_its_files. An outsider is refused the list and the bytes of a DM it is not in, including through a channel it reads; a missing position is refused; and a channel message's file is readable by a non-sender.Agents see the files
DeliveredMessageSegment) and a local CLI bridge's frame derive one line per file from the store, naming the read that returns it. Each route keeps its own frame class (incoming_frame); the route answers only which files it names (HarnessDeliveryRecords.files_of).PushedTranscript.files_ofnames none, and the watch client frames the body alone (ClaudeMonitorFrame.of_wire). Naming files there needs a watch protocol change and its own rollout.Limits derived from one owner
MAX_SEND_REQUEST_BYTESderives from the file cap. It sets the connector'sclient_max_size, which aiohttp otherwise defaults to 1 MiB and which would refuse any file over about 750 KB, and the native tool socket's line limit.Evidence
Head b80128b, base 4d0206b (the merge base).
tests/test_message_files.py), 6 of 6 pass:fileskey;.,..,../escapeand a backslash), all refuse before anything is written;DurableFile,ReconciledFile.existing_inlists it, andcarry_schemakeeps its rows (the carry test).tests/test_coordinated_runtime.py::test_delivered_frame_names_each_file_with_the_read_that_returns_it;tests/test_codex_delivery_reporting.py::test_a_bridge_frames_a_message_with_its_files_and_refuses_an_echo_without_them.tools/old_reader_decodes_files.pyruns the installed runtime's own interpreter,$(head -1 ~/.local/bin/toad), withagent_commsfrom its site-packages and no PYTHONPATH. It decodes a DM page, a channel history, an inbox and a file-free send request, all carrying file-bearing messages:test_acp_selected_write_plan::test_second_pid_public_acp_owner_ipc_preplan: pass.test_concurrency::TestConcurrentWire::test_concurrent_claims_allocate_unique_names: pass.test_forks::test_registered_fork_sends_parent_problem_with_fork_actor: pass.test_monitor_delivery::test_wrong_complete_parts_stay_pending_without_claiming_delivery: failed on this branch (IncomingFramemissingfiles, from a fixture building a frame by hand). Fixed: the fixture frames through the route. It passes.test_private_idle_drain.py::test_observation_waits_for_the_held_coordinator_snapshot, fails the same way on base 4d0206b (assert not any(task.done() ...)). It is blocked by this host's systemd user manager outage since 04:54 and will be rerun once that is back. Its path (input_drain._observe_private_revision) does not reach this change.read_export. Its tests on b80128b (test_claude_turn,test_monitor_delivery,test_inbox_watch,test_codex_delivery_reporting,test_message_files): 139 passed, 0 failed.tools/nra_gate.py, base 4d0206b, head b80128b):--root src: exit 0. 17 paths, nothing introduced, nothing grew. Eight type errors that exist on base are gone:inbox_watch−1,shared−1,connector−1,send−1,served−2, and toad'sfocus_burst_scenarioclient check −2.--root tools: exit 0, nothing introduced.Rollout
A toad built from that branch needs this change on the bus first: it reads a page's files through
comms_message_files.🤖 Generated with Claude Code
https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3