Skip to content

refactor: drop single-asset mutation endpoints; sync via batch only#76

Merged
lwshang merged 1 commit into
mainfrom
lwshang/state_mutation_sync_only
Jun 5, 2026
Merged

refactor: drop single-asset mutation endpoints; sync via batch only#76
lwshang merged 1 commit into
mainfrom
lwshang/state_mutation_sync_only

Conversation

@lwshang
Copy link
Copy Markdown
Collaborator

@lwshang lwshang commented Jun 5, 2026

What

Makes a committed batch the only way to mutate assets. Removes the direct single-asset update endpoints so sync() (the batch / commit_batch path the plugin uses) is the only write surface:

store, create_asset, set_asset_content, unset_asset_content, set_asset_properties, delete_asset, clear

The 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 matching canister_core::* wrapper functions.
  • crates/canister/assets.did — the "Asset mutations" service block.

Kept

  • Batch upload flow: create_batch, create_chunks, commit_batch, delete_batch.
  • All BatchOperationKind variants and their argument types — these are the sync wire protocol and are still applied atomically inside commit_batch.
  • The State::* state-machine primitives that commit_batch and the tests build on.

Cleanup

store was a single-call create-with-content composite that only backed the removed endpoint (not reused by the batch path), so this also drops the orphaned State::store method and the StoreArg type, and migrates the store-based timestamp tests onto commit_batch (one was redundant with timestamp_updates_on_commit_batch and was removed).

Verification

  • cargo test -p canister-core — 97 passed
  • cargo test -p canister — candid service_equal check passes, confirming assets.did matches the generated interface
  • cargo test -p sync-core — 190 passed
  • cargo test -p e2e — 12 passed (deploy / no-op re-sync / content update / deletion / multi-dir, through the icp CLI against a live replica)

The sync plugin never called these endpoints, so no client-side changes were needed.

🤖 Generated with Claude Code

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>
@lwshang lwshang marked this pull request as ready for review June 5, 2026 16:35
@lwshang lwshang requested a review from a team as a code owner June 5, 2026 16:35
@lwshang lwshang merged commit aad4af8 into main Jun 5, 2026
6 checks passed
@lwshang lwshang deleted the lwshang/state_mutation_sync_only branch June 5, 2026 16:35
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.

1 participant