fsanyoto commited on
Commit
c1cbe44
·
verified ·
1 Parent(s): 79b3ae0

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "b530d142",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "e2341f6a",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- b530d142
 
1
+ e2341f6a
api/main.py CHANGED
@@ -2063,6 +2063,30 @@ def _resync_mirror_pass(manual, passes, entities=None):
2063
 
2064
  Returns `(sync_report, delete_report, error)` where `error` is None or a classified dict.
2065
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2066
  try:
2067
  from harness import datastore as _ds, mirror_store
2068
  import core.odoo as _odoo
@@ -2077,22 +2101,27 @@ def _resync_mirror_pass(manual, passes, entities=None):
2077
  # chose into a recurring error in the log; a `continue` would skip the Meta pull and the
2078
  # relational rebuild, which `manual` says nothing about.
2079
  if manual:
 
2080
  return None, None, None
2081
  absent = _smallest_first(_ds, _absent_mirror_entities(_ds, entities))
2082
  first = {}
2083
  if absent:
2084
  # Tables the boot seed lacks first: minutes, where the whole catch-up runs an hour.
 
2085
  try:
2086
  first = mirror_store.tracked_sync("odoo", _ds._resident_odoo_runtime(), _ds.sync_all,
2087
- entities=absent, log=lambda *a, **k: None,
2088
  _catch_up_complete=False)
 
2089
  print(f"[aios-api] store resync: synced {', '.join(absent)} first, "
2090
  f"absent from the boot seed")
2091
  except Exception as exc: # noqa: BLE001
2092
  print(f"[aios-api] store resync: the absent tables first failed "
2093
  f"({type(exc).__name__}); the full pass below still syncs them")
 
2094
  sync_report = mirror_store.tracked_sync("odoo", _ds._resident_odoo_runtime(), _ds.sync_all,
2095
- entities=entities, log=lambda *a, **k: None)
 
2096
  for key, row in first.items():
2097
  if isinstance(sync_report, dict) and isinstance(sync_report.get(key), dict):
2098
  sync_report[key]["pulled"] = sync_report[key].get("pulled", 0) + row.get("pulled", 0)
@@ -2103,9 +2132,18 @@ def _resync_mirror_pass(manual, passes, entities=None):
2103
  # HOTFIX 2026-09-29: EVERY pass, not every fourth. At a daily cadence a fourth pass is four
2104
  # days, and the first pass after a reseed never reconciled at all. `reconcile_deletes`
2105
  # compares counts first and walks ids only for an entity whose count moved.
2106
- delete_report = _ds.reconcile_deletes(entities=entities, log=lambda *a, **k: None)
 
 
 
 
 
 
 
 
2107
  return sync_report, delete_report, None
2108
  except Exception as e: # noqa: BLE001
 
2109
  # A partial report must never be mistaken for a confirmed zero-change pass.
2110
  return None, None, _classify_resync_error(e)
2111
 
 
2063
 
2064
  Returns `(sync_report, delete_report, error)` where `error` is None or a classified dict.
