// Package evidence is the activity port: a dumb active-window sensor behind a // Source interface, plus the value types it emits. It makes no judgment about // whether a window is on-task — that is the advisor's job in a later milestone. package evidence import ( "context" "regexp" ) // EvidenceHealth records whether the sensor could observe the active window. type EvidenceHealth struct { Available bool // true when a window was observed Reason string // empty when Available; populated when not } // WindowSnapshot is one observation of the active window. type WindowSnapshot struct { Title string // full _NET_WM_NAME (raw; used in live view + raw log) Class string // WM_CLASS Health EvidenceHealth } // Source is the activity port. Watch runs until ctx is cancelled, invoking // onChange on every active-window change, and once immediately with the // current window. type Source interface { Watch(ctx context.Context, onChange func(WindowSnapshot)) } // titleNoise matches the legacy clock/ratio/percent runs that pollute bucket // keys (e.g. "1:23", "50.5%", "-3.0"). Ported verbatim from the Rust impl. var titleNoise = regexp.MustCompile(`-?\d+([:.]\d+)+%?`) // ScrubTitle removes volatile numeric runs so window titles bucket stably. // The raw event log keeps the unscrubbed title; only bucket keys are scrubbed. func ScrubTitle(title string) string { return titleNoise.ReplaceAllString(title, "") }