feat: resilient violation reporting — DB spool + cron retry (#7) - #25
Merged
Conversation
Upgrades the minimal shutdown-flush reporter from #5 to survive ingest outages without adding page latency. - New webdecoy_violation_queue table (activator + DB_VERSION 2.2.0, dropped on uninstall). Violations are spooled the moment they occur. - Delivery: on shutdown, fastcgi_finish_request() hands the response back to the client first, then a blocking batch POST drains the spool — so enforcement stays near-instant (tripwire hit → deny-list in seconds) with zero user-facing latency. - Resilience: failed batches are retried once then dropped; the queue is hard-capped at 1000 rows (oldest discarded) so a prolonged outage can't grow the table unbounded. A webdecoy_flush_violations cron (every 15 min) drains anything left behind. - clearance tokens survive the spool round-trip, so the tripwire→deny loop still works after a retry. - Cloud-gated: no API key -> no spooling, no reporting; rules still enforce. Verified drain success/retry-once/drop/recovery/hard-cap and clearance preservation with a stubbed $wpdb harness. Closes #7. Part of #16. Co-authored-by: Claude <noreply@anthropic.com>
15 tasks
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.
Upgrades the minimal shutdown-flush reporter (shipped with #5) into the resilient delivery pipeline #7 asks for — without adding page latency.
What changed
webdecoy_violation_queue(activator +DB_VERSION→ 2.2.0, dropped on uninstall). Violations are written the moment they occur.fastcgi_finish_request()hands the response back to the visitor first, then a blocking batch POST drains the spool. So enforcement stays near-instant (a tripwire hit reaches the deny-list in seconds) while the visitor waits for nothing.webdecoy_flush_violationscron (every 15 min) drains whatever the shutdown path couldn't.wd_clearancetoken survives the spool round-trip, so the tripwire → durable-deny loop still works even after a retry.Why a DB spool (not just fire-and-forget)
The P0 reporter used a non-blocking POST — fast, but it couldn't tell whether delivery succeeded, so a momentary ingest blip silently dropped detections. Spooling + a confirmed (blocking, post-response) send + cron retry makes delivery reliable without ever blocking the visitor.
Tests
Verified with a stubbed
$wpdb+ HTTP harness: enqueue, success clears the queue, clearance preserved through the spool, failure keeps the row and bumps attempts, drop after the retry, delivery on recovery before the drop, and the hard cap trimming overflow. Existing SDK suite still green (35 assertions).Closes #7. Part of #16.