#178 ·
pluto · child of #174resolveDataAccessScope → fn_resolveDataAccessScope SQL fn + React cache() — collapse 3-4 round trips per protected render to 1; src/lib/access-scope.ts
- Ref
#178(#178)- Project
pluto- Parent
- backlog #174 Vercel + Supabase optimization — reduce Fluid Active CPU bill creep, eliminate dashboard misconfig, lower latency
- Status
- done
- Priority
- normal
- Type
- --priority
- Assigned
- —
- Created by
- —
- Created
- 2026-05-03T02:02:02.619Z
- Updated
- 2026-05-06T06:45:28.302Z
- Closed
- 2026-05-06T06:45:28.302Z
Questions
No questions.
Event log
-
wi cli; parent=#174
-
Staged DDL+TS draft at pm/plans/wi178-fn-resolve-data-access-scope.md (2026-05-06). fn_resolveDataAccessScope(uuid,uuid,text[])→jsonb, STABLE. Single-call CTE w/ deletedAt filter, NULL periodo branch, global short-circuits before assignment-table reads. TS wrapper uses React cache() keyed by (userId, periodoOrEmpty, sortedRolesKey); public signature unchanged. PM review before live apply + coder consume swap.
-
DDL applied 2026-05-06; commit 1deb130. Verification 5/5 PASS: role coverage (admin/titular/reportes->global; jtp/adjunto/ayudante/alumno->perComision correct ids); parity vs TS-equiv CTE byte-equal for jtp + ayudante users; soft-delete excluded (BEGIN/INSERT-soft-deleted/ROLLBACK harness); NULL periodo (non-global->empty perComision; global->global); empty ayudanteJtpIds path returns ayu_com=[] no error; NULL roles falls through perComision (COALESCE). Role-dedup nit confirmed no risk: fn uses && intersection only on p_roles; never unnest. schema.md re-exported (function appears as fn_resolvedataaccessscope per pg lowercase folding; case-insensitive at call site). Coder swap blocked on PM dispatch.
-
PM close — pluto-coder ee1ebf2 (v1.57.11) + pluto-db 1deb130 DDL live. pluto-audit PASS (pluto-audit-w-cc-6961): wrapper, 14 call sites untouched, SQL fn parity. Empirical cache() dedup counter skipped (informational flag, structural placement correct).