feat(ledger): the consumer map surfaces — every css row carries used_by on list_shapes, flag="unused-css" (the map's negative space, surfaced never deleted), derive groups and the write-path family carry consumers, the derive line says "used by N template(s)", coverage payload unused_css + the standing block; docs, SKILL, plugin 0.1.44; the two step-2 tests expected 5 edges where fan-out makes 6 (milestone 302 step 3, #2936)
CI & Build / Plugin hooks (push) Successful in 9s
CI & Build / Python lint (push) Successful in 4s
CI & Build / TypeScript typecheck (push) Successful in 38s
CI & Build / integration (push) Failing after 44s
CI & Build / Python tests (push) Successful in 1m26s
CI & Build / Build & push image (push) Successful in 31s
CI & Build / Plugin hooks (push) Successful in 9s
CI & Build / Python lint (push) Successful in 4s
CI & Build / TypeScript typecheck (push) Successful in 38s
CI & Build / integration (push) Failing after 44s
CI & Build / Python tests (push) Successful in 1m26s
CI & Build / Build & push image (push) Successful in 31s
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -703,11 +703,13 @@ async def test_consumer_map_syncs_edges_from_template_references(seeded):
|
||||
"v/B.vue": {"error-msg": 1},
|
||||
"v/C.vue": {"error-msg": 1, "btn-primary": 4},
|
||||
}
|
||||
assert await sync_repo_consumers(pid, REPO, refs) == 5
|
||||
# A and B consume their OWN error-msg; C defines none, so its use fans
|
||||
# out to both rows; btn-primary resolves to the shared sheet from A and C.
|
||||
assert await sync_repo_consumers(pid, REPO, refs) == 6
|
||||
rows = {(r.path, r.symbol): r.id for r in await live_rows(pid) if r.kind == "css"}
|
||||
edges = await consumers_of(rows.values())
|
||||
view = {(p, s): [(e.path, e.count) for e in edges.get(i, [])] for (p, s), i in rows.items()}
|
||||
assert view[("v/A.vue", "error-msg")] == [("v/A.vue", 2)]
|
||||
assert view[("v/A.vue", "error-msg")] == [("v/A.vue", 2), ("v/C.vue", 1)]
|
||||
assert view[("v/B.vue", "error-msg")] == [("v/B.vue", 1), ("v/C.vue", 1)]
|
||||
assert view[("assets/components.css", "btn-primary")] == [("v/A.vue", 1), ("v/C.vue", 4)]
|
||||
assert view[("web/button.css", "btn")] == [] # the seeded row: no template names it
|
||||
@@ -719,6 +721,22 @@ async def test_consumer_map_syncs_edges_from_template_references(seeded):
|
||||
assert [(e.path, e.count) for e in edges[rows[("v/B.vue", "error-msg")]]] == [("v/B.vue", 1)]
|
||||
assert [(e.path, e.count) for e in edges[rows[("assets/components.css", "btn-primary")]]] == [("v/A.vue", 2)]
|
||||
|
||||
# The readout side: used_by per css row, the unused-css flag, and the
|
||||
# family's consumers on the write-path check.
|
||||
from scribe.services.shape_ledger import (
|
||||
apply_derive_groups, used_by_map, write_time_derive,
|
||||
)
|
||||
owner = seeded["owner"]
|
||||
live = [r for r in await live_rows(pid) if r.kind == "css"]
|
||||
used = await used_by_map(live)
|
||||
assert used[rows[("v/B.vue", "error-msg")]] == {"count": 1, "paths": ["v/B.vue"]}
|
||||
assert used[rows[("web/button.css", "btn")]] == {"count": 0, "paths": []}
|
||||
unused, n = await list_project_shapes(owner, pid, flag="unused-css")
|
||||
assert n == 1 and [(r.path, r.symbol) for r in unused] == [("web/button.css", "btn")]
|
||||
await apply_derive_groups(pid)
|
||||
out = await write_time_derive(pid, "v/New.vue", [("css", "error-msg")])
|
||||
assert out and out[0]["family"]["consumers"] == {"count": 2, "paths": ["v/A.vue", "v/B.vue"]}
|
||||
|
||||
# B's rule vanishes from the tree → its edges go with the pass.
|
||||
await sync_repo_shapes(pid, REPO, [d for d in defs if d[0] != "v/B.vue"], seen_marker="m2")
|
||||
await sync_repo_consumers(pid, REPO, refs2)
|
||||
|
||||
Reference in New Issue
Block a user