fix(ledger): the proposer prefers a same-project canon on a tie — family canon elsewhere is the fallback, not the first hit
CI & Build / Python lint (push) Successful in 5s
CI & Build / Plugin hooks (push) Successful in 9s
CI & Build / integration (push) Successful in 35s
CI & Build / TypeScript typecheck (push) Successful in 37s
CI & Build / Python tests (push) Successful in 1m17s
CI & Build / Build & push image (push) Successful in 40s
CI & Build / Python lint (push) Successful in 5s
CI & Build / Plugin hooks (push) Successful in 9s
CI & Build / integration (push) Successful in 35s
CI & Build / TypeScript typecheck (push) Successful in 37s
CI & Build / Python tests (push) Successful in 1m17s
CI & Build / Build & push image (push) Successful in 40s
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -190,9 +190,24 @@ def test_text_containment_is_whitespace_insensitive_with_a_floor():
|
||||
assert not text_contains("x = 1", "x = 1") # below the substance floor
|
||||
|
||||
|
||||
def _canon(sid, kind="sym", symbol="", locations=(), signature="", code=""):
|
||||
def _canon(sid, kind="sym", symbol="", locations=(), signature="", code="", project_id=0):
|
||||
from scribe.services.shape_ledger import Canon, _norm_text
|
||||
return Canon(sid, kind, symbol, tuple(locations), signature, _norm_text(code))
|
||||
return Canon(sid, kind, symbol, tuple(locations), signature, _norm_text(code), project_id)
|
||||
|
||||
|
||||
def test_match_canon_prefers_the_shapes_own_project_on_a_tie():
|
||||
"""The same helper recorded in two projects: the shape's own project's
|
||||
record is its canon; family canon elsewhere is the fallback."""
|
||||
from scribe.services.shape_ledger import match_canon
|
||||
family = _canon(3, "sym", "slugify", [("lib/text.py", "slugify")], project_id=1)
|
||||
own = _canon(4, "sym", "slugify", [("src/util/text.py", "slugify")], project_id=2)
|
||||
assert match_canon("sym", "src/other.py", "slugify", "def slugify(t):", "",
|
||||
[family, own], project_id=2) == (4, "symbol", 1.0)
|
||||
assert match_canon("sym", "src/other.py", "slugify", "def slugify(t):", "",
|
||||
[family, own], project_id=1) == (3, "symbol", 1.0)
|
||||
# No project given → first-best stands; nothing breaks.
|
||||
assert match_canon("sym", "src/other.py", "slugify", "def slugify(t):", "",
|
||||
[family, own])[1] == "symbol"
|
||||
|
||||
|
||||
def test_match_canon_orders_bases_strongest_first_and_respects_kind():
|
||||
|
||||
Reference in New Issue
Block a user