Repository navigation
Description
Overview
Phase 2 of the #1331 priors/messages batch — the behaviour-changing pair, split from Phase 1 (#1344, merged via #1345) because it alters prior-passing widths in search chaining (SLaM-style pipelines). Verdicts: bug/priors/06 + 08 on #1330; decisions resolved on #1331 (Decision 5: minimal — abs(mean) + optional configurable absolute floor; Decision 2: reject σ ≤ 0 strictly).
Sequencing constraint (from the Phase-1 impact analysis): the width fix (D5) lands with the strict σ check (D2) in one PR so today's silent σ=0 degeneracy (a mean=0 chained parameter freezes into a delta function) never becomes an unexplained hard crash: where a computed width is still ≤ 0, prior passing raises a clear, parameter-named PriorException pointing at the width-modifier config — not a deep MessageException.
Plan
RelativeWidthModifier:sigma = value * abs(mean), plus opt-inabsolute_floor(YAML-configurable; engages whenvalue*abs(mean)falls below it). Negative means no longer produce negative sigma (today0.5 * -1.0 = -0.5flows silently intoGaussianPriorand flipsvalue_for).- Prior passing (
gaussian_prior_model_for_argumentswidth application): if the final width ≤ 0 (e.g.mean=0, no floor), raisePriorExceptionnaming the parameter path with remediation guidance (set an absolute width modifier or anabsolute_floor). NormalMessage.__init__: enforce σ > 0 (numpy path; JAX defers to NaN propagation — the existingassert_sigma_non_negativehelper'slax.condbranch is broken by design and is retired).GaussianPrior(mean, sigma<=0)andGaussianPrior.with_limits(5, 5)become loud.TruncatedNormalMessage: extend its existing< 0rejection to<= 0so the two classes agree (strictly).- Regression tests:
mean=0chained parameter (clear error without floor; correct width with floor),abs(mean)on negative means, floor engagement + config round-trip, strict ctor rejection on both message classes. - Full
test_autofit/suite; pre-flight grep for tests that deliberately construct σ ≤ 0 messages (they may encode point-mass behaviour —FixedMessageis the sanctioned path for that).
Detailed implementation plan
Affected Repositories
- PyAutoLabs/PyAutoFit (primary)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoFit | main (post-#1345, c0b6c94) | clean |
Suggested branch: feature/prior-width-safety
Parallel disjoint PyAutoFit claim alongside ep-graphical-docs (#1334) + ep-diagnostics (#1335), both autofit/graphical — this work is autofit/mapper/prior/width_modifier.py, autofit/mapper/prior_model/abstract.py (width application site), autofit/messages/{normal,truncated_normal}.py. Zero overlap.
Implementation Steps
autofit/mapper/prior/width_modifier.py—RelativeWidthModifier.__init__(value, absolute_floor=None);__call__returnsmax(value * abs(mean), floor)when floor set, elsevalue * abs(mean);from_dict/dictround-trip the optional key.autofit/mapper/prior_model/abstract.py— afterwidth = width_modifier(mean)(and the explicitr/apaths), raiseexc.PriorExceptionnaming the prior path ifwidth <= 0.autofit/messages/normal.py— numpy-path strictsigma > 0enforcement inNormalMessage.__init__; retire the brokenassert_sigma_non_negativeJAX branch.autofit/messages/truncated_normal.py—< 0→<= 0.- Tests per the plan bullet above (numpy-only).
Behaviour changes (user-visible, disclosed)
- Chained fits with parameters whose posterior median is negative get a positive passed width (previously negative sigma, silently sign-flipping
value_for). Sampling of affected chained fits changes — for the better. - Chained fits with a
mean=0unconfigured parameter now fail loudly with guidance (previously silently froze the parameter via a delta-function prior). GaussianPrior/NormalMessagewith σ ≤ 0 raise at construction.
Autonomy: supervised (--auto, human instructed live 2026-07-10 after Phase-1 merge; heart-ack 6-reason set recorded in active.md this chain).
🤖 Generated with Claude Code
Activity
Jammy2211 commentedon Jul 10, 2026
Supervised-mode disclosure: Decision 2 adjusted on new evidence (strict → permissive)
The #1331 recommendation for Decision 2 was reject σ ≤ 0 strictly. Implementing it broke 16 tests + 4 errors across three subsystems, and the failures are not stale tests — they pin a deliberate, load-bearing design idiom:
non_linear/samples/util.py::simple_model_for_kwargswraps every known latent value asGaussianPrior(mean=value, sigma=0.0)— the σ=0 point-mass carrier is how latent quantities become model parameters (10+ tests).message.from_mode(x, covariance=np.zeros(()))is the sanctioned zero-covariance projection (test_correspondence.py::test_from_mode).test_result.py::test_model_relativeassertssigma == 0.0for a zero-centred parameter through the explicitmodel_centred_relative(r=...)path.#1331's own caveat asked exactly this: "the reviewer should confirm whether any current call site depends on σ == 0 constructing" — answer: three subsystems do. So this PR ships the permissive variant (the explicitly-listed alternative on #1331):
NormalMessagerejects σ < 0 (the actual bug — negative sigma previously constructed silently with deceptivevariance = σ² > 0and sign-flippedvalue_for); σ = 0 permitted and documented as the point-mass idiom.TruncatedNormalMessagekeeps its σ < 0 rejection — the two classes now agree, which was the real defect Decision 2 targeted.PriorExceptionwithabsolute_floorguidance) is scoped to the default width-modifier path — the silent-freeze bug frombug/priors/08. Explicita=/r=widths keep their historical, test-pinned point-mass semantics atmean=0.Everything else is unchanged from the plan:
RelativeWidthModifier→abs(mean)+ opt-inabsolute_floor(config round-trip included),mean=0chained regression tests, negative-median chained parameters now get positive widths.If the strict variant is still wanted, the follow-on work is a first-class point-mass representation for the latent machinery (migrating
simple_model_for_kwargsoff degenerate Gaussians) — happy to file that as a separate design prompt. Validation state: targeted clusters 67/67 green; full suite re-running now, result on the PR.Jammy2211 commentedon Jul 10, 2026
Shipped at PR-open — #1348
PR #1348 open (
pending-release,--autovalidation checklist in body — note the explicit human check on the D2 permissive call).priors_xp_dispatchPASS;emcee_gaussian_bias_checkrunning, result to follow.library-shipped, awaiting-merge; autonomy-log row appended.Merge stays human. With this and #1345 merged, the #1331 batch is fully landed except the parked design items (09/11/12/13/14).
Jammy2211 commentedon Jul 10, 2026
Smoke complete:
emcee_gaussian_bias_check.pyPASS — all four gate legs green for #1348: tests 1447/14 · smoke 2/2 · review CLEAN (D2 amendment disclosed above) · Heart YELLOW within the live ack. Awaiting human merge decision.Jammy2211 commentedon Jul 10, 2026
Merged —
cf0cc4bbbvia #1348 (merged-unchanged incl. the disclosed D2 permissive amendment; pending-release). With #1345 + #1348 both in, the #1331 fix batch is fully landed. Closing.