refactor(sdk): drop unused incrementedUnread payload from ChatMessageAppendOutcome#121
Merged
Merged
Conversation
…AppendOutcome
The .inserted associated value was added to support a haptic-decision use
case that turned out not to need it. ChatCoordinator.handleChatEvent only
ever pattern-matches on `case .inserted` for the haptic — it never reads
the payload. Tests that exercised the unread side effect also assert
store.unreadCount directly (the canonical source).
Per the project's YAGNI guidance ("Don't design for hypothetical future
requirements"), drop the payload. The enum becomes:
case duplicate
case inserted
If a future consumer genuinely needs a fresh-unread signal it can be
added back as an associated value at that time.
Updated ADR-0020 rationale and alternatives-considered section to reflect
the actual motivation for the enum shape (readable named cases at call
sites vs Bool) and the reason for dropping the payload.
Tests rewritten: every `.inserted(incrementedUnread: ...)` simplified to
`.inserted`, with explicit `store.unreadCount` assertions added where the
payload was the sole carrier of the unread-side-effect check
(specifically `unreadCutoffSuppressesReplayedHistory`).
All 21 ChatMessageStore tests pass; full xcodebuild RoadFlareTests scheme
passes.
The phrase implied .claude/CLAUDE.md contains a YAGNI principle, but it
does not — its Project Conventions section covers SDK/app split, build
verification, and concurrency only. Reword the justification to stand
on its own ("the payload was dead public surface") so a future reader
chasing the citation does not come up empty.
Owner
Author
Code review (full ritual)No issues found. 5-agent pass on the rebased HEAD:
🤖 Generated with Claude Code |
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.
Re-opening: original PR #119 was auto-closed by GitHub when its base branch (`chore/renumber-adr-chat-message-store`) was deleted on PR #118 merge. Rebased cleanly onto main.
Summary
The `.inserted(incrementedUnread:)` payload was a hypothetical-haptic-decision feature that turned out unused. `ChatCoordinator.handleChatEvent` only matches `case .inserted` — it never reads the payload. Tests that exercised the unread side effect also assert `store.unreadCount` directly, which is the canonical source.
Drop the payload. The enum becomes:
```swift
public enum ChatMessageAppendOutcome: Equatable, Sendable {
case duplicate
case inserted
}
```
First-principles
State changes should be observable through their canonical source, not via return-value side channels. `unreadCount` IS the canonical source. The payload was duplicating it. Dropping it eliminates duplication without losing information.
Changes
Test plan
No protocol-surface impact (Kind 3178 wire format unchanged).