monitor.component-state
A status page component's state from its checks: operational, degraded, partial or major outage, or maintenance.
1.0.0 · published 2026-10-03 by charlie · Anterra
Pinned by 15 tests, run in TypeScript, Python and Rust.
What it does
The state a status page shows for one component (the API, the website, the database), from the latest status of each check behind it, in the vocabulary of Atlassian Statuspage, the de facto standard for public status pages:
| `ComponentState` | Statuspage label | Statuspage API value | | --- | --- | --- | | `operational` | Operational | `operational` | | `degraded` | Degraded performance | `degraded_performance` | | `partial-outage` | Partial outage | `partial_outage` | | `major-outage` | Major outage | `major_outage` | | `maintenance` | Under maintenance | `under_maintenance` |
For example
component_state(up, up, up, false)→ operational every check up is operationalcomponent_state(up, degraded, up, false)→ degraded one slow check is degraded performancecomponent_state(up, down, up, false)→ partial-outage some checks down is a partial outage
The function
The same function in TypeScript, Python and Rust, pinned by the same tests. Pick your language; the choice follows you around the registry.
def component_state(statuses: Sequence[CheckStatus], under_maintenance: bool) -> ComponentState
| statuses | CheckStatus[] | the latest status of each check behind the component, at least one |
| under_maintenance | bool | true during a scheduled maintenance window; wins over every status |
| returns | ComponentState |
The type it declares, generated into your project
ComponentState = Literal["operational", "degraded", "partial-outage", "major-outage", "maintenance"]
Your code names it in one line, in the file that uses it
from fune.monitor.component_state import component_state # monitor.component-state@^1
Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
from typing import Sequence
from .monitor_check_status import CheckStatus ← from monitor.check-status ^1.0.0 · built alongside by fune
from .monitor_component_state_types import ComponentState
def component_state(statuses: Sequence[CheckStatus], under_maintenance: bool) -> ComponentState:
"""One component's state in Atlassian Statuspage's vocabulary. Maintenance
wins, so planned work never pages anyone as an outage; the statuses are
still checked, so a bad feed fails loudly even during maintenance."""
if len(statuses) == 0:
raise ValueError("statuses must not be empty")
if not isinstance(under_maintenance, bool):
raise ValueError("underMaintenance must be true or false")
down = 0
degraded = 0
for s in statuses:
if s == "down":
down += 1
elif s == "degraded":
degraded += 1
elif s != "up":
raise ValueError("unknown check status: %s" % (s,))
if under_maintenance:
return "maintenance"
if down == len(statuses):
return "major-outage"
if down > 0:
return "partial-outage"
return "degraded" if degraded > 0 else "operational"Install
fune build
With that line in your source, in a Python project (language python in fune.project), fune build resolves it and its 1 dependency, pins them in fune.lock, downloads only the Python package of each, and builds the code above into your project’s .fune/build, one readable file per capability with a header linking back here. Or pin a range in fune.project and build in one step:
fune add monitor.component-state
The manifest, vectors and README with only the Python implementation. Install it without the registry with fune add ./monitor.component-state-1.0.0-python.fune, or fetch it from a terminal with fune pull monitor.component-state@1.0.0:python.
The whole function, every language, is one file too: monitor.component-state-1.0.0.fune, 9,719 bytes, sha256 cffd933922c240ddf102b7ac117550f261e261ec98c4c1781338eee2a23942d6. It installs into a project of any language.
Customise it in your app
The seams this capability offers. Put a marker directly above a function of your own and fune build wires it into the built code; the package on the registry is not changed, the built file’s header lists it under CUSTOMISED, and fune hooks lists every hook in the project. How hooks work.
before — your function gets the arguments and returns them, changed or not, or throws to refuse the call.
# fune: before monitor.component-state
after — your function gets the result and the arguments, and returns the final result.
# fune: after monitor.component-state
replace — inside this capability’s code only, calls to a dependency go to your function, with the same signature. Other capabilities that use it are unaffected; write in * to replace it everywhere.
# fune: replace monitor.check-status in monitor.component-state
step — your function runs at a numbered point inside the function’s body, receives the in-scope values it names as parameters, and may return replacements. List the points with fune show monitor.component-state --steps.
# fune: step monitor.component-state after <n|label>
Tests
A version published now needs at least 8 tests for every function, and one that expects the error for each function that throws; the registry refuses it otherwise. fune verify --all runs each case in TypeScript, Python and Rust, and a project runs them again with fune verify. This page lists the cases; it does not run them. The exact JSON is vectors.json.
| Case | Arguments | Expected | |
|---|---|---|---|
| every check up is operational | up, up, up, false | → | operational |
| one slow check is degraded performance | up, degraded, up, false | → | degraded |
| some checks down is a partial outage | up, down, up, false | → | partial-outage |
| down beats degraded: one down and one degraded is still a partial outage | degraded, down, up, false | → | partial-outage |
| every check down is a major outage | down, down, false | → | major-outage |
| a single check down is a major outage, not a partial one | down, false | → | major-outage |
| all degraded is degraded, never an outage | degraded, degraded, false | → | degraded |
| maintenance wins over a major outage | down, down, true | → | maintenance |
| maintenance with every check up is still maintenance | up, true | → | maintenance |
| a single check up is operational | up, false | → | operational |
Show the other 5 tests
| Case | Arguments | Expected | |
|---|---|---|---|
| an empty list is an error | , false | → | error: statuses must not be empty |
| an empty list is an error even under maintenance | , true | → | error: statuses must not be empty |
| an unknown status is an error | up, offline, false | → | error: unknown check status: offline |
| an unknown status is an error even under maintenance | partial, true | → | error: unknown check status: partial |
| a maintenance flag that is not a boolean is an error | up, 1 | → | error: underMaintenance must be true or false |
More from the author
The values here are kebab-case like the rest of the registry's enums; map them to Statuspage's snake_case when calling its API.
## The rule, in order
1. `underMaintenance` is true: **maintenance**. Planned work is announced as such, not reported as an outage. 2. Every check down: **major-outage**. So a component with one check that is down is a major outage, not a partial one. 3. Some checks down: **partial-outage**. 4. Any check degraded: **degraded**. Degraded checks never add up to an outage. 5. Otherwise **operational**.
The statuses are validated even under maintenance, so a broken feed fails loudly instead of hiding behind a maintenance window. To decide whether a maintenance window is active, see `monitor.maintenance-window`; to combine one target's probe locations into a single status first, `monitor.check-status`.
## Errors
- `statuses must not be empty`: a component with no checks has no state. - `unknown check status: X` - `underMaintenance must be true or false`
## Sources
- Atlassian Support, "Show service status with components": https://support.atlassian.com/statuspage/docs/show-service-status-with-components/ (the five component statuses: Operational, Degraded performance, Partial outage, Major outage, Under maintenance). - Statuspage Status API (component `status` values `operational`, `degraded_performance`, `partial_outage`, `major_outage`): https://metastatuspage.com/api
Files
| Path | Bytes |
|---|---|
| README.md | 2,055 |
| impl/python.py | 1,122 |
| impl/rust.rs | 1,410 |
| impl/typescript.ts | 1,094 |
| vectors.json | 1,849 |