Skip to content

feat(traits): implement ControlDependence on Model; migrate is_control_free/has_control to CTBase#354

Merged
ocots merged 1 commit into
mainfrom
feat/control-dependence-trait
Jun 28, 2026
Merged

feat(traits): implement ControlDependence on Model; migrate is_control_free/has_control to CTBase#354
ocots merged 1 commit into
mainfrom
feat/control-dependence-trait

Conversation

@ocots

@ocots ocots commented Jun 28, 2026

Copy link
Copy Markdown
Member

Summary

Implements the new CTBase.Traits.ControlDependence trait (added in CTBase 0.26) on Model, and migrates the is_control_free / has_control predicates from CTModels-local definitions to the generic CTBase functions. This is PR2 of the ecosystem-wide traits cleanup (CTBase → CTModels → CTFlows).

What changed

  1. Model implements the control-dependence contract (src/Models/model.jl):

    • has_control_dependence_trait(::Model) = true
    • control_dependence(ocp::Model) reads the control model type: EmptyControlModelControlFree, any other → WithControl
    • This mirrors the existing variable-dependence design verbatim (read from the field type, not the dimension)
  2. is_control_free / has_control migrated to CTBase.Traits (src/Models/Models.jl):

    • Removed the bespoke runtime definitions (control_dimension(ocp) == 0)
    • Now imported from CTBase.Traits and re-exported, so CTModels.Models.is_control_free / has_control keep working unchanged
    • Bonus: is_control_free is now type-stable (derived from the control model type)
  3. Dependencies: CTBase compat 0.250.26; version 0.13.3-beta0.14.0-beta

  4. Tests (test/suite/models/test_variable_control_checks.jl): extended the control-free / with-control cases with trait-path assertions (control_dependence, has_control_dependence_trait, has_control)

  5. Docs: added a Control dependence subsection to the model Types and traits guide

Why this matters

Control presence is a genuine dispatch axis. PR3 (CTFlows) will dispatch Flow(ocp) on control_dependence(ocp) to route control-free vs with-control problems, closing a latent bug where a with-control OCP would silently mis-build a Hamiltonian. This PR makes the trait available on Model (its proper home, avoiding type piracy in CTFlows).

Verification

  • Tests: models/components/display suites 313/313 passing (including extended control-checks)
  • Docs build: succeeds (exit 0). The @ref warnings for is_control_free/has_control are identical to the pre-existing is_autonomous warning on the same page (imported CTBase predicates, no InterLinks) — consistent, tolerated via warnonly
  • Smoke test: control_dependence dispatches on Model; is_control_free/has_control confirmed === CTBase.Traits.* (re-export preserved)

Compatibility

No breaking changes — predicate names and behaviour preserved via re-export. Requires CTBase ≥ 0.26.0-beta. See BREAKING.md.


🤖 Generated with Claude Code

…as_control to CTBase

- Model now implements the CTBase.Traits.ControlDependence contract
  (has_control_dependence_trait + control_dependence), reading ControlFree from an
  EmptyControlModel and WithControl otherwise — from the control model TYPE, mirroring
  the existing variable-dependence design (not from control_dimension)
- is_control_free / has_control are now generic functions owned by CTBase.Traits;
  CTModels re-exports them so CTModels.Models.is_control_free / has_control are unchanged.
  is_control_free is now type-stable (no runtime control_dimension == 0)
- Bump CTBase compat 0.25 -> 0.26 (and docs env compat); bump version 0.13.3-beta -> 0.14.0-beta
- Extend control-checks tests with trait-path assertions (control_dependence, has_control)
- Add a Control dependence subsection to the model Types-and-traits guide
- Update CHANGELOG.md and BREAKING.md (purely additive, no breaking changes)

Tests: models/components/display suites 313/313 pass; docs build succeeds (exit 0).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ocots ocots merged commit 199a9ec into main Jun 28, 2026
6 checks passed
@ocots ocots deleted the feat/control-dependence-trait branch June 28, 2026 13:24
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.

1 participant