Skip to content

Savings ledger 3/6: per-session ledger and the ledger-key sweep - #31

Merged
cris005 merged 1 commit into
mainfrom
savings/03-ledger
Nov 2, 2026
Merged

cris005 merged 1 commit into
mainfrom
savings/03-ledger

Conversation

@cris005

@cris005 cris005 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Part 3 of 6. Nothing here is wired in yet; #32 connects it.

  • services/ledger-store.ts: per-session totals in plugin storage under ledger/<sessionID>.
    • Validated on load.
    • Updates are serialised per session.
    • A change that throws leaves the totals as they were.
  • services/savings-ledger.ts: stretchStarted, pingCharged, stretchRescued and readout.
    • Each event is priced through the PriceBook, and a failed lookup counts as unpriced.
    • One unpriced event makes the session unit-free for good.
  • services/settings-store.ts: sweepDeletedSessions takes several key prefixes and looks each session up once. The server keeps sweeping only session/ until Savings ledger 4/6: savings setting, stretch tracking and server wiring #32.

Testing

Unit tests, plus properties: concurrent events give the same totals as sequential ones, and totals never decrease.


Stack created with GitHub Stacks CLI • Give Feedback 💬

@cris005
cris005 added this pull request to stack #35 October 31, 2026 13:27
@cris005 cris005 changed the title feat(savings): per-session ledger and the ledger-key sweep Savings ledger 3/6: per-session ledger and the ledger-key sweep Oct 31, 2026
Base automatically changed from savings/02-prices to main November 2, 2026 03:59
Adds the storage-backed LedgerStore (validated on load, serialised per
session) and the SavingsLedger that charges pings and rescued stretches
against the PriceBook, with unpriced events sticky per session. The
deleted-session sweep now takes several key prefixes and looks each
session up once. Nothing is wired yet.
@cris005
cris005 merged commit 1af35d2 into main Nov 2, 2026
2 checks passed
@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

@cris005
cris005 deleted the savings/03-ledger branch November 2, 2026 05:21
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