Skip to content

chore: implement phase 9 - #2787

Open
Tofel wants to merge 2 commits into
dx-5122-alerts-assertion-p8from
dx-5122-alerts-assertion-p9
Open

chore: implement phase 9#2787
Tofel wants to merge 2 commits into
dx-5122-alerts-assertion-p8from
dx-5122-alerts-assertion-p9

Conversation

@Tofel

@Tofel Tofel commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Implements Check(), the I/O shell around pure decide() (invariants H5/H7). Single-step mode synthesizes the header and its own sentinel, so no mode flag reaches the pure layer; log mode stops the recorder before the one full read. The header (not a re-resolved definition) decides skipped, the drain set, and transitionGrace; the flock (not the pidfile) is the authority for whether a writer still exists.

Review focus: check.go mode handling, and the header-vs-flock authority decisions.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

📊 API Diff Results

No changes detected for module github.com/smartcontractkit/chainlink-testing-framework/grafana-alertcheck

View full report

@Tofel
Tofel force-pushed the dx-5122-alerts-assertion-p9 branch 2 times, most recently from 99e5355 to 95381e3 Compare September 1, 2026 14:18
@Tofel
Tofel force-pushed the dx-5122-alerts-assertion-p9 branch from 95381e3 to 04ba08e Compare September 1, 2026 14:46
@Tofel
Tofel force-pushed the dx-5122-alerts-assertion-p9 branch 2 times, most recently from 267665d to 7d9cc1e Compare September 2, 2026 09:45
@Tofel
Tofel force-pushed the dx-5122-alerts-assertion-p9 branch from 7d9cc1e to effe464 Compare September 2, 2026 09:57
@Tofel
Tofel force-pushed the dx-5122-alerts-assertion-p9 branch from effe464 to ce02d17 Compare September 2, 2026 11:05
@Tofel
Tofel force-pushed the dx-5122-alerts-assertion-p9 branch 2 times, most recently from 1377467 to f659144 Compare September 4, 2026 15:15
@Tofel
Tofel force-pushed the dx-5122-alerts-assertion-p9 branch from f659144 to c61028a Compare September 7, 2026 09:35
@Tofel
Tofel marked this pull request as ready for review September 7, 2026 09:37
@Tofel
Tofel requested a review from a team as a code owner September 7, 2026 09:37
Copilot AI lite review requested due to automatic review settings September 7, 2026 09:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It introduces a large, correctness-critical orchestration layer (check.go) with substantial new behavior despite strong tests, so final human review is warranted.

Pull request overview

Implements Phase 9 by adding the Check() I/O shell around the existing pure classification/coverage logic, with explicit handling for single-step vs recorded-log modes and tightened “authority” decisions (header vs re-resolved definitions; flock vs pidfile) to avoid fail-open behavior.

Changes:

  • Added Check() (and helpers) to orchestrate validation, definition resolution, timing derivation, evidence collection, recorder shutdown via flock authority, drain wait, and final decide() classification.
  • Centralized first-round polling into firstObservations() for both watch-start and single-step measurement passes, including §3.2 verification and stable poll ordering.
  • Updated timing/skipped logic so “paused at window start” is sourced from the log header (or equivalent start-of-step snapshot) rather than post-window re-resolved definitions; added supporting helpers and tests.
File summaries
File Description
grafana-alertcheck/internal/gate/watch.go Extracts firstObservations() and uses it for initial heartbeats/latency measurement prior to budget checking.
grafana-alertcheck/internal/gate/watch_daemon_test.go Adds a lock-holder test helper process to validate flock-based recorder stop behavior.
grafana-alertcheck/internal/gate/schedule.go Makes transitionGrace exclusion depend on “paused at start” authority (header/snapshot), not post-window definition state.
grafana-alertcheck/internal/gate/schedule_test.go Pins the new header-authoritative grace exclusion behavior in log mode.
grafana-alertcheck/internal/gate/log.go Adds Header.pausedAtStart(), stateRuleByUID(), and ReadLogHeader() to support early identity checks and shared UID selection logic.
grafana-alertcheck/internal/gate/flock.go Adds tryLockExclusive() to distinguish contention from actual flock failures for “writer exists?” probing.
grafana-alertcheck/internal/gate/coverage.go Updates commentary to reflect Phase 9/P8 responsibilities now implemented elsewhere.
grafana-alertcheck/internal/gate/classify.go Switches skipped-rule detection to header authority via pausedAtStart.
grafana-alertcheck/internal/gate/classify_test.go Updates tests to construct pause authority via header rather than Definition.IsPaused.
grafana-alertcheck/internal/gate/check.go New: full Phase 9 Check() implementation including validation, early header read, stop protocol, drain wait, and result merge.
grafana-alertcheck/internal/gate/check_test.go New: comprehensive integration-style tests for single-step and recorder modes, including edge cases and regressions.
grafana-alertcheck/internal/gate/check_process.go New: process signaling helper (signalRecorder) used by recorder stop logic.
Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread grafana-alertcheck/internal/gate/watch.go
@Tofel
Tofel force-pushed the dx-5122-alerts-assertion-p9 branch from c61028a to ab74eba Compare September 7, 2026 09:46
Invariant defended: H5/H7. The one question: can check report a pass
over a window it did not prove?

Check() is the I/O shell around the pure decide(). Single-step
synthesizes the header and its own sentinel, so no mode flag reaches
the pure layer. Log mode stops the recorder before the one full read.

The header, not a definition re-resolved after the window closed, is
the authority for what was paused when the window opened — it decides
`skipped`, the drain set, and the transitionGrace max. The flock, not
the pidfile, is the authority for whether a writer still exists.
@Tofel
Tofel force-pushed the dx-5122-alerts-assertion-p9 branch from ab74eba to 7c3f206 Compare September 7, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants