Skip to content

fix(core): make memory transactions rollback-safe - #429

Draft
Egge21M wants to merge 1 commit into
masterfrom
feat/nut29-memory-transaction-rollback
Draft

fix(core): make memory transactions rollback-safe#429
Egge21M wants to merge 1 commit into
masterfrom
feat/nut29-memory-transaction-rollback

Conversation

@Egge21M

@Egge21M Egge21M commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • make in-memory repository transactions commit and roll back atomically across repositories
  • preserve stable repository references held by existing services
  • serialize root repository operations around active transactions so rollback cannot erase unrelated writes
  • add regression coverage for create, update, delete, stable-reference, and concurrent-write behavior
  • add a patch Changeset for @cashu/coco-core

Problem

MemoryRepositories.withTransaction previously invoked the callback directly, so a thrown callback could leave partial durable state behind. A snapshot-only implementation would also risk rolling back unrelated root writes made while a transaction was active.

This pull request resolves #422.

Scope

This is limited to rollback-safe in-memory transactions and regression tests. It does not introduce a Batch Mint Operation model, repository, public API, migration, or runtime behavior.

Verification

  • bun run --filter='@cashu/coco-core' test -- test/unit/MemoryRepositories.test.ts
  • bun run --filter='@cashu/coco-core' test:unit — 1,245 passed
  • bun run --filter='@cashu/coco-core' build
  • bun run --filter='@cashu/coco-core' typecheck
  • SQLite3 repository contract
  • Bun SQLite repository contract
  • Expo SQLite repository contract
  • IndexedDB Chromium repository contract — 54 passed
  • Prettier check
  • git diff --check

Changeset

  • .changeset/safe-memory-transactions.md

@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 53dd6b9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@cashu/coco-core Patch
@cashu/coco-adapter-tests Patch
@cashu/coco-expo-sqlite Patch
@cashu/coco-indexeddb Patch
@cashu/coco-react Patch
@cashu/coco-sql-storage Patch
@cashu/coco-sqlite-bun Patch
@cashu/coco-sqlite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.69231% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.43%. Comparing base (eb21988) to head (53dd6b9).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...ges/core/repositories/memory/MemoryRepositories.ts 97.69% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #429      +/-   ##
==========================================
+ Coverage   93.40%   93.43%   +0.03%     
==========================================
  Files         113      113              
  Lines       17930    18059     +129     
==========================================
+ Hits        16748    16874     +126     
- Misses       1182     1185       +3     
Flag Coverage Δ
core-integration 52.73% <97.69%> (+2.80%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Make in-memory repository transactions rollback-safe

1 participant