Skip to content

feat: new canister setting status_visibility - #10667

Merged
mraszyk merged 13 commits into
masterfrom
mraszyk/canister-status-visibility
Jul 17, 2026
Merged

mraszyk merged 13 commits into
masterfrom
mraszyk/canister-status-visibility

Conversation

@mraszyk

@mraszyk mraszyk commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

What

Introduces a new canister setting, status_visibility, that governs which
principals are allowed to read a canister's status via the canister_status
management endpoint. It mirrors the existing log_visibility and
snapshot_visibility settings:

type status_visibility = variant {
    controllers;
    public;
    allowed_viewers : vec principal;
};
  • controllers (default): only the canister's controllers (and subnet
    admins) can read the status — the pre-existing behavior.
  • public: anyone can read the status.
  • allowed_viewers: the controllers, the subnet admins, and up to 10
    explicitly listed principals can read the status.

How

  • Access control: a new validate_status_visibility helper reuses the
    existing VisibilitySettings::has_access mechanism. It is enforced on both
    the ingress-acceptance path (should_accept_ingress_message) and both
    execution paths (replicated update and non-replicated query) via
    get_canister_status. A canister reading its own status is still exempt.
  • State: status_visibility is added to SystemState, persisted in
    CanisterStateBits (proto tag 69). Checkpoints written before this change
    decode to the default (controllers), so loading old state is
    backward-compatible.
  • New error code: denied canister_status calls now return the dedicated
    CanisterStatusAccessDenied (542) error code, replacing the previous
    CanisterInvalidController / CanisterInvalidControllerOrSubnetAdmin. It maps
    to the same CanisterError reject code as before.

Compatibility notes

  • Default preserves existing behavior: canisters created without specifying
    the setting default to controllers, so access is unchanged.
  • Error-code change: tooling that matched on the exact ErrorCode for a
    denied canister_status (previously CanisterInvalidController /
    CanisterInvalidControllerOrSubnetAdmin) will now see
    CanisterStatusAccessDenied. The reject code is unchanged.

Testing

  • New integration test rs/execution_environment/tests/canister_status.rs
    exercises the full matrix of {status_visibility} x {controller, subnet_admin, allowed_viewer, other} x {update, query} call paths, asserting the
    granted/denied outcome (and that canister_status returns the expected
    status visibility upon success), and, on denial, the returned error code and
    description.
  • The test also asserts the canister_status query success metric increments
    exactly once for an allowed query call and never for a denied query or an
    update call — restoring (and broadening) the coverage from the
    canister_status_via_query_call_* tests removed from execution_test.rs.

@github-actions github-actions Bot added the feat label Jul 6, 2026
mraszyk and others added 6 commits July 6, 2026 14:21
# Conflicts:
#	rs/execution_environment/tests/execution_test.rs
#	rs/protobuf/src/gen/state/state.canister_state_bits.v1.rs
…n_test.rs

Commit 2c0413f ("simplify") deliberately removed the three
canister_status_via_query_call_* tests and the canister_status_count
helper from execution_test.rs, as they are fully covered by the
table-driven test_status_visibility_of_canister_status in
canister_status.rs (which exercises every visibility x sender
combination over both the query and update call paths).

The merge of master (6ab53de) accidentally resurrected these tests
during conflict resolution, reintroducing the stale negative test that
still asserted the pre-status-visibility error code
(CanisterInvalidControllerOrSubnetAdmin instead of the new
CanisterStatusAccessDenied). Re-remove them to restore the intended
state.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@mraszyk
mraszyk force-pushed the mraszyk/canister-status-visibility branch from bef2cc0 to 7849177 Compare July 13, 2026 15:50
mraszyk and others added 2 commits July 15, 2026 07:19
Re-add the query success-metric coverage lost when the
canister_status_via_query_call_* tests were removed from execution_test.rs,
folding it into the status_visibility matrix test: the successful
canister_status query metric must increment exactly once for an allowed
query call and never for a denied query or an update call.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Create the test canister with zero cycles: the subnet uses a free cost
  schedule, so no cycles are needed (removes the INITIAL_CYCLES_BALANCE
  constant that was carried over from the original tests).
