Skip to content

Report matched TSA automation regex in reasons - #521

Open
jack-atlas wants to merge 1 commit into
KumoCorp:mainfrom
jack-atlas:fix-tsa-matched-rule-reason
Open

Report matched TSA automation regex in reasons#521
jack-atlas wants to merge 1 commit into
KumoCorp:mainfrom
jack-atlas:fix-tsa-matched-rule-reason

Conversation

@jack-atlas

Copy link
Copy Markdown
Contributor

Summary

  • carry the regex that matched a TSA automation rule out of the existing rule scan
  • use that matched regex in generated suspension, bounce, and config override reasons
  • keep the full rule intact for threshold tracking, action hashing, and Lua match_rules compatibility
  • include the rustfmt-only mod-counter-series hunk required by the current nightly formatter check

Fixes #350.

Notes

This avoids the extra regex-list scan from the earlier sketch in the issue thread. Rule matching still performs a single pass over each rule's regex list; the matched regex is retained as display metadata alongside the full Rule.

Tests

  • cargo test -p kumo-api-types --lib
  • cargo test -p tsa-daemon
  • cargo test -p mod-counter-series
  • cargo +nightly fmt --all -- --check
  • git diff --check

Not tested

  • cargo test -p kumo-api-types, because the crate's doctest pass currently fails on an existing BounceV1Request documentation snippet that is unrelated to this change.

TSA automation rules can contain several regexes, but generated suspension, bounce, and config override reasons were showing the whole regex list. That made internal TransientFailure records hard to read and forced operators to rediscover which pattern actually triggered the automation.

This carries the matching regex out of the existing rule scan as MatchedRule metadata, while preserving the full Rule for threshold accounting, hashing, and action identity. The Lua shaping:match_rules API continues to return the original rule objects. The mod-counter-series hunk is the rustfmt change required by the repository's nightly formatter check.

Constraint: Maintainer feedback on KumoCorp#350 objected to an additional regex-list scan in the suspension path.

Rejected: Re-scan rule.regex while building reasons | increases matching work by another pass over the regex list.

Confidence: high

Scope-risk: moderate

Directive: Keep matched_regex as display metadata only; do not trim Rule.regex before hashing or threshold accounting.

Tested: cargo test -p kumo-api-types --lib

Tested: cargo test -p tsa-daemon

Tested: cargo test -p mod-counter-series

Tested: cargo +nightly fmt --all -- --check

Tested: git diff --check

Not-tested: cargo test -p kumo-api-types full doctests fail on an existing BounceV1Request documentation snippet unrelated to this change.
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.

Only record the matching pattern from a traffic shaping rule to log on internal transient failure

1 participant