Habits: close days with the tracker, vacations and a pg-boss job #3

Merged
alex merged 7 commits from feat/habits-day-closing into feat/habits-goals 2026-10-30 19:23:05 +01:00
Owner
  • Tracker aggregate, one per user: time zone, week start, vacations (at most 90 days, never in the past, cut short when cancelled while running). A day closes at local midnight plus 3 hours, in order.
  • habits.close_days job every 5 minutes on pg-boss. Per user and day it closes the tracker's day, judges each habit, then records the summary that announces DayClosed. One transaction per step; each step is idempotent and an interrupted run is resumed. A user several days behind catches up, up to 7 days per run.
  • Platform jobs library: recurring jobs that never overlap across API instances, started after boot and drained on shutdown.
  • Instant.startOfDay and TimeZone.offsetAt, tested across a daylight-saving change.
  • Tracker API; the web app sets the tracker up from the device and follows its time zone.

Open question in docs/contexts/habits.md: changing the week start after set-up.

🤖 Generated with Claude Code

- `Tracker` aggregate, one per user: time zone, week start, vacations (at most 90 days, never in the past, cut short when cancelled while running). A day closes at local midnight plus 3 hours, in order. - `habits.close_days` job every 5 minutes on pg-boss. Per user and day it closes the tracker's day, judges each habit, then records the summary that announces `DayClosed`. One transaction per step; each step is idempotent and an interrupted run is resumed. A user several days behind catches up, up to 7 days per run. - Platform `jobs` library: recurring jobs that never overlap across API instances, started after boot and drained on shutdown. - `Instant.startOfDay` and `TimeZone.offsetAt`, tested across a daylight-saving change. - Tracker API; the web app sets the tracker up from the device and follows its time zone. Open question in `docs/contexts/habits.md`: changing the week start after set-up. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The Tracker aggregate holds each user's time zone, week start and
vacations, and closes days in order once local midnight plus the grace
period has passed. A recurring job (habits.close_days, every 5 minutes,
on a new pg-boss platform library) runs the closing process: close the
day on the tracker, judge every habit in its own transaction, then
record the summary that announces DayClosed. Every step is idempotent
and an interrupted day is resumed before the next one is closed.

The web app sets its tracker up from the device's zone and locale,
follows the device across time zones, and uses the real week start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The alias was missing from the previous commit, so the branch did not
build on a clean checkout. Also records Nx's analytics opt-out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The relay drains the outbox in commit order under an advisory lock, hands each
entry to its own context's projections and, when the context's publisher
translates it, to every subscriber as an integration event. A failing entry
holds later ones back and is set aside after five attempts. Consumers
deduplicate through platform.inbox inside their own unit of work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ledger and Vitality aggregates fed by Habits' integration events through an
anti-corruption layer; one versioned balance policy; a projection of granted
rewards; GET /api/rewards/ledger and /api/rewards/vitality.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed-on: https://git.selene.acl.sh/Habitea/App/pulls/4
alex merged commit ed490ff349 into feat/habits-goals 2026-10-30 19:23:05 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
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
Habitea/App!3
No description provided.