Skip to content

ADFA-5146 fix(env): a killed download no longer locks every deep operation - #423

Merged
luisguzman-adfa merged 7 commits into
mainfrom
fix/ADFA-5146-busy-flag-expiry
Aug 17, 2026
Merged

luisguzman-adfa merged 7 commits into
mainfrom
fix/ADFA-5146-busy-flag-expiry

Conversation

@luisguzman-adfa

@luisguzman-adfa luisguzman-adfa commented Aug 17, 2026 •

Copy link
Copy Markdown
Collaborator

State-spine finding 2, the release blocker. When a content-download service was
killed before a terminal state, EnvironmentLock.isBusyNow() stayed true for the
life of the process, so clone / backup / restore / install / rebuild / maps all
refused with "An install is already running" while nothing ran — the only exit
was force-stopping the app.

What this changes

  • A per-poll last-progress heartbeat on the three content sources (ZIM, Books,
    Courses). isBusyNow() now counts each via isActiveNow() = hasSession &&
    !isComplete && Freshness.fresh(...). A dead session ages out after ~30s; a
    live-but-slow download refreshes every poll and keeps blocking; a finished one
    never blocks. Freshness is pure (unit-tested).
  • EnvironmentLock.currentHolder(ctx) + util/BusyMessage: the six deep-op gates
    now name the real holder (a copy / backup / restore / install / download)
    instead of always "an install". Five strings, base + 33 locales.
  • Removes the dead InstallJobs.isBusy() delegate.

Deliberately not here

  • The module queue keeps its own signal (Option 2): its stuck case is dominated
    by the durable install guard, whose lifecycle is ADFA-5147-adjacent, not this
    flag. Known limit: a module runrole killed within one session — covered
    cross-session by the guard + ADFA-5147. Design + rationale in
    controller/docs/ADFA-5146-busy-expiry-design.md.

Verification

  • Build + lint (MissingTranslation on the five new strings × 33 locales).
  • FreshnessTest (JVM). Device: a live download still blocks a deep op and the
    refusal names it; a finished one does not.

Coordination

  • Touches one gate line in CloneFragment; region-disjoint from the in-flight
    ADFA-5158 branch (renderPrepare/renderCopy), so no real conflict expected.

State-spine finding 2 (release blocker). A content-download service killed
before a terminal state left EnvironmentLock.isBusyNow() true for the life of
the process, so every deep operation refused with "An install is already
running" while nothing ran — the only exit was force-stopping the app.

- Freshness (pure) + a per-poll last-progress heartbeat on the three content
  sources (ZIM, Books, Courses). isBusyNow() now counts them via isActiveNow()
  (hasSession && !isComplete && fresh), so a dead session ages out after ~30s
  while a live-but-slow download stays fresh and keeps blocking; a finished one
  never blocks. The module queue is unchanged — its stuck case belongs to the
  durable install guard (ADFA-5147-adjacent), not this flag.
- EnvironmentLock.currentHolder(ctx) + util/BusyMessage: the six deep-op gates
  now name the real holder (copy / backup / restore / install / download)
  instead of always "an install". Five strings, base + 33 locales.
- Remove the dead InstallJobs.isBusy() delegate.
- FreshnessTest (JVM). Design + plan: controller/docs/ADFA-5146-busy-expiry-design.md.

Known limit (documented): a module runrole killed within one session; covered
cross-session by the install guard + ADFA-5147.
@luisguzman-adfa luisguzman-adfa changed the title ADFA-5146 fix(env): expire a stale busy flag, and name the holder ADFA-5146 fix(env): a killed download no longer locks every deep operation Aug 17, 2026
…rflowing the stack

ensureHotspot() runs on every render and re-launched ACCESS_FINE_LOCATION
whenever it wasn't granted; the permission callback then re-renders. On OEMs
that return the denied result synchronously this recursed with no async gap
(render -> ensureHotspot -> launch -> deny -> callback -> render …) until the
8 MB stack overflowed when opening Clone > Send. A locationAsked latch requests
the permission at most once per attempt; setMode() clears it so a Hotspot/Wi-Fi
switch is a natural retry.
Reproduces the stale-heartbeat case deterministically (a content download whose
poll loop died with the process alive) — otherwise hard to trigger by hand, and
NOT the same as "download + Wi-Fi off" (that keeps the poll loop, so the flag
stays fresh by design). The receiver lives in src/debug, so it never ships in
release; remove it with debugSeedStaleCandidate() before merge.
Drops the src/debug broadcast receiver, its manifest entry and the
debugSeedStaleCandidate() seeder used to verify the stale-flag expiry on
device. The rule stays covered by FreshnessTest; the one-time end-to-end
check is done.
… of truth)

isHeld() re-listed the same lock sources as currentHolder(), so a source
added to one and not the other would block while naming the wrong holder
(or defaulting to "an install") — a silent drift nobody would notice until
it bit. isHeld now returns currentHolder(ctx) != NONE, so currentHolder is
the single place that enumerates the sources. Behavior is unchanged today.
…on the left

state-spine.svg: S13 "stale busy" and finding 2 (the release blocker) move to
resolved — the busy flag expires in ~30s and the refusal names the holder; the
findings summary drops to one open (6).

operation-model-roadmap.svg: DELIVERED becomes two columns holding every DONE
card — the state-spine arc (5143/5137/5147/5146) and 5119 move out of NEXT /
IN FLIGHT, which shift right and now carry only open work, so a card's column
matches its status. The isBusyNow ledger row and the 5146 card flip to done,
and the inter-column arrows are redrawn to the new positions.
@luisguzman-adfa
luisguzman-adfa merged commit 39ab041 into main Aug 17, 2026
2 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the fix/ADFA-5146-busy-flag-expiry branch August 17, 2026 18:47
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