OPER-PHI-1
[OPER-PHI-1] Register PHI-eligible reviewer AgentWorker for Studio team
Suggested
Justin Cooke
Body
## Context Three Studio tickets (OPER-113 RLS enable, OPER-QA-6 TestRun state machine, OPER-QA-9 TestRun canvas) are correctly flagged `phiInScope: true` and are stuck at PLANNING_VALIDATED because no PHI-eligible reviewer is registered for the Studio team. The dispatcher's admission gate requires an `AgentWorker` with `kind = "reviewer"`, non-`offline` status, and `"phi"` in `capabilities`. Per Marisol's PDT constraint ([REDACTED-DOB] PHI-handling memo), every PHI-touching agent-authored PR needs a human-plus-reviewer-agent two-lane review before merge. The reviewer agent is not a second coding agent — it's a lightweight worker that gates on the PHI checklist (no plaintext PHI in test fixtures, `@PHI` annotations present, AuditLog writes, `getOrgScopedDb(orgId)` used, RLS policy tests present). Portico already has an equivalent reviewer registered (that's why POR-QA-2/3/4 dispatched fine despite touching PHI-adjacent code). This ticket ports the same pattern to the Studio team. ## Goal An `AgentWorker` row exists on the Studio team with `kind = "reviewer"`, `status = "online"`, and `capabilities` including `"phi"`. Dispatcher's next tick promotes the 3 stuck tickets. ## Human-gate steps None — this is a data-only registration in the Studio DB. Dispatcher can do it directly via a migration or seed script. ## Agent-owned steps (dispatcher) 1. Read Portico's PHI reviewer AgentWorker row as the reference shape: `SELECT * FROM "AgentWorker" WHERE "teamId" = 'cmrawxwg40004obz9jqc7y5p2' AND kind = 'reviewer' AND 'phi' = ANY(capabilities);` 2. Insert equivalent row for Studio team (teamId `cmrawxvxa0001obz9h9wjtha8`), matching Portico's `runbookRef`, `promptRef`, `slaSeconds`, `capabilities` (must include `phi`), and `status = "online"`. 3. Add a migration `packages/database/prisma/migrations/YYYYMMDD_oper_phi_1_studio_reviewer/` that upserts this row (idempotent). This survives DB rebuilds. 4. Vitest at `packages/dispatcher/src/__tests__/phi-gate.test.ts`: a PHI-flagged ticket on Studio team promotes past the `phi-no-reviewer` gate (integration test against `withTeamContext(studio)`). 5. Confirm OPER-113, OPER-QA-6, OPER-QA-9 flip out of PLANNING_VALIDATED on the next dispatcher tick. ## Acceptance criteria - `AgentWorker` row exists for Studio team with the required shape (verified by SELECT) - Migration is committed and idempotent (safe to re-run) - Vitest phi-gate test passes: registering the reviewer flips a `phiInScope: true` ticket from PLANNING_VALIDATED past the gate - OPER-113, OPER-QA-6, OPER-QA-9 promote on the next tick (verified by their status changing) ## Why this matters Unblocks 3 Studio tickets in one shot. Small, mechanical, low-risk. Same pattern already proven in Portico. No PHI is created or exposed by this change — it registers an *identity* that will review future PHI-touching PRs. --- <!-- admission-rejected --> **Admission rejected (missing_feature_id):** ticket body is missing `feature_id: FEAT-...` frontmatter — declare which feature this ticket implements
Attachments
Loading attachments…
Comments
Loading comments…