Skip to content

docs(486): document both non_matches record shapes - #598

Open
WilliamK112 wants to merge 4 commits into
awslabs:devfrom
WilliamK112:docs/486-non-match-record-shapes
Open

WilliamK112 wants to merge 4 commits into
awslabs:devfrom
WilliamK112:docs/486-non-match-record-shapes

Conversation

@WilliamK112

@WilliamK112 WilliamK112 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Issue #, if available: Fixes #486

Description of changes:

"Non-Match Entry Structure" in Guides/Evaluation/understanding-results.md listed six keys for every non_matches entry. List-item records have a different shape, so code written from the table (nm["details"]["reason"]) raised KeyError on the first one. This PR documents the shapes as they are (unifying them stays with #137):

  • the table now says similarity_score is on false discoveries only, details (holding "reason") is on scalar and nested fields, and list records carry reason at the top level instead. It also lists similarity, which whole list-item false discoveries emit with the same value as similarity_score;
  • a line after the table covers sub-field records of matched list items ("products[0].name"): reason (currently always "field mismatch") and similarity_score, with no similarity and no details. field_path keeps both examples;
  • the debugging snippet reads the reason with nm.get('details', {}).get('reason') or nm.get('reason') and prints it;
  • the Evaluation guide's (Guides/Evaluation/README.md) snippet reads similarity_score only where it exists;
  • adds a ### Documentation bullet under [Unreleased] in CHANGELOG.md.

Checked on dev at 9fc70de, with stickler imported from that checkout's src/. compare_with(document_non_matches=True) on a model with scalar, nested and list fields emits:

x          false_discovery ['details', 'ground_truth_value', 'prediction_value', 'similarity_score']
y          false_alarm     ['details', 'ground_truth_value', 'prediction_value']
z          false_negative  ['details', 'ground_truth_value', 'prediction_value']
addr.city  false_discovery ['details', 'ground_truth_value', 'prediction_value', 'similarity_score']
lines[1]   false_discovery ['ground_truth_value', 'prediction_value', 'reason', 'similarity', 'similarity_score']
lines[0]   false_negative  ['ground_truth_value', 'prediction_value', 'reason']
lines[2]   false_alarm     ['ground_truth_value', 'prediction_value', 'reason']

The page's updated snippet runs on that model and prints a reason for each false discovery, including lines[1]; the same loop reading nm['details']['reason'] raises KeyError: 'details'. docs/check_links.py passes. 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

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 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

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.

  1. CHANGELOG.md: after merge, the #486 bullet sits under the released ## [1.0.2] section. Move it under ## [Unreleased].
  2. 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-level reason (always "field mismatch") and similarity_score, but no similarity and no details. The field_path example 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: details holds reason, and only false discoveries have similarity_score.
  • The claims for whole list-item records, including lists of strings and an empty ground-truth list: top-level reason, and similarity equal to similarity_score on 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.py exits 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.

Comment thread CHANGELOG.md Outdated
`stickler.evaluate`) or a JSON Schema `string`
([#492](https://github.com/awslabs/stickler/issues/492)).

- Understanding Results now documents both `non_matches` record shapes

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: 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]"`). |

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 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").

Comment on lines +336 to +337
| `reason` | string | List items: the reason, in place of `details`. |
| `similarity` | float | List-item false discoveries: the same value as `similarity_score`. |

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 (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 similarity key. Code written from this table that reads nm["similarity"] on list-item false discoveries raises KeyError on lines[1].name and lines[2].name in the measured output.
  • Row 336: their reason is always the literal "field mismatch". The helper reads non_match.get("reason", "field mismatch"), but the nested record keeps its reason in details, 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>
@WilliamK112

Copy link
Copy Markdown
Contributor Author

Thanks @vawsgit, all three findings were right. I merged dev (8b75f3e) and pushed 3d703ee:

  • CHANGELOG.md: the Document the second non_matches record shape: list-item records have no details key #486 bullet moved out of [1.0.2] into [Unreleased] → ### Documentation.
  • understanding-results.md: field_path keeps both examples ("products[0]", "products[0].name"). The reason and similarity rows are scoped to list records and to whole list-item false discoveries. A new line after the table describes the third shape: a sub-field of a matched list item has reason (currently always "field mismatch") and similarity_score, with no similarity and no details.
  • I also fixed the docs/docs/Guides/Evaluation/README.md snippet you flagged: it now reads similarity_score with .get() and prints the score only when it's there, so false alarms and false negatives no longer raise KeyError.

Checked at 3d703ee with stickler imported from the checkout. The model has scalar, nested, list-of-objects and list-of-strings fields:

x              false_discovery ['details', 'ground_truth_value', 'prediction_value', 'similarity_score']
y              false_alarm     ['details', 'ground_truth_value', 'prediction_value']
z              false_negative  ['details', 'ground_truth_value', 'prediction_value']
addr.city      false_discovery ['details', 'ground_truth_value', 'prediction_value', 'similarity_score']
lines[0]       false_discovery ['ground_truth_value', 'prediction_value', 'reason', 'similarity', 'similarity_score']
lines[1].name  false_discovery ['ground_truth_value', 'prediction_value', 'reason', 'similarity_score']
tags[1]        false_discovery ['ground_truth_value', 'prediction_value', 'reason', 'similarity', 'similarity_score']

Run verbatim on those records, both snippets print without a KeyError (lines[1].name reports reason=field mismatch). uv run --frozen python docs/check_links.py exits 0.

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 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 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

  1. 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.
  2. field_path example: fixed. Line 330 lists "products[0]" and "products[0].name", so it agrees with threshold-gated-evaluation.md again.
  3. reason and similarity rows: fixed. Rows 336-337 and the line after the table scope similarity to whole list-item false discoveries and describe the sub-field shape.
  4. Evaluation guide snippet: fixed. Lines 172-174 read similarity_score with .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...3d703ee and the two-dot diff are identical: 3 files, +27/−8. The merge of dev (8b75f3e) reverts nothing.
  • The Understanding Results debugging snippet, run verbatim on these records: no KeyError, and a reason prints for every false discovery (for example lines[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.py exits 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 --strict stops on 6 griffe warnings about missing type annotations in src/. This PR changes no src/ 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].note above) have the same shape minus similarity_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.

@github-actions

Copy link
Copy Markdown

Security Scan Results

ASH Security Scan Report

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

Scan Metadata

  • Project: ASH
  • Scan executed: 2026-11-23T17:34:57+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 7129 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-23T17:37:46+00:00

This branch has not been deployed

No deployments
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.

Document the second non_matches record shape: list-item records have no details key

3 participants