Repository navigation
ci(rust): boar_fast_filter — testable pure-Rust core, 19 unit tests, clippy 1.95-safe CI gate - #263
Closed
FabioLeitao wants to merge 2 commits into
Closed
FabioLeitao wants to merge 2 commits into
FabioLeitao wants to merge 2 commits into
Conversation
…filter Refactor (no behaviour change for the Python binding): - pub fn try_new() -> Result<Self, regex::Error> — pure-Rust constructor that returns the underlying regex error directly, so cargo test can drive it without a Python interpreter. - pub fn filter_batch_pure(&self, batch: &[String]) -> Vec<usize> — borrowed-slice testable core. The PyO3-exposed filter_batch now delegates here so the Python and Rust paths share one implementation. - pub fn check_luhn(...) — exposed for direct unit testing. 19 #[cfg(test)] unit tests: - Luhn (8): valid Visa / MasterCard / Amex test PANs, invalid check digit, too-short, too-long, separator tolerance (- and space), empty / non-numeric. - Constructor (1): try_new compiles all baseline regexes. - Detection (4): CPF with punctuation, CPF without punctuation, email, valid-Luhn credit card. - Negative paths (3): clean content, card-shaped digits failing Luhn, empty batch. - Behaviour (3): each line reported at most once, output preserves input order, mixed-signal batch returns indexes in order. Clippy 1.95 portability: keep the canonical % 2 / % 10 Luhn arithmetic and suppress clippy::manual_is_multiple_of behind #[allow(unknown_lints, ...)]. The std method u32::is_multiple_of only stabilised in Rust 1.87, so following clippy's suggestion would break the homelab toolchain pinned at 1.83. unknown_lints is paired so older clippys (which haven't seen the new lint yet) still accept the attribute. Local verification on both stable 1.95 (CI runner) and 1.83 (homelab): - cargo fmt --all -- --check clean - cargo check --all-targets --locked clean - cargo test --all-targets --locked 19 passed - cargo clippy --all-targets --locked -- -D warnings clean Co-authored-by: Fabio Tavares Leitão <[email protected]>
New workflow .github/workflows/rust-ci.yml: - Triggers on push and PR to main / master, scoped via paths to rust/** and the workflow file itself, so unrelated Python or docs PRs do not spin Rust builds. - working-directory pinned to rust/boar_fast_filter so steps stay terse. - actions/checkout and actions/setup-python reuse the SHAs already vetted in ci.yml. Toolchain installed via rustup (no new third-party Action SHA to track). - Steps in order: cargo fmt --all -- --check, cargo check --all-targets --locked, cargo test --all-targets --locked, cargo clippy --all-targets --locked -- -D warnings — promotes any clippy lint to a CI failure. - permissions: contents: read only. Wire the new workflow into Slack failure notify: - slack-ci-failure-notify.yml now subscribes to CI, Rust CI, Semgrep, SBOM (was: CI, Semgrep, SBOM). When the Rust gate fails, the operator gets a Slack ping on the same SLACK_WEBHOOK_URL secret as every other CI failure (skipped cleanly when the secret is unset). Tests: - test_github_workflows.py: new test_rust_ci_workflow_present_and_valid asserts name, contents: read permission, path-scoped triggers, working directory, and that all four cargo steps with the exact -D warnings predicate are present. Regression guard so removing or downgrading the Rust gate is caught at PR time. - Updated test_slack_ci_failure_notify_workflow_present_and_valid to expect the new workflow list. - 12 of 12 workflow guard tests pass. Co-authored-by: Fabio Tavares Leitão <[email protected]>
FabioLeitao
force-pushed
the
main
branch
2 times, most recently
from
May 3, 2026 17:52
ae0da8d to
b5c995c
Compare
FabioLeitao
force-pushed
the
cursor/anchieta-rust-ci-c9ab
branch
from
May 3, 2026 17:52
f896e49 to
20dc1a8
Compare
FabioLeitao
added a commit
that referenced
this pull request
May 3, 2026
… merges Maintainer Slack message in thread 1777319823.055829 (channel C0AN7HY3NP9) asks to halt new Rust PRs based on origin/main and rebase/wait for the auditoria-ia branch (claimed 27 commits ahead; origin currently shows 2, implying ~25 unpushed local commits). This commit is doc-only, additive, zero blast radius: - New file docs/ops/sre_audits/STOP_DIRECTIVE_AUDITORIA_IA_REBASE_2026-04-27.md records the directive verbatim, the reproducible gh/git trace that established ground truth, the open-PR surface this STOP applies to (#255, #256, #258, #260, #263), and the maintainer-side resolution recommendation. Pattern matches neighbouring dated SRE audit ledgers. - Index docs/ops/sre_audits/README.md gets one new row pointing at the STOP ledger so the next Slack-triggered SRE agent reads it before trying to base another Rust PR on the old main. No Rust crate, workflow, connector, DB, or customer payload was touched. Defensive Scanning Manifesto and The Art of the Fallback respected: audit-only, diagnostic-on-fall, paper trail before silence. Co-authored-by: Fabio Tavares Leitão <[email protected]>
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
Lands the missing CI/CD coverage and unit tests for the repository's only Rust component —
rust/boar_fast_filter/(PyO3 high-speed PII pre-filter for Data Boar Pro+). Supersedes the failing PRs in the #255–#260 series by combining the cleanest scope from each, fixing theclippy 1.95 manual_is_multiple_ofself-block, and proving the gate green on both the homelab toolchain (Rust 1.83) and the CI runner toolchain (stable Rust 1.95).What changes
1. Pure-Rust testable core in
rust/boar_fast_filter/src/lib.rsThe previous module returned
PyResult<Self>fromnewand consumedVec<String>by value, both awkward to drive fromcargo test. Refactor with zero behaviour change for the Python binding:pub fn try_new() -> Result<Self, regex::Error>— pure-Rust constructor.pub fn filter_batch_pure(&self, batch: &[String]) -> Vec<usize>— borrowed-slice testable core. The PyO3-exposedfilter_batchdelegates here so the Python and Rust paths share one implementation.pub fn check_luhn(...)— exposed for direct unit testing.2. 19
#[cfg(test)]unit tests-and space), empty / non-numerictry_newcompiles all baseline regexes3.
.github/workflows/rust-ci.ymlmain/master, scoped viapaths:torust/**and the workflow file itself.working-directory: rust/boar_fast_filter.actions/checkoutandactions/setup-pythonSHAs already vetted inci.yml(PyO3 needs a Python interpreter at link time).rustupdirectly to avoid adding a new third-party Action SHA to track.cargo fmt --all -- --check→cargo check --all-targets --locked→cargo test --all-targets --locked→cargo clippy --all-targets --locked -- -D warnings. Any clippy lint promotes to a CI failure.permissions: contents: readonly.4. Slack failure notify
slack-ci-failure-notify.ymlnow subscribes toCI, Rust CI, Semgrep, SBOM(wasCI, Semgrep, SBOM). When the Rust gate fails, the operator gets a Slack ping on the sameSLACK_WEBHOOK_URLsecret as every other CI failure. Skipped cleanly when the secret is unset (pertests/test_github_workflows.py::test_slack_post_workflows_guard_webhook_secret).5. Workflow guard test
New
test_rust_ci_workflow_present_and_validintests/test_github_workflows.pyassertsname,contents: read, path-scoped triggers, working directory, and that all four cargo steps (with the exact-D warningspredicate) are present. Regression guard so removing or downgrading the Rust gate is caught at PR time.The clippy 1.95 fix (why we keep
% 10)clippy 1.95 added
manual_is_multiple_of, which suggests rewritingsum % 10 == 0assum.is_multiple_of(10). With-D warnings, that's a hard error. Butu32::is_multiple_ofonly stabilised in Rust 1.87, and the homelab toolchain is pinned at 1.83. Following clippy's auto-suggestion would break the homelab build witherror[E0658]: use of unstable library feature 'unsigned_is_multiple_of'.The chosen fix keeps the canonical Luhn arithmetic readable and tells clippy this is intentional:
unknown_lintsis paired with the lint name so older clippys (which haven't seenmanual_is_multiple_ofyet) still accept the attribute.Local verification (both toolchains)
From
rust/boar_fast_filter/:Repository hygiene:
Defensive architecture review
boar_fast_filteris a pure-CPU regex+Luhn prefilter; it does not open connections, hold locks, or change any DB-bound code path.main: zero on the hot path.filter_batchstill takesVec<String>and returnsPyResult<Vec<usize>>; it just delegates tofilter_batch_pure. Every existing caller in Python keeps working.#[allow]becomes a one-line removal — theis_multiple_ofmigration is a clean follow-up.Commits (split per commit-grouping policy)
test(rust): expose pure-Rust API and add 19 unit tests for boar_fast_filterci(rust): add Rust CI workflow with fmt, check, test, clippy -D warningsRelationship to the open PR series
cursor/fix-rust-ci-coverage-9061) — same intent, but the Rust CI job fails on clippy 1.95. This PR carries the equivalent lib.rs refactor + 19 tests, plus the#[allow(clippy::manual_is_multiple_of)]fix already validated on PR fix(rust-ci): clippy 1.95 manual_is_multiple_of blocks PR #255 — keep classic Luhn% 10#258.% 10#258 / ci(rust): supersede #255 — clippy 1.95-safe Luhn predicate in boar_fast_filter #256 — fix-only PRs that supersede the clippy block. This PR rolls their fix in alongside the workflow + Slack wiring so the gate ships green from the first commit on this branch.The maintainer can pick this branch and close the others as superseded, or cherry-pick the
% 10#[allow]block into whichever branch they prefer to land.Slack Thread