Skip to content

chore: prepare release 0.3.2 - #118

Merged
lwshang merged 6 commits into
mainfrom
release-0.3.2
Jul 30, 2026
Merged

lwshang merged 6 commits into
mainfrom
release-0.3.2

Conversation

@lwshang

@lwshang lwshang commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Four changes bundled into the 0.3.2 patch release. Nothing here touches a
stable-state shape, so a deployed canister moves with --mode upgrade and
keeps its assets.

fix(asset-prep): scan a relative dist directory as given

state-hash ./dist — the exact invocation
docs/verifying-contents.md tells a verifier to
run — failed with read_dir /dist: No such file or directory. scan rebuilt its
root by prepending / and keeping only Normal components, so any relative path
became absolute. The plugin never hit it (the host hands it a preopen guest name)
and the e2e verifier test passes an absolute path, so it went unnoticed.

dir is now used verbatim. Nothing needed the absolute root: walk only joins
onto the root it was handed and strips that same prefix back off, and the sibling
_headers / _redirects reads were already relative. The docstring keeps the
reasoning that motivated the rebuild — don't reintroduce canonicalize, it
ENOENTs under a multi-component WASI preopen — and now states where sandbox
safety actually comes from: the preopen itself, plus the host rejecting absolute
/ .. dirs entries. All three spellings (./dist, dist, absolute) now
produce the same hash.

Two test-infrastructure fixes found while verifying it:

  • crates/e2e/build.rs never listed asset-prep in rerun-if-changed, so the
    first nested-preopen run silently tested a stale dist/plugin.wasm.
    wire-types, state-hash and sync-plugin/wit/ were missing too. It now
    watches every crate that lands in either wasm, plus the root manifest and
    lockfile.
  • The nested fixture gained a _redirects at the root of its multi-component
    preopen, and nested_dir_deploy fetches /old to prove the rule loaded — an
    absent config file means "no rules", so a path that failed to resolve there
    would have dropped every redirect rule without an error.

docs: fix issue_token call form and empty-argument calls

Closes #116. issue_token takes a single IssueTokenArgs record, but the quick
start and the managing-tokens table passed three positional arguments — a call
that traps in the canister. The scan the issue asked for turned up one more
broken form: the zero-argument methods were written bare (list_tokens,
check_protection_status, disable_protection). Given no argument,
icp canister call doesn't send an empty one — it opens an interactive prompt,
which for a non-interactive caller is either arguments were not provided and could not fetch candid type or a silent User cancelled. They now pass '()'.

Verified against a local replica: every icp canister call line extracted from
the edited files succeeds, the old positional form fails, and the documented
quick start ends with a logged-out 307 → /login.html and a 200 for a request
bearing the passphrase.

test(e2e): run the docs' canister-call snippets

The drift above shipped because nothing executed the documented form.
documented_calls_are_accepted_by_the_canister extracts every
<method> '<candid>' pair from the committed docs — fenced sh blocks and
reference tables, since the bug was in both — and sends each to the deployed
example. Reference forms carry placeholders, so a small explicit table fills them
in; a placeholder with no entry fails the test rather than silently skipping the
snippet. A final assertion requires all six management methods to have been
covered, so a reformatted table can't leave the test passing vacuously.

Verified load-bearing both ways: restoring the positional issue_token fails
with the canister's decode trap, attributed to the document; renaming a
placeholder fails with unfilled placeholder … add it to PLACEHOLDERS.

feat(recipe): adopt the metadata visibility field

dfinity/icp-cli-recipes#34
(merged) added an optional visibility to metadata entries, but it edited
recipes/static-site/ directly — and this repo is that directory's source:
scripts/publish-recipe.sh overwrites both recipe.hbs (from the release asset
generated out of recipe.hbs.in) and README.md (copied from
crates/recipe-gen/assets/). The next publish would have silently reverted it.
Ported verbatim, and confirmed the loop closes: regenerating the v0.3.1 release
recipe now matches the published recipe.hbs byte for byte, and the README
source matches the published README byte for byte.

