test(macos): Filters subscription events by entity#225
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughI command: subscriber handlers now filter incoming events by entityName, invoking handlers only for matching entities to avoid cross-entity noise in tests. Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Test Context
participant Sub as Filtered Subscriber
participant Store as Event Store
Test->>Sub: Subscribe(with entityName)
Store->>Sub: Emit event(event.entityName)
rect `#f0f8ff`
Note over Sub: entityFilteredSubscriber checks entityName equality
end
alt entity matches
Sub->>Sub: Invoke handler (record / fail if intended)
Note over Sub: ✓ handler runs
else entity differs
Sub->>Sub: Yield / ignore event
Note over Sub: ✗ ignored
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to data retention organization setting 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Claude finished @NickSeagull's task —— View job PR Review: Filtering Subscription Events by EntityReview Tasks:
✅ Overall Assessment: Good Fix with Room for ConsistencyThis PR successfully addresses the macOS test interference issue with a targeted, minimal change that's well-documented. The fix is sound but could be applied more broadly for consistency. 📝 Code Quality & Best Practices✅ Positive:
🐛 Potential IssuesMinor Concerns:
No Critical Issues Found: The change doesn't introduce any bugs or breaking changes. ⚡ Performance Considerations✅ Performance Impact: Minimal
Potential optimization: Since all tests in this suite seem to use 🔒 Security Concerns✅ No Security Issues: The change involves test-only code with no security implications. Entity name filtering is a safe operation. 🧪 Test Coverage Impact✅ Positive Impact:
Suggestion: Consider adding a dedicated test that verifies entity filtering works correctly across multiple entities. 🎯 Recommendations
🏆 SummaryThis is a well-executed fix that directly addresses the macOS test interference problem. The implementation is clean, documented, and follows project conventions. While there's room for applying this pattern more broadly across the test suite, this targeted fix effectively resolves the immediate issue without over-engineering. Recommendation: ✅ Approve - The change is safe, effective, and improves test reliability. --- | Branch: |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
core/testlib/Test/Service/EventStore/Subscriptions/Spec.hs (3)
248-263: The divine protection remains incomplete! Additional tests remain vulnerable to cross-test interference.The filtering applied to the first test is absent here. This test subscribes to all events without filtering by
context.entityName, rendering it susceptible to the same cross-test interference this PR seeks to vanquish.Apply entity filtering to achieve protection:
-- Define different subscriber functions let subscriber1 event = do + if event.entityName == context.entityName + then subscriber1Events |> ConcurrentVar.modify (Array.push event) + else Task.yield unit - subscriber1Events |> ConcurrentVar.modify (Array.push event) Task.yield unit :: Task Text Unit let subscriber2 event = do + if event.entityName == context.entityName + then subscriber2Events |> ConcurrentVar.modify (Array.push event) + else Task.yield unit - subscriber2Events |> ConcurrentVar.modify (Array.push event) Task.yield unit :: Task Text Unit let subscriber3 event = do + if event.entityName == context.entityName + then subscriber3Events |> ConcurrentVar.modify (Array.push event) + else Task.yield unit - subscriber3Events |> ConcurrentVar.modify (Array.push event) Task.yield unit :: Task Text Unit
313-320: Another unshielded test discovered! Cross-test contamination may corrupt thy assertions.This test also subscribes to all events without entity filtering, leaving it vulnerable to events from concurrent test executions.
Apply the sacred filter:
-- Define subscriber function let subscriber event = do + if event.entityName == context.entityName + then receivedEvents |> ConcurrentVar.modify (Array.push event) + else Task.yield unit - receivedEvents |> ConcurrentVar.modify (Array.push event) Task.yield unit :: Task Text Unit
362-369: The high-frequency test stands exposed! Grant it the same protection.This test processes rapid event insertion without entity filtering, making it vulnerable to interference from events generated by parallel test executions.
Bestow the filtering logic upon this subscriber as well:
-- Define subscriber function that tracks events let subscriber event = do + if event.entityName == context.entityName + then receivedEvents |> ConcurrentVar.modify (Array.push event) + else Task.yield unit - receivedEvents |> ConcurrentVar.modify (Array.push event) Task.yield unit :: Task Text Unit
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
core/testlib/Test/Service/EventStore/Subscriptions/Spec.hs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: tests-macos
- GitHub Check: tests-linux
|
Claude finished @NickSeagull's task —— View job PR Review: Filtering Subscription Events by EntityReview Tasks:
✅ Overall Assessment: Good Fix with Room for ConsistencyThis PR successfully addresses the macOS test interference issue with a targeted, minimal change that's well-documented. The fix is sound but could be applied more broadly for consistency. 📝 Code Quality & Best Practices✅ Positive:
🐛 Potential IssuesMinor Concerns:
No Critical Issues Found: The change doesn't introduce any bugs or breaking changes. ⚡ Performance Considerations✅ Performance Impact: Minimal
Potential optimization: Since all tests in this suite seem to use 🔒 Security Concerns✅ No Security Issues: The change involves test-only code with no security implications. Entity name filtering is a safe operation. 🧪 Test Coverage Impact✅ Positive Impact:
Suggestion: Consider adding a dedicated test that verifies entity filtering works correctly across multiple entities. 🎯 Recommendations
🏆 SummaryThis is a well-executed fix that directly addresses the macOS test interference problem. The implementation is clean, documented, and follows project conventions. While there's room for applying this pattern more broadly across the test suite, this targeted fix effectively resolves the immediate issue without over-engineering. Recommendation: ✅ Approve - The change is safe, effective, and improves test reliability. --- | Branch: |
|
Claude finished @NickSeagull's task —— View job PR Review: Filtering Subscription Events by EntityReview Tasks:
✅ Overall Assessment: Excellent Fix with Strong ImplementationThis PR successfully addresses the macOS test interference issue with a well-architected solution. The introduction of the 📝 Code Quality & Best Practices✅ Positive:
✅ Code Style Compliance:
🐛 Potential Issues✅ No Critical Issues Found: The implementation is robust and well-thought-out. The helper function approach eliminates the previous inconsistency identified by CodeRabbit and provides a clean, maintainable solution. Minor Observations:
⚡ Performance Considerations✅ Performance Impact: Optimal
Optimization achieved: The refactoring from inline filtering to a helper function actually improves code organization without performance cost. 🔒 Security Concerns✅ No Security Issues:
🧪 Test Coverage Impact✅ Significant Positive Impact:
Test Coverage Analysis:
🎯 Recommendations✅ Implementation Completed Excellently The PR addresses all the concerns from the previous CodeRabbit review and implements a superior solution:
Minor Enhancement Opportunities (for future PRs):
🏆 SummaryThis is an exemplary fix that transforms a targeted bug fix into a comprehensive, maintainable solution. The introduction of the
Recommendation: ✅ Excellent Implementation - This PR demonstrates how to properly evolve from a tactical fix to a strategic solution. 📋 Change SummaryCore Changes (
CI Changes (
--- | Branch: |
Addresses test interference in macOS by filtering subscription events based on the entity name. This ensures that tests only process events relevant to their specific context, preventing cross-test contamination.
Summary by CodeRabbit
Bug Fixes
Chores