Repository navigation
Description
Problem
ErrorSim cannot test the thing it exists to test. Three structural reasons, none of which is the
error kind it simulates:
It replaces the client instead of decorating it. MauiProgram.cs:119-126 selects stubs with
#if CI / #elif ERROR_SIM, so fixtures and faults are mutually exclusive, and
FailingAniListClient answers all 23 of its IAniListClient methods with throw Fail(). Every call
fails, so you can never reach the screen whose error state you wanted to see. This blocked the
device pass on #120: the details-page error and retry states could not be verified because My Anime
and Discover died first, leaving nothing to navigate through. That path is covered by unit tests and
has never been seen on a device.
It injects below the HTTP pipeline. Sitting at IAniListClient bypasses
AniListRateLimitHandler, LoggingHandler, AniListClient.SendAsync's retry-once, and
AniListErrorClassifier. The code that actually handles real-world failure is precisely the code
ErrorSim cannot reach.
Changing the error costs a rebuild. FailingAniListClient.cs:24 is
private const ApiErrorKind SimulatedError. Roughly three minutes per variation, which is why it
doesn't get reached for.
What this makes untestable today
- Retry succeeding. With every call failing, Retry always fails again. The recovery path — on all
four details pages, plusFavouriteToggleRunner's rollback snackbar andListOperationRunner's —
has never run on a device. - Partial failure. Media details loading while
LoadMediaCharactersPageAsyncfails on Load More,
orDiscoverSectionssucceeding while a row'sBrowseAnimepaging fails. That is where
ListOperationRunner's swallow-and-snackbar contract lives. - Anything living in a timing window. Cancellation on navigate-away via
PageLoadScope, the
IsBusy/CanLoadMoreinterlocks, the Search and Discover debounce races. The CI stub returns
instantly, so on device those windows are zero-width. The six Replace hamburger flyout with a bottom tab bar (#43) #116 defects were all in this family. - Rate-limit handling. Rehearsing
AniListRateLimitHandler's adaptive spacing andRetry-After
path currently means actually getting 429'd by AniList.
Options
Recorded as the intended direction when this was filed, rather than as a settled design. It is the
shape that was subsequently built — see the #125 commits on
feature/125-130-132-fault-injection-name-language-lifecycle — so this section is now a record of
what was chosen, not an open question.
Two seams, because they test genuinely different things. Decorator first.
1. FaultInjectingAniListClient (decorator)
Wraps whichever IAniListClient is registered — CI stub or the real caching client — and decides per
call whether to fail, delay, or pass through. Composes with the fixtures, so you load a real screen
and then break the next call. Disarmed by default, so a build with it present behaves exactly like a
build without it.
The armed state:
sealed record FaultProfile(
string? OperationPrefix, // null = any; else e.g. "GetStudio"
ApiErrorKind Kind,
FaultScope Scope, // Next | EveryNth(n) | FirstN(n) | Always
TimeSpan Delay); // latency, independent of whether it failsDeterministic scopes only — no randomness. Next / EveryNth / FirstN / Always cover every
scenario worth arming and are reproducible by construction; a random fault you saw once is one you
cannot re-run. If chaos/soak testing ever justifies randomness, seed it then and log the seed.
Delay matters independently of failure: it is the only way to open the cancellation and interlock
windows listed above.
2. Fault-injecting DelegatingHandler (follow-up)
Injects synthetic 429 / 503 / timeout into the HTTP pipeline so the real
AniListRateLimitHandler, the SendAsync retry-once, and AniListErrorClassifier all run. Full
fidelity, and it rehearses the rate-limit path without spending budget against AniList. Needs the
real client and a signed-in session, so it does not compose with the CI fixtures — which is exactly
why it is the second seam rather than a replacement for the first.
3. Arm it over adb, not over a rebuild
A [BroadcastReceiver] (attribute-generated, no manifest editing) reads the profile:
adb shell am broadcast -a com.RainbowSprinkles.FAULT \
--es op GetStudio --es kind NotFound --es scope next
adb shell am broadcast -a com.RainbowSprinkles.FAULT --ez clear truedriver.ps1 gains fault <op> <kind> <scope> / fault clear, which is what turns error states from
a manual rebuild into three lines of the normal device pass — and lets the CI screenshot job capture
them, where today it only ever sees happy paths.
The receiver has to be exported for am broadcast to reach it. That is acceptable here: a Debug
build is already debuggable, so anyone with adb access can run-as the package regardless, and the
receiver cannot exist in Release.
4. Retire -p:ErrorSim=true
The flag exists because the current design makes a fault build useless for anything else. A decorator
that is disarmed by default removes that problem, so gate the machinery on plain #if DEBUG and drop
the flag, the _BlockErrorSimInRelease target (AniSprinkles.csproj:93-100), and the #elif ERROR_SIM arm. FailingAniListClient and SimAuthService both get deleted rather than ported: with
the decorator, data comes from the CI stubs or a real session, so neither has a job left.
This also removes the last rebuild from the loop — you arm faults in the build you are already
running.
Constraint
- Fault injection is armable and clearable at runtime with no rebuild, and defaults to off.
- With CI stubs plus an armed fault, each of the four details pages can be driven to its error state
and back to Content via Retry — thescope nextcase, which is what proves retry recovery works. Services/ErrorSimulation/no longer contains a whole-interface throwing stub.-p:ErrorSim=trueis gone fromAniSprinkles.csprojandAGENTS.md.driver.ps1 faultdocumented in/run-anisprinkles, and the fault verbs in/ani-debug.- Nothing in the fault path compiles into a Release build.
Related
- Extract the shared spine from the four details page models #120 — the details-page spine; its error/retry states are the immediate thing this makes verifiable
on device. - Replace hamburger flyout with a bottom tab bar (#43) #116 — the debounce/interlock defect family, which needs
Delayrather than failure to reproduce.
Activity
zhollis21 commentedon Aug 25, 2026
Verified against
fe4dbad(main, after #133 merged). Every claim in the body still holds; linenumbers have shifted since filing.
#if CI/#elif ERROR_SIM/#elseselection is nowMauiProgram.cs:128-150(body says:119-126).FailingAniListClient.cs:24is stillprivate const ApiErrorKind SimulatedError = ApiErrorKind.ServiceOutage;,and the file is 149 lines of
throw Fail()across the interface._BlockErrorSimInReleaseis atAniSprinkles.csproj:98-100, theERROR_SIMDefineConstantsPropertyGroupat:95-97.SimAuthService.csandFailingAniListClient.csare the only two files undersrc/AniSprinkles/Services/ErrorSimulation/.AniSprinkles.csproj:139-142is a secondDefineConstants;ERROR_SIMblock, but it is commentedout, as is the
CIone above it at:136-138.-p:ErrorSim=truehas a fourth reference the acceptance list does not name. The body asks for itto be gone from
AniSprinkles.csprojandAGENTS.md(AGENTS.md:86).DEVELOPER_NOTES.md:9-24is awhole section titled "Option 1:
ErrorSimbuild flag (recommended)" documenting the flag, the VSconditional-compilation-symbol alternative, both stub classes, and the edit-and-rebuild loop for
changing the error kind.
.claude/skills/project-architecture/SKILL.md:19andAGENTS.md:14both list"the CI/ErrorSim stubs" in the
src/AniSprinkles/description.Related, for ordering. #132 is a lifecycle bug whose repro needs a load held open long enough to
tab away mid-flight; the
Delayhalf of the proposedFaultProfileis the only way to open thatwindow on demand. #131 is the "nothing can catch pushed-page lifecycle bugs" issue.
Document that the fault op means a different thing per layer (#125, P…
Pin FaultState.Decide's atomicity under contention (#125, PR review)
Runtime fault injection, pushed-page lifecycle, and staff name langua…
zhollis21 commentedon Aug 27, 2026
Shipped in #135 (925d79f). Verified on main:
src/AniSprinkles.Core/Services/FaultInjection/contains both seams the issue asked for —FaultInjectingAniListClient.cs(decorator) andFaultInjectingHttpHandler.cs(HTTP layer) — plusFaultProfile.cs,FaultState.cs, andPlatforms/Android/FaultBroadcastReceiver.csfor arming at runtime.FailingAniListClient.csis deleted and the remaining ErrorSim mentions are comments recording its removal (AniSprinkles.csproj:93,MauiProgram.cs:124).Send the last five minutes of activity from the device, and stop NotF…
Runtime fault injection, pushed-page lifecycle, and staff name langua…
Send the last five minutes of activity from the device, and stop NotF…