fix(operations): cache usage endpoint (avoid 429) + weekly-Sonnet instead of Opus #245

Merged
chaim merged 1 commits from worktree-usage-cache into main 2026-06-13 10:44:24 +00:00
Owner

שני תיקוני-המשך לפיצ'ר אחוז-השימוש (#244):

  1. קאשינג נגד 429/api/oauth/usage מחזיר 429 כשפונים אליו תכוף; דף /operations מתרענן כל 5 שניות וכל ריענון פגע בו (+ הסופרוייזר + קריאות אד-הוק) → 429, והכרטיס הציג null. עכשיו ה-bridge מקאשש את התשובה הטובה האחרונה ל-60 שניות; אנתרופיק מקבל ~קריאה אחת לדקה ללא קשר לתדירות-הריענון. בכישלון (429 חולף) מגיש את הקאש הישן במקום לרוקן את הכרטיס.
  2. שבועי-Sonnet במקום Opus — המד השלישי הציג weekly-Opus שהוא null בחשבון הזה; הקאפ הפר-מודלי שמאוכלס בפועל הוא Sonnet. הוחלף ל-seven_day_sonnet / "שבועי · Sonnet". (הסופרוייזר ממשיך לגדר על seven_day_opus — הדריינר רץ Opus, אז זה השער הנכון גם כשהוא null.)

אימות

  • server.py עובר ast.parse; tsc --noEmit עובר.

פריסה

  • host (court_fetch_service) → סנכרון + pm2 restart legal-court-fetch-service (הקאש).
  • קונטיינר (web-ui) → deploy (תווית Sonnet).

🤖 Generated with Claude Code

שני תיקוני-המשך לפיצ'ר אחוז-השימוש (#244): 1. **קאשינג נגד 429** — `/api/oauth/usage` מחזיר 429 כשפונים אליו תכוף; דף `/operations` מתרענן כל 5 שניות וכל ריענון פגע בו (+ הסופרוייזר + קריאות אד-הוק) → 429, והכרטיס הציג null. עכשיו ה-bridge מקאשש את התשובה הטובה האחרונה ל-60 שניות; אנתרופיק מקבל ~קריאה אחת לדקה ללא קשר לתדירות-הריענון. בכישלון (429 חולף) מגיש את הקאש הישן במקום לרוקן את הכרטיס. 2. **שבועי-Sonnet במקום Opus** — המד השלישי הציג weekly-Opus שהוא `null` בחשבון הזה; הקאפ הפר-מודלי שמאוכלס בפועל הוא Sonnet. הוחלף ל-`seven_day_sonnet` / "שבועי · Sonnet". (הסופרוייזר ממשיך לגדר על `seven_day_opus` — הדריינר רץ Opus, אז זה השער הנכון גם כשהוא null.) ## אימות - `server.py` עובר `ast.parse`; `tsc --noEmit` עובר. ## פריסה - **host** (`court_fetch_service`) → סנכרון + `pm2 restart legal-court-fetch-service` (הקאש). - **קונטיינר** (`web-ui`) → deploy (תווית Sonnet). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-13 10:44:18 +00:00
fix(operations): cache the usage endpoint (avoid 429) + show weekly-Sonnet not Opus
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 3s
693126484b
Two follow-ups to the usage-% feature:

1. The /api/oauth/usage endpoint 429s when polled often — /operations refreshes
   every 5s and each refresh hit it (plus the supervisor + ad-hoc calls). Cache
   the last good payload on the host bridge for 60s and serve it; only re-fetch
   when stale, so Anthropic sees ~1 req/min regardless of dashboard polling. On
   a fetch failure (e.g. a transient 429) serve the last good payload instead of
   blanking the card. The 5-hour window moves slowly, so 60s stays fresh.

2. The third meter showed weekly-Opus, which is null on this account (the
   per-model weekly cap that's actually populated is Sonnet). Switched the
   display to seven_day_sonnet / "שבועי · Sonnet". (The supervisor keeps gating
   on seven_day_opus — the halacha drain runs Opus, so the Opus cap is the
   correct gate even when it's null/inactive.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chaim merged commit 01bc1b9743 into main 2026-06-13 10:44:24 +00:00
chaim deleted branch worktree-usage-cache 2026-06-13 10:44:24 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ezer-mishpati/legal-ai#245