| 1 | # backup_create.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `backup_create.py` API endpoint. |
| 6 | - This module handles backup create requests. |
| 7 | - Keep this file-level DOX profile synchronized with `backup_create.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `backup_create.py` owns the runtime implementation. |
| 12 | - `backup_create.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Classes: |
| 14 | - `BackupCreate` (`ApiHandler`) |
| 15 | - `requires_auth(cls) -> bool` |
| 16 | - `requires_loopback(cls) -> bool` |
| 17 | - `async process(self, input: dict, request: Request) -> dict | Response` |
| 18 | |
| 19 | ## Runtime Contracts |
| 20 | |
| 21 | - HTTP handlers must derive from `helpers.api.ApiHandler`; WebSocket handlers must derive from `helpers.ws.WsHandler`. |
| 22 | - Update this file whenever request payloads, authentication or CSRF requirements, response shapes, route side effects, or WebSocket event contracts change. |
| 23 | - `BackupCreate` is an `ApiHandler`. |
| 24 | - `BackupCreate` defines `process(...)`. |
| 25 | - `BackupCreate` defines `requires_auth(...)`. |
| 26 | - `BackupCreate` defines `requires_loopback(...)`. |
| 27 | - Observed side-effect areas: filesystem writes. |
| 28 | - Imported dependency areas include: `helpers.api`, `helpers.backup`, `helpers.persist_chat`. |
| 29 | |
| 30 | ## Key Concepts |
| 31 | |
| 32 | - Important called helpers/classes observed in the source: `save_tmp_chats`, `BackupService`, `send_file`, `backup_service.create_backup`, `line.strip`, `line.startswith`, `patterns_string.split`, `line.strip.startswith`. |
| 33 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 34 | |
| 35 | ## Work Guidance |
| 36 | |
| 37 | - Preserve authentication, CSRF, loopback, and API-key checks unless the endpoint contract explicitly changes. |
| 38 | - Update frontend callers, plugin callers, and tests together when payload shape changes. |
| 39 | - Use `helpers.api.Response` for non-JSON responses, files, redirects, or status-specific replies. |
| 40 | |
| 41 | ## Verification |
| 42 | |
| 43 | - Run endpoint-specific or API/WebSocket tests for changed behavior; smoke-test browser callers when no focused test exists. |
| 44 | - Related tests observed by source search: |
| 45 | - `tests/test_download_toast_regressions.py` |
| 46 | |
| 47 | ## Child DOX Index |
| 48 | |
| 49 | No child DOX files. |