Skip to content

Deploy tools 1–6 combined: bundle host, upload store, pipeline, MCP tools, remote serving, metrics - #261

Merged
aterga merged 17 commits into
mainfrom
deploy-core-all
Nov 19, 2026
Merged

aterga merged 17 commits into
mainfrom
deploy-core-all

Conversation

@aterga

@aterga aterga commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Combines the "Deploy tools" stack (#254–#259) into one PR against main, with review fixes, tests and a merge of main on top.

The stack

Everything in the stack as of its current heads (#259 at f8ae6aa) is here. The six original commits are patch-identical to the stack's. The two commits added to the stack since were cherry-picked: the candid bump from #254 (fc0db8c) and the upload-store fix from #255 (2da0fb7, conflict-resolved against the changes below). This is the PR that ships; #254–#259 are superseded by it.

On top of the stack

#264 (merged into this branch): three findings from the review of #256. Pruning a deploy directory no longer follows a link; a deploy that failed with a call unanswered carries the warning an interrupted one does; the record on disk is brought up to the answer before the directory is cut down.

Fixes from the Copilot reviews of this PR (271dda6, 6389dc1, 5db77f0, 1859439):

  • A deploy that created a canister keeps its record however it ended, not only when interrupted: the answer is sent after the deploy returns, and a client that goes away then would otherwise have no record. On the hosted server records expire after 7 days; on imcp2-local they stay until the user deletes them.
  • imcp2-local stops a running deploy and waits for it (up to 25 seconds) before exiting, when its client closes the pipe and on SIGINT/SIGTERM.
  • The upload store holds the deploy directory's lock for as long as an extraction is still writing.
  • Hosted: a notifications/cancelled naming a running deploy call stops it, for the same session only. The stateless transport drops the notification otherwise.
  • Deploys::stop also stops uploads: new ones get a 503, counted as stopping in imcp2_deploy_uploads_total, and one still arriving is given up on.
  • A finished deploy waits at most 30 seconds, and not past a stop, for progress notifications nobody reads, so it cannot hold its slot.
  • An upload ticket the store never minted is refused before the store is swept (the route is outside the bearer gate).
  • The upload command is curl -sS --fail-with-body, so a refused upload prints the server's reason (needs curl 7.76 or later).
  • The canister-id mapping a caller passes is checked, then written in one write off the runtime.
  • Deploys::new refuses a state directory that is not UTF-8 with InvalidInput, before clearing anything.
  • The deploy dispatch reads a request up to the endpoint's configured cap. Its own fixed 4 MiB cap, which would have overridden $MCP_MAX_REQUEST_BODY once Cap the MCP request body behind the bearer gate #241 was merged in, is gone.
  • A bundle its deploy never took is removed off the runtime's workers, like one that lapsed.
  • The deploy guide says how to sign in on each kind of server, and how to read an upload that was cut off.

Left as is on purpose: an HTTP 5xx from the replica is classified as a failed call, not an unanswered one. That is identical to the icp CLI's AgentCalls::wrap, which the deploy tools follow.

main merged in (through #241): the MCP request-body cap sits inside the bearer gate on the deploy-aware endpoint too, deploy calls included. The bundle upload stays a route of its own, outside both, with its own limits.

Tests

The suite is 493 tests. Added here:

  • crates/imcp2-local/tests/shutdown.rs runs the built binary over its pipes: it exits cleanly when the pipe closes, and on SIGTERM/SIGINT with the pipe still open.
  • Hosted, over the composed router with only the network stubbed: a cancellation stops the deploy call it names and no other, the call answers on its stream, and its slot is freed.
  • Hosted: a stopping server refuses an upload and keeps nothing.
  • Unit tests for the record decision, the seeded mapping (read back through icp-project's id store), the upload store's stop and lock lease, unknown tickets, the non-UTF-8 state directory, and the two bounded waits.

Not covered by a test: a cancellation or signal arriving while a deploy is partway through creating canisters. That needs a signed-in session against a replica.

Decided

  • Module copies in the size budget (host.rs): a build holds a scratch copy of each module, uncounted, until that module's build returns, so a running deploy can pass the cap for a moment by what its modules come to (at most half the cap again). Left uncounted on purpose and documented, with the headroom a RAM-backed state directory needs (8370061).
  • Default account changed mid-deploy (identity.rs): not an issue. The deploy tools sign in at https://cli.id.ai, where the user cannot change the default account.
  • Deploy records on imcp2-local are not expired: each is one small file, and the README says when they can be deleted.
  • logging/setLevel (server.rs): the server advertises MCP logging and does not handle setLevel, so a client that sends it gets method not found. Accepted for this PR; a follow-up will handle it.

Before merging

  • Run a real deploy on this branch through imcp2-local and the hosted server, including a cancel mid-deploy.

https://claude.ai/code/session_01VP2vTFUYW9ZKb1Rjv176Za


Generated by Claude Code

raymondk and others added 7 commits November 18, 2026 21:41
…sted project, and the checks before a deploy

The first step of deploying an icp project bundle from the MCP servers:
`imcp2_core::deploy::host`, which takes a bundle archive and makes of it
something the icp CLI's project library can deploy from, treating the
bundle as untrusted input. Nothing calls it yet.

- **Extraction** reads the archive as a stream and writes regular files and
  directories only, confined to its directory, refusing the `.icp` state a
  deploy seeds for itself. Both sizes are held as it reads: the archive's,
  and what the entries occupy (whole 4 KiB blocks and 1 KiB an entry, which
  is what a bundle costs a server that keeps it in memory). How large is
  the server's to say (`BundleLimits`).
- **The project** is loaded through the library's own untrusted rule
  (`icp_project::untrusted`): no script step, no remote source, no recipe,
  no path through a link; what the load retains is metered.
- **The checks before a deploy** (`check_bundle`): every canister built by
  one pre-built module that hashes to its recorded checksum, the Candid a
  bundle carries held to what the parser takes, the copy of each
  canister's module the deploy will keep counted against the limit, and
  every sync plugin one the server runs (`AllowedPlugins`: any, on the
  user's own machine; the releases a server knows, by the hash of their
  module, where it deploys for others).

This is where the dependency cost lands: `icp-project` and its siblings,
and with `icp-sync-plugin` the wasmtime runtime, in every build of
imcp2-core. The `candid` floor moves to 0.10.39 for the subtype check a
deploy's upgrade compatibility check runs.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
…t only by how the archive spells it

An entry under `.icp/` was refused by comparing its first component with
the name. A name is the disk's to interpret: Windows takes `.icp.`,
`.icp ` and `.icp::$INDEX_ALLOCATION` for `.icp`, so an archive could
supply the id mappings the check is there to keep out.

The spelling check stays, as the refusal that names the entry before it
is written. Once the archive is out, the extraction directory is asked
whether `.icp` is there, which answers for every spelling the disk
honours.

The Windows alias test is gated to Windows and has not been run: CI
tests on Linux only.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
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
…p without losing a canister

`imcp2_core::deploy::run::deploy_bundle`: extract (or take) the bundle,
load it as an untrusted project, check it, and run every phase of `icp
deploy` through the icp CLI's project library, reporting each phase as it
completes.

- **Signed as the user, for as long as it runs.** A per-app delegation
  lasts five minutes and a deploy can outlast it, so the agent signs
  through an identity that is refreshed alongside it, pinned to the
  account the first delegation resolved to: the principal that creates a
  canister is the one that goes on to install it. `Identities` says which
  account a delegation was resolved to, and which failure ends a session.
- **Canister calls from certificates.** Whether a canister exists, what is
  installed on it and where it sits are read from the state tree, not from
  what a canister says of itself.
- **A stop loses nothing.** A canister call in flight may already have
  created and funded a canister that only its answer names. So a stop lets
  that call run to its answer, which is recorded, refuses any call after
  it, and gives the run twenty seconds to end by itself; a deploy stopped
  before it began anything says so and creates nothing.
- **A record outlives an interrupted deploy.** Its directory is cut down
  to the ids it created and kept, for a caller who never got the answer;
  a start cuts down what a killed process left, and old records are
  removed.
- **The server's own failures are told from the request's**, so a caller
  knows whether trying again is any use.

Known limit: a sync plugin holds its thread while it runs, so the
twenty-second grace cannot cut one short. Its canister calls are refused
once a stop is asked for and the plugin runtime has its own compute
deadline, but a hard deadline belongs upstream, in icp-sync-plugin.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
- **The tools** (`imcp2_core::deploy::IcDeployTools`, mounted beside the
  core surface by `WithDeploy`): `icp_deploy_bundle` deploys a bundle to
  the Internet Computer as the user, every phase of `icp deploy`, creating
  the canisters the given mapping does not name and upgrading those it
  does, and reports each phase as it completes; `icp_cycles_balance`
  reports the balance those deploys create canisters from, and the
  principal that holds it; `icp_deploy_upload` mints an upload ticket, on
  a server that takes its bundles that way; `icp_deploy_guide` returns the
  skill that walks an agent through the loop (also a resource).
- **One way in per server.** A server on the project's machine reads the
  bundle at the path the agent names; one the agent cannot hand a file to
  takes an upload, and reads no path a caller gives it. Each lists the one
  argument it takes.
- **Bounded.** One deploy per session, and so many at once across sessions
  in slots a process can share between its endpoints: past either a deploy
  is refused, not queued. A server that is stopping begins none and
  interrupts those running, and can wait for them to have ended.
- **Observable.** What became of each deploy call — refused, and why; or
  how it ended, and how long it held its slot — is told to an observer,
  for a server to count: the call itself is one request among many to the
  transport that carries it.
- **imcp2-local serves them**, signing as the user's default Internet
  Identity account at `https://cli.id.ai`, the principal `icp identity
  link web` links the CLI to, with each deploy's directory under the
  user's local data directory.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
…loaded on a ticket

The deploy tools on the `imcp2` server, for an embedder that turns them on
(`McpServer::with_deploy`); the bundled binary always does.

- **How the bundle arrives.** `icp_deploy_upload` mints a ticket inside an
  authenticated call, and the archive is `PUT` to `{mcp_path}/deploy/upload`
  on it. The route is outside the bearer gate — the ticket is its
  authentication — and the body is extracted as it arrives: 413 at the
  byte that takes the archive, or what it extracts to, past its limit, and
  422 for what is not a bundle or carries a sync plugin the server does
  not run. The deploy tool here refuses a path: the server opens no file a
  caller names.
- **A deploy call is answered as an event stream**, so each phase reaches
  the client before the result; every other request keeps the plain JSON
  answer. A client that goes away stops its deploy.
- **One deploy state for the process** (`Deploys`): the slots, the upload
  store and the word that the server is stopping are shared by every
  endpoint. It locks its directory, so a second server over the same
  state directory is refused rather than clearing the first one's
  uploads; clears what a killed process left; and sweeps what has lapsed.
- **Stopping.** `Deploys::stop` before the drain tells running deploys to
  end and refuses new ones, and `Deploys::stopped` waits, bounded, for
  them to have ended: a deploy waiting on a canister call whose client
  has gone holds no connection for a drain to wait on. The server's own
  `spawn_session_reaper` and `shutdown` cover the sweeper and the stop for
  an embedder that does nothing more.
- **Configuration** is `DeployConfig`: deploys at once, the archive and
  extracted limits, the budget for every bundle held, and the sync plugins
  run besides the ones the server knows. The library reads no environment
  variable; the bundled binary maps `MCP_DEPLOY_*` onto it and refuses to
  start on values that contradict one another.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
A deploy is one `tools/call` inside a `POST`, answered 200 whether it
succeeded, failed or was refused for want of a slot, so the request
metrics say nothing about deploys; and the upload route's status codes
fold several reasons into one.

The `Metrics` handle an embedder already builds over its servers also
publishes, where a server serves the deploy tools, as totals for the
process:

- `imcp2_deploys_running` against `imcp2_deploy_slots`: how full it is.
- `imcp2_deploy_refusals_total{reason}`: busy, session_busy, stopping,
  no_room. A sustained rate of `busy` is a cap that is too low.
- `imcp2_deploys_total{outcome}`: succeeded, failed, rejected,
  setup_failed (the server's own failure, not the request's),
  interrupted; and `imcp2_deploy_duration_seconds`.
- `imcp2_deploy_uploads_total{outcome}`: accepted, bad_ticket, too_large,
  extracts_too_large, not_a_bundle, plugin_not_allowed, store_full,
  session_busy, body_error, storage_error.
- `imcp2_deploy_upload_bytes` and `imcp2_deploy_bundle_extracted_bytes`,
  which is where the two size limits should sit is read off.
- `imcp2_deploy_upload_store_bytes` against its capacity, and the uploads
  held and arriving: what the deploy tools keep under the state directory.

The counters are fed as things happen, a deploy dropped mid-run and an
upload abandoned mid-body included; the gauges by `Metrics::refresh`.
Every label value is a variant named in code: nothing a client sends
becomes a label. Every series starts at zero.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV

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

Critical gaps in error classification, cancellation, shutdown, and recovery-record retention can lead to duplicate funded canisters or leave funded canisters without recoverable ID mappings.

10 open issues
What changed in this PR

Combines the deploy-tools stack into shared imcp2-core functionality, exposed through both the local and hosted MCP servers.

Changes:

  • Adds guarded bundle uploads and deployment support, including identity refresh, resource limits, stop handling, and recovery records.
  • Integrates deploy tools and guidance into both servers, with streamed progress on hosted deployments.
  • Adds deploy/upload metrics, configuration, tests, and operational documentation.
File Description
src/​metrics/​deploy.rs Defines deploy and upload metrics.
src/​metrics.rs Registers deploy collectors and refreshes gauges.
src/​main.rs Configures shared deploy state and shutdown handling.
src/​lib.rs Adds optional deploy routing and lifecycle integration.
src/​deploy.rs Implements hosted state, uploads, and progress streaming.
src/​auth.rs Adds a test-only bearer-token helper.
README.md Documents hosted deployment, limits, and metrics.
deploy/​native/​README.md Documents native deployment storage and operation.
deploy/​native/​imcp2.service Updates shutdown comments; service settings are unchanged.
crates/​imcp2-local/​src/​server.rs Composes deploy tools with core and login tools.
crates/​imcp2-local/​src/​main.rs Initializes local deploy tools and their working directory.
crates/​imcp2-local/​README.md Explains deployment identity, workflow, and recovery.
crates/​imcp2-core/​static/​skills/​deploy-with-mcp.md Adds agent-facing deployment guidance.
crates/​imcp2-core/​src/​tools.rs Makes the non-deploy instruction paragraph replaceable.
crates/​imcp2-core/​src/​management.rs Shares cycles-balance querying across identities.
crates/​imcp2-core/​src/​lib.rs Exports the deploy module and supporting helpers.
crates/​imcp2-core/​src/​identities.rs Exposes resolved delegation accounts and identity helpers.
crates/​imcp2-core/​src/​deploy/​uploads.rs Implements ticketed extraction, upload budgets, and expiry.
crates/​imcp2-core/​src/​deploy/​server.rs Merges deploy tools, resources, and server instructions.
crates/​imcp2-core/​src/​deploy/​observe.rs Defines bounded deploy outcome events for observers.
crates/​imcp2-core/​src/​deploy/​identity.rs Refreshes signing delegations while preserving the principal.
crates/​imcp2-core/​src/​deploy/​calls.rs Adapts network calls and certified reads for deployment.
crates/​imcp2-core/​src/​calls.rs Exposes the Candid guard and adds subtype regression coverage.
crates/​imcp2-core/​Cargo.toml Adds project-library and deployment dependencies.
Cargo.toml Raises the Candid floor and adds transport dependencies.

Review effort: Max

Comment thread crates/imcp2-core/src/deploy/calls.rs Resolved
Comment thread crates/imcp2-core/src/deploy/run.rs Resolved
Comment thread crates/imcp2-local/src/main.rs Resolved
Comment thread src/deploy.rs Resolved
Comment thread src/deploy.rs Resolved
Comment thread crates/imcp2-core/src/deploy/mod.rs Resolved
Comment thread crates/imcp2-core/src/deploy/run.rs Resolved
Comment thread crates/imcp2-core/src/deploy/uploads.rs Resolved
Comment thread src/deploy.rs Resolved
Comment thread src/deploy.rs Resolved
- Keep a deploy's record whenever it created a canister, not only when it
  was interrupted: the answer is sent after the deploy returns, and a client
  that goes away while it is sent would otherwise leave funded canisters
  with no record. Records still expire on the hosted server.
- imcp2-local: on stdin EOF, cancel the calls still running and wait for a
  deploy to end (STOP_GRACE plus a margin) before the runtime exits, rather
  than rmcp's five-second drain.
- The upload store holds the deploy directory's lock for as long as it, or a
  thread extracting into it, lives.
- Hosted: forward `notifications/cancelled` to the running deploy call it
  names, by session and JSON-RPC id; the stateless transport drops it.
- The upload command uses `--fail-with-body`, so a refused upload prints
  the server's reason.
- Seed the caller's canister-id mapping in one write, off the runtime,
  after checking every name.
- Remove bundles off the store's lock and off the async workers, keeping
  their room charged until their files are gone.
- `Deploys::new` refuses a state directory that is not UTF-8 with
  `InvalidInput`, before clearing anything.
- `Deploys::stop` also stops uploads: new ones are refused (503, counted as
  `stopping`) and one arriving is given up on at its next read.

Error classification (HTTP 5xx) is unchanged: it is already identical to
the icp CLI's `AgentCalls::wrap`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTFUYW9ZKb1Rjv176Za
@aterga
aterga marked this pull request as ready for review November 19, 2026 16:33
@aterga
aterga requested review from a team and a max review from Copilot November 19, 2026 16:33
candid 0.10.41 makes the subtype check linear on a chain of `opt`
aliases; candid_parser 0.4.2 loads a long alias chain without
overflowing the stack or taking quadratic time.

candid_parser 0.4 wraps a function's argument and result types in
`IDLArgType`, so the two places that document them read `.typ`.

icp-project 0.1.0 requires candid_parser 0.3, so the tree now holds
both: the library's own parsing still runs on 0.3.2.

The comment on the candid floor in Cargo.toml is dropped.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV

Copilot AI left a comment

Copy link
Copy Markdown

Comment thread crates/imcp2-core/src/deploy/mod.rs Resolved
Comment thread crates/imcp2-local/src/main.rs Resolved
Comment thread crates/imcp2-core/src/deploy/host.rs Resolved
Comment thread crates/imcp2-core/src/deploy/server.rs Resolved
Comment thread crates/imcp2-core/src/deploy/uploads.rs Resolved
Copilot AI max review requested due to automatic review settings November 19, 2026 16:54
… 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

(cherry picked from commit c779da6)

Conflict with 271dda6 resolved by taking this commit's removal of
lapsed and replaced bundles in place of 271dda6's, and keeping 271dda6's
upload stop (Uploads::stop, ReceiveError::Stopping) and directory lease
(Uploads::held_with) on top.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTFUYW9ZKb1Rjv176Za
claude and others added 4 commits November 19, 2026 18:00
…tickets)

- Don't wait past a stop, or more than 30 seconds, for a finished deploy's
  last progress notifications: a client that keeps the stream open without
  reading it would otherwise hold the call and its slot. The outcome's log
  carries every line regardless.
- imcp2-local: stop on SIGINT/SIGTERM as on stdin EOF: cancel the calls
  running and wait for a deploy to end before exiting.
- Refuse an upload ticket the store never minted before sweeping: the route
  is outside the bearer gate, and the sweep is work under the store's lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTFUYW9ZKb1Rjv176Za
…pplied to the combined stack (#264)

From the Copilot review of #256, the ones the combined stack still had.

Pruning a deploy directory to its record went into `.icp`, `data` and
`mappings` by name, following a link: one planted there had what it
pointed at emptied. Each part is now gone into only as a real directory,
and a link in its place is removed like anything else that is not the
record.

A deploy that failed, not stopped, with a call unanswered returned the
error chain alone. It now carries the warning an interrupted run already
did: the call may have created a canister that nothing lists, and the
caller's next move is a retry.

The mapping a deploy hands back fills in every canister it created, but
the record left on disk was whatever the id store had managed to write.
The record is now brought up to the answer before the directory is cut
down, and the log says so when that write fails.


Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV

Co-authored-by: Claude Fable 5.2 <[email protected]>
Conflicts with #241 (the MCP request-body cap) resolved by keeping both
sides: McpServer has both `deploy` and `max_request_body`, the body cap is
layered inside the bearer gate on the deploy-aware MCP router (the bundle
upload stays a route of its own, outside both, with its own limits), and the
binary reads $MCP_MAX_REQUEST_BODY next to the deploy settings. futures-util
is a normal dependency (the deploy endpoint streams bodies), so it is no
longer listed again under dev-dependencies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTFUYW9ZKb1Rjv176Za

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.

🔵 Needs a closer look

Unresolved critical issues let stalled SSE clients hold deployment resources indefinitely and allow retained recovery records and decoded interfaces to exceed storage or memory budgets.

3 open issues
4 previously missed issues

In code that hasn't changed since last review

High severity Bound aggregate Candid memory during compatibility checks

crates/​imcp2-core/​src/​deploy/​host.rs:997

Thousands of canisters can share one small gzipped module with a near-1-MiB Candid section and pass this deduplicated budget, yet retain gigabytes of decoded interface text during upgrades. The upstream compatibility phase at cfff56f runs concurrent per-canister checks and holds each owned new_candid while fetching metadata; supplying existing canister IDs avoids creation costs. Keep the hash cache, but add an aggregate per-canister interface-memory limit or bound concurrency before those allocations.

High severity Cancel blocked progress forwarding when deploy ends

crates/​imcp2-core/​src/​deploy/​mod.rs:814

If an SSE client leaves its response open but stops reading, progress forwarding can block on rmcp's bounded output channel, leaving this join holding the deploy slot and upload reservation indefinitely. Stopping the deploy does not cancel that wait. Bound the notification drain and abort the forwarder when cancellation or the deadline wins; the result already contains the full log.

High severity Keep retained recovery mappings charged against storage quota

crates/​imcp2-core/​src/​deploy/​uploads.rs:331

Once the upload has been renamed, this branch releases its reservation even if the deploy keeps a recovery mapping for seven days. Repeatedly interrupting runs after seeding large mappings can therefore accumulate records beyond max_stored_bytes without creating any canisters, while the store reports the space as free. Keep retained records charged, or enforce a separate record quota at deploy admission without deleting needed recovery data.

Medium severity Recheck capacity after expired uploads are reclaimed

crates/​imcp2-core/​src/​deploy/​uploads.rs:588

This check includes charges for expired uploads that sweep() has already scheduled for deletion, so a valid PUT can consume its ticket and return Full even though cleanup frees enough room before the response. The same issue occurs in take at lines 673–675, which returns a cached NoRoom after awaiting cleanup. Recheck admission after reclaiming expired bundles, keeping their bytes charged until deletion finishes and preserving single-use tickets.

3 resolved since last review

Review effort: Max

Copilot AI max review requested due to automatic review settings November 19, 2026 17:15
… bug they found

Tests:
- imcp2-local, the built binary driven over its pipes (tests/shutdown.rs):
  it ends cleanly when its client closes the pipe, and on SIGTERM/SIGINT
  with the pipe still open.
- imcp2-local: as it ends it waits for a running deploy, and for no longer
  than a stopped deploy is given.
- Hosted, over the composed router with only the network stubbed (the IC
  endpoint is a listener that never answers): a `notifications/cancelled`
  naming a deploy call in flight stops it, one naming another call does
  not, and the call answers on its stream and frees its slot.
- Hosted: a stopping server refuses an upload with 503 and keeps nothing.
- A finished deploy does not wait on progress nobody reads: not past a
  stop, nor longer than FORWARD_GRACE.

Fix, found by the signal test: with a signal handled (6389dc1), imcp2-local
no longer exited on SIGTERM while its client kept the pipe open. The
transport reads stdin on a runtime thread that cannot be interrupted, and
returning from `serve` waited on it. On a signal the process now stops its
calls, waits for a running deploy, and exits. The handlers are installed
before the MCP handshake, so a signal during it ends the process too.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTFUYW9ZKb1Rjv176Za

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.

Comment thread crates/imcp2-local/src/main.rs Resolved
Comment thread crates/imcp2-core/src/deploy/uploads.rs Resolved
Comment thread src/deploy.rs Resolved
Copilot AI max review requested due to automatic review settings November 19, 2026 17:32
…cleanup, guide)

- The deploy dispatch buffered each request under a fixed 4 MiB cap of its
  own, so with the deploy tools on, a request cap raised with
  $MCP_MAX_REQUEST_BODY (or `with_max_request_body`) was held to 4 MiB for
  every call. It now reads up to the endpoint's configured cap, which the
  layer in front of it already enforces.
- A bundle its deploy never took (the deploy was refused or stopped first)
  was removed by the drop of its handle, on a runtime worker. It is now
  handed to a blocking thread like a lapsed bundle, charged until it has
  gone; one the deploy did take frees its room at once, as before.
- The deploy guide: signing in is said for both kinds of server (the local
  login tools, or reconnecting in the MCP client on a hosted one), and a
  cut-off upload is checked against the limits before it is taken for too
  large, with one retry on a new ticket when it is within both.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTFUYW9ZKb1Rjv176Za

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.

Copilot AI max review requested due to automatic review settings November 19, 2026 17:48
…fixed default account

The size budget counts a bundle and the copy of each module the artifact
store keeps. While a canister is built, the icp library also holds a scratch
copy of its module in the deploy's directory until that build returns, and
the canisters are built at once: a running deploy can pass the cap for a
moment by what its modules come to, at most half the cap again. That is left
uncounted on purpose and now said where the limit is described (check_bundle,
BundleLimits, DeployConfig, the README), with the headroom a RAM-backed state
directory needs.

A deploy that started as the unnamed account asks for the default account
again at each refresh. The doc on RefreshingIdentity::start now says why that
is the same account for the deploy tools: the default at the origin they sign
in at cannot be changed by the user.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTFUYW9ZKb1Rjv176Za

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.

🔵 Needs a closer look

Human assessment is needed to weigh omitted findings about configuration parsing that can prevent startup and upload-error guidance that can misdiagnose recoverable failures.

1 open issue
2 resolved since last review

Review effort: Max

Copilot AI max review requested due to automatic review settings November 19, 2026 18:06

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.

🔵 Needs a closer look

Human assessment is needed because status polling can retain an expired delegation despite identity refresh, potentially losing a canister-creation result.

1 open issue

Review effort: Max

Comment thread crates/imcp2-core/src/deploy/mod.rs Resolved
@aterga
aterga merged commit e4e94fd into main Nov 19, 2026
17 checks passed
aterga pushed a commit that referenced this pull request Nov 19, 2026
…undle's way in per server

The description of `icp_deploy_bundle` no longer lists the phases of a
deploy or says which argument carries the bundle and what the environment
is called: the arguments say that themselves. As suggested in review of
#261.

It keeps one sentence on how to hand the bundle over, and that sentence is
the server's own, put in where the tool list is already fitted to the
server: one with an upload store says to upload the bundle with
`icp_deploy_upload`; one without says to pass its path as `bundle_path`.
One description for both would name, on the local server, a tool that
server does not list.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTFUYW9ZKb1Rjv176Za
aterga added a commit that referenced this pull request Nov 19, 2026
…dle description (#265)

* Deploy tools: answer logging/setLevel

The deploy handler declares the MCP logging capability, since a deploy sent
no progress token reports its phases as log messages, but did not handle
`logging/setLevel`: a client that sent it was told there is no such method.

`WithDeploy` now takes the request, and `LocalServer` passes it on. The
deploy tools log at one level, `info`, so the level decides whether they log
at all: asked for messages from a level above `info` only, a deploy without
a progress token sends none (its outcome still carries every line), and a
level at or below `info` turns them back on. Progress under a token is the
request's own asking and is sent whatever the level.

The level is the handler's. On imcp2-local that is the connection. The
hosted transport is stateless, a handler per request, so a level set there
is accepted and applies to no later call.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTFUYW9ZKb1Rjv176Za

* Deploy tools: a shorter description for icp_deploy_bundle, with the bundle's way in per server

The description of `icp_deploy_bundle` no longer lists the phases of a
deploy or says which argument carries the bundle and what the environment
is called: the arguments say that themselves. As suggested in review of
#261.

It keeps one sentence on how to hand the bundle over, and that sentence is
the server's own, put in where the tool list is already fitted to the
server: one with an upload store says to upload the bundle with
`icp_deploy_upload`; one without says to pass its path as `bundle_path`.
One description for both would name, on the local server, a tool that
server does not list.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTFUYW9ZKb1Rjv176Za

* Deploy tools: a log level set while a deploy runs holds for that deploy

The level a client sets with `logging/setLevel` was read once, as a deploy
call began, so one set while a deploy was running changed nothing for it: a
deploy that began logging went on to its end, and one that began muted
could not be heard again.

The handler's flag is now shared with the deploy calls running, which read
it for each line they send. Progress under a progress token is as before,
whatever the level.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTFUYW9ZKb1Rjv176Za

---------

Co-authored-by: Claude <[email protected]>
@aterga aterga mentioned this pull request Nov 19, 2026
6 of 8 tasks
@raymondk raymondk mentioned this pull request Nov 19, 2026
6 of 8 tasks
aterga pushed a commit that referenced this pull request Nov 19, 2026
* Bump crates to 0.7.0

All three crates share one version. A minor bump: since 0.6.1 the server
gained the deploy tools (bundle host, upload store, pipeline, MCP tools,
remote serving and metrics, #261, #265, #266), the cap on the MCP request
body behind the bearer gate (#241), vetted-connector branding surfaced to
Internet Identity (#200), and get_canister_candid now carries the interface
text in its structured output (#229).

The rc-0.7.0 candidate needs this on main first: deploy-candidate.yml and
publish-crate.yml both refuse a tag whose version disagrees with every
Cargo.toml.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTGJNrpdaVxN1aY8XSX

* Deploy tools: say per server how to hand icp_deploy the bundle again

#266 rewrote the icp_deploy description and hard-coded its step (2) as
"upload that bundle via icp_deploy_upload". The local server does not list
that tool: it takes the bundle as `bundle_path`. The sentence that
IcDeployTools::tools() put in per server was anchored on text the rewrite
removed, so it silently stopped being put in, and
a_server_lists_the_bundle_argument_it_takes has failed on main since.

Step (2) is now the anchor. The description says "hand that bundle to this
tool", and each server replaces that with its own way in: upload via
`icp_deploy_upload` on a server with an upload store, the bundle's absolute
path as `bundle_path` on one without. The hosted server's text is what #266
wrote, with the tool name in backticks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTGJNrpdaVxN1aY8XSX

* README: depend on imcp2 0.7

`imcp2 = "0.6"` matches 0.6.x only, and the README ships in the crate, so a
reader of 0.7.0's page would be told to depend on the release before it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTGJNrpdaVxN1aY8XSX

* Deploy tools: keep the description's step (2) as written

Review asked for the description's text back. The tool's description in
the source says step (2) as #266 wrote it, "upload that bundle via
icp_deploy_upload", and the hosted server lists it unchanged. Only a
server without an upload store, imcp2-local, puts "pass that bundle's
absolute path as `bundle_path`" in its place, since it lists no
icp_deploy_upload.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTGJNrpdaVxN1aY8XSX

---------

Co-authored-by: Claude <[email protected]>
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.

5 participants