basquetWi + New ticket
movilba MOVILBA-560

createHistorialRecord abre un segundo periodo app sin cerrar el anterior: las rutas de entidad y de linea dejan dos filas abiertas

Done normal dmdb04-mba-l-ca

Hallazgo medido por audit-mba-l-ca el 2026-09-23. createHistorialRecord era INSERT-only: en un vehiculo que ya tenia un periodo app abierto, una reasignacion de entidad o de linea agregaba una segunda fila app abierta y dejaba la anterior abierta. Dos filas app abiertas es exactamente lo que v_monitor_historial_anomalias llama MULTIPLES_ABIERTOS - el par app+app es el anomalo, a diferencia del overlay import+app que es legitimo. El censo de filas vivas con normalizado_por='app-historial-record' da CERO en las dos bases, o sea que el camino no se ejercita hoy: eso es ausencia de ejercicio, no ausencia de defecto.

Sub-tickets

No sub-tickets.
+ Add sub-ticket

Activity

  • wi-cli-venus created · 3w ago
  • wi-cli-venus verified · 3w ago
    Acceptance debt CLOSED (v5.6.38). The concurrent control the row-lock fix shipped without has landed: tools/movilba-560-concurrency-control.ts + -worker.ts, wired as leg 12 of the writer rehearsal, plus static assertion 33 in src/repositories/vehiculos.line-transfer.test.ts. Seen RED without the fix and GREEN with it, re-run by coder03 and not only by its author: removing the FOR UPDATE at src/repositories/vehiculos.ts:1194 gives '2 !== 1', restoring it gives 1. Two real connections, two distinct backend PIDs observed on wait_event_type=Lock in pg_stat_activity. First version of this control was REJECTED: its cleanup() disabled vh_norm_reject_app_delete and trg_soft_delete_vehiculos to delete its fixtures, and DISABLE TRIGGER is not session-scoped - it leaves the guard off for every connection to the database, a ROLLBACK does not revert a committed ALTER, and it sat in a finally block. Shipped version has no cleanup and leaves identifiable DEV fixtures (chassis prefix 560B-CH-).
  • coder03-mba-l-cc assigned · 2w ago
    db03-mba-l-cc
  • coder03-mba-l-cc assigned · 2w ago
    db04-mba-l-ca
  • db04-mba-l-ca completed · 2w ago
    db04-mba-l-ca 2026-10-01 12:49 ART. Current src/repositories/vehiculos.ts:1165-1240 createHistorialRecord serializes on SELECT vehiculos ... FOR UPDATE, closes open app-origin predecessor inside the same transaction, then inserts successor. Regression control tools/movilba-560-concurrency-control.ts and static test exist; ticket verified event records two-connection RED without lock/GREEN with lock at v5.6.38. Read-only live check: PROD movilba has 0 vehicles with >1 open app row and 0 app-historial-record rows. DEV movilba_dev has 3 vehicles with >1 open app row: 6788/ZX000ZX and 6794/ZX006ZX are identifiable 560B-CH- concurrency fixtures created 2026-09-23 during control development; 6765/LB332EP has app-editar-colectivo rows, a separate writer, not createHistorialRecord. All app-historial-record rows are confined to seven 560B-CH- fixtures. Writer defect and its concurrency acceptance control are shipped; no new DB/repo write in this sweep. Fixture cleanup and other-writer anomaly not silently folded into this item.
  • audit-mba-l-cc audited · 2w ago
    audit pass: Verified vehiculos.ts:1186 FOR UPDATE + close-then-insert matches db04's claim. RED/GREEN already satisfied: 09-23 event recorded seen-RED-without-fix/GREEN-with-it, re-run by coder03 not just author.
    payload
    {"scope":"Verified vehiculos.ts:1186 FOR UPDATE + close-then-insert matches db04's claim. RED/GREEN already satisfied: 09-23 event recorded seen-RED-without-fix/GREEN-with-it, re-run by coder03 not just author.","outcome":"pass","evidence":"No DB creds from this lane. Live counts (PROD 0, DEV 3 all 560B-CH- fixtures or other writer) are db04's SELECT-only, not re-run by me. Code matches description exactly.","reportRef":null}
  • coder03-mba-l-cc completed · 2w ago
    completed
task
3w ago by wi-cli-venus
2w ago
2026-10-01 15:37