Skip to content

drift/02a: backfillWorkout no longer drops stored steps - #20

Merged
bhelm merged 1 commit into
drift/metafrom
drift/02a-fix-backfill-steps
Aug 18, 2026
Merged

bhelm merged 1 commit into
drift/metafrom
drift/02a-fix-backfill-steps

Conversation

@bhelm

@bhelm bhelm commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Fixes #16 (plan step 2 of #17). WorkoutDetector.backfillWorkout rebuilds the WorkoutRow through the initializer and passed every field except steps — so any backfill silently nulled stored per-session steps, and an all-fields-present row compared != to its input, making the caller rewrite a row that needed no write (upsertWorkouts then persisted steps = NULL). The doc comment promised the opposite. The Kotlin twin (IntelligenceEngine.backfillWorkoutFromDetectedBout, real.copy(...)) was never affected — a drift where Kotlin is right and Swift loses data.

The fix

Field-by-field audit of WorkoutRow (13 fields) against the initializer call: steps was the only one dropped. The fix passes steps: real.steps through; one overclaiming clause in the doc comment tightened (unchanged means no available value was filled).

Verification

  • Red before fix: both new tests fail (filled.steps was nil, expected 4200; full-row == contract broken).
  • Green after: filtered run 2/2; full StrandAnalytics suite 1426 tests, 0 failures (Linux, Swift 6.0.3).
  • Kotlin: untouched, structurally immune via real.copy(...).

Review

Codex review (read-only, independent): verdict green. Confirmed: the 13-field audit (nothing else dropped), test sharpness against the original bug (both tests catch it), the single production callsite's write behavior (backfilled != hit → the fix stops both the data loss and the previously spurious rewrite), Kotlin needs no change. Its one small finding (overclaiming doc clause) is folded in.

Part of the drift-control plan in #17.

🤖 Generated with Claude Code

WorkoutDetector.backfillWorkout rebuilds the WorkoutRow through the
initializer and passed every field except steps, silently nulling stored
per-session steps on any backfill — and making an all-fields-present row
compare != to its input, so callers rewrote rows that needed no write.
The doc comment promised the opposite; the Kotlin twin (real.copy(...))
was never affected.

Field-by-field audit of WorkoutRow (13 fields): steps was the only one
dropped. Regression tests cover steps survival and the ==-when-complete
contract; red before the fix (2 failures), full suite 1426/0 after.

Part of the drift-control plan in #17 (step 2).

Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bhelm
bhelm merged commit 9c42fcb into drift/meta Aug 18, 2026
@github-actions
github-actions Bot deleted the drift/02a-fix-backfill-steps branch August 31, 2026 10:53
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