pluto
PLUTO-102
· child of PLUTO-304 EAV audit — evaluar columnas DB para migración a patrón EAV Done
D8 Tier-1: collapse fan-out-vs-pool on 4 hot pages (admin/usuarios:97 8-wide, a-solucionar:37 6-wide, practicas:188/249, alumnos/[id]:86) via bundle-RPC/CTE per PLUTO-97
Done high
dpdb-pluto-cc
Questions
No questions.
Activity
-
parent=#98
-
db-pluto-cc / db
-
Elazar greenlit ('102 do'). Queued behind 471 (same db). Collapse N-query fan-out on 4 hot pages to bundle-RPC/CTE. Audit pre-apply gate.
-
Proceed — db lane. Collapse N-query fan-out on the 4 hot pages to bundle-RPC/CTE; this is the SAFE pool-pressure reduction (fewer queries, not more connections) per the 471 finding. Audit pre-apply gate on any migration.
-
db PLAN + premise correction (evidence-based, ACCEPTED): no app-level per-row fan-out on any of the 4 pages — the 188-249/86 numbers are Postgres statement counts from heavy-VIEW internal expansion, not JS fan-out. Bundling reduces pool round-trips (the safe goal) but only alumnos/[id] gets a clean view-rescan-elimination. SEQUENCING DECISION: (1) alumnos/[id] FIRST — HIGH ROI, one RPC keyed (studentId,periodoId) scans practicas ONCE, kills the 4-5x re-scan across the 5 detail queries. (2) practicas quartet (hierarchy/teamStats/kpis/auditLog) → 1 RPC, MEDIUM ROI round-trip win; the true 188-249 driver (vPracticasAuditEntries per-row correlated subqueries @ LIMIT 250) is a SEPARATE view-flattening follow-up → PLUTO-483. (3) admin/usuarios + a-solucionar DEFERRED — LOW ROI, zero pool-timeout evidence (logs were /informes+/practicas only), nonzero regression risk not worth it. Authz preserved: RPCs take TS-resolved scope params (fn_resolveDataAccessScope), no gate moves into the bundle, mirrors fn_getInformesBundle. JOINT WI: db writes fns, coder wires pages.
-
AUDIT PASS:050 (fn_getAlumnoDetailBundle) — independent byte-for-byte SQL-vs-source review of all 5 sections: audit scope-array byte-identical no widening; both parity nuances (cursor ::date, archiveSeq strip) shape-identical; STABLE+4s-timeout+DOWN-drop correct; null-profile→JSON-null holds at fn (notFound mapping is wrapper-scope). AUTHZ preserved: 4 non-audit sections apply NO scope filter (page-level getStudentsForTeacher gate is containment, stays TS), only audit-log carries in-query scope arrays. db appending REVOKE FROM PUBLIC,anon,authenticated for 049-parity (not a live exposure — SECURITY INVOKER + Data API disabled), then apply→export→push. *** TWO CARRY-FORWARDS FOR THE CODER WRAPPER STAGE: (1) HIGH-VALUE FOOTGUN — fn signature order is (jtp_ids, jtp_gates, adjunto_comision_ids) but body numbers //; TS wrapper MUST pass RPC args in SIGNATURE positional order NOT hmtBcnumber order — swapping gates vs adjunto_comision_ids silently corrupts scope. (2) null profileSummary → notFound() lives in page.tsx wrapper (verify). ***
-
STEP 1a (migration 050 fn_getAlumnoDetailBundle) LIVE + PTD-PASS on tip 11fd7f8 (rides f0724e7). BUT fn is UNUSED until the page-wire — alumnos/[id]/page.tsx still runs the 5 parallel queries. 102 STAYS OPEN. Dispatched: coder wires page.tsx to getAlumnoDetailBundle() TS wrapper (carry-forwards: pass RPC scope args in SIGNATURE positional order jtp_ids/jtp_gates/adjunto_comision_ids NOT $-number; hasMore/slice stays TS; null profileSummary→notFound()). In parallel db builds the independent practicas-quartet fn (step 2, no file overlap).
-
STEP-1 (alumnos/[id]) COMPLETE + live-verified. Page-wire SHA 74bedf9 v1.99.0 PTD-PASS (deploymentId dpl_HrrB→74bedf9, READY, alias-bound, runtime 0-error on this build + on /alumnos/[id]). alumnos/[id] now renders via one fn_getAlumnoDetailBundle RPC instead of 5 parallel queries. Version collision self-healed (unique 1.99.0). Correctness basis = pre-push byte-parity proof (arg order $7/$8/$9, hasMore/slice, mapper, date-neutrality); not functionally exercised under a live teacher session. 102 STAYS OPEN for STEP-2 = db's practicas Branch-A quartet (fn_getPracticasBundle, mig 051, in-flight ETA ~06:38→). Then 449.
-
STEP-2 migration 051 (fn_getPracticasBundle) READY → audit pre-apply gate. Collapses /practicas GLOBAL-OVERSIGHT branch (guard isGlobalScope && !jtp && !alumno && !cursor, page.tsx:189-197) 4 round-trips→1. Timing 232ms/210ms (~17× under 4s timeout). db independent-oracle byte-parity ✓ all 4 sections. Security-sensitive: embeds getTeacherKpis(null)→all-students-in-periodo fold (correct for global branch only; branch guard is containment — audit confirming non-global caller can't reach it). Per-teacher/filtered/cursor branch (:251) is OUT (different composition). vPracticasAuditEntries per-row flatten stays PLUTO-483. On PASS: apply→export→push→PTD, then coder wires branch-A call-site.
-
STEP-2 AUDIT PASS:051 — byte-parity 4 sections, branch-only containment PROVEN (getTeacherKpis(null) hardcoded NULL literals, no scope param reachable; filtered path page.tsx:238 never calls fn; no scope moved into RPC; NULL-fold → all-students-in-periodo is reportes semantics, correct for global branch only). db applying→export→push→PTD. *** MANDATORY WRAPPER GATE (audit hard-gates branch-A call-site review): comisionFilter is string[]|undefined; fn treats ONLY NULL as no-filter — EMPTY array → =ANY('{}') matches ZERO rows, source fns omit-clause-on-[]→ALL. Wrapper MUST coalesce (undefined||[])→NULL. Plus arg order p_periodo_id,p_comision_ids,p_focus_jtp_id; omit limit params (defaults 250/200). *** Non-blocking (same as step1b): auditLog.at ISO-string vs JS Date, display-neutral via formatDateTimeEsAr anchored regex.
-
step-2 051 migration push PASS:d5bd7bc (v1.99.1): deploymentId dpl_Zoq9aYk4→d5bd7bc, prod-alias-bound READY gru1, 0 runtime errors on build. fn_getPracticasBundle live on prod but UNUSED until coder wires the branch-A /practicas wrapper (in flight, ~15min). NOT closing 102 til the wrapper ships+PTDs. Wrapper review hard-gated by audit on (undefined||[])→NULL coalesce + signature-order args (omit both limit params).
-
Both legs live on prod. Leg-1 alumnos/[id]: 5 parallel queries -> 1 RPC (fn_getAlumnoDetailBundle, migration 050, wrapper SHA 74bedf9). Leg-2 /practicas global-oversight: 4 round-trips -> 1 RPC (fn_getPracticasBundle, migration 051 SHA d5bd7bc, wrapper SHA 27cc632 v2.0.0). Both PTD-PASS (deploymentId->sha, alias-bound, 0 runtime errors). Byte-parity proven pre-push (arg order, empty->NULL coalesce, builder parity, inert numeric divergence, no import cycle). Coverage residual: no live global-oversight render driven under reportes/admin session; correctness basis = parity proof + absence-of-error, not asserted rendered payload.
task
2026-06-14 by wi-cli-venus
6w ago
2026-07-03 10:19