Skip to content

feat(pic): add IC spec drift detection and update canister settings#255

Merged
nikosxenakis merged 6 commits intomainfrom
nikosxenakis/SDK-2624-spec-drift-check
Mar 17, 2026
Merged

feat(pic): add IC spec drift detection and update canister settings#255
nikosxenakis merged 6 commits intomainfrom
nikosxenakis/SDK-2624-spec-drift-check

Conversation

@nikosxenakis
Copy link
Copy Markdown
Contributor

@nikosxenakis nikosxenakis commented Mar 16, 2026

Motivation

The IC management canister interface (ic.did) evolves upstream in dfinity/ic, but pic-js maintains hand-written IDL definitions in management-canister.ts. When the spec changes, we only discover it manually.

SDK-2624

Summary

  • Pinned the upstream IC management canister spec at spec/ic.did
  • Updated the pinned spec and management-canister.ts to match the latest upstream.
  • Added scripts/check-spec-drift.sh that fetches the latest upstream spec and diffs it against the pinned copy, outputting actionable instructions on drift
  • Added .github/workflows/check-spec-drift.yml running weekly on Sundays, on manual dispatch, and as a prerequisite in create-release-pr.yml
  • On drift, the check emits a CI warning annotation rather than failing the workflow

@nikosxenakis nikosxenakis requested a review from a team as a code owner March 16, 2026 18:03
Copilot AI review requested due to automatic review settings March 16, 2026 18:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds automated drift detection for the IC management canister Candid spec and updates pic canister-settings handling to align with the newly pinned upstream spec snapshot.

Changes:

  • Add a pinned upstream spec copy at spec/ic.did and a script to diff it against upstream (scripts/check-spec-drift.sh).
  • Add a GitHub Actions workflow to run the drift check on a schedule / dispatch / as a reusable workflow, and gate create-release-pr.yml on it.
  • Extend PIC canister settings support with snapshotVisibility and logMemoryLimit, plus corresponding IDL wiring.

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
spec/ic.did Adds pinned management canister Candid spec snapshot for drift comparisons.
scripts/check-spec-drift.sh Fetches upstream ic.did and diffs against the pinned copy; emits CI warning on drift.
.github/workflows/check-spec-drift.yml Runs drift check weekly, on-demand, and as a reusable workflow.
.github/workflows/create-release-pr.yml Adds drift check as a prerequisite job for release PR creation.
packages/pic/src/management-canister.ts Adds IDL/types for snapshot_visibility and log_memory_limit in canister settings.
packages/pic/src/util/candid.ts Adds optSnapshotVisibilityToIDL converter and exports SnapshotVisibility IDL type.
packages/pic/src/pocket-ic.ts Plumbs new canister settings fields through create/update settings calls.
packages/pic/src/pocket-ic-types.ts Exposes SnapshotVisibility, snapshotVisibility, and logMemoryLimit in public types.
package.json Bumps dev dependencies (@icp-sdk/bindgen, @types/node, vitest).
pnpm-lock.yaml Lockfile updates reflecting the dependency bumps.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

packages/pic/src/management-canister.ts:65

  • The pinned spec (spec/ic.did) defines definite_canister_settings with additional fields (controller, snapshot_visibility, log_memory_limit) compared to the DefiniteCanisterSettings IDL/type in this module. If the intent is to keep management-canister.ts aligned with the pinned upstream spec, please update the DefiniteCanisterSettings (and any related canister_status response types) to include these fields (or explicitly document that this module intentionally models a subset).
const SnapshotVisibility = IDL.Variant({
  controllers: IDL.Null,
  public: IDL.Null,
  allowed_viewers: IDL.Vec(IDL.Principal),
});

export type SnapshotVisibility =
  | { controllers: null }
  | { public: null }
  | { allowed_viewers: Principal[] };

export interface CanisterSettings {
  controllers: [] | [Principal[]];
  compute_allocation: [] | [bigint];
  memory_allocation: [] | [bigint];
  freezing_threshold: [] | [bigint];
  reserved_cycles_limit: [] | [bigint];
  log_visibility: [] | [LogVisibility];
  snapshot_visibility: [] | [SnapshotVisibility];
  log_memory_limit: [] | [bigint];
  wasm_memory_limit: [] | [bigint];
  wasm_memory_threshold: [] | [bigint];
  environment_variables: [] | [EnvironmentVariable[]];
}

