fsanyoto commited on
Commit
bf6f7b2
·
verified ·
1 Parent(s): 4bda856

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "1e8b01be",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "29e88d035",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- 1e8b01be
 
1
+ 29e88d035
api/assistant_mirror.py CHANGED
@@ -98,7 +98,57 @@ NO_BINDING = ("this database is read live from its connector mirror, and this de
98
  "read-through binding for it yet, so it holds no rows the assistant can read")
99
 
100
 
101
- def unavailable_reason(table_key, definition=None):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  """The ONE sentence `list_databases` and `query_database` both give when the mirror holds no rows.
103
 
104
  A bound table whose mirror tables are absent is loading (a restart starts from the boot seed);
@@ -110,7 +160,7 @@ def unavailable_reason(table_key, definition=None):
110
  import amazon_relational as amazon
111
  if key in amazon.SOURCE:
112
  return amazon.missing_source(key)["missing"]
113
- spec = _rot()._sources().get(key)
114
  if spec and not spec.get("missing"):
115
  label = str((definition or {}).get("label") or key)
116
  return (f"{label} is still loading into this server after a restart, "
@@ -120,29 +170,32 @@ def unavailable_reason(table_key, definition=None):
120
  return NO_BINDING
121
 
122
 
123
- def still_loading(table_key):
124
  """True while an Odoo table behind this binding is in its first backfill, so its rows are partial.
125
 
126
  Evidence only: a `_sync_state` phase other than live, or an empty table with no state row yet
127
  (created, first batch not written). A mirror with no sync bookkeeping is not loading.
128
  """
129
  from harness import datastore
 
130
  try:
131
- spec = _rot()._sources().get(str(table_key or "")) or {}
 
132
  names = set((spec.get("tables") or {}).values()) | ({spec["table"]} if spec.get("table") else set())
133
- cur = datastore.ro_cursor()
134
- try:
135
- for name in sorted(n for n in names if n in datastore.ENTITIES):
136
- row = cur.execute("SELECT phase FROM _sync_state WHERE entity = ?", [name]).fetchone()
137
- if row is not None and row[0] != "live":
138
- return True
139
- if row is None and not cur.execute(f"SELECT count(*) FROM (SELECT 1 FROM {name} LIMIT 1)").fetchone()[0]:
140
- return True
141
- finally:
142
- cur.close()
143
  except Exception: # noqa: BLE001
144
  return False
145
- return False
 
 
 
 
 
146
 
147
 
148
  def binding(cur, table_key):
@@ -159,7 +212,7 @@ def binding(cur, table_key):
159
  return None
160
 
161
 
162
- def is_bound(cur, table_key):
163
  """CAN this deployment read `table_key` through the mirror at all? The availability question.
164
 
165
  ⭐⭐ THE CHEAP PREFIX OF `_source_for`, AND IT IS HERE BECAUSE THE FULL CALL COSTS 300 ms.
@@ -186,12 +239,16 @@ def is_bound(cur, table_key):
186
  try:
187
  rot = _rot()
188
  key = str(table_key or "")
189
- spec = rot._sources().get(key)
190
  if not spec and key.startswith("ut_amzn_"):
191
  # S67-T33: a registry built before the Amazon mirror loaded holds no Amazon key.
192
  # `_source_for` and `_materialised_table` both learn them on demand; so must this.
193
- rot._learn_amazon_sources()
194
- spec = rot.GRID_SOURCES.get(key)
 
 
 
 
195
  if not spec:
196
  # A dynamically sized Amazon snapshot is admitted per key by the grid door, not by
197
  # the provider build, so the registry can lack a key the grid serves (measured on
@@ -208,7 +265,8 @@ def is_bound(cur, table_key):
208
  aliases = dict(spec.get("tables") or {})
209
  if spec.get("table"):
210
  aliases.setdefault("", spec["table"])
211
- return all(datastore.columns_of(name, cur=cur) for name in aliases.values())
 
212
  except Exception: # noqa: BLE001
213
  return False
214
 
 
98
  "read-through binding for it yet, so it holds no rows the assistant can read")
99
 
100
 
