Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
e364b7a
fix(importers): resolve unstated threshold and clip as the Python pat…
sromoam Oct 15, 2026
adbda67
fix(importers): credit a zero threshold to the comparator only when i…
sromoam Oct 16, 2026
3637981
Merge origin/dev into fix/334-348-importer-defaults
sromoam Oct 28, 2026
530e77f
test: pin the free-form clip default from #334 in the extension refer…
sromoam Oct 28, 2026
ede3216
Merge remote-tracking branch 'origin/dev' into m408
sromoam Oct 29, 2026
60703e0
fix(334): name an adopted comparator threshold in the explain() trail
sromoam Oct 29, 2026
626f6dd
fix(348): resolve comparator keys on a nested model as the Python pat…
sromoam Oct 29, 2026
7dfab62
docs(348): document the nested-model comparator warning and the new d…
sromoam Oct 29, 2026
83f1556
docs(348): say the nested-object default threshold is fixed, not the …
sromoam Oct 30, 2026
6e51532
fix(348): plural warning verbs, keep ValueError for a list comparator…
sromoam Oct 30, 2026
fe8b830
Merge origin/dev into fix/334-348-importer-defaults
sromoam Nov 17, 2026
c6878eb
fix(importers): check an adopted comparator threshold and resolve nes…
sromoam Nov 17, 2026
2934248
docs(importers): state the threshold and clip defaults the importers …
sromoam Nov 17, 2026
dad0ca9
fix(importers): load a comparator that requires threshold on an array…
sromoam Nov 17, 2026
f7a4640
test(importers): pin the union, nested-warning and explain() behaviou…
sromoam Nov 17, 2026
1caa1cb
docs(importers): correct the free-form clip, nested comparator and wa…
sromoam Nov 17, 2026
ff19b01
docs(importers): scope the free-form clip claim to each object, and n…
sromoam Nov 17, 2026
a7ab802
docs(thresholds): state that an invalid field threshold raises, on ev…
sromoam Nov 17, 2026
09dcedd
fix(thresholds): raise on a field threshold that is not a number from…
sromoam Nov 17, 2026
a17802c
test(thresholds): pin the raise for an invalid field threshold on eve…
sromoam Nov 17, 2026
4f0fb4a
docs(thresholds): one message per path, int or float only, match_thre…
sromoam Nov 17, 2026
f5ad746
fix(thresholds): check Annotated fields, quote values as written, no …
sromoam Nov 17, 2026
3991537
test(thresholds): pin the per-path messages, Annotated, postponed ann…
sromoam Nov 17, 2026
be9b0b0
fix(thresholds): load an in-range Decimal, Fraction or numpy threshol…
sromoam Nov 17, 2026
d78cb3c
fix(thresholds): give every threshold message a fix, and the list ref…
sromoam Nov 17, 2026
526061b
fix(thresholds): check a forward-referenced field when the class is d…
sromoam Nov 17, 2026
7aa8375
docs(thresholds): a number from 0.0 to 1.0, on the class, config and …
sromoam Nov 17, 2026
55e4023
fix(thresholds): keep the runtime match_threshold check of evaluate()…
sromoam Nov 17, 2026
1654b58
fix(thresholds): check forward-referenced lists, keep numpy verdicts,…
sromoam Nov 17, 2026
32febb2
fix(importers): name a titled schema's model in its warnings, and say…
sromoam Nov 17, 2026
89b7e07
docs(thresholds): scope the runtime check, forward-referenced lists, …
sromoam Nov 17, 2026
9794614
docs(thresholds): a bare alias name for a list is ignored once resolv…
sromoam Nov 17, 2026
9d4a8a5
chore: merge origin/dev into fix/334-348-importer-defaults
sromoam Nov 17, 2026
0cad533
fix(thresholds): check an Annotated field whose type is defined furth…
sromoam Nov 17, 2026
4e59553
docs(thresholds): numpy float16 and float32 compare as Python floats,…
sromoam Nov 17, 2026
f7c7782
fix(auto): a runtime match_threshold=False does not warn that the thr…
sromoam Nov 17, 2026
60cc3a2
fix(thresholds): correct the threshold messages whose advice was wron…
sromoam Nov 17, 2026
d77fb56
docs(thresholds): scope the numpy, runtime, class match_threshold and…
sromoam Nov 17, 2026
e9228d7
fix(thresholds): evaluate Annotated metadata as pydantic does, once p…
sromoam Nov 17, 2026
44d21f9
fix(thresholds): a list-of-models message no longer tells an element …
sromoam Nov 17, 2026
96f5567
fix(thresholds): an unresolved dict or tuple gets the usual fix, and …
sromoam Nov 17, 2026
c4612ba
docs(thresholds): scope the Python list warning, name match_threshold…
sromoam Nov 17, 2026
9b2b5a9
docs(changelog): rewrap the threshold-rule paragraph
sromoam Nov 17, 2026
3a18858
test(thresholds): pin that a numpy float16 or float32 match_threshold…
sromoam Nov 17, 2026
cb26400
test(thresholds): drop the postponed Annotated case from the dict-or-…
sromoam Nov 17, 2026
8ce3b28
Revert "fix(thresholds): evaluate Annotated metadata as pydantic does…
sromoam Nov 17, 2026
5d85b9b
Revert "fix(thresholds): check an Annotated field whose type is defin…
sromoam Nov 17, 2026
605ea32
docs(thresholds): an Annotated field written as a string that names s…
sromoam Nov 17, 2026
a5230d5
fix(thresholds): a class loads when the working directory no longer e…
sromoam Nov 18, 2026
d86e94e
docs(importers): a threshold a custom comparator's constructor sets i…
sromoam Nov 18, 2026
43579b1
docs(thresholds): scope the Annotated, numpy float64 and array-sentin…
sromoam Nov 18, 2026
2b8d1b0
fix(evaluate): a runtime match_threshold of any real type in range is…
sromoam Nov 18, 2026
f7149a4
docs(thresholds): scope the Set at, None and unread-key claims
sromoam Nov 18, 2026
a93086a
docs(changelog): give the TP-to-FD example for a comparator's constru…
sromoam Nov 18, 2026
726726f
ci(thresholds): mark the test's exec calls reviewed, and skip the mad…
sromoam Nov 18, 2026
f0800a4
Merge origin/dev into fix/334-348-importer-defaults
sromoam Nov 23, 2026
b78859f
test(thresholds): patch in the NaN threshold the report test needs
sromoam Nov 23, 2026
e7ccbdc
test(thresholds): name the bool match_threshold test for the refusal …
sromoam Nov 23, 2026
619b714
fix(importers): name the model in the nested-model warnings as the er…
sromoam Nov 23, 2026
006f558
Merge dev into fix/334-348-importer-defaults
sromoam Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs(importers): a threshold a custom comparator's constructor sets i…
…s adopted too

