docs/sdk-watcher.md
The SDK service exposes a watcher integration that surfaces granular auth updates without forcing a full reload. This document explains the queue contract, how the service consumes updates, and how high-frequency change bursts are handled.
watcher.AuthUpdate represents a single credential change. Action may be add, modify, or delete, and ID carries the credential identifier. For add/modify the Auth payload contains a fully populated clone of the credential; delete may omit Auth.WatcherWrapper.SetAuthUpdateQueue(chan<- watcher.AuthUpdate) wires the queue produced by the SDK service into the watcher. The queue must be created before the watcher starts.ensureAuthUpdateQueue, using a buffered channel (capacity=256) and a dedicated consumer goroutine (consumeAuthUpdates). The consumer drains bursts by looping through the backlog before reacquiring the select loop.internal/watcher/watcher.go keeps a shadow snapshot of auth state (currentAuths). Each filesystem or configuration event triggers a recomputation and a diff against the previous snapshot to produce minimal AuthUpdate entries that mirror adds, edits, and removals.ensureAuthUpdateQueue before starting the watcher to allocate the shared channel.WatcherWrapper is created, call SetAuthUpdateQueue with the service queue, then start the watcher.handleAuthUpdate.Following this flow keeps auth changes responsive while avoiding full reloads for every edit.