basquetWi + New ticket
movilba MOVILBA-666

Quitar motor_modelo de la API publicada: duplica la marca del motor y MovilBA no necesita modelo de motor

Done high dmdb04-mba-l-ca

Elazar 2026-10-02: MovilBA se simplifica; modelo de motor no se necesita. v_vehiculos_api_public proyecta vd.motor_fabricante AS motor_modelo (0/2419 PROD, 0/2455 DEV distintos de motor_marca, medido por db04 en MOVILBA-608). Quitar la columna de la vista en PROD primero y despues DEV, mas el contrato docs/reference/parque-movil-api/ y cualquier codigo que la lea (coder04). Censo de lectores antes del cambio. Tipo_Motor NO se agrega a la API.

Sub-tickets

No sub-tickets.
+ Add sub-ticket

Activity

  • coder03-mba-l-cc created · 2w ago
  • db04-mba-l-ca progress · 2w ago
    2026-10-02 SELECT-only reader/dependency census, both current_database() checked. In PROD and DEV, public.v_vehiculos_api_public has 13 columns, motor_modelo at ordinal 8, expression 'vd.motor_fabricante AS motor_modelo'; pg_get_viewdef md5 c80b1a9a337050a932d465cdc6811eda in both. Database dependent: public.v_api_status references the relation (count(*)), no column-specific dependency; no other dependent views or functions found. v_api_status viewdef md5 4e4295ee4717f78db81ba9289e13b8b4 both. PROD owner movilba_owner and explicit SELECT ACL for svc_nextjs,audit_ro on BOTH views; DEV owner movilba_user, relacl NULL. No view/column comments, security labels, or reloptions. CREATE OR REPLACE cannot remove ordinal 8, so a transaction must drop/recreate v_api_status then v_vehiculos_api_public, then recreate main and status, preserving owner and grants. Code reader: scripts/sync-to-api.ts:55/70/92/113 explicitly SELECTs and forwards motor_modelo to api.movilba.com; api-external/php-api sync.php/dev_sync.php:77-78 and api-external/nodejs-api services/sync.ts:12/78 consume/store it. docs/reference/parque-movil-api has no motor_modelo, and its /api/v1/parque routes read base tables, not this view; this is a different external sync contract. PROD-first column DROP before changing/retiring the sync reader breaks that writer. Alerted coder03+coder04; no DDL applied.
  • db04-mba-l-ca progress · 2w ago
    2026-10-02 DDL draft /data-lezama/movilba/migration-evidence/2026-10-02-movilba-666-drop-api-motor-modelo-DEV-Y-PROD.sql SHA256 fc6ca45099c04a79d21c218b5371b23f1282dd5a785fc02560cd0711835cf2c9. PROD and DEV ROLLBACK rehearsals both PASS: 13->12 view columns, unchanged 2419 PROD/2455 DEV row images after excluding motor_modelo, unchanged v_api_status row, owner/ACL/reloptions preserved; DROP without CASCADE/recreate the dependent v_api_status; no other dependent view or function. PROD initially required creation as elazar then ALTER OWNER to movilba_owner and GRANT as owner because owner lacks CREATE on public; DEV creates as movilba_user. Post-rehearsal live still 13 columns/motor_modelo present in both. HOLD APPLY: scripts/sync-to-api.ts directly SELECTs motor_modelo and will fail after DDL; coder04/coder03 alerted about code/external API contract. Audit requested next, then apply only after reader cutover.
  • audit-mba-l-cc audited · 2w ago
    audit pass: DDL structural review only (DB execution not performed by audit, no creds): drop/recreate of both views, pre/post guards, ACL restore.
    payload
    {"scope":"DDL structural review only (DB execution not performed by audit, no creds): drop/recreate of both views, pre/post guards, ACL restore.","outcome":"pass","evidence":"Checked: drop order (status before main, dependent first), unique anchor match on motor_modelo expr, PROD-only re-grant matches ACL precondition (DEV expects NULL ACL), row-diff via EXCEPT ALL both ways, default ROLLBACK. Confirmed scripts/sync-to-api.ts is the only in-repo reader of this column from this view - apply-hold is correct.","reportRef":null}
  • coder04-mba-l-ca progress · 2w ago
    coder04-mba-l-ca | 2026-10-02 14:06 ART. Reader census: scripts/sync-to-api.ts:55/70 declared motor_modelo in row/payload types, :92 selected it from v_vehiculos_api_public, and :113 forwarded it to POST /sync; removed all three references. drizzle/schema.ts typed vVehiculosApiPublic and its SQL definition also had the column; removed it from both. docs/reference/parque-movil-api/ has zero motor_modelo references (rg, all five files); no edit needed there. The separate sync endpoint receiver code (api-external/php-api sync/dev_sync.php and api-external/nodejs-api services/sync.ts) accepts/stores an optional incoming key, but does not query this view; retained backward-compatible input handlers. Updated the sync-to-api YAML payload example to omit the key. No Tipo_Motor added. Source deploy must precede db04 applying the audited view DDL, otherwise the live timer query would fail. No tests/lint/typecheck run by this lane.
  • coder04-mba-l-ca progress · 2w ago
    coder04-mba-l-ca | 2026-10-02 14:07 ART. Implemented the code/documentation cutover from the census: scripts/sync-to-api.ts no longer SELECTs or forwards motor_modelo; drizzle/schema.ts removes the typed column and SQL projection from vVehiculosApiPublic; sync-to-api-movilba.yaml sample payload omits it. docs/reference/parque-movilba-api had no references to remove. Receiver handlers under api-external still accept legacy optional payloads; they do not query v_vehiculos_api_public and were left unchanged for compatibility. No Tipo_Motor added. Code must ship before db04 applies the already-audited DDL because the sync timer formerly selected this column. No gates run by this lane.
  • coder04-mba-l-ca progress · 2w ago
    coder04-mba-l-ca | 2026-10-02 14:08 ART. Correction: the documentation census path is docs/reference/parque-movil-api/ (five files, zero motor_modelo matches), not parque-movilba-api. Prior progress event contains a path typo only.
  • audit-mba-l-cc audited · 2w ago
    audit pass: sync-to-api.ts + sync-to-api-movilba.yaml only: motor_modelo removed from interfaces/SELECT/mapToPayload/example. schema.ts hand-edit excluded per coder03 (generated, regenerates post-DDL)
    payload
    {"scope":"sync-to-api.ts + sync-to-api-movilba.yaml only: motor_modelo removed from interfaces/SELECT/mapToPayload/example. schema.ts hand-edit excluded per coder03 (generated, regenerates post-DDL)","outcome":"pass","evidence":"sync.php:77, dev_sync.php:78 use ?? null (PHP tolerates missing key); nodejs sync.ts:12,78 already optional, uses || null. All 3 receivers accept payload without the field","reportRef":null}
  • coder04-mba-l-ca progress · 2w ago
    coder04-mba-l-ca | 2026-10-02 14:10 ART. External-contract follow-up to census: api-external/php-api sync.php/dev_sync.php and api-external/nodejs-api services/sync.ts consume the posted motor_modelo key, store it, and expose it through their own vehicle API; external-api-db.yaml names PLUG and DGT as consumers. After the sender stops including the key, PHP maps it to NULL and Node maps the missing key to NULL on update, clearing stored values. These are not readers of the Postgres view, but sender cutover changes their contract/data. Their APIs/DB were left untouched pending scope decision; prior note that receivers are backward-compatible did not capture the downstream clear/output effect.
  • coder04-mba-l-ca progress · 2w ago
    coder04-mba-l-ca | 2026-10-02 14:13 ART. Correction to the 14:07 event: coder03 excluded my drizzle/schema.ts hand-edit from the committed audit scope; it remains unchanged until the view DDL is applied and the schema mirror is regenerated. The 14:09 commit 491772ea contains scripts/sync-to-api.ts and sync-to-api-movilba.yaml only, plus release metadata. The empty local candidate patch was removed.
  • coder04-mba-l-ca progress · 2w ago
    coder04-mba-l-ca | 2026-10-02 14:19 ART. Step 1 measured read-only: absent or explicit null motor_modelo is accepted by all three receivers. PHP sync.php:77 and dev_sync.php:78 use ?? null, then include the nullable value in insert/update fields at :69-103 and :70-104; the UPDATE filters by key only, so NULL is retained and written. Node api-external/nodejs-api/src/services/sync.ts:12 types the field optional+nullable, :78 maps absent/null to null, and the nullable DB column is declared in src/db/schema.ts:40 / migration 0000_pale_aqueduct.sql:60. Both create and update use vehicleData at :86-98. Consequence: existing receiver records are cleared on the next sync; their response mapper still emits the nullable key (vehicles.ts:30). Step 2 is already audited and committed as 491772ea: the source sync no longer reads or sends motor_modelo; no api-external files changed. No code edit needed for receiver tolerance.
  • coder03-mba-l-cc note · 2w ago
    2026-10-02 14:21 coder03-mba-l-cc: v5.6.147 (sync no longer sends motor_modelo) on PROD, DEV and pod (proxy serviceId 21050). View DDL on hold: Elazar decides whether PLUG/DGT lose motor_modelo when sync resumes (movilba-sync.timer and dev-movilba-sync.timer are disabled on lezama today).
  • coder03-mba-l-cc decision · 1w ago
    Elazar 2026-10-05 (CLI, literal '1a'): motor_modelo goes NULL for PLUG/DGT when sync resumes; db04 drops the column from v_vehiculos_api_public and any backing column. Relayed by coder03-mba-l-cc.
  • coder03-mba-l-cc unblocked · 1w ago
    Elazar decided 1a on 2026-10-05
  • db04-mba-l-ca progress · 1w ago
    2026-10-05 decision 1a lifted hold. Reader scan: scripts/sync-to-api.ts already stopped selecting motor_modelo in v5.6.147; src/tools/scripts/importer have no other reader of public.v_vehiculos_api_public.motor_modelo. No dedicated backing column: view expression vd.motor_fabricante AS motor_modelo aliases the independently-used motor_marca source. Existing audited draft header updated at /data-lezama/movilba/migration-evidence/2026-10-02-movilba-666-drop-api-motor-modelo-DEV-Y-PROD.sql. ROLLBACK rehearsals succeeded: PROD 2419 rows/12 output columns/1 v_api_status row with owner+ACL+other-field postchecks; DEV 2457/12/1. No DB write committed. Audit requested before apply.
  • audit-mba-l-cc audited · 1w ago
    audit pass: re-bound to SHA d4214cd4: header-only change lifting the apply hold (decision 1a), body byte-identical to prior PASS (same md5 pins, GRANT, DROP/CREATE sequence)
    payload
    {"scope":"re-bound to SHA d4214cd4: header-only change lifting the apply hold (decision 1a), body byte-identical to prior PASS (same md5 pins, GRANT, DROP/CREATE sequence)","outcome":"pass","evidence":"scripts/sync-to-api.ts confirmed clean of motor_modelo; package.json version 5.6.150 >= the v5.6.147 cutover the header cites. Hold is correctly lifted","reportRef":null}
  • db04-mba-l-ca progress · 1w ago
    2026-10-05 audit PASS bound to SHA256 d4214cd4. Applied exact draft PROD first then DEV with -v apply=true, both COMMIT. Post-COMMIT SELECT: PROD 2419 view rows, 12 columns, motor_modelo absent, relacl {svc_nextjs=r/movilba_owner,movilba_owner=arwdDxtm/movilba_owner,audit_ro=r/movilba_owner}; DEV 2457 rows, 12 columns, motor_modelo absent, relacl NULL unchanged. No dedicated backing column existed; vd.motor_fabricante remains for motor_marca. Awaiting repository SHIP.
  • db04-mba-l-ca progress · 1w ago
    Applied and audited SQL placed at docs/migrations/2026-10-05-movilba-666-drop-api-motor-modelo-DEV-Y-PROD.sql; SHA256 d4214cd4786dc5537618aed5a78834b1ea98022737c56aac9b8a8d67bd55f3d5 matches applied instrument. PROD and DEV post-COMMIT checks passed; awaiting SHIP.
  • audit-mba-l-cc audited · 1w ago
    audit pass: git diff drizzle/schema.ts post mba-introspect.sh, relations.ts confirmed unchanged
    payload
    {"scope":"git diff drizzle/schema.ts post mba-introspect.sh, relations.ts confirmed unchanged","outcome":"pass","evidence":"vVehiculosApiPublic drops motorModelo field matching applied DDL; no other hunk","reportRef":null}
  • coder03-mba-l-cc completed · 1w ago
    coder03-mba-l-cc 2026-10-05: applied PROD then DEV by db04 with audit PASS; SQL, README row and regenerated drizzle mirror (audit PASS) shipped as v5.6.151 on PROD and DEV; pod push requested from proxy-mba-w-cc.
chore
2w ago by coder03-mba-l-cc
1w ago
2026-10-05 15:23