From e2197ac799587bad3abf93563295145dd543b070 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 22 Sep 2026 08:09:52 -0400 Subject: [PATCH] fix(tests): assert the withdrawn flag on its row, not on a count the skew margin inflates (#4208) Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01821k5B3Ysecp9fNYs92Kuy --- tests/test_integration_shape_classify.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/test_integration_shape_classify.py b/tests/test_integration_shape_classify.py index eb4b62e..74e2578 100644 --- a/tests/test_integration_shape_classify.py +++ b/tests/test_integration_shape_classify.py @@ -1057,24 +1057,36 @@ async def test_a_later_conclusive_miss_withdraws_a_flag_raised_before_it(seeded) from unittest.mock import AsyncMock, patch from scribe.services import shape_ledger - from scribe.services.shape_ledger import flag_divergence, propose_for_repo + from scribe.services.shape_ledger import ( + BASIS_NO_SEMANTIC_MATCH, flag_divergence, live_rows, propose_for_repo, + ) owner, pid, later, previous = await _two_generations(seeded, "withdraw") since = previous - timedelta(seconds=1) + async def _danger(): + return next(r for r in await live_rows(pid) if r.symbol == "confirmDanger") + + # Asserted on the ROW, not on a flag count. `since` sits a second before + # the second sync to absorb clock skew, which also admits the fixture's + # old helper as "new" — how many rows get flagged is a property of that + # margin, and this test is about one row's flag coming off. + # First refresh: the arm is quiet (formed no opinion), so the prompt is raised. with patch.object(shape_ledger, "_semantic_canon", AsyncMock(return_value=None)): await propose_for_repo(owner, pid, REPO, later) - assert await flag_divergence(pid, since=since) == 1 + await flag_divergence(pid, since=since) + assert (await _danger()).diverges_from is not None # A later refresh re-reads the body (a ruleset bump forces it) and is sure. with patch.object(shape_ledger, "_PROPOSER_VERSION", 10_000), \ patch.object(shape_ledger, "_semantic_canon", AsyncMock(side_effect=_conclusive)): await propose_for_repo(owner, pid, REPO, later) - assert await flag_divergence(pid, since=since) == 0 - _, total = await list_project_shapes(owner, pid, flag="divergence") - assert total == 0 + await flag_divergence(pid, since=since) + danger = await _danger() + assert danger.proposal_basis == BASIS_NO_SEMANTIC_MATCH + assert danger.diverges_from is None @pytest.mark.integration