fix: make Result#action return the outcome

fix: make Result#action return the outcome

Result#action now returns what the caller should do:

  • :block — rule matched, exceeded, rule configured to block
  • :log — rule matched, exceeded, rule configured to log
  • :allow — rule matched but within limit, no rule matched, or error (fail-open)

Previously action returned the rule's configured action regardless of whether the limit was exceeded, requiring callers to check both result.action and result.exceeded?. The rule's configured action is still available via result.rule.action.

action is now a required keyword argument on Result — it can no longer default to nil. The no-match and error cases explicitly pass action: :allow.

A table-based "Result action outcome matrix" replaces 5 individual integration tests (Scenarios G, I, J, S, and "limit 0") with 9 parameterized cases that assert the full Result object via structural equality. Scenarios H (logger assertion) and K (multi-call counter accumulation) are retained as they test behavior beyond the Result shape.

Discovered while working on gitlab-com/gl-infra/production-engineering#28798 (closed)

Merge request reports

Loading
Loading