| 1 | # state_migration.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `state_migration.py` helper module. |
| 6 | - This module moves retired state tree paths to current runtime locations. |
| 7 | - Keep this file-level DOX profile synchronized with `state_migration.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `state_migration.py` owns the runtime implementation. |
| 12 | - `state_migration.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Top-level functions: |
| 14 | - `migrate_retired_state_tree(source: Path, destination: Path, owner: str, migrated: list[str], warnings: list[str], errors: list[str]) -> None`: Move retired plugin state into its plugin-owned state directory. |
| 15 | - `_move_path(source: Path, target: Path, migrated: list[str]) -> None` |
| 16 | - `_next_conflict_path(path: Path) -> Path` |
| 17 | - `_remove_empty_dir(path: Path, owner: str, warnings: list[str]) -> None` |
| 18 | - `_same_path(left: Path, right: Path) -> bool` |
| 19 | |
| 20 | ## Runtime Contracts |
| 21 | |
| 22 | - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together. |
| 23 | - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change. |
| 24 | - Observed side-effect areas: filesystem reads, filesystem writes, plugin state, settings/state persistence. |
| 25 | - Imported dependency areas include: `__future__`, `pathlib`, `shutil`. |
| 26 | |
| 27 | ## Key Concepts |
| 28 | |
| 29 | - Important called helpers/classes observed in the source: `_same_path`, `final_target.parent.mkdir`, `shutil.move`, `path.with_name`, `_move_path`, `source.is_dir`, `target.is_dir`, `source.rmdir`, `target.exists`, `target.is_symlink`, `_next_conflict_path`, `candidate.exists`, `candidate.is_symlink`, `path.rmdir`, `source.exists`, `source.is_symlink`, `destination.mkdir`, `_remove_empty_dir`, `source.iterdir`, `left.resolve`. |
| 30 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 31 | |
| 32 | ## Work Guidance |
| 33 | |
| 34 | - Preserve public helper APIs used by core code and plugins unless every caller is updated. |
| 35 | - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded. |
| 36 | - Prefer adding cohesive helper functions here only when behavior is reused across modules. |
| 37 | |
| 38 | ## Verification |
| 39 | |
| 40 | - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers. |
| 41 | - No direct test reference was found by name search; choose the nearest behavioral test or perform a focused smoke check. |
| 42 | |
| 43 | ## Child DOX Index |
| 44 | |
| 45 | No child DOX files. |