Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
b74079d
fix(400): classify a list item's primitive sub-field through the disp…
sromoam Oct 15, 2026
e7810fa
fix(400): widen the CHANGELOG and tests to every path the guard covers
sromoam Oct 15, 2026
89fd840
Merge remote-tracking branch 'origin/dev' into fix/400-any-dict-in-li…
sromoam Oct 16, 2026
3145138
Merge origin/dev into fix/400-any-dict-in-list-item
sromoam Oct 28, 2026
e2377a5
Merge origin/dev into fix/400-any-dict-in-list-item
sromoam Nov 17, 2026
2c43b0e
fix(400): read list sub-fields as top level does, and keep empty list…
sromoam Nov 17, 2026
992fc09
test(400): pin list sub-field counts instead of comparing two dispatc…
sromoam Nov 17, 2026
e30e6be
refactor(400): delete the list sub-field classifier, which has no caller
sromoam Nov 17, 2026
2452289
test(400): reword a comment the docs-drift guard flags
sromoam Nov 17, 2026
8252c77
docs(400): list every count the list path moves, and narrow the parit…
sromoam Nov 17, 2026
ad608ac
fix(400): count a model of another class in a list sub-field as dev does
sromoam Nov 17, 2026
0999f7a
fix(400): count every pair under aggregate when a sub-field mixes shapes
sromoam Nov 17, 2026
a9a9542
test(400): pin a non-recursing compare_with override, update a docstring
sromoam Nov 17, 2026
b26a6b5
docs(400): describe the other-class and mixed-shape counts, fix the e…
sromoam Nov 17, 2026
95f16be
fix(400): leave a list-annotated sub-field's other-class pairs to the…
sromoam Nov 17, 2026
0a52737
fix(400): read only a non-list sub-field's empty values by value
sromoam Nov 17, 2026
01b2c9f
docs(400): scope the list sub-field rules to non-nested, non-list fields
sromoam Nov 17, 2026
9a4b615
test(400): pin a list against None in an Any sub-field at one FN
sromoam Nov 17, 2026
b643ce2
docs(400): widen the AttributeError paragraph, and name the TP it now…
sromoam Nov 17, 2026
1f0973d
docs(400): file the list sub-field entry under Fixed, not Breaking
sromoam Nov 17, 2026
f755ea4
docs(400): say a subclass for its base is a TP in an Any sub-field
sromoam Nov 17, 2026
f98703e
test(400): pin the base-first list, the other-class pair TP and the w…
sromoam Nov 17, 2026
2df3183
refactor(400): drop a model check no matched pair can fail
sromoam Nov 17, 2026
f17b715
test(400): pin an other-class pair at the default threshold as a TP
sromoam Nov 17, 2026
b756a79
docs(400): say an other-class pair whose unset field matches is a TP
sromoam Nov 17, 2026
e069405
docs(400): name the list pairing TP in the different-classes warning
sromoam Nov 17, 2026
f9f0fc3
docs(400): name the fixed-score override row and the ground-truth crash
sromoam Nov 17, 2026
e40c334
fix(400): keep a self-scoring non-model GT item out of field classifi…
sromoam Nov 17, 2026
e414a7c
docs(400): name the List[Any] and other-class crash shapes, and the o…
sromoam Nov 17, 2026
bfea4ad
docs(400): say a whitespace string or empty tuple against [] is no lo…
sromoam Nov 17, 2026
9ae4385
docs(400): call the fixed-score override row's TP unsettled, not fixed
sromoam Nov 17, 2026
1269607
docs(400): say the ground-truth raise needs a model first and a match…
sromoam Nov 17, 2026
776449e
docs(400): list every null value an empty tuple or whitespace string …
sromoam Nov 17, 2026
eee3e1b
Merge remote-tracking branch 'origin/dev' into fix/400-any-dict-in-li…
sromoam Nov 17, 2026
e34e9b8
docs(400): name every fixed-score override row as a TP, as without th…
sromoam Nov 17, 2026
5dc6c0e
test(400): pin every fixed-score override row at a TP
sromoam Nov 17, 2026
0100113
docs(400): except a union field two classes declare differently from …
sromoam Nov 17, 2026
3446fe5
test(400): pin a union field two classes declare differently, in both…
sromoam Nov 17, 2026
ce4a97d
docs(400): rewrap an over-long CHANGELOG line
sromoam Nov 17, 2026
f39c15f
docs(400): name the fixed crash for a self-scoring non-model ground-t…
sromoam Nov 17, 2026
eeb73f9
test(400): pin a Sequence sub-field at per-element counts, as at top …
sromoam Nov 17, 2026
9f85e15
test(400): pin an Optional[Annotated[Inner, Field(...)]] sub-field as…
sromoam Nov 17, 2026
e2d3287
docs(400): state the list sub-field rule in the CHANGELOG, with examples
sromoam Nov 17, 2026
5814586
docs(400): say which list sub-fields are read by value, by example
sromoam Nov 17, 2026
15ffdc2
fix(400): count a list an override element cannot score as dev did
sromoam Nov 17, 2026
57d5c1c
test(400): pin an override element's unscorable list at dev's FD
sromoam Nov 17, 2026
cd3fb59
docs(400): say an override element's unscorable list counts as before
sromoam Nov 17, 2026
f32912a
docs(400): except plain pydantic elements from the non-model pair TP
sromoam Nov 17, 2026
b0890cc
docs(400): note the comparator fallback in the refactoring record
sromoam Nov 17, 2026
fac2680
test(400): pin a dispatched sub-field of mixed shapes leaving the oth…
sromoam Nov 18, 2026
780c213
test(400): pin an extra field on a predicted list element as uncounted
sromoam Nov 18, 2026
f1aa451
test(400): pin a fixed-score element's sub-field warning as without it
sromoam Nov 18, 2026
7b8841c
docs(400): scope the CHANGELOG's mixed-shapes case to every sub-field
sromoam Nov 18, 2026
5654027
docs(400): say the CHANGELOG's uncounted field is an extra one on the…
sromoam Nov 18, 2026
a5e8aa0
docs(400): say a fixed-score element's sub-fields now warn as without it
sromoam Nov 18, 2026
9ab8ec9
docs(400): say which pairs of model classes warn under a fixed-score …
sromoam Nov 18, 2026
dfc5cc1
test(400): check the fixed-score warning and its raise in separate tests
sromoam Nov 18, 2026
ff33e1b
fix(400): count a fixed-score model a fixed-score element cannot scor…
sromoam Nov 18, 2026
5746007
test(400): pin a fixed-score model under a fixed-score element at dev…
sromoam Nov 18, 2026
823c451
docs(400): say a fixed-score element's model pair the dispatcher rais…
sromoam Nov 18, 2026
b9ab522
fix(400): count a list sub-field the first element's class does not r…
sromoam Nov 18, 2026
c8e5d72
test(400): pin a list sub-field the first element's class does not ro…
sromoam Nov 18, 2026
efa47ca
docs(400): say a list sub-field the first element's class does not ro…
sromoam Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
docs(400): say a list sub-field the first element's class does not ro…
…ute 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.
  • Loading branch information
