refactor(bin): collapse fm-pr-check-migrate legacy classifier into one function - #2897
Open
harmeet-1337 wants to merge 1 commit into
Open
refactor(bin): collapse fm-pr-check-migrate legacy classifier into one function#2897harmeet-1337 wants to merge 1 commit into
harmeet-1337 wants to merge 1 commit into
Conversation
…e function The legacy-check classification loop appeared four times in fm-pr-check-migrate.sh: current_checks_authenticated and unsafe_checks_absent were byte-identical, migration_needed was the same loop negated, and the main migration loop repeated the preamble a fourth time. Introduce classify_check, which evaluates one check file in the existing order (valid X-mode shim, then registered custom check, then canonical PR poll, else legacy) and prints exactly one of x-shim|custom|poll|legacy. current_checks_ authenticated now scans for any legacy check; unsafe_checks_absent is a one-line alias of it; migration_needed is its negation; and the main loop dispatches on the classifier. Behavior is byte-identical: same outputs, diagnostics, and exit codes. Add a security-suite case asserting that when all four check kinds coexist in one state dir, only the legacy check is quarantined.
Confidence Score: 5/5The PR appears safe to merge with no actionable regressions identified. The centralized classifier preserves the former evaluation order, identifiers, predicates, and return behavior, while the added test covers all four classifications together. Reviews (1): Last reviewed commit: "refactor(bin): collapse fm-pr-check-migr..." | Re-trigger Greptile |
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.
Summary
Implements accepted simplification-audit finding F-S09-2 (P0): the legacy-check classification loop in
bin/fm-pr-check-migrate.shwas written four times.current_checks_authenticatedandunsafe_checks_absentwere byte-identical.migration_neededwas the same loop, negated.Change
Introduce one
classify_check <path>that evaluates a check file in today's exact order — valid X-mode shim, then registered custom check, then canonical PR poll (fm_pr_poll_artifacts_valid), else legacy — and prints exactly one ofx-shim|custom|poll|legacy. Then:current_checks_authenticatedscans for any legacy check via the classifier.unsafe_checks_absentis a one-line alias of it (both names kept because callers use each).migration_neededis its negation.Behavior is byte-identical: same outputs, diagnostics, and exit codes. The classifier runs the three validators in a command-substitution subshell, which is safe because they are read-only predicates whose globals the callers do not consume (the main loop recomputes canonical metadata via
metadata_pr_is_canonical).Tests
Adds one
tests/fm-pr-check-security.test.shcase that seeds all four check kinds in one state dir and asserts only the legacy one is quarantined. Full suite passes (37 ok) andshellcheck0.11.0 is clean.Validation
Validated through the no-mistakes pipeline: intent, rebase, review (0 findings), test (passed), document (no changes), and lint all green. The pipeline injected no commits; this PR contains only the single authored commit. Delivered via fork because the pipeline's push to upstream returned 403 (read-only on upstream); the lint step's local "ShellCheck not found" was an environment gap in the pipeline runner, not a code issue.