fix: eliminate reconnect duplicate logs with KMP dedup (FAR-105) #4

Closed
farhoodliquor-paperclip[bot] wants to merge 1 commits from fix/far-105-dedup-kmp-v2 into master

1 Commits

Author SHA1 Message Date
Test User 3fe4721da6 fix: eliminate reconnect duplicate logs with KMP-based dedup (FAR-105)
The prior fix (sinceSeconds window anchored to lastLogReceivedAt) still
caused duplicates: on reconnect, the K8s API re-streams N seconds of
already-seen content and those bytes were forwarded to onLog verbatim.

New approach:
- First stream attempt: emit chunks to onLog in real-time as before.
- Reconnect attempts: buffer all incoming chunks rather than emitting
  immediately, then call findNewLogContent() to strip any prefix of the
  buffered data that overlaps with content already sent, and forward only
  the genuinely new suffix.
- findNewLogContent uses the KMP failure-function algorithm (O(N)) to
  find the longest prefix of the reconnect data that matches a suffix of
  the accumulated content, guaranteeing correct deduplication even for
  large sinceSeconds windows or rapidly repeated lines.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-21 20:13:58 +00:00