Repository navigation
feat(canister): upload_assets writes several files in one call - #149
Merged
Merged
Conversation
Adds `upload_assets: (vec UploadAssetArguments) -> (blob)`, the batch form of `upload_asset`. All assets are validated up front and written in a single final `execute_operations` call, so a batch lands whole or not at all. `upload_asset` is now `upload_assets` with one entry: the endpoint forwards to it and `State::begin_upload_asset` is replaced by `begin_upload_assets`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Merged
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The operation driver can yield between live-store mutations, exposing partial batches and preventing rollback after a later trap; atomic publication or a bounded non-yielding mutation phase is needed, with a regression test crossing the yield boundary.
1 open issue
What changed in this PR
Adds upload_assets for uploading multiple files outside a deploy, reusing the existing sync machinery and preserving the single-file endpoint’s interface.
Changes:
- Exposes the batch endpoint and routes
upload_assetthrough it. - Validates all entries before staging, including duplicate-key rejection.
- Adds batch tests and a documented example exercised by end-to-end tests.
| File | Description |
|---|---|
docs/site-files.md |
Documents batch uploads, limits, and an example call. |
crates/wire-types/src/lib.rs |
Clarifies that upload arguments also represent batch entries. |
crates/e2e/tests/preserve.rs |
Exercises the documented batch call and checks served content. |
crates/canister/src/lib.rs |
Exposes the guarded upload_assets endpoint. |
crates/canister-core/src/state/tests.rs |
Tests batch results, validation, duplicates, and empty input. |
crates/canister-core/src/state/sync.rs |
Adds batch validation and shared per-asset staging. |
crates/canister-core/src/lib.rs |
Adds batch orchestration and delegates single-file uploads. |
certified-assets.did |
Declares the additive batch method. |
.claude/rules/testing.md |
Updates guidance to mention both documented upload calls. |
Review effort: Balanced
The shared `execute_operations` driver yields to a self-call between operations once the instruction budget runs low, which commits whatever was applied so far. A large `upload_assets` batch could therefore be visible half-written, and a later failure could not roll the first half back. An upload now applies all of its operations in the message that opened it, and only the state-hash recompute is handed to the yielding driver. A batch that fails, or is too large for one message, traps and rolls back whole. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Merges the two batch tests, drops the relative-key and one-by-one tests the batch tests subsume, shares `body_of` and the canister-shaped upload helper across test modules, and runs the documented `upload_assets` call inside the existing preserve e2e test rather than booting a second replica for it. Co-Authored-By: Claude Fable 5.2 <[email protected]>
lwshang
approved these changes
Nov 18, 2026
lwshang
pushed a commit
that referenced
this pull request
Nov 18, 2026
Stacked on #149. Prepares the `1.0.0` release of the certified-assets canister and its sync plugin. ## What 1.0.0 changes The version rule in `wire-types/src/version.rs` already covers it, no code change needed: - **From now on a major bump is the breaking one.** Minor and patch releases (`1.0.0 → 1.1.0`, `1.0.0 → 1.0.1`) must both upgrade in place and recover stable state. Before this, a minor bump was the escape hatch for state-shape changes; after it, only `2.0.0` is. - **`0.4.x → 1.0.0` is itself a series switch.** A `1.0.0` plugin that meets a `0.4.x` canister tells the user to reinstall, which wipes state not re-derived from the project (access-protection tokens, files kept by `_preserve`). Worth deciding before tagging: the only change since `v0.4.3` is #149, which is additive and touches no stable state, so nothing in this release actually needs the reinstall. It is the version number alone that makes the plugin ask for one. If there are stable-state shapes or legacy fields you want gone, this is the last release where dropping them is free. ## Changes - `Cargo.toml` / `Cargo.lock`: workspace version `0.4.3` → `1.0.0` - `docs/overview.md`: the example recipe version - `README.md` (Releasing), `.claude/rules/project-stage.md`, `docs/governance.md`, a `wire-types` doc comment: the breaking-vs-non-breaking rule restated for `1.x` (they described the `0.x` rule) ## After merge 1. `make tag && git push origin v1.0.0`: triggers the release workflow 2. `scripts/publish-recipe.sh v1.0.0 --push`: refreshes the `icp-cli-recipes` PR with the release's own `recipe.hbs` 3. After that merges, tag `static-site-v1.0.0` in `icp-cli-recipes` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5.2 <[email protected]>
lwshang
added a commit
to dfinity/icp-cli-recipes
that referenced
this pull request
Nov 18, 2026
Publishes the `static-site` recipe at v1.0.0, pinning the canister and sync-plugin wasm from dfinity/certified-assets's v1.0.0 release. ## Draft: do not merge yet The v1.0.0 release of certified-assets does not exist yet. It is prepared by dfinity/certified-assets#149 and dfinity/certified-assets#150, and is cut by tagging `v1.0.0` once they merge. Until then: - The two release URLs in `recipe.hbs` return 404. - The two `sha256` values come from a local `make recipe-release` on the #150 branch, not from the release CI. They are placeholders: the released wasm may hash differently. ## Before marking ready Replace `recipes/static-site/recipe.hbs` with the asset attached to the release, verbatim, and confirm the two match: https://github.com/dfinity/certified-assets/releases/download/v1.0.0/recipe.hbs After merge, tag `static-site-v1.0.0` in this repo to cut the recipe release. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.2 <[email protected]> Co-authored-by: Linwei Shang <[email protected]>
lwshang
added a commit
that referenced
this pull request
Nov 18, 2026
The deleted v1.0.0 release treated 0.4.x → 1.0.0 as a breaking (reinstall) switch. But 1.0.0 is 0.4.3 plus `upload_assets` (#149); stable state (`canister-core/src/store/`) hasn't changed since 0.4.3. So a reinstall would wipe protection tokens, `authorize`d principals and preserved files for no reason. - `Version::series()` maps `0.4` to series `(1, 0)`, so `upgrade_compatible_with` treats 0.4.x ↔ 1.x as an in-place upgrade. The plugin's mismatch hint now says to upgrade. `0.3.x` and earlier stay separate series. - Updated the docs that said 0.4.x → 1.0.0 is breaking: README, `project-stage.md` (1.x must also recover 0.4.x state), `governance.md`, `.did` comments, and an e2e doc comment. Verified by hand on a local network: deployed the published v0.4.3 recipe wasms, `authorize`d a principal, then ran `icp deploy` with this branch's build. Result: `version` = 1.0.0, the principal is still listed, sync reported "3 asset(s) already up to date" (nothing re-uploaded), and the site serves. After merge: re-tag `v1.0.0` on the merge commit and republish the recipe. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Adds
upload_assets: (vec UploadAssetArguments) -> (blob), the batch form ofupload_asset.Behaviour
execute_operationscall. One bad entry rejects the whole call.upload_asset, per asset. Key must start with/, an error page must fit in one chunk, refused in by-proposal mode and while a sync is in progress, stored as the identity encoding only.upload_assetnow reuses itcanister_core::upload_asset(arg)isupload_assets(vec![arg]).State::begin_upload_assetis replaced byState::begin_upload_assets; the per-asset chunking and operation building moved into a privatestage_uploaded_asset.Compatibility
Additive: one new candid method, no changed signature, no stable-state change.
Tests
canister-core: batch lands in one step, batch equals the same assets uploaded one by one (same hash and details), one invalid entry rejects the batch, duplicate key rejected, empty batch is a no-op. Existingupload_assettests now run through the shared path.e2e(preserve.rs): runs the newupload_assetssnippet extracted fromdocs/site-files.md.Not run locally:
canbench(not installed here), so the benchmark job in CI is the first check of that.🤖 Generated with Claude Code