Skip to content

feat(usb): tier-1 fbuild-core::usb resolver + online-data branch wiring#712

Merged
zackees merged 1 commit into
mainfrom
feat/usb-ids-resolver-and-online-data
Jun 20, 2026
Merged

feat(usb): tier-1 fbuild-core::usb resolver + online-data branch wiring#712
zackees merged 1 commit into
mainfrom
feat/usb-ids-resolver-and-online-data

Conversation

@zackees

@zackees zackees commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • New fbuild_core::usb module: three-tier USB VID:PID → vendor/product name resolver.
    • Tier 1: bundled usb-ids crate (~20,480 entries, phf perfect hash, zero IO).
    • Tier 2: optional { "VVVV:PPPP": {vendor, product} } JSON overlay loaded from a daemon-managed cache file; tracks the new online-data orphan branch in this repo.
    • Tier 3: synthetic "Unknown vendor 0xVVVV" fallback — resolve() never returns None.
    • pretty(vid, pid) is the canonical "vendor product (VVVV:PPPP)" display string.
  • Wired into the daemon's device enumeration so /api/devices/list, /api/devices/{port}/status, the CLI's device list / device status, and the deploy port selection log all carry the resolved name everywhere a port is mentioned.
  • crates/fbuild-core/examples/dump_usb_ids.rs (an example, not a new crate — monocrate policy preserved) dumps the bundled DB as JSON. Used by the nightly workflow as the tier-1 input source.
  • .github/workflows/nightly-usb-ids.yml refreshes the orphan online-data branch daily + on-demand (workflow_dispatch). Fault-tolerant against any single source failure; refuses to overwrite a healthy committed dataset with too-small output; prunes history to the most recent 200 commits.
  • New ci/hooks/crate_guard.py PreToolUse hook blocks Edit/Write of any Cargo.toml outside the approved set — real-time monocrate enforcement, complementing the batch CI check.
  • The per-edit lint hook is removed from PostToolUse (it was triggering a full cargo clippy --all-targets on every save). The Stop hook still gates everything on session end.
  • Hook commands in .claude/settings.json are now wedge-proof: they prefer \$CLAUDE_PROJECT_DIR (the harness anchor that survives worktree shifts) and [ -f <script> ] so an orphan-branch worktree without ci/hooks/ no longer freezes the shell.
  • Design + URL contract + manifest schema in docs/online-data.md and tasks/todo.md.

Companion artifacts

Test plan

  • `soldr cargo check --workspace` clean.
  • `soldr cargo test -p fbuild-core usb` — 9/9 pass (FTDI, CP210x, CH340, unknown fallback, overlay file round-trip, malformed input).
  • `soldr cargo test -p fbuild-daemon --lib` — 178/178 pass (DeviceState now carries vendor/product; existing tests updated).
  • Merger script end-to-end test locally over all three sources → 20,536 unioned entries, 4 trivial conflicts.
  • Both URLs serve HTTP 200 with valid JSON.
  • Manual `workflow_dispatch` of `Nightly USB IDs refresh` after merge — verify it self-bootstraps the worktree against the now-seeded branch and produces a no-op (or trivially-different) commit.

🤖 Generated with Claude Code

- Add `usb-ids` crate as tier-1 bundled VID:PID -> {vendor, product}
  resolver in `fbuild_core::usb`. Tier-2 reads an optional JSON overlay
  installed by the daemon at startup. Tier-3 returns a synthetic
  `"Unknown vendor 0xVVVV"` placeholder so callers never see None.
- Wire the resolver into the daemon's device enumeration so device
  descriptions, `/api/devices/list`, and `/api/devices/{port}/status`
  carry pretty vendor/product names. CLI `device list` / `device status`
  print `"vendor product (VVVV:PPPP)"`; deploy port selection logs the
  same canonical string at connect time.
