diff --git a/checker/types.go b/checker/types.go index ed4a9fc..ee67132 100644 --- a/checker/types.go +++ b/checker/types.go @@ -220,6 +220,24 @@ type ObservationProvider interface { Collect(ctx context.Context, opts CheckerOptions) (any, error) } +// ObservationSharer is an optional interface an ObservationProvider can +// implement to declare that its observation depends only on a subset of the +// inputs and may therefore be shared across check targets. +// +// ShareKey returns a stable string derived purely from the inputs that affect +// the result (e.g. the sorted IP set + ping count). Two collections with the +// same ShareKey produce identical data; the host may serve one from the other. +// Return "" to opt out (the host falls back to per-target caching). +// +// ShareKey MUST be a pure function of opts: no network, no I/O. The host calls +// it before deciding whether to collect, possibly on the locally registered +// provider even when actual collection is delegated to a remote endpoint. +// +// Detect support with a type assertion: _, ok := provider.(ObservationSharer) +type ObservationSharer interface { + ShareKey(opts CheckerOptions) (string, error) +} + // CheckRuleInfo is the JSON-serializable description of a rule, for API/UI listing. type CheckRuleInfo struct { Name string `json:"name"`