feat(grafana-alertcheck): add stop subcommand to reap a detached recorder - #2843
Merged
Merged
Conversation
📊 API Diff Results
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved recorder identity and cleanup error-handling issues can cause unsafe termination or incomplete cleanup.
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
Adds a stop subcommand and shared recorder-stop protocol for safely reaping detached Grafana recorders.
Changes:
- Adds SIGKILL fallback and pidfile cleanup.
- Exposes
gate.StopRecorderand registers the CLI command. - Adds tests and updates documentation while preserving
checksemantics.
| File | Summary |
|---|---|
grafana-alertcheck/README.md |
Updates workflow documentation. |
grafana-alertcheck/internal/gate/stop.go |
Implements recorder stopping and cleanup. |
grafana-alertcheck/internal/gate/stop_test.go |
Tests stop behavior. |
grafana-alertcheck/internal/gate/check.go |
Reuses the shared stop protocol. |
grafana-alertcheck/internal/gate/check_process.go |
Adds SIGKILL support. |
grafana-alertcheck/docs/reference/cli.md |
Documents stop usage and semantics. |
grafana-alertcheck/docs/index.md |
Adds cleanup guidance. |
grafana-alertcheck/docs/architecture.md |
Documents stop and check semantics. |
grafana-alertcheck/cmd/stop.go |
Implements the stop command. |
grafana-alertcheck/cmd/stop_test.go |
Tests CLI behavior. |
grafana-alertcheck/cmd/main.go |
Registers the stop subcommand. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Tofel
force-pushed
the
alertgate/stop
branch
from
September 28, 2026 13:49
fa0ada0 to
dddb17e
Compare
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved stop-protocol cleanup issues affect idempotence and can remove a newer pidfile; the unrelated 1 artifact should also be removed.
Review effort: Lite
Findings: 1
Open (3)
Resolved since last review (2)
Tofel
force-pushed
the
alertgate/stop
branch
2 times, most recently
from
September 28, 2026 18:09
775b869 to
9bbfec2
Compare
Tofel
force-pushed
the
alertgate/stop
branch
from
September 28, 2026 18:44
9bbfec2 to
9865ad6
Compare
Tofel
marked this pull request as ready for review
September 29, 2026 09:08
Tofel
removed this pull request from stack #2845
September 29, 2026 09:17
sebawo
approved these changes
Sep 29, 2026
Tofel
enabled auto-merge (squash)
September 29, 2026 09:20
…rder Extract the recorder-stop protocol out of check into an exported gate.StopRecorder, then expose it as `stop --out <file> [--pidfile F]`. stop reuses check's pidfile-plus-flock authority: the flock proves a writer exists right now, the pidfile names it. Unlike check it is a cleanup operation, so it SIGKILLs a recorder that ignores SIGTERM, removes the pidfile, and treats a missing pidfile as "nothing to stop". That makes it idempotent and safe as an `if: always()` step after a failed work step, where the recorder's Setsid session means neither check nor the runner will otherwise reap it. check keeps its semantics unchanged: a writer that will not exit is a could-not-check, never a silent kill, and it never removes the pidfile.
* feat(grafana-alertcheck): fail fast on a condition that cannot become a pass
check now stops collecting as soon as it observes a monotone terminal
verdict instead of always holding the runner to
to + transitionGrace + drainTimeout:
- a post-from bad onset, which the full classifier calls newly_bad or
flapping and fails whether or not it later clears; or
- an inability that has already happened: a heartbeat gap, a sustained
health=error run, a stale evaluation, an in-window pause, an absent
rule.
terminalVerdict is pure and reuses proveCoverage and classifyRule over
the observed sub-window with a synthetic sentinel. A preexisting bad
instance is deliberately not terminal: it can still become recovered,
which passes. unobservable still beats violation (H6).
In recorder mode the evidence lives in another process, so check tails
the recorder's log while it waits, consuming complete newline-terminated
records only. That reading is used only for the guard; the strict
whole-file ReadLog still runs after the writer exits and is the only
evidence classified. On a terminal verdict the run is classified over
[from, At] by the same decide, with the policy window clamped and the
grace zeroed; the requested window and real thresholds are restored and
the Result carries TerminatedEarly. An early exit can never be 0.
--no-fail-fast leaves the guard unset and reproduces the previous
full-window behavior exactly.
* feat(grafana-alertcheck): rename outcomes and print plain-worded tables (#2850)
check's output now speaks plain words, in both the JSON vocabulary and the
human tables:
- outcomes: clean -> healthy, newly_bad -> new_failure,
persistently_bad -> still_failing, flapping -> unstable,
skipped -> paused, unobservable -> not_verified, and
terminated_early.kind follows the same rename. A --min-observed deficit
that no resolved rule explains is now not_counted instead of being
blamed on a paused rule.
- RESULTS and VIOLATIONS columns are spelled out (ALERT, VERDICT,
BROKEN FOR, CHECKED EVERY, WINDOW COVERED, DETAILS; GRAFANA STATE,
GRAFANA HEALTH, INSTANCES). INSTANCES is one word: the old
"INSTANCE COUNT" header read as two columns, one of them empty
under the count.
- THRESHOLDS became LIMITS USED, with each limit named in plain words
and explained by a legend under the table. The footer spells out the
extra observation time, the evaluation wait and the clock difference
from Grafana.
The rename reaches the JSON output, so consumers of violations[].outcome,
outcomes and terminated_early must move to the new vocabulary.
Tofel
force-pushed
the
alertgate/stop
branch
from
September 29, 2026 09:27
1d9c3bc to
203e3c9
Compare
sebawo
approved these changes
Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Extract the recorder-stop protocol out of check into an exported
gate.StopRecorder, then expose it as
stop --out <file> [--pidfile F].stop reuses check's pidfile-plus-flock authority: the flock proves a writer exists right now, the pidfile names it. Unlike check it is a cleanup operation, so it SIGKILLs a recorder that ignores SIGTERM, removes the pidfile, and treats a missing pidfile as "nothing to stop". That makes it idempotent and safe as an
if: always()step after a failed work step, where the recorder's Setsid session means neither check nor the runner will otherwise reap it.check keeps its semantics unchanged: a writer that will not exit is a could-not-check, never a silent kill, and it never removes the pidfile.
Stack created with GitHub Stacks CLI • Give Feedback 💬