I invented a requirement, built around it, then asked other teams to accommodate it
I want to write up a mistake I made recently, because the bug wasn’t in the code. The code worked. The tests passed. The mistake was that I built something nobody asked for, forgot that I’d made it up, and then started treating it as a fixed point that other parts of the system had to bend around.
What the design actually said
I was implementing authentication for long-lived streams in a service. The design was short and clear on this point: a stream’s first message carries the caller’s access token, nothing is delivered until that token verifies, and the stream is closed if verification doesn’t happen within a few seconds of opening. The prose went further and said, more or less, that this token is the same one every other request uses, and that no other credential exists for a stream.
That was the whole rule. Nothing about re-authenticating an open stream. Nothing about the stream’s lifetime being tied to the token’s expiry. Nothing about a “renew” message.
Our project has an explicit convention: anything the documentation doesn’t say is an implementation detail. So the smallest correct implementation was obvious in hindsight. Verify the first message, then hold the stream open until one side closes it. Done.
What I built instead
Access tokens in our system expire after a fairly short window. Somewhere in my head, “the token expires” became “the stream’s authentication expires”, and I never stopped to notice that those are two different claims. The design made the first one. I made the second one.
So I built a renewal protocol:
- A new message type a client sends to refresh its standing on an open stream.
- A server-side timer armed on the opening token’s expiry, which closes the stream if no renewal arrives, with a helpful-sounding error telling the client to reconnect with a fresh token.
- A principal check so that a renewal from a different identity kills the stream.
- A client-side loop that polls the token source on an interval and sends a renewal whenever a newer token appears.
- Plumbing in the CLI and the remote client library to keep that loop fed with fresh tokens.
I documented all of this in module docs and wrote the end-to-end test harness to speak the same protocol. The commit message described the behaviour plainly and confidently. It just didn’t trace back to anything in the design, and I didn’t notice, because by the time I was writing the commit message the behaviour already felt like a requirement.
How it spread
This is the part that actually bothers me.
Later, while working on routing these streams through a gateway, I found a real problem: the gateway relayed stream frames unchanged, so a client coming through it would present a credential type the backend’s verifier wouldn’t accept. Legitimate bug, needed a fix.
My recommended fix was for the gateway to exchange the token in the first message. Fine. But then I kept going: the gateway also had to parse and rewrite renewal messages, “otherwise a relayed stream dies when the short-lived token expires.” I rejected an alternative approach partly because it “still left renewal unsolved.”
Read that back. I was asking another component to understand and rewrite a message type whose only reason for existing was a decision I’d made alone, in code, without writing it down anywhere the design lived. The “has to” in my recommendation didn’t trace to a requirement. It traced to me.
The rationale came second
When someone asked the obvious question — why does renewal need to exist at all? — I had to admit that no requirement asked for it, that it was an implementation choice, and that it didn’t actually prove identity. If the connection has been open the whole time, the entity on the other end hasn’t changed. Re-sending a token doesn’t tell you anything the open socket doesn’t already tell you.
I then reached for revocation as the justification. But revocation wasn’t in the stream design either, renewal only approximates it (a revoked credential still works until the next expiry), and the auth service already publishes revocation events that the stream server could simply subscribe to. I had invented the constraint first and gone looking for a reason afterwards. That ordering is the tell.
Even when I finally laid out the alternatives, I ranked “close the stream when its token expires” at the top — which is the same unstated premise, just without the renewal machinery. The person reviewing chose the option I should have started from: streams stay authenticated by their first message, and revocation is handled by the events that already exist for it.
The design now has an explicit requirement stating that a stream remains authenticated beyond its opening token’s expiry. That requirement exists to forbid something the design never permitted. We had to write it down because I’d made the absence ambiguous.
What I should have done
In the implementation: the smallest thing that satisfied the stated requirements. First-message verification, a timeout on that verification, and nothing else. No renew message, no expiry timer, no client refresh loop.
If I believed there was a gap: say so where design decisions get made. “The design doesn’t say when a stream’s standing ends; revocation currently never reaches an open stream” is a perfectly good issue to file. It changes the wire protocol, the client library’s contract, and what every consumer observes. That’s a design question by any reasonable definition, and I resolved it silently in a feature commit instead.
In the later analysis: separate what the design requires from what the implementation happens to do. “The gateway must exchange the first message’s token” is a requirement. “The gateway must also handle renewal” is an artifact. I should have flagged the second as undocumented behaviour and asked whether to keep it before proposing that anything else adapt to it.
The pattern I’m going to watch for
Stated generally: add a constraint the design doesn’t name, build machinery to satisfy it, then propose that other components change to accommodate the machinery. The signals, so I can catch it earlier next time:
- A protocol message, state, or timer that no requirement names, and whose removal would still satisfy every requirement. If I can delete it and nothing in the spec breaks, I should ask why it’s there.
- A commit or module doc describing behaviour the design page for that domain doesn’t mention. The commit message is a good place to catch this, because it’s where I’m forced to say what I did in plain words.
- A recommendation that says another component “has to” do something, where the “has to” traces to a prior implementation choice rather than to a requirement.
- A rationale I can only produce when asked, or that invokes a goal the system already serves some other way.
The concrete check I’m adopting: for every behaviour a change introduces, name the requirement it satisfies. If I can’t, it’s either an implementation detail — in which case it must never shape another component’s design — or it’s a design gap, in which case it gets filed and decided in the docs before it gets built. Not after.
The frustrating thing is that none of this required better engineering. The renewal code was fine. It required me to notice the moment a reasonable-sounding assumption turned into a requirement in my head, and to go check whether anyone had actually written it down. Nobody had. I should have looked.