Book Deep-Read · Software Engineering at Google · Chapter 21
Software Engineering at Google · Ch 21 · Dependency Management · Titus Winters · 2020
No app on your phone was written from scratch. It uses parts other people built, and those parts use more parts, layer upon layer. Those borrowed parts are called "dependencies." This chapter asks: the owners of those parts can change them at any time, and you have no say — how do you keep the whole machine from falling apart over the years?
You'd think a part's version number tells you whether an upgrade is safe: a big version jump means be careful, a small one means go ahead. Google's experience is that a version number is just the author's guess. They think "I only fixed a tiny bug," yet some user was quietly relying on that bug. They think "this is a big change," yet you never used the part that changed — and you're still blocked from upgrading.
Picture a renovation: you hire a carpenter and an electrician, and both use screws from the same factory. The factory releases a new screw with a different thread. The carpenter switches; the electrician sticks with the old one — and your house can only take one kind. Neither tradesperson did anything wrong, yet your house won't go together. Worse, you're the one who finds out, and you're neither a carpenter nor an electrician. The bigger the web of parts, the more often "both sides are right, together it fails" happens.
For a small project with a few well-maintained parts, version numbers are good enough. When the web reaches thousands of parts and the project must live for decades, put the burden on the part's author: if you want to change it, first prove you didn't break anyone. The honest cost: this needs automated checks everywhere and huge amounts of computing to run them — today, only a company at Google's scale manages it, and only inside its own walls.
A dependency isn't a one-time loan but a long-term contract; a version number is only the other side's guess, and the reliable answer comes from running the checks of everyone who uses it.
Want to see why diamond dependencies are nearly hopeless in C++, how SemVer both overconstrains and overpromises, the logic of Minimum Version Selection, how to choose among four dependency models, and the gflags and AppEngine cautionary tales? → Switch to the deep read
You think dependency management is about picking the right version number; this chapter says a version number is only the provider's lossy estimate of compatibility, and at scale SemVer plus a solver both overconstrains and underprotects. Google's answer: turn dependency-management problems into source-control problems whenever you can, and in the long run make providers bring evidence from downstream tests — Live at Head.
Sixth chapter of Part IV, "Tools," following Ch 16 on version control: Ch 16 handles code you control, this chapter handles code you don't; it also sets up Ch 22, "Large-Scale Changes." Real-world counterparts: npm, pip, Maven, Cargo, Go modules.
Dependency management governs a network of libraries and packages we don't control: how to update between versions, how to describe versions, what changes dependencies may make, and when it's wise to depend on another organization's code. Its boundary with source control is a single question: does our organization control the development and updates of this subproject?
In source control, you change a line, run the tests, and see who uses it. In dependency management, upstream changes happen out of your sight and are more likely to break your build. At scale you depend on a whole network, and at some point two dependencies can't both be satisfied. The author admits Google has no firsthand evidence of a solution that works well across organizations at scale; much of the chapter summarizes what doesn't work.
The central difficulty is conflicting requirements: two nodes in the network demand mutually exclusive things, and you depend on both. The canonical form is the diamond dependency, which needs at least three layers:
libbase makes an incompatible change; liba and libb belong to different organizations and don't upgrade together — one needs v1, the other v2, and libuser has no general way to put them together. A diamond can form at any depth. It's more common than it looks: requirements on the OS, language version, or compiler version are all isomorphic to a hidden node in the graph.
Java can cushion this with shading (renaming a dependency's symbols so each user carries its own copy); C++ has nearly zero tolerance — two definitions violate the One Definition Rule and trigger undefined behavior. But renaming is only half a fix: once types cross dependency boundaries — a map from v1 handed to a v2 API — there's no semantically consistent answer.
When you hit one, you can only skip forward or backward in versions to find a compatible set, or patch locally — and the person who discovers the problem is usually the one who understands it least: only you, pulling in both, run into it. If a security fix forced the upgrade, downgrading is off the table too. The author boils the whole field down to one question: how do we avoid conflicting requirements while still allowing change among noncoordinating groups?
Reuse beats rewriting — no one should write their own JSON parser. But once time enters, importing isn't free: even if you never intend to upgrade, security bugs, platform changes, and the evolving network can force you to. How expensive will that day be? It depends on the provider's compatibility promise. The book compares four:
The key distinction is programming task vs. software engineering task: if it only needs to work today and never upgrade, grab as many dependencies as you like and break any rule; once the project must live long, dependencies get expensive. Google encourages asking first: are there tests that pass, who provides it, what compatibility does it aim for, how long will we depend on it, how often does it break, and who will upgrade it and how hard will that be. The author admits: there's no formula for import vs. reimplement, and Google gets it wrong more often than not.
How does Google do it? "We could do better." The overwhelming majority of dependencies are internal, so internal dependency management is really just source control — by design. External code goes into the monorepo's third_party directory with a low bar: it builds, no duplicate version exists, at least two OWNERS. In the book, Alice imports a package for a pre-vacation demo and gets teammate Bob to sign on; later Charlie depends on it from deep inside Search infrastructure, and it quietly becomes critical. One day a security vulnerability lands: Bob has moved into management, Alice has changed teams, thousands of projects depend on it indirectly, nobody understands it, and the upgrade must leap every release accumulated since import. Lesson: raise the ownership bar, make regular upgrades easier, and make "orphaned yet important" harder to happen.
A good solution avoids conflicting requirements in a dynamic ecosystem where any node can gain new dependencies at any time; if it does so without assuming version stability, cross-organization visibility and coordination, or vast compute, it's a great solution. The author lists the four known options:
major.minor.patch triple — a major bump may break existing usage, minor only adds features, patch only touches implementation details. Requirements read "libbase ≥ 1.5," and a solver in the package manager finds a version set satisfying every constraint. When none exists, that's dependency hell.The chapter's sharpest argument: a version number is the provider's estimate of how compatible a change is for existing users, yet solvers treat it like a true/false value in a SAT problem — an absolute. We've built all our version-satisfaction logic on a shaky foundation, and it fails in two directions:
Overconstraining: libraries almost always contain independent interfaces. Suppose libbase has just two functions, Foo and Bar, and liba and libb use only Foo. The maintainer breaks Bar and must bump the major version; the solver only accepts 1.x and rejects 2.0 — though everything would work together perfectly. "I broke something, so bump major" is only accurate at the granularity of a single API.
Overpromising: SemVer assumes changes fall into three buckets — breaking, purely additive, non-API-impacting. So which bucket holds adding 1 millisecond of latency to a time-sensitive API? Changing log format, dependency import order, or the order of an "unordered" stream? Per Hyrum's Law, at scale each of these breaks somebody. The term "breaking change" itself misleads: removing an unused API is theoretically breaking but safe in practice; Hyrum-style changes are theoretically safe but break in practice. A change in isolation is neither breaking nor nonbreaking — it can only be judged in the context of how it's used, which is exactly the information SemVer's formulation lacks.
There's also incentive: maintainers bear only a tiny fraction of the cost of a major bump. The author likes Go and Clojure: a major bump should be a whole new package. Add human error — semantic changes can't be detected by tools, so which digit to bump always comes down to someone's judgment.
In 2018, while designing package management for Go, Google's Russ Cox proposed Minimum Version Selection (MVS). Most solvers pick the newest versions when downstream upgrades are needed; MVS does the opposite: if liba requires libbase ≥ 1.7, use 1.7 even when 1.8 exists. The reasoning: whoever wrote "≥ 1.7" almost certainly had 1.7 installed, so if they did even basic testing before publishing, that pair has been tried together. Just as committing an hour of work is safer than dumping a year's at once, dependencies should move only as far as needed. The author's verdict is measured: a manifest improvement on how SemVer is used, but whether it makes SemVer "good enough" lacks empirical evidence.
The industry uses SemVer because it needs only local information and assumes no tests or compute. But dependency networks only grow inside a single organization or in the open-source ecosystem, where source is visible — information about how downstream uses you is already out there. If compute were free, the truth of "is this change safe?" would come from running the affected downstream tests: if they pass, the change is good — no classifying, no estimating. With limited resources, prioritize heavily used, high-signal dependents and relax the goal to "risk mitigation."
Open source is far from this: not every dependency has unit tests; most package managers can't show who depends on a package (reverse edges); most developers lack test clusters; and dependencies are commonly pinned, so you can't run a change through downstream tests. Then ask: "against which version of each dependency do we test?" Testing every historical combination would burn staggering compute even by Google's standards; the obvious simplification is test the current stable version — so the infinite-resources optimum is effectively Live at Head. What remains open is whether it works with practical resources and whether providers will accept the testing responsibility.
Flip it around: when your code becomes someone's dependency, poor maintenance hurts your reputation, and out-of-sync internal and external versions mean every fork gets expensive. Two cases:
Takeaway: external users of an API cost far more to maintain than internal ones. That's not "don't release," but "don't release without a plan, and a mandate, to support it long term."
Criteria: can you see and test downstream, how big is the network, how long must it live.
Table 1 · Four dependency models
| Model | Who picks versions | Fits | Cost / failure mode |
|---|---|---|---|
| Nothing changes | No choice needed | New projects and organizations, first few years | Eventually false, and you don't know when; one security fix can force the whole network to update |
| SemVer + solver | Algorithm solves the constraints | Few deps, responsible maintainers, fine-grained, expected usage | Overconstrains (dependency hell) and overpromises (silent breakage) at once; worse with scale |
| SemVer + MVS | Lowest version meeting constraints | Same, plus more reproducible builds | Still relies on human compatibility estimates; benefit unproven |
| Bundled distribution | Dedicated distributors | Outside users relying on one distribution | Distributors must keep integrating, testing, patching; lower layers tend to lag |
| Live at Head | Always latest; safety proven by downstream tests | Monorepos / orgs that can see all dependents | Needs ubiquitous tests and CI, lots of compute; providers own migration; unproven across orgs at scale |
The author argues dependency management may be becoming the most important problem in software engineering policy. When an architecture review debates "should we import this package" or "should we split into many repos," the chapter's verdict is: all else equal, prefer source-control problems over dependency-management problems — drawing the "organization" boundary wider is often a good trade. If an interviewer asks whether SemVer is enough, recite the three preconditions: responsible, accurate providers; fine-grained dependencies; all usage within expected usage. All three can hold at small scale; at large scale they rarely all stay true over time.
Industry evidence · public sources
internal — "providers should be clear about what they promise," in practice. abseil/abseil.github.io · about/compatibility.md ↗① Dependency management = managing how a network of code we don't control changes over time; the line from source control is "does our organization control this subproject?"
② All else equal, prefer source-control problems: most of Google's internal dependencies are, by design, just source control.
③ The diamond dependency is the archetype of conflicting requirements; shading is half a fix, and C++ has nearly zero tolerance.
④ Importing is nearly free for a programming task, not for a software engineering task: weigh the compatibility promise and who will upgrade.
⑤ Four models — nothing changes, SemVer, bundled distribution, Live at Head — differ in who picks the version.
⑥ SemVer is a lossy estimate of human-judged risk that solvers treat as absolute: it overconstrains (dependency hell) and overpromises (silent breakage).
⑦ MVS moves only as far as needed, closest to what the author actually tested; an improvement, but unproven.
⑧ With infinite resources, "is it safe?" comes from downstream tests — the optimum is effectively Live at Head, with the cost on providers.
⑨ Exporting is expensive too: gflags rotted and forked, AppEngine was locked in for almost three years.