@@ -489,7 +489,9 @@ async def test_context_labels_passed_through(self, target, seed_group):
489489
490490 assert calls [0 ]["memory_labels" ]["foo" ] == "bar"
491491
492- async def test_completed_result_carries_context_labels (self , target , seed_group ):
492+ async def test_completed_result_carries_context_labels_async (
493+ self , * , target : MagicMock , seed_group : AttackSeedGroup
494+ ) -> None :
493495 a = _make_strategy (outcomes = [AttackOutcome .FAILURE ], name = "a" )
494496 compound = SequentialAttack (
495497 objective_target = target , child_attacks = [SequentialChildAttack (strategy = a , seed_group = seed_group )]
@@ -501,6 +503,26 @@ async def test_completed_result_carries_context_labels(self, target, seed_group)
501503
502504 assert result .labels == {"op" : "seq" }
503505
506+ async def test_label_query_finds_the_completed_result_async (
507+ self , * , seed_group : AttackSeedGroup , sqlite_instance : MemoryInterface
508+ ) -> None :
509+ target = MockPromptTarget ()
510+ compound = SequentialAttack (
511+ objective_target = target ,
512+ child_attacks = [
513+ SequentialChildAttack (strategy = _OkChildStrategy (objective_target = target ), seed_group = seed_group )
514+ ],
515+ )
516+
517+ result = await compound .execute_async (objective = "obj" , memory_labels = {"op" : "seq" })
518+
519+ labelled = await sqlite_instance .get_attack_results_async (labels = {"op" : "seq" })
520+ assert result .attack_result_id in {row .attack_result_id for row in labelled }
521+ assert {row .attack_result_id for row in labelled } == {
522+ result .attack_result_id ,
523+ * result .metadata [SequentialAttack .CHILD_ATTACK_RESULT_IDS_KEY ],
524+ }
525+
504526 async def test_child_attack_labels_override_context_labels (self , target , seed_group ):
505527 a = _make_strategy (outcomes = [AttackOutcome .SUCCESS ], name = "a" )
506528 child_attacks = [
0 commit comments