feat(coverage): the line names standing work with 0 unclassified + derive_new, copies that joined a family since the previous refresh (#2899, milestone 299 step 1)
CI & Build / TypeScript typecheck (push) Successful in 40s
CI & Build / Python lint (push) Successful in 6s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / integration (push) Successful in 33s
CI & Build / Python tests (push) Successful in 1m7s
CI & Build / Build & push image (push) Successful in 24s
CI & Build / TypeScript typecheck (push) Successful in 40s
CI & Build / Python lint (push) Successful in 6s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / integration (push) Successful in 33s
CI & Build / Python tests (push) Successful in 1m7s
CI & Build / Build & push image (push) Successful in 24s
Since the scoped bucket (#2869) the ledger reads 100% accounted while 439 derive rows stand; the standing block was gated on unclassified > 0 and so went silent. Build it whatever the todo count ("; standing: ..."), and add derive_new — derive-grouped rows first seen after the previous refresh stamp — so entering a project names the drift ("+2 new copies since last refresh: .error-msg in InceptionCard.vue") instead of waiting for an audit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -597,6 +597,39 @@ async def test_derive_groups_land_on_rows_and_in_the_summary(seeded):
|
||||
assert {r.symbol for r in rows} == {"slug"} # 2 files < the name floor
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
async def test_derive_new_names_the_copy_that_joined_a_family_since_the_stamp(seeded):
|
||||
"""#2899: the first sync seeds one `slug`; a later sync adds an identical
|
||||
copy. Against the stamp between them, derive_new counts ONLY the
|
||||
newcomer — the drift since the last refresh, not the whole family."""
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from scribe.services.shape_ledger import (
|
||||
apply_derive_groups, derive_new_summary, live_rows,
|
||||
)
|
||||
|
||||
owner, pid = seeded["owner"], seeded["pid"]
|
||||
first = _defs(
|
||||
("a/one.py", "sym", "slug", "def slug(t):", "def slug(t):\n return t.lower()"),
|
||||
)
|
||||
await sync_repo_shapes(pid, REPO, first, seen_marker="m1")
|
||||
stamp = datetime.now(timezone.utc)
|
||||
second = _defs(
|
||||
("a/one.py", "sym", "slug", "def slug(t):", "def slug(t):\n return t.lower()"),
|
||||
("a/two.py", "sym", "slug", "def slug(t):", "def slug(t):\n return t.lower()"),
|
||||
)
|
||||
await sync_repo_shapes(pid, REPO, second, seen_marker="m2")
|
||||
assert await apply_derive_groups(pid) == 2
|
||||
|
||||
rows = await live_rows(pid)
|
||||
out = derive_new_summary(rows, since=stamp)
|
||||
assert out["count"] == 1
|
||||
assert out["examples"][0]["path"] == "a/two.py"
|
||||
assert out["examples"][0]["label"] == "slug"
|
||||
assert out["examples"][0]["group"].startswith("dup:")
|
||||
assert derive_new_summary(rows, since=None)["count"] == 0
|
||||
|
||||
|
||||
# --- #2793: the divergence readout against real rows -------------------------
|
||||
|
||||
|
||||
|
||||
@@ -276,6 +276,8 @@ async def test_coverage_measures_the_tree_exactly_and_caches(seeded):
|
||||
assert coverage["largest_gaps"] == [
|
||||
{"dir": "src", "unclassified": 2, "total": 3}
|
||||
]
|
||||
# #2899: a first computation has no previous stamp — nothing is "new".
|
||||
assert coverage["derive_new"] == {"count": 0, "examples": []}
|
||||
|
||||
# The walk fed the LEDGER (#2788): every extracted shape has a row, the
|
||||
# snippet reference locations are mechanically stamped canonical WITH
|
||||
@@ -512,6 +514,41 @@ def test_coverage_line_names_the_proposers_standing():
|
||||
assert "top canon #2844 ×78" in line and "top copy closed-msg (identical body) ×3 files" in line
|
||||
|
||||
|
||||
def test_coverage_line_shows_standing_work_even_with_nothing_unclassified():
|
||||
"""#2899: since the scoped bucket a ledger can be fully accounted and
|
||||
still carry derive groups / proposals / divergence — the line names
|
||||
them as `standing:` instead of hiding them behind the todo count, and
|
||||
names the drift since the previous refresh first-copy-first."""
|
||||
from scribe.services.coverage import coverage_line
|
||||
|
||||
base = {
|
||||
"total": 4693, "accounted": 4693, "unclassified": 0,
|
||||
"counts": {"canonical": 37, "instance": 977, "variant": 73, "exempt": 1797, "scoped": 1809},
|
||||
"computed_at": "2026-08-22T00:00:00+00:00", "largest_gaps": [],
|
||||
}
|
||||
quiet = coverage_line(base)
|
||||
assert "unclassified" not in quiet and "standing" not in quiet
|
||||
line = coverage_line({
|
||||
**base,
|
||||
"derive_groups": [{"group": "dup:abc", "label": "log-empty (identical body)", "files": 4}],
|
||||
"derive_new": {"count": 2, "examples": [
|
||||
{"label": ".error-msg", "path": "frontend/src/components/InceptionCard.vue", "group": "dup:9f0"},
|
||||
{"label": ".error-msg", "path": "frontend/src/components/Other.vue", "group": "dup:9f0"},
|
||||
]},
|
||||
"divergent": 1,
|
||||
})
|
||||
assert "; standing: 1 derive group, +2 new copies since last refresh: .error-msg in " \
|
||||
"frontend/src/components/InceptionCard.vue, 1 DIVERGENT, top copy log-empty (identical body) ×4 files" in line
|
||||
assert "unclassified" not in line
|
||||
# One copy reads singular; with a todo the block keeps its old place.
|
||||
one = coverage_line({**base, "derive_new": {"count": 1, "examples": []}})
|
||||
assert one.endswith("; standing: +1 new copy since last refresh")
|
||||
todo = coverage_line({**base, "unclassified": 3, "accounted": 4690, "proposed": 2,
|
||||
"derive_new": {"count": 1, "examples": [{"label": "x", "path": "a.py"}]},
|
||||
"largest_gaps": [{"dir": "src", "unclassified": 3, "total": 9}]})
|
||||
assert "; 3 unclassified (2 proposed, +1 new copy since last refresh: x in a.py), largest: src" in todo
|
||||
|
||||
|
||||
def test_coverage_line_names_divergence_and_recheck():
|
||||
from scribe.services.coverage import coverage_line
|
||||
|
||||
|
||||
@@ -317,6 +317,38 @@ def test_derive_groups_copy_before_name_with_floors():
|
||||
assert ("i.py", "sym", "one") not in g
|
||||
|
||||
|
||||
def test_derive_new_summary_counts_copies_first_seen_since_the_previous_refresh():
|
||||
"""#2899: the arrival-moment drift signal — derive-grouped rows created
|
||||
after the previous refresh's stamp, newest first, judged rows and a
|
||||
first seed (since=None) never count."""
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from scribe.models.code_shape import CodeShape
|
||||
from scribe.services.shape_ledger import derive_new_summary
|
||||
|
||||
t0 = datetime(2026, 8, 22, 12, 0, tzinfo=timezone.utc)
|
||||
|
||||
def row(path, symbol, at, kind="css", status="scoped", group="dup:abc", basis="derive"):
|
||||
r = CodeShape(project_id=2, repo_key="r", path=path, symbol=symbol, kind=kind,
|
||||
status=status, proposal_basis=basis, proposal_group=group)
|
||||
r.created_at = at
|
||||
return r
|
||||
rows = [
|
||||
row("v/Old.vue", "error-msg", t0 - timedelta(days=3)), # before the stamp
|
||||
row("v/InceptionCard.vue", "error-msg", t0 + timedelta(hours=1)), # new copy
|
||||
row("v/Other.vue", "error-msg", t0 + timedelta(hours=2)), # newer copy
|
||||
row("v/J.vue", "error-msg", t0 + timedelta(hours=3), status="exempt"), # judged: never
|
||||
row("s/a.py", "load", t0 + timedelta(hours=1), kind="sym", group=None, basis=None), # no family
|
||||
]
|
||||
out = derive_new_summary(rows, since=t0)
|
||||
assert out["count"] == 2
|
||||
assert [e["path"] for e in out["examples"]] == ["v/Other.vue", "v/InceptionCard.vue"]
|
||||
assert out["examples"][0] == {"label": ".error-msg", "path": "v/Other.vue", "group": "dup:abc"}
|
||||
assert derive_new_summary(rows, since=None) == {"count": 0, "examples": []}
|
||||
assert derive_new_summary(rows, since=t0, top=1)["examples"] == [
|
||||
{"label": ".error-msg", "path": "v/Other.vue", "group": "dup:abc"}]
|
||||
|
||||
|
||||
def test_proposal_summary_ranks_body_identical_groups_first_and_sees_scoped_rows():
|
||||
"""#2872: dup groups (the real copies) outrank name groups (usually
|
||||
convention), wider spread first; #2869: scoped rows are in the readout."""
|
||||
|
||||
Reference in New Issue
Block a user