test(optimization): allow output-contract and request-schema names

Additional changes
- Describe contract names and roles in the skill, MIGRATION.md and ADRs 0004 and 0007.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
This commit is contained in:
Bobby Noelte
2026-11-27 13:55:41 +01:00
co-authored by Claude Opus 5.5
parent 8c06245e8b
commit b108335ee4
5 changed files with 169 additions and 35 deletions
@@ -52,8 +52,8 @@ with `--finalize`, and the architecture test passes with the fixed entries remov
## What may remain in `BASELINE`
After step 6 GENETIC0 kept three entries, all types of the output contract or the public request
schema that live in banned modules: the solution's DataFrame (`core.pydantic`), the plan's
operation-mode enums (`devices.devicesabc`) and `TimeWindowSequence` (`config.configabc`).
Whether the test should allow these types is an open decision; until it is made they stay in
`BASELINE`, and any other entry left is unfinished migration.
Nothing. After step 6 GENETIC0 has no entry left: the output-contract and public-schema types it
needs from banned modules are contract names of the test (`CONTRACT_NAMES`, allowed in the roles
of `CONTRACT_ROLES`). An entry left after
the last step is unfinished migration; a further contract type is added to `CONTRACT_NAMES`, with
its reason in the pull request.
+9 -4
View File
@@ -25,14 +25,19 @@ and flag any conflict.
cache in `core.cache`). This includes data only needed to present the
solution: time zone, device IDs, run start and the prediction series the run
used travel in the optimization parameters. The modules and names this
covers are listed once, in `WORLD_MODULES`, `WORLD_NAMES` and `EMS_*` of
covers are listed once, in `WORLD_MODULES`, `WORLD_NAMES` and `PREPARATION_BANNED_*` of
`tests/test_optimizerarchitecture.py`; that list is authoritative. Among
them: `config`, `prediction`, `measurement`, `adapter`, `server`,
`core.ems`, `core.cache`, the `core.*settings` and database modules, the
`core.coreabc` mixins and getters, `OptimizationBase` and the shared device
configuration (`devices.settings`, `devices.profile`, `devices.devices`,
`devices.devicesabc`). From `optimization.optimization` only the contract
class `OptimizationSolution` may be imported (`CONTRACT_NAMES`).
`devices.devicesabc`). From `optimization.optimization` only
`OptimizationSolution` may be imported. The other contract names of
`CONTRACT_NAMES` (`PydanticDateTimeDataFrame` of the solution, the plan's
`BatteryOperationMode` and `ApplianceOperationMode`, the request schema's
`TimeWindow` and `TimeWindowSequence`) are allowed only in the request,
conversion, visualization and API modules (`CONTRACT_ROLES`), never in the
parameters or the simulation.
- Parameter preparation runs once per run, never fails, never returns `None` and follows the
"Optimization parameters are always valid" rules of the `energy-domain` skill.
- Parameter preparation does not read EMS state either (`core.ems`,
@@ -155,7 +160,7 @@ classes `<Name><Role>`. This table is the one maintained copy; ADR 0010 links he
into a shared module, and never merge copies across optimizers to remove duplication. A fix in
one copy reaches another optimizer only through a deliberate change to that optimizer.
- An optimizer may import: generic utilities (such as `datetimeutil`; Pydantic only in the roles allowed above), the
output contract (`OptimizationSolution`, the energy management plan) and, in parameter
output contract (`OptimizationSolution`, the energy management plan, and in the roles above the contract names) and, in parameter
preparation only, the configuration settings, including the shared operation-mode enums and
settings-side resolution such as battery profiles. Translate those into the optimizer's own
types during parameter preparation; do not pass settings objects or enums from the