Skip to content

Refactor: move existing code to save/, add design documentation#195

Draft
ocots wants to merge 213 commits into
mainfrom
develop
Draft

Refactor: move existing code to save/, add design documentation#195
ocots wants to merge 213 commits into
mainfrom
develop

Conversation

@ocots
Copy link
Copy Markdown
Member

@ocots ocots commented Apr 28, 2026

  • Move src/, docs/, ext/, test/ to save/ for rewrite
  • Add reports/ with design documentation:
    • design.md: abstract types, strategy family contracts, pipelines
    • candidate_strategies.md: candidate strategy families and rationale
    • strategies.md: CTSolvers strategy contract reference
  • Update .windsurf/rules/:
    • modules.md: submodule architecture standards (CTSolvers pattern)
    • testing.md: adapt CTModels testing standards to CTFlows
  • Update test/runtests.jl: use CTBase.run_tests() pattern

- Move src/, docs/, ext/, test/ to save/ for rewrite
- Add reports/ with design documentation:
  - design.md: abstract types, strategy family contracts, pipelines
  - candidate_strategies.md: candidate strategy families and rationale
  - strategies.md: CTSolvers strategy contract reference
- Update .windsurf/rules/:
  - modules.md: submodule architecture standards (CTSolvers pattern)
  - testing.md: adapt CTModels testing standards to CTFlows
- Update test/runtests.jl: use CTBase.run_tests() pattern
@ocots ocots marked this pull request as draft April 28, 2026 10:15
ocots added 27 commits April 28, 2026 12:37
… documentation

- Reorder submodules to correct DAG: Core -> Systems -> Integrators -> ADBackends -> Modelers -> Flows -> Pipelines
- Add I<:Integrators.AbstractODEIntegrator constraint to Flow
- Remove Pipelines/build_solution.jl wrapper (was causing recursion, Systems.build_solution is re-exported instead)
- Update test runner to use CTBase.run_tests with TestOptions pattern (aligned with CTSolvers/CTModels)
- Update all test files to use Main.TestOptions instead of Main.TestData
- Add docs/ structure on CTModels light model: Project.toml, make.jl, api_reference.jl, src/index.md
- Auto-generate API reference for all 7 submodules via CTBase.automatic_reference_documentation
- Fix abstract_system.jl: parameter naming to 'system', error message format aligned with design.md
- All tests pass (97/97)
…and open questions

- Add Goal section with overall objective
- Add Phase 1 scope (vector-field flow with full trait matrix, SciML integrator)
- Add Deferred section (matrix fields, solution wrapper, plot recipe, internalnorm fix, GPU, concatenation, real AD backends)
- Add Open questions section (trait matrix shape, option ownership, integrator granularity, GPU pathway, internalnorm placement, solution wrapper API, plot recipe location, SciML option verification)
- Move long code snippets to Appendix (Exa CPU/GPU metadata, dual-number internalnorm)
- Consolidate all references in one place
…n pattern

