fix(plc): require a verified, claimed org identity for building-group auto-roster #4584
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.37) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 231 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.326
Real PR Conversation Timeline
1 comments
"Review active on #4584"
general
weight: 0.35
claude[bot]
What was vulnerable
Building-group auto-roster (
onUserProfileBuildingsChangedV1trigger and therosterBuildingGroupbackfill run bycreateBuildingGroupV1/syncBuildingGroupV1) tookauth.getUser(uid).emailas the user's org identity without checkingemailVerified. It also accepted anyorganizations/{org}/members/{email}doc not marked inactive/removed, including an unclaimedinviteddoc. Since email/password sign-in is enabled, anyone could register an invitee's address, setselectedBuildings, and be added as an active viewer to every auto-roster group for that building, gaining member read access to its PLC data. The lead/co-leadgetUserByEmailfallback had the same gap.What changed
BuildingGroupDeps.getUser/getUserByEmailnow returnemailVerified. Auto-roster and the lead/co-lead fallback inresolveAccountaccept an account only when it istrue.isActiveOrgMembernow requiresstatus === 'active'and, when the member doc has auid, that it matches the account being rostered.No rules, client or data changes. Behaviour change: a teacher whose member doc is still
invited(never claimed the invite) is not auto-rostered until they claim it; an admin can still add them by hand.How I checked
plcBuildingGroups.test.ts: an unverified account, an unclaimed invite and a member doc linked to another uid are not added by the trigger, the backfill,createBuildingGrouporsyncBuildingGroup, and an unverified account cannot be resolved as a lead. They fail on the old code and pass now (37/37).---
_Generated by Claude Code_