Repository navigation
ci: fail closed when the .fbuild allowlist baseline ref cannot be resolved - #1919
Merged
Merged
Conversation
…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.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ci/check_fbuild_path_baseline.pyis the ratchet that keepsdylints/ban_raw_fbuild_path/src/allowlist.txtshrink-only (#1349). Two argumentpaths silently disabled it — both verified against
origin/mainat99c0e861:Both come from one seam:
read_at_ref()treated any non-zerogit showas"the file is absent at that ref", and an empty ref is not empty to git —
git show :<path>reads the index.Fix
--baseto a commit first (git rev-parse --verify --quiet <ref>^{commit}). Unresolvable → exit 1 with the offending ref named; an emptyor whitespace ref is rejected outright, so the index can never be mistaken for
a base.
git cat-file -e <commit>:<path>on the resolvedcommit, 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.
main()intoresolve/read_at_commit/report/parse_args.Tests
New
ci/test_check_fbuild_path_baseline.py, 15 tests, driving the realgitsubprocess path against a throwaway repository (no mocking of git):
HEAD);origin/mian) and empty/whitespace refs are hard errors,including the exact staged-addition case that used to pass;
--base HEAD).RED proven by two in-place mutations of the production script, then
restored: bypassing
resolve()(old fail-open semantics) → 2 failures, exactlythe 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 isaccounted for";
check_python_complexity→ "All checks passed!"; ruff on alltouched files → clean;
ruff format --check→ 2 files already formatted.Ratchet
[scripts.check_fbuild_path_baseline] tests = [...], entry deleted fromuntested,MAX_UNTESTED7 → 6, module added toDRIFT_UNITTEST_MODULESandthe drift workflow command in the same position (
test_local_suitesverifiesboth). Six untested gates remain.