Skip to content

Persist only changed emulator state and roll up Autumn usage - #33

Merged
RhysSullivan merged 1 commit into
mainfrom
autumn/skip-idle-persist
Sep 25, 2026
Merged

RhysSullivan merged 1 commit into
mainfrom
autumn/skip-idle-persist

Conversation

@RhysSullivan

@RhysSullivan RhysSullivan commented Sep 24, 2026 •

Copy link
Copy Markdown

Staging billing admission was slow on the shared emulator (UsefulSoftwareCo/executor-next#676).

  • Durable Object persistence. After every non-GET request, persist() rewrote the whole store snapshot and up to 1,000 ledger entries, then listed every prefix to delete leftovers. It now keeps the JSON last written for each key, writes only keys that changed, and deletes only keys that went away. A read-only POST such as customers.get_or_create writes its ledger entry and the ledger index only. A rejected write writes nothing. The recorded values are read from storage once per live instance; direct writes (seed, legacy migration) and failed writes reset the record.
  • Autumn usage rollup. Every check with send_event added an event, and balances scanned all events. Once a customer has more than 64 events for a feature, adjacent events are merged into one. Events that a subscription's usage watermark or a current reset window separates are never merged, so every balance stays the same. Balance reads now use the customer index instead of scanning every event. events.list returns the rolled-up events (documented in the Autumn skill).

Tests are in #34.

Not deployed. The shared emulator needs a separate approval to merge and redeploy.

@RhysSullivan
RhysSullivan force-pushed the autumn/skip-idle-persist branch from c2a641d to ccc7c71 Compare September 24, 2026 19:19
@RhysSullivan
RhysSullivan added this pull request to stack #35 September 24, 2026 19:20
@RhysSullivan
RhysSullivan marked this pull request as ready for review September 25, 2026 04:21
@RhysSullivan
RhysSullivan merged commit 5a7db52 into main Sep 25, 2026
1 check passed
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