- Add `.github/workflows/nightly-usb-ids.yml` that refreshes the orphan
  `online-data` branch daily. The workflow YAML lives on `main` (required
  for `schedule` / `workflow_dispatch`); the merger script + data files
  live on `online-data` only. Fault-tolerant against any single source
  failure; refuses to write a too-small dataset; prunes history to 200.
- Add `crates/fbuild-core/examples/dump_usb_ids.rs` as the tier-1 dump
  source for the nightly workflow (kept as an example so no new crate
  is introduced — see `ci/hooks/crate_guard.py`).
- New `ci/hooks/crate_guard.py` PreToolUse hook blocks Edit/Write of any
  `Cargo.toml` outside the approved set, enforcing the monocrate policy
  in real time. Remove the per-edit lint hook from PostToolUse — it was
  triggering a full `clippy --all-targets` recompile on every save; the
  Stop hook still gates everything on session end.
- Document the full design in `docs/online-data.md` and `tasks/todo.md`.

Goal acceptance:
  fbuild-core: 9 new usb tests pass
  fbuild-daemon: 178/178 tests pass
  workspace `cargo check` clean
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@zackees, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 27 minutes and 46 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c56c3dcc-57b8-4116-b567-fdbd2f1964cf

📥 Commits

Reviewing files that changed from the base of the PR and between b22a016 and 1e6848d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (23)
  • .claude/settings.json
  • .github/workflows/nightly-usb-ids.yml
  • .gitignore
  • CLAUDE.md
  • Cargo.toml
  • ci/hooks/crate_guard.py
  • crates/fbuild-cli/src/cli/device.rs
  • crates/fbuild-cli/src/daemon_client/README.md
  • crates/fbuild-cli/src/daemon_client/types.rs
  • crates/fbuild-core/Cargo.toml
  • crates/fbuild-core/examples/README.md
  • crates/fbuild-core/examples/dump_usb_ids.rs
  • crates/fbuild-core/src/lib.rs
  • crates/fbuild-core/src/usb/README.md
  • crates/fbuild-core/src/usb/data.rs
  • crates/fbuild-core/src/usb/mod.rs
  • crates/fbuild-core/src/usb/resolver.rs
  • crates/fbuild-daemon/src/device_manager.rs
  • crates/fbuild-daemon/src/handlers/devices.rs
  • crates/fbuild-daemon/src/handlers/operations/deploy_port.rs
  • crates/fbuild-daemon/src/models.rs
  • docs/online-data.md
  • tasks/todo.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/usb-ids-resolver-and-online-data

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 and usage tips.

@zackees zackees merged commit 7bacab4 into main Jun 20, 2026
85 of 91 checks passed
zackees added a commit that referenced this pull request Jun 20, 2026
…llow-up) (#713)

Two changes to .claude/settings.json:

1. Removed the project-local `tool_guard.py` PreToolUse hook — the user
   confirmed they install soldr/uv guards globally, so the duplicate
   fires twice without value. `forbidden_commands.py` (pyocd/esptool
   policy) stays as the project-specific Bash gate.

2. Every hook command is now wedge-proof:
   - Prefer `${CLAUDE_PROJECT_DIR}` (the harness anchor that survives
     worktree shifts) and fall back to `git rev-parse --show-toplevel`.
   - Wrap the actual `uv run` invocation in `[ -f <script> ] && ... || exit 0`
     so a worktree without `ci/hooks/` (e.g. the `online-data` orphan
     branch's worktree, or a freshly-orphaned branch mid-setup) cannot
     fail the hook startup and freeze the shell.

This was the catch-22 that wedged the original `online-data` orphan
setup in PR #712: `git rm -rf .` removed `ci/hooks/` from the worktree;
the PreToolUse hook command then resolved `git rev-parse --show-toplevel`
to that worktree, tried `uv run ci/hooks/tool_guard.py`, and python
errored with "no such file" — blocking every subsequent Bash/Edit/Write
call. The guard above turns the "script not found" case into a no-op
instead of a block.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 21, 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