fix: P1 evaluator gating bug, DRY refactors, engine unit tests#9
Merged
Conversation
- Fix P1 bug: evaluator.Evaluate(conn) now called unconditionally in runJSON so threshold rules count all packets, not just fingerprint- producing ones (was already fixed in TUI/shard path, missed here) - Export PacketInfo/PacketTimestamp from engine package, remove duplicate implementations from main.go - Extract replayThrottler type shared by runJSON and runTUI - Extract wireAlertSinks helper (was duplicated across 3 run functions) - Add 11 unit tests for engine core: sharding, dirty flush, eviction, ConnChan backpressure, pcap mode - Fix redundant PacketTimestamp call in replayThrottler - Use tracker.MakeKey() in tests instead of hardcoded ID strings Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Crank-Git
added a commit
that referenced
this pull request
May 9, 2026
fix: P1 evaluator gating bug, DRY refactors, engine unit tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
evaluator.Evaluate(conn)was gated behindlen(results) > 0inrunJSON, causing threshold rules to undercount packets in JSON/SIEM mode. Removed the guard so all packets are evaluated (matches TUI/shard path behavior).engine.PacketInfo()/PacketTimestamp(), extractedreplayThrottlertype andwireAlertSinks()helper — eliminates 3 instances of duplicated code across run functions.tracker.MakeKey()in tests, redundantPacketTimestampcall eliminated,encMucomment added.Test plan
go build ./...— compiles cleango test ./internal/engine/— 22 tests passgo test ./cmd/ja4monitor/— 10 tests passja4monitor analyze --json <pcap>with custom threshold rules — verify alerts fire on non-fingerprint packetsja4monitor live <iface>— verify TUI still works after DRY refactors🤖 Generated with Claude Code