05 profiles
Context¶
Step 5 of the internal-modularization migration: move profiles.py and rig_loader.py into src/rigplane/profiles/, leaving silent re-export shims at the old top-level paths.
Plan section: §4.1 Step 5 — profiles.
Pre-conditions¶
Blocked by #1287 (Step 4: commands top-level).
Scope¶
Move these 2 files from src/rigplane/ into src/rigplane/profiles/:
src/rigplane/profiles.py→src/rigplane/profiles/profiles.py(or keep asprofiles/__init__.pybody — sub-agent's call, but if going that route, the existingprofiles/__init__.pystub from Step 1 is overwritten and the result must still pass the contract tests).src/rigplane/rig_loader.py→src/rigplane/profiles/rig_loader.py
Add 2 re-export shim files at the old top-level paths (src/rigplane/profiles.py, src/rigplane/rig_loader.py) using the plan §5.1 template.
CRITICAL pre-mitigation (plan §6.2 / R3): the function-local cycle-breaker at src/rigplane/profiles.py:266 (from .rig_loader import … inside a function body) MUST be preserved verbatim. Do NOT hoist it to module level. Same for the top-level rig_loader → profiles import. These two imports together form the runtime cycle-breaker; both must stay exactly where they are.
Out of scope¶
- No behaviour changes whatsoever.
- No new tests for new functionality (Step 1 commits the public-API contract test, but it tests the existing surface).
- No edits to
_LAZY_MAP(deferred to Step 13; see plan §5.4). - No imports outside the listed scope, even if a "cleaner" import suggests itself.
- No silent fixups, no "while we're at it" refactors.
Acceptance criteria¶
uv run pytest tests/ -q --tb=short --ignore=tests/integrationreports 5213 tests (unchanged).uv run ruff check src/ tests/clean.uv run mypy src/clean.uv run pytest tests/contracts/test_lazy_imports.py -vpasses (3 tests green).- Public-import smoke check (each must succeed):
uv run python -c "from rigplane.profiles import RadioProfile, load_profile_toml"uv run python -c "from rigplane.rig_loader import *"(legacy path via shim).uv run python -c "from rigplane import Radio; r = Radio # ensure top-level still imports"
Implementation prompt for the sub-agent¶
You are implementing one step of the rigplane internal modularization
work. Read these references first:
- /Users/moroz/Projects/rigplane-research/2026-04-29-internal-modularization-orchestrator.md
- docs/plans/2026-04-29-modularization-plan.md
- The full text of this issue, especially the Scope and Acceptance
Criteria sections
Your scope is exactly the files listed in Scope. You may not modify
any other file. You may not change runtime behavior. You may not add
tests for new functionality.
Workflow:
1. Create branch refactor/modularization-step-5 from main
2. Move/edit only files in scope
3. Add re-export shims for backwards compatibility per the plan
4. Run pytest — must pass
5. Run mypy — must not introduce new errors
6. Run ruff check — must not introduce new errors
7. Run lint-imports — skip (not yet integrated; Step 13 introduces it)
8. Commit in atomic semantic commits per the plan
9. Push branch, open PR linking to this issue
10. PR description must follow the template in the orchestrator brief
Constraints: Do not modify any file outside the Scope list. Do not
change behaviour. Do not add tests for new functionality.
If anything is unclear or any check fails for non-obvious reasons,
stop and ask via PR comment. Do not guess.
Reviewer note¶
- Verify the shim header (plan §5.1 template, verbatim) is present in every shim file.
- Confirm
profiles.py:266(now in its new location) still hasfrom .rig_loader import …inside a function body, not at top level. This is the documented cycle-breaker; lifting it to module level reintroduces an import cycle. - LAZY_MAP target tuples must be UNCHANGED.
- Verify the top-level
rig_loader.pyimport ofprofilesis preserved exactly as it was (the other half of the cycle-breaker).