Commit a8c00e2
feat(core): cache successful sys_setting localization reads, invalidated synchronously on write (#12694)
* feat(core): cache successful sys_setting localization reads, invalidated synchronously on write (#11966)
Leg C (ship-first) of the accepted #11633 cross-request caching design.
`resolveLocalizationContext` re-read `sys_setting` on every authenticated
request for three values that change roughly never. That read is now cached,
behind invalidation that is synchronous and in-process rather than TTL-bound.
- Primary trigger: `SettingsService.subscribe('localization', ...)`, which
dispatches synchronously from the write path after the row is persisted.
No change was needed in `@objectstack/service-settings` — the seam was
already public and already does exactly this.
- Backstop: the #11968 engine write epoch, read structurally rather than
imported (objectql depends on core, so the edge cannot be reversed).
Covers direct `sys_setting` writes that never pass through the service.
- Residual bound: `OS_LOCALIZATION_CACHE_TTL_MS`, default 30s, `0` = off.
Two rules carry it, and both are pinned: a success is cached ONLY when the
engine exposes the write epoch (no seam ⇒ no cache, rather than degrading to
the TTL-only shape that was reverted here once already), and invalidation
retires SUCCESS entries only (retiring #10221's failure memo on a write would
restart the per-request driver log spam it removed).
`analytics-timezone.dogfood.test.ts` is unchanged and unweakened.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZbWd2jNV1FErXTPSS4Dry
* test(core): hold the caller's bound in the leg-C localization cache double (#11966)
`check:objectql-double-limit` (#10978): a `find` double that hands back every
row it matched cannot tell this read's `limit: 10` from no bound at all, so a
folded or dropped bound would stay green by construction. Applied after the
filter and by presence, matching the sibling `bounded()` helper.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZbWd2jNV1FErXTPSS4Dry
* test(core): refuse combinators in the leg-C localization cache matcher (#11966)
`check:where-matcher`: a hand-written WHERE matcher with no combinator branch
reads `$and` as a field name and silently answers the wrong question rather
than failing. Refusing the unsupported shape is the convention the sibling
double in resolve-authz-context.test.ts already follows.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZbWd2jNV1FErXTPSS4Dry
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 2805e52 commit a8c00e2
5 files changed
Lines changed: 775 additions & 21 deletions
File tree
- .changeset
- content/docs/deployment
- packages/core/src/security
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
| 358 | + | |
358 | 359 | | |
359 | 360 | | |
360 | 361 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | | - | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
400 | 403 | | |
401 | 404 | | |
402 | 405 | | |
| |||
458 | 461 | | |
459 | 462 | | |
460 | 463 | | |
461 | | - | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
462 | 473 | | |
463 | 474 | | |
464 | 475 | | |
| |||
472 | 483 | | |
473 | 484 | | |
474 | 485 | | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
479 | 491 | | |
480 | 492 | | |
481 | 493 | | |
| |||
0 commit comments