fix(s31): close 2 review findings — drop description from the embedding + re-derive SC2 on the minted shape

This commit is contained in:
Kjell Tore Guttormsen 2026-07-25 12:31:06 +02:00
commit 969d450b31
3 changed files with 172 additions and 43 deletions

View file

@ -80,14 +80,26 @@ def _magnitude_bucket(value: float) -> int:
def _canonical_feature_string(features: ProposalFeatures) -> str:
"""Order-independent textual projection of the features. ``affected_codes`` is a set, so it
is sorted; the raw saving is bucketed so near-identical amounts land on the same point."""
"""Order-independent projection of the STRUCTURAL triple: sorted ``affected_codes``, the
measure type, and the magnitude bucket. ``affected_codes`` is a set, so it is sorted; the raw
saving is bucketed so near-identical amounts land on the same point.
``description`` is deliberately EXCLUDED, matching the two invariants that already govern this
data: ``verdicts.similarity`` ("text is ignored by design") and ``verdicts._mint_id``, which
hashes the same three fields so two proposals differing only in prose already share one id
and one structural score. Including description here made the embedding the single place where
surface text leaked into retrieval, which inverted the feature's purpose: on a mixed store the
framework's own echo of the query outranked genuine expert prose.
Honesty limit, stated at the site: over a structural tie the cosine ordering is deterministic
but semantically ARBITRARY, because the shipped ``FakeEmbedder`` is a sha256 projection with no
semantics. Retrieval *quality* arrives only with an injected embedder the seam is the
deliverable, not better ranking."""
return "|".join(
(
",".join(sorted(features.affected_codes)),
features.measure_type,
str(_magnitude_bucket(features.claimed_saving_nok)),
features.description,
)
)