Skip to content

feat: target cloud engines by name with --engine - #802

Open
raymondk wants to merge 2 commits into
rk/wasmtime-49.0.2from
rk/engine-flag
Open

raymondk wants to merge 2 commits into
rk/wasmtime-49.0.2from
rk/engine-flag

Conversation

@raymondk

@raymondk raymondk commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

icp deploy and icp canister create take --engine <name> to target a cloud engine by name. The name is resolved to the engine's subnet through the engine canister (q6cfj-fyaaa-aaaar-qb77q-cai on mainnet, ENGINE_CANISTER_ID overrides it), and the command then behaves exactly as --subnet would with that subnet.

  • --engine <name> calls listVisibleEngines, drops deleted engines, fetches getEngineMetadata for the rest, and matches the input against an engine's name, its id, or name/slug.
  • --engine <subnet-id> is --subnet <subnet-id>: a principal is taken to be the subnet itself, with no lookup.
  • --engine conflicts with --subnet and --proxy, and on deploy with --no-create, exactly like --subnet.
  • Errors are specific: a name nobody can see lists the engines the identity can see (or says it sees none), a name shared by several engines lists each with slug and id, an engine with no subnet yet is refused, and a network without the engine canister says so.
  • On deploy a named engine is resolved before the build so a bad name fails fast.

Code

  • crates/icp-cli/src/engine.rs (new): EngineSelector (the clap value type), resolve_subnet and its error enum, with unit tests against a fake CanisterCalls.
  • icp-canister-interfaces::engine_canister: Candid types for Engine, EngineMetadata, EngineError and MetadataResult, taken from the canister's live candid:service on mainnet, plus the two method names.
  • CallError::is_canister_not_found in icp-project: the check the engine-operator lookup already did, moved onto the error type so both lookups share it.

The engine canister id stays hard-coded (with the existing env override). A per-network setting is left for a follow-up.

Test plan

  • Unit tests: cargo test -p icp-cli --bin icp engine, cargo test -p icp-canister-interfaces, cargo test -p icp-project (default and --no-default-features)
  • Integration: canister_create_on_requested_engine (creates on the given subnet via --engine <subnet-id> on a multi-subnet local network, then checks the named-engine refusal where no engine canister exists), the clap conflict tests for both commands, and the existing Docker deploy_cloud_engine / canister_create_cloud_engine tests
  • cargo clippy --all-targets, cargo fmt --check, wasm32 clippy for icp-project, scripts/check-no-host-reach.sh
  • scripts/generate-cli-docs.sh regenerated docs/reference/cli.md
  • Manual: icp deploy -e ic --engine <your engine> against mainnet with an identity that can see an engine

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings October 5, 2026 21:37
@raymondk
raymondk requested a review from a team as a code owner October 5, 2026 21:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Exact engine IDs can incorrectly produce ambiguity errors when they match another engine’s name.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds cloud-engine targeting by name to canister creation and deployment, reusing existing subnet placement behavior.

Changes:

  • Adds --engine resolution, subnet-ID passthrough, and argument conflicts.
  • Introduces engine registry interfaces and shared missing-canister detection.
  • Adds tests and documents engine selection.
File Description
docs/​reference/​environment-variables.md Documents the registry override.
docs/​reference/​cli.md Documents --engine options.
docs/​guides/​deploying-to-specific-subnets.md Adds cloud-engine examples.
crates/​icp-project/​src/​operations/​create.rs Uses shared missing-canister detection.
crates/​icp-project/​src/​calls.rs Adds shared detection and tests.
crates/​icp-cli/​tests/​deploy_tests.rs Tests argument conflicts.
crates/​icp-cli/​tests/​canister_create_tests.rs Tests subnet passthrough and lookup errors.
crates/​icp-cli/​src/​main.rs Registers the engine module.
crates/​icp-cli/​src/​engine.rs Implements engine selection and resolver tests.
crates/​icp-cli/​src/​commands/​deploy.rs Resolves engines before building.
crates/​icp-cli/​src/​commands/​canister/​create.rs Integrates engine targeting.
crates/​icp-canister-interfaces/​src/​engine_canister.rs Adds registry types and override tests.
CHANGELOG.md Announces engine targeting.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/icp-cli/src/engine.rs
`icp deploy` and `icp canister create` take `--engine <name>`, which
resolves the engine's subnet through the engine canister and then
behaves as `--subnet` would with it. The name is looked up among the
engines visible to the identity in use (`listVisibleEngines`, then
`getEngineMetadata` for each); `name/slug` or the engine's id picks
one of several engines sharing a name, and a subnet id passed as the
engine is used as-is. A name nobody can see lists the visible engines,
a shared name lists each candidate, and a network without the engine
canister says so.

The Candid types for the two queries join the engine-canister
interface, and the canister-not-found check the operator lookup used
moves onto `CallError` so both lookups share it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@raymondk
raymondk changed the base branch from main to rk/wasmtime-49.0.2 October 5, 2026 22:33
An engine's id is unique and settles the lookup by itself, so it is
answered before any name is compared: an engine whose name happens to
be another engine's id no longer makes that id ambiguous.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@raymondk
raymondk added this pull request to stack #804 October 6, 2026 00:18

This branch has not been deployed

No deployments
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.

2 participants