fsanyoto commited on
Commit
07ca850
Β·
verified Β·
1 Parent(s): 1d3d42c

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "aaa78f5201",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "6db84bf9e82",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- aaa78f5201
 
1
+ 6db84bf9e82
api/main.py CHANGED
@@ -1485,7 +1485,8 @@ def _sweep_automation_schemas(why):
1485
 
1486
 
1487
  def _rebuild_odoo_relational(why, previous_meta_fingerprint=None, meta_state_out=None, *,
1488
- tenant=None, cadence_seconds=None, table_keys=None):
 
1489
  """Spawn/refresh the four locked Odoo databases, then compute their cells. `why` is 'boot' or
1490
  'resync' and rides every log line, because "it failed" and "it failed at boot, before anyone
1491
  could have asked" are different diagnoses.
@@ -1545,7 +1546,8 @@ def _rebuild_odoo_relational(why, previous_meta_fingerprint=None, meta_state_out
1545
  # Only the designated default owns this mirror. A selection must never be lent to
1546
  # another connection; the full recovery path still refreshes every connection.
1547
  counts = _rel.refresh(_rt, tenant_key, all_connections=table_keys is None,
1548
- **({"table_keys": table_keys} if table_keys is not None else {}))
 
1549
  if table_keys is None:
1550
  raw_models, schema_errors = _rel.authoritative_schema_snapshot()
1551
  _ut.record_odoo_schema_snapshot(raw_models, complete=not schema_errors,
@@ -2310,6 +2312,27 @@ def _resync_confirm_fresh(tenant, cadence_seconds):
2310
  print(f"[aios-api] odoo freshness stamp not saved ({type(e).__name__}: {e})")
2311
 
2312
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2313
  def _store_resync_loop():
2314
  """Keep the analytical mirror current β€” the API-process stand-in for the re-sync the
2315
  Streamlit app piggybacks on page renders. Measure memos key on the pool stamp, so a
@@ -2509,6 +2532,10 @@ def _store_resync_loop():
2509
  f"next scheduled pass is due in {max(0, _every - _age)}s")
2510
  last_full_pass_at = last_good_pass_at
2511
  continue
 
 
 
 
2512
  # ⭐ WAVE 27 item 17 (E's ASK ->A, resolved): whenever the Odoo RELATIONAL tables need
2513
  # refreshing, they run AFTER the mirror they derive from. A confirmed zero-change report
2514
  # is the W39 exception; deriving before a changed mirror advances would publish a one-cycle
@@ -2620,6 +2647,8 @@ def _store_resync_loop():
2620
  if _rebuild_variadic or "tenant" in _rebuild_params else {})
2621
  if _rebuild_variadic or "table_keys" in _rebuild_params:
2622
  _rebuild_scope["table_keys"] = _table_keys
 
 
2623
  if _rebuild_odoo_relational(
2624
  "resync", _meta_previous, _meta_state, **_rebuild_scope):
2625
  last_source_fingerprints = source_fingerprints or None
 
1485
 
1486
 
1487
  def _rebuild_odoo_relational(why, previous_meta_fingerprint=None, meta_state_out=None, *,
1488
+ tenant=None, cadence_seconds=None, table_keys=None,
1489
+ source_counts=None):
1490
  """Spawn/refresh the four locked Odoo databases, then compute their cells. `why` is 'boot' or
1491
  'resync' and rides every log line, because "it failed" and "it failed at boot, before anyone
1492
  could have asked" are different diagnoses.
 
1546
  # Only the designated default owns this mirror. A selection must never be lent to
1547
  # another connection; the full recovery path still refreshes every connection.
1548
  counts = _rel.refresh(_rt, tenant_key, all_connections=table_keys is None,
1549
+ **({"table_keys": table_keys} if table_keys is not None else {}),
1550
+ **({"source_counts": source_counts} if source_counts else {}))
1551
  if table_keys is None:
1552
  raw_models, schema_errors = _rel.authoritative_schema_snapshot()
1553
  _ut.record_odoo_schema_snapshot(raw_models, complete=not schema_errors,
 
2312
  print(f"[aios-api] odoo freshness stamp not saved ({type(e).__name__}: {e})")
2313
 
2314
 
2315
+ def _capture_resync_source_counts(tenant):
2316
+ """Count the default connection's Odoo source right after its mirror pull, or None.
2317
+
2318
+ The vendor pulls run between the mirror pull and the rebuild, so a count taken at rebuild
2319
+ time describes a later source than the mirror holds (D-9131). Never raises.
2320
+ """
2321
+ try:
2322
+ if not tenant:
2323
+ return None
2324
+ import odoo_relational as _rel_counts
2325
+ from harness import runtime as _runtime_counts
2326
+ counts = _rel_counts.capture_source_counts(_runtime_counts.get_runtime(tenant))
2327
+ print(f"[aios-api] store resync: counted the Odoo source for {len(counts)} "
2328
+ f"database(s) at mirror-pull time", flush=True)
2329
+ return counts or None
2330
+ except Exception as e: # noqa: BLE001
2331
+ print(f"[aios-api] store resync: the Odoo source was not counted at mirror-pull time "
2332
+ f"({type(e).__name__}); the rebuild counts it fresh", flush=True)
2333
+ return None
2334
+
2335
+
2336
  def _store_resync_loop():
2337
  """Keep the analytical mirror current β€” the API-process stand-in for the re-sync the
