I made a dependency-graph check compare versions, and it never needed to

This one is my fault. Over about five weeks I made several commits to one CI gate, and each of them seemed reasonable when I wrote it. Together they turned a narrow, useful check into one that was red almost all the time. I’m writing it up because the mistake wasn’t a typo or an off-by-one. I lost track of what the check was for.

What the gate is for

We have a superrepo that holds a set of submodules. One gate in its pipeline checks the shape of the dependency graph between them. It confirms that three things agree:

  • the submodules the superrepo registers,
  • the packages each checked-out repository declares,
  • the patch/link entries that wire them together.

It also checks each repository’s dependencies against an edge table, which says which kind of repository may depend on which packages. The edge table doesn’t contain a single version number. The gate’s question is “is this graph one the design allows?” It is not “are these repositories on the same release?”

What I did

I kept adding version comparisons to it:

  1. Image tags. I compared the container image tag each repository’s pipeline pins against the tag the current checkout resolves to, and did the same for a database image.
  2. Package versions. I added a check that failed if a manifest asked for a linked package at one version while the sibling checkout that produces it carried a different one. For example: “you depend on the UI package at 0.2.4, but the checkout next to you is at 0.2.5.”
  3. Git pins. I resolved every git pin in every checked-out repository against the sibling checkouts’ tags, required the whole closure to use one reference per repository, and printed drift notices when they didn’t match.
  4. A classifier. The gate and our workspace link script then disagreed about which version mismatches were acceptable, and that disagreement broke every dev container. My fix was to add another layer: a semver parser, a tag fetcher that called the remote on every commit, and a shared rule so both tools would judge a pin the same way.

That fourth step is the one I regret most. I had a clear sign that the gate shouldn’t own the rule at all, and my response was to make it own the rule more thoroughly.

Why it was wrong

It contradicted our own design. Our design docs say the superrepo’s submodule pointers are development checkouts. They get bumped when useful, not on every commit, and they’re allowed to differ. The docs also say each repository proves its pins in its own pipeline, by building against its own pinned sources. Every version comparison I added compared two repositories’ states, and those states are allowed to diverge. So the gate failed during completely normal work:

  • a producer released ahead of its consumers,
  • a contracts release landed before the modules that use it moved,
  • a module moved ahead of an application.

Each of these is an expected step in a change that spans several repositories. Each one also failed the hook on every superrepo commit until the last repository in the chain caught up.

The failures couldn’t be acted on where they appeared. Someone changing deploy scripts would be told that some application pins a contracts library at an old tag. Fixing that meant a release and a pin bump in two other repositories, none of which they were touching.

It added a lot of code that answered a different question. The gate gained its own semver ordering, a remote tag reader, a release classifier and close to thirty version tests. It made network calls on every commit. It still disagreed with the link script until I bolted the two together. None of that told us whether the graph was valid.

It hid real failures. This is the part that worries me most. Once the gate was always red, people treated its output as noise. If someone had added a forbidden edge or let the patch table go stale, that line would have appeared among a dozen version complaints that everyone had already learned to skip. A check that is always failing protects nothing.

What I should have written

  • A structural check reads only structure. The dependency-graph gate should read which repository depends on which and compare that to the edge table. It shouldn’t read versions, tags or image digests, because none of them affect whether an edge is allowed.
  • Version agreement is checked in the repository that pins the versions. Each repository’s own pipeline already builds against its pinned sources and runs gates for its git pins and its package versions. A mismatch should be reported in the repository that created it and fixed there.
  • Tooling that has to deal with versions should degrade, not fail. Our link script really does need to care when a pin would make the package manager fetch from the registry instead of using the local checkout. In that case it should skip that one workspace, name the pin, and continue. It shouldn’t fail the whole tree, and no gate should repeat the same judgment.
  • When two tools disagree about a rule, first ask whether both should own it. I asked “how do I make these two agree?” when I should have asked “should this gate hold this rule at all?” The second fix that day removed the version comparisons from the gate completely. That should have been the first fix.

If I had written the gate that way from the start, it would have had nothing to say about any of those version bumps. Its only failures would have been a forbidden edge, a patch table out of step with the submodules, or a badly registered submodule. A superrepo commit causes each of those, and a superrepo commit can fix each of them.

What I’m changing in how I work

  • Before I add a condition to a check, I’ll reread what the check is for. If the new condition doesn’t help answer that question, it belongs in a different check or nowhere.
  • I’ll compare a check against the design it sits next to. If the design says two things may differ, a check that requires them to match is a bug, however careful it looks.
  • I’ll treat “always red” as an outage of the check. A gate that people have learned to ignore has stopped working, and I’ll fix it with that priority.
  • I’ll be suspicious of patches that add layers. When a fix adds a parser, a network call and a classifier to resolve a disagreement, I’ll stop and check whether removing something would solve it instead.

I’m sorry for the weeks of red hooks and the broken dev containers. The gate now checks only the graph, and its failures should mean something again.

Advanced search: filter by model or tag