On a config or schema scalar, a registered comparator whose constructor
passes a threshold to super().__init__() now gates the field, over 0.5 or a
schema type default such as 1.0 for an enum, as ComparableField(comparator=...)
already did. The CHANGELOG, README, Evaluation guide, module README and the
model_from_json, ModelFactory and from_json_schema docstrings named only a
comparator-config threshold. No built-in comparator sets one when built bare,
so fields naming one do not move. A parity test pins the four shapes.
  • Loading branch information
sromoam committed Nov 18, 2026
commit d86e94e5ebb23f3e98fcf8cc194c3106d4879aaf
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ Each release links to full notes on the
`x-aws-stickler-comparator-config`) with no field `threshold` gated at the
importer's own default instead (0.5 for a string), so a pair scoring 0.78
was a TP there and an FD in Python. It is 0.9 on all
three paths now. A field threshold still wins, and a comparator threshold
three paths now. The same goes for a threshold a custom comparator's
constructor passes to `super().__init__()`, which
`ComparableField(comparator=...)` already adopted: a field that names that
comparator and no threshold moves from the importer's default, 0.5 or a
schema type default such as 1.0 for an enum, to that value. No built-in
comparator passes one when built without a threshold, so fields naming
one do not move. A field threshold still wins, and a comparator threshold
outranks an inferred one. This includes a `structured_model` or
`optional_structured_model` field and an object with `properties`, where
`ComparableField(comparator=X(threshold=0.9))` also gates at 0.9; the
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ even though the field on the built class ends up a plain `str` — read the choi

**Type:** `number` (0.0 to 1.0, inclusive)
**Required:** No
**Default:** a `threshold` in `x-aws-stickler-comparator-config`, unless the property is an
array of models. Otherwise position-dependent, not one number. `0.5` for a plain scalar, an array of plain
**Default:** a threshold named on the comparator, in `x-aws-stickler-comparator-config` or by a
custom comparator's constructor, unless the property is an array of models. Otherwise position-dependent, not one number. `0.5` for a plain scalar, an array of plain
scalars, and an array of models; `0.7` for an object with `properties`; `1.0` for a free-form
`{"type": "object"}` (or an array of them) and for any property or array `items` with `enum`,
`const`, or a string `format` of `date`/`date-time`/`uri`/`uuid`/`time`, whether or not a
Expand Down
7 changes: 4 additions & 3 deletions docs/docs/Guides/Evaluation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ on the position, because different positions fall back to different defaults:

