> ## Documentation Index
> Fetch the complete documentation index at: https://aspect.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Ratchet Mechanism

> Use a Bazel ratchet mechanism in CI to lock in invariants like type-check fixes so new commits cannot reintroduce previously eliminated build errors.

The [ratchet](https://en.wikipedia.org/wiki/Ratchet_mechanism) is a mechanical tool to ensure "no backsliding".

<img src="https://mintcdn.com/aspectbuild/x1L7Iep716jCyJVo/images/blog/hashnode/hn-8643b17d90.png?fit=max&auto=format&n=x1L7Iep716jCyJVo&q=85&s=51d7f944ebc0227736c1dfcbfef99623" alt="" width="1920" height="1245" data-path="images/blog/hashnode/hn-8643b17d90.png" />

Whenever you tighten the semantics of the build, by ensuring some new invariant holds, you should have a ratchet in place to make sure it stays that way
For example, if you fix some type-check errors, you should make sure the CI system will mark any subsequent changes red if they re-introduce those type-check errors.

Combined with "change one thing at a time" this can give you incredible power to work in a huge codebase.
For example if you just introduce one type-check error code at a time, you can fix only those, and use your ratchet to make sure those don't come back.
You can then rinse-and-repeat with low risk changes, while ensuring that the system as a whole is eventually converging on the correct behavior.
It feels slow, but this is the same as a gear ratio on a bike: you have incredible "mechanical advantage" to move heavy objects at that slow speed.