101
+ class ReadinessSnapshot:
102
+ """Reuse mirror metadata within one source listing, without caching permissions or row access."""
103
+
104
+ def __init__(self):
105
+ self._sources = None
106
+ self._columns = {}
107
+ self._phases = {}
108
+ self._loading = {}
109
+ self._amazon_learned = False
110
+
111
+ def source(self, key):
112
+ if self._sources is None:
113
+ self._sources = dict(_rot()._sources())
114
+ return self._sources.get(key)
115
+
116
+ def learn_amazon(self, cur):
117
+ if not self._amazon_learned:
118
+ self._amazon_learned = True
119
+ rot = _rot()
120
+ rot._learn_amazon_sources(cur)
121
+ self._sources = dict(rot.GRID_SOURCES)
122
+
123
+ def columns(self, cur, name):
124
+ from harness import datastore
125
+ key = (id(cur), name)
126
+ if key not in self._columns:
127
+ self._columns[key] = datastore.columns_of(name, cur=cur)
128
+ return self._columns[key]
129
+
130
+ def loading(self, cur, name):
131
+ key = (id(cur), name)
132
+ if key not in self._loading:
133
+ cursor_id = id(cur)
134
+ if cursor_id not in self._phases:
135
+ try:
136
+ phases = dict(cur.execute("SELECT entity, phase FROM _sync_state").fetchall())
137
+ except Exception: # noqa: BLE001
138
+ phases = None
139
+ self._phases[cursor_id] = phases
140
+ phases = self._phases[cursor_id]
141
+ if phases is None:
142
+ return False # Mirrors without sync bookkeeping retain standalone semantics.
143
+ if name in phases:
144
+ self._loading[key] = phases[name] != "live"
145
+ else:
146
+ self._loading[key] = not cur.execute(
147
+ f"SELECT count(*) FROM (SELECT 1 FROM {name} LIMIT 1)").fetchone()[0]
148
+ return self._loading[key]
149
+
150
+
151
+ def unavailable_reason(table_key, definition=None, *, snapshot=None):
152
  """The ONE sentence `list_databases` and `query_database` both give when the mirror holds no rows.
153
 
154
  A bound table whose mirror tables are absent is loading (a restart starts from the boot seed);
 
160
  import amazon_relational as amazon
161
  if key in amazon.SOURCE:
162
  return amazon.missing_source(key)["missing"]
163
+ spec = snapshot.source(key) if snapshot is not None else _rot()._sources().get(key)
164
  if spec and not spec.get("missing"):
165
  label = str((definition or {}).get("label") or key)
166
  return (f"{label} is still loading into this server after a restart, "
 
170
  return NO_BINDING
171
 
172
 
173
+ def still_loading(table_key, *, cur=None, snapshot=None):
174
  """True while an Odoo table behind this binding is in its first backfill, so its rows are partial.
175
 
176
  Evidence only: a `_sync_state` phase other than live, or an empty table with no state row yet
177
  (created, first batch not written). A mirror with no sync bookkeeping is not loading.
178
  """
179
  from harness import datastore
180
+ owned_cur = None
181
  try:
182
+ snapshot = snapshot if snapshot is not None else ReadinessSnapshot()
183
+ spec = snapshot.source(str(table_key or "")) or {}
184
  names = set((spec.get("tables") or {}).values()) | ({spec["table"]} if spec.get("table") else set())
185
+ names = sorted(n for n in names if n in datastore.ENTITIES)
186
+ if not names:
187
+ return False
188
+ if cur is None:
189
+ owned_cur = cur = datastore.ro_cursor()
190
+ return any(snapshot.loading(cur, name) for name in names)
 
 
 
 
191
  except Exception: # noqa: BLE001
192
  return False
193
+ finally:
194
+ if owned_cur is not None:
195
+ try:
196
+ owned_cur.close()
197
+ except Exception: # noqa: BLE001
198
+ pass
199
 
200
 
201
  def binding(cur, table_key):
 
212
  return None
213
 
214
 
215
+ def is_bound(cur, table_key, *, snapshot=None):
216
  """CAN this deployment read `table_key` through the mirror at all? The availability question.
217
 
218
  ⭐⭐ THE CHEAP PREFIX OF `_source_for`, AND IT IS HERE BECAUSE THE FULL CALL COSTS 300 ms.
 
239
  try:
240
  rot = _rot()
241
  key = str(table_key or "")
