Skip to content

Runtime fault injection, pushed-page lifecycle, and staff name language (#125, #132, #130) - #135

Merged
zhollis21 merged 8 commits into
mainfrom
feature/125-130-132-fault-injection-name-language-lifecycle
Aug 26, 2026
Merged

zhollis21 merged 8 commits into
mainfrom
feature/125-130-132-fault-injection-name-language-lifecycle

Conversation

@zhollis21

@zhollis21 zhollis21 commented Aug 26, 2026 •

Copy link
Copy Markdown
Owner

Three issues, one theme in two of them: things that could not be observed — an error state
you could never reach, a lifecycle hook that never fired — plus one setting that was saved
and never read.

Each issue is its own commit (plus one for review feedback), and each builds and tests green on
its own (verified in a throwaway worktree, not assumed). 984 unit tests, zero warnings on the
test, Core, Debug and CI builds.

Every claim below was measured on a device or against the live API. Two of them contradict
what the issues assumed, and one contradicts what I had already written down.

#125 — fault injection replacing ErrorSim

ErrorSim could not test the thing it existed to test. It replaced the client instead of
decorating it, so FailingAniListClient answered all 23 interface methods with throw and
every call failed — you could never reach the screen whose error state you wanted. That is why
the details pages' error and retry states had never been exercised on a device.

Two seams share one disarmed-by-default FaultState:

  • FaultInjectingAniListClient decorates whichever client DI selected, so it composes with
    the CI fixtures: a real screen loads and the next call breaks. scope next is what makes
    Try Again genuinely recover.
  • FaultInjectingHttpHandler sits innermost in the pipeline, so a synthetic 429 or 503 is
    processed by the real AniListRateLimitHandler, LoggingHandler, SendAsync retry-once and
    AniListErrorClassifier.

A profile names which layer it fires at. Both seams share one state, so without that tag a
single armed fault would fire twice for one logical call — not something the issue anticipated,
because it did not anticipate both seams coexisting.

Delay is independent of failure: latency with no error kind is the only way to open the
cancellation and interlock windows #116's defect family lives in. Scopes are deterministic
only — a fault you cannot re-run is not a fixture.

Armed over adb (driver.ps1 fault), so changing what fails costs a broadcast rather than a
~3 minute rebuild. All of it is behind #if DEBUG, including the exported receiver, which is
why -p:ErrorSim=true and its Release guard are gone. Verified absent from every Release
manifest; the receiver also references four #if DEBUG types, so removing one guard is a
compile error rather than a silent ship.

Found on device: after Retry restored a page to Content, the global outage banner stayed
up. The banner is sticky and normally clears via AniListClient's ReportSuccess, which never
runs behind the fixtures — so an injected outage pinned it for the session and made recovery
look broken. The decorator now clears an outage it raised, gated on having raised it: it sits
above CachingAniListClient and cannot tell a cache hit from a round-trip, so reporting success
unconditionally would let a cache hit clear a genuine banner.

All six HTTP scenarios were driven against a real signed-in session — both branches of the
rate-limit handler, SendAsync's retry-once on AniList's real 400-with-"Invalid token" shape,
a 200-with-errors body, and a thrown HttpRequestException. Faulted requests never leave the
device (2–3ms), so the pass cost about five real calls.

#132 — pushed pages never cancelled on a tab switch

OnDisappearing never fires on the five pushed pages when the tab changes, so
CancelInFlight() and _loader.OnDisappearing() did not run. Tab away mid-load and the fetch
plus any Load More ran to completion — spending rate-limit budget on a page the user had left —
and PageLoadScope was never cancelled, making the guards written against it inert on that path.

Measured rather than assumed. The navigation hooks are a strict superset:

path OnAppearing OnDisappearing OnNavigatedTo OnNavigatedFrom
initial navigation yes — yes —
tab away (pushed) — NO — yes
tab back (pushed) NO — yes —
forward nav to sub-page — yes — yes
back nav from sub-page yes — yes —
sort popup open — yes — yes
sort popup close yes — yes —
tab-root page (Settings) yes yes yes yes

That answered both open questions on the issue: the popup fires both pairs, so moving the
cleanup leaves the popup, forward-nav and back-nav paths behaving exactly as before.

The naive fix would have been worse than the bug. DeferredContentLoader.OnDisappearing
clears _hasAppeared, which gates both IsCurrent and TrySchedule. Moving the cleanup
without a matching re-arm latches the loader off after one tab round-trip and leaves the page
on its spinner forever. The two must stay paired.

Verified with an armed delay: a load cancelled at 6308ms of an 8000ms delay on tab-away, and
tabbing back re-armed and completed it. Tab-root pages are unaffected, so SettingsPage's
pending-save flush (#118, #128) still runs.

#130 — Staff Name Language saved but never read

Both accessors were Name?.Full ?? …, so Full always won and every name rendered identically
whatever the viewer picked.

The issue proposed composing the name locally from first/last. That was implemented, then
abandoned on evidence
gathered against a real account:

  • full is not a stable western-order field. AniList resolves it server-side against the
    viewer setting, exactly like userPreferred. Staff id 113181 is "Taiki Kawakami"
    unauthenticated and "Kawakami Taiki" on an account set to ROMAJI. Composing Romaji Western
    from full renders family-first for those users — the app could not have shown western order
    at all. Invisible to CI stubs and to unauthenticated queries.
  • AniList is not internally consistent. Under ROMAJI, a Latin-script name returns
    full="Bairstow Caitlyn" but userPreferred="Caitlyn Bairstow". userPreferred is
    script-aware; full is not. Any local last first rule diverges from anilist.co for every
    western voice actor.

So the question defers entirely to userPreferred, falling back to full then native.
All eleven name { … } selections request it — the issue named two; the other nine are
every name appearing in a list rather than as a page hero, and either proposed option would
have left them behind.

The cost is a refetch rather than a re-projection, accepted for a setting changed rarely if
ever: IAniListClient.InvalidateEntityCache() drops the cached character/staff/studio reads and
pages reload lazily as the user navigates back to them. It fires for an upstream change too —
the website or another device — which arrives through PopulateFromUser rather than the changed
handler.

Verified on a real account with the setting on ROMAJI: Japanese names stay flipped
(Hoshiki Seena), Latin ones no longer are (Caitlyn Bairstow, Karina Fonseca) — matching
anilist.co exactly.

Also fixes CIAniListClient.UpdateUserAsync, which returned the untouched static viewer
instead of echoing the request, so every Display Preferences change reverted on the next
Settings load and the whole section was unverifiable in a CI build. DisplayAdultContent stays
unechoed so the adult-content canary cannot be flipped from inside the app.

Follow-ups

Review feedback addressed

fault <op> was documented everywhere as an IAniListClient method prefix. That is only true at
the client seam — the HTTP seam parses the GraphQL operationName out of the request body, so
fault GetStudio ... -layer http matched nothing and read as a broken seam rather than a
targeting mistake. Every HTTP scenario in the device pass used op any, which is why it was not
caught.

No normalisation is attempted, because none would work: stripping Get/Load/Async lines up
GetStudioAsync with Studio, but GetMyAnimeListAsync is MediaListCollection over the wire
and SearchAnimePageAsync is Search. So the rule is stated in all five places that document it,
and the handler logs FAULT http no match naming the operation it actually saw when an armed
targeted profile misses. Two tests pin the distinction.

A second comment held that lock on a System.Threading.Lock boxes per use and so synchronises
nothing. It does not: Lock is a sealed class, and C# 13 lowers lock on it to
using (x.EnterScope()) rather than Monitor.Enter. Converting one to object — the suggested
remedy — is precisely the case warning CS9216 exists to catch, and this branch builds warning-free.
No production change, but FaultStateConcurrencyTests now pins the invariant: next fires once
across 64 racing callers, firstn:10 affects exactly 10 of 200, everynth:4 exactly 50. Removing
the lock from Decide makes firstn fail, so the test is not passing vacuously.

Screenshots

The screenshot job builds with -p:CiBuild=true and so picks up the UpdateUserAsync echo. The
run on this branch moved all nine images by well under 0.1%, uniformly — the signature of emulator
rendering nondeterminism rather than a content change, and no capture step taps a settings control.
Spot-checked staff_details.png: the hero renders from userPreferred and the native subtitle
田中真弓 is correctly shown, since it differs from the display name.

Zach Hollis added 3 commits August 25, 2026 22:46
…CI fixtures (#125)

ErrorSim could not test the thing it existed to test. It replaced the client
rather than decorating it, so `FailingAniListClient` answered all 23 interface
methods with `throw` and every call failed — you could never reach the screen
whose error state you wanted to see. That is why the details pages' error and
retry states had never been exercised on a device.

Two seams instead, sharing one disarmed-by-default `FaultState`:

- `FaultInjectingAniListClient` decorates whichever client DI selected, so it
  composes with the CI fixtures: a real screen loads and the *next* call breaks.
  `scope next` is what makes Retry genuinely recover.
- `FaultInjectingHttpHandler` sits innermost in the pipeline, so a synthetic 429
  or 503 is processed by the real `AniListRateLimitHandler`, `LoggingHandler`,
  `SendAsync` retry-once and `AniListErrorClassifier`.

A profile names which layer it fires at; both seams share one state, so without
that tag a single armed fault would fire twice for one logical call.

`Delay` is independent of failure — latency with no error kind is the only way to
open the cancellation and interlock windows that #116's defect family lives in.
Scopes are deterministic only: a fault you cannot re-run is not a fixture.

Armed over adb through an attribute-generated `BroadcastReceiver` and
`driver.ps1 fault`, so changing what fails costs a broadcast rather than a
~3 minute rebuild. Everything is behind `#if DEBUG`, including the exported
receiver, which is why `-p:ErrorSim=true` and its Release guard are gone.

The decorator clears an outage banner it raised once a call succeeds. Caught on
device: the banner is sticky and normally clears via `AniListClient`'s
`ReportSuccess`, which never runs behind the fixtures, so an injected outage
pinned it for the session and recovery looked broken.
`OnDisappearing` never fires on the five pushed pages when the tab changes, so
`ViewModel.CancelInFlight()` and `_loader.OnDisappearing()` simply did not run.
Tab away from a details page mid-load and the fetch, plus any Load More, ran to
completion against AniList — spending rate-limit budget on a page the user had
left — and `PageLoadScope` was never cancelled, making the guards written
against it inert on that path.

Measured on device rather than assumed. The navigation hooks are a strict
superset of the appearing hooks: they fire everywhere those do, plus the two
tab-switch cases where those do not.

    path                        OnAppearing  OnDisappearing  OnNavigatedTo  OnNavigatedFrom
    initial navigation              yes            -              yes              -
    tab away (pushed page)           -            NO               -              yes
    tab back (pushed page)          NO             -              yes               -
    forward nav to sub-page          -            yes              -              yes
    back nav from sub-page          yes            -              yes               -
    sort popup open                  -            yes              -              yes
    sort popup close                yes            -              yes               -
    tab-root page (Settings)        yes           yes             yes              yes

So the whole lifecycle moves to `OnNavigatedTo`/`OnNavigatedFrom`, leaving the
popup, forward-nav and back-nav paths behaving exactly as before.

The pair has to stay together. `DeferredContentLoader.OnDisappearing` clears
`_hasAppeared`, which gates both `IsCurrent` and `TrySchedule`, so moving the
cleanup without a matching re-arm would latch the loader off after a single tab
round-trip and leave the page on its spinner forever — worse than the bug.

Verified on device with an armed delay fault: a load cancelled at 6308ms of an
8000ms delay on tab-away, and tabbing back re-armed and completed it.

Tab-root pages get the full set and are unaffected, so `SettingsPage`'s pending
save flush (#118, #128) still runs.
Staff Name Language was saved to AniList and read by nothing: both accessors
were `Name?.Full ?? Name?.UserPreferred ?? ...`, so `Full` always won and every
staff and character name rendered identically whatever the viewer had picked.

The issue proposed composing the name locally from `first`/`last`. That was
implemented, then abandoned on evidence gathered against a real account:

- `full` is NOT a stable western-order field. AniList resolves it server-side
  against the viewer setting, exactly like `userPreferred`. Staff id 113181 is
  "Taiki Kawakami" unauthenticated and "Kawakami Taiki" on an account set to
  ROMAJI. Composing Romaji Western from `full` therefore renders family-first
  for those users — the app could not have shown western order at all.
- AniList is not internally consistent. Under ROMAJI a Latin-script name comes
  back as full="Bairstow Caitlyn" but userPreferred="Caitlyn Bairstow";
  `userPreferred` is script-aware and `full` is not. Any local `last first` rule
  diverges from anilist.co for every western voice actor, and matching it would
  mean inventing a CJK heuristic and hoping it keeps tracking theirs.

So the whole question defers to `userPreferred`, falling back to `full` then
`native`. All eleven `name { ... }` selections request it — the issue named two;
the other nine are every name appearing in a list rather than as a page hero,
and would have been left behind by either proposed option.

The cost is that `userPreferred` is fixed at fetch time, so a change needs a
refetch rather than a re-projection. `IAniListClient.InvalidateEntityCache()`
drops the cached character/staff/studio reads; pages reload lazily as the user
navigates back to them rather than firing a burst on a settings tap. It fires
for an upstream change too — the website or another device — which arrives
through `PopulateFromUser`, not the changed handler.

Also fixes `CIAniListClient.UpdateUserAsync`, which returned the untouched
static viewer instead of echoing the request, so every Display Preferences
change reverted on the next Settings load and the whole section was unverifiable
in a CI build. `DisplayAdultContent` stays unechoed so the adult-content canary
cannot be flipped from inside the app.

The native-script subtitle under the hero is suppressed when it would just
repeat the name above it, which happens once the setting is Native.
Copilot AI lite review requested due to automatic review settings August 26, 2026 02:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The fault <op> documentation for the HTTP injection layer is inconsistent with how the code targets GraphQL operationName, which can mislead users and should be corrected.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR improves AniSprinkles’ observability and correctness around (1) runtime fault injection for exercising error/retry states, (2) MAUI Shell lifecycle handling for pushed pages across tab switches, and (3) Staff Name Language rendering by deferring to AniList’s userPreferred and invalidating cached entity reads when the setting changes.

Changes:

  • Replace ErrorSim build-flag stubs with runtime, adb-armable fault injection at both IAniListClient and HTTP-pipeline layers.
  • Move pushed-page lifecycle work (deferred loading + cancellation) from OnAppearing/OnDisappearing to OnNavigatedTo/OnNavigatedFrom to cover tab-switch cases.
  • Render staff/character names via userPreferred (with fallback) and invalidate the entity cache on Staff Name Language changes.
File summaries
File Description
tests/AniSprinkles.UnitTests/StaffNameFormatTests.cs Adds unit coverage for userPreferred-first name rendering and native subtitle suppression behavior.
tests/AniSprinkles.UnitTests/StaffNameCacheInvalidationTests.cs Verifies InvalidateEntityCache() behavior and that Settings triggers it on staff-name-language changes.
tests/AniSprinkles.UnitTests/FaultInjectionTests.cs Tests deterministic fault scope arithmetic and matching/arming rules.
tests/AniSprinkles.UnitTests/FaultInjectingHttpHandlerTests.cs Tests HTTP-layer fault shaping (status/body) and rate-limit handler retry behavior.
tests/AniSprinkles.UnitTests/FaultInjectingClientTests.cs Tests client-decorator fault behavior (pass-through, next, delay-only, outage banner clearing rules).
src/AniSprinkles/Views/StaffDetailsLoadedContentView.xaml Binds native subtitle visibility to ShowNativeName and uses DisplayName for card names.
src/AniSprinkles/Views/MediaDetailsLoadedContentView.xaml Uses DisplayName in staff/VA card bindings.
src/AniSprinkles/Views/CharacterDetailsLoadedContentView.xaml Binds native subtitle visibility to ShowNativeName and uses DisplayName for card names.
src/AniSprinkles/Services/ErrorSimulation/SimAuthService.cs Removes ERROR_SIM auth stub (deleted).
src/AniSprinkles/Services/ErrorSimulation/FailingAniListClient.cs Removes whole-interface throwing stub (deleted).
src/AniSprinkles/Services/CI/CIAniListClient.cs Adds InvalidateEntityCache() no-op and makes UpdateUserAsync echo updates back into the stub viewer.
src/AniSprinkles/Platforms/Android/FaultBroadcastReceiver.cs Adds exported Debug-only receiver to arm/clear fault injection over adb.
src/AniSprinkles/Pages/StudioDetailsPage.xaml.cs Moves deferred-load scheduling and cancellation to navigation hooks for pushed-page tab switching.
src/AniSprinkles/Pages/StaffDetailsPage.xaml.cs Same lifecycle shift; ensures cancel logic runs on tab switch and navigation.
src/AniSprinkles/Pages/MediaDetailsPage.xaml.cs Same lifecycle shift; updates NAVTRACE message to reflect navigation-hook usage.
src/AniSprinkles/Pages/MediaBrowsePage.xaml.cs Same lifecycle shift for “View All” pushed page.
src/AniSprinkles/Pages/CharacterDetailsPage.xaml.cs Same lifecycle shift; ensures cancellation runs on tab switch.
src/AniSprinkles/MauiProgram.cs Wires fault injection (FaultState, client decorator, HTTP handler) into Debug builds and simplifies CI client registration.
src/AniSprinkles/AniSprinkles.csproj Removes ErrorSim flag/Release guard in favor of Debug-gated runtime fault injection.
src/AniSprinkles.Core/Utilities/StaffNameFormat.cs Introduces userPreferred-first display formatting with safe fallbacks.
src/AniSprinkles.Core/Services/IAniListClient.cs Adds InvalidateEntityCache() API contract and documents why it’s needed for staff name language.
src/AniSprinkles.Core/Services/FaultInjection/FaultState.cs Adds shared, thread-safe runtime fault state and hit-count bookkeeping.
src/AniSprinkles.Core/Services/FaultInjection/FaultProfile.cs Defines deterministic scope/layer model and matching rules for fault injection.
src/AniSprinkles.Core/Services/FaultInjection/FaultInjectingHttpHandler.cs Implements HTTP-pipeline fault injection with realistic shapes (including GraphQL errors).
src/AniSprinkles.Core/Services/FaultInjection/FaultInjectingAniListClient.cs Implements IAniListClient decorator that composes with CI fixtures and manages outage banner recovery.
src/AniSprinkles.Core/Services/CachingAniListClient.cs Implements InvalidateEntityCache() by clearing the entity/page cache.
src/AniSprinkles.Core/Services/AniListClient.cs Adds InvalidateEntityCache() no-op and requests userPreferred in all relevant GraphQL name selections.
src/AniSprinkles.Core/PageModels/SettingsPageModel.cs Invalidates entity cache on staff-name-language changes (local and upstream), tracks last synced value.
src/AniSprinkles.Core/PageModels/PageLoadScope.cs Updates documentation to reflect navigation-hook cancellation point.
src/AniSprinkles.Core/PageModels/MediaDetailsPageModel.cs Updates remarks about staff name language impact and why it’s not re-projected locally.
src/AniSprinkles.Core/PageModels/DetailsPageModelBase.cs Documents measured pushed-page lifecycle behavior and updates comments to match navigation-hook flow.
src/AniSprinkles.Core/Models/VoiceActor.cs Adds DisplayName accessor using StaffNameFormat.
src/AniSprinkles.Core/Models/StaffEdge.cs Adds DisplayName accessor on StaffNode using StaffNameFormat.
src/AniSprinkles.Core/Models/Staff.cs Switches DisplayName to StaffNameFormat and adds ShowNativeName.
src/AniSprinkles.Core/Models/Character.cs Switches DisplayName to StaffNameFormat and adds ShowNativeName.
DEVELOPER_NOTES.md Updates local verification guidance to use runtime fault injection instead of ErrorSim.
AGENTS.md Updates repo architecture/docs for fault injection and staff-name-language behavior.
.claude/skills/run-anisprinkles/SKILL.md Documents new driver verbs and runtime fault injection workflow.
.claude/skills/run-anisprinkles/driver.ps1 Adds fault command to arm/clear injection via adb broadcast.
.claude/skills/project-architecture/SKILL.md Updates architecture skill doc to mention fault receiver and remove ErrorSim.
.claude/skills/ani-debug/SKILL.md Adds guidance for interpreting FAULT log lines in Debug sessions.
Review details
  • Files reviewed: 41/41 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread DEVELOPER_NOTES.md Resolved
@github-actions

github-actions Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

📱 UI Screenshots

✅ Authenticated UI — screenshots rendered via compile-time CI stub services with hardcoded data. No OAuth token required.

View Workflow Run →

Library Discover View All (Browse) Search One Piece Details Toei Animation (Studio) Luffy (Character) Mayumi Tanaka (Staff) Settings
Library Discover View All (Browse) Search One Piece Details Toei Animation (Studio) Luffy (Character) Mayumi Tanaka (Staff) Settings

Zach Hollis and others added 2 commits August 26, 2026 08:52
…R review)

`fault <op>` was documented everywhere as an `IAniListClient` method prefix. That
is only true at the client seam. The HTTP seam parses the GraphQL `operationName`
out of the request body, because that is all it can see — so
`fault GetStudio ... -layer http` matched nothing and looked like a broken seam
rather than a targeting mistake.

Every HTTP scenario in the device pass used `op any`, which is why this was not
caught during verification.

No normalisation is attempted, because none would work. Stripping
`Get`/`Load`/`Async` lines up `GetStudioAsync` with `Studio`, but the namespaces
genuinely diverge elsewhere: `GetMyAnimeListAsync` is `MediaListCollection` over
the wire and `SearchAnimePageAsync` is `Search`. Partial magic that covers most
operations and silently fails on the rest is worse than none.

So the rule is stated in all five places that document it (driver help,
/run-anisprinkles, DEVELOPER_NOTES, AGENTS.md, and FaultProfile's XML doc), and
the handler now logs `FAULT http no match` naming the operation it actually saw
when an armed targeted profile misses — the failure diagnoses itself instead of
looking like nothing happened. Only reachable with a targeted Http profile armed,
so it cannot flood the log.

Two tests pin the distinction so nobody "fixes" it by normalising one side.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

FaultState uses System.Threading.Lock with lock (_gate), which likely boxes per use and breaks synchronization, creating a real race risk when faults are armed.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 41/50 changed files
  • Comments generated: 1
  • Review effort level: Lite

Zach Hollis and others added 2 commits August 26, 2026 19:05
A review comment claimed `lock (_gate)` on a `System.Threading.Lock` boxes a new
object per use and therefore synchronizes nothing. It does not — `Lock` is a
sealed class, and C# 13 lowers `lock` on it to `using (x.EnterScope())` rather
than `Monitor.Enter`. Converting one to `object`, which the comment suggested as
the fix, is the case warning CS9216 exists to catch.

No production change; these tests make the answer checkable rather than argued,
and guard an invariant worth guarding on its own. `Decide` is a read-modify-write
on the hit counter reached from the UI thread and from HTTP continuations on pool
threads, and every scope's meaning rests on it being atomic: `next` must fire once
however many callers race, `firstn:N` must affect exactly N.

Confirmed the tests are not vacuous by removing the lock from `Decide` and
re-running — `firstn` fails, because lost increments let extra callers slip under
the threshold.
@zhollis21
zhollis21 merged commit 925d79f into main Aug 26, 2026
3 checks passed
@zhollis21
zhollis21 deleted the feature/125-130-132-fault-injection-name-language-lifecycle branch August 26, 2026 23:36
zhollis21 added a commit that referenced this pull request Nov 19, 2026
…ge (#125, #132, #130) (#135)

* Replace ErrorSim with runtime fault injection that composes with the CI fixtures (#125)

ErrorSim could not test the thing it existed to test. It replaced the client
rather than decorating it, so `FailingAniListClient` answered all 23 interface
methods with `throw` and every call failed — you could never reach the screen
whose error state you wanted to see. That is why the details pages' error and
retry states had never been exercised on a device.

Two seams instead, sharing one disarmed-by-default `FaultState`:

- `FaultInjectingAniListClient` decorates whichever client DI selected, so it
  composes with the CI fixtures: a real screen loads and the *next* call breaks.
  `scope next` is what makes Retry genuinely recover.
- `FaultInjectingHttpHandler` sits innermost in the pipeline, so a synthetic 429
  or 503 is processed by the real `AniListRateLimitHandler`, `LoggingHandler`,
  `SendAsync` retry-once and `AniListErrorClassifier`.

A profile names which layer it fires at; both seams share one state, so without
that tag a single armed fault would fire twice for one logical call.

`Delay` is independent of failure — latency with no error kind is the only way to
open the cancellation and interlock windows that #116's defect family lives in.
Scopes are deterministic only: a fault you cannot re-run is not a fixture.

Armed over adb through an attribute-generated `BroadcastReceiver` and
`driver.ps1 fault`, so changing what fails costs a broadcast rather than a
~3 minute rebuild. Everything is behind `#if DEBUG`, including the exported
receiver, which is why `-p:ErrorSim=true` and its Release guard are gone.

The decorator clears an outage banner it raised once a call succeeds. Caught on
device: the banner is sticky and normally clears via `AniListClient`'s
`ReportSuccess`, which never runs behind the fixtures, so an injected outage
pinned it for the session and recovery looked broken.

* Cancel in-flight work when a pushed page's tab is switched away (#132)

`OnDisappearing` never fires on the five pushed pages when the tab changes, so
`ViewModel.CancelInFlight()` and `_loader.OnDisappearing()` simply did not run.
Tab away from a details page mid-load and the fetch, plus any Load More, ran to
completion against AniList — spending rate-limit budget on a page the user had
left — and `PageLoadScope` was never cancelled, making the guards written
against it inert on that path.

Measured on device rather than assumed. The navigation hooks are a strict
superset of the appearing hooks: they fire everywhere those do, plus the two
tab-switch cases where those do not.

    path                        OnAppearing  OnDisappearing  OnNavigatedTo  OnNavigatedFrom
    initial navigation              yes            -              yes              -
    tab away (pushed page)           -            NO               -              yes
    tab back (pushed page)          NO             -              yes               -
    forward nav to sub-page          -            yes              -              yes
    back nav from sub-page          yes            -              yes               -
    sort popup open                  -            yes              -              yes
    sort popup close                yes            -              yes               -
    tab-root page (Settings)        yes           yes             yes              yes

So the whole lifecycle moves to `OnNavigatedTo`/`OnNavigatedFrom`, leaving the
popup, forward-nav and back-nav paths behaving exactly as before.

The pair has to stay together. `DeferredContentLoader.OnDisappearing` clears
`_hasAppeared`, which gates both `IsCurrent` and `TrySchedule`, so moving the
cleanup without a matching re-arm would latch the loader off after a single tab
round-trip and leave the page on its spinner forever — worse than the bug.

Verified on device with an armed delay fault: a load cancelled at 6308ms of an
8000ms delay on tab-away, and tabbing back re-armed and completed it.

Tab-root pages get the full set and are unaffected, so `SettingsPage`'s pending
save flush (#118, #128) still runs.

* Render staff and character names from userPreferred (#130)

Staff Name Language was saved to AniList and read by nothing: both accessors
were `Name?.Full ?? Name?.UserPreferred ?? ...`, so `Full` always won and every
staff and character name rendered identically whatever the viewer had picked.

The issue proposed composing the name locally from `first`/`last`. That was
implemented, then abandoned on evidence gathered against a real account:

- `full` is NOT a stable western-order field. AniList resolves it server-side
  against the viewer setting, exactly like `userPreferred`. Staff id 113181 is
  "Taiki Kawakami" unauthenticated and "Kawakami Taiki" on an account set to
  ROMAJI. Composing Romaji Western from `full` therefore renders family-first
  for those users — the app could not have shown western order at all.
- AniList is not internally consistent. Under ROMAJI a Latin-script name comes
  back as full="Bairstow Caitlyn" but userPreferred="Caitlyn Bairstow";
  `userPreferred` is script-aware and `full` is not. Any local `last first` rule
  diverges from anilist.co for every western voice actor, and matching it would
  mean inventing a CJK heuristic and hoping it keeps tracking theirs.

So the whole question defers to `userPreferred`, falling back to `full` then
`native`. All eleven `name { ... }` selections request it — the issue named two;
the other nine are every name appearing in a list rather than as a page hero,
and would have been left behind by either proposed option.

The cost is that `userPreferred` is fixed at fetch time, so a change needs a
refetch rather than a re-projection. `IAniListClient.InvalidateEntityCache()`
drops the cached character/staff/studio reads; pages reload lazily as the user
navigates back to them rather than firing a burst on a settings tap. It fires
for an upstream change too — the website or another device — which arrives
through `PopulateFromUser`, not the changed handler.

Also fixes `CIAniListClient.UpdateUserAsync`, which returned the untouched
static viewer instead of echoing the request, so every Display Preferences
change reverted on the next Settings load and the whole section was unverifiable
in a CI build. `DisplayAdultContent` stays unechoed so the adult-content canary
cannot be flipped from inside the app.

The native-script subtitle under the hero is suppressed when it would just
repeat the name above it, which happens once the setting is Native.

* CI: Update UI screenshots [skip ci]

* Document that the fault op means a different thing per layer (#125, PR review)

`fault <op>` was documented everywhere as an `IAniListClient` method prefix. That
is only true at the client seam. The HTTP seam parses the GraphQL `operationName`
out of the request body, because that is all it can see — so
`fault GetStudio ... -layer http` matched nothing and looked like a broken seam
rather than a targeting mistake.

Every HTTP scenario in the device pass used `op any`, which is why this was not
caught during verification.

No normalisation is attempted, because none would work. Stripping
`Get`/`Load`/`Async` lines up `GetStudioAsync` with `Studio`, but the namespaces
genuinely diverge elsewhere: `GetMyAnimeListAsync` is `MediaListCollection` over
the wire and `SearchAnimePageAsync` is `Search`. Partial magic that covers most
operations and silently fails on the rest is worse than none.

So the rule is stated in all five places that document it (driver help,
/run-anisprinkles, DEVELOPER_NOTES, AGENTS.md, and FaultProfile's XML doc), and
the handler now logs `FAULT http no match` naming the operation it actually saw
when an armed targeted profile misses — the failure diagnoses itself instead of
looking like nothing happened. Only reachable with a targeted Http profile armed,
so it cannot flood the log.

Two tests pin the distinction so nobody "fixes" it by normalising one side.

* CI: Update UI screenshots [skip ci]

* Pin FaultState.Decide's atomicity under contention (#125, PR review)

A review comment claimed `lock (_gate)` on a `System.Threading.Lock` boxes a new
object per use and therefore synchronizes nothing. It does not — `Lock` is a
sealed class, and C# 13 lowers `lock` on it to `using (x.EnterScope())` rather
than `Monitor.Enter`. Converting one to `object`, which the comment suggested as
the fix, is the case warning CS9216 exists to catch.

No production change; these tests make the answer checkable rather than argued,
and guard an invariant worth guarding on its own. `Decide` is a read-modify-write
on the hit counter reached from the UI thread and from HTTP continuations on pool
threads, and every scope's meaning rests on it being atomic: `next` must fire once
however many callers race, `firstn:N` must affect exactly N.

Confirmed the tests are not vacuous by removing the lock from `Decide` and
re-running — `firstn` fails, because lost increments let extra callers slip under
the threshold.

* CI: Update UI screenshots [skip ci]

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
zhollis21 added a commit that referenced this pull request Nov 19, 2026
Removing screenshots/ from main's history gave every commit a new SHA. The
four commits the create-issue and kickoff skills cite as examples now read
3fb0aa3 (#123), 3707476 (#135), 18d252a (#143) and 30ff33c (#61).
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.

2 participants