Skip to content

Split specs.py into focused modules #61

@jc-macdonald

Description

@jc-macdonald

Summary

Break specs.py (~1,950 lines) into focused, single-responsibility modules.

Problem

specs.py currently spans at least 6 concerns:

  1. Axis normalization_normalize_axes(), axis type inference
  2. Constraint parsing_validate_constraint_axes(), _resolve_constraint_mode(), _validate_constraint_rule(), _normalize_constraints()
  3. Template expansion_expand_state_templates(), _expand_alias_templates()
  4. Equation normalizationnormalize_expr_rhs()
  5. Transition normalizationnormalize_transitions_rhs(), _expand_single_transition()
  6. Symbol extraction_collect_symbols(), param detection

As the Pydantic models land (#20–28, #58), each model will pull validation logic out — but without a deliberate split, the file risks becoming a mix of old procedural code and new model imports, with increasing merge-conflict risk across parallel PRs.

Proposed Structure

src/op_system/
├── specs.py          → slim facade: normalize_rhs(), public types
├── _axes.py          → axis normalization
├── _constraints.py   → constraint parsing/validation
├── _templates.py     → state/alias/transition template expansion
├── _normalize.py     → normalize_expr_rhs(), normalize_transitions_rhs()
└── _symbols.py       → symbol collection and param extraction

Constraints

  • All public exports must remain importable from op_system and op_system.specs
  • No behavioral changes — pure file reorganization
  • Must pass ruff check --preview and mypy --strict

Priority

Lower than Pydantic model issues. Best done either before or after the Pydantic batch — not during — to minimize conflicts.

Related

Metadata

Metadata

Assignees

Labels

refactorCode reorganization without behavior change

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions