Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/sync_alerts.py +14 -10
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "c64651c93",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
c64651c93
|
api/sync_alerts.py
CHANGED
|
@@ -29,8 +29,8 @@ AMAZON_NOT_OFFERED = "Amazon does not offer this report to this seller account"
|
|
| 29 |
AMAZON_ROLE = re.compile(r"has not granted access|access to requested resource is denied", re.I)
|
| 30 |
# A missing role is a standing account fact: it alerts once and never reminds.
|
| 31 |
ONCE_CODES = frozenset({"role"})
|
| 32 |
-
# A throttle alerts only when it repeats on this many passes in a row.
|
| 33 |
-
REPEAT_CODES = {"throttled": 2}
|
| 34 |
|
| 35 |
|
| 36 |
def utc_now():
|
|
@@ -65,8 +65,8 @@ _SCRUB = [
|
|
| 65 |
r"client_secret|password|passwd|pwd|signature|sig)=)[^&\s\"']+"), r"\1[masked]"),
|
| 66 |
(re.compile(r"(?i)\b((?:access_token|refresh_token|client_secret|password|secret|api_key)"
|
| 67 |
r"[\"']?\s*[:=]\s*[\"']?)[^\s,;\"'}]+"), r"\1[masked]"),
|
| 68 |
-
# A long run holding a digit and a letter is a key;
|
| 69 |
-
(re.compile(r"\b(?=[\w\-+/=]*\d)(?=[\w\-+/=]*[A-Za-z])[\w\-+/=]{32,}"), "[token]"),
|
| 70 |
]
|
| 71 |
|
| 72 |
|
|
@@ -229,8 +229,10 @@ def _due(alert, now):
|
|
| 229 |
return None
|
| 230 |
|
| 231 |
|
| 232 |
-
def _reconcile(document, tenant, connector, current, observed, now, claim, quiet=frozenset()):
|
| 233 |
-
"""Fold this pass into the document; return the plan of what this pass must send.
|
|
|
|
|
|
|
| 234 |
document = document if isinstance(document, dict) else {}
|
| 235 |
alerts = document.setdefault("alerts", {})
|
| 236 |
recovered = document.setdefault("recovered", {})
|
|
@@ -251,7 +253,7 @@ def _reconcile(document, tenant, connector, current, observed, now, claim, quiet
|
|
| 251 |
if alert is None and alert_id in recovered:
|
| 252 |
# Failing again before its RECOVERED went out: the owner never heard it cleared.
|
| 253 |
alert = {k: v for k, v in recovered.pop(alert_id).items() if k != "cleared_at"}
|
| 254 |
-
if alert is None:
|
| 255 |
# The same key under a new code is the same failure: it keeps what the owner was told.
|
| 256 |
prior = next((v for a, v in mine.items() if a not in current and v.get("key") == failure["key"]
|
| 257 |
and v.get("sent_at")), None)
|
|
@@ -375,11 +377,13 @@ def _mark(document, tenant, connector, plan, now, claim, delivered):
|
|
| 375 |
|
| 376 |
# ---- entry point ----------------------------------------------------------------------------
|
| 377 |
|
| 378 |
-
def notify(tenant, connector, failures, *, observed=None, now=None, sender=None, store=None, quiet=None
|
|
|
|
| 379 |
"""Record this pass's failures and send at most one Telegram line; never raises.
|
| 380 |
|
| 381 |
`failures` is the full current list for the tenant and connector; [] means healthy.
|
| 382 |
`observed` limits clearing to the keys this pass checked; None means the list is complete.
|
|
|
|
| 383 |
"""
|
| 384 |
result = {"ok": False, "sent": False, "failed": [], "reminder": [], "recovered": [], "cause": None}
|
| 385 |
try:
|
|
@@ -396,12 +400,12 @@ def notify(tenant, connector, failures, *, observed=None, now=None, sender=None,
|
|
| 396 |
# Save first, so a delivery marker from a past pass is never re-sent.
|
| 397 |
quiet = frozenset(str(key) for key in (quiet or ()))
|
| 398 |
document = store.update(DOCUMENT, lambda doc: _reconcile(
|
| 399 |
-
doc, tenant, connector, current, observed, now, claim, quiet))
|
| 400 |
plan = _plan_of(document or {}, tenant, connector, now, claim)
|
| 401 |
if plan is None or not any(plan.values()):
|
| 402 |
result.update(ok=True, cause=None if plan is not None else "another pass is sending")
|
| 403 |
return result
|
| 404 |
-
text = compose(tenant, connector, plan, document)
|
| 405 |
try:
|
| 406 |
response = (sender or default_sender)(text)
|
| 407 |
delivered, detail = (response if isinstance(response, tuple) and len(response) == 2
|
|
|
|
| 29 |
AMAZON_ROLE = re.compile(r"has not granted access|access to requested resource is denied", re.I)
|
| 30 |
# A missing role is a standing account fact: it alerts once and never reminds.
|
| 31 |
ONCE_CODES = frozenset({"role"})
|
| 32 |
+
# A throttle or a held table alerts only when it repeats on this many passes in a row.
|
| 33 |
+
REPEAT_CODES = {"throttled": 2, "held": 2}
|
| 34 |
|
| 35 |
|
| 36 |
def utc_now():
|
|
|
|
| 65 |
r"client_secret|password|passwd|pwd|signature|sig)=)[^&\s\"']+"), r"\1[masked]"),
|
| 66 |
(re.compile(r"(?i)\b((?:access_token|refresh_token|client_secret|password|secret|api_key)"
|
| 67 |
r"[\"']?\s*[:=]\s*[\"']?)[^\s,;\"'}]+"), r"\1[masked]"),
|
| 68 |
+
# A long run holding a digit and a letter is a key; snake_case and hashed ut_ table names are not.
|
| 69 |
+
(re.compile(r"\b(?!ut_)(?=[\w\-+/=]*\d)(?=[\w\-+/=]*[A-Za-z])[\w\-+/=]{32,}"), "[token]"),
|
| 70 |
]
|
| 71 |
|
| 72 |
|
|
|
|
| 229 |
return None
|
| 230 |
|
| 231 |
|
| 232 |
+
def _reconcile(document, tenant, connector, current, observed, now, claim, quiet=frozenset(), carry=True):
|
| 233 |
+
"""Fold this pass into the document; return the plan of what this pass must send.
|
| 234 |
+
|
| 235 |
+
`carry=False` sends a key whose code changed as a new failure instead of keeping what was told."""
|
| 236 |
document = document if isinstance(document, dict) else {}
|
| 237 |
alerts = document.setdefault("alerts", {})
|
| 238 |
recovered = document.setdefault("recovered", {})
|
|
|
|
| 253 |
if alert is None and alert_id in recovered:
|
| 254 |
# Failing again before its RECOVERED went out: the owner never heard it cleared.
|
| 255 |
alert = {k: v for k, v in recovered.pop(alert_id).items() if k != "cleared_at"}
|
| 256 |
+
if alert is None and carry:
|
| 257 |
# The same key under a new code is the same failure: it keeps what the owner was told.
|
| 258 |
prior = next((v for a, v in mine.items() if a not in current and v.get("key") == failure["key"]
|
| 259 |
and v.get("sent_at")), None)
|
|
|
|
| 377 |
|
| 378 |
# ---- entry point ----------------------------------------------------------------------------
|
| 379 |
|
| 380 |
+
def notify(tenant, connector, failures, *, observed=None, now=None, sender=None, store=None, quiet=None,
|
| 381 |
+
composer=None, carry=True):
|
| 382 |
"""Record this pass's failures and send at most one Telegram line; never raises.
|
| 383 |
|
| 384 |
`failures` is the full current list for the tenant and connector; [] means healthy.
|
| 385 |
`observed` limits clearing to the keys this pass checked; None means the list is complete.
|
| 386 |
+
`composer(tenant, connector, plan, document)` writes the message for a sender other than Telegram.
|
| 387 |
"""
|
| 388 |
result = {"ok": False, "sent": False, "failed": [], "reminder": [], "recovered": [], "cause": None}
|
| 389 |
try:
|
|
|
|
| 400 |
# Save first, so a delivery marker from a past pass is never re-sent.
|
| 401 |
quiet = frozenset(str(key) for key in (quiet or ()))
|
| 402 |
document = store.update(DOCUMENT, lambda doc: _reconcile(
|
| 403 |
+
doc, tenant, connector, current, observed, now, claim, quiet, carry))
|
| 404 |
plan = _plan_of(document or {}, tenant, connector, now, claim)
|
| 405 |
if plan is None or not any(plan.values()):
|
| 406 |
result.update(ok=True, cause=None if plan is not None else "another pass is sending")
|
| 407 |
return result
|
| 408 |
+
text = (composer or compose)(tenant, connector, plan, document)
|
| 409 |
try:
|
| 410 |
response = (sender or default_sender)(text)
|
| 411 |
delivered, detail = (response if isinstance(response, tuple) and len(response) == 2
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
af7a5a888493e2c10373654ade66b370b017a9ab3ba7759b81fa4f35d8ede2ad
|