7.5 KiB
War-Room Migration Plan (Prioritized, Code-Level)
Date: 2026-02-20 Goal: Stabilize entrypoints and create a coherent, testable architecture from the current code reality.
Phase 0 - Stop The Bleeding (P0, 1-2 days)
Risk: High if skipped, Low implementation risk
Moves:
- Fix broken module import paths in runtime code:
optimization_engine/future/llm_optimization_runner.pyoptimization_engine/config/setup_wizard.py
- Make
optimization_engine/run_optimization.pyimportable/executable. - Fix plugin directory resolution in all loaders:
core/runner.pyfuture/llm_optimization_runner.pyconfig/setup_wizard.py
Interface changes:
- None to user CLI shape.
- Internal module paths become explicit (
optimization_engine.future.*or extracted to a new stable package).
Dependency order:
- Fix import paths.
- Fix plugin discovery path.
- Add smoke tests for
atomizer.py --helpandoptimization_engine/run_optimization.py --help.
Concrete refactor steps:
- Replace missing imports with real module paths:
optimization_engine.extractor_orchestrator->optimization_engine.future.extractor_orchestratoroptimization_engine.inline_code_generator->optimization_engine.future.inline_code_generatoroptimization_engine.hook_generator->optimization_engine.future.hook_generator
- In hook loaders, resolve plugin root to
optimization_engine/plugins(shared constant helper). - Add assertion/telemetry when no hooks are loaded to avoid silent no-op behavior.
Phase 1 - Entrypoint Contract Unification (P0, 2-4 days)
Risk: Medium
Moves:
- Define a single canonical optimization runner API used by both:
atomizer.pyworkflowsoptimization_engine/run_optimization.py
- Remove dead import (
OptimizationRunner) from unified runner unless actually used. - Implement manual mode or explicitly remove it behind feature flag.
Interface changes:
- Introduce a stable internal entry function, e.g.
optimization_engine.app.run(spec). - Keep CLI flags backward-compatible in this phase.
Dependency order:
- Stabilize Phase 0.
- Create adapter layer from old study scripts to new runner API.
- Route
run_optimization.pythrough this API.
Concrete refactor steps:
- Create
optimization_engine/app/runner_service.pywith:- config parsing
- model update/solve/extract loop
- hook execution
- Convert
run_optimization.pyto thin CLI adapter. - Add compatibility wrapper for existing study scripts.
Phase 2 - Study Script Decoupling (P1, 1-2 weeks)
Risk: High (behavioral)
Moves:
- Stop subprocess dependence on arbitrary
studies/<study>/run_optimization.pyfromatomizer.py. - Replace with deterministic “load study spec + run canonical engine”.
Interface changes:
atomizer neural-optimize --study Xresolves study metadata and calls canonical engine directly.- Study-local scripts become optional wrappers, not required runtime dependency.
Dependency order:
- Canonical runner available (Phase 1).
- Study resolver module.
- Migrate one or two representative studies first (UAV + M1 mirror).
Concrete refactor steps:
- Implement study resolver for
1_setup/optimization_config.jsonand/oratomizer_spec.json. - Add
atomizerpath for direct in-process execution. - Keep fallback to legacy script for unmigrated studies with explicit warning.
Phase 3 - Hooks/Plugins Hardening (P1, 3-5 days)
Risk: Medium
Moves:
- Consolidate lifecycle hook system (
plugins) and clarify that NX Open wrappers (hooks) are separate. - Fix mismatches:
custom_objectivehook point vscustom_objectivesfolder naming.- broken plugin registration patterns (e.g. return list without registering).
Interface changes:
- Standard plugin authoring contract:
register_hooks(hook_manager) -> None- must call
hook_manager.register_hook(...)
Dependency order:
- Shared plugin root helper.
- Plugin validation lint.
- Hook contract docs + tests.
Concrete refactor steps:
- Add plugin linter test to fail on non-registered plugins.
- Normalize folder naming to enum values.
- Add runtime summary printout for loaded/active hooks at each hook point.
Phase 4 - Extractor Surface Rationalization (P1, 1 week)
Risk: Medium
Moves:
- Classify extractors into tiers:
- Tier A (active runtime): displacement/stress/mass/frequency basics
- Tier B (domain-specific): zernike, optical, special studies
- Tier C (candidate deprecate): no references (
field_data_extractor.py,zernike_helpers.py)
- Move tier C to
archive/or mark deprecated.
Interface changes:
- New extractor registry metadata: status (
active,experimental,deprecated).
Dependency order:
- Build reference report snapshot.
- Mark deprecated modules.
- Remove only after one release cycle.
Concrete refactor steps:
- Add machine-readable registry file for extractors.
- Enforce registration for runtime-eligible extractors.
- Update callers to consume registry, not free-form imports.
Phase 5 - Template/Study Generation Repair (P1, 2-4 days)
Risk: Medium
Moves:
- Fix template loader roots and generated script imports.
- Current issues:
- templates resolve to
optimization_engine/templatesinstead of repotemplates/JSON set. - studies root points to missing
optimization_engine/studies. - generated scripts import missing
optimization_engine.study_runner.
- templates resolve to
Interface changes:
atomizer create-studyshould generate runnable study directly against canonical runner API.
Dependency order:
- Canonical runner available (Phase 1).
- Replace generated script template.
- Add integration test for create+validate flow.
Concrete refactor steps:
- Correct template/study root resolution to repo-level paths.
- Replace
study_runnerimport with canonical service call. - Validate generated study with
atomizer validatein CI smoke test.
Phase 6 - Future Folder Re-homing (P2, 1 week)
Risk: Low/Medium
Moves:
- Split
optimization_engine/future/into:experimental/(not production-wired)runtime/(production-wired)
- Remove deprecation aliases from
optimization_engine/__init__.pythat point to non-runtime pieces unless intentionally supported.
Interface changes:
- Explicit import policy: production code cannot import
experimentalwithout feature flag.
Dependency order:
- Tag modules by runtime usage.
- Move files and add shims.
- Remove shims after transition window.
Concrete refactor steps:
- Create
optimization_engine/experimental/. - Move low-usage research modules.
- Keep only proven runtime modules in primary namespace.
Phase 7 - Verification and Guardrails (P0 ongoing)
Risk: High if omitted
Moves:
- Add CI checks that would have caught current breakage:
- import smoke for both entrypoints
- plugin load count assertions
- create-study runnable check
Concrete refactor steps:
- Add tests:
test_entrypoint_imports.pytest_plugin_discovery_paths.pytest_template_loader_paths.py
- Add static scan that fails on unresolved
optimization_engine.<module>imports. - Add architecture decision record (ADR) for canonical runner + plugin model.
Dependency-Critical Ordering Summary
- Phase 0 (import/plugin path fixes)
- Phase 1 (canonical runner contract)
- Phase 2 and 5 (atomizer/study generation migration)
- Phase 3 (hooks hardening)
- Phase 4 and 6 (extractor/future rationalization)
- Phase 7 continuously
Quick Wins (do immediately)
- Fix
run_optimization.pyimport crash. - Fix all three plugin loader paths.
- Remove or wire
OptimizationRunnerimport in unified runner. - Fix
template_loaderroots andstudy_runnerreference.