Skip to content

fix(ci): allow the platform-boundary dylint manifest in the crate hook; test the allowlist parity - #1912

Merged
zackees merged 1 commit into
mainfrom
agent/crate-guard-parity
Nov 5, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/crate-guard-parity

Conversation

@zackees

@zackees zackees commented Nov 5, 2026

Copy link
Copy Markdown
Member

What

The monocrate policy ("no new crates") is enforced twice from two files that both only ask humans to keep them in sync:

enforcement file constant
batch, crate-gate.yml ci/check_workspace_crates.py APPROVED_MEMBERS
real time, PreToolUse hook ci/hooks/crate_guard.py APPROVED_CRATE_DIRS

The real-time list had already drifted: dylints/enforce_platform_boundary has a real Cargo.toml and is listed in the root [workspace] exclude, but was not in APPROVED_CRATE_DIRS. The hook therefore denied every Edit/Write of that manifest with a "you are creating a new crate" message — a blocking false positive on the permanent whole-tree-scanner dylint (#1306 / #1315), i.e. on exactly the policy work the dylint protects. This is the same bug class as #794 ("a worktree of this repo is still this repo with the same approved-crates contract"): the allowlist misdescribes the repository.

Change

  • add the missing dylints/enforce_platform_boundary entry;
  • new ci/test_crate_guard_parity.py — asserts repository facts, not list text:
    • APPROVED_MEMBERS == [workspace] members, exactly, both directions;
    • every [workspace] exclude dir that actually contains a Cargo.toml is writable through the hook;
    • the hook authorizes nothing beyond members + exclude + the repo root, so a stale entry cannot pre-authorize a crate added later;
    • no allowlist entry has rotted to a missing directory;
    • three tests drive the real hook process with JSON on stdin: root manifest → allow, excluded dylint manifest → allow, brand-new crates/fbuild-not-approved/Cargo.toml → deny;
  • registered in both entry points: ci/local_suites.py DRIFT_UNITTEST_MODULES + the ci-workflow-drift.yml step (so ci.test_local_suites' parity and no-unwired-module guards hold);
  • ci/README.md bullet points at the parity test; CLAUDE.md's stale "workspace root + 14 member dirs" note corrected (there are 21 members).

No new workflow, no new crate, no threshold change.

RED → GREEN (real output)

Before the allowlist fix, the new module fails on exactly the two drift assertions:

FAIL: test_every_excluded_cargo_project_is_writable_through_the_hook
AssertionError: Items in the first set but not the second:
'dylints/enforce_platform_boundary'
FAIL: test_excluded_dylint_manifest_is_allowed
AssertionError: 'deny' != 'allow'
Ran 7 tests ... FAILED (failures=2)

After the one-line allowlist addition:

Ran 7 tests in 0.260s
OK

Hosted self-test set (ci-workflow-drift.yml step, verbatim module list) went 103 → 110 tests, OK (Ran 110 tests in 1.916s).

Other gates: uv run --no-project python -m ruff check ci/test_crate_guard_parity.py ci/hooks/crate_guard.py ci/local_suites.py → All checks passed!; python ci/check_python_complexity.py → All checks passed! (the new file is tracked, so it is inside the C901/RUF100 ratchet); python ci/check_workspace_crates.py → OK: 21 approved workspace members, no new crates.

bash test cannot run on this host (fbuild-python links -lpython3.14, only libpython 3.13 is installed — pre-existing environmental), and this change touches no Rust.

Refs #1315, #1639, #794.

…st the allowlist parity

`ci/hooks/crate_guard.py` (real-time PreToolUse) and
`ci/check_workspace_crates.py` (batch, crate-gate.yml) each carry a
hand-maintained allowlist, and both docstrings only say "keep the two lists in
sync". Nothing asserted it, so the real-time list had drifted:
`dylints/enforce_platform_boundary` has a real `Cargo.toml` and is listed in the
root `[workspace] exclude`, but was missing from `APPROVED_CRATE_DIRS` -- so the
hook denied every Edit/Write of that manifest with a "you are creating a new
crate" message. That is a blocking false positive on the permanent
whole-tree-scanner dylint (#1306/#1315), i.e. exactly the policy work it exists
to protect; same bug class as #794 ("a worktree of this repo is still this
repo").

* add the missing entry to `APPROVED_CRATE_DIRS`;
* new `ci/test_crate_guard_parity.py` asserts the repository facts instead of
  the list text: `APPROVED_MEMBERS` == `[workspace] members` exactly; every
  `[workspace] exclude` dir that actually contains a `Cargo.toml` is writable
  through the hook; the hook authorizes nothing beyond
  members + exclude + the repo root (a stale entry must not pre-authorize a
  crate somebody adds later); no entry has rotted to a missing directory;
* three of the tests drive the real hook process with JSON on stdin
  (root manifest allow, excluded dylint manifest allow, new crate deny), so the
  decision path is covered, not just the constants;
* register the module in `ci/local_suites.py` and the drift workflow step;
* correct the stale "workspace root + 14 member dirs" note in CLAUDE.md (there
  are 21 members) and point ci/README.md at the parity test.
@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@zackees
zackees added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit e25dd46 Nov 5, 2026
31 checks passed
@zackees
zackees deleted the agent/crate-guard-parity branch November 5, 2026 09:39
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 6, 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