Spaces:
Runtime error
Runtime error
Fix: never emit Infinity in health JSON (strict JSON for browsers)
Browse files659 unmodified lines6606616626636646656662 unmodified lines669670671672673674675235 unmodified lines911912913914915916917659 unmodified lines"""Check if state is stale (not updated recently)."""last = self._last_write.get('state', 0)if last == 0:return True, float('inf')age = time.time() - lastreturn age > self._stale_threshold, age2 unmodified lineslast = self._last_write.get('state', 0)return {'last_write': datetime.fromtimestamp(last).isoformat() if last > 0 else 'NEVER','age_seconds': now - last if last > 0 else float('inf'),'is_stale': (now - last > self._stale_threshold) if last > 0 else True,'write_count': self._write_count,}235 unmodified linesif state_freshness['is_stale']:health = 'degraded' if health == 'healthy' else healthissues.append(f"State stale: {state_freshness['age_seconds']:.0f}s old")return {'status': health,659 unmodified lines6606616626636646656662 unmodified lines669670671672673674675676677235 unmodified lines913914915916917918919920921659 unmodified lines"""Check if state is stale (not updated recently)."""last = self._last_write.get('state', 0)if last == 0:return True, -1.0 # never written; -1.0 = unknown (never Infinity — strict JSON)age = time.time() - lastreturn age > self._stale_threshold, age2 unmodified lineslast = self._last_write.get('state', 0)return {'last_write': datetime.fromtimestamp(last).isoformat() if last > 0 else 'NEVER',# None when never written: float('inf') would serialize as the literal# `Infinity` token, which browsers cannot JSON.parse.'age_seconds': now - last if last > 0 else None,'is_stale': (now - last > self._stale_threshold) if last > 0 else True,'write_count': self._write_count,}235 unmodified linesif state_freshness['is_stale']:health = 'degraded' if health == 'healthy' else healthage = state_freshness.get('age_seconds')stale_detail = 'never written' if age is None else f"{age:.0f}s old"issues.append(f"State stale: {stale_detail}")return {'status': health,
aureon/core/aureon_operational_core.py+7-3