242
+ spec = snapshot.source(key) if snapshot is not None else rot._sources().get(key)
243
  if not spec and key.startswith("ut_amzn_"):
244
  # S67-T33: a registry built before the Amazon mirror loaded holds no Amazon key.
245
  # `_source_for` and `_materialised_table` both learn them on demand; so must this.
246
+ if snapshot is not None:
247
+ snapshot.learn_amazon(cur)
248
+ spec = snapshot.source(key)
249
+ else:
250
+ rot._learn_amazon_sources()
251
+ spec = rot.GRID_SOURCES.get(key)
252
  if not spec:
253
  # A dynamically sized Amazon snapshot is admitted per key by the grid door, not by
254
  # the provider build, so the registry can lack a key the grid serves (measured on
 
265
  aliases = dict(spec.get("tables") or {})
266
  if spec.get("table"):
267
  aliases.setdefault("", spec["table"])
268
+ return all(snapshot.columns(cur, name) if snapshot is not None
269
+ else datastore.columns_of(name, cur=cur) for name in aliases.values())
270
  except Exception: # noqa: BLE001
271
  return False
272
 
api/deps.py CHANGED
@@ -1099,10 +1099,13 @@ def assistant_source_status(session: Session, databases=None):
1099
  what they hold.
1100
  """
1101
  import core.perm_scope as perm_scope
 
1102
  from core import user_tables
1103
 
 
1104
  definitions = None
1105
  read_definitions = False
 
1106
  mirror_cur = None
1107
  read_mirror = False
1108
 
@@ -1244,7 +1247,8 @@ def assistant_source_status(session: Session, databases=None):
1244
  definition = (defs or {}).get(key)
1245
  if not isinstance(definition, dict):
1246
  continue
1247
- lent = user_tables.lend(session.runtime, user_tables=defs)
 
1248
  # ⭐ S67-T33 / R33: the NAV's predicate, so this list and the navigation are one set.
1249
  if not _assistant_nav_opens(session, key, lent, definition):
1250
  continue
@@ -1289,14 +1293,14 @@ def assistant_source_status(session: Session, databases=None):
1289
  # batch, which is called on mount by both the Assistant and Query. See `is_bound`.
1290
  try:
1291
  import assistant_mirror
1292
- bound = assistant_mirror.is_bound(cur, key)
1293
  except Exception: # noqa: BLE001
1294
  bound = False
1295
  import assistant_mirror
1296
- if bound and not assistant_mirror.still_loading(key):
1297
  row["answerable"] = True
1298
  else:
1299
- row["reason"] = assistant_mirror.unavailable_reason(key, definition)
1300
  return out
1301
 
1302
 
 
1099
  what they hold.
1100
  """
1101
  import core.perm_scope as perm_scope
1102
+ import assistant_mirror
1103
  from core import user_tables
1104
 
1105
+ readiness = assistant_mirror.ReadinessSnapshot()
1106
  definitions = None
1107
  read_definitions = False
1108
+ lent = None
1109
  mirror_cur = None
1110
  read_mirror = False
1111
 
 
1247
  definition = (defs or {}).get(key)
1248
  if not isinstance(definition, dict):
1249
  continue
1250
+ if lent is None:
1251
+ lent = user_tables.lend(session.runtime, user_tables=defs)
1252
  # ⭐ S67-T33 / R33: the NAV's predicate, so this list and the navigation are one set.
1253
  if not _assistant_nav_opens(session, key, lent, definition):
1254
  continue
 
1293
  # batch, which is called on mount by both the Assistant and Query. See `is_bound`.
1294
  try:
1295
  import assistant_mirror
1296
+ bound = assistant_mirror.is_bound(cur, key, snapshot=readiness)
1297
  except Exception: # noqa: BLE001
1298
  bound = False
1299
  import assistant_mirror
1300
+ if bound and not assistant_mirror.still_loading(key, cur=cur, snapshot=readiness):
1301
  row["answerable"] = True
1302
  else:
1303
+ row["reason"] = assistant_mirror.unavailable_reason(key, definition, snapshot=readiness)
1304
  return out
1305
 
1306
 
platform/harness/filter_eval.py CHANGED
@@ -340,12 +340,16 @@ def _match_filter(rule, row, columns, today):
340
  # below ends in a blank-value short-circuit and these leaves carry a blank `value`; one
