Repository navigation
[2G-Bug-02]: Credit habit_completions rows toward evaluate_graduation "Already done" rate on expired nudges - #196
Merged
WilliM233 merged 1 commit intoApr 19, 2026
Conversation
…ation (#184) Expired nudges with no response are now credited when a HabitCompletion row exists for the same date. Preserves back-compat: explicit 'Already done' responses still count, and explicit non-'Already done' responses (e.g., 'Skip today') are never overridden. Implements D5 hybrid credit per [2G-01] Amendment 12 — reflects the ADHD quality lens that multiple low-friction completion paths (direct complete, routine cascade, reconciliation) all represent 'I did it' from the user's perspective. Duplication with evaluate_frequency_step_down (#185) is expected and retained; the shared read_completion_history helper refactor lives in Wave 3 (#186).
WilliM233
deleted the
feature/2G-Bug-02-evaluate-graduation-hybrid-credit
branch
April 19, 2026 17:07
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.
Verification
ruff check .— ✅ Pass (All checks passed!)pytest -v— ✅ Pass (1292 passed, 4 skipped)Ran locally against develop HEAD at
90d6989immediately before opening this PR.Summary
evaluate_graduationnow credits a same-datehabit_completionsrow when an expired nudge has no response. The result: a user who completes a habit through any path (direct complete, routine cascade, reconciliation) gets credit toward graduation — not only when they explicitly tap "Already done" on a nudge. This is the ADHD quality lens in action: multiple low-friction completion paths work better than a single path, and all of them feel like "I did it" to the user.Explicit responses still win. An explicit
"Already done"counts on its own (back-compat preserved). An explicit non-"Already done"response (e.g.,"Skip today") is never overridden by a completion row — a user saying "no" to a nudge means no, even if reconciliation later recorded a completion.Changes
app/services/graduation.py—evaluate_graduationnow querieshabit_completionsover the evaluation window and builds a set of completion dates. Thealready_done_countderivation iterates notifications:"Already done"responses count as before; expired notifications withresponse IS NULLcount if a same-date completion exists; all other explicit responses are untouched.GraduationResultshape unchanged.tests/test_graduation.py— newTestEvaluateGraduationHybridCreditclass covers the five acceptance tests from the issue (routine-cascade credit, individual credit, no-credit-without-row, no-credit-on-date-mismatch, explicit-"Already done" back-compat) plus an explicit-negative-override guard.How to Verify
git checkout feature/2G-Bug-02-evaluate-graduation-hybrid-creditruff check .— passes cleanpytest -v tests/test_graduation.py— all 160 graduation tests pass, including the 6 new hybrid-credit testspytest -v— full suite: 1292 passed, 4 skippedDeviations
None. Implementation matches the GitHub issue acceptance criteria and
[2G-01]v2 Amendment 12.Per Wave 2 brief guidance (D7, Wave 3 #186): the hybrid-credit logic here is deliberately inline. Duplication with the companion step-down fix (#185) is expected and retained — the shared
read_completion_historyhelper refactor lands in Wave 3 as #186.Test Results
```
$ ruff check .
All checks passed!
$ pytest -v
====================== 1292 passed, 4 skipped in 21.73s =======================
```
New tests in
TestEvaluateGraduationHybridCredit:test_routine_cascade_completion_credited_toward_graduationtest_individual_completion_credited_toward_graduationtest_no_credit_when_no_completion_rowtest_no_credit_when_date_mismatchtest_response_already_done_still_counts_without_completion_rowtest_explicit_negative_response_not_overridden_by_completionAll existing graduation tests continue to pass (AC #6).
Acceptance Checklist
evaluate_graduationreads bothnotification_queue.response='Already done'andhabit_completionsrows dated to expired-nudge datesresponse IS NULL+ matching same-dateHabitCompletion→ counted towardalready_done_count"Already done"continues to count regardless of completion-row presence (back-compat)"Already done"responses (e.g.,"Skip today") are NOT overridden by a completion rowGraduationResultresponse shape unchanged; onlyalready_done_count/ derivedcurrent_ratedifferCloses #184