ENH: split StateTransitionManager into a workflow module - #344
Open
grayson-helmholz wants to merge 6 commits into
Open
ENH: split StateTransitionManager into a workflow module#344grayson-helmholz wants to merge 6 commits into
StateTransitionManager into a workflow module#344grayson-helmholz wants to merge 6 commits into
Conversation
Extract the pipeline stages of the `StateTransitionManager` into free functions in a new `qrules.workflow` module, so that intermediate results (most notably `QNProblemSet`s) can be inspected, modified, and fed back into the pipeline. The STM remains as a thin facade that delegates to these functions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
redeboer
self-requested a review
July 10, 2026 13:15
Contributor
Author
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Introduce `QNProblemSetCollection`, returned by `create_qn_problem_sets()`, which carries the intermediate-particle selection, final state, and formalism along with the strength-grouped `QNProblemSet`s. `find_solutions()` defaults to these values, so the solving stage can no longer silently diverge from the values with which the problem sets were created (e.g. matching against the full PDG although the problem sets were built for a restricted resonance selection, or deduplicating canonical solutions with helicity filters). Explicit arguments still override, and a plain strength-grouped dictionary is still accepted. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TWmXKcjJMmRVJCUi58JDLH
The topology creation (including the n-body mass-conservation toggle) and the `ProblemSet` to `QNProblemSet` conversion were duplicated between the `StateTransitionManager` and the workflow module; both now delegate to the single implementation in `qrules.workflow`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TWmXKcjJMmRVJCUi58JDLH
Mirrors `src/qrules/workflow.py` with `tests/unit/test_workflow.py`, covering the intermediate-particle selection, `InteractionConfig` get/set semantics, and an equivalence test that reproduces the STM-generated `ReactionInfo` through the `create_qn_problem_sets`/`find_solutions` pipeline. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TWmXKcjJMmRVJCUi58JDLH
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.

StateTransitionManagerto facilitate use of intermediate results #305allowed_intermediate_particles#306allowed_interaction_types#307QNProblemSets without theStateTransitionManager#284What
Extracts the pipeline stages of the
StateTransitionManagerinto free functions in a newqrules.workflowmodule, so that intermediate results — most notablyQNProblemSets — can be inspected, modified, and fed back into the pipeline (GROMACS-style workflow, as proposed in #305). The STM remains as a thin facade that delegates to these functions; its public API and behavior are unchanged.New data structures
AllowedIntermediateParticles+filter_intermediate_particles()(Create struct and appropriate modification-functions forallowed_intermediate_particles#306) — replaces the STM-private pair__intermediate_particle_filters/__allowed_intermediate_states. Makes explicit that this selection feeds both problem-set creation (intermediate edge QN domains) and theCSPSolver(particle matching), which the STM previously shared invisibly between two private code paths.InteractionConfigwithget/set_allowed_interaction_types()(Struct and functions forallowed_interaction_types#307) — bundles interaction-type settings, allowed types per node, and the interaction determinators (LeptonCheck,GammaCheck).Pipeline stage functions
create_graph_settings()STM.__determine_graph_settingscreate_problem_sets()STM.create_problem_setssolve()STM.find_quantum_number_transitions+STM._solveconvert_to_particle_transitions()STM._find_particle_transitions+STM.__convert_to_particle_definitionscollect_reaction_info()STM.find_solutionsCrucially,
solve()takes strength-groupedQNProblemSets directly, closing the gap described in #305: generatedQNProblemSets can now be filtered/modified (e.g. withfilter_quantum_number_problem_set()) and solved, without reconstructing STM-internal state around a bareCSPSolver.Default use-case wrappers
Two functions cover the standard workflow, meeting at the strength-grouped
QNProblemSets — the natural inspection point:create_qn_problem_sets()generatesQNProblemSets without theStateTransitionManager, which closes #284 as written. Note that it still expands spin projections into separate problem sets internally (via the particle-levelProblemSetdual); the facts-driven generation without projection expansion is tracked separately in #338/#339.Notes
tests/channels/results are identical._group_by_strength,_filter_by_name_pattern,_match_final_state_ids, and_strip_spinmoved fromtransition.pytoworkflow.py, next to their only remaining callers.functools.partial) instead of the whole STM instance.BEHAVIORfix):STM.reaction_modeis stored asstr(solving_mode), so theSolvingMode.FASTearly-break in the solving loop never triggers through the STM. The newworkflow.solve()compares the enum properly, soFASTworks as documented when using the new API; the STM delegation preserves the old (always-FULL) behavior.qrules.workflowis not re-exported inqrules.__init__for now; happy to add that if preferred.Part of epic #336 (Stage 3 of the roadmap).
Verification
pytest tests/unit src -m "not slow": 696 passedpytest tests/channels -m "slow or not slow": 55 passedmypy src/qrules: clean;ruff check/ruff format: clean; all pre-commit hooks (incl. pyright) pass🤖 Generated with Claude Code