basquetWi + New ticket
movilba MOVILBA-621

Empresas no muestra historial de cesion de linea

Done normal cmcoder03assistant-mba-l-ca

Reported by Eugenia via WhatsApp 2026-09-29, forwarded by Elazar. Example: cesion de la linea 26 a la 132 (17/08, Nuevos Rumbos) - el cambio no aparece en la pantalla de Empresas. Investigacion audit: el mecanismo de historial SI existe a nivel de linea - linea_entidad_asignaciones cierra la fila vieja (borrado_en) e inserta una nueva en src/actions/lineas.ts:75-96 y src/repositories/lineas.ts:202-224, y se muestra via el componente LineaEntidadHistorial en /lineas/[id]. Pero src/app/entidades/[id]/page.tsx solo trae lineasData ACTUAL (lineas.ts:86,105,145,444-458) - no hay ningun componente ni query de historial en el lado Empresa. Una linea cedida deja de listarse en la empresa que la perdio y nunca aparecio historial ahi. Gap de codigo real, no de dato: falta un historial (o al menos las lineas perdidas) en la vista de detalle de Entidad.

Sub-tickets

No sub-tickets.
+ Add sub-ticket

Activity

  • audit-mba-l-cc created · 2w ago
  • coder03-mba-l-cc assigned · 2w ago
    coder03assistant-mba-l-ca / coder
  • db04-mba-l-ca progress · 2w ago
    db04-mba-l-ca 2026-10-01 12:19 ART, SELECT-only PROD movilba; full report /data-lezama/movilba/evidencia/MOVILBA-621/2026-10-01-prod-linea-entidad-periodos.md. LEA has 39 rows, 11 closed (10 with borrado_por, one NULL). Current snapshot8 imported vehicle history has 5548 rows. Line26 transfer: LEA old 17 DE AGOSTO entity54 row72 closed 2026-09-02, new NUEVOS RUMBOS entity71 row109 opened same day, Resol-2026-186-GCABA-SECT; book vehicle history has 188 old-entity rows (73 domains) and 64 new-entity rows (60 domains), mostly handoff 2026-09-01. Therefore BOTH carriers contain it; LEA dates are app-write timestamps, book dates are business dates. Distinct (linea_id,entidad_id) membership: history37 vs LEA38, history-only0, LEA-only1 (line39/entity61). Literal distinct (linea_id,entidad_id,start,end) using vehicle fecha_alta/baja vs LEA created/deleted dates: 1385 vs39, exact matches0, history-only1385, LEA-only39. Coalescing overlapping/touching vehicle periods per pair gives 37 episodes vs39 LEA periods, exact0; 35/37 history episodes and 36/39 LEA periods overlap. This period diff is not a fidelity defect by itself because the clocks and granularity differ. No writes.
  • db04-mba-l-ca progress · 2w ago
    db04-mba-l-ca 2026-10-01 12:21 ART, SELECT-only PROD follow-up on LEA-only line39/entity61. Current book snapshot8 has 203 line39 rows, all TRANSPORTES SANTA FE entity55, zero La Nueva Metropol entity61. LEA id84 assigned entity61 2026-04-30..2026-05-19, expediente EX1111, observation 'cambio de empresa', after initial entity55 row74; LEA id88 restored entity55 on 2026-05-19 with observation 'Se realizo cambio manual a pedido de la gerencia (Corrección)'. No matching audit_log row found by LEA table/record id. This is an uncorroborated, reversed app entry, not a book-confirmed cesion; whether a genuine brief transfer happened remains unmeasured. Evidence appended to /data-lezama/movilba/evidencia/MOVILBA-621/2026-10-01-prod-linea-entidad-periodos.md. No writes.
  • db04-mba-l-ca progress · 2w ago
    db04-mba-l-ca 2026-10-01 12:22 ART, SELECT-only PROD date check. Scoped current-book snapshot8 to all 520 rows where linea_numero=26 OR entidad_id IN (54,71). Zero fecha_alta/fecha_baja on 17 August (any year), zero 17/08/08-17/ISO YYYY-08-17 tokens in raw date/expediente/observaciones or any other raw row field. In contrast, 189 scoped raw rows name the prior company '17 DE AGOSTO S.A.' The report's '17/08' may be shorthand for that company, not an asserted event date; wording is ambiguous. No 17 August business date exists in the current book for this scope. Book main handoff is 01 Sep; LEA app-write timestamp 02 Sep. This is a provenance/wording clarification, not evidence of a DB date defect. Evidence appended to /data-lezama/movilba/evidencia/MOVILBA-621/2026-10-01-prod-linea-entidad-periodos.md.
  • coder03-mba-l-cc decision · 2w ago
    coder03-mba-l-cc 2026-10-01 12:25 ART. No va ninguna pregunta a Eugenia por una fecha del 17 de agosto: el '17/08' del reporte no es una fecha, es el nombre de la empresa que cedio la linea. Entidad 54 es '17 DE AGOSTO S.A.' y entidad 71 es NUEVOS RUMBOS, o sea el parentesis del reporte nombra las dos empresas del traspaso, no un dia. Medido por db04 en PROD sobre 520 filas de linea 26 y entidades 54/71: cero fecha_alta y cero fecha_baja un 17 de agosto de cualquier anio, y cero tokens 17/08, 08/17, 17-08 o YYYY-08-17 en ninguna parte de la fila cruda, expedientes incluidos; 189 filas nombran la empresa. El traspaso del libro es el 1 de septiembre y la escritura en linea_entidad_asignaciones el 2, o sea un dia de demora de carga, que no es una discrepancia. Yo mismo publique esto como 'tres fechas para el mismo evento' y esa lectura queda retirada: eran dos fechas y un nombre de empresa. Que nadie reabra una discrepancia de fecha desde el texto del reporte.
  • db04-mba-l-ca progress · 2w ago
    db04-mba-l-ca 2026-10-01 12:24 ART, SELECT-only PROD all-origin check for no-book-date LEA episodes. rutap.vehiculo_historial_normalizado line39 has 203 periods across ALL origins/snapshots/open/closed/soft-deleted, all import snapshot8 and all entity55: 92 open and 111 closed. Entity61 has 0 vehicle periods there. Comparing every LEA row's (linea_id,entidad_id) to all vehicle periods returns exactly ONE uncorroborated LEA row: id84 line39/entity61, the reversed April30-May19 assignment. This is one row, not a class in current PROD. The Empresa component needs defined no-book-date behavior for it; LEA created/deleted timestamps must not be displayed as event dates under the agreed split. Evidence appended to /data-lezama/movilba/evidencia/MOVILBA-621/2026-10-01-prod-linea-entidad-periodos.md.
  • db04-mba-l-ca progress · 2w ago
    db04-mba-l-ca 2026-10-01 12:27 ART. PROD movilba, current imported snapshot 8, SELECT-only. Line26/incoming entity71: 64 rows; fecha_alta 2026-08-31:1, 09-01:55, 09-02:2, 09-04:3, 09-09:1, 09-24:2. MIN=08-31 (AI429SH id127102), not 09-01 bulk date. Outgoing entity54: 188 rows over 21 fecha_baja dates; MIN=2025-08-11 (NBU015 id130520), MAX=2026-09-01 (54 rows). The full date-frequency list is in the coder/assistant DM of this measurement. Across all 37 line/entity groups: fecha_alta single date 3, spread 34, widest 455 days (line_id80/entity60); 9 groups have no open rows, of which fecha_baja single date 2, spread 7, widest 386 days. MIN over all outgoing periods predates this transfer by more than a year, so it cannot represent the handoff end at this grain; date rule needs review before UI implementation.
  • db04-mba-l-ca progress · 2w ago
    db04-mba-l-ca 2026-10-01 12:29 ART. PROD read-only: pg_trigger for public.linea_entidad_asignaciones has ZERO noninternal triggers; public.audit_log has ZERO rows with table_name=linea_entidad_asignaciones, hence no LEA id can serve as an audit_log positive control. src/actions/lineas.ts cambiarEntidadLinea writes LEA directly in db.transaction (lines 51-100), not through auditedOperation; it calls log() after commit (lines 111-116). Positive control of the OTHER trail: public.app_logs id34972 at 2026-04-30 12:58:55.748858-03 says Entidad de línea cambiada, lineaId=73, oldEntidadId=55, newEntidadId=61, matching LEA id84 creation at 12:58:55.741701-03. There is no app_logs line73 change record for the May19 id88 reversal. Absence of audit_log rows for id84/id88 is expected, not a trigger defect. App log absence for id88 is not proof that no app path ran, as retention/completeness is unmeasured.
  • db04-mba-l-ca progress · 2w ago
    db04-mba-l-ca 2026-10-01 12:35 ART. PROD current imported snapshot8, SELECT-only. Pair criterion: same vehiculo_id + same linea_id + outgoing entity different from incoming entity + outgoing fecha_baja = incoming fecha_alta; COUNT DISTINCT incoming history row prevents multiple old-period fan-out. Line26 LEA id109 old entity54 -> new71: 64 incoming rows/60 vehicles; 54 rows/54 vehicles have an exact old-entity closure, all on 2026-09-01; 10 rows have no such pair (08-31:1, 09-01:1, 09-02:2, 09-04:3, 09-09:1, 09-24:2). Thus paired episode date/range is 2026-09-01..2026-09-01; NBU015 2025 baja and AI429SH 08-31 incoming are excluded. Across all 37 current-book line/entity groups: 271 paired rows / 5548 total, 6 groups with >=1 pair, 31 with none; all 6 paired groups have a single paired transition date, widest spread 0 days. Important denominator caveat: the 37 groups include initial/nontransfer episodes, so 271/5548 is NOT transfer coverage. Of the 8 LEA successor episodes specifically, 5 have paired rows (262 paired of 915 incoming rows), 3 have none (LEA id86 line23/entity52; correction id84 entity61; restoration id88 entity55). This exact-date pairing is suitable for observed transfers but no-date branch remains necessary.
  • db04-mba-l-ca progress · 2w ago
    db04-mba-l-ca 2026-10-01 12:37 ART, PROD SELECT-only clarification: LEA id84 has linea_id=73; public.lineas id73 has numero_linea=39. Neighbor LEA id74 (entity55) and id88 (restored entity55) share linea_id=73 and therefore displayed line number 39. public.app_logs id34972 data.lineaId=73, oldEntidadId=55, newEntidadId=61 at 2026-04-30 12:58:55.748858-03, matching id84 inserted at 12:58:55.741701-03. There is no contradiction: line 39 is the business number and 73 is its database key. The evidence file uses line 39 in the display-number sense; its one-uncorroborated-LEA-row conclusion remains intact.
  • coder03assistant-mba-l-ca statusChanged · 2w ago
    coder03assistant-mba-l-ca | 2026-10-01 22:17 ART. Implemented entity-side history: new read action filters the approved v_linea_entidad_historial view by entidadId and resolves display line numbers through v_lineas; new read-only history card renders active/closed periods on /entidades/[id]. Changed src/actions/lineas.ts, src/app/entidades/[id]/page.tsx; added src/components/EntidadLineaHistorial.tsx. No tests/typecheck/lint run per lane rule; audit review pending.
  • audit-mba-l-cc audited · 2w ago
    audit pass: src/actions/lineas.ts (new getEntidadLineaHistorial), entidades/[id]/page.tsx (+2 lines), new EntidadLineaHistorial.tsx. tools/rutap-dominios-prueba.json and rutap-fidelidad.py NOT in scope - also dirty, not this claim.
    payload
    {"scope":"src/actions/lineas.ts (new getEntidadLineaHistorial), entidades/[id]/page.tsx (+2 lines), new EntidadLineaHistorial.tsx. tools/rutap-dominios-prueba.json and rutap-fidelidad.py NOT in scope - also dirty, not this claim.","outcome":"pass","evidence":"Queries catalogued views v_linea_entidad_historial/v_lineas (view-catalog.md:98, schema.ts:3671,3706), auth+permission check present, read-only. Ran lint on the 3 files (clean) and pnpm typecheck (clean, 8104 project lint errors are preexisting vendored-file baseline noise, unrelated).","reportRef":null}
  • coder03-mba-l-cc note · 2w ago
    coder03-mba-l-cc 2026-10-01 22:2x ART: SHIPPED. dev 52283905, prod via main 92fc5430; prod+dev01 serve patch 133. Pod leg (131) requested from proxy-mba-w-cc, NOT yet verified.
  • coder03-mba-l-cc note · 2w ago
    coder03-mba-l-cc 2026-10-01 22:3x ART: pod leg done by proxy-mba-w-cc (push 45c00d6->48ddba9, EventListener 202). prod, dev01 and pod all serve patch 133.
  • coder03assistant-mba-l-ca progress · 2w ago
    coder03assistant-mba-l-ca | 2026-10-01 22:45 ART. Applied Elazar's carrier split to the existing Empresa timeline. LEA still identifies line/entity episodes and expediente; displayed Desde/Hasta now come only from current v_vehiculo_historial rows, paired by same vehicle+line and exact outgoing fecha_baja=incoming fecha_alta across an entity change. LEA creado_en is used only to order assignments internally; creado_en/borrado_en are no longer displayed as event dates. If a line/entity transition is repeated or has no exact vehicle-period pair, dates are withheld instead of substituting LEA timestamps. PROD measurement supports the 26->132 case: 54/64 incoming rows pair on 2026-09-01; 10 unmatched dates remain without a claim. Changed src/actions/lineas.ts and src/components/EntidadLineaHistorial.tsx. No tests/lint/typecheck run; audit review pending.
  • audit-mba-l-cc audited · 2w ago
    audit fail: src/actions/lineas.ts + EntidadLineaHistorial.tsx, the two-file carrier-split diff on top of the already-shipped 621/570 commits.
    payload
    {"scope":"src/actions/lineas.ts + EntidadLineaHistorial.tsx, the two-file carrier-split diff on top of the already-shipped 621/570 commits.","outcome":"fail","evidence":"pnpm typecheck FAILS: 12x TS18048 (possibly undefined) at lineas.ts:271-276,349-351 - rows[index-1]/rows[index] array access under strict mode. Lint clean. Logic itself (pairing, ambiguity guard via transitionCounts==1, date withholding) reads correct, but this does not typecheck and cannot ship.","reportRef":null}
  • coder03assistant-mba-l-ca progress · 2w ago
    coder03assistant-mba-l-ca | 2026-10-01 22:52 ART. Replaced the exact-boundary date pairing draft with Elazar's decided episode rule. For each (linea_id, entidad_id) episode, start date is MIN(fecha_alta); when distinct dates spread, the card shows MIN plus observed min–max range. End date is MIN(fecha_baja) only when every matching vehicle period is closed; any open period makes it NULL, while a spread among closed baja dates remains visible as an observed range. Date selection sorts by date ASC, id DESC. LEA supplies episode identity/expediente only; LEA creado_en/borrado_en are never displayed as event dates. Missing vehicle periods render an explicit no-date state. Existing PROD read: line26/entity71 64 incoming periods span 2026-08-31..2026-09-24; earlier measured distribution was 1 on 08-31, 55 on 09-01, 2 on 09-02, 3 on 09-04, 1 on 09-09, 2 on 09-24. Outgoing 188 periods spanned 21 fecha_baja dates, 2025-08-11..2026-09-01; db04 is re-counting distribution per PM. Changed src/actions/lineas.ts and src/components/EntidadLineaHistorial.tsx. No tests/lint/typecheck run; updated audit pending.
  • coder03assistant-mba-l-ca progress · 2w ago
    coder03assistant-mba-l-ca | 2026-10-01 22:51 ART. Applied the no-period behavior to the PROD edge case db04 measured: line39/entity61 LEA id84 (reversed by id88) has zero matching vehicle periods; the entity page keeps its LEA episode and expediente visible but renders no fecha_alta/fecha_baja date. It does not infer an event date from LEA timestamps or treat the uncorroborated entry as a book-confirmed transfer. Scope: one current PROD row, not a class. This is the explicit fallback behavior requested by Elazar.
  • audit-mba-l-cc audited · 2w ago
    audit fail: src/actions/lineas.ts + EntidadLineaHistorial.tsx, episode-rule (MIN/MIN-MAX, NULL-if-open) diff. Second review of this item; same gate as the previous FAIL.
    payload
    {"scope":"src/actions/lineas.ts + EntidadLineaHistorial.tsx, episode-rule (MIN/MIN-MAX, NULL-if-open) diff. Second review of this item; same gate as the previous FAIL.","outcome":"fail","evidence":"pnpm typecheck FAILS again: TS2322 at lineas.ts:294,298 - fechasAltaDistintas[0]/[length-1] possibly undefined, same array-index narrowing class as the first FAIL. Lint clean. Display logic matches the stated rule; cannot ship until this compiles.","reportRef":null}
  • coder03assistant-mba-l-ca progress · 2w ago
    coder03assistant-mba-l-ca | 2026-10-01 22:53 ART. Elazar clarified the no-corroboration rule: render every LEA episode, including correction pair id84/id88, never filter it for lack of vehicle periods. For line39/entity61, the two LEA rows remain visible with expediente/observaciones and no business date; the pair is a deliberate correction of an app mistake, not a confirmed cesión. Current component/query preserves these rows and emits an explicit no-date state. This behavior is in the submitted diff; only the decided MIN/range implementation remains under audit.
  • coder03assistant-mba-l-ca progress · 2w ago
    coder03assistant-mba-l-ca | 2026-10-01 22:57 ART. db04's detailed PROD distribution now sizes the chosen MIN/range rule. Line26/entity71: MIN fecha_alta=2026-08-31 (one vehicle); max=2026-09-24; 55/64 rows are 2026-09-01. The UI therefore shows 08-31 with range 08-31..09-24, not the mode 09-01. Outgoing entity54 has fecha_baja observations 2025-08-11..2026-09-01 across 188 periods and includes open periods; per Elazar's explicit rule its end date is NULL when any are open, and any closed-date spread is shown as an observed range, not a claimed handoff end. db04 recorded the measured per-date counts in BWI. No code adjustment from this measurement.
  • coder03assistant-mba-l-ca progress · 2w ago
    coder03assistant-mba-l-ca | 2026-10-01 23:02 ART. Superseded the unpaired MIN implementation per Elazar's latest rule. No event-date calculation is in this diff pending db04's paired-population measurement. The Empresa timeline still renders every LEA episode with expediente/observaciones; all date fields are withheld and labeled as undetermined from vehicle history rather than replaced by LEA timestamps. This preserves the no-corroboration behavior for correction pair id84/id88. Next implementation gate is the paired counts/distribution requested in BWI; no tests/lint/typecheck run.
  • coder03assistant-mba-l-ca progress · 2w ago
    coder03assistant-mba-l-ca | 2026-10-01 23:12 ART. Implemented Elazar's measured paired-vehicle date rule. A vehicle contributes only when its same vehiculo_id+linea_id has an outgoing row for the prior entidad with fecha_baja exactly equal to its incoming row's fecha_alta for the new entidad. Episode date is MIN of that paired set; the card shows MIN..MAX when paired dates differ. LEA rows/expedientes remain the carriers of episode identity; all episodes, including id84/id88 correction records, stay visible, with no date when there is no paired period. Repeated identical LEA transition keys are conservatively left undated because dates cannot be assigned to one episode uniquely. PROD paired evidence: line26 54->71 has 54/64 incoming rows paired (all 2026-09-01), 10 unpaired; across 37 groups, 271/5548 rows pair, 6 groups have pairs, paired spread 0 days; among 8 LEA successor episodes, 5 pair and 3 do not (ids 86,84,88). Previous audit FAILs were for superseded exact-boundary and unpaired-MIN drafts. Changed src/actions/lineas.ts and src/components/EntidadLineaHistorial.tsx. No gates run; current paired implementation needs audit.
  • audit-mba-l-cc audited · 2w ago
    audit fail: src/actions/lineas.ts + EntidadLineaHistorial.tsx, paired-population same-vehicle outgoing/incoming rule. Third review of this item.
    payload
    {"scope":"src/actions/lineas.ts + EntidadLineaHistorial.tsx, paired-population same-vehicle outgoing/incoming rule. Third review of this item.","outcome":"fail","evidence":"typecheck now CLEAN (prior TS18048/TS2322 fixed via guards). lint FAILS: unused lineaId at lineas.ts:348, no-unused-vars. Logic matches stated paired rule: MIN/range over paired set, transitionCounts==1 guard, no LEA-timestamp fallback, all episodes rendered.","reportRef":null}
  • coder03assistant-mba-l-ca progress · 2w ago
    coder03assistant-mba-l-ca | 2026-10-01 23:02 ART. Corrected audit FAIL: removed unused lineaId destructuring in end-date iteration; paired-population logic unchanged. Audit had confirmed date logic and typecheck clean; only lint failure was this no-unused-vars at lineas.ts:348. No lint/typecheck/tests run per lane rule; re-audit requested.
  • audit-mba-l-cc audited · 2w ago
    audit pass: src/actions/lineas.ts + EntidadLineaHistorial.tsx, paired-population rule. Fourth review: only change from the prior FAIL is the lint fix (transitionsByLine.values() instead of [lineaId, rows]), confirmed by diff.
    payload
    {"scope":"src/actions/lineas.ts + EntidadLineaHistorial.tsx, paired-population rule. Fourth review: only change from the prior FAIL is the lint fix (transitionsByLine.values() instead of [lineaId, rows]), confirmed by diff.","outcome":"pass","evidence":"lint clean, typecheck clean. Logic unchanged from the already-reviewed paired rule: MIN/range over paired set only, transitionCounts==1 ambiguity guard, no LEA-timestamp fallback, all episodes rendered.","reportRef":null}
  • coder03-mba-l-cc note · 2w ago
    coder03-mba-l-cc 2026-10-01 23:1x ART: SHIPPED on audit PASS. prod+dev01 serve patch 135. Pod leg (133) requested from proxy-mba-w-cc, NOT yet verified.
  • coder03-mba-l-cc note · 2w ago
    coder03-mba-l-cc 2026-10-01 23:2x ART: pod leg done (proxy push 48ddba9->bc22060). prod, dev01, pod all serve patch 135 (serviceId 19406), checked by me.
  • coder03assistant-mba-l-ca completed · 1w ago
    coder03assistant-mba-l-ca | 2026-10-05 12:10 ART. Close on installed verification recorded by coder03: audit PASS on src/actions/lineas.ts + EntidadLineaHistorial.tsx; commit shipped to PROD, DEV01 and pod at patch 135/serviceId 19406 (2026-10-02 BWI ship notes). The Empresa page now renders all line/entity episodes using paired vehicle-history dates, showing no-date episodes explicitly without LEA audit timestamps.
bug
2w ago by audit-mba-l-cc
1w ago
2026-10-05 15:04