Add security agent auto-analysis queue system#625
Open
jeanduplessis wants to merge 5 commits intomainfrom
Open
Add security agent auto-analysis queue system#625jeanduplessis wants to merge 5 commits intomainfrom
jeanduplessis wants to merge 5 commits intomainfrom
Conversation
Contributor
Code Review SummaryStatus: No New Issues Found | Recommendation: Address existing review comments, then merge OverviewThis is a large, well-structured PR that introduces a new Cloudflare Worker ( The previous review rounds (72 inline comments) identified and addressed a comprehensive set of issues including:
All flagged issues appear to have been addressed in subsequent commits. No new issues were identified in this review pass. Files Reviewed (48 files)
|
71a84d0 to
7e56799
Compare
src/app/api/internal/security-analysis-callback/[findingId]/route.ts
Outdated
Show resolved
Hide resolved
7e56799 to
e929176
Compare
3289a11 to
fdf5974
Compare
8d45b7d to
c2670ca
Compare
c2670ca to
8e07fb9
Compare
71ee7d0 to
bbc9f85
Compare
bbc9f85 to
e366fc3
Compare
545453e to
7097c84
Compare
41a79e2 to
47f9d7f
Compare
alex-alecu
approved these changes
Mar 3, 2026
Cloudflare Worker that automatically triages and analyzes security findings via a queue-based pipeline. Dispatches due owners on a cron schedule, claims queued findings per-owner with pessimistic locking, runs LLM triage to filter noise, then launches full analysis sessions via cloud-agent-next. Uses @kilocode/db with Drizzle ORM for all database access through Hyperdrive, matching the cloudflare-security-sync reference pattern. Includes DB migration for security_analysis_queue and security_analysis_owner_state tables, plus indexes on security_findings for in-flight analysis tracking.
47f9d7f to
616f9dd
Compare
- Wrap finalizeAnalysis in try/catch so queue transitions to 'failed' on throw - Widen transitionAutoAnalysisQueueFromCallback to match 'pending' OR 'running' - Document fallback CTE previousStatus limitation during concurrent insert races
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cloudflare-security-auto-analysis) that dispatches due owners on a per-minute cron, claims queued findings with pessimistic locking (FOR UPDATE SKIP LOCKED), runs LLM triage to filter noise, then launches full analysis sessions viacloud-agent-nextsecurity_analysis_queueandsecurity_analysis_owner_state(migration 0038)Architecture
The worker connects to Postgres via Hyperdrive using
@kilocode/db+ Drizzle ORM (matching thecloudflare-security-syncreference pattern). It uses CF service bindings tocloud-agent-next(for launching analysis sessions) andgit-token-service(for repo access). A dead letter queue captures permanently failed messages.Pipeline flow:
sync-service.ts) whenauto_analysis_enabledis true and the finding meets theauto_analysis_min_severitythresholdcloud-agent-next, withInsufficientCreditsErrorhandling that blocks the owner and requeues remaining workConfig
auto_analysis_enabled(default:false) andauto_analysis_min_severity(default:'high') on the security agent configauto_analysis_enabled_attimestamp onsecurity_analysis_owner_stateprevents retroactive analysis of old findingsOther changes
user.ts/user.test.ts)docs/security-auto-analysis-runbook.md)FlatCompatimport from rooteslint.config.mjsPost-deployment
No manual steps required. Migration 0038 runs automatically via the
run-migrationsjob. Secrets, Hyperdrive, and service bindings are all shared resources that already exist. The feature is gated behindauto_analysis_enabled(defaults tofalse), so the cron will be a no-op until an owner opts in.Verify after first deploy:
security-auto-analysis-owner-dlqand-dlq-dev). Wrangler should auto-create them, but if not: