Repository navigation
Reduce backlog replay cost and preserve capture during upgrades - #307
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8aad690648
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| complete: true, | ||
| continuation: None, | ||
| }); | ||
| self.publish().await?; |
There was a problem hiding this comment.
Preserve the fetched control when a batch flush fails
When replaying a persisted backlog, next_input() has already advanced the journal reader past the control before this flush runs. If publish() encounters a transient storage failure, recovery retries the saved publication for the preceding batch and then calls advance() without resetting the reader or retaining entry. The control is consequently skipped, and a later commit can delete it without applying it. In particular, skipping a Reset makes subsequent events use stale translator state. Retain the fetched control across the failed flush, or rewind the reader to the successfully committed prefix before resuming.
Useful? React with 👍 / 👎.
Large Claude tracing backlogs can repeatedly serialize conversation history, consume a CPU core, and block hooks during daemon upgrades. Replay now checkpoints batches of up to 16 events, keeping inputs durable until their spans and matching state commit atomically. Status and shutdown respond during recovery.
Hooks capture with the running daemon before requesting an upgrade. They wait for durable acceptance without a capture timeout or handover retry cutoff. Only the maintenance request after successful capture has a bounded wait.
Addresses SDK-897.
Validated optimized replay of 1,600 synthetic turns in 10.4 seconds. The same workload previously took 55.9 seconds. Fault injection verifies failed batches retain all input and restart without duplicate output; the recovery-gate test verifies hook data is stored before handover while recovery is blocked. Translator, server, doctor tests, formatting, and strict all-target Clippy passed. The daemon keeps its listener available during draining so late hooks can retry through handover. Validation includes all 51 pipeline tests, replay/root-provenance tests, server tests, and strict all-target Clippy. Real desktop verification remains outstanding.