Add incident coalescing (D-0052) #129

Merged
hannah-vernon merged 1 commit from feature/incident-coalescing into dev 2026-09-23 00:47:38 -05:00
Owner

What does this PR do?

Adds incident coalescing (D-0052). It merges same-source events that arrive within a settle window into a single incident and a single final decision, fixing the observed bug where two events seconds apart produced two separate decisions instead of one.

Design is Option B (debounced-final, withdraw-pending, superseded-always-visible):

  • The first event emits an immediate provisional decision while the incident stays absorbable until its CoalesceUntil deadline.
  • Later same-source events append to the incident and extend the window (bounded by MaxCoalesceWindow) without re-enqueuing.
  • When the window closes, CoalescingFinalizerWorker either reopens and re-classifies a grown incident, emitting one merged final decision that supersedes the still-pending provisional one, or closes an unchanged incident.
  • Reviewing a decision finalizes its incident so later events start a fresh incident.

The three settings (Enabled, SettleWindowSeconds, MaxCoalesceWindowSeconds) are exposed via the read-only API and are editable in the Admin UI behind a step-up gate, with an audit record written on change. Superseded decisions show a badge and are non-actionable in the review queue.

Includes the EF migration AddIncidentCoalescing, in-memory and Postgres config stores with change notification, and documentation updates (DECISIONS.md D-0052, ARCHITECTURE.md, AGENT-README.md, TODO.md, docs/read-only-api.md).

How was this tested?

  • dotnet build - 0 errors, 0 warnings
  • dotnet test - Application 564/564, AdminApi 212/212, and Postgres integration 87/87 (against a disposable Postgres 17 container) all pass
  • Manually tested on the in-memory rig (no touch to the live installation or database)

Checklist

  • I have read the Contributing Guide
  • Changes are focused - one logical change per PR
  • Documentation updated (README.md / DECISIONS.md / TODO.md / AGENT-README.md, if applicable)
  • New dependencies are MIT/Apache-2.0/BSD, security-vetted, and recorded in THIRD-PARTY-NOTICES.md
  • No secrets, credentials, or real infrastructure identifiers in the diff
  • No commented-out code or debug leftovers
## What does this PR do? Adds incident coalescing (D-0052). It merges same-source events that arrive within a settle window into a single incident and a single final decision, fixing the observed bug where two events seconds apart produced two separate decisions instead of one. Design is Option B (debounced-final, withdraw-pending, superseded-always-visible): - The first event emits an immediate provisional decision while the incident stays absorbable until its `CoalesceUntil` deadline. - Later same-source events append to the incident and extend the window (bounded by `MaxCoalesceWindow`) without re-enqueuing. - When the window closes, `CoalescingFinalizerWorker` either reopens and re-classifies a grown incident, emitting one merged final decision that supersedes the still-pending provisional one, or closes an unchanged incident. - Reviewing a decision finalizes its incident so later events start a fresh incident. The three settings (`Enabled`, `SettleWindowSeconds`, `MaxCoalesceWindowSeconds`) are exposed via the read-only API and are editable in the Admin UI behind a step-up gate, with an audit record written on change. Superseded decisions show a badge and are non-actionable in the review queue. Includes the EF migration `AddIncidentCoalescing`, in-memory and Postgres config stores with change notification, and documentation updates (DECISIONS.md D-0052, ARCHITECTURE.md, AGENT-README.md, TODO.md, docs/read-only-api.md). ## How was this tested? - [x] `dotnet build` - 0 errors, 0 warnings - [x] `dotnet test` - Application 564/564, AdminApi 212/212, and Postgres integration 87/87 (against a disposable Postgres 17 container) all pass - [x] Manually tested on the in-memory rig (no touch to the live installation or database) ## Checklist - [x] I have read the [Contributing Guide](../CONTRIBUTING.md) - [x] Changes are focused - one logical change per PR - [x] Documentation updated (README.md / DECISIONS.md / TODO.md / AGENT-README.md, if applicable) - [x] New dependencies are MIT/Apache-2.0/BSD, security-vetted, and recorded in THIRD-PARTY-NOTICES.md - [x] No secrets, credentials, or real infrastructure identifiers in the diff - [x] No commented-out code or debug leftovers
Merge same-source events that arrive within a settle window into a single
incident and a single final decision, fixing the bug where two events
seconds apart produced two separate decisions.

Design (Option B, debounced-final): the first event emits an immediate
provisional decision while the incident stays absorbable until CoalesceUntil.
Later same-source events append to the incident and extend the window
(bounded by MaxCoalesceWindow) without re-enqueuing. When the window closes,
CoalescingFinalizerWorker either reopens and re-classifies a grown incident,
emitting one merged final decision that supersedes the still-pending
provisional one, or closes an unchanged incident. Reviewing a decision
finalizes its incident so later events start fresh.

Settings (Enabled, SettleWindowSeconds, MaxCoalesceWindowSeconds) are exposed
via the read-only API and editable in the Admin UI behind a step-up gate,
with an audit record on write. Superseded decisions render a badge and are
non-actionable in the review queue.

Includes EF migration AddIncidentCoalescing, in-memory and Postgres config
stores with change notification, 16 new in-memory tests, and Postgres
round-trip tests. Docs updated: DECISIONS.md (D-0052), ARCHITECTURE.md,
AGENT-README.md, TODO.md, docs/read-only-api.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
hannah-vernon deleted branch feature/incident-coalescing 2026-09-23 00:47:38 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
hannah-vernon/viegard-sentinel!129
No description provided.