feat: recover restart gaps when tail connects - #219
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 6:12 PM ET / 22:12 UTC (Revision 2). ClawSweeper reviewWhat this changesAdds opt-in startup catch-up for Discord capture, preserving history cursors while live messages arrive and reusing the existing repair lifecycle. Merge readiness✅ Ready for maintainer review The previous cursor-race finding is resolved, and no remaining blocking defect was found. Startup catch-up remains distinct from current main and the latest release; this member-authored PR should remain available for landing. Priority: P2 Review scores
Verification
How this fits togetherDiscrawl archives Discord Gateway events and REST history into a local SQLite database. Startup repair fetches missed history while live capture continues, using the same archive owner. flowchart TD
A[Tail command options] --> B[Connect Discord Gateway]
B --> C[Archive ownership ready]
C --> D[Serialized REST catch-up]
B --> E[Live message capture]
D --> F[SQLite archive and history cursor]
E --> G[Archive messages and live freshness]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep startup catch-up opt-in, with REST owning history progress and live capture retaining immediate archive writes. Do we have a high-confidence way to reproduce the issue? Not applicable as a feature request: current main visibly waits for periodic repair. The earlier patch defect is addressed by the revised source and targeted regression tests; this review did not execute them. Is this the best way to solve the issue? Yes. Reusing serialized repair and preserving REST history progress addresses the earlier race without a second checkpoint format or changes to existing defaults. AGENTS.md: not found in the target repository. Codex review notes: model internal, reasoning medium; reviewed against 0f35f710441b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Additional instructions
Keep Allow edits from maintainers enabled.
What Problem This Solves
Fixes an issue where users restarting
discrawl tailafter downtime can wait until the next periodic repair for missed messages to appear. A six-hour repair interval can leave that history gap for hours, requiring an external pre-start sync.Why This Change Was Made
Add opt-in
tail --repair-on-start. After the Gateway connects and the existing ownership-ready callback succeeds, request one immediate latest-only repair through the existing serialized repair lifecycle. Capture remains connected during REST catch-up, and both use the same archive writer owner. Shutdown cancels and joins the repair through the existing bounded cleanup path.In this opt-in mode, REST alone advances history cursors for the lifetime of the tail; live events still update messages and live freshness immediately. A new live message therefore cannot mark offline history as fetched, and an interrupted owner leaves a recoverable cursor for the next startup. This reuses existing state without another cursor or checkpoint.
User Impact
Service managers can start Discrawl directly and recover restart gaps without a separate sync process. Default behavior is unchanged. Repairs in the new mode may re-fetch already captured messages because history progress belongs to REST. The option also works with
--repair-every 0for startup-only repair and rejects replay-only mode.Evidence