Skip to content

Number hot ops per author, persist the CRDT state - #4638

Open
TrueDoctor wants to merge 1 commit into
graph-storage-3-retirement-stampsfrom
graph-storage-4-settled-marks
Open

TrueDoctor wants to merge 1 commit into
graph-storage-3-retirement-stampsfrom
graph-storage-4-settled-marks

Conversation

@TrueDoctor

Copy link
Copy Markdown
Member

No description provided.

@Keavon Keavon changed the title Number hot ops per author, persist the crdt state Number hot ops per author, persist the CRDT state Oct 2, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 11 files

Confidence score: 2/5

  • In document.rs, a settled late copy can leave the hot sequence and Lamport clock behind, so the next local edit may reuse an operation ID that peers discard or get a timestamp that is not causally later. Advance both before returning from that path.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="document/graph-storage/src/document.rs">

<violation number="1" location="document/graph-storage/src/document.rs:104">
P1: A settled late copy can return before advancing `last_hot_sequence` or the Lamport clock. The next local edit may reuse a settled `HotOpId` that peers discard, and its timestamp may not be causally later than the observed op; update both counters before these early returns.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment on lines +104 to +113
if self.settled.covers(hot_op.id()) {
return Ok(());
}
if self.hot_timestamps.contains(&hot_op.timestamp) {
return Ok(());
}
// Our own ops raise the sequence counter too, should the persisted one lag.
if hot_op.timestamp.peer == self.peer {
self.last_hot_sequence = self.last_hot_sequence.max(hot_op.sequence);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: A settled late copy can return before advancing last_hot_sequence or the Lamport clock. The next local edit may reuse a settled HotOpId that peers discard, and its timestamp may not be causally later than the observed op; update both counters before these early returns.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At document/graph-storage/src/document.rs, line 104:

<comment>A settled late copy can return before advancing `last_hot_sequence` or the Lamport clock. The next local edit may reuse a settled `HotOpId` that peers discard, and its timestamp may not be causally later than the observed op; update both counters before these early returns.</comment>

<file context>
@@ -82,20 +91,67 @@ impl Document {
-	/// Replay a persisted or received hot op. One already reflected in the registry changes nothing.
+	/// Replay a persisted or received hot op. One already settled or held changes nothing.
 	pub fn replay_hot_op(&mut self, hot_op: HotOp) -> Result<(), CrdtError> {
+		if self.settled.covers(hot_op.id()) {
+			return Ok(());
+		}
</file context>
Suggested change
if self.settled.covers(hot_op.id()) {
return Ok(());
}
if self.hot_timestamps.contains(&hot_op.timestamp) {
return Ok(());
}
// Our own ops raise the sequence counter too, should the persisted one lag.
if hot_op.timestamp.peer == self.peer {
self.last_hot_sequence = self.last_hot_sequence.max(hot_op.sequence);
}
self.clock.observe(hot_op.timestamp);
// Our own ops raise the sequence counter too, should the persisted one lag.
if hot_op.timestamp.peer == self.peer {
self.last_hot_sequence = self.last_hot_sequence.max(hot_op.sequence);
}
if self.settled.covers(hot_op.id()) {
return Ok(());
}
if self.hot_timestamps.contains(&hot_op.timestamp) {
return Ok(());
}

Comment thread document/format/src/persist.rs
@TrueDoctor
TrueDoctor force-pushed the graph-storage-4-settled-marks branch from d62dc25 to 85414b0 Compare October 5, 2026 21:07

This branch was successfully deployed

1 active (outdated) deployment
graphite-dev (Preview) — 36c878c2 Deployed Oct 2, 2026 by github-actions[bot]
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.

1 participant