Skip to content

[AI] Port upstream data-integrity and sync fixes - #214

Merged
chrisvasz merged 7 commits into
masterfrom
claude/port-upstream-data-integrity
Nov 29, 2026
Merged

chrisvasz merged 7 commits into
masterfrom
claude/port-upstream-data-integrity

Conversation

@chrisvasz

@chrisvasz chrisvasz commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Ports upstream data-integrity and sync fixes. Five are ported, two were already in the fork, and two don't apply. There is one commit per port, plus two follow-ups from an adversarial review.

Ported

Review follow-ups (from an adversarial review of these ports)

  • scheduleFullSync does nothing while syncs are stopped, and resumeFullSync clears a leftover timer. Without this, a timer set during close could fire while the next budget was half-loaded and write the old budget's clock into it.
  • unloadBudget turns syncing off once the database is closed. Turning it off any earlier would stop an edit made during close from being logged for sync. The shutdown test checks that such an edit is still logged.
  • The clock-restore tests now hold the mutator queue, so the receives they test are actually pending. With the fork's synchronous apply, they previously passed without testing anything.

Already in the fork: actualbudget/actual#9027 (ef0f0614a0) and actualbudget/actual#8706 (5f60f2971c), both via the upstream merge in #52.

Skipped

Known gaps, not addressed here

  • close-budget now waits for an in-flight sync, and postBinary has no timeout, so a stalled server can delay close.
  • A sync triggered by app-focused while _loadBudget runs still emits sync:success, which can start the schedule service on a half-loaded budget. This existed before this PR.
  • A crash during an atomic write can leave temp files behind. This is inherited from upstream.

Checks: yarn typecheck and yarn lint pass. The full loot-core suite passes (1011 tests). The TransactionsTable test passes. The sync-server app-sync, atomic-write and paths tests pass; the supertest ones ran outside the sandbox so they could bind a port. Each ported test fails without its fix. The branch merges cleanly with #215.

🤖 Generated with Claude Code

@chrisvasz chrisvasz changed the title [AI] Port upstream data-integrity and sync fixes (atomic file writes) [AI] Port upstream data-integrity and sync fixes Nov 2, 2026
chrisvasz and others added 7 commits November 28, 2026 20:17
Port actualbudget/actual#9014 (168e174b47). loot-core's node and API fs
writeFile and the sync server's /upload-user-file now write a temp file
and rename it over the target, so a failed or killed write leaves the
previous file intact. Symlinks are followed and the file mode is kept.
getPathForUserFile also refuses paths outside the user files directory.

Adapted: the upstream Electron fs changes land in the fork's
index.node.ts (Electron is gone), the ArrayBuffer-to-Uint8Array
conversion the fork's writeFile already did is kept, and the upstream
owner/admin upload tests (from a multi-user change the fork lacks) were
left out of app-sync.test.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ream #8904)

Port actualbudget/actual#8904 (1b245f2600). receiveMessages now
receives the batch's latest timestamp inside the apply transaction and
restores the clock only if that transaction throws, so a failed batch no
longer leaves the clock advanced. Adapted to the fork's synchronous
applyMessages; the deferUnknownSchema flag becomes isReceived as
upstream.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Port actualbudget/actual#8791 (e82ea4dc35). closeBudget stops new full
syncs, waits for the running sync and every queued mutator, then
unloads. The post-sync schedule run happens inside its mutator and
re-checks lastScheduleRun there, so a run queued by an earlier sync
doesn't repeat.

Adapted: the fork has no spreadsheet, so the shutdown test gates
persistence.flush instead of waitOnSpreadsheet. It also calls the
fork's synchronous batchMessages from inside an async mutator.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…309)

Port actualbudget/actual#9309 (945fce10bb). evalArithmetic returns the
default value for Infinity as well as NaN, so expressions like 1/0
no longer reach amount fields.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…upstream #9173)

Port actualbudget/actual#9173 (8e6eb272a7). updateSchedule compares the
account condition through extractScheduleConds and ignores the field
name, so editing a schedule whose account condition uses the internal
name no longer resets next_date and drops a skipped date. The test
drops awaits on the fork's synchronous aqlQuery.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-up to the #8791 and #8904 ports. scheduleFullSync does
nothing while syncs are stopped, and resumeFullSync clears a leftover
timer. unloadBudget turns syncing off, so a sync that starts while the
next budget loads can't apply the old clock to it. The clock-restore
tests now hold the mutator queue, so the receives really are pending.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-up. Disabling sync at the start of unloadBudget let an
edit that landed during close skip messages_crdt, so it never reached
other devices. Disable it after db.closeDatabase instead; while closing,
the stopped full sync already keeps syncs and timers out. The shutdown
test now checks that such an edit is still logged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chrisvasz
chrisvasz force-pushed the claude/port-upstream-data-integrity branch from 2b8ea1e to f4b8caa Compare November 29, 2026 02:17
@chrisvasz
chrisvasz merged commit 0707757 into master Nov 29, 2026
7 checks 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