Skip to content

feat(core): consent queue guardrails — size limits, drop telemetry, flush drain#12

Merged
tyssejc merged 1 commit intomainfrom
fix/consent-queue-guardrails
Mar 24, 2026
Merged

feat(core): consent queue guardrails — size limits, drop telemetry, flush drain#12
tyssejc merged 1 commit intomainfrom
fix/consent-queue-guardrails

Conversation

@tyssejc
Copy link
Copy Markdown
Owner

@tyssejc tyssejc commented Mar 24, 2026

Summary

Closes #5 — three related consent queue gaps identified during adversarial review:

  • Queue size limits: New maxQueueSize option on ConsentConfig. When exceeded, oldest events are dropped (drop-oldest strategy, consistent with ring buffer semantics).
  • Queue expiry telemetry: queue:drop event emitted with { count, reason: "timeout" | "overflow" } whenever events are lost. Feeds into debug panel and application monitoring.
  • Flush drains consent queue: flush() now drains the consent queue for any now-permitted events, not just the event buffer. Critical for page unload — the client calls flush() on pagehide, and previously queued events that gained consent would have been silently lost.

Files changed

  • packages/core/src/types.tsmaxQueueSize on ConsentConfig, queue:drop on CollectorEvent
  • packages/core/src/consent.tsonDrop listener, overflow enforcement in enqueue(), drop notification in cleanup timer
  • packages/core/src/collector.ts — wire queue:drop emission, enhance flush() to drain consent queue

Test plan

  • All 179 tests pass (10 new tests added)
  • Consent: drop telemetry on timeout expiry (emits count + reason)
  • Consent: drop telemetry on queue overflow (emits count + reason)
  • Consent: drop listener unsubscribe works
  • Consent: maxQueueSize drops oldest, preserves newest
  • Consent: no limit enforced when maxQueueSize not set
  • Collector: queue:drop event emitted on timeout
  • Collector: queue:drop event emitted on overflow
  • Collector: flush() dispatches consent-queued events when consent now granted
  • Manual: verify debug panel shows queue:drop events

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junctionjs Ready Ready Preview, Comment Mar 24, 2026 0:07am

…lush drain

Add maxQueueSize to ConsentConfig with drop-oldest overflow behavior.
Emit queue:drop events (with count and reason) when events are lost to
either timeout expiry or queue overflow, giving the debug panel and
application code visibility into data loss.

Enhance flush() to drain the consent queue for any now-permitted events.
This is critical for page unload: the client calls flush() on pagehide,
and previously queued events that gained consent would have been lost.

Closes #5

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tyssejc tyssejc force-pushed the fix/consent-queue-guardrails branch from d0eda3e to ffa010f Compare March 24, 2026 12:06
@tyssejc tyssejc merged commit cc7d872 into main Mar 24, 2026
6 checks passed
@tyssejc tyssejc deleted the fix/consent-queue-guardrails branch March 24, 2026 18:14
@github-actions github-actions bot mentioned this pull request Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core: page unload flush, queue size limits, queue expiry telemetry

1 participant