Repository navigation
Description
Overview
Search-extensibility phase A4: decompose NonLinearSearch (abstract_search.py is 2,102 lines today, target ≤600), add the one search-level seed (D4), and delete the AbstractMCMC/AbstractNest/AbstractMLE family bases behind one-release deprecated thin subclasses (D14). Dependencies A2 and A3 are merged; the review-05 post-merge fixes landed as PyAutoFit#1683 on 2026-10-14. Design authority: PyAutoMind draft/research/autofit/search_extensibility_epic_report.md §3.2 (nine invariants), §3.3 "Seed (D4)" + legacy table, §8.3, §8.5, the "#### A4" phase entry. Do not re-derive the decisions.
Plan
- PR 1 (A4a):
TestModeBypass+ sharedfinalize_result(samples)+ genericapply_test_modevia a post-init hook; moveSearchFactorOptimisertographical/expectation_propagation/;SearchRuntimeSettings+paths_from; paths capabilities. Legacy pool shims stay (deprecated) until A5;SneakyPoolstays asPoolFactory.sneaky. - PR 2 (A4b): search-level
seedwithSeedSequencefan-out, conditional identifier walk, the legacy table (Nautilus/NSS alias, NUTS/SMC unhashed default 42 with sentinel), initializer off globalrandom, grid children on child streams. - PR 3 (A4c): family bases out of the MRO; deprecated thin subclasses warning via
__init_subclass__; per-posterior_kinddefault objects and plotter; SMC →weightedwith evidence; companion PRs for PyAutoBrainsampler_pipeline/reference.mdand the three developer-tier searches. - Every PR: golden table byte-identical (A0a), clipper tripwire, serialized constructor-argument sets,
search.jsonround-trip, old outputs load; serial full suite +unittest-nojaxemulation; autofit + autolens workspace smoke before ship.
Tier: judge — merge mode: human /prm (PR 1 → PR 2 → PR 3, stacked)
Detailed implementation plan
Affected Repositories
- PyAutoFit (primary; all three PRs)
- PyAutoBrain, autofit_workspace_developer (companion docs/developer-tier updates with PR 3)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoFit | main (8437a3b) | clean |
Suggested branch: feature/search-ext-a4-decompose (PR 1), feature/search-ext-a4-seed (PR 2, stacked), feature/search-ext-a4-family-bases (PR 3, stacked)
Implementation Steps
See the prompt (folded below) — the three PR scopes, the nine invariants and the witness are specified there. Key files: autofit/non_linear/search/abstract_search.py, initializer.py, mapper/identifier.py (conditional seed walk), non_linear/search/{mcmc,nest,mle}/abstract*.py (family bases), graphical/expectation_propagation/ (optimiser move), test_autofit/non_linear/search/test_golden_*.py, test_identifiers.py (#1493 tripwire), docs/design/run_ctx.md.
Out of scope
FitLifecycle extraction (A5, D22); deletion of make_pool/make_sneaky_pool/number_of_cores shims (A5); per-search run(ctx) migrations (A5); Prior/Message design (#1500).
Original Prompt
Click to expand starting prompt
@PyAutoFit A4: decompose NonLinearSearch, search-level seed, delete the family bases
Type: refactor
Target: autofit
Repos:
- PyAutoFit
Difficulty: large
Autonomy: supervised
Priority: high
Status: formalised
Consequence: judge
Epic: search-extensibility
Phase: A4
Witness:abstract_search.pyis ≤600 lines; BFGS at test-mode level 1 runs a reducedmaxiter; twoEmcee(seed=1)fits on one platform produce identicalsamples.csv;Nautilus().hash_listis unchanged; the A0a golden table is byte-identical for all 15 default constructions (default, explicit-None, explicit-seed, old-JSON and old-incomplete-output cases tested separately, the explicit-seed NUTS/SMC re-key accepted and recorded); the feat: put the clipper in the search identifier (MLE searches only) #1493 clipper tripwire passes; serialized constructor-argument sets match; subclassing a deprecated family base warns; the three developer-tier searches (autofit_workspace_developer/searches/{nss,ultranest},pyswarms) still run; a 2-step EP test with MockSearch passes; autofit + autolens workspace smoke andautofit_workspace_test/scripts/graphicalpass.
Review-minutes: 45
Unattended: needs-slicing
Filed: 2026-10-14
Authority: epic report draft/research/autofit/search_extensibility_epic_report.md
§3.2 (family bases + the nine invariants), §3.3 "Seed (D4)" with its legacy
table, §8.3 (D14), §8.5 (D22: FitLifecycle deferred to A5), the "#### A4"
phase entry; surveys 01 P4 and 02 P4. Dependencies A2 and A3 are merged;
review-05 fixes merged 2026-10-14 (PyAutoFit#1683). Human-agreed order
2026-10-14: A4 after B4a. Do not re-derive the decisions.
Shape: ONE task, THREE stacked PRs, merged in order
PR 1 — A4a decompose. TestModeBypass with a shared
finalize_result(samples) and a generic apply_test_mode from
test_mode_budget via a post-init hook (BFGS level 1 → reduced maxiter);
SearchFactorOptimiser moves to graphical/expectation_propagation/ keeping
release_search_internal and the updater cache-invalidation semantics;
SearchRuntimeSettings and paths_from; paths capabilities. FitLifecycle
is NOT extracted (D22). The legacy pool shims (make_pool, make_sneaky_pool,
number_of_cores accessors on the search) are marked deprecated but kept —
Emcee and the initializer still call them; their deletion is A5 when every
search is on run(ctx). SneakyPool itself stays as PoolFactory.sneaky
(human ruling 2026-10-14). Target: abstract_search.py ≤600 lines.
PR 2 — A4b seed (D4). One search-level seed with SeedSequence fan-out:
stream 0 to the initializer (which stops using global random), stream 1+ to
the backend; grid-search children derive child streams. The seed enters the
identifier through a conditional in the identifier walk when not None — never
by adding "seed" to the base __identifier_fields__. Legacy table: Nautilus
and NSS keep their static "seed" field and their seed kwarg becomes an
alias of the base seed; NUTS and SMC keep an unhashed default 42 (sentinel
default to tell "default 42" from "user passed 42") and a user-supplied seed is
hashed — record the accepted re-key of existing explicit-seed NUTS/SMC output
folders; the other 11 hash the seed only when not None. Promise scoped
honestly: same seed → same initial points for every search; bit-identical
samples only within a pinned backend/platform where demonstrated; MCMC archive
searches resume statistically.
PR 3 — A4c family bases (D14). Delete AbstractMCMC/AbstractNest/
AbstractMLE from the concrete searches' MRO. Their modules keep exporting
distinct deprecated thin subclasses that preserve the former defaults and warn
via __init_subclass__ (removed one release later). Initializer, clipper and
autocorrelation defaults move into per-posterior_kind default objects applied
in each concrete __init__, never on NonLinearSearch; BFGS/MultiStart keep
"clipper" in __identifier_fields__. The plotter becomes per-posterior_kind,
replacing the family plot_results. SMC moves to the weighted posterior kind
with evidence and drops auto_correlation_settings (old search.json carrying
it still loads); its module stays at mcmc/blackjax/smc/. AbstractDynesty
stays. Brain skills/sampler_pipeline/reference.md (the subclassing guidance at
~:128-129) and the three developer-tier searches are updated in the same PR set
(PyAutoBrain + autofit_workspace_developer companion PRs, after PR 3 opens).
Invariants every PR must hold (report §3.2)
- Public class names and
af.export names. 2. Identifier hashes — the A0a
golden table; the only change is the seed rule's table. 3.files/search.json
class paths, round-tripping, and serialized constructor-argument sets
(dictable.pywalks__bases__). 4. On-disk layout and filenames incl.
search_internal/*; old outputs read forever. 5.samples_info["class_path"]
values (re-export aliases for moved classes). 6. The feat: put the clipper in the search identifier (MLE searches only) #1493 clipper tripwire. NonLinearSearchstays a subclass ofAbstractFactorOptimiser
(EPOptimiseracceptsaf.Emcee()). 8. External subclasses keep working one
release. 9.Resultstays one class.
Risks (report)
EP's path mutation and memory release (the RAL comments ~:470-505); test-mode
changes reach every workspace smoke run (bypass levels 2/3 heavily used in
autolens_workspace) — run autofit + autolens workspace smoke before each ship.
Constraints
pytest -n autois broken on the PyAutoFit suite (address-based parametrize
ids); run serially. Emulate theunittest-nojaxleg before each ship.
Sphinx warnings ≤30. Prior/Message design (design: unify the Prior/Message hierarchy around a single-source density #1500) untouched.
Activity
Jammy2211 commentedon Oct 14, 2026
Shipped — three stacked PRs merged in order 2026-10-14 by human
/prm:Pre-merge Codex gpt-6-astra adversary review 07 (4 findings) enacted on the branches before merge; one follow-up CI red (covariance interpolator test determinism) fixed test-only. Full serial suite 3776 passed / 1 skipped / 0 xfailed at merge. All three carry
pending-release.Companion changes (Brain sampler_pipeline reference, developer-tier ultranest/pyswarms, workspace_test seeded Dynesty) are filed in PyAutoMind as
draft/refactor/autofit/search_ext_a4_companions.md. Mind record:complete/2026/10/search-ext-a4-decompose.md.