Skip to content

test(benchmark): scope host rules per host and cover host-subagent-swarm-burst - #472

Merged
blitzcrieg1 merged 1 commit into
blitzcrieg1:masterfrom
surendraSinghKamboj:test/corpus-host-subagent-swarm
Nov 25, 2026
Merged

blitzcrieg1 merged 1 commit into
blitzcrieg1:masterfrom
surendraSinghKamboj:test/corpus-host-subagent-swarm

Conversation

@surendraSinghKamboj

Copy link
Copy Markdown
Contributor

What and why

Refs #36. One of the two uncovered rules, host-subagent-swarm-burst, could not be covered by adding a case alone. run_benchmark passed each recorded file to run_detections, which runs the session rules only, and read the whole file as one session. A host-scoped rule can never fire there, and a case that spans several sessions is read as one.

So this change has two parts:

  • benchmark.py now scopes the way detection.live does: session rules per correlation_id, host rules per host_id. Every existing case holds one session and one host, so their results do not move.
  • A new attack case, attack_host_subagent_swarm.jsonl: nine subagent starts over three sessions of three, in twenty minutes on one host. Each session is under the per-session threshold of five, so subagent-swarm-burst stays silent and only the host rule sees the campaign. That is the evasion the rule exists for.

The benchmark reports 15 rules covered, 104 cases, 0 missed and 0 false positives. Two tests pin the new scoping. README numbers and the CHANGELOG are updated.

The other rule: off-hours-activity (a finding, not a case)

I did not add a case for off-hours-activity. The rule is opt-in (AGENTMETRY_DETECT_OFF_HOURS) and returns nothing unless settings.detect_off_hours is true, and the benchmark runs on default settings. So a corpus case cannot fire it as the harness stands, however realistic the session. The unit tests enable it with monkeypatch.

The issue says to report this kind of thing rather than force a case. If you want it covered, one option is an optional per-case settings: mapping in corpus.yaml (for example detect_off_hours: true, business_tz, business_hours), applied only while that case runs, which also pins the timezone so the case does not depend on the machine. I held back because it changes what a corpus case can express. Happy to do it here or in a follow-up, whichever you prefer.

Checks

  • python -m pytest -q: 2958 passed, 19 skipped
  • python -m ruff check agentmetry tests passes
  • agentmetry benchmark: 0 missed, 0 false positives
  • Frozen detection files untouched (benchmark.py is not on the list), so the fingerprint does not move
  • No secrets in the diff

…arm-burst

The benchmark passed each recorded case to the session rules only, as a single
session, so a host-scoped rule could never fire in it and a case spanning
several sessions was read as one. It now scopes as detection.live does: session
rules per correlation_id, host rules per host_id.

That gives host-subagent-swarm-burst its corpus case: nine subagent starts over
three sessions of three, each under the per-session threshold. Refs blitzcrieg1#36
@blitzcrieg1
blitzcrieg1 merged commit 3a73500 into blitzcrieg1:master Nov 25, 2026
10 checks passed
blitzcrieg1 added a commit that referenced this pull request Nov 25, 2026
 #474) (#475)

Generated by Mistral Vibe.

Co-authored-by: Mistral Vibe <[email protected]>
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.

2 participants