Repository navigation
Description
Split from #5477.
Problem: The SRE guideline asks for a scheduled job that reads the SLO state of each service and the state of each running job. No job detects a stall, a passed deadline or a spent budget. The job acts only through the existing controls of the Service, such as the mode of a row. It writes a ticket for each other finding. Why deferred: The approved pipeline split uses #5477 as the incident job. The incident job and the supervise job have different due predicates and result lines. One pull request must deliver one job. Acceptance criteria: - A source test asserts that the supervise job runs on its schedule and reads the SLO state of each service from the Sloth rules of #4709. - A source test asserts that the job detects a stall, a passed deadline and a spent budget from the state of each running job. - A source test asserts that the job acts only through the existing controls of the Service, such as the mode of a row. - A source test asserts that the job writes one ticket for each other finding. - The job starts in mode plan, and a run in mode plan changes no row mode.
Proposed design
Problem statement
No job detects a stall, a passed deadline or a spent budget of a running job. The SRE guideline asks for a scheduled job that reads the SLO state of each service and the state of each running job. This item adds the supervise job to the roadmap Service. The job reads the SLO state from the Sloth rule groups of #4709. It acts only through the existing Service controls, such as the mode of a row. It writes one ticket for each other finding, and it starts in mode plan.
Acceptance criteria
Requirement: Supervise schedule row
The roadmap Service SHALL run the supervise job from a row of its own in DEFAULT_DUE_TABLE.
Scenario: The due table holds the supervise row
- WHEN A source test builds
DEFAULT_DUE_TABLEand runs the supervise row with no findings. - THEN The table holds exactly one row named
supervisewith its own interval, and the row writes one result line.
Requirement: SLO state from the Sloth rules
The supervise job SHALL read the SLO state of each service from the Sloth rule groups of #4709.
Scenario: A service has a spent error budget
- WHEN A source test gives the job a recorded series set with a spent budget for one service.
- THEN The job reports the service and the recorded series that it read.
Requirement: Findings of a running job
The supervise job SHALL detect a stall, a passed deadline and a spent budget from the state of each running job.
Scenario: A running job passed its deadline
- WHEN A source test gives the job a runner Job whose deadline passed.
- THEN The job writes one finding of the class
deadlinefor that job.
Requirement: Service controls only
The supervise job MUST act only through the existing controls of the Service, such as the mode of a row.
Scenario: A stalled job is stopped
- WHEN A source test runs the job in mode on against a stalled job.
- THEN The job calls the row-mode control once and writes no label, issue or job record.
Requirement: One ticket per other finding
The supervise job SHALL write one ticket for each finding that no Service control fixes.
Scenario: Two findings need a ticket
- WHEN A source test gives the job two findings that no control fixes.
- THEN The job writes exactly two tickets, one for each finding.
Requirement: Plan mode changes nothing
The supervise job SHALL start in mode plan, and a run in mode plan MUST change no row mode.
Scenario: The first run is in mode plan
- WHEN A source test runs the job in mode plan against a stalled job and a spent budget.
- THEN The job writes its findings and changes no row mode.
Existing Tool Considered
No alternatives check has run. Sloth (slok/sloth, https://github.com/slok/sloth) and Prometheus cover the SLO state; the project renders the Sloth prometheus/v1 spec in src/devops_cli/prometheus/slo_rules.py:1 because the runner image holds no sloth program. Kubernetes Job deadlines and src/devops_cli/roadmap/implement/implement_deadline.py:1 cover a passed deadline and a stall, and src/devops_cli/roadmap/finding_issues.py:1 covers the ticket. Sloth and Prometheus lack the two actions of this item: they cannot set the mode of a Service row, and they cannot write a ticket in the roadmap format. The job therefore holds only the mapping from a finding to a row mode and to the ticket writer: about 25k tokens to build, keep and fix, and about 3 hours of elapsed agent time.
Key questions
- How does the job read the SLO state of each service?: The job queries Prometheus for the recorded series of the Sloth rule groups of feat(monitoring): define the Service SLOs in a Sloth spec #4709, with the
servicelabel.src/devops_cli/prometheus/slo_rules.py:104fixes the record names, andsrc/devops_cli/prometheus/slo_rules.py:215putsserviceandsloon each series. The render is ink8s/devops/monitoring/prometheus-rules-values.yaml:637. The job does not parse the Sloth spec files again. (best practice) [sources: src/devops_cli/prometheus/slo_rules.py:104, src/devops_cli/prometheus/slo_rules.py:215, k8s/devops/monitoring/prometheus-rules-values.yaml:637, docs/guidelines/sre.md:59, https://sloth.dev/introduction/, https://github.com/slok/sloth]- Chosen: Query Prometheus with the Sloth recording rules. The recorded series hold the error ratios, the objective and the budget ratio of each service, and the
servicelabel joins them. Sloth generates these rules from one spec (docs/guidelines/sre.md:59). - Rejected: Reuse the project-review SLO reader. It queries the raw event queries over a review window and returns the review data model, so it duplicates the query path and does not read the recorded state.
- Rejected: Parse the Sloth spec files. A second parser of the same spec can disagree with the generated rules.
- Rejected: Build a new SLO calculator. AGENTS.md rule 3 puts an open tool before code that the project keeps.
- Chosen: Query Prometheus with the Sloth recording rules. The recorded series hold the error ratios, the objective and the budget ratio of each service, and the
- Which scheduler runs the supervise job?: A row of
DEFAULT_DUE_TABLEwith its own interval and its own result line. The sweep creates one unit of the row when it is due, and ADR 0021 runs the unit in a pod of its own. The row holds the schedule and the lane; the job holds no CronJob of its own. (best practice) [sources: src/devops_cli/roadmap/run.py:266, src/devops_cli/roadmap/run.py:1391, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:40]- Chosen: A row of the due table. Each roadmap job already has a row with its interval and its lane, and the sweep creates its unit when due.
- Rejected: A CronJob of its own. It adds a second scheduler and a second due record for the same work.
- Rejected: Argo Workflows. The row already becomes an Argo unit under ADR 0021, so a separate workflow adds a second due record.
- How does the job detect a stall, a passed deadline and a spent budget?: The job reads the runner Job of each running job and its Service record. The progress annotation (digest and time) gives a stall (
implement_deadline.py:7). The Job deadline gives a passed deadline (implement_deadline.py:17). The job's own token and time budget gives a spent budget (implement_limits.py:1), and the kill class names it (attempt_kill.py:16). The Service record holds the Job name and its state (stores/store.py:483). (best practice) [sources: src/devops_cli/roadmap/implement/implement_deadline.py:7, src/devops_cli/roadmap/implement/implement_deadline.py:17, src/devops_cli/roadmap/implement/implement_limits.py:1, src/devops_cli/roadmap/attempt_kill.py:16, src/devops_cli/roadmap/stores/store.py:483]- Chosen: The runner Job and the Service job record. The Service already keeps the progress, the deadline and the budget of each runner Job there.
- Rejected: kube-state-metrics. It adds a second view of a state that the Service already records.
- Rejected: The pod logs. A log line gives no stable field for a stall or a deadline.
- How does the job act on a finding?: It uses the existing row-mode control of the Service: it sets the mode of the row through
RowMode(src/devops_cli/config/defaults.py:1274). It changes no label and no other state. SRE8 gives the case: when an SLO spent its 28-day budget, the jobs take only a fix of that SLO, a P0 item and a security fix (docs/guidelines/sre.md:192). (best practice) [sources: src/devops_cli/config/defaults.py:1274, docs/guidelines/sre.md:192, docs/guidelines/sre.md:247]- Chosen: The mode of the row. The item names this control, and the Service already owns
RowMode. - Rejected: A direct label change. It makes a second writer of the labels.
- Rejected: No action, a ticket only. The item asks for an action through the Service controls.
- Chosen: The mode of the row. The item names this control, and the Service already owns
- Where does the job write a ticket?: It uses the existing finding-issue writer in
src/devops_cli/roadmap/finding_issues.py:1. It writes one issue for each finding that no control fixes, and the writer puts a fingerprint marker in the body (finding_issues.py:217) so a later run writes no second ticket. The SRE guideline defines a ticket as an issue (docs/guidelines/sre.md:77). (best practice) [sources: src/devops_cli/roadmap/finding_issues.py:1, src/devops_cli/roadmap/finding_issues.py:217, docs/guidelines/sre.md:77]- Chosen: The existing finding-issue writer. The repository already files issues with a marker, and a later run finds the open issue.
- Rejected: A new ticket file in the repository. It puts roadmap state in a file that no job reads.
- Rejected: An Alertmanager webhook. It cannot write a ticket in the roadmap format.
- Which mode does the job start in, and where does that default live?: The job starts in mode plan. Add
DEFAULT_ROADMAP_SUPERVISE_MODE: RowMode = "plan"insrc/devops_cli/config/defaults.py:1274and amode: RowModefield in theRoadmapSuperviseConfigofsrc/devops_cli/config/settings.py:2110, as each row does. An agent does not editconfig.yaml(AGENTS.md:18). (best practice) [sources: src/devops_cli/config/defaults.py:1274, src/devops_cli/config/settings.py:2110, AGENTS.md:18]- Chosen: A
RowModedefault inconfig/defaults.py. It follows the pattern of each row and needs no edit ofconfig.yaml, which rule 12 forbids to an agent. - Rejected: A key in
config.yaml. The plan pull request would change a file that rule 12 keeps from an agent.
- Chosen: A
Fit
Fits in one pull request.
Suspected block
None.
Activity
devops-cli-service commentedon Nov 29, 2026
Both work on the supervise job of #5477; this candidate creates the job, #5511 adds a D10 rule to it.devops-cli-service commentedon Nov 29, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.