Repository navigation
docs(486): document both non_matches record shapes - #598
WilliamK112 wants to merge 4 commits into
Conversation
List-item records carry reason at the top level instead of in details, list false discoveries add similarity, and only false discoveries have similarity_score. The debugging snippet now reads the reason from either place, so it no longer raises KeyError on a list-item record. Signed-off-by: Ching Wei Kang <164879897+WilliamK112@users.noreply.github.com>
vawsgit
left a comment
There was a problem hiding this comment.
needs changes
Two medium findings, both inline. I measured the record shapes with stickler imported from a worktree at the PR head (8330b8b), and got the same output after a test merge into current dev (0855590). The code that builds non-match records has not changed between this branch's base and dev.
CHANGELOG.md: after merge, the #486 bullet sits under the released## [1.0.2]section. Move it under## [Unreleased].docs/docs/Guides/Evaluation/understanding-results.md: the table misses a third record shape. A sub-field of a matched list item (lines[1].name) has top-levelreason(always"field mismatch") andsimilarity_score, but nosimilarityand nodetails. Thefield_pathexample change removes the one example of that shape.
Measured keys from compare_with(document_non_matches=True) on a model with scalar, nested, list-of-objects, list-of-strings and empty-list fields:
x false_discovery ['details', 'ground_truth_value', 'prediction_value', 'similarity_score'] reason='below threshold (0.600 < 1.0)'
y false_alarm ['details', 'ground_truth_value', 'prediction_value'] reason='unmatched prediction'
z false_negative ['details', 'ground_truth_value', 'prediction_value'] reason='unmatched ground truth'
addr.city false_discovery ['details', 'ground_truth_value', 'prediction_value', 'similarity_score'] reason='below threshold (0.857 < 0.9)'
lines[0] false_discovery ['ground_truth_value', 'prediction_value', 'reason', 'similarity', 'similarity_score'] reason='below threshold (0.000 < 0.5)'
lines[1].name false_discovery ['ground_truth_value', 'prediction_value', 'reason', 'similarity_score'] reason='field mismatch'
lines[2].name false_discovery ['ground_truth_value', 'prediction_value', 'reason', 'similarity_score'] reason='field mismatch'
tags[1] false_discovery ['ground_truth_value', 'prediction_value', 'reason', 'similarity', 'similarity_score'] reason='below threshold (0.000 < 0.5)'
empty_gt[0] false_alarm ['ground_truth_value', 'prediction_value', 'reason'] reason='unmatched prediction'
Checked and cleared
- The table's claims for scalar and nested records:
detailsholdsreason, and only false discoveries havesimilarity_score. - The claims for whole list-item records, including lists of strings and an empty ground-truth list: top-level
reason, andsimilarityequal tosimilarity_scoreon false discoveries. - The example reason format
below threshold (0.300 < 1.0)matches real output. - The updated debugging snippet, run verbatim on the records above: it prints a reason for every false discovery with no
KeyError. uv run --frozen python docs/check_links.pyexits 0. The PR adds no links or anchors.- No code or test files changed, so there were no tests to run or mutation-test.
Non-blocking (pre-existing, on lines this PR does not touch): docs/docs/Guides/Evaluation/README.md lines 171-173 reads nm['similarity_score'] on every non-match. That raises KeyError on false-alarm and false-negative records, and it contradicts the new table. Fix it here or track it separately.
| `stickler.evaluate`) or a JSON Schema `string` | ||
| ([#492](https://github.com/awslabs/stickler/issues/492)). | ||
|
|
||
| - Understanding Results now documents both `non_matches` record shapes |
There was a problem hiding this comment.
Medium: after merge, this bullet sits under the released [1.0.2] section.
This branch was cut before v1.0.2. On dev, ## [Unreleased] is empty and ## [1.0.2] - 2026-11-20 starts two lines below it. Git merges this file with no conflict, so nothing warns about the move. In a test merge (git merge-tree origin/dev pr598), the bullet lands at line 374, inside [1.0.2] → ### Fixed (line 57 to line 453), and [Unreleased] stays empty. The changelog would then say this change shipped in 1.0.2.
Fix: rebase on dev and move the bullet under ## [Unreleased], in a new section such as ### Documentation.
| |-------|------|-------------| | ||
| | `field_path` | string | Dot-notation path to the field (e.g., `"contact.phone"`, `"products[0].name"`). | | ||
| | `non_match_type` | string | One of `"false_discovery"`, `"false_alarm"`, or `"false_negative"`. | | ||
| | `field_path` | string | Path to the field (`"contact.phone"`, `"products[0]"`). | |
There was a problem hiding this comment.
Medium: this example change removes the one example of a third record shape.
A list item that matches overall, but has a sub-field below threshold, produces a record at products[0].name, not at the item. The path is built in non_matches_helper.py lines 277-286. Measured at this head:
lines[1].name false_discovery ['ground_truth_value', 'prediction_value', 'reason', 'similarity_score'] reason='field mismatch'
threshold-gated-evaluation.md line 162 still shows "products[0].name", so the two pages now disagree.
Fix: keep both examples ("products[0]", "products[0].name").
| | `reason` | string | List items: the reason, in place of `details`. | | ||
| | `similarity` | float | List-item false discoveries: the same value as `similarity_score`. | |
There was a problem hiding this comment.
Medium (same root cause as the field_path comment): rows 336 and 337 are wrong for sub-field records of matched list items.
- Row 337: those records have no
similaritykey. Code written from this table that readsnm["similarity"]on list-item false discoveries raisesKeyErroronlines[1].nameandlines[2].namein the measured output. - Row 336: their
reasonis always the literal"field mismatch". The helper readsnon_match.get("reason", "field mismatch"), but the nested record keeps its reason indetails, so the lookup always falls back to the default.
This misses #486's done-when line: "The table matches the keys compare_with(document_non_matches=True) emits for scalar, nested and list fields."
Fix: scope row 337 to whole list-item records. Then add one line saying that sub-field records of matched items carry reason (currently always "field mismatch") and similarity_score, with no similarity and no details. Optional: track the lost reason as a separate bug.
- Keep both field_path examples and describe the third record shape: a sub-field of a matched list item has reason (currently always "field mismatch") and similarity_score, with no similarity and no details. - Scope the reason and similarity rows to list records. - Evaluation README snippet: read similarity_score only where it exists. - CHANGELOG: move the awslabs#486 bullet from [1.0.2] to [Unreleased] ### Documentation. Signed-off-by: Ching Wei Kang <164879897+WilliamK112@users.noreply.github.com>
|
Thanks @vawsgit, all three findings were right. I merged
Checked at 3d703ee with Run verbatim on those records, both snippets print without a I didn't change any code for the lost sub-field reason. I can open a separate issue for it if that's useful. |
vawsgit
left a comment
There was a problem hiding this comment.
✅ LGTM!
All three medium findings from my review of 8330b8b are fixed at 3d703ee, and so is the non-blocking one. I measured with stickler imported from a worktree at 3d703ee (inspect.getfile(stickler) printed that worktree's src/stickler/__init__.py).
Previous findings
- Changelog placement: fixed. The #486 bullet is under
## [Unreleased]→### Documentation, above## [1.0.2]. A test merge (git merge-tree --write-tree origin/dev 3d703ee) keeps it there, and "486" appears once in the merged file. field_pathexample: fixed. Line 330 lists"products[0]"and"products[0].name", so it agrees withthreshold-gated-evaluation.mdagain.reasonandsimilarityrows: fixed. Rows 336-337 and the line after the table scopesimilarityto whole list-item false discoveries and describe the sub-field shape.- Evaluation guide snippet: fixed. Lines 172-174 read
similarity_scorewith.get().
Measured record shapes from compare_with(document_non_matches=True) on a model with scalar, nested, missing nested object, list-of-objects (unmatched item, and sub-field false discovery, false alarm and false negative inside matched items), list-of-strings, empty ground-truth list and shorter prediction list. field_path and non_match_type are on every record and omitted here:
x false_discovery [details, ground_truth_value, prediction_value, similarity_score] reason='below threshold (0.600 < 1.0)'
y false_alarm [details, ground_truth_value, prediction_value] reason='unmatched prediction'
z false_negative [details, ground_truth_value, prediction_value] reason='unmatched ground truth'
addr.city false_discovery [details, ground_truth_value, prediction_value, similarity_score] reason='below threshold (0.857 < 0.9)'
addr2 false_negative [details, ground_truth_value, prediction_value] reason='unmatched ground truth'
lines[0] false_discovery [ground_truth_value, prediction_value, reason, similarity, similarity_score] reason='below threshold (0.000 < 0.5)'
lines[1].name false_discovery [ground_truth_value, prediction_value, reason, similarity_score] reason='field mismatch'
lines[2].note false_alarm [ground_truth_value, prediction_value, reason] reason='field mismatch'
lines[3].note false_negative [ground_truth_value, prediction_value, reason] reason='field mismatch'
tags[1] false_discovery [ground_truth_value, prediction_value, reason, similarity, similarity_score] reason='below threshold (0.000 < 1.0)'
empty_gt[0] false_alarm [ground_truth_value, prediction_value, reason] reason='unmatched prediction'
more_gt[1] false_negative [ground_truth_value, prediction_value, reason] reason='unmatched ground truth'
Every table row and the line after the table match this output. similarity equals similarity_score wherever both appear.
Also checked and cleared
git diff --stat origin/dev...3d703eeand the two-dot diff are identical: 3 files, +27/−8. The merge ofdev(8b75f3e) reverts nothing.- The Understanding Results debugging snippet, run verbatim on these records: no
KeyError, and a reason prints for every false discovery (for examplelines[1].name: ... reason=field mismatch). - The Evaluation guide snippet, run verbatim: no
KeyError, and(score=…)prints only on false discoveries. - Other pages that describe
non_matches(threshold-gated-evaluation.md,classification-logic.md,bulk-evaluation.md,Best-Practices/README.md) agree with the new table. uv run --frozen python docs/check_links.pyexits 0.uv run --frozen pytest -q tests/test_docs_build.py: 77 passed. The table renders as a header plus 8 rows of 3 cells.mkdocs build --strictstops on 6 griffe warnings about missing type annotations insrc/. This PR changes nosrc/files.- No code or tests changed, so mutation testing does not apply.
Non-blocking
- The line after the table describes only sub-fields "below its threshold". Sub-field false alarms and false negatives inside matched items (
lines[2].note,lines[3].noteabove) have the same shape minussimilarity_score, and the table rows already cover them. Optional wording change. - The lost sub-field reason (always
"field mismatch") is still a code bug. Yes, please open the separate issue you offered.
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-23T17:37:46+00:00 |
Issue #, if available: Fixes #486
Description of changes:
"Non-Match Entry Structure" in
Guides/Evaluation/understanding-results.mdlisted six keys for everynon_matchesentry. List-item records have a different shape, so code written from the table (nm["details"]["reason"]) raisedKeyErroron the first one. This PR documents the shapes as they are (unifying them stays with #137):similarity_scoreis on false discoveries only,details(holding"reason") is on scalar and nested fields, and list records carryreasonat the top level instead. It also listssimilarity, which whole list-item false discoveries emit with the same value assimilarity_score;"products[0].name"):reason(currently always"field mismatch") andsimilarity_score, with nosimilarityand nodetails.field_pathkeeps both examples;nm.get('details', {}).get('reason') or nm.get('reason')and prints it;Guides/Evaluation/README.md) snippet readssimilarity_scoreonly where it exists;### Documentationbullet under[Unreleased]inCHANGELOG.md.Checked on
devat 9fc70de, withsticklerimported from that checkout'ssrc/.compare_with(document_non_matches=True)on a model with scalar, nested and list fields emits:The page's updated snippet runs on that model and prints a reason for each false discovery, including
lines[1]; the same loop readingnm['details']['reason']raisesKeyError: 'details'.docs/check_links.pypasses. Docs only, so no test changes.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
🤖 Generated with Claude Code