From 6a20fb42ab4ba3121eabae435350a14fadf61e24 Mon Sep 17 00:00:00 2001 From: Arnel Robles Date: Mon, 16 Nov 2026 22:20:18 +0800 Subject: [PATCH 1/3] add failure backoff, opt-in cache sweep, and Umbraco 18 publish leg --- .github/workflows/publish-nuget.yml | 10 +- CHANGELOG.md | 15 ++ README.md | 29 +++ .../AzureSpeechEngine.cs | 11 +- .../Caching/AudioCacheSweepService.cs | 101 ++++++++ .../Caching/CoalescingAudioSource.cs | 137 ++++++++++ .../Caching/DiskAudioCache.cs | 42 ++- .../Caching/IAudioCacheSweep.cs | 14 + .../Engine/SynthesisRejectedException.cs | 34 +++ .../ReadAloudComposer.cs | 1 + .../ReadAloudOptions.cs | 42 +++ .../CacheSweepTests.cs | 140 ++++++++++ .../FailureBackoffTests.cs | 243 ++++++++++++++++++ 13 files changed, 811 insertions(+), 8 deletions(-) create mode 100644 src/BaryoDev.Umbraco.ReadAloud/Caching/AudioCacheSweepService.cs create mode 100644 src/BaryoDev.Umbraco.ReadAloud/Caching/IAudioCacheSweep.cs create mode 100644 src/BaryoDev.Umbraco.ReadAloud/Engine/SynthesisRejectedException.cs create mode 100644 tests/BaryoDev.Umbraco.ReadAloud.Tests/CacheSweepTests.cs create mode 100644 tests/BaryoDev.Umbraco.ReadAloud.Tests/FailureBackoffTests.cs diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 2ca169f..d736940 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -201,16 +201,16 @@ jobs: # A package must never ship without its tests having run, on every framework it ships for. # The package targets net9.0 and net10.0. The test project picks its framework from - # UmbracoVersion (16 is net9.0, 17 and 18 are net10.0), so one run per framework: 16.5.1 - # for net9.0 and 17.6.1 for net10.0, the same versions ci.yml pins. Each run must produce + # UmbracoVersion (16 is net9.0, 17 and 18 are net10.0), so one run per Umbraco major: 16.5.1 + # for net9.0, 17.6.1 and 18.1.0 for net10.0, the same versions ci.yml pins. Each run must produce # a trx with at least 65 passing tests (the floor ci.yml uses) and a bin folder for the # framework it claims, so zero discovered tests or a wrong framework fails the publish. - name: Test the package on every shipped framework run: | - for LEG in 16.5.1:net9.0 17.6.1:net10.0; do + for LEG in 16.5.1:net9.0 17.6.1:net10.0 18.1.0:net10.0; do UMBRACO=${LEG%%:*} FRAMEWORK=${LEG##*:} - RESULTS="$GITHUB_WORKSPACE/testresults/$FRAMEWORK" + RESULTS="$GITHUB_WORKSPACE/testresults/$UMBRACO" echo "::group::Umbraco $UMBRACO on $FRAMEWORK" dotnet test tests/BaryoDev.Umbraco.ReadAloud.Tests \ --configuration Release \ @@ -224,7 +224,7 @@ jobs: echo "::error::Expected $FRAMEWORK test output for Umbraco $UMBRACO" && exit 1 } scripts/assert-tests-ran.sh "$RESULTS/results.trx" 65 || { - echo "::error::The $FRAMEWORK test run did not meet the floor." && exit 1 + echo "::error::The Umbraco $UMBRACO test run did not meet the floor." && exit 1 } done diff --git a/CHANGELOG.md b/CHANGELOG.md index 44468d6..1f181f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,21 @@ and [semantic versioning](https://semver.org). ## [Unreleased] +### Added + +- Failure backoff. After a synthesis fails, the same text skips the speech service for + `FailureBackoffSeconds` (30). A rejected Azure key backs off every request for + `AuthFailureBackoffSeconds` (300), and a 429 for its Retry-After (capped at 300 seconds) or + `FailureBackoffSeconds`. Both validated at startup, 0 turns them off. New public + `SynthesisRejectedException` and `SynthesisFailureKind` let an engine report these cases. +- Opt-in cache sweep. `CacheMaxAgeDays` (unset by default) deletes cached audio last written + longer ago than that, once a day, in batches. New optional `IAudioCacheSweep`, implemented by + `DiskAudioCache`. `IAudioCache` is unchanged (#5). + +### Changed + +- The publish workflow also tests Umbraco 18.1.0, as ci.yml does. + ### Fixed - Text extraction no longer takes quadratic time on a page with many unclosed `