PLUTO-70 ·
plutoInformes filter by jefe-de-TP returns wrong/doubled student set (cross-jefe contamination) - was working before, regression
- Ref
PLUTO-70(#962)- Project
pluto- Status
- done
- Priority
- high
- Type
- task
- Assigned
- audit-pluto-cc
- Created by
- wi-cli-venus
- Created
- 2026-06-12T17:27:30.202Z
- Updated
- 2026-06-12T17:41:44.419Z
- Closed
- 2026-06-12T17:41:44.419Z
Questions
No questions.
Event log
-
Client report (WhatsApp via nw-whey 2026-06-12 ~13:22): Informes, filter adjunto=Giovacchini + jefe-de-TP=Mastricchio + comision-del-viernes returns ~20 students, HALF not his; he has ~10. Cross-jefe contamination. Client hint: person who is jefe one dia + ayudante another may be mixing. Regression ('lo teniamos bien controlado'). Dispatched audit-pluto-cc (logic: jefe+comision+dia scope, soft-delete leak on comisionJtps/jtpAyudantes deletedAt, JOIN fan-out, deploy timeline) + db-pluto-cc (data: does Mastricchio really have 10, why 20 - data vs code). Fraud-assignment attribution - precise. NO row patching.
-
ROOT CAUSE (audit code-confirmed + db data-confirmed). PRIMARY: getStudentsForTeacher + getStudentsForTeacherPage (src/db/queries.ts:2304-2310, 2410-2416) OR-combine jefe-filter with adjunto-comision-scope. When adjunto selected, comisionId=ANY(adjuntoComisionIds) is true for whole comision -> jefe filter ignored -> ~20 (all jefes) instead of ~10. FIX: independently-nullable AND not OR ((jtpIds IS NULL OR jtpId=ANY) AND (adjComIds IS NULL OR comisionId=ANY)); fix BOTH twins + 3 stats queries (getTeacherReportStats/getPerComisionStats/getPerJtpStats). SECONDARY latent: resolveTeacherFilterIds (queries.ts:3443) returns dual-role teacher's PARENT jefes' ids instead of own, dropping jefe identity (masked by the OR; corrupts when no adjunto). NOT a deploy regression - latent, triggered today by adjunto+jefe combo on dual-role Mastricchio (docente_jtp + docente_ayudante_primera). RULED OUT: soft-delete leak (vActiveRoster filters deletedAt), JOIN fan-out (COUNT DISTINCT). Dispatched coder to fix; audit owns diff-review; db quantifying 20->10.
-
Fix implemented (coder, in audit diff-review, src/db/queries.ts only): 6 primary OR->AND sites fixed (audit mapped 5: getStudentsForTeacher/getStudentsForTeacherPage twins + getTeacherReportStats/getPerComisionStats/getPerJtpStats; coder FOUND a 6th audit missed = getTeacherKpis L1855, same OR bug -> would desync KPI cards 44 vs table 11; PM confirmed in-scope). SECONDARY resolveTeacherFilterIds made ROLE-AWARE per audit (active comisionJtps row -> jefe, return [self]; only pure ayudantes resolve to parents - NOT blind union, which would still drag parent jefe students). Expected: Mastricchio 44->11. Audit PASS -> push -> PTD.
-
SHIPPED + PTD. SHA 6372e5e, live v1.67.33. Root cause: Informes query OR-combined jefe-filter with adjunto-comision-scope -> jefe filter ignored when adjunto selected -> whole comision returned. Fixed 6 OR->AND sites in queries.ts (getStudentsForTeacher/Page twins + getTeacherReportStats/getPerComisionStats/getPerJtpStats + getTeacherKpis cards) + role-aware resolveTeacherFilterIds (dual-role jefe keeps own identity vs returning parent jefe). Quantified live: Mastricchio A-Viernes 44-comision-wide -> his real 11. NOT a deploy regression (latent, triggered today by adjunto+jefe combo on dual-role teacher). Audit PASS:6372e5e (build READY, deploymentId match, zero runtime errors, count re-verified). Client Informes complaint resolved.