Skip to content

Expose missing data to the AI (account filters, achievements, score trend, investment txns)#16

Open
cdinnison wants to merge 3 commits intomainfrom
cdinnison/ai-data-gaps
Open

Expose missing data to the AI (account filters, achievements, score trend, investment txns)#16
cdinnison wants to merge 3 commits intomainfrom
cdinnison/ai-data-gaps

Conversation

@cdinnison
Copy link
Copy Markdown
Owner

Summary

The AI was blind to data that existed in the schema but had no tool to query. This PR closes those gaps.

Filters on existing tools

  • get_transactionsaccount, label, include_pending
  • search_transactionsaccount
  • get_spending_summaryaccount, merchant

New tools

  • get_achievements — list unlocks (table was populated but unreadable)
  • get_score_trend — daily score history (was latest-only)
  • get_investment_transactions — buy/sell activity (table was seeded but unqueryable)
  • list_recat_rules + delete_recat_rule — rule CRUD was write-only before

Output improvements

  • get_accounts surfaces credit utilization ("15% of $5,000 limit") when balance_limit is set
  • get_recurring merges manually-added recurring_bills alongside Plaid-detected streams

Origin: user asked "what is my biggest expense in Free to Spend" and the AI said "I can't filter by account" — even though transactions.account_id exists. Audit surfaced a handful of similar gaps.

Test Coverage

  • 4 new regression tests covering account, label, excludePending filters on getTransactionsFiltered, and account-scoped searchTransactions
  • Tests: 104 → 108 (+4)
  • All 108 tests pass, TypeScript clean

Paths not covered by unit tests: new AI handler cases (thin SQL + string formatting, consistent with existing tool handler pattern in the file). Credit utilization render path, recurring merge output, and investment transactions join are validated by the query-layer tests and manual verification.

Pre-Landing Review

Self-review of the diff:

  • All SQL parameterized; account/merchant/label LIKE values flow through ? placeholders
  • getAccountBalances behavior preserved; new balance_limit column additive
  • getTransactionsFiltered default behavior preserved — pending filter is opt-in (excludePending), so the ray transactions CLI is unchanged. AI get_transactions defaults to excluding pending, explicitly documented in the tool schema
  • Credit utilization calc guarded against null/zero balance_limit
  • delete_recat_rule follows the same unauthenticated-by-ID pattern as delete_budget / delete_goal
  • get_investment_transactions caps at LIMIT 50 by default to prevent large-portfolio blowup

Notes

milestones table was flagged during the gap audit but is untouched here — it has no writer or reader outside backup round-trip. Worth a separate cleanup PR to drop it if you want; goals already covers the same space with proper progress tracking.

Test plan

  • npx tsc --noEmit clean
  • npm test — 108/108 passing
  • Manual: ask chat "what's my biggest expense in Free to Spend" and confirm it filters correctly
  • Manual: ray transactions CLI still shows pending transactions (no behavior change)

🤖 Generated with Claude Code

cdinnison and others added 3 commits April 23, 2026 09:31
- TransactionFilters: add account, label, excludePending
- getAccountBalances: return balance_limit for utilization calc
- searchTransactions: optional account scope
- New getScoreTrend for daily score history
- Regression tests for new filters

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Filters:
- get_transactions: account, label, include_pending
- search_transactions: account
- get_spending_summary: account, merchant

New tools:
- get_achievements, get_score_trend, get_investment_transactions
- list_recat_rules, delete_recat_rule

Output improvements:
- get_accounts shows credit utilization when balance_limit present
- get_recurring merges manual recurring_bills alongside Plaid streams

Previously the AI could see this data in the schema but had no tool to
query it, so it would tell users "I can't filter by account" even though
transactions had account_id all along.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ray-finance Ready Ready Preview, Comment Apr 23, 2026 4:32pm

Request Review

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