refactor: drop single-asset mutation endpoints; sync via batch only#76
Merged
Conversation
Make a committed batch the only way to mutate assets. Remove the direct single-asset update endpoints: store, create_asset, set_asset_content, unset_asset_content, set_asset_properties, delete_asset, clear across all three layers that defined them (canister endpoints, the canister_core wrappers, and assets.did). The batch upload flow (create_batch / create_chunks / commit_batch / delete_batch) and every BatchOperationKind variant stay — per-asset changes ride inside a batch's `operations` and apply atomically on commit. The State-machine primitives commit_batch builds on are unchanged. Also drop the now-orphaned State::store method and StoreArg type (they only backed the removed `store` endpoint) and migrate the store-based timestamp tests onto commit_batch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Makes a committed batch the only way to mutate assets. Removes the direct single-asset update endpoints so
sync()(the batch /commit_batchpath the plugin uses) is the only write surface:store,create_asset,set_asset_content,unset_asset_content,set_asset_properties,delete_asset,clearThe removal spans all three layers that defined them:
crates/canister/src/lib.rs— the 7#[update]endpoints (and now-unused type imports).crates/canister-core/src/lib.rs— the matchingcanister_core::*wrapper functions.crates/canister/assets.did— the "Asset mutations" service block.Kept
create_batch,create_chunks,commit_batch,delete_batch.BatchOperationKindvariants and their argument types — these are the sync wire protocol and are still applied atomically insidecommit_batch.State::*state-machine primitives thatcommit_batchand the tests build on.Cleanup
storewas a single-call create-with-content composite that only backed the removed endpoint (not reused by the batch path), so this also drops the orphanedState::storemethod and theStoreArgtype, and migrates the store-based timestamp tests ontocommit_batch(one was redundant withtimestamp_updates_on_commit_batchand was removed).Verification
cargo test -p canister-core— 97 passedcargo test -p canister— candidservice_equalcheck passes, confirmingassets.didmatches the generated interfacecargo test -p sync-core— 190 passedcargo test -p e2e— 12 passed (deploy / no-op re-sync / content update / deletion / multi-dir, through theicpCLI against a live replica)The sync plugin never called these endpoints, so no client-side changes were needed.
🤖 Generated with Claude Code