Fix outage data loss with per-target fetch cursors; audit cleanups; 1.8.1#55
Merged
Conversation
….8.1 The fetch cursor was the latest synced timestamp across ALL targets. If Garmin auth broke while Strava kept syncing, Strava kept advancing that shared cursor, and once Garmin recovered the fetch started after the outage window: those weigh-ins never reached Garmin and nothing retried them. The cursor is now per target and the fetch starts from the oldest one; the up-to-date target skips re-fetched measurements via is_synced. This also subsumes the new-target 7-day backfill branch (a target with no rows gets a 7-day cursor), so has_any_syncs is gone. Also from the audit: - Same-date guard: a skipped-because-already-in-Garmin row no longer counts as "we uploaded on this date", so a second measurement that day can't slip past the guard and duplicate an external entry. - Date lookups narrow the scan with a SQL two-day window before the exact local-date check in Python. - app.py: extract _tally_run and _target_label (each was copy-pasted). - --install-agent now requires a config, so a fresh machine can't schedule an agent that fails every few hours. - --status Garmin hint now says --reauth garmin like everywhere else. - README documents --history; pyproject gains Homepage and Funding URLs. - Flatten the keep-db conditional in --uninstall. 332 tests, 5 new (outage recovery, new-target backfill, per-target cursor, skip-row guard at both state and sync level). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
An Opus 4-lens audit (correctness, quality, security, UX/docs) found one real bug and a handful of cleanups. This ships all of it.
The bug: a Garmin outage permanently lost measurements
sync_userfetched only measurements newer than the latest synced timestamp across all targets. With Garmin auth down and Strava healthy, Strava kept advancing that shared cursor. After--reauth garmin, the fetch started past the outage window, so those weigh-ins never reached Garmin and nothing ever retried them.Fix: each target keeps its own cursor and the fetch reaches back to the oldest one. The healthy target skips re-fetched measurements through the existing
is_synceddedup. A target with no rows yet gets a 7-day cursor, which replaces the old new-target backfill branch.Also in here
has_synced_on_date/weight_only_syncs_on_datenarrow the scan with a SQL date window instead of reading every row.--install-agentrefuses on a machine with no config instead of scheduling an agent that fails every few hours.--statusnow suggests--reauth garminlike every other surface.--history; pyproject gains Homepage and Ko-fi Funding links for PyPI.Security lens came back clean. 332 tests pass, 5 new.
🤖 Generated with Claude Code