- Fix the two `.expect` messages on the success path so each matches the
  layer it unwraps: the outer Result is the access-control gate, the inner
  Result is the reply/reject layer (unreachable via ingress/query).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

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.

Pull request overview

Adds a new canister setting, status_visibility, to control who can call the management canister’s canister_status endpoint, aligning it with existing visibility patterns (logs/snapshots) while preserving default behavior (controllers). The change propagates through the public management canister types, replicated state persistence (protobuf/checkpoints), access-control enforcement in the execution environment, and test coverage (including a new integration test matrix and updated error-code expectations).

Changes:

  • Introduce StatusVisibility as a first-class setting in management types and canister settings APIs, and persist it in checkpoints/protobuf (tag 69).
  • Enforce status_visibility for canister_status across ingress acceptance and execution paths, returning the new CanisterStatusAccessDenied error code on denial.
  • Add/adjust tests to cover the access matrix and metric behavior; update existing tests for the new error code.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.

Show a summary per file
File Description
rs/types/management_canister_types/tests/ic.did Extends candid test interface with status_visibility and new settings fields.
rs/types/management_canister_types/src/lib.rs Adds StatusVisibility type + protobuf conversions; wires it into settings/status result types.
rs/state_manager/src/tip.rs Serializes status_visibility into checkpointed canister state bits.
rs/state_manager/src/checkpoint.rs Loads status_visibility from persisted canister state bits.
rs/state_layout/src/state_layout/tests.rs Updates default CanisterStateBits test fixture to include status_visibility.
rs/state_layout/src/state_layout/proto.rs Adds protobuf encode/decode plumbing for status_visibility in CanisterStateBits.
rs/state_layout/src/state_layout.rs Extends CanisterStateBits struct with status_visibility.
rs/rust_canisters/tests/test/canister_management.rs Updates expected error code for denied canister_status.
rs/replicated_state/src/canister_state/system_state.rs Adds status_visibility to SystemState and ensures default/init/checkpoint paths carry it.
rs/replicated_state/src/canister_state.rs Exposes status_visibility() accessor on CanisterState.
rs/replica_tests/tests/canister_lifecycle.rs Updates test construction of CanisterStatusResultV2 to include status_visibility.
rs/protobuf/src/gen/state/state.canister_state_bits.v1.rs Regenerates prost types to include StatusVisibility and tag 69 in CanisterStateBits.
rs/protobuf/def/state/canister_state_bits/v1/canister_state_bits.proto Adds StatusVisibility messages and field 69; bumps Next ID.
rs/pocket_ic_server/src/pocket_ic.rs Sets explicit default status_visibility when creating canisters in PocketIC scenarios.
rs/nervous_system/clients/src/update_settings.rs Adapts client-side update_settings conversion to new field (currently always sending None).
rs/execution_environment/tests/execution_test.rs Removes older canister_status query metric/access tests (replaced by new matrix test).
rs/execution_environment/tests/canister_status.rs Adds new integration test covering {visibility} x {caller} x {update/query} plus metrics assertions.
rs/execution_environment/src/execution/common.rs Introduces validate_status_visibility helper to centralize access checks.
rs/execution_environment/src/execution_environment/tests.rs Updates ingress acceptance tests to expect CanisterStatusAccessDenied.
rs/execution_environment/src/canister_settings.rs Extends settings parsing/builders and visibility abstraction to include StatusVisibility.
rs/execution_environment/src/canister_manager/types.rs Adds CanisterStatusAccessDenied variant + mapping to UserError (error code 542).
rs/execution_environment/src/canister_manager/tests.rs Updates manager tests to assert new error code/message for denied status calls.
rs/execution_environment/src/canister_manager.rs Enforces status_visibility for canister_status (ingress acceptance + execution paths) and returns it in results.
rs/cycles_account_manager/src/cycles_account_manager.rs Bumps max “delayed ingress induction cost” payload size constant for update_settings payload changes.
Comments suppressed due to low confidence (1)

