Repository navigation
Conversation
`eval_for()` accepted a `RootModel` and returned a spec. What happened next depended on the root type, and one of the four outcomes was silent: RootModel[list[Point]] AttributeError: 'list' object has no attribute 'keys' RootModel[int] AttributeError: 'int' object has no attribute 'copy' RootModel[dict[str, int]] ValidationError, missing `root` RootModel[Point] scored 1.0 for two values differing in every field The three errors came from `ConfigurationHelper.from_json`, where the dump of a root value arrives as something other than a mapping. They arrived once per document rather than once at configuration time, and named neither `RootModel` nor the field they could not key. The fourth reported a perfect match for a wrong prediction, which is the outcome worth closing. The check sits beside the `BaseModel` guard already at the top of `structured_model_for`, so both public entry points inherit it: `eval_for` reaches it for anything that is not a `StructuredModel`, and `evaluate()` calls `eval_for`. The message names the class and points at declaring the root value as a named field on a `BaseModel`. Issue #366 offered two directions and called the refusal useful on its own even if root-value comparison stays out of scope. This takes that one: a root value is still not compared, and a `RootModel` held in a field is untouched, since it fails on its own terms with a pydantic `ValidationError` that names the field. Suite: 2793 passed, 12 skipped, 1 xfailed, against 2779 on dev. Closes #366
`run_pytest.yaml`, `lint.yaml` and `security.yaml` all declared `on: [push, pull_request]`. On a branch in this repository with an open pull request both events fire, so every push validated the same commit twice. On `854fc00e` (PR #384) that is six runs of three workflows, fourteen jobs: ten tests, two lint, two security. The two copies are not guaranteed to agree, which is the sharper reason to drop one. On that same commit the `pull_request` copy passed all five Python versions while the `push` copy failed 3.10, on a wall-clock assertion that measured 41.69s against a 35s budget. One commit, two verdicts. `push` is now limited to `dev` and `main`, which keeps those branches validated while a pull request from a feature branch reports through `pull_request` alone. A pull request whose head is `dev`, as a release promotion to `main` would be, still fires both. `run_pytest.yaml` and `lint.yaml` also take a concurrency group so a superseded pull-request head stops running. A push gets a group of its own, keyed on `github.run_id`: a group holds one running and one pending run, so sharing a group per branch would let a third push cancel the pending one no matter what `cancel-in-progress` says, and that flag only protects the run already executing. `security.yaml` takes the trigger change and no concurrency. `security-pr-comment.yaml` wakes on its completion, a cancellation included, and downloads the `security-reports` artifact; a cancelled scan uploads none, and that consumer fails rather than skipping on a missing artifact, as it did on `b32d3ffd`. Limiting `push` already removes the duplicate run. No behaviour change to the library, so there is no CHANGELOG entry.
Use contextlib.redirect_stdout to ensure sys.stdout is always restored, even when an error occurs during file writing. Previously, any exception between stdout reassignment and restoration would leave stdout pointing at a closed file, breaking all subsequent print() calls in the process. Also catch only OSError from open() instead of all exceptions, and add missing bulk_info_summary to file output branch. Fixes #385
Remove OSError narrowing and bulk_info_summary addition from the previous commit to focus solely on fixing the stdout restoration bug described in issue #385.
calculate_list_confusion_matrix, calculate_nested_field_metrics and calculate_single_nested_field_metrics only called each other, and their only way in was three StructuredModel wrappers that nothing calls. All six had zero executed lines across the full suite. Remove them, the HungarianHelper, NonMatchesHelper and List imports that only they used, and the refactoring notes that listed the wrappers. StructuredListComparator._calculate_nested_field_metrics is a separate, live method with the same name and is untouched. So are ConfusionMatrixCalculator.__init__, classify_field_for_confusion_matrix and StructuredModel._classify_field_for_confusion_matrix, which StructuredListComparator calls. The 1e-10 threshold window that algorithms/README.md and the HungarianMatcher.calculate_metrics docstring attribute to ConfusionMatrixCalculator lived in the deleted calculate_nested_field_metrics. The method that remains compares with a bare >=, so both now name only ThresholdHelper and ComparisonHelper. Also run ruff format on the calculator file, which only strips the trailing whitespace from 9 blank docstring lines. Closes #296
Review on #384 (digalaviz): - A declared comparator is now called for any pair of non-structured values, in both compare_with() and compare(). The strict scalar list applies only to an inferred comparator, where an arbitrary object would reach Levenshtein as a near-identical repr. This restores compare() for bytes and custom classes, and fixes compare_with() for them. ComparableFieldConfig carries comparator_explicit, read from the same _comparator_explicit bit the object-grade substitution uses. - Drop Tuple/Set: no set ordering, no tuple/set branch, and an empty tuple or set is no longer absent. Inferred-comparator tuples and sets keep their pre-#383 behaviour in each reader, tracked in #391. With a declared comparator they arrive as the caller supplied them, so a set-aware comparator works. - Mark the CHANGELOG entry Breaking and list what moves for existing callers; scope the stickler.evaluate() sentence to the zero-config path. #392 tracks merging the two readers.
…nfusion-matrix-code refactor(296): remove the dead ConfusionMatrixCalculator methods
chore(ci): validate a pull request commit once, not twice
ErrorCaptureAtBudgetMetric keys budgets with strings such as "0.10" so the dict round-trips through JSONL, and cell 11 of the notebook applied the % format code to those strings, so it raised ValueError: Unknown format code '%' for object of type 'str'. Convert the key with float() before formatting, as the confidence metrics docs already do. Store the outputs of a full run, so a reader sees the real numbers.
fix(383): let date, Decimal, UUID, Enum, tuple and set fields reach their comparator
A None element in a list is now left out before matching: it is never paired, counted or scored, and a list of only None is an empty list. A float NaN element counts as None; an empty string is still a value. This holds for list fields of models and of primitives, in compare_with() and compare(), and reports keep each element's original index. Counting a None as an element credited two of them as a true positive and counted a missed row as a false discovery (or, in a list of models, a true positive), so recall stayed at 1.0. It also removes the order dependence of List[Optional[Model]]: element kind and the Hungarian match_threshold were read from [0], so a leading None skipped the class gate (#386) and took the parent's threshold (#322). The rule is defined in docs/docs/Advanced/classification-logic.md, "None elements in a list". Closes #386. Closes #322.
The guard read the class passed in and nothing below it, so a `RootModel` held in a field or as a list element still reached the builder. Both produced a shadow carrying a single `root` field that no dumped value ever filled: both sides read None, and two values differing in every field scored 1.0. That is the same silent outcome the top-level refusal closed. The check now sits at the top of `_build`, which assembles the shadow class for every model the zero-config builder mirrors, beside the refusals for a recursive graph, a reserved field name and a model with no fields. One check covers the class passed in and every model reached from it, at any depth. `_build`, `_field_definition` and `_shadow_for` carry a `_path` argument so the message names the field rather than only the class: `Holder.pt` for a field, `Holder.items[]` for a list element, since the two reach the builder through different branches. The builder descends through a nested model and a `List[BaseModel]` element, and those are exactly the positions that carried the bug. A `RootModel` reached only through a `Dict` value, a `Tuple`, a `Set` or a union is still built, unchanged, because it is compared as canonical JSON rather than mirrored: two differing values score 0.0 to 0.667 there, never a false 1.0. The previous commit said a `RootModel` held in a field was untouched because it failed on its own terms with a pydantic `ValidationError` naming the field. That holds for `RootModel[list[...]]`, which raised once per document, and not for `RootModel[Model]`, which raised nothing and scored 1.0. The test that asserted it is inverted here, and the CHANGELOG entry corrected. An explicitly configured `StructuredModel` is returned as configured and never mirrored, so the refusal does not reach inside one: its fields keep the comparators the caller declared. `auto/README.md` records that boundary, and that the order of the refusals is not a precedence guarantee, since a model tripping two of them reports whichever its fields reach first.
fix(366): refuse a RootModel when the evaluator is built
…bsent `print_non_matches` and `print_evaluation_results` printed "No non-matches found - all fields matched successfully!" for `EvalResult.raw` or any `compare_with()` dict computed without `document_non_matches=True`, including one with a wrong field. Such a dict has no `non_matches` key, and the printers fell back to `confusion_matrix["non_matches"]`, a placeholder the engine always writes empty. `_extract_non_matches` now returns None when the results carry no records, distinct from an empty list, and only trusts a populated placeholder. Missing records print a note naming `document_non_matches=True`; an empty list prints "No non-matches found." without the `all_fields_matched` wording removed in #287. A bulk `ProcessEvaluation` built with `document_non_matches=False` gets the same note. Closes #298.
`to_json_schema()` fell back to `{"type": "string"}` for a list element it
did not recognise, so `List[Dict[...]]` re-imported as `List[str]` and the
round-tripped model raised `ValidationError` on the data the original
accepted. A mapping element now exports as `{"type": "object"}` (nullable
when the element is optional), which the importer reads back as `dict`.
The exported clip setting already matches what the field resolves to: the
object-grade substitution writes it into the metadata the exporter reads, so
with the items typed correctly the round trip scores as the original did.
Tests pin both, plus the stickler-config path.
Closes #333.
…lResult.raw Review follow-ups on the #298 fix. - `print_non_matches` on input that is not a result (an arbitrary object, None, a bare list of records) printed the "pass document_non_matches=True" note, which sends the owner of a list of records after something they already did. It now prints an error, as `print_confusion_matrix` does. - The note now names the remedy for `EvalResult.raw` first: `evaluate()` takes no `document_non_matches`, so passing the `EvalResult` itself is the only actionable advice for the issue's own case. - CHANGELOG: an `evaluator_format=True` dict always carries a `non_matches` list, so it still prints the success line without records. Say so rather than claim every `compare_with()` dict is covered. - Docstring note moved above `Args`. - Tests: non-result input, bulk with records and no failures, and the EvalResult hint on `.raw`.
The CHANGELOG said to_stickler_config() already exported this shape as List[Dict]; it writes List[Mapping] for a Mapping element, which model_from_json() refuses. The docs paragraph sat under a both-methods heading without saying so, and neither text said the value type is lost (values are no longer coerced) or that a singular mapping field still exports as a string (#349). Kept-settings claims now name weight and are scoped to what ComparableField declared, since a bare field keeps nothing. Tests: assert weight survives, and pin the two documented limits so the docs fail when the shapes start working.
`CODEOWNERS` requested one person on every pull request, so every review in the queue waited on the same reviewer, and a change request could only be withdrawn by them. Adding the second maintainer to the default owner line is what makes the automatic request reach both. `MAINTAINERS.md` is the list `CONTRIBUTING.md` points contributors at, and its "Becoming a maintainer" section puts nomination and approval with the current maintainers, so this lands as a pull request for the existing maintainer to approve rather than as a direct commit.
strands-agents-evals 1.6.0 scores structured output with stickler (StructuredOutputSimilarity, StructuredOutputReport). Its suite pins a released stickler, so only a test here fails on the commit that breaks it. - tests/integrations/strands_corpus.py: five models covering the shapes users pass as structured_output_model, 42 cases, and a verbatim copy of 1.6.0's _passed gate. - test_strands_evals_contract.py (no strands dependency): import paths, eval_for kwargs, evaluate/explain shapes, every EvalResult attribute, that raw["confusion_matrix"]["overall"] carries integer tp/fa/fd/fp/tn/fn, recall = tp/(tp+fn), matched = score >= threshold, the nothing-to-find guard, and aggregate_from_comparisons on stripped and JSON-reloaded raws. - test_strands_evals_snapshot.py + strands_evals_snapshot.json: exact scores, verdicts and aggregate metrics for 40 typical cases. STICKLER_UPDATE_STRANDS_SNAPSHOT=1 regenerates it. - test_strands_evals_e2e.py: the real evaluator through Experiment, offline; skipped without strands_evals, fails if stickler is not this checkout. - CI: a strands-evals job installs strands-agents-evals==1.6.0 without its [stickler] extra and runs tests/integrations on Python 3.10 and 3.14. Refs #365.
The HTML report's Non-Matches Analysis section rendered "No non-matches found." for a compare_with() dict computed without document_non_matches=True, including one whose name field scored 0.0, and for a bulk ProcessEvaluation built with document_non_matches=False. DataExtractor.extract_non_matches returned [] both when records had been collected and were empty and when they were never collected, so the renderer had nothing to distinguish them by. It now returns None for the second case and the section says the records are missing and how to collect them. An empty list still renders the success message. tests/reporting/html/test_data_extractors.py pinned the conflation by asserting [] for a ProcessEvaluation whose non_matches is None; that assertion is now is None. Every other test in the directory patches the extractor, which is why the defect survived them, so the new coverage drives real comparison dicts and a real bulk evaluator through SectionGenerator without patching.
to_json_schema() and to_stickler_config() fell back to "string" / "str" for
any annotation missing from their type tables. A plain BaseModel, a list of
plain models and a list of lists all took that fallback, so the re-imported
field was str (or List[str], or an unknown type in the config) and could not
load the data the original model accepted. The guard meant to stop a nested
model reaching the fallback checked `isinstance(field_type, type)`, which is
False for Union[Card, Bank], so that union exported as "string" too.
from_json_schema() builds exactly that union from a multi-arm anyOf, so a
schema-only round trip broke.
- A plain BaseModel is scored as one object, as a mapping is, so it exports
as a free-form {"type": "object"} ("dict" in a Stickler config, List[dict]
for a list) and re-imports as dict with its comparison settings. Its own
field types are not exported.
- A list of lists exports as nested arrays, so List[List[float]] and
List[List[Dict]] reload. The element goes through the existing primitive
list branch, so that branch stays the one place that writes a list
property.
- to_stickler_config() has no type for a union with a model arm, or for a
StructuredModel inside a nested list, so both exporters raise ValueError
for these and follow one rule. JSON Schema could express the union (anyOf),
and that export could follow; a model inside a nested list would also
need importer work. Optional and
Annotated wrappers are stripped at every level before the check.
Mapping fields and List[Dict] elements are left alone here: the first is
handled in #360, the second in #405.
Refs #349 (parts B and C)
fix(298): stop reporting success when results carry no non-match records
fix: check documentation links on pull requests
docs(479): set a tolerance, not a threshold, in NumericComparator amount examples
…odel Merge dev (keep its LLMComparator Fixed bullet first) and apply the review wording: stickler.evaluate compares the five postal field names exactly only on a plain Pydantic BaseModel. A StructuredModel, even one passed to stickler.evaluate, keeps edit distance for a field without a comparator, as does a JSON Schema string. Say the same in the CHANGELOG bullet, and give ZipLookupComparator DEFAULT_THRESHOLD = 1.0 like the other two examples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- a bare int or float on a StructuredModel resolves to LevenshteinComparator, so inf vs -inf scores 0.75 - state it next to the default threshold table, with the one-line way to compare numbers as numbers - no scoring change: whether the default should change stays open in #579
…ispatcher (#406) * fix(400): classify a list item's primitive sub-field through the dispatcher `_handle_non_hierarchical_field` counted each matched pair's primitive sub-field by calling the field's comparator directly, skipping the guards `_dispatch_field_comparison` applies. A dict in an `Any` sub-field of a list item raised `TypeError` out of `compare_with()`, where the same field at top level warns and scores an FD. Route it through the dispatcher, as the hierarchical and simple-list branches already do, so the counts agree with the top-level path by construction. Counts also move, but not scores: with an inferred comparator, a tuple, set or `date` vs ISO string is an FD, not a TP; a list in an `Any` sub-field counts one per element; and a whitespace-only string is a value, not null. Closes #400. * fix(400): widen the CHANGELOG and tests to every path the guard covers The crash is not Any-only: a Union sub-field, or a Dict one with an explicit LevenshteinComparator, raised too. bytes, arbitrary objects and plain pydantic models under a refused comparator also moved from TP to FD. Adds those cases, a whitespace-vs-None case, and a check that the counts now agree with non_matches. * fix(400): read list sub-fields as top level does, and keep empty lists null Review follow-ups on the list path in StructuredListComparator: - Read a pair's sub-field with getattr(..., None), as top level does, and classify each pair on its GT item's own fields. A list holding more than one model class (a subclass, or List[Union[A, B]]) raised AttributeError. - Keep the nested `fields` the dispatcher returns for a model held in an Any or Union sub-field, so `aggregate` matches top level. - Read an empty list as null by its value, as the classification docs say. The dispatcher does so only for a list-annotated field, so routing an Any sub-field through it turned None vs [] and [] vs [] from TN into FA, FN or no count. Two absent values are a TN again, and an absent list facing a non-list reads as None. Two lists still count per element. * test(400): pin list sub-field counts instead of comparing two dispatcher calls The parity assertion compared two calls into the same dispatcher, so it passed whatever the dispatcher returned. Every row now expects literal counts, and new rows cover empty lists in an Any sub-field, a model's leaves in aggregate, and lists of mixed model classes. * refactor(400): delete the list sub-field classifier, which has no caller ConfusionMatrixCalculator.classify_field_for_confusion_matrix and its StructuredModel wrapper lost their last caller when the list path moved to the dispatcher. Drop them, the test that only exercised the wrapper, and their mentions in the component maps. * test(400): reword a comment the docs-drift guard flags Also keep the models README diff to the deleted file name. * docs(400): list every count the list path moves, and narrow the parity claim The Breaking entry now comes from a before/after matrix against dev: empty tuples, sets, bytes and whitespace against None, per-element list counts, model-valued verdicts and aggregate including other-class pairs, and the two crashes. Scores do not change for any input that ran before. classification-logic.md no longer says a list element's field follows the top-level rules without exception: a field only the prediction has is not counted inside a list. The different-classes box now says a nested object is scored on the fields both objects have. * fix(400): count a model of another class in a list sub-field as dev does Two models of different classes in an `Any` or `Union` sub-field of a list element were classified through the dispatcher, which scores them with `compare()`. That skips the fields the prediction lacks, so `Inner(a, b)` vs `Other(c)` and `Search` vs `Browse` went from FD to TP. Classify such a pair as dev did: the GT model's `compare_with()` score against the field's threshold, one TP or FD, with no nested fields. A model of the GT's class still takes the item's score, as at top level. Fixing `compare()` itself stays with #327. * fix(400): count every pair under aggregate when a sub-field mixes shapes When one pair of an `Any` sub-field held a model, the merged node kept that model's fields, and `AggregateMetricsCalculator` summed only them. A pair with flat counts, such as a model against `None` or a string, dropped out of `aggregate` and the root. GT `[Inner(x), Inner(y)]` vs `[Inner(x), None]` gave root `aggregate` tp3 tn1 instead of dev's tp3 fn1. Keep the subtree only when every pair has one. A mixed node is one leaf again, as on dev, so it loses the model's leaves but counts every pair. * test(400): pin a non-recursing compare_with override, update a docstring The override test passed through to `super().compare_with()`, so on dev it raised like the plain case and did not reproduce the reviewer's case. An override that returns a fixed score does: dev counts fd1, this branch tp1. The classification test's module docstring said only non-list sub-fields go through the dispatcher. `List[str]` and nested-model sub-fields do too, and a model of another class is classified by `compare_with()`. * docs(400): describe the other-class and mixed-shape counts, fix the extras line - classification-logic: drop the line saying two objects with no field in common score 1.0, since a list sub-field now counts them as dev did. The nested-lists note lists the two cases counted differently from top level: an undeclared extra field, and a model of another class in an `Any` or `Union` field. The extras line said "a field only the predicted element has", which is wrong for a subclass's own field. - CHANGELOG: name the cases that differ from top level instead of claiming parity and agreement with `non_matches`, widen the `AttributeError` bullet, and restrict "one per element" to two lists. - REFACTORING: count `_classify_field_for_confusion_matrix` among the removed methods, with its module. * fix(400): leave a list-annotated sub-field's other-class pairs to the dispatcher ad608ac classified two models of different classes by `compare_with()` in every non-nested sub-field. Dev did that only for a field that is not list-annotated. A list-annotated one, such as `Union[Search, Browse, List[str]]` or `Union[Any, List[str]]`, took the simple-list branch, which sent every pair to the dispatcher. So `Search(query="hotels")` vs `Browse(url="x.com")` there moved from TP with `aggregate` fn1 to FD, and `Inner(a, b)` vs `Other(c)` lost its fn2 leaves. Read the annotation first and use `compare_with()` only when the field is not list-annotated. A test pins both rows and the `Optional[Union[...]]` case, which is routed as a nested model, at the counts top level gives. * fix(400): read only a non-list sub-field's empty values by value 2c43b0e read an empty list as null by its value in every sub-field. The rule exists because the dispatcher reads `[]` as null only in a list-annotated field. In a list-annotated field, such as `Optional[Union[str, List[str]]]` or `Union[Any, List[str]]`, it also turned `""`, `{}` and NaN into `None`, which the dispatcher there reads as values. Counts moved off dev and top level: `None` vs `""` went from FA to TN, and `""` vs `["a", "b"]` from 1 FA to 2. Apply both value-reading rules, empty values and other-class models, only to a sub-field that is neither nested nor list-annotated. Every other sub-field goes straight to the dispatcher, as on dev. A test pins the list-annotated rows at the counts top level gives. * docs(400): scope the list sub-field rules to non-nested, non-list fields - classification-logic: the other-class rule applies to a field typed `Any` or `Union[A, B]`. An `Optional` union of models or a union with a list arm counts such a pair as top level does. List the mixed-shape `aggregate` case, which keeps one leaf per pair in an `Any` field and drops the other pairs in a nested or list-annotated one, and the empty-list case, which differs from a top-level `Any` field. Drop the case count. - CHANGELOG: scope the entry to sub-fields that are neither nested nor list-annotated, say those otherwise count as before, move the `AttributeError` fix out as applying to every sub-field, and list four cases that still differ from top level, including the mixed-shape leaf. - REFACTORING: say which sub-fields `_dispatch_pairs` reads by value. * test(400): pin a list against None in an Any sub-field at one FN The PR description lists it as unchanged from dev and pinned, but no test covered it. It is 1 FN on dev, on this branch and at top level. * docs(400): widen the AttributeError paragraph, and name the TP it now counts The crash also hit a list of models in an Any or object field, at top level or in a list element, against a list of non-models. Such a pair now takes its object-level verdict from compare(), so [Search] against [Browse] counts a TP while the field scores 0.0. Also note that a Pet against its subclass Cat stays a TP in an Any sub-field, as on dev. * docs(400): file the list sub-field entry under Fixed, not Breaking Every count it moves brings the list path in line with the documented rules, with top level and with the item's own score. No public name, default, accepted input or documented output changes, and the deleted ConfusionMatrixCalculator is an internal helper. * docs(400): say a subclass for its base is a TP in an Any sub-field compare_with() scores only the ground truth's own fields, so Pet against Cat scores 1.0, as the different-classes warning already says. Same on dev. * test(400): pin the base-first list, the other-class pair TP and the wider crash Each case the CHANGELOG now names: a base-first list counts the subclass's fields, a Search against a Browse pairs as a TP at score 0.0, and a list of models in an Any, object or Union[Any, List[str]] field against non-models no longer raises. All 15 fail on dev. * refactor(400): drop a model check no matched pair can fail Scoring the list calls each matched ground-truth item's compare_with(), so a list mixing a model with a non-model raises there, before the field metrics filter pairs. The filter's isinstance check was unreachable. Pin that raise, at top level and in a list element, so a fix to it revisits the filter. * test(400): pin an other-class pair at the default threshold as a TP compare_with() reads a field the prediction lacks as None, so Inner(a="x") against Other(c="z") scores 0.5 on the unset b and is a TP at the default threshold of 0.5, in an Any sub-field. The same on dev. * docs(400): say an other-class pair whose unset field matches is a TP compare_with() reads a field the prediction lacks as None, so a ground-truth field left None matches it. Inner(a="x", b=None) against Other(c="z") scores 0.5 and is a TP at the default threshold in an Any sub-field, as on dev. The docs said only that such a pair scores 0.0. * docs(400): name the list pairing TP in the different-classes warning The warning covered only two StructuredModel objects scored field by field. In a list of models, pairing uses compare(), so [Search] against [Browse] counts a TP at score 0.0, and a model paired with a non-model element, such as [Inner] against ["a"] in an Any or object field, is a TP the same way. * docs(400): name the fixed-score override row and the ground-truth crash With an element compare_with() that does not recurse, [Inner] against [{"a": "x"}] in an Any sub-field ran on dev as an FD and is now a TP, like the other model-against-non-model pairs. A ground-truth list mixing a model with a non-model still raises AttributeError; only the prediction side is fixed. * fix(400): keep a self-scoring non-model GT item out of field classification 2df3183 dropped the isinstance(StructuredModel) check on matched GT items, on the claim that scoring the list rejects any non-model first. A plain pydantic model or plain class with its own compare_with() passes scoring and then raised at the dispatcher or model_fields. Restore the check, drop the false comment, pin the run at top level and as a sub-field, and narrow the CHANGELOG to a value that has no compare_with(). * docs(400): name the List[Any] and other-class crash shapes, and the object scope The AttributeError fix also covers a list of models in a List[Any] field, and one against a list holding a model of another class. An object sub-field counts the other-class, mixed-shape and empty-list rows as an Any one does. Say so in the CHANGELOG, the Nested lists bullets and the different-classes warning, and pin each shape at top level and as a sub-field. * docs(400): say a whitespace string or empty tuple against [] is no longer a TN In an Any or object sub-field, [] and [None] read as null, so a value such as " ", (), set() or b"" against them moves from TN to FN (the reverse FA), as it does against None. Name it in the CHANGELOG, and pin " " vs [] and [] vs () in both sub-field types. All four rows are TN on dev. * docs(400): call the fixed-score override row's TP unsettled, not fixed [Inner] vs [{"a": "x"}] in an Any sub-field, whose element class returns a fixed compare_with() score, ran before and counted an FD. It now counts the TP the pair counts without the override and at top level. That goes against the different-classes FD rule, and whether it stays is still open. Move it out of the list of fixes in the CHANGELOG, say in the different-classes warning that the model-vs-non-model TP is not decided, and mark the pinning test as today's verdict. Behaviour is unchanged. * docs(400): say the ground-truth raise needs a model first and a matched value The CHANGELOG said any ground-truth list mixing a model with a value that has no compare_with() still raises. It raises only when the first element is a model, so the list is scored as a list of models, and such a value is matched: ["b", Inner] against itself runs at 2 TP, and [Inner, "b"] against [Inner] at 1 TP and 1 FN. Narrow the sentence, pin the raise for a string, a number and a dict, and pin both inputs that run. * docs(400): list every null value an empty tuple or whitespace string now meets The CHANGELOG named None, [] and [None] as the null values that an empty tuple, set, bytes or whitespace string now counts an FN (or FA) against, but "", {} and NaN move the same way, from TN, in Any, object and str sub-fields. It also left out " " vs " " (TN to TP) and " " vs "x" (FA to FD). Name them all, and pin the rows in Any and object sub-fields, each against the same field at top level, and in an Optional[str] sub-field. All are TN or FA on dev. * docs(400): name every fixed-score override row as a TP, as without the override The CHANGELOG paragraph named one pair, a dict in an Any sub-field. The same override also moved strings, numbers, lists and other dicts, in an object sub-field too, and a model of another class at a 0.9 threshold, from FD to TP. At the default threshold that pair was already a TP and only its aggregate moves. State all of them as the current behaviour, which follows the field-by-field scoring StructuredModel still uses for objects of different classes, and widen the different-classes warning to match. * test(400): pin every fixed-score override row at a TP A list element whose compare_with() returns 1.0 without recursing, with an Any or object sub-field at threshold 0.9 or an Any one at the default, counts [Inner(a="x")] against a string, number, list, dict or model of another class as a TP, with a an FN and b a TN under aggregate, at score 1.0. Every row was an FD or a leaf-only TP on dev. The dict row under the override moves here from the dict test, which keeps its plain row, and the comment calling the TP undecided goes. * docs(400): except a union field two classes declare differently from "as before" A field's kind comes from the first matched ground-truth element whose class declares it. With AStr(x: Optional[str]) before BList(x: Optional[List[str]]), dev read BList's lists by value as one TP, and the list path now counts them per element, as with BList first. * test(400): pin a union field two classes declare differently, in both orders [AStr(x="p"), BList(x=["a", "b"])] against [AStr(x="p"), BList(x=["a", "c"])] counts x 2 TP and 1 FD at 0.875 with either class first. The AStr-first row counted 2 TP on dev. * docs(400): rewrap an over-long CHANGELOG line * docs(400): name the fixed crash for a self-scoring non-model ground-truth element [Inner(a="x"), Scored()] against itself, where Scored is a plain pydantic model with its own compare_with(), raised AttributeError on dev and now scores. Field classification skips it, since it has no dispatcher. * test(400): pin a Sequence sub-field at per-element counts, as at top level A Sequence[...] sub-field is read by value, so two lists go to the dispatcher. ["a", "b"] vs ["a", "c"] in Sequence[str] counts 1 TP and 1 FD, and two matching Inner in Sequence[Inner] count 2 TP with a and b under aggregate (4 TP), as at top level. On dev both counted one TP with no fields. * test(400): pin an Optional[Annotated[Inner, Field(...)]] sub-field as Optional[Inner] The Annotated spelling is not routed as a nested model, so the pair is read by value and goes to the dispatcher. Inner(a="hotel") vs Inner(a="hotels") at a 0.9 threshold is now an FD with a and b under aggregate (1 TP, 1 TN), as in Optional[Inner] and at top level. On dev the Annotated spelling counted one TP with no fields. * docs(400): state the list sub-field rule in the CHANGELOG, with examples The entry listed which inputs move. That list was incomplete (Decimal, UUID or Enum pairs, Inner vs [Inner], frozenset() or b" " against None), and its "count as before" sentence was false for Sequence[...] and Optional[Annotated[Inner, Field(...)]] sub-fields, which the list path also read without the dispatcher. It now states the rule: a list element's sub-field is classified by the same dispatcher as a top-level field, so its counts match top level, apart from the four cases, and scores do not change. The bullets are examples, now naming those two spellings, and the "count as before" sentence is gone. The union field example moves into the bullets, and the four cases name the sub-fields they apply to. * docs(400): say which list sub-fields are read by value, by example The Nested lists note scoped its differences to fields typed Any, object or Union[A, B]. Sequence[str] and Optional[Annotated[Inner, Field(...)]] are read by value too. The note now says every field goes through the same dispatcher as at top level, names by example the fields that go to it directly and the ones read by value first, and scopes the differences to the second kind. It also says the first matched ground-truth element that declares a field decides when classes in one list annotate it differently. * fix(400): count a list an override element cannot score as dev did A list whose first ground-truth element is a model is scored as a list of models. That raises when a matched ground-truth element has no compare_with(), such as [Inner(a="x"), "b"] against ["a", "b"], or when a prediction is a plain pydantic model, such as [Inner(a="x")] against [Point(x=1)]. At top level, and in a list element whose compare_with() recurses, scoring raises first, on dev too. An element whose compare_with() returns a score without recursing never scores the field, so on dev these inputs scored 1.0 and the sub-field counted one FD from the comparator. Routing the sub-field through the dispatcher made them raise. When the dispatcher raises AttributeError or TypeError on two lists in a sub-field read by value, the pair now counts as on dev: one TP or FD from the field's comparator. Every other input is unchanged. * test(400): pin an override element's unscorable list at dev's FD Under an element compare_with() that returns a fixed score, an Any or object sub-field holding [Inner(a="x"), v] against ["a", "b"], for a string, number, dict, list or plain pydantic v, and [Inner(a="x")] against one or two plain pydantic models, score 1.0 and count one FD from the comparator, with no fields, as on dev. All 21 rows raised on 5814586. * docs(400): say an override element's unscorable list counts as before The fixed-score override paragraph said every list of models in an Any or object sub-field now counts a TP. Where the dispatcher raises, as it does at top level, such as [Inner(a="x"), "b"] against ["a", "b"] or [Inner(a="x")] against [Point(x=1)], the pair still counts one TP or FD from the comparator. The paragraph now says so, and that the score is 1.0 before and after in every case. The crash paragraph now says a model against a plain pydantic prediction element still raises TypeError, as before. * docs(400): except plain pydantic elements from the non-model pair TP The different-classes warning said a model paired with any non-model element is a TP. Against a plain pydantic element it raises TypeError, at top level and in a list element. The warning now says so, and that under a fixed-score element compare_with(), a field read by value counts one TP or FD from its comparator wherever scoring the list would raise. * docs(400): note the comparator fallback in the refactoring record _dispatch_pairs now counts two lists the dispatcher raises on from the field's comparator, as the removed classifier did. Only an item whose compare_with() does not recurse reaches it. The record of the classifier removal now says so. * test(400): pin a dispatched sub-field of mixed shapes leaving the other pairs out Optional[Inner], Inner | None, Annotated[Optional[Inner], Field(...)] and Optional[List[Inner]] keep the model pair's fields under aggregate, so the None pair's FN drops out: 1 TP and 1 TN, where the same pairs at top level sum to 1 TP, 1 TN and 1 FN. Unchanged from dev. * test(400): pin an extra field on a predicted list element as uncounted An undeclared extra field on the prediction adds an FA to the root overall at top level, and nothing in a list element. Unchanged from dev. * test(400): pin a fixed-score element's sub-field warning as without it Under an element compare_with() that returns a score without recursing, a sub-field holding a mapping or a plain pydantic model its comparator cannot score, or two plain models of different classes, now warns as it does without the override and at top level, and raises under warnings as errors. Dev was silent there. The score stays 1.0 and the pair is an FD. * docs(400): scope the CHANGELOG's mixed-shapes case to every sub-field The mixed-shapes case also holds where a sub-field goes to the dispatcher directly, such as Optional[Inner] or Optional[List[Inner]]: aggregate keeps the models' fields and leaves the other pairs out, as before. The scoping sentence now says the extra-field and mixed-shapes cases apply to every sub-field, and the bullet gives both shapes, as classification-logic.md does. * docs(400): say the CHANGELOG's uncounted field is an extra one on the prediction "A field the predicted element's class does not declare" also reads as a ground-truth field the prediction lacks, which is counted, as an FN. The case is an undeclared extra field on the prediction, which top level counts as an FA on the root overall. * docs(400): say a fixed-score element's sub-fields now warn as without it Under an element compare_with() that does not recurse, the list path was the only reader of a sub-field and called its comparator silently. The dispatcher now warns there as it does without the override and at top level, which raises under warnings as errors. * docs(400): say which pairs of model classes warn under a fixed-score element The class-mismatch warning needs only one side to be a plain pydantic model: Point against Point2, Point against Inner and Inner against Point all warn. Two StructuredModels of different classes do not, since a field read by value scores them with compare_with(). * test(400): check the fixed-score warning and its raise in separate tests warn_once on the pushed head recorded a warning before emitting it, so the raise under warnings as errors swallowed the later pytest.warns and the test failed there for a reason that is not the behaviour it pins. One call per test, with the conftest's per-test reset, checks each on every tree. * fix(400): count a fixed-score model a fixed-score element cannot score as dev did Under a list element whose compare_with() returns a score without recursing, a sub-field read by value (Any, object, Union[Leaf, Inner], Optional[Annotated[Leaf, Field(...)]]) can hold two models of one class whose own compare_with() also returns a fixed score, with fields the dispatcher raises on, such as Leaf(d=[Inner(a="x")]) against Leaf(d=[Point(x=1)]) (TypeError) or Leaf(d=[Inner(a="x"), "b"]) against itself (AttributeError). Dev scored these 1.0 and counted one TP from Leaf.compare_with(). The dispatcher recursed into Leaf and raised, with or without include_confusion_matrix, and one list level down plain compare() raised too. The fallback covered only two lists. When the dispatcher raises AttributeError or TypeError on two models of one class in a sub-field read by value, the pair now counts as on dev: one TP or FD from the ground-truth model's compare_with(). If that recurses, it raises as on dev. _other_class_result, which already scored two models of different classes that way, is renamed _compare_with_result. Every other input is unchanged. * test(400): pin a fixed-score model under a fixed-score element at dev's TP Under an element compare_with() that returns a fixed score, a FixedScoreLeaf pair whose Any field d holds [Inner] vs [Point], or [Inner, "b"] against itself, scores 1.0 with field_scores {"items": 1.0}, with and without include_confusion_matrix, and counts value 1 TP, aggregate 1 TP, no fields. That holds in Any (two thresholds), object, Union[FixedScoreLeaf, Inner] and Optional[Annotated[FixedScoreLeaf, Field(...)]] sub-fields (20 rows), one list level down under plain compare() and compare_with() (2), and in the bulk evaluator, with no error and no FN (2). An Optional[FixedScoreLeaf] sub-field, which goes to the dispatcher directly, still raises, as on dev (2). The 24 non-control rows fail on dfc5cc1; all 26 pass on dev. * docs(400): say a fixed-score element's model pair the dispatcher raises on counts as before The CHANGELOG said that where the dispatcher raises under a fixed-score element, the pair counts one TP or FD from the comparator, and the classification docs said so "where scoring the list would raise". Both held only for a list directly in the field. They now say two lists count from the comparator and two models of one class from the ground truth's own compare_with(), which runs when that too returns a fixed score, with a Leaf example, and the CHANGELOG adds that a sub-field routed as a nested model or a list, such as Optional[Leaf] or List[Any], still raises on them, as before. The refactoring record names both fallbacks. * fix(400): count a list sub-field the first element's class does not route as a list as dev did Dev read only the first ground-truth element's class, so a field that class lacks, or declares by value, never reached the dispatcher. HEAD reads every matched class, so such a field could reach it as a list with no fallback and raise where dev scored: - R-A: TaggedBase before a fixed-score subclass whose List[Any] or Optional[List[Any]] tags hold [Inner(a="x"), "b"] vs ["a", "b"] (AttributeError) or [Inner(a="x")] vs [Point(x=1)] (TypeError). Dev scored 1.0. Also one list level down and in the bulk evaluator. - R-B: List[Union[Note, Tags]] where Note declares v as Optional[str] or Any and fixed-score Tags as Optional[List[Any]]. When the Note pair failed its match verdict, Tags's annotation read v for every pair. Dev scored 0.667 (1.0 with a fixed-score Note). A pair whose sub-field the first element's class does not route as a nested model or a list now counts from the comparator, or from compare_with() for two models, when the dispatcher raises, as a pair read by value already did. When the first element's pair is not a match, each pair is read by its own class's annotation rather than the first matched one's. A field the first element's class routes as a list still raises, as on dev. On a 67,584-case grid of two classes per list, nothing raises that ran on dev or on 823c451, no score differs from dev, and no count differs from 823c451 where it ran. The R3 single-class grid output is byte-identical to 823c451's. * test(400): pin a list sub-field the first element's class does not route as a list R-A: TaggedBase listed before a fixed-score subclass with tags as List[Any] or Optional[List[Any]], holding [Inner(a="x"), "b"] vs ["a", "b"] or [Inner(a="x")] vs [Point(x=1)]: score 1.0, field_scores {"items": 1.0}, with and without include_confusion_matrix, and tags 1 FD, aggregate 1 FD, no fields (8). One list level down under plain compare() and compare_with() (2), and in the bulk evaluator with no error (2). With the subclass first, it still raises, as on dev (4). R-B: [Note, FixedScoreTags] in a union whose Note declares v as Optional[str], Any, or Optional[str] with a fixed-score compare_with(), the Note pair failing: score 2/3, 2/3 and 1.0, v 1 FD, with and without the confusion matrix (12), and in the bulk evaluator (2). A later AnyNote pair after a failed first pair is read by value, so "x" against [] is an FN, as with the first pair matched (2). All 32 pass on HEAD. On 823c451, 27 fail: every row but the 4 still-raises controls and the first-matches row. On dev 6f76236, 10 fail, all on counts dev did not take: tags in R-A (dev skipped it) and the Tags pair's lists, which dev counted as one TP. * docs(400): say a list sub-field the first element's class does not route so counts as before The CHANGELOG said a sub-field routed as a nested model or a list still raises, as before, under a fixed-score element. That now holds only when the list's first element's class routes it that way too. It now says so, and that otherwise the pair counts the same way: a fixed-score subclass's List[Any] field after its base counts one FD for [Inner(a="x"), "b"] vs ["a", "b"], where dev did not count it, and a union class's Optional[List[Any]] field counts one FD, as on dev, when the first element's class declares it Optional[str] or Any. The union bullet, classification-logic.md and the refactoring record add that a failed first pair leaves each pair read by its own class.
#406 deleted the module. It was never exported or documented, but its import path worked, so restore it unchanged for 1.0.x with a DeprecationWarning on import. Nothing in Stickler imports it; removal moves to 1.1.0.
…at disagree with it (#419) * docs: state the list contract in one place, and correct the claims that disagree with it * docs: link the None-list row gap to #418 * docs: link the first-pair mean_score exception to #428 * docs: narrow the raw_similarity_score gap to List[StructuredModel] after #420 * docs(lists): correct the list contract against dev Drop the gap bullets that #364 and #421 fixed, and replace the rest with one short known-gaps note without issue links. State the bar for a list declared without ComparableField (the class match_threshold), say that a runtime match_threshold does not move a List[StructuredModel] bar, and limit the unordered claim to a list's own elements: a nested list element is one value, and on the zero-config path it and a list in an Any field match exactly. * docs(results): drop the fixed match gap and correct weighted_score for list rows #364 made a nested list row's match a bool and built element rows with the field's comparator, so the 'On dev' sentence is removed. A primitive list element row's weighted_score is its raw, unclipped similarity, unweighted. The clip note now points at the Score rule instead of restating it, and the remaining gaps link the contract's known-gaps note instead of issues. * docs(thresholds): correct what the runtime match_threshold gates On the zero-config path it is also the field threshold of nested plain-model and dict fields, and on a StructuredModel it reaches only matched, so the cheat sheet no longer says it overrides the model threshold. The parameter goes to evaluate() or eval_for(), not EvalSpec. State the bare-annotation list bar, qualify 'FN and FA are impossible for an equal-length list' for None elements, point list clipping at the Score rule, and make the All Four example runnable with measured values. * docs(threshold-gated): qualify equal-length pairing for None, link the Score rule The page now carries dev's measured worked scenario (Laptop is a TP under the 1e-10 tolerance) and runnable compare_with block. On top of it: an item is left unmatched only when one list is longer once None elements are removed, and Score Aggregation points list fields at the contract's Score rule. * docs(hungarian): make the Result Structure checkable and nest leaf counts under overall Add the gt/pred construction and the compare_with call, and show each field's counts under its overall key as the result does. Drop 'warns' from the JSON Schema threshold note: an exported 0.5 is ignored silently. * docs: point list clipping at the Score rule, and limit the unordered claim 'Lists apply it per element' was wrong for List[StructuredModel] and for dict and plain-model lists, which do not clip by default. Those pages now link the contract's Score rule. Best Practices no longer says every list is unordered, and architecture.md states the clip default per field kind without an issue link. * docs(auto): state every effect of the runtime match_threshold in the facade docstrings On a plain pydantic class it is also the field threshold of nested plain-model and dict fields, as src/stickler/auto/README.md already says. Drop the issue number from the rendered API docstring. * docs(changelog): re-add the list contract entry under Unreleased The entry is rewritten against dev: the fixed report gaps and the Laptop FD are gone, the raw_similarity_score and bulk mean_score lines are dropped (dev's own entries cover them), and each remaining limit links its own issue. * docs(auto): describe the List[BaseModel] clip gap without an issue link * docs(lists): word the known gaps as defects, not as places the table is wrong * docs(thresholds): the runtime match_threshold also gates zero-config List[dict] elements On a plain pydantic class the runtime value is the element bar of a List[dict] field as well as of List[Model], at every nesting level. A primitive list keeps its inferred threshold (0.7 for List[str]). Say so in What it gates, the precedence row, Key Rule 3, the cheat sheet, both facade docstrings and the CHANGELOG entry. * docs: clip_under_threshold is off by default on dict and plain-model fields Measured on a StructuredModel with threshold 0.9 and one key of three different: a dict and a plain-model field each score 0.6667 by default and 0.0 with clip_under_threshold=True. The parameter table gave the default as True for every non-list field, and three paragraphs said "(the default)" without the exception. * docs: qualify the equal-length pairing claims for None elements [P1, None] vs [P1, P2] holds two items on each side and gives tp=1 fa=1, because None elements are removed before pairing. The thresholds worked example still said unmatched items appear only when lengths differ, and the threshold-gated paragraph qualified only its second sentence. * docs(lists): scope the order claim to a list field's elements "A list's elements" also covers the inner list of a List[List[str]], which scores 0.8 when reordered on a StructuredModel and 0.0 zero-config, and a list held in an Any field, which scores 0.0 zero-config. Use the Pairing row's scope in Best Practices, the List order edge case and the CHANGELOG. * docs(lists): mark the List[StructuredModel] clip behaviour as a known gap, and scope list defaults to Python The intro now says the table is how Stickler treats a list field and that Known gaps lists where the code does not yet follow it. The Score row describes what clip_under_threshold does on List[StructuredModel] today (an FD pair keeps 0.5 with clip True or False) and calls it a known gap rather than a rule, as do architecture.md and the CHANGELOG. The Bar and Score defaults hold for Python declarations only. The JSON Schema importer passes clip True: a free-form object array with ANLS* at 0.9 scores 0.0 there and 0.6667 as a Python List[dict]. Both rows and architecture.md now link the JSON Schema defaults, and the Bar row points at the zero-config defaults. * docs(lists): fix the review nits on reports, null lists and examples - Reports row and understanding-results: an element of a primitive, dict or plain-model list is one row whatever its classification, and a dict or plain-model element is not expanded (measured ds[0] and ps[1], TP, with no leaf rows). - Known gaps: a None list is reported differently from [] in field_comparisons. Against another None it gets one row, while every other pair of null lists ([] vs [], [] vs None, [None] vs None, ...) gets none, although each counts one TN. - aggregate-metrics: say the [A, B] vs [A] example has two-field items. - CHANGELOG: the Hungarian result block is checkable, not runnable. * docs(lists): scope the Reports row to field_comparisons, and say non_matches keeps only FD, FN and FA rows The row said non_matches and field_comparisons both get one row per element of a primitive, dict or plain-model list, whatever its classification. Only field_comparisons does. Measured on HEAD and dev with ds: List[Dict[str, str]], ps: List[Plain] and ts: List[str]: field_comparisons has ds[0], ps[0], ps[1], ts[0] and ts[1], while non_matches has only ps[1] (FD) and ts[1] (FN); FA elements and FD leaves of a TP item appear in both. match is a field_comparisons key, so the row now says so. * docs(lists): scope the clip defaults to a StructuredModel declared in Python, and the zero-config list threshold to the field name The zero-config path is declared in Python too, and infers clip per field: a plain Z(notes: List[str], tags: List[str], description: str) gives notes and description FuzzyComparator@0.6 with clip off, and tags Levenshtein@0.7 with clip on. On 'alpha beta gamma delta' vs 'omega theta kappa' notes and description are FD and keep 0.5128, tags is FD at 0.0 (HEAD and dev). The Score row, architecture.md and understanding-results.md now say 'on a StructuredModel declared in Python' and link the JSON Schema and zero-config defaults, as the Bar row does. The runtime match_threshold section said a primitive list keeps 0.7 for List[str]; the inferred threshold depends on the field name (0.7 for tags, 0.6 for notes). The CHANGELOG bullet uses the same scope. * docs(json-schema): x-aws-stickler-infer-unspecified also infers the clip setting The extension reference said x-aws-stickler-clip-under-threshold defaults to true in every position and that the flag infers a comparator, threshold and weight. With the flag, a property that names no comparator takes its clip setting from inference. Measured on HEAD and dev: a free-form object and an array of them get ANLSStarComparator@0.7 with clip off and keep 0.6667, and a notes string or string array gets FuzzyComparator@0.6 with clip off; without the flag they get Exact@1.0 or Levenshtein@0.5 with clip on and score 0.0. A stated threshold or clip key still wins. * docs(json-schema): keep the clip Default cell at true, and put the inferred case in Purpose tests/test_readme_examples.py pins the Default column against an undeclared schema, where clip is true for every property. The inferred case belongs to the flag, so the cell keeps true and Purpose points at the paragraph below. * docs(thresholds): fix the list rows the dev merge left inconsistent Follow-up to the origin/dev merge (69e178c), which resolved conflicts with #577 in thresholds-and-metrics.md and CHANGELOG.md. - Key Rule 2 took #577's "Match threshold on the element class controls object-level TP/FD classification for list matching", which contradicts the precedence rows for other lists. Scope it to List[StructuredModel] and point other lists at the table. Measured on this tree: on a StructuredModel with match_threshold 0.85, a bare List[Plain] pair at 0.8 is FD (bar 0.85, the containing class); declared with ComparableField() a 0.6 pair is TP (bar 0.5); a zero-config List[Item] pair at 0.9 is TP with no runtime value and FD at runtime 0.95. - Restore this branch's primitive/dict/plain-model list pairing row, including its link to the list contract's Bar row, which the merge had replaced with a pointer to the declaration table. - CHANGELOG: the #484 entry already says a runtime match_threshold sets only matched on a StructuredModel, so this branch's sub-bullet now states only the zero-config behaviour and keeps the #416 link. The merge also dropped "`spec.explain()` shows the resolved values." from Runtime Match Threshold. It stays dropped: on a plain class holding List[SMEl] with SMEl.match_threshold 0.85, at runtime 0.5, explain() reports threshold 0.5 while a 0.8 pair is FD, so it misreports the List[StructuredModel] carve-out the paragraph now states. * docs(thresholds): keep the List[StructuredModel] exception in Key Rule 3 and the CHANGELOG
…tries, flag model keys no class reads (#407) * fix(json-schema): read model keys on ["object","null"] and check $defs bodies A `["object", "null"]` node is rewritten to `anyOf` before parsing, and its model-scope keys stayed beside the `anyOf` instead of on the object arm that becomes the class. The node built `DynamicModel` at match_threshold 0.7, so a near-miss `items` element at 0.9 against a declared 0.93 counted tp 1 instead of fd 1 / fp 1. The object arm now carries `x-aws-stickler-model-name`, `-match-threshold` and `-infer-unspecified`. Regression from 0.7.0. The extension walk entered `$defs` / `definitions` bodies with no scope, so a typo there imported silently while the same typo inline raised. Definitions are now checked and read only model-scope keys. A field-scope key inside one raises and points at the property that uses the definition, beside its `$ref`, where it is already read; honouring it would make the key work on a property `$ref` and vanish on an `items` `$ref`. Both are breaking: results move for nullable-object schemas that declared a model key, and schemas with a typo or field key inside a definition now raise. Refs #349 (part A only; B and C are out of scope) Closes #340 * fix(json-schema): reject object-level keys on non-object $defs entries A scalar, array, combiner or alias definition generates no class, so the "definition" scope accepted model keys there and then dropped them. Such a definition now reads neither set. The field-key error names the $ref, and a non-mapping $defs is walked as before. Docs and CHANGELOG narrowed to where definition keys are actually read; the CHANGELOG notes invalid values on an ["object","null"] node now raise. Refs #340, #349. * fix(json-schema): reject model keys no class reads; name the items position Addresses review on #407. - Model keys on an `allOf` arm (inline or through `$ref`), or on a definition reached through `allOf` or a root `$ref`, now raise. They passed the check and were dropped: a definition's match-threshold 0.93 built `AllOfModel` / `DynamicModel` at 0.7. The root `$ref` message points beside the `$ref`, where the root reads them. - A field key inside a definition now names both working positions: beside the `$ref`, or on the array property when used as `items`. - A `$defs` body is a "definition" only when it has `properties`. A `type: "object"` mapping becomes a `dict` field and reads no model keys. - A union root (`["object", "null"]`, root `anyOf`/`oneOf`) raises a clear ValueError instead of `AttributeError: model_fields`. Docs now limit the list-form statement to nested nodes. - Fold the duplicated "model"/"definition" branches. Refs #340, #349. * fix(json-schema): check only definitions a $ref reaches, and allOf keys nothing reads Every $defs entry was validated, referenced or not, so a dereferenced schema (refs inlined, $defs kept) raised for keys that its inlined copies read. Model keys on an allOf arm raised even when another position built the same object from them, or when the allOf built nothing (an unused definition, under 'not'). A definition is now walked once a $ref reaches it. The allOf and root $ref checks run after the walk, only for positions that build a class, and skip any object some other position reads. Data keywords and x-* payloads are no longer walked as schemas. The second traversal in _reject_unread_model_keys is folded into the walk. * fix(json-schema): keep $ref off the null arm of a list-form type `["object", "null"]` beside a `$ref` is rewritten to anyOf, and every non-type keyword, the `$ref` included, was copied onto each arm. The null arm then parsed as a second object, so the node built a union of two classes compared with ExactComparator: a one-character difference scored 0.0 where `"object"` scored 0.9. The null arm is now `{"type": "null"}`, and the object arm drops its `type` beside a `$ref`, which otherwise made the parser merge the two into a new class. Pre-existing on dev. * fix(json-schema): raise for model keys beside a non-root $ref Beside a `$ref` on `items`, an anyOf/oneOf arm, or an object property, the class is built from the target and reads only its keys, so a match-threshold of 0.93 there passed the check and built at 0.7. The errors for keys inside a definition pointed authors to this spelling. It now raises and names the target. The root still reads the keys beside its own `$ref`. Pre-existing on dev. * test(json-schema): pin reached-definition checks, allOf readers, $ref beside list types and model keys Regression tests for the PR #407 review of 2026-10-28: a dereferenced schema and unreferenced or data-embedded $defs import; a definition read directly and through allOf builds its class; an allOf that builds nothing is left alone; ["object", "null"] beside a $ref scores like "object"; model keys beside a non-root $ref raise. * docs(json-schema): state which definitions are checked and where model keys are read * fix(json-schema): a $ref that builds nothing does not excuse an allOf that drops the keys * docs(json-schema): say unreached definitions are no longer checked, and which references build nothing * docs(json-schema): an items array reads only the weight; say so in the error and the docs * fix(json-schema): count readers inside a $ref target outside $defs The allOf and root-$ref checks skip an object another position builds from its keys, but only `$defs`/`definitions` entries were walked from their references. A target under `#/components/...` was walked in place as a position that builds nothing, and one under an `x-*` key not at all, so a property `$ref` inside it did not count as a reader. With `team` referencing `components.schemas.Team`, whose `lead` builds `Person` at 0.93, an `allOf` arm on `Person` elsewhere raised although `lead` reads the keys. Every resolved `$ref` target is now queued for a walk that carries the referencing position's `built` flag. A target outside a definition keeps no scope at its top, so, as before, its own keys are not checked as a definition's are; only what it builds now counts. The CHANGELOG sentence saying the allOf and root-$ref raises need no other builder now names this case. * fix(json-schema): name the position that reads a field key from a definition A field key inside a definition raised and said to put it beside the `$ref`. When the `$ref` is an `anyOf`, `oneOf` or `allOf` arm, that position raised again ("belongs on the field"), and a definition used as the root has no position at all. Measured: beside the combiner on the property reads `threshold` and `weight`; `items` reads them on the array property (only the weight for an array of objects); the root reads neither. The error now names the combiner and says a root definition reads no field keys. CHANGELOG, dynamic-models.md and the README say the same. * docs(changelog): say an unreached schema under an x-* key is no longer checked The walk stopped descending into `x-*` payloads, so a typo in a property of a schema kept under an `x-*` key raised on dev and now imports unless a `$ref` reaches it. The entry listed the same change for unreached `$defs` entries only. * fix(json-schema): walk a $ref target inside a $defs entry from the reference A `$ref` that points inside a definition entry queued the whole entry with the reference's `built` flag. Two failures followed: - Silent drop. A root `$ref` or an `allOf` arm to `#/$defs/Wrap/properties/inner` or `#/$defs/List/items` counted every reader in the entry, though nothing builds the entry, so the target's `match-threshold: 0.93` passed the check and built the default class at 0.7, as on dev. - False raise. A target under `not`, `x-*`, `additionalProperties` or `then` in the entry was walked as building nothing, so `team.lead` building `Person` at 0.93 did not count and an `allOf` elsewhere raised where dev imports. The entry is now queued as built nothing, so it is still checked as a definition, and the target is walked from the reference with its flag. The error names such a target an object rather than a definition. CHANGELOG says a reader inside any `$ref` target counts. * fix(json-schema): accept x-aws-stickler-aggregate inside a definition The key was removed in #226 and is accepted and ignored on a field so older schemas still import. The new definition check accepted only the model keys, so an object or scalar definition carrying it raised "Unrecognized Stickler extension" where dev imports, against the 1.0.0 entry saying such a schema still imports. Both definition scopes now accept it, and it is still not offered as a valid key. * fix(json-schema): check the contents of $defs entries no $ref reaches, as dev does Only entries a `$ref` reaches were walked, so a typo in a property of an unreached entry imported where dev raises. The same held for a misplaced key, `patternProperties`, a keyword beside a combiner, a field key on an `allOf` arm, a nested `$defs` (also inside a reached entry), and an entry reached only from an unreached one. Once the queue is drained, every entry no `$ref` reached is now walked as dev walks it: its own keys are left alone, so a dereferenced schema still imports, and its contents are checked. It builds nothing, so the `allOf` and beside-`$ref` model-key checks do not apply there, and the `$ref`s it holds are not followed. Data keywords and `x-*` payloads are still not walked. Where the two rules meet, a `$defs` entry inside such a value, dev's behaviour is kept: its contents are checked. CHANGELOG, dynamic-models.md and the README say so. * fix(json-schema): point each import error at a position that reads the key - A field key in a definition used from `items` now says the array property reads only `x-aws-stickler-weight` and the elements pair by the definition's `match-threshold`, and covers `items` whose arm is the `$ref` (`items: {anyOf: [{$ref}, null]}`), where "beside the `anyOf`" raised again. - For a definition that is not an object with `properties`, the advice no longer offers the `allOf`: a one-arm `allOf` of a scalar, array or mapping fails to import whatever its keys, on dev too. - A model key beside a `$ref` to an alias names the end of the chain, not the alias, which reads no model keys. - A root `$ref` to an `["object", "null"]` or `anyOf` definition gets a root error that names that case. Tests pin the wording the replies rely on, including the threshold case from the `items` review thread. CHANGELOG, dynamic-models.md and the README say the same. * test(json-schema): pin that x-* payloads and data keywords are not walked Deleting the `x-*` skip passed every test. Each shape that raised on dev under an `x-*` key (at the root or on a property), `default` or `examples`, now imports and is pinned: a typo, a misplaced key, `patternProperties` and a keyword beside a combiner, plus schema-shaped `enum` and `const` values and the review's comparator config shaped like an `allOf` of model keys. An `x-*` payload that a `$ref` reaches is still checked. Removing the `x-*` skip now fails 10 tests; removing the data-keyword skip fails 11. * docs(json-schema): scope the object-level raises and record them inside components - dynamic-models.md said object-level keys raise wherever no class reads them. An inline `type: "object"` mapping with `match-threshold` still imports with the key ignored, so the sentence now names the three positions it covers. - Counting readers inside any `$ref` target also made the three checks apply inside a `#/components/...` target that a building position references: an `allOf` arm, model keys beside an `items` or typed `$ref`, and a root `$ref` to it. Dev imports these at the defaults. CHANGELOG, dynamic-models.md and the README now say so, and the README calls the root `$ref` target an object rather than a definition. Tests pin all four raises (each fails against 529c7e2's importer), the unreferenced target importing, and the root reading its own keys. * fix(json-schema): offer the allOf for a field key on an alias of an object A field key on an alias definition (`{"$ref": "#/$defs/Row", "x-aws-stickler-threshold": 0.9}`) raised with the advice for a scalar: beside the `$ref`, or beside the `anyOf` or `oneOf`. When the alias ends at an object with `properties`, `allOf: [{"$ref": Alias}]` with the keys beside it reads them too (threshold 0.9, weight 2.0, as on dev), and the CHANGELOG and dynamic-models.md already say `allOf` works through an alias. Such an alias now gets the object's advice, with the elements of an `items` array pairing by the match threshold of the object it aliases. An alias of a scalar keeps the scalar's advice. * test(json-schema): pin the x-* skip with a comparator config shaped like a schema The review's comparator config, an `allOf` of model keys, imports whether or not `x-*` payloads are walked, so it does not pin the skip. A config holding `properties` with `x-aws-stickler-thresold`, or `patternProperties`, raises on dev and fails both new tests when the skip is removed; with the skip, it imports and the comparator ignores the keys with a warning. * docs(json-schema): say a $ref into an entry checks the node only where the walk does The CHANGELOG said a key inside a `$defs` entry that a `$ref` reaches is now checked. For a `$ref` to a node under `not`, `if`, `then`, `else`, `additionalProperties`, `dependentSchemas` or an `x-*` key inside an entry, the node's own keys are not checked: `x-aws-stickler-match-threshhold` there imports and builds the class at 0.7, on dev and here, while the same key on the whole entry raises. The entry now says the entry's own keys are checked, and names where a node inside it is not, as for a target outside `$defs`. The importer docstring says the same. The README's object-level sentence ended in a run-on clause; it is split. * docs(changelog): a misplaced key on a node inside an entry imports too Measured on this branch and dev: `x-aws-stickler-weight` on a `$ref` target under `not` in a `$defs` entry, under an `x-*` key, or in `#/components/...` imports and is not read (the property's weight stays 1.0), as a typo there does. * fix(json-schema): raise for a model key beside a $ref on a node inside an entry A property, `items` or `anyOf` arm that `$ref`s a node inside a `$defs` entry, such as `#/$defs/List/items` or `#/$defs/W/properties/inner`, built it at 0.7 (`items@0.7`, `inner@0.7`, `DynamicModel@0.7`) when the node carried `x-aws-stickler-match-threshold` beside its own `$ref`. baff4e0 walks the entry around such a node as building nothing, and the node itself with no scope, so the beside-`$ref` check ran at neither. The pushed head 529c7e2 raised for all seven shapes; a `$ref` to the whole entry still did. The entry's walk now records such keys where it reads them without building, and they raise once a `$ref` chain from a position that builds a class passes through the node. Under `not`, or from an unused definition, nothing is built and the schema imports, as on dev. A target outside `$defs` (`#/components/R`) is unchanged. * fix(json-schema): check an x-* payload that only an unused definition references `$defs.Outer.properties.i = {"$ref": "#/x-models/T"}`, with `Outer` unused and a typo on a property of `x-models.T`, raised on dev and imported here, as it did on 529c7e2. The walk of an unused entry queued its `$ref`s, but the queue was already drained, so the target was never walked. The same held for a `$ref` in a `$defs` inside `default`. The queue is now drained again after the unused entries, walking each target for its contents only, as building nothing. Their own keys stay unchecked, so a dereferenced schema still imports. * fix(json-schema): offer the allOf only where a one-arm allOf imports A field key on a definition typed `["object", "null"]`, `["null", "object"]` or `["object"]` with `properties`, or on an alias of one, was told to go beside the `allOf` when the `$ref` is its arm. But `allOf: [{"$ref": N}]` with threshold 0.9 and weight 2.0 beside it fails with `field_definitions must contain at least one field`, here and on dev, directly or through an alias. Untyped and `"object"` definitions import there at 0.9 and 2.0. The advice now offers the `allOf` only when the definition and each alias hop to its end are typed `"object"` or untyped. Measured over five end types and five alias shapes, it offers the `allOf` exactly where the one-arm `allOf` imports. `$ref`, `anyOf`, `oneOf` and the array weight read the keys for a list-typed definition, as the advice says. * test(json-schema): pin the object-level raises inside a node of an entry baff4e0 walks a `$ref` target inside a `$defs` entry from the reference, so the three object-level checks fire inside it wherever it sits. Under `not`, `then`, `additionalProperties` or an `x-*` key of `$defs.Holder`, an `allOf` arm reaching a keyed `Addr`, a model key beside an `items` `$ref` and a model key beside a typed `$ref` raise (12 cases). Dev and 529c7e2 build these at the defaults (`AllOfModel@0.7`, `Row@0.7`); all 12 fail there. Unreferenced, or with only the whole entry referenced, nothing is built under those keys and the schema imports, as on dev. * docs(json-schema): align the allOf advice, the raises inside entries and the docstring - The `allOf` is offered only for an object typed "object" or untyped, as the error now says. dynamic-models.md said "only an object with `properties`", and the README offered "the combiner whose arm the `$ref` is" with no limit, which a scalar or a list-typed object fails. - The object-level raises apply inside any `$ref` target a building position references: `#/components/...`, and also under `not`, `then`, `additionalProperties` or an `x-*` key in a `$defs` entry (pinned in 4fc6ac6). Both docs named only `#/components/...`. - dynamic-models.md: the sentence about definitions no `$ref` reaches followed "For example:", whose example is reached from two properties. It now follows the example, and says their `$ref` targets are checked. - The importer docstring gives an open example list (`not`, `if`, `contains`, `x-*`) instead of a closed one, says the targets of an unused entry's `$ref`s are walked, and that a property that `$ref`s a property node does not read the node's field keys (threshold stays 0.5). * docs(changelog): relabel #407's entries under the breaking rule Breaking means a public name, parameter or result field removed, renamed or retyped; a default changed; input the docs accept now rejected; or a documented output format changed. Measured on dev 8c56dfa against this branch, every key that now raises was dropped on dev, with no effect on the built model (field keys in 4 kinds of definition, model keys on 6, beside a `$ref` at 4 positions, on `allOf` arms and through a root `$ref`). Moved to Fixed, unlabelled: `["object", "null"]` reading its model keys (scores move toward what the docs say; invalid values now raise); checking definitions (typos and keys the docs never place there); model keys on `items` and `anyOf`/`oneOf` arms beside a `$ref`, on `allOf` arms and through a root `$ref`; the x-* and data-value relaxation; the union root's `ValueError`. Kept as Breaking, split out: a model key beside a `$ref` on a property typed "object" or ["object", "null"]. Dev's README lists object-level keys as "valid on the root schema or on any object-typed property", so that input was documented as accepted; dev imports it (`Row@0.7`) and the branch raises. Also: "anywhere else (for example `not`, `if`, `contains` or an `x-*` key)" for the node positions that are not checked, the property-node case, "on a definition entry" for the aggregate key, the `allOf` advice limited to objects typed "object" or untyped, and the raises inside an entry's nodes alongside `#/components/...`. * refactor(json-schema): resolve a local $ref at module level The array warning needs the same resolver as the validation walk, so the resolver, the label and the alias chain leave the walk's closure. No behaviour change. * fix(json-schema): name the definition an array's items $ref leads to A threshold on an array of models warns that the element class's `x-aws-stickler-match-threshold` gates pairing, "declared inside that property's 'items'". Where `items` is a `$ref`, that read as beside the `$ref`: `items: {"$ref": "#/$defs/Row", "x-aws-stickler-match-threshold": 0.93}` built `Row` at 0.7 on dev and now raises, naming `$defs.Row`. So two messages gave opposite advice for the same key. The warning now names the end of the `$ref` chain when `items`, or an `anyOf`/`oneOf` arm of them, is a `$ref`: "declared on definition '$defs.Row', where its 'items' '$ref' leads". Inline `items` keep the old wording. Following the advice reads the threshold in all five shapes tested (a `$ref`, an alias, an `anyOf` arm, inside a definition, under the root `$ref`); without the fix the five naming tests fail. * test(json-schema): pin what a $ref to a node of an entry builds and checks - An object-typed property node with model keys, reached only through the root `$ref` or an `allOf` arm, raises, in `$defs`, under `#/components/...` and under an entry's `items` (6 cases; all fail on dev, which builds `DynamicModel` or `AllOfModel` at 0.7). - The rest of an entry around the node a `$ref` targets builds nothing: a typed `$ref`, an `items` `$ref` or an `allOf` arm with keys no class reads imports, as on dev, while a `$ref` to the whole entry raises for each, and a typo there still raises. The pushed head raised for the three; HEAD walks that part as an unused definition. - Beside a `$ref`, `["null", "object"]` and `["object"]` raise like `"object"`, inline and on a property node of an entry. - The documented gaps, as on dev: model keys beside the `$ref` of a target under `not` or `additionalProperties` in an entry, or outside `$defs` (`#/components/...`, `#/x-models/...`), are dropped; outside `$defs` a typo on a property or `items` target raises where the class is built, and one at the top of a target imports. * docs(json-schema): label the property-node raise breaking and scope the rest Under the breaking rule (input the docs accept now rejected): a model key on an object-typed property that no position builds, reached only through the root `$ref` or an `allOf` arm (`{"$ref": "#/$defs/Wrap/properties/inner"}`), raises on this branch, and dev imports it as `DynamicModel@0.7` or `AllOfModel@0.7`. Dev's README calls object-level keys "valid on the root schema or on any object-typed property", which is the reading that keeps the beside-`$ref` entry Breaking, so this one is a second Breaking entry under Changed, not Fixed. Also: - The beside-`$ref` Breaking entry names every list form that includes "object" (`["null", "object"]` and `["object"]` raise too), and says the rest of an entry around a referenced node builds nothing, so a property there imports. The pushed head raised for that; HEAD walks it as an unused definition, as dev does. - dynamic-models.md and the README no longer state the beside-`$ref` raise unconditionally: on a node that is itself a `$ref` target it is checked only on a property or `items` node of a `$defs` entry, and dropped under `not`, `additionalProperties` or outside `$defs` (`#/components/R`), as on dev. The README's object-level heading points at those exceptions. - CHANGELOG: outside `$defs`, a typo on a property or `items` target is caught where the class is built, and only one at the top of a target imports; an `x-*` payload is checked where a `$ref` from the schema or a definition points into it, and a `$ref` held in an unreached value is not followed; the array-threshold warning now names the definition. - The walk's docstring drops "a combiner arm" (a `$ref` to an arm fails to import) and says the rest of an entry around a target builds nothing. * fix(json-schema): warn, not raise, for model keys on an object-typed property Dev's README calls the object-level keys valid "on any object-typed property". Two raises rejected them there: beside a `$ref` on a property typed "object" (or a list form that includes it), and on such a property reached only through the root `$ref` or an `allOf` arm. Both now warn, name the key, the position and where it is read, say it becomes a ValueError in 1.1.0, and import as dev does (the keys dropped). `items` and combiner arms, positions no doc names, still raise. Tests pin the warning and the class and threshold dev builds; run against dev's src, only the warning assertions fail. * fix(json-schema): name the keyword in the path of a node under not or then The walk left `not`, `then`, `contains`, `additionalProperties` and the other non-building keywords out of the error path, so a model key beside the `$ref` on `#/$defs/W/not/items` was reported at '$defs.W[]', and a typo there at '[]' (dev too), nodes that do not exist. The path now names the keyword: '$defs.W.not[]', '$defs.W.not.p'. Pins the beside-`$ref` check on property and `items` nodes under those keywords of a `$defs` entry: an `items` node raises, an object-typed property warns and builds `p` at 0.7 as dev does, and nodes under an `x-*` key or outside `$defs` import unchecked, as on dev. The importer docstring now says the check covers them. * fix(json-schema): name the definition for an array in an allOf arm or a dotted name The warning for `x-aws-stickler-threshold` on an array of models looked the property up by splitting its path on '.' and did not look through `allOf` arms. For an array inside an `allOf` arm, or a property named `a.b`, it fell back to "declared inside that property's 'items'", advice that raises beside the `$ref`. The lookup now matches whole names and reads `allOf` arms. Where it still finds no single array property, the warning says what holds for inline `items` and a `$ref`. * docs(json-schema): describe the warnings, and where a node's own keys are checked CHANGELOG: the two Breaking entries become one Changed entry for the new warning, with an open list of where the property may sit (an `x-*` payload such as `#/x-models/T` too). Nothing in #407 is breaking now. Fixed names the `items` node raise anywhere in an entry, the dropped cases (`#/$defs/W/not`, under `x-*`, outside `$defs`), the per-hop `allOf` rule, the warning's new lookup and the error path. dynamic-models.md and the evaluator README say the same, and stop claiming a whole-entry alias drops the keys beside its `$ref` (it raises, as any definition that builds no class does). * test(json-schema): pin the warning for an object-typed property in an x-* payload `t: {"$ref": "#/x-models/T"}` with `T.properties.w` typed "object" beside a `$ref` and a match threshold builds `w` as `Row` at 0.7, as on dev, and warns. The CHANGELOG lists this position; nothing pinned it. * fix(json-schema): warn that a model key is ignored only once the import builds A list-typed object property reached through the root `$ref` or a one-arm `allOf` fails to import whatever its keys, as on dev. The walk warned "It is ignored" and advised putting the key on the root, which cannot be nullable, before the import raised. The walk now returns its warnings, and the importer issues them once the fields are built, so an import that fails gives none. A second `allOf` arm still builds `AllOfModel` at 0.7 and warns. * fix(json-schema): read a pointer into an unknown map as names too An object-typed property reached through the root `$ref` or an `allOf` arm warns, but `_is_property_pointer` read every segment against the schema keywords, even inside a map it does not know. So `#/components/schemas/properties/properties/inner` was not a property, and the import raised where dev builds `DynamicModel` at 0.7; a component named `Wrap` warned. Under a key no schema has (`components`, an `x-*` payload) both readings are now kept, and the pointer is a property if either ends at one. * docs(changelog): scope the warning for a property that is a $ref target, and fix the old paths The Changed entry said the beside-`$ref` warning holds wherever the property sits, but a property that is itself the target of a property, `items` or arm `$ref` warns only as a property node of a `$defs` entry outside an `x-*` key, as Fixed says. It also said such imports go on as before, which a failing import (a root `$ref` to a nullable property) does not: it fails, now with no warning. The error-path entry named '$defs.W[]' as the old path, which never shipped; dev reported '[]' and 'p'. * style(test): wrap the x-models case of the keyword-named members * docs(json-schema): say what unread() leaves to the import, without "as before" A root `$ref` to a nullable property failed on dev with an AttributeError and fails here with the root-shape ValueError, so "fails as it did" overstated it. The import builds what dev builds and warns, or still fails and does not warn. * fix(json-schema): read a property named definitions or $defs as a name _resolve_local_ref marked any segment after `$defs` or `definitions` as a definition entry, even when that segment was a property NAMED like the keyword. So `#/properties/definitions/properties/term` queued `properties.definitions.properties` as an entry and walked its property map as a schema: a sub-property named `items`, `anyOf` or `patternProperties` then raised, where dev imports. Read the pointer from the root, as _is_property_pointer does, and mark an entry only where the segment before was read as the keyword. * fix(json-schema): check a property or items $ref target under an x-* key The walk skips x-* payloads, and a $ref target is walked from the reference for its contents only, so a typo or misplaced key on a property or items node under an x-* key (`#/x-models/T/properties/p`, `#/$defs/W/x-sub/properties/p`, `#/x-models/L/items`) imported where dev raised. Check that node's own keys from the reference, with the path and scope the walk would give it there. The path and the x-* test read the pointer as the walk does, so a property NAMED `properties` keeps its name in the label and a property NAMED `x-a` is not an x-* key. A root $ref to a non-object property under x-models now raises dev's "belongs on the object" error, so the two tests that matched the root-$ref message now match that one. * docs(json-schema): a $ref into an x-* payload checks that node, and the warned import drops the keys A $ref into an x-* payload walks the node it points at for its contents, plus a property or items node's own keys, not the rest of the payload: a typo in another member imports. Say so in the CHANGELOG and dynamic-models.md, where they said the payload, or whatever the $refs point to, is checked. The warned import is not always what dev built: beside a $ref, ["object", "null"] builds Optional[Row] with the default comparator, where dev built Union[Row, Row, None] with ExactComparator. The Changed entry and the unread() docstring now say only that the keys are dropped. * style(test): wrap the x-models case of a property named properties * fix(json-schema): read $defs and definitions as definitions only as a keyword of a schema Three places decided on their own whether a key named $defs or definitions held definitions, and each read too much: - _resolve_local_ref kept a second reading under a key no schema keyword holds, so `#/components/schemas/G/properties/definitions/ properties/q/items`, or `#/x-models/G/$defs/X`, resolved into a definition entry and checked it as one. - collect() took any such key inside an x-* payload or a data value (examples, default, enum, const) as a set of definitions and walked its entries as schemas. - The walk sent a member named so of a map no schema keyword holds (`components.schemas.definitions`) to the definitions queue. Each raised where dev imports. One rule now decides in all three: _position_after reads each key as what it is in the document, and only a $defs or definitions keyword of a schema (the root, or a node reached from it through schema keywords) holds definitions. A property name, a member of another map, and anything inside an x-* payload or a data keyword do not. The resolver and the walk both use it, and collect() is gone, since nothing inside a value holds definitions. So a $defs inside default or an x-* payload is no longer walked: a typo in its entries imports, and a $ref it holds is not followed. The three tests that pinned the old walk now assert the import. A test pins that an unused entry named `properties` is checked as an entry. * docs(json-schema): say only a keyword of a schema holds definitions State the rule the importer now applies: only a $defs or definitions keyword of the root, or of a node reached from it through schema keywords, holds entries. One under components, inside an x-* payload or a data value, or a property named so, holds none. The CHANGELOG said a $defs entry inside an x-* payload or a data value was still walked for its contents; it no longer is. * docs(changelog): an unused entry named like a keyword is read as an entry The entry said an unused definition's contents are checked "as before". Dev walked the $defs mapping as a schema, so an entry named like a keyword was read as that keyword: a typo in a property of an entry named `properties` imported, and an entry named `items`, `anyOf`, `allOf` or `patternProperties` had its own keys checked, or its name rejected. This branch reads each as an entry, so the first now raises and the rest import. Say so. Measured on dev 6f76236 and this branch. * fix(json-schema): walk a $ref target that is a properties map by member _validate_supported_shapes walks every $ref target, an unused entry's too. Where the target is a map of schemas by name, such as `#/properties` or `#/$defs/W/properties`, it walked the map as a schema, so a property named like a keyword was read as that keyword. Dev, which never followed a $ref, only walked such a map by name. Each of these raised where dev imports: - a property named `oneOf` beside another, or one named `patternProperties`, under `{"$ref": "#/properties"}`; - a field key on a property named `items`, `definitions`, `$defs`, `anyOf`, `oneOf` or `allOf` of a used `W`, with an unused `{"$ref": "#/$defs/W/properties"}` beside it. A class reads the key there, and dropping the alias imported it. The same held under `#/x-models/...`, `#/components/...` and a data value. Such a target is now walked one member at a time, reading each segment as the walk around it does. Its members' contents are still checked. * fix(json-schema): raise ValueError for a recursive $ref the parser leaves unresolved The parser leaves a $ref back into a type it is still building as a name, the pointer's last segment. Where no model has that name (an array definition, `#/properties/kind`), the field's type stays undefined, and reading its schema raised PydanticUserError. Named `type`, it resolved to the builtin and raised PydanticInvalidForJsonSchema. Dev built a list form beside such a $ref (`["object", "null"]`) as a union of two classes, so it imported. Building one class, as "object" does, made it raise the pydantic error too, where dev imported. Every form now raises the ValueError for a recursive model, naming the field. * test(json-schema): pin what a list form beside a $ref builds as an array or where object fails With the null arm no longer a copy of the $ref, a list form beside one builds what the single type builds, and dev did not: - Where "object" fails to import, the list form now fails too: a comparator on an array whose items are `["object", "null"]` beside a $ref, or on an anyOf whose arm is such a $ref to an array of objects, and a $ref to an array of objects with no properties. Dev built a union of two classes there, which imported. - `["array", "null"]` beside a $ref builds what "array" does: an array of objects at field threshold 0.5, or the target's class with LevenshteinComparator at 0.7. Dev built a union compared with ExactComparator at 1.0. - `["object", "array", "null"]` still builds a union, of two arms where dev built three. The "object" cases pass on dev. The rest fail there. * docs(json-schema): say a list form beside a $ref builds what the single type builds The CHANGELOG documented the null-arm fix for `["object", "null"]` only. It also applies to `["array", "null"]` beside a $ref, which now builds what "array" does: an array of objects at field threshold 0.5, or a $ref to an object as that class with LevenshteinComparator at 0.7, where dev built a union compared with ExactComparator at 1.0. `["object", "array", "null"]` still builds a union, of two arms. Where the single type fails to import, the list form now fails too, where dev's union imported. Say which shapes, add an entry for the recursive $ref that now raises the recursion ValueError, and say that a $ref to a properties map reads it by name. dynamic-models.md states the list-form rule in one sentence. * fix(json-schema): read a member named like a map keyword as a schema in a $ref target walk_target decided whether a $ref target is a map of schemas by name with _is_named_map, which read every segment as a keyword wherever the walk reads a node as a schema. So a member named `definitions`, `$defs` or `dependentSchemas` under `components`, an `x-*` payload or a data value was read as that keyword, and a $ref to it walked its `properties` map as a schema. A property named `items`, `anyOf`, `allOf` or `patternProperties` there was then read as that keyword, and the import raised where dev imports and reads the key: - `{"$ref": "#/components/schemas/definitions"}` from a property, `items` or the root, with a property `items` at threshold 0.9 or `anyOf` at weight 2.0, or properties `allOf` and `b`, or `patternProperties`; - the same under `#/x-models/...`, `#/$defs/W/x-sub/...` and `#/properties/a/default/...`; - `not: {"$ref": "#/components/schemas/definitions/properties"}`. _is_named_map now reads those keywords as a map only as a keyword of a schema, as _position_after does. A `properties` key of any node the walk reads as a schema is still one. All 112 new cases fail on the previous head and pass on dev 6f76236. * fix(json-schema): read a keyword in a $ref pointer only where a schema holds it _is_named_map and _walk_position each read the segments of a $ref pointer their own way, and both read keyword names as keywords at positions that are no schema: - a member named `anyOf`, `oneOf`, `allOf` or `prefixItems` of an `x-*` payload or `#/components/schemas` was read as a list, so the next segment was taken for an index, and a property named `properties` two segments on was read as the keyword. A $ref to `#/x-models/anyOf/properties/properties` raised that threshold 0.9 on its property `items` is not read, where dev reads it; a property named `anyOf` or `patternProperties` there raised a shape error; and a typo on `#/x-models/anyOf/properties/p` imported, where dev raises. - _walk_position read `definitions`, `$defs` and `dependentSchemas` as maps under an `x-*` payload, so `#/x-models/definitions/properties/ items` was checked as an `items` node and raised for a field key. Both now read the pointer with one helper, _map_holders: a key is a keyword only where the node holding it is read as a schema. A `properties` key of any such node holds names, as the walk reads it. The other map keywords hold names only as a keyword of a schema reached from the root through schema keywords, as _position_after reads them. A pointer passes only through objects, so a list keyword before another segment holds an object, read as a schema. _is_property_pointer also counts a property in this reading. TestAKeywordIsReadOnlyWhereASchemaHoldsIt: 63 cases, all pass on dev c70ca6e; 54 fail on the previous head. * fix(json-schema): leave the shape of an entry named properties unchecked, as dev did Reading a `$defs` or `definitions` entry named `properties` as an entry, not as the `properties` keyword of its set of definitions, also checked the entry's own shape, which dev never did: dev read the entry as a map of properties and checked each member instead. So `patternProperties`, or `anyOf` beside `properties`, at the top of such an entry raised ("Unsupported anyOf for field '$defs.properties'") where dev imports, whether a `$ref` reaches the entry or not. walk gains a `shapes` flag, off for such an entry only. Its keys and contents are still checked as an entry's, so a typo in one of its properties still raises, as the CHANGELOG says. test_an_entry_named_properties_keeps_its_own_shape_unchecked: 6 cases, pass on dev c70ca6e, fail on f58142e. (The previous commit's message says 54 of its 63 cases fail on f58142e; the count is 44.) * fix(json-schema): build the scalar a nullable list form beside a $ref to one builds on dev The null arm of a list-form `type` beside a $ref became `{"type": "null"}`, so that `["object", "null"]` beside a $ref to an object builds one class rather than a union of two. Beside a $ref to a scalar, dev's null arm kept the $ref, so every arm parsed as that scalar, and the node built what the single type builds. Dropping the $ref there made the field nullable: - `items: {"$ref": "#/$defs/S", "type": ["array", "null"]}`, with `S` a string, built `list[Optional[str]]`, where dev and `"array"` build `list[str]`; - a required property typed `["object", "null"]` beside a $ref to a number built `Optional[float]`, where dev and `"object"` build `float`. The null arm keeps the $ref again where the end of the $ref chain is a scalar: only scalar types declared, or none with `enum` or `const`, and no keyword that builds an object, an array or a union. 28 new cases in TestAListFormTypeBesideARef, for both orders of both list forms, a string, number and enum target, directly and through an alias. All pass on dev c70ca6e and fail on f58142e. * docs(json-schema): say ["object"] reads model keys, and what stays as on dev - `"type": ["object"]` is rewritten like `["object", "null"]`, so it now reads the model keys too (`Row` at 0.9, where dev built `DynamicModel` at 0.7). The CHANGELOG, dynamic-models.md and the evaluator README named only `["object", "null"]`. - Beside a $ref to a scalar, a nullable list form builds that scalar, as on dev, so a required property stays required. - The shape of a definition entry named `properties` is still not checked, as on dev; only its keys and contents are. - A member of an `x-*` payload or other value named like a keyword is a schema, so a $ref through it reads the `properties` under it as names.
fix(report): use literal document IDs for PDF controls
…atch-default docs(585): numeric and integer schema fields use exact match by default
…cope docs(comparators): say which path compares postal codes exactly
* docs(483): fix the install page floor, extras and verify steps - requires-python is >=3.10 and CI runs 3.10 to 3.14, so every "Python 3.12" mention now says 3.10 or later - list the docsplit, reporting and all extras and what each needs - name all nine core comparators, and say BERT fetches a model - keep only the import check under Verify: examples/ and tests/ are not in the wheel * docs(483): name the model BERTComparator downloads - the default is roberta-large, about 1.4 GB, not distilbert-base-uncased - the README reporting row no longer says HTML reports need the extra
test(591): pin comparator scores on Arabic and Persian text
fix(450): write the results JSONL and report payload as strict JSON when a value is NaN or infinite
fix(from_json): do not force first model arm of Union[A, B, None]
… stays under Changed
fix(406): restore confusion_matrix_calculator as a deprecated shim
Security Scan ResultsASH Security Scan Report
Scan Metadata
SummaryScanner ResultsThe table below shows findings by scanner, with status based on severity thresholds and dependencies:
Report generated by Automated Security Helper (ASH) at 2026-11-20T16:34:45+00:00 |
vawsgit
left a comment
There was a problem hiding this comment.
✅ LGTM!
Reviewed at cbd7532944127e6ad74742494e52f31cb5d2f0da. I found no medium or high defects. Every number below was measured with the head's own src on the import path (stickler.__version__ == "1.0.2"), compared against main (f8a954e, 1.0.1) where a before/after applies.
Version and lockfile
pyproject.toml,src/stickler/__init__.pyand thestickler-evalentry inuv.lockall say 1.0.2.uv lock --checkpasses (167 packages).- CUDA/nvidia platform markers: 25 lines on
main, 25 at head, none changed.exclude-newer-span = "P7D"is unchanged.
CHANGELOG claims, run on main → head
- #560
NumericComparator:"١٢٥٠"vs"1250"0.0 → 1.0;"−1250"vs"-1250"0.0 → 1.0;"(-1250)"vs"-1250"0.0 → 1.0. #534Truevs1:InvalidOperation→ 0.0. - #573
Union[A, B, None]with B-shaped data:from_jsonbuilt A → builds B. - #406
Anysub-field["a","b"]vs[]: 1 FN → 2 FN (matches top level).DictwithLevenshteinComparator:TypeError→ 1 FD. - #407 nullable object with
match-threshold: 0.93:DynamicModelat 0.7 →Rowat 0.93. A typo'd key in$defsnow raisesValueError. - #576 NaN/inf in JSONL: bare
NaN/Infinity→ strict JSON parses. - #596 shim import emits
DeprecationWarning;import sticklerunder-W error::DeprecationWarningdoes not load it. - #549 new
_json_for_scriptescape gives the same output as 1.0.1 on 20,000 random payloads and is 5.4× faster on a 5,000-document payload.
Semver (patch claim)
- An AST comparison of public functions, classes and signatures in
srcfound nothing added and no signature changed. Removed names are unexported internal helpers that nothing called onmain. The deletedstructured_object_evaluator/utils.pywas never importable (theutils/package shadowed it);utils.compare_jsonstill resolves with an identical body.
Commits without a PR
- 45 of 46 first-parent commits in
cf90773..cbd7532map to merged PRs. The one direct push iscbd7532, the version bump RELEASING.md requires; it changes only the version strings and the CHANGELOG headings and link definitions.
Tests, build, CI
- Full suite with
--extra llm --extra bert: 5584 passed, 3 skipped (strands_evalsnot installed, 2 placeholders), 1 xfailed. Docs tests: 88 passed.ruff check .clean;docs/check_links.pyexit 0. uv buildwheel installs in a clean 3.12 venv, imports as 1.0.2 from site-packages, shipsinteractive/main.jsandstyling/style.css, and generates a report from NaN data with no NaN tokens on the page.- Nothing on
mainis lost on merge (git diff origin/main cf90773is empty). CI matrix andrequires-pythonare unchanged.security.yamlis stricter: nocontinue-on-erroron the ASH scan, a check that bandit, detect-secrets and semgrep actually ran, and a new cooldown job.
Mutation tests (each reverted afterwards)
- #573: drop
len(union_args(annotation)) == 1inconfiguration_helper.py→ 5 of 6 tests intest_from_json_union_of_models.pyfail. - #560: make the other-script branch in
numeric.pyreturnNone→ 103 of 472 numeric/Arabic tests fail. - #576: remove
allow_nan=Falsefrom_jsonl_line→ 15 tests fail. - Scores on 400 random list-of-model document pairs are byte-identical between
mainand head.
Non-blocking (low)
- The PR body's Security line says multidict 6.9.1 fixes GHSA-54p9-h82j-f925. That bump is only in
uv.lock;pyproject.tomlchanges only the version, so installers of 1.0.2 do not get it. The CHANGELOG correctly omits it. If the GitHub release notes are copied from the PR body, say it applies to dev and CI only. uv.lockexclude-newernow reads0001-01-01T00:00:00Z(was2026-07-07T13:31:42Z) andrevisionmoved 3 → 5, from the Dependabot bump in #470. AGENTS.md asks to restore the timestamp, but uv itself annotates the value as having no effect alongsideexclude-newer-span, and the new cooldown job checks the span.- The CHANGELOG
### Deprecatedentry for theconfusion_matrix_calculatorshim links #406; the shim came in #596.
Not checked: whether #407's new ValueErrors belong in a patch release (the CHANGELOG documents them), and a single date range whose two ends differ in time-zone awareness (#546).
Summary
Scoring and comparators
Anysub-field warns instead of raisingTypeError(fix(400): classify a list element's sub-field through the top-level dispatcher #406)LLMComparatorscores a reply as a match only when it is exactlytrue(fix(506): score an LLM reply as a match only when it is exactly "true" #583)NumericComparatorreads non-ASCII digits (fix: read non-ASCII digits in NumericComparator #560) and handles boolean inputs (fix: handle boolean inputs in NumericComparator #534)DateComparatoraligns naive and aware dates in range paths (fix(comparators): align naive/aware dates in DateComparator range paths #546)from_jsonno longer forces the first model arm ofUnion[A, B, None](fix(from_json): do not force first model arm of Union[A, B, None] #573)JSON Schema import
$defsentries are checked, and model keys no class reads raise or warn with where to put them (fix(json-schema): read model keys on nullable objects, check $defs entries, flag model keys no class reads #407)Results, reports and output
document_count(fix(report): colour executive summary cards and read document_count #474); gallerydocument_fileskeys and paths are coerced (fix(454): coerce document_files keys and paths in the gallery #455);_json_for_scriptusesstr.replace, about ten times faster than the 1.0.1 escape (fix(report): replace translate with str.replace in _json_for_script #549)compare_withwarnings point at the caller's line (fix(warning): attribute compare_with warnings to caller line (#541) #553)pip installextras are quoted for zsh, and optional comparators install through their extras (fix(482): quote every pip extras install and use the extras for optional comparators #595)Security
print_confusion_matrix_htmlescapes its output (fix(pretty_print): escape HTML in print_confusion_matrix_html output #548)Deprecated
stickler.structured_object_evaluator.models.confusion_matrix_calculatoris back as a shim with aDeprecationWarning, to be removed in 1.1.0 (fix(406): restore confusion_matrix_calculator as a deprecated shim #596)chore(deps): uv group (#470), certifi (#575), opentelemetry-api (#580), astral-sh/setup-uv (#537)
ci: lint fails on ruff findings (#567), the security scan fails on new findings (#568), the uv dependency cooldown is enforced (#569)
refactor (no runtime change): bulk evaluator failure records (#528), accumulator keyed-pair state (#532), object dispatch and field classification (#535), model factory validation (#536), unused helpers removed (#542), unimportable
utils.pydeleted (#547)test: comparator scores pinned on Arabic and Persian text (#597)
docs: list contract in one place (#419); default field threshold per declaration style (#577); install page floor, extras and verify steps (#593); 1.0.2 changes retargeted to 1.1.0 (#477); runnable examples (#527, #531, #550); SemanticComparator fallback warning (#545); post-1.0 release docs (#562); IBAN example (#581); NumericComparator tolerance (#582); postal codes (#586); numeric schema fields exact match (#588); bare int and float fields compare as text (#594)
Version
1.0.1→1.0.2(patch: fixes, docs and dependency bumps, no new public API). Not breaking under the rule proposed in #587, but some results move where the code contradicted the docs (#406, #560, #583), the JSONL now writesnullfor NaN and infinity (#576), and JSON Schema keys the docs never allowed now raise (#407). Each is spelled out in the CHANGELOG.Test plan
uv lock --check, version 1.0.2 by import path, ruff, full suite (5490 passed), docs tests (88 passed)