Make the Kotlin v18-aux prune threshold injectable, as Swift's already is (#888) - #904
Merged
Merged
Conversation
…y is (#888) `DeepCaptureMigrationTest.repositoryInsertV18Aux_insertsThenPrunes` has been failing on main since #888. It inserts one aux row and asserts pruneV18Aux fired, which the amortised sweep cannot do — that PR changed the sweep to run once per V18_AUX_PRUNE_EVERY_ROWS (10 000) rows rather than on every batch. The Swift half of #888 handled this: StreamStore.insert takes v18AuxRetentionRows and v18AuxPruneEveryRows as parameters, and DeepCaptureChannelsTests passes 1, 7 and 5 000 to exercise the sweep, the deferral and the counter reset. The Kotlin twin kept reading the companion constants, so no test could observe the sweep without inserting ten thousand rows, and the one test that tried was left asserting the pre-#888 behaviour. android.yml is disabled, so nothing reported it. Found by @vishk23 while running the suite for #896, and correctly identified there as pre-existing rather than theirs. WhoopRepository.insert now takes both as defaulted parameters, mirroring the Swift signature. Production callers pass neither and get the shipped constants; every existing call site passes exactly two arguments, so appending defaulted parameters leaves them binding as before. Also brings the Kotlin coverage up to what Swift has had since #888: the fixed test now states why it needs a threshold of 1, and two more pin the amortisation itself — that three rows against a 5 000-row budget sweep nothing, and that two rows per batch against a budget of 3 sweep exactly once because the counter resets. Those are the twins of testRetentionSweepIsDeferredBelowTheThreshold, testRetentionSweepRunsOnceTheThresholdIsCrossed and testTheAmortisationCounterResetsAfterEachSweep. Verified: the three expected sweep counts were re-derived by simulating the exact gate (banked accumulates per device, sweeps at >= budget, resets only on a successful sweep) rather than by arithmetic in my head; all call sites checked for positional-argument binding; doc_comment_lint passes. Not compiled — Gradle cannot run on this host (aapt2 is x86-64 only) and no CI job builds Android, which is the same gap that let the regression sit on main for this long.
Owner
Author
|
That removes the "not compiled" caveat from the description. It confirms the defaulted parameters compile, and that the fixed test plus the two amortisation tests pass rather than just looking right. The branch is based on post-#902 main, so aapt2 also processed that PR's 22 new strings across six locales — the resource check I could not run locally either. The workflow triggers on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DeepCaptureMigrationTest.repositoryInsertV18Aux_insertsThenPruneshas been failing on main since #888. Found by @vishk23 while running the suite for #896, and correctly identified there as pre-existing rather than theirs.What broke
#888 made the v18-aux sweep amortised —
WhoopRepositoryprunes once perV18_AUX_PRUNE_EVERY_ROWS(10 000) rows instead of on every batch. The test inserts one row and assertspruneV18Auxfired, which the amortised path cannot do.The Swift half of #888 handled exactly this:
StreamStore.inserttakesv18AuxRetentionRowsandv18AuxPruneEveryRowsas parameters, andDeepCaptureChannelsTestspasses1,7and5_000to exercise the sweep, the deferral and the counter reset. The Kotlin twin kept reading the companion constants, so no test could observe a sweep without inserting ten thousand rows — and the one test that tried was left asserting pre-#888 behaviour.android.ymlis disabled, so nothing reported it. That is the cost of the gap, made concrete.The fix
WhoopRepository.inserttakes both as defaulted parameters, mirroring the Swift signature. Production callers pass neither and get the shipped constants. Every existing call site passes exactly two arguments, so appending defaulted parameters leaves them binding as before — checked, not assumed.The alternative was loosening the assertion to accept no sweep, which would have deleted the only Kotlin coverage of the retention path rather than fixing it.
Coverage brought up to Swift's
The fixed test now says why it needs a threshold of 1. Two more pin the amortisation itself:
testRetentionSweepIsDeferredBelowTheThreshold)testRetentionSweepRunsOnceTheThresholdIsCrossed+testTheAmortisationCounterResetsAfterEachSweep)Verification
>= budget, resets only on a successful sweep — rather than by arithmetic in my head. All three match..insert(call sites checked for positional-argument binding.doc_comment_lintpasses.Not compiled. Gradle cannot run on this host (aapt2 is x86-64 only) and no CI job builds Android. Worth a local
./gradlew testFullDebugUnitTestbefore merge — and this PR is itself the argument for enablingandroid.yml, since a disabled job is why a red test sat on main unnoticed.