Skip to content

Latest commit

 

History

History
130 lines (103 loc) · 6.8 KB

CHANGELOG.md

File metadata and controls

130 lines (103 loc) · 6.8 KB

Changelog — aimdb-persistence

All notable changes to this crate are documented here.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Changed (breaking)

  • .persist() takes no name (#426). History is stored under the record key, so record.query returns the key as topic and WebSocket clients read history with the same grants as live values. Rows already written under a custom name stay as they are; nothing new is written under them.
  • The with_persistence query handler returns typed rows (#429), matching the new QueryHandlerFn signature in aimdb-core. Replies no longer carry total.
  • The query handler no longer applies a default limit (#430). It uses the resolved QueryHandlerParams::limit from aimdb-core, which defaults to 1 as before.

0.3.0 - 2026-11-03

Changed (breaking)

  • Requires aimdb-core 3.0 (#326). The .persist() tap reads the Stamped<T> values core 3.0 buffers carry and stores .value. The backend still records its own persist time, not the write stamp (design 058 §5.1).

Added

  • log feature (#365), forwarding operational events through the log facade. It can be enabled together with tracing.

Changed

  • Operational failures are reported through core's log_*! macros (#365): a missing backend, serialize and store failures, retention cleanup failures, and rows skipped by query_* because they fail to deserialise. tracing now enables aimdb-core/tracing instead of depending on tracing directly. Log targets are unchanged (aimdb_persistence::ext, ::builder_ext, ::query_ext). With neither tracing nor log, a retention cleanup failure is printed to stderr.

0.2.0 - 2026-09-18

Changed (breaking) — Design 047

  • with_persistence's registered QueryHandlerFn returns the shared record.query shape {"records": [{topic, payload, ts}, …], "total": N} (rows sorted by ts ascending) instead of {values: [{record, value, stored_at}], count}, so every transport shares one query vocabulary.
  • PersistenceBackend::query patterns are MQTT-style, the grammar subscriptions already use: * covers exactly one segment and # zero or more, over dot-separated record keys. Previously the contract was a prefix glob ("accuracy::*"), so one pattern meant different things live and historically — and a query could return records outside it. New pattern::{literal_prefix, prefix_upper_bound} build the index range a backend narrows with, and topic_matches is re-exported so it decides with the same implementation core uses. Backends matching * themselves must switch to that pair.

Changed (breaking)

  • Issue #131: RecordRegistrarPersistExt/AimDbBuilderPersistExt/AimDbQueryExt are non-generic over the runtime (they extend RecordRegistrar<'a, T> / AimDbBuilder / AimDb); the retention-cleanup on_start task receives RuntimeContext and sleeps via ctx.time().sleep_secs(...).
  • RecordRegistrarPersistExt::persist takes a fresh borrow (Issue #130, design 034 Phase 2). fn persist(&mut self, …) -> &mut RecordRegistrar<'a, T, R> (was &'a mut self -> &'a mut …), following core's registrar lifetime fix — persist() no longer borrows the registrar for its entire remaining lifetime. Call sites compile unchanged.
  • All R: Spawn bounds replaced with R: RuntimeAdapter on public traits (AimDbBuilderPersistExt, RecordRegistrarPersistExt, AimDbQueryExt) and internal helpers (Issue #88). No behavioural change — aimdb-persistence never called runtime.spawn directly, the bound was just propagated.

0.1.1 - 2026-05-22

Changed

  • Bumped aimdb-core dependency to 1.1.0 and aimdb-executor to 0.2.0

0.1.0 — 2026-02-21

Added

  • PersistenceBackend trait — pluggable async storage interface with store, query, cleanup, and an optional initialize hook (backend.rs)
  • StoredValue — typed record returned by query: record_name, value: serde_json::Value, stored_at: u64 (Unix ms)
  • QueryParams — limit_per_record: Option<usize>, start_time: Option<u64>, end_time: Option<u64>; None limit means "return all matching rows" (no implicit truncation)
  • AimDbBuilderPersistExt trait — adds .with_persistence(backend, retention) to AimDbBuilder<R>; stores PersistenceState in the builder's Extensions TypeMap and registers a 24-hour retention cleanup task via on_start()
  • PersistenceState — backend: Arc<dyn PersistenceBackend> + retention_ms: u64; stored in Extensions and shared between the subscriber and query-time code
  • RecordRegistrarPersistExt trait — adds .persist(record_name) to RecordRegistrar<T, R>; accepts impl Into<String> for ergonomic call sites; spawns a tap_raw subscriber that serialises each T to JSON and writes it to the backend
  • AimDbQueryExt trait — adds query_latest, query_range, and query_raw to AimDb<R>:
    • query_latest<T>(&self, pattern, limit) -> Vec<T> — typed, limit per record
    • query_range<T>(&self, pattern, start_ms, end_ms, limit_per_record) -> Vec<T> — typed, time range with optional per-record limit (None = all rows)
    • query_raw(&self, pattern, params) -> Vec<StoredValue> — untyped escape hatch used by the AimX record.query protocol handler
  • PersistenceError — NotConfigured, Backend(String), BackendShutdown, Serialization(serde_json::Error)
  • tracing feature — optional structured logging for subscriber events, cleanup results, and query-time deserialisation failures
  • Cleanup observability — when the tracing feature is disabled, cleanup errors are printed to stderr via eprintln! so operators are never silently left with unbounded database growth

Design decisions

  • No coupling to aimdb-core persistence types — persistence state flows through the Extensions TypeMap; aimdb-core carries only a type-erased QueryHandlerFn for the AimX protocol delegation
  • Runtime-agnostic subscriber — RecordRegistrarPersistExt requires only T: Serialize; .with_remote_access() is not needed
  • StoredValue.value moved, not cloned — filter_map in AimDbQueryExt destructures StoredValue to move the Value into from_value() directly