Operant Studio
OPER-187

D-29: qa-run-scheduler cron symmetric to qa-freshness

Suggested
Justin Cooke

Body

---
feature_id: FEAT-studio-qa
---

> D-29 ticket 4: qa-run-scheduler cron. Target FEAT-studio-qa-run-scheduler (child). BLOCKED-BY: OPER-127a #422 rerun-loop state machines.

## Context

(PDT decision-memo lineage; see source line below.)

**Source: PDT D-29 (coverage by construction), ticket 4 of 5.**

## What
New cron at `apps/web/src/app/api/cron/qa-run-scheduler/route.ts`. Symmetric partner to existing `qa-autogen` and `qa-freshness` crons.

On tick:
1. Enumerate CoverageCells in state RED, stale, or FAILING that have at least one READY TestCase.
2. For each cell, enqueue a `TestRun` (status QUEUED) if no in-flight run exists.
3. Dispatch by runtime:
   - Headless-runnable (unit, integration, e2e) -> dispatch to Playwright cron / GitHub Action runner
   - `manual` runtime -> create a RUN_TEST TestAssignment via existing `notify.ts` path

## Blocked-by
OPER-127a #422 (rerun-loop state machines). The scheduler needs the state machine substrate for TestRun lifecycle transitions. This dependency rides the D-28 drain.

## Acceptance Criteria
- [ ] Cron route registered in `vercel.json`
- [ ] Enumerates RED/stale/FAILING cells with READY TestCases
- [ ] Enqueues TestRun with QUEUED status, idempotency-protected against duplicates
- [ ] Headless dispatch and manual-runtime task creation both work
- [ ] Integration test exercising the full path against a fixture cell

## Feature
FEAT-studio-qa-run-scheduler (add via feature-map + depmap two-PR sequence FIRST)

## Size / Band
MEDIUM / assurance.

Attachments

Loading attachments…

Comments

Loading comments…