Skip to content

Commit 89ff3aa

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-2etnqx
2 parents 4a97112 + 31260ca commit 89ff3aa

34 files changed

Lines changed: 1622 additions & 161 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@objectstack/core': patch
3+
'@objectstack/service-messaging': patch
4+
'@objectstack/service-queue': patch
5+
---
6+
7+
fix(core,service-messaging,service-queue): an idle dispatch loop wakes at the next due time, and a sole writer's loop no longer re-runs the idle ramp after every boot
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: none
11+
12+
- **`@objectstack/core`: `DispatchLoop` wakes at the next due time.** A new optional `DispatchLoopOptions.nextDueAt()` answers the earliest instant work becomes claimable (a deferred row, a claim's expiry). The loop asks it once per idle streak, after the first empty tick, and never sleeps past the answer, so a deferred row goes out within one tick of coming due whatever `maxIdleIntervalMs` is. The answer is remembered rather than re-read on every ceiling tick, so an idle loop's steady-state cost is unchanged; the new `DispatchLoop.wakeAt(dueAtMs)` lets a producer in the same process announce a deferred row at no read. An answer at or before the tick that found nothing is not chased, and a rejected tick or read still counts as idle, so neither can make the loop spin.
13+
- **`@objectstack/core`: `DispatchLoopOptions.soleWriter`** (default `false`). On a host where no other process writes the store, an empty tick sleeps straight to the next due time or the ceiling instead of re-running the ramp from `intervalMs`, which only ever bought latency on rows another process wrote. A fresh sole-writer loop over an empty store now ticks once in its first minute; before, every boot re-ran the ramp (six ticks in the first minute at the dispatchers' 500 ms base, five at the queue's 1 s).
14+
- **`@objectstack/service-messaging`:** `INotificationOutbox.nextDueAt` / `IHttpOutbox.nextDueAt` (optional; both built-in stores implement it: two reads, the earliest future `next_attempt_at` / `next_retry_at` and the oldest `in_flight` claim plus the claim TTL), wired into `NotificationDispatcher` and `HttpDispatcher`; `soleWriter` on both dispatchers' options, and `dispatchSoleWriter` on `MessagingServicePlugin`. Retries, quiet hours, digest windows and a crashed node's claims are taken at their due time instead of up to `dispatchMaxIdleIntervalMs` late.
15+
- **`@objectstack/service-queue`:** `DbQueueAdapter` reads the earliest future `scheduled_for` of its subscribed queues (one read per idle streak), a deferred `publish()` announces its due time to the loop through `wakeAt` instead of waiting out the backoff, and `DbQueueAdapterOptions.soleWriter` (reachable as `QueueServicePlugin` `db.soleWriter`) skips the ramp.
16+
17+
Nothing changes for a host that sets neither `soleWriter` flag except the due-time wake: the ramp keeps its shape, cut short only when a due row is earlier, and an idle stretch costs one extra read at its start.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/formula': patch
3+
'@objectstack/lint': patch
4+
---
5+
6+
fix(formula,lint): a date-arithmetic verdict in a flow condition says the run fails, not that the value reads null
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
- **`@objectstack/formula`: four codes join `ExpressionRefusalCode`**: `date-arithmetic-run-fails`, `date-arithmetic-run-may-fail`, `date-text-arithmetic-run-fails` and `date-text-arithmetic-run-may-fail`, with the same params as `date-arithmetic` / `date-text-arithmetic`. A flow condition (a `'flattened'` site) that does arithmetic on a date field used to be told the field "silently evaluates to null", but the engine's `evaluateCondition` throws on the fault on every flow, so the run fails at the condition. Where the caller declares the run proven to hold the field (`faultOutcome: 'run-fails'`, with `bareNamesUnproven` unset) the verdict is served under `-run-fails` and says the run fails; anywhere else in a flow it is served under `-run-may-fail` and says the run fails wherever the name holds the field's date when the condition runs (a flow started by an API call, an action or a parent flow binds what its entrance hands over, which can be a number). The grade is unchanged: an error at every site. A `record`-scoped site (a formula field, a validation rule, a display predicate) keeps `date-arithmetic` / `date-text-arithmetic` and their sentence. A consumer keyed to the old codes on a flow condition re-keys to the new ones.
12+
- **`@objectstack/lint`**: the fault-outcome ledger's docblock names the date verdicts' flow codes; the routing is the existing `faultOutcome` / `bareNamesUnproven` hint, unchanged.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@object-ui/core': patch
3+
---
4+
5+
fix(core): a compareTo widget on an already-past date range (yesterday, last week / month / quarter / year, last N days) compares with the period before it, and previousYear from 29 February stays in February
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
- **`shiftFilterByCompareTo`, `kind: 'previousPeriod'`.** `{yesterday}` and the `last_*` tokens were never moved, so a dashboard filtered to `yesterday`, `last_week`, `last_month`, `last_quarter` or `last_year` compared the window with itself and the delta always read 0. They now compare with the period before them: `{yesterday}` with `{2_days_ago}`, and `last_week_*` … `last_year_*` with the week, month, quarter or year before last. The macro vocabulary has no token for "two periods back", so those windows are computed: the `last_*` start is resolved in the display zone, moved back one period, and the end is the day before it.
11+
- **Rolling windows.** `{N_days_ago}` … `{today}` (`last_7_days`, `last_30_days`, `last_90_days`; N + 1 days) moved only its end and compared with the N days ending yesterday, which overlap it. It now compares with the N + 1 days before it, `{(2N+1)_days_ago}` … `{(N+1)_days_ago}`, the same window the dataset executor computes.
12+
- **`kind: 'previousYear'` from 29 February** re-resolved the filter at 1 March of the year before (`new Date(2027, 1, 29)`), so `this_month` compared with March. The day is now clamped to the month's last day, 28 February.
13+
- **`compareToTrendLabelKey`** reads all of these as `vsPreviousPeriod` (they read `vsLastWeek`, `vsLastMonth`, `vsLastQuarter`, `vsLastYear` and `vsYesterday`); no `dashboard.trend.*` key names "the month before last". `today`, the `this_*` and the forward presets compare and label as before.

‎content/docs/automation/webhooks.mdx‎

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -452,16 +452,39 @@ same partition — useful for in-order delivery and connection reuse. On a
452452
single-node runtime the lock is an always-grant stub.
453453

454454
Each tick opens with **one** visibility-timeout reap for the whole table —
455-
`in_flight` rows claimed longer than `claimTtlMs` ago return to `pending` — and
456-
then claims partition by partition, so a tick over an empty outbox costs
457-
`1 + partitionCount` statements. The loop **backs off while idle**: every tick
458-
that claims nothing doubles the delay to the next, from `intervalMs` (default
459-
500 ms) up to `maxIdleIntervalMs` (default 30 s; `dispatchMaxIdleIntervalMs` on
460-
`MessagingServicePlugin`), and a tick that claims work snaps it back.
461-
`messaging.enqueueHttp()` and `messaging.redeliverHttp()` wake the dispatcher
462-
running in the same process, so a delivery written there goes out at once. Work
463-
nobody announces — a retry coming due, a row another process wrote — is noticed
464-
within one backed-off interval, never more than `maxIdleIntervalMs` late.
455+
`in_flight` rows claimed longer than `claimTtlMs` ago return to `pending` — then
456+
asks once, across every partition, whether any `pending` row is due. Only when
457+
one is does it claim partition by partition. A tick over an empty outbox
458+
therefore costs **two** statements, both reads, whatever `partitionCount` is:
459+
the reap's "anything expired?" read (its UPDATE runs only when that finds a
460+
row) and the "anything due?" read.
461+
462+
The loop **backs off while idle**: every tick that claims nothing doubles the
463+
delay to the next, from `intervalMs` (default 500 ms) up to `maxIdleIntervalMs`
464+
(default 30 s; `dispatchMaxIdleIntervalMs` on `MessagingServicePlugin`), and a
465+
tick that claims work snaps it back. `messaging.enqueueHttp()` and
466+
`messaging.redeliverHttp()` wake the dispatcher running in the same process, so
467+
a delivery written there goes out at once.
468+
469+
The loop also **wakes at the next due time**. After the first empty tick of an
470+
idle stretch it reads, once, the earliest instant a row becomes claimable
471+
without anyone writing: the soonest future `next_retry_at`, or the moment the
472+
oldest `in_flight` claim passes `claimTtlMs`. It never sleeps past that
473+
instant, so a retry is attempted when it comes due and a crashed node's claim is
474+
recovered when its TTL passes, whatever the ceiling. That costs two more reads
475+
at the start of each idle stretch, not one per tick. The backoff is left with
476+
one job: a row **another process** wrote, which is noticed within one
477+
backed-off interval, never more than `maxIdleIntervalMs` late.
478+
479+
On a host where no other process writes these tables, that job is empty. Set
480+
`dispatchSoleWriter: true` on `MessagingServicePlugin` there, for example on a
481+
hosted tenant kernel with one kernel per tenant database. An empty tick then
482+
sleeps straight to the next due time or the ceiling, instead of re-running the
483+
ramp from `intervalMs` after every boot and every burst, and a fresh kernel's
484+
dispatchers tick once in their first minute. The job queue takes the same flag
485+
as `DbQueueAdapter`'s `soleWriter`, set through `QueueServicePlugin`'s
486+
`db.soleWriter`. Leave both off when a second node or a worker process writes
487+
the same database. Default: off.
465488

