fsanyoto commited on
Commit
87481c4
·
verified ·
1 Parent(s): 23f07cc

Deploy Data Management Platform (rename + sales forecast removed)

Browse files
aios_grid_component/index.html CHANGED
The diff for this file is too large to render. See raw diff
 
aios_grid_embed.html CHANGED
The diff for this file is too large to render. See raw diff
 
app.py CHANGED
@@ -5284,6 +5284,17 @@ def _cl_resolve_measures(views, pending_view, team_id, allowed_pids, stamp):
5284
  repr(sorted(allowed_pids)).encode(), digest_size=8).hexdigest()
5285
  out = {}
5286
  for rule in rules:
 
 
 
 
 
 
 
 
 
 
 
5287
  key = (stamp, team_id, pool_key, _mf.signature(rule))
5288
  if key not in memo:
5289
  try:
 
5284
  repr(sorted(allowed_pids)).encode(), digest_size=8).hexdigest()
5285
  out = {}
5286
  for rule in rules:
5287
+ # ⚠ THE COLD-CONTAINER BELT (2026-07-27). A rule the component is still editing — or a
5288
+ # view-state echo that momentarily lost its rhs — is a question not yet fully asked.
5289
+ # Resolving it would mint an answer to a DIFFERENT question (`to_num(None)` is 0 by the
5290
+ # engines' shared contract, so a valueless `Sales > …` became `Sales > 0`), and the id
5291
+ # landing in the payload is what CLEARS the client's pending marker — a wrong set under
5292
+ # a count nobody would doubt. Skipped SILENTLY: mid-edit is a normal state, not a
5293
+ # telemetry event; the id stays out and the client says "Calculating…" until the full
5294
+ # rhs arrives on a later run. `resolve_rule` also refuses these (fail-closed for every
5295
+ # other caller); the predicate here just keeps the normal transient quiet.
5296
+ if not _mf.rule_complete(rule):
5297
+ continue
5298
  key = (stamp, team_id, pool_key, _mf.signature(rule))
5299
  if key not in memo:
5300
  try:
harness/measure_filter.py CHANGED
@@ -379,6 +379,39 @@ def _pool_of(allowed_pids):
379
  return None if allowed_pids is None else {int(p) for p in allowed_pids if p is not None}
380
 
381
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  def resolve_rule(rule, today, team_id=None, allowed_pids=None):
383
  """One measure condition -> the SET OF CUSTOMER IDS satisfying it.
384
 
@@ -392,6 +425,13 @@ def resolve_rule(rule, today, team_id=None, allowed_pids=None):
392
  "who has gone quiet" filter is FOR. So the caller passes `allowed_pids` (the pool) and the
393
  zero-group is reconstructed explicitly below rather than left to the SQL.
394
  """
 
 
 
 
 
 
 
395
  rhs = rule.get('rhs')
396
  if isinstance(rhs, dict) and rhs.get('kind') == 'measure':
397
  return resolve_pair(rule, today, team_id, allowed_pids)
 
379
  return None if allowed_pids is None else {int(p) for p in allowed_pids if p is not None}
380
 
381
 
382
+ def rule_complete(rule):
383
+ """Is this rule's right-hand side FULLY present — a question that has actually been asked?
384
+
385
+ THE GAP THIS CLOSES (2026-07-27, the cold-container race). The component's view state
386
+ passes through the host while the user — or the client's own initialisation — is mid-edit,
387
+ and a rule can transiently arrive with its window, statistic or value missing. `to_num(None)`
388
+ is 0 by the engines' shared contract, so resolution used to ANSWER that half-asked question
389
+ as `<op> 0`: the id landed in `measureSets`, the client read the rule as answered and
390
+ cleared its pending marker, and the grid stood behind a count for a question nobody asked.
391
+ Refusing instead leaves the id OUT of the payload, which the client renders as PENDING
392
+ ("Calculating…") — the honest state for a question still being typed. Exactly the class the
393
+ module docstring already names: an unresolvable condition never becomes an answer.
394
+
395
+ INCOMPLETE is distinct from MALFORMED, on purpose. An ABSENT window / stat / value is a
396
+ normal transient (the caller skips it silently — mid-edit is not a telemetry event); a
397
+ PRESENT-but-bogus one is a real defect and still RAISES downstream (`unresolvable window`,
398
+ `not a statistic`, `not admitted`). `value` presence is textual, not numeric: "0" is a
399
+ typed answer, while parseability stays `to_num`'s business so the two engines keep one
400
+ contract for garbage input.
401
+ """
402
+ if not isinstance(rule, dict) or not rule.get('op'):
403
+ return False
404
+ if rule.get('window') is None:
405
+ return False
406
+ rhs = rule.get('rhs')
407
+ if isinstance(rhs, dict) and rhs.get('kind') == 'measure':
408
+ return bool(rhs.get('colId')) and rhs.get('window') is not None
409
+ if isinstance(rhs, dict) and rhs.get('kind') == 'stat':
410
+ return bool(rhs.get('stat'))
411
+ v = rule.get('value')
412
+ return v is not None and str(v).strip() != ''
413
+
414
+
415
  def resolve_rule(rule, today, team_id=None, allowed_pids=None):
416
  """One measure condition -> the SET OF CUSTOMER IDS satisfying it.
417
 
 
425
  "who has gone quiet" filter is FOR. So the caller passes `allowed_pids` (the pool) and the
426
  zero-group is reconstructed explicitly below rather than left to the SQL.
427
  """
428
+ if not rule_complete(rule):
429
+ # An absent value would coerce to 0 and resolve as a DIFFERENT question under an
430
+ # authoritative-looking count — the same failure class as defaulting a missing window
431
+ # to all time, caught by the same principle: refuse, never guess.
432
+ raise _sem.ModelError(
433
+ 'incomplete measure condition — its window, statistic or value is not present; '
434
+ 'refusing to answer a question that has not been fully asked')
435
  rhs = rule.get('rhs')
436
  if isinstance(rhs, dict) and rhs.get('kind') == 'measure':
437
  return resolve_pair(rule, today, team_id, allowed_pids)