Repository navigation
Conversation
…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
There was a problem hiding this comment.
🟡 Changes recommended
Unaccounted build scratch space and extraction path memory can exceed resource budgets, while Windows path aliases can bypass protection of .icp state.
5 open issues
Account for build scratch space when enforcing artifact size limits · New Reject Windows aliases of the protected state directory · New Bound memory used by ancestor-path extraction bookkeeping · New Add check_bundle regressions for Candid argument limits and binary inputs · New Test decompressed-stream limit with padding in a valid gzip archive · New
What changed in this PR
Adds the shared bundle-host foundation for future deployment tools in imcp2-core, for use by both servers. This first stack step handles untrusted bundles; nothing calls it yet.
Changes:
- Adds streaming extraction with configurable limits and confined, metered project loading.
- Adds mainnet-only preflight checks for checksums, Candid safety, module-copy space, and allowed sync plugins.
- Integrates the icp CLI dependencies and raises the Candid floor to 0.10.39 with a subtype regression test.
| File | Description |
|---|---|
crates/imcp2-core/src/lib.rs |
Exposes the deploy module and Candid text guard. |
crates/imcp2-core/src/deploy/mod.rs |
Documents the staged deployment module and exports the host. |
crates/imcp2-core/src/deploy/host.rs |
Implements extraction, host adapters, preflight checks, plugin policy, and tests. |
crates/imcp2-core/src/calls.rs |
Makes the guard public and adds the subtype regression test. |
crates/imcp2-core/Cargo.toml |
Adds deployment dependencies, runtime features, and test support. |
Cargo.toml |
Raises the workspace Candid version floor. |
Cargo.lock |
Records the new deployment dependency tree and version updates. |
Review effort: Max
Comment on lines
+922
to
+923
| directory = directory.saturating_add(occupies(module)); | ||
| if directory > directory_bytes { |
Contributor
Author
There was a problem hiding this comment.
That's correct ... despite nothing actually getting built, the file moves twice. If many canisters reference the same wasm the cli will keep an extra copy for each canister.
This is probably an improvement we can make in icp-cli.
Comment on lines
+1346
to
+1352
| let implied: Vec<Utf8PathBuf> = rel | ||
| .ancestors() | ||
| .skip(1) | ||
| .filter(|dir| !dir.as_str().is_empty()) | ||
| .take_while(|dir| !dirs.contains(*dir)) | ||
| .map(Utf8Path::to_path_buf) | ||
| .collect(); |
Comment on lines
+937
to
+940
| if let Some(CanisterArgs::Text { content, format }) = args { | ||
| if *format == Default::default() { | ||
| guard_candid_text(&format!("`{field}`"), content) | ||
| .map_err(|e| at(Unsupported(e)))?; |
Comment on lines
+1274
to
+1278
| let decoder = Limited { | ||
| inner: flate2::read::GzDecoder::new(source), | ||
| left: limits.stream_bytes(), | ||
| tripped: Some((meter, limits.extracted_bytes)), | ||
| }; |
…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
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
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.


First of six PRs that add deploying an icp project bundle to the MCP servers. Together they replace #230, #246, #231, #247, #232, #243, #249, #250, #251, #252 and #253: the same code, each piece once and in its final form, living in
imcp2-coreinstead of a separateimcp2-deploycrate.What this PR adds
imcp2_core::deploy::host: takes a bundle archive and turns it into something the icp CLI's project library can deploy from, treating the bundle as untrusted input. Nothing calls it yet.BundleLimits).check_bundle). Every module matches its recorded checksum; Candid text is within what the parser can take; the per-canister module copies the deploy will make are counted against the limit; every sync plugin is one the server runs (AllowedPlugins).The dependency cost lands here
There is no cargo feature: the deploy tools are part of every build of
imcp2-core. This PR addsicp-projectand its sibling crates, and throughicp-sync-pluginthe wasmtime runtime.imcp2-coregoes from about 360 to about 515 crates in its dependency tree. I have not measured the effect on build time or binary size.The
candidfloor moves to 0.10.39 for the subtype check a deploy's upgrade compatibility check runs.Why one crate
Both servers use this code, so it has to live somewhere both depend on. A separate published crate meant a fourth version to keep in lockstep, a manual first publish, and a second build configuration to test. Folding it into
imcp2-coreremoves all three.Stack
Until the tools land in PR 4, the module's items are
pubso the intermediate PRs build without dead-code warnings.Testing
Each PR in the stack passes
cargo fmt --check,cargo clippy --workspace --all-targets -- -D warningsandcargo test --workspace --all-targetson its own. The tree at the top of the stack is identical, file for file, to the old chain's final state with the crate folded in.🤖 Generated with Claude Code
https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV