feat(assets-sync): warn on unmatched config rules; adopt stderr-persistent plugin output#51
Merged
Conversation
Track which AssetConfigRule glob patterns matched at least one asset during scanning and emit warnings for unused ones, so users are alerted to typos in their .ic-assets.json[5] files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The icp-cli sync-plugin runtime now treats plugin stdout as transient progress and stderr as persistent output displayed after the step completes. Update the WIT contract to match (`exec` returns `result<_, string>` — no more `option<string>` payload), have the plugin `eprintln!` its summary, and emit unmatched-config-rule warnings inline from scan.rs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 tasks
There was a problem hiding this comment.
Pull request overview
This PR completes the SDK-2714 deliverable by adding "unmatched config rule" warnings, and migrates the sync plugin to the new icp-cli stdout/stderr contract (where stderr is persisted past the rolling progress view). The WIT export exec no longer returns an optional summary; the plugin now emits its summary and warnings via eprintln!.
Changes:
- Add
AssetSourceDirectoryConfiguration::get_unused_configs()andis_own_for_dir(), capturing the original glob pattern on each rule, and emit per-directory unmatched-rule warnings to stderr fromscan::walk. - Update WIT signature
execfromresult<option<string>, string>toresult<_, string>and have the plugineprintln!the summary instead of returning it. - Update plugin docs/WIT comments to describe the new stdout-transient / stderr-persistent contract, and tick the README checklist item.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| plugin/wit/sync-plugin.wit | Document new stdout/stderr semantics; drop optional summary payload from exec return type. |
| plugin/src/lib.rs | Switch Guest::exec to Result<(), String> and route the summary through eprintln!. |
| plugin/README.md | Mark the "warn on unmatched config rules" checklist item done. |
| assets-sync/src/config.rs | Store rule's original pattern, expose get_unused_configs / is_own_for_dir, drop dead_code allow on origin, add focused unit tests. |
| assets-sync/src/scan.rs | After each owned directory walk, eprintln! warnings from get_unused_configs; replace removed Vec-based test with a smoke test; introduce scan_sources alias. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
adamspofford-dfinity
approved these changes
May 19, 2026
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.
Summary
.ic-assets.json[5]rules whose glob never matched any asset are reported to the user, mirroringic-asset'sget_unused_configs().execreturnsresult<_, string>— theoption<string>summary payload is gone.eprintln!s its end-of-run summary; warnings fromassets-sync(e.g. unmatched-config-rule patterns) areeprintln!ed inline at the point of detection.plugin/wit/sync-plugin.witis now byte-identical to the copy in icp-cli.Release coordination
This PR requires dfinity/icp-cli#556.
CI on this repo installs the latest released
icp-clifor the integration tests, so the expected order is:icp-clirelease that includes it.Until that release is out, CI on this PR is expected to fail at the integration-test stage.
Test plan
cargo check --workspace --all-targetsis cleancargo test -p assets-sync— 71 unit tests pass (3 scan-level warning-Vec tests replaced by focusedget_unused_configstests inconfig.rs)icp-clirelease is out: re-run CI here and confirm integration tests passicp-cli: deploy a project containing an.ic-assets.jsonrule with a typo'd pattern, verify the warning shows up under the canister name after the step completes🤖 Generated with Claude Code