fix(item): deleting a job frees its unclaimed rewards #185

Merged
nalum merged 4 commits from fix/delete-frees-unclaimed-rewards into main 2026-08-26 18:32:41 +00:00
Owner

Deleting a job left every unclaimed reward linked to it pointing at a row
that no longer exists. Every eligibility filter — client and server — skips a
reward that already has an item, so the reward was not returned to the pool.
It was destroyed, with no message and no way back.

Unlinking now runs inside the delete transaction, over the job and over each
cascaded sub-job, on the same locked-read then write path the completion
auto-claim uses. A claimed reward keeps its link: it is settled ledger
history, the points are already banked to whoever earned them, and ADR-0015
refuses to relink one anyway. Banked points are untouched either way.

The live data feed hears about the freed rows after the commit, since they
move without the svc seams.

Why now

This is the one server change the jobs flow redesign needs (#184, step 0). The
delete dialog tells the household "the 22 points reward goes back to the
rewards list" — that sentence is only true after this lands, so #176 depends
on it.

Verification

  • Two integration specs in item_integration_test.go: unclaimed rewards on the
    job and on a sub-job come back unlinked and relink to another job with no
    unlink first; a banked reward keeps its link, its claim and its value.
  • make check and make test-integration both green.

One thing the specs surfaced and now record: Claim refuses a linked reward
outright ("this reward is earned by completing its linked job"), so completion
is the only door to the banked state.

Closes nothing on its own — see #184 for the flow this unblocks.

🤖 Generated with Claude Code

Deleting a job left every unclaimed reward linked to it pointing at a row that no longer exists. Every eligibility filter — client and server — skips a reward that already has an item, so the reward was not returned to the pool. It was destroyed, with no message and no way back. Unlinking now runs inside the delete transaction, over the job and over each cascaded sub-job, on the same locked-read then write path the completion auto-claim uses. A claimed reward keeps its link: it is settled ledger history, the points are already banked to whoever earned them, and ADR-0015 refuses to relink one anyway. Banked points are untouched either way. The live data feed hears about the freed rows after the commit, since they move without the `svc` seams. ## Why now This is the one server change the jobs flow redesign needs (#184, step 0). The delete dialog tells the household "the 22 points reward goes back to the rewards list" — that sentence is only true after this lands, so #176 depends on it. ## Verification - Two integration specs in `item_integration_test.go`: unclaimed rewards on the job and on a sub-job come back unlinked and relink to another job with no unlink first; a banked reward keeps its link, its claim and its value. - `make check` and `make test-integration` both green. One thing the specs surfaced and now record: `Claim` refuses a linked reward outright ("this reward is earned by completing its linked job"), so completion is the only door to the banked state. Closes nothing on its own — see #184 for the flow this unblocks. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(item): deleting a job frees its unclaimed rewards
Some checks failed
check / commits (pull_request) Successful in 21s
check / web (pull_request) Successful in 6m11s
check / go (pull_request) Failing after 2m20s
check / report (pull_request) Successful in 3s
a7819ecbcd
A points reward linked to a deleted job kept pointing at the dead row,
and every eligibility filter excludes a reward whose item.uid is
non-empty — so the reward was not returned to the pool, it was lost.
Nothing could relink it and nothing could claim it.

Unlinking runs inside the delete transaction, over the job and over each
cascaded sub-job, on the same locked-read/write path the auto-claim uses.
Claimed rewards keep their link: they are settled ledger history, banked
points survive the job, and ADR-0015 already refuses to relink them.

Test report

Suite Tests Result Skipped
Unit 1373 ✅ pass 1
Integration 90 ✅ pass —

Coverage: 26.7%

Updated by the check workflow · commit 7ca62a0a2b

<!-- ci-test-report --> ## Test report | Suite | Tests | Result | Skipped | | --- | --: | --- | --: | | Unit | 1373 | ✅ pass | 1 | | Integration | 90 | ✅ pass | — | **Coverage:** 26.7% <sub>Updated by the check workflow · commit 7ca62a0a2bc70ed17ccb3a818020eb665d7d98c6</sub>
nalum force-pushed fix/delete-frees-unclaimed-rewards from a7819ecbcd
Some checks failed
check / commits (pull_request) Successful in 21s
check / web (pull_request) Successful in 6m11s
check / go (pull_request) Failing after 2m20s
check / report (pull_request) Successful in 3s
to 3a0abc339a
All checks were successful
check / commits (pull_request) Successful in 9s
check / go (pull_request) Successful in 3m7s
check / web (pull_request) Successful in 4m33s
check / report (pull_request) Successful in 3s
2026-08-24 09:15:27 +00:00
Compare
nalum force-pushed fix/delete-frees-unclaimed-rewards from 3a0abc339a
All checks were successful
check / commits (pull_request) Successful in 9s
check / go (pull_request) Successful in 3m7s
check / web (pull_request) Successful in 4m33s
check / report (pull_request) Successful in 3s
to 7ca62a0a2b
Some checks failed
check / commits (pull_request) Successful in 19s
check / go (pull_request) Successful in 2m52s
check / web (pull_request) Successful in 6m0s
check / report (pull_request) Successful in 3s
check / commits (push) Has been cancelled
check / go (push) Has been cancelled
check / report (push) Has been cancelled
check / web (push) Has been cancelled
tag / tag (push) Has been cancelled
2026-08-26 07:02:33 +00:00
Compare
nalum merged commit 7ca62a0a2b into main 2026-08-26 18:32:41 +00:00
nalum deleted branch fix/delete-frees-unclaimed-rewards 2026-08-26 18:32:41 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
eagraiclainne/app!185
No description provided.