fsanyoto commited on
Commit
32744f6
·
verified ·
1 Parent(s): 6032706

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "current": "4dbf8213dda4",
3
  "releases": [
4
  {
5
  "version": "v83",
 
1
  {
2
+ "current": "a4e6ccbce1ed",
3
  "releases": [
4
  {
5
  "version": "v83",
VERSION CHANGED
@@ -1 +1 @@
1
- 4dbf8213dda4
 
1
+ a4e6ccbce1ed
api/main.py CHANGED
@@ -2989,8 +2989,13 @@ def _restore_sync_request_desks():
2989
 
2990
 
2991
  def _boot_mirrors():
 
2992
  _restore_sync_request_desks()
2993
  _seed_mirror_if_absent()
 
 
 
 
2994
  _restore_amazon_mirror("boot")
2995
  _restore_declared_mirrors("boot")
2996
 
 
2989
 
2990
 
2991
  def _boot_mirrors():
2992
+ import process_role as _role_boot
2993
  _restore_sync_request_desks()
2994
  _seed_mirror_if_absent()
2995
+ if _role_boot.role() == "web":
2996
+ # Every connector but Odoo reaches the web process through the worker's hand-off.
2997
+ print("[aios-api] web boot restores the Odoo mirror only; other mirrors arrive from the sync worker")
2998
+ return
2999
  _restore_amazon_mirror("boot")
3000
  _restore_declared_mirrors("boot")
3001
 
api/process_role.py CHANGED
@@ -41,6 +41,8 @@ def resolve_role(env=None):
41
 
42
 
43
  ROLE, ROLE_SOURCE = resolve_role()
 
 
44
  if ROLE_SOURCE != "AIOS_PROCESS_ROLE" and ROLE == "web":
45
  print(f"[process-role] {ROLE_SOURCE}: role=web. Heavy jobs run only in the sync worker.", flush=True)
46
  if ROLE == "web":
 
41
 
42
 
43
  ROLE, ROLE_SOURCE = resolve_role()
44
+ # The data layer cannot import this module, so it reads the resolved role from the environment.
45
+ os.environ["AIOS_PROCESS_ROLE"] = ROLE
46
  if ROLE_SOURCE != "AIOS_PROCESS_ROLE" and ROLE == "web":
47
  print(f"[process-role] {ROLE_SOURCE}: role=web. Heavy jobs run only in the sync worker.", flush=True)
48
  if ROLE == "web":
platform/harness/mirror_store.py CHANGED
@@ -56,6 +56,22 @@ def register_publish_listener(fn):
56
  _PUBLISH_LISTENERS.append(fn)
57
 
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  def install_handoff(connector, tenant_key, rt, manifest, rows, paths):
60
  """Install a snapshot another process already published. Returns False if it is already resident."""
61
  store = for_connector(connector)
@@ -71,8 +87,14 @@ def install_handoff(connector, tenant_key, rt, manifest, rows, paths):
71
  newest = _record_newest(con, store.connector)
72
  finally:
73
  con.close()
74
- # The next restore re-reads the stored manifest instead of trusting this process's copy.
75
- store.cache.pop(store._mirror_cache_key(tenant_key, rt), None)
 
 
 
 
 
 
76
  with _CATCH_UP_LOCK:
77
  state = _catch_up_source(rt, store.connector)
78
  if not state["refused"]:
@@ -663,6 +685,15 @@ class MirrorStore:
663
  result = {"state": "local", "problems": [], "manifest": {}, "dirty": set(), "runtime": rt,
664
  "refused_tables": []}
665
  con, _path = self._connect(tenant_key, rt)
 
 
 
 
 
 
 
 
 
666
  _RESTORE_PROGRESS.store = self
667
  try:
668
  if self._has_local(con):
@@ -679,6 +710,7 @@ class MirrorStore:
679
  local_id = datastore._publication(con, self.connector).get("snapshot_id")
680
  if saved.get("snapshot_id") and saved["snapshot_id"] != local_id:
681
  self._install_snapshot(con, saved, rows, paths)
 
682
  result["manifest"] = saved
683
  if not result["manifest"].get("snapshot_id"):
684
  self._after_restore(con, result, log)
@@ -705,6 +737,7 @@ class MirrorStore:
705
  manifest, rows, paths, total, refused = self._validated_snapshot(
706
  tenant_key, rt, con, raw, tmp, allow_partial=True)
707
  self._install_snapshot(con, manifest, rows, paths)
 
708
  result.update(state="partial" if refused else "restored", manifest=manifest, refused_tables=refused)
709
  if refused:
710
  result["problems"].append(f"{self.label} mirror tables refused: " + ", ".join(refused)
 
56
  _PUBLISH_LISTENERS.append(fn)
57
 
58
 
59
+ def _web_waits_for_worker(connector):
60
+ """True in the web process for every mirror but Odoo: those arrive only from the sync worker."""
61
+ return os.environ.get("AIOS_PROCESS_ROLE") == "web" and connector != "odoo"
62
+
63
+
64
+ def _notify_publish(connector, tenant_key, manifest, rows, paths, log=print):
65
+ """Hand a restored snapshot to the listeners too, so the web process never restores it itself."""
66
+ if not paths or not manifest.get("snapshot_id"):
67
+ return
68
+ for listener in list(_PUBLISH_LISTENERS):
69
+ try:
70
+ listener(connector, tenant_key, manifest, [tuple(row) for row in rows], paths)
71
+ except Exception as exc: # noqa: BLE001
72
+ log(f"{connector} mirror restore hand-off failed ({type(exc).__name__}: {exc})")
73
+
74
+
75
  def install_handoff(connector, tenant_key, rt, manifest, rows, paths):
76
  """Install a snapshot another process already published. Returns False if it is already resident."""
77
  store = for_connector(connector)
 
87
  newest = _record_newest(con, store.connector)
88
  finally:
89
  con.close()
90
+ cache_key = store._mirror_cache_key(tenant_key, rt)
91
+ if _web_waits_for_worker(store.connector):
92
+ # The web process never persists, so the installed hand-off is its restore answer.
93
+ store.cache[cache_key] = {"state": "restored", "problems": [], "manifest": manifest, "dirty": set(),
94
+ "runtime": rt, "refused_tables": []}
95
+ else:
96
+ # The next restore re-reads the stored manifest instead of trusting this process's copy.
97
+ store.cache.pop(cache_key, None)
98
  with _CATCH_UP_LOCK:
99
  state = _catch_up_source(rt, store.connector)
100
  if not state["refused"]:
 
685
  result = {"state": "local", "problems": [], "manifest": {}, "dirty": set(), "runtime": rt,
686
  "refused_tables": []}
687
  con, _path = self._connect(tenant_key, rt)
688
+ if _web_waits_for_worker(self.connector):
689
+ # The sync worker restores this mirror and hands it over; the web process never downloads it.
690
+ try:
691
+ result["state"] = "local" if self._has_local(con) else "absent"
692
+ finally:
693
+ con.close()
694
+ with _CATCH_UP_LOCK:
695
+ _catch_up_source(rt, self.connector)["pass_pending"] = True
696
+ return result
697
  _RESTORE_PROGRESS.store = self
698
  try:
699
  if self._has_local(con):
 
710
  local_id = datastore._publication(con, self.connector).get("snapshot_id")
711
  if saved.get("snapshot_id") and saved["snapshot_id"] != local_id:
712
  self._install_snapshot(con, saved, rows, paths)
713
+ _notify_publish(self.connector, tenant_key, saved, rows, paths, log)
714
  result["manifest"] = saved
715
  if not result["manifest"].get("snapshot_id"):
716
  self._after_restore(con, result, log)
 
737
  manifest, rows, paths, total, refused = self._validated_snapshot(
738
  tenant_key, rt, con, raw, tmp, allow_partial=True)
739
  self._install_snapshot(con, manifest, rows, paths)
740
+ _notify_publish(self.connector, tenant_key, manifest, rows, paths, log)
741
  result.update(state="partial" if refused else "restored", manifest=manifest, refused_tables=refused)
742
  if refused:
743
  result["problems"].append(f"{self.label} mirror tables refused: " + ", ".join(refused)
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- ed6a56a1b0794e850c673152ddf55b37163111bc9ccabf76514d493118a00d5f
 
1
+ 31637b3b3f684b7c7795e667f4cd10da6215d5d665724db8d0e0de6b34741c43