Skip to content

feat: group incident correlation (spec 04 backend v1) - #31

Merged
fclairamb merged 11 commits into
mainfrom
feat/group-incident-correlation
May 2, 2026
Merged

fclairamb merged 11 commits into
mainfrom
feat/group-incident-correlation

Conversation

@fclairamb

Copy link
Copy Markdown
Owner

Summary

Implements spec 04 — group-based incident correlation backend v1: when a shared dependency fails, several checks in the same check_group collapse into a single group incident with one notification per channel instead of one-per-check.

What's in this PR

  • Migrations (004_group_incidents): nullable incidents.check_group_uid, new incident_member_checks join table, partial indexes for active/failing lookups.
  • Models: Incident.CheckGroupUID *string, IncidentMemberCheck, IncidentMemberUpdate.
  • db.Service: FindActiveIncidentByGroupUID, FindRecentlyResolvedIncidentByGroupUID, member CRUD + count, MemberCheckUID filter on ListIncidents. FindActiveIncidentByCheckUID widens to also return the group incident a check participates in.
  • State machine (incidents.Service):
    • routeCheckResult dispatches to per-check or group handlers based on incident.CheckGroupUID || check.CheckGroupUID.
    • Failure: createOrReopenGroupIncident (cooldown reopen on group key, otherwise new incident with first member); handleGroupFailure upserts member rows, bumps incident counters, escalates when any member crosses its individual threshold, rebuilds title <group> — N/M checks down.
    • Success: handleGroupSuccess flips a member to recovered when its (adaptive) recovery threshold is met; resolves the incident only when zero members remain failing.
  • Notification dedup: queueGroupNotifications builds the union of failing members' connections, deduped by connection UID. Recovered members are excluded from mid-incident events but included on resolved.
  • API: IncidentResponse gains checkGroupUid, checkGroupSlug, members[]. New filters ?checkGroupUid= and ?memberCheckUid=. Per-check incidents serialize unchanged.

Deferred to follow-up

Documented in the archived spec under "v1 Deferred Items":

  • CheckUpdate side effects (OnCheckGroupChanged, OnCheckDisabled, OnCheckDeleted).
  • incidents.check_uid FK change to ON DELETE SET NULL (sqlite needs full table rebuild).
  • Frontend rendering pass on incident list/detail.
  • service_group_test.go table-driven cases.

Why land v1 without those?

  • All changes are additive: per-check incidents (where CheckGroupUID IS NULL) keep their exact existing behavior.
  • The state machine, notification dedup, and API surface are the load-bearing parts; deferred items are polish on edge cases or UI work.

Test plan

  • make build-backend passes
  • make lint-back clean (golangci-lint v2.12.0, 0 issues)
  • make test passes (modulo the known intermittent embedded-postgres dyld flake on parallel runs — passes consistently in isolation)
  • make build-dash0 / build-dash / build-status0 all green
  • Manual end-to-end per §10 (deferred — needs a running stack)

🤖 Generated with Claude Code

fclairamb added 11 commits May 2, 2026 04:51
Step 1 of group-incident-correlation: postgres + sqlite
migrations 004_group_incidents add a nullable
incidents.check_group_uid column (FK to check_groups, ON DELETE
SET NULL) and a new incident_member_checks join table tracking
per-member state inside a group incident. Partial indexes target
active group incidents and currently-failing members for the
hot lookups.

Existing per-check incidents (check_group_uid IS NULL) are
unchanged.
Step 2 of group-incident-correlation: extend the Incident model
with CheckGroupUID (NULL = per-check, existing behavior) and add
IncidentMemberCheck + IncidentMemberUpdate to track per-member
state inside a group incident.
Step 3 of group-incident-correlation: postgres + sqlite
implementations for the new group-incident queries.

- FindActiveIncidentByGroupUID / FindRecentlyResolvedIncidentByGroupUID
- ListIncidentMemberChecks / GetIncidentMemberCheck
- UpsertIncidentMemberCheck / UpdateIncidentMemberCheck
- CountFailingIncidentMembers

FindActiveIncidentByCheckUID now matches both per-check
incidents and group incidents that include the check via the
new join table — the state-machine code uses this returned
incident's CheckGroupUID to choose per-check or group routing.
The recently-resolved-per-check lookup explicitly filters out
group incidents to keep the cooldown/reopen path stable.

Notification mocks updated to satisfy the wider db.Service
interface.
Steps 4-5 of group-incident-correlation: failure and success
paths for grouped checks.

ProcessCheckResult routes through routeCheckResult, which uses
the active incident's CheckGroupUID (or the check's group when
no active incident yet) to dispatch to handleGroupFailure /
handleGroupSuccess. Per-check checks keep the existing
handleFailure / handleSuccess paths untouched.

Group failure path:
- threshold met & no active group incident → createOrReopenGroupIncident
- active group incident → upsert this check's member row, bump
  incident.failure_count, escalate when any member's individual
  escalation_threshold is met, rebuild title with current N/M.

Group success path:
- check is a currently_failing member and met its (adaptive)
  recovery_threshold → mark member recovered.
- if zero members remain failing → resolve the group incident.
- otherwise rebuild title with the new failing count.

Title format: "<group> — N/M checks down". Members joining
mid-incident insert a new row; relapses inside an incident
flip currently_failing back to true without touching
incident.relapse_count (only group-level resolved→active does).
Step 6 of group-incident-correlation: queueGroupNotifications
walks the member list and dispatches one notification job per
(connection, event-type), deduped by connection UID across
members. Recovered members are skipped on mid-incident events
but included on resolved so every channel that heard about the
incident also hears the recovery.

emitEvent now picks queueGroupNotifications when the incident
has CheckGroupUID set. The shared marshalling/job-creation logic
moved to enqueueNotificationJob so per-check and group paths
agree on the wire format.
Step 7 of group-incident-correlation: API surface.

IncidentResponse gains CheckGroupUID, CheckGroupSlug, and
Members[] (typed IncidentMemberResponse) — populated only when
the incident has a group. Per-check incidents look identical
to before.

ListIncidents accepts two new filters:
- ?checkGroupUid=X — only incidents on group X.
- ?memberCheckUid=X — incidents that contain check X (per-check
  or group member, currently or historically).

Query parsing extracted into parseListIncidentsOptions to keep
the handler under cyclop. Postgres + sqlite ListIncidents both
honor the new filters.

GetIncident and ListIncidents now load member rows via
loadIncidentMembers when the incident has a CheckGroupUID,
resolving each member's check for slug/name embedding.
@fclairamb
fclairamb enabled auto-merge (squash) May 2, 2026 03:09
@fclairamb
fclairamb merged commit 1883986 into main May 2, 2026
11 checks passed
@fclairamb
fclairamb deleted the feat/group-incident-correlation branch May 2, 2026 03:14
@fclairamb fclairamb mentioned this pull request May 2, 2026
fclairamb added a commit that referenced this pull request Jun 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.1.0](v0.0.0...v0.1.0)
(2026-06-22)


### Features

