Skip to content

ADFA-5364 refactor(content): one admission rule for the REST content streams - #515

Merged
luisguzman-adfa merged 2 commits into
mainfrom
refactor/ADFA-5364-content-admission-collapse
Sep 1, 2026
Merged

luisguzman-adfa merged 2 commits into
mainfrom
refactor/ADFA-5364-content-admission-collapse

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

Books, ZIM and Kolibri each carried the same deferral rule word for word — proot or a dashboard
update in flight, then another stream with unfinished work — so a fourth stream would have carried a
fourth copy. It now lives once, in system/data/ContentAdmission, next to the PendingContent it
consults: a package that already depends on both callers' packages, so no new dependency direction.

First slice of ADFA-5364. No new capability — the connection dimension lands on this gate later,
in one place instead of three.

Changes

  • ContentAdmission.canStart(ctx, ContentType) — the rule, once.
  • The three provisioners call it; KolibriProvisioner.canDrainNow stays as a one-line wrapper
    because its javadoc records why it stopped being public API.
  • Takes a ContentType, not the stream's name: the type already owns that identity, and it carries
    the execution class that says which types this gate is about — MAPS is STOPPED, so it is not a
    caller here but one of the things this rule defers to.

−59 / +11 in the callers. No behaviour change: same checks, same order, same reasons. The only
observable difference is the log wording, unified on "deferred" (Kolibri said "blocked") — the
accurate word, since a deferred order stays in the wishlist for the next pass.

Not touched, on purpose

Maps and Modules have a similar-looking gate that is a different rule for a different family
(proot operations) — they are what this rule defers to. Sharing it would make maps defer on REST
work it must ignore. The ticket's first draft said "five copies"; it is three.

Verification

:app:testDebugUnitTest + :app:lintDebug green. On device, both branches of the rule:

Caller Admits Defers
Books handing 3 to BooksDownloadService ×3
ZIM handing 2 to ZimDownloadService ×10
Courses handing 1 to KolibriSeedService —

All three emitted the right ContentType.key() label, which is the only thing the signature change
could have broken. Courses' defer branch is not reachable through the pump: KolibriProvisioner
clears its wishlist at hand-off (unlike Books/ZIM, TODO(ADFA-4874)), so hasPending goes false
immediately and nothing asks again.

No JVM test: canStart holds no logic, only which four collaborators it asks. With stubs a test
could assert !false && !false — the implementation restated. The risk it would have covered (a
stream consulting a different rule) is now the compiler's.

Note for the ticket

Recon for the next slice found that FQR is a live REST stream outside this rule in both
directions
— FqrController never consults it, and PendingContent (built on ContentType)
cannot see an FQR job, so the others do not defer for it either. Recorded in ADFA-5364 as fork D;
not addressed here.

…streams

Books, ZIM and Kolibri each carried the same deferral rule word for word — proot or a dashboard
update in flight, then another stream with unfinished work — so a fourth stream would have carried
a fourth copy. It now lives once, in system/data next to the PendingContent it consults, which is a
package that already depends on both callers' packages: no new dependency direction.

Behaviour is unchanged: same checks, same order, same reasons. The only observable difference is the
log wording, unified on "deferred" (Kolibri said "blocked"), which is the accurate word — a deferred
order stays in the wishlist and the next pass takes it.

Not touched: the proot provisioners (maps, modules). Their gate looks similar but is a different
rule for a different family — they are what this one defers to, and sharing it would make maps defer
on REST work it must ignore.

First slice of ADFA-5364: the gate now exists in one place, so the connection dimension lands there
instead of in three copies. No behaviour to verify by test; the device check is that queueing
content during a module install still defers, on all three streams.
…not by name

Review follow-up on the collapse. The shared rule took the stream's name as a free string, so the
three callers carried three literals of an identity that system/domain/ContentType already owns —
the same drift its own javadoc was written about. It now takes the type: the log output is
byte-identical (key() is "books" / "zim" / "kolibri"), the signature carries the execution class
that says which types this gate is even about (MAPS is STOPPED — not a caller here but one of the
things this rule defers to), and a fifth content type needs no edit in this class.

Also drops the MapsProvisioner import KolibriProvisioner no longer uses — it only ever served the
rule that moved out, and an unused import is a lint warning, not an error, so it would have landed.
@luisguzman-adfa
luisguzman-adfa merged commit 49c49c8 into main Sep 1, 2026
3 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the refactor/ADFA-5364-content-admission-collapse branch September 1, 2026 19:26
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