fix: Clean up acknowledged messages in message routing loop#342
Open
aronchick wants to merge 1 commit intodlorenc:mainfrom
Open
fix: Clean up acknowledged messages in message routing loop#342aronchick wants to merge 1 commit intodlorenc:mainfrom
aronchick wants to merge 1 commit intodlorenc:mainfrom
Conversation
## Problem Messages were piling up in the filesystem because acknowledged messages were never deleted. The messages.Manager had a DeleteAcked() method, but it was never called by the daemon's message routing loop. Evidence: - 128 message files accumulated in production - 17 acked messages that should have been deleted - 111 delivered messages never acknowledged ## Root Cause The messageRouterLoop delivered messages and marked them as "delivered", but had no cleanup mechanism. The DeleteAcked() method existed but was only used in tests. ## Solution Added automatic cleanup of acknowledged messages to the routeMessages() function. After delivering pending messages to each agent, the loop now calls DeleteAcked() to remove any messages that have been acknowledged. The cleanup: - Runs every 2 minutes as part of the normal message routing cycle - Only deletes messages with status "acked" - Logs cleanup activity at debug level for visibility - Handles errors gracefully without disrupting message delivery ## Testing - Added TestMessageRoutingCleansUpAckedMessages to verify cleanup works - All existing daemon tests pass - Verified in production: 17 acked messages cleaned up after daemon restart ## Impact - Prevents unbounded growth of message files - Reduces filesystem clutter - Makes the message system more reliable - No breaking changes to message API or behavior Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Contributor Author
| ✅ Merge Queue: READY TO MERGE
This PR is ready for maintainer merge. |
whitmo added a commit to whitmo/multiclaude that referenced this pull request Feb 28, 2026
whitmo added a commit to whitmo/multiclaude that referenced this pull request Feb 28, 2026
…nc#336, dlorenc#340, dlorenc#342 Add 659 lines of tests covering: - All 18 structured error constructors from PR dlorenc#340 (individual + bulk format test) - JSON CLI output edge cases from PR dlorenc#335 (empty/nested/all-internal subcommands) - Structured CLIError validation for workspace names from PR dlorenc#340 integration - Message routing edge cases from PR dlorenc#342 (no acked, mixed ack status) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 28, 2026
whitmo added a commit to whitmo/multiclaude that referenced this pull request Mar 1, 2026
whitmo added a commit to whitmo/multiclaude that referenced this pull request Mar 1, 2026
…nc#336, dlorenc#340, dlorenc#342 Add 659 lines of tests covering: - All 18 structured error constructors from PR dlorenc#340 (individual + bulk format test) - JSON CLI output edge cases from PR dlorenc#335 (empty/nested/all-internal subcommands) - Structured CLIError validation for workspace names from PR dlorenc#340 integration - Message routing edge cases from PR dlorenc#342 (no acked, mixed ack status) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Mar 1, 2026
3 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.
Problem
Messages were piling up in the filesystem because acknowledged messages were never deleted. The
messages.Managerhad aDeleteAcked()method, but it was never called by the daemon's message routing loop.Evidence:
Root Cause
The
messageRouterLoopdelivered messages and marked them as "delivered", but had no cleanup mechanism. TheDeleteAcked()method existed but was only used in tests.Solution
Added automatic cleanup of acknowledged messages to the
routeMessages()function ininternal/daemon/daemon.go:423-429. After delivering pending messages to each agent, the loop now callsDeleteAcked()to remove any messages that have been acknowledged.The cleanup:
Testing
TestMessageRoutingCleansUpAckedMessagesto verify cleanup worksFiles Changed
internal/daemon/daemon.go- Added cleanup call inrouteMessages()(8 lines)internal/daemon/daemon_test.go- Added test for message cleanup (76 lines)Impact
Future Opportunities
While this PR fixes the acked message accumulation, there are still 111 delivered messages that were never acknowledged. These could be addressed in a future PR by:
🤖 Generated with Claude Code