# Effector interface An **effector is not a separate program**. It's the CCF **agent** running one or more **effector plugins**, next to (or instead of) its collector plugins. The agent already has what an effector needs: API authentication, plugin download and verification, remote configuration, heartbeats and instance IDs. This document covers what the agent adds to act as an effector: configuration, effector actions, validation, and the plugin contract. The protocol with the API is in [wire interface](wire-interface.md). ```mermaid flowchart TB subgraph Agent["ccf-agent"] subgraph Shared["Shared (exists today)"] CFG["Config file + remote config overlay"] PL["Plugin loader
OCI sources, trusted_sources"] AUTH["API client + auth"] HB["Heartbeat, config report,
instance ID, state dir"] end subgraph Collect["Collector plugins (exists today)"] SCH["Scheduler"] --> CP["collector plugins"] end subgraph Effect["Effector plugins (new)"] RX["Webhook receiver
signature, dedupe,
action + target check"] MEM["In-memory effects
(from the API)"] WK["Worker + reconciler"] XR["External ingress
/ext/{plugin}/…"] EP["effector plugins"] end end RX --> MEM --> WK --> EP XR --> EP PL --> CP PL --> EP CP -- "ApiHelper" --> AUTH EP -- "EffectorHelper only" --> AUTH ``` One agent can run collector plugins, effector plugins, or both. A plugin's `type` says which. ## Configuration Effector settings use the agent's existing configuration file and conventions: snake_case keys, `CCF_` environment variables, `${env:NAME}` placeholders for secrets in plugin config, and `remote_config` for what an API overlay may change. Today placeholders are resolved only in `plugins.*.config`; they'd be resolved in `plugins.*.actions.*.config` too, with the same rules. Three things are new: - `plugins..type`: `collector` (the default, so existing configs don't change) or `effector`. - `plugins..actions`: the effector actions an effector plugin offers. - A top-level `effector` block: the webhook listener and defaults. It's only needed when at least one effector plugin is enabled. ```yaml daemon: true api: url: https://ccf.acme.com auth: # or CCF_API_AUTH_CLIENT_ID / CCF_API_AUTH_CLIENT_SECRET client_id: 6f1c… client_secret: … effector: listen: 0.0.0.0:8443 public_url: https://agent-platform.acme.internal # base URL; must equal the one an admin set in the API tls: # optional: omit when TLS is terminated in front of the agent cert: /tls/tls.crt key: /tls/tls.key stale_after: 15m # no successful API contact for this long → on_stale applies defaults: # for every effector plugin and action, unless overridden below on_stale: keep # keep | fail-open | fail-closed reconcile_interval: 10m targets_refresh: 15m plugins: github-settings: # a collector plugin: unchanged from today source: ghcr.io/compliance-framework/plugin-github-settings:1.2.0 schedule: "0 * * * *" policies: [ghcr.io/compliance-framework/plugin-github-settings-policies:1.0.0] config: token: ${env:GITHUB_TOKEN} slack: type: effector source: ghcr.io/compliance-framework/effector-slack:1.0.0 reconcile_interval: 5m # overrides effector.defaults for this plugin config: # plugin config: credentials and connection bot_token: ${env:SLACK_BOT_TOKEN} actions: notify-platform: description: Short alert to platform channels effect: notify targets: include: ["slack-channel:#platform", "slack-channel:#platform-*"] exclude: ["slack-channel:#platform-exec"] on_clear: resolve publish_targets: true config: # action config: how to perform it template: short notify-person: description: Detailed direct message effect: notify targets: include: ["slack-user:*"] config: template: detailed github-checks: type: effector source: ghcr.io/compliance-framework/effector-github-checks:1.0.0 config: app_id: "123456" private_key: ${env:GITHUB_APP_KEY} webhook_secret: ${env:GITHUB_WEBHOOK_SECRET} actions: block-prs: description: Required check that fails while the rule is active effect: block targets: include: ["github-repo:github.com/acme/*"] on_clear: revert on_stale: fail-open # overrides effector.defaults.on_stale for this action config: check_name: CCF compliance remote_config: # unchanged: local only mode: report trusted_sources: ["ghcr.io/compliance-framework/*"] allow_local_sources: false ``` ### The `effector` block | Field | Required | Meaning | | --- | --- | --- | | `listen` | Yes | Address the webhook receiver binds to | | `public_url` | Yes | The agent's **base URL** as the API reaches it. The agent serves `/v1/webhook` (deliveries), `/ext/{plugin}/…` (provider webhooks), `/healthz` and `/readyz` under it. It must equal the base URL an admin set for this agent in the API, after normalisation (`409` on registration otherwise), so a leaked key can't redirect deliveries. Must be `https`, unless the API runs with `CCF_EFFECTOR_ALLOW_INSECURE_WEBHOOKS=true` (local development) | | `tls` | **No** | Certificate and key for the listener. Omit it when TLS is terminated in front of the agent (ingress, load balancer, service mesh): `public_url` still has to be `https`, but the agent itself listens in plain HTTP | | `stale_after` | No (`15m`) | How long without successful API contact before `on_stale` applies | | `defaults` | No | Defaults for plugins and actions (below) | ### Defaults and overrides Settings in `effector.defaults` can be overridden by a plugin or an action. The most specific one wins: | Setting | `effector.defaults` | `plugins.

` | `plugins.

.actions.` | Default | | --- | --- | --- | --- | --- | | `on_stale` | yes | yes | yes | `keep` | | `reconcile_interval` | yes | yes | — | `10m` | | `targets_refresh` | yes | yes | yes | `15m` | | `on_clear` | — | — | yes | the default the plugin declares for that effect | `reconcile_interval` is per plugin because `Reconcile` works on all of a plugin's effects at once. ### Plugin fields | Field | Collector | Effector | | --- | --- | --- | | `type` | `collector` (default) | `effector` | | `source`, `enabled`, `protocol_version`, `config`, `labels` | as today | as today | | `schedule`, `policies`, `policy_data`, `policy_behavior` | as today | not allowed: effector plugins are driven by effects, not schedules, and don't evaluate policies | | `actions` | not allowed | required (at least one) | | `reconcile_interval`, `targets_refresh`, `on_stale` | not allowed | optional overrides | | `apply_timeout`, `reconcile_timeout`, `max_concurrency` | not allowed | optional ([plugin runtime](plugin-runtime.md#timeouts)) | The plugin's `type` must match what the binary implements. Collector plugins only serve the `Runner` service (`Configure`, `Eval`, `Init`), so there's no `Describe` to ask them. Instead the agent dispenses the go-plugin service that `type` names (`runner` for collectors, `effector` for effectors), and a binary that doesn't serve it fails to start. An effector binary then answers `Describe()`. ## Effector actions An effector action is a named, operator-defined use of an effector plugin, under `plugins.

