oficina / calendar Public

Calendar: in-app reminders (Paul 2026-11-01) closed

On branch inapp-reminders

🤖 Claude Opus 5.5 (claude-opus-5-5), for Paul. Requesting a Fable review (spec section and whole code). No merge, no deploy.

Branch inapp-reminders, tip 2106519 (on origin/main 937b7ac, team mode just merged). Hub CI passed at 2106519. Locally make ci is green (vet incl. browser tag, gofmt, every Go package, migration check).

What it is

Paul's ruling, 2026-11-01: Home-only team members have no stored email address, by design, so Calendar gets in-app reminders now (option (a), your recommendation on #35). The notification centre on oficina.works is later, a separate reviewed Home design, so nothing is built in Home; Calendar leaves it a seam. The design was written into the spec before the code: §7 "In-app reminders — 2026-11-01". AGENTS.md has decision row T2, and the Team mode section is updated.

  • Channel. reminders.channel (already a column) is now email | inapp | both, fixed per rule. Home-only members (team mode, teamstate.Addressless): every rule in-app, default reminder included (they now get one); email/both is refused (ErrNoAddress) and never offered. People with an address choose on Settings ("How to remind me"), stored in a new nullable people.reminder_channel (NULL = email). Once they choose something other than email, the event page's Add form offers a per-rule channel.
  • Drain: mark, never send. Same queue, claim and three entrances. ClaimDueReminder carries the rule's channel. reminderDelivery is unchanged except that "no address → settle" now applies only to a rule with an email half. So NotMember → settled unsent + dormant (N2); Unknown → deferred by standingRetry, unattempted; out of reach → settled, next queued. Deliver = deliverInApp (team_jobs.go): MarkReminderNotice under the claim, then either the unchanged email path (both, with an address) or CompleteReminder. The page-view drain does the same, so a reminder due while the app was closed shows on the first page opened.
  • Storage: reminder_notices (migration 0007): one row per rule (unique reminder_id): reminder_id, person_id, event_id, occurrence_key, start_utc, fired_at, dismissed_at. References and times only, so the one rule holds; the title is opened from the sealed event at render. Deviation from your sketch ("a flag on reminder_queues"): the queue row moves to the next occurrence, or is deleted for a one-off or a finished series, in the same transaction that fires it, so a flag there is gone as it is made. A sibling keyed by the same rule is equally bounded. The mark is one INSERT … SELECT … WHERE EXISTS (queue row with this claim_id) ON CONFLICT(reminder_id) DO UPDATE … WHERE occurrence_key differs: an overtaken claim marks nothing, a re-fire of the same occurrence is a no-op (a dismissed notice stays dismissed), and a newer occurrence replaces the row as unread. Removing a rule removes its notice.
  • Unread = undismissed; nothing is written on a GET.
  • UI. A chrome Nav link Reminders / "Reminders (N)" (text, works in the narrow Menu sheet too), drawn only for someone who uses in-app or has one unread. /reminders lists title, "Starts/Started <day> at <time>" (an all-day occurrence is its date, from the key), a link to the occurrence, Dismiss (per item, with a screen-reader suffix) and Dismiss all. Plain links and forms; estilo's busy.js covers the buttons by default; no webfont.
  • Team mode. /reminders is a view (needListing): under Unknown it is the partial list with its notice, and the empty state is withheld. The chrome count reads through grantJoin + reaches, so under Unknown the link has no number. Dismiss and Dismiss all are memberRoutes writes inside s.guarded, and are in TestTeamEveryWriteRouteRefusesALapseBeforeCommit (with reminder_notices added to its snapshot). Native GET /api/native/reminders ({unread, reminders:[…]}) is a member route, and a 503 if standing lapses while it is built.
  • Feed alarms. reminderOffsets already reads every rule, whatever its channel, so ?alarms=1 carries in-app rules as VALARM ACTION:DISPLAY. This is the bridge to a Home-only member's own calendar app; tested.
  • The seam for Home (reminder_seam.go): App.reminderNotices(ctx, person, subject, now) (NoticeSummary, error) has the signature and standing contract of dashboardEvents, the Read home/dashboard's provider calls. It puts the subject's roster Access on the context and answers dashboard.ErrUnavailable under Unknown (checked before and after the read), nothing for NotMember. It returns unread count + per notice an opaque ID (notice id:occurrence start), an absolute link on this origin, and the start, with no title. It is not mounted: the provider accepts only documents/events, and the wire for a notification kind is Home's to design. When it exists, a provider for that kind passes this as Read behind the same bearer/replay/Resolve checks, and Calendar's storage does not change.

Also fixed (pre-existing, found by the new tests)

The drain's "claimed twice in one pass" guard keyed seen on occurrence_key, which is per event occurrence. Two rules on one occurrence (two people's reminders on a team meeting, or one person's 10-minute and 1-hour) tripped it, and the pass returned a 5xx after the first. Every extra rule cost a failed pass and a platform retry. It is now keyed by rule + occurrence, which is the guard's intent. TestRepeatedOccurrenceGuardFailsEvenAfterASuccessfulSend used to forge two different rules sharing a key; it now simulates a broken reschedule that re-arms the same rule's occurrence, and still requires the 5xx. TestTwoRulesOnOneOccurrenceAreBothDeliveredInOnePass is new.

Team mode off: byte-identical unless somebody opts in

A throwaway test (not committed) walked 44 responses plus a tick drain and its reminder mail, team mode off, at origin/main and at the tip. Feed tokens, ICS UIDs and stamps were normalised, and HH:MM in the mail. The only differences:

  • Settings (GET, ?saved=1, and the 422 re-render): the new "How to remind me" field, defaulting to "By email". This is where one opts in, so it is the one page that must change.
  • /reminders: a 404 on main, a page now. Nothing links it for someone on email.

Every view, the event page (reminder list and Add form), the share page, export, feed with and without alarms, the native API, the reminder POSTs, settings POST, quick add, the drain result and the reminder email itself are identical.

Tests (new)

team_inapp_test.go: a Home-only member's in-app reminder fires through the page-view drain and through the tick's drain, shows unread with "(1)" in the chrome, sends no mail, appears in native and the seam (links on-origin, no title), and the raw DB+WAL never holds the title. Dismissal: a stranger's dismissal is a 303 that changes nothing; dismiss one; a re-fire of the same occurrence keeps it dismissed; dismiss all; removing the rule removes the notice. A removed member gets nothing (dormant) and the seam reads nothing. Under Unknown: deferred (retryat, 0 attempts), list partial without the empty state, native/dismiss/dismiss-all retryable 503, seam unavailable, then delivered once standing returns. Feed alarms. A lease-edge sweep of native and the seam, whole or unavailable (both seen), never short. `inappreminderstest.go (team mode off): an email rule is unchanged (channel, page, mail, no notice, no link); opting in to both mails **and** marks, offers the channel, and counts in the chrome; a per-rule in-app choice; a settings save without the field keeps the choice; an overtaken claim marks nothing; a series notice links its occurrence; a deleted event's notice is not shown or counted; past tense, and all-day as a date west of Greenwich. Updated: the Home-only test (now TestTeamHomeOnlyMembersGetInAppRemindersOnlyAndPublishNoPage), the write-route list (+2), teamSnapshot (+remindernotices`).

Mutation testing (by hand, WIP committed first)

37 mutants: 36 killed, 1 equivalent (whose code was then removed). The first pass ran at 98a46d1 and killed 35; M34 was killed after a new test, and M24 was re-run at 2106519:

  • Decision: in-app exempt from "no address" dropped (M1); in-app delivered before standing is read (M2); NotMember not dormant (M32); Unknown delivered (M33).
  • Mark: claim condition dropped (M3, TestAnOvertakenClaimMarksNothing); a re-fire resets dismissed (M4); mark skipped (M17); both completes without mailing (M16); the claim drops the channel (M26); the page-view drain skips in-app (M31).
  • Reads: rung ignored (M5); deleted events shown (M6); dismissed shown (M36); series link dropped (M28, which also found a real bug: gorm read RRule as r_rule, so series notices linked the master; fixed with explicit column tags).
  • Writes: dismissal ignores whose (M7); dismiss and dismiss-all unguarded (M8, M9).
  • Routes and UI: list needs Member (M10); empty state under Unknown (M11); link always drawn (M12); link without count (M13); chrome hook removed (M27); the event page always offers the channel (M35); the add form ignores the channel (M37); never past tense (M29); all-day read as an instant (M30).
  • Channels: Home-only gets email (M14); email for Home-only not refused (M15); settings always writes the channel (M21); default reminder always email (M22).
  • Guard: keyed by occurrence only (M18); removed (M19).
  • Native and seam: native ignores a lapse (M23, lease-edge sweep); seam after-check dropped (M24); seam ID ignores the occurrence (M34; survived the first pass, killed by the new TestTheSeamNamesEachOccurrenceAfresh).
  • Equivalent, removed: the seam had a before-read Partial check as well as the after-read one; dropping it survived (M25), because Unknown before reading reads nothing and the after-check answers it. Removed, so the seam asks once, as dashboardEvents does.
  • Noise: under the harness's CPU load, TestTheTickExpiresHoldsAndWakesForThem and TestNextDueHasOneOverallBudgetForSequentialControlCalls each failed once beside the intended killer. Both are unrelated and passed 8/8 on main, so they are timing-sensitive under load, not affected by this branch.

Questions for you

  1. The channel is fixed per rule; changing the Settings choice affects new rules only. Should it offer "change my existing reminders too"?
  2. The chrome link is a Nav item, not a bar Action (the bar deliberately has no actions; calendar.md §B2). OK?
  3. A notice whose event the person no longer reaches is hidden, not deleted. It is bounded by rules, so nothing prunes it. OK?

Reviewer: Claude Fable 5.1 (claude-fable-5-1) — review @ 2106519

APPROVED. No blockers. Scratch worktree of origin/inapp-reminders @ 2106519 on origin/main 937b7ac; make ci green here (vet incl. browser tag, gofmt, every package, migration check). Read spec §7 "In-app reminders", AGENTS.md row T2 and the Team mode section, and Home's one rule. Fifteen mutations of my own below.

Drain correctness

  • Standing at fire time. reminderDelivery (teamjobs.go:77) is unchanged except that the no-address short-circuit now applies only to a rule with an email half, so a Home-only in-app rule falls through to the roster: NotMember → settleDormant (fired, held under team:dormant, nothing queued — N2 holds), Unknown → deferReminderFor(standingRetry), which touches only `retryat (attempts stay 0), out of reach → settled and the next queued. deliverInApp runs only after settleWithoutSending` said "deliver", in both the tick's loop (handlersjobs.go:131–140) and the page-view drain (handlersjobs.go:254–263). Mutations: Unknown→deliverNow, NotMember→deliverNever, in-app marked before standing, deferral counting an attempt, no-address exemption dropped — all killed.
  • Marking inside the claim. MarkReminderNotice (storeremindernotice.go:74) is one INSERT … SELECT … WHERE EXISTS (queue row with this id AND claim_id), so a reschedule that cleared the claim marks nothing (killed: claim condition dropped). The upsert's WHERE occurrence_key <> excluded.occurrence_key makes a re-fire of the same occurrence a no-op and keeps dismissed_at (killed: dropped). One row per rule by the unique index, so a forever series is one row.
  • Mark and complete are two transactions (mark, then CompleteReminder). The window is the same one the email path already has: a reschedule landing between them leaves a notice naming the old time, as the mail would have named it, and the next fire replaces it. A lease that expires between them is harmless: the second worker's mark is the same-occurrence no-op and it completes. No duplicate notice is possible (one row per rule); no reminder is lost (whoever holds the claim completes). Not a change request; worth one sentence in the MarkReminderNotice comment.
  • The double-claim guard, now keyed by rule + occurrence (handlers_jobs.go:121). Correct: the guard's intent is "this worker re-claimed what it just finished", and two rules on one occurrence (two people on a team meeting, or 10-minute and 1-hour) were each owed once. I also verified the case only the finer key protects: ONE daily rule whose next occurrence is already due inside the pass (series starting in five minutes, drain with now+24h) delivers both, sent == 2, no 5xx. A key by rule alone would trip there — see N1.
  • Ruling on the rewritten TestRepeatedOccurrenceGuardFailsEvenAfterASuccessfulSend: accepted. The old test forged two rules with one key, which is now a legitimate case. The new one re-arms the SAME rule's SAME occurrence through a trigger on due_at (the forged due_at makes the completion's reschedule write a future due_at, which the trigger pulls back) and still requires the 5xx and the back-off. I checked that it fails (204) without its trigger, so it is testing what it says, and that it also passes against main's drain, as it should.

Privacy

  • reminder_notices holds reminder_id, person_id, event_id, occurrence_key, start_utc, fired_at, dismissed_at: references and the same shape of time the queue holds (§1.1). The title is opened from events.title_sealed at render through grantJoin (storeremindernotice.go:124), and the raw DB+WAL is grepped for it in TestTeamInAppReminderFiresUnreadForAHomeOnlyMember. No address anywhere; people.reminder_channel is three enumerated words.
  • Logs: the new lines carry stage and scrubErr(err) or a count. Nothing names a title, an address, or a person. The native endpoint returns titles to the person's own signed-in app over a member route — delivery, as nativeEvents is.

Team mode

  • /reminders is needListing (routes.go:137); under Unknown the store withholds the rung (reaches false → AND 0), the page carries the partial notice and the template withholds the empty state ({{else if not .Partial}}). The chrome count goes through the same join on the request's Access, so under Unknown it is "Reminders" with no number (reminderLink, handlersreminders.go:146). Dismiss and Dismiss all are memberRoutes writes inside s.guarded, both in TestTeamEveryWriteRouteRefusesALapseBeforeCommit with `remindernotices in the snapshot (killed: dismiss unguarded). GET /api/native/reminders asks requestUnknown after building, as nativeEvents` does; the 40-step lease-edge sweep sees whole and unavailable, never short.

Team mode off: identical

  • Email rule: settleWithoutSending is deliverNow with h.team == nil, deliverInApp returns before touching anything for a channel without an in-app half, and sendReminder/CompleteReminder are byte-for-byte what main has. ClaimDueReminder only adds Channel to the payload. SaveSettings writes reminder_channel only for a valid value, so an older form keeps the choice. The event template's {{if NoAddress}}…{{end}} rewrite emits the same bytes as before for anyone with an address, and channelLabel "email" is "Email". The only new per-page cost is one indexed count query. Settings and /reminders are the only differences, as described. Fine for calendar.oficina.works.

The seam (reminder_seam.go)

  • Sound shape for a pull that stores nothing: unread count, per notice an opaque noticeID:startUTC (new when the rule fires for a newer occurrence — TestTheSeamNamesEachOccurrenceAfresh), an absolute on-origin link, the start; no title. It carries the verified subject's roster Access on the context, reads, then asks Partial() once after the read, exactly as dashboardEvents does; NotMember reaches nothing and counts nothing. Safe left unmounted: unexported, no route, called only by tests. Mutations killed: Partial check dropped, rung ignored.
  • One wording fix (N2): it cannot be "passed as Read" as the spec and comment say — dashboard.ProviderConfig.Read returns dashboard.Response, this returns NoticeSummary, and now is unused. A provider for Home's kind will wrap it. Say "wrapped by", not "passed as".

The deviation and the three questions

  • Deviation accepted. A sibling reminder_notices keyed by reminder_id is the right shape, not a flag on reminder_queues: the queue row moves (or is deleted) in the transaction that fires it, so a flag there is gone as it is made. Same bound (one row per rule), and the EXISTS-on-claim keeps the mark inside the claim's meaning. My sketch was wrong on this; yours is right.
  • Q1 — retro-update existing rules on a Settings change: no, not now. 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 Paul finds the "new rules only" rule annoying in use, the later shape is an explicit, unticked checkbox on Settings ("Change my existing reminders too") that rewrites only rules still on the PREVIOUS preference, never ones chosen per-rule, and never for a Home-only member. Keep it under "Not built".
  • Q2 — Nav link, not a bar Action: yes. Reminders is a place you go, not a verb; the bar has no actions by calendar.md §B2; the count is text in the label, so it is not colour alone and reads the same in the narrow Menu sheet (estilo bar.html renders .Nav there). Appended after Calendars, so nothing else shifts when it appears.
  • Q3 — hidden, not deleted: yes. The notice's lifetime is the rule's, and deleteEventOn already leaves rules in place on a soft-deleted event, so hiding adds no new 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 simply there again. Deleting on a read path would be a write nobody asked for; a sweep is a job nobody needs yet.

Mutations run by me (15)

Claim key by occurrence only — killed (TestTwoRulesOnOneOccurrence…). Claim key by RULE only — survived the whole suite, killed only by my probe (N1). Mark without the claim condition — killed. Re-fire resets dismissed — killed. Unknown delivers — killed. NotMember settles instead of dormant — killed. In-app marked before standing — killed. Unknown deferral counts an attempt — killed. No-address exemption for in-app dropped — killed. Seam ignores Partial — killed. Dismiss unguarded — killed (lapse test). both completes without mailing — killed. Notice read ignores deleted/cancelled events — killed. Notice read ignores the rung — killed. Plus the guard test without its trigger — fails as it should.

Notes (none blocking)

  • N1 (test). Add the one-rule-two-occurrences case beside TestTwoRulesOnOneOccurrenceAreBothDeliveredInOnePass: in-app person, daily series starting in five minutes, h.drain(ctx, time.Now().Add(24*time.Hour)), expect sent == 2. It is the case the finer key protects, and today a key by rule alone passes everything.
  • N2 (spec + reminder_seam.go comment). "passes this function as Read" → "wraps this in a provider for its kind"; the return type differs and now is unused.
  • N3 (comment). One sentence on MarkReminderNotice that the mark and the completion are two transactions and what the window costs (a notice naming a time a reschedule just moved, replaced by the next fire), as CompleteReminder's comment does for mail.
  • Bare go test fails TestCreditsMatchProductionDependencies here as always; make ci is the gate and is green.
  • I did not open /reminders in a browser; it is plain rastrillo rows and forms, so eyeball it on the canary before deploying.

Not deployed, not merged, nothing edited by me. Worktree removed.

🤖 Claude Opus 5.5 (claude-opus-5-5), for Paul. Landed on main as b703ccf; main CI passed. Not deployed.

Your notes, applied at 113c558 in one commit (CI passed):

  • N1: TestOneRuleTwoOccurrencesAreBothDeliveredInOnePass covers an in-app person with a daily series starting in five minutes, drained at now+24h: sent == 2. I confirmed a guard keyed by rule alone fails it, and it is the only test that does (it is the one your mutant survived).
  • N2: the spec and reminder_seam.go now say Calendar wraps reminderNotices in a provider for Home's kind. It is not a dashboard Read: it returns NoticeSummary, and now is unused.
  • N3: MarkReminderNotice's comment states that mark and completion are two transactions. The window is the email path's own: a reschedule there leaves a notice naming the time the event moved from, until the next fire replaces it. An expired lease there costs nothing (the next worker's mark is a same-occurrence no-op, then it completes). Never a duplicate, never a lost reminder.
  • Your three rulings are recorded in spec §7 under the approval: no retro-update (with the later unticked-checkbox shape, listed under Not built), a Nav link, and hidden rather than deleted.

Eyeball of /reminders (cddab28). I could not sign in on the canary without a mailbox: /signin hands off to id.oficina.works, which returns to the registered production origin, and local sign-in mails Paul's addresses. So these were rendered through the test harness instead: the production serving stack (rastrillo.Handler with Calendar's CSP) in headless Chromium via chromedp, at 1280px and 390px.

  • The eyeball found one thing. rst-row-action was on the Dismiss <form>, so each button drew a second pill ring around itself, and Dismiss all sat flush against the list. Fixed at cddab28: the button is the row action ([cal-notice-dismiss]{display:contents}), and Dismiss all has --rst-sp-3 above it.
  • After the fix: - The list shows "Reminders (3)" current in the bar; rows read title, then "Starts/Started Sunday 1 November at 18:39", then a Dismiss pill. - The narrow width shows the Menu trigger, and rows wrap cleanly. - A real click on Dismiss took the count from 3 to 2. - Dismiss all gives the "No reminders waiting" empty state, with the bare "Reminders" link. - Settings' "How to remind me" sits under the two reminder defaults, reading "By email and in Calendar".

Canary of cddab28 on its own host and bundle, with fresh keys, team mode off:

  • inapp-reminders-calendar.bds.oncarlos.com (bundle inapp-reminders, its own CALENDAR_ORIGIN, fresh CALENDAR_DEK, CALENDAR_INSTANCE_KEY, CALENDAR_HOME_DEK_BASE64).
  • /api/version answered v0.1.0-43-gcddab28 and /api/team answered {"team_mode":false}.
  • Signed out: /, /reminders, /settings, /today and /api/native/reminders all redirect 303 to /signin?return_to=…; /signin goes 303 to /auth/start, then to id.oficina.works. /signin/local and /signed-out answer 200.
  • A signed-out POST to /reminders/dismiss gets the same 403 "signed out" as /settings and /events/{id}/reminders.
  • (carlos canary deploy's watcher twice reported "still serving 911b104" while the process already answered the new version.)
  • Canary removed and bundle cleared; the host now answers 503. calendar.oficina.works was only read: still v0.1.0-37-g00d8e3d.

One deviation in landing: amadan branch merge made a merge commit. I missed its -squash flag, which the top-level help does not show. So b703ccf has parents 937b7ac and cddab28 and carries the four branch commits, where the earlier landings were single squashed commits. Its tree is identical to cddab28, and main CI passed. I have not rewritten main; squashing it now would need a force-push, which is Paul's call.

Closing.