AGENT_PEPM OWNER_ROLLUP Repair (Inconsistent is_active) — Proof
Purpose: Validate that AGENT_PEPM save repairs inconsistent OWNER_ROLLUP rows where effective_end_date is set but is_active=TRUE, which blocked readiness.
Deployed SHA: [fill after deploy]Cloud Run Revision: [fill]
Date: [fill]
Problem (Prod State)
Forbusiness_id=e948cad9d7cf99eb:
| Row | org_id | is_active | effective_start_date | effective_end_date |
|---|---|---|---|---|
| A | cbs-main | TRUE | 2025-12-01 | 2025-11-30 |
| B | NULL | FALSE | 2025-12-01 | 2025-11-30 |
effective_end_date IS NOT NULL) but still active (is_active=TRUE).Existing close logic only targeted
effective_end_date IS NULL, so Row A was never touched. Readiness (ORG_SCOPED) could still see it as active and block.
Repair UPDATE (Step 1b)
New UPDATE runs immediately after the “close open OWNER_ROLLUP” step in the atomic script:- No org_id filter — repairs both SHARED and ORG_SCOPED rows.
- Safe predicate —
effective_end_date < @effective_start_dateavoids deactivating rows still effective for the new period.
Before / After BQ Query
Run before and after AGENT_PEPM save:org_id='cbs-main', is_active=TRUE, effective_end_date=2025-11-30.After: Same row has
is_active=FALSE, updated_at bumped.
Readiness Before / After
Before: Readiness blocked with"OWNER_ROLLUP policy requires confirmation" for the affected business.
After: Readiness should no longer block for that business (OWNER_ROLLUP no longer considered active).
Validation Checklist
- Save AGENT_PEPM for
e948cad9d7cf99ebwith period2025-12-01(or current period). - Re-run BQ query — confirm
is_active=FALSEon previously inconsistent row. - Re-run readiness — confirm no
OWNER_ROLLUP policy requires confirmationfor that business.