| 1 | # kvp.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `kvp.py` helper module. |
| 6 | - This module provides runtime and persistent key-value storage helpers. |
| 7 | - Keep this file-level DOX profile synchronized with `kvp.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `kvp.py` owns the runtime implementation. |
| 12 | - `kvp.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Top-level functions: |
| 14 | - `_persistent_dir() -> str` |
| 15 | - `_validate_key(key: str) -> None` |
| 16 | - `_key_to_path(key: str) -> str` |
| 17 | - `get_runtime(key: str, default: Any=...) -> Any` |
| 18 | - `set_runtime(key: str, value: Any) -> None` |
| 19 | - `remove_runtime(key: str) -> None` |
| 20 | - `find_runtime(pattern: str) -> list[str]` |
| 21 | - `get_persistent(key: str, default: Any=...) -> Any` |
| 22 | - `set_persistent(key: str, value: Any) -> None` |
| 23 | - `remove_persistent(key: str) -> None` |
| 24 | - `find_persistent(pattern: str) -> list[str]` |
| 25 | |
| 26 | ## Runtime Contracts |
| 27 | |
| 28 | - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together. |
| 29 | - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change. |
| 30 | - Observed side-effect areas: filesystem reads, filesystem writes, filesystem deletion, settings/state persistence. |
| 31 | - Imported dependency areas include: `fnmatch`, `glob`, `helpers.files`, `json`, `os`, `tempfile`, `threading`, `typing`. |
| 32 | |
| 33 | ## Key Concepts |
| 34 | |
| 35 | - Important called helpers/classes observed in the source: `threading.RLock`, `get_abs_path`, `_validate_key`, `os.path.join`, `_key_to_path`, `os.path.dirname`, `_persistent_dir`, `ValueError`, `_runtime_store.pop`, `os.makedirs`, `tempfile.mkstemp`, `glob.glob`, `keys.sort`, `os.replace`, `os.unlink`, `os.path.isdir`, `json.load`, `os.fdopen`, `json.dump`, `f.flush`. |
| 36 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 37 | |
| 38 | ## Work Guidance |
| 39 | |
| 40 | - Preserve public helper APIs used by core code and plugins unless every caller is updated. |
| 41 | - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded. |
| 42 | - Prefer adding cohesive helper functions here only when behavior is reused across modules. |
| 43 | |
| 44 | ## Verification |
| 45 | |
| 46 | - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers. |
| 47 | - Related tests observed by source search: |
| 48 | - `tests/test_browser_agent_regressions.py` |
| 49 | |
| 50 | ## Child DOX Index |
| 51 | |
| 52 | No child DOX files. |