fix(submodel): statistical-model validators for the two-channel design - #74
Merged
Conversation
…pydantic-ai 2.x
Post the pydantic-ai builtin->native rename (issue #5338), a native tool
attaches through capabilities= wrapped in a NativeTool capability. Bare
capabilities=[WebSearchTool()] failed at run time ("'WebSearchTool' object
is not callable"), breaking the lit-search stage of the extraction pipeline.
The 0.8.0 population-spread design has two channels: observation_code pins the CENTER (SEM-scale), observed_distribution carries the population SPREAD (omega). The rules were stated in the authoring prompt but not enforced, so statistically-broken targets validated cleanly. Add validators: - center-channel SEM-scale: a population observed_distribution requires its observation_code to use sample_size (rejects double-encoding the spread). - bounded-observable shape: a percent/fraction/proportion/probability observable in the moments form must use shape=logit_normal. - positive-crossing-zero: warn when an un-clipped observation_code pushes a positive-median quantity below zero (use multiplicative/lognormal error); complements the existing clip warning, which only caught the clipped case. Add ObservedDistribution.n_biological_is_floor for 'n>=' unit counts so precision-weighting consumers don't over-weight the panel. Teach the authoring prompt the multiplicative-error rule, logit_normal-for-percent, the do-not-double-encode rule, the 1.645 z-factor, and n_biological_is_floor.
jeliason
added a commit
that referenced
this pull request
Jul 23, 2026
The 0.8.1 authoring prompt tells authors to use `1.645` (normal z for the 5th–95th percentile range) when reconstructing an SD from box-plot whiskers, but `ALLOWED_CONSTANTS` only whitelisted `1.96` (2.5th–97.5th) — so a literal `1.645` failed `validate_no_hardcoded_values_in_observation_code`. This adds `1.645` alongside `1.96`, closing the prompt/validator inconsistency introduced in #74.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 0.8.0 population-spread design has two channels —
observation_codepins the CENTER (SEM-scale) andobserved_distributioncarries the population SPREAD (omega) — but the rules were only stated in the authoring prompt, so statistically-broken targets validated cleanly. This enforces them.observed_distributionnow requires itsobservation_codeto usesample_size(rejects double-encoding the spread).percent/fraction/proportion/probabilityobservable in themomentsform must useshape: logit_normal, notnormal/lognormal.observation_codepushes a positive-median quantity below zero (use multiplicative/lognormal); complements the existing clip warning, which only caught the clipped case.ObservedDistribution.n_biological_is_floorforn>=counts, and teaches the authoring prompt the multiplicative-error rule,logit_normal-for-percent, do-not-double-encode, the1.645z-factor, andn_biological_is_floor.Also folds in
fix(extraction): attach native web search viacapabilities=[NativeTool(WebSearchTool())]for pydantic-ai ≥2.x (barecapabilities=[WebSearchTool()]failed at run time, breaking lit-search).