Repository navigation
Description
Problem
keep_state_record (server/service.py) logs one error line and goes on with memory only when a record cannot be written. This is a documented design (#2474). RequestBudget.admit calls it for every admitted request, so it must not raise there.
The Service writes three records:
- the request budget (
RequestBudget, service.py); - the halt file (service.py, line 386);
- the failure ledger (
FailureLedger._keep_locked, run.py).
After a write error, nothing shows the fault except one log line. A restart loses the state.
Expected
Keep the log line in the request path. Keep keep_state_record from raising.
Add a kind argument to keep_state_record: budget, halt or ledger. Each of the three call sites passes its own value.
Add the gauge devops_cli_service_state_unkept with the label record (the kind). keep_state_record sets it with GLOBAL_METRICS.set_gauge:
- 1 after a write error;
- 0 after the next write that works.
The gauge has 3 series. The next round start does not fail.
Add the alert RoadmapServiceStateUnkept (warning, for 15 minutes) to k8s/monitoring/prometheus-values.yaml. Add a promtool case in tests/fixtures/prometheus_rules/roadmap_service_tests.yaml. Add a row in the alert tables of k8s/README.md.
Acceptance criteria
-
uv run pytest tests/server/test_service_state_unkept.py -k budget_write_error- a write error of the budget file logs, sets the gauge to 1 forbudget, and raises nothing inadmit. The next good write sets 0. -
uv run pytest tests/server/test_service_state_unkept.py -k 'halt_write_error or ledger_write_error'- a write error of the halt file and of the ledger file each set the gauge for their record. -
grep -q 'RoadmapServiceStateUnkept' k8s/monitoring/prometheus-values.yaml && grep -q 'RoadmapServiceStateUnkept' tests/fixtures/prometheus_rules/roadmap_service_tests.yaml && uv run pytest tests/prometheus/test_k8s_monitoring_alerting.py- the alert and its promtool case exist and pass.
Every command above fails on the unchanged code. The pull request cites the fail-to-pass run (devops ci fail-to-pass --base <ref>).
Feasibility
I read these files at origin/main: server/service.py (read_state_record, keep_state_record, RequestBudget.admit, the halt write), run.py (FailureLedger._keep_locked, _report_locked) and k8s/README.md. I checked that GLOBAL_METRICS.set_gauge takes labels (the gauge devops_cli_service_job_suspended uses them). I did not run the Service.
A first plan made the halt and ledger faults fail the next round start. That is dropped. A disk fault should not stop all work. The gauge and the alert give the signal.
Existing tool considered
The gauge helpers of GLOBAL_METRICS, read_state_record and the existing alert group. No library is needed.
Cost
Build: about 40k tokens and 2 h (gauge, alert, 3 call sites, 4 tests). Keep: about 2k tokens per quarter. Fix: about 10k tokens and 0.5 h.
Related
Part of #3027. #3666, #3655. Order: this issue changes run.py after the issue #4042.
Activity
dan-petty commentedon Nov 7, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(service)scope of the title gives the scope.A state write failure is silent except for one log line, but it does not stop the Service, so it is important yet not urgent.Operators gain a Prometheus signal and an alert for state write failures that today are invisible in dashboards.The change touches three call sites, adds one gauge, one alert, one promtool case, and four tests in about 2 hours.Both concern keep_state_record in service.py; #2474 made the state persist across restarts, the candidate adds a gauge and alert for when a write fails.chore(main): release 0.87.2 (#4132)
devops-cli-service commentedon Nov 8, 2026
Released in v0.87.2: https://github.com/dan-petty/devops-cli/releases/tag/v0.87.2
devops-cli-service commentedon Nov 8, 2026
Live since 2026-11-08 05:08 UTC