testsAndMisc/docs/superpowers/evidence/enforcement-log-test-split-2026-08-16.json
Krzysztof kuhy Rudnicki 3b37d7b422 Split the fix-selection tests out of EnforcementLogTest
EnforcementLogTest was 251 lines and covered two unrelated subjects: the
log itself, and EnforcementRunner.best's fix-selection ordering. The six
best() tests move to EnforcementRunnerBestTest; 251 -> 169 + 90.

The shared candidate() builder is hoisted into the existing
EnforcementFixtures object rather than copied, and EnforcementLogTest now
takes homeLat/homeLon from there too -- the home coordinates should exist
in one file, given this suite asserts they never reach a log record.

Verified by running, not just building: 40 tests, 0 failures, 0 skipped,
matching the documented focus_owner Kotlin baseline; the original 15 are
preserved as 9 + 6.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-16 22:46:51 +02:00

45 lines
3.4 KiB
JSON

{
"intent": "Bring EnforcementLogTest.kt (251 lines) under the 250-line cap by splitting off the six EnforcementRunner.best fix-selection tests, which share no subject with the log tests.",
"scope": [
"focus_owner/android/app/src/test/kotlin/com/kuhy/focus_owner/EnforcementLogTest.kt",
"focus_owner/android/app/src/test/kotlin/com/kuhy/focus_owner/EnforcementRunnerBestTest.kt (new)",
"focus_owner/android/app/src/test/kotlin/com/kuhy/focus_owner/EnforcementFixtures.kt",
"Non-goal: no assertion changed, no test deleted, skipped or weakened; no production code touched"
],
"changes": [
"Move the six `EnforcementRunner.best` tests into a new EnforcementRunnerBestTest class, verbatim including their explanatory comments.",
"Hoist the shared `candidate()` fix builder into the existing internal EnforcementFixtures object rather than duplicating it, per docs/app-split-recipes.md's Kotlin rule.",
"Point EnforcementLogTest's homeLat/homeLon at EnforcementFixtures so the home coordinates exist in exactly one file -- the file has a test asserting those coordinates never reach a log record."
],
"verification": [
{
"command": "JAVA_HOME=/usr/lib/jvm/java-21-openjdk ./gradlew :app:testDebugUnitTest --tests 'com.kuhy.focus_owner.EnforcementLogTest' (baseline, before the split)",
"result": "pass",
"evidence": "BUILD SUCCESSFUL; TEST-...EnforcementLogTest.xml reported tests=\"15\" failures=\"0\" errors=\"0\" skipped=\"0\"."
},
{
"command": "JAVA_HOME=/usr/lib/jvm/java-21-openjdk ./gradlew :app:testDebugUnitTest --tests 'com.kuhy.focus_owner.*' (after the split)",
"result": "pass",
"evidence": "BUILD SUCCESSFUL. Summed JUnit XML: tests=40 failures=0 errors=0 skipped=0, matching the documented 40-test focus_owner Kotlin baseline. Per class: EnforcementDecisionCurfewTest 13, EnforcementDecisionTest 12, EnforcementLogTest 9, EnforcementRunnerBestTest 6 -- the original 15 preserved as 9+6."
},
{
"command": "bash ~/utils/scripts/check_file_length.sh focus_owner/android/app/src/test/kotlin/com/kuhy/focus_owner/*.kt",
"result": "pass",
"evidence": "Exit 0. EnforcementLogTest 251 -> 169; EnforcementRunnerBestTest 90; EnforcementFixtures 77 -> 92. All five files under 250."
},
{
"command": "Intermediate failure, recorded deliberately: an initial attempt wrote a fresh EnforcementFixtures.kt over the existing one",
"result": "fail, then fixed",
"evidence": "compileDebugUnitTestKotlin FAILED with 14 'Unresolved reference' errors (homeLat, policy, installed, latOffset...) from EnforcementDecisionTest and EnforcementDecisionCurfewTest. Restored via `git checkout --` and re-applied as an extension of the existing object. This is the exact failure docs/app-split-recipes.md warns about -- list every private member before cutting."
}
],
"risks": [
"Low: test-only change. The gradle run is the full authority here and it matches the baseline exactly.",
"EnforcementLogTest keeps its own fix() builder (outcome ACTIVE_OK) separate from the shared candidate() (CACHED_FRESH); merging them would change what the log tests exercise, so they stay distinct."
],
"rollback": [
"git revert the commit; EnforcementRunnerBestTest.kt disappears and the six tests return to EnforcementLogTest.kt.",
"Re-run the gradle command above and confirm tests=40 failures=0."
]
}