From 23637564c3adc6fca92f79dadf523e5c3c2e9ac3 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Tue, 24 Nov 2026 15:01:56 +0100 Subject: [PATCH] docs: say where the remembered native basis lives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit API_DESIGN §3.5 said a backend remembers the STATUS and PRIORITY it wrote next to native_status and native_priority and compares on save, but no field held that value. The section now puts it in a private _native_basis on the task, handed over as StoredObject.native_basis, says why it is not kept in the backend or recomputed from .native, and what a direct assignment to a native value means. This came up in the review of https://github.com/pycalendar/calendaring/pull/5. Prompt: [pick from the task list: "calendaring: say where the remembered native STATUS/PRIORITY lives (API_DESIGN §3.5)"] Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- docs/design/API_DESIGN.md | 26 ++++++++++++++++++++++++++ news/+native-basis.documentation.rst | 1 + 2 files changed, 27 insertions(+) create mode 100644 news/+native-basis.documentation.rst diff --git a/docs/design/API_DESIGN.md b/docs/design/API_DESIGN.md index d1f3950..837691b 100644 --- a/docs/design/API_DESIGN.md +++ b/docs/design/API_DESIGN.md @@ -820,6 +820,7 @@ class TaskStatus(StrEnum): # values are the iCalendar strings class Task(Item): # component is an icalendar.Todo native_status: str | None # see "Native passthrough"; not in the iCalendar data native_priority: str | None # likewise + _native_basis: tuple[str | None, str | None] # STATUS, PRIORITY the backend wrote with them; private planned_start: datetime | None # X-PYCAL-PLANNED-START (see "Properties with no standard home") planned_end: datetime | None # X-PYCAL-PLANNED-END # the time log: see "Time tracking" below, on every bound item @@ -1034,6 +1035,31 @@ wherever the backend maps `COMPLETED`. Comparing on save, rather than clearing the native value in a setter, also catches a change made through `item.icalendar` directly. +The remembered values live on the item, in the private +`_native_basis`: the `STATUS` and `PRIORITY` (as strings, `None` where +absent; `PRIORITY:0` counts as absent) that the backend wrote into the +component when it set `native_status` and `native_priority`. A +backend's primitives hand it over next to them, as +`StoredObject.native_basis`, and the generic layer sets all three +together. There is one basis per stored object: its occurrences share +it, as they share the native values. A task that was never read has +the basis `(None, None)`. + +Not kept in the backend, because an item is plain data +([A1](#1-layers-and-modes)) that outlives the collection object that +read it and may be saved through another one; and not recomputed from +`.native`, because `as_data()` drops that live object, and a backend +need not provide one at all +([§8](#8-the-escape-hatch)). + +A caller who assigns `native_status` or `native_priority` directly is +asking for that native value. Each half is compared on its own: the +backend uses the native value while `STATUS` (or `PRIORITY`) still +matches its half of the basis, and maps the property otherwise. So a +changed property wins, silently, over a native value assigned with it, +and on a new task a native value is used only where the property is +absent. + This answers [survey §4.4](TASK_MODEL_SURVEY.md#44-details-to-be-decided-later)'s question "plain string or typed object": a plain string. Legal transitions (RT, OpenProject) are reachable through `native` and are not part of the model. diff --git a/news/+native-basis.documentation.rst b/news/+native-basis.documentation.rst new file mode 100644 index 0000000..af35bc2 --- /dev/null +++ b/news/+native-basis.documentation.rst @@ -0,0 +1 @@ +The design document now says where a task keeps the ``STATUS`` and ``PRIORITY`` its backend wrote with ``native_status`` and ``native_priority``: in a private ``_native_basis``, which a save compares against.