export const CanisterSettings = IDL.Record({
  controllers: IDL.Opt(IDL.Vec(IDL.Principal)),
  compute_allocation: IDL.Opt(IDL.Nat),
  memory_allocation: IDL.Opt(IDL.Nat),
  freezing_threshold: IDL.Opt(IDL.Nat),
  reserved_cycles_limit: IDL.Opt(IDL.Nat),
  log_visibility: IDL.Opt(LogVisibility),
  snapshot_visibility: IDL.Opt(SnapshotVisibility),
  log_memory_limit: IDL.Opt(IDL.Nat),
  wasm_memory_limit: IDL.Opt(IDL.Nat),
  wasm_memory_threshold: IDL.Opt(IDL.Nat),
  environment_variables: IDL.Opt(IDL.Vec(EnvironmentVariable)),
});

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

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR pins the upstream IC management canister Candid spec into the repo and adds automation to detect upstream spec drift, while also extending pic canister settings support to include snapshot visibility and log memory limits.

Changes:

  • Added a pinned upstream management canister spec at spec/ic.did.
  • Added CI + a script to check for upstream spec drift on a schedule, manually, and as part of the release PR workflow.
  • Extended pic canister settings encoding/types to support snapshotVisibility and logMemoryLimit.

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
spec/ic.did Adds a pinned copy of the upstream management canister spec for drift comparisons.
scripts/check-spec-drift.sh Fetches upstream ic.did, diffs against pinned copy, emits actionable output + CI warning.
.github/workflows/check-spec-drift.yml Runs the drift check weekly, on dispatch, and as a reusable workflow.
.github/workflows/create-release-pr.yml Makes spec drift check a prerequisite job for release PR creation.
packages/pic/src/util/candid.ts Adds SnapshotVisibility (PIC↔IDL) conversion helpers.
packages/pic/src/pocket-ic.ts Includes snapshot_visibility and log_memory_limit when creating/updating canisters.
packages/pic/src/pocket-ic-types.ts Exposes SnapshotVisibility and new canister settings fields in public types/docs.
packages/pic/src/management-canister.ts Updates management canister settings IDL/types to include new fields.
package.json / pnpm-lock.yaml / bun.lock Bumps dev tooling dependencies (bindgen/types/vitest) and updates lockfiles accordingly.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an automated mechanism to detect upstream drift in the IC management canister spec and updates PocketIC canister settings support to include newly added management-canister fields (notably snapshot visibility and log memory limit).

Changes:

  • Add a pinned upstream management canister spec (spec/ic.did) plus a CI/scripted drift check that compares against dfinity/ic.
  • Extend PocketIC canister settings APIs and IDL encoding to support snapshotVisibility and logMemoryLimit.
  • Bump dev tooling dependencies (bindgen, Node types, Vitest) and refresh lockfiles.

Reviewed changes

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

Show a summary per file
File Description
spec/ic.did Adds the pinned upstream management canister Candid spec used for drift detection.
scripts/check-spec-drift.sh Script to fetch upstream ic.did and diff against the pinned spec, emitting actionable output/warnings.
.github/workflows/check-spec-drift.yml New scheduled/manual/reusable workflow to run the drift check in CI.
.github/workflows/create-release-pr.yml Runs spec drift check as a prerequisite job for release PR creation.
packages/pic/src/management-canister.ts Updates canister settings IDL/types to include snapshot visibility and log memory limit.
packages/pic/src/util/candid.ts Adds PIC↔IDL conversion helpers for snapshot visibility and re-exports the new IDL type.
packages/pic/src/pocket-ic-types.ts Extends public PocketIC types to surface snapshotVisibility/logMemoryLimit as settings inputs and clarifies status is a subset.
packages/pic/src/pocket-ic.ts Wires new settings fields through createCanister/updateCanisterSettings payload encoding.
packages/pic/tests/src/pocket-ic.spec.ts Extends settings update test to exercise the new options (ensuring requests accept them).
package.json Bumps devDependencies (@icp-sdk/bindgen, @types/node, vitest).
pnpm-lock.yaml Lockfile refresh for updated devDependencies.
bun.lock Lockfile refresh aligned with updated dependencies.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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

You can also share your feedback on Copilot code review. Take the survey.

viviveevee
viviveevee previously approved these changes Mar 17, 2026
Co-authored-by: Vivienne Siffert <vivienne.siffert@dfinity.org>
@nikosxenakis nikosxenakis added this pull request to the merge queue Mar 17, 2026
Merged via the queue into main with commit bf3a38c Mar 17, 2026
15 checks passed
@nikosxenakis nikosxenakis deleted the nikosxenakis/SDK-2624-spec-drift-check branch March 17, 2026 11:01
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.

3 participants