rs/nervous_system/clients/src/update_settings.rs:96

  • CanisterSettings is documented as matching the ic-interface-spec, but the new status_visibility setting is not represented here and is always sent as None in the CanisterSettingsArgs conversion. This means nervous-system clients cannot set status_visibility (even to the defaults like controllers/public), and the local struct is now out of sync with the management canister interface.
        management_canister::CanisterSettingsArgs {
            controllers: controllers.map(management_canister::BoundedControllers::new),
            compute_allocation,
            memory_allocation,
            freezing_threshold,
            reserved_cycles_limit,
            log_visibility: log_visibility.map(management_canister::LogVisibilityV2::from),
            snapshot_visibility: snapshot_visibility
                .map(management_canister::SnapshotVisibility::from),
            status_visibility: None,
            log_memory_limit: None,
            wasm_memory_limit,
            wasm_memory_threshold,
            environment_variables: None,
            minimum_incoming_canister_call_cycles: None,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mraszyk
mraszyk marked this pull request as ready for review July 15, 2026 08:21
@mraszyk
mraszyk requested review from a team as code owners July 15, 2026 08:21

@github-actions github-actions Bot 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.

This pull request changes code owned by the Governance team. Therefore, make sure that
you have considered the following (for Governance-owned code):

  1. Update unreleased_changelog.md (if there are behavior changes, even if they are
    non-breaking).

  2. Are there BREAKING changes?

  3. Is a data migration needed?

  4. Security review?

How to Satisfy This Automatic Review

  1. Go to the bottom of the pull request page.

  2. Look for where it says this bot is requesting changes.

  3. Click the three dots to the right.

  4. Select "Dismiss review".

  5. In the text entry box, respond to each of the numbered items in the previous
    section, declare one of the following:

  • Done.

  • $REASON_WHY_NO_NEED. E.g. for unreleased_changelog.md, "No
    canister behavior changes.", or for item 2, "Existing APIs
    behave as before.".

Brief Guide to "Externally Visible" Changes

"Externally visible behavior change" is very often due to some NEW canister API.

Changes to EXISTING APIs are more likely to be "breaking".

If these changes are breaking, make sure that clients know how to migrate, how to
maintain their continuity of operations.

If your changes are behind a feature flag, then, do NOT add entrie(s) to
unreleased_changelog.md in this PR! But rather, add entrie(s) later, in the PR
that enables these changes in production.

Reference(s)

For a more comprehensive checklist, see here.

GOVERNANCE_CHECKLIST_REMINDER_DEDUP

@zeropath-ai

zeropath-ai Bot commented Jul 15, 2026

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed everything up to f092104.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/cycles_account_manager/src/cycles_account_manager.rs
      Increase MAX_DELAYED_INGRESS_COST_PAYLOAD_SIZE from 352 to 366
► rs/execution_environment/src/canister_manager.rs
      Add CanisterStatus handling with status visibility validation
► rs/execution_environment/src/canister_manager.rs
      Integrate status_visibility into status checks and propagation
► rs/execution_environment/src/canister_manager/tests.rs
      Update tests to reflect CanisterStatusAccessDenied instead of previous errors
► rs/execution_environment/src/canister_manager/types.rs
      Add CanisterStatusAccessDenied variant and mapping to UserError
► rs/execution_environment/src/canister_settings.rs
      Add status_visibility field to CanisterSettings and related accessors
► rs/execution_environment/src/execution/common.rs
      Add validate_status_visibility function
► rs/execution_environment/tests/canister_status.rs
      New tests for canister_status visibility scenarios
► rs/execution_environment/tests/execution_test.rs
      Remove legacy canister_status query count helper and related tests
► rs/protobuf/def/state/canister_state_bits/v1/canister_state_bits.proto
      Add StatusVisibility message and status_visibility field
► rs/protobuf/src/gen/state/state.canister_state_bits.v1.rs
      Add generated StatusVisibility-related structures
► rs/replicated_state/src/canister_state.rs
      Expose status_visibility accessor
► rs/replicated_state/src/canister_state/system_state.rs
      Include status_visibility in SystemState construction and propagation
► rs/rust_canisters/tests/test/canister_management.rs
      Adjust expectation to CanisterStatusAccessDenied in error cases
► rs/state_layout/src/state_layout.rs
      Include StatusVisibility in imports
► rs/state_layout/src/state_layout/proto.rs
      Serialize/deserialize status_visibility in CanisterStateBits

@zeropath-ai

zeropath-ai Bot commented Jul 15, 2026

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed everything up to f092104.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/cycles_account_manager/src/cycles_account_manager.rs
      Increase MAX_DELAYED_INGRESS_COST_PAYLOAD_SIZE from 352 to 366
► rs/execution_environment/src/canister_manager.rs
      Add CanisterStatus handling with status visibility validation
► rs/execution_environment/src/canister_manager.rs
      Integrate status_visibility into status checks and propagation
► rs/execution_environment/src/canister_manager/tests.rs
      Update tests to reflect CanisterStatusAccessDenied instead of previous errors
► rs/execution_environment/src/canister_manager/types.rs
      Add CanisterStatusAccessDenied variant and mapping to UserError
► rs/execution_environment/src/canister_settings.rs
      Add status_visibility field to CanisterSettings and related accessors
► rs/execution_environment/src/execution/common.rs
      Add validate_status_visibility function
► rs/execution_environment/tests/canister_status.rs
      New tests for canister_status visibility scenarios
► rs/execution_environment/tests/execution_test.rs
      Remove legacy canister_status query count helper and related tests
► rs/protobuf/def/state/canister_state_bits/v1/canister_state_bits.proto
      Add StatusVisibility message and status_visibility field
► rs/protobuf/src/gen/state/state.canister_state_bits.v1.rs
      Add generated StatusVisibility-related structures
► rs/replicated_state/src/canister_state.rs
      Expose status_visibility accessor
► rs/replicated_state/src/canister_state/system_state.rs
      Include status_visibility in SystemState construction and propagation
► rs/rust_canisters/tests/test/canister_management.rs
      Adjust expectation to CanisterStatusAccessDenied in error cases
► rs/state_layout/src/state_layout.rs
      Include StatusVisibility in imports
► rs/state_layout/src/state_layout/proto.rs
      Serialize/deserialize status_visibility in CanisterStateBits

@mraszyk
mraszyk dismissed github-actions[bot]’s stale review July 15, 2026 08:25

No canister behavior changes.

@mraszyk
mraszyk added this pull request to the merge queue Jul 17, 2026
Merged via the queue into master with commit a4eb8fc Jul 17, 2026
46 of 47 checks passed
@mraszyk
mraszyk deleted the mraszyk/canister-status-visibility branch July 17, 2026 18:26
mraszyk added a commit to dfinity/developer-docs that referenced this pull request Aug 3, 2026
…315)

