Skip to content

Tighten RulesModel: typed discriminated-union rules, constrained mappings, regex validation#23102

Merged
mvdbeek merged 1 commit into
galaxyproject:devfrom
jmchilton:tighten-rules-model
Jul 21, 2026
Merged

Tighten RulesModel: typed discriminated-union rules, constrained mappings, regex validation#23102
mvdbeek merged 1 commit into
galaxyproject:devfrom
jmchilton:tighten-rules-model

Conversation

@jmchilton

Copy link
Copy Markdown
Member

Replace rules: list[dict[str, Any]] with 18 typed Pydantic rule models keyed on a type discriminator (1:1 with the runtime rules_dsl rule set). Constrain RulesMapping.type to the known mapping Literals. Validate regex expression fields (AfterValidator). Fix add_filter_compare value int->float. RulesMapping/ RulesModel become BaseModel (extra ignored) so model_dump emits DSL-only fields.

Give RulesParameterModel a workflow-aware pydantic_template mirroring the other inline params (optional in unlinked workflow_step, allow_connected_value when linked) so gx_rules validates across state representations.

Adds gx_rules.xml framework tool + gx_rules parameter_specification.yml cases. Pairs with editor UI-metadata leak fix #22823 and IWC cleanup galaxyproject/iwc#1278.

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

class RulesMapping(StrictModel):
type: str
def _validate_regex_expression(v: str) -> str:
import re

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably not be a local import ?

…ings, regex validation

Replace `rules: list[dict[str, Any]]` with 18 typed Pydantic rule models keyed
on a `type` discriminator (1:1 with the runtime rules_dsl rule set). Constrain
RulesMapping.type to the known mapping Literals. Validate regex `expression`
fields (AfterValidator). Fix add_filter_compare value int->float. RulesMapping/
RulesModel become BaseModel (extra ignored) so model_dump emits DSL-only fields.

Give RulesParameterModel a workflow-aware pydantic_template mirroring the other
inline params (optional in unlinked workflow_step, allow_connected_value when
linked) so gx_rules validates across state representations.

Adds gx_rules.xml framework tool + gx_rules parameter_specification.yml cases.
Pairs with editor UI-metadata leak fix galaxyproject#22823 and IWC cleanup galaxyproject/iwc#1278.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jmchilton
jmchilton force-pushed the tighten-rules-model branch from 86d2270 to ccb8d3b Compare July 20, 2026 19:29
@mvdbeek
mvdbeek merged commit caf9484 into galaxyproject:dev Jul 21, 2026
57 of 59 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in Galaxy Dev - weeklies Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

2 participants