2338
  Streamlit app piggybacks on page renders. Measure memos key on the pool stamp, so a
 
2532
  f"next scheduled pass is due in {max(0, _every - _age)}s")
2533
  last_full_pass_at = last_good_pass_at
2534
  continue
2535
+ # D-9131: count the source now, before the vendor pulls, so reconciliation compares the
2536
+ # mirror with the source as of the same moment. A pass without a good pull counts nothing.
2537
+ _source_counts = (_capture_resync_source_counts(_cad["tenant"])
2538
+ if _err is None and sync_report and not _manual else None)
2539
  # ⭐ WAVE 27 item 17 (E's ASK ->A, resolved): whenever the Odoo RELATIONAL tables need
2540
  # refreshing, they run AFTER the mirror they derive from. A confirmed zero-change report
2541
  # is the W39 exception; deriving before a changed mirror advances would publish a one-cycle
 
2647
  if _rebuild_variadic or "tenant" in _rebuild_params else {})
2648
  if _rebuild_variadic or "table_keys" in _rebuild_params:
2649
  _rebuild_scope["table_keys"] = _table_keys
2650
+ if _source_counts and (_rebuild_variadic or "source_counts" in _rebuild_params):
2651
+ _rebuild_scope["source_counts"] = _source_counts
2652
  if _rebuild_odoo_relational(
2653
  "resync", _meta_previous, _meta_state, **_rebuild_scope):
2654
  last_source_fingerprints = source_fingerprints or None
api/odoo_relational.py CHANGED
@@ -3697,6 +3697,36 @@ def _source_domain_count(client, bucket):
3697
  raise Refused("the database source-count mode is not supported")
3698
 
3699
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3700
  def _group_identity_ids(client, model, domain, field):
3701
  """Return a read-only grouped identity set without retaining relation labels."""
3702
  groups = client.read_group(model, domain, [field], [field], lazy=False)
@@ -6538,12 +6568,15 @@ def health_view(report):
6538
 
6539
 
6540
  def refresh_curated(rt, cur, buckets, *, connection_id=None, username="automation",
6541
- today=None, retire=True, on_apply=None, source_client=None):
 
6542
  """Refresh each enabled database independently; retain failed databases unchanged.
6543
 
6544
  Counts describe the database's own domain, never its shared Odoo model. When a read-only
6545
  source client is available, each receipt asks Odoo independently for that exact population;
6546
  a failed source/count or mirror reader marks only that database and cannot stale siblings.
 
 
6547
  """
6548
  from copy import deepcopy
6549
  built, written, errors, receipts, report = {}, {}, {}, {}, {}