Reflect the new status_visibility canister setting (dfinity/ic#10667),
which governs who can read a canister's status via canister_status:
controllers (default), public, or allowed_viewers. Mirrors the existing
log_visibility and snapshot_visibility settings.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
pull Bot pushed a commit to mikeyhodl/ic that referenced this pull request Aug 12, 2026
…ity#11119)

The `status_visibility` canister setting (introduced in dfinity#10667) was only
available in the internal `ic-management-canister-types-private` crate.
Add it to the public crate as well: the `StatusVisibility` type, the
fields on `CanisterSettings` and `DefiniteCanisterSettings`, and the
corresponding entries in `tests/ic.did`.

Also complete the unreleased changelog, which was missing the
`minimum_incoming_canister_call_cycles` field (dfinity#10398) and the tightened
`wasm_memory_threshold` bound (dfinity#10574).

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
raymondk added a commit to dfinity/icp-cli that referenced this pull request Aug 28, 2026
Adds the `status_visibility` canister setting from dfinity/ic#10667,
which controls who may read a canister's status through the management
canister's `canister_status` endpoint. It takes the same three forms as
`log_visibility` in a manifest and the same flag shapes on `icp canister
settings update`; `icp canister status` and `icp canister settings show`
report it, it is applied at creation, and it is kept in sync by `icp
canister settings sync`.

The three visibility settings the management canister exposes are
structurally identical but distinct Candid types, so rather than
duplicate the manifest type, the parser, the set-wise comparison, the
add/remove merge and the renderer per setting, this introduces one shared
`Visibility` enum in `icp::canister::visibility` plus a
`visibility_setting!` macro that declares the per-setting manifest
newtype, so parse errors and the generated schema still name the specific
setting. `log_visibility` behaviour is unchanged.

Requires `ic-management-canister-types` 0.9.0, which is where
`StatusVisibility` landed. `DefiniteCanisterSettings` gained a
non-optional `status_visibility`, so reading a canister's status now
requires a replica that reports it — every mainnet subnet does, and so
does the pinned network launcher.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp
raymondk added a commit to dfinity/icp-cli that referenced this pull request Aug 28, 2026
Adds the `status_visibility` canister setting from dfinity/ic#10667,
which controls who may read a canister's status through the management
canister's `canister_status` endpoint. It takes the same three forms as
`log_visibility` in a manifest and the same flag shapes on `icp canister
settings update`; `icp canister status` and `icp canister settings show`
report it, it is applied at creation, and it is kept in sync by `icp
canister settings sync`.

The three visibility settings the management canister exposes are
structurally identical but distinct Candid types, so rather than
duplicate the manifest type, the parser, the set-wise comparison, the
add/remove merge and the renderer per setting, this introduces one shared
`Visibility` enum in `icp::canister::visibility` plus a
`visibility_setting!` macro that declares the per-setting manifest
newtype, so parse errors and the generated schema still name the specific
setting. `log_visibility` behaviour is unchanged.

Requires `ic-management-canister-types` 0.9.0, which is where
`StatusVisibility` landed. `DefiniteCanisterSettings` gained a
non-optional `status_visibility`, so reading a canister's status now
requires a replica that reports it — every mainnet subnet does, and so
does the pinned network launcher.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp
raymondk added a commit to dfinity/icp-cli that referenced this pull request Aug 28, 2026
Adds the `status_visibility` canister setting from dfinity/ic#10667,
which controls who may read a canister's status through the management
canister's `canister_status` endpoint. It takes the same three forms as
`log_visibility` in a manifest and the same flag shapes on `icp canister
settings update`; `icp canister status` and `icp canister settings show`
report it, it is applied at creation, and it is kept in sync by `icp
canister settings sync`.

The three visibility settings the management canister exposes are
structurally identical but distinct Candid types, so rather than
duplicate the manifest type, the parser, the set-wise comparison, the
add/remove merge and the renderer per setting, this introduces one shared
`Visibility` enum in `icp::canister::visibility` plus a
`visibility_setting!` macro that declares the per-setting manifest
newtype, so parse errors and the generated schema still name the specific
setting. `log_visibility` behaviour is unchanged.

Requires `ic-management-canister-types` 0.9.0, which is where
`StatusVisibility` landed. `DefiniteCanisterSettings` gained a
non-optional `status_visibility`, so reading a canister's status now
requires a replica that reports it — every mainnet subnet does, and so
does the pinned network launcher.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp
raymondk added a commit to dfinity/icp-cli that referenced this pull request Aug 31, 2026
* feat: new canister setting status_visibility

Adds the `status_visibility` canister setting from dfinity/ic#10667,
which controls who may read a canister's status through the management
canister's `canister_status` endpoint. It takes the same three forms as
`log_visibility` in a manifest and the same flag shapes on `icp canister
settings update`; `icp canister status` and `icp canister settings show`
report it, it is applied at creation, and it is kept in sync by `icp
canister settings sync`.

The three visibility settings the management canister exposes are
structurally identical but distinct Candid types, so rather than
duplicate the manifest type, the parser, the set-wise comparison, the
add/remove merge and the renderer per setting, this introduces one shared
`Visibility` enum in `icp::canister::visibility` plus a
`visibility_setting!` macro that declares the per-setting manifest
newtype, so parse errors and the generated schema still name the specific
setting. `log_visibility` behaviour is unchanged.

Requires `ic-management-canister-types` 0.9.0, which is where
`StatusVisibility` landed. `DefiniteCanisterSettings` gained a
non-optional `status_visibility`, so reading a canister's status now
requires a replica that reports it — every mainnet subnet does, and so
does the pinned network launcher.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp

* feat: list allowed viewers one per line

`Allowed viewers: <a>, <b>` put two 63-character principals on the label's
line, which wraps in any normal terminal. The policy now stays on the
label and each viewer gets its own line, nested two spaces past the label
the way the other lists in those reports are:

      Status visibility: Allowed viewers
        viewer: 7tjgl-udln4-...
        viewer: cgbip-rubo2-...

The label sits at a different indent in `canister status` than in
`canister settings show`, so `format_visibility` takes the label's indent
and nests relative to it. `log_visibility` is rendered by the same
function, so it changes with it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp

* feat: list controllers one per line, and name the viewer per setting

Applies the per-line rendering to the controller list too, so the two
reports list principals the same way throughout:

      Controllers:
        controller: 2vxsx-fae
      ...
      Log visibility: Allowed viewers
        log viewer: aaaaa-aa
      Status visibility: Allowed viewers
        status viewer: 2vxsx-fae

`format_principal_list` holds the shared shape — sorted, one entry per
line, nested two spaces past the label, with a note where the entries
would have gone when the list is empty. Controllers were not sorted
before; they are now, since the replica does not promise an order.

Each entry names what it grants rather than a bare `viewer:`, because a
report carries a line for both visibility settings and the entries under
them would otherwise not say which they belong to.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp

* chore: stop tracking the Python bytecode from the test assets

`crates/icp-cli/tests/assets/__pycache__/limit_transfer.cpython-312.pyc`
was committed alongside the Python asset it is compiled from. Nothing
reads it, and since `.gitignore` did not cover it, anyone who ran the
asset saw it come back as a dirty working tree.

Untracked, and `__pycache__/` ignored so it stays that way.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp

* feat: warn when a viewer edit takes access away instead of granting it

`--add-status-viewer P` on a canister whose status is `public` resolves
to `AllowedViewers([P])`, which revokes everyone else's access rather
than adding to it; `--remove-status-viewer P` on the same canister
resolves to an empty list. The log flags behave the same way — the
resolution is shared — and neither said anything about it.

`resolve` stays pure. `maybe_warn_on_lost_access` runs at the callsite
alongside `maybe_warn_on_env_vars_change` and warns in the two cases
where a viewer edit costs access: the current policy is `public` and the
result names viewers, or the result names none at all. A warning rather
than a prompt, because unlike losing control of a canister either change
can be undone by any controller, and a prompt would break scripted use.

`--set-*-viewer` did not fetch the current settings, since it does not
build on them, so the public-to-viewers case could not be detected for
the one flag that states the new list outright. It now fetches too; the
extra query buys a warning that fires for all three flags.

Removal switches from `swap_remove` to `retain`, so the viewers it
leaves behind keep their order — that order is what the `status viewer:`
and `log viewer:` lines print.

The resolution matrix is now unit-tested, which is what the integration
test already claimed: a fixed policy beats viewer edits, `--set`
replaces, `--add` dedupes, an edit against a fixed policy starts from an
empty list, removal is order-preserving and may empty the list, and
every viewer edit requires the current settings. The two warnings are
covered against a live replica instead, since they go through `warn!`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp

* fix: refuse a relative viewer edit while the visibility is public

`public` grants access to everyone, so it carries no allowed viewers
list for `--add-log-viewer` / `--remove-log-viewer` and their status
counterparts to be relative to. They started one from empty instead,
which meant `--add-log-viewer P` on a public canister took access away
from everyone but P, and `--remove-log-viewer P` took it away from
everyone including P. Warning about it was the wrong tool: these flags
do not say to change the policy at all, so there is nothing to warn
about — the edit has no meaning to carry out.

They are now refused while the setting is public, and the error names
the two flags that do state a policy outright:

    Log visibility is currently public, so there is no allowed viewers
    list for --add-log-viewer to edit. Use `--set-log-viewer <PRINCIPAL>`
    to replace the public policy with an explicit list, or
    `--log-visibility controllers` to revoke public access on its own.

`controllers` keeps accepting relative edits, because a list built from
it grants access on top of the controllers rather than taking any away.
`--set-*-viewer` on a public canister stays legal for the same reason
the relative edits are not: it states the whole new list, so what it
revokes is on its face — it warns rather than refuses, as does removing
the last viewer.

`resolve` grows a `Result` and the group carries the setting's names, so
one implementation still serves both settings and its messages can name
whichever it was reached through.

This is breaking for the log flags, which shipped with the old
behaviour: `canister_settings_update_log_visibility` asserted the
add-to-a-public-canister case succeeding, and now asserts the refusal
followed by the `--set-log-viewer` that expresses it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
basvandijk pushed a commit to Ocheretovich/ic that referenced this pull request Oct 23, 2026
Bump the workspace dependency `ic-management-canister-types` from 0.8.0
to 0.11.0. This is needed for dfinity#11894 (offline derivation of secp256r1
keys in `ic-pub-key`).

Between 0.8.0 and 0.11.0 nothing was removed or renamed. The additions
still break Rust code in places, because none of these types is
`#[non_exhaustive]`:
- `CanisterSettings` and `DefiniteCanisterSettings` gained the fields
`minimum_incoming_canister_call_cycles` and `status_visibility`, along
with the new `StatusVisibility` type.
- `HttpRequestArgs` gained `pricing_version`, and `HttpMethod` gained
`PATCH`.
- New types for flexible HTTP outcalls and subnet metrics.
- `EcdsaCurve` gained `Secp256r1`.

Changes that follow from the bump:
- `canister_test`: one struct literal lists every `CanisterSettings`
field, so it now sets the two new fields as well.
- CMC: `cmc.did` declares the two new `CanisterSettings` fields, because
`test_candid_interface_compatibility` requires it. The CMC now forwards
these two settings in `create_canister` and `notify_create_canister`.
Before, it dropped them. `unreleased_changelog.md` records this. dfinity#10756
did the same for `snapshot_visibility`.
- ckDOGE minter: `ckdoge_minter.did` declares the two new
`DefiniteCanisterSettings` fields, which `get_canister_status` now
returns. The replica returns both fields unconditionally since dfinity#10398
and dfinity#10667, and all mainnet GuestOS versions in
`mainnet-icos-revisions.json` contain both PRs. So decoding
`canister_status` with the new types also works on mainnet.
- Changelogs: `pocket-ic` and `ic-pub-key` re-export these types, so
both record the bump.

The older copies left in `Cargo.lock` come from `ic-utils` and
`evm_rpc_types`, which have no newer release, and from the cdk, which a
follow-up PR bumps.

This does not yet remove the secp256r1 workarounds in the system tests
(`cast_ecdsa_key_id`, the signer canister) and in the PocketIC test
canister. Those are cdk canisters, and the workspace's
`ic-cdk-management-canister` 0.1.1 re-exports the 0.7.1 types. Its 0.3.0
requires `ic-management-canister-types` ^0.11, so this bump comes first.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants