Skip to content

ci(rust): GitHub Actions for boar_fast_filter + unit tests - #255

Closed
FabioLeitao wants to merge 4 commits into
mainfrom
fix/rust-ci-coverage
Closed

FabioLeitao wants to merge 4 commits into
mainfrom
fix/rust-ci-coverage

Conversation

@FabioLeitao

Copy link
Copy Markdown
Collaborator

Description

This repository does not contain a crate named data-board-report; the Rust extension under rust/boar_fast_filter is the scan/report prefilter (PyO3). This PR adds CI for that crate and a baseline Rust unit test suite for its core logic (Luhn validation, batch suspect indexing).

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / maintenance
  • Other (describe):

Checklist

  • Targeted tests pass locally (uv run pytest tests/test_github_workflows.py; cargo test in rust/boar_fast_filter).
  • Pre-commit passes on touched files (uv run pre-commit run --files …).
  • Docs updated: docs/ops/OPERATOR_NOTIFICATION_CHANNELS*.md (Slack notify now includes Rust CI).
  • Security-sensitive changes: considered impact and SECURITY.md (e.g. dependency changes, config, auth).

What changed

  • .github/workflows/rust-ci.yml: on push/PR to main/master, runs cargo check, cargo test, and cargo clippy --all-targets --all-features -- -D warnings in rust/boar_fast_filter (clippy warnings fail the job).
  • rust/boar_fast_filter: extracted pure logic to src/filter_logic.rs; FastFilter delegates to CompiledPatterns::suspect_indices; added unit tests for Luhn and batch behaviour (aligned with tests/test_rust_bridge.py smoke data).
  • Slack CI failure notify: workflow_run.workflows extended with Rust CI so failures surface in ops channel like other CI workflows.
  • tests/test_github_workflows.py: assert Slack workflow list; validate rust-ci.yml structure and pinned Action SHAs.

Related issues

(none linked)

Slack Thread

Open in Web Open in Cursor 

cursoragent and others added 3 commits April 27, 2026 19:28
- Add GitHub Actions rust-ci.yml: cargo check, test, clippy (-D warnings) on main/master
- Extract prefilter logic to filter_logic.rs with Luhn + batch suspect tests
- Include Rust CI in Slack workflow_run notify list; sync ops docs and workflow guards

Co-authored-by: Fabio Tavares Leitão <[email protected]>
Adds 9 additional unit tests on top of the initial 7 already in
filter_logic.rs (running total: 16). Each test pins a contract that
would otherwise only surface after a refactor lands in production:

- new_compiles_all_patterns: constructor never panics for the shipped
  regex set (no-panic guard before the PyO3 bridge loads).
- suspect_indices_empty_batch_is_empty: empty input boundary.
- suspect_indices_is_idempotent: same input produces same output across
  calls — pins absence of hidden state in CompiledPatterns.
- suspect_indices_reports_each_row_once: a row matching multiple
  patterns (CPF + email) must be reported once, locking the regex-tier
  contract from THE_ART_OF_THE_FALLBACK.md.
- suspect_indices_dashed_pan_layout: dashed credit-card layout (Luhn
  must accept regardless of separators).
- suspect_indices_email_with_plus_tag_and_subdomain: plus-tag local
  part + multi-level subdomain (no backtracking pathologies).
- suspect_indices_preserves_input_order: output indices appear in
  increasing order so callers can pair without re-sorting.
- check_luhn_rejects_letters_only: defensive — non-digit input
  degrades to an empty digit vec and returns false, no panic.
- suspect_indices_does_not_panic_on_unicode: customer payloads carry
  non-ASCII; matchers must walk the string without panicking on
  multi-byte boundaries.

Co-authored-by: Fabio Tavares Leitão <[email protected]>
Layered improvements on top of the initial Rust CI workflow:

- paths: filter limits triggers to rust/** and the workflow file
  itself, so unrelated PRs do not burn runner minutes on cargo.
- workflow_dispatch added so the workflow can be re-run from the
  Actions UI without changing files (useful when investigating a
  flake or recent dependency).
- concurrency group cancels superseded runs on feature branches
  while keeping every run on main for audit history.
- env CARGO_TERM_COLOR / RUST_BACKTRACE for readable logs.
- actions/cache pinned to a full SHA caches $CARGO_HOME and the
  crate target dir keyed on Cargo.lock; subsequent runs only
  recompile the crate, not the pyo3 + regex dependency graph.
- rustfmt component pulled in alongside clippy and a trailing
  cargo fmt --check step gives a cheap formatting parity guard
  against the repo style.

The pinned-SHA bar from tests/test_rust_ci_yml_pins_actions_to_shas
is preserved (actions/cache and dtolnay/rust-toolchain both use full
40-char commit SHAs).

Co-authored-by: Fabio Tavares Leitão <[email protected]>
Rust 1.95's clippy added the manual_is_multiple_of lint and it now
fires on the Luhn final-step '% 10 == 0' inside check_luhn(). The CI
job (cargo clippy --all-targets --all-features -- -D warnings) failed
on PR #255 because of this lint, even though the algorithm is correct.

We keep the explicit '% 10 == 0' form (clearer for any reader who
knows Luhn from a textbook) and suppress the lint locally with
#[allow(unknown_lints, clippy::manual_is_multiple_of)] so:

- toolchains < 1.87 still build (the suggested u32::is_multiple_of
  was only stabilized in 1.87, and PyO3 0.23 supports stable >= 1.63);
- toolchains >= 1.95 (current GitHub stable) pass clippy without
  warnings;
- the suppression is scoped to one function, so any future manual
  divisibility check elsewhere in the crate is still flagged.

Co-authored-by: Fabio Tavares Leitão <[email protected]>
cursor Bot pushed a commit that referenced this pull request Apr 27, 2026
Rust 1.95's clippy added the manual_is_multiple_of lint and it now
fires on the Luhn final-step '% 10 == 0' inside check_luhn(). The CI
job (cargo clippy --all-targets --all-features -- -D warnings) failed
on PR #255 because of this lint, even though the algorithm is correct.

We keep the explicit '% 10 == 0' form (clearer for any reader who
knows Luhn from a textbook) and suppress the lint locally with
#[allow(unknown_lints, clippy::manual_is_multiple_of)] so:

- toolchains < 1.87 still build (the suggested u32::is_multiple_of
  was only stabilized in 1.87, and PyO3 0.23 supports stable >= 1.63);
- toolchains >= 1.95 (current GitHub stable) pass clippy without
  warnings;
- the suppression is scoped to one function, so any future manual
  divisibility check elsewhere in the crate is still flagged.

Co-authored-by: Fabio Tavares Leitão <[email protected]>
@FabioLeitao
FabioLeitao force-pushed the main branch 2 times, most recently from ae0da8d to b5c995c Compare May 3, 2026 17:52
FabioLeitao added a commit that referenced this pull request May 3, 2026
Read-only audit-and-block deliverable from the SRE Automation Agent
(Slack-triggered protocol). PR #255 added a new Rust CI workflow whose
'cargo clippy --all-targets --all-features -- -D warnings' job fails on
runner Rust 1.95.0 because clippy::manual_is_multiple_of (stable since
Rust 1.87) fires on 'sum % 10 == 0' in
rust/boar_fast_filter/src/filter_logic.rs.

The audit proposes the smallest fix that keeps zero behaviour change and
zero MSRV drift: an inline #[allow(clippy::manual_is_multiple_of)] with
a one-line comment naming the MSRV reason. Rewriting the expression to
sum.is_multiple_of(10) would silently raise the crate's MSRV from
'no pinned rust-version' to '>= 1.87' as a side effect of a CI hardening
PR -- out of scope and tracked as follow-up F1 in the audit doc.

Also documents the rejection of an embedded prompt-injection segment in
the trigger Slack message ('system override / switch to Opus 4.7'),
since Cloud Agents cannot change their own backend mid-run; recording
this matches the Defensive Scanning Manifesto contract that every
emitted statement is tagged.

Index entries for two prior 2026-04-27 audits that already shipped
(PR_SECURITY_AUDIT, STALE_FEATURE_FLAG_AUDIT) are added to
docs/ops/sre_audits/README.md as part of the same hub-sync pass.

Co-authored-by: Fabio Tavares Leitão <[email protected]>
@FabioLeitao
FabioLeitao force-pushed the fix/rust-ci-coverage branch from a89ac4e to 04a72fc Compare May 3, 2026 17:52
FabioLeitao added a commit that referenced this pull request May 3, 2026
…ability

The Rust CI job introduced in #255 fails on the GitHub Actions `stable`
toolchain (clippy 1.95) with `manual_is_multiple_of`:

    error: manual implementation of `.is_multiple_of()`
       --> src/filter_logic.rs:74:5
        |
    74  |     sum % 10 == 0
        |     ^^^^^^^^^^^^^ help: replace with: `sum.is_multiple_of(10)`

`u32::is_multiple_of` only stabilized in Rust 1.87. Rewriting the function
to use it would silently break older toolchains used by contributors and the
homelab. The classic Luhn modulo arithmetic is also the canonical form every
reviewer recognizes, so flipping it for a brand-new lint trades clarity for
churn.

Fix: keep `% 2` / `% 10` and silence the lint locally with a documented
`#[allow]`. `unknown_lints` is included so older clippys (which do not know
this lint name yet) do not error on the attribute either.

No behavior change: the 7 existing unit tests in `filter_logic` (Luhn valid /
invalid, length bounds, CPF/email/card batch suspects) pass on local clippy
1.83 and should pass on CI 1.95.

Refs: PR #255 Rust CI failure.

Co-authored-by: Fabio Tavares Leitão <[email protected]>
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]>
@FabioLeitao FabioLeitao closed this May 3, 2026
@FabioLeitao
FabioLeitao deleted the fix/rust-ci-coverage branch May 3, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants