Skip to content

feat(internal): add stat-based file change poller#407

Draft
kinyoklion wants to merge 8 commits into
rlamb/sdk-2654/filedata-reloaderfrom
rlamb/sdk-2654/filedata-poller
Draft

feat(internal): add stat-based file change poller#407
kinyoklion wants to merge 8 commits into
rlamb/sdk-2654/filedata-reloaderfrom
rlamb/sdk-2654/filedata-poller

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Jul 7, 2026

Copy link
Copy Markdown
Member

Adds a Poller to internal/filedata that detects file changes by examining modification time and size on a fixed interval. It exists for environments where filesystem notifications are unavailable or unreliable (network mounts, some containers, Kubernetes ConfigMap symlink swaps): the file-based override source will offer it as a configurable alternative or supplement to watching, and it can later back a polling option on the file data sources if wanted.

A file appearing, disappearing, or becoming unreadable all count as changes. Detection is deliberately generous — the callback feeds a Reloader.Trigger, whose debouncing and skip-unchanged handling absorb spurious detections, so the poller itself stays trivial. The known blind spot (a same-size rewrite within the filesystem's timestamp granularity) is acceptable for the same reason: the retry path covers the failure half of that window, and tests sidestep it by explicitly bumping mtimes.

Internal only; nothing consumes it yet.

SDK-2654


Note

Low Risk
New internal-only utility with no callers yet; behavior is isolated behind tests and designed to pair with existing Reloader debouncing.

Overview
Adds an internal/filedata Poller that watches a list of paths on a fixed interval via os.Stat (existence, mod time, size) and calls onChange when any observed state changes, including create/delete/unreadable transitions. It is meant as a fallback or complement to fsnotify for unreliable mounts/containers, with Reloader.Trigger expected to debounce and skip no-op reloads.

Lifecycle is NewPoller (immediate baseline snapshot, goroutine + ticker) and idempotent Close that waits for shutdown. Tests cover modification, file appearing/disappearing, multi-path watching, and that callbacks stop after close (tests force distinct mtimes to avoid timestamp granularity blind spots).

Reviewed by Cursor Bugbot for commit a693af0. Bugbot is set up for automated code reviews on this repo. Configure here.

@kinyoklion kinyoklion requested a review from a team as a code owner July 7, 2026 21:23

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a693af0. Configure here.

// Poller detects changes to a set of files by examining them on a fixed interval, as an
// alternative or supplement to filesystem change notifications for environments where those
// are unavailable or unreliable. A change to any file's modification time or size — including
// the file appearing or disappearing — invokes the onChange callback. A file that cannot be

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unicode dashes in poller comments

Low Severity

The new Poller godoc uses Unicode em dashes () in two phrases. Project Go comment style expects ASCII -- instead of em dashes for readability across editors and terminals.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by learned rule: Go comments: use ASCII dashes and arrows, not Unicode

Reviewed by Cursor Bugbot for commit a693af0. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant