Skip to content

Reminders: skip missed policy, last_run_at and error_class, pause on unknown operation - #110

Merged
cardmagic merged 5 commits into
mainfrom
reminders-skip-last-run-103
Dec 2, 2026
Merged

cardmagic merged 5 commits into
mainfrom
reminders-skip-last-run-103

Conversation

@cardmagic

Copy link
Copy Markdown
Owner

Refs #103

Summary

 ReminderScheduler#run_once(now:)
   claim_next
   enqueue
-    unknown operation -> raise UnknownMessage (claim released, reclaimed every pass)
+    unknown operation -> pause: status "paused", error_class "SolidObjects::UnknownMessage", claim cleared
     lock instance + reminder, verify claim
+    skip, recurring, now >= T + I -> enqueue nothing, next_run_at = first aligned time after now
     enqueue internal message (idempotency key reminder:<id>:<occurrence>, unchanged)
-    occurrence += 1, advance
+    occurrence += 1, last_run_at = now, advance
  • schedule(missed:) accepts :skip / "skip"; default stays :latest; :latest and :all unchanged.
  • ReminderStatus gains last_run_at (Time or nil) and error_class (String or nil), appended after handle. A replace (committed and in-turn read) keeps last_run_at and occurrence, clears error_class, sets "scheduled".
  • New migration 20261130000000_add_solid_objects_reminder_run_history.rb: adds reminders.last_run_at, reminders.error_class, and widens chk_so_reminders_missed to latest/all/skip. Doctor lists the new columns.
  • Docs: docs/reminders.md (three policies, when a reminder fires, run history fields), docs/architecture.md catch-up bullets, CHANGELOG.md Unreleased.

Not added: a reschedule method, a cancel return value, a resume API, mailbox retry count on ReminderStatus.

Evidence

  • Before (origin/main 80523e7): new test/integration/reminder_missed_policy_test.rb → 17 runs, 6 failures, 10 errors (missed reminder policy must be all or latest, undefined method 'error_class', …).
    After: 17 runs, 102 assertions, 0 failures.
skip, T <= N < T+I      -> 1 message, occurrence 1, last_run_at N, next T+I
skip, N = T+2.5I        -> 0 messages, history unchanged, next T+3I, not due again at N
skip, N = T+I           -> 0 messages, next T+2I
skip one-shot, late     -> 1 message, completed
latest, N = T+2.5I      -> 1 message, next T+3I
all, N = T+2.5I         -> 3 passes, 3 messages (reminder:<id>:0..2), next T+3I
unknown op at fire      -> paused, UnknownMessage, no message, never reclaimed
replace after pause     -> scheduled, error nil, occurrence/last_run_at kept (in-turn + committed)
mailbox failure         -> dead letter, reminder still scheduled, no error_class
stale claim             -> still fires
authorize_message false -> fired reminder runs; external async raises Unauthorized
same occurrence twice   -> one message
  • test/models/reminder_run_history_migration_test.rb: applies every earlier migration, inserts latest and all rows, applies the new one; rows survive, skip now accepted, unknown policy still refused. Fresh install is the suite's own schema.
  • Local (SQLite): bundle exec rake test → 1010 runs, 4262 assertions, 0 failures, 0 errors, 39 skips. rake at_least_once, standard, rubocop, rbs, steep, security pass. PostgreSQL and MySQL run in CI.

Merge Danger

Door: two-way for code; the migration is reversible (down restores the old check, which fails if skip rows exist).

Blast Radius: schema

Applications must run bin/rails solid_objects:install:migrations and migrate before upgrading a scheduler, because every enqueue now writes last_run_at. ReminderStatus has two more members, so positional ReminderStatus.new(...) callers (unlikely) would break. run_once no longer raises for an unknown reminder operation; it pauses and returns true.

@greptile-apps

greptile-apps Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge with the documented migration rollout.

Summary

Adds missed: :skip, reminder run history, and pausing for unknown reminder operations.

  • Recurring reminders can drop runs after their scheduled window passes.
  • Reminders pause when their actor no longer declares the operation.
  • Reminder status shows the last enqueue time and any pause reason.

No new actionable issues were found. Both earlier unnumbered findings are addressed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Claim due reminder] --> B{Operation declared?}
  B -->|No| C[Pause and clear claim]
  B -->|Yes| D[Lock actor and reminder; check claim]
  D --> E{Skip missed window?}
  E -->|Yes| F[Advance time and clear claim]
  E -->|No| G[Enqueue message and update run history]
Loading

Reviews (4) · Last reviewed commit: "Keep both Unreleased changelog entries" · Reviewed by Greptile

Comment thread lib/solid_objects/actor.rb Resolved
@context7

context7 Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Docs7 for cardmagic/solid-objects-ruby

Result Status Action
Deployment ➖ Not used —
Content review ❌ Needs attention. 1 problem remains. —

Commit b6335b9

1 finding is inline on the changed files.

@cardmagic

Copy link
Copy Markdown
Owner Author

@greptileai review

Comment thread lib/solid_objects/actor.rb Resolved
@cardmagic

Copy link
Copy Markdown
Owner Author

@greptileai review

@cardmagic

Copy link
Copy Markdown
Owner Author

@greptileai review

Comment thread docs/reminders.md
its `missed:` policy. The default is `:latest`. The policy can be a symbol or
a string.

- `missed: :latest` coalesces missed occurrences (the JS PRD's `run_once`). The

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs conventions: "the JS PRD" is not used anywhere else in the docs; the repository writes "JavaScript".

@cardmagic
cardmagic merged commit 167c4b4 into main Dec 2, 2026
47 checks passed
@cardmagic
cardmagic deleted the reminders-skip-last-run-103 branch December 2, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant