The critical path in software: find it, map it, guard it
TL;DR
Difficulty: Intermediate
The critical path is the short chain of steps that must work for the business to earn money or meet its legal duties: basket, checkout, payment, order, confirmation, invoice, data requests.
- Find it by following the money, the law and the customer.
- Score each step as likelihood times impact, and keep every legal duty on the path whatever its score.
- Map it top to bottom with every failure branch, and write it down in the repository.
- Guard it six ways: end to end tests tagged @critical, contract tests at the boundaries, a release gate that runs them first, an approval that freezes the verified path, a smoke test after every deploy, and an alert on missing orders.
What to read first
A broken blog page is embarrassing. A broken checkout is a shop that is open, busy and taking no money. This chapter shows how to find the few steps your software must never get wrong, and how to guard them so a release cannot quietly break them, worked through on an invented Bristol tea shop.
The part of your software that pays the bills
A broken blog page is embarrassing. A broken checkout is a shop that is open, busy and taking no money. Both are bugs. Only one of them costs you a day's revenue before anyone notices.
So the question this article answers is simple: which part of my software must never break, and how do I make sure it doesn't? The answer has a name, the critical path, and three jobs attached to it. You find it, you map it, and you guard it.
One word of warning before we start, because the same phrase means something else in project management. There, the critical path is the longest chain of tasks that decides when a project can finish. I wrote about that meaning in the time to market article. Here it means something different: a chain of steps inside the running software, not a chain of tasks in a plan.
This chapter builds on the previous one in the series, unit, integration and end to end tests. If the words "end to end test" are new to you, start there. If not, read on.
What the critical path is
The critical path is the chain of steps that must work for the business to earn money or to meet its legal duties. If any link in that chain breaks, the business either stops earning or starts breaking the law. Everything else in the software matters, but it can be broken for an afternoon without real harm.
For an online shop, the chain usually looks like this: a customer signs up or continues as a guest, logs in if they have an account, adds something to the basket, checks out, pays, receives an order confirmation, and later gets an invoice. Running alongside, there is a legal chain that is easy to forget: when a customer asks for a copy of their data, or asks you to delete it, the software has to be able to do it.
Notice what is not on the list: the blog, the "about us" page, product reviews, the newsletter sign up form. All useful. None of them stops the money or breaks the law if it fails for an hour.
I define the critical path of every product I build, because everything else about testing and releasing follows from it.
Example: a tea shop's critical path in plain words
Fernhill Tea is an online tea shop in Bristol (invented for this series, at fernhilltea.example). It sells loose tea by the 100g bag and monthly tea subscriptions, takes card payments through a payment provider, offers discount codes, keeps stock and sends order emails. Its developer is Priya, and its owner is Tom.
Asked "what must never break?", Tom and Priya write this list on a whiteboard:
- A customer can find a tea and open its product page.
- They can add it to the basket and change the quantity.
- They can check out with an address, a delivery option and, if they have one, a discount code.
- The payment provider approves or declines the card, and the shop shows the right result.
- An approved payment creates exactly one order and reduces stock exactly once.
- The customer gets a confirmation email.
- The order gets a VAT invoice with the correct rate for each item.
- When a customer asks for their data or asks to be deleted, Priya can export or erase it.
Steps one to seven are the money chain. Step eight is the legal chain. Subscriptions renew through steps four to seven every month, so they ride on the same path. That is the whole critical path of Fernhill Tea, eight lines long.
How to find it: follow the money, the law and the customer
A whiteboard list is a good start, but it depends on who is in the room. Three questions make the search systematic, and each one catches things the others miss.
Follow the money
Trace a pound from the customer's card to your bank account. Every screen, every background job and every outside service that pound passes through is on the critical path. This catches the parts nobody sees: the webhook (a message the payment provider sends to your server to say "this payment succeeded"), the job that marks the order as paid, the stock update.
Follow the law
List the things the law requires your software to do, with a deadline. Two show up in almost every business. Invoices must carry the right details. And under UK data protection law, a person who asks for a copy of their personal data must normally get it within one month of the request1. If your software cannot produce that copy, you find out on the day someone asks, with the clock already running.
Follow the customer
Sit next to a real customer, or read your support emails, and note the moments where a failure would make them leave or complain. This catches things the first two miss: a login that locks people out, a password reset email that never arrives, a discount code that silently does nothing.
Example: three questions, three new findings
When Priya runs Fernhill Tea through the three questions, each one adds something to the whiteboard list.
Follow the money turns up the payment webhook. The checkout page can show "thank you" while the webhook fails in the background, so the order never gets marked as paid and never ships. The webhook joins step five.
Follow the law turns up the data request. Nobody had ever tested the export. Priya tries it on a copy of the database and finds it leaves out subscription history. That becomes step eight, with a test.
Follow the customer turns up the password reset email. Tom's support inbox shows that subscribers who forget their password and never receive the reset email cancel instead of asking. Password reset joins the path next to login.
Ten minutes per question, and the list is more complete than any one person would have made it.
Score the risk, so the tests go where the harm is
Not every step on the path deserves the same amount of testing. Software testers have a standard way to decide where effort goes, called risk based testing. The International Software Testing Qualifications Board (ISTQB) describes risk with two factors: the likelihood that something goes wrong, and the impact if it does. Together they give the risk level, and in the quantitative approach the risk level is simply the one multiplied by the other2.
Here is the risk score of one step, is the likelihood that a change breaks that step, on a scale from 1 (rare) to 5 (likely in almost any release that touches it), and is the impact if it breaks, from 1 (cosmetic) to 5 (money lost or a legal duty missed). The idea is close to an expected value, the chance of an outcome times its size; Foundations: expected value explains that from scratch.
The numbers are judgement, not measurement. Their job is to make two people argue about the right thing ("is the discount code really a 4?") instead of the wrong one ("do we test this at all?").
Then set a rule: any step with a score of 12 or more is on the critical path, and so is any step that carries a legal duty, whatever its score. The second half of the rule matters. Legal duties are often rare and quiet, so their likelihood looks low, and a low score would hide them.
Example: scoring the tea shop, step by step
Priya and Tom score each step together. The numbers below are invented for this example.
| Step | Likelihood | Impact | Score | Critical? |
|---|---|---|---|---|
| Discount code applied at checkout | 4 | 4 | 16 | Yes |
| Card payment and webhook | 3 | 5 | 15 | Yes |
| Order saved, stock reduced once | 3 | 5 | 15 | Yes |
| Login and password reset | 3 | 4 | 12 | Yes |
| Confirmation email | 3 | 3 | 9 | No, by score |
| VAT invoice | 2 | 4 | 8 | Yes, legal duty |
| Data export and deletion | 2 | 4 | 8 | Yes, legal duty |
| Add to basket | 2 | 4 | 8 | No, by score |
| Newsletter sign up | 2 | 2 | 4 | No |
| Product reviews | 3 | 1 | 3 | No |
Take the top row step by step. The discount code logic changes often, because Tom runs a new promotion most months, so Priya rates the likelihood at . A broken code either gives tea away or makes customers abandon the basket, so the impact is . The score is , above the threshold of 12, so it is critical.
Now two rows the rule pulls up or pushes down. The VAT invoice scores only , but it is a legal duty, so it goes on the path anyway. The confirmation email and add to basket both score below 12. Tom and Priya discuss them and decide to put them on the path regardless, because a customer who gets no email or cannot fill a basket is lost just as surely. The rule is a starting point for that conversation, not a replacement for it.
Map it as a diagram
A list tells you which steps matter. A map tells you how they connect and, just as important, where each one can fail and what should happen then. Drawing the failure branches is the moment most teams discover that nobody decided what happens when the payment is declined, or when the email service is down.
Draw it top to bottom, one box per step, a diamond wherever the software makes a decision, and a separate box for every failure. Then mark the route a normal, successful order takes. That route is the critical path. The branches are the places a test has to prove the shop fails safely.
Example: the tea shop's checkout, mapped
Priya draws the money chain with every place it can fail. The highlighted route is the critical path that every release must keep working.
Three things on this map were never written down before Priya drew it. A rejected discount code must not empty the basket. A declined card must leave the customer where they were, with a message they understand. And a failed email must not block the invoice, it goes into a retry queue and alerts a person instead. Each of those three sentences becomes a test.
Write it down where the code lives
A critical path that exists only on a whiteboard is forgotten by the next release. Put it in a plain text file in the repository, next to the code, so it is versioned with the code and every developer (and every AI assistant) working on the project can read it. Then link every test that guards it back to that file.
Example: the tea shop's critical path file
Priya adds a file called docs/critical_path.md to the repository:
# Fernhill Tea: critical path
Verified 3 November 2026, approved by Tom (owner)
1. Product page opens for every tea in stock
2. Basket: add, change quantity, remove
3. Checkout: address, delivery option, discount code
4. Card payment approved or clearly declined, basket kept on decline
5. Webhook marks the order paid: one order, stock reduced once
6. Confirmation email sent, or queued for retry with an alert
7. VAT invoice with the correct rate for each item
8. Customer data export and deletion on request
Also: login and password reset
Guarded by: every scenario tagged @critical in features/critical/
Change rule: any change to these steps needs Tom's approval
Read it line by line. The title names the shop. The "verified" line records when the path was last checked and who approved it. The numbered lines are the path itself, in words Tom can read without knowing any code. The last two lines are the bridge to the code: where the tests live, and who must approve a change. Those two lines are what turn a document into a guard.
Guard one: an end to end test for every step
An end to end test drives the real application the way a customer would: it opens pages, fills in forms, presses buttons and checks what appears. It is the slowest kind of test, which is why the previous chapter argued for having few of them. The critical path is exactly where those few belong.
Write each step as a behaviour driven scenario in Gherkin, the plain language format Cucumber reads, and tag it @critical. A tag is a label on a test that lets you run a chosen group on its own3. (The Cucumber article covers the tooling in depth. Here we only need the tag.)
Example: the payment step as a critical scenario
Priya writes this scenario in features/critical/checkout.feature:
@critical
Feature: Paying for tea
Scenario: A guest pays by card and gets one order
Given "Assam Breakfast" costs £6.50 and 12 bags are in stock
When a guest buys one bag and the card is approved
Then they see "Thank you for your order"
And there is exactly 1 order for "Assam Breakfast"
And 11 bags of "Assam Breakfast" are in stock
Scenario: A declined card keeps the basket
Given "Assam Breakfast" costs £6.50 and 12 bags are in stock
When a guest buys one bag and the card is declined
Then they see "Your card was declined"
And the basket still holds 1 bag of "Assam Breakfast"
And 12 bags of "Assam Breakfast" are in stock
The @critical line at the top tags both scenarios. Each scenario reads like a sentence Tom could have said: a starting situation (Given), an action (When) and an outcome (Then). The second scenario is the failure branch from the map, written as a test.
Behind each sentence is a step definition in Ruby that drives the browser with Capybara. Here is the one for buying:
When("a guest buys one bag and the card is {word}") do |result|
FakePaymentProvider.next_result = result.to_sym # :approved or :declined
visit product_path(Product.find_by!(name: "Assam Breakfast"))
click_button "Add to basket"
click_link "Checkout"
fill_in "Email", with: "guest@fernhilltea.example"
click_button "Pay now"
end
Line by line: {word} captures "approved" or "declined" from the sentence. The first line tells a fake payment provider (a stand in for the real one, used only in tests) how to answer. visit opens the product page, click_button and click_link press what a customer would press, and fill_in types into the email field. Nothing here knows how the checkout is built inside. That is the point: if Priya rewrites the checkout code, these tests still describe what the customer must experience.
To run only the critical scenarios, Priya types bundle exec cucumber --tags @critical. If the shop had a Next.js front end tested with Playwright, the same idea works there: a test gets tag: '@critical' and npx playwright test --grep @critical runs only those4. RSpec has the same feature with rspec --tag critical5.
Guard two: contract tests where your system meets someone else's
The riskiest steps on most critical paths sit at a boundary: the moment your shop talks to the payment provider, the email service or the warehouse. Your end to end tests use a fake there, because you cannot charge a real card on every test run. So you need a second guard that checks the fake still matches reality.
That is a contract test. The Pact project defines contract testing as "a technique for testing an integration point by checking each application in isolation"6. Each side checks itself against a shared description of the messages that pass between them. When you control both sides, a tool like Pact handles both halves (the API testing article shows how). When the other side is an outside provider, you cannot run their half. You can still pin down your half: record a real message from the provider's test mode, store it in your repository, and test that your code reads every field it relies on.
Example: pinning the payment webhook
Priya saves a real "payment succeeded" message from the provider's test mode as test/fixtures/files/payment_succeeded.json, then writes this Minitest test:
require "test_helper"
class PaymentWebhookContractTest < ActiveSupport::TestCase
test "reads the fields the shop relies on" do
payload = JSON.parse(file_fixture("payment_succeeded.json").read)
event = PaymentWebhook.parse(payload)
assert_equal "pi_test_123", event.payment_id
assert_equal 650, event.amount_pence
assert_equal "gbp", event.currency
end
end
file_fixture loads the recorded message. PaymentWebhook.parse is the shop's own code that turns the provider's message into something the order logic understands. The three assert_equal lines check the three facts the critical path depends on: which payment it was, how much (in pence, so £6.50 is 650) and in which currency. If the provider renames a field in a new version of its message, Priya refreshes the recording, this test fails, and she finds out on her laptop instead of from an unshipped order.
Guard three: a release gate that runs the critical tests first
A release gate is an automatic check that stands between a change and production: if the tests fail, the release does not happen. Every release I ship goes through one. The useful refinement for the critical path is order. Run the critical tests first, on their own, so a broken checkout fails the release in minutes instead of after the whole suite.
GitHub Actions, the automation built into GitHub, expresses this with one keyword. A job can declare that it needs another job, and the documentation is explicit: "If a job fails or is skipped, all jobs that need it are skipped"7. A deploy job that needs the critical tests therefore cannot run when they fail.
Example: the tea shop's release gate
Priya adds .github/workflows/release.yml:
name: Release gate
on:
push:
branches: [main]
env:
RAILS_ENV: test
jobs:
critical:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bin/rails db:prepare
- run: bundle exec cucumber --tags @critical
full_suite:
needs: critical
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bin/rails db:prepare
- run: bin/rails test:all
- run: bundle exec cucumber --tags "not @critical"
deploy:
needs: [critical, full_suite]
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- run: bin/deploy
Read it from the top. on: push: branches: [main] starts the workflow whenever code lands on the main branch. env sets the test environment for every step. The critical job checks out the code, installs Ruby and the gems, prepares a test database and runs only the scenarios tagged @critical. The full_suite job has needs: critical, so it starts only if the critical tests passed, then runs every unit and system test and the remaining scenarios (the tag expression not @critical skips the ones already run). The deploy job needs both, so a single red test anywhere stops it. bin/deploy stands for whatever deploy command the project uses. The line environment: production is the hook for the next guard.
Guard four: freeze the verified path behind an approval
Tests catch a change that breaks the critical path by accident. They do not catch a change that alters it on purpose and updates the tests to match. Someone rewrites the discount rule, adjusts the scenario so it passes, and the release gate is green. Every test passed, and the shop now does something the owner never agreed to.
So I freeze verified critical paths behind an approval step: once the owner has confirmed the path behaves as it should, any change to it needs their explicit sign off. GitHub offers two mechanisms for this, and they work well together.
The first is a CODEOWNERS file. It names who owns which files, and code owners are automatically asked to review any pull request (a proposed change) that touches their files. With the branch protection setting "Require review from Code Owners" switched on, the change cannot be merged until an owner approves8.
The second is the deployment environment. A job that names an environment waits until that environment's protection rules pass, and one of those rules is a list of required reviewers, up to six people or teams, of whom one must approve before the job runs9 7. One honest limit: on GitHub's free plan, environments are only available for public repositories9, so a private shop repository needs a paid plan for this part.
Example: freezing the verified checkout
Priya adds .github/CODEOWNERS:
# Verified critical path: changes need an owner's approval
/docs/critical_path.md @tom-fernhill
/features/critical/ @tom-fernhill @priya-fernhill
/app/services/checkout/ @priya-fernhill
/app/models/order.rb @priya-fernhill
Each line is a path followed by the people who own it. The plain language file and the critical scenarios list Tom, because they describe what the business promises. The checkout code lists Priya, because she understands it. She switches on "Require review from Code Owners" for the main branch, and adds herself as the required reviewer on the production environment.
Three weeks later, a contractor helping with a summer promotion changes how discounts are rounded and edits a critical scenario so it passes. The pull request automatically asks Tom to review the scenario change. Tom reads one line, "a 15% code on £6.50 now gives £0.97 off instead of £0.98", asks why, and the contractor fixes the rounding instead. The tests never failed. The approval caught it.
Guard five: a smoke test after every deploy
Tests run against a copy of the shop. Production is a different place, with real configuration, real secrets and a real network. A smoke test is a quick check, right after a deploy, that the live site is up and its pages load. The name comes from electronics: switch it on and see if anything smokes.
Rails has a small built in starting point. New Rails applications include a health check at /up that returns status 200 "if the app has booted with no exceptions, and a 500 status code otherwise". The documentation is clear that it "does not reflect the status of all of your application's dependencies, such as the database"10. It tells you the application started. It does not tell you a customer can buy tea.
So after every deploy I run a smoke test that requests every page of the site, and treat anything but a 200 as a failed release.
Example: the tea shop's smoke test
Priya adds a short script, bin/smoke.mjs, that runs straight after bin/deploy:
// Request every page in the sitemap, fail on anything but 200
const base = process.argv[2] ?? "https://fernhilltea.example";
const xml = await (await fetch(`${base}/sitemap.xml`)).text();
const urls = [...xml.matchAll(/<loc>(.*?)<\/loc>/g)].map((m) => m[1]);
let failed = 0;
for (const url of [`${base}/up`, ...urls]) {
const res = await fetch(url, { redirect: "manual" });
if (res.status !== 200) {
console.error(`${res.status} ${url}`);
failed += 1;
}
}
console.log(`${urls.length + 1} pages checked, ${failed} failed`);
process.exit(failed ? 1 : 0);
The script reads the sitemap (the file that lists every public page), pulls every address out of it, adds the /up health check, and requests each one. redirect: "manual" stops it from quietly following a redirect, so a page that suddenly sends customers elsewhere counts as a failure. Every failure is printed, and the script exits with code 1, which makes the deploy job red. It does not buy tea in production (that would create real orders). For the money chain itself, Priya relies on the next guard.
Guard six: watch the path in production
Something will eventually break in production that no test predicted: the payment provider has an outage, a certificate expires, a queue stops. The last guard is monitoring, and the most useful advice on it comes from Google's Site Reliability Engineering book. Its four golden signals for a user facing system are latency, traffic, errors and saturation, and it recommends spending "much more effort on catching symptoms than causes"11. A symptom is what the customer feels ("nobody can pay"). A cause is why ("the database connection pool is full"). The same chapter insists that "every page should be actionable": an alert that wakes a person must need a person11.
For a shop, the clearest symptom on the critical path is orders. If orders stop, something on the path is broken, whatever the cause.
Example: when silence means trouble
During opening hours, Fernhill Tea takes on average 6 paid orders an hour (invented for this example). Priya wants an alert when orders stop, but not one that fires during a normal quiet spell. How long a silence is suspicious?
If orders arrive independently at a steady average rate, the chance of seeing none at all in a window of time follows the Poisson model:
Here is the average number of orders per hour, is the length of the window in hours, and is the base of the natural logarithm. Foundations: probability explains chances like this from the beginning.
Try a 15 minute window first, so . Then , a 22% chance of silence by pure luck. An alert on a 15 minute gap would fire about one window in five on a perfectly healthy day, and Priya would learn to ignore it. Now try 45 minutes, so . Then , about 1%. A 45 minute silence during opening hours is rare enough to mean something is probably wrong, so that becomes the alert: "no paid order in 45 minutes between 8am and 10pm". Outside those hours the steady rate assumption fails (night is always quiet), so the alert sleeps. When it fires, Priya's first move is to run the critical scenarios against staging and place a test order. The alert names a symptom, the critical path tells her where to look.
To see whether all six guards are working over time, DORA, the research programme behind the best known software delivery measures, tracks the change fail rate, "the ratio of deployments that require immediate intervention following a deployment"12. Priya counts it per quarter. If it climbs, the critical path has a gap somewhere.
Keeping track of it, day to day
The guards above run on their own. The developer's part is to keep the critical path in mind while working, so it never drifts away from the code. Three habits do most of it. Read docs/critical_path.md before starting a change, and ask "does this touch a numbered step?". Run the critical tests first on your own machine, before the full suite, with bundle exec cucumber --tags @critical. And when a new feature joins the money chain or the legal chain, add it to the file, score it, map it and tag its scenario in the same pull request, so the file and the tests never disagree.
The same file serves AI coding assistants. An assistant starts each session without memory of the last one. A critical path file in the repository, referenced from the project's instruction file, is how it learns which parts it must not touch without saying so. Chapter 8 of this series, test driven development with AI, shows how to set that rule up.
Example: a small change on a Tuesday
Tom asks Priya for a new discount type: "buy three bags, get the lowest priced one free". Priya opens the critical path file. Discount codes are step three, so this change is on the path.
She writes a new scenario in features/critical/discounts.feature, tagged @critical, for three bags at £6.50, £6.50 and £4.20, expecting £4.20 off and a total of £13.00. She runs bundle exec cucumber --tags @critical and watches the new scenario fail, because the feature does not exist yet. She builds it, test first, until the scenario and every other critical scenario pass, then runs the full suite.
She opens the pull request. CODEOWNERS asks Tom to review, because the change touches features/critical/. Tom reads the scenario, which is in plain English, and approves it. The release gate runs the critical tests first, then the full suite, then waits for Priya's approval on the production environment. She approves, the deploy runs, the smoke test requests every page and passes, and the release gets its version number in the release register. Twenty minutes after the deploy, an order with the new discount arrives, and the order alert stays quiet.
What to ask for if you commission software
If you are the Tom in this story and someone else writes your code, you do not need to read YAML to know whether your critical path is guarded. Ask five questions, and expect a straight answer to each.
- Can you show me our critical path, written in plain words, in the repository?
- Which tests guard each step, and can I read them?
- Does a failing critical test stop a release automatically?
- Who has to approve a change to the critical path, and is that enforced or just agreed?
- What happens after a deploy, and who gets told if orders stop?
Example: two answers to question three
A supplier who says "we always test before releasing" has described a habit. A supplier who says "the deploy job needs the critical job in our workflow, so it cannot run if a critical scenario fails, and here is the run from last Thursday's release" has described a guard, and shown evidence of it. Only the second one survives a busy Friday. The evidencing compliance article explains how that evidence also serves auditors and insurers.
Conclusion
Every product has a short chain of steps that keeps the money coming in and the business on the right side of the law. Find it by following the money, the law and the customer. Score each step with likelihood times impact, and keep every legal duty on the path whatever its score. Map it top to bottom with every failure branch, and write it down in the repository where the code and the people (and the AI assistants) working on it can see it.
Then guard it six ways: end to end scenarios tagged @critical, contract tests at the boundaries, a release gate that runs the critical tests first and blocks the deploy, an approval that freezes the verified path, a smoke test after every deploy, and an alert on the symptom that matters most. None of it is complicated. All of it together means the part of your software that pays the bills is the part that never surprises you.
The next chapters turn to what happens when things go wrong anyway, starting with errors and exceptions explained.