sromoam committed Nov 18, 2026
commit efa47ca237dce5d931938a02292f6b5d586271d0
19 changes: 14 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ Each release links to full notes on the
`Any` or `Optional[Annotated[Inner, Field(...)]]`, as it already was in
`Optional[Inner]`;
- a field that the classes of a union declare with different annotations
is read by the first matched ground-truth element that declares it. With
`AStr(x: Optional[str])` listed before `BList(x: Optional[List[str]])`,
`BList(x=["a", "b"])` against `BList(x=["a", "c"])` now counts `x` as
1 TP and 1 FD, not 1 TP, as it does with `BList` first.
is read by the first matched ground-truth element that declares it, or
by each pair's own class when the list's first element is not matched.
With `AStr(x: Optional[str])` listed before
`BList(x: Optional[List[str]])`, `BList(x=["a", "b"])` against
`BList(x=["a", "c"])` now counts `x` as 1 TP and 1 FD, not 1 TP, as it
does with `BList` first.

In a list of models, whatever the sub-field's type, a matched prediction
that lacked a field of the first ground-truth element's class raised
Expand Down Expand Up @@ -100,7 +102,14 @@ Each release links to full notes on the
`Leaf(d=[Inner(a="x")])` against `Leaf(d=[Point(x=1)])` is a TP. The score
is 1.0 before and after in each of these cases. A sub-field routed as a
nested model or a list, such as `Optional[Leaf]` or `List[Any]`, still
raises on them, as before.
raises on them, as before, if the list's first element's class declares it
that way too. If that class does not, the pair counts the same way, since
only that class's fields were read before. So a fixed-score subclass's
`List[Any]` field, listed after its base, which lacks the field, counts one
FD for `[Inner(a="x"), "b"]` against `["a", "b"]`, where it was not
counted. A union class's `Optional[List[Any]]` field counts one FD there,
as before, when the list's first element is of a class that declares the
field as `Optional[str]` or `Any`.
Every sub-field of such an element now also gets the dispatcher's
warnings, as it does without the override and at top level. A dict or a
plain pydantic model its comparator cannot score, or two models of
Expand Down
8 changes: 6 additions & 2 deletions docs/docs/Advanced/classification-logic.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ where a subclass arrived for its base, which `Optional[Pet]` accepts.
two models of one class would raise, such as two models whose fields hold
those lists, the field counts one TP or FD from the ground-truth model's
own `compare_with()`. That runs when the model's class also returns a
fixed score, and raises the same way when it recurses.
fixed score, and raises the same way when it recurses. A field that goes
to the dispatcher directly, such as `List[Any]`, raises on these pairs,
unless the list's first element's class does not declare it as a model
or a list, as with a subclass's field after its base. Then it counts
them the same way.

Whether a refused object should still *pair* inside a list, or should instead
be counted as a missed ground truth plus an invented prediction, is the open
Expand Down Expand Up @@ -222,7 +226,7 @@ These are computed at every node of the result tree, from that node's own counts

**List order** -- Order does not matter. The Hungarian algorithm finds the optimal pairing regardless of element position.

**Nested lists** -- For `List[StructuredModel]`, the Hungarian algorithm pairs objects at the list level, then each matched pair is evaluated recursively: every field the ground-truth element's class declares is classified by the same dispatcher as a top-level field, so it follows the rules on this page. A field annotated as a model, a list, or an `Optional` model or union of models, such as `Optional[Inner]`, `List[str]`, `Optional[Union[A, B]]` or `Union[A, B, List[str]]`, goes to the dispatcher directly. Any other field, such as `Any`, `object`, `Union[A, B]`, `Sequence[str]` or `Optional[Annotated[Inner, Field(...)]]`, is read by its value first. If the classes in one list annotate a field differently, the first matched ground-truth element that declares it decides which. These cases are counted differently from top level:
**Nested lists** -- For `List[StructuredModel]`, the Hungarian algorithm pairs objects at the list level, then each matched pair is evaluated recursively: every field the ground-truth element's class declares is classified by the same dispatcher as a top-level field, so it follows the rules on this page. A field annotated as a model, a list, or an `Optional` model or union of models, such as `Optional[Inner]`, `List[str]`, `Optional[Union[A, B]]` or `Union[A, B, List[str]]`, goes to the dispatcher directly. Any other field, such as `Any`, `object`, `Union[A, B]`, `Sequence[str]` or `Optional[Annotated[Inner, Field(...)]]`, is read by its value first. If the classes in one list annotate a field differently, the first matched ground-truth element that declares it decides which, or, when the list's first element is not matched, each pair's own class does. These cases are counted differently from top level:

- A field the predicted element's class does not declare (an extra field) is not counted, where at top level it adds an FA to the root `overall`.
- In a field read by value, a model of another class than the ground truth's is one TP or FD, from the ground-truth model's `compare_with()` score against the field's threshold, and `aggregate` counts it the same way rather than per field. That score reads a field the prediction lacks as `None`, so `Search(query="hotels")` against `Browse(url="x.com")` scores `0.0` and is an FD. A ground-truth field left `None` matches the missing one, so `Inner(a="x", b=None)` against `Other(c="z")` scores `0.5`, from `b`, and is a TP at the default threshold of `0.5`. It scores only the ground truth's own fields, so `Pet(name="tom")` against its subclass `Cat(name="tom", lives=9)` scores `1.0` and is a TP, as the warning under [Objects of different classes](#objects-of-different-classes) says. A field that goes to the dispatcher directly counts such a pair as top level does.
Expand Down
2 changes: 1 addition & 1 deletion docs/structured_model_REFACTORING.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class StructuredModel(BaseModel):

Older callers (and many tests) reach for private methods on `StructuredModel` such as `_dispatch_field_comparison`, `compare_recursive`, `_collect_enhanced_non_matches`, `_add_derived_metrics_to_result`, `_format_for_evaluator`, etc. The ones that still have callers are kept as short wrappers that forward the call to the component that does the work. They are retained for backward compatibility; new code should call the component directly. Five private methods that nothing called have been removed, as listed below.

Three wrappers that nothing called were removed in [#390](https://github.com/awslabs/stickler/pull/390): `_calculate_list_confusion_matrix`, `_calculate_nested_field_metrics` and `_calculate_single_nested_field_metrics`. Their work is done by `StructuredListComparator` for a list of models, including the fields inside matched items, and by `FieldComparator.compare_structured_field` for a single nested model. [#398](https://github.com/awslabs/stickler/pull/398) removed `_calculate_object_level_metrics`, an uncalled copy of `StructuredListComparator._calculate_object_level_metrics`. [#406](https://github.com/awslabs/stickler/pull/406) removed `_classify_field_for_confusion_matrix` and `confusion_matrix_calculator.py`, which held only the method it delegated to: `StructuredListComparator` now classifies a matched item's sub-fields through `_dispatch_field_comparison`. In a sub-field that is neither nested nor list-annotated, such as `Any`, `StructuredListComparator._dispatch_pairs` first reads an empty list as null, and scores two models of different classes with `compare_with()` rather than the dispatcher. If the dispatcher raises there, which only an item whose `compare_with()` does not recurse reaches, the pair counts as the removed classifier counted it: two lists from the field's comparator (`_comparator_result`), and two models of one class from their own `compare_with()` (`_compare_with_result`, which also scores two models of different classes).
Three wrappers that nothing called were removed in [#390](https://github.com/awslabs/stickler/pull/390): `_calculate_list_confusion_matrix`, `_calculate_nested_field_metrics` and `_calculate_single_nested_field_metrics`. Their work is done by `StructuredListComparator` for a list of models, including the fields inside matched items, and by `FieldComparator.compare_structured_field` for a single nested model. [#398](https://github.com/awslabs/stickler/pull/398) removed `_calculate_object_level_metrics`, an uncalled copy of `StructuredListComparator._calculate_object_level_metrics`. [#406](https://github.com/awslabs/stickler/pull/406) removed `_classify_field_for_confusion_matrix` and `confusion_matrix_calculator.py`, which held only the method it delegated to: `StructuredListComparator` now classifies a matched item's sub-fields through `_dispatch_field_comparison`. In a sub-field that is neither nested nor list-annotated, such as `Any`, `StructuredListComparator._dispatch_pairs` first reads an empty list as null, and scores two models of different classes with `compare_with()` rather than the dispatcher. If the dispatcher raises there, which only an item whose `compare_with()` does not recurse reaches, the pair counts as the removed classifier counted it: two lists from the field's comparator (`_comparator_result`), and two models of one class from their own `compare_with()` (`_compare_with_result`, which also scores two models of different classes). So does a pair in a nested or list-annotated sub-field that the list's first element's class does not declare that way (`may_fall_back`), since the removed classifier read only that class's fields. When the first element's pair is not a match, each pair is read by its own class's annotation (`reader=None`).

## Component Responsibilities

Expand Down
Loading