dev → main: the meaning check reads new shapes first, and its miss withdraws an early flag (#4208) #181
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user