applyGroundingVerification method
Applies a verification result (§3.1/§3.3) — either the live
grounding_verification frame or the reconnect catch-up
grounding_verified event, both funneled through the same
GroundingVerificationFrame shape. Idempotent / last-write-wins,
keyed on queryId, and also propagated to any sibling rows in the
same queryGroupId that already share this turn's grounding.
Implementation
void applyGroundingVerification(GroundingVerificationFrame frame) {
if (frame.queryId.isEmpty) return;
final PupauMessage? target = messages.firstWhereOrNull(
(PupauMessage m) => m.id == frame.queryId,
);
if (target == null) return;
final GroundingInfo base =
target.grounding ?? GroundingInfo(queryId: frame.queryId);
target.grounding = base.withVerification(frame);
final String groupId = target.groupId;
if (groupId.isNotEmpty) {
backfillGroupGrounding(
messages.where((PupauMessage m) => m.groupId == groupId).toList(),
);
}
messages.refresh();
update();
}