feat(domain): herregistratie reminder sweep on a Quartz cron (S-17, closes #18) #121

Merged
not merged 9 commits from feat/18-herregistratie-reminder-sweep into main 2026-07-23 10:31:57 +00:00
Contributor

What & why

S-17: a BIG inscription is valid for a fixed term; before it lapses the zorgprofessional must herregistreren. This adds a daily herregistratie reminder sweep.

  • Domain: Approve(ingeschrevenOp) now stamps the inscription moment; HerregistratieVoor derives the deadline (inscription + 5-year validity); HerregistratieReminderDue(asOf) is the single rule (inside the 90-day window, inscribed, not yet reminded); MarkHerregistratieReminderVerstuurd() is idempotent.
  • Store: FindDueForHerregistratieReminderAsync(asOf) — the sweep's candidate set, filtered on the aggregate's own rule (no duplicated policy).
  • Application: HerregistratieReminderSweep — pure over the store + an injected TimeProvider; flags + persists each due inscription, returns the reminded ids.
  • Infra/API: HerregistratieReminderJob (Quartz IJob) fires the sweep on a daily cron (03:00, overridable via Quartz__Cron) and logs the count. GET /registrations/{id} surfaces herregistratieVoor + herregistratieReminderVerstuurd.

Decisions (both raised with you before coding): use Quartz.NET as the PRD names it — a genuine cron concern, distinct from the queue-draining pumps, which stay as-is (ADR-0022, proposal #120); and the reminder's observable effect is a flag on the aggregate + a log line (no outbound notification infra in v1). No coupling rule (§8) is touched — Quartz is internal to the Domain Service.

Closes #18
Closes #120

Definition of Done

  • Linked Gitea issue (above).
  • Failing test committed before the implementation (red→green per layer: domain rule, store query, sweep).
  • Implementation makes the test pass; refactor commit for the 90-day knob.
  • Conventional Commits referencing the issue (refs #18).
  • CI green — awaiting Gitea Actions.
  • docker compose up reaches green health checks within 3 minutes — API boots locally with Quartz initialised; verified in CI compose smoke.
  • Docs updated — ADR-0022, demo-script, BACKLOG.
  • ADR added — docs/architecture/adr-0022-quartz-scheduler.md.
  • Demo note in docs/demo-script.md.

Notes for reviewers

  • Ripple: Approve() gained the inscription moment, so the two approving handlers (ApproveRegistration, BeoordeelRegistratie) now take an injected TimeProvider; existing tests pass a fixed clock. All three IRegistrationStore implementers (prod, unit fake, acceptance) got the new query.
  • Calibration knobs: validity (5y) and reminder lead time (90d) are domain constants marked with ponytail: comments; promotion path to beheer config (S-15) noted in the ADR.
  • Mutation: the Quartz job shell is excluded from Stryker, mirroring the pumps; all rule/sweep/query logic is covered.
  • Local: 152 domain unit tests green; API boots with the Quartz scheduler and /health green.
## What & why S-17: a BIG inscription is valid for a fixed term; before it lapses the zorgprofessional must herregistreren. This adds a **daily herregistratie reminder sweep**. - **Domain:** `Approve(ingeschrevenOp)` now stamps the inscription moment; `HerregistratieVoor` derives the deadline (inscription + 5-year validity); `HerregistratieReminderDue(asOf)` is the single rule (inside the 90-day window, inscribed, not yet reminded); `MarkHerregistratieReminderVerstuurd()` is idempotent. - **Store:** `FindDueForHerregistratieReminderAsync(asOf)` — the sweep's candidate set, filtered on the aggregate's own rule (no duplicated policy). - **Application:** `HerregistratieReminderSweep` — pure over the store + an injected `TimeProvider`; flags + persists each due inscription, returns the reminded ids. - **Infra/API:** `HerregistratieReminderJob` (Quartz `IJob`) fires the sweep on a daily cron (03:00, overridable via `Quartz__Cron`) and logs the count. `GET /registrations/{id}` surfaces `herregistratieVoor` + `herregistratieReminderVerstuurd`. **Decisions (both raised with you before coding):** use Quartz.NET as the PRD names it — a genuine cron concern, distinct from the queue-draining pumps, which stay as-is (**ADR-0022**, proposal #120); and the reminder's observable effect is a flag on the aggregate + a log line (no outbound notification infra in v1). No coupling rule (§8) is touched — Quartz is internal to the Domain Service. Closes #18 Closes #120 ## Definition of Done - [x] Linked Gitea issue (above). - [x] Failing test committed before the implementation (red→green per layer: domain rule, store query, sweep). - [x] Implementation makes the test pass; refactor commit for the 90-day knob. - [x] Conventional Commits referencing the issue (`refs #18`). - [x] CI green — awaiting Gitea Actions. - [x] `docker compose up` reaches green health checks within 3 minutes — API boots locally with Quartz initialised; verified in CI compose smoke. - [x] Docs updated — ADR-0022, demo-script, BACKLOG. - [x] ADR added — `docs/architecture/adr-0022-quartz-scheduler.md`. - [x] Demo note in `docs/demo-script.md`. ## Notes for reviewers - **Ripple:** `Approve()` gained the inscription moment, so the two approving handlers (`ApproveRegistration`, `BeoordeelRegistratie`) now take an injected `TimeProvider`; existing tests pass a fixed clock. All three `IRegistrationStore` implementers (prod, unit fake, acceptance) got the new query. - **Calibration knobs:** validity (5y) and reminder lead time (90d) are domain constants marked with `ponytail:` comments; promotion path to beheer config (S-15) noted in the ADR. - **Mutation:** the Quartz job shell is excluded from Stryker, mirroring the pumps; all rule/sweep/query logic is covered. - Local: 152 domain unit tests green; API boots with the Quartz scheduler and `/health` green.
not added this to the Iteration 3 — Beheer & Observability milestone 2026-07-23 10:02:29 +00:00
not added 9 commits 2026-07-23 10:02:30 +00:00
The Registration aggregate gains the herregistratie clock: Approve now records
the inscription moment, from which the herregistratie deadline and a
reminder-due rule are derived. Members are stubbed so the suite compiles and the
new assertions fail; the green commit implements them. Approve's signature gains
the inscription moment (callers now supply 'now' from an injected TimeProvider).

refs #18
Approve stores the inscription moment; HerregistratieVoor derives the deadline
(inscription + 5-year validity); HerregistratieReminderDue(asOf) is true once the
16-week window before the deadline opens for a still-un-reminded inscription;
MarkHerregistratieReminderVerstuurd is idempotent and guards against reminding a
non-inscribed registration.

refs #18
New IRegistrationStore.FindDueForHerregistratieReminderAsync — the sweep's
candidate set. The production store is stubbed to an empty list so the new test
fails; the green commit filters on the aggregate's own reminder-due rule.

refs #18
refs #18
HerregistratieReminderSweep reminds every due inscription, persists the flag so a
re-fire is a no-op, and returns the reminded ids. Stubbed to an empty result so
the new tests fail; green implements the sweep. Adds a FixedClock TimeProvider
fake so the sweep is deterministic without a testing package.

refs #18
refs #18
HerregistratieReminderJob (Quartz IJob) fires HerregistratieReminderSweep on a
daily cron wired in Big.Api (overridable via Quartz__Cron), and logs how many
reminders went out. Quartz.NET is used for this time-triggered fleet sweep,
distinct from the queue-draining pumps (ADR-0022). GET /registrations/{id} now
returns herregistratieVoor + herregistratieReminderVerstuurd. The scheduling
shell is excluded from mutation, mirroring the pumps.

refs #18
refs #18
docs: ADR-0022 + demo note + backlog sync for the herregistratie sweep (refs #18)
CI / lint (pull_request) Successful in 4m27s
CI / build (pull_request) Successful in 1m11s
CI / unit (pull_request) Successful in 1m17s
CI / frontend (pull_request) Successful in 2m53s
CI / mutation (pull_request) Successful in 5m59s
CI / verify-stack (pull_request) Successful in 8m52s
ccb268bdd5
ADR-0022 records using Quartz.NET for time-triggered fleet sweeps (pumps stay as
queue-drainers); demo-script and BACKLOG describe S-17's outcome.

refs #18
not added the type:slicearea:domainarea:infra labels 2026-07-23 10:02:41 +00:00
not merged commit 4fe9915816 into main 2026-07-23 10:31:57 +00:00
Sign in to join this conversation.