Skip to content

Faithful HIR matcher model (Stage 1: ir + eval) - #362

Merged
mostafa merged 3 commits into
mainfrom
feat/convert-ir-backend
Jul 20, 2026
Merged

Faithful HIR matcher model (Stage 1: ir + eval)#362
mostafa merged 3 commits into
mainfrom
feat/convert-ir-backend

Conversation

@mostafa

@mostafa mostafa commented Jul 20, 2026

Copy link
Copy Markdown
Member

Foundation for wiring convert through the HIR (follow-up to #360). Reworks the rsigma-ir matcher model so it is faithful and lossless, and moves the physical work (lowercasing, regex/aho-corasick, encoding expansion) into eval's compile step.

What changed

  • IrMatcher::Str carries a wildcard-aware, original-case IrPattern; encoding modifiers stay explicit as IrMatcher::Encoded { encodings: Vec<IrEncoding>, … }. Lowering no longer lowercases, compiles regexes, or expands encodings.
  • compile_to_compiled (eval) reconstructs the modifier context and reuses the existing leaf compilers, so matching is byte-identical (the compile_rule vs compile_rule_legacy differential stays green).
  • Removes SurfaceSpec and the regex/ipnet/base64 deps from rsigma-ir; keywords are lossless without a sidecar.

This is Stage 1 of the convert migration: it touches only rsigma-ir + rsigma-eval. Convert still routes conditions through lower_conditions and is untouched. Stage 2 will have convert render backend queries directly from the faithful matcher.

Checks

  • cargo test -p rsigma-ir -p rsigma-eval (832 pass, differential included)
  • cargo test -p rsigma-convert (343) and CLI convert/eval/explain (72) unaffected
  • cargo clippy -p rsigma-ir -p rsigma-eval --all-targets --all-features -- -D warnings
  • cargo fmt --all; npm run docs:validate
  • CI green

xref #346

mostafa added 3 commits July 20, 2026 21:34
Lowering is now purely structural: string matches carry a wildcard-aware,
original-case IrPattern and encoding modifiers stay explicit as IrEncoding
steps. Nothing is lowercased, regex-compiled, or encoding-expanded during
lowering. Eval's compile step reconstructs the modifier context and reuses
the proven leaf compilers, so matching stays byte-identical (differential
green). This removes SurfaceSpec and the regex/cidr/base64 deps from
rsigma-ir, and sets up convert to render backend queries straight from the
HIR without the parser AST.
Drop the module-doc references to the removed IrValue/SurfaceSpec, and
resync ci/wasm-smoke and fuzz lockfiles after rsigma-ir dropped its
base64/ipnet/regex dependencies, so the --locked wasm build resolves.
@mostafa
mostafa marked this pull request as ready for review July 20, 2026 19:49
@mostafa
mostafa merged commit b5a66ea into main Jul 20, 2026
18 checks passed
@mostafa
mostafa deleted the feat/convert-ir-backend branch July 20, 2026 19:49
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