Repository navigation
feat(core): audit-grade timeline — history survives forget, deprecated events, MCP tool (schema v20) - #1280
Merged
Conversation
…d events, MCP tool (schema v20) Owner decision 2026-09-18 (contract doc kontrak-core-cloud/03): timeline is the audit layer and must survive memory deletion. - migration v19->v20: rebuild timeline_events WITHOUT the FK ON DELETE CASCADE (defensive: creates the table if an old store never materialized it) + backfill `created` events (actor=backfill) for memories lacking one (~9.7k in PROD) - deprecate_with_reason now records a `deprecated` event with reason (the fleet's dominant delete traffic — 1.4k deprecations — was previously unwired); idempotent re-deprecation writes no duplicate - hard forget() writes a `forgot` tombstone BEFORE the delete so the audit trail exists even on pre-v20 stores - new TimelineEventType::Deprecated variant (append-only enum rule) - new MCP tool uteke_timeline (id + limit, mirrors uteke_provenance) - tests: migration preserves rows/drops FK/backfills once; soft and hard forget event assertions (7 timeline tests + 567 lib tests green) Next up (separate PR): actor plumbing from caller identity (CLI/MCP/ HTTP) — Created events still default to a NULL actor.
… v20 atomicity documented
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This was referenced Sep 28, 2026
ajianaz
added a commit
that referenced
this pull request
Sep 29, 2026
- mcp.md: 46 -> 49 tools; add uteke_timeline, uteke_verify, uteke_repair rows (shipped in #1280/#1272, tool table had not caught up) - architecture.md: schema history v15 -> v20 (v16 author_type #1083, v17 deprecated_at #1086, v18 provenance #1172, v19 rooms.description #1202, v20 audit-grade timeline #1280) Co-authored-by: CMO <[email protected]>
This was referenced Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
crates/uteke-core/src/memory/schema.rs): rebuildtimeline_eventsWITHOUT theREFERENCES memories(id) ON DELETE CASCADEFK — deleting a memory no longer wipes its history. Defensive path for stores that never materialized the table. Fresh-store DDL instore.rsaligned (no FK).createdevents (actor='backfill', timestamped at the memory's owncreated_at) for memories lacking one — ~9.7k in the PROD store (pre-timeline-schema rows + import path).TimelineEventType::Deprecatedvariant, append-only enum):deprecate_with_reasonnow records adeprecatedevent with the reason. Idempotent re-deprecation writes no duplicate. This wires the fleet's dominant delete traffic (1.4k deprecations since 2026-09-06, previously zero events).forget()writes aforgotevent BEFORE the delete — and only when the memory actually exists (no spurious tombstones for unknown IDs). On post-v20 stores the tombstone persists as an orphan; on pre-v20 stores it was the only chance to record anything.uteke_timeline(crates/uteke-mcp/src/lib.rs):id+ optionallimit(default 100, cap 1000), mirrorsuteke_provenance. Works as a tombstone lookup for forgotten memories too.Why
Owner decision 2026-09-18 (contract doc
kontrak-core-cloud/03): the timeline is the audit layer ("history jangan dihapus"). Forensics (uteke-cloud#90 cmt 2836): PROD had 15.342 events = 100%created, 0 lifecycle events,actorNULL everywhere, ~62% of memories without any event, and the FK CASCADE actively destroyed history at the moment audit needs it most.Atomicity: each batch runs in one SQLite implicit transaction and the migration dispatcher wraps the whole step in its own transaction, stamping v20 only on success — an interrupted run rolls back entirely.
Known gap (explicitly deferred):
createdevents still carry a NULL actor; threading caller identity (CLI/MCP/HTTP) throughtry_timeline_eventis the next small PR.Testing
test_migration_v19_to_v20_history_survives_delete_and_backfills_created: v19 DB (with FK) → migrate → rows preserved, backfill exactly-once, delete memory → events survive,pragma_foreign_key_list= 0.test_timeline_deprecate_and_forget_events: soft forget →deprecatedevent present; hard forget →forgottombstone recorded AND still present after the row is gone.test_author_type_migration_v15_to_v16(hardcoded v19 →CURRENT_SCHEMA_VERSION, breaks every bump otherwise).cargo test -p uteke-core: 567 passed, 0 failed; clippy clean on uteke-core + uteke-mcp; cargo fmt applied. Cora pre-commit review: No issues found (after fixing 2 MAJORs from round 1: spurious tombstones for nonexistent IDs; migration atomicity documentation).