# Stage 4 implementation notes

The device-constraint implementation is verified in `../features/AUTOMATIC_UPDATE_CONSTRAINTS.md`,
including concrete telemetry limits. Updates/Upcoming filtering is
implemented in `../features/ACTIVITY_FILTERS.md`; smart rules and group scope are
implemented and verified in `../features/SMART_UPDATE_RULES.md`.

## Upstream behavior and compatibility

Animetail revision `d0eab5d6237dd09ebdb21a63fff5b66097c91087` exposes separate
Wi-Fi-only, unmetered and charging restrictions. Its smart-update switches skip
completed titles, titles with unread/unseen releases, known-but-unstarted titles,
and titles outside the expected release period. Empty titles remain eligible for
the started restriction so their first release list can still be discovered.
Yokan already calculates automatic cadence and accepts a manual zero/every-update
interval; defaults must preserve its existing scheduling behavior.

Group update mode in the upstream worker is Global, current group, or all groups
when Ungrouped is selected. Manual group scope must be computed from raw membership,
before text/row filters, and captured as title IDs. All and an empty group must
remain distinct: an empty/stale selection cannot silently become a full-library run.
Scheduled refreshes must have an explicit stable scope rather than depend on a
currently composed UI or mutable global profile accessor.

Foreground/OS periodic refreshes call `LibraryUpdaterService` directly, alongside
manual controller runs. The implementation adds service-level serialization and
atomic, scoped update-error settings writes. Preserve these while adding device
constraints; do not discard concurrent preference changes or another media type's
error report.

## Platform evidence checked 2026-10-15

- Android WorkManager supports charging/network constraints and stops work if a
  required constraint becomes unmet. Apply library-specific constraints only to
  library work; changing them must update daily work even when its time is unchanged.
  [Official work-request documentation](https://developer.android.com/develop/background-work/background-tasks/persistent/getting-started/define-work).
- iOS `BGProcessingTaskRequest` provides `requiresExternalPower` and
  `requiresNetworkConnectivity`. Foreground refreshes need the same shared admission
  rules as OS workers. Existing fixed background identifiers belong to the Default
  profile; preserve that ownership.
  [Apple task-request documentation](https://developer.apple.com/documentation/backgroundtasks/bgprocessingtaskrequest).
- Battery Status is a secure-context browser API with limited browser availability;
  a browser may also obscure the actual condition. A missing/denied API cannot be
  treated as evidence that a selected restriction is satisfied. Implement observable
  unknown/deferred outcomes and document concrete browser limits; do not claim a
  universal hardware capability or silently bypass the selected restriction.
  [W3C specification](https://www.w3.org/TR/battery-status/),
  [MDN compatibility overview](https://developer.mozilla.org/en-US/docs/Web/API/Battery_Status_API).

Existing network helpers use permissive fallback values on several platforms and
desktop/web currently report unmetered unconditionally. They are insufficient proof
for new explicit user-selected device restrictions. Keep existing download semantics
stable while introducing a richer, testable update-condition observation boundary.
