Repository navigation
Bump ic-agent/ic-transport-types to 0.48.0 and forward read-only delegation permissions - #33
Merged
Merged
Conversation
These versions add the `permissions` field to `Delegation` (with the new `DelegationPermissions` enum) for read-only delegation support. `Delegation` is not `#[non_exhaustive]`, so the struct literal built from II's `mcp_get_delegation` response now sets `permissions: None` explicitly — II issues full-access delegations for the MCP flow and does not sign a `permissions` field, and `None` hashes/verifies identically to a pre-0.48 delegation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RzjuJVat2CTiCYzeU9F6e2
aterga
commented
Jul 5, 2026
There was a problem hiding this comment.
Pull request overview
Updates the project’s Internet Computer agent dependency to ic-agent 0.48.x and adjusts the local delegation conversion code to accommodate the newly added permissions field on Delegation while keeping existing MCP delegation behavior unchanged.
Changes:
- Bumped
ic-agentdependency from0.47to0.48inCargo.toml. - Updated
Cargo.lockto resolveic-agentandic-transport-typesto0.48.0. - Updated
IiSignedDelegation::into_agentto setDelegation { permissions: None, ... }for compatibility with the new struct field.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/identities.rs |
Sets permissions: None when converting II’s mcp_get_delegation response into ic-agent’s Delegation to match the new 0.48 struct shape without changing behavior. |
Cargo.toml |
Bumps ic-agent dependency requirement to 0.48. |
Cargo.lock |
Locks ic-agent and ic-transport-types to 0.48.0 with updated checksums. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
II carries a per-MCP-session permission (`opt Permissions`,
`variant { queries; all }`) on the delegation returned by
`mcp_get_delegation`, and that field is part of what II signs. Decode it
via a local Candid mirror enum and forward it into the `ic-agent`
`Delegation` (0.48's new `permissions` field) so the reconstructed
delegation hashes to exactly what II signed, instead of hardcoding
`None` and dropping it.
An absent permission still maps to `None`, which hashes identically to a
pre-0.48 delegation, so unrestricted sessions are unaffected. Adds a test
locking in the queries/all decode-and-map and the absent -> None case.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RzjuJVat2CTiCYzeU9F6e2
aterga
commented
Jul 5, 2026
Adds an end-to-end test that drives the full server path for a read-only (`queries`) delegation — II reply -> `Decode!` -> `IiSignedDelegation::into_agent` -> `build_identity` -> `Identity::sign` — with a genuinely anchor-signed chain (no network). It asserts that: - the read-only scope survives decoding into the `ic-agent` delegation, - every request the resulting identity signs (an update AND a read) carries the `Queries` permission, so the replica scopes both to queries/read_state, and - the scope is bound into the delegation signature: stripping it to an unrestricted delegation changes the signed bytes and invalidates the chain, so a client cannot silently widen a read-only delegation to full access. The shared II wire types (`WirePermissions` / `WireDelegation` / `WireSignedDelegation`) are lifted to the test module so both permission tests reuse them. Also adds a CI workflow that runs `cargo build`/`cargo test --locked` on pull requests and pushes to main — previously CI only ran the status-dashboard's npm tests, so no Rust tests (including this one) ran in CI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RzjuJVat2CTiCYzeU9F6e2
aterga
marked this pull request as ready for review
July 5, 2026 12:06
The existing "absent permission" case encoded `permissions: None`, which Candid still serializes as an `opt`-null field. A genuine pre-0.48 II reply omits the `permissions` field from the `Delegation` record entirely, which is a distinct wire type. Add a field-less legacy fixture and assert it decodes to `None`, locking in backward compatibility with old II replies (Candid subtyping decodes the absent optional as None). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RzjuJVat2CTiCYzeU9F6e2
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.
What
ic-agent0.47→0.48(andic-agent/ic-transport-typesto0.48.0inCargo.lock).ic-agentDelegation, so read-only (queries) delegations are honored.cargo testinto CI.Why
ic-agent/ic-transport-types0.48.0 add apermissionsfield toDelegationand aDelegationPermissionsenum (Queries|All) describing which request kinds a signed delegation authorizes — matching II's per-MCP-session read-only delegations (internet-identity#4086). Thepermissionsfield is part of what II signs, so it must be forwarded verbatim or the reconstructed delegation won't verify.Changes
Cargo.toml:ic-agent = "0.47"→"0.48".Cargo.lock:ic-agentandic-transport-typesresolved to0.48.0.src/identities.rs:permissions: opt variant { queries; all }frommcp_get_delegationinto a local Candid mirror (IiPermissions) — needed becauseic-agent'sDelegationPermissionsisn'tCandidType— and map it 1:1 intoDelegationPermissionswhen building theic-agentDelegation. An absent permission staysNone, which hashes identically to a pre-0.48 delegation, so unrestricted sessions are unchanged.signed_delegation_forwards_ii_permissions: locks in thequeries/all/absent decode-and-map contract.read_only_delegation_scopes_signed_requests_end_to_end: hermetic e2e over the real decode →DelegatedIdentity→Identity::signpath with an anchor-signed chain. Asserts the read-only scope survives decoding, that an update and a read request both carry theQueriespermission (so the replica scopes them to queries/read_state), and that stripping the scope invalidates the delegation signature (a client can't silently widen it to full access)..github/workflows/ci.yml: new workflow runningcargo build/cargo test --lockedon pull requests and pushes tomain. Previously CI only ran the status-dashboard's npm tests, so no Rust tests ran in CI;--lockedalso guards the dependency pins from silent drift.ic-transport-typesremains a transitive dependency (the code uses the re-exports viaic_agent::identity::…), so it is not added toCargo.toml.Testing
cargo test— all 37 tests pass.testjob is green on this PR.🤖 Generated with Claude Code
https://claude.ai/code/session_01RzjuJVat2CTiCYzeU9F6e2