mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-08-26 12:23:06 +02:00
fix: complete intelligence layer refreshes and UAP fallback
This commit is contained in:
@@ -878,6 +878,40 @@ def _load_nuforc_sightings_cache(*, force_refresh: bool = False) -> list[dict] |
|
||||
return None
|
||||
|
||||
|
||||
def _load_nuforc_last_known_sightings() -> list[dict] | None:
|
||||
"""Return the last non-empty snapshot for display when refresh is unavailable.
|
||||
|
||||
This deliberately skips freshness and rolling-window checks. It is only a
|
||||
stale-data safety net after a refresh has produced no usable rows; the
|
||||
normal cache loader remains strict so stale data is never presented as
|
||||
fresh.
|
||||
"""
|
||||
with _data_lock:
|
||||
current = latest_data.get("uap_sightings")
|
||||
if isinstance(current, list):
|
||||
in_memory = [row.copy() for row in current if isinstance(row, dict)]
|
||||
if in_memory:
|
||||
return in_memory
|
||||
|
||||
if not _NUFORC_SIGHTINGS_CACHE_FILE.exists():
|
||||
return None
|
||||
try:
|
||||
raw = json.loads(_NUFORC_SIGHTINGS_CACHE_FILE.read_text(encoding="utf-8"))
|
||||
sightings = raw.get("sightings")
|
||||
if not isinstance(sightings, list):
|
||||
return None
|
||||
last_known = [row.copy() for row in sightings if isinstance(row, dict)]
|
||||
if last_known:
|
||||
logger.warning(
|
||||
"UAP sightings: using %d last-known cached reports because the refresh returned no usable rows",
|
||||
len(last_known),
|
||||
)
|
||||
return last_known or None
|
||||
except Exception as e:
|
||||
logger.warning("UAP sightings: last-known cache load error: %s", e)
|
||||
return None
|
||||
|
||||
|
||||
def _save_nuforc_sightings_cache(sightings: list[dict]) -> None:
|
||||
if not sightings:
|
||||
logger.warning("UAP sightings: refusing to save empty daily cache")
|
||||
@@ -1693,9 +1727,17 @@ def fetch_uap_sightings(*, force_refresh: bool = False):
|
||||
if sightings:
|
||||
sightings = _filter_uap_sightings_recent(sightings)
|
||||
|
||||
fresh_snapshot = bool(sightings)
|
||||
if not sightings:
|
||||
sightings = _load_nuforc_last_known_sightings()
|
||||
if sightings:
|
||||
logger.warning(
|
||||
"UAP sightings: retaining last-known snapshot; current refresh did not produce usable recent reports"
|
||||
)
|
||||
|
||||
with _data_lock:
|
||||
latest_data["uap_sightings"] = sightings or []
|
||||
if sightings:
|
||||
if fresh_snapshot:
|
||||
_mark_fresh("uap_sightings")
|
||||
return
|
||||
|
||||
|
||||
@@ -17,7 +17,18 @@ _INSTANT_LAYER_KEYS: frozenset[str] = frozenset(
|
||||
# Background — network-bound OR large local scans (full CCTV SELECT can stall
|
||||
# the single uvicorn worker if run inline on enable).
|
||||
_SLOW_LAYER_KEYS: frozenset[str] = frozenset(
|
||||
{"cctv", "firms", "psk_reporter", "fishing_activity"}
|
||||
{
|
||||
"cctv",
|
||||
"firms",
|
||||
"psk_reporter",
|
||||
"fishing_activity",
|
||||
"uap_sightings",
|
||||
"malware_c2",
|
||||
"cyber_threats",
|
||||
"scm_suppliers",
|
||||
"telegram_osint",
|
||||
"gt_risk",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -85,6 +96,42 @@ def _slow_fetch(key: str) -> None:
|
||||
fetch_fishing_activity()
|
||||
logger.info("Fishing activity loaded (layer enabled)")
|
||||
return
|
||||
if key == "uap_sightings":
|
||||
from services.fetchers.earth_observation import fetch_uap_sightings
|
||||
|
||||
fetch_uap_sightings()
|
||||
logger.info("UAP sightings loaded (layer enabled)")
|
||||
return
|
||||
if key == "malware_c2":
|
||||
from services.fetchers.malware import fetch_malware_threats
|
||||
|
||||
fetch_malware_threats()
|
||||
logger.info("Malware C2 loaded (layer enabled)")
|
||||
return
|
||||
if key == "cyber_threats":
|
||||
from services.fetchers.cyber_status import fetch_cyber_threats
|
||||
|
||||
fetch_cyber_threats()
|
||||
logger.info("Cyber threats loaded (layer enabled)")
|
||||
return
|
||||
if key == "scm_suppliers":
|
||||
from services.scm.suppliers import fetch_scm_suppliers
|
||||
|
||||
fetch_scm_suppliers()
|
||||
logger.info("SCM suppliers loaded (layer enabled)")
|
||||
return
|
||||
if key == "telegram_osint":
|
||||
from services.fetchers.telegram_osint import fetch_telegram_osint
|
||||
|
||||
fetch_telegram_osint()
|
||||
logger.info("Telegram OSINT loaded (layer enabled)")
|
||||
return
|
||||
if key == "gt_risk":
|
||||
from analytics.integration import maybe_refresh_gt_analytics
|
||||
|
||||
maybe_refresh_gt_analytics()
|
||||
logger.info("Strategic Risk Analytics refreshed (layer enabled)")
|
||||
return
|
||||
raise KeyError(key)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user