Commit graph

4 commits

Author SHA1 Message Date
216dacb0f2 Raise output token cap; add one-time note about the rota-methodology fix
MAX_OUTPUT_TOKENS was 600 and briefings were hitting it mid-sentence
(confirmed on a live generation — cut off mid-bullet). Raised to 900.

Also adds a time-boxed methodology note (expires 29/07/2026) so the
model doesn't flag the 25/07 base-cost-only rota fix as an unexplained
swing when it sees a prior insight's rota variance figures differ —
it was told to compare against recent insights explicitly, and without
this note it correctly but unhelpfully treated a deliberate correction
as an open question needing clarification.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-25 09:30:15 +00:00
661e219aac Fix rota-vs-actual comparison: base-cost mismatch and missing dept names
Two bugs inflating the rota variance figures in AI insights:
1. Actual cost (incl. NI oncosts) was compared against rota cost that
   silently falls back to base pay — Workforce's schedules API never
   actually supplies oncosts (confirmed: published_total_cost equals
   published_base_cost on every synced row), so every variance was
   inflated by ~14-20% for reasons unrelated to real overspend. Now
   always compares base cost on both sides, with a note in the prompt
   that this is a base-pay-only comparison.
2. Variance was summed over the full window using actual cost, but
   only over covered days using rota cost, understating rota further
   whenever coverage was incomplete. Now restricts the actual-cost side
   to the same days rota data exists for, and reports coverage (days
   w/ rota vs total) explicitly so partial coverage isn't presented as
   a confirmed figure.

Also: the employee anomalies section only had department_id (a raw
Workforce code), not department_name, since wage_actuals_detail doesn't
store it — resolved via wage_actuals so the model can say "Chef"
instead of guessing from a numeric code.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-25 00:43:12 +00:00
6339b33270 Add insight history view; feed recent insights back into the prompt
Dashboard now shows a collapsible history of past AI insights (reusing
the existing /history endpoint), and generation now includes the last
3 insights in the prompt so the model can reference what it already
said instead of repeating the same points every day.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-24 22:01:13 +00:00
95da5ea237 Add AI cost insights dashboard; rota-informed forecast method
AI Insights: a daily Claude-generated wage cost briefing covering
month-to-date pace vs budget, prior-month/prior-year comparison,
rota-vs-actual variance by department, a rota-informed forecast to
month-end, employee-level anomalies, and wage cost as a % of revenue.
Runs on a configurable daily schedule or on demand, gated by a manual
5-minute rate limit and a daily token budget. Uses the Anthropic key
configured centrally in Portal → Settings → Integrations.

Also includes the rota-vs-repeat-pattern forecast method (published/
draft rota tiers with same-weekday fallback) already built into the
Weekly/Monthly views, and adds a .gitignore for node_modules/dist.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-24 20:43:18 +00:00