feat(session): add conflict-safe memory rollback - #4460
Open
Stamina9 wants to merge 1 commit into
Open
Conversation
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.
Description
Session commits can mutate long-term memory, while deleting the session currently leaves those mutations behind. This PR adds a conflict-safe rollback path that replays every archived
memory_diff.jsonin reverse commit and operation order before optionally deleting the session.The owning implementation lives in
openviking/service/session_memory_rollback.py. The server route, Python SDK, and Rust CLI transport the samedry_run,force, anddelete_sessionsafety options instead of reimplementing rollback rules.The rollback service:
New audit records use schema v2 with canonical raw before/after/deleted snapshots and an explicit operation order. Legacy or incomplete snapshots are reported as conflicts rather than reconstructing metadata heuristically. Existing sessions remain readable; only rollback of records without sufficient raw snapshots is rejected safely.
The issue was not reproduced against a deployed server in this environment. The production execution paths were traced from commit audit creation through the service, REST route, SDK, and CLI, then validated with focused contract and failure-boundary tests.
Human Involvement
The human selected the issue and risk standard, reviewed progress, provided the fork, and approved the release workflow. AI assistance was used for implementation and validation.
Related Issue
Fixes #4178
Type of Change
Changes Made
POST /api/v1/sessions/{session_id}/rollback, Python SDK methods,ov session rollback, andov session delete --rollback-memories.Testing
Validation performed on upstream
maincommitcd8580c6f8a50ec44593618b3102799ab0b553fd:Checklist
No dependent changes are required.
Screenshots (if applicable)
Not applicable; this change exposes REST, SDK, and CLI behavior without a graphical UI.
Additional Notes
pytestaddopts requirepytest-cov, which was unavailable in the isolated runtime, so the exact focused command overrides addopts with-o addopts=''.tests/server/test_api_sessions.pyfile on this Windows runtime produced 51 setup errors because the installed x86 wheel does not package the nativePersistStorebackend. The rollback route contract test itself passes and is included above.HOMEvalue. All remaining 473 Rust tests pass.