Skip to content

ADFA-5074 fix(setup): forget the module install state when the system goes - #380

Merged
luisguzman-adfa merged 4 commits into
mainfrom
fix/ADFA-5074-clear-the-module-batch
Aug 11, 2026
Merged

luisguzman-adfa merged 4 commits into
mainfrom
fix/ADFA-5074-clear-the-module-batch

Conversation

@luisguzman-adfa

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

Copy link
Copy Markdown
Collaborator

Reinstalling with Full, after Books reader had been installed by hand on the previous system, drew a "Books reader" row in the install index for a module this run never asked for.

The module-install flow keeps two stores, and each was only cleared at the moment it happened to be finished with: ModuleWishlist when the batch is handed to the engine, ModuleBatch when the index reaches the library. Neither is cleared when the system goes away, so both outlived a wipe. They were not in the enumeration PendingContent owns, because a module install is not content.

Worse than the stale row: SetupProgressActivity.moduleInSession() latches on ModuleBatch, and that decides whether the index becomes a gate, whether "Run in background" is offered, and whether the post-runrole server restart is awaited. A leftover batch changes how the screen behaves, not just how it looks.

And a second store turned up while fixing the first, with a worse failure: a stale ModuleWishlist is a scheduled install that survived the box it was scheduled against — at best repeating work the new tier already ships, at worst running a runrole nobody asked for in this run.

ModuleInstallState.clearAll forgets both, called from the two places that already drop the content orders — a fresh wizard run, and a completed system replacement — because it is the same event for the same reason.

ContentStateInvalidator now clears nine stores rather than seven, so its name undersells it. Renaming would touch all five destructive routes for no behavioural gain, so the name stays and its javadoc carries the correction: what it forgets is state that described the system that went away, whether or not that state is content.

Verification. Unit tests and lint on your run; nothing pure to add here, it is all SharedPreferences. On device: install Standard, install Books reader by hand from Module management, let it finish, then reinstall with Full choosing all four content categories — the Books reader row must not appear. And a plain Module management install must still show its row as before, which is what proves this did not clear too eagerly.

A third store turned up while verifying this: ModuleQueueRepository holds the queue's verdict in memory for the life of the process, and the index reads that phase to decide whether a row is done. A module installed earlier by hand left it on DONE, so a Full reinstall drew a green check over a maps install that had not started, correcting itself only once the real runrole published RUNNING. It is reset with the other two, never over a live queue.

Two more found while verifying this branch, both the same shape — a screen
reading state that did not belong to this run.

ModuleQueueRepository holds the queue's verdict in memory for the life of the process, and the index reads that phase to decide whether a row is done. A module installed earlier by hand left it on DONE, so a Full reinstall drew a
green check over a maps install that had not started. Reset with the flow's other two stores, never over a live queue.

And the index offered "Run in background" while the header still said "Starting services…" and every row was Queued — including runs about to install a proot module, which must not offer it. prootActive() reads a latch that
engages only once the proot work registers, so on entry it answers false for a run that is about to be gated. Gated on servicesReady rather than taught to predict the work: until the engine answers there is nothing live to leave
running.

Verified on device: Analytics (Matomo) installs with no escape offered and the app can be left and returned to; a REST-only run offers it once services answer; a module install still shows its check when it really finishes; and entering a reinstall logs the state being discarded.

… goes

Reinstalling with Full, after Books reader had been installed by hand on the
previous system, drew a "Books reader" row in the install index for a module this
run never asked for.

The module-install flow keeps two stores, and each was only cleared at the moment
it happened to be finished with: `ModuleWishlist` when the batch is handed to the
engine, `ModuleBatch` when the index reaches the library. Neither is cleared when
the *system* goes away, so both outlived a wipe. They were not in the enumeration
`PendingContent` owns, because a module install is not content.

Worse than the stale row: `SetupProgressActivity.moduleInSession()` latches on
`ModuleBatch`, and that decides whether the index becomes a gate, whether "Run in
background" is offered, and whether the post-runrole server restart is awaited. A
leftover batch changes how the screen behaves, not just how it looks.

And a second store turned up while fixing the first, with a worse failure: a stale
`ModuleWishlist` is a scheduled install that survived the box it was scheduled
against — at best repeating work the new tier already ships, at worst running a
runrole nobody asked for in this run.

`ModuleInstallState.clearAll` forgets both, called from the two places that already
drop the content orders — a fresh wizard run, and a completed system replacement —
because it is the same event for the same reason.

`ContentStateInvalidator` now clears nine stores rather than seven, so its name
undersells it. Renaming would touch all five destructive routes for no behavioural
gain, so the name stays and its javadoc carries the correction: what it forgets is
state that described the system that went away, whether or not that state is
content.

**Verification.** Unit tests and lint on your run; nothing pure to add here, it is
all SharedPreferences. On device: install Standard, install Books reader by hand
from Module management, let it finish, then reinstall with Full choosing all four
content categories — the Books reader row must not appear. And a plain Module
management install must still show its row as before, which is what proves this did
not clear too eagerly.
Review follow-ups.

The wizard's clear-on-open and the replacement each listed the two facades
in a pair, which is the same enumeration by hand one level up: six stores
in five screens became two facades in three places. PendingWork.clearAll
holds the list now, and both moments ask it — a seventh store is one line
in one place.

ModuleInstallState no longer asks before clearing. That cost two
SharedPreferences reads purely to decide whether to log, and one caller is
the wizard's onCreate; both clears are idempotent.

Records why HiddenModules is not in there: it persists module keys too, but
it is a preference about what the user sees on Home, not work arranged
against a system, so it is meant to outlive a wipe.

And the Courses hub card's note is no longer amber. The tint was a
deliberate marker for "In-app: TBD"; with the card naming what it offers,
amber had stopped meaning "unfinished" and started meaning "something is
wrong with this one". Courses was the only card using the flag, so the flag
goes too — a future not-ready card should reintroduce it on purpose.
The install index drew a green check over a maps install that had not
started. mapsRow() decides "done" from ModuleQueueRepository's phase, and
that repository is a process singleton: a module installed earlier by hand
left it on DONE, so a new run read a verdict without asking whose it was.
It corrected itself only once the real runrole published RUNNING.

Same omission as the failure count, which was gated on queueVerdictIsOurs
in an earlier commit while the row was left reading the phase directly.
The state is now reset with the flow's other two stores — it is the same
thing, held in memory rather than in preferences.

Never over a live queue: a runrole in flight owns that state and posting
idle under it would replace a true report with a false one. On a
replacement the queue has already been stopped; on a fresh wizard run
there is nothing to stop.

Maps still runs on a Full reinstall, which is correct: the image ships the
module, not the tiles, and the wizard banked a tile selection.
… shape

The index showed "Run in background" while the header still said "Starting
services…" and every row was Queued — including runs about to install a proot
module, which is exactly what that button must not offer.

prootActive() reads a latch that engages only once the proot work registers:
launched, batched, or reported by the queue. On entry none of that has
happened, so it answers false for a run that is about to be gated, and the
screen offered an escape it would then withdraw.

Gated on servicesReady rather than taught to predict the work. Until the
engine answers there is no live work to leave running, so the button was
offering nothing in that window; and inferring proot work from another
source would add one more place that knows the same thing.

The other window is left alone on purpose: once a module has finished and
the server is back, the button returns, which is correct — only proot may
trap the user, and it no longer is.
@luisguzman-adfa
luisguzman-adfa merged commit cf52d75 into main Aug 11, 2026
3 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the fix/ADFA-5074-clear-the-module-batch branch August 11, 2026 01:22
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