341
  # fall-through and a permission wall reading `Agent is any of [...]` admits every row.
342
  if op in MULTI_VALUE_OPS:
343
- # Numeric and date columns REFUSE, matching the other two engines exactly: `_cmp_num`'s
344
- # documented `default: True` would widen, and comparing a number against its own string
345
- # form would make the three engines disagree about a rendering rather than a value.
346
- if ftype in NUMERIC_TYPES or ftype in DATE_TYPES:
347
  return False
348
- return _match_multi_value(op, raw, parse_filter_values(rule.get('values')))
 
 
 
 
 
 
 
349
 
350
  rhs = rule.get('rhs')
351
  has_rhs = rhs is not None
 
340
  # below ends in a blank-value short-circuit and these leaves carry a blank `value`; one
341
  # fall-through and a permission wall reading `Agent is any of [...]` admits every row.
342
  if op in MULTI_VALUE_OPS:
343
+ if ftype in DATE_TYPES:
 
 
 
344
  return False
345
+ values = parse_filter_values(rule.get('values'))
346
+ if ftype in NUMERIC_TYPES:
347
+ if op not in ('isAnyOf', 'isNoneOf') or not values:
348
+ return False
349
+ number = to_num(raw)
350
+ hit = any(_cmp_num('eq', number, to_num(value)) for value in values)
351
+ return hit if op == 'isAnyOf' else not hit
352
+ return _match_multi_value(op, raw, values)
353
 
354
  rhs = rule.get('rhs')
355
  has_rhs = rhs is not None
platform/harness/filter_sql.py CHANGED
@@ -561,27 +561,28 @@ def _compile_multi_value(op, v, t, rule, used):
561
  makes ``contains`` find *Done* inside *Not done*, and removing that is half of why these
562
  operators exist. ``hasAllOf`` is the AND of the memberships, per the ticket's `how` line.
563
 
564
- BLANKS, decided once for all three engines: a blank cell has NO members and equals no listed
565
  value, so ``isNoneOf`` / ``hasNoneOf`` answer TRUE over it and the other three answer FALSE.
566
  ``str_split('', ',')`` yields one empty member, which ``list_contains`` never matches because
567
  `parse_filter_values` drops empty values.
568
 
569
- NUMERIC and DATE columns REFUSE (``1=0``, matches nothing) rather than compare. They do not
570
- offer these operators, but a saved view whose column later changed type can carry one, and
571
- the alternatives are both wrong: SQL_TRUE would widen exactly as the client's documented
572
- ``default: true`` would, and stringifying the number would compare against a RENDERING the
573
- three engines do not spell the same way.
574
 
575
  Every value is BOUND, never interpolated: these strings are tenant prose.
576
  """
577
- if t in NUMERIC_TYPES or t in ('date', 'created_time'):
578
  return ('1=0', [])
579
  vals = parse_filter_values(rule.get('values'))
580
  if not vals:
581
  # Unreachable: `is_rule_active` already demanded a non-empty list. Never SQL_TRUE.
582
  return ('1=0', [])
583
  if op in ('isAnyOf', 'isNoneOf'):
584
- union = '(' + ' OR '.join(f"({v} = LOWER(?))" for _ in vals) + ')'
 
 
 
 
585
  return used((f"(NOT {union})" if op == 'isNoneOf' else union), vals)
586
  members = f"list_transform(str_split({v}, ','), x -> trim(x))"
587
  parts = [f"list_contains({members}, TRIM(LOWER(?)))" for _ in vals]
 
561
  makes ``contains`` find *Done* inside *Not done*, and removing that is half of why these
562
  operators exist. ``hasAllOf`` is the AND of the memberships, per the ticket's `how` line.
563
 
564
+ TEXT BLANKS, decided once for all three engines: a blank cell has NO members and equals no listed
565
  value, so ``isNoneOf`` / ``hasNoneOf`` answer TRUE over it and the other three answer FALSE.
566
  ``str_split('', ',')`` yields one empty member, which ``list_contains`` never matches because
567
  `parse_filter_values` drops empty values.
568
 
569
+ Numeric any/none use numeric eq's rounded expression, comparand coercion and null-to-zero rule.
570
+ Date multi-value and numeric has* still refuse rather than widen.
 
 
 
571
 
572
  Every value is BOUND, never interpolated: these strings are tenant prose.
573
  """
