Repository navigation
fix(core): refresh source_hash on update and record update, aging and contradiction events (#1595) - #1635
Merged
Conversation
… 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).
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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
Closes #1595.
update_memory(Store::update_fields): when the content changes,source_hashis refreshed and anupdatedtimeline 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"}], actorsystem:edit(Cloud's default).Store::deprecate_by_ids(aging cleanup, lifecycle cycle, bulk forget) records onedeprecatedevent per memory it actually deprecates, with the reason, in the same transaction (UPDATE … RETURNING id). Already-deprecated ids get no duplicate event.deprecate_with_reason(contradiction: replaced by <id>), so it leaves adeprecatedevent next to the existingconsolidatedone.timeline_events). Checked, no code change; a test now covers it.uteke provenancewording: a mismatch now reads "content changed outside the API".active_content_hashesdoc 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 thecreatedevent and each revision linksprevious_hash→source_hash./provenanceis 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):
TaggedandRecalledstill have no producer, and a metadata-only update writes no event, matching Cloud'supdate_fields_tx.Testing
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.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.