fsanyoto commited on
Commit
4a26bdc
·
verified ·
1 Parent(s): 52c6936

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,6 +1,12 @@
1
  {
2
- "current": "v60 (dd1b062)",
3
  "releases": [
 
 
 
 
 
 
4
  {
5
  "version": "v60",
6
  "sha": "dd1b062",
 
1
  {
2
+ "current": "v61 (bbc4c07)",
3
  "releases": [
4
+ {
5
+ "version": "v61",
6
+ "sha": "bbc4c07",
7
+ "date": "2026-08-30",
8
+ "subject": "v61 - wave 46 hotfix: D-590 schema overlay reaches the grid read (all three assemblies), D-599 route to zone association"
9
+ },
10
  {
11
  "version": "v60",
12
  "sha": "dd1b062",
VERSION CHANGED
@@ -1 +1 @@
1
- v60 (dd1b062)
 
1
+ v61 (bbc4c07)
api/routes_customers.py CHANGED
@@ -572,6 +572,35 @@ def grid_assembly(session: Session, scope: str = "customer", storage_key: str =
572
  fields = [field for field in fields if field.get("key") not in {"routes", "zone"}]
573
  fields.extend(route_system.customer_projection_fields(normalized_routes, normalized_zones))
574
  fields = [route_system.field_axes(field) for field in fields]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
575
  return {"rows_src": rows_src, "pids": pids, "ws": ws, "workspace": workspace,
576
  "fields": fields, "views": views, "lists": lists, "derived": derived,
577
  "measures": measures, "measure_sets": measure_sets, "today": today,
@@ -870,6 +899,10 @@ def _route_dto(route, allowed, active, session, share_mark=None):
870
  route, can_edit=can_edit, can_duplicate=source_edit,
871
  can_delete=can_edit),
872
  "assignee": route.get("assignee"), "date": route.get("date"),
 
 
 
 
873
  "starred": route.get("starred") is True,
874
  "source": {"viewId": route.get("sourceViewId"),
875
  "revision": route.get("sourceViewRevision")},
@@ -884,6 +917,30 @@ def _route_dto(route, allowed, active, session, share_mark=None):
884
  return dto
885
 
886
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
887
  def _route_or_404(session, route_id):
888
  route = next((item for item, _mark in _visible_normalized_routes(session)
889
  if item.get("id") == str(route_id)), None)
@@ -1047,6 +1104,7 @@ def create_route(body: dict = Body(default=None), session: Session = Depends(mod
1047
  if any(pid not in permitted for pid in _route_input_pids(raw)):
1048
  raise err(403, "out_of_scope", "a Route stop must be in your customer book")
1049
  _route_schedule_patch_or_400(session, raw)
 
1050
  route = route_system.put_route(session.runtime, raw, tenant_id=session.tenant, created_by=session.uname)
1051
  if route is None:
1052
  raise err(400, "invalid_route", "a Route needs a name and an optional HTTPS Google Maps URL")
@@ -1089,6 +1147,7 @@ def update_route(route_id: str, body: dict = Body(default=None),
1089
  if "stops" in raw and any(pid not in allowed_pids(session) for pid in _route_input_pids(raw)):
1090
  raise err(403, "out_of_scope", "a Route stop must be in your customer book")
1091
  _route_schedule_patch_or_400(session, raw)
 
1092
  route = route_system.put_route(session.runtime, raw, tenant_id=session.tenant, created_by=session.uname)
1093
  if route is None:
1094
  raise err(400, "invalid_route", "a Route needs a name and an optional HTTPS Google Maps URL")
 
572
  fields = [field for field in fields if field.get("key") not in {"routes", "zone"}]
573
  fields.extend(route_system.customer_projection_fields(normalized_routes, normalized_zones))
574
  fields = [route_system.field_axes(field) for field in fields]
575
+ # ⭐⭐ D-590 (wave 46 hotfix) — **THE PER-TENANT SCHEMA OVERLAY, APPLIED TO THE GRID READ.**
576
+ # Wave 46 built the overlay end to end and left this wire out, so Manage Database saved a hide,
577
+ # the panel showed it hidden on reload, and the column was still on the grid. `merge()` is the
578
+ # grid-shaped read that DROPS a hidden field; `for_grid` is the one caller shape all three
579
+ # assemblies share. See `core/schema_overlay.py`'s "THE GRID SEAM" header for the polarity of a
580
+ # failed read (fails OPEN here, 503s on the admin route) and why `st` has no default.
581
+ #
582
+ # ⚠ LAST, AND DELIBERATELY. The overlay's `order` is a DISPLAY order, so it must sort the list
583
+ # that actually ships — sorting before the route projections are appended would leave them
584
+ # outside it. Hiding last is also the only position that covers `custom_`/`measure_` columns
585
+ # AND the route/zone projections, which is what the Manage Database panel enumerates.
586
+ # ⚠ THE LOCKED SET COMES FROM THE CANONICAL CONTRACT, not the assembled list, because that is
587
+ # what `routes_admin._overlay_view` derives its own from. If the two disagreed, the panel would
588
+ # report `partner_id` locked while the grid honoured a hide of it.
589
+ # ⛔ `MODULE` IS THE DATABASE KEY, and it is the same string `_perm_modules` lists and the
590
+ # panel PATCHes under. A different vocabulary here would read `doc.get(<wrong key>)`, find
591
+ # nothing, and be a silent no-op with every module-level gate leg still green.
592
+ import core.schema_overlay as schema_overlay
593
+ fields, _ov_hidden = schema_overlay.for_grid(MODULE, fields, st=rt,
594
+ contract=aios_grid.FIELDS)
595
+ if _ov_hidden:
596
+ # The same third wire the field wall above narrows: `/workspace` serves `ws["overlays"]`
597
+ # verbatim, so a hidden column's cells would still ride it. `ws` is a detached copy
598
+ # (`store.get` deep-copies), so nothing is written back.
599
+ _ovc = ws.get("overlays") or {}
600
+ if _ovc:
601
+ ws["overlays"] = {pid: {k: v for k, v in (cells or {}).items()
602
+ if k not in _ov_hidden}
603
+ for pid, cells in _ovc.items()}
604
  return {"rows_src": rows_src, "pids": pids, "ws": ws, "workspace": workspace,
605
  "fields": fields, "views": views, "lists": lists, "derived": derived,
606
  "measures": measures, "measure_sets": measure_sets, "today": today,
 
899
  route, can_edit=can_edit, can_duplicate=source_edit,
900
  can_delete=can_edit),
901
  "assignee": route.get("assignee"), "date": route.get("date"),
902
+ # D-599 (wave 46 hotfix) — the route's Zone association. ALWAYS present, `null` when
903
+ # the route has none: a key the client has to test for is a key the client forgets to
904
+ # test for, and every route saved before this change legitimately has none.
905
+ "zoneId": route.get("zoneId") or None,
906
  "starred": route.get("starred") is True,
907
  "source": {"viewId": route.get("sourceViewId"),
908
  "revision": route.get("sourceViewRevision")},
 
917
  return dto
918
 
919
 
920
+ def _route_zone_or_400(session, raw):
921
+ """D-599: a Route may name a Zone this database actually has, or none at all.
922
+
923
+ ⛔ THE REFUSAL IS NAMED AND IT CARRIES THE ID. `route_system._route` deliberately cannot do
924
+ this check: it sees one route and never the Zone table. Doing it here means an unknown id is
925
+ `400 unknown_zone` naming the offending value, rather than `400 invalid_route` blaming the
926
+ name and the Maps URL for something that is neither.
927
+
928
+ ⚠ ONLY WHEN THE KEY IS PRESENT. An absent `zoneId` inherits the stored one (the writer's own
929
+ polarity), so validating an absent key would refuse every PATCH that does not mention zones.
930
+ ⚠ `null` / `""` IS ALWAYS ALLOWED: clearing a Route's zone can never name a missing one.
931
+ """
932
+ if "zoneId" not in raw and "zone_id" not in raw:
933
+ return
934
+ from core import route_system
935
+ wanted = str(raw.get("zoneId", raw.get("zone_id")) or "").strip()
936
+ if not wanted:
937
+ return
938
+ if wanted not in route_system.zone_ids(session.runtime):
939
+ raise err(400, "unknown_zone",
940
+ f"there is no Zone {wanted} on this database. Pick one that exists, "
941
+ f"or clear the Zone on this Route.")
942
+
943
+
944
  def _route_or_404(session, route_id):
945
  route = next((item for item, _mark in _visible_normalized_routes(session)
946
  if item.get("id") == str(route_id)), None)
 
1104
  if any(pid not in permitted for pid in _route_input_pids(raw)):
1105
  raise err(403, "out_of_scope", "a Route stop must be in your customer book")
1106
  _route_schedule_patch_or_400(session, raw)
1107
+ _route_zone_or_400(session, raw)
1108
  route = route_system.put_route(session.runtime, raw, tenant_id=session.tenant, created_by=session.uname)
1109
  if route is None:
1110
  raise err(400, "invalid_route", "a Route needs a name and an optional HTTPS Google Maps URL")
 
1147
  if "stops" in raw and any(pid not in allowed_pids(session) for pid in _route_input_pids(raw)):
1148
  raise err(403, "out_of_scope", "a Route stop must be in your customer book")
1149
  _route_schedule_patch_or_400(session, raw)
1150
+ _route_zone_or_400(session, raw)
1151
  route = route_system.put_route(session.runtime, raw, tenant_id=session.tenant, created_by=session.uname)
1152
  if route is None:
1153
  raise err(400, "invalid_route", "a Route needs a name and an optional HTTPS Google Maps URL")
api/routes_products.py CHANGED
@@ -525,6 +525,24 @@ def product_assembly(session: Session, scope: str = "product", storage_key: str
525
  # choice hydration. Build their effective, already-walled row values before returning the
526
  # field contract so a populated select never opens as "no choices yet".
527
  fields = _hydrate_effective_choice_options(fields, rows_src, ws.get("overlays"), derived)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
  return {"rows_src": rows_src, "pids": pids, "ws": ws, "workspace": workspace,
529
  "fields": fields, "views": views, "lists": lists,
530
  "derived": derived,
 
525
  # choice hydration. Build their effective, already-walled row values before returning the
526
  # field contract so a populated select never opens as "no choices yet".
527
  fields = _hydrate_effective_choice_options(fields, rows_src, ws.get("overlays"), derived)
528
+ # ⭐⭐ D-590 (wave 46 hotfix) — **THE PER-TENANT SCHEMA OVERLAY, APPLIED TO THE GRID READ.**
529
+ # ⛔ THIS SURFACE IS THE ONE W46-T40 FAILED ON, and the staged spec named only the customer and
530
+ # user-table assemblies because lane E traced `routes_grid.py::workspace` alone. T40's evidence
531
+ # is `GET /api/v1/products` — which is THIS builder, through its own `workspace_wire` call — so
532
+ # wiring the other two would have left the ticket that reported the defect still failing.
533
+ # The seam, the polarity of a failed read and the `st` rule are in `core/schema_overlay.py`'s
534
+ # "THE GRID SEAM" header; `grid_assembly` carries the same block for the customer topic.
535
+ # ⚠ `fields_base` IS THE CANONICAL CONTRACT here (`scoped_pool` built it from `pd_fields`), so
536
+ # the locked set is derived from the same stratum `routes_admin._overlay_view` reads.
537
+ import core.schema_overlay as schema_overlay
538
+ fields, _ov_hidden = schema_overlay.for_grid(MODULE, fields, st=session.runtime,
539
+ contract=fields_base)
540
+ if _ov_hidden:
541
+ _ovc = ws.get("overlays") or {}
542
+ if _ovc:
543
+ ws["overlays"] = {str(pid): {k: v for k, v in (row or {}).items()
544
+ if k not in _ov_hidden}
545
+ for pid, row in _ovc.items()}
546
  return {"rows_src": rows_src, "pids": pids, "ws": ws, "workspace": workspace,
547
  "fields": fields, "views": views, "lists": lists,
548
  "derived": derived,
api/routes_tables.py CHANGED
@@ -1430,6 +1430,29 @@ def ut_assembly(session: Session, table_key: str, storage_key: str = "",
1430
  session.runtime.measure_memo).items():
1431
  derived.setdefault(_pid, {}).update(_cells)
1432
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1433
  return {"rows_src": rows_src, "pids": pids, "ws": ws, "workspace": workspace,
1434
  "fields": fields, "views": views, "lists": lists, "hidden": hidden,
1435
  "derived": derived,
 
1430
  session.runtime.measure_memo).items():
1431
  derived.setdefault(_pid, {}).update(_cells)
1432
 
1433
+ # ⭐⭐ D-590 (wave 46 hotfix) — **THE PER-TENANT SCHEMA OVERLAY, APPLIED TO THE GRID READ.**
1434
+ # The third of the three assemblies; `grid_assembly` and `product_assembly` carry the same
1435
+ # block. Manage Database lists a `ut_*` database under its own table key, so that key IS the
1436
+ # overlay's database key here — the same string `_perm_modules` yields from `nav_entries`.
1437
+ # See `core/schema_overlay.py`'s "THE GRID SEAM" header for the fail-open polarity and why
1438
+ # `st` is keyword-only with no default.
1439
+ # ⚠ `session.runtime` AND NOT THE LEND, so the handle is the same tenant-runtime object the
1440
+ # admin route passes and the gate can assert identity rather than mere tenancy.
1441
+ # ⚠ `fields_base` is this table's canonical definition, so the locked set matches the panel's.
1442
+ import core.schema_overlay as schema_overlay
1443
+ fields, _ov_hidden = schema_overlay.for_grid(table_key, fields, st=session.runtime,
1444
+ contract=fields_base)
1445
+ if _ov_hidden:
1446
+ # Both cell wires, exactly as the `hidden` block above narrows them: `/workspace` serves
1447
+ # `ws["overlays"]` verbatim and `table_rows` layers `shared_cells` on top.
1448
+ _ovc = ws.get("overlays") or {}
1449
+ if _ovc:
1450
+ ws["overlays"] = {pid: {k: v for k, v in (cells or {}).items()
1451
+ if k not in _ov_hidden}
1452
+ for pid, cells in _ovc.items()}
1453
+ if shared_cells:
1454
+ shared_cells = {pid: {k: v for k, v in cells.items() if k not in _ov_hidden}
1455
+ for pid, cells in shared_cells.items()}
1456
  return {"rows_src": rows_src, "pids": pids, "ws": ws, "workspace": workspace,
1457
  "fields": fields, "views": views, "lists": lists, "hidden": hidden,
1458
  "derived": derived,
platform/core/route_system.py CHANGED
@@ -196,6 +196,26 @@ def _route(raw, *, ordinal=0, created_by="", tenant_id="", prior=None):
196
  # appear at an unknowable time or for nobody, and a later PATCH could accidentally
197
  # complete a schedule the user never submitted together.
198
  return None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  stops_raw = raw.get("stops") if "stops" in raw else prior.get("stops")
200
  maps_url = str(raw.get("mapsUrl", prior.get("mapsUrl")) or "").strip()[:2048]
201
  if maps_url and not _GOOGLE_MAPS_URL_RE.match(maps_url):
@@ -208,7 +228,7 @@ def _route(raw, *, ordinal=0, created_by="", tenant_id="", prior=None):
208
  "sourceViewRevision": revision, "stops": _stops(stops_raw), "managedBy": MANAGED_BY,
209
  "createdBy": str(prior.get("createdBy") or created_by or "")[:120],
210
  "shareKey": share_key,
211
- "assignee": assignee, "date": route_date,
212
  "starred": raw.get("starred", prior.get("starred", False)) is True,
213
  "createdAt": prior.get("createdAt") or stamp, "updatedAt": stamp}
214
  if maps_url:
@@ -220,6 +240,18 @@ def _route(raw, *, ordinal=0, created_by="", tenant_id="", prior=None):
220
  return out
221
 
222
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  def _point_in_ring(lon, lat, ring):
224
  inside = False
225
  if len(ring) < 4:
@@ -948,6 +980,14 @@ def delete_zone(st, zone_id, *, table_key=DEFAULT_ZONE_TABLE):
948
  state["zones"] = [item for item in prior if not (
949
  isinstance(item, dict) and item.get("id") == zone_id
950
  and _zone_table_key(item) == table_key)]
 
 
 
 
 
 
 
 
951
  return state, len(prior) != len(state["zones"])
952
 
953
  return bool(_persist(st, mutate))
@@ -963,6 +1003,14 @@ def delete_zones_for_table(st, table_key):
963
  prior = list(state.get("zones") or [])
964
  state["zones"] = [item for item in prior if not (
965
  isinstance(item, dict) and _zone_table_key(item) == table_key)]
 
 
 
 
 
 
 
 
966
  return state, len(prior) - len(state["zones"])
967
 
968
  return int(_persist(st, mutate) or 0)
 
196
  # appear at an unknowable time or for nobody, and a later PATCH could accidentally
197
  # complete a schedule the user never submitted together.
198
  return None
199
+ # ⭐⭐ D-599 (wave 46 hotfix) — **THE ROUTE→ZONE ASSOCIATION.** Until this line no route record
200
+ # carried one: `ROUTES_KEY` and `ZONES_KEY` are two separate top-level tables, `ZONE_FIELD_KEY`
201
+ # is a field on a CUSTOMER row, and `customer_projections` attaches Routes and Zone to a
202
+ # customer INDEPENDENTLY. So a route's zone could not be changed because there was nothing to
203
+ # change (W46-T22, whose stop-delete half already worked).
204
+ #
205
+ # ⭐ THE MIGRATION FOR EXISTING SAVED ROUTES IS **NOTHING TO RUN**, and that is a decision
206
+ # rather than an omission. An absent key reads as `prior.get("zoneId")` -> `None`, so every
207
+ # route saved before this change has a null zone the first time it is read and keeps it until
208
+ # somebody sets one. No backfill script, no dry-run/apply pass, nothing deleted. The
209
+ # `ops/migrate_legacy_routes.py` shape was the precedent to reach for and it is not needed:
210
+ # that one moved DATA between representations; this adds an optional scalar with a safe null.
211
+ #
212
+ # ⚠ ABSENT INHERITS, EXPLICIT `null` CLEARS — the same polarity `assignee` and `date` above
213
+ # already use, so a PATCH carrying only `{"name": ...}` cannot silently unset a zone.
214
+ # ⛔ THE ID IS NOT VALIDATED HERE. This normaliser sees one route and never the zone table;
215
+ # the caller checks it against `zone_ids()` and refuses with a named 400, and `delete_zone`
216
+ # detaches the id from every route so a dangling reference cannot outlive its zone.
217
+ zone_id = str(raw.get("zoneId", raw.get("zone_id", prior.get("zoneId")))
218
+ or "").strip()[:96] or None
219
  stops_raw = raw.get("stops") if "stops" in raw else prior.get("stops")
220
  maps_url = str(raw.get("mapsUrl", prior.get("mapsUrl")) or "").strip()[:2048]
221
  if maps_url and not _GOOGLE_MAPS_URL_RE.match(maps_url):
 
228
  "sourceViewRevision": revision, "stops": _stops(stops_raw), "managedBy": MANAGED_BY,
229
  "createdBy": str(prior.get("createdBy") or created_by or "")[:120],
230
  "shareKey": share_key,
231
+ "assignee": assignee, "date": route_date, "zoneId": zone_id,
232
  "starred": raw.get("starred", prior.get("starred", False)) is True,
233
  "createdAt": prior.get("createdAt") or stamp, "updatedAt": stamp}
234
  if maps_url:
 
240
  return out
241
 
242
 
243
+ def zone_ids(st, *, table_key=DEFAULT_ZONE_TABLE):
244
+ """Every Zone id one database currently has — the vocabulary a route's `zoneId` may name.
245
+
246
+ ⭐ D-599 (wave 46 hotfix). Cheaper than `list_zones` for the one question the Route writer's
247
+ caller asks, because it never deep-copies a geometry or refreshes a membership.
248
+ """
249
+ wanted = str(table_key or DEFAULT_ZONE_TABLE).strip()
250
+ return {str(zone.get("id")) for zone in read(st).get("zones") or []
251
+ if isinstance(zone, dict) and zone.get("id")
252
+ and _zone_table_key(zone) == wanted}
253
+
254
+
255
  def _point_in_ring(lon, lat, ring):
256
  inside = False
257
  if len(ring) < 4:
 
980
  state["zones"] = [item for item in prior if not (
981
  isinstance(item, dict) and item.get("id") == zone_id
982
  and _zone_table_key(item) == table_key)]
983
+ # ⭐ D-599 — A DELETED ZONE TAKES ITS ROUTE ASSOCIATIONS WITH IT, in the SAME mutation.
984
+ # A route pointing at a zone that no longer exists would render as a blank selector that
985
+ # nothing explains, and the id would silently reappear in the wire. Detaching here rather
986
+ # than resolving leniently at every read means one place knows the rule.
987
+ # ⚠ IT DETACHES, IT NEVER DELETES A ROUTE. A zone is a grouping; a route is the work.
988
+ state["routes"] = [dict(item, zoneId=None)
989
+ if isinstance(item, dict) and item.get("zoneId") == zone_id else item
990
+ for item in (state.get("routes") or [])]
991
  return state, len(prior) != len(state["zones"])
992
 
993
  return bool(_persist(st, mutate))
 
1003
  prior = list(state.get("zones") or [])
1004
  state["zones"] = [item for item in prior if not (
1005
  isinstance(item, dict) and _zone_table_key(item) == table_key)]
1006
+ # D-599, the same rule as `delete_zone`: a zone that is gone leaves no route pointing at
1007
+ # it. Written here too rather than left to the single-zone door, because a database
1008
+ # deletion removes a whole family at once and is exactly when a dangling id would survive.
1009
+ gone = {str(item.get("id")) for item in prior
1010
+ if isinstance(item, dict) and _zone_table_key(item) == table_key}
1011
+ state["routes"] = [dict(item, zoneId=None)
1012
+ if isinstance(item, dict) and str(item.get("zoneId")) in gone else item
1013
+ for item in (state.get("routes") or [])]
1014
  return state, len(prior) - len(state["zones"])
1015
 
1016
  return int(_persist(st, mutate) or 0)
platform/core/schema_overlay.py CHANGED
@@ -366,3 +366,75 @@ def write(doc, st=None):
366
  type(doc).__name__, reason="the overlay document must be an object.")
367
  (st or _store()).put(STORE_KEY, doc)
368
  return doc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  type(doc).__name__, reason="the overlay document must be an object.")
367
  (st or _store()).put(STORE_KEY, doc)
368
  return doc
369
+
370
+
371
+ # =================================================================================================
372
+ # THE GRID SEAM — D-590 (wave 46 hotfix, 2026-08-30)
373
+ #
374
+ # ⛔ WHY THIS FUNCTION EXISTS AT ALL. Wave 46 shipped the overlay end to end — the store, the R12
375
+ # wall, the merge, `GET/PATCH /api/v1/admin/schema-overlay`, and the Manage Database panel — and
376
+ # then nothing on the GRID read ever called `merge()`. An admin hid `price_1`, the panel saved it,
377
+ # a reload showed it hidden, and the column was still on the grid. `schema_overlay` grepped ZERO
378
+ # in all five candidate read paths. So the last wire is this: ONE function, called by all three
379
+ # assemblies (`routes_customers.grid_assembly`, `routes_products.product_assembly`,
380
+ # `routes_tables.ut_assembly`), which are the only builders of a served field list.
381
+ #
382
+ # ⛔⛔ `st` IS REQUIRED AND `None` IS REFUSED, WHICH IS THE POINT OF THE SIGNATURE. `read()`'s own
383
+ # default resolves through `core.store`'s module default — tenant #0's repo under `hf`, `AIOS_TENANT`
384
+ # or a hardcoded `royal-imports` under `pg` — so a dropped handle here would be a SILENT
385
+ # CROSS-TENANT READ: one tenant's hides applied to another tenant's grid. Lane E's own words about
386
+ # that discipline on this path were "documented and ENFORCED BY NOTHING". A keyword-only argument
387
+ # with no default makes the omission a `TypeError` at the call site, and the explicit `None` check
388
+ # makes the other spelling of the same mistake a refusal rather than a 200 off the wrong document.
389
+ # The gate's static leg over the three route files is the second lock, not the only one.
390
+ #
391
+ # ⚠ A FAILED READ FAILS **OPEN**, DELIBERATELY, AND IT IS NOT THE ADMIN ROUTE'S POLARITY.
392
+ # `read()` resolves a store failure to `{}`, which here means "no hides" — a column the admin hid
393
+ # stays visible for that request. The admin route 503s on the same condition (leg 17) because
394
+ # serving the bare contract there reads as "my overlay was never saved" and costs re-done work.
395
+ # On the GRID the trade is the other way: refusing the whole table over a DISPLAY preference would
396
+ # take the product down for an outage that costs, at worst, a visible column. Stated because a
397
+ # polarity nobody wrote down is a polarity nobody can review.
398
+ #
399
+ # ⚠ AN ABSENT DATABASE KEY RETURNS THE CALLER'S OWN LIST, UNCOPIED AND UNSORTED. C1's "an absent
400
+ # key means inherit" has to be free: the overwhelming majority of requests carry no overlay for the
401
+ # database being read, and a merge that rebuilt every dict on every one of them would be a cost
402
+ # with no behaviour attached.
403
+ # =================================================================================================
404
+
405
+ def for_grid(database_key, fields, *, st, contract=None, doc=None):
406
+ """`(fields, removed)` — this tenant's overlay applied to an ASSEMBLED grid field list.
407
+
408
+ `database_key` is the key Manage Database writes under, which is `_perm_modules`' key: the
409
+ registry topic (`customer_data`, `product_data`) or the `ut_*` table key. A mismatch here is
410
+ the silent no-op this whole item exists to remove, so the assemblies pass the same constant
411
+ they already use as their permission topic.
412
+
413
+ `contract` is the CANONICAL field contract, used only to derive the locked set. It defaults to
414
+ the assembled list, but a caller that holds the canonical one should pass it: `locked_keys`
415
+ reads `derived`/`pinned`, and the admin panel derives its own locked set from the canonical
416
+ contract. If the two disagree, the panel reports a field locked while the grid honours a hide
417
+ of it — a screen contradicting itself about a join key.
418
+
419
+ `doc` lets a caller that already read the document this request reuse it. `core.store.get`
420
+ deep-copies on every call, so a second read is a second copy of the whole document.
421
+
422
+ `removed` is the set of keys the overlay took OUT of the list. The caller needs it because the
423
+ field list is not the only wire: `/workspace` serves `ws["overlays"]` raw, and a hidden
424
+ column's cells would still ride that dict. One narrowing cannot speak for a wire it never
425
+ touches — the sentence the perm wall already writes three times over the same dict.
426
+ """
427
+ if st is None:
428
+ raise SchemaOverlayUnsupported(
429
+ "st", reason="the grid read needs this tenant's own store handle; the default lands "
430
+ "on another tenant.")
431
+ if doc is None:
432
+ doc = read(st=st)
433
+ per_db = (doc or {}).get(database_key) if isinstance(doc, dict) else None
434
+ if not isinstance(per_db, dict) or not per_db:
435
+ return fields, frozenset()
436
+ before = [f.get("key") for f in fields if isinstance(f, dict)]
437
+ locked = locked_keys(database_key, contract if contract is not None else fields)
438
+ merged = merge(fields, per_db, database_key, locked=locked)
439
+ after = {f.get("key") for f in merged if isinstance(f, dict)}
440
+ return merged, frozenset(k for k in before if k not in after)
web/src/customer-grid/MapView.tsx CHANGED
@@ -3383,6 +3383,9 @@ export function MapView({
3383
  {mapNavigator === "routes" && (
3384
  <aside id="cg-route-popover" className="cg-route-popover cg-route-nav-panel cg-route-index" aria-label="Routes">
3385
  {navigatorTabs}
 
 
 
3386
  <RouteNav
3387
  routes={namedRoutes}
3388
  folders={routeFolders}
@@ -3416,6 +3419,7 @@ export function MapView({
3416
  mapLinkRefusal={activeRouteMapsRefusal}
3417
  deliveries={routeDeliveries}
3418
  assignees={routeAssignees?.people ?? null}
 
3419
  routeToday={routeAssignees?.today ?? null}
3420
  assigneeError={routeAssigneeError}
3421
  onSchedule={scheduleNamedRouteDelivery}
 
3383
  {mapNavigator === "routes" && (
3384
  <aside id="cg-route-popover" className="cg-route-popover cg-route-nav-panel cg-route-index" aria-label="Routes">
3385
  {navigatorTabs}
3386
+ {/* D-599 / W46-T22 - `zones` is the vocabulary a Route's Zone selector offers. It
3387
+ is already loaded here to draw the map, so RouteNav gets a pass-through and
3388
+ never a second fetch of its own. */}
3389
  <RouteNav
3390
  routes={namedRoutes}
3391
  folders={routeFolders}
 
3419
  mapLinkRefusal={activeRouteMapsRefusal}
3420
  deliveries={routeDeliveries}
3421
  assignees={routeAssignees?.people ?? null}
3422
+ zones={zones || []}
3423
  routeToday={routeAssignees?.today ?? null}
3424
  assigneeError={routeAssigneeError}
3425
  onSchedule={scheduleNamedRouteDelivery}
web/src/customer-grid/RouteNav.tsx CHANGED
@@ -11,7 +11,7 @@ import type { NormalizedRouteMapLink } from "./routeLinks";
11
  import { submitRouteStopMove } from "./routeStopMove";
12
  import { boundedGoogleMapsUrl } from "./routeZoneTypes";
13
  import type {
14
- MapRouteDto, MapRouteFolderDto, MapRouteSource, MapRouteUpdate,
15
  RouteAssignee, RouteDeliveryDto, RouteDeliveryRequest,
16
  } from "./routeZoneTypes";
17
  import "../styles/wave42/route-nav.css";
@@ -104,7 +104,7 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
104
  stopCoords = {},
105
  onFolderCreate, onFolderUpdate, onFolderDelete, onFolderReorder, filteredRecordCount,
106
  onSelectFiltered, onCreateStart, mapLinks, mapLinkRefusal, deliveries, onSchedule,
107
- onDeleteDelivery, assignees, routeToday, assigneeError }: {
108
  routes: MapRouteDto[];
109
  folders: MapRouteFolderDto[];
110
  selectedIds: ReadonlySet<string>;
@@ -152,6 +152,12 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
152
  assigneeError: string | null;
153
  onSchedule: (route: MapRouteDto, request: RouteDeliveryRequest) => Result;
154
  onDeleteDelivery: (route: MapRouteDto, delivery: RouteDeliveryDto) => Result;
 
 
 
 
 
 
155
  }) {
156
  const routePathKey = `aios-routes-at-${storageKey}`;
157
  const [at, setAt] = useState<string | null>(() => {
@@ -168,6 +174,8 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
168
  const [orderErrors, setOrderErrors] = useState<Record<number, string>>({});
169
  const [titleDraft, setTitleDraft] = useState<string | null>(null);
170
  const [editMapsUrl, setEditMapsUrl] = useState("");
 
 
171
  const [assignmentAssignee, setAssignmentAssignee] = useState("");
172
  const [assignmentDate, setAssignmentDate] = useState("");
173
  const [assignmentNotice, setAssignmentNotice] = useState<string | null>(null);
@@ -256,6 +264,7 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
256
  useEffect(() => {
257
  setTitleDraft(null);
258
  setEditMapsUrl(route?.mapsUrl || "");
 
259
  setOrderDrafts({});
260
  setOrderErrors({});
261
  setDeleteConfirm(false);
@@ -264,7 +273,7 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
264
  setDeliveryError(null);
265
  setMapCopyNotice(null);
266
  setMapCopyError(null);
267
- }, [route?.id, route?.mapsUrl, route?.name]);
268
  useEffect(() => {
269
  setAssignmentAssignee(route?.assignee || "");
270
  setAssignmentDate(route?.date || "");
@@ -1041,9 +1050,35 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
1041
  <input className="cg-input" type="url" value={editMapsUrl} maxLength={2048}
1042
  placeholder="https://www.google.com/maps/..." onChange={(event) => setEditMapsUrl(event.target.value)} />
1043
  </label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1044
  <div className="cg-form-actions">
1045
  <button type="button" className="cg-btn cg-btn--primary" disabled={busy}
1046
- onClick={() => finish(onUpdate(route, { mapsUrl: editMapsUrl.trim() }))}>
 
1047
  Save Route
1048
  </button>
1049
  <button type="button" className="cg-btn" disabled={busy} onClick={() => finish(onShare(route))}>Share</button>
 
11
  import { submitRouteStopMove } from "./routeStopMove";
12
  import { boundedGoogleMapsUrl } from "./routeZoneTypes";
13
  import type {
14
+ MapRouteDto, MapRouteFolderDto, MapRouteSource, MapRouteUpdate, MapZoneDto,
15
  RouteAssignee, RouteDeliveryDto, RouteDeliveryRequest,
16
  } from "./routeZoneTypes";
17
  import "../styles/wave42/route-nav.css";
 
104
  stopCoords = {},
105
  onFolderCreate, onFolderUpdate, onFolderDelete, onFolderReorder, filteredRecordCount,
106
  onSelectFiltered, onCreateStart, mapLinks, mapLinkRefusal, deliveries, onSchedule,
107
+ onDeleteDelivery, assignees, routeToday, assigneeError, zones = [] }: {
108
  routes: MapRouteDto[];
109
  folders: MapRouteFolderDto[];
110
  selectedIds: ReadonlySet<string>;
 
152
  assigneeError: string | null;
153
  onSchedule: (route: MapRouteDto, request: RouteDeliveryRequest) => Result;
154
  onDeleteDelivery: (route: MapRouteDto, delivery: RouteDeliveryDto) => Result;
155
+ /** D-599 / W46-T22 - the Zones this database has, so a Route can be put in one. The host
156
+ * already holds them to draw the map, so this is a pass-through and never a second fetch.
157
+ * ⚠ OPTIONAL with a `[]` default for the same reason `stopLabels` is: this component also
158
+ * mounts in a render harness with no host behind it. An empty list renders the selector
159
+ * disabled with a sentence, never a silently empty dropdown. */
160
+ zones?: MapZoneDto[];
161
  }) {
162
  const routePathKey = `aios-routes-at-${storageKey}`;
163
  const [at, setAt] = useState<string | null>(() => {
 
174
  const [orderErrors, setOrderErrors] = useState<Record<number, string>>({});
175
  const [titleDraft, setTitleDraft] = useState<string | null>(null);
176
  const [editMapsUrl, setEditMapsUrl] = useState("");
177
+ /** D-599 - the Route's Zone, as a draft, saved by the same Save Route button as the Maps URL. */
178
+ const [editZoneId, setEditZoneId] = useState("");
179
  const [assignmentAssignee, setAssignmentAssignee] = useState("");
180
  const [assignmentDate, setAssignmentDate] = useState("");
181
  const [assignmentNotice, setAssignmentNotice] = useState<string | null>(null);
 
264
  useEffect(() => {
265
  setTitleDraft(null);
266
  setEditMapsUrl(route?.mapsUrl || "");
267
+ setEditZoneId(route?.zoneId || "");
268
  setOrderDrafts({});
269
  setOrderErrors({});
270
  setDeleteConfirm(false);
 
273
  setDeliveryError(null);
274
  setMapCopyNotice(null);
275
  setMapCopyError(null);
276
+ }, [route?.id, route?.mapsUrl, route?.name, route?.zoneId]);
277
  useEffect(() => {
278
  setAssignmentAssignee(route?.assignee || "");
279
  setAssignmentDate(route?.date || "");
 
1050
  <input className="cg-input" type="url" value={editMapsUrl} maxLength={2048}
1051
  placeholder="https://www.google.com/maps/..." onChange={(event) => setEditMapsUrl(event.target.value)} />
1052
  </label>
1053
+ {/* ⭐⭐ D-599 / W46-T22 - THE ROUTE'S ZONE. Until wave 46's hotfix no route record
1054
+ carried a zone at all, so this control had nothing to write and did not exist:
1055
+ Routes and Zones were two separate tables and `__zone__` was a field on a CUSTOMER
1056
+ row. It saves through the same Save Route button as the Maps URL beside it,
1057
+ because both are properties of the Route and two save buttons on one form is how
1058
+ a user loses the edit they did not press.
1059
+ ⚠ THE UNAVAILABLE ARM IS DELIBERATE. A Route can hold a zone this reader cannot
1060
+ currently see; rendering the raw id as a disabled option says so, where dropping
1061
+ it would silently clear the field on the next save. */}
1062
+ <label className="cg-w44-route-label">Zone
1063
+ <select className="cg-input" value={editZoneId} disabled={busy}
1064
+ onChange={(event) => setEditZoneId(event.target.value)}>
1065
+ <option value="">No zone</option>
1066
+ {editZoneId && !zones.some((zone) => zone.id === editZoneId) && (
1067
+ <option value={editZoneId} disabled>{editZoneId} (unavailable)</option>
1068
+ )}
1069
+ {zones.map((zone) => (
1070
+ <option key={zone.id} value={zone.id}>{zone.name}</option>
1071
+ ))}
1072
+ </select>
1073
+ </label>
1074
+ {!zones.length && (
1075
+ <span className="cg-w44-route-empty">Draw a Zone on the map first, then a Route
1076
+ can belong to it.</span>
1077
+ )}
1078
  <div className="cg-form-actions">
1079
  <button type="button" className="cg-btn cg-btn--primary" disabled={busy}
1080
+ onClick={() => finish(onUpdate(route, { mapsUrl: editMapsUrl.trim(),
1081
+ zoneId: editZoneId || null }))}>
1082
  Save Route
1083
  </button>
1084
  <button type="button" className="cg-btn" disabled={busy} onClick={() => finish(onShare(route))}>Share</button>
web/src/customer-grid/routeZoneTypes.ts CHANGED
@@ -70,6 +70,9 @@ export interface MapRouteDto {
70
  navOrder: number;
71
  assignee: string | null;
72
  date: string | null;
 
 
 
73
  starred?: boolean;
74
  capabilities?: Partial<Record<"rename" | "duplicate" | "star" | "share" | "delete", boolean>>;
75
  }
@@ -87,6 +90,9 @@ export type MapRouteUpdate = {
87
  starred?: boolean;
88
  assignee?: string | null;
89
  date?: string | null;
 
 
 
90
  };
91
 
92
  export interface RouteSelectionRequest { routeIds: string[]; viewState: Record<string, unknown>; }
 
70
  navOrder: number;
71
  assignee: string | null;
72
  date: string | null;
73
+ /** D-599: the Zone this Route belongs to, or null. Always present on the wire; every Route
74
+ * saved before wave 46's hotfix legitimately has none, so null is data and not an error. */
75
+ zoneId: string | null;
76
  starred?: boolean;
77
  capabilities?: Partial<Record<"rename" | "duplicate" | "star" | "share" | "delete", boolean>>;
78
  }
 
90
  starred?: boolean;
91
  assignee?: string | null;
92
  date?: string | null;
93
+ /** D-599. Absent inherits the stored Zone; an explicit null clears it. The server refuses an
94
+ * id no Zone on this database carries, with `unknown_zone`. */
95
+ zoneId?: string | null;
96
  };
97
 
98
  export interface RouteSelectionRequest { routeIds: string[]; viewState: Record<string, unknown>; }
web/src/styles/wave45/data-applications.css CHANGED
@@ -138,14 +138,11 @@
138
  .cg-history-list { display:grid; gap:8px; padding:0; list-style:none; }
139
  .cg-history-list li { display:grid; grid-template-columns:1fr auto; gap:4px 10px; padding:10px; border:1px solid var(--lp-line); border-radius:8px; }
140
  @media (max-width:1050px) { .cg-workspace-drawer { width:min(330px,48vw); } .cg-drawer-launchers .cg-btn { padding-inline:8px; } }
141
- .cg-application-rail { flex:0 0 256px; width:256px; min-width:0; overflow:auto; padding:14px 12px; box-sizing:border-box; background:var(--lp-surface); border-left:1px solid var(--lp-line); border-right:1px solid var(--lp-line); }
142
- .cg-application-rail header { display:flex; align-items:center; justify-content:space-between; }
143
- .cg-application-context { color:var(--lp-ink-muted); font-size:var(--lp-fs-3xs); line-height:1.45; }
144
- .cg-application-list { display:grid; gap:8px; }
145
- .cg-application-card { border:1px solid var(--lp-line); border-radius:9px; padding:8px; background:var(--lp-surface); }
146
- .cg-application-open { display:grid; width:100%; gap:2px; padding:2px; border:0; background:none; color:inherit; font:inherit; text-align:left; cursor:pointer; }
147
- .cg-application-open small { color:var(--lp-ink-muted); text-transform:capitalize; }
148
- .cg-application-actions { display:flex; align-items:center; flex-wrap:wrap; gap:5px; margin-top:7px; }
149
  /* W45-T14/C6: one folder, one meaning. Legacy shape/tone metadata never changes this glyph. */
150
  .cg-folder-mark path { fill:var(--lp-purple-deep); stroke:var(--lp-purple-deep); }
151
  .home-app-glyph { background:var(--lp-primary); color:#fff; font-weight:700; }
 
138
  .cg-history-list { display:grid; gap:8px; padding:0; list-style:none; }
139
  .cg-history-list li { display:grid; grid-template-columns:1fr auto; gap:4px 10px; padding:10px; border:1px solid var(--lp-line); border-radius:8px; }
140
  @media (max-width:1050px) { .cg-workspace-drawer { width:min(330px,48vw); } .cg-drawer-launchers .cg-btn { padding-inline:8px; } }
141
+ /* D-602 / W46-T10 (wave 46 hotfix, 2026-08-30) - the Applications RAIL's six rules are
142
+ deleted here. The rail itself was removed in wave 46 and its stylesheet outlived it:
143
+ `.cg-application-rail`, `-context`, `-list`, `-card`, `-open` and `-actions` matched
144
+ nothing in `src/` and nothing on the deployed build (0 `.cg-application-rail` nodes,
145
+ 0 "Applications" text nodes). The rest of this sheet is live and untouched. */
 
 
 
146
  /* W45-T14/C6: one folder, one meaning. Legacy shape/tone metadata never changes this glyph. */
147
  .cg-folder-mark path { fill:var(--lp-purple-deep); stroke:var(--lp-purple-deep); }
148
  .home-app-glyph { background:var(--lp-primary); color:#fff; font-weight:700; }