When new macOS releases, there is a chance that brew will be broken. But there is also a chance that brew developers are already working on support for the new macOS version. To try the newest brew version without waiting for it to get into the stable branch you can do the following:
In this example, use feature branch for macOS 15 support
cd `brew --cellar`
git checkout macos-15