Repository navigation
Conversation
Accept `skip` beside `latest` and `all` on both the SQL and Durable Objects
adapters. Default missed policy stays `latest`. `latest` is the PRD
`run_once`. `all` is the PRD `catch_up`.
A recurring `skip` reminder considered at N enqueues once when T <= N < T+I.
When N >= T+I it does not enqueue, does not increment occurrence, and does
not set last run. It moves to the next aligned time still in the future.
`latest` and `all` are unchanged. SQL still decides the next run at enqueue.
Durable Objects still re-arms at consume, and jumps a skipped window at the
due pass without a mailbox message.
`ScheduledReminder` now includes `lastRunAtMilliseconds`, `occurrence`, and
`errorName` on both adapters. Occurrence is the PRD "attempt". It starts at
0 and increases by 1 on each enqueue. Replace keeps last run and occurrence
and clears `errorName`, including the in-turn read. Resume does not reset
them. Durable Objects writes `errorName` when it pauses on an exhausted
mailbox or a payload that is too large. Operator `ReminderRecord` does not
gain last run.
SQL schema version 15 adds `last_run_at_ms` and widens the missed-policy
check to include `skip`. Existing `latest` and `all` rows stay valid. The
migration is a no-op when the current CREATE TABLE already has that shape.
One portable scheduling suite covers create, replace, cancel, execution,
missed policies, the new fields, restart recovery, authorization of a fired
reminder versus an external enqueue, and duplicate delivery. SQL and Durable
Objects both run it. `docs/api.md` states the timing contract next to
`schedule({ at })` and documents the new fields in place of the sentence
that omitted occurrence.
[Medium impact] The changes affect reminder scheduling and inspection across both adapters. The PR appears safe to merge, with non-blocking gaps in migration and replacement tests. FindingsFix with agent prompt### Issue 1
test/dead-letters.test.ts:233-234
The new upgrade test always uses SQLite. It never exercises the PostgreSQL and MySQL branches of `missedPolicyAllowsSkip` and `replaceMissedPolicyCheck`, which use different queries and statements to replace checks. Upgrade failures on those databases could go unnoticed.
Add tests for both backends that start with the old check, preserve existing reminders, accept `skip`, and succeed on a second install.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
### Issue 2
test/support/portable-scheduling-contract.ts:262-270
The shared suite only replaces scheduled reminders. It resumes the paused reminder before replacing it, and never replaces a completed one-shot. The tests could therefore miss an old error surviving replacement or run history being lost.
Add direct replacement tests for both states. Assert that the in-turn read matches the saved reminder, keeps `occurrence` and `lastRunAtMilliseconds`, and clears `errorName`. This also protects the new completed-row ordering in `#reminderView`.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryThis PR adds
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Due recurring reminder] --> B{Skip policy and a full interval late?}
B -->|Yes| C[Move to next aligned future time]
C --> D[Keep run history unchanged]
B -->|No| E[Enqueue mailbox message]
E --> F[Increase occurrence and save last run]
F --> G{Adapter}
G -->|SQL| H[Advance schedule at enqueue]
G -->|Durable Objects| I[Advance schedule after consumption]
Reviews (1) · Last reviewed commit: "feat: add skip missed policy and actor-f..." · Reviewed by Greptile |
| runtime = configuredRuntime({ database: sqlite({ path }) }) | ||
| await runtime.install() |
There was a problem hiding this comment.
Database upgrades lack coverage
The new upgrade test always uses SQLite. It never exercises the PostgreSQL and MySQL branches of missedPolicyAllowsSkip and replaceMissedPolicyCheck, which use different queries and statements to replace checks. Upgrade failures on those databases could go unnoticed.
Add tests for both backends that start with the old check, preserve existing reminders, accept skip, and succeed on a second install.
Knowledge Base Used: SQLite, PostgreSQL, and MySQL adapters
Prompt To Fix With AI
This is a comment left during a code review.
Path: test/dead-letters.test.ts
Line: 233-234
Comment:
**Database upgrades lack coverage**
The new upgrade test always uses SQLite. It never exercises the PostgreSQL and MySQL branches of `missedPolicyAllowsSkip` and `replaceMissedPolicyCheck`, which use different queries and statements to replace checks. Upgrade failures on those databases could go unnoticed.
Add tests for both backends that start with the old check, preserve existing reminders, accept `skip`, and succeed on a second install.
**Knowledge Base Used:** [SQLite, PostgreSQL, and MySQL adapters](https://app.greptile.com/-/switch-tenant?tenant=craftsmanfounder&next=%2Fcustom-context%2Fknowledge-base%2Fcardmagic%2Fsolid-objects-js%2F-%2Fdocs%2Fdatabase-adapters.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| const replaced = await reference.replaceAndInspect({ at: future + INTERVAL, missed: "all" }) | ||
| expect(replaced).toMatchObject({ | ||
| status: "scheduled", | ||
| occurrence: paused!.occurrence, | ||
| lastRunAtMilliseconds: paused!.lastRunAtMilliseconds, | ||
| errorName: null, | ||
| missedPolicy: "all", | ||
| runAtMilliseconds: future + INTERVAL, | ||
| }) |
There was a problem hiding this comment.
Replacement states lack coverage
The shared suite only replaces scheduled reminders. It resumes the paused reminder before replacing it, and never replaces a completed one-shot. The tests could therefore miss an old error surviving replacement or run history being lost.
Add direct replacement tests for both states. Assert that the in-turn read matches the saved reminder, keeps occurrence and lastRunAtMilliseconds, and clears errorName. This also protects the new completed-row ordering in #reminderView.
Prompt To Fix With AI
This is a comment left during a code review.
Path: test/support/portable-scheduling-contract.ts
Line: 262-270
Comment:
**Replacement states lack coverage**
The shared suite only replaces scheduled reminders. It resumes the paused reminder before replacing it, and never replaces a completed one-shot. The tests could therefore miss an old error surviving replacement or run history being lost.
Add direct replacement tests for both states. Assert that the in-turn read matches the saved reminder, keeps `occurrence` and `lastRunAtMilliseconds`, and clears `errorName`. This also protects the new completed-row ordering in `#reminderView`.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Docs7 for cardmagic/solid-objects-js
Commit |
Why
Remaining work on #37 (portable durable scheduling):
skipas a missed-run policy, actor-facing last run / occurrence / error on both adapters, the timing contract in JS docs, and one conformance suite both adapters run.What
skip. Publicmissed/missedPolicyis"latest" | "all" | "skip"onReminderOptions,ReminderIntent,ScheduledReminder,ReminderRecord, and the Durable Objects storedmissedvalue. SQLCHECKaccepts all three. Default whenmissedis omitted stayslatest. Docs nameskipand saylatestis the PRDrun_onceandalliscatch_up. No rename.skip. At the due pass, with nowNand stored next runTand intervalI: ifT <= N < T+I, enqueue once, increment occurrence, set last run. IfN >= T+I, do not enqueue, do not increment occurrence, do not set last run, and move to the next aligned time still in the future. A skipped window creates no mailbox message.latestandallare unchanged. SQL still decides the next run at enqueue. Durable Objects still re-arms at consume, and jumps a skipped window at the due pass. One-shotskipis stored if requested and does not change one-shot fire.ScheduledReminder.lastRunAtMilliseconds(nullif never enqueued),occurrence(starts at 0, +1 per enqueue; the PRD "attempt"), anderrorName(nullunless paused). Replace keeps last run and occurrence and clearserrorName, including the in-turn read. A read still applies this turn's staged intents, including completed rows before hiding them, so replace of a completed one-shot matches SQLON CONFLICT. Resume does not reset last run or occurrence. OperatorReminderRecorddoes not gain last run. Durable Objectsgenerationis not exposed. Mailbox retry count is not onScheduledReminder.errorNamefrom the mailbox message when it pauses on an exhausted mailbox orPayloadTooLarge.last_run_at_msand widens the missed-policy check. Existinglatest/allrows stay valid. Other stored reminder data is not rewritten. Idempotent when the currentCREATE TABLEalready has that shape. Test installs it on a database that already had the current schema, after downgrading the check and dropping the column.schedule({ at }): storesat.getTime()as epoch ms; invalidDateisTypeError(reminder time must be valid); compared with SQL connectionnowMillisecondsor a test now, or Durable ObjectsDate.now()at the due pass; retry and retention follow the mailbox message; no time-zone or clock-skew guarantee. Replaces the sentence that omitted occurrence because only SQL had it. Cancel paragraph from docs: replace stale unschedule rationale #97 is unchanged.test/support/portable-scheduling-contract.ts, actorPortableReminders. Invoked from the SQL portable tests (a describe that does not callruntime.run()) and from the Durable Objects contract tests. Covers create, replace, cancel, recurring and one-shot execution,latest/all/skipincluding Durable Objectsallcatch-up, the new fields including pause, restart recovery (SQL claim owner gone; Durable Objects constructor /alarm()/ storage alarm / 30s retry), authorization (fired reminder still runs whenauthorizeMessagereturns false; external enqueue of the same operation still goes through it), and a fired reminder not delivered twice.Cancel still returns nothing. No
reschedulemethod.authorizeMessagedefault is unchanged. No module-level external-enqueue flag on the shared Durable Objects test worker.Checks
On Node 24.22:
format:check,check,test(865 passed, 32 skipped),build,test:cloudflare(70 passed). PostgreSQL and MySQL CI are not run here.Do not merge from this PR alone. Related to #37; this does not close it.