Calendar: in-app reminders — Fable #36 N1–N3 and its three rulings
N1: TestOneRuleTwoOccurrencesAreBothDeliveredInOnePass (a daily rule drained a day late delivers both; a guard keyed by rule alone fails it, checked). N2: the seam is wrapped in a provider for Home's kind, not passed as Read. N3: MarkReminderNotice says what the mark-then-complete window costs. Spec §7 records the approval and the rulings: no retro-update of existing rules, a Nav link, hidden rather than deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed,
+66
−8
docs/superpowers/specs/2026-09-02-calendar-design.md+36 −4internal/calendar/inapp_reminders_test.go+16 −0internal/calendar/reminder_seam.go+5 −4internal/calendar/store_reminder_notice.go+9 −0
CI passed — run details
Intent
diff --git a/docs/superpowers/specs/2026-09-02-calendar-design.md b/docs/superpowers/specs/2026-09-02-calendar-design.md| index 5e524cd..0ba3841 100644 |
| --- a/docs/superpowers/specs/2026-09-02-calendar-design.md |
| +++ b/docs/superpowers/specs/2026-09-02-calendar-design.md |
| @@ -624,11 +624,43 @@ notice, an opaque ID, an absolute link on this origin and the occurrence's |
| start** — no title, so Home holds no content even transiently beyond a |
| link. It is not mounted: home/dashboard's provider takes only the kinds |
| `documents` and `events` today, and the notification centre is Home's |
| -design to make. When it exists, a provider for its new kind passes this |
| -function as `Read` (behind the same bearer, replay and `Resolve` checks) |
| -and nothing in Calendar's storage changes. |
| +design to make. When it exists, Calendar wraps this function in a |
| +provider for its kind (it is not itself a dashboard `Read`: it returns a |
| +`NoticeSummary`, and its `now` is unused), behind the same bearer, replay |
| +and `Resolve` checks, and nothing in Calendar's storage changes (Fable #36 |
| +N2). |
| + |
| +**Reviewed by Claude Fable 5.1 (claude-fable-5-1) on oficina/calendar |
| +#36, APPROVED at `2106519`**, the sibling table accepted in place of the |
| +flag on `reminder_queues` its own sketch had. Its rulings on the three |
| +questions: |
| + |
| +1. **A Settings change does not rewrite existing rules.** The channel is a |
| + property of the rule, the event page names each rule's channel, and a |
| + per-rule choice made on the event page must never be silently rewritten |
| + by a preference. If "new rules only" proves annoying in use, the later |
| + shape is an explicit, unticked Settings checkbox ("Change my existing |
| + reminders too") that rewrites only rules still on the PREVIOUS |
| + preference, never ones chosen per rule, and never a Home-only member's. |
| +2. **Reminders is a Nav link, not a bar Action.** It is a place you go, |
| + not a verb; the bar has no actions (calendar.md §B2); the count is text |
| + in the label, so not colour alone, and it reads the same in the narrow |
| + Menu sheet. Appended after Calendars, so nothing shifts when it appears. |
| +3. **A notice on an event out of reach is hidden, not deleted.** Its |
| + lifetime is its rule's, and a soft-deleted event keeps its rules, so |
| + hiding adds no growth. Reach can come back (a re-added member's dormant |
| + rule wakes, a grant returns, a cancellation is reverted) and the notice |
| + is then there again. Deleting on a read path would be a write nobody |
| + asked for; a sweep is a job nobody needs yet. |
| + |
| +The two transactions of a delivery (the mark, then the completion) leave |
| +the window the email path already has, said on `MarkReminderNotice` (N3); |
| +one rule with two occurrences due in one pass is delivered twice, the case |
| +only the rule-and-occurrence guard protects (N1, |
| +`TestOneRuleTwoOccurrencesAreBothDeliveredInOnePass`). |
| **Not built.** Push to the native apps or the browser; email for a |
| Home-only member (option (b), its own privacy review); a "seen" state |
| apart from dismissed; expiry of old undismissed notices (they are bounded |
| -by rules); a channel change rewriting existing rules. |
| +by rules); a channel change rewriting existing rules (the checkbox above, |
| +if wanted). |
diff --git a/internal/calendar/inapp_reminders_test.go b/internal/calendar/inapp_reminders_test.go| index 56ad499..b8b5ae4 100644 |
| --- a/internal/calendar/inapp_reminders_test.go |
| +++ b/internal/calendar/inapp_reminders_test.go |
| @@ -143,6 +143,22 @@ func TestTwoRulesOnOneOccurrenceAreBothDeliveredInOnePass(t *testing.T) { |
| } |
| } |
| +// ONE rule whose next occurrence is already due inside the same pass (a |
| +// daily series, drained a day late) is owed both: the guard is keyed by |
| +// rule AND occurrence, and a key by rule alone would stop the pass here |
| +// (Fable #36 N1). |
| +func TestOneRuleTwoOccurrencesAreBothDeliveredInOnePass(t *testing.T) { |
| + w := newPlainWorld(t) |
| + w.app.db.G.Model(&Person{}).Where("id = ?", w.person.ID).Update("reminder_channel", ChannelInApp) |
| + start, end := soon(5) |
| + if rec := w.do("POST", "/events", url.Values{"calendar_id": {itoa(w.calendar)}, "title": {"Daily, late"}, "start": {start}, "end": {end}, "tz": {"UTC"}, "kind": {"meeting"}, "status": {"confirmed"}, "repeat": {"daily"}}); rec.Code != http.StatusSeeOther { |
| + t.Fatalf("create = %d", rec.Code) |
| + } |
| + if sent, _, err := w.app.h.drain(context.Background(), time.Now().Add(24*time.Hour)); err != nil || sent != 2 { |
| + t.Fatalf("drain a day late = %d %v, want both occurrences delivered", sent, err) |
| + } |
| +} |
| + |
| // The mark is conditional on the claim, as every completion is: a |
| // reschedule that overtook the claim announces nothing. |
| func TestAnOvertakenClaimMarksNothing(t *testing.T) { |
diff --git a/internal/calendar/reminder_seam.go b/internal/calendar/reminder_seam.go| index c92389a..afedc4b 100644 |
| --- a/internal/calendar/reminder_seam.go |
| +++ b/internal/calendar/reminder_seam.go |
| @@ -9,10 +9,11 @@ package calendar |
| // a link to each. reminderNotices is that read, shaped like |
| // dashboardEvents — the Read home/dashboard's provider calls today, with |
| // (ctx, person, verified subject, now) in and an answer or an |
| -// unavailability out — so that when Home has a kind for it, a provider |
| -// mounts this behind the same bearer, replay and Resolve checks the |
| -// dashboard pull already has (dashboard.go), and nothing in Calendar's |
| -// storage changes. |
| +// unavailability out. It is not itself a dashboard Read (it returns a |
| +// NoticeSummary, not a dashboard.Response, and its now is unused): when |
| +// Home has a kind for it, Calendar wraps this in a provider for that kind, |
| +// behind the same bearer, replay and Resolve checks the dashboard pull |
| +// already has (dashboard.go), and nothing in Calendar's storage changes. |
| // |
| // It is not mounted: home/dashboard's provider accepts only the kinds |
| // "documents" and "events" today, and the wire for a notification kind is |
diff --git a/internal/calendar/store_reminder_notice.go b/internal/calendar/store_reminder_notice.go| index c31cf94..e480279 100644 |
| --- a/internal/calendar/store_reminder_notice.go |
| +++ b/internal/calendar/store_reminder_notice.go |
| @@ -80,6 +80,15 @@ func (s *Store) ruleChannel(p Person, asked string) (string, error) { |
| // upsert replaces the rule's notice only for a DIFFERENT occurrence, so a |
| // second fire of the same one (at least once, ruling 6) changes nothing |
| // and a notice already dismissed stays dismissed. |
| +// |
| +// The mark and the completion that follows it (CompleteReminder, or the |
| +// email half first) are two transactions, and the window between them is |
| +// the one the email path already has: a reschedule landing there leaves a |
| +// notice naming the time the event just moved from, as the mail would have |
| +// named it, until the next fire replaces it; a lease that expires there |
| +// costs nothing, because the next worker's mark is the same-occurrence |
| +// no-op and it completes. Never a duplicate notice (one row per rule), |
| +// never a lost reminder (whoever holds the claim completes). |
| func (s *Store) MarkReminderNotice(ctx context.Context, due DueReminder, now int64) error { |
| err := s.g.WithContext(ctx).Exec(`INSERT INTO reminder_notices |
| (reminder_id, person_id, event_id, occurrence_key, start_utc, fired_at) |