Skip to content

feat: load USB VID overlay from boards protobuf#767

Merged
zackees merged 1 commit into
mainfrom
codex/usb-vid-proto-cache
Jun 22, 2026
Merged

feat: load USB VID overlay from boards protobuf#767
zackees merged 1 commit into
mainfrom
codex/usb-vid-proto-cache

Conversation

@zackees

@zackees zackees commented Jun 22, 2026

Copy link
Copy Markdown
Member

Summary

Switches the USB VID/PID online overlay from the old fbuild JSON URL to the new FastLED/boards usb-vids.proto.zstd artifact.

Changes

  • Adds protobuf structs in fbuild-core::usb::data for the boards sidecar schema.
  • Adds install_online_cache_proto_zstd() to inflate the zstd payload in memory, decode protobuf bytes, and retain the flattened map in the existing resolver cache.
  • Updates fbuild port scan lazy fetch to store usb-vids.proto.zstd under the fbuild cache root (~/.fbuild/{dev|prod}/cache/usb/ by default, or FBUILD_CACHE_DIR/usb/).
  • Keeps the legacy JSON loader/constants for compatibility.
  • Adds unit coverage for protobuf/zstd decode, bad-cache fallback, cache-root routing, and atomic download writes.

Depends on FastLED/boards#24, merged and dispatched via the boards site workflow.

Validation

  • python -m pytest tests/test_build_usb_ids.py in FastLED/boards
  • uv run --no-project --with zstandard python -c "... build(...) ..." in FastLED/boards
  • soldr cargo test -p fbuild-core usb::data:: -- --nocapture
  • soldr cargo test -p fbuild-cli port_scan -- --nocapture

Summary by CodeRabbit

  • Improvements

    • Upgraded USB device caching mechanism for enhanced reliability, performance optimization, and atomic write safety.
  • Tests

    • Extended test coverage for device data caching, loading operations, and environmental isolation scenarios.
  • Chores

    • Updated core internal dependencies and refactored data format handling.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR migrates the tier-2 USB VID online overlay from a JSON-based cache (usb-vid.json) to a protobuf+zstd cache (usb-vids.proto.zstd). fbuild-core gains a prost dependency, new protobuf message structs, a new URL constant, and install_online_cache_proto_zstd. fbuild-cli's port_scan is updated to fetch and install from the new format with an updated atomic temp suffix.

Changes

Proto+zstd USB overlay migration

Layer / File(s) Summary
Proto message types, URL constant, and loader in fbuild-core
crates/fbuild-core/Cargo.toml, crates/fbuild-core/src/usb/data.rs, crates/fbuild-core/src/usb/mod.rs
Adds prost workspace dependency; defines UsbVidDatabase, Vendor, Product protobuf structs via prost::Message; adds USB_VIDS_PROTO_ZSTD_URL constant; implements install_online_cache_proto_zstd (zstd decompress → prost decode → flatten into ONLINE_MAP); re-exports both new symbols; adds round-trip and bad-input unit tests.
CLI port_scan migration to proto-zstd fetch and atomic write
crates/fbuild-cli/src/cli/port_scan.rs
Updates populate_online_overlay and overlay_cache_path to target usb-vids.proto.zstd; rewires HTTP download to fetch_overlay_to_inner_with_client with USB_VIDS_PROTO_ZSTD_URL; changes atomic temp suffix to proto.zstd.tmp; adds EnvVarGuard/ENV_LOCK test helpers and tests for cache path selection and atomic write correctness.

Possibly related PRs

  • FastLED/fbuild#742: Introduced the original fbuild port scan implementation using the legacy usb-vid.json overlay (USB_VID_JSON_URL + install_online_cache) — the exact code path that this PR replaces with the proto-zstd flow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 Hop hop, the JSON days are done,
Protobuf and zstd have won!
We flatten the vendors, compress them tight,
And write with a .tmp — then all is right.
The overlay installs with nary a care,
A fluffy new cache beyond compare! 🗜️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: load USB VID overlay from boards protobuf' clearly and concisely describes the main change: switching USB VID overlay loading from JSON to protobuf format from the boards artifact.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/usb-vid-proto-cache

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zackees zackees merged commit 2e9c503 into main Jun 22, 2026
84 of 91 checks passed
@zackees zackees deleted the codex/usb-vid-proto-cache branch June 22, 2026 22:50
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant