Repository navigation
[AI] Port upstream data-integrity and sync fixes - #214
Merged
Merged
Conversation
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
force-pushed
the
claude/port-upstream-data-integrity
branch
from
November 29, 2026 02:17
2b8ea1e to
f4b8caa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
168e174b47).writeFile(in theapiandnode-testbuilds) and the sync server's/upload-user-filenow write to a temp file and rename it over the target. Symlinks are followed and the file mode is kept.getPathForUserFilerefuses paths outside the user files directory.index.node.ts, since Electron is gone. The fork's ArrayBuffer→Uint8Array conversion is kept. Upstream's owner/admin upload tests were left out, because they depend on a multi-user change the fork doesn't have.1b245f2600).applyMessages.e82ea4dc35).closeBudgetstops new full syncs and waits for the running sync and every queued mutator before unloading.lastScheduleRunthere.persistence.flushinstead ofwaitOnSpreadsheet. It also calls the fork's synchronousbatchMessagesfrom inside an async mutator.945fce10bb). Applied as-is.8e6eb272a7). The test drops itsawaits becauseaqlQueryis synchronous in the fork.Review follow-ups (from an adversarial review of these ports)
scheduleFullSyncdoes nothing while syncs are stopped, andresumeFullSyncclears 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.unloadBudgetturns 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.Already in the fork: actualbudget/actual#9027 (
ef0f0614a0) and actualbudget/actual#8706 (5f60f2971c), both via the upstream merge in #52.Skipped
schedule-template.tswas deleted with the goal templates in [AI] Remove the upstream goal template system #111, and nothing else simulates schedule rules against a category.Known gaps, not addressed here
close-budgetnow waits for an in-flight sync, andpostBinaryhas no timeout, so a stalled server can delay close.app-focusedwhile_loadBudgetruns still emitssync:success, which can start the schedule service on a half-loaded budget. This existed before this PR.Checks:
yarn typecheckandyarn lintpass. The full loot-core suite passes (1011 tests). TheTransactionsTabletest passes. The sync-serverapp-sync,atomic-writeandpathstests 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