- Rename Core module to Common to avoid conflicts with Julia's Core
- Add explicit traits for VectorField: TimeDependence (Autonomous/NonAutonomous) and VariableDependence (Fixed/NonFixed)
- Implement VectorField and VectorFieldSystem with trait-based compile-time dispatch
- Add SciML extension pattern for integrators (CTFlowsSciMLExt)
- Remove deprecated ADBackends and Modelers modules
- Update Flow to use config-based callable (PointConfig/TrajectoryConfig)
- Add build_integrator, flow_constructor, and build_solution to Pipelines
- Update all tests to v1 API and fix trait constructor calls
- All tests passing (81 passed, 0 failed)
- Add SciMLTag as concrete struct for extension dispatch
- Add CTFlowsSciMLExt.jl with full strategy metadata (8 options with validators)
- Implement build_sciml_integrator and callable in extension
- Implement ode_problem for VectorFieldSystem (Fixed/NonFixed × PointConfig/TrajectoryConfig)
- Add Base.show for PointConfig and TrajectoryConfig
- Fix build_solution call signature in flow.jl
- Add scalar/vector/matrix cases in VectorField tests
- Update VectorField examples with comprehensive pipeline demos
- Add test_common.jl for __autonomous/__variable tests
- Update Project.toml with OrdinaryDiffEqTsit5 weakdep and extension
- Remove old testing.md, add testing-creation.md and testing-execution.md
- is_autonomous / is_nonautonomous for time dependence
- is_variable / has_variable (alias) / is_nonvariable for variable dependence
- Export all predicates from Systems module
- Add tests for all predicates
- Create VectorFieldSolution type to wrap raw SciML ODE solutions
- Update build_solution for TrajectoryConfig to return VectorFieldSolution
- Add solve(system, config, integrator) method (builds flow then solves)
- Add solve(vf, config, integrator) method (builds system then solves)
- Add kwargs support to solve() and integrate() for NonFixed systems
- Update example script to use Tsit5 with all solve() methods
- Add tests for VectorFieldSolution and solve() hierarchy
- Add Section 5: Flow Construction to example script
- Demonstrate build_flow(system, integrator)
- Demonstrate Flow(vf, id=:sciml; opts...) constructor
- Test with Fixed and NonFixed VectorFields
- Add tests for Flow constructor from VectorField
- Add tests with options and NonFixed cases
- Test that Fixed systems reject variable kwarg (MethodError)
- Test that NonFixed systems require variable kwarg (UndefKeywordError)
- Update FakeFlow to match real Flow type dispatch pattern
- Add Flows.system and Flows.integrator accessors to FakeFlow
- Add Systems.ode_problem implementation for FakeSystem
- Change solve.jl to use accessors instead of direct field access
- Skip tests that require SciML extension in test_build_flow
- Fix test_solve to expect correct return values from solve()
- Shows Flow type, system traits, vector_field type, and integrator type
- Uses nameof() to get clean type names without typename() wrapper
- Accesses sys.vf field (correct field name for VectorFieldSystem)
…ystem

- Add is_autonomous, is_nonautonomous, is_variable, is_nonvariable, has_variable to VectorFieldSystem
- Add predicate methods to AbstractFlow that delegate to system(flow)
- Add tests for predicate methods on VectorField flow
- Add tests for NotImplemented error when system(flow) not implemented
- Shows raw type name (not full signature) for cleaner display
- Shows time span and number of time points if available
- Add display() call in example script
- Remove integrate.jl (no longer needed)
- Remove solve_system.jl and solve_vector_field.jl (simplified to solve(flow, config))
- Remove test_integrate.jl (no longer needed)
- Update Pipelines.jl manifest
- Add RecipesBase to deps and Plots to weakdeps
- Add CTFlowsPlotsExt extension with plot, plot! methods
- Add RecipesBase.plot stub in solution.jl (throws error if extension not loaded)
- Move RecipesBase import to Systems.jl module level
- Remove callable stub (not needed for extension)
- Update example script to use new API
- Remove callable stub from solution.jl
- Add actual callable directly in solution.jl (delegates to sol.raw)
- Remove callable from CTFlowsPlotsExt.jl (not Plots-specific)
- Callable is always available since it just delegates to raw SciML solution
- Add comprehensive docstring for AbstractTag explaining its role as a dispatch tag for extension architecture
- Update docstrings.md to clarify that internal references (@ref) must use full module path including root package
- Fix templates to show proper qualification pattern (PackageName.ModuleName.symbol)
…tion

- Add docstrings for PointConfig and TrajectoryConfig structs
- Add docstring for AbstractTag explaining dispatch-based extension architecture
- Fix api_reference.jl: replace Core with Common, remove ADBackends and Modelers
- Update index.md to remove references to non-existent modules
- Update docstrings.md to clarify @ref qualification requires full module path
- Add AbstractConfig abstract type as marker for configuration objects
- Update PointConfig and TrajectoryConfig to subtype AbstractConfig
- Export AbstractConfig from Common module
- Type config parameters with Common.AbstractConfig in:
  - AbstractFlow callable signature
  - Systems.ode_problem signature
  - Systems.build_solution signature
  - Pipelines.solve signature
- Update docstring cross-references to use full module path
…andards

