Mirror YNAB budget into Postgres with delta sync and change log

YNAB has no event feed, so keep a local copy in ynab_* tables synced via
server_knowledge delta requests: full download on first run, deltas every
YNAB_SYNC_INTERVAL seconds and on demand before each tool call, full
resync daily. Each sync diffs against the mirror and appends real edits
(transactions, assignments, renames) to ynab_changes, the edit history
YNAB doesn't keep.

Agent YNAB tools now answer from the mirror: budget summary (spending
computed from transactions, since YNAB's month activity nets in credit
card payment categories), account balances, transaction search with
splits expanded, spending reports by category/payee/account/month,
category budget, and recent changes. Adds an admin-only read-only
ynab_sql tool guarded by a sqlglot allowlist (scope-resolved tables, no
dangerous functions), a READ ONLY transaction, a timeout, and a row cap.

Replaces utils/ynab_service.py and drops the unused ynab SDK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 17:32:38 -04:00
parent 3e2a237eb6
commit 8f02318542
21 changed files with 1846 additions and 903 deletions
+1
View File
@@ -19,6 +19,7 @@ TORTOISE_CONFIG = {
"blueprints.scheduled_messages.models",
"blueprints.cron.models",
"blueprints.beli.models",
"blueprints.ynab.models",
"aerich.models",
],
"default_connection": "default",