fix(ST-1107): cron schedule daily — Vercel Hobby allows only 1 run/day
Vercel deploy faalde met: > Hobby accounts are limited to daily cron jobs. > This cron expression (0 */6 * * *) would run more than once per day. Schedule van 4×/dag (0 */6 * * *) naar 1×/dag (0 4 * * * — 04:00 UTC, rustig tijdstip). Functioneel acceptabel: ClaudeQuestion TTL is 24u, dus daily cleanup pakt alles dat in de afgelopen 24u verlopen is. Login-pairings TTL is 2 min — die zijn al onbruikbaar zodra ze expiren, cron is alleen voor status-housekeeping. Schedule-referenties consistent bijgewerkt in docs (API.md, architecture, backlog M11-sectie, plan-doc, pattern-doc) + comment in route.ts. Vermelding overal dat dit een Hobby-plan-beperking is en Pro fijnmaziger ondersteunt. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e5819ee079
commit
a408ff37c3
7 changed files with 12 additions and 9 deletions
|
|
@ -1,6 +1,8 @@
|
|||
// ST-1107: Vercel cron handler die verlopen Claude-vragen op 'expired' zet.
|
||||
//
|
||||
// Wordt elke 6 uur door Vercel POST'd (zie vercel.ts crons-config). Auth is
|
||||
// Wordt dagelijks om 04:00 UTC door Vercel POST'd (zie vercel.json crons-
|
||||
// config; Vercel Hobby-plan staat alleen daily crons toe — Pro ondersteunt
|
||||
// fijnmaziger). Auth is
|
||||
// via een gedeeld secret in de Authorization-header — Vercel injecteert
|
||||
// `Authorization: Bearer <CRON_SECRET>` automatisch wanneer de env-var op de
|
||||
// project-omgeving staat.
|
||||
|
|
|
|||
|
|
@ -461,11 +461,11 @@ const source = new EventSource('/api/realtime/notifications', { withCredentials:
|
|||
|
||||
### `POST /api/cron/expire-questions`
|
||||
|
||||
Vercel cron handler die elke 6 uur draait. Markeert verlopen open vragen als `expired` en verlopen pending login_pairings als `cancelled`.
|
||||
Vercel cron handler die dagelijks draait. Markeert verlopen open vragen als `expired` en verlopen pending login_pairings als `cancelled`.
|
||||
|
||||
**Auth:** `Authorization: Bearer ${CRON_SECRET}` — header die Vercel automatisch injecteert wanneer de env-var op de project-omgeving staat. Zonder secret of bij mismatch: 401.
|
||||
|
||||
**Schedule:** `0 */6 * * *` (4× per dag).
|
||||
**Schedule:** `0 4 * * *` (dagelijks om 04:00 UTC; Vercel Hobby-plan staat alleen daily crons toe — Pro ondersteunt fijnmazigere schedules).
|
||||
|
||||
**Response 200:**
|
||||
```json
|
||||
|
|
|
|||
|
|
@ -79,8 +79,9 @@ weert.
|
|||
- **MCP-tool wait_seconds**: max 600 s — Claude wacht maximaal 10 min op een
|
||||
antwoord; daarna `status: 'pending'` zodat hij later kan terugkomen via
|
||||
`get_question_answer`
|
||||
- **Cron schedule**: `0 */6 * * *` — 4× per dag genoeg om 'expired' op te
|
||||
ruimen zonder Vercel-cron-budget te belasten
|
||||
- **Cron schedule**: `0 4 * * *` — daily op een rustig tijdstip (Vercel Hobby
|
||||
staat alleen daily crons toe; Pro ondersteunt fijnmaziger). 24 u TTL +
|
||||
daily cleanup houdt de tabel klein zonder cron-budget te belasten
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ Backlog-entries: zie [scrum4me-backlog.md § M11](../scrum4me-backlog.md#m11-cla
|
|||
```ts
|
||||
export const config: VercelConfig = {
|
||||
// ... bestaande config
|
||||
crons: [{ path: '/api/cron/expire-questions', schedule: '0 */6 * * *' }],
|
||||
crons: [{ path: '/api/cron/expire-questions', schedule: '0 4 * * *' }],
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -638,7 +638,7 @@ sequenceDiagram
|
|||
| **Demo-account misbruik** | `requireWriteAccess` op MCP-write-tools (PERMISSION_DENIED), early-return op `session.isDemo` in answerQuestion Server Action, disabled submit + tooltip in AnswerModal |
|
||||
| **Cross-product leak** | `productAccessFilter` op DB-query én SSE-server-side-filter (Set met user's accessible product-IDs) |
|
||||
| **Cron-endpoint misbruik** | `Authorization: Bearer ${CRON_SECRET}` — Vercel injecteert automatisch; faalt 401 als secret niet gezet (geen open endpoint in dev) |
|
||||
| **Onbeperkte vragen-groei** | `expires_at` 24 u + Vercel cron `0 */6 * * *` markeert `status='expired'` → uit notifications-bell |
|
||||
| **Onbeperkte vragen-groei** | `expires_at` 24 u + Vercel cron `0 4 * * *` (dagelijks; Hobby-plan-limiet) markeert `status='expired'` → uit notifications-bell |
|
||||
| **Gevoelige info in logs** | Logging alleen `question_id`, nooit vraag- of antwoord-tekst |
|
||||
|
||||
### Waarom hergebruik scrum4me_changes-kanaal
|
||||
|
|
|
|||
|
|
@ -707,7 +707,7 @@ Persistent vraag-antwoord-kanaal tussen Claude Code (via MCP) en de actieve Scru
|
|||
|
||||
- [ ] **ST-1107** Vercel cron `expire-questions`
|
||||
- **`app/api/cron/expire-questions/route.ts`** — POST handler beveiligd via `Authorization: Bearer ${CRON_SECRET}`; `updateMany WHERE status='open' AND expires_at<now → status='expired'`
|
||||
- **`vercel.ts`** — `crons` entry: `{ path: '/api/cron/expire-questions', schedule: '0 */6 * * *' }`
|
||||
- **`vercel.json`** — `crons` entry: `{ path: '/api/cron/expire-questions', schedule: '0 4 * * *' }` (dagelijks; Vercel Hobby-plan staat alleen daily crons toe)
|
||||
- **`lib/env.ts`** + `.env.example` — `CRON_SECRET` via Zod
|
||||
- Optioneel: ook M10's `login_pairings`-cleanup in dezelfde route opnemen
|
||||
- Done when: handmatige `curl -X POST` met secret expireert oude rijen; Vercel-dashboard toont cron-config na deploy; onbevoegde call → 401
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"crons": [
|
||||
{
|
||||
"path": "/api/cron/expire-questions",
|
||||
"schedule": "0 */6 * * *"
|
||||
"schedule": "0 4 * * *"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue