{"modulePath":"github.com/agentshield-dev/agentshield","version":"v0.0.1-rc.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package coherentcache\n\nPackage coherentcache is the consumer loop shared by the Kubernetes-backed semantic plugins. It subscribes to a plugin's resource collections and the Kubernetes coverage collection, keeps a cache from replay and live changes, and calls the plugin's projector only on a coherent snapshot: every resource collection and the coverage collection synced at the same Kubernetes generation. It then replaces the plugin's contribution at the plugin's next generation.\n\n## Functions\n\n```go\nfunc Run(ctx context.Context, runtime discovery.Runtime, config Config) error\n```\nRun consumes the collections and replaces the contribution whenever both the objects and the coverage reach a new coherent generation. It returns on ctx cancellation, a subscription error or unexpected closure, a malformed change, or a failed projection or publication. Before returning for a subscription failure after a successful publication, it republishes the last coherent snapshot with degraded health.\n\n## Types\n\n```go\ntype Config struct {\n\tPluginID string\n\tSourceID string\n\t// Contribution is the name of the contribution Project fills.\n\tContribution string\n\tResources    []*kubernetesplugin.ResourceClient[*unstructured.Unstructured]\n\t// ReadyCollection, if set, is marked ready at each published generation\n\t// for plugins that consume this plugin's projection.\n\tReadyCollection string\n\t// OnObjects, if set, receives each new coherent object set before it is\n\t// published, for example to refresh a telemetry resolver. It must not\n\t// modify the map or its objects.\n\tOnObjects func(map[string]Object)\n\t// Project returns the contribution input and the source health derived\n\t// from coverage. It must be a pure function of the snapshot.\n\tProject func(Snapshot) (graph.Input, string, error)\n}\n```\nConfig describes one semantic plugin instance.\n\n```go\ntype Object struct {\n\tKey        string\n\tObject     *unstructured.Unstructured\n\tEventID    string\n\tRevision   string\n\tObservedAt time.Time\n}\n```\nObject keeps collection delivery metadata beside the native object so projected assertions can cite the native event as evidence.\n\n```go\ntype Snapshot struct {\n\tObjects []Object\n\t// Coverage is keyed by lowercase capability/GVR.\n\tCoverage map[string]kubernetesplugin.ResourceCoverage\n}\n```\nSnapshot is one coherent immutable view of every consumed collection.\n\n","path":"github.com/agentshield-dev/agentshield/plugins/internal/coherentcache","name":"coherentcache","synopsis":"Package coherentcache is the consumer loop shared by the Kubernetes-backed semantic plugins.","isRedistributable":true}
