Engineering Guardrails That Fail Closed
A required check can pass without checking anything. Failing closed means that when a control cannot show its result, the change is not accepted, and the cost of that rule is stated up front.
- Topics
- EngineeringCI/CDQualityArchitecture
- Published
- Reading time
- 6 min read
A check can report success without proving what it was built to protect. It might look at no files, run against the wrong version of the work, or quietly drop out of the process while changes keep flowing in. The useful question is what happens when the expected evidence is missing.
Failing closed means that when a required control cannot show its result, the change is not accepted. That has a price: a broken tool can block perfectly good work. The price needs an explicit exception policy, rather than a fallback that quietly turns "we don't know" into "approved".
Consider a checker that reads a folder of simple data records. Each record must have a non-empty label and a revision number greater than zero; extra fields are fine. The point is the control around that rule, not the rule itself.
Decide what a green result proves
The checker's promise is narrow: every data file directly inside the chosen folder satisfies the rule. If the folder is missing, a file cannot be read, a file is malformed, a record breaks the rule, or there are no records at all, the checker must stop and report failure.
That promise has limits. The checker does not look inside sub-folders, and it cannot prove that the folder holds every record the application will ever use. Requiring at least one record makes an accidentally empty folder visible, but it cannot prove the folder is complete. If the application starts reading nested folders, the checker and its test cases have to change together.
Keep different outcomes distinct
Several situations block acceptance, but they call for different responses:
| Outcome | What we know | What to do next |
|---|---|---|
| Invalid record | A record that was examined breaks the rule. | Fix the record, or change the rule on purpose. |
| Checker unavailable | The check could not run or could not read files. | Repair the check. Do not assume the data is valid. |
| No records found | Nothing was examined. | Confirm what the folder should contain and if empty is OK. |
| Check skipped | Validation did not run for this change. | Find out why, and require a real result. |
| Required result missing | Nothing acceptable is on record for this change. | Keep the change blocked, or grant a deliberate exception. |
An empty folder could be perfectly legitimate in another application. Here at least one record is required, so the policy follows the domain. "Zero files is always a failure" is no more universal than "no findings means success".
A broken tool is also different from a bad record. Both block the change, but the message should tell an engineer whether to repair the environment or the data. Reporting every error as a rule violation would hide that.
Three layers, three jobs
A local hook runs the check before a commit. It gives fast feedback on the developer's own machine. Because local hooks can be missing or skipped, their existence says nothing about what the shared branch will accept.
An automated job in the shared pipeline runs the same check somewhere else and records the result. Its wrapper has to preserve failures: an optional step, an "always succeed" fallback, or a pipeline that swallows the checker's exit status can defeat a correct checker. The job also has to look at the version of the work that will actually be merged.
The repository's merge policy decides whether that result is required. A required result needs a stable name, a trusted source, and a link to the exact change being accepted; a success from an older version does not count. A job that appears in a configuration file is not evidence that the repository refuses changes when its result is missing.
Skipped jobs deserve extra attention wherever the pipeline only runs for certain files. The goal is that every relevant change gets the validation it needs. I check how the hosting platform treats skipped and missing results rather than assuming their names imply rejection, and I test that behavior directly.
One checker can serve all three layers without making them interchangeable (Figure 1). Local feedback saves waiting. The pipeline records that the check ran. The merge policy decides whether that record is mandatory.
Read top to bottom: where the same check runs, then what the merge policy allows.
Local hook
Before a commit
Fast feedback; can be missing or skipped, so it decides nothing.
Pipeline job
Shared environment
Records a result for the exact version being merged. Must keep failures: no optional step, no always-succeed fallback.
Merge policy
Repository setting
Decides whether the recorded result is required.
Change can be accepted
Passing result for this version
Change stays blocked
Result missing, skipped or stale
Unless an accountable exception exists.
Test the failure path
For this example I ran a working version of the checker in a temporary folder. A valid record passed. A bad revision number, a malformed file, an empty folder and a missing folder each stopped it with a failure status. Calling a script that did not exist also failed. Together these tested the whole process, not only the rule.
Including a deliberately invalid record matters, because a checker that always says "fine" also passes every valid example. I keep one known violation in a separate test folder to show the rejection still works, away from the real data, where it would rightly block normal use.
None of that shows how a hosted platform behaves. Testing that boundary takes a controlled change that omits or blocks the expected result, and a check that the platform refuses it. It also means looking at who is allowed to change the required checks or submit a trusted result. A test of the script cannot establish those things.
Make exceptions accountable
Blocking good work during a tooling outage can cost more than accepting a carefully reviewed exception. The choice should be visible: which change, which evidence is missing, who accepts the risk, and when the exception ends. A broad, permanent bypass turns a required control into a suggestion.
Administrative power is part of the design too. Anyone who can remove a requirement can weaken the guarantee. Watching changes to the policy and limiting who can make them helps; the checker cannot solve it.
Finally, a green result cannot tell you whether the rule itself is right. A positive revision number and a non-empty label may be irrelevant to what an application really needs. That judgment belongs to people. The control's job is to apply the agreed rule reliably, and to make an inconclusive run visible at the moment acceptance is decided.