scene_service.annotations¶
User annotations — user-authored semantics anchored to the SLAM map.
Functions
|
Validate user-supplied annotation fields; return an error string on the first violation, None when everything is acceptable. |
Classes
|
One user annotation. |
|
Per-map JSON persistence for user annotations. |
- class scene_service.annotations.Annotation(annotation_id: str, kind: str, name: str, points: list[list[float]] = <factory>, theta: float | None = None, created_at: float = 0.0, updated_at: float = 0.0, stale: bool = False, stale_reason: str = '')[source]¶
Bases:
objectOne user annotation.
- annotation_id: str¶
- created_at: float = 0.0¶
- classmethod from_json(d: dict) Annotation[source]¶
Rebuild from a stored dict, dropping unknown keys so a file written by a newer scene still loads (forward-tolerant).
- kind: str¶
- name: str¶
- points: list[list[float]]¶
- stale: bool = False¶
- stale_reason: str = ''¶
- theta: float | None = None¶
- updated_at: float = 0.0¶
- class scene_service.annotations.AnnotationStore(base_dir: str, *, map_id: str, generation: int | None = None)[source]¶
Bases:
objectPer-map JSON persistence for user annotations.
- create(*, kind: str, name: str, points: list, theta: float | None = None) Annotation[source]¶
Create + persist an annotation and return it.
- delete(annotation_id: str) bool[source]¶
Remove an annotation; True when it existed. Persists on change.
- get(annotation_id: str) Annotation | None[source]¶
- has_saved(map_id: str) bool[source]¶
True when a persisted annotation file already exists for map_id.
- list() list[Annotation][source]¶
- list_json() list[dict][source]¶
JSON-ready dump of every annotation (the /api/state field and GET /api/annotations share this shape).
- property map_id: str¶
- mark_all_stale(reason: str, *, new_generation: int | None = None) int[source]¶
Flag every non-stale annotation stale with reason (map frame epoch changed at runtime — the _lifecycle_watch hook).
- property path: Path¶
- read_saved(map_id: str) list[dict][source]¶
Another map’s regions, read without rebinding; [] if unreadable.
- rebind(map_id: str, *, generation: int | None = None, carry_current: bool = False) None[source]¶
Switch this store to another map partition.
- reconcile_generation(live_generation: int) int[source]¶
Called when the map’s true generation becomes known at runtime (the lifecycle watcher’s confirmation) — a store built under a static binding (generation None) cannot judge staleness at load time, so the judgement happens here instead.
- snapshot(map_id: str, *, generation: int | None = None) Path[source]¶
Write another map’s snapshot without changing the live partition.
- update(annotation_id: str, *, name: str | None = None, points: list | None = None, theta: float | None = None, clear_stale: bool = False) Annotation | None[source]¶
Apply the provided fields to an existing annotation (None = keep), bump updated_at, persist, and return it; None when the id is unknown.