- Add tests for AbstractConfig export verification
- Add tests for type hierarchy (PointConfig/TrajectoryConfig <: AbstractConfig)
- Add tests for Base.show methods for both config types
- Follow testing standards with clear section separation and descriptive test names
ocots added 30 commits May 19, 2026 15:17
- Add AugmentedHamiltonianTrait and AbstractAugmentedHamiltonianConfig in Common module
- Update AbstractHamiltonianSystem to include AD trait parameter (AT)
- Add HamiltonianSystem struct with AD backend support, mirroring HamiltonianVectorFieldSystem
- Implement build_rhs_augmented with batch compatibility checks for matrix inputs
- Add build_system overloads for Data.Hamiltonian with AD backend
- Update all references to AbstractHamiltonianSystem to include AT parameter:
  - AbstractHamiltonianFlow in Flows
  - MultiPhaseHamiltonianFlow in MultiPhase
  - All test files with fake Hamiltonian systems
- Add comprehensive docstrings following documentation standards
- Add tests for HamiltonianSystem, ad_trait, build_rhs_augmented, and type stability
- All 1786 tests passing
Add HamiltonianSystem with AD support and AugmentedHamiltonianTrait
…am_split

- Split test_flow_callables_sciml.jl into three files by system:
  - test_flow_callables_sciml_vector_field.jl (VectorFieldSystem)
  - test_flow_callables_sciml_hamiltonian_vector_field.jl (HamiltonianVectorFieldSystem)
  - test_flow_callables_sciml_hamiltonian_system.jl (HamiltonianSystem with fake AD backend)
- Replace original test_flow_callables_sciml.jl with stub delegating to new files
- Add coverage for MVector and ForwardDiff.Dual types in all system test files
- Fix CTFlowsStaticArrays._ham_split overloads: restrict to SVector/SMatrix
  so MVector falls through to AbstractVector @view implementation (mutable)
- All tests pass: 1867/1867
- Add CTFlowsDifferentiationInterface extension with DifferentiationInterfaceCache
- Implement prepare_cache, hamiltonian_gradient, variable_gradient with cached/uncached variants
- Add initial_time/final_time methods to AbstractConfig
- Update prepare_cache signature to include typical_t parameter
- Simplify call methods: remove specialized HamiltonianFlow overload, use generic call with prepare_cache
- Add cache= keyword to CTFlowsSciML build_problem
- Set prepare_cache default to false in DifferentiationInterface metadata
- Add comprehensive unit and integration tests for DI extension
- Skip complex and dual type tests (known limitations)
- Update AD backend stub test for new prepare_cache signature
- Add fallback prepare_cache method for AbstractSystem that returns nothing
- Update build_problem signature to require cache parameter (no default)
- Update CTFlowsSciML build_and_solve to remove cache default value
- Update all test files to pass cache=nothing to build_problem calls
- Update FakeHarmonicADBackend prepare_cache signature to include typical_t
- Update Differentiation.jl module docstring for prepare_cache signature
- Update abstract_integrator.jl docstring for build_problem signature
- Add hamiltonian(sys) and backend(sys) accessor functions to HamiltonianSystem
- Update prepare_cache to use AbstractHamiltonianSystem instead of HamiltonianSystem
- Update prepare_cache to use accessor functions instead of direct field access
- Remove default value for cache parameter in hamiltonian_gradient and variable_gradient
- Update docstrings to reflect cache parameter without default
- Add required accessor functions and prepare_cache stub to test fake system
- Update hamiltonian_gradient and variable_gradient test stubs to pass cache=nothing
- Comment out prepare_cache stub in test_calling_flows.jl to avoid method ambiguity with extension
- Add DifferentiationInterface import to test_calling_flows.jl
- Create abstract_hamiltonian.jl with AbstractHamiltonian type and trait accessors
- Modify hamiltonian.jl to contain only concrete Hamiltonian type
- Update Data.jl to include abstract_hamiltonian.jl before hamiltonian.jl
- Create test_abstract_hamiltonian.jl with fake type tests for abstract contract
- Modify test_hamiltonian.jl to test only concrete type
- Follow the pattern established for vector fields
- All tests pass (1997 tests)
…an-files

