Skip to content

ci: fail closed when the .fbuild allowlist baseline ref cannot be resolved - #1919

Merged
zackees merged 1 commit into
mainfrom
agent/fbuild-path-baseline-tests
Nov 5, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/fbuild-path-baseline-tests

Conversation

@zackees

@zackees zackees commented Nov 5, 2026

Copy link
Copy Markdown
Member

Problem

ci/check_fbuild_path_baseline.py is the ratchet that keeps
dylints/ban_raw_fbuild_path/src/allowlist.txt shrink-only (#1349). Two argument
paths silently disabled it — both verified against origin/main at 99c0e861:

$ python ci/check_fbuild_path_baseline.py --base origin/mian
dylints/.../allowlist.txt does not exist at origin/mian — nothing to ratchet against yet.
rc=0                                    # typos/fetches unenforced

$ git add dylints/.../allowlist.txt     # index == working tree (CI checkout)
$ python ci/check_fbuild_path_baseline.py --base ''
dylints/.../allowlist.txt: 4 entries, 0 removed since , 0 added.
rc=0                                    # staged addition compared to itself

Both come from one seam: read_at_ref() treated any non-zero git show as
"the file is absent at that ref", and an empty ref is not empty to git — git show :<path> reads the index.

Fix

  • Resolve --base to a commit first (git rev-parse --verify --quiet <ref>^{commit}). Unresolvable → exit 1 with the offending ref named; an empty
    or whitespace ref is rejected outright, so the index can never be mistaken for
    a base.
  • Test existence with git cat-file -e <commit>:<path> on the resolved
    commit
    , then read it. "nothing to ratchet against yet" (the
    introducing-PR case, documented in the module header) is now reachable only
    when a commit that exists genuinely lacks the file.
  • Split main() into resolve / read_at_commit / report / parse_args.

Tests

New ci/test_check_fbuild_path_baseline.py, 15 tests, driving the real git
subprocess path against a throwaway repository (no mocking of git):

  • additions fail and name the path; removals and comment-only edits pass;
  • an unstaged addition is seen (the gate reads the file, not HEAD);
  • unresolvable ref (origin/mian) and empty/whitespace refs are hard errors,
    including the exact staged-addition case that used to pass;
  • a base commit without the allowlist still passes as an introducing change;
  • the real repository satisfies its own ratchet (--base HEAD).

RED proven by two in-place mutations of the production script, then
restored: bypassing resolve() (old fail-open semantics) → 2 failures, exactly
the two fail-open tests; comparing committed content instead of the working tree
→ 3 failures (added, removed, unstaged).

GREEN: Ran 15 tests ... OK; hosted self-test set 171 → 186 OK;
gate_script_coverage --budget 6 → "Every workflow-invoked gate script is
accounted for"; check_python_complexity → "All checks passed!"; ruff on all
touched files → clean; ruff format --check → 2 files already formatted.

Ratchet

[scripts.check_fbuild_path_baseline] tests = [...], entry deleted from
untested, MAX_UNTESTED 7 → 6, module added to DRIFT_UNITTEST_MODULES and
the drift workflow command in the same position (test_local_suites verifies
both). Six untested gates remain.

…olved

`ci/check_fbuild_path_baseline.py` enforces the shrink-only baseline of
`dylints/ban_raw_fbuild_path/src/allowlist.txt`. Two argument paths
silently switched the ratchet off:

* an unresolvable `--base` (a typo, an unfetched ref, a renamed default
  branch) made `git show` fail, which the script read as "the allowlist
  does not exist at that ref" -- the introducing-PR case -- and exited 0;
* `--base ""` named git's *index* (`git show :<path>`), so in a clean
  checkout the allowlist was compared against a copy of itself and an
  added entry compared equal. `git add` made it pass even outside CI.

Resolve the base ref to a commit first (`rev-parse --verify`), reject an
empty ref outright, and probe existence with `cat-file -e` on the
resolved commit -- so "nothing to ratchet against yet" is only reachable
when the file is genuinely absent from a commit that exists.

New `ci/test_check_fbuild_path_baseline.py` (15 tests) drives the real
`git` subprocess path against a throwaway repository: additions fail,
removals/comment-only edits pass, unstaged additions are seen, and both
fail-open paths are hard errors. Registry entry added, `untested` shrunk
7 -> 6, MAX_UNTESTED 7 -> 6, module wired into both entry points.
@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 removed this pull request from the merge queue due to a manual request Nov 5, 2026
@zackees
zackees added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit 2e1c754 Nov 5, 2026
31 checks passed
@zackees
zackees deleted the agent/fbuild-path-baseline-tests branch November 5, 2026 17:20
@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