Repository navigation
refactor(bot)!: remove gateway sharding - #199
Merged
Merged
Conversation
Sturnus serves one guild per installation, so the bot holds one Discord gateway connection. The sharded client, per-shard readiness and the shard_id log field were built for many guilds and only made /readyz wait for shards that never exist. - SturnusClient is a commands.Bot again. on_ready reconciles every guild. - on_disconnect clears the single gateway flag and logs one WARNING (bot.disconnected); on_resumed sets the flag and logs INFO (bot.resumed). - ReadinessState is one gateway flag plus the database flag. - STURNUS_SHARD_COUNT is removed from settings, chart and docs. A leftover value is ignored and logged once at startup. - application/sharding.py and its tests are deleted. BREAKING CHANGE: STURNUS_SHARD_COUNT is gone; the bot holds a single gateway connection and /readyz reports that one connection.
TheMeinerLP
force-pushed
the
refactor/remove-gateway-sharding
branch
from
November 8, 2026 12:19
86a80b7 to
2cc3a4f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sturnus is installed for one guild, but the bot was still built for many. It opened several gateway connections (shards) and kept per-shard state for them. From the operator's side that showed up in three places:
/readyzwaited for "every shard this process is supposed to hold", a rule that only means something for a bot in thousands of guilds. The probe body reported shard numbers that were the same for every installation.on_readyno longer ran the way discord.py code expects. The reconcile had moved into a per-shard hook, so the usual place to look for it was empty.shard_idthat is0on every line, anddocs/operations.mdsection 3.6 explained a mechanism nobody could use.Discord only asks for sharding from 2,500 guilds on (gateway docs). One guild is far below that, so the decision is to hold one gateway connection, let
/readyzreport that one connection, and removeSTURNUS_SHARD_COUNT.The failure this prevents is a readiness probe that can go red for a state that cannot occur, and a pod that crash-loops over a leftover variable. A deployment that still sets
STURNUS_SHARD_COUNTstarts normally and logs once that the variable is ignored. Unset it after upgrading.This is the first part of the OpenSpec change
remove-multi-guild-machinery. The removal of per-guild OAuth sign-in and its migration ship in a separate PR. The change as a whole needssingle-guild-instancedeployed first, as its proposal states.Checks
pytest2724 passed ·ruff checkandruff format --checkclean ·mypyno issues in 293 files ·helm template charts/sturnusrendersBEGIN_COMMIT_OVERRIDE
refactor(bot)!: remove gateway sharding
BREAKING CHANGE: STURNUS_SHARD_COUNT is gone. The bot holds a single gateway connection, and /readyz reports that one connection.
END_COMMIT_OVERRIDE