| 1 | # migration.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `migration.py` helper module. |
| 6 | - This module migrates legacy user data and runtime layout at startup. |
| 7 | - Keep this file-level DOX profile synchronized with `migration.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `migration.py` owns the runtime implementation. |
| 12 | - `migration.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Top-level functions: |
| 14 | - `startup_migration() -> None` |
| 15 | - `migrate_user_data() -> None`: Migrate user data from /tmp and other locations to /usr. |
| 16 | - `convert_agents_json_yaml() -> None` |
| 17 | - `_move_dir(src: str, dst: str, overwrite: bool=...) -> None`: Move a directory from src to dst if src exists and dst does not. |
| 18 | - `_move_file(src: str, dst: str, overwrite: bool=...) -> None`: Move a file from src to dst if src exists and dst does not. |
| 19 | - `_migrate_memory(base_path: str=...) -> None`: Migrate memory subdirectories. |
| 20 | - `_merge_dir_contents(src_parent: str, dst_parent: str) -> None`: Moves all items from src_parent to dst_parent. |
| 21 | - `_cleanup_obsolete() -> None`: Remove directories that are no longer needed. |
| 22 | |
| 23 | ## Runtime Contracts |
| 24 | |
| 25 | - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together. |
| 26 | - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change. |
| 27 | - Startup cleanup removes obsolete `memory`, `knowledge/default`, and legacy `logs` directories; repeated runs are safe. |
| 28 | - Observed side-effect areas: filesystem reads, filesystem writes, filesystem deletion, settings/state persistence, secret handling, scheduler state. |
| 29 | - Imported dependency areas include: `helpers`, `helpers.print_style`, `json`, `os`. |
| 30 | |
| 31 | ## Key Concepts |
| 32 | |
| 33 | - Important called helpers/classes observed in the source: `migrate_user_data`, `convert_agents_json_yaml`, `extension.call_extensions_sync`, `_move_dir`, `_move_file`, `_migrate_memory`, `_merge_dir_contents`, `_cleanup_obsolete`, `subagents.get_agents_roots`, `files.get_subdirectories`, `files.list_files`, `files.deabsolute_path`, `files.exists`, `files.move_dir`, `files.move_file`, `files.get_abs_path`, `os.path.isdir`, `os.path.join`, `files.delete_dir`, `os.path.isfile`. |
| 34 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 35 | |
| 36 | ## Work Guidance |
| 37 | |
| 38 | - Preserve public helper APIs used by core code and plugins unless every caller is updated. |
| 39 | - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded. |
| 40 | - Prefer adding cohesive helper functions here only when behavior is reused across modules. |
| 41 | |
| 42 | ## Verification |
| 43 | |
| 44 | - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers. |
| 45 | - Related tests observed by source search: |
| 46 | - `tests/test_migration_cleanup.py` |
| 47 | - `tests/test_browser_agent_regressions.py` |
| 48 | - `tests/test_office_canvas_setup.py` |
| 49 | - `tests/test_office_document_store.py` |
| 50 | - `tests/test_speech_plugin_split.py` |
| 51 | |
| 52 | ## Child DOX Index |
| 53 | |
| 54 | No child DOX files. |