Repository navigation
refactor: share object dispatch and field classification - #535
Conversation
Closes awslabs#516 Signed-off-by: luojie <16602829831@163.com>
Signed-off-by: luojie <16602829831@163.com>
vawsgit
left a comment
There was a problem hiding this comment.
✅ LGTM!
Verified at head 212967c, merged with current dev 58f2dd3, with stickler imported from that checkout's src:
- Behaviour is unchanged. I generated 3,000 random ground-truth and prediction pairs. They covered nested models at two levels, lists of models and scalars, Optional scalars,
Dict[str, Any]with default andExactComparator, plain BaseModels and lists of them,Union[Cat, Dog],Any, None vs empty, and bothclip_under_thresholdsettings. Each pair's fullcompare_withoutput (confusion matrix, non-matches, field comparisons),evaluator_format=Trueoutput,compare()and the warnings hash to the same value ondevand on this PR:39c77db8…a186b. An instrumented run confirmed that every changed path is reached: the object-pair gate in both directions, the Cat/Dog refusals, and TP / clipped FD / unclipped FD in both classifiers. - Branch order holds. A model-vs-model pair still takes CASE 3, a mixed pair reaches the merged branch, and a dict paired with a BaseModel falls through to the mismatch branch. No new configuration lookup is added, and
TestTheFieldConfigurationIsLookedUpOncepasses. - Full suite on the merge: 4127 passed, 3 skipped, 1 xfailed with the llm, bert and dev extras. Mutations are caught: swapping the clip rule in
_classifyfails 31 tests, and dropping the BaseModel arm fails 36. - Every "Done when" item in #516 is met, and no test was edited. Ruff is clean. No conflict with
dev.
Non-blocking (low):
- Stale references:
configuration_helper.py:375, 442, 506, 560andcomparison_helper.py:35, 96still say "CASE 4 and CASE 5" or "CASE 5". Thecan_compare_object_pairdocstring still counts "FIVE readers", where there are now four. comparison_dispatcher.py:236cites #135 for "the comparator decides coercion", but #135 is about ANLSTree vs ComparisonEngine.- No test pins the #516 rule that
_classifyreturns a new dict on every call. Returning shared dicts passes all tests.
Security Scan ResultsASH Security Scan Report
Scan Metadata
SummaryScanner ResultsThe table below shows findings by scanner, with status based on severity thresholds and dependencies:
Top 4 HotspotsFiles with the highest number of security findings:
Detailed FindingsShow 7 actionable findingsFinding 1: SECRET-HEX-HIGH-ENTROPY-STRING
Description: Code Snippet: Finding 2: B310
Description: Code Snippet: Finding 3: B108
Description: Code Snippet: Finding 4: B307
Description: Code Snippet: Finding 5: B307
Description: Code Snippet: Finding 6: B102
Description: Code Snippet: Finding 7: B310
Description: Code Snippet: Report generated by Automated Security Helper (ASH) at 2026-11-12T19:47:43+00:00 |
Issue Reference
Closes #516. Claimed in #516 (comment).
Description of Changes
Dict pairs and plain Pydantic model pairs now share CASE 4/5 in the dispatcher. The StructuredModel branch still runs first. The merged branch uses the already-resolved comparator and preserves the existing object-pair gate.
Primitive and structured field comparisons share a private TP/FD classifier. It returns a fresh metrics dictionary on each call and preserves the original threshold and clipping rules. Public signatures, output shape, and existing tests are unchanged. Removed the duplicate import and replaced the scoped history/TODO comments with the current rules.
Two source files changed: +27 / -134 lines. No dependency, lockfile, test, or public documentation changes.
Testing
Compared against clean
devatcf90773855035fa7ac3d8bd0932dbea3367dc151.uv sync --frozendependencies. Fullpython -m pytest -q -o addopts=--tb=shorton both trees: 4091 passed, 13 skipped, 1 xfailed, no failures. Confirmedinspect.getfile(stickler)pointed to the corresponding head/baseline checkout before each run.signal.SIGALRM, which Windows lacks.ruff check .reports the same 16 existing diagnostics on baseline and head (notebook imports/unused f-string prefixes and the LLM example import); diagnostic output is identical.git diff --checkpassed. No existing test was edited, as requested for this behavior-preserving refactor.Optional BERT/Strands live-provider extras were not installed locally; skipped tests are not counted as executed.
Checklist
Additional Notes
AI assistance: OpenAI Codex (GPT-6 Astra) for source analysis, implementation, and validation. No independent fresh-context review is claimed.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.