2065
  """
2066
+ import time as _pass_clock
2067
+ from datetime import datetime as _pass_dt, timezone as _pass_tz
2068
+
2069
+ def _resync_log(*parts, **_kw):
2070
+ # One timestamped line per step. A logging error never changes the pass.
2071
+ try:
2072
+ stamp = _pass_dt.now(_pass_tz.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
2073
+ print(f"[aios-api] {stamp} odoo pass: {' '.join(str(p) for p in parts)}", flush=True)
2074
+ except Exception: # noqa: BLE001
2075
+ pass
2076
+
2077
+ def _log_entities(label, report):
2078
+ # The sync_all report: {entity: {"phase", "pulled", "secs"}}. Tolerates None or another shape.
2079
+ try:
2080
+ for key, row in (report.items() if isinstance(report, dict) else ()):
2081
+ row = row if isinstance(row, dict) else {}
2082
+ _resync_log(f"{label} {key}: phase {row.get('phase')}, "
2083
+ f"{row.get('pulled', 0) or 0:,} rows, {row.get('secs', '?')}s")
2084
+ except Exception: # noqa: BLE001
2085
+ pass
2086
+
2087
+ pass_started = _pass_clock.monotonic()
2088
+ _resync_log(f"start (manual={manual}, pass {passes}, entities="
2089
+ f"{'all' if entities is None else len(entities) if hasattr(entities, '__len__') else 'selected'})")
2090
  try:
2091
  from harness import datastore as _ds, mirror_store
2092
  import core.odoo as _odoo
 
2101
  # chose into a recurring error in the log; a `continue` would skip the Meta pull and the
2102
  # relational rebuild, which `manual` says nothing about.
2103
  if manual:
2104
+ _resync_log("skipped, the tenant syncs manually")
2105
  return None, None, None
2106
  absent = _smallest_first(_ds, _absent_mirror_entities(_ds, entities))
2107
  first = {}
2108
  if absent:
2109
  # Tables the boot seed lacks first: minutes, where the whole catch-up runs an hour.
2110
+ _resync_log(f"absent tables first: {', '.join(absent)}")
2111
  try:
2112
  first = mirror_store.tracked_sync("odoo", _ds._resident_odoo_runtime(), _ds.sync_all,
2113
+ entities=absent, log=_resync_log,
2114
  _catch_up_complete=False)
2115
+ _log_entities("absent", first)
2116
  print(f"[aios-api] store resync: synced {', '.join(absent)} first, "
2117
  f"absent from the boot seed")
2118
  except Exception as exc: # noqa: BLE001
2119
  print(f"[aios-api] store resync: the absent tables first failed "
2120
  f"({type(exc).__name__}); the full pass below still syncs them")
2121
+ _resync_log("full pass start")
2122
  sync_report = mirror_store.tracked_sync("odoo", _ds._resident_odoo_runtime(), _ds.sync_all,
2123
+ entities=entities, log=_resync_log)
2124
+ _log_entities("full", sync_report)
2125
  for key, row in first.items():
2126
  if isinstance(sync_report, dict) and isinstance(sync_report.get(key), dict):
2127
  sync_report[key]["pulled"] = sync_report[key].get("pulled", 0) + row.get("pulled", 0)
 
2132
  # HOTFIX 2026-09-29: EVERY pass, not every fourth. At a daily cadence a fourth pass is four
2133
  # days, and the first pass after a reseed never reconciled at all. `reconcile_deletes`
2134
  # compares counts first and walks ids only for an entity whose count moved.
2135
+ deletes_started = _pass_clock.monotonic()
2136
+ delete_report = _ds.reconcile_deletes(entities=entities, log=_resync_log)
2137
+ try:
2138
+ gone = {k: v for k, v in (delete_report or {}).items() if v} if isinstance(delete_report, dict) else {}
2139
+ _resync_log(f"deletes reconciled: {sum(gone.values()):,} rows removed over {len(gone)} entities "
2140
+ f"in {_pass_clock.monotonic() - deletes_started:.1f}s")
2141
+ except Exception: # noqa: BLE001
2142
+ pass
2143
+ _resync_log(f"end in {_pass_clock.monotonic() - pass_started:.1f}s")
2144
  return sync_report, delete_report, None
2145
  except Exception as e: # noqa: BLE001
2146
+ _resync_log(f"failed after {_pass_clock.monotonic() - pass_started:.1f}s ({type(e).__name__})")
2147
  # A partial report must never be mistaken for a confirmed zero-change pass.
2148
  return None, None, _classify_resync_error(e)
2149
 
platform/harness/mirror_store.py CHANGED
@@ -1053,6 +1053,22 @@ def sync_mirror(connector, tenant_key, rt, *, report=None, log=print, before_pub
1053
  before_publish(tenant_key, con, metadata) returns False to hold, or raises to refuse publication.
1054
  """
1055
  store = for_connector(connector)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1056
  with store.lock:
1057
  if getattr(datastore._SYNC_TLS, "candidate", None) is not None:
1058
  raise RuntimeError("A source publication is already active on this thread")
@@ -1066,7 +1082,10 @@ def sync_mirror(connector, tenant_key, rt, *, report=None, log=print, before_pub
1066
  installed = False
1067
  save_started = None
1068
  try:
 
1069
  candidate, started = _open_candidate(store, tenant_key, rt, published)
 
 
1070
  pending = {row[0] for row in candidate.execute("SELECT name FROM _candidate_pending").fetchall()}
1071
  requested = set(store.spec.tables if expected_tables is None else expected_tables)
1072
  if requested:
@@ -1089,13 +1108,23 @@ def sync_mirror(connector, tenant_key, rt, *, report=None, log=print, before_pub
1089
  if done:
1090
  candidate.executemany("DELETE FROM _candidate_pending WHERE name=?", [[name] for name in done])
1091
  if candidate.execute("SELECT 1 FROM _candidate_pending LIMIT 1").fetchone():
 
 
 
1092
  return
1093
  if report is not None:
1094
  completed, current = _sync_result(store.connector, report)
1095
  if not (completed if store.connector == "meta" else current):
 
 
 
 
 
1096
  return
1097
  if store.connector == "odoo" and any(row[1] not in {"live", "done"}
1098
  for row in store._state_rows(candidate)):
 
 
1099
  return
1100
  if set(restored.get("refused_tables", ())) - store._tables(candidate):
1101
  raise PublicationHeld("The source still has unavailable tables. The previous snapshot is kept.")
@@ -1107,8 +1136,11 @@ def sync_mirror(connector, tenant_key, rt, *, report=None, log=print, before_pub
1107
  if check is not None and check(tenant_key, candidate, metadata) is False:
1108
  raise PublicationHeld("The source publication was held. The previous snapshot is still available.")
1109
  if store.connector == "odoo":
 
1110
  metadata["validation"] = datastore.check_odoo_snapshot(rt, candidate, published, metadata["rows"])
1111
  failed = [row["check"] for row in metadata["validation"]["checks"] if row["state"] == "failed"]
 
 
1112
  if failed:
1113
  prior = _publication_summary(datastore._publication(published, store.connector))
1114
  hold = {"previous_snapshot_id": prior["snapshot_id"], "previous_publication": prior,
@@ -1126,9 +1158,15 @@ def sync_mirror(connector, tenant_key, rt, *, report=None, log=print, before_pub
1126
  result = {"problems": []}
1127
  save_started = time.monotonic()
1128
  with tempfile.TemporaryDirectory(prefix="mirror-publish-") as tmp:
 
1129
  paths = _export_tables(store, candidate, tmp)
 
 
 
1130
  manifest = store.persist_mirror(tenant_key, rt, candidate, store._tables(candidate),
1131
  report=result, log=log, _publication=metadata)
 
 
1132
  if not manifest:
1133
  problems = result["problems"] or ["The source snapshot is incomplete."]
1134
  if report is not None and "problems" in report:
@@ -1136,11 +1174,14 @@ def sync_mirror(connector, tenant_key, rt, *, report=None, log=print, before_pub
1136
  return
1137
  raise RuntimeError("; ".join(problems))
1138
  try:
 
1139
  store._install_snapshot(published, manifest, store._state_rows(candidate), paths)
1140
  installed = True
1141
  except BaseException:
1142
  store.cache.pop(store._mirror_cache_key(tenant_key, rt), None)
1143
  raise
 
 
1144
  finally:
1145
  if save_started is not None and store.connector == "odoo":
1146
  status = datastore.ODOO_MIRROR_STATUS.setdefault(str(Path(rt.datastore_path).resolve()), {})
 
1053
  before_publish(tenant_key, con, metadata) returns False to hold, or raises to refuse publication.
1054
  """
1055
  store = for_connector(connector)
1056
+ odoo = store.connector == "odoo"
1057
+
1058
+ def note(message, started=None, names=None):
1059
+ # Callers guard on odoo. A logging error never changes control flow.
1060
+ try:
1061
+ text = message
1062
+ if names is not None:
1063
+ listed = sorted(str(name) for name in names())
1064
+ text += ": " + (", ".join(listed[:10]) or "none") + (
1065
+ f" and {len(listed) - 10} more" if len(listed) > 10 else "")
1066
+ if started is not None:
1067
+ text += f" ({time.monotonic() - started:.1f}s)"
1068
+ log("mirror " + text)
1069
+ except Exception:
1070
+ pass
1071
+
1072
  with store.lock:
1073
  if getattr(datastore._SYNC_TLS, "candidate", None) is not None:
1074
  raise RuntimeError("A source publication is already active on this thread")
 
1082
  installed = False
1083
  save_started = None
1084
  try:
1085
+ opened = time.monotonic()
1086
  candidate, started = _open_candidate(store, tenant_key, rt, published)
1087
+ if odoo:
1088
+ note("candidate open", opened)
1089
  pending = {row[0] for row in candidate.execute("SELECT name FROM _candidate_pending").fetchall()}
1090
  requested = set(store.spec.tables if expected_tables is None else expected_tables)
1091
  if requested:
 
1108
  if done:
1109
  candidate.executemany("DELETE FROM _candidate_pending WHERE name=?", [[name] for name in done])
1110
  if candidate.execute("SELECT 1 FROM _candidate_pending LIMIT 1").fetchone():
1111
+ if odoo:
1112
+ note("held, tables still pending", names=lambda: [row[0] for row in candidate.execute(
1113
+ "SELECT name FROM _candidate_pending").fetchall()])
1114
  return
1115
  if report is not None:
1116
  completed, current = _sync_result(store.connector, report)
1117
  if not (completed if store.connector == "meta" else current):
1118
+ if odoo:
1119
+ note(f"held, the pass is not current (completed={completed}), entities not live",
1120
+ names=lambda: [f"{name}={row.get('phase') if isinstance(row, dict) else row}"
1121
+ for name, row in report.items()
1122
+ if not (isinstance(row, dict) and row.get("phase") == "live")])
1123
  return
1124
  if store.connector == "odoo" and any(row[1] not in {"live", "done"}
1125
  for row in store._state_rows(candidate)):
1126
+ note("held, sync state not live or done", names=lambda: [
1127
+ f"{row[0]}={row[1]}" for row in store._state_rows(candidate) if row[1] not in {"live", "done"}])
1128
  return
1129
  if set(restored.get("refused_tables", ())) - store._tables(candidate):
1130
  raise PublicationHeld("The source still has unavailable tables. The previous snapshot is kept.")
 
1136
  if check is not None and check(tenant_key, candidate, metadata) is False:
1137
  raise PublicationHeld("The source publication was held. The previous snapshot is still available.")
1138
  if store.connector == "odoo":
1139
+ validating = time.monotonic()
1140
  metadata["validation"] = datastore.check_odoo_snapshot(rt, candidate, published, metadata["rows"])
1141
  failed = [row["check"] for row in metadata["validation"]["checks"] if row["state"] == "failed"]
1142
+ note("validation " + ("failed" if failed else "passed"), validating,
1143
+ names=(lambda: failed) if failed else None)
1144
  if failed:
1145
  prior = _publication_summary(datastore._publication(published, store.connector))
1146
  hold = {"previous_snapshot_id": prior["snapshot_id"], "previous_publication": prior,
 
1158
  result = {"problems": []}
1159
  save_started = time.monotonic()
1160
  with tempfile.TemporaryDirectory(prefix="mirror-publish-") as tmp:
1161
+ exporting = time.monotonic()
1162
  paths = _export_tables(store, candidate, tmp)
1163
+ if odoo:
1164
+ note(f"export, {len(paths)} tables", exporting)
1165
+ saving = time.monotonic()
1166
  manifest = store.persist_mirror(tenant_key, rt, candidate, store._tables(candidate),
1167
  report=result, log=log, _publication=metadata)
1168
+ if odoo:
1169
+ note("save" if manifest else "save failed", saving)
1170
  if not manifest:
1171
  problems = result["problems"] or ["The source snapshot is incomplete."]
1172
  if report is not None and "problems" in report:
 
1174
  return
1175
  raise RuntimeError("; ".join(problems))
1176
  try:
1177
+ installing = time.monotonic()
1178
  store._install_snapshot(published, manifest, store._state_rows(candidate), paths)
1179
  installed = True
1180
  except BaseException:
1181
  store.cache.pop(store._mirror_cache_key(tenant_key, rt), None)
1182
  raise
1183
+ if odoo:
1184
+ note("install", installing)
1185
  finally:
1186
  if save_started is not None and store.connector == "odoo":
1187
  status = datastore.ODOO_MIRROR_STATUS.setdefault(str(Path(rt.datastore_path).resolve()), {})
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- ffa8a9af11b9a86019b3977deccd782a8e26d4a529f4b1b7875cfb399a3b2b11
 
1
+ fd9f81e8074c49fb460735f53628a3cb93b2e589e5163d90b70473d91cf37bad