@@ -216,17 +216,20 @@ def test_format_orchestrated_counts_and_models(self) -> None:
216216 review_reviewer = "premium" ,
217217 local_passed = True ,
218218 ),
219+ _job (job = "blank" , apply_source = "" , applied = False ),
219220 ]
220221 self .assertEqual (
221222 format_orchestrated (results ),
222223 "\n " .join (
223224 [
224- "jobs=2 applied=2 delegated=1" ,
225+ "jobs=3 applied=2 delegated=1" ,
225226 "pass@end=1.00 delegated_jobs=1" ,
226227 " keep_one: delegated=False route=incident_debug "
227228 "outcome=kept_on_premium source=premium models=-" ,
228229 " do_one: delegated=True route=mechanical "
229230 "outcome=applied_local source=local models=['fast']" ,
231+ " blank: delegated=False route=incident_debug "
232+ "outcome=kept_on_premium source=- models=-" ,
230233 ]
231234 ),
232235 )
@@ -294,6 +297,9 @@ def test_local_mcp_repairs_format_then_stops(self) -> None:
294297 )
295298 self .assertEqual (len (attempts ), 2 )
296299 self .assertEqual (attempts [0 ].record .attempt , 1 )
300+ self .assertEqual (attempts [0 ].record .job , "whitespace_extract#1" )
301+ self .assertEqual (attempts [0 ].record .backend , "stub" )
302+ self .assertEqual (attempts [0 ].record .profile , "golden" )
297303 self .assertFalse (attempts [0 ].record .passed )
298304 self .assertEqual (attempts [0 ].record .first_failure , "format" )
299305 self .assertEqual (attempts [0 ].record .model , "fast" )
@@ -403,6 +409,31 @@ def test_secret_file_stays_on_premium(self) -> None:
403409 self .assertEqual (result .route_reason , "secrets_file" )
404410 self .assertEqual (result .applied_text , "hold" )
405411
412+ def test_delegated_attempt_keeps_job_backend_and_profile (self ) -> None :
413+ case = CASES_BY_ID ["whitespace_extract" ]
414+ session = _Session ([_golden_tool ()])
415+ job = OrchestrationJob (
416+ id = "do_one" ,
417+ signals = mechanical_signals (),
418+ eval_case = case ,
419+ review = accept (),
420+ )
421+ seen : list [tuple [str , str , str ]] = []
422+ real = harness ._run_local_mcp
423+
424+ async def _spy (session , case , * , job , backend , profile ):
425+ seen .append ((job , backend , profile ))
426+ return await real (session , case , job = job , backend = backend , profile = profile )
427+
428+ with patch .object (harness , "_run_local_mcp" , _spy ):
429+ result = asyncio .run (
430+ harness ._run_orchestrated_job (
431+ session , job , backend = "stub" , profile = "golden"
432+ )
433+ )
434+ self .assertEqual (seen , [("do_one" , "stub" , "golden" )])
435+ self .assertEqual (result .outcome , "applied_local" )
436+
406437
407438class CampaignTests (unittest .TestCase ):
408439 def _cases (self ) -> tuple [object , object ]:
@@ -440,6 +471,8 @@ async def _with_session(*, backend, profile, fast_ms, strong_ms, base_url, body)
440471 ],
441472 )
442473 self .assertTrue (all (row .passed for row in rows ))
474+ self .assertEqual (rows [0 ].backend , "stub" )
475+ self .assertEqual (rows [0 ].profile , "golden" )
443476 self .assertEqual (
444477 captured ,
445478 [("stub" , "golden" , 1.5 , 4.5 , "http://127.0.0.1:9" )],
@@ -486,6 +519,8 @@ async def _with_session(*, backend, profile, fast_ms, strong_ms, base_url, body)
486519 with patch .object (harness , "_with_session" , _with_session ):
487520 rows = asyncio .run (harness .run_campaign (backend = "stub" , profile = "golden" ))
488521 self .assertEqual ([row .job for row in rows ], [f"{ first .id } #1" ])
522+ self .assertEqual (rows [0 ].backend , "stub" )
523+ self .assertEqual (rows [0 ].profile , "golden" )
489524 self .assertEqual (captured , [(8.0 , 25.0 , None )])
490525
491526 def test_orchestrated_campaign_filters_jobs (self ) -> None :
@@ -505,7 +540,7 @@ def test_orchestrated_campaign_filters_jobs(self) -> None:
505540 captured : list [tuple [object , ...]] = []
506541
507542 async def _with_session (* , backend , profile , fast_ms , strong_ms , base_url , body ):
508- captured .append ((fast_ms , strong_ms , base_url , profile ))
543+ captured .append ((backend , fast_ms , strong_ms , base_url , profile ))
509544 await body (session , backend , profile )
510545
511546 with patch .object (harness , "MCP_JOBS" , (keep , delegated )):
@@ -542,7 +577,7 @@ async def _with_session(*, backend, profile, fast_ms, strong_ms, base_url, body)
542577 self .assertEqual (both [1 ].outcome , "applied_local" )
543578 self .assertEqual ([item .job for item in only_keep ], ["keep_one" ])
544579 self .assertEqual (session .calls [0 ][0 ], case .tool )
545- self .assertEqual (captured [0 ], (3.0 , 9.0 , None , "golden" ))
580+ self .assertEqual (captured [0 ], ("stub" , 3.0 , 9.0 , None , "golden" ))
546581 self .assertEqual (str (missing .exception ), "no orchestration jobs selected" )
547582
548583 def test_orchestrated_defaults_timing_and_forwards_base_url (self ) -> None :
@@ -554,7 +589,7 @@ def test_orchestrated_defaults_timing_and_forwards_base_url(self) -> None:
554589 captured : list [tuple [object , ...]] = []
555590
556591 async def _with_session (* , backend , profile , fast_ms , strong_ms , base_url , body ):
557- captured .append ((fast_ms , strong_ms , base_url ))
592+ captured .append ((backend , fast_ms , strong_ms , base_url ))
558593 await body (_Session ([]), backend , profile )
559594
560595 with patch .object (harness , "MCP_JOBS" , (keep ,)):
@@ -567,7 +602,7 @@ async def _with_session(*, backend, profile, fast_ms, strong_ms, base_url, body)
567602 )
568603 )
569604 self .assertEqual ([item .job for item in rows ], ["keep_one" ])
570- self .assertEqual (captured , [(8.0 , 25.0 , "http://127.0.0.1:8" )])
605+ self .assertEqual (captured , [("stub" , 8.0 , 25.0 , "http://127.0.0.1:8" )])
571606
572607
573608class SessionBootstrapTests (unittest .TestCase ):
0 commit comments