Coverage for the new field at both levels:

  • recipe-gen unit tests pin the full ic-wasm command line rather than
    grepping it. An entry omitting visibility must render byte-for-byte what it
    did before the field existed (the backward-compatibility claim, and the case
    that would break under icp-cli's handlebars strict mode); a second test covers
    public, explicit private, and omitted in one mixed list.
  • recipe_metadata (e2e) gained a visibility: public entry beside the private
    one and now reads the sections back off the deployed canister, the only place
    the difference is observable: visibility decides whether ic-wasm writes
    icp:public <name> or icp:private <name>, and the replica serves the former
    to anyone while gating the latter on being a controller. So the public section
    is read with --identity anonymous and the private one must be refused, with a
    controller read of both first so neither anonymous check passes vacuously.

chore: prepare release 0.3.2

Patch bump, and Cargo.lock carries it for all 11 workspace members with no
dependency churn — the compressor builds whose bytes end up in deployed canisters
and in state_hash are untouched.

Testing

cargo nextest run --locked --all-targets — 466 pass (462 before this branch);
cargo clippy --workspace --all-targets and cargo fmt --check --all clean.

🤖 Generated with Claude Code

lwshang and others added 6 commits July 30, 2026 16:39
`state-hash ./dist` — the exact invocation `docs/verifying-contents.md`
tells a verifier to run — failed with "read_dir /dist: No such file or
directory". `scan` rebuilt its root by prepending `/` and keeping only
`Normal` components, so any relative path became absolute. Predates the
`state-hash` tool; the plugin never hit it because the host hands it a
preopen guest name, and the e2e verifier test passes an absolute path.

Use `dir` verbatim instead. Nothing needed the absolute root: `walk` only
joins onto the root it was handed and strips that same prefix back off,
and the sibling `_headers` / `_redirects` reads already used `dir`
relative. The docstring keeps the reasoning that motivated the rebuild —
don't reintroduce `canonicalize`, it ENOENTs under a multi-component WASI
preopen — and now states where sandbox safety actually comes from: the
preopen itself (a guest reaches nothing outside it however a path is
spelled) plus the host rejecting absolute / `..` `dirs` entries. The
`Normal`-only filter protected nothing; its only real effect was silently
reinterpreting relative paths. All three spellings of a directory
(`./dist`, `dist`, absolute) now produce the same hash.

Two test-infrastructure fixes found while verifying this:

- `crates/e2e/build.rs` never listed `asset-prep` in `rerun-if-changed`,
  so the first nested-preopen run silently tested a stale
  `dist/plugin.wasm` and proved nothing. `wire-types`, `state-hash` and
  `sync-plugin/wit/` were missing too. It now watches every crate that
  lands in either wasm, whole-crate, plus the root manifest and lockfile.

- The `nested` fixture gained a `_redirects` at the root of its
  multi-component preopen, and `nested_dir_deploy` fetches `/old` to
  prove the rule loaded. An absent config file means "no rules", so a
  path that failed to resolve there would have dropped every redirect
  rule without an error. Verified load-bearing by breaking the read and
  watching the test fail.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…otection docs

Closes #116.

`issue_token` takes a single `IssueTokenArgs` record, but the quick start
and the managing-tokens table in `docs/access-protection.md` passed three
positional arguments. The call fails — an arity/type mismatch that traps
in the canister, or a serialization error when the CLI has the candid
interface to check against. The runnable example
(`examples/access-protection/README.md`) already had the record form, so
the docs contradicted both the `.did` and the working example.

The scan the issue asked for turned up one more broken form in the same
tables: the methods that take no arguments were written bare
(`list_tokens`, `check_protection_status`, `disable_protection`). Given no
argument, `icp canister call` does not send an empty one — it opens an
interactive prompt to build the arguments, which for a non-interactive
caller is either "arguments were not provided and could not fetch candid
type" or a silent "User cancelled." They now pass `'()'`, and a line under
the table says why. No other doc snippet drifted: every remaining
`canister call` occurrence across the docs, READMEs and ARCHITECTURE.md
matches the `.did`.

Verified by deploying `examples/access-protection` to a local replica and
running every `icp canister call` line extracted from the two edited files
(both with and without `--candid`, stdin closed): all succeed, the old
positional form fails, and the documented quick start ends with a logged-out
307 to /login.html and a 200 for a request bearing the passphrase. Also
confirmed the table's claim about random tokens — `value = null` and an
omitted `value` field both mint one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#116 was a documented call that never worked: `issue_token` printed with
three positional arguments in a copy-pasteable quick start *and* in the
reference table, while `protection.rs` called the same method correctly by
hand. Nothing executed the documented form, so the drift shipped.

`documented_calls_are_accepted_by_the_canister` closes that: it extracts
every `<method> '<candid>'` pair from the committed `docs/access-protection.md`
and `examples/access-protection/README.md` — fenced `sh` blocks and reference
tables alike, since the bug was in both — and sends each to the deployed
example. Reference forms carry placeholders, so a small explicit table fills
them in; a placeholder with no entry fails the test rather than silently
skipping the snippet. A final assertion requires all six management methods
to have been covered, so a reformatted table that stopped matching can't
leave the test passing vacuously.

Snippets are judged one at a time, not as a sequence: only `issue_token`
needs the gate open, so it is re-enabled before those, and the documented
order stays the concern of the existing gating test. Reading the committed
files (not the deployed copy) is deliberate — the guarantee is about the
files a reader lands on.

Verified load-bearing both ways: restoring the positional `issue_token`
fails the test with the canister's decode trap, attributed to
`docs/access-protection.md`; renaming a placeholder fails it with "unfilled
placeholder … add it to PLACEHOLDERS".

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…pes#34

dfinity/icp-cli-recipes#34 (merged) added an optional `visibility` to
`metadata` entries across all five recipes that expose the parameter,
`static-site` among them — but it edited `recipes/static-site/` directly,
and this repo is that directory's source: `scripts/publish-recipe.sh`
overwrites both `recipe.hbs` (from the release asset generated out of
`recipe.hbs.in`) and `README.md` (copied from `crates/recipe-gen/assets/`).
The next publish would have silently reverted it. Ported here verbatim, so
it survives.

    - … metadata "{{ name }}" -d "{{ value }}" --keep-name-section
    + … metadata "{{ name }}" -d "{{ value }}"{{#if visibility}} -v {{ visibility }}{{/if}} --keep-name-section

Confirmed the port closes the loop: regenerating the v0.3.1 release recipe
now matches the published `recipes/static-site/recipe.hbs` byte for byte,
and `crates/recipe-gen/assets/README.md` matches the published README byte
for byte. So the next `publish-recipe.sh` run is a no-op on these lines
rather than a revert.

Coverage for the new field, at both levels:

- `recipe-gen` unit tests pin the full `ic-wasm` command line rather than
  grepping it: `local_with_metadata` now asserts an entry that omits
  `visibility` renders byte-for-byte what it did before the field existed
  (the backward-compatibility claim, and the case that would break under
  icp-cli's handlebars strict mode), and `local_with_metadata_visibility`
  covers `public`, explicit `private`, and omitted in one mixed list — the
  shape where a template slip shows up as a stray flag or a lost
  `--keep-name-section`.

- `recipe_metadata` (e2e) gains a `visibility: public` entry beside the
  existing private one and now reads the sections back off the deployed
  canister, which is the only place the difference is observable:
  `visibility` decides whether ic-wasm writes `icp:public <name>` or
  `icp:private <name>`, and the replica serves the former to anyone while
  gating the latter on the caller being a controller. So the public section
  is read with `--identity anonymous` and the private one must be refused,
  with a controller read of both first so neither anonymous check can pass
  vacuously. Verified load-bearing: dropping `visibility: public` from the
  fixture fails the test with the intended message.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Patch bump — `0.3.1 → 0.3.2` — so a deployed canister moves in place with
`--mode upgrade` and keeps its state; nothing in this series changed a
stable-state shape. The value is also the canister↔plugin release identity
(`crates/wire-types/src/version.rs`), so both wasms rebuild reporting
0.3.2 and only talk to each other.

`Cargo.lock` carries the same bump for all 11 workspace members and no
dependency churn — the compressor builds whose output bytes end up in
deployed canisters and in `state_hash` are untouched.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…'s identity

`recipe_metadata` failed on both CI runners while passing locally. The
assertion it failed on read the *private* section anonymously and required
a refusal — which assumes the anonymous principal is not a controller of
the canister. On a fresh icp-cli install the only identity is the built-in
`anonymous` one and it is the default (`icp/src/identity/manifest.rs`), so
CI deploys as anonymous, anonymous *is* the controller, and every section
reads back fine. A developer machine with a real default identity behaves
the opposite way. The test was passing for a reason that had nothing to do
with the recipe.

Visibility is now read where it does not depend on who is asking: the
section *names* on the built wasm, via `ic-wasm <wasm> metadata`, which
prints `icp:public build:commit` / `icp:private app:framework`. That is
exactly the distinction `-v public` controls, and the replica cannot supply
it — it serves a public section to anyone and a private one to controllers,
so telling them apart needs a non-controller caller, and no identity is
available that a test can rely on being one. The controller-side read of
both values off the deployed canister stays, so the visibility check still
can't pass on a wasm whose sections never reached the replica.

Reaching into `.icp/cache/artifacts/<canister>` is an icp-cli implementation
detail (`icp build` has no `--output`), so the helper asserts the artifact is
there with a message saying to update the path if the layout moves, rather
than failing as if the recipe broke.

Verified by reproducing CI's condition locally instead of guessing at it:
under a throwaway `ICP_HOME` — a fresh install, anonymous as default
identity — the previous test fails with CI's exact message ("must stay
private … Got: react") and the new one passes; it also still passes under a
normal home with a real default identity. Dropping `visibility: public` from
the fixture fails it with the intended message, so the check is still
load-bearing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@lwshang
lwshang marked this pull request as ready for review July 30, 2026 21:41
@lwshang
lwshang requested a review from a team as a code owner July 30, 2026 21:41
@lwshang
lwshang merged commit a385daf into main Jul 30, 2026
7 checks passed
@lwshang
lwshang deleted the release-0.3.2 branch July 30, 2026 21:42
raymondk pushed a commit to dfinity/icp-cli-recipes that referenced this pull request Jul 31, 2026
Publishes the `static-site` recipe at v0.3.2, pinning the canister and
sync-plugin wasm from dfinity/certified-assets's v0.3.2 release.

The committed `recipe.hbs` is the asset attached to that release,
verbatim — verify it matches:

https://github.com/dfinity/certified-assets/releases/download/v0.3.2/recipe.hbs

After merge, tag `static-site-v0.3.2` in this repo to cut the recipe
release.

------

### Context: version ordering

This publishes `static-site-v0.3.2`, below the existing
`static-site-v0.4.0`. That's
deliberate: the `static-site` recipe version tracks the certified-assets
release it
pins, and v0.4.0 pins v0.3.1 artifacts. A minor bump upstream also
carries a specific
meaning — breaking change, canister reinstall, every asset re-uploaded —
which doesn't
apply here.

Sequence: merge this → tag `static-site-v0.3.2` → retire the
`static-site-v0.4.0` tag
and release. One local checkout references it, coordinated directly.

#34's `visibility` option is unaffected: it was carried upstream in

[certified-assets#118](dfinity/certified-assets#118),
so it's in
the recipe committed here and the diff is only the two wasm pins. These
files are
regenerated from that repo on each publish, so changes persist by
landing there.
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.

docs/access-protection.md: issue_token quick-start uses positional args, but the method takes a record (IssueTokenArgs)

1 participant