Skip to content

refactor(src): typed errors and simpler parameter merge (T1 of #449) - #457

Merged
ocots merged 1 commit into
mainfrom
fix/t1-review
Nov 19, 2026
Merged

ocots merged 1 commit into
mainfrom
fix/t1-review

Conversation

@ocots

@ocots ocots commented Nov 19, 2026

Copy link
Copy Markdown
Member

Refs #449 (T1, findings). Applied conventions: ct-conventions v0.14.0, ct-agents v0.5.0.

Fixes findings 1–5 of the T1 review. No change to the exported API.

Changes

  1. EXC1, load-time checks. src/Metadata/loading.jl (a metadata field missing, unknown or of the wrong type) and src/References/objectives.jl (a malformed reference table) throw CTBase.Exceptions.IncorrectArgument, with got, expected and suggestion, instead of error(...).
  2. EXC1, features(:unknown) throws the IncorrectArgument of problem_metadata instead of an UndefVarError.
  3. Catalogue.status reads Metadata.problem_metadata(problem)[:status]: one check of the name, with the structured message.
  4. Metadata.merge removed. Its four methods shadowed Base.merge. parameters_data(problem, parameters) returns the defaults for nothing, throws the PreconditionError itself for a problem without parameters, and uses Base.merge otherwise, without catching and rethrowing.
  5. ModelingToolkit named in the docstrings of OptimalControlProblems and Modelings.

Tests

  • test_parameters.jl: tests parameters_data instead of Metadata.merge. No problem of the collection is without parameters, so the test adds one to METADATA_STORAGE and removes it (try/finally).
  • test_references.jl: a broken reference file throws IncorrectArgument.
  • test_modelings.jl: features(:not_a_problem) throws IncorrectArgument.

Test plan

  • Locally (Julia 1.12): Pkg.test(; test_args=["core"]): 1309 passed, 1 broken (the existing one of test_discovery_cache.jl).
  • CI.

🤖 Generated with Claude Code

- Metadata and reference files: the load-time checks throw
  `IncorrectArgument` instead of `error(...)` (EXC1).
- `features(:unknown)` throws `IncorrectArgument` instead of `UndefVarError`.
- `Catalogue.status` reads `Metadata.problem_metadata`, with its check.
- `Metadata.merge` (four methods shadowing `Base.merge`) removed:
  `parameters_data(problem, parameters)` handles `nothing` and uses
  `Base.merge`, without catching and rethrowing.
- ModelingToolkit named in the docstrings of the package and `Modelings`.

Refs #449

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ocots ocots added the run ci github-runner Trigger the CI workflow on GitHub-hosted runners label Nov 19, 2026
@ocots
ocots merged commit 539857d into main Nov 19, 2026
20 checks passed
@ocots
ocots deleted the fix/t1-review branch November 19, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run ci github-runner Trigger the CI workflow on GitHub-hosted runners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant