observe method

bool observe(
  1. String id,
  2. int revision
)

Records revision as the last applied for id.

Returns true when the revision is contiguous (the first for id, or exactly one past the previous), false when it skips a revision (a gap) or is a duplicate/regressive delivery (at or below the last applied revision). A duplicate/regressive revision never rewinds the frontier, so an at-least-once transport's redelivery cannot make a real gap read as healed.

Implementation

bool observe(String id, int revision) {
  final last = _lastApplied[id];
  if (last != null && revision <= last) return false; // duplicate/regressive
  _lastApplied[id] = revision;
  return last == null || revision == last + 1;
}