Skip to content

CreatorTrack finance auto-categorization

Live on prod since 2026-07-06 (merge d11144f). Replaces the code-frozen keyword lists.

  • Engine: lib/finance-categorize.ts; job lib/finance-jobs/categorize.ts now CHAINS at the end of every finance sync (the old backlog came from sync never chaining it).
  • Rules live in finance.category_rules (pattern, match_type, conditions, priority, hit_count, source builtin|learned|user|ai). Priority: user 20 < ai 30 < learned 40 < builtin 1000+.
  • Learn loop: hand-categorizing a tx (POST /api/finance/transactions) upserts a learned merchant rule; merchants with >=3 unanimous historical charges are mined into learned rules on each job run.
  • Never re-files user_category=true or category_source='ai' rows. Provenance on finance.transactions.category_source / applied_rule_id.
  • Rules UI: Categorize tab, CzRulesPanel (filter, hit counts, disable/delete) via /api/finance/categorize/rules.
  • AI pass (for a later Opus session): GET /api/finance/categorize/ai?limit=50 (FINANCE_JOBS_TOKEN bearer) returns uncategorized txns + merchant history; POST {decisions:[{id,category,confidence,createRule}]} applies with source=ai. Usage doc in the route header.

URL: https://mkdocs.justinsforge.com/memory/general/reference_creatortrack_finance_autocat/