diff --git a/tests/test_portfolio.py b/tests/test_portfolio.py index 93597c6..1281410 100644 --- a/tests/test_portfolio.py +++ b/tests/test_portfolio.py @@ -82,3 +82,26 @@ async def test_a2_unknown_project_id_raises(make_portfolio_client_factory, fresh store=fresh_store, client_factory=make_portfolio_client_factory(REPLIES), ) + + +async def test_b_shared_store_accumulates_and_surfaces_prior_verdict( + make_portfolio_client_factory, fresh_store +) -> None: + """SC4 (load-bearing, not mere non-emptiness): the ONE shared store accumulates a distinct + verdict per project (3 -> 3 pairwise-distinct ids), and the cross-project ExpeL retrieval + surfaces the STRUCTURAL match — BRU (runs[2]) retrieves FV42's verdict (runs[0]), since + sim(BRU,FV42)=0.60 (shared code 05.2 + identical "Reduce scope" measure + same magnitude + bucket) ranks above the RV13 decoy at sim(BRU,decoy)=0.15. If retrieval ranking breaks, or + two proposals collide to a single minted id, this fails — it asserts the specific match, not + store-non-empty.""" + result = await run_portfolio( + _PORTFOLIO_IDS, + "local", + store=fresh_store, + client_factory=make_portfolio_client_factory(REPLIES), + ) + assert len(result.store.verdicts) == 3 + ids = [v.id for v in result.store.verdicts] + assert len(set(ids)) == 3 # pairwise distinct minted ids (no collision) + # BRU surfaces FV42 (the structural match), ranked above the decoy. + assert result.runs[2].retrieved[0].id == result.runs[0].verdict.id