.actions.`: | Field | Meaning | | --- | --- | | name (key) | Unique **within the agent**, across all its plugins. Rules refer to it together with the agent's name | | `description` | Shown in the rule builder | | `effect` | Which of the plugin's effect types the action performs. See [Effect types](#effect-types) | | `targets.include` | Patterns of targets this action may act on: `scheme:pattern`, for example `github-repo:github.com/acme/*`. The scheme must be one the plugin declares | | `targets.exclude` | Optional patterns removed from `include` | | `rule_kinds` | Optional: narrow to `state` or `event`. Defaults to what the plugin supports for that effect | | `on_clear`, `on_stale`, `targets_refresh` | Overrides ([above](#defaults-and-overrides)) | | `publish_targets` | Optional, default `false`. Publish the targets the plugin can list, for the rule builder's dropdown ([below](#published-targets)) | | `config` | Action config, passed to the plugin with every effect for this action | ### Effect types Effect types are **declared by plugins**, not a list owned by CCF. An effect type is a short label (a lowercase slug such as `notify`, `block`, `remediate-apply`, `dispatch`) plus the properties the API actually needs, all in the plugin's manifest: | Declared per effect | Used for | | --- | --- | | `effect` | A label: shown in the rule builder, usable as a filter. The API attaches no meaning to it | | `rule_kinds` | Which rules can use it: `state`, `event` or both. A plugin that can't undo what it does (for example applying a fix) declares `state` only if it wants the next collection to confirm it | | `default_on_clear` | What clearing means for it: `revert`, `resolve` or `none`. An action can override it with `on_clear` | The API validates rules against those registered properties only: a rule kind the action didn't register is rejected, and `on_clear` must be one of `revert`, `resolve`, `none`. It doesn't know or check any particular label. A new kind of effect, such as `dispatch` for handing results to another system, is just a plugin declaring it: no CCF change. The labels in this design (`notify`, `block`, `remediate`) are conventions used by the example plugins, not a closed list. ### Targets: an allowlist `targets` is an **allowlist**, so anything not matched is denied. `include` lists what's allowed, and `exclude` takes patterns back out of it ("every repo in `acme` except `acme/prod-*`"). There's no way to allow something that isn't in `include`. The patterns are enforced twice: the API rejects or skips targets that don't match, and the agent checks every delivery again before it reaches a plugin (`403` otherwise). So a compromised or misconfigured API can't make an agent act outside what its operator wrote. ### Target pattern grammar Both sides must match the same way, or the API accepts a target the agent then refuses. So the grammar is defined once and implemented once, in a public package both import (for example `pkg/effector/targets` in the API module, which the agent already depends on). | Part | Rule | | --- | --- | | Identity | `scheme:value`. The first `:` separates them; the value may contain more `:` | | Scheme | `[a-z][a-z0-9-]*`, matched exactly. Patterns can't use wildcards in the scheme | | Value | Any non-empty string of printable characters. It must also match the scheme's `value-pattern` (an RE2 regular expression, anchored) | | Pattern | `scheme:glob`. The glob is matched against the **whole** value, case-sensitively | | `*` | Any sequence of characters, except `/` | | `**` | Any sequence of characters, including `/` | | `?` | One character, except `/` | | `\` | Escapes the next character (`\*` is a literal `*`) | Examples: | Pattern | Matches | Doesn't match | | --- | --- | --- | | `github-repo:github.com/acme/*` | `github.com/acme/repo-1` | `github.com/acme/team/repo-1`, `github.com/ACME/repo-1` | | `github-repo:github.com/acme/**` | `github.com/acme/team/repo-1` | `github.com/other/repo-1` | | `slack-channel:#platform-*` | `#platform-alerts` | `#platform` | | `slack-user:*` | any value of the `slack-user` scheme | anything in another scheme | An identity is allowed when it matches at least one `include` pattern and no `exclude` pattern. ### Two kinds of config | | Plugin config (`plugins.

.config`) | Action config (`plugins.

.actions..config`) | | --- | --- | --- | | Holds | Credentials, endpoints, accounts | How to perform one action: template, check name, settings baseline | | How many | One per plugin | One per action; many actions share a plugin | | Validated by | The plugin's `Configure`, at startup | The plugin's `ValidateAction`, at startup | | Reported to the API | With the agent's config report (`remote_config.mode` other than `off`), masked as today | Same | How a plugin organizes accounts (one, or several in its config) is up to the plugin. The agent only needs it to accept its config, perform its actions and list its targets. ## Remote configuration Effector settings follow the agent's remote configuration rules: an overlay from the API changes them only within what `remote_config` allows, and the agent classifies each change. Today an operator can set `remote_config.mode: apply_all`, which applies **unsafe** changes too. If widening an effector were only unsafe, an `apply_all` agent would let the API add actions or targets, and "the API can't make an agent act outside what its operator wrote" would be false. So anything that widens what an effector can do is **forbidden**: rejected in every mode, like changes to `api`. Proposed classification: | Change | Class | | --- | --- | | `effector.*` | **forbidden**, like `api` and `remote_config`: it controls a network listener | | Adding a plugin with `type: effector`, or changing any plugin's `type` | **forbidden** | | Adding an action; adding an `include` pattern; removing an `exclude` pattern; changing `effect` | **forbidden** (widens what the agent can do) | | `publish_targets: true` | **forbidden** (sends more data to the API) | | `on_clear`, `on_stale` | **unsafe** | | Removing an action; removing an `include` pattern; adding an `exclude` pattern; `publish_targets: false`; disabling an effector plugin | safe (narrows what the agent can do) | | `description`, `targets_refresh`, `reconcile_interval` | safe | | An action's `config` key | Safe only if it matches the new `overridable_action_config_flags` list; unsafe otherwise | **Action config overrides get their own list.** Existing `overridable_config_flags` patterns are matched with `path.Match`, where `*` also matches dots (`pkg/agentconfig/remoteconfig.go`). If action config keys were matched against that list, an existing `"*"` or `"slack:*"` entry would silently make every action's config overridable. A separate list, `remote_config.overridable_action_config_flags`, with entries `::` matched segment by segment, keeps that opt-in explicit. Existing lists don't change meaning. So whatever `mode` an operator picks, an overlay can only make an effector do less, or tune config keys the operator listed by name. `trusted_sources` and `allow_local_sources` apply to effector plugin sources exactly as to collector plugins. ## State The agent keeps **no effector state of its own**. The API is the only store: - The effects an agent owns, and what each plugin last reported for them (status and `refs`, such as a Slack message ID or check run IDs), live in the API. Every effect document the agent receives carries the last applied status and refs back. - The agent holds the current effects **in memory**. On startup, and on every resync, it fetches them from the API (`GET /api/agent/effects`). - Webhook deduplication (`webhook-id`) is in memory, for the 5-minute signature window. - The agent's existing state directory (instance ID, remote config cache) is unchanged and isn't used for effects. Until its first successful fetch after a start, an agent ignores provider events (`HandleExternal`) for effects it doesn't know yet. The first `Reconcile` afterwards catches up. If a local store is ever needed, it goes under a namespaced key (`effector.store.local.path`, `effector.store.postgres`, …), and the API stays the source of truth. ### Multiple instances **v1 supports one replica per agent with effector plugins.** Deliveries go to one URL, and that agent holds the effects in memory; nothing keeps several pods' memory in sync. Running more than one replica of such an agent isn't supported in v1: a delivery would reach one pod and the others would keep acting on older state. Multiple replicas come with leader election in v2 (below). With one active pod at a time, the protocol doesn't need a change feed, an "as of" digest or per-pod retries, so v1 doesn't build them. ### Later (v2): leader election Parked for after v1, as an **agent-wide** feature rather than an effector one. The agreed shape: - An opt-in, local-only agent setting (forbidden in overlays, like `api`), for example `ha.mode: all-active | leader`, defaulting to `all-active` so existing agents don't change. - In `leader` mode, instances hold a lease in the CCF API, renewed periodically. Writes (evidence, effect status) carry the lease epoch, and the API rejects stale ones (fencing). Only the leader runs collector schedules and effector plugins, and only it reports Ready, so a Service routes webhooks to it. This also stops two pods from sending the same evidence. - Agents with effector plugins would then require `leader` mode. An agent that needs per-host collection (a DaemonSet with `local-ssh`) and effectors becomes two agents. - With one active pod, effectors work as in v1: the leader holds the effects, and a new leader starts with a full fetch. ## Published targets If a plugin can enumerate targets (`supports_listing` on a target scheme), an action with `publish_targets: true` publishes them to the API: 1. On startup and every `targets_refresh`, the agent calls the plugin's `ListTargets` for each scheme of the action. 2. It keeps only identities allowed by the action's `targets` (`include` minus `exclude`), up to a cap (default 5,000 per action), and marks the list `truncated` beyond it. 3. It sends the list with `PUT /api/agent/instances/{instanceId}/targets` ([wire interface](wire-interface.md#published-targets)). Publishing is off by default because it sends provider names (channels, repositories) to the API. A target missing from the list can still be used: the list helps the rule builder; it isn't a check. ## Validation ```mermaid flowchart TD A["1. Agent startup / overlay apply"] --> A1["Config file schema, plugin types"] A1 --> A2["Fetch plugins, verify trusted_sources and digests"] A2 --> A3["Dispense the service plugins.p.type names;
Describe() for effectors"] A3 --> A4["Configure(): plugin config valid"] A4 --> A5["For each action: effect declared by the plugin,
target schemes declared by the plugin,
ValidateAction(config) passes, name unique in the agent"] A5 -->|"failure at startup: exit non-zero
failure on overlay: revision rejected, report sent"| X1["Not applied"] A5 --> B["2. Registration (API)"] B --> B1["Well-formed effects and rule kinds,
valid patterns and value formats"] B1 -->|"422"| X2["Agent logs and retries with backoff"] B1 --> C["3. Rule saved (API)"] C --> C1["Agent and action exist, target allowed,
effect fits the rule kind, author can read the source"] C1 -->|"422 / 403"| X3["Rule admin fixes the rule"] C1 --> D["4. Delivery (agent)"] D --> D1["Signature, timestamp, webhook-id,
action exists, target allowed, generation"] D1 -->|"401/403/409"| X4["Rejected, reported"] D1 --> OK["Plugin Apply / Clear with the action's config"] ``` An overlay that fails step 1 is rejected like any other invalid overlay: the running configuration stays, and the rejection is reported with a reason. A new `ccf-agent validate --config agent.yaml` subcommand would run step 1 without starting anything, for CI. ## Plugin contract Effector plugins use the same mechanism as collector plugins: hashicorp go-plugin over gRPC, with the agent serving helper services to the plugin through the go-plugin broker. Collector plugins get `ApiHelper` today. **Effector plugins get only an `EffectorHelper`**, never the `ApiHelper`. The services are summarized here. The full messages, how status flows back, timeouts, concurrency, retries, and how the agent runs plugins and its listener are in [plugin runtime](plugin-runtime.md). ```proto syntax = "proto3"; package ccf.effector.v1; service Effector { // What the plugin can do. Called once at startup; also tells the agent this is an effector. rpc Describe(DescribeRequest) returns (Manifest); // Plugin config (credentials, connection). Validate and connect. rpc Configure(ConfigureRequest) returns (ConfigureResponse); // Validate one action's config. Called at startup and on overlay apply, for every action. rpc ValidateAction(ValidateActionRequest) returns (ValidateActionResponse); // Make the provider reflect an active (or occurred) effect. The request carries the effect // document (transition, last applied status and refs) and the action's config. // Idempotent per generation. rpc Apply(ApplyRequest) returns (ApplyResponse); // Revert or resolve an inactive effect, following the action's on_clear. Idempotent. rpc Clear(ClearRequest) returns (ClearResponse); // Converge on all of this plugin's effects. Called after a fetch and every reconcile_interval. rpc Reconcile(ReconcileRequest) returns (ReconcileResponse); // An inbound provider webhook routed by the agent (/ext/{plugin}/...). rpc HandleExternal(ExternalRequest) returns (ExternalResponse); // Optional: list identities of a scheme, for published targets. rpc ListTargets(ListTargetsRequest) returns (stream ListedTarget); } // Served by the agent to effector plugins only. Effector plugins never get ApiHelper // (CreateEvidence, UpsertRiskTemplates, UpsertSubjectTemplates). service EffectorHelper { rpc ListEffects(ListEffectsRequest) returns (ListEffectsResponse); // from the agent's memory rpc ReportStatus(ReportStatusRequest) returns (ReportStatusResponse); // status + refs, stored in the API rpc Observe(ObserveRequest) returns (ObserveResponse); rpc GetContext(GetContextRequest) returns (GetContextResponse); // proxies the API context route } message Manifest { string name = 1; string version = 2; repeated Capability capabilities = 3; bytes plugin_config_schema = 4; // JSON Schema, for docs and `validate` repeated string external_routes = 5; // e.g. "github" → /ext/github-checks/github } message Capability { string effect = 1; // plugin-declared label, e.g. notify, block, remediate-apply string default_on_clear = 2; // revert | resolve | none repeated string rule_kinds = 3; // state | event repeated TargetScheme target_schemes = 4; bytes action_config_schema = 5; // JSON Schema, for docs and `validate` bool supports_exceptions = 6; repeated ObservationType observations = 7; } message TargetScheme { string name = 1; // e.g. github-repo, slack-channel string value_pattern = 2; // RE2 regular expression the value must match string description = 3; string example = 4; bool supports_listing = 5; } message ObservationType { string type = 1; // plugin's own label string kind = 2; // exception-request | dismissed | notice } message ListedTarget { string value = 1; string label = 2; } ``` ### No evidence from effectors Effector plugins **can't produce evidence**, by design. Collector plugins observe a system and report evidence; effector plugins act on it. If an effector could report evidence, it could report on the results of its own actions, and the chain from observation to rule to effect would no longer be one-directional. The agent enforces this: an effector plugin runs in the effector context, which serves only `EffectorHelper`. It has no `ApiHelper`, so no `CreateEvidence`, `UpsertRiskTemplates` or `UpsertSubjectTemplates`. A binary declared as `type: effector` that asks for `ApiHelper` gets nothing. Whether an action worked is shown by the next collection. What an effector sees that a person should know about (a bypass, a rejected fix) goes back as an observation. ### Rules for plugin authors - `Apply`, `Clear` and `Reconcile` must be **idempotent**. The agent may call them again for the same generation after a restart or a retry. - Keep provider state (message IDs, check run IDs, PR numbers) in the `refs` of `ReportStatus`. They're stored in the API and come back with the effect; there's no local storage. - Report `links` for people (the message, the pull request, the settings page), and use `waiting` once the result is in a person's hands, so the effect view can show what's pending and since when ([status](wire-interface.md#status)). - Handle every transition `Apply` can receive, including `repeated` (the rule asked to act again: a reminder, a re-assert, a retry) and `finished` (no more repeats; the condition still holds, so this isn't a clear). - Validate a target's existence in the provider at `Apply`, and report `failed` with a clear message. Format checks already happened in the API and the agent. - Never decide policy: report an observation and let the API decide. - Answer `HandleExternal` from `ListEffects` (the agent's memory), not by calling the API. ### Lifecycle | Situation | Agent does | | --- | --- | | Startup | Load config, start plugins, `Describe`, `Configure`, `ValidateAction`, register effector actions, fetch effects, `Reconcile` | | Delivery | Check, update the effect in memory, queue `Apply` or `Clear` | | Plugin crash | Restart it with backoff, replay the current effect for each of its effects | | Resync | Fetch all effects again from the API, replace memory, `Reconcile` per plugin | | No API contact past `stale_after` | Apply each action's `on_stale`: `keep` changes nothing, `fail-open` clears state effects (for example unblocks), `fail-closed` leaves blocks and blocks targets with no known effect | | Overlay applied | Re-register. A rule action turns `degraded` once no fresh instance of the agent registers its action | | Shutdown | Stop accepting webhooks (`503`), let in-flight calls finish | ## Decisions 1. **Agent, not a separate binary.** Effectors are the agent with effector plugins (`plugins.

.type: effector`). Authentication, remote configuration, plugin loading and config reporting come from the agent. 2. **Remote configuration** extends to effector settings, with the classification above. 3. **Action config visibility** comes from the agent's config report (masked), as for plugin config today. 4. **No local store.** The API stores effects and plugin refs; the agent keeps them in memory. 5. **Accounts** are the plugin's business. 6. **Plugin types** are `collector` (default) and `effector`. 7. **No evidence from effectors.** Effector plugins get no `ApiHelper` ([above](#no-evidence-from-effectors)). 8. **One replica in v1.** Multiple replicas come with agent-wide leader election in v2 ([above](#multiple-instances)). v1 builds no change feed or other multi-pod machinery. 9. **Remote config classification** as proposed, with widening changes forbidden in every mode; to be revisited after trying it. 10. **Effect types are plugin-declared.** No fixed list in the API; it validates rules only against each action's registered rule kinds and `on_clear`. 11. **Target patterns** follow one grammar, implemented in one public package ([above](#target-pattern-grammar)). ## Open questions None at the moment.