Repository navigation
Keep newer local edits to tasks, notes and projects when importing a backup - #96
Merged
Merged
Conversation
…backup Import already skips a memory whose local copy is newer than the backup's, but tasks, notes and projects were overwritten unconditionally, so importing an older backup silently reverted anything edited since it was made. Their upserts now update only when the backup copy is newer.
Owner
|
Thanks @rudycelekli — clear write-up and a solid regression test. Merging! |
This was referenced Oct 27, 2026
pablopfg
added a commit
to pablopfg/talorys
that referenced
this pull request
Oct 28, 2026
…quieter logs (#13) <!-- claude-projects-attribution: {"github_login":"pablopfg"} --> _Requested by **Pablo** · [project thread](https://claude.ai/code/project/chan_01548W9A2AStvwh6Y6QFd3YH?thread=cmsg_01548W9A2AStvwh6Y6QFd3YHCuLNruan51BNAoAR9y64zW)_ Plan, phase 1, PR 3. This closes what was left of AGT-04, and also AGT-07, AGT-08 and AGT-09 from the handoff audit. ## Changes - **AGT-04 (backup import).** rociiu#96 made "newer copy wins". But a forged date such as `9999-…` still beat every later local edit. - Any date that can't be read, or that is more than 5 minutes in the future, is stored as the import time. It never replaces an existing task, note, project or memory. - The import route now reads at most 10 MB, down from 25 MB. Each kind of record has a cap (`MAX_IMPORT_RECORDS`). A backup over either limit is refused whole: nothing is imported. - The web upload check is now 10 MB too. - **AGT-07 (budget day).** - `UsageService` counts the day in the owner's timezone, read from settings. Before, the budget reset at UTC midnight, which is 21:00 in Brasília. An unusable timezone falls back to UTC. - Semantic recall's own embedding caps still use the static UTC day. - Tool calls from a chat turn or scheduled run that fails now count toward the day (`finally`). - **AGT-08 (logs).** Workers AI and chat-turn failures log only `errorSummary`: the error name plus any 3–4 digit code. The message can quote a prompt or a note, so it is no longer logged. - **AGT-09 (update check).** The npm update check now starts off on new installations. The docs say how to turn it on. - I updated the changelog (Alterado and Segurança) and `docs/security.md`, and added the pt-BR text for the new error. ## Tests - `npm run lint`, `typecheck`, `build` and `npm test` all pass (879 tests). - There are 9 new tests in `apps/agent/test/import-and-budget.test.ts`: - a forged future date, then a local edit, then the same file imported again; - unreadable dates; - the record cap, which imports nothing; - the day in São Paulo and in Tokyo; - the fallback for an invalid timezone; - tool calls counted on a failed turn; - `errorSummary`. - `update-check.test.ts` now turns the check on where it needs it, and has a test that it starts off. ## Upgrading No migration. Existing installs keep their saved update-check setting. --- _Generated by [Claude Code](https://claude.ai/code/session_012XDDEe3xJunmyfeKA7zqv2)_ Co-authored-by: Claude <noreply@anthropic.com>
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.
Bug
Importing a backup reverts tasks, notes and projects edited since the backup was made. For example: you download a backup, keep writing in a note, then import the backup again (or a copy of it from another device). The note goes back to its old text with no warning.
Memories already have a guard for this:
importDataskips a memory whenexisting.updated_at >= m.updated_at, and the README documents it. The project, task and note upserts have no such guard and always overwrite.Fix
The three upserts now update only when the backup copy is newer (
ON CONFLICT(id) DO UPDATE ... WHERE excluded.updated_at > tal_<table>.updated_at). That matches the memory rule. New records and records that exist only locally behave as before, and a backup copy newer than the local one still imports. The README sentence on import and theimportDatadoc comment now say this covers tasks, notes and projects too.Test
New case in
apps/agent/test/backup-import.test.ts: it creates a project, a task and a note, then imports older backup copies of each with different text. It expects the local versions to stay. Then it imports a newer note copy and expects that one to apply.cd apps/agent && npx vitest run test/backup-import.test.ts -t "does not revert"expected 'Trip, old' to be 'Trip, current'.tsc --noEmitand biome are clean.