A scalar is plain when it has none of the keywords in the last row. Any other
`format` (`email`, `hostname`, ...) leaves it plain. Declaring the key explicitly
overrides the default in every position that reads it. Without it, a `threshold`
in `x-aws-stickler-comparator-config` overrides the default instead, as it does
on the Python path. Whichever the field uses must be a number from 0.0 to 1.0;
overrides the default in every position that reads it. Without it, a threshold
named on the comparator, in `x-aws-stickler-comparator-config` or by a custom
comparator's constructor, overrides the default instead, as it does on the
Python path. Whichever the field uses must be a number from 0.0 to 1.0;
any other value raises `ValueError` on import, quoting the key as written:

```text
Expand Down
2 changes: 1 addition & 1 deletion src/stickler/structured_object_evaluator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ result = gt.compare_with(pred)

- `x-aws-stickler-comparator`: comparator **class name**, such as `"ExactComparator"`, `"FuzzyComparator"`, `"LevenshteinComparator"`, `"SemanticComparator"`. Lowercase aliases are not accepted and raise.
- `x-aws-stickler-comparator-config`: keyword arguments for that comparator's constructor
- `x-aws-stickler-threshold`: matching threshold, 0.0 to 1.0 (default: a `threshold` in `x-aws-stickler-comparator-config`, else the type default). Whichever the field uses must be a number from 0.0 to 1.0, or the import raises `ValueError` naming the model, the field and the key as written
- `x-aws-stickler-threshold`: matching threshold, 0.0 to 1.0 (default: a threshold named on the comparator, in `x-aws-stickler-comparator-config` or by a custom comparator's constructor, else the type default). Whichever the field uses must be a number from 0.0 to 1.0, or the import raises `ValueError` naming the model, the field and the key as written
- `x-aws-stickler-weight`: field importance weight (default: 1.0)
- `x-aws-stickler-clip-under-threshold`: clip scores below threshold to 0.0 (boolean, default: true; false on a free-form object or an array of them)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def create_model_from_json(
"type": "str|int|float|bool|List[str]|etc.", # Required
"comparator": "LevenshteinComparator|ExactComparator|etc.", # Optional
"comparator_config": {"threshold": 0.9}, # Optional; a threshold the field adopts must be a number from 0.0 to 1.0, else ValueError
"threshold": 0.8, # Optional; default: comparator_config's threshold, else 0.5
"threshold": 0.8, # Optional; default: a threshold named on the comparator (comparator_config or a custom constructor), else 0.5
"weight": 2.0, # Optional, default 1.0
"required": true, # Optional, default false
"default": "value", # Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ def model_from_json(cls, config: Dict[str, Any]) -> Type["StructuredModel"]:
"type": "str|int|float|bool|List[str]|etc.", # Required
"comparator": "LevenshteinComparator|ExactComparator|etc.", # Optional
"comparator_config": {"threshold": 0.9}, # Optional; a threshold the field adopts must be a number from 0.0 to 1.0, else ValueError
"threshold": 0.8, # Optional; default: comparator_config's threshold, else 0.5
"threshold": 0.8, # Optional; default: a threshold named on the comparator (comparator_config or a custom constructor), else 0.5
"weight": 2.0, # Optional, default 1.0
"required": true, # Optional, default false
"default": "value", # Optional
Expand Down Expand Up @@ -1362,8 +1362,10 @@ def from_json_schema(cls, schema: Dict[str, Any]) -> Type["StructuredModel"]:
- x-aws-stickler-comparator: Comparator algorithm name (built-in or registered custom)
- x-aws-stickler-comparator-config: Keyword arguments for that comparator
- x-aws-stickler-threshold: Similarity threshold for match/no-match (0.0-1.0,
default: a threshold in x-aws-stickler-comparator-config, else the
type default, such as 0.5 for a string and 0.7 for a nested object).
default: a threshold named on the comparator, in
x-aws-stickler-comparator-config or by a custom comparator's
constructor, else the type default, such as 0.5 for a string and 0.7
for a nested object).
Whichever threshold the field uses must be a number from 0.0 to 1.0;
any other value raises ValueError naming the model and the field.
- x-aws-stickler-weight: Field importance in overall scoring (>0.0, default: 1.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ def test_a_schema_config_without_a_comparator_name_still_reaches_it(self):
)
assert _info(sch).threshold == 0.9

def test_one_a_custom_comparators_constructor_sets_reaches_it(self, strict95):
"""As in Python, over the importer's 0.5 and a schema type default."""
enum = {"type": "string", "enum": ["a", "b"]}
models = {
"python": _python(str, ComparableField(comparator=_Strict95())),
"config": _config({"type": "str", "comparator": strict95}),
"schema": _schema({"type": "string", "x-aws-stickler-comparator": strict95}),
"schema enum": _schema({**enum, "x-aws-stickler-comparator": strict95}),
}
assert {n: _info(m).threshold for n, m in models.items()} == dict.fromkeys(
models, 0.95
)

def test_it_outranks_an_inferred_threshold(self):
"""Field, then comparator, then inference: the author wrote it."""
cfg = _config(
Expand Down