refactor: co-locate each strategy's contract with its abstract type#162
Merged
Conversation
Behavior-preserving reorganization so every strategy family keeps its contract stub next to its abstract type, mirroring the existing DOCP/contract.jl precedent. - Modelers: new contract.jl holds the canonical build_model / build_solution NotImplemented stubs, narrowed to ::AbstractNLPModeler (the documented TYPEDSIGNATURES stubs live with the modeler). Optimization keeps bare generic declarations (building.jl) so the binding exists and the re-export is valid. - Solvers: split common_solve_api.jl into contract.jl (mid-level solve stub + __display) and orchestration.jl (high-level composition). - DOCP: merge types.jl + accessors.jl into discretized_model.jl; rename building.jl to conveniences.jl. - docs/api_reference.jl: resync the per-submodule source-file lists (also fixes pre-existing staleness: add built_model.jl, solver_info.jl under Solvers, drop removed contract_impl/builders/common_solve_api). - test: FakeModeler now subtypes AbstractNLPModeler so an unimplemented (problem, modeler) pair still yields NotImplemented (not MethodError). Only semantic change: the modeler stub narrows from an untyped 3rd arg to ::AbstractNLPModeler. CTSolvers suites + Aqua green; CTDirect needs no source change (same CTSolvers.* functions, only method locations moved). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Version 0.4.24-beta - CHANGELOG: contract co-location refactor entry - Project.toml: CTBase 0.25→0.26, CTModels 0.13→0.14 - docs/Project.toml: CTBase 0.21→0.26 - docs/api_reference.jl: remove stale Core section (file does not exist) Co-Authored-By: Claude Opus 4.8 <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
Behavior-preserving reorganization so every strategy family keeps its contract
stub next to its abstract type, mirroring the existing
DOCP/contract.jlprecedent. Before this PR the contract was co-located only for the discretizer;
the modeler and solver contracts were scattered.
AbstractDiscretizerdiscretizeDOCP/contract.jl(already)AbstractNLPModelerbuild_model/build_solutionModelers/contract.jl(new)AbstractNLPSolversolve(nlp, ::AbstractNLPSolver)Solvers/contract.jl(new)Changes
contract.jlwith the canonicalbuild_model/build_solutionNotImplementedstubs, narrowed to::AbstractNLPModeler(documented with$(TYPEDSIGNATURES)).Optimizationkeeps bare generic declarations inbuilding.jlso the binding exists and the re-export stays valid.common_solve_api.jlintocontract.jl(mid-levelsolve(nlp, ::AbstractNLPSolver)stub +__display) andorchestration.jl(high-level composition).
types.jl+accessors.jlintodiscretized_model.jl;renamed
building.jl→conveniences.jl.docs/api_reference.jl(also fixes pre-existing staleness: adds
built_model.jl, movessolver_info.jlunder Solvers, drops removed
contract_impl/builders/common_solve_api).FakeModelernow subtypesAbstractNLPModelerso an unimplemented(problem, modeler)pair still yieldsNotImplemented.Behavior
Only semantic change: the modeler stub narrows from an untyped 3rd arg to
::AbstractNLPModeler(stillNotImplemented; more correct). Concrete CTDirectmethods are strictly more specific → no ambiguity; CTDirect needs no source
change.
Tests
Full CTSolvers suite green (non-extension suites + extensions + Aqua). CTDirect
smoke is currently blocked by an unrelated CTBase
0.25↔0.26-betacompatdrift, not by this reorg.
🤖 Generated with Claude Code