Repository navigation
fix(tui): prevent reducer snapshot cursor regression #11374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -931,7 +931,9 @@ impl WorkspaceRegistry { | |
| }); | ||
| self.connection.execute( | ||
| "INSERT INTO meta(key, value) VALUES(?1, ?2) | ||
| ON CONFLICT(key) DO UPDATE SET value = excluded.value", | ||
| ON CONFLICT(key) DO UPDATE SET value = excluded.value | ||
| WHERE COALESCE(CAST(json_extract(meta.value, '$.cursor') AS INTEGER), 0) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: The monotonic guard breaks the intentional reducer-state reset path. In Prompt for AI agents |
||
| <= CAST(json_extract(excluded.value, '$.cursor') AS INTEGER)", | ||
| params![format!("journal_reducer.{reducer_id}"), value.to_string()], | ||
| )?; | ||
| Ok(()) | ||
|
|
@@ -2022,6 +2024,22 @@ mod tests { | |
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn reducer_state_cursor_does_not_regress_on_late_write() { | ||
| let registry = WorkspaceRegistry::in_memory("reducer-cursor-monotonic").unwrap(); | ||
| registry | ||
| .put_journal_reducer_state("agent_roster", 3, 10, r#"{"entries":{"new":{}}}"#) | ||
| .unwrap(); | ||
| registry | ||
| .put_journal_reducer_state("agent_roster", 3, 9, r#"{"entries":{"old":{}}}"#) | ||
| .unwrap(); | ||
|
|
||
| let (_, cursor, snapshot) = | ||
| registry.journal_reducer_state("agent_roster").unwrap().unwrap(); | ||
| assert_eq!(cursor, 10); | ||
| assert!(snapshot.contains("new")); | ||
| } | ||
|
|
||
| #[test] | ||
| fn persistent_reader_observes_commits_on_an_independent_connection() { | ||
| let root = std::env::temp_dir().join(format!("cmux-journal-reader-{}", new_uuid_v4())); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: When a fold and terminal retirement produce snapshots at the same cursor,
<=still lets the late fold overwrite the newer retirement snapshot. Serialize snapshot mutation with persistence or add an ordering token; a nondecreasing cursor alone does not protect equal-cursor writes.Prompt for AI agents