Repository navigation
feat: dry run covers the full selected window — background drain (backend) - #119
Conversation
🤖 CodeAnt AI — Review Status
|
✅ Deploy Preview for moderaty ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Sequence DiagramThe dashboard previews the first page of a selected comment window and stores continuation state when more pages remain. Later cron runs continue one drain page after the normal channel run, rescoring previously moderated comments until the window completes. sequenceDiagram
participant User
participant Dashboard
participant Backend
participant YouTube
participant Storage
participant Cron
User->>Dashboard: Start dry run with month window
Dashboard->>Backend: Claim channel and request first window page
Backend->>YouTube: Fetch comments bounded by window
YouTube-->>Backend: Return comment page
Backend->>Storage: Save preview audits and drain state
Backend-->>Dashboard: Return preview counts and background status
Cron->>Backend: Run normal channel scan
Backend->>Backend: Drain one preview page
Backend->>YouTube: Fetch next window page and rescore comments
Backend->>Storage: Update continuation or clear completed drain
Generated by CodeAnt AI |
There was a problem hiding this comment.
The implementation successfully addresses the dry-run audit issue by enabling full historical window previews. The changes are well-architected with proper separation of concerns:
Key Strengths:
- Database migration properly adds independent dry-run state tracking (
dryRunBoundary/dryRunPageToken) - Window mode correctly bypasses stored-ID deduplication via the
rescoreflag, enabling re-scoring of already-moderated comments - Background drain continuation is properly isolated from live cursor state
- Comprehensive test coverage (953 tests passed, 0 errors/warnings)
- Proper concurrency control with atomic lease claims prevents race conditions
- Cron prioritizes channels with active drains to prevent starvation
Architecture:
The implementation correctly separates dry-run window state from live moderation, ensuring real runs continue undisturbed while previews drain in the background. The window boundary validation limits cost exposure (presets: 1,3,6,12,24 months), and the shared deadline prevents runaway operations.
No blocking defects identified. The feature is ready for merge.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
🏁 CodeAnt Quality Gate ResultsCommit: ✅ Overall Status: PASSEDQuality Gate Details
|
PR Summary by QodoDry-run window preview with background drain and independent continuation
AI Description
Diagram
High-Level Assessment
Files changed (13)
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | ✅ 59 (≤ 100 complexity) |
| Duplication | ✅ 0 (≤ 1 duplication) |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
PR Code Suggestions ✨Previous suggestions up to commit
|
| Category | Suggestion | Severity | Generated at (UTC) |
| Performance |
Shared deadline can starve the dry-run drain after an expensive normal runThe normal run and the drain share the same deadline, but the normal run always src/routes/api/cron/+server.ts [107-111] Why it matters? 🤔
(Use Cmd/Ctrl + Click for best experience) Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** src/routes/api/cron/+server.ts
**Line:** 107:111
**Comment:**
*Performance: The normal run and the drain share the same deadline, but the normal run always executes first. If it consumes the 20-second budget, the drain starts after its deadline and returns partial without a continuation, so the prioritized preview can make no progress on every invocation. Reserve budget for the drain or run the drain independently with an appropriate deadline.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix | Major | 2026-08-06 10:52
|
Latest suggestions up to commit 11398d8
| Category | Suggestion | Severity | Generated at (UTC) |
| Logic error |
Failed window pages can create duplicate dry-run audit records on retryWindow-mode audit rows are inserted before the src/lib/server/pipeline.ts [626-637] Why it matters? 🤔
(Use Cmd/Ctrl + Click for best experience) Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** src/lib/server/pipeline.ts
**Line:** 626:637
**Comment:**
*Logic Error: Window-mode audit rows are inserted before the `failures` check. If one comment decision fails, `runChannel` throws after auditing the successful decisions, so the caller leaves the same page token in place; the next retry rescoring that page inserts duplicate dry-run audit rows for those comments. Make the audit insertion and failure handling atomic, or ensure successful decisions from a failed page cannot be persisted before retry.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix | Major | 2026-08-06 11:28
|
Code Review by Qodo
1.
|
… previews replace the in-flight drain
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesDry-run preview continuation
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant Dashboard
participant Pipeline
participant Channels
participant Cron
Dashboard->>Pipeline: run dry-run window page
Pipeline-->>Dashboard: decisions and continuation state
Dashboard->>Channels: persist boundary and page token
Cron->>Channels: select pending dry-run channel
Cron->>Pipeline: drain one bounded page
Pipeline-->>Cron: next token or completion
Cron->>Channels: persist token or clear state
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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 |
|
Triage summary — all review feedback addressed: @qodo-code-review[bot] — both findings valid, fixed in 3774b9a (failing tests first):
Codacy (10 new code clones): fixed in 11398d8 — extracted shared helpers in the three touched test files ( @CodeRabbit / Amazon Q: review noted, no blocking defects — thanks. Snyk (code/snyk: "Code test limit reached"; security/snyk): the code check is a quota limit, not a finding, and security/snyk fails identically on dependency-free PRs — please check the Snyk dashboard org settings; this remains a repo-level config issue, not something this PR can fix. Gate before push: 955 tests passing, Merge note: this PR carries migration 0019 ( |
|
Tip For best results, initiate chat on the files or code changes.
Before production traffic reaches the updated service, run ✏️ Learnings added
You are interacting with an AI system. |
The two actionable Qodo findings are addressed: finding 1 and finding 2 are marked implemented, and the described safeguards cover the reported cases. One review item remains open: finding 3 is still pending and concerns spaces used for indentation in The reported test, check, and build results—and the Snyk quota/configuration issue—can be treated as merge-gate context. The migration/deploy-guard sequencing note is also clear: apply migration |
There was a problem hiding this comment.
Warning
CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.
Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/routes/api/cron/`+server.ts:
- Around line 112-122: Update the completed-window branch in the drain handling
to restrict the `dryRunBoundary`/`dryRunPageToken` reset to the channel’s
currently active dry-run boundary, adding that predicate alongside the existing
channel ID condition. Keep the incomplete-window token update unchanged so an
abandoned drain cannot clear replacement preview state.
In `@src/routes/api/cron/cron.test.ts`:
- Line 416: Update the test around the console.error spy to assert the exact
drain log message emitted by the cron handler, rather than only verifying that
console.error was called. Match the established exact-message assertion style
used by the nearby tests and the message produced in the cron server’s drain
path.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: b55dd0da-2d72-4dc1-947d-7e0d0042ab37
📒 Files selected for processing (13)
AGENTS.mddrizzle/0019_channels_dry_run_window.sqldrizzle/meta/0019_snapshot.jsondrizzle/meta/_journal.jsonsrc/lib/server/db/schema.test.tssrc/lib/server/db/schema.tssrc/lib/server/pipeline.test.tssrc/lib/server/pipeline.tssrc/lib/server/testdb.tssrc/routes/(app)/dashboard/+page.server.tssrc/routes/(app)/dashboard/actions.test.tssrc/routes/api/cron/+server.tssrc/routes/api/cron/cron.test.ts
…oundary (replant race)
… drain-failure log message
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
|
Triage update — round 2 review feedback addressed: @coderabbitai — both findings valid, fixed (failing tests first):
Codacy: now green ("up to standards") — the remaining clones were collapsed via Snyk (security/snyk): still failing — unchanged recurring repo-level issue; this PR touches no dependencies. Please check the Snyk dashboard org settings. Gate: 957 tests passing, |
|
Tip For best results, initiate chat on the files or code changes.
The reported test, check, build, and third-party review results are noted. The remaining Snyk failure is a repository-level configuration issue and is not caused by this PR. 🐇 ✅ If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! You are interacting with an AI system. |
|
Consolidation note (maintainer decision): to cut Netlify production-deploy credit spend, this repo is moving to a single- |



User description
What
Fixes the audited no-op: the dry-run preview fetched with the live
cursorand deduped against storedcommentsids, so on any channel with moderation history it wrote nothing. The dry run now covers all comments over a selected time period — including comments real runs already moderated.channels.dry_run_boundary/dry_run_page_token(nullable; both null = no drain in flight). Independent of the live cursor — real runs keep advancing undisturbed. Applied + PRAGMA-verified on dev (20 migrations). (Note:history_next_page_token/history_boundaryfrom Live-first scanning during long history drains #70 are dead columns — nothing on main reads them; dropping them is DB-lane, out of scope.)runChannelwindow mode —window: { boundary, pageToken }withforceDryRun: fetches one page bounded by the window (cursor/checkpoint ignored,maxPagesforced to 1), anddecideNewCommentsgainsrescorewhich skips the stored-IDs dedupe (within-batch dedupe stays). ReturnswindowNextPageToken/windowComplete; persists nothing itself (I8).dryRunaction — validatesmonths∈ {1,3,6,12,24} (default 3, same presets as Analyze history), scores the first page synchronously under the atomic lease, and persists the drain continuation (or clears it when the window completes). Response gainsmonthsandbackground.Out of scope (frontend lane follow-up)
<select>on the dry-run form (same presets, default 3) — backend accepts/defaultsmonths, so the shipped button already works with the 3-month window.Verification
npm run test: 953 passed — new failing-first tests: window fetch semantics + rescore + continuation (pipeline), months validation/default/drain-state persist/reset (dashboard), drain continuation/clear/rotation-order/failure-isolation (cron).npm run check: 0 errors / 0 warnings.npm run build: green.CodeAnt-AI Description
Extend dry-run previews across a selected comment history window
What Changed
Impact
✅ Complete previews across the selected history window✅ Existing moderated comments included in dry-run results✅ Live moderation cursor remains undisturbed💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.