574
+ if t in ('date', 'created_time') or (t in NUMERIC_TYPES and op not in ('isAnyOf', 'isNoneOf')):
575
  return ('1=0', [])
576
  vals = parse_filter_values(rule.get('values'))
577
  if not vals:
578
  # Unreachable: `is_rule_active` already demanded a non-empty list. Never SQL_TRUE.
579
  return ('1=0', [])
580
  if op in ('isAnyOf', 'isNoneOf'):
581
+ numeric = t in NUMERIC_TYPES
582
+ comparison = f"({v} = ?)" if numeric else f"({v} = LOWER(?))"
583
+ union = '(' + ' OR '.join(comparison for _ in vals) + ')'
584
+ if numeric:
585
+ vals = [to_num(value) for value in vals]
586
  return used((f"(NOT {union})" if op == 'isNoneOf' else union), vals)
587
  members = f"list_transform(str_split({v}, ','), x -> trim(x))"
588
  parts = [f"list_contains({members}, TRIM(LOWER(?)))" for _ in vals]
platform/modules/sheet.py CHANGED
@@ -862,11 +862,7 @@ def rewrite_linked_filters(nodes, resolve):
862
 
863
 
864
  def linked_id_predicate(column, ids):
865
- """Membership using existing numeric equality, with no ID cap or deep SQL OR chain.
866
-
867
- isAnyOf deliberately refuses numeric columns in filter_sql. Balanced groups of eq leaves
868
- express the same membership without changing that pure compiler or truncating its values.
869
- """
870
  values = sorted({int(pid) for pid in ids})
871
 
872
  def tree(lo, hi):
 
862
 
863
 
864
  def linked_id_predicate(column, ids):
865
+ """Preserve every linked ID through balanced numeric eq groups, with an explicit false empty set."""
 
 
 
 
866
  values = sorted({int(pid) for pid in ids})
867
 
868
  def tree(lo, hi):
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 25a1fa4133a390c1d2553844c3a77f32f5464ee841ece6ef7a95439087734a2d
 
1
+ df6f89a9f0a417b3202edd1183e83b5926afecdad1c426801a1f3e9937aa3a2c
web/src/customer-grid/useVisibleRows.ts CHANGED
@@ -166,13 +166,15 @@ function matchFilter(
166
  // short-circuit. Falling through even one of them would make `Agent is any of [A, B, C]`
167
  // match every row under a count nobody would doubt.
168
  if (MULTI_VALUE_OPS.has(rule.op as FilterOp)) {
169
- // A numeric or date column does not OFFER these, but a stale saved view can carry one (a
170
- // column that has since changed type). Matching NOTHING is the decision, in all three
171
- // engines: `cmpNum`'s documented `default: true` would widen, and comparing a rounded
172
- // number against its own string form would have the engines disagree about the RENDERING
173
- // rather than the value (`String(5000)`, `str(5000)` and DuckDB's CAST do not agree).
174
- if (isNumericType(f.type) || isDateType(f.type)) return false;
175
- return matchMultiValue(rule.op, raw, filterValues(rule.values));
 
 
176
  }
177
 
178
  // --- CG-9: the comparand is another CELL of this row, not a typed value ----------------
 
166
  // short-circuit. Falling through even one of them would make `Agent is any of [A, B, C]`
167
  // match every row under a count nobody would doubt.
168
  if (MULTI_VALUE_OPS.has(rule.op as FilterOp)) {
169
+ if (isDateType(f.type)) return false;
170
+ const values = filterValues(rule.values);
171
+ if (isNumericType(f.type)) {
172
+ if ((rule.op !== "isAnyOf" && rule.op !== "isNoneOf") || !values.length) return false;
173
+ const number = toNum(raw);
174
+ const hit = values.some((value) => cmpNum("eq", number, toNum(value)));
175
+ return rule.op === "isAnyOf" ? hit : !hit;
176
+ }
177
+ return matchMultiValue(rule.op, raw, values);
178
  }
179
 
180
  // --- CG-9: the comparand is another CELL of this row, not a typed value ----------------