Skip to content

fix(chores): prune a half-done split once its any-day period ends - #410

Merged
jherforth merged 2 commits into
jherforth:mainfrom
adamecker:fix/split-any-day-expiry
Dec 2, 2026
Merged

jherforth merged 2 commits into
jherforth:mainfrom
adamecker:fix/split-any-day-expiry

Conversation

@adamecker

Copy link
Copy Markdown
Contributor

Bug

mrramam reported (Dec 1, on #407, reproduced on f6f103e with a fresh database): a half-done split on an any-day chore never expires. Weekly any-day 5-Star bonus chore, card due Saturday, split Ava + Ben, Ava ticks. After Saturday the nightly job keeps the card — still visible with the split a week and two weeks later. The chore gets no new weekly card. Ben can still tick the stale card after its due date and is paid, and his open share blocks his bonus claims (409 "already has an outstanding bonus chore" 15 days later).

Cause

Two guards that are right for plain one-time splits combine badly on an any-day card:

  • The nightly prune only takes a split once every share is ticked.
  • The split return keeps a one-time split with a ticked share.

An expired any-day card is one-time, so neither path lets it go.

Fix

The period ending now prunes the card regardless of its ticks: the prune query marks rows matched by the any-day-expiry branch, and the filter prunes those unconditionally. A ticked share stays earned — the prune moves its history row to the parent schedule, as it already does — and the next period rolls a fresh unsplit card like an unsplit any-day chore. The split return is untouched: it never sees the card, because the prune runs first. No client change: once the server prunes the card, it is gone everywhere.

Regression test

server/tests/bonusChoreSplitAssign.test.js: "a half-done split on an any-day chore expires with its period" — reproduces the bug on f6f103e (failed before the fix: the stale card survived the nightly run with the split intact), then verifies all five: the stale card is pruned; Ava's 3 Stars stay earned (history moved to the parent); Ben's late tick is a 404; a fresh unsplit card rolls for the new week; Ben can claim again. A second nightly changes nothing.

Verification

  • Full server suite: 862 pass, 0 fail.
  • End-to-end on a running test instance from this branch (throwaway DB): the same scenario through the HTTP API — nightly pruned 1 schedule, stale card gone, Ava's 3-Star completion kept, Ben's late tick 404, fresh card due Saturday, Ben's claim 200.

A split on an any-day card never expired: the nightly prune only took
a split once every share was ticked, and the split return kept a
one-time split with a ticked share, so an expired any-day card stayed
visible for weeks — its open share could still be ticked and paid, and
it blocked its holder's bonus claims.

The period ending now prunes the card regardless of its ticks: a ticked
share stays earned in history, and the next period rolls a fresh card
like an unsplit any-day chore.

Regression test: a half-done split on an any-day chore expires with its
period (server/tests/bonusChoreSplitAssign.test.js).
@jherforth

Copy link
Copy Markdown
Owner

Thanks, Adam. This is the right fix, and a tidy one. The regression test fails on main and passes here, the split tests pass 21/21, and the full server suite passes 862/862.

One small thing before it goes in. The nightly job's description in docs/reference/backend-api.md (lines 66–68) still says a half-done one-time split "stays split until every share is ticked". An any-day card is now the exception. Something like:

… except a half-done one-time split, which stays split until every share is ticked (issue #407). An any-day card goes when its period ends, split or not: a ticked share stays earned, and the next period starts with a fresh card.

Once that's in, it's good to merge.

The nightly-job description still said a half-done one-time split
stays split until every share is ticked (issue jherforth#407), with no
exception for any-day cards. PR jherforth#410 prunes those when their period
ends, split or not: a ticked share stays earned, and the next period
starts with a fresh card.
@adamecker

Copy link
Copy Markdown
Contributor Author

Done — added that note to the nightly-job description in docs/reference/backend-api.md: an any-day card goes when its period ends, split or not, a ticked share stays earned, and the next period starts with a fresh card. Thanks for the review!

@jherforth
jherforth merged commit 2243164 into jherforth:main Dec 2, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in HomeGlow Kanban Dec 2, 2026
adamecker pushed a commit to adamecker/HomeGlow that referenced this pull request Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants