Skip to content

refactor: co-locate each strategy's contract with its abstract type#162

Merged
ocots merged 2 commits into
mainfrom
refactor/contract-colocation
Jun 28, 2026
Merged

refactor: co-locate each strategy's contract with its abstract type#162
ocots merged 2 commits into
mainfrom
refactor/contract-colocation

Conversation

@ocots

@ocots ocots commented Jun 28, 2026

Copy link
Copy Markdown
Member

Summary

Behavior-preserving reorganization so every strategy family keeps its contract
stub next to its abstract type
, mirroring the existing DOCP/contract.jl
precedent. Before this PR the contract was co-located only for the discretizer;
the modeler and solver contracts were scattered.

Strategy Abstract type Contract Now lives in
Discretizer AbstractDiscretizer discretize DOCP/contract.jl (already)
Modeler AbstractNLPModeler build_model/build_solution Modelers/contract.jl (new)
Solver AbstractNLPSolver solve(nlp, ::AbstractNLPSolver) Solvers/contract.jl (new)

Changes

  • Modelers: new contract.jl with the canonical build_model/build_solution
    NotImplemented stubs, narrowed to ::AbstractNLPModeler (documented with
    $(TYPEDSIGNATURES)). Optimization keeps bare generic declarations in
    building.jl so the binding exists and the re-export stays valid.
  • Solvers: split common_solve_api.jl into contract.jl (mid-level
    solve(nlp, ::AbstractNLPSolver) stub + __display) and orchestration.jl
    (high-level composition).
  • DOCP: merged types.jl + accessors.jl into discretized_model.jl;
    renamed building.jlconveniences.jl.
  • Docs: resynced the per-submodule source-file lists in docs/api_reference.jl
    (also fixes pre-existing staleness: adds built_model.jl, moves solver_info.jl
    under Solvers, drops removed contract_impl/builders/common_solve_api).
  • Tests: FakeModeler now subtypes AbstractNLPModeler so an unimplemented
    (problem, modeler) pair still yields NotImplemented.

Behavior

Only semantic change: the modeler stub narrows from an untyped 3rd arg to
::AbstractNLPModeler (still NotImplemented; more correct). Concrete CTDirect
methods 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.250.26-beta compat
drift, not by this reorg.

🤖 Generated with Claude Code

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>
@ocots
ocots merged commit c8bcd02 into main Jun 28, 2026
5 checks passed
@ocots
ocots deleted the refactor/contract-colocation branch June 28, 2026 21:01
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