r/RuneCast • u/CycleFive • Oct 08 '26
Turned it around on the last turn with "Hickory"
r/RuneCast • u/CycleFive • Oct 08 '26
r/RuneCast • u/CycleFive • Oct 08 '26
Every time you open RuneCast in Discord, the game first asks Discord who you are. Starting with backend v0.42.0, that conversation runs on catacombs, an open-source Rust crate that began life as RuneCast's own login code.
It's MIT-licensed. Version 0.2.0 went up on crates.io on October 6, and it now signs people in to two of our projects: RuneCast, and the CrackTunes web dashboard.
I wrote RuneCast's Discord login myself: the OAuth code exchange, a signed session, refresh tokens encrypted at rest, and a check of who had bought premium. It was ironically perhaps the most time-consuming piece of the original RuneCast code to get working. I recognized, as I was building it, that I had a module that was useful more generally than to RuneCast and that, while required for the game to function, had almost nothing whatsoever to do with the actual playing of RuneCast. Any Discord app that wants to know who its users are needs the same routes and the same careful token handling.
RuneCast itself was playable and released on Discord right around Christmas of last year, and by January I had already pulled out the part of the code that RuneCast used for OAuth, got it working, and put it up on GitHub as an open-source module.
I am fundamentally a believer in open source and so I try to build in public and release under a permissive open-source license, and where that isn't done or isn't possible, I still try to carve out useful tools or modules that get built along the way and release those under MIT and/or Apache. sleevenote, which resolves music links for CrackTunes without an API key, came out the same way. So did serve-the-source, from our websites' build.
What brought catacombs back to life recently was CrackTunes, whose new web dashboard needed "Log in with Discord" for an ordinary website. That became catacombs 0.1.0 on September 30, the same day CrackTunes v0.15.0 shipped the dashboard on top of it. It took until just this week to finally get catacombs onto crates.io and integrate it properly with RuneCast. CrackTunes, still on 0.1, moves to 0.2 next.
catacombs adds "Log in with Discord" to a Rust web service built on axum. Your handlers ask for an AuthenticatedUser and never touch a token:
async fn hello(user: AuthenticatedUser) -> String {
format!("Hello, {}!", user.username)
}It covers both ways people sign in with Discord:
/auth/exchange and get a session token back. That's RuneCast./auth/login. catacombs redirects them to Discord, checks the state that comes back, sets an HttpOnly session cookie, and returns them to the page they started on. That's the CrackTunes dashboard.Around that:
Storage trait instead, and catacombs works on top of it.AuthObserver hears about every login attempt: who, how long it took, and why it failed.Swapping out a game's login is easy to get wrong in ways nobody notices until players can't get in. So the switch had one rule: nobody gets logged out, and nothing about the login changes unless we wrote it down first.
First, pin what RuneCast does today. Before touching the login, we wrote a contract suite of dozens of tests that drives every login route through RuneCast's real server against a stand-in Discord. That stand-in records everything sent to it. The tests check status codes, the exact fields of each response, what gets stored, that refresh tokens are encrypted, and that a session signed by the old code is still accepted by the new one. They all passed against the old login, and then against catacombs. Only one file of tests was allowed to change: the list of deliberate differences.
Then, plug catacombs into RuneCast's own tables. catacombs 0.2 lets an app bring its own storage. RuneCast's adapter is a couple hundred lines over the tables players' accounts already live in. No database migration, same session format, same token encryption. Rolling back is redeploying the previous version.
Then, delete. RuneCast's login handlers went from over a thousand lines to roughly half that, and the game's source shrank by several hundred lines overall.
The tests also caught things on both sides:
Each of those is now fixed, in catacombs 0.2.0 or in RuneCast. That's the payoff of extracting a library: the second user finds what the first one never would.
Almost nothing, which was the point. You stay logged in across the update, your stats and premium are where you left them, and the game opens the same way.
Two small things change behind the scenes:
If you're building a Discord Activity, a bot dashboard, or any Rust site that should let people sign in with Discord:
[dependencies]
catacombs = "0.2"It has two users in production, RuneCast and the CrackTunes dashboard, one for each login flow. If you make it a third, or it doesn't fit your app, open an issue. That's exactly the feedback a young library needs.
The exact figures behind the rounded ones, as of RuneCast backend v0.42.0:
RuneCast is a word game that runs as a Discord Activity: runeca.st. This post is also on the Cycle Five blog: cyclefive.xyz/blog/catacombs. I wrote where it came from; the rest was drafted with Claude and we edited it together.
r/RuneCast • u/CycleFive • Oct 01 '26
The Continuous Integration / Development process (CI/CD) for any non-trivial software project is important; it is this which exercises your code, makes it breathe, jump, fly, choke, crash and burn -- preferably before the code makes it to production. At the size and complexity of RuneCast this is especially true, and inefficiencies that used to be slight annoyances become choke points for development. Cue xkcd 303, "Compiling".
With this in context, I was ecstatic early this morning working on fixing some UI bugs with Claude and we were able to reduce the most expensive chunk of the pipeline by over 50% (upon further testing more like 70-80%). It all had to do with unnecessary dependencies I had invented for a small convenience -- and which turned out to have a "degenerate" effect on the reproducability of the build by forcing multiple and redundant builds for every release, merge, and tag.
Our CI was spending about 28 minutes of runner time per release rebuilding an image that already existed. The cause was a variable whose entire job was to print the time it was built -- and which, by existing, stopped the same commit from producing the same image upon repeated builds.
A release in our repos does two things in quick succession: merge to master, then push a version tag at that same commit. Both are push events. Both fire an image-publishing workflow. This has the effect of building the same image twice because the release gets tagged both as vX.Y.Z and master (and latest).
I had come upon this before earlier in the week (maybe last week?) and fixed it — or thought I had. The two runs were racing: the tag run started before the master run had written the shared build cache, so it got no cache and recompiled everything from scratch. The fix was a concurrency key on the commit SHA, so the second run waits for the first and reads the cache it just wrote.
That was a real improvement, and it is also the wrong question answered well. I had made the redundant compile cheaper instead of asking why it was happening at all. The comment I left in the workflow even said so, in a way I did not hear at the time: "neither is redundant — only their compiles were."
We run two self-hosted CI runners. Here is what the last five backend releases actually looked like:
| run | wall clock | of which |
|---|---|---|
| master push | 29–37 min | the build |
| tag push | 51–62 min | ~35 min waiting for the first run, then ~28 min rebuilding |
So the cache was helping — 28 minutes beats 35 — and the whole thing was still absurd. Roughly an hour of runner time per release, on two runners, with every open PR's CI queued behind it. We also published a debug variant (alpine with musl has no debug symbols by default) so each run built two images. Four builds for two distinct artifacts.
Then the story fell apart. I had been saying the two images were byte-identical, and I had checked: same manifest digest. But they were only identical because both runs write :latest and the tag run happened to finish last and overwrite it. The images themselves were not the same. One build argument differed.
It was RUNECAST_BUILD_TIME, and it came from date -u.
That was the reaction when I described the field: it serves no purpose other than to report the build time.
It is worth checking before believing. built_at has exactly three consumers: a tooltip, a "built …" line in a build-info widget, and a test asserting it is non-empty. Nothing branches on it. Our version-skew detection — the thing that actually cares whether a client is running stale code — uses the bundle hash and the build announced by the server, not this.
So it is inert. But it is not harmless, and the distinction is the whole point.
The intended relationship is image = f(commit). One commit, one image. With a clock reading as an input it becomes image = f(commit, t) where t is free — so commit → image stops being a function at all and becomes one-to-many. Every question of the form "which image is this commit?" loses its answer. That is not an abstraction: it is exactly why :latest and :v0.41.1 could disagree, and why "what is prod actually running?" needed a digest comparison rather than a glance.
The sharpest way I can put it:
The variable had entropy but no information. Nonzero variance, zero signal about anything anyone cared about.
That is noise, in the strict sense. And "degenerate" is the right word for it, in the rank-deficiency sense — treat the provenance record as a vector of facts (version, git_sha, git_describe, git_branch, dirty, built_at) and, once keyed properly, built_at lies in the span of git_sha. It adds no dimension. Before the fix it did add one, but the dimension it added was pure clock.
Use the commit date.
TZ=UTC git show -s --format=%cd --date=format:%Y-%m-%dT%H:%M:%SZ HEADThis is not a clever trick; it is the SOURCE_DATE_EPOCH convention that the Reproducible Builds project standardised years ago, and it is why the field keeps its name. built_at is the timestamp the build represents, not the moment a runner happened to execute.
The proof is two rebuilds, two seconds apart:
| backend | frontend |
|---|---|
| rebuild 1 | 07:25:38Z |
| rebuild 2 | 07:25:38Z |
| commit date | 07:25:38Z |
| wall clock at build | 12:57:13Z |
Before the change, those two rebuilds differed. After it, a rebuild of the same commit is idempotent.
Which means the actual saving is not the 28 minutes. It is that the tag run no longer needs to build anything: a tag is a name for an image, not a reason to produce one. When master has already published :sha-<sha>, the tag run now points :v0.41.1 at that exact manifest and exits. Seconds, no compile, and :sha-<sha>, :latest and :v0.41.1 are the same digest by construction rather than by whichever run finished last.
That re-tag was only safe once the build became reproducible. With a clock in the inputs, naming master's image :v0.41.1 would have been a guess that it was the right image.
The first build to run the new workflow came in at 17.0 minutes, against 29-37 before. That is the debug image alone -- one image per run instead of two.
The double build comes off on top of it. A release used to cost the master run plus another 22-27 minutes for the tag run to rebuild the same commit, so 52-64 minutes of runner time per release. It should now be about 17.
| before | after |
|---|---|
| build, per run | 29-37 min |
| images per run | 2 |
| tag run | 22-27 min rebuilding |
| runner time per release | 52-64 min |
Update: when I first wrote this, the re-tag was a projection; no release had run through the new workflow yet. The next one (v0.41.2, Sep 30) measured it: the master build took 12m37s, and the tag run took 23 seconds, a re-tag with no compile. That is about 13 minutes of runner time per release, against 52-64 before. Part of the drop from 17 to 12.6 minutes comes from a dependency cache (cargo-chef) that landed the same week, so not all of it belongs to the timestamp.
I have been thinking a lot recently on orthogonality, specifically in spectral contexts such as Fourier Transforms (Jacob Lurie has a great lecture on the Categorification of Fourier Theory that is not only a master class in the subject, but in how to give a great lecture), and orthogonal bases ideas in general. Happily for me this is another concept that comes up over and over again and almost seeming like a self-fulfilling prophecy -- anything I work on seems to have some tie to it.
The part I keep turning over is where this hid. It hid in metadata -- the category of thing we all agree is inert. Nobody audits a display field. Nobody writes a test for a tooltip. "It only reports itself" reads as a reason to stop looking, when it should be the opposite: a value that feeds nothing has no downstream pressure keeping it honest, so it is exactly where an undeclared input can sit for years.
The principle has a name specifically for use in build systems: hermeticity. A hermetic build depends only on its declared inputs. The timestamp at which the build happens to be run is an undeclared, ambient input, which in our case made it actively harmful, not just a little messy or unclean. The orthogonality concept comes in here because the build wall-clock time is an unrelated high entropy event that the build now has a dependency on (a random variable) which of course makes the outcome entirely non-deterministic. This ruins any sort of caching, or identity verification provenance.
The whole point of the build hash is that I, the author, provide a build hash I know is good. Then you, yes you Dear reader, download my code, build it, and get the same hash. Given you know and trust my key (which ideally means meeting irl to exchange and verify keys, but that's not a fight for here and now), you have a root of trust and an attestation chain from yourself, having just built the code and seen the hash, back to me with the trusted key and signed hash.
RuneCast is a word game that runs as a Discord Activity: runeca.st. I wrote the intro and the closing sections by hand. The middle was drafted with Claude from the session where we found this, and we edited it together.
r/RuneCast • u/CycleFive • Oct 01 '26
Two players in the same Discord voice channel, playing different modes of the same game in an activity, and they could see each other's tile selections on their own boards: someone else's finger dragging across your letters, in a game you weren't playing.
It was the sixth time in five months that one bug had shown up. This post is about why the first five fixes didn't hold, and what was different about the sixth.
The first useful question was not "what's broken?" but "what did the ghost look like?" It was a live selection trail: the other player tracing letters before submitting a word.
There is a message, selection_update, that is broadcast by a player when they make an update to the selected tiles on their board (during their turn) it is sent only to members of the sender's game: its players and spectators. So the ghosted player had to still be a member of the other game. That ruled out a whole class of theories (wrong broadcast scope, crossed lobby ids) and left one: membership.
RuneCast is a multiplayer word game that runs as a Discord Activity: a Rust backend, a TypeScript client, and a shared protocol crate. Every player in a voice channel shares one lobby. The family of bugs looks like this:
| date | incident | fix |
|---|---|---|
| May 31 | a Daily killed by multiplayer disconnect handling | a Daily short-circuit in the disconnect handler |
| Jun 23 | a stale game leaks across voice channels | lobby-scoping in the "which game is this user in?" lookup |
| Jun 25 | a paused Adventure hijacks a regular game | a sweep for stale Adventure state |
| Jul 14 | a reconnect yanks a player off their Daily board | a client-side resume path |
| Aug 4 | pressing Start conscripts players already mid-Daily | an "already in a live game" check |
| Sep 29 | other players' selections on your board | this post |
Every fix was a new guard at a new call site. By August, the rule "a player is in one game at a time" lived in at least six places, and none of them was the rule. Each guard was correct, and the bug kept coming back through a path no guard covered.
I gave the investigation one constraint from the start: neither player had pressed Spectate. The first read-only pass found three routes into "member of two games". All three needed a Spectate press, so all three looked ruled out.
A second, adversarial pass found that the code was doing the pressing:
And the client applied any game-scoped message it received without checking game_id, so every one of these turned into a ghost on screen.
The lesson I keep coming back to: "nobody pressed Spectate" rules out an action, not a state. The question that mattered was "can a user be a member of two games?", not "did a user ask to be?"
This time the rule got written down as numbered invariants, before any code. The backend spec, in short:
SetPlayerGame, is the only writer of a game's spectator list, and it first removes the user's spectator seats in every other game.The client got its own spec: one pure function, classifyGameMessage, with six rules for what a message is allowed to do based on its game_id. Accept it if it's for the game on screen; adopt a snapshot only for a game you asked to enter; while a solo run is live, only that game gets through; drop everything else. Every game-scoped listener in the client goes through that one function. There are 25 of them.
The two specs were written as two plans, one per repo, with a handoff section between them. That mattered: deploying the backend alone opened a window where a spectator whose connection blipped would see a frozen board, because only the new client knew to re-spectate. The plan named that window and said to ship the two close together. In practice it stayed open about 17 hours while the client half finished review.
I ran both plans with the Superpowers plugin's subagent-driven workflow. The backend had 12 tasks, the frontend 16.
The per-task and branch reviews were where the spec paid for itself. Things they caught before anything shipped:
The test suite had a say too. Fourteen end-to-end tests faked a spectate by flipping a flag and injecting a snapshot the client never asked for. The new guard correctly dropped those snapshots, so the tests failed. They now spectate the way the real app does. And one flaky RuneBox test got bisected across both backend versions instead of waved through: it failed the same way on the old version, so it's a test-helper race, not a regression.
Both halves are in production: backend v0.41.2 and client v0.73.2, about 9,800 lines changed across the two pull requests, tests and plans included. Shipping isn't the finish line, though. Every change like this gets a soak week: a week of real players on it, with the counters checked each day against the day before, before I call it fixed. Passing tests and a quiet first day are one observation, not proof. This one is in its soak week now.
It isn't finished. I2 only reports a player seated in two games; it doesn't make that impossible. The next step is a single record of which game each user is in, so a second membership can't be represented at all. The PRs list every known gap in writing, along with the counters that will tell us whether the invariants hold in production.
RuneCast is a word game that runs as a Discord Activity: runeca.st. This post was drafted with Claude from the plans, pull requests and session notes, and checked by me. The fix was built the same way: specs and plans drafted with Claude and approved by me, tasks done by Claude subagents, each one reviewed.
r/RuneCast • u/CycleFive • Jul 04 '26
Hey everyone! I'm u/CycleFive, solo developer of RuneCast https://discord.gg/mru3dpDAYv
I originally made this game as a replacement for SpellCast, which Discord retired last year, and it's grown far beyond what I originally planned, with features like daily leader boards, custom themes, and more in the works.