Skip to content

tooling: Ship a repo-level agent hook that enforces soldr over bare cargo/rustup #691

Closed

Description

@zackees

Part of the contributor-unblocking meta (#699).

Problem

The build and cache tooling is Soldr, and it cannot be mixed with bare Rust tools. Bare cargo, rustup, rustc and friends skip Soldr's zccache-backed cache and can disagree with the toolchain Soldr pins.

AGENTS.md states the rule ("Use soldr cargo ..., never bare cargo"), but nothing in this repo enforces it. Maintainer sessions are protected only because clud enforces it from the maintainer's own clud settings. External contributors and their agents (Claude Code or Codex without clud) get no guard at all. A contributor's fork CI hit soldr: command not found and then Soldr permission errors, the setup this rule exists to prevent (see #370).

Prior art: we had this before

The guard moved out of the repos and into clud and the global setup, so only people running our tooling get it.

Change

  1. Ship a repo-level hook that doesn't depend on clud.
    • Port soldr's tool_guard.py, with its tests, into this repo, for example as ci/hooks/tool_guard.py.
    • Make it a uv run --script file (repo rule).
    • Drop or keep the python/pip arm to match AGENTS.md (this repo also requires uv).
  2. Wire it in the repo's Claude Code project settings as a PreToolUse hook on Bash, following fbuild's wedge-proof pattern:
    • anchor on $CLAUDE_PROJECT_DIR, and guard with [ -f <script> ]
    • mention any Codex equivalent in AGENTS.md
  3. Don't double-fire for clud users.
    • Either the hook exits early when it detects a clud session, or we accept both firing; they give the same answer.
    • Also ship .clud/settings.json with "rust": { "use_soldr": true }, so clud users get the shims too.
  4. Match on the parsed command, not substrings.
    • The current clud guard blocks text that merely mentions the tool names: it rejected a gh issue create whose body said "rustup" while this issue was being filed.
    • soldr's tool_guard.py already parses with shlex; keep that and add regression tests for heredoc and quoted-body cases (process: Friction points in the dev cycle and how to remove them #634 item 9).
  5. CI side. A ./lint check that no script under ci/ or rust/tools/ invokes bare Rust tools, so the rule also holds for non-agent contributors.

Acceptance

  • In a fresh clone with plain Claude Code (no clud), cargo test is denied with a soldr cargo test hint, and soldr cargo test runs.
  • FOO=1 cargo build, bash -c "cargo build" and env cargo build are denied.
  • gh issue create --body "use soldr instead of bare rustup", echo cargo:warning and heredoc bodies are allowed.
  • With clud, behaviour is unchanged and there are no confusing duplicate denials.
  • ./lint runs the hook's tests.

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