Repository navigation
Phase 3: persistence + time in app - #5
Merged
Merged
Conversation
- Room v1 (schema exported): daily_app_aggregate (+ calibrationVersion, activeScrollMs), scroll_session, daily_app_usage. Insert-or-add as INSERT OR IGNORE + additive UPDATE in one transaction (API 28 has SQLite 3.22, no UPSERT); usage days replaced per range. - ScrollPipeline (pure Kotlin, single-threaded): accumulator, sessions, flush every 10 s / 50 events / new day / interrupt / end of pipeline; the write is NonCancellable, a failed write is retried. The own package is never stored (debug test mode measures it live only). - Time in app: UsageEventsSource, ForegroundTimeAggregator (local days, DST, grace for activity switches), UsageSyncer (window from last sync, replace), UsageAccessChecker; sync on resume, on stale connect, on day change. PACKAGE_USAGE_STATS, optional. - SettingsRepository (DataStore) feeds excluded packages to the engine. - Permissions are an allowlist in PolicyGuardTest and check_manifest_policy.py; pure packages guarded against Android imports. - Home shows today's stored distance. - ADR-025 (time in app details), ADR-026 (persistence); docs updated. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Session and active-scroll gaps judge the pause on uptime and wall clock: eventTime stops in deep sleep, so an hour asleep between two scrolls no longer continues a session. - The pipeline publishes what it counted but has not committed yet; ScrollRepository adds it to every distance, so Home's "Dnes" is exact at once instead of up to 10 s late. The confusing since-connect line is gone. - ADR-027: dataExtractionRules exclude every domain from cloud backup and device-to-device transfer. Guards: rules file pinned, sdk-23 permission tag checked, exact package match for the androidx permission, exported components need a permission (Compose PreviewActivity tolerated in debug only). - Service and usage sync read settings without falling back to defaults on a read error — exclusions never fail open. - Usage-access intent falls through on any RuntimeException. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- ScrollPipeline.flush() takes a mutex: Room writes on its own executor, which let a ticker / interrupt flush start during a running write. New test with a suspending store fails without the mutex. - Home re-reads today's date at local midnight while it stays open. - Emulator reboot and the R8 release build recorded in docs/accuracy-testing.md; handoff.md: Phase 3 exit report, debt V4/V5, open points closed (D2D, calibrationVersion) and added (Phase 6 wipe). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Phase 3 — Persistence + čas v aplikaci (PLAN.md Phase 3)
Goal: data survives kill, restart, app switches and day changes; at most one flush interval (10 s) lost.
What changed
scrollmeter.db, schema JSON inapp/schemas/):daily_app_aggregate(SPEC §17 +calibrationVersion+activeScrollMs),scroll_session,daily_app_usage. Insert-or-add in one transaction (INSERT OR IGNORE+ additiveUPDATE; API 28 has SQLite 3.22, no UPSERT) — ADR-026.ScrollPipeline(pure Kotlin, single-threaded): accumulator + sessions; flush every 10 s while pending / 50th event / new day /onInterrupt/ end of the pipeline;NonCancellablewrite, retry on failure, flushes serialized. Own package never stored.ScrollRepository→ Home "Dnes" is exact immediately.eventTimestops in deep sleep).UsageEventsSource→ForegroundTimeAggregator(local days, DST, 2 s activity-switch grace) →UsageSyncer(window from last sync, replace); sync on app resume, stale service connect (≥ 6 h), day change.PACKAGE_USAGE_STATSoptional.PolicyGuardTestandcheck_manifest_policy.py(incl.uses-permission-sdk-23, exported components); ADR-027dataExtractionRules— no cloud backup, no device-to-device transfer; pure packages guarded against Android imports.Definition of Done
ForegroundTimeAggregatorTest: two RESUMED = once, 23:50→00:10 = 10 + 10 min, DST 23/25 h, SCREEN_OFF, SHUTDOWN/STARTUP, unpaired PAUSED, open cut at now, split screen, own package, API 28 codes 1/2kill -9lost only the unflushed ~4 s and the service came back; force-stop documented (it disables the service); screen off/on; two apps; reboot keeps data; time in app = systemtotalTimeUsedto the second; R8 release runsGates
./gradlew testDebugUnitTest lintDebug assembleDebug assembleRelease(168 tests, lint: 6 pre-existing debug warnings) ·python3 -m unittest discover -s tools -p 'test_*.py'(24) ·check_manifest_policy.pyok for debug and release.Review
/topshitover the cumulative diff → sleep-safe gaps, live totals, R8 run, D2D exclusion.ADRs: 025, 026, 027. Docs: architecture, measurement-model, accessibility-policy, accuracy-testing, README, handoff.
🤖 Generated with Claude Code