Skip to content

Wave B: per-action throttling with safety hardening#26

Merged
noelsaw1 merged 2 commits into
mainfrom
wave-b-per-action-throttling
May 7, 2026
Merged

Wave B: per-action throttling with safety hardening#26
noelsaw1 merged 2 commits into
mainfrom
wave-b-per-action-throttling

Conversation

@noelsaw1
Copy link
Copy Markdown
Contributor

@noelsaw1 noelsaw1 commented May 7, 2026

Summary

  • start Wave B by wiring the priority registry into runtime Action Scheduler throttle decisions
  • defer lower-priority actions from action_scheduler_before_execute using a filterable load-level x priority-tier delay matrix
  • document the initial Wave B behavior and its current before-execute caveat

Notes

Validation

  • php -l hypercart-query-guard.php
  • php -l class-hcqg-load-monitor.php
  • php -l class-hcqg-priority-registry.php
  • git diff --check

@noelsaw1 noelsaw1 force-pushed the wave-b-per-action-throttling branch from 1fec837 to dbb4c59 Compare May 7, 2026 03:25
Address the QA red flags raised on the initial Wave B per-action throttle:

- Skip the action_scheduler_before_execute registration in test_observe so
  capability-probe mode does not pay per-action DB cost.
- Refuse to defer recurring schedules. Cancelling a recurring instance
  breaks AS's recurrence chain, and re-rooting it at now+delay silently
  shifts the cadence (and for cron schedules can drop a tick entirely).
- Cap deferrals per (hook, args, group) at 5 by default, filterable via
  hypercart_query_guard_max_defer_count, so a deferrable action under
  sustained critical load eventually runs instead of starving.
- Guard ActionScheduler_Action::get_priority/set_priority with method_exists
  so sites on AS < 3.7 (older bundled WooCommerce) no longer fatal.
- Log as_action_defer_failed on the save_action-returns-zero path, not
  just on exceptions.
- Dedupe observe-mode as_action_deferred records by (hook, level) per
  request to bound log volume during sustained load.
- Document the action_delay_matrix filter contract — override-existing-cells
  only; unknown levels and tiers are dropped; values clamp to non-negative
  integers.

Tests: extend the bootstrap to load the main plugin file with both modes
forced off so init() bails, and add ActionThrottleTest covering the matrix
filter contract, get_action_delay_seconds boundaries, and the defer-count
helpers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@noelsaw1 noelsaw1 changed the title Start Wave B per-action throttling Wave B: per-action throttling with safety hardening May 7, 2026
@noelsaw1 noelsaw1 merged commit 5f4f5ec into main May 7, 2026
@noelsaw1 noelsaw1 deleted the wave-b-per-action-throttling branch May 7, 2026 03:36
noelsaw1 added a commit that referenced this pull request May 7, 2026
Move the original P1-PRIORITY-CC-AS planning doc from 1-INBOX to 3-DONE
with a completion header mapping its phases to shipped waves: Phase 1
to Wave A (PR #25), Phase 2 to Wave B (PR #26), Phase 3 carved out into
the new Wave C design doc.

Add PROJECT/2-WORKING/P1-MUTEX-GUARD.md, the Wave C design for a third
subsystem that prevents thundering-herd patterns by deduplicating
concurrent invocations of the same operation. The doc captures storage
decisions (wp_options + autoload no, atomic INSERT...ON DUPLICATE KEY
UPDATE with PHP-anchored time, expires_at|nonce delimited value, md5
key hashing), the four-method API with reentrancy and TTL semantics,
explicit caller patterns, contention-only logging defaults, and a
phased rollout with checklists. Phase 1 ships the smallest thing that
solves the NoFraud admin_init herd; Phase 2 is gated on production
evidence.

Drop empty placeholder files and the unused AGENTS-NAV-CMS.md as part
of folder cleanup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant