Skip to content

feat(contracts): stream file content in the executor FileService - #2832

Merged
blkt merged 2 commits into
mainfrom
feat/2770-chunked-file-transfer
Nov 18, 2026
Merged

blkt merged 2 commits into
mainfrom
feat/2770-chunked-file-transfer

Conversation

@blkt

@blkt blkt commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2770.

FileService moved whole files in single unary messages, so every server, proxy, and client had to raise gRPC's 4 MiB default message limit to carry a file. This changes file content to chunked streaming before #2691, #2694, #2701, and #2710 build on the unary shape.

Changes

  • ReadFile streams its response; CreateFile and ReplaceFile stream their requests. Message fields are unchanged; only the stream keywords differ.
  • A write's first message carries the context, path, and expected version; later messages carry only data. A read's last message carries the version, the hash of exactly the bytes sent, so the server never buffers the file to compute it.
  • Chunks are at most 3 MiB, fixed, with no negotiation. Every end keeps gRPC's default 4 MiB message limit, and the protocol sets no file size limit.
  • The server spools a write to a temporary file and renames it into place only after the client closes its side of the stream, checking the expected version at that point; a stream that fails before then writes nothing. Disk usage is bounded by the volume alone.
  • The Workspace port keeps its whole-file methods for the agent tools. Unbuffered transfers go through an optional WorkspaceStreamer extension (ReadVersionTo, CreateFileFrom, ReplaceFileFrom), discovered by type assertion and failing soft when absent; it is documented here and implemented in a follow-up. The authorizing proxy relays chunks without assembling the file.
  • The decision is recorded in the new "File content" section of docs/drafts/kubernetes-execution/executor-protocol.md, and the ReadFile limit comment is removed from files.proto.

API compatibility

  • Assessment: breaking change to mecatl.executor.v1 (ReadFile, CreateFile, and ReplaceFile change from unary to streaming).
  • Rationale: no Go code implements or calls FileService yet, and the executor server is not used by the running system, so no conforming client exists to break.
  • Major/feature changes: none; executor/v1 is a private protocol with no deployed consumers.
  • Approval: approved by the operator for this change.
  • Upgrade implications: none.

Expected CI failure

The "Lint the executor protocol and check it for breaking changes" step fails on buf breaking for the three RPCs above (RPC_SAME_CLIENT_STREAMING / RPC_SAME_SERVER_STREAMING). The break is intentional; it was decided to leave the job red rather than add a buf.yaml ignore.

@blkt
blkt force-pushed the feat/2770-chunked-file-transfer branch from 251a637 to 175bf4c Compare November 17, 2026 15:37

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Streaming looks right to me: first-message-carries-metadata, commit on client close, and the proxy authorizing from the first message all hang together. One thing I'd want settled in the doc before the server side lands (inline).

@blkt blkt self-assigned this Nov 17, 2026
@blkt
blkt force-pushed the feat/2770-chunked-file-transfer branch 3 times, most recently from 7c4711c to 5d30a87 Compare November 17, 2026 21:02
@blkt
blkt added this pull request to stack #2854 November 17, 2026 21:45
blkt added 2 commits November 18, 2026 10:00
`ReadFile` streams its response and `CreateFile` and `ReplaceFile`
stream their requests, in chunks of at most 3 MiB, so every end keeps
gRPC's default 4 MiB message limit and the protocol sets no file size
limit. The decision is recorded in the executor protocol draft.

Closes #2770
A streamed read carries its version in the last message, covering
exactly the bytes sent. Writes spool to a temporary file and rename into
place on commit. Unbuffered transfers go through an optional
`WorkspaceStreamer` extension that fails soft when a workspace lacks it;
the agent tools keep the whole-file `Workspace` methods.
@blkt
blkt force-pushed the feat/2770-chunked-file-transfer branch from 5d30a87 to 483338f Compare November 18, 2026 09:03

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spooling writes to a temp file and renaming on close resolves the memory concern, and the reasoning for leaving disk use bounded by the volume makes sense. Non-blocking for the server PRs: temp files live in the workspace, so a crash mid-write can leave them visible to ReadDir and shell programs; worth a recognisable name and cleanup on startup. LGTM.

@blkt
blkt merged commit e4f7016 into main Nov 18, 2026
42 of 44 checks passed
@blkt
blkt deleted the feat/2770-chunked-file-transfer branch November 18, 2026 09:50
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Nov 18, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decide on chunked file transfer in the executor FileService

2 participants