main
md 64 lines 2.83 KB
Rendered Raw
1 # cache.py DOX
2
3 ## Purpose
4
5 - Own the `cache.py` helper module.
6 - This module provides in-process cache areas with optional global and area toggles.
7 - Keep this file-level DOX profile synchronized with `cache.py` because this directory is intentionally flat.
8
9 ## Ownership
10
11 - `cache.py` owns the runtime implementation.
12 - `cache.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
13 - Classes:
14 - `CacheEntry` (no explicit base class)
15 - Top-level functions:
16 - `toggle_global(enabled: bool) -> None`
17 - `toggle_area(area: str, enabled: bool) -> None`
18 - `has(area: str, key: Any) -> bool`
19 - `add(area: str, key: Any, data: Any) -> None`
20 - `get(area: str, key: Any, default: Any=...) -> Any`
21 - `remove(area: str, key: Any) -> None`
22 - `clear(area: str) -> None`
23 - `trim_cache(area: str, seconds: float=...) -> None`
24 - `clear_all() -> None`
25 - `_is_enabled(area: str) -> bool`
26 - `_create_entry(value: Any) -> CacheEntry`
27 - `_touch_entry(entry: CacheEntry) -> None`
28 - `_get_matching_areas(area: str) -> list[str]`
29 - `determine_cache_key(agent, *additional)`
30
31 ## Runtime Contracts
32
33 - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together.
34 - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change.
35 - Observed side-effect areas: filesystem deletion, plugin state, settings/state persistence.
36 - Imported dependency areas include: `dataclasses`, `fnmatch`, `threading`, `time`, `typing`.
37
38 ## Key Concepts
39
40 - Important called helpers/classes observed in the source: `threading.RLock`, `dataclass`, `CacheEntry`, `time.time`, `_is_enabled`, `_touch_entry`, `_create_entry`, `_cache.pop`, `_get_matching_areas`, `_cache.clear`, `agent.context.get_data`, `area_cache.pop`, `fnmatch.fnmatch`.
41 - Keep request/response, tool, or helper semantics documented here at the same time as source changes.
42
43 ## Work Guidance
44
45 - Preserve public helper APIs used by core code and plugins unless every caller is updated.
46 - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded.
47 - Prefer adding cohesive helper functions here only when behavior is reused across modules.
48
49 ## Verification
50
51 - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers.
52 - Related tests observed by source search:
53 - `tests/test_browser_agent_regressions.py`
54 - `tests/test_file_tree_visualize.py`
55 - `tests/test_office_canvas_setup.py`
56 - `tests/test_office_document_store.py`
57 - `tests/test_self_update_tag_filter.py`
58 - `tests/test_time_travel.py`
59 - `tests/test_webui_extension_surfaces.py`
60 - `tests/test_whatsapp_bridge_manager.py`
61
62 ## Child DOX Index
63
64 No child DOX files.