Skip to content
🎓 Take the Quiz
.md

Freshness Policies

The strictest policy requires every PR to be tested against the exact current state of main. But this isn’t always necessary.

Freshness PolicyDescriptionUse Case
StrictMust be tested against current HEADCritical systems, regulated industries
Within N commitsCan be up to N commits behindBalance between safety and throughput
Within scopeOnly up-to-date within its partitionMonorepos with independent components
Time-basedValid for N minutes after queue CI passesHigh-velocity teams with fast CI

Strict freshness means every merge invalidates all in-flight queue tests. With high PR volume, this creates a race condition where PRs struggle to merge.

Example:

  • PR #1 passes queue CI at 10:00
  • PR #2 merges at 10:01
  • PR #1’s test is now “stale” and must re-run

With relaxed freshness (e.g., “within 2 commits”), PR #1 can still merge if it’s only 1 commit behind.

Strict Freshness

Lower Throughput

Maximum Safety

Relaxed Freshness

Higher Throughput

Theoretical Risk

The risk is usually theoretical because:

  • Most PRs don’t conflict semantically
  • Type systems catch many integration issues
  • Runtime failures are rare for unrelated changes
Team ProfileRecommended Policy
Regulated/complianceStrict
High-velocity startupTime-based (5-10 min)
Monorepo with scopesWithin scope
Medium velocityWithin 2-3 commits

Consider a team merging 30 PRs per day with a 15-minute CI pipeline.

With strict freshness, every merge invalidates all in-flight tests. If 3 PRs are testing and one merges, the other 2 must restart. During peak hours, PRs can cycle through 3-4 restarts before finally merging — turning a 15-minute pipeline into a 60-minute wait.

The math is unforgiving:

PRs in queueAvg restarts per PR (strict)Effective merge time
20.5~22 min
51.5~37 min
103+~60+ min

Relaxing freshness to “within 2 commits” eliminates most restarts while maintaining strong safety guarantees. The probability of a semantic conflict between two unrelated PRs is typically well under 1%.

When using parallel queues, freshness can be applied per scope. A frontend PR only needs to be fresh relative to other frontend changes — a backend merge doesn’t invalidate it.

This is the most powerful freshness optimization for monorepos. It combines the safety of strict freshness within each domain with the throughput of relaxed policies across domains.

See also: High-Velocity Teams for guidance on choosing freshness policies at scale.