main
md 45 lines 2.17 KB
Rendered Raw
1 # context_utils.py DOX
2
3 ## Purpose
4
5 - Own the `context_utils.py` helper module.
6 - This module provides context managers/utilities for current context binding.
7 - Keep this file-level DOX profile synchronized with `context_utils.py` because this directory is intentionally flat.
8
9 ## Ownership
10
11 - `context_utils.py` owns the runtime implementation.
12 - `context_utils.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
13 - Top-level functions:
14 - `use_context(lock: ThreadLockType, ctxid: str, create_if_not_exists: bool=...)`
15
16 ## Runtime Contracts
17
18 - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together.
19 - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change.
20 - Observed side-effect areas: WebSocket state, settings/state persistence.
21 - Imported dependency areas include: `threading`, `typing`.
22
23 ## Key Concepts
24
25 - Newly constructed contexts reconcile their active profile against Global
26 availability before returning. Existing context lookups return the stored
27 context unchanged; explicit profile and project transitions own any repair.
28 - Important called helpers/classes observed in the source: `AgentContext.use`, `AgentContext.first`, `AgentContext`, `Exception`, `initialize_agent`, `projects.get_context_project_name`, `projects.reconcile_agent_profile`.
29 - Keep request/response, tool, or helper semantics documented here at the same time as source changes.
30
31 ## Work Guidance
32
33 - Preserve public helper APIs used by core code and plugins unless every caller is updated.
34 - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded.
35 - Prefer adding cohesive helper functions here only when behavior is reused across modules.
36
37 ## Verification
38
39 - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers.
40 - `tests/test_projects.py` verifies that lookup is read-only while context
41 creation reconciles once.
42
43 ## Child DOX Index
44
45 No child DOX files.