Skip to content

Phase 6: Daily Intelligence - #12

Merged
Evin009 merged 18 commits into
mainfrom
develop
Jun 23, 2026
Merged

Evin009 merged 18 commits into
mainfrom
develop

Conversation

@Evin009

@Evin009 Evin009 commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Safe to Spend engine — balance minus bills due before next payday minus buffer reserve; nightly Celery recompute; hero number on dashboard with tappable breakdown
  • Pay Timing Intelligence engine — credit utilization optimizer (target 8%) + bill stacking detector; surfaces dangerous windows where balance won't cover clustered bills
  • Merchant logo service — Clearbit fetch with DB cache; logo on every calendar entry
  • Smart Payment Calendar — unified /calendar feed merging bills + subscriptions, sorted by date, urgency-coded, filter chips; replaces the old bills calendar
  • Both engines registered as Argus tools — Argus can now answer "how much can I spend" and "when should I pay my card" in chat

Test plan

  • CI green (backend tests + Vercel deploy)
  • Safe to Spend number appears on dashboard, tap expands breakdown
  • /calendar page loads with bills and subscriptions sorted by due date
  • Urgency colors correct — red ≤3 days, amber ≤7 days
  • /insights/pay-timing returns card recommendations with correct pay amounts

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 23, 2026 21:19
@vercel

vercel Bot commented Jun 23, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
argus-ai-baqq Ready Ready Preview, Comment Jun 23, 2026 9:26pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds “Daily Intelligence” surfaces and APIs: Safe-to-Spend (cached + live compute), Pay Timing recommendations, merchant logos, and a unified Smart Payment Calendar feed/page.

Changes:

  • Frontend: adds /calendar navigation + new Calendar page and Safe-to-Spend hero on the dashboard.
  • Backend: introduces Safe-to-Spend + Pay Timing engines/endpoints, a /calendar feed, merchant logo lookup/caching, and a nightly recompute Celery task.
  • Tests/migrations: adds cache + logo tables and test coverage for the new engines/endpoints/services.

Reviewed changes

Copilot reviewed 44 out of 45 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
frontend/app/(app)/layout.tsx Adds Calendar entry to app navigation.
frontend/app/(app)/dashboard/page.tsx Renders new Safe-to-Spend hero on dashboard.
frontend/app/(app)/dashboard/_components/SafeToSpendHero.tsx Client component fetching and displaying safe-to-spend + breakdown.
frontend/app/(app)/calendar/page.tsx New Smart Payment Calendar UI consuming /calendar + pay-timing insights.
backend/tests/test_safe_to_spend_tool.py Validates Safe-to-Spend Argus tool registration/behavior.
backend/tests/test_safe_to_spend_engine.py Unit tests for Safe-to-Spend engine computation.
backend/tests/test_safe_to_spend_endpoint.py Endpoint tests for cached vs live Safe-to-Spend.
backend/tests/test_recompute_safe_to_spend.py Tests Celery recompute task upserts cache row.
backend/tests/test_pay_timing_engine.py Unit tests for pay timing logic (utilization + stacking).
backend/tests/test_pay_timing_endpoint.py Endpoint tests for /insights/pay-timing.
backend/tests/test_merchant_logos.py Unit tests for logo cache hit/miss behavior.
backend/tests/test_calendar_endpoint.py Endpoint tests for /calendar sorting + urgency computation.
backend/tasks/recompute_safe_to_spend.py Celery task to recompute and upsert Safe-to-Spend cache.
backend/services/merchant_logos.py Clearbit-based logo lookup with Supabase cache.
backend/routers/pay_timing.py New insights router for pay-timing recommendations.
backend/routers/insights.py Adds /insights/safe-to-spend endpoint (cached + live compute).
backend/routers/calendar.py New /calendar feed merging bills + subscriptions + logos + urgency.
backend/migrations/017_merchant_logos.sql Adds merchant_logos table for logo caching.
backend/migrations/016_safe_to_spend_cache.sql Adds safe_to_spend_cache table + RLS policy.
backend/main.py Registers new pay_timing and calendar routers.
backend/engines/safe_to_spend.py Implements Safe-to-Spend computation engine.
backend/engines/pay_timing.py Implements pay timing + bill stacking detection engine.
backend/celery_app.py Registers recompute task and schedules nightly beat job.
backend/agents/tools.py Registers get_safe_to_spend + get_pay_timing as Argus tools.
Comments suppressed due to low confidence (2)

