Skip to content

fix(strategies): describe(id, registry) FieldError for 3+ type-parameter strategies - #519

Merged
ocots merged 1 commit into
mainfrom
fix/describe-registry-arity-516
Jul 29, 2026
Merged

fix(strategies): describe(id, registry) FieldError for 3+ type-parameter strategies#519
ocots merged 1 commit into
mainfrom
fix/describe-registry-arity-516

Conversation

@ocots

@ocots ocots commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary

  • _strategy_base_name and _strategy_type_name each peeled exactly one UnionAll layer before assuming a DataType underneath, which only holds for strategies with exactly two total type parameters. CTSolvers.Integrators.SciML (4 params) crosses that line, breaking describe(:sciml, ...) and, because the parameter branch walks every strategy in the registry, describe(:cpu, ...) / describe(:gpu, ...) too on any registry containing it.
  • Both helpers now handle any parameter depth: _strategy_base_name falls through to the existing nameof-based fallback, _strategy_type_name peels every UnionAll layer instead of one.
  • Adds a new arity-matrix test (1–4 type parameters) exercising the public describe(id, registry) entry point, plus a describe(:cpu, registry) regression covering the blast-radius case — this entry point had zero prior coverage.
  • Adds a describe(:di, registry) test for DifferentiationInterface, CTBase's own strategy, previously only reachable through CTFlows' flow registry.
  • Adds validation in create_registry for a related, previously-silent contract: 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 Exceptions.IncorrectArgument.
  • Documents the parameter-position contract in AbstractStrategy's docstring.

Fixes #516

Test plan

  • suite/strategies (980 tests) green
  • suite/differentiation (108 tests) green
  • suite/meta code-quality/docstring checks green
  • Full suite green: 4923/4923

🤖 Generated with Claude Code

…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>
@ocots
ocots merged commit 347a7c7 into main Jul 29, 2026
3 checks passed
@ocots
ocots deleted the fix/describe-registry-arity-516 branch July 29, 2026 19:26
@ocots ocots mentioned this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

describe() throws FieldError for strategies with 3+ type parameters (:sciml); no arity coverage, no describe test for DifferentiationInterface

1 participant