basquetWi + New ticket

Motor manufacturer book-label aliases need FK carrier after MOVILBA-490 phase 1

Blocked normal dmdb04-mba-l-ca

Remaining MOVILBA-490 manufacturer-alias carrier, explicitly excluded from the applied phase-1 propulsion cutover. Current book has 12 motor labels in both bases: 11 exact live fabricantes matches (5557 rows) and CUMMINS 6 CIL (1 row, AH992CY) mapped by a CASE inside rutap.proyectar_snapshot to CUMMINS id24; MERCEDEZ substring has 0 current rows. Deliver a reviewed table of source-label aliases with a real FK to fabricantes, approved state and evidence, then change the projector to read it without assuming IDs align PROD/DEV. Preserve raw_motor and prevent ambiguous/absent mappings from silently passing. Sequence after MOVILBA-367, 749, and 751+282 projector re-pins; PROD-first, audit before apply. MOVILBA-746 separately fixes the preflight view false positive and is not this FK carrier.

Sub-tickets

No sub-tickets.
+ Add sub-ticket

Activity

  • db04-mba-l-ca created · 1w ago
    parent=#3931
  • db04-mba-l-ca statusChanged · 1w ago
    Starting SELECT-only carrier design/census; projector DDL is sequenced after MOVILBA-367, 749, and 751+282, so no overlap write now.
  • db04-mba-l-ca progress · 1w ago
    SELECT-only carrier census in PROD movilba and DEV movilba_dev: identical current-book distribution, 5558 rows/12 normalized motor labels. Eleven labels exact-match one LIVE fabricantes name (5557 rows); only CUMMINS 6 CIL (AH992CY, 1 row) lacks exact live manufacturer and is the approved alias to CUMMINS. Existing projector join uses CASE CUMMINS 6 CIL->CUMMINS plus broad MERCEDEZ->MERCEDES; old documented typo MERCEDEZ BENZ is absent from current book but appears in rutap-transform-rules.md and old book. Active fabricantes counts PROD 31/DEV 32, but no duplicate upper(btrim(fabricante)) names in either; CUMMINS and MERCEDES BENZ each unique. Resolver design direction: PK on normalized source label (upper/btrim, no broad rewrite), estado aprobado/pendiente/conflicto, nullable fabricante_id with FK and approved<->nonnull CHECK, evidence; seed targets by UNIQUE live fabricante name, never literal id, and flag absent/pending/ambiguous rather than silently accepting. Preserve raw_motor. DDL/projector cutover remains sequenced after 367, 749, 751+282 and needs audit; no write made.
  • db04-mba-l-ca spec · 1w ago
    Read-only design pin (PROD movilba snapshot 11, DEV movilba_dev snapshot 21): each base has exactly one 5558-row raw snapshot and the same 12 UPPER(BTRIM(motor)) keys. Installed targets by live fabricante name: MERCEDES BENZ 2421->MERCEDES BENZ; CUMMINS 2082->CUMMINS; YUCHAI 498->YUCHAI; MWM 288->MWM; SCANIA 89->SCANIA; WEICHAI 85->WEICHAI; EQUIPMAKE 31->EQUIPMAKE; DANA 26->DANA; VOLVO 22->VOLVO; MAN 10->MAN; FPT 5->FPT; CUMMINS 6 CIL 1->CUMMINS. Installed IDs happen to agree for these 12 today, but migration must resolve targets by UNIQUE live UPPER(BTRIM(fabricantes.fabricante)) independently in each base, never pin IDs. Historic MERCEDEZ BENZ is documented in rutap-transform-rules.md but 0 current raw rows; replace broad replace(MERCEDEZ,MERCEDES) with at most one exact, evidence-backed alias key, not a substring rule. Proposed carrier rutap.motor_fabricante_resolver: valor_fuente_normalizado text PRIMARY KEY with nonblank/check equal UPPER(BTRIM(self)); fabricante_id integer nullable FK public.fabricantes(id); estado text NOT NULL CHECK in (aprobado,pendiente,conflicto); CHECK ((estado=aprobado)=(fabricante_id IS NOT NULL)); evidencia text NOT NULL/nonblank; creado_en timestamptz DEFAULT now(); nonunique index on fabricante_id for FK maintenance. Multiple source aliases may intentionally share one target; no unique target constraint. Seed 12 current keys plus separately documented exact historical alias, after asserting each target LIVE and unique. No automatic approval for unknown key, no broad typo normalization. Projector joins the carrier on UPPER(BTRIM(s.motor)) and approved state, then live fabricantes on FK; absent/pending/conflict/deleted target raises motor_fabricante_no_resuelto, raw_motor retained byte-for-byte. Because projector is SECURITY INVOKER, PROD must GRANT SELECT to svc_nextjs; DEV owner movilba_user, PROD owner movilba_owner. Rollback controls must prove 5558 stored-target parity, CUMMINS 6 CIL positive, unknown/pending/wrong-target/deleted-target fail closed, and no ambiguity. No DDL/rehearsal now: 749 and 751+282 projector re-pins precede cutover, then audit and PROD-first apply.
  • db04-mba-l-ca progress · 1w ago
    Draft only, NOT rehearsed or applied: docs/migrations/2026-10-08-movilba-752-motor-fabricante-fk-PROD-Y-DEV.sql SHA256 08e3f60324e8d47d9b2d38937130c3429de474ef190ea529f03f8e16b4944e63 (252 lines). Both bases currently have md5(prosrc)=ade30cdf61b58fb67cbd5c2b2112fced and md5(pg_get_functiondef)=3ba101fbf32733c941af10d836b5c685. Script is default ROLLBACK, creates 13 explicit normalized source keys with FK to live fabricantes by per-base name (12 current plus exact historical MERCEDEZ BENZ), nonblank evidence and approved/pending/conflict state; indexes FK; grants PROD svc_nextjs SELECT; rewrites only the exact installed motor join. Gates include current-book old/FK parity 5558, stored motor FK and raw_motor parity 5558, CUMMINS 6 CIL wrong-target mutant 1, absent/pending/conflict probe, function owner/ACL preservation. Retired-target join is filtered but NOT positively exercised: both bases currently have zero retired fabricantes. No repository gates, DDL, or DB writes run. The 752 description still sequences after 751+282, both backlog; PM has been asked whether drafting now supersedes apply order. Audit and rollback rehearsal remain owed.
  • db04-mba-l-ca progress · 1w ago
    Default-ROLLBACK rehearsal completed on exact SQL SHA256 a107435ec60778818d440af2a50b8f4e2b4eaeade28f8f8f2673c288ff6f7a4a, docs/migrations/2026-10-08-movilba-752-motor-fabricante-fk-PROD-Y-DEV.sql (252 lines). Initial draft 08e3f603 stopped on PROD at SQL parse before DDL; its owner-check CASE was corrected, so that SHA is superseded and never executed. Corrected SHA: PROD via owner-capable postgres URL, rc0, NOTICE verbatim: MOVILBA-752 movilba: book parity 5558/5558, wrong-alias mutant 1, FK carrier and projector patched under transaction. DO then ROLLBACK. Post-rollback SELECT: md5(prosrc)=ade30cdf61b58fb67cbd5c2b2112fced, to_regclass(carrier) IS NULL. DEV via DEV_DATABASE_URL/movilba_user, rc0, NOTICE verbatim: MOVILBA-752 movilba_dev: book parity 5558/5558, wrong-alias mutant 1, FK carrier and projector patched under transaction. DO then ROLLBACK. Same post-rollback digest and carrier absence. Migration also asserts stored 5558 motor_fabricante_id and byte-exact raw_motor parity, 13 carrier rows, FK, absent/pending/conflict probes, function owner/ACL. No real projector import run; retired-target branch is syntactically filtered but cannot be positively exercised because both bases have 0 retired fabricantes. NO APPLY: PM explicitly retains 282 then 751 re-pin before 752 apply. Audit verdict owed on a107435e and this two-base rehearsal.
  • db04-mba-l-ca progress · 1w ago
    Superseding draft SHA a107435e: exact new SQL SHA256 9e25a0581acab35493e359ef983f20fb8bb3bf3923213a33a4f9b0c80de0ebf7, 288 lines, adds a REQUIRED retired-target positive control. Existing approved CUMMINS 6 CIL carrier alias points at live CUMMINS; nested PL/pgSQL subtransaction soft-deletes that fabricante, exercises the same approved-carrier/live-fabricante join, requires 1/1 alias to resolve no live target, then raises a caught sentinel to roll back the soft-delete. Post-subtransaction assertion requires CUMMINS live again. Ran exact bytes default ROLLBACK PROD first and DEV second, rc0 both. Each printed NOTICE retired-target guard fired 1/1; synthetic soft-delete rolled back, then book parity 5558/5558 and wrong-alias mutant 1. Independent post-rollback reads on both bases: projector md5(prosrc) remains ade30cdf61b58fb67cbd5c2b2112fced, carrier to_regclass IS NULL, exactly one live CUMMINS row. No real import run, no apply. PM expressly retains apply after MOVILBA-282 then 751 projector re-pins. Audit verdict now owed on 9e25a058 and these two rehearsals, not on a107435e.
  • db03-mba-l-cc note · 1w ago
    db03 2026-10-08 ART, for db04: your rehearsal at 9e25a058 pins the pre-apply projector body, so its preflight now aborts. MOVILBA-282 was applied to PROD 21:35:53 ART and DEV 21:36:41 ART; the installed body is md5(prosrc) a7c701fd3ac3a18b62e1584b01b102d7, md5(functiondef) 177038f472d409b3d848845746acc9ba, 39723 characters / 39845 octets, identical in both bases, owners preserved. Re-base the pin before the next run. Nothing else about 752 changed and no 752 bytes were touched by me.
  • db04-mba-l-ca progress · 1w ago
    2026-10-08 21:50 ART pre-apply SELECT-only check: audited/rehearsed SQL SHA 9e25a058 pins old md5(prosrc)=ade30cdf; installed PROD and DEV projector prosrc now both a7c701fd3ac3a18b62e1584b01b102d7 after 282, fdef 177038f472d409b3d848845746acc9ba, carrier absent. Exact old motor join remains once in both installed definitions, so mechanical rebase appears feasible, but the current file MUST abort on its preflight and cannot be applied. No 752 audit PASS exists yet. 751 remains backlog; PM asked whether 752 apply supersedes its earlier sequencing. No DDL or repo write. Next: re-pin when checkout is free, PROD then DEV default-ROLLBACK rehearsal, audit new SHA, then apply only on explicit sequence decision.
  • db04-mba-l-ca progress · 1w ago
    2026-10-08 21:51 ART measured rebase draft OUTSIDE shared checkout: /data-lezama/movilba/evidencia/MOVILBA-752/2026-10-08-movilba-752-motor-fabricante-fk-rebased-after-282-PROD-Y-DEV.sql SHA256 b572f7721b07ecd5f8e36dc3de574c86d1259e0b0898e07ace9574822fb5b193. Independent SELECT on PROD and DEV: installed md5(prosrc), NOT functiondef, equals a7c701fd3ac3a18b62e1584b01b102d7; functiondef digest 177038f472d409b3d848845746acc9ba. Existing motor join remains once on each base. Diff from 9e25a058 is one preflight digest line plus draft/sequence comment. No SQL run, no DDL, no checkout write. PM confirms 751 still precedes 752 APPLY. This draft is not an apply artifact; 751 may change the preimage again. Next: after 751, re-read installed prosrc, re-pin as needed, PROD→DEV default-ROLLBACK rehearsal and new audit verdict before any apply.
  • coder03assistant-mba-l-ca verified · 1w ago
    2026-10-08 SELECT-only census saved at /data-lezama/movilba/evidencia/MOVILBA-752/2026-10-08-function-body-digest-census.md (SHA256 86487e2324334918c2e8ba43133435da237bc7f7a76a94821b42e107a550c6c3); reproducible SQL /data-lezama/movilba/evidencia/MOVILBA-752/2026-10-08-function-body-digest-census.sql (SHA256 3414c4157f2c0b0239733f9f5a247e44e5e67f390f0ee4625ef5eb5d4541f709). Inventory: 29 files, 40 distinct expected function-body digest values; applied state per file and prosrc/functiondef kept separate. Current unapplied 752 pins projector prosrc ade30cdf..., while PROD and DEV are a7c701fd...; stale/dead-on-arrival. Existing applied stale pre-image pins are historical. SELECT-only probes in both bases; no migration, fixture, DDL, or write path exercised.
  • coder03assistant-mba-l-ca note · 1w ago
    Correction to the prior census note: re-counted the final digest table directly. Correct totals are 29 files, 41 fixed-digest guard references, and 36 distinct expected digest strings (not 40). Corrected report SHA256: 3df2a9eb02e0501ea96c76b4b5f5379a3ffc0445239bdbe97ead341eb9cd4331. SQL SHA256 unchanged: 3414c4157f2c0b0239733f9f5a247e44e5e67f390f0ee4625ef5eb5d4541f709. Core finding unchanged: checked-in unapplied 752 expects projector md5(prosrc)=ade30cdf...; PROD and DEV both have a7c701fd... . No write path was exercised.
  • coder03assistant-mba-l-ca note · 1w ago
    Corrected census follow-up (2026-10-08): report /data-lezama/movilba/evidencia/MOVILBA-752/2026-10-08-function-body-digest-census.md SHA256 68c1e379bdc50ac3c7382e6775484b8ab8d72a79255264eafca8f8620fa227cd; SQL unchanged SHA256 3414c4157f2c0b0239733f9f5a247e44e5e67f390f0ee4625ef5eb5d4541f709. Actionable UNAPPLIED MIGRATION count: 1 file, 2026-10-08-movilba-752-motor-fabricante-fk-PROD-Y-DEV.sql, stale projector prosrc ade30cdf... versus installed a7c701fd... in PROD and DEV (one file diverges in both bases). Two additional stale UNAPPLIED artifacts are DEV-only rollback fixtures, not migrations: 2026-09-20-movilba-518-w5-negativo-fixture-DEV-ROLLBACK-ONLY.sql and 2026-09-20-movilba-521-control-negativo-emisiones-DEV.sql. Strict all-file non-applied count: PROD 1, DEV 3, total distinct files 3. The remaining 26 files are applied migrations; stale pre/postcondition pins there are expected historical evidence and excluded from the actionable list (25 have at least one mismatch; one still matches). Corrected digest table: 43 fixed comparison sites, 36 distinct strings. Six expected digest values repeat across distinct files; names/pairs are in report. No migration/rehearsal/write executed by this census.
  • coder03assistant-mba-l-ca note · 1w ago
    Supersedes the preceding census correction after reconciling guard references vs all comparisons. Final report SHA256 b149d4d1de6bdce69798154ad76c72b031a1c1fac76ebf9436a31604066ba9e3; SQL unchanged SHA256 3414c4157f2c0b0239733f9f5a247e44e5e67f390f0ee4625ef5eb5d4541f709. Final inventory: 29 files, 41 fixed-digest guard references plus one fixed-digest postcondition comparison (42 comparison sites total), 36 distinct digest strings. Actionable unapplied migrations: one (752), stale in both PROD and DEV; two extra stale files are DEV-only rollback fixtures, not migrations. Applied files' stale pre/postcondition pins are historical and excluded. Six distinct expected digests repeat across files; the report lists all pairs. No execution/write.
  • db04-mba-l-ca blocked · 1w ago
    Parked: design/census complete; apply is sequenced after MOVILBA-751. That item is awaiting Elazar decision on WARN+NULL versus ABORT, followed by its projector re-pin. Rebase and rehearse 752 only after that body is installed.
tech-debt
1w ago by db04-mba-l-ca
1w ago