Refactor/split hamiltonian files
- Change strategy ID from :differentiation_interface to :di for brevity
- Update test to match new ID
…mFlow trajectory call

- Add NotProvided sentinel type in Common.default to distinguish "not provided" from explicit nothing
- Refactor call in Flows.calling with trait-based dispatcher and 4 overloads for Fixed/NonFixed traits
- Throw PreconditionError when variable parameter violates flow's trait contract
- Add comprehensive docstrings for NotProvided, call, core_call, and dispatch overloads
- Update tests to use NotProvided() and expect PreconditionError for invalid variable usage
- Add new trajectory call method for SciMLProblemFlow returning complete solution
- Fix SciMLProblemFlow point call to return final state only (not wrapped result)
- Update SciMLProblemFlow tests for point and trajectory call modes
- Full test suite passing (2003 tests)
- Add NotProvided sentinel type to distinguish missing variable parameter from explicit nothing
- Update __variable() to return NotProvided() instead of nothing
- Export NotProvided from Common module
- Add trajectory call signature to SciMLProblemFlow (tspan, x0) returning complete solution
- Fix point call in SciMLProblemFlow to return final state only (matching build_solution behavior)
- Update docstrings to reflect three call modes for SciMLProblemFlow
- Update calling.jl docstring to explain trait-based dispatch on variable parameter
- Update tests to verify new behavior
…ostate

- Add _variable_costate()::Bool = false default in Common/default.jl
- Add initial_variable_costate stub on AbstractConfig
- Add AugmentedHamiltonianPointConfig{T0,X0,P0,PV0,TF} struct with getters
- Add Base.show overloads for AugmentedHamiltonianPointConfig
- Update Common.jl exports for AugmentedHamiltonianPointConfig, initial_variable_costate, _variable_costate
- Add tests for _variable_costate in test_default.jl
- Add comprehensive tests for AugmentedHamiltonianPointConfig in test_configs.jl
…spatch

- Updated build_solution signature to accept ::Type{Common.PointTrait}, ::Type{Common.StateTrait}, etc. instead of trait instances
- Updated calling code in src/Flows/calling.jl to pass trait types via Common.mode_trait and Common.content_trait
- Updated internal RHS builder functions in vector_field_system.jl and hamiltonian_vector_field_system.jl to use ::Type{OutOfPlace} and ::Type{InPlace}
- Added comprehensive docstrings for all modified functions
- Updated all test files to match new signature:
  - test_sciml_extension.jl
  - test_calling_flows.jl
  - test_flow_callables.jl
  - test_calling_multiphase.jl
  - test_building_solutions.jl
- Fixed method ambiguity in test_flow_callables.jl by splitting mock into type-specific methods
- Removed unused _rhs_oop wrapper function from hamiltonian_vector_field_system.jl
…ions

- Add new trait family AbstractVariableCostateCapability (SupportsVariableCostate, NoVariableCostate)
- Move ad_trait to Common with default WithoutAD implementation
- Add variable_costate_trait getter on systems (SupportsVariableCostate for NonFixed)
- Add ad_trait and variable_costate_trait getters on flows
- Update prepare_cache to use Common.ad_trait
- Add _aug_split_solution helper and build_solution overload for AugmentedHamiltonianTrait
- Add build_problem overload for augmented Hamiltonian configs in CTFlowsSciML
- Add variable_costate kwarg and call_variable_costate dispatch chain in Flows
- Create test_variable_costate.jl with 20 unit tests
- Update test_abstract_trait.jl with new trait tests
- Update exports in Common/Common.jl
- Added scalarize helper in Common/helpers.jl for handling scalar/vector conversions
- Updated build_solution signatures to use config instead of initial_state
- Added variable costate dispatch with type-based error handling (PreconditionError)
- Implemented call_variable_costate methods for SupportsVariableCostate/NoVariableCostate traits
- Added error handling for missing variable parameter and trajectory configs
- Updated test_variable_costate.jl with linear Hamiltonian and analytical solution
- Fixed test signatures for build_solution across multiple test files
- Added comprehensive error tests for variable costate constraints
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.

2 participants