feat: contradiction resolution ledger + undo across CLI/HTTP/MCP (#1172) - #1185
Merged
Conversation
Fase 2 of #1172: supersessions become a first-class, auditable ledger. - contradiction_resolutions(): edge-driven ledger (deprecated row + superseded_by edge) β same predicate undo_supersession resolves against, so listed = undoable, always - undo_supersession(): atomic restore + edge-pair removal in one tx (was: promote() committed first, edge delete could fail after β active memory with live superseded_by pair), post-commit vector index re-add + cache invalidation - supersede(): re-supersession refreshes deprecate_reason/deprecated_at so the ledger names the CURRENT winner - Surfaces: GET /contradictions, POST /contradictions/undo, uteke contradictions list|undo, MCP uteke_contradictions(+_undo) - Fix: no-namespace ledger query bound limit to nonexistent ?2 - Tests: core (ledger/undo/chain/resupersession), server API (2), MCP roundtrip (1); fmt/clippy clean; cora review pass
π Cora AI Code Reviewβ No issues found. Code looks good! Review powered by cora-code Β· BYOK Β· MIT |
This was referenced Sep 6, 2026
Closed
Merged
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
Fase 2 of #1172: contradiction resolutions become a first-class, auditable ledger.
Uteke::contradiction_resolutions(namespace, limit)β the resolution ledger: superseded-but-not-restored memories with reason + timestamp. Membership is EDGE-driven (deprecated rowJOIN memory_edges ON edge_type = 'superseded_by') β the same predicateundo_supersessionresolves against, so listed β undoable.Uteke::undo_supersession(id)β now atomic: restore + edge-pair removal in ONE transaction (previouslypromote()committed first, so a failed edge delete left an ACTIVE memory carrying a livesuperseded_bypair). Vector-index re-add + recall-cache invalidation run as post-commit side effects, mirroringpromote()'s contract.supersede()re-supersession fix β superseding an already-deprecated memory now refreshesdeprecate_reason/deprecated_at, so the ledger always names the CURRENT winner (previously the stale first-winner reason contradicted the edge pair).GET /contradictions?namespace=&limit=,POST /contradictions/undo({id}β 404 when nothing to undo)uteke contradictions list [--namespace --limit --json],uteke contradictions undo <id|prefix>uteke_contradictions,uteke_contradictions_undoLIMIT ?2while binding a single parameter β runtime bind error on every call. Caught by the new MCP roundtrip test.docs/cli-reference.md(contradictions section), CHANGELOG[Unreleased],docs/api-reference.mdregenerated via docgen.Why
#1172 Fase 2. Supersede was a side effect with no audit surface: agents couldn't see what the pipeline decided or revert a wrong decision without hand-editing edges. The ledger + undo close that loop, and the edge-driven membership guarantees the ledger can never disagree with what undo actually operates on (cora review caught exactly that divergence β plus the non-atomic undo β across three review rounds; all three findings are fixed here with regression tests).
Testing
cargo test --workspaceβ 554 passed, 0 failed (incl. 4 new: core resupersession-ledger regression, MCP list/undo roundtrip with short-id resolution + double-undo error, 2 server API tests via TestRequest: ledger-list/undo-restores + undo-404/malformed-400)cargo fmt --all -- --checkclean;cargo clippy --workspace --all-targetszero warningscora review --stagedpass (3 iterations: fixed non-atomic undo, stale re-supersession reason, LIKE-based ledger membership β each verified by the new tests)cargo run -p docgenregenerates api-reference with both endpoints