Skip to content

fix(core): refresh source_hash on update and record update, aging and contradiction events (#1595) - #1635

Merged
ajianaz merged 1 commit into
developfrom
feat/timeline-update-events
Nov 2, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/timeline-update-events

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

What

Closes #1595.

  • update_memory (Store::update_fields): when the content changes, source_hash is refreshed and an updated timeline event is written in the same transaction as the content write (fails closed). The shape is identical to uteke-cloud fix: remove VitePress base — routing handled by Worker #354 / contract 0.28.2:
    • event_data: {"fields":["content"],"previous_hash":<old>,"source_hash":<new>}
    • evidence_json: [{"memory":<id>,"relation":"subject"}], actor system:edit (Cloud's default).
    • An update that does not change the content (tags, importance, the same text) touches neither the hash nor the timeline, as in Cloud.
  • Store::deprecate_by_ids (aging cleanup, lifecycle cycle, bulk forget) records one deprecated event per memory it actually deprecates, with the reason, in the same transaction (UPDATE … RETURNING id). Already-deprecated ids get no duplicate event.
  • Contradiction on write deprecates the old memory through deprecate_with_reason (contradiction: replaced by <id>), so it leaves a deprecated event next to the existing consolidated one.
  • Prune: already keeps history since schema v20 (feat(core): audit-grade timeline — history survives forget, deprecated events, MCP tool (schema v20) #1280 dropped the FK cascade; prune deletes nothing from timeline_events). Checked, no code change; a test now covers it.
  • uteke provenance wording: a mismatch now reads "content changed outside the API".
  • active_content_hashes doc comment updated (it still hashes the live content, so a row edited outside the API still matches what it holds).

Why

Owner decision on #1595 (2026-11-02): every legitimate update showed as ✗ MISMATCH, a false positive. With the refresh, a mismatch means an edit outside the API, which is what the audit is for. No history is lost: the write-time hash stays in the created event and each revision links previous_hash → source_hash. /provenance is CORE and its fields, names and types are unchanged; Cloud already behaves this way (uteke-cloud #354), so this is parity, not a new CORE semantic.

Not done here (left on purpose): Tagged and Recalled still have no producer, and a metadata-only update writes no event, matching Cloud's update_fields_tx.

Testing

  • New crates/uteke-core/src/timeline_write_tests.rs (7 tests): hash follows content and the event matches Cloud's shape; a second update chains from the first; no event and no hash change without a content change; a direct SQL edit is still a mismatch; bulk deprecation events with no duplicates; aging cleanup and contradiction-on-write events; prune keeps created/updated/deprecated events.
  • The existing provenance test (operations/listing.rs) tampers through SQL, so it still holds unchanged; the import duplicates test does not depend on a stale hash.
  • cargo test --workspace, cargo clippy --workspace --all-targets -D warnings, cargo fmt --check: green locally.

… contradiction events (#1595)

A content update through the API now refreshes source_hash and writes an
updated event {fields, previous_hash, source_hash} in the same transaction,
as uteke-cloud does since #354. Bulk deprecations record a deprecated event
per memory in their transaction, and a contradiction on write deprecates
with a reason. A test covers that prune keeps the history (schema v20).
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 6e200f4 into develop Nov 2, 2026
15 checks passed
@ajianaz
ajianaz deleted the feat/timeline-update-events branch November 4, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(core): timeline events for update, aging and contradiction deprecations; refresh source_hash on update

1 participant