Skip to content

tooling: enforce soldr cargo for Rust/fbuild builds via FastLED's PreToolUse hook #2871

Closed

Description

@zackees

Background

fbuild ships its own tool_guard.py PreToolUse hook that forces all
cargo / rustc / rustfmt calls through soldr cargo … (huge
speed-up — soldr seeds zccache + a cached target-tree, turning
multi-minute cold builds into seconds-long warm hits). The hook is
documented at fbuild#429.

But Claude Code loads hooks from the session project root, not
from whatever directory commands execute in. When an agent runs in
the FastLED workspace and cds into a fbuild dev checkout (e.g.
under clud-pr against a fbuild issue, or working on fbuild from a
FastLED session), the fbuild hook is never consulted — the agent
just runs bare cargo build and burns minutes that should have been
seconds.

Concrete impact: the recent fbuild PR #424 / #427 stack iterated
through ~6-7 cold cargo builds (~3 min each) before someone caught
it and switched to manual soldr cargo. That's ~15 min of wall time
on a single PR loop. Multiply across the agent-driven development
workflow we run and it's measurable.

What this issue asks for

Extend FastLED's .claude/settings.json PreToolUse hook so that any
cargo / rustc / rustfmt / clippy-driver invocation — no
matter what directory the command runs in
— is rewritten to
soldr <tool> …. Specifically:

  1. Add a Rust-tool gate to the existing
    ci/hooks/tool_guard.py-style PreToolUse chain (or a new
    ci/hooks/rust_tool_guard.py).
  2. Trigger condition: the first whitespace token of the command is
    cargo / rustc / rustfmt / clippy-driver AND the cwd
    contains a Cargo.toml (walking up to root). Avoids false
    positives for shell scripts named cargo.
  3. Block bare invocations with an error message that includes the
    correct fix (soldr cargo build …).
  4. Document the rationale + the fbuild#429 cross-link in the hook
    source so the next maintainer can see why.

Why FastLED owns this

  • fbuild is the canonical Rust workload that gets driven from this
    repo (every agent that opens a fbuild PR from a FastLED workspace).
  • The fbuild-side hook is the right enforcement for sessions whose
    project root is fbuild, but it can't catch cross-project
    sessions. That's a Claude Code feature gap (fbuild#429 has the
    upstream-request discussion).
  • The cheapest defensive measure that closes the gap today is to
    add the gate at FastLED's session-root, where it does fire.

Out of scope

  • The deeper Claude Code feature request for per-directory hook
    discovery (tracked at fbuild#429).
  • Any change to soldr itself; it works fine, it just isn't being
    invoked.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions