Repository navigation
Conversation
Add stickler.decisions: Choice, Score and Noul fields that score typed decision models (Strands Decider, OpenJev, Jev) against gold labels. - The questions sent to the model are the eval schema: stickler.integrations.systemone.model_from_questions builds the model, and from_systemone passes a response's answers through. - from_json reads each System One answer into its predicted value and confidence, the probability of the predicted answer. Only probabilities/noul are read; choice, confidence and legend are not. - BulkStructuredModelEvaluator adds a DecisionAccumulator on its own when the schema has decision fields, at any depth. Results land in ProcessEvaluation.decision_metrics: correctness and calibration per field, by question type. - A decision field whose gold is None was not asked: it carries no weight and adds no counts, comparisons or confidence pairs. - accept_or_escalate() and confidence_intervals() (bootstrap by document) run on the stored records after compute(). - The HTML report gains a Decision Metrics section (inline SVG reliability diagram and risk-coverage plot). - A 100-ticket System One fixture with a recorder script, a guide, and an example notebook. The committed responses are synthetic placeholders until recorded. Models without decision fields produce byte-identical results.
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 6 HotspotsFiles with the highest number of security findings:
Detailed FindingsShow 11 actionable findingsFinding 1: SECRET-HEX-HIGH-ENTROPY-STRING
Description: Code Snippet: Finding 2: B310
Description: Code Snippet: Finding 3: B310
Description: Code Snippet: Finding 4: B310
Description: Code Snippet: Finding 5: B108
Description: Code Snippet: Finding 6: B307
Description: Code Snippet: Finding 7: B307
Description: Code Snippet: Finding 8: B102
Description: Code Snippet: Finding 9: B310
Description: Code Snippet: Finding 10: B310
Description: Code Snippet: Finding 11: python.lang.security.audit.dynamic-urllib-use-detected.dynamic-urllib-use-detected
Description: Code Snippet: Report generated by Automated Security Helper (ASH) at 2026-11-04T18:42:07+00:00 |
digalaviz
left a comment
There was a problem hiding this comment.
First pass on 6320fbc: the feature matches #469 in substance and leaves existing results unchanged, but I'd split it before approval, and a few answer-parsing paths should fail instead of defaulting.
What I checked. Each rule in #469 against the code; the full suite on this head; dev's own tests against this src; a compare_with result for a model without decision fields hashes identically on both trees; timings for compare_with, from_json and bulk update are within noise; no new dependencies; the HTML section escapes option keys, field names and doc ids (a </script> payload renders as text).
Blocking
- Scope. This ships all three phases of #469 in one +5981 PR. Phase 1 (
systemone, Choice/Noul, their metrics, contract tests, notebook) reviews on its own. The HTML section (~657 lines with its test),accept_or_escalate(174),confidence_intervals(44+) and the recorder/generator scripts (400) could follow. Can we split it that way? - Silent defaults in answer parsing. A bare label answer (
{"queue": "billing"}) is accepted as one-hot, so it enters calibration with confidence 1.0. On the dict path,from_systemone({"answers": [1, 2]})returns[1, 2]instead of raising, while the object path checks the type. Both should raiseAnswerError.
Non-blocking
_score_key_indexusesstr.isdigit()(normalize.py:69):"٢"is read as level 2 and"²"raisesValueErrorrather thanAnswerError. With criteria["2", "1", "0"], the key"2"is read as a level number without the ambiguity error the issue describes.- Every
ProcessEvaluationandsave_metrics()file now carriesdecision_metrics: null, andReportConfiggainsinclude_decision_metrics. The CHANGELOG says other fields are unchanged; worth one line for consumers that check key sets. - A user accumulator named
"decision_metrics"is picked up as decision metrics and handed to the reporter (bulk_structured_model_evaluator.py:674). Reserve the name or key off the accumulator type. - The fixtures are synthetic, and
provenance.jsonsays so clearly; #469 asks for recorded outputs with model and version. Fine for offline tests, but the notebook should not present those numbers as a model's results until a recording replaces them. - Notebook cell 2's committed output prints a local temp path; clear or regenerate it.
renormalise only for float driftvs themax(0.01, k * 5e-4)tolerance: the comment explains the rounding case, so I read this as intended. Worth aligning the issue text or the guide.
Notebook and recorder
I ran all 15 code cells offline in order on this head: no errors, and 14 of 15 outputs match the committed ones (the 15th is the path in item 7). Re-running make_synthetic_responses.py reproduces responses.jsonl and provenance.json byte for byte, and the notebook follows the #469 method (legend and confidence ignored, gold None, missing answers, tau as an input).
- Blocking: one more item I'll send you directly rather than here.
- Blocking: a recording where every answer comes back empty exits 0 and writes
"synthetic": false, so it would pass as a real measurement. Fail the run when a ticket, or the run, has no answers. provenance.jsonrecords the endpoint URL, so a private host or a token in the URL would be committed with the fixture. Record the model and version only.- A refusal (the HTTP 422 case #469 cites) aborts the recorder and raises in the live cell, so the missing-answer rule never applies to a real model. Record it as missing.
- Cell 21: "Lower is better for all of them" follows
auroc_label, where higher is better. - Cell 20 reads
qfrom cell 18, which cells 12 and 30 overwrite as a loop variable; re-running cell 12 then 20 raisesTypeError. - Cell 26 formats
tauwith:.3f, while the guide saystau_at_targetcan beNone.
Versioning. This adds public API (stickler.decisions, stickler.integrations.systemone), so the release that carries it is 1.1.0.
Not verified: rendering in a Jupyter kernel (I executed the cells as a script), and the contract tests against the real decider schema.
|
@sromoam in my opinion this fits 1.1.0 better than 1.0.2. It conflicts with |
harrycav
left a comment
There was a problem hiding this comment.
Thanks Spencer, this is a really useful direction. Decision models have a growing audience: Decider passed 1.2k stars in about 7 weeks. Their users need something stickler is well placed to give: field-by-field evaluation of multi-question pipelines, and in particular "how far can I trust this model on its own?"
I reviewed this as a design first and code second. Short version: yes to supporting decision models, and I'm happy for most of this to ship, with a few changes first. Details below.
Bigger points
1. Keep it out of stickler's core.
Right now the new field types need edits to JSON loading, ComparisonEngine, StructuredModel.compare and the bulk evaluator. That means every user runs the new code paths, even if they never use decision models. I'd suggest:
- keep the fields as normal
ComparableFields - have
from_systemone()produce rich values carrying the probabilities - put the metrics in an opt-in
DecisionAccumulator, the wayBBoxMAPAccumulatorworks
Same features, with zero change for everyone else.
2. Mark it experimental.
Once it's in 1.x, every public name (Choice(), accept_or_escalate(), the result-file fields) becomes a compatibility promise. We don't know yet what users will need, so labelling it experimental (in the docs or a namespace) keeps us free to change it without a breaking release.
3. Target 1.1.0, not 1.0.2.
It's a new feature, so a minor release fits semver better than a patch. That also gives time for the fixes below. #469 is still on the 1.0.2 milestone: shall we move it?
4. Make accept-or-escalate the headline.
It's the question these teams actually ask: "if I auto-accept above X, how much is handled automatically, and how much of that is wrong?" The System One docs (docs.typesafe.ai) are built around exactly this (act / confirm / escalate). I'd lead the docs and notebook with it, with calibration metrics underneath as the explanation. Could it be built on the existing ErrorCaptureAtBudgetMetric rather than as a second implementation?
5. Show it on real recorded outputs.
The fixture says it's synthetic and "NOT a recording". Generated test cases are fine, but we should run a real model on them and save what it actually outputs. We should also avoid datasets the model was trained or calibrated on (banking77, clinc150, PubMedQA, SNLI, FEVER, CUAD, massive_intent and so on), or the results will look better than they really are.
6. Measure what users actually threshold on.
- The
confidencefield. The docs tell users to set cut-offs onconfidence, which is the rescaled top probability, not the top probability itself. The accept-or-escalate table should be able to use it. - The companion yes/no check. The docs teach a "should I trust this answer?" Noul alongside the main question. It would be great to score that check against whether the main answer was right.
- The model version. Record it per result, so you can compare across vendor updates.
7. Avoid duplicates.
ECE and Brier already exist in stickler, so I'd reuse them rather than add second versions. I'd also leave overall_score and weights untouched by decision fields.
Must fix before merge
- AURC improves when the model refuses to answer (
escalate.py:166). The curve only uses answered rows. In my test, 4 answers gave AURC 0.1146, and the same 4 plus 4 refusals gave 0.0573. Refusals should count as errors, or be reported separately. - An answer with no probabilities counts as 100% confident (
accumulator.py,_probs). This skews calibration toward "overconfident". I'd exclude those rows from the confidence metrics, or flag them. - The exported schema can't be loaded back.
x-stickler-decisiondoesn't round-trip, and it breaks thex-aws-stickler-naming convention. A round-trip test would catch this.
Smaller fixes
- Noul precision/recall/F1 shows 0.0 when there are no positive cases. That should be "undefined" (0.0 reads as "terrible").
- Level names like "1", "2", "3" can be mistaken for list positions. Reject them or document how they're read.
- Small samples mislead: a perfectly calibrated model shows ECE of about 0.23 at n=20. A warning below a minimum n would help.
- Confidence intervals are computed on counts rather than rates.
- Saved files contain
decision_metrics: null, and records are written twice. - One very wrong row can dominate log loss. Clip it, or report the median too.
- Name which AURC convention is used in the docstring.
- The risk-coverage curve is implemented twice (
data_extractors.py:330-345andescalate._curve). One would be better.
After it ships
Ideas to get it adopted:
- the real-output notebook
- a one-line CLI command
- a listing on awesome-jev
- a short docs PR to Decider (its issues #43–45 ask for evaluation help)
- reading JevBench's format
On Strands Evals, decision fields already work there as normal fields, so I think a docs recipe is enough for now.
Happy to pair on any of this, especially the accumulator refactor or the recorded-output notebook.
|
Amazing Job, Thank you so much. Here are a few fixes that would be great to have. SummaryThe metric definitions are sound, and they match an independent implementation closely. I scored 2 × 2,270 real
Tie handling in Four issues change reported numbers and should be fixed before merge. One is a floating-point bug in how yes/no
Should fix1. Yes/no confidences derived as 1 − P(yes) break ties
This happens for clean inputs: for 8 of the 49 two-decimal confidences from 0.51 to 0.99, Repro: Doc = model_from_questions({"q": {"type": "noul", "instructions": "?"}}, model_name="Doc")
ev = BulkStructuredModelEvaluator(target_schema=Doc)
ev.update(Doc(q=True), Doc.from_json({"q": {"type": "noul", "noul": 0.57}}), doc_id="a") # yes at 0.57, right
ev.update(Doc(q=True), Doc.from_json({"q": {"type": "noul", "noul": 0.43}}), doc_id="b") # no at 0.57, wrong
ev.compute().decision_metrics["fields"]["q"]["calibration"]["auroc"] # 0.0; a tie should give 0.5Why it matters:
Suggest: snap confidences to a fixed precision before any tie-sensitive step, for example 2. AURC improves as answers go missingIn Repro: 400 yes/no documents, then the same answers with every second answer removed.
Why it matters: AURC is used to rank systems, and a system that times out or refuses more often gets a better Suggest: pick one definition and document it. Two candidates:
Reporting both, under clearly named keys, also works. Either way, the current mix of the two shouldn't ship. 3.
|
|
Thanks @parmidaatg, this review was a big help, and the four "should fix" items are fixed. Two of your suggestions we'd like your view on before we settle them. 5. One malformed answer rejects the whole document. We're making this a per-field setting rather than a 7. Answers that omit options. We'd rather not fill these in Stickler. Zero-filling a top-k readout leaves the listed probabilities summing to about 0.97, which fails the sum check, so any fill has to put the leftover mass somewhere. Renormalising raises the top probability, making answers look more confident than the model said. Spreading it evenly over the omitted options is a guess about the tail. The converter that builds the answer knows the real tail mass, so our plan is:
Does that work for your log-prob system, or is there a fill rule you'd consider standard enough to build in? |
|
One more, on 8 (percentile intervals for BCa does fix it, and we're open to implementing it for Would you rather see BCa for |
Pull Request
Issue Reference
Closes #469
Description of Changes
Adds first-class evaluation for typed decision models that answer System One questions (Strands Decider, OpenJev, Jev). The questions sent to the model are the eval schema; answers are scored as returned.
Changes Made
stickler.decisions:Choice,Score,Noulfields; answer normalisation;DecisionAccumulator; numpy-only metrics;accept_or_escalate();confidence_intervals(). Design notes insrc/stickler/decisions/README.md.stickler.integrations.systemone:model_from_questions(),from_systemone(). No dependency ontypesafe_sdkorstrands-decider.StructuredModel.from_jsonconverts System One answers on decision fields to rich values before validation.ComparisonEngineandStructuredModel.compare(): a decision field with goldNone(not asked) carries no weight, adds no confusion-matrix counts, and gets nofield_comparisonsrow orfield_scoresentry. A document with only unasked decisions scores 1.0, ascompare()already did.BulkStructuredModelEvaluatorinstallsDecisionAccumulatorwhentarget_schemahas decision fields; JSONL writes models as dicts only for such schemas.StructuredModel.__pydantic_init_subclass__rejects a non-Optionaldecision field.ProcessEvaluation.decision_metrics(new optional field).Evaluate_A_Decider_Model.ipynb, and a 100-ticket fixture inexamples/notebooks/fixtures/systemone/withrecord_systemone.py.Why These Changes Are Needed
See #469. Flattening System One answers into rich values loses the distribution, invites wrong calibration (
noulis P(yes), and the answer'sconfidenceis not P(correct)), and gives extraction F1 where decision users need per-class, ordinal and accept-or-escalate metrics.Where this differs from the issue text
confidence_intervals(res)aftercompute(), not aci=Trueflag (compute()takes no arguments).Optional(None means not asked or not answered) and do not supportalias.Testing
tests/decisions/(metrics against sklearn, end to end, nested and list fields, fixture, review regressions),tests/integrations/test_systemone.py(contract tests pinned to Decider's published shapes),tests/reporting/html/test_decision_metrics_section.py(including injection attempts).dev(scores, confusion matrix, field_comparisons, non_matches, bulk output, warnings, HTML report).tests/test_docs_build.py: 77 passed.An independent review of the diff found 10 issues (a stale path cache on forward references, a cache leak, missing-decision gaps in two list shapes and the JSONL round trip, unasked fields still counted in the confusion matrix, and others). All are fixed with regression tests in
tests/decisions/test_review_regressions.py.Reviewers
@digalaviz
Checklist
CHANGELOG.mdentry added under[Unreleased]Additional Notes
provenance.jsonsays so and every score cell in the notebook repeats it. They will be replaced with real Strands Decider outputs recorded withrecord_systemone.py. Do not cite the notebook's scores.from_jsonoverhead for models without decision fields: about 1.6 µs per call on a small model.