Background
DriverDetailViewState.from() and RideRequestDriverOption.from() inline the
predicate driver.hasKey && !isKeyStale && location?.status == "online" for
canRequestRide, instead of calling the SDK-side
FollowedDriversRepository.canRequestRide(_:) that already exists.
History
This drift was first surfaced in PR #58's 4th-pass review and re-flagged in PR
#61's review as a follow-up to fix at next touch. PR #93 (Kind 30173 vehicle
work) did modify DriverDetailViewState.swift (added a vehicle: parameter)
but kept the inline predicate to honour PR #91's "don't widen scope" constraint.
Why it matters
- The inline predicate omits the "driver exists in repo" guard pinned by
CanRequestRideTests.staleCallerSnapshot_hasKeyButRepoMissingKey_returnsFalse
on the SDK side. Practically harmless today (callers always pass a real
FollowedDriver), but a real semantic gap.
- Two divergent definitions of "rider can request a ride from this driver" make
future protocol-level changes (e.g. new key staleness conditions) risky:
callers updating one definition and forgetting the other would silently drift
the UI from the SDK contract.
Scope
Consolidate the inline predicate in:
RoadFlare/RoadFlareCore/Presentation/DriverDetailViewState.swift
RoadFlare/RoadFlareCore/Presentation/RideRequestDriverOption.swift
into calls to FollowedDriversRepository.canRequestRide(_:). Update the
factory signatures to accept canRequestRide: Bool (resolved by
AppState+Presentation) rather than re-deriving from raw inputs. Update
existing tests to feed the resolved boolean.
Effort
Small — one-shot refactor + test churn. No protocol changes.
Background
DriverDetailViewState.from()andRideRequestDriverOption.from()inline thepredicate
driver.hasKey && !isKeyStale && location?.status == "online"forcanRequestRide, instead of calling the SDK-sideFollowedDriversRepository.canRequestRide(_:)that already exists.History
This drift was first surfaced in PR #58's 4th-pass review and re-flagged in PR
#61's review as a follow-up to fix at next touch. PR #93 (Kind 30173 vehicle
work) did modify
DriverDetailViewState.swift(added avehicle:parameter)but kept the inline predicate to honour PR #91's "don't widen scope" constraint.
Why it matters
CanRequestRideTests.staleCallerSnapshot_hasKeyButRepoMissingKey_returnsFalseon the SDK side. Practically harmless today (callers always pass a real
FollowedDriver), but a real semantic gap.future protocol-level changes (e.g. new key staleness conditions) risky:
callers updating one definition and forgetting the other would silently drift
the UI from the SDK contract.
Scope
Consolidate the inline predicate in:
RoadFlare/RoadFlareCore/Presentation/DriverDetailViewState.swiftRoadFlare/RoadFlareCore/Presentation/RideRequestDriverOption.swiftinto calls to
FollowedDriversRepository.canRequestRide(_:). Update thefactory signatures to accept
canRequestRide: Bool(resolved byAppState+Presentation) rather than re-deriving from raw inputs. Updateexisting tests to feed the resolved boolean.
Effort
Small — one-shot refactor + test churn. No protocol changes.