main
md 63 lines 3.37 KB
Rendered Raw
1 # scheduler.py DOX
2
3 ## Purpose
4
5 - Own the `scheduler.py` agent tool.
6 - This module creates, updates, lists, runs, waits for, and deletes scheduled/planned/adhoc tasks.
7 - Keep this file-level DOX profile synchronized with `scheduler.py` because this directory is intentionally flat.
8
9 ## Ownership
10
11 - `scheduler.py` owns the runtime implementation.
12 - `scheduler.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
13 - Classes:
14 - `SchedulerTool` (`Tool`)
15 - `async execute(self, **kwargs)`
16 - `async list_tasks(self, **kwargs) -> Response`
17 - `async find_task_by_name(self, **kwargs) -> Response`
18 - `async show_task(self, **kwargs) -> Response`
19 - `async run_task(self, **kwargs) -> Response`
20 - `async delete_task(self, **kwargs) -> Response`
21 - `async update_task(self, **kwargs) -> Response`
22 - `async create_scheduled_task(self, **kwargs) -> Response`
23 - Top-level functions:
24 - `_current_action(tool: Tool, kwargs: dict) -> str`
25 - `_normalize_timezone(value: Any) -> str | None`
26 - `_schedule_timezone(kwargs: dict) -> str | None`
27 - `_task_schedule_from_input(schedule: Any, timezone: str | None=...) -> TaskSchedule`
28 - `_validate_task_schedule(task_schedule: TaskSchedule) -> str`
29 - `_task_plan_from_input(plan: Any) -> tuple[TaskPlan | None, str]`
30 - Notable constants/configuration names: `DEFAULT_WAIT_TIMEOUT`, `LOCAL_TIMEZONE_ALIASES`.
31
32 ## Runtime Contracts
33
34 - Tool modules must define `helpers.tool.Tool` subclasses and return `helpers.tool.Response` from `execute(...)`.
35 - Update this file whenever tool arguments, output shape, `break_loop` behavior, intervention handling, prompt instructions, or side effects change.
36 - `SchedulerTool` is a `Tool`.
37 - `SchedulerTool` defines `execute(...)`.
38 - Observed side-effect areas: filesystem writes, filesystem deletion, settings/state persistence, secret handling, scheduler state.
39 - Imported dependency areas include: `agent`, `asyncio`, `datetime`, `helpers`, `helpers.localization`, `helpers.projects`, `helpers.task_scheduler`, `helpers.tool`, `json`, `pytz`, `random`, `re`, `typing`.
40
41 ## Key Concepts
42
43 - Important called helpers/classes observed in the source: `str.strip.lower.replace`, `str.strip`, `_normalize_timezone`, `TaskSchedule`, `task_schedule.to_crontab`, `timezone_name.lower`, `Localization.get.get_timezone`, `pytz.timezone`, `schedule.split`, `re.match`, `parse_datetime`, `TaskPlan.create`, `_current_action`, `get_context_project_name`, `TaskScheduler.get.get_tasks`, `Response`, `TaskScheduler.get.find_task_by_name`, `TaskScheduler.get.get_task_by_uuid`, `scheduler.get_task_by_uuid`, `self._resolve_project_metadata`.
44 - Keep request/response, tool, or helper semantics documented here at the same time as source changes.
45
46 ## Work Guidance
47
48 - Keep tool output concise, model-readable, and safe for history persistence.
49 - Coordinate argument or behavior changes with prompt tool instructions and skill guidance.
50 - Respect intervention flow for long-running, external, or user-visible operations.
51
52 ## Verification
53
54 - Run targeted tool and prompt-contract tests for changed behavior; smoke-test agent execution when no focused test exists.
55 - Related tests observed by source search:
56 - `tests/test_task_scheduler_timezone.py`
57 - `tests/test_timezone_regressions.py`
58 - `tests/test_tool_action_contracts.py`
59 - `tests/test_tool_request_normalization.py`
60
61 ## Child DOX Index
62
63 No child DOX files.