Skip to content

feat(#347): timeline event tracking — per-memory audit log - #388

Merged
ajianaz merged 5 commits into
developfrom
feat/347-timeline
Jun 19, 2026
Merged

ajianaz merged 5 commits into
developfrom
feat/347-timeline

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Closes #347. See CHANGELOG entry for full details. All tests pass, clippy + fmt clean.

Add an append-only event log per memory (created, updated, recalled,
consolidated, tagged, forgot) in a new timeline_events table (schema v9).

Core (uteke-core):
  - New timeline.rs module:
    - TimelineEventType enum (6 variants)
    - TimelineEvent struct (id, memory_id, event_type, event_data, created_at)
    - Store::add_timeline_event / list_timeline_events / count_timeline_events
    - Uteke::timeline / count_timeline_events / try_timeline_event
  - Schema migration v8 → v9: timeline_events table + 3 indices (idempotent,
    no data backfill — timeline starts from this version forward)
  - remember_precomputed() now emits a 'created' event (best-effort)

CLI (uteke-cli):
  - New 'uteke timeline <id> [--limit N]' command (default 20, JSON support)

Tests (+5 new):
  - TimelineEventType roundtrip
  - timeline_add_and_list (with JSON event_data)
  - timeline_limit + count
  - empty for missing memory
  - migration_dispatcher_reaches_v9

Existing schema-version assertions updated (v8 → v9).

Closes #347
@ajianaz ajianaz added this to the v0.2.1 — DX & Ecosystem milestone Jun 18, 2026
@ajianaz ajianaz added enhancement New feature or request scope:core Core engine work scope:cli CLI and UX type:feature New feature priority:medium Fix soon labels Jun 18, 2026
@github-actions

github-actions Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (1)

  • crates/uteke-core/src/timeline.rs:159 — The new Uteke::timeline(&self, memory_id, limit) method directly returns self.store.list_timeline_events(memory_id, limit) without verifying that the referenced memory exists. As implemented, callers get an empty list for an invalid or deleted ID, which is indistinguishable from a valid memory that simply has no events. The bundled test timeline_empty_for_missing_memory codifies this behavior. This makes the new CLI command misleading: uteke timeline <bad-id> prints No timeline events for memory ... instead of reporting that the memory was not found.

Review powered by cora-cli · BYOK · MIT

CodeCora #388 questioned whether the 'created' timeline event covers all
remember paths. The hook is correctly placed in remember_precomputed
(the single shared creation path called by remember(), remember_typed(),
remember_with_contradiction(), and the consolidate path). Comment now
makes that explicit.

Also emits a 'consolidated' event when remember_with_contradiction
supersedes an older memory, with the deprecated id in event_data.
Comment thread crates/uteke-core/src/timeline.rs Fixed
CodeCora #388 found two issues:

1. Consolidated timeline event was attached to the NEW replacement
   memory, but semantically it should be on the OLD (superseded) memory
   — that's the one being retired. Fix: attach to deprecated_id, with
   metadata 'replaced_by' pointing to the new memory.

2. Timeline events ordered by created_at DESC only, but RFC3339 strings
   from to_rfc3339() omit fractional seconds when zero. Events created
   in the same second had undefined relative order. Fix: add 'id DESC'
   as a secondary sort key (AUTOINCREMENT ensures insertion order).

Also: handle deprecated_id being Option<String> properly.
Comment thread crates/uteke-core/src/timeline.rs Fixed
…ring

CodeCora #388: add_timeline_event used serde_json::to_string(v)
.unwrap_or_default() which stored empty string "" on serialization
failure, silently corrupting event data.

Fix: on serialization failure, log a warning and store 'null' as a
detectable sentinel value instead of masking it as empty.
Comment thread crates/uteke-core/src/timeline.rs Fixed
lib.rs: kept both salience_recency and timeline modules + types module.
CHANGELOG: added #347 timeline section alongside #349 and #352.
fn map_timeline_row(r: &rusqlite::Row) -> rusqlite::Result<TimelineEvent> {
Ok(TimelineEvent {
id: r.get(0)?,
memory_id: r.get(1)?,
@ajianaz
ajianaz merged commit 889a27c into develop Jun 19, 2026
8 of 9 checks passed
@ajianaz
ajianaz deleted the feat/347-timeline branch July 9, 2026 14:28
ajianaz added a commit that referenced this pull request Aug 13, 2026
* feat(#347): timeline event tracking — per-memory audit log

Add an append-only event log per memory (created, updated, recalled,
consolidated, tagged, forgot) in a new timeline_events table (schema v9).

Core (uteke-core):
  - New timeline.rs module:
    - TimelineEventType enum (6 variants)
    - TimelineEvent struct (id, memory_id, event_type, event_data, created_at)
    - Store::add_timeline_event / list_timeline_events / count_timeline_events
    - Uteke::timeline / count_timeline_events / try_timeline_event
  - Schema migration v8 → v9: timeline_events table + 3 indices (idempotent,
    no data backfill — timeline starts from this version forward)
  - remember_precomputed() now emits a 'created' event (best-effort)

CLI (uteke-cli):
  - New 'uteke timeline <id> [--limit N]' command (default 20, JSON support)

Tests (+5 new):
  - TimelineEventType roundtrip
  - timeline_add_and_list (with JSON event_data)
  - timeline_limit + count
  - empty for missing memory
  - migration_dispatcher_reaches_v9

Existing schema-version assertions updated (v8 → v9).

Closes #347

* fix(#347): clarify timeline hook placement + emit Consolidated event

CodeCora #388 questioned whether the 'created' timeline event covers all
remember paths. The hook is correctly placed in remember_precomputed
(the single shared creation path called by remember(), remember_typed(),
remember_with_contradiction(), and the consolidate path). Comment now
makes that explicit.

Also emits a 'consolidated' event when remember_with_contradiction
supersedes an older memory, with the deprecated id in event_data.

* fix(#347): Consolidated event on superseded memory + tiebreaker sort

CodeCora #388 found two issues:

1. Consolidated timeline event was attached to the NEW replacement
   memory, but semantically it should be on the OLD (superseded) memory
   — that's the one being retired. Fix: attach to deprecated_id, with
   metadata 'replaced_by' pointing to the new memory.

2. Timeline events ordered by created_at DESC only, but RFC3339 strings
   from to_rfc3339() omit fractional seconds when zero. Events created
   in the same second had undefined relative order. Fix: add 'id DESC'
   as a secondary sort key (AUTOINCREMENT ensures insertion order).

Also: handle deprecated_id being Option<String> properly.

* fix(#347): log JSON serialization failures instead of silent empty string

CodeCora #388: add_timeline_event used serde_json::to_string(v)
.unwrap_or_default() which stored empty string "" on serialization
failure, silently corrupting event data.

Fix: on serialization failure, log a warning and store 'null' as a
detectable sentinel value instead of masking it as empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority:medium Fix soon scope:cli CLI and UX scope:core Core engine work type:feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: timeline event tracking — chronological history per memory

2 participants