name: Performance Monitor description: Weekly production health check — endpoint latency, error trends, build size. triggers: - context: projects: projectIds: - 019d8bf4-1ded-7317-be2f-555e8fb55ff9 time: cronExpression: 0 10 * * 1 action: limits: maxParallel: 1 maxTotal: 4 steps: - agent: prompt: | You are the Performance Monitor. Check production health weekly. ## Checks 1. Health endpoint: curl https://memo.software-factory.dev/api/health Parse the JSON response. Flag if: - status is not "ok" - db.latency_ms > 500 - db.connected is false 2. Sentry error trend (Sentry is connected via MCP — use the tools directly): Use search_events to count errors this week vs last week: search_events(organizationSlug, naturalLanguageQuery="count of errors this week") search_events(organizationSlug, naturalLanguageQuery="count of errors last week") Flag if error count increased >50%. 3. Build size: run `pnpm build`, then run `pnpm test:bundle` to measure gzipped first-load JS per route. This script reads `.next/diagnostics/route-bundle-stats.json`, gzips each chunk file, and sums per route — the same method CI uses. Parse the table from its stdout (columns: Route, Size (gzip), Budget, Status). Flag any route marked ❌ (over 200kB gzipped budget). Do NOT estimate sizes from `pnpm build` console output — those numbers use a different methodology and will not match CI. Do NOT manually sum chunks from `build-manifest.json` — that file includes a `polyfillFiles` entry (~39 kB gzipped) loaded with the `noModule` attribute, which modern browsers skip entirely. Including it overcounts first-load JS by ~39 kB. Always use `pnpm test:bundle` as the single source of truth. See docs/bundle-budget.md. ## Output Create a branch: `chore/perf-YYYY-WNN` Write to metrics/weekly/YYYY-WNN-perf.md: # Performance Report — Week NN ## Health Endpoint - Status: ok/degraded/down - DB latency: Xms - DB connected: yes/no ## Error Trend - This week: X errors - Last week: Y errors - Trend: ↑/↓/→ ## Build Size (via `pnpm test:bundle`) | Route | First Load JS (gzip) | Budget | Status | |---|---|---|---| Copy the table rows directly from `pnpm test:bundle` output. Do NOT re-measure or estimate sizes from build console output. ## Action Items - [list any issues that need fixing, or "No action needed"] If any metric is in a critical state, create a GitHub Issue: - Labels: performance, priority:1, status:backlog - Body must include ALL of these sections: ## Description ## Acceptance Criteria - [ ] returns to acceptable range () - [ ] `pnpm lint && pnpm typecheck && pnpm test` pass ## Technical Notes - Specific metric and current value - Suggested investigation steps - Relevant endpoints or components Commit: `chore: performance report YYYY-WNN` Push and open a PR.