Skip to content

Failure backoff, opt-in cache sweep, Umbraco 18 publish leg - #36

Merged
arnelirobles merged 3 commits into
mainfrom
decisions/backoff-sweep-gate
Nov 16, 2026
Merged

arnelirobles merged 3 commits into
mainfrom
decisions/backoff-sweep-gate

Conversation

@arnelirobles

@arnelirobles arnelirobles commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Adds failure backoff (R4), an opt-in cache age sweep (R6), and an Umbraco 18 leg in the publish gate (R8). No public member or signature changed.

What changed

  • CoalescingAudioSource remembers failures. A failed key skips the engine for FailureBackoffSeconds (30) and gets the same 503. Auth failure (401/403) backs off all keys for AuthFailureBackoffSeconds (300), logged once per window. A 429 backs off all keys for Retry-After (capped at 300 s), else FailureBackoffSeconds. Failure map is capped at 1000 keys, expired entries dropped first, then the oldest evicted.
  • CacheMaxAgeDays (null default). A hosted service sweeps once a day in batches of 500 through a new optional IAudioCacheSweep, which DiskAudioCache implements. IAudioCache is untouched.
  • publish-nuget.yml tests 16.5.1 (net9.0), 17.6.1 and 18.1.0 (net10.0). Results folder is now per Umbraco version, since 17 and 18 share a framework.
  • README and CHANGELOG updated. Options validated at startup.

Design calls

  • Per-key backoff only for plain failures. Auth and 429 are global, because they say nothing about one text.
  • New public SynthesisRejectedException (subclass of InvalidOperationException, so existing catches still work) and SynthesisFailureKind. The Azure engine uses it for AuthenticationFailure, Forbidden and TooManyRequests. The Speech SDK gives no Retry-After, so Azure 429 uses FailureBackoffSeconds. A custom engine can pass RetryAfter, and an HttpRequestException with 401, 403 or 429 is also recognised.
  • Backoff state is in memory, per process. Cache hits are still served during a backoff. A request that finds an attempt already running joins it.
  • 0 turns each backoff off. Range 0 to 86400.
  • Sweep uses last write time, since the disk cache does not record reads. It only deletes files named like cache entries (64 hex, .mp3 or .json), so a wrong CachePath cannot cost other files. Stale .tmp files are left alone.
  • Sweep starts 5 minutes after boot, then daily.
  • CoalescingAudioSource keeps its public 4-argument constructor. A new internal one takes a TimeProvider for tests.
  • Workflow edit changed values only, no keys added, so no duplicate keys.

Proof

  • dotnet build tests/BaryoDev.Umbraco.ReadAloud.Tests -c Release: 0 Error(s)
  • New tests: FailureBackoffTests, CacheSweepTests. Not run locally (queue-only rule); CI runs them.
  • Mutation check: not run, see below.

Round 2

  • CI failed 4 Azure tests because AzureSpeechAdmin took CoalescingAudioSource, which builds IAudioCache and validates ReadAloudOptions before a key is stored. The admin now takes a new internal BackoffResetSignal with no dependencies and calls Reset() after save and remove. CoalescingAudioSource compares the signal's generation at the start of each request and clears the global window and per-key map when it changed.
  • The public 4-argument constructor is unchanged. The composer builds the source through the internal constructor so it shares the signal.
  • New test: resolving the admin with Provider Azure and no region or key does not throw.
  • Build: dotnet build tests/BaryoDev.Umbraco.ReadAloud.Tests: 0 Error(s). Tests not run locally; CI runs them.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@arnelirobles
arnelirobles marked this pull request as ready for review November 16, 2026 14:37
@arnelirobles
arnelirobles merged commit 947e031 into main Nov 16, 2026
5 checks passed
@arnelirobles
arnelirobles deleted the decisions/backoff-sweep-gate branch November 16, 2026 14:37
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