* add check type registry, sample configs, notification senders, and
observability integrations
([eea049e](eea049e))
* batch — Warning/Degraded statuses, SSL/Docker check upgrades, MCP
OAuth 2.1, config-as-code
([#85](#85))
([936d830](936d830))
* batch spec implementations (dashboard UI, jobs, notifications, SaaS,
perf) ([#78](#78))
([fe003e4](fe003e4))
* bulk feature integration (discovery, web push, badges, webhooks, and
more) ([#73](#73))
([a976856](a976856))
* custom user-agent, refresh checks, vite plugin switch, CI updates
([#1](#1))
([cc00858](cc00858))
* documentation site served at /docs (co-located in web/docs)
([#88](#88))
([27d9ccd](27d9ccd))
* email check frontend (spec 03)
([#30](#30))
([aebd106](aebd106))
* email inbox foundation via JMAP (spec 01)
([#24](#24))
([0f3b0c1](0f3b0c1))
* email passive checks (spec 02)
([#27](#27))
([ba5536f](ba5536f))
* **entitlements:** trim to MaxSSOUsers + MaxChecksPerMinute + status
page history fixes
([#50](#50))
([a007de0](a007de0))
* **entitlements:** trim to MaxSSOUsers + MaxChecksPerMinute, enforce
both ([#49](#49))
([d25cc5f](d25cc5f))
* group incident correlation (spec 04 backend v1)
([#31](#31))
([1883986](1883986))
* **observability:** instrument hot path + add bench harness
([#60](#60))
([c6604cc](c6604cc))
* **oncall:** searchable timezone dropdown + sidebar logo polish
([#46](#46))
([4396898](4396898))
* per-IP HTTP rate limiting and concurrency limiting
([#59](#59))
([f9cc273](f9cc273))
* soften HTTP rate limits with bounded queues + request timeout
([#63](#63))
([025501b](025501b))
* SolidPing — distributed uptime monitoring platform
([eef4383](eef4383))
* **statuspages:** drag-and-drop resource reordering + dash conventions
([#41](#41))
([cf910d4](cf910d4))


### Bug Fixes

* **deps:** update dependency i18next to v26
([#26](#26))
([d5d1b7e](d5d1b7e))
* **deps:** update dependency lucide-react to v1
([#28](#28))
([cdc8e8c](cdc8e8c))
* **deps:** update dependency react-i18next to v17
([#29](#29))
([13135d8](13135d8))
* **deps:** update dependency recharts to v3.8.1
([#14](#14))
([5d95a3b](5d95a3b))
* **deps:** update go dependencies (non-major)
([#16](#16))
([2450f13](2450f13))
* **deps:** update go dependencies (non-major)
([#19](#19))
([f842310](f842310))
* **deps:** update go dependencies (non-major)
([#37](#37))
([c020eca](c020eca))
* **deps:** update go dependencies (non-major)
([#44](#44))
([ff0bcd0](ff0bcd0))
* **deps:** update go dependencies (non-major)
([#52](#52))
([2e3bc28](2e3bc28))
* **deps:** update go dependencies (non-major)
([#69](#69))
([a65ed4c](a65ed4c))
* **deps:** update go dependencies (non-major)
([#77](#77))
([a0920ff](a0920ff))
* **deps:** update go dependencies (non-major) to v1.4.2
([#86](#86))
([1eb7504](1eb7504))
* **deps:** update module github.com/aws/aws-sdk-go-v2/config to
v1.32.18 ([#72](#72))
([6406537](6406537))
* **deps:** update module github.com/aws/aws-sdk-go-v2/service/s3 to
v1.101.0 ([#39](#39))
([f9c9563](f9c9563))
* **deps:** update module github.com/go-webauthn/webauthn to v0.17.3
([#45](#45))
([593931a](593931a))
* **deps:** update module github.com/go-webauthn/webauthn to v0.17.4
([#70](#70))
([fca1c97](fca1c97))
* **deps:** update module github.com/ibm/sarama to v1.48.1
([#47](#47))
([93ccf3a](93ccf3a))
* **deps:** update module github.com/ibm/sarama to v1.48.2
([#54](#54))
([e84d868](e84d868))
* **deps:** update module github.com/ibm/sarama to v1.49.0
([#64](#64))
([fd61bd7](fd61bd7))
* **deps:** update module github.com/oapi-codegen/runtime to v1.4.1
([#65](#65))
([a3a3e9f](a3a3e9f))
* **deps:** update module github.com/prometheus/common to v0.67.5
([#61](#61))
([095dd6f](095dd6f))
* **deps:** update module github.com/slack-go/slack to v0.24.0
([#75](#75))
([6e86d5b](6e86d5b))
* **deps:** update module golang.org/x/sys to v0.44.0
([#42](#42))
([a245730](a245730))
* **deps:** update module golang.org/x/sys to v0.45.0
([#67](#67))
([49c3d90](49c3d90))
* **deps:** update module golang.org/x/term to v0.43.0
([#43](#43))
([4a934f1](4a934f1))
* **deps:** update module google.golang.org/grpc to v1.81.0
([#36](#36))
([1be183a](1be183a))
* **deps:** update module google.golang.org/grpc to v1.81.1
([#55](#55))
([6bfac2d](6bfac2d))
* status lifecycle improvements and created/running result handling
([#5](#5))
([fc64c7d](fc64c7d))
* **status0:** white page header and de-duplicated footer
([#48](#48))
([77506a7](77506a7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
This was referenced Sep 8, 2026
fclairamb added a commit that referenced this pull request Oct 11, 2026
## What & why

Deals with every open alert on the Security tab.

**Fixed in this PR**
- Dependabot #9: `github.com/moby/go-archive` v0.2.0 → v0.3.0 (tar
archive can write outside the extraction dir).
- Dependabot #10: `github.com/moby/sys/user` v0.4.0 → v0.4.1 (unbounded
parsing DoS).
- CodeQL #65 (clear-text logging, grdp `sec.go`): `sendFlagged` logged
the plaintext PDU in hex at debug level, and the client info PDU carries
the RDP password. It now logs the length only. Also removed the debug
logs of the client random and the four NTLM signing/sealing keys (same
class of leak, not flagged).
- CodeQL #61 (allocation-size overflow, `credentials/secret_fields.go`):
map size hint is now `max(a, b)` instead of `a + b`. Same change on
`MergePatch`.

**Dismissed (no code change)**
- #72-#81, #68-#71 (weak crypto / weak hashing in vendored
`third_party/grdp`): RC4, MD4, MD5, SHA-1 and DES are mandated by RDP
standard security and NTLM. Same reasoning as the VNC DES alerts
#94/#95.
- #31 (MD5 in `checksip`): SIP digest auth (RFC 3261/2617) is MD5.
- #33 (SHA-256 on password, `passwords/bcrypt.go`): pre-hash before
bcrypt to bypass the 72-byte limit. bcrypt is the slow hash.
- #54 (InsecureSkipVerify, `checkrdp`): leaf-only certificate inspection
by design, same as #62/#93.
- #47/#48 (cookie Secure, `statuspagelock`): `Secure: httpx.IsTLS(req)`,
same as #44/#59.
- #39 (request forgery, `jmap/client.go`): the JMAP session URL is set
by a super admin (instance operator), and reaching their own mail
server, often on the LAN, is the feature. Same as the Freebox alert #35.
- #17 (clear-text logging, `slack/commands.go`): map-value taint through
the check config, the password never reaches the log. Same as #18.

## How to test

- `go build ./...` and `go test ./internal/crypto/credentials/
./internal/checkers/checkrdp/...` in `server/`
- `go test ./...` in `server/third_party/grdp`
- `golangci-lint` v2.14.0 on `internal/crypto/...`: 0 issues

## Checklist
- [x] `go build`, lint and tests pass on the touched packages (full
`make test` left to CI)
- [ ] Tests added or updated for the change (log-only and size-hint
changes, existing tests cover behaviour)
- [ ] Docs updated (not user-visible)
- [ ] Schema changes (none)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant