Skip to content

fix: evaluate authored numeric decisions structurally - #732

Merged
kvlonge merged 1 commit into
mainfrom
fix/authored-numeric-decisions
Sep 18, 2026
Merged

kvlonge merged 1 commit into
mainfrom
fix/authored-numeric-decisions

Conversation

@kvlonge

@kvlonge kvlonge commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Why

SQBRDECLARATION102 previously authorized a compiled numeric comparison whenever the same numeric token appeared anywhere in the full authored model file. Header metadata, comments, casts, output values, and macro-expanded SQL could therefore create both false positives and false negatives.

Fixed output bucket projections such as CASE WHEN offset_seconds = 30 ... AS amount_30 are structural schema definitions rather than unnamed policy thresholds.

Changes

  • pass the authored query body separately from the complete model file to native Rules
  • match complete authored comparison expressions instead of model-wide numeric tokens
  • ignore comments while matching authored comparisons
  • inspect direct comparison operands so nested arithmetic and cast precision do not authorize a finding
  • recognize equality-based fixed output buckets when the literal is encoded in the output name
  • retain strict findings for threshold comparisons, including aliases that happen to end in the threshold
  • add native regressions for constants, comments, casts, nested comparisons, and fixed buckets

Verification

  • native Rust test suite
  • focused Python Rule evaluation and cache tests
  • Rust clippy with warnings denied
  • uv sync --all-extras
  • make check-ci
  • downstream cache-free static compile across 974 models with the SQBRDECLARATION102 inventory reduced to zero after genuine thresholds were declared as constants
  • public repository hygiene scan

@kvlonge
kvlonge enabled auto-merge (squash) September 18, 2026 09:24
@kvlonge
kvlonge merged commit 6753680 into main Sep 18, 2026
18 checks passed
@kvlonge
kvlonge deleted the fix/authored-numeric-decisions branch September 18, 2026 09:35
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.

1 participant