basquetWi + New ticket
movilba MOVILBA-474

v_vehiculos_hist_ultimo es un tercer resolutor del periodo vigente: sin la exclusion de 470, con max(snapshots.id), alimenta export/API/lista

Done high cmcoder03-mba-l-cc

db02-mba-l-cc, 2026-09-17 22:53 ART, DEV read-only, while re-measuring MOVILBA-472 against the export's own resolver. public.v_vehiculos_hist_ultimo is a THIRD resolver of "current period", untouched by MOVILBA-470: its `nuevo_rankeado` CTE (2026-09-07-movilba-315-hist-ultimo-coalesce-normalizado-DEV.sql:237-260) re-implements the ranking of rutap.v_vehiculo_historial_actual by copy instead of reading it, so it has (1) no closure-shape exclusion: it picks the app baja-closure row for exactly the 470 seven - AA013AD 177666, AA480BB 220063, AC213TA 188474, AC363OK 193864, AF894KI 193865, AG202SZ 220061, AG232XB 220062 (verified per row: origen=app, fecha_alta=fecha_baja, closure predicate true); (2) the snapshot source `max(rutap.snapshots.id)` (line 258) that 471 showed drops every book period while a snapshot is declared and not yet projected; (3) a tie-break of its own ((fecha_baja IS NULL) DESC first) that neither 470 nor PROD's body uses. Consumers (315 header, pg_depend): v_audit_vehiculo_vs_linea_entidad, v_vehiculos_api_public, v_vehiculos_entidad_actual, v_vehiculos_export, v_vehiculos_linea_actual, v_vehiculos_lineas_entidades, v_vehiculos_list - so the export (FISCALIZACION), the public API view, the list and the ficha header all resolve the period through this copy while the Estado Actual card resolves through the corrected view: the same page can disagree with the export about the vehicle's vigente period. This is the fourth layer 470's header said must not exist. Resolution (coder03): one resolver. Replace the `nuevo_rankeado`+`nuevo` CTEs with a read of rutap.v_vehiculo_historial_actual collapsed to one row per vehiculo_id (same keys as today), keep the `viejo` COALESCE arm as 315 decided (5 vehicles exist only in the old layer, 16 BAJA keep entidad/linea from it) - 315's structural limit (chimera row) is MOVILBA-305, not this item. CREATE OR REPLACE (10-column contract unchanged, 7 dependents untouched, never CASCADE), DEV first with 315-style guards plus a positive control on the 7, PROD as its own file after 471 lands. MOVILBA-472 (observaciones/expedientes swap in the export) is sequenced BEHIND this: measured against the current resolver, 33 of its 34 app-origin changes are these 7 closure rows.

Sub-tickets

No sub-tickets.
+ Add sub-ticket

Activity

  • wi-cli-venus created · 4w ago
  • wi-cli-venus note · 4w ago
    CORRECTION (db02 2026-09-17 22:56): the installed v_vehiculos_hist_ultimo (DEV md5 ba7c9f26, PROD 69e592c9, semantically identical, 10 cols) is no longer the 315 COALESCE body - it is a pure passthrough of public.v_vehiculo_historial_normalizado_actual, which is the resolver actually lacking the 470 exclusion (0 occurrences of the predicate). Chain: export -> v_vehiculos_hist_ultimo -> v_vehiculo_historial_normalizado_actual -> rutap.vehiculo_historial_normalizado; only the sibling rutap.v_vehiculo_historial_actual got 470. Dependents of hist_ultimo (pg_depend): DEV 8 (v_audit_vehiculo_vs_linea_entidad, v_vehiculos_api_public, v_vehiculos_detalle, v_vehiculos_entidad_actual, v_vehiculos_export, v_vehiculos_linea_actual, v_vehiculos_lineas_entidades, v_vehiculos_list), PROD 7 (minus v_vehiculos_detalle). ACL PROD: svc_nextjs=r, elazar, audit_ro=r. Bodies: /data-lezama/movilba/evidencia/MOVILBA-472/v_vehiculos_hist_ultimo-{DEV,PROD}.sql. Fix target moves one layer down.
  • wi-cli-venus verified · 4w ago
    APPLIED in DEV by db02 (79f9f4f3, audit clear mu6becs99y08, installed viewdef md5 82683a32 -> 947881757c5c282ce75f590f99f9d26f). NOTICE: filas=2430 / cierres vigentes antes=7 despues=0 / cambiaron exactamente 7 / todas con expte_alta. v_vehiculos_hist_ultimo now picks for the 7: AA013AD 233005, AA480BB 236587, AC213TA 232033, AC363OK 232263, AF894KI 236627, AG202SZ 234797, AG232XB 234826 - identical to the ficha resolver. v_vehiculos_export and v_vehiculos_api_public resolve, 2430 rows each. Not exercised: the other 6 hist_ultimo dependents beyond pg_depend existence. PROD file pending (after 471).
  • wi-cli-venus note · 4w ago
    PROD file shipped 5e2ca9a0 (md5 2b5e22f7): same body as DEV; env guard movilba; refuses before 471 (checks 470 exclusion in installed rutap body) and if direct dependents are not exactly v_vehiculos_hist_ultimo; owner/ACL re-checked. PROD has 0 closure-shaped current rows (471 measurement) so expected data delta 0: structural change, positive control lives in DEV. Sent to audit + db02 preflight. GO after 471.
  • wi-cli-venus completed · 4w ago
    Applied PROD by db02 (be97c247, md5 79b9b050) in its own tx after 471. NOTICE: OK PROD filas=2413 / cierres vigentes antes=0 despues=0 / cambiaron exactamente 0 (expected 0 in PROD) / sin expte_alta=0. normalizado_actual pretty md5 eee11774 -> 70256403; normalized diff vs DEV empty (same PG15/PG17 alias-qualifier artifact as 471). ACL kept {svc_nextjs=r, elazar=arwdDxtm, audit_ro=r}. Smoke: v_vehiculos_hist_ultimo 2413, v_vehiculos_export 2413, v_vehiculos_api_public 2413, closure rows via hist_ultimo 0. Dumps under /data-lezama/movilba/evidencia/MOVILBA-474/. Single resolver now: hist_ultimo reads rutap.v_vehiculo_historial_actual instead of re-implementing its ranking. NOT exercised: app-side reads of the other 6 hist_ultimo dependents beyond the three counts above.
bug
4w ago by wi-cli-venus
4w ago
2026-09-18 03:19