Repository navigation
fix(matching): tf: true with no exact level published fine and failed every run - #616
Merged
Merged
Conversation
…ed every run
Term-frequency adjustment scales against the exact-match level's u probability.
`er-compile` attaches the adjustment to a comparison's FIRST declared level
whenever `tf: true`, without requiring that level to be an exact match, and at
scoring time `scoring::u_probability_for_tf_base` searches for a sibling level
that is an exact match on exactly the TF column and errors when there is none.
Nothing checked for one — not `er-config`, not `config_check`, not the
compiler. Proven end to end before fixing, against the committed fixture with
`given_name`'s exact level removed and its `tf: true` left in place:
config_reference_problems -> [] (publish allowed)
er_compile::compile -> Ok (compiles cleanly)
match_weight_parts_sql -> Err("comparison 'given_name': tf adjustment
on level 'jaro_winkler_similarity(...) >= 0.9'
requires an exact-match level on column
'given_name'")
So a tenant could publish a config that failed the scoring stage on every
subsequent run. The same shape as the constraint-column hole directly above the
new check, whose comment is the better description: the run failed "loudly, but
minutes later and inside the tenant's pipeline rather than at the publish that
introduced it".
Only the `exact` token qualifies as the base. Every other comparator either is
not an equality (`variant_match`, `jaro_winkler:`, `levenshtein:`) or compares
a derived expression rather than the bare columns (`username_exact`,
`domain_exact`, `first_n:`, `dob_same_year_month`), and `exact_match_columns`
detects only an equality of two bare columns. The engine's escape hatch,
`disable_tf_exact_match_detection`, is not reachable from a tenant config. All
eight committed configs that set `tf: true` already declare `exact` first, so
the refusal rejects nothing that exists.
The regression test keeps the proof: one case asserts the publish refusal, and
a second compiles the bad config and asserts the engine's own error, which is
the positive control for why the gate exists — if `u_probability_for_tf_base`
ever grows a fallback, the refusal becomes over-strict and that test says so.
Alongside it, the advisory this started out as: `profile_advisories` now
recommends `tf: true` where it would change scores materially. The spread comes
from the scoring SQL rather than from the idea of TF —
weight * ( log2(u_exact) - log2(greatest(tf_l, tf_r, minimum_u_value)) )
so a value of relative frequency p is adjusted by weight * log2(u_exact / p),
and comparing the commonest value against a typical one gives
weight * log2(n_max / n_avg). `u_exact` cancels, which is what makes it
answerable from a profile alone.
It is a SKEW and not a span, and two existing tests are why. The first draft
compared the mode against a hypothetical one-off, giving log2(n_max), which
grows with the corpus: it fired on a column whose commonest value covered 2% of
a 100,000-row table and would have fired on nearly every column in any large
corpus. Measuring against the average frequency is scale-free and asks the
question that decides the matter — on a uniform column TF shifts every value by
the same amount and discriminates nothing. A regression test uses the numbers
that exposed it.
Also corrects the two refusal wrappers. The publish path said "config
references columns the standardized schema does not have", which already
misdescribed the ensemble and survivorship checks and would have misdescribed
this one; a reader goes looking for a typo that is not there. Both now say what
they actually reject and let each problem speak for itself.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Term-frequency adjustment scales against the exact-match level's u probability.
er-compileattaches the adjustment to a comparison's first declared level whenevertf: true, without requiring that level to be an exact match — and at scoring timescoring::u_probability_for_tf_basesearches for a sibling level that is an exact match on exactly the TF column, and errors when there is none.Nothing checked for one: not
er-config, notconfig_check, not the compiler.Proven before fixing
Against the committed fixture with
given_name'sexactlevel removed and itstf: trueleft in place:So a tenant could publish a config that failed the scoring stage on every subsequent run. It is the same shape as the constraint-column hole directly above the new check, whose own comment is the better description: the run failed "loudly, but minutes later and inside the tenant's pipeline rather than at the publish that introduced it."
Why only
exactqualifiesEvery other comparator either is not an equality (
variant_match,jaro_winkler:,levenshtein:) or compares a derived expression rather than the bare columns (username_exact,domain_exact,first_n:,dob_same_year_month), andexact_match_columnsdetects only an equality of two bare columns. The engine's escape hatch,disable_tf_exact_match_detection, is not reachable from a tenant config.All eight committed configs that set
tf: truealready declareexactfirst, so the refusal rejects nothing that exists.The regression test keeps the proof in two parts: one asserts the publish refusal, and a second compiles the bad config and asserts the engine's own error. The second is the positive control for why the gate exists — if
u_probability_for_tf_baseever grows a fallback, the refusal becomes over-strict and that test says so.The advisory this started out as
profile_advisoriesnow recommendstf: truewhere it would change scores materially. The spread is taken from the scoring SQL rather than from the idea of TF:so a value of relative frequency
pis adjusted byweight * log2(u_exact / p), and comparing the commonest value against a typical one givesweight * log2(n_max / n_avg).u_exactcancels, which is what makes it answerable from a profile alone — no estimate of the collision probability needed, only two counts the profile already has.It is a skew, not a span — and two existing tests are why
The first draft compared the mode against a hypothetical one-off, giving
log2(n_max). That grows with the corpus: it fired on a column whose commonest value covered 2% of a 100,000-row table, and would have fired on nearly every column in any large corpus. Measuring against the average frequency instead is scale-free, and it asks the question that actually decides the matter — on a uniform column TF shifts every value by the same amount and discriminates nothing. A regression test uses the numbers that exposed it.Two refusal wrappers corrected
The publish path said "config references columns the standardized schema does not have". That already misdescribed the ensemble and survivorship checks and would have misdescribed this one — a reader goes hunting for a typo that is not there. Both wrappers now say what they actually reject and let each problem speak for itself. Nothing asserted the old wording.
Verification
make checkgreen from the repo root — 838 tests, 0 failures; entities current, skills-check ok.config_checkis at 35 tests, up from 29. Re-verified after rebasing onto a main that had moved 8 commits: entity verify clean,config_check35/35,er-compile17/17.🤖 Generated with Claude Code