feat(rotation): Phase 4 — retired-key cleanup scheduler (#72) - #131
Closed
sarg3nt wants to merge 1 commit into
Closed
feat(rotation): Phase 4 — retired-key cleanup scheduler (#72)#131sarg3nt wants to merge 1 commit into
sarg3nt wants to merge 1 commit into
Conversation
4 tasks
Adds a background sweeper that walks every enabled box on a tick and removes any keys whose retired_at + overlap window has passed — completing the install→use→remove three-phase rotation cycle without operator intervention. Originally Phase 4 in the issue plan also covered auto-rotation on a schedule (off by default, configurable cadence). That needs a new global-settings surface in the dashboard (no app-level config table exists today; only user_preferences), which is its own design pass. Deferring the auto-rotate scheduler to a follow-up so this PR stays focused on the piece that's actually needed regardless of whether auto-rotation is enabled. What's here ----------- `services/agent_keyring/cleaner.go` - `RetiredKeyCleaner` runs as a goroutine off the dashboard's process-lifetime context. - Hourly tick (`CleanerInterval`) — short enough that a 24h rotation cleans up within a few hours of its target, long enough that the sweep is cheap. - Immediate sweep on start so a freshly-deployed dashboard catches up on any retired keys left from manual rotations done while the prior instance was down. - Per-box failures are logged but don't halt the sweep; one unreachable agent shouldn't block cleanup on the others. `cmd/server/main.go` - Wires the cleaner into startup alongside the existing alert evaluator. Cancelled when main returns. Tests ----- - `TestCleaner_RemovesRetiredKeyOnTick` — rotates a box, then runs the cleaner with a 1ms overlap and 20ms interval; verifies the retired key is removed from both the mock agent and the DB. - `TestCleaner_NoopWhenNothingRetired` — no rotation happens, so the cleaner finds nothing to do; verifies the seeded entry survives a sweep. Refs: Phase 4 (lite) of the implementation plan posted to #72. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
sarg3nt
force-pushed
the
feature/issue-72-phase-3-rotate-ui
branch
from
May 17, 2026 19:03
c66f37a to
139e7b7
Compare
sarg3nt
force-pushed
the
feature/issue-72-phase-4-cleanup-scheduler
branch
from
May 17, 2026 19:03
71f92b0 to
7645c9b
Compare
4 tasks
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.
Summary
Stacked on #130 (Phase 3). Adds a background sweeper that walks every enabled box on a tick and removes any keys whose retired_at + overlap window has passed — completing the install→use→remove three-phase rotation cycle without operator intervention.
Implementation
services/agent_keyring/cleaner.go—RetiredKeyCleanerruns as a goroutine off the dashboard's process-lifetime contextCleanerInterval) — short enough that a 24h-overlap rotation cleans up within a few hours of its target, long enough that the sweep is cheapcmd/server/main.gostartup alongside the existing alert evaluatorTest plan
CleanerIntervallow for testing); confirm the old kid is removed from both the agent's/api/v1/system/keyringand the dashboard's DBStack
Phase 4 of 5. Base:
feature/issue-72-phase-3-rotate-ui(#130).Closes part of #72.
🤖 Generated with Claude Code