Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Joining a project
Every open-source project began with someone sharing code, and survives because others fix it, document it and review changes. A first contribution can be small: a clearer error message, a missing test, a documentation fix. What matters is following the project’s conventions, keeping changes focused, and understanding the promises the project makes to its users through its version numbers.
2,000 simulated dependencies over two years (seed 0). Breakages per dependency per year against weeks spent exposed to a vulnerability that a newer release had already fixed:
Every range trades breakage for exposure; a lockfile with tested weekly updates gets close to both corners.
In Exercise 2, pinning a dependency never broke the build but left a known vulnerability unpatched 47.1% of the time; always installing the latest release broke 0.463 times a year per dependency; a lockfile with weekly tested updates cut breakages reaching the main branch to 0.107 with 1.4% exposure.
- 1. A good first contribution is often…
- 2. Semantic versioning promises that a minor release…
- 3. Pinning every dependency to an exact version…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Workflow: find an issue (often labelled “good first issue”), discuss the approach, fork, branch, make a focused change with tests, open a pull request (topic C2-1 covers git), respond to review.
- Diffs: a patch lists lines kept, removed and added; tools compute it from the longest common subsequence of the two files (Hunt and McIlroy) or from the shortest edit script (Myers).
- Semantic versioning: MAJOR.MINOR.PATCH; a major release may break users, a minor adds features compatibly, a patch fixes bugs; 0.y.z versions promise nothing.
- Version ranges: exact (=1.2.3), tilde (~1.2.3, patches only), caret (^1.2.3, minors and patches), any (*); a lockfile records the exact versions resolved.
- Licences: permissive (MIT, BSD, Apache 2.0) or copyleft (GPL); contributions may need a contributor licence agreement or a sign-off.
- Project health: a code of conduct, contributing guide, tests and continuous integration; the bus factor is the number of people whose loss would stall the project.
- 1. Under semantic versioning, a breaking change requires a new…
- 2. The range ^1.2.3 admits…
- 3. A lockfile records…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Diffs, versions and dependency policies
Exercise 1.
- Build the longest-common-subsequence table of two files and read a diff from it.
- Apply a diff to recover the new file.
- Parse semantic versions, test them against exact, tilde, caret and any ranges, and resolve the newest match.
Practice.
- Read the contributing guide and recent merged pull requests before writing code.
- Keep each pull request to one change, with tests and a clear description.
- Use version ranges with a lockfile, and let a bot propose tested updates.
- Release with semantic versioning and a changelog; never break users in a minor release.
- Spread knowledge: review others’ changes and document the parts only you understand.
admitted = sum(satisfies(v, spec) for v in versions) # a prefix
for w in range(weeks):
last = newest release by week w
new = min(last, admitted - 1)
if new > cur: broken += brk[cur + 1:new + 1].any(); cur = new
exposed += fix[cur + 1:last + 1].any()- 1. In Practice 2, raising the share of breaking minor releases from 5% to 20% raised caret breakages from 0.106 to about…
- 2. Projects with 5 contributors in Practice 4 had a bus factor of 1 about…
- 3. At 90% maintainer load, a pull request waited on average about…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Diffs and edit distance. If the longest common subsequence of files of n and m lines has length L, the shortest edit script deletes n − L lines and inserts m − L, so its length is D = n + m − 2L. The dynamic-programming table costs n × m cells whatever D is; Myers’s algorithm runs in time proportional to (n + m)D, which for a small patch to a large file is far less.
Which releases a range admits. Versions only increase, so the releases a range admits form a prefix of the history: exact stops at the first release, tilde at the first minor or major release, caret at the first major release. A project receives breakage from every breaking release in its admitted prefix and is exposed whenever a security fix lies beyond it.
Expected breakages. With patch, minor and major releases at weekly rates r_p, r_m and r_M and breaking chances b_p, b_m and b_M, installing every release breaks at about 52(r_p b_p + r_m b_m + r_M b_M) times a year, here 52(0.0012 + 0.002 + 0.006) = 0.48. A caret range removes the major term until the first major release, which takes about two years at r_M = 0.01.
Queues. With pull requests arriving at rate λ and a maintainer reviewing at rate μ (both random), the mean wait before review is ρ/(μ − λ) with load ρ = λ/μ: it grows without bound as the load approaches 1.
- 1. The length of the shortest edit script is…
- 2. A caret range ^1.0.0 stops admitting releases at…
- 3. As maintainer load approaches 1, the mean wait…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.How do version policies for dependencies trade breakage against exposure to vulnerabilities that a newer release has already fixed?
History.
- R. Stallman launched the GNU project in 1983 and the GPL in 1989; L. Torvalds released Linux in 1991; the term “open source” was adopted in 1998.
- J. Hunt and M. D. McIlroy (1976) wrote the Unix diff; E. Myers (1986) gave the O(ND) difference algorithm used by git.
- T. Preston-Werner published Semantic Versioning in 2010; npm, Cargo and others resolve caret and tilde ranges.
- The left-pad incident (2016), in which removing an 11-line package broke thousands of builds, and the Log4Shell vulnerability (2021) showed how fragile and how exposed dependency trees can be; Dependabot (2017, acquired by GitHub in 2019) automated update pull requests.
Exercise 2.
- 2,000 dependencies, each from 1.0.0 over 104 weeks; each week a patch (chance 0.12), minor (0.04) or major (0.01) release may appear.
- A release breaks users with probability 0.01 (patch), 0.05 (minor) or 0.6 (major), and fixes a security vulnerability with probability 0.08.
- Each week the project installs the newest release its policy admits; it is exposed while a security fix exists in a newer release than the one installed.
Seed 0:
| policy | breakages per dependency per year | weeks exposed |
|---|---|---|
| pinned (=1.0.0) | 0.000 | 47.1% |
| pinned, updated to latest twice a year | 0.318 | 15.7% |
| tilde (~1.0.0) | 0.010 | 37.5% |
| caret (^1.0.0) | 0.107 | 15.8% |
| latest (*) | 0.463 | 0.0% |
Seeds 1 and 2: pinned 47.9% and 45.6% exposed; caret 0.093 and 0.094 breakages, 16.3% and 16.1% exposed; latest 0.475 and 0.473 breakages.
Findings.
- No range avoided both problems: pinning never broke but was exposed about 47% of the time, while taking every release closed every fix but broke about 0.47 times a year per dependency.
- The caret range cut breakages to about a fifth of the latest policy’s, at about 16% exposure, mostly from fixes released only in a new major version.
- Updating a pin twice a year traded the same exposure as caret for three times its breakages, because each update jumped over many releases at once.
- The tilde range barely broke but stayed exposed 37% to 39% of the time: most fixes came in minor or later releases.
Contributing in practice
- Start small: documentation, tests, reproducing bug reports; read the contributing guide and code of conduct.
- Discuss before large changes in an issue; keep pull requests focused, tested and described, and respond to reviews promptly and politely.
- Release your research code with a licence, a README, pinned environments (topic C1-4) and semantic versions.
- Manage dependencies with ranges plus a lockfile, automated tested update pull requests, and vulnerability alerts.
- Sustain projects: review others’ work, document what only you know, and credit contributors.
References
- J. W. Hunt and M. D. McIlroy (1976). “An algorithm for differential file comparison.” Bell Laboratories Computing Science Technical Report 41.
- E. W. Myers (1986). “An O(ND) difference algorithm and its variations.” Algorithmica.
- T. Preston-Werner (2013). Semantic Versioning 2.0.0. semver.org.
- N. Eghbal (2020). Working in Public: The Making and Maintenance of Open Source Software. Stripe Press.
- G. Avelino, L. Passos, A. Hora and M. T. Valente (2016). “A novel approach for estimating truck factors.” IEEE International Conference on Program Comprehension.