fix(supply-layers): dev_group_name in L3 upsert key (#970 CRITICAL) #1035

Merged
bot-backend merged 1 commit from fix/970-l3-dev-group-key into main 2026-06-04 05:06:59 +00:00
Collaborator

REOPENED CRITICAL #970 — L3 future-supply collapse (~95.6% loss).

L3 computed per (district_name, dev_group_name) but dev_group_name was never a key column -> all dev_groups of a district collapsed into one upsert key. Ground-truth (Akademichesky, prod): should be 13808 units / 15 dev_groups, only 1 row / 607 survived.

Migration 128: +dev_group_name column + rebuild uq_supply_layers_logical -> (layer,district_name,complex_id,obj_class,dev_group_name,source,snapshot_date) NULLS NOT DISTINCT (L1/L2 unaffected, L3 un-collapses). Dry-run vs prod catalog OK.
Worker: dev_group_name in SupplyLayerRow + _UPSERT_SQL INSERT/VALUES/ON CONFLICT (CAST, not in DO UPDATE). No-collapse regression tests. 234 supply tests green.

Deploy applies migration before restart; collapsed data self-heals on next supply_layers_refresh. Verification = prod re-measure post-deploy. Refs #970

REOPENED CRITICAL #970 — L3 future-supply collapse (~95.6% loss). L3 computed per (district_name, dev_group_name) but dev_group_name was never a key column -> all dev_groups of a district collapsed into one upsert key. Ground-truth (Akademichesky, prod): should be 13808 units / 15 dev_groups, only 1 row / 607 survived. Migration 128: +dev_group_name column + rebuild uq_supply_layers_logical -> (layer,district_name,complex_id,obj_class,dev_group_name,source,snapshot_date) NULLS NOT DISTINCT (L1/L2 unaffected, L3 un-collapses). Dry-run vs prod catalog OK. Worker: dev_group_name in SupplyLayerRow + _UPSERT_SQL INSERT/VALUES/ON CONFLICT (CAST, not in DO UPDATE). No-collapse regression tests. 234 supply tests green. Deploy applies migration before restart; collapsed data self-heals on next supply_layers_refresh. Verification = prod re-measure post-deploy. Refs #970
bot-backend added 1 commit 2026-06-04 05:06:55 +00:00
fix(supply-layers): thread dev_group_name into L3 upsert key (#970 CRITICAL)
All checks were successful
Deploy / changes (push) Successful in 6s
Deploy / build-frontend (push) Has been skipped
Deploy / build-backend (push) Successful in 1m22s
Deploy / build-worker (push) Successful in 2m32s
Deploy / deploy (push) Successful in 1m4s
ed3b302d57
REOPENED. L3 future-supply rows are computed per (district_name, dev_group_name)
but dev_group_name was never a key column — only embedded in method text. With
complex_id/obj_class NULL for L3, every dev_group of a district collapsed to one
upsert key → ~95.6% loss. Ground-truth (Академический, prod): should be 13,808
units / 15 dev_groups / 54 objects; only 1 row / 607 units survived.

Migration 128: ADD COLUMN supply_layers.dev_group_name TEXT + rebuild
uq_supply_layers_logical to (layer, district_name, complex_id, obj_class,
dev_group_name, source, snapshot_date) NULLS NOT DISTINCT (L1/L2 dev_group_name
NULL stays transparent → their dedup unchanged; L3 distinct groups no longer
collapse). Dry-run-verified vs prod catalog (applies clean, ROLLBACK clean).

Worker: SupplyLayerRow gains dev_group_name (L1/L2=None, L3=group); _UPSERT_SQL
adds it to INSERT/VALUES (CAST(:dev_group_name AS text)) + ON CONFLICT (key col,
not in DO UPDATE SET). Service+worker regression tests assert same-district/
different-dev_group → distinct keys (no collapse). 234 supply tests pass.

Deploy applies migration before container restart; collapsed data self-heals on
next supply_layers_refresh. Verification = prod re-measure post-deploy.

Refs #970
bot-backend merged commit ed3b302d57 into main 2026-06-04 05:06:59 +00:00
bot-backend deleted branch fix/970-l3-dev-group-key 2026-06-04 05:06:59 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#1035
No description provided.