Add an atomic zone event outbox - 2 - #5730
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical concurrency and coalescing issues, plus moderate expiry and error-propagation issues, block approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a standalone, persistent outbox for zone events without integrating delivery into ZoneManager.
Changes:
- Adds persisted pending-event models and outbox operations.
- Implements expiry, coalescing, capacity handling, and atomic file storage.
- Adds 23 focused XCTest cases.
File summaries
| File | Summary |
|---|---|
Tests/App/ZoneManager/ZoneEventOutbox.test.swift |
Tests persistence, ordering, expiry, coalescing, capacity, and failure handling. |
Sources/App/ZoneManager/ZoneEventOutbox.swift |
Defines the outbox interface. |
Sources/App/ZoneManager/PendingZoneEvent.swift |
Defines persisted zone-event data. |
Sources/App/ZoneManager/AtomicFileZoneEventOutbox.swift |
Implements file-backed storage and queue management; has two critical and two moderate unresolved findings covering concurrency, coalescing, expiry, and error propagation. |
Review details
Suppressed comments (1)
Sources/App/ZoneManager/AtomicFileZoneEventOutbox.swift:44
- Appending an already-expired event returns before
load(). If the persisted file is corrupt or otherwise unreadable, this path silently hides the read/decoding error instead of propagating it as promised by the outbox contract, so callers can continue believing the store is usable. Load the existing events before applying the freshness guard (without saving the expired input).
guard isFresh(event, at: now) else { return }
var events = try freshEvents(from: load(), at: now)
- Files reviewed: 4/4 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟢 Approval recommended
The implementation is well-covered and addresses prior concurrency and expiry findings; only the test count in the PR description needs correction.
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Balanced
| XCTAssertEqual(try Data(contentsOf: fileURL), original) | ||
| } | ||
|
|
||
| func testConcurrentInstancesPreserveEveryAppend() throws { |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5730 +/- ##
==========================================
- Coverage 42.87% 42.78% -0.10%
==========================================
Files 1124 1126 +2
Lines 78186 78005 -181
==========================================
- Hits 33523 33374 -149
+ Misses 44663 44631 -32
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
AI Policy
Select exactly one option that describes AI usage in this contribution:
Summary
Add a standalone, atomic file-backed outbox for pending zone events. This is part 2 of the split requested for #5629.
This foundation does not activate outbox delivery in ZoneManager and does not depend on #5703. Delivery integration will follow separately.
Screenshots
N/A — internal persistence changes only; no visual changes.
Link to pull request in Documentation repository
N/A — this foundation does not activate user-facing functionality or configuration.
Any other notes
Completed validation:
Pending CI verification:
The test count describes the available test cases, not a completed test run.