Sub topic 13
Maintainability and operability requirements
Prerequisites and scope
This chapter assumes you can already tell functional requirements from non-functional ones. It also assumes you know what an SLO is and can read short Python snippets. Here you will learn to write requirements for the qualities that decide how costly a system is to change and to run, and to write them so someone can check them.
Two qualities, two audiences
Maintainability is how easily engineers can change the system. They may fix a bug, add a feature or upgrade a dependency, and the system should not break when they do. Operability is how easily people can run the system in production. They deploy it, watch it, diagnose problems and recover from failures.
The two overlap, but they have different users. A maintainability requirement serves the developer who opens the code six months from now. An operability requirement serves the on-call engineer who is paged at 03:00 and has never seen this component.
Users never see either quality directly. They feel the results: slow feature delivery, long outages, and bugs that return after each release.
Why these requirements get skipped
Latency and availability show up in demos and dashboards. Maintainability and operability costs arrive later and are spread out. A missing runbook costs nothing until the first incident. Phrases like "the system should be easy to maintain" are common, but no one can test them, so no one can be held to them.
The fix is the same one you apply to other quality attributes. Name the observable outcome, choose a metric, pick a threshold and state the measurement window.
Turning vague wishes into targets
| Vague wish | Measurable form | Example target |
|---|---|---|
| Easy to change | Lead time for change: merge to running in production | Median under 1 working day |
| Safe to change | Change failure rate: share of deploys that cause an incident or rollback | Under 10% over 90 days |
| Quick to recover | Time to restore: incident start to service restored | Median under 60 minutes |
| Easy to roll back | Rollback duration | Under 10 minutes, no code change |
| Easy to diagnose | Time to detect, from fault to alert | 95% of incidents alerted within 5 minutes |
| Quiet on-call | Pages per on-call engineer per week | At most 5 |
| Easy to learn | Time for a new engineer to ship a first change | Within 5 working days |
| Up to date | Dependency age | No dependency with a known critical vulnerability unpatched for more than 7 days |
Each row names a quantity you can compute from records you already keep. That is the test of a good requirement here. If you cannot say where the number would come from, rewrite the requirement.
Operability requirements you can check
Operability is easier to specify as capabilities the system must have. A reviewer can answer yes or no for each one.
- Observability. The service emits metrics, structured logs and traces. Every request carries an ID that appears in every log line it produces. Logs are retained for a stated period.
- Health checks. The service exposes liveness and readiness endpoints, and the orchestrator uses them to restart or remove unhealthy instances.
- Safe deployment. Releases roll out gradually, such as canary or rolling updates. A rollback is one command or one click.
- Configuration. Operational settings such as timeouts and feature flags change without a rebuild. Changes are versioned and reviewable.
- Graceful shutdown. An instance finishes in-flight requests before it exits, so deploys do not produce errors.
- Alerting. Alerts fire on symptoms users feel, such as an SLO burning too fast, rather than on every CPU spike. Every alert links to a runbook.
- Runbooks. Each known failure mode has written steps that a person unfamiliar with the code can follow.
Example: extending the URL shortener
The earlier requirements document had three non-functional entries. These entries continue the numbering and keep the same structure.
non_functional:
- id: NFR-4
quality: maintainability
text: The median lead time from merge to production is under 1 working day, measured over 90 days.
- id: NFR-5
quality: operability
text: An on-call engineer can roll back any release in under 10 minutes without a code change.
- id: NFR-6
quality: operability
text: Every page-level alert links to a runbook, and no on-call engineer is paged more than 5 times per week on average.
- id: NFR-7
quality: operability
text: Any redirect can be traced by request ID through all service logs, which are retained for 30 days.Note that NFR-7 is a capability with a retention number. NFR-4 and NFR-6 are rates over a window. Both styles are testable.
Measuring the targets from data
Time to restore and change failure rate come from incident and deployment records. This script computes them and compares two ways of summarizing the same incidents.
from datetime import datetime
from statistics import mean, median
FMT = "%Y-%m-%d %H:%M"
# (incident start, service restored)
incidents = [
("2026-10-02 09:10", "2026-10-02 09:55"),
("2026-10-14 22:30", "2026-10-15 00:30"),
("2026-11-03 13:00", "2026-11-03 13:20"),
]
def minutes_between(start, end):
delta = datetime.strptime(end, FMT) - datetime.strptime(start, FMT)
return delta.total_seconds() / 60
durations = [minutes_between(s, e) for s, e in incidents]
total_deploys = 40
failed_deploys = 3
print(f"median time to restore: {median(durations):.1f} min") # 45.0
print(f"mean time to restore: {mean(durations):.1f} min") # 61.7
print(f"change failure rate: {failed_deploys / total_deploys * 100:.1f}%") # 7.5%Against a target of "under 60 minutes", the median passes and the mean fails. A requirement that does not name the statistic can be satisfied or violated depending on who does the arithmetic. State it.
The incident timeline
Several of these metrics are intervals on one timeline. Writing down where each interval starts and stops removes arguments later.
Edge cases and gotchas
- Choose start and end events. "Time to restore" can start when the fault begins, when the alert fires, or when a human notices. Starting at the alert hides detection failures. Start at the fault, using the best evidence available after the fact.
- Small samples. With three incidents in a quarter, a percentile means little. Use a longer window or a median, and say so in the requirement.
- Gaming. Deploy frequency can be raised with trivial deploys. Coverage can be raised with tests that assert nothing. Pair a speed metric with a safety metric, such as lead time with change failure rate.
- Code coverage as a proxy. A coverage threshold is easy to measure but weakly tied to maintainability. If you require one, say what it is meant to protect, such as "all redirect logic has automated tests".
- Requirements without owners. An on-call page budget needs someone with authority to fix noisy alerts. Name the owning team.
- Not every system needs all of these. A prototype with one user does not need a 10-minute rollback. Match the targets to the cost of failure.
Where these requirements collide with others
These qualities cost something. Canary releases and extra tracing add infrastructure and a small latency overhead. Fast change competes with strict compliance review. A high deploy frequency competes with a high availability target if each deploy risks an outage. The trade-offs chapter returns to these conflicts, and this chapter's job is to make them visible as numbers.
Exercise
A draft requirement says, "The service must be easy to operate and mean time to recovery should be low." Rewrite it as two testable requirements, and state one reason the original could not be tested.
Show answer
Possible rewrite: (1) "Median time to restore, from fault start to service restored, is under 30 minutes, measured over 90 days." (2) "Every page-level alert links to a runbook, verified in a quarterly review." The original could not be tested because "easy", "low" and "mean" give no threshold, no measurement window, and no agreed start and end events for recovery. "Mean" also hides slow outliers, so naming the median or a percentile is clearer.