feat(server): add bounded retention cursor windows#63
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
📝 WalkthroughWalkthroughChangesRetention GC windowing
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant RetentionGcApi
participant scanRowidWindow
participant SQLite
RetentionGcApi->>scanRowidWindow: request bounded rowid window
scanRowidWindow->>SQLite: ordered rowid seek query
SQLite-->>scanRowidWindow: rowids and window metadata
scanRowidWindow-->>RetentionGcApi: closed window and cursor
RetentionGcApi->>SQLite: prune or purge within closed window
SQLite-->>RetentionGcApi: deletion result
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8)packages/server/package.jsonTraceback (most recent call last): Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e55e85fc3f
ℹ️ 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 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 address that feedback".
| export type RetentionGcWindowScanResult = RetentionGcWindow & { | ||
| expiredCount: number; | ||
| /** D1 query metadata for the bounded rowid scan, when supplied by the executor. */ | ||
| meta?: RetentionGcRunMeta; |
There was a problem hiding this comment.
Keep the published scan result Node-neutral
RetentionGcWindowScanResult now explicitly exposes D1 query metadata from a published @relayauth/server API. This reintroduces a Cloudflare-shaped contract into the OSS package; keep the interface expressed in plain Node/SQL terms and put any D1-specific adapter behavior in the cloud repository instead.
AGENTS.md reference: AGENTS.md:L191-L193
Useful? React with 👍 / 👎.
| * The first statement is a rowid B-tree range seek. It efficiently crosses | ||
| * sparse rowid gaps without evaluating expiry predicates outside the returned | ||
| * window. Once cursorAfter is fixed, later inserts receive higher rowids and | ||
| * cannot enlarge the range; concurrent deletes can only shrink it. |
There was a problem hiding this comment.
Prevent rowid reuse from reopening closed windows
The claimed closed-range guarantee does not hold for these tables because their implicit SQLite rowids are not AUTOINCREMENT. If a concurrently running cleanup deletes the highest scanned row before another writer inserts, SQLite can assign that new row an id at or below cursorAfter; the later range delete can then remove an unscanned expired/backfilled row, and a live replacement can be skipped by subsequent cursors. Preserve candidate identities or use a transaction/snapshot rather than treating a rowid range as immutable.
Useful? React with 👍 / 👎.
Summary
The implementation has no Cloudflare imports, no MATERIALIZED planner-hint dependency, and uses 3 binds for token operations / 6 for audit operations (well below D1s 100-parameter limit). The 90-day audit default is unchanged.
Safety
Verification
Release gate
Owner merge and npm publish are required. Do not self-publish.