Skip to content

imcp2-deploy 2/6: sign a deploy's calls as the user, with an identity that refreshes - #246

Closed
raymondk wants to merge 1 commit into
deploy-1-bundle-hostfrom
deploy-1b-signing
Closed

raymondk wants to merge 1 commit into
deploy-1-bundle-hostfrom
deploy-1b-signing

Conversation

@raymondk

@raymondk raymondk commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The two pieces a deploy signs with. Neither depends on the bundle host in #230 beyond the crate existing, so this can be read on its own.

  • calls.rs: AgentCalls, the library's CanisterCalls over an ic-agent Agent, modelled on icp-app's own implementation without proxy routing. Updates and queries as the caller, and the certified reads a deploy makes through read_state: module hash, controllers, metadata sections, the subnet a canister is on. A candid:service section read off a canister is held to core's guard_candid_text before it is handed back. The caller principal is read once at construction, because CanisterCalls::caller is infallible while Agent::get_principal is not.
  • identity.rs: RefreshingIdentity, the signer a long deploy holds. A per-app delegation lives five minutes and a deploy can run longer, so it swaps in a fresh delegation from the session store every ten seconds. It keeps signing as the account the first derivation resolved to, so a user changing their default account mid-deploy does not change the principal, and it stops signing for good once Internet Identity says the session is over.

imcp2-core (identities.rs):

  • delegated_identity_resolved returns the account a delegation was resolved to next to the identity; delegated_identity is now a wrapper over it. AppDelegation carries that account.
  • RECONNECT_MSG is public, so a holder of a long-lived signer can tell "the session is over" from a transient failure.
  • Identities::agent_as is public.

Where this came from

calls.rs was in #231 and identity.rs in #232; both files are unchanged from the top of the old stack.

Changes

  • crates/imcp2-deploy/src/calls.rs (268 lines of code, 97 of tests), src/identity.rs (182 and 48).
  • crates/imcp2-core/src/identities.rs.
  • crates/imcp2-deploy/Cargo.toml adds ic-agent, candid and tracing.

Testing

  • cargo build --locked --workspace --all-targets
  • cargo test --locked --workspace --all-targets
  • cargo fmt --all -- --check

Tested here: the certified-read paths and their absent-versus-failed distinction, the identity's swap, its same-principal check, and that a revoked identity refuses to sign with the reconnect message.

Not covered: AgentCalls against a network. Nothing in the stack makes an on-chain call in a test (see #231).

The stack

Six stacked PRs that bring icp deploy to 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 current main.

PR What
1 #230 The crate and the icp-project host for an untrusted bundle
2 #246 Signing: canister calls over ic-agent, an identity that refreshes
3 #231 The deploy pipeline, its events and its interruption
4 #247 The upload-ticket store
5 #232 The MCP tools, and the local server serving them
6 #243 The hosted server serving them

#242 (streamed phases, interruption) and #245 (one bundle source per server, crates.io) are closed: their changes are folded into the PRs above.

Checklist

  • I have read the Contributing guidelines.
  • Docs (README / comments) updated for any user-visible change.
  • No secrets, credentials, or internal-only information are included.

🤖 Generated with Claude Code

…an identity that refreshes

`calls` implements icp-project's `CanisterCalls` over an ic-agent `Agent`:
updates and queries as the caller, and the certified reads a deploy makes
(module hash, controllers, metadata sections, the subnet a canister is on).

`identity` is the signer a long deploy holds: it re-derives the session's
delegation while the deploy runs, keeps signing as the account the first
derivation resolved to, and stops signing once Internet Identity says the
session is over.

imcp2-core returns the account a delegation resolved to
(`delegated_identity_resolved`) and makes `RECONNECT_MSG` and `agent_as`
public for it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@raymondk

Copy link
Copy Markdown
Contributor Author

Superseded by the stack #254 → #259, which carries the same code in six PRs from main, with the deploy tools living in imcp2-core instead of a separate crate. Signing with a refreshing identity is in #256.

@raymondk raymondk 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.

1 participant