Repository navigation
imcp2-deploy 3/6: deploy a bundle through icp-project, the pipeline, its events and its interruption - #231
imcp2-deploy 3/6: deploy a bundle through icp-project, the pipeline, its events and its interruption#231raymondk wants to merge 2 commits into
Conversation
6ccabf9 to
7131710
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Critical validation and input-bounding gaps can leave funded canisters unreported, trigger stack-overflow aborts, and allow bundle reads to exceed the promised 256 MiB memory limit.
3 open issues
What changed in this PR
Adds the deployment pipeline over the bundle host from #230, using the icp-project operations behind icp deploy. MCP tool exposure remains in #232.
Changes:
- Adds bundle loading, validation, ID seeding, deployment execution, and outcomes that preserve created canister IDs after failures.
- Implements signed canister calls and certified reads through
ic-agent. - Adds offline pipeline, input-rejection, and log-rendering tests; on-chain deployment remains untested.
| File | Description |
|---|---|
crates/imcp2-deploy/src/lib.rs |
Documents and exports the deployment API. |
crates/imcp2-deploy/src/deploy.rs |
Implements the pipeline, recovery mappings, logs, and offline tests. |
crates/imcp2-deploy/src/calls.rs |
Adapts signed calls and certified reads to CanisterCalls. |
Review effort: Balanced
7131710 to
331b699
Compare
331b699 to
cae8000
Compare
e331f38 to
fb78ce5
Compare
fb78ce5 to
1e9a238
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Bundle-supplied plugins execute in the server process without a Wasmtime memory limit, allowing a small untrusted plugin to exhaust server memory before its compute-time budget stops it.
4 open issues
2 resolved since last review
Review effort: Balanced
1e9a238 to
7073d71
Compare
| tokio::select! { | ||
| biased; | ||
| _ = watch.stop.cancelled() => None, | ||
| result = &mut run => Some(result), | ||
| } |
There was a problem hiding this comment.
Agreed, and not fixed here. Dropping the run while a create call is in flight can leave a funded canister whose id reaches neither report.created nor the kept mapping, and a retry then creates a second one. The fix is cooperative cancellation that lets in-flight creations finish and be recorded, which needs either support in icp-project's deploy or deferring the stop while a create task is open. That is a design change rather than a patch to this select, so it stays open.
… interruption `deploy_bundle` reads the archive, extracts it into a working directory of its own, loads the project through the host, and runs the library's deploy operation as a given identity on mainnet: create the canisters the mapping does not name, wire their ids, apply settings, install or upgrade, run the sync steps. The request is refused at entry for what cannot be deployed (mode, oversized file, deep Candid), and the blocking work runs off the async workers. Each phase is reported as it completes to whoever watches (`Watch`), and written to the server log under the caller's span. A cancelled token stops the deploy at its next step; the outcome then says `interrupted` and still carries every canister created, and the working directory is kept. Co-Authored-By: Claude Fable 5.2 <[email protected]>
7073d71 to
c42d2d3
Compare
…ough the ways it ends Three things review found in how a deploy ends: - The scratch directory is now owned by the extraction while it runs. A blocking task is not stopped when the deploy's future is dropped, and one that outlived the directory wrote its files back under a path nothing removes. - The lines the deploy adds after the run (where an interrupted deploy's directory is kept, a failure to read the ids back or to remove the directory) go to the watcher as the run's own lines do, not to the outcome's log alone. - The merge that makes the mapping a retry is handed is a function of its own, `ids_for_a_retry`, tested for a store that recorded only some of the created canisters and for one that could not be read back. Co-Authored-By: Claude Fable 5.2 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Cancellation can discard in-flight creation responses, losing funded canister IDs and risking duplicate creation on retry; sync-plugin cancellation and finalization logging also remain unresolved.
7 open issues
Drain in-flight creations before cancelling deploy work Limit memory for untrusted sync plugins Sync plugin execution blocks cancellation polling · New Forward post-processing diagnostics to log watchers Prevent FIFO replacement from blocking bundle reads Test recovery of created canister IDs Keep scratch alive until extraction finishes
Review effort: Balanced
| let run = deploy(&host, &calls, ¶ms, &reporter, &mut report); | ||
| tokio::pin!(run); |


Summary
deploy_bundle, the function that runs a deploy, over the host from #230 and the calls from #246. Still no MCP surface.resolve_targetsand the library'sdeploy: the entry pointicp deployuses, so creation, id wiring, settings, install or upgrade with the Candid check, and the sync steps behave as the CLI does. The agent is on mainnet (mainnet_agent).deployed,failed,interrupted,nothing_to_deploy), the canisters created, and the resulting mapping: the id store read back, merged with what was created, so a failed run still reports every canister it made.Watchhandsdeploy_bundlea stop token and an optional sender; each log line is sent the moment it is made, so the outcome's log and the streamed lines are the same lines in the same order. Each is also written to the server log, under the caller's span.What changed in this PR at the re-cut
deploy.rsis in its final form. It now includes what Report each deploy phase as it completes, and stop the deploy when the call is cancelled #242 added (events, interruption, theinterruptedstatus), what imcp2-deploy 5/6: the MCP tools, served from the local server #232 added (the working directory rules), what imcp2-deploy 6/6: serve the deploy tools on the hosted server, with the bundle uploaded on a ticket #243 added (the server log) and what Take the bundle one way per server: a path locally, an upload on the hosted one #245 removed (BundleSource::Upload).calls.rsmoved down to imcp2-deploy 2/6: sign a deploy's calls as the user, with an identity that refreshes #246.Review so far
icp_cycles_balancedescription) is in imcp2-deploy 5/6: the MCP tools, served from the local server #232, where that description now lives.Changes
crates/imcp2-deploy/src/deploy.rs(570 lines of code, 600 of tests).crates/imcp2-deploy/Cargo.tomladdstokio-util,serde_json, andtracing-subscriberfor one test.Testing
cargo build --locked --workspace --all-targetscargo test --locked --workspace --all-targetscargo fmt --all -- --checkThe tests run the real pipeline offline: a hand-built bundle is extracted, loaded through icp-project, checked, and stopped at the create phase with
no_create, whereicp deploy --no-createstops. Refused before any phase: a checksum mismatch, a script build or sync step, a managed network and a testnet, a path the bundle does not hold, an unknown environment or canister, a bundle path that is not a regular file, an unknown mode, a gzipped module past its limit, two canister names differing only in case. Plus: the log is streamed as it is made, an interrupted deploy stops and keeps its directory, and the events reach the server log.Not covered: an on-chain deploy. Nothing creates a canister, installs code or runs a sync plugin. The existing PocketIC fixture has no cycles ledger or engine registry, which the create phase needs.
The stack
Six stacked PRs that bring
icp deployto the MCP servers through the icp CLI's own project library. Re-cut on 2026-11-18 so that each file arrives once, in the form it has at the top; the tree at the top is unchanged from before the re-cut, rebased onto currentmain.icp-projecthost for an untrusted bundleic-agent, an identity that refreshes#242 (streamed phases, interruption) and #245 (one bundle source per server, crates.io) are closed: their changes are folded into the PRs above.
Checklist
🤖 Generated with Claude Code