refactor(sdk): drop unused incrementedUnread payload from ChatMessageAppendOutcome#119
Closed
variablefate wants to merge 2 commits into
Closed
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 reviewOne issue found and fixed in 1b050d1:
Other checks clean: all call sites swept (no remaining `incrementedUnread` or `.inserted(` patterns), `ChatCoordinator.handleChatEvent` pattern-match still compiles against the no-payload `.inserted`, test semantic coverage preserved (the explicit `unreadCount == 0` after the stale append in `unreadCutoffSuppressesReplayedHistory` is strictly equivalent to the dropped payload-based assertion), ADR-0020 internal consistency confirmed. roadflare-ios/decisions/0020-chat-message-store.md Lines 119 to 130 in 1b050d1 🤖 Generated with Claude Code |
3 tasks
variablefate
added a commit
that referenced
this pull request
May 12, 2026
…AppendOutcome (#121) 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). Drop the payload. The enum becomes: case duplicate case inserted Updated ADR-0020 rationale + alternatives. (Re-opens the auto-closed PR #119; rebased onto main after PR #118 merged.)
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 top of #118 (renumber ADR). When #118 merges, GitHub will rebase this onto main.
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.
Per CLAUDE.md's "Don't design for hypothetical future requirements" guidance, drop the payload. The enum becomes:
```swift
public enum ChatMessageAppendOutcome: Equatable, Sendable {
case duplicate
case inserted
}
```
First-principles check
The principle: state changes are observable through their canonical source, not via return-value side channels. `unreadCount` IS the canonical source. The payload was a side channel duplicating it. Dropping it eliminates the duplication without losing information.
If a future consumer (driver app, badge-pulse UI, push routing) genuinely needs a "did this append bump unread" signal that's race-free from polling `unreadCount`, the payload can be added back at that point with the actual use case driving the shape.
Changes
Test plan
No protocol-surface impact (Kind 3178 wire format unchanged).