Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/external_freshness.py +29 -2
- api/external_openapi.py +1 -1
- api/main.py +8 -1
- api/process_role.py +35 -0
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
- web/src/typed/openapi.fixture.json +6 -3
- web/src/typed/schema.d.ts +3 -3
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "9722ffc75",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
9722ffc75
|
api/external_freshness.py
CHANGED
|
@@ -238,6 +238,28 @@ def _mirror_refreshes(session, definitions, keys):
|
|
| 238 |
return refreshed
|
| 239 |
|
| 240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
def snapshot(session, databases):
|
| 242 |
"""Index source receipts and edit times once for this authorized discovery call."""
|
| 243 |
from core import connector_sync, user_tables
|
|
@@ -301,6 +323,9 @@ def snapshot(session, databases):
|
|
| 301 |
if not user_tables.materialises(key, st=lent, defn=definitions[key])}
|
| 302 |
mirror = _mirror_refreshes(session, definitions, mirror_keys) if mirror_keys else {}
|
| 303 |
facts = {}
|
|
|
|
|
|
|
|
|
|
| 304 |
odoo_failed = {str(item.get("key")) for item in (odoo.get("failedDatabases") or ())
|
| 305 |
if isinstance(item, dict) and item.get("key")}
|
| 306 |
for key in wanted:
|
|
@@ -310,6 +335,8 @@ def snapshot(session, databases):
|
|
| 310 |
fact.update(source_sync="edited", last_edited_at=_latest(edits.get(key), definition.get("updated")))
|
| 311 |
elif key == "ut_activity":
|
| 312 |
fact["source_sync"] = "not_applicable"
|
|
|
|
|
|
|
| 313 |
else:
|
| 314 |
health = definition.get(user_tables.CONNECTOR_HEALTH_FIELD) or {}
|
| 315 |
job = receipts.get(key) or {}
|
|
@@ -363,14 +390,14 @@ def add(result, session, *, facts=None):
|
|
| 363 |
refreshed = _refresh_value(version) if kind == "mirror_user_table" else None
|
| 364 |
if kind == "mirror_user_table" and isinstance(version, dict):
|
| 365 |
stamp = utc_stamp(refreshed)
|
| 366 |
-
if stamp is not None:
|
| 367 |
result.update(source_synced_at=stamp, source_sync="synced")
|
| 368 |
return result
|
| 369 |
if facts is None:
|
| 370 |
facts = snapshot(session, [result.get("database")])
|
| 371 |
result.update(facts.get(result.get("database"), {}))
|
| 372 |
synced_on = _sync_date(refreshed)
|
| 373 |
-
if synced_on is not None and result["source_synced_at"] is None:
|
| 374 |
result.pop("last_edited_at", None)
|
| 375 |
result.update(source_synced_on=synced_on, source_sync="synced_date_only",
|
| 376 |
source_sync_reason="The source reports only a sync date, without a time.")
|
|
|
|
| 238 |
return refreshed
|
| 239 |
|
| 240 |
|
| 241 |
+
def _served_behind(session, key):
|
| 242 |
+
"""process_role's install lag for the connector behind one mirror database, or None."""
|
| 243 |
+
key = str(key or "")
|
| 244 |
+
connector = ("amazon" if key.startswith("ut_amzn_") else
|
| 245 |
+
"odoo" if key.startswith("ut_odoo_") or key in ("customer_data", "product_data") else None)
|
| 246 |
+
if connector is None:
|
| 247 |
+
return None
|
| 248 |
+
try:
|
| 249 |
+
import process_role
|
| 250 |
+
return process_role.served_behind(getattr(session.runtime, "key", None) or session.tenant, connector)
|
| 251 |
+
except Exception:
|
| 252 |
+
return None
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
def _stale_fact(served):
|
| 256 |
+
"""A fact for a mirror whose newest published sync this deployment could not install."""
|
| 257 |
+
day = _sync_date(served) or (utc_stamp(served) or "")[:10] or None
|
| 258 |
+
reason = (f"This deployment still serves the data synced on {day}. The newest sync could not be installed."
|
| 259 |
+
if day else "This deployment serves an older copy of the data. The newest sync could not be installed.")
|
| 260 |
+
return {"source_synced_at": None, "source_sync": "stale", "source_sync_reason": reason}
|
| 261 |
+
|
| 262 |
+
|
| 263 |
def snapshot(session, databases):
|
| 264 |
"""Index source receipts and edit times once for this authorized discovery call."""
|
| 265 |
from core import connector_sync, user_tables
|
|
|
|
| 323 |
if not user_tables.materialises(key, st=lent, defn=definitions[key])}
|
| 324 |
mirror = _mirror_refreshes(session, definitions, mirror_keys) if mirror_keys else {}
|
| 325 |
facts = {}
|
| 326 |
+
# One install-lag read per connector: a secondary web worker reads it from the primary's file.
|
| 327 |
+
behind = {group: _served_behind(session, next(iter(keys)))
|
| 328 |
+
for group, keys in (("odoo", odoo_keys), ("amazon", amazon_keys)) if keys}
|
| 329 |
odoo_failed = {str(item.get("key")) for item in (odoo.get("failedDatabases") or ())
|
| 330 |
if isinstance(item, dict) and item.get("key")}
|
| 331 |
for key in wanted:
|
|
|
|
| 335 |
fact.update(source_sync="edited", last_edited_at=_latest(edits.get(key), definition.get("updated")))
|
| 336 |
elif key == "ut_activity":
|
| 337 |
fact["source_sync"] = "not_applicable"
|
| 338 |
+
elif behind.get("amazon" if key in amazon_keys else "odoo" if key in odoo_keys else None) is not None:
|
| 339 |
+
fact = _stale_fact(amazon.get(key) if key in amazon_keys else mirror.get(key))
|
| 340 |
else:
|
| 341 |
health = definition.get(user_tables.CONNECTOR_HEALTH_FIELD) or {}
|
| 342 |
job = receipts.get(key) or {}
|
|
|
|
| 390 |
refreshed = _refresh_value(version) if kind == "mirror_user_table" else None
|
| 391 |
if kind == "mirror_user_table" and isinstance(version, dict):
|
| 392 |
stamp = utc_stamp(refreshed)
|
| 393 |
+
if stamp is not None and _served_behind(session, result.get("database")) is None:
|
| 394 |
result.update(source_synced_at=stamp, source_sync="synced")
|
| 395 |
return result
|
| 396 |
if facts is None:
|
| 397 |
facts = snapshot(session, [result.get("database")])
|
| 398 |
result.update(facts.get(result.get("database"), {}))
|
| 399 |
synced_on = _sync_date(refreshed)
|
| 400 |
+
if synced_on is not None and result["source_synced_at"] is None and result["source_sync"] != "stale":
|
| 401 |
result.pop("last_edited_at", None)
|
| 402 |
result.update(source_synced_on=synced_on, source_sync="synced_date_only",
|
| 403 |
source_sync_reason="The source reports only a sync date, without a time.")
|
api/external_openapi.py
CHANGED
|
@@ -59,7 +59,7 @@ def _schemas(databases, records):
|
|
| 59 |
freshness = {
|
| 60 |
"source_synced_at": {**date, "description": "Time of the last successful source sync, never a read or edit time."},
|
| 61 |
"source_synced_on": {"type": "string", "format": "date"},
|
| 62 |
-
"source_sync": {"type": "string", "enum": ["synced", "synced_date_only", "edited", "not_applicable", "never_synced"]},
|
| 63 |
"source_sync_reason": {"type": "string"},
|
| 64 |
"last_edited_at": {**date, "description": "Time of the last recorded edit when source_sync is edited."},
|
| 65 |
}
|
|
|
|
| 59 |
freshness = {
|
| 60 |
"source_synced_at": {**date, "description": "Time of the last successful source sync, never a read or edit time."},
|
| 61 |
"source_synced_on": {"type": "string", "format": "date"},
|
| 62 |
+
"source_sync": {"type": "string", "enum": ["synced", "synced_date_only", "edited", "not_applicable", "never_synced", "stale"]},
|
| 63 |
"source_sync_reason": {"type": "string"},
|
| 64 |
"last_edited_at": {**date, "description": "Time of the last recorded edit when source_sync is edited."},
|
| 65 |
}
|
api/main.py
CHANGED
|
@@ -606,7 +606,14 @@ def odoo_sync_freshness(session: Session = Depends(deps_require_session)):
|
|
| 606 |
"""
|
| 607 |
routes_connectors._odoo_admin(session)
|
| 608 |
import odoo_relational as _rel_fresh
|
| 609 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 610 |
# ⚠ routes_forms is the FIRST NEW PUBLIC DOOR since the `_DEV_FIXTURES` scar (see :257 below). Its
|
| 611 |
# two paths are DELIBERATELY unauthenticated — a form is filled in by someone with no account — so
|
| 612 |
# it joins `/api/health`, the automation hook and the tick on the exempt list. It resolves a token
|
|
|
|
| 606 |
"""
|
| 607 |
routes_connectors._odoo_admin(session)
|
| 608 |
import odoo_relational as _rel_fresh
|
| 609 |
+
answer = _rel_fresh.sync_freshness(session.runtime)
|
| 610 |
+
# A published sync this deployment failed to install is a card failure, so the watchdog alerts.
|
| 611 |
+
behind = process_role.served_behind(getattr(session.runtime, "key", None) or session.tenant, "odoo")
|
| 612 |
+
current = answer.get("failure") if isinstance(answer, dict) else None
|
| 613 |
+
if behind is not None and isinstance(answer, dict) and not (isinstance(current, dict) and current.get("code")):
|
| 614 |
+
answer["failure"] = {"code": "mirror_not_installed",
|
| 615 |
+
"message": "The newest Odoo sync could not be installed. This deployment still serves older data."}
|
| 616 |
+
return answer
|
| 617 |
# ⚠ routes_forms is the FIRST NEW PUBLIC DOOR since the `_DEV_FIXTURES` scar (see :257 below). Its
|
| 618 |
# two paths are DELIBERATELY unauthenticated — a form is filled in by someone with no account — so
|
| 619 |
# it joins `/api/health`, the automation hook and the tick on the exempt list. It resolves a token
|
api/process_role.py
CHANGED
|
@@ -532,6 +532,40 @@ def pending_handoffs(root=None):
|
|
| 532 |
return sorted(pending)
|
| 533 |
|
| 534 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 535 |
# ----------------------------------------------------------------------------- several web workers
|
| 536 |
_PRIMARY = {"fd": None}
|
| 537 |
|
|
@@ -590,6 +624,7 @@ def write_primary_state(root=None):
|
|
| 590 |
"installed": {f"{key[0]}/{key[1]}": snap for key, snap in dict(_INSTALLED).items()},
|
| 591 |
"workerBeat": _STORED["beat"],
|
| 592 |
"storeMirrors": {f"{key[0]}/{key[1]}": snap for key, snap in dict(_STORED["mirrors"]).items()},
|
|
|
|
| 593 |
"mirrorVersion": version})
|
| 594 |
return True
|
| 595 |
|
|
|
|
| 532 |
return sorted(pending)
|
| 533 |
|
| 534 |
|
| 535 |
+
def _failure_map(root=None):
|
| 536 |
+
"""{(tenant, connector): {snapshotId, attempts, type, at}} for each published snapshot that failed to install."""
|
| 537 |
+
if not is_primary():
|
| 538 |
+
stored = primary_state(root).get("installFailures") or {}
|
| 539 |
+
return {tuple(key.split("/", 1)): row for key, row in stored.items()
|
| 540 |
+
if "/" in key and isinstance(row, dict)}
|
| 541 |
+
last, failures = dict(LAST_INSTALL_ERROR), {}
|
| 542 |
+
for key, snapshot in dict(_STORED["mirrors"]).items():
|
| 543 |
+
attempts = _INSTALL_FAILURES.get((key, snapshot), 0)
|
| 544 |
+
if attempts:
|
| 545 |
+
# LAST_INSTALL_ERROR is one slot: its type and time belong only to the snapshot it names.
|
| 546 |
+
same = (last.get("tenant"), last.get("connector"), last.get("snapshotId")) == (*key, snapshot)
|
| 547 |
+
failures[key] = {"snapshotId": snapshot, "attempts": attempts,
|
| 548 |
+
"type": last.get("type") if same else None, "at": last.get("at") if same else None}
|
| 549 |
+
return failures
|
| 550 |
+
|
| 551 |
+
|
| 552 |
+
def served_behind(tenant, connector, root=None):
|
| 553 |
+
"""`{published, served, attempts, error}` when the store published a snapshot this container failed to install.
|
| 554 |
+
|
| 555 |
+
None when nothing is published, the published snapshot is served, or no install of it failed yet.
|
| 556 |
+
"""
|
| 557 |
+
key = (str(tenant or "").strip().lower(), str(connector))
|
| 558 |
+
published = _known_mirrors(root).get(key)
|
| 559 |
+
if not published:
|
| 560 |
+
return None
|
| 561 |
+
served = _installed_map(root).get(key)
|
| 562 |
+
failure = _failure_map(root).get(key) or {}
|
| 563 |
+
attempts = int(failure.get("attempts") or 0) if failure.get("snapshotId") == published else 0
|
| 564 |
+
if served == published or attempts < 1:
|
| 565 |
+
return None
|
| 566 |
+
return {"published": published, "served": served, "attempts": attempts, "error": failure.get("type")}
|
| 567 |
+
|
| 568 |
+
|
| 569 |
# ----------------------------------------------------------------------------- several web workers
|
| 570 |
_PRIMARY = {"fd": None}
|
| 571 |
|
|
|
|
| 624 |
"installed": {f"{key[0]}/{key[1]}": snap for key, snap in dict(_INSTALLED).items()},
|
| 625 |
"workerBeat": _STORED["beat"],
|
| 626 |
"storeMirrors": {f"{key[0]}/{key[1]}": snap for key, snap in dict(_STORED["mirrors"]).items()},
|
| 627 |
+
"installFailures": {f"{key[0]}/{key[1]}": row for key, row in _failure_map(root).items()},
|
| 628 |
"mirrorVersion": version})
|
| 629 |
return True
|
| 630 |
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
5550654043b2d2a41f2c5c03e9b78548e6020acf9a6c9c5598356bd3ee5a0bce
|
web/src/typed/openapi.fixture.json
CHANGED
|
@@ -83,7 +83,8 @@
|
|
| 83 |
"synced_date_only",
|
| 84 |
"edited",
|
| 85 |
"not_applicable",
|
| 86 |
-
"never_synced"
|
|
|
|
| 87 |
],
|
| 88 |
"type": "string"
|
| 89 |
},
|
|
@@ -178,7 +179,8 @@
|
|
| 178 |
"synced_date_only",
|
| 179 |
"edited",
|
| 180 |
"not_applicable",
|
| 181 |
-
"never_synced"
|
|
|
|
| 182 |
],
|
| 183 |
"type": "string"
|
| 184 |
},
|
|
@@ -3088,7 +3090,8 @@
|
|
| 3088 |
"synced_date_only",
|
| 3089 |
"edited",
|
| 3090 |
"not_applicable",
|
| 3091 |
-
"never_synced"
|
|
|
|
| 3092 |
],
|
| 3093 |
"type": "string"
|
| 3094 |
},
|
|
|
|
| 83 |
"synced_date_only",
|
| 84 |
"edited",
|
| 85 |
"not_applicable",
|
| 86 |
+
"never_synced",
|
| 87 |
+
"stale"
|
| 88 |
],
|
| 89 |
"type": "string"
|
| 90 |
},
|
|
|
|
| 179 |
"synced_date_only",
|
| 180 |
"edited",
|
| 181 |
"not_applicable",
|
| 182 |
+
"never_synced",
|
| 183 |
+
"stale"
|
| 184 |
],
|
| 185 |
"type": "string"
|
| 186 |
},
|
|
|
|
| 3090 |
"synced_date_only",
|
| 3091 |
"edited",
|
| 3092 |
"not_applicable",
|
| 3093 |
+
"never_synced",
|
| 3094 |
+
"stale"
|
| 3095 |
],
|
| 3096 |
"type": "string"
|
| 3097 |
},
|
web/src/typed/schema.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ export interface components {
|
|
| 82 |
permitted: boolean;
|
| 83 |
reason?: string;
|
| 84 |
/** @enum {string} */
|
| 85 |
-
source_sync: "synced" | "synced_date_only" | "edited" | "not_applicable" | "never_synced";
|
| 86 |
source_sync_reason?: string;
|
| 87 |
/**
|
| 88 |
* Format: date-time
|
|
@@ -116,7 +116,7 @@ export interface components {
|
|
| 116 |
retrieved_at?: string | null;
|
| 117 |
source_kind?: string;
|
| 118 |
/** @enum {string} */
|
| 119 |
-
source_sync: "synced" | "synced_date_only" | "edited" | "not_applicable" | "never_synced";
|
| 120 |
source_sync_reason?: string;
|
| 121 |
/**
|
| 122 |
* Format: date-time
|
|
@@ -809,7 +809,7 @@ export interface components {
|
|
| 809 |
sorts?: components["schemas"]["Sort"][];
|
| 810 |
source_kind: string;
|
| 811 |
/** @enum {string} */
|
| 812 |
-
source_sync: "synced" | "synced_date_only" | "edited" | "not_applicable" | "never_synced";
|
| 813 |
source_sync_reason?: string;
|
| 814 |
/**
|
| 815 |
* Format: date-time
|
|
|
|
| 82 |
permitted: boolean;
|
| 83 |
reason?: string;
|
| 84 |
/** @enum {string} */
|
| 85 |
+
source_sync: "synced" | "synced_date_only" | "edited" | "not_applicable" | "never_synced" | "stale";
|
| 86 |
source_sync_reason?: string;
|
| 87 |
/**
|
| 88 |
* Format: date-time
|
|
|
|
| 116 |
retrieved_at?: string | null;
|
| 117 |
source_kind?: string;
|
| 118 |
/** @enum {string} */
|
| 119 |
+
source_sync: "synced" | "synced_date_only" | "edited" | "not_applicable" | "never_synced" | "stale";
|
| 120 |
source_sync_reason?: string;
|
| 121 |
/**
|
| 122 |
* Format: date-time
|
|
|
|
| 809 |
sorts?: components["schemas"]["Sort"][];
|
| 810 |
source_kind: string;
|
| 811 |
/** @enum {string} */
|
| 812 |
+
source_sync: "synced" | "synced_date_only" | "edited" | "not_applicable" | "never_synced" | "stale";
|
| 813 |
source_sync_reason?: string;
|
| 814 |
/**
|
| 815 |
* Format: date-time
|