@@ -6555,7 +6588,9 @@ def refresh_curated(rt, cur, buckets, *, connection_id=None, username="automatio
6555
  source_count = None
6556
  source_mode = "unavailable"
6557
  source_failure = None
6558
- if source_client is not None:
 
 
6559
  try:
6560
  source_count, source_mode = _source_domain_count(source_client, bucket)
6561
  except Exception as exc: # noqa: BLE001
@@ -6658,7 +6693,7 @@ def _canonical_mirror_ready(rt):
6658
 
6659
 
6660
  def refresh(rt, tenant, username="automation", cur=None, today=None, connection_id=None,
6661
- all_connections=False, table_keys=None, on_apply=None):
6662
  """THE entry point β€” the store-resync path and the route both call this.
6663
 
6664
  ⚠ It must be CALLED on resync by something outside this file. If it is not wired, every row
@@ -6681,7 +6716,8 @@ def refresh(rt, tenant, username="automation", cur=None, today=None, connection_
6681
  if all_connections:
6682
  if table_keys is not None:
6683
  raise Refused("a database selection must name one connection")
6684
- return refresh_all(rt, tenant, username=username, cur=cur, today=today)
 
6685
  # β›” THE NAMESPACE IS SETTLED BEFORE ANY GUARD RUNS, because a named connection that does not
6686
  # resolve must be REFUSED rather than quietly served the default (R7).
6687
  if rt is None:
@@ -6772,7 +6808,7 @@ def refresh(rt, tenant, username="automation", cur=None, today=None, connection_
6772
  if source is None:
6773
  built, written, database_errors, database_receipts, plan_report = refresh_curated(
6774
  rt, cur, keep, connection_id=ns, username=username, today=today,
6775
- retire=requested is None, on_apply=on_apply)
6776
  if ns is None and requested is None and cur is not None and _canonical_mirror_ready(rt):
6777
  canonical_receipts = canonical_reconciliation_receipts(cur)
6778
  else:
@@ -6786,7 +6822,8 @@ def refresh(rt, tenant, username="automation", cur=None, today=None, connection_
6786
  source_client = None
6787
  built, written, database_errors, database_receipts, plan_report = refresh_curated(
6788
  rt, cur, keep, connection_id=ns, username=username, today=today,
6789
- retire=requested is None, on_apply=on_apply, source_client=source_client)
 
6790
  if ns is None and requested is None and cur is not None and _canonical_mirror_ready(rt):
6791
  canonical_receipts = canonical_reconciliation_receipts(
6792
  cur, source_client=source_client)
@@ -6840,7 +6877,7 @@ TRANSIENT_STORE_ERRORS = frozenset({"ProtocolViolation", "OperationalError", "Po
6840
  REFRESH_RETRY_SECONDS = 20
6841
 
6842
 
6843
- def refresh_all(rt, tenant, username="automation", cur=None, today=None):
6844
  """Refresh EVERY Odoo connection this tenant holds, one at a time (R4 / R7 / C4).
6845
 
6846
  β›”β›” ONE CONNECTION'S FAILURE MUST NOT ABORT THE OTHERS. An agency with four clients cannot
@@ -6878,9 +6915,12 @@ def refresh_all(rt, tenant, username="automation", cur=None, today=None):
6878
  named = None if (entry_cid is None or entry_cid == default) else entry_cid
6879
  for attempt in (1, 2):
6880
  try:
 
6881
  one = refresh(rt, tenant, username=username,
6882
  cur=(cur if named is None else None),
6883
- today=today, connection_id=named)
 
 
6884
  break
6885
  except Exception as exc: # noqa: BLE001
6886
  # S67-T19: one retry for a TRANSIENT store error only; every other failure is
 
3697
  raise Refused("the database source-count mode is not supported")
3698
 
3699
 
3700
+ def capture_source_counts(rt, connection_id=None):
3701
+ """`{bucket: (count, mode)}` for each enabled curated database, counted at the source now.
3702
+
3703
+ The resync loop calls this right after the mirror pull, so reconciliation compares the mirror
3704
+ with the source as of the same moment. A bucket whose count raises is left out, and that
3705
+ bucket counts fresh at reconciliation. No source or no client returns `{}`.
3706
+ """
3707
+ try:
3708
+ source = (rt.odoo_source() if connection_id is None else rt.odoo_source(connection_id))
3709
+ except Exception: # noqa: BLE001
3710
+ return {}
3711
+ if source is None:
3712
+ return {}
3713
+ counts = {}
3714
+ with source._bound(): # tenant credential + scope
3715
+ try:
3716
+ from core.odoo import get_odoo
3717
+ client = get_odoo()
3718
+ except Exception: # noqa: BLE001
3719
+ return {}
3720
+ if client is None:
3721
+ return {}
3722
+ for bucket in sorted(enabled_buckets(rt, connection_id)):
3723
+ try:
3724
+ counts[bucket] = _source_domain_count(client, bucket)
3725
+ except Exception: # noqa: BLE001
3726
+ continue
3727
+ return counts
3728
+
3729
+
3730
  def _group_identity_ids(client, model, domain, field):
3731
  """Return a read-only grouped identity set without retaining relation labels."""
3732
  groups = client.read_group(model, domain, [field], [field], lazy=False)
 
6568
 
6569
 
6570
  def refresh_curated(rt, cur, buckets, *, connection_id=None, username="automation",
6571
+ today=None, retire=True, on_apply=None, source_client=None,
6572
+ source_counts=None):
6573
  """Refresh each enabled database independently; retain failed databases unchanged.
6574
 
6575
  Counts describe the database's own domain, never its shared Odoo model. When a read-only
6576
  source client is available, each receipt asks Odoo independently for that exact population;
6577
  a failed source/count or mirror reader marks only that database and cannot stale siblings.
6578
+ `source_counts` (`capture_source_counts`) carries counts taken at mirror-pull time; a bucket
6579
+ it names uses that count, so a source that moved during the vendor pulls cannot mismatch.
6580
  """
6581
  from copy import deepcopy
6582
  built, written, errors, receipts, report = {}, {}, {}, {}, {}
 
6588
  source_count = None
6589
  source_mode = "unavailable"
6590
  source_failure = None
6591
+ if source_counts and bucket in source_counts:
6592
+ source_count, source_mode = source_counts[bucket]
6593
+ elif source_client is not None:
6594
  try:
6595
  source_count, source_mode = _source_domain_count(source_client, bucket)
6596
  except Exception as exc: # noqa: BLE001
 
6693
 
6694
 
6695
  def refresh(rt, tenant, username="automation", cur=None, today=None, connection_id=None,
6696
+ all_connections=False, table_keys=None, on_apply=None, source_counts=None):
6697
  """THE entry point β€” the store-resync path and the route both call this.
6698
 
6699
  ⚠ It must be CALLED on resync by something outside this file. If it is not wired, every row
 
6716
  if all_connections:
6717
  if table_keys is not None:
6718
  raise Refused("a database selection must name one connection")
6719
+ return refresh_all(rt, tenant, username=username, cur=cur, today=today,
6720
+ source_counts=source_counts)
6721
  # β›” THE NAMESPACE IS SETTLED BEFORE ANY GUARD RUNS, because a named connection that does not
6722
  # resolve must be REFUSED rather than quietly served the default (R7).
6723
  if rt is None:
 
6808
  if source is None:
6809
  built, written, database_errors, database_receipts, plan_report = refresh_curated(
6810
  rt, cur, keep, connection_id=ns, username=username, today=today,
6811
+ retire=requested is None, on_apply=on_apply, source_counts=source_counts)
6812
  if ns is None and requested is None and cur is not None and _canonical_mirror_ready(rt):
6813
  canonical_receipts = canonical_reconciliation_receipts(cur)
6814
  else:
 
6822
  source_client = None
6823
  built, written, database_errors, database_receipts, plan_report = refresh_curated(
6824
  rt, cur, keep, connection_id=ns, username=username, today=today,
6825
+ retire=requested is None, on_apply=on_apply, source_client=source_client,
6826
+ source_counts=source_counts)
6827
  if ns is None and requested is None and cur is not None and _canonical_mirror_ready(rt):
6828
  canonical_receipts = canonical_reconciliation_receipts(
6829
  cur, source_client=source_client)
 
6877
  REFRESH_RETRY_SECONDS = 20
6878
 
6879
 
6880
+ def refresh_all(rt, tenant, username="automation", cur=None, today=None, source_counts=None):
6881
  """Refresh EVERY Odoo connection this tenant holds, one at a time (R4 / R7 / C4).
6882
 
6883
  β›”β›” ONE CONNECTION'S FAILURE MUST NOT ABORT THE OTHERS. An agency with four clients cannot
 
6915
  named = None if (entry_cid is None or entry_cid == default) else entry_cid
6916
  for attempt in (1, 2):
6917
  try:
6918
+ # Pull-time source counts describe the default connection's mirror only.
6919
  one = refresh(rt, tenant, username=username,
6920
  cur=(cur if named is None else None),
6921
+ today=today, connection_id=named,
6922
+ **({"source_counts": source_counts}
6923
+ if named is None and source_counts else {}))
6924
  break
6925
  except Exception as exc: # noqa: BLE001
6926
  # S67-T19: one retry for a TRANSIENT store error only; every other failure is
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 683cf59e6a4de1f79003e4b7c7fd7d716dabadf377b986a040083f1aece25472
 
1
+ 8cfd4fdc0c9357618afdd7307cbb5b8da55e918d63ec45bf664e9fadb2073968