Skip to content

Deploy tools 2/6: an upload store that extracts a bundle as it arrives - #255

Closed
raymondk wants to merge 2 commits into
deploy-core-1-bundle-hostfrom
deploy-core-2-upload-store
Closed

raymondk wants to merge 2 commits into
deploy-core-1-bundle-hostfrom
deploy-core-2-upload-store

Conversation

@raymondk

Copy link
Copy Markdown
Contributor

Second of six. Stacked on the bundle host PR.

What this PR adds

imcp2_core::deploy::Uploads: how a bundle reaches a server that cannot read the user's disk. A tool call carries JSON the model writes, which cannot be an archive, so the bundle arrives on an ordinary PUT authorised by a one-time ticket minted inside an authenticated tool call.

  • Tickets. 256 random bits, single use, valid five minutes, one pending per session. The upload is deployable only by the session that minted the ticket.
  • Extracted as it arrives. The body is fed to the bundle host chunk by chunk, on a thread that owns the body and cleans up after itself. The archive is never held whole in memory or on disk, and the upload stops at the byte that takes the archive or its extracted size past its limit. The deploy later takes the extracted directory by a rename.
  • Refused early. An upload that is not a bundle, or that carries a sync plugin the server does not run, is refused here, before any deploy is asked for.
  • One budget, in extracted bytes. A bundle that is arriving or being deployed is charged the most one may come to; a waiting one is charged its actual size. A session has one upload at a time. An upload waits five minutes for its deploy. A body idle for 30 seconds or longer than 10 minutes in total is dropped. Leftovers from an earlier process are removed when a store is created.

Notes for review

  • A failed upload still replaces the bundle the session was holding, because replacement happens on admission.
  • Nothing serves the store yet; the HTTP route is in PR 5.

Testing

Extraction on arrival, both size limits (including stopping without reading the rest of the body), budget charging at each stage, a refused replacement, stalled and abandoned uploads, the plugin allowlist, and leftovers cleared at start.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV

@raymondk
raymondk requested a review from a team as a code owner November 19, 2026 02:52
Copilot AI max review requested due to automatic review settings November 19, 2026 02:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Existing store directories can retain unsafe permissions, allowing other local users to replace received bundle trees before deployment.

3 open issues
What changed in this PR

Adds an upload-store API for remote deployments, preparing session-bound bundles for the later deploy pipeline without retaining the archive. HTTP routing remains for a later PR.

Changes:

  • Adds single-use tickets and streaming extraction with size limits, plugin validation, and timeouts.
  • Implements shared storage accounting, replacement, expiry, and cleanup, with lifecycle tests.
  • Exposes Uploads through the deploy module.
File Description
crates/​imcp2-core/​src/​deploy/​uploads.rs Implements the upload store, resource controls, validation, cleanup, and tests.
crates/​imcp2-core/​src/​deploy/​mod.rs Exports the upload store and updates staged-rollout documentation.

Review effort: Max

Comment thread crates/imcp2-core/src/deploy/uploads.rs Resolved
Comment thread crates/imcp2-core/src/deploy/uploads.rs Resolved
Comment thread crates/imcp2-core/src/deploy/uploads.rs Resolved
For a server the agent cannot hand a file to. A tool call carries JSON the
model writes, which cannot be an archive, so the bundle arrives on an
ordinary `PUT` authorised by a one-time ticket minted inside an
authenticated tool call (`imcp2_core::deploy::Uploads`).

- **Tickets**: 256 random bits, single use, five minutes, one pending per
  session, and the upload deployable by the session that minted it alone.
- **Extracted as it arrives.** The body is fed to the bundle host a chunk
  at a time, on a thread that owns the body and cleans up after itself, so
  the archive is nowhere whole and the upload stops at the byte that takes
  the archive, or what it extracts to, past its limit. What the store
  holds is the extracted bundle, which its deploy takes by a rename. What
  is not a bundle, or carries a sync plugin the server does not run, is
  refused here, before any deploy is asked for.
- **Bounded in the bytes it keeps**, since a server's state directory may
  be a RAM filesystem: one budget for the store, in extracted bytes. A
  bundle arriving or being deployed is charged the most one may come to,
  one waiting what it came to; a session has one upload at a time; an
  upload waits five minutes for its deploy; a body that stalls or takes
  too long is given up on; and what an earlier process left is removed
  when a store is made.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
@raymondk
raymondk force-pushed the deploy-core-2-upload-store branch from c731dd7 to f2e1067 Compare November 19, 2026 15:59
… directory private

Two review findings on the upload store.

A bundle that lapsed or was replaced was removed (a recursive delete)
under the state mutex, on whichever Tokio worker ran mint, receive or
take, so every session's calls waited on it. The store now only stops
holding the bundle under the lock; the tree is removed once the lock is
released, on a blocking thread. Its bytes stay charged until it is gone,
so the budget is still of what is on disk. An arrival or a deploy that
finds a lapsed bundle counts it as room, as before, and removes it before
it writes: on the extraction thread for an arrival, awaited for a deploy.

A store directory that existed already was taken as it was, whatever its
mode. Under one other users can write to, a bundle's directory could be
renamed away and another tree put in its place before the deploy. An
existing directory is now made 0700, at the store's making and at each
upload, and the upload refused if it cannot be.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
@aterga aterga closed this Nov 19, 2026
@aterga aterga reopened this Nov 19, 2026
@aterga aterga closed this Nov 19, 2026
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.

3 participants