Operant Studio
OPER-200

HV-4: FeatureConfidenceRollup materializer cron

Suggested
Justin Cooke

Body

---
feature_id: FEAT-studio-qa
size: S
module: qa
phi_in_scope: false
has_migration: false
write_sets:
  - packages/qa/src/rollup.ts
  - apps/web/src/app/api/cron/confidence-rollup/route.ts
---

## Context

Parent: OPER-196.

Once HV-1 lands the `FeatureConfidenceRollup` table, this ticket adds the cron that materializes it. Same shape and cadence as `CoverageCell` materialization (`apps/web/src/app/api/cron/qa-freshness/route.ts`).

Rollup carries three bars: machine pass rate (from `TestResult`), expected-smiley median (from `HumanVerification.experienceScoreExpected`), time-saving-smiley median (from `HumanVerification.experienceScoreTimeSaving`). Read by the release gate as one row per `(teamId, projectId, featureId, buildSha)`.

## Acceptance Criteria

- `materializeRollup({ teamId, projectId, featureId, buildSha }): Promise<FeatureConfidenceRollup>` in `packages/qa/src/rollup.ts`
- Cron route `/api/cron/confidence-rollup` runs every 15 minutes, materializes rollups for any (team, project, feature, buildSha) tuple with new HumanVerification or TestResult rows since last run
- Idempotent: same inputs produce same output row (upsert on unique key)
- Vitest tests for empty-verifications, single-verification, mixed-smiley-distribution cases

Attachments

Loading attachments…

Comments

Loading comments…