Skip to content

fix(restore): recover a replica's alert when the declaration is disabled (audit M10) - #440

Merged
passcod merged 1 commit into
mainfrom
claude/pr-370-fix-m10-replica-disable
Aug 1, 2026
Merged

fix(restore): recover a replica's alert when the declaration is disabled (audit M10)#440
passcod merged 1 commit into
mainfrom
claude/pr-370-fix-m10-replica-disable

Conversation

@passcod

@passcod passcod commented Aug 1, 2026

Copy link
Copy Markdown
Member

Fixes M10 (medium) from the audit in #370.

The bug

RestoreReplica::update recovers stale alerts when a declaration's scope moves, and delete recovers them too — both with the same reasoning in their doc-comments: "the overdue sweep only walks current declarations, so a stale key would otherwise never clear."

Flipping enabled to false removes the declaration from that sweep in exactly the same way — sweep_overdue filters enabled = true — but triggered no recovery. And a disabled replica generates no consumer work, so record_report can't clear the alert either.

The result is that the ordinary decommissioning move — a verification goes overdue and pages, the operator disables the declaration — leaves the alert and its incident open indefinitely, with nothing left in the system that could ever close them.

The fix

An enabled→disabled transition takes the same recovery path as a scope change.

Re-enabling deliberately recovers nothing: the sweep picks the declaration back up and re-raises if it's still overdue, so clearing on re-enable would just hide a live problem.

Tests

  • disabling_recovers_the_stale_alert — raise an alert, disable, assert it's cleared. Confirmed to fail against the unfixed code (alert stays active).
  • re_enabling_does_not_recover_anything — pins the other direction so the fix doesn't turn into "any enabled write clears alerts".

The existing 21-test restore suite passes unchanged.


Generated by Claude Code

`update` recovers stale alerts when a declaration's scope moves, and `delete`
recovers them too — both because "the overdue sweep only walks current
declarations, so a stale key would otherwise never clear". Flipping `enabled`
false removes the declaration from that sweep in exactly the same way
(`sweep_overdue` filters `enabled = true`), but triggered no recovery. A
disabled replica also generates no consumer work, so `record_report` can't
clear the alert either.

So the ordinary decommissioning move — a verification goes overdue and pages,
the operator disables the declaration — leaves the alert and its incident
open indefinitely, with nothing left in the system that could ever close
them.

Disabling now recovers the alert on the same path a scope change does.
Re-enabling deliberately doesn't clear anything: the sweep picks the
declaration back up and re-raises if it is still overdue.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SGfH1cdFKPnKpM7ytRThft
@passcod
passcod marked this pull request as ready for review August 1, 2026 22:16
@passcod
passcod added this pull request to the merge queue Aug 1, 2026
Merged via the queue into main with commit 61fe144 Aug 1, 2026
7 checks passed
@passcod
passcod deleted the claude/pr-370-fix-m10-replica-disable branch August 1, 2026 22:31
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