Skip to content

docs: state the list contract in one place, and correct the claims that disagree with it - #419

Merged
sromoam merged 32 commits into
devfrom
docs/lists-contract
Nov 18, 2026
Merged

sromoam merged 32 commits into
devfrom
docs/lists-contract

Conversation

@sromoam

@sromoam sromoam commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Refs #330.

What this does

Docs only. The rules for list fields were spread over nine pages that disagreed with each other and with the code. They now live in one table, The list contract, with a short Known gaps note for the four places the code does not yet follow it. Other pages link to the table instead of restating it, and every claim that disagreed with measured output on dev is corrected.

No behaviour change. The only .py edit is the eval_for / evaluate docstrings in src/stickler/auto/facade.py. User docs carry no issue numbers. The issues below are the record, and the CHANGELOG entry links them.

The contract

Aspect Rule
Pairing A list field's elements are Hungarian-paired, so their order does not matter. A nested list element is one value, and on the zero-config path it, and a list in an Any field, must match exactly. None/NaN elements are removed first.
Bar List[StructuredModel]: the element class's match_threshold, which a runtime value does not change. Other lists on a StructuredModel declared in Python: the field threshold, else the comparator's, else 0.5 with ComparableField() or the class match_threshold without it. JSON Schema and zero-config have their own defaults.
Counts Paired: TP or FD. Unpaired: FN or FA. Null lists: both null is one TN. One null side gives one FN or FA per element.
Recursion Only TP StructuredModel pairs are descended into. aggregate holds TP items' leaves and falls back to the list node when nothing was accepted.
Score sum(pair scores) / max(n_gt, n_pred), never clipped as a whole. In Python, clip is on by default for primitive lists and off for dict and plain-model lists. On List[StructuredModel] it has no effect (a known gap).
Reports field_comparisons: one row per primitive, dict or plain-model element, or per leaf of a TP item, plus one object row per FD, FN or FA item. non_matches keeps only the FD, FN and FA rows.

Main corrections

  • A list without ComparableField pairs against the class match_threshold (0.7), not 0.5.
  • Order: scoped to a list field's elements (nested lists and zero-config Any lists are order-sensitive).
  • Runtime match_threshold: sets only matched on a StructuredModel. On a plain class it also gates List[Model] and List[dict] pairing and nested plain-model and dict field thresholds, while a primitive list keeps its inferred threshold.
  • clip_under_threshold defaults to off on dict and plain-model fields in Python. With x-aws-stickler-infer-unspecified, JSON Schema takes it from inference.
  • Equal-length lists can still give FN/FA when an element is None.
  • weighted_score on list element rows, and aggregate leaving out FN/FA items beside an accepted sibling.
  • Hungarian example: counts nested under overall, a measured Step 4 List Score, and a checkable result block. A field threshold on List[StructuredModel] raises ValueError.

Known gaps (code, tracked in issues)

Merge with dev

Merged origin/dev (8c56dfa6) in 1dd90898 rather than rebasing, so no force-push. Dev's side was taken in every conflict where dev already had corrected text: threshold-gated-evaluation.md and bulk-evaluation.md whole, the mean_score bullet, the field-threshold bullets, the threshold-boundary edge case, and the CHANGELOG. The CHANGELOG entry is under [Unreleased].

How numbers were measured

Every claim was re-measured on the merged tree, and where noted on dev 8c56dfa6. Each script printed inspect.getfile(stickler) and pointed into the tree it measured.

Checks

  • ruff check .: clean.
  • pytest (excluding docs build): 4087 passed, 13 skipped, 1 xfailed.
  • pytest tests/test_docs_build.py: 77 passed.
  • docs/check_links.py: exit 0, with only the 6 tolerated griffe warnings.

@sromoam sromoam added this to the 1.0.1 (Minor) milestone Oct 16, 2026
@sromoam
sromoam requested a review from digalaviz October 16, 2026 21:19
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Security Scan Results

ASH Security Scan Report

  • Report generated: 2026-11-18T17:56:46+00:00
  • Time since scan: 2 minutes

Scan Metadata

  • Project: ASH
  • Scan executed: 2026-11-18T17:54:08+00:00
  • ASH version: 3.1.2

Summary

Scanner Results

The table below shows findings by scanner, with status based on severity thresholds and dependencies:

  • Severity levels:
    • Suppressed (S): Findings that have been explicitly suppressed and don't affect scanner status
    • Critical (C): Highest severity findings that require immediate attention
    • High (H): Serious findings that should be addressed soon
    • Medium (M): Moderate risk findings
    • Low (L): Lower risk findings
    • Info (I): Informational findings with minimal risk
  • Duration (Time): Time taken by the scanner to complete its execution
  • Actionable: Number of findings at or above the threshold severity level that require attention
  • Result:
    • PASSED = No findings at or above threshold
    • FAILED = Findings at or above threshold
    • MISSING = Required dependencies not available
    • SKIPPED = Scanner explicitly disabled
    • ERROR = Scanner execution error
  • Threshold: The minimum severity level that will cause a scanner to fail
    • Thresholds: ALL, LOW, MEDIUM, HIGH, CRITICAL
    • Source: Values in parentheses indicate where the threshold is set:
      • global (global_settings section in the ASH_CONFIG used)
      • config (scanner config section in the ASH_CONFIG used)
      • scanner (default configuration in the plugin, if explicitly set)
  • Statistics calculation:
    • All statistics are calculated from the final aggregated SARIF report
    • Suppressed findings are counted separately and do not contribute to actionable findings
    • Scanner status is determined by comparing actionable findings to the threshold
Scanner Suppressed Critical High Medium Low Info Actionable Result Threshold
bandit 0 0 0 0 6930 0 0 PASSED MEDIUM (global)
cdk-nag 0 0 0 0 0 0 0 PASSED MEDIUM (global)
cfn-nag 0 0 0 0 0 0 0 MISSING MEDIUM (global)
checkov 0 0 0 0 0 0 0 PASSED MEDIUM (global)
detect-secrets 0 0 0 0 0 0 0 PASSED MEDIUM (global)
grype 0 0 0 0 0 0 0 MISSING MEDIUM (global)
npm-audit 0 0 0 0 0 0 0 PASSED MEDIUM (global)
opengrep 0 0 0 0 0 0 0 MISSING MEDIUM (global)
semgrep 3 0 0 0 0 0 0 PASSED MEDIUM (global)
syft 0 0 0 0 0 0 0 MISSING MEDIUM (global)

Report generated by Automated Security Helper (ASH) at 2026-11-18T17:56:46+00:00

# Conflicts:
#	CHANGELOG.md
#	docs/docs/Getting-Started/Contributing/architecture.md
#	docs/docs/Guides/Evaluation/understanding-results.md

@vawsgit vawsgit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs changes

The PR was measured at 003b5f1. That commit predates #364 (merged 2026-10-20, already in this PR's base) and #421 (the 1e-10 tolerance on every gate, now on dev). As a result, several pages describe fixed bugs as open, or give counts the code no longer produces. Measured on head 260fc04 and on dev 52e8ef4 with this PR merged, with the imported path printed each time.

The PR also conflicts with dev in 6 files (11 hunks): CHANGELOG.md, classification-logic.md (2), threshold-gated-evaluation.md (5), thresholds-and-metrics.md, bulk-evaluation.md and understanding-results.md. In every hunk, dev already has the corrected text, including #403's mean_score rewrite. Resolving in this PR's favour would publish the stale claims. Please rebase, take dev's side in those hunks, and re-measure.

Inline: 4 high (fixed bugs described as open, #421 tolerance) and 9 medium. Outside the diff: the Threshold Cheat Sheet (thresholds-and-metrics.md:432) says the runtime match_threshold "Overrides model threshold". That contradicts this PR's Key Rule 3 and #416: with Prod.match_threshold=0.4, evaluate(match_threshold=0.9) still gives TP at 0.5.


**Where `dev` does not yet follow it.** Each gap is a code change, not a docs change, and links its tracking issue where one exists:

- **Reports for primitive, dict and plain-model lists** are built from a second pairing that compares elements by equality against a `0.7` bar, not the field's comparator and bar. Rows can disagree with the counts: with `threshold=0.6`, `["abcde"]` vs `["abcxy"]` (similarity `0.6`) counts a TP but is reported as an FD with `similarity_score` `0.0`. Fixed by [#364](https://github.com/awslabs/stickler/pull/364).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High: the two bullets at lines 54-55 under "Where dev does not yet follow it" describe report bugs that #364 already fixed. #364 is in this PR's base.

On head, tags: List[str] = ComparableField(LevenshteinComparator(), threshold=0.6) with ['abcde'] vs ['abcxy'] gives a row with match true, score 0.6, and empty non_matches. It does not give an FD with similarity_score 0.0. outers[0].inner carries a bool False, not the string 'True'. Remove both bullets.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, removed both in a17dc85. Re-measured with dev merged in: ['abcde'] vs ['abcxy'] at threshold 0.6 gives a row with match true, score 0.6 and no non_matches, and outers[0].inner carries a bool. The gaps that still reproduce are now one short note under the table (see the thread on line 52).

| `match` | bool | Whether the score met the threshold. |
| `score` | float | Raw similarity score. |
| `weighted_score` | float | Score multiplied by the field's weight. |
| `match` | bool | Whether the row's own classification is TP or TN: a value or object row met its threshold; a list row had every element paired as a TP ([Reports](../../Advanced/classification-logic.md#list-contract)). On `dev` a list row inside a list item still carries the string `"True"`/`"False"` from its score against the field threshold, and primitive, dict and plain-model element rows come from an equality pairing; [#364](https://github.com/awslabs/stickler/pull/364) brings both to this rule. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High: this row says dev still emits the string 'True'/'False' for a list row inside a list item, and builds element rows from an equality pairing, with #364 to fix both. Both statements are false in this PR's base.

On head, match is a bool, and primitive element rows use the field's comparator and threshold (score 0.6, match true at threshold 0.6).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Dropped the "On dev" sentence in 0597663, along with the equality-pairing claim and the #364 link. The row now states only the rule: match is true when the row's own classification is TP or TN, so a list row is false when any element is FD, FN or FA. That matches dev, where match is a bool and primitive element rows use the field's comparator and threshold.

### Good Match (similarity >= 0.8)
| GT | Pred | Pair similarity | Classification |
|----|------|-----------------|----------------|
| `("PROD-001", "Laptop", 999.99)` | `("PROD-001", "Laptop Computer", 999.99)` | `0.7999999999999999` | **FD** |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High: with #421 on dev, the Laptop pair (0.7999999999999999 vs threshold 0.8) is a TP, not an FD.

On dev with this PR merged, using this page's own models and data: products overall gives tp=1 fd=2 fn=0, not fd=3, and price is a TP. The same claim is repeated at line 101 ("the object gate is a bare >="), at line 212, and at CHANGELOG.md:305. The 0.79 variant is correct on both trees.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took dev's text for the whole page when merging dev in (1dd9089). The worked scenario now has Laptop as a TP, because 0.7999999999999999 meets 0.8 through the rounding tolerance. The bare >= line at 101 and the boundary note at 212 are gone. Re-measured with the page's own models: products tp=1 fd=2 fn=0, cm_precision 0.3333, and name is an FD at 0.4. d7dd08b rewrote the CHANGELOG entry, and it no longer mentions the Laptop pair.

**TN in object matching** -- A TN is absence of evidence, not evidence of a match. Fields absent on both sides are excluded from the weighted object similarity used by Hungarian matching. If every field is absent, the similarity is defined as `1.0`.

**Threshold boundary** -- A similarity score exactly equal to the threshold counts as a match (TP).
**Threshold boundary** -- A similarity score exactly equal to the threshold counts as a match (TP). Scores are floats, so one that prints as the threshold can sit just below it: the Laptop pair in [How Below-Threshold Pairs Are Classified](threshold-gated-evaluation.md#worked-scenarios) is `0.7999999999999999` against `0.8` and counts FD. The element gate in a primitive list allows a `1e-10` tolerance; the object and field gates do not ([#417](https://github.com/awslabs/stickler/issues/417)).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High: on dev, every gate uses the 1e-10 tolerance (#421), not only the primitive-list element gate. That includes the object and field gates and EvalResult.matched.

Take a str field whose comparator returns 0.7+0.1, with threshold 0.8. Head gives fd=1, and dev with this PR merged gives tp=1. A nested StructuredModel field gate flips the same way. The gap bullet at line 59 (0.7999999999999999 vs 0.8 is FD) is stale for the same reason.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took dev's threshold-boundary text in 1dd9089. It says every gate uses the 1e-10 tolerance and links Meeting a Threshold. a17dc85 dropped the line 59 bullet, and the Bar row now links that section instead of restating it.

```

**What it gates:** Same as Model Match Threshold, but applied at runtime. Overrides the class-level `match_threshold` for this evaluation.
**What it gates:** `EvalResult.matched` (`overall_score >= match_threshold`). On the zero-config path (a plain pydantic class) it also becomes the `match_threshold` of every inferred element model, so it decides TP vs FD for `List[Model]` elements at every nesting level. A `StructuredModel` element class keeps its own `match_threshold` for pairing, and the runtime value then drives only `matched` ([#416](https://github.com/awslabs/stickler/issues/416)).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: "What it gates" lists only matched and List[Model] element TP/FD.

On the zero-config path, the runtime match_threshold is also the field threshold of nested BaseModel and Dict fields. Example: a plain Inv with an addr (BaseModel) field and a meta (Dict) field.

  • At match_threshold=0.5, both are TP, with precision 1.0.
  • At 0.95, both are FD, with precision 0.5.

overall_score is 0.8258 in both runs. auto/README.md:80 and :84 already document this behaviour. The edited facade.py:279-286 and :332-335 docstrings leave it out too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. "What it gates" now covers both class kinds. On a StructuredModel class the runtime value sets only matched. On a plain pydantic class it also decides TP vs FD for List[Model] and List[dict] elements at every nesting level, and sets the field threshold of nested plain-model and dict fields. A primitive list keeps the threshold inferred from its element type and name (0.7 for tags: List[str], 0.6 for notes: List[str]), and explain() shows the resolved values. Key Rule 3, the precedence rows, the cheat sheet and both facade docstrings now say the same (789509f, 5528a7e, 174ed08, 3218bc4). Measured on your two-field Inv: explain() reports 0.5 and 0.95, both fields are TP at 0.5 and FD at 0.95, and overall_score does not change. A List[dict] field is TP, TP and FD at 0.3, 0.5 and 0.95, while a List[str] stays at 0.7.

- `name`: TP (similarity ~0.9)
- `price`: TP (exact match)
- **The Laptop pair misses by a rounding error.** It prints as `0.800` but is just below `0.8`, and the object gate is a bare `>=` ([#417](https://github.com/awslabs/stickler/issues/417)). Its `name` similarity is only `0.4`; `product_id` and `price` carry it.
- **Equal-length lists cannot produce FN or FA.** Every element gets a partner, so `Cable` is an FD against `New Product`, not an FN plus an FA.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: "Equal-length lists cannot produce FN or FA" is false when an element is None. None elements are removed before pairing, as the contract's own Pairing row says. List[Optional[P]] with [P('1'), None] vs [P('1'), P('2')] gives tp=1 fa=1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sentence went with dev's side in the merge. Dev's text and the thresholds-and-metrics worked example made the same claim, so I qualified both (310a741). threshold-gated now opens that paragraph with "Once None elements are removed". thresholds-and-metrics says FN and FA are impossible for an equal-length list with no None elements, and that unmatched items appear only when the lists differ in length once None elements are removed. Measured your [P('1'), None] vs [P('1'), P('2')]: tp=1 fa=1.


- **TP vs FD classification:** If `similarity >= threshold`, the field is a True Positive. Otherwise, it's a False Discovery.
- **Score clipping:** When `clip_under_threshold=True` (the default), scores below the threshold are zeroed out in the weighted average.
- **Score clipping:** When `clip_under_threshold=True` (the default), scores below the threshold are zeroed out in the weighted average. A list field clips per element, never as a whole ([list contract](../Advanced/classification-logic.md#list-contract)).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: "A list field clips per element, never as a whole" disagrees with the contract's Score row.

The same sentence appears at threshold-gated-evaluation.md:169 and understanding-results.md:39, and architecture.md:251 is also stale. It omits two cases:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each page you listed now links the Score row of the list contract instead of restating it, so there is only one place to keep right (789509f, 71fc040, 0597663, ec0a2f9). The Score row covers both of your cases:

  • On a StructuredModel declared in Python, dict and plain-model lists do not clip by default. The row links the JSON Schema and zero-config defaults, which differ (3218bc4).
  • On List[StructuredModel] the flag currently has no effect, so an FD pair keeps its score. The row and the Known gaps note both call this a known gap while clip_under_threshold has no effect on List[StructuredModel] #415 is open (9de4212).

architecture.md gives the default per field kind. Checking this found the same error outside lists: dict and plain-model fields default to off, and the parameter table and the "(the default)" mentions now say so (8150c77). The JSON Schema table now says x-aws-stickler-infer-unspecified infers the clip setting too (23bc208, 6330692).

That second run, measured:

```python
cm["fields"]["products"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: this block reads cm[...] and result[...], but neither is defined on the page, and the bare ... entries are not valid Python. The block raises NameError and cannot be reproduced. Dev's side of the conflict has the model construction and the compare_with call; keep that side.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept dev's side (1dd9089). I ran its block as written, and it reproduces the counts and non_matches on the page.

Comment thread CHANGELOG.md Outdated
`clip_under_threshold` has no effect there
([#415](https://github.com/awslabs/stickler/issues/415)); `raw_similarity_score`
on a list node and bulk `mean_score` inside list items are described as
they are today ([#330](https://github.com/awslabs/stickler/issues/330)).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: the entry attributes the raw_similarity_score and bulk mean_score gaps to #330, but the docs link #437 and #428. After #420, the raw_similarity_score gap only applies to List[StructuredModel], because primitive lists already report the raw value (primitive_list_comparator.py:161).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrote the entry under Unreleased (d7dd08b). The raw_similarity_score and mean_score lines are gone: this PR doesn't change that text, and dev's 1.0.1 entries already describe both (the mean_score one links #428). The defects left in the entry each link their own issue: #416, #415 and #418.

| Score | `sum(pair scores) / max(n_gt, n_pred)`. The pair score is the element similarity, zeroed below the bar when `clip_under_threshold` is on (default on for primitive lists, off for dict and plain-model lists). For `List[StructuredModel]` the pair score is `GT[i].compare_with(Pred[j])["overall_score"]`, which can differ from the pairing similarity, and `clip_under_threshold` currently has no effect ([#415](https://github.com/awslabs/stickler/issues/415)). The list's score is never clipped as a whole against the field threshold. [Worked example](hungarian-matching.md#step-4-list-score). |
| Reports | `non_matches` and `field_comparisons`: one row per primitive element or per leaf of a TP item, and one object row per FD, FN or FA item. `match` is true when the row's own classification is TP or TN: a value or object row met its bar; a list row had every element paired as a TP, with no FD, FA or FN at the element level. Failures deeper down get their own rows. |

**Where `dev` does not yet follow it.** Each gap is a code change, not a docs change, and links its tracking issue where one exists:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: the "Where dev does not yet follow it" list puts temporary code-bug states, with measured values, in the user-facing contract page.

Copies of the list appear in 4 other pages and in the facade docstrings. #364 and #421 merged while this PR was open, and none of the copies were updated, so 3 of the 7 bullets were already false at review time. Keep the gap state in the issues (#330) and leave one short note here with links.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collapsed the seven bullets into one short Known gaps note. It names the four defects that still reproduce on dev and gives no measured values (a17dc85, e1d4e47). I dropped the three that #364 and #421 fixed, along with the copies on other pages and the #416 reference in the facade docstrings (5528a7e).

The table's intro now says the note lists where the code does not yet follow the table. The Score row describes the List[StructuredModel] clip behaviour as a known gap, not a rule (9de4212). The None-list item also covers the row a None list gets against another None (e649f73).

I left the links out because we keep issue numbers out of user docs. The issues are the record, and the CHANGELOG links #415 and #418. Short mentions remain where a reader would otherwise misread a value: understanding-results.md (the two field_comparisons gaps, linking the note), and auto/README.md and architecture.md (the clip gap).

@sromoam sromoam modified the milestones: 1.0.1 (Minor), 1.0.2 Oct 30, 2026
@sromoam

sromoam commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

…e 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.
…unts 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.
…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.
…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.
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.
…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.
…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.
[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.
"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.
… 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.
- 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.
…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.
… 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.
…lip 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.
…ferred 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.
@sromoam

sromoam commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review. I merged dev in rather than rebasing, to avoid a force-push (1dd9089), and took dev's side in every conflict where dev already had the corrected text. I kept the contract table, corrected it against dev in follow-up commits, and re-measured the corrected claims on the merged tree, printing the imported stickler path each time. The cheat sheet Runtime row no longer says "Overrides model threshold". It now lists what the runtime value gates: matched, and on the zero-config path also List[Model] and List[dict] pairing and nested plain-model and dict field thresholds (789509f, 174ed08). Your Prod case still gives TP at 0.5, and Key Rule 3 now says so.

@sromoam

sromoam commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, fixed here in both rows, so #577 doesn't need to carry them: the Bar row in classification-logic.md (a17dc85) and the primitive, dict and plain-model list row in the precedence table (789509f). Heads up for your rebase: this PR also edits the Runtime Match Threshold section, the precedence table, Key Rule 3, the All Four example and the cheat sheet, so #577 conflicts in six hunks on thresholds-and-metrics.md and one in the CHANGELOG. Please don't take either side wholesale.

  • Keep this PR's Runtime "What it gates". On the zero-config path a primitive list keeps its inferred threshold, so "list element pairing" on its own overclaims.
  • Keep this PR's precedence table rows, and its All Four gt_order/pred_order lines and "In this example" values.
  • Keep docs(484): state the default field threshold for each declaration style #577's Key Rule 2, cheat sheet Model row and CHANGELOG entry alongside this PR's.

The field default (0.5 vs the class match_threshold) and "Precedence, in one line" are untouched and still yours.

@vawsgit vawsgit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM!

All 16 findings from my previous review (CHANGES_REQUESTED on 260fc04) are fixed on 6330692. I found no new medium or high problems. Every script I used imported stickler from a worktree checked out at 6330692 and printed that path.

Previous findings

Finding Status on 6330692
Conflicts with dev in 6 files Fixed. The merge base is the dev tip 8c56dfa, and git merge-tree --write-tree origin/dev pr419 is clean. Dev's text is kept in threshold-gated-evaluation.md and bulk-evaluation.md.
Cheat sheet said the runtime value "Overrides model threshold" Fixed. With Prod.match_threshold=0.4 and evaluate(match_threshold=0.9), items stays tp=1 fd=0, as the new text says.
Known-gap bullets for report bugs that #364 already fixed Removed. The one Known gaps note lists only defects that still reproduce.
'True' string and equality-pairing claim in understanding-results.md Fixed. match is a bool, and an element row at threshold 0.6 gives True with score 0.6.
Laptop pair described as FD in threshold-gated-evaluation.md Fixed (dev's text). The page's models give products tp=1 fd=2.
Tolerance described as applying only to the primitive-list gate Fixed (dev's "Threshold boundary" text, 1e-10 on every gate).
"What it gates" for the runtime match_threshold was incomplete Fixed. Zero-config nested model and dict fields: addr is TP at 0.5 and FD at 0.95. List[Item] and List[dict] are TP at 0.3 and 0.5 and FD at 0.95. List[str] keeps its inferred 0.7 and 0.6. The facade.py docstrings say the same.
Default list bar given as 0.5 Fixed. Bare List[str] at similarity 0.6: fd=1. With ComparableField(): tp=1. With class match_threshold=0.55: tp=1. List[dict] and plain-model lists behave the same.
"Every list is unordered" Fixed. ["a","b"] vs ["b","a"] gives 1.0. A reordered inner List[List[str]] gives 0.8 on a StructuredModel and 0.0 zero-config. A reordered Any list gives 0.0 zero-config.
weighted_score definition Fixed. With threshold 0.9 and weight 2.0, tags[0] has score 0.8 and weighted 0.8. A TP-item leaf with weight 3 gives 3.0.
mean_score paragraph in bulk-evaluation.md Fixed. The file is no longer in the diff, so dev's text stands.
Equal-length lists described as unable to give FN/FA Fixed. The None qualifier is added. [P('1'), None] vs [P('1'), P('2')] gives tp=1 fa=1.
"Clips per element, never as a whole" Fixed. Primitive lists clip by default (0.5). List[dict] and plain-model lists do not (0.8). Explicit clip on List[dict] gives 0.0. List[StructuredModel] with clip on keeps 0.8, which is the #415 gap the page names.
Snippet read undefined cm and result Fixed (dev's block). It runs as written.
CHANGELOG entry cited the wrong issues Fixed. The entry is under [Unreleased] (above ## [1.0.1]) and links only #415, #416 and #418.
Temporary bug states written into a user page Fixed. One short Known gaps paragraph with no measured values and no issue links.

Also verified

  • Hungarian example: the pairing matrix matches Step 1. overall is tp=1 fd=2. The pair scores are 0.6667, 0.5 and 0.0. field_scores['transactions'] is 0.38889 and overall_score is 0.6333. A field threshold on List[Transaction] raises ValueError.
  • Null lists: None/None, []/[], [None]/None and []/None each give one TN with score 1.0. A null list on one side only gives one FN or FA per element, with score 0.0. NaN elements are removed.
  • Aggregate: [A,B] vs [A] gives overall tp=1 fn=1 and aggregate tp=2. When every item is rejected, aggregate equals overall.
  • Reports: List[dict] and plain-model elements get one row each. List[StructuredModel] gives leaf rows for a TP item and one object row per FD, FN or FA item. non_matches contains exactly the rows where match is False.
  • JSON Schema: x-aws-stickler-threshold on an array of models warns and is ignored. With x-aws-stickler-infer-unspecified, the clip setting is inferred for each field as the extension table says.
  • All four Known gaps still reproduce, and #415, #416 and #418 are open.
  • No behaviour change: the AST of facade.py, with docstrings blanked, is identical to dev's. The PR adds or changes no tests.
  • Checks: pytest (excluding the docs build) gave 4104 passed, 3 skipped and 1 xfailed. tests/test_docs_build.py gave 77 passed. docs/check_links.py exited 0 with the 6 known griffe warnings. ruff check . is clean. All 15 CI checks pass, and every new anchor exists in the built site.

sromoam and others added 5 commits November 17, 2026 16:29
Resolve conflicts with #577 in CHANGELOG.md and thresholds-and-metrics.md.

- CHANGELOG.md: keep both Documentation entries under [Unreleased].
- thresholds-and-metrics.md: keep #577's per-declaration default table and
  this branch's list rows. Runtime match_threshold takes dev's
  List[StructuredModel] carve-out plus this branch's zero-config scope,
  primitive-list and overall_score wording. The primitive/dict/plain-model
  list pairing row now points at the declaration table instead of restating
  it. The example keeps the measured data and verdicts; the cheat sheet
  merges both rows.
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.
Keep #406's Nested lists rules with the list contract's TP-pair wording
(an FD pair is not descended into, measured on the merged tree), and point
the Known gaps note at those cases: the value kinds it listed now count as
at top level.
@sromoam
sromoam merged commit ad3d868 into dev Nov 18, 2026
15 checks passed
@sromoam
sromoam deleted the docs/lists-contract branch November 18, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants