Repository navigation
FIX: Combine scenario group counts for unmatched attempts (#3699) - #3780
Merged
Roman Lutz (romanlutz) merged 4 commits intoNov 3, 2026
Conversation
Roman Lutz (romanlutz)
self-requested a review
November 2, 2026 08:05
Roman Lutz (romanlutz)
approved these changes
Nov 3, 2026
Copilot started reviewing on behalf of
Hrushikesh Ramilla (Hrushikesh-ramilla)
November 3, 2026 05:55
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change to preserve scenario-history counts when group identities collide.
No open issues 🎉
What changed in this PR
Fixes #3699 by preserving scenario-history group counts when planned and unplanned attempts resolve to the same canonical group identity.
Changes:
- Combine counts for existing canonical and raw group keys instead of overwriting them.
- Add a regression test verifying that planned completion and success counts are preserved while both attempts are counted.
| File | Description |
|---|---|
tests/unit/memory/memory_interface/test_interface_scenario_history.py |
Adds regression coverage for planned and unplanned attempts sharing a canonical group. |
pyrit/memory/memory_interface.py |
Combines colliding group counts using combine_execution_counts. |
Review effort: Balanced
Keep canonical group accumulation while assigning each unique raw SQL group once. This removes a redundant branch and restores complete coverage of the scenario history fix. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Roman Lutz (romanlutz)
merged commit Nov 3, 2026
987d356
into
microsoft:main
85 of 101 checks passed
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.
Description
Fixes #3699.
When querying scenario history aggregates (
get_scenario_history_aggregates_asyncinpyrit/memory/memory_interface.py), per-group attempt counts fromgroup_rowsare grouped by(scenario_result_id, unit_group_id)in SQL.For unmatched attempts,
raw_gidis formatted asname\x1feval_hash, which lines 7336-7338 convert to the canonical configuration hashcanonical_gid = config_hash({"atomic_attack_name": name, "technique_eval_hash": eval_hash}).Previously,
run_groups[canonical_gid] = countsunconditionally assigned the row counts. If an unplanned attempt shared the same atomic attack name and technique configuration as a planned group, its row overwrote the existing canonical group's counts instead of combining the disjoint attempt populations. As a result, the group's planned completed/successful counts were overwritten, while overall run counts remained correct.Fix
MemoryInterface.get_scenario_history_aggregates_async:canonical_gidalready exists inrun_groups, combine the counts usingcombine_execution_counts([run_groups[canonical_gid], counts]).canonical_gid != raw_gid, combine intorun_groups[raw_gid]if already present.Tests
test_scenario_history_aggregates_combine_unplanned_attempt_counts_with_canonical_groupintests/unit/memory/memory_interface/test_interface_scenario_history.pyusing canonical configuration hashes and both planned and unplanned attempt records.pytest tests/unit/memory/memory_interface/test_interface_scenario_history.py: 25 passed.pytest tests/unit/analytics/test_scenario_statistics_parity.py: 37 passed.ruff check pyrit/memory/memory_interface.py tests/unit/memory/memory_interface/test_interface_scenario_history.py: 0 errors.ruff format --check pyrit/memory/memory_interface.py tests/unit/memory/memory_interface/test_interface_scenario_history.py: Clean.