TimelessLogs.LibsqlEngine (timeless_logs v1.6.0)

Copy Markdown View Source

In-process storage engine over the timeless-libsql timeless_logs virtual table — Session 1 of the port plan (notes/libsql_engine_port_plan_2026-08-09.md).

Opt-in via config :timeless_logs, engine: :libsql. The writer owns <data_dir>/logs.db: ingest encodes public rich-v1 batches (the migration candidate's validated encoder) and control commands ride the vtab's shadow-name channel — the same public surface the external Rust owner uses, so embedded and external share one on-disk format.

Session 1 scope is the write path (ingest/flush/optimize) plus raw SQL access; the query surface routes here in Session 2.

Summary

Functions

Single-snapshot backup: flush, then VACUUM INTO <target>/logs.db.

Returns a specification to start this module under a supervisor.

Exact count of entries matching the filters.

Persist buffered entries into blocks now.

Ingest normalized entries (%{timestamp:, level:, message:, metadata:}).

Run a bounded background optimize pass.

Query entries with the facade's filter vocabulary. Time range and a single level equality push down into the vtab scan; everything else (metadata, metadata_any, message-contains) applies the SHARED TimelessLogs.Filter residual — semantics identical to the Elixir engine by construction.

Aggregate statistics from timeless_stats('logs') — no block reads.

Functions

backup(target_dir)

Single-snapshot backup: flush, then VACUUM INTO <target>/logs.db.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

count(filters)

Exact count of entries matching the filters.

flush()

Persist buffered entries into blocks now.

ingest(entries)

Ingest normalized entries (%{timestamp:, level:, message:, metadata:}).

optimize()

Run a bounded background optimize pass.

query(filters)

Query entries with the facade's filter vocabulary. Time range and a single level equality push down into the vtab scan; everything else (metadata, metadata_any, message-contains) applies the SHARED TimelessLogs.Filter residual — semantics identical to the Elixir engine by construction.

start_link(opts)

stats()

Aggregate statistics from timeless_stats('logs') — no block reads.