fix(shapes): weak stamps elect no canon; the arrival line names the review; Svelte scopes by default (#4608)
CI & Build / Python lint (push) Successful in 8s
CI & Build / Plugin hooks (push) Successful in 16s
CI & Build / TypeScript typecheck (push) Successful in 54s
CI & Build / integration (push) Successful in 1m3s
CI & Build / Python tests (push) Successful in 1m44s
CI & Build / Build & push image (push) Successful in 1m5s

Librarian and Stash had 132 and 488 write-path stamps written at 0.68-0.72,
before the 0.80 floor (#4204). Nothing re-judged them, and dominant_canon
counted them, so a YAML CI snippet (#3410) "dominated" Librarian's web
directory and every write there was told it diverged from it — 1408 flags
on one project, 902 on the other, all skimmed past.

- is_weak_stamp: one predicate for "hook-stamped below today's floor".
  dominant_canon and canon_form skip such rows; stamps_to_review lists them
  by the same predicate. No stored row changes — they stay for judgment.
- flag_divergence withdraws a standing flag whose canon no longer dominates
  its directory. A flag is a mechanical prompt, not a judgment.
- The coverage line ends "N weak stamps · M incoherent canons to judge —
  stamps_to_review" when either is nonzero, so a project's own session sees
  the queue on arrival. The shape-accounting skill says what to do with it.
- scoped_definitions handles .svelte: every <style> is component-scoped
  unless <style global> or :global(...); instance-script syms are scoped,
  module-script ones stay ordinary.

Plugin version minted for the skill change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-30 23:27:07 -04:00
co-authored by Claude Opus 5.5
parent 3270fe90c1
commit eb5cc6d3a7
7 changed files with 291 additions and 12 deletions
+50
View File
@@ -350,3 +350,53 @@ def test_the_coherence_verdict_reads_rows_and_writes_nothing() -> None:
canon_coherence(rows)
assert [(r.path, r.symbol, r.status, r.snippet_id, r.signature)
for r in rows] == before
# ── a weak stamp is listed for judgment and counted by nobody (#4608) ─────
#
# The floor guarded new writes; the rows written before it went on electing
# canons. On two projects a YAML CI snippet "dominated" a Svelte directory on
# the strength of 0.68-0.72 stamps, and every write there was told it
# diverged from it. The readers below must agree with the review surface
# about what "weak" means — one predicate, so they cannot drift apart.
def test_one_predicate_says_what_weak_is() -> None:
from scribe.services.shape_ledger import is_weak_stamp
assert is_weak_stamp(_stamped(0.72))
assert not is_weak_stamp(_stamped(_RESEMBLE_MIN))
# A by-name stamp carries no score: it is not resemblance evidence at all.
assert not is_weak_stamp(_Row(reason="hook: pulled #1; payload references `f`"))
for by in ("agent", "audit", "mechanical"):
assert not is_weak_stamp(_stamped(0.5, classified_by=by)), by
def test_weak_stamps_do_not_elect_a_dominant_canon() -> None:
from scribe.services.shape_ledger import dominant_canon
weak = [_stamped(0.72, path=f"web/src/lib/{i}.ts", symbol=f"f{i}") for i in range(5)]
assert dominant_canon(weak) is None
# The same rows judged by an agent do — the kind of evidence is the point.
judged = [_stamped(0.72, path=f"web/src/lib/{i}.ts", symbol=f"f{i}", classified_by="agent")
for i in range(5)]
assert dominant_canon(judged) == (1, 5, 5)
# And weak rows do not dilute a real majority either: they are not counted
# as judged at all.
mixed = judged[:3] + [_stamped(0.7, snippet_id=2, symbol=f"g{i}") for i in range(4)]
assert dominant_canon(mixed) == (1, 3, 3)
def test_weak_stamps_do_not_say_what_form_a_canon_is() -> None:
from scribe.services.shape_ledger import FORM_UNKNOWN, canon_form
weak = [_stamped(0.7, symbol=f"T{i}", signature=f"class T{i}:") for i in range(5)]
assert canon_form(weak, 1) == FORM_UNKNOWN
judged = [_stamped(0.7, symbol=f"T{i}", signature=f"class T{i}:", classified_by="audit")
for i in range(5)]
assert canon_form(judged + weak, 1) == canon_form(judged, 1) != FORM_UNKNOWN
def test_counting_them_out_leaves_them_listed() -> None:
"""Not counted is not withdrawn: the review still lists every one."""
rows = [_stamped(0.7, symbol=f"f{i}") for i in range(3)]
assert stamps_to_review(rows)["weak_count"] == 3