466489
Within a held partition, the lock-holder claims a batch with an **atomic
467490
conditional UPDATE** rather than `SELECT … FOR UPDATE SKIP LOCKED`:
@@ -697,7 +720,7 @@ A precise table of what the runtime promises and what it does not.
697720
|------------------------------------------|-------------------------------------------------------------|
698721
| Producer node crashes mid-emit | **Not durable today.** The realtime bus (`InMemoryRealtimeAdapter`) is an unpersisted, in-process pub/sub — an event lost before Stage 3's INSERT is gone, not redelivered (see §4.1). |
699722
| Subscriber node crashes after persist | Row exists in `sys_http_delivery`, another node picks it up. |
700-
| Dispatcher node crashes mid-HTTP | Row stays `in_flight` with `claimed_by`; the first dispatcher tick after the claim TTL reverts it to `pending` and it is re-posted. The TTL derives from the dispatcher tick (`intervalMs`, default 500ms): `lockTtlMs = 5 × intervalMs`, `claimTtlMs = 2 × lockTtlMs` (so ~5s at defaults), all configurable via `HttpDispatcherOptions`. An idle surviving dispatcher ticks at least every `maxIdleIntervalMs` (default 30s), so recovery takes at most `claimTtlMs + maxIdleIntervalMs` (~35s at defaults). |
723+
| Dispatcher node crashes mid-HTTP | Row stays `in_flight` with `claimed_by`; the first dispatcher tick after the claim TTL reverts it to `pending` and it is re-posted. The TTL derives from the dispatcher tick (`intervalMs`, default 500ms): `lockTtlMs = 5 × intervalMs`, `claimTtlMs = 2 × lockTtlMs` (so ~5s at defaults), all configurable via `HttpDispatcherOptions`. An idle surviving dispatcher wakes when the oldest claim it read at the start of its idle stretch passes its TTL, and ticks at least every `maxIdleIntervalMs` (default 30s) in any case, so recovery takes about `claimTtlMs` for a claim it saw and at most `claimTtlMs + maxIdleIntervalMs` (~35s at defaults) for one made after that read. |
701724
| A send outlasts the claim TTL and another dispatcher re-claims the row | The re-claiming dispatcher posts the delivery again (at-least-once — the receiver can see it twice; see the last row). The first dispatcher's late outcome is **not** written over the live attempt: its ack carries the claim credential (`claimed_by`, `claimed_at`) its claim stamped, the conditional update matches nothing, and it logs `http-dispatcher: ack refused, claim no longer held`. The row records the outcome of the attempt that still holds it. |
702725
| Receiver returns 5xx | Retry per backoff schedule until the fixed 8-attempt budget is exhausted (§4.5). |
703726
| Receiver returns 4xx | Treated as terminal — no retry, status `dead` immediately. Exception: 408 / 429 are retried. |

0 commit comments

Comments
 (0)