main
md 77 lines 4.24 KB
Rendered Raw
1 # self_update.py DOX
2
3 ## Purpose
4
5 - Own the `self_update.py` helper module.
6 - This module manages self-update status, scheduling, tag selection, and durable scripts.
7 - Keep this file-level DOX profile synchronized with `self_update.py` because this directory is intentionally flat.
8
9 ## Ownership
10
11 - `self_update.py` owns the runtime implementation.
12 - `self_update.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
13 - Classes:
14 - `PendingUpdateConfig` (`TypedDict`)
15 - `UpdateStatus` (`TypedDict`)
16 - `SelectorTagOption` (`TypedDict`)
17 - Top-level functions:
18 - `_now_iso() -> str`
19 - `get_update_file_path() -> Path`
20 - `get_status_file_path() -> Path`
21 - `get_log_file_path() -> Path`
22 - `get_durable_exe_dir() -> Path`
23 - `get_durable_self_update_manager_path() -> Path`
24 - `_load_yaml(path: Path) -> dict[str, Any] | None`
25 - `_write_yaml(path: Path, payload: dict[str, Any]) -> None`
26 - `load_pending_update() -> PendingUpdateConfig | None`
27 - `load_last_status() -> UpdateStatus | None`
28 - `get_log_text() -> str`
29 - `get_default_backup_dir(repo_dir: str | Path | None=...) -> Path`
30 - `get_repo_dir(repo_dir: str | Path | None=...) -> Path`
31 - `get_repo_self_update_manager_path(repo_dir: str | Path | None=...) -> Path`
32 - `_get_official_remote_url() -> str`
33 - `_run_git_raw(*args) -> str`
34 - `_run_git(repo_dir: str | Path, *args) -> str`
35 - `_normalize_describe_to_version(describe: str) -> str`
36 - `_split_describe_version(describe: str) -> tuple[str, int]`
37 - `_is_latest_selector_tag(tag: str) -> bool`
38 - `_get_tag_release_time_in_repo(repo_dir: str | Path, tag: str) -> str`
39 - `get_repo_version_info(repo_dir: str | Path | None=...) -> dict[str, str]`
40 - `_sanitize_filename(name: str, default_name: str) -> str`
41 - `_slugify_version(text: str) -> str`
42 - `build_default_backup_name(current_version: str, target_tag: str | None=...) -> str`
43 - `_resolve_backup_path(backup_path: str, repo_dir: str | Path | None=...) -> Path`
44 - `_is_excluded_self_update_branch(branch: str) -> bool`
45 - `_sort_branch_names(branches: list[str]) -> list[str]`
46 - `_get_remote_branch_names() -> list[str]`
47 - `_get_local_origin_branch_names(repo_dir: str | Path | None=...) -> list[str]`
48 - Notable constants/configuration names: `OFFICIAL_REPO_AUTHOR`, `OFFICIAL_REPO_NAME`, `BRANCH_OPTIONS`, `SUPPORTED_BRANCHES`, `BACKUP_CONFLICT_POLICIES`, `MIN_SELECTOR_VERSION`, `REMOTE_BRANCH_TAG_CACHE_TTL_SECONDS`, `REMOTE_BRANCH_LIST_CACHE_TTL_SECONDS`, `UPDATE_FILE_PATH`, `STATUS_FILE_PATH`, `LOG_FILE_PATH`, `DURABLE_EXE_DIR`.
49
50 ## Runtime Contracts
51
52 - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together.
53 - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change.
54 - Observed side-effect areas: filesystem reads, filesystem writes, subprocess/runtime control, settings/state persistence.
55 - Imported dependency areas include: `__future__`, `datetime`, `helpers`, `helpers.localization`, `os`, `pathlib`, `re`, `subprocess`, `tempfile`, `time`, `typing`.
56
57 ## Key Concepts
58
59 - Important called helpers/classes observed in the source: `Path`, `Localization.get.now_iso`, `yaml.loads`, `path.parent.mkdir`, `path.write_text`, `_load_yaml`, `get_log_file_path`, `path.read_text`, `subprocess.run`, `completed.stdout.strip`, `re.fullmatch`, `describe.strip`, `tag.strip`, `get_repo_dir`, `_run_git`, `_normalize_describe_to_version`, `strip`, `re.sub.strip`, `Localization.get.now.strftime`, `path.resolve`.
60 - Keep request/response, tool, or helper semantics documented here at the same time as source changes.
61
62 ## Work Guidance
63
64 - Preserve public helper APIs used by core code and plugins unless every caller is updated.
65 - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded.
66 - Prefer adding cohesive helper functions here only when behavior is reused across modules.
67
68 ## Verification
69
70 - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers.
71 - Related tests observed by source search:
72 - `tests/test_office_document_store.py`
73 - `tests/test_self_update_tag_filter.py`
74
75 ## Child DOX Index
76
77 No child DOX files.