fix(strategies): describe(id, registry) FieldError for 3+ type-parameter strategies - #519
Merged
Merged
Conversation
…ter strategies _strategy_base_name and _strategy_type_name each peeled exactly one UnionAll layer before assuming a DataType underneath, which only holds when a strategy has exactly two total type parameters. CTSolvers.Integrators.SciML (4 params) is the first strategy to cross that line, breaking describe(:sciml, ...) and, since the parameter branch walks every strategy in the registry, also describe(:cpu, ...) / describe(:gpu, ...) on any registry containing it. Both helpers now handle any parameter depth: _strategy_base_name falls through to the existing nameof-based fallback, and _strategy_type_name peels every UnionAll layer instead of one. Also adds validation in create_registry for a related, previously-silent contract violation: the strategy parameter must be the first declared type parameter (every Strategies.parameter implementation reads slot 1). Violating it used to surface as a bare TypeError or a misleading NotImplemented; it now raises a clear IncorrectArgument. Fixes #516 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
_strategy_base_nameand_strategy_type_nameeach peeled exactly oneUnionAlllayer before assuming aDataTypeunderneath, which only holds for strategies with exactly two total type parameters.CTSolvers.Integrators.SciML(4 params) crosses that line, breakingdescribe(:sciml, ...)and, because the parameter branch walks every strategy in the registry,describe(:cpu, ...)/describe(:gpu, ...)too on any registry containing it._strategy_base_namefalls through to the existingnameof-based fallback,_strategy_type_namepeels everyUnionAlllayer instead of one.describe(id, registry)entry point, plus adescribe(:cpu, registry)regression covering the blast-radius case — this entry point had zero prior coverage.describe(:di, registry)test forDifferentiationInterface, CTBase's own strategy, previously only reachable through CTFlows' flow registry.create_registryfor a related, previously-silent contract: the strategy parameter must be the first declared type parameter (everyStrategies.parameterimplementation reads slot 1). Violating it used to surface as a bareTypeErroror a misleadingNotImplemented; it now raises a clearExceptions.IncorrectArgument.AbstractStrategy's docstring.Fixes #516
Test plan
suite/strategies(980 tests) greensuite/differentiation(108 tests) greensuite/metacode-quality/docstring checks green🤖 Generated with Claude Code