backend/services/merchant_logos.py:35

  • 🟡 risk: This upserts logo_url=None on any miss/timeout/404, permanently caching failures and preventing future retries (even if Clearbit/network recovers).
    except requests.RequestException:
        logo_url = None

    supabase.table("merchant_logos").upsert(
        {"merchant": merchant, "logo_url": logo_url},
        on_conflict="merchant",
    ).execute()

    return logo_url

backend/tasks/recompute_safe_to_spend.py:44

  • 🟡 risk: safe_to_spend_cache.computed_at never updates on nightly recompute because the upsert payload omits it (DB default only applies on insert).
        on_conflict="user_id",
    ).execute()


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/celery_app.py
Comment on lines +33 to +38
celery.conf.beat_schedule = {
"nightly-safe-to-spend-recompute": {
"task": "tasks.recompute_safe_to_spend.recompute_safe_to_spend_for_user",
"schedule": crontab(hour=2, minute=0),
"args": [],
},
Comment on lines +36 to +41
subscriptions = (
supabase.table("subscriptions")
.select("id, merchant, avg_amount, next_due_date")
.eq("user_id", user_id)
.eq("is_active", True)
.execute()
Comment thread backend/routers/calendar.py Outdated
Comment on lines +46 to +56
for b in bills:
entries.append({
"id": b["id"],
"type": "bill",
"merchant": b["merchant"],
"amount": b.get("avg_amount"),
"due_date": b.get("next_due_date"),
"logo_url": get_logo_url(b["merchant"], supabase),
"urgency": _urgency(b.get("next_due_date") or ""),
"ai_reasoning": None,
})
Comment on lines +24 to +28
bills_due = sum(
b["avg_amount"]
for b in bills
if b.get("next_due_date") and date.fromisoformat(b["next_due_date"]) <= cutoff
)
Comment thread backend/engines/pay_timing.py Outdated
Comment on lines +39 to +44
card_recommendations.append({
"account_id": acct["id"],
"pay_amount": pay_amount,
"target_utilization": _TARGET_UTILIZATION,
"closing_day": acct.get("closing_date"),
})
Comment thread backend/routers/calendar.py Outdated
Comment on lines +41 to +48
<div
onClick={() => setOpen((o) => !o)}
style={{
background: "var(--surface-1)", borderRadius: "var(--r-xl)",
border: "1px solid var(--surface-3)", padding: "20px 24px",
cursor: "pointer", userSelect: "none",
}}
>
Comment on lines +69 to +73
[
["Current balance", data.breakdown.balance, false],
["Bills due this window", data.breakdown.bills_due, true],
["Buffer reserve", data.breakdown.buffer_reserve, true],
] as [string, number, boolean][]
Comment on lines +67 to +73
Promise.all([
api.get<{ entries: CalendarEntry[] }>("/calendar"),
api.get<PayTiming>("/insights/pay-timing"),
]).then(([cal, pt]) => {
setEntries(cal.entries);
setPayTiming(pt);
}).finally(() => setLoading(false));
Comment thread backend/agents/tools.py
Comment on lines +105 to +107
if cached:
return cached[0]
return {"safe_amount": None, "breakdown": {}, "computed_at": None}
@Evin009
Evin009 merged commit 9bc793e into main Jun 23, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Preview — 861d1f14 Deployed Jun 23, 2026 by vercel[bot]
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.

2 participants