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
+38 -8
View File
@@ -1066,6 +1066,8 @@ def canon_form(rows: Iterable, snippet_id: int) -> str:
for r in rows:
if r.snippet_id != snippet_id or r.status not in ("canonical", "instance"):
continue
if is_weak_stamp(r):
continue
f = shape_form(getattr(r, "signature", "") or "", r.kind)
if f:
forms[f] = forms.get(f, 0) + 1
@@ -2190,6 +2192,25 @@ async def confirm_proposals(
# suggestion, not the same.
_RESEMBLE_MIN = 0.80
def is_weak_stamp(row) -> bool:
"""Was this row written by the hook, unattended, on a resemblance below
the floor it would have to clear today?
ONE PREDICATE FOR "WEAK", read by the review surface that lists these rows
and by every reader that would otherwise take them as evidence. The floor
guards new writes only; the rows stamped before it (#4204) are still
stored, and until an agent re-judges them they must not speak. They are
not withdrawn here — `stamps_to_review` still lists them for judgment —
they are simply not counted, which is the module's rule for evidence it
cannot trust: quieter, never more confident (#4608).
"""
if getattr(row, "classified_by", None) not in _UNATTENDED_BY:
return False
score = stamp_score(getattr(row, "reason", None))
return score is not None and score < _RESEMBLE_MIN
_DENSITY_MIN_JUDGED = 3
_DENSITY_SHARE = 0.6
@@ -2229,6 +2250,11 @@ def dominant_canon(rows: Iterable[CodeShape]) -> tuple[int, int, int] | None:
counts: dict[int, int] = {}
judged = 0
for r in rows:
# A weak stamp is not a judgment: counted, it let a YAML CI snippet
# "dominate" a Svelte directory and every write there was told it
# diverged from it (#4608).
if is_weak_stamp(r):
continue
if r.status in ("canonical", "instance") and r.snippet_id is not None:
judged += 1
counts[r.snippet_id] = counts.get(r.snippet_id, 0) + 1
@@ -2488,6 +2514,16 @@ async def flag_divergence(project_id: int, *, since: datetime | None) -> int:
if r.status not in _MECHANICAL_TODO:
continue
if r.diverges_from is not None:
# A flag is a mechanical prompt resting on one premise —
# "this canon dominates here". When the premise no longer
# holds (the rows that elected it were weak stamps, #4608,
# or were re-judged away) the prompt is false, and a false
# prompt on every write is how the flag stopped being
# read. Withdrawing it judges nothing: the row stays
# unclassified, and a judgment is never touched here.
if dom is None or dom[0] != r.diverges_from:
r.diverges_from = None
continue
flagged += 1
continue
if dom is None or r.created_at is None or r.created_at <= since:
@@ -2565,11 +2601,9 @@ def stamps_to_review(rows: Iterable[CodeShape], *, top: int = 10) -> dict:
live = [r for r in rows if r.vanished_at is None]
weak = []
for r in live:
if r.status not in _NEEDS_TARGET or r.classified_by != "hook":
if r.status not in _NEEDS_TARGET or not is_weak_stamp(r):
continue
score = stamp_score(r.reason)
if score is None or score >= _RESEMBLE_MIN:
continue
weak.append({
"path": r.path, "symbol": r.symbol, "kind": r.kind,
"status": r.status, "snippet_id": r.snippet_id,
@@ -2602,11 +2636,7 @@ def stamps_to_review(rows: Iterable[CodeShape], *, top: int = 10) -> dict:
# The listing below is capped; without this you cannot tell a
# canon with twelve strangers from one with three hundred.
"stranger_count": len(coh["strangers"]),
"weak_rows": sum(
1 for r in members
if r.classified_by in _UNATTENDED_BY
and (stamp_score(r.reason) or 1.0) < _RESEMBLE_MIN
),
"weak_rows": sum(1 for r in members if is_weak_stamp(r)),
# The rows that do NOT fit — not the first dozen members. The
# reader's question is "which ones are wrong", and a sample of
# the majority cannot answer it.