fix(8249): a redundant verdict can name a cover the sync has not read yet
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Python tests (push) Successful in 2m7s
CI & Build / integration (push) Successful in 2m41s
CI & Build / Build & push image (push) Successful in 25s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Python tests (push) Successful in 2m7s
CI & Build / integration (push) Successful in 2m41s
CI & Build / Build & push image (push) Successful in 25s
A test is usually rewritten in the same change that removes the one it replaces, so the cover is new to the ledger when the verdict is recorded, and the next refresh retires the removed test. classify_shapes refused such a cover as matching no live shape. With a bound `repo` the cover now resolves the way the judged shape already does, as a provisional row the next sync adopts; without one it is refused as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -800,12 +800,22 @@ async def classify_shapes(
|
||||
status = item["status"]
|
||||
cover_id = None
|
||||
if status == "redundant":
|
||||
# The cover is a live row of this project, resolved exactly
|
||||
# like the shape being judged; a cover no row matches is an
|
||||
# error, because a redundant verdict without its cover is the
|
||||
# one claim nobody can check.
|
||||
# The cover resolves exactly like the shape being judged: a
|
||||
# live row, or with a bound `repo` a provisional one, because
|
||||
# a test is usually rewritten in the same change that removes
|
||||
# the one it replaces, so the cover is new to the ledger. A
|
||||
# cover nothing can name is an error: a redundant verdict
|
||||
# without its cover is the one claim nobody can check.
|
||||
cover = item["covered_by"]
|
||||
covers = by_key.get((cover["path"].strip(), cover["symbol"].strip())) or []
|
||||
cpath, csymbol = cover["path"].strip(), cover["symbol"].strip()
|
||||
covers = by_key.get((cpath, csymbol)) or []
|
||||
if not covers and repo_key:
|
||||
covers = [await provisional_row(
|
||||
session, project_id=project_id, repo_key=repo_key, path=cpath,
|
||||
symbol=csymbol, kind=snippet_kind(csymbol, ""),
|
||||
)]
|
||||
by_key.setdefault((cpath, csymbol), []).extend(covers)
|
||||
provisional += 1
|
||||
if not covers:
|
||||
raise ValueError(
|
||||
f"covered_by {cover['path']}::{cover['symbol']} matches no live shape "
|
||||
|
||||
@@ -109,6 +109,33 @@ async def test_a_kept_group_leaves_the_readout_until_its_members_change(seeded):
|
||||
assert (await tg.guard_groups(pid))["count"] == 1
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
async def test_a_redundant_verdict_can_name_a_cover_the_sync_has_not_read_yet(seeded):
|
||||
"""The replacement test lands in the same change as the removal, so its
|
||||
row does not exist yet: with a bound repo the cover becomes a provisional
|
||||
row, and the sync that reads it keeps the link. Without repo the verdict
|
||||
is refused, as a cover nobody can check."""
|
||||
from grimoire.services import repo_bindings as repo_bindings_svc
|
||||
|
||||
pid, owner = seeded["pid"], seeded["owner"]
|
||||
await repo_bindings_svc.set_binding(owner, REPO, pid)
|
||||
new = ("tests/test_d.py", "test_charges_and_counts")
|
||||
verdict = [{"path": A[0], "symbol": A[1], "kind": "sym", "status": "redundant",
|
||||
"reason": "the rewrite checks the charge and the count",
|
||||
"covered_by": {"path": new[0], "symbol": new[1]}}]
|
||||
|
||||
with pytest.raises(ValueError, match="matches no live shape"):
|
||||
await classify_shapes(owner, pid, verdict)
|
||||
out = await classify_shapes(owner, pid, verdict, repo=REPO)
|
||||
assert out["provisional"] == 1
|
||||
|
||||
await sync_repo_shapes(pid, REPO, SHAPES + [(new[0], "sym", new[1])], seen_marker="c2")
|
||||
rows = await _rows(pid)
|
||||
assert rows[A].status == "redundant"
|
||||
assert rows[A].covered_by_id == rows[new].id
|
||||
assert rows[new].vanished_at is None
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
async def test_the_end_of_turn_question_asks_about_product_code_not_test_cases(seeded):
|
||||
from grimoire.services.shape_ledger import unjudged_shapes
|
||||
|
||||
Reference in New Issue
Block a user