# Wire interface
The protocol between the API and effectors, in both directions. An effector is a CCF agent
running effector plugins, so this is what the **agent** implements; plugins never see it (they
see the [effector interface](effector-interface.md)).
```mermaid
flowchart LR
API["CCF API"] -->|"webhooks: effector.verify,
effect.apply, effect.clear"| EF["Agent (effector plugins)"]
EF -->|"REST: token, registration, heartbeat,
effects list, status, observations, context"| API
```
- **API → agent:** signed webhooks that tell the agent something changed. Each carries a
whole document, so no follow-up call is needed.
- **Agent → API:** REST calls with the agent's JWT, to register, report and pull. They sit
under `/api/agent/`, next to the agent's existing routes (heartbeat, config sync).
All bodies are JSON with kebab-case keys. Every request in both directions carries
`ccf-effector-protocol: 1`.
## Authentication
Effectors are agents, so they use the agent token they already have. The exchange is unchanged:
```http
POST /api/auth/agent/token
content-type: application/x-www-form-urlencoded
client_id=…&client_secret=…
```
The JWT identifies the agent. Effector routes accept agent JWTs only (never a user token or
an anonymous caller, even with public agent endpoints on). The effects routes additionally
require the instance to have registered effector actions. An agent only sees and reports on
effects for its own actions.
## Registration
```mermaid
sequenceDiagram
autonumber
actor Admin
participant API as CCF API
participant EF as Agent
Admin->>API: PUT /api/admin/agents/{id}/effector {base-url}
Note over API: status = pending-verify (no instance yet)
Note over EF: Agent starts, already authenticated
(existing agent token)
EF->>API: PUT /api/agent/instances/{instanceId}/effector
API->>API: base URL matches? upsert the instance, store its actions
API-->>EF: 200 {revision, delivery_keys}
API->>EF: effector.verify {challenge} (to base-url + /v1/webhook)
EF-->>API: 200 {challenge}
API->>API: agent effector status = ready
EF->>API: GET /api/agent/effects (all pages)
loop every heartbeat interval
EF->>API: POST /api/agent/heartbeat (effector block)
API-->>EF: 201 {effector: {resync?, delivery_keys}}
end
```
v1 assumes **one replica** per agent with effector plugins
([multiple instances](effector-interface.md#multiple-instances)).
### The base URL belongs to the agent, and the admin sets it
The address deliveries go to is a property of the **agent**, set by an admin, not by whichever
instance registers first or last. It's a **base URL**; the agent serves fixed paths under it:
| Path | Used for |
| --- | --- |
| `{base-url}/v1/webhook` | Deliveries from the API (`effector.verify`, `effect.apply`, `effect.clear`) |
| `{base-url}/ext/{plugin}/…` | Provider webhooks routed to a plugin |
| `{base-url}/healthz`, `{base-url}/readyz` | Health and readiness ([plugin runtime](plugin-runtime.md#the-listener)) |
- `PUT /api/admin/agents/{id}/effector` with `{"base-url": "https://…"}` sets it (`https`
only, unless the API runs with `CCF_EFFECTOR_ALLOW_INSECURE_WEBHOOKS=true`). The admin can
set it before any agent is deployed. Changing it resets the agent to `pending-verify`.
- An instance registration carries its `public_url` as `base-url`. The two are compared after
normalisation: scheme and host lowercased, default port (`:443`, `:80`) removed, trailing
slash removed, no query or fragment allowed. A different URL, or none set by the admin yet,
gets `409`. The instance's actions are stored anyway (so the admin sees them), but nothing
is delivered until the URL is set and verified.
So a leaked agent key can register a fake instance, but it can't redirect deliveries: only an
admin can change where they go.
### `effector.verify`
Verification is **per agent**, and needs a running agent to answer it. The API sends a
challenge to `{base-url}/v1/webhook` when an instance registers with a matching URL while the
agent is `pending-verify` (the URL was just set or changed, or a new signing key came into
use). Until it's answered, the API retries with backoff after each later registration or
heartbeat. The agent is already authenticated by then: it uses its existing agent token, so
there's no extra login step for effectors.
```json
{ "type": "effector.verify", "agent-id": "5d0c…", "challenge": "q8Xc…" }
```
The agent answers `200 {"challenge": "q8Xc…"}`. Until it does, the agent's effector status is
`pending-verify` and nothing is delivered. Instance health is separate and unchanged: an
instance is fresh or stale by the API's existing `InstanceStaleAfter` setting.
### `PUT /api/agent/instances/{instanceId}/effector`
`instanceId` is the agent's existing instance ID. An instance registers when it starts with at
least one effector plugin enabled, and again after every applied configuration change.
Registration is idempotent: the same body returns the same revision.
Registration **upserts the instance's `AgentInstance` row**. Today that row is only created by
heartbeats that carry a `config_digest`, which an agent with `remote_config.mode: off` never
sends (`internal/service/relational/agentcfg/service.go`). An effector must have an instance
row whatever its remote config mode. At the per-agent instance cap, registration fails with
`409` and a reason, instead of silently not creating the row as heartbeats do today.
```json
{
"version": "1.9.0",
"base-url": "https://agent-platform.acme.internal",
"plugins": [
{ "name": "github-checks", "version": "1.0.0", "digest": "sha256:9f2c…" },
{ "name": "slack", "version": "1.0.0", "digest": "sha256:41ab…" }
],
"actions": [
{
"name": "block-prs",
"description": "Required check that fails while the rule is active",
"plugin": "github-checks",
"effect": "block",
"rule-kinds": ["state"],
"targets": { "include": ["github-repo:github.com/acme/*"], "exclude": [] },
"target-schemes": [
{
"name": "github-repo",
"value-pattern": "^github\\.com/[^/]+/[^/]+$",
"description": "Repository as host/owner/name",
"example": "github.com/acme/repo-1"
}
],
"on-clear": "revert",
"publish-targets": false,
"supports-exceptions": true,
"observations": [{ "type": "change-claims-remediation", "kind": "exception-request" }]
},
{
"name": "notify-platform",
"description": "Short alert to platform channels",
"plugin": "slack",
"effect": "notify",
"rule-kinds": ["state", "event"],
"targets": { "include": ["slack-channel:#platform", "slack-channel:#platform-*"], "exclude": ["slack-channel:#platform-exec"] },
"target-schemes": [
{ "name": "slack-channel", "value-pattern": "^#[a-z0-9_-]+$", "description": "Channel name", "example": "#platform" }
],
"on-clear": "resolve",
"publish-targets": true,
"supports-exceptions": false,
"observations": []
}
]
}
```
`actions` are the effector actions from the agent's config
([effector interface](effector-interface.md#effector-actions)), already validated by their
plugins. Their `config` is never sent here: the API only learns what an action is and where it
may act (the agent's config report, when enabled, carries the masked config separately).
Target patterns follow the [target pattern grammar](effector-interface.md#target-pattern-grammar).
| Response | Meaning |
| --- | --- |
| `200` | `{revision, delivery_keys: [{kid, alg: "Ed25519", public_key, status: current \| next}]}` |
| `400` | Malformed body |
| `409` | `base-url` differs from the agent's, the admin hasn't set one yet, or the agent is at its instance cap |
| `422` | A malformed effect label, an empty or unknown rule kind (only `state`, `event`), an `on-clear` other than `revert`, `resolve`, `none`, a duplicate action name, a malformed target pattern, a target pattern using a scheme not in `target-schemes`, an invalid `value-pattern` |
| `403` | The agent is disabled |
### The agent's actions
The agent's actions are the ones its fresh instance last registered. A rule action is
`degraded` when no fresh instance of the agent registers its action. A delivery that reaches
an agent without the action gets `410`, and the rule action turns `degraded`.
### Heartbeat
The existing `POST /api/agent/heartbeat` gets an `effector` block in its request, and, for the
first time, a response body. Both use the heartbeat's existing conventions (snake_case, the
instance ID as a UUID). The block is only honored on heartbeats authenticated with an agent
JWT; an anonymous heartbeat (public agent endpoints on) never carries effector state.
```json
{
"effector": {
"registration_revision": 3,
"held_digest": "sha256:…"
}
}
```
- `held_digest` is a hash over the sorted (effect ID, generation) pairs the agent holds in
memory, that is, what it **received**, not what it applied. Failed, in-progress or dismissed
effects still match, so the digest settles. The API compares it with its current desired
set for the agent.
- The response, `201` with a body for agents that send an `effector` block, says whether to
resync and carries the signing keys:
`{"effector": {"resync": true, "delivery_keys": [...]}}`. On `resync: true` the agent
fetches every effect again.
Today the heartbeat handler answers `201` with no body (`internal/api/handler/heartbeat.go`),
and the SDK's `Create` discards the response (`sdk/heartbeat.go`). The response body is
additive. The SDK gets a new method that returns it, leaving `Create` unchanged for older
agents.
An admin's "resync" sets the flag for the agent's next heartbeat.
### What the agent holds
`GET /api/agent/effects` returns **effects**, not rules, and not a log of events. Each effect
is the current desired state of one rule action on one target: the agent doesn't need the
rules, only what they currently want done. What caused each effect is inside it:
- `trigger.subjects`: the subjects that currently make it hold (for example the failing
evidence streams), each with the document the rule saw.
- `trigger.event`: for an event rule, the event that fired it.
- `transition` and `generation`: the latest change, not every change.
It isn't a job queue: a state effect that changed three times while an agent was down comes
back once, at its latest generation. Event effects are the closest thing to jobs (one per
occurrence, held until the agent reports a final status). The full history of every effect
(every generation, delivery and status) stays in the API, for people to read.
The set an agent holds, and that `GET /api/agent/effects` returns, is bounded:
| Effect | Held while |
| --- | --- |
| State effect, active | It's active |
| State effect, finished | Until the agent reports the `finished` delivery as applied. Then it's dropped; the API still keeps it until it clears |
| State effect, inactive | Until the agent reports its `cleared` (or `disabled`, `removed`) as applied. Then it's dropped from the set |
| Event effect (`occurred`) | Until the agent reports a final status (`applied`, `failed`, `dismissed`). Then it's dropped |
A target with no effect is **inactive**. Plugins must treat it that way (for example, a
blocking plugin posts a passing check on a target it has no effect for), so the set doesn't
grow with every target that was ever matched. History stays in the API.
## Webhooks (API → effector)
| Event | Sent when | Body |
| --- | --- | --- |
| `effector.verify` | The admin set or changed the agent's URL, or a new signing key came into use | challenge |
| `effect.apply` | A state effect turned active, changed while active, reached its `repeat` interval, ran out of repeats (`finished`), or was redelivered; an event effect occurred | effect document |
| `effect.clear` | A state effect turned inactive, its rule was disabled, or its action or rule was deleted | effect document |
There's no resync webhook: resyncs are asked for in the heartbeat response.
### Headers and signing
[Standard Webhooks](https://www.standardwebhooks.com/) with asymmetric signatures:
```http
POST https://agent-platform.acme.internal/v1/webhook
webhook-id: dlv_01JDX7K9Q2
webhook-timestamp: 1764500000
webhook-signature: v1a,MEUCIQD…
ccf-effector-protocol: 1
content-type: application/json
```
- `v1a` is Ed25519 over `{webhook-id}.{webhook-timestamp}.{body}`.
- **One key pair for the whole API**, not one per agent. The private key is a file named by
`CCF_EFFECTOR_SIGNING_KEY`. Agents only ever receive public keys, in registration and
heartbeat responses (`delivery_keys`), each identified by `kid` (a hash of the public key).
- **Rotation:** the operator configures the next key as `CCF_EFFECTOR_SIGNING_KEY_NEXT`. The
API then publishes it as `next` while still signing with the current one, so every agent
learns it within a heartbeat. When the operator promotes it (it becomes
`CCF_EFFECTOR_SIGNING_KEY`), the API signs with it, re-verifies each agent's URL, and keeps
publishing the old public key as accepted for an overlap period.
- The agent rejects timestamps more than 5 minutes off, and `webhook-id`s it has seen.
### The effect document
```json
{
"type": "effect.apply",
"effect": {
"id": "eff_7f3c",
"generation": 42,
"transition": "activated",
"state": "active",
"active-since": "2026-11-30T09:12:00Z",
"rule": { "id": "rul_19a2", "name": "Repos keep branch protection", "kind": "state" },
"action": {
"rule-action-id": "act_55d1",
"effector-action": "apply-branch-baseline",
"effect": "remediate-apply"
},
"target": {
"identity": "github-repo:github.com/acme/repo-1",
"scheme": "github-repo",
"value": "github.com/acme/repo-1"
},
"trigger": {
"source": "evidence",
"subjects": [
{
"id": "4d1a…",
"title": "Branch protection on main",
"matched-since": "2026-11-30T08:40:00Z",
"entered-at": "2026-11-30T09:12:00Z",
"url": "https://ccf.acme/evidence/4d1a…",
"document": { "status": "not-satisfied", "labels": { "team": "platform" } }
}
],
"changes": { "entered": ["4d1a…"], "left": [] },
"event": null
},
"exceptions": [],
"applied": {
"generation": 41,
"status": "applied",
"links": [{ "rel": "settings", "href": "https://github.com/acme/repo-1/settings/branches", "title": "Branch protection" }],
"refs": { "changed-fields": ["required-reviews"] }
},
"links": { "ui": "https://ccf.acme/rules/rul_19a2/effects/eff_7f3c" }
}
}
```
| Field | Notes |
| --- | --- |
| `transition` | `activated`, `updated`, `repeated` (the rule action's `repeat` elapsed; `repeat-count` says which), `finished` (`max_repeats` reached; no more repeats until the condition changes), `redelivered` (an admin asked to apply it again), `cleared`, `disabled` (the rule was disabled), `removed` (action, rule or agent deleted), `occurred` (event rule) |
| `state` | `active`, `finished`, `inactive`, `occurred` |
| `trigger.subjects` | What caused this effect, for this target, now. For state rules, every subject that has entered it. Each has its `id`, `matched-since` (when it started matching), `entered-at` (when it counted, after `for` and `delay`), and `document`, the subject document the rule's expressions were evaluated against (the source's schema, kebab-case) |
| `trigger.changes` | State rules: the subject IDs that `entered` or `left` with this generation. Lets a plugin act per subject (edit one message, resolve another) |
| `trigger.event` | Event rules only: `{type, occurred-at, document}`, where `document` is the event document the rule's `if` saw |
| `exceptions` | Accepted exceptions: `{kind, ref, expires, risk-id?, poam-id?}` |
| `applied` | What the agent last reported for this effect: generation, status, `links` and `refs`. The API is the only store of plugin state, so this is how a plugin gets its refs (a message ID, a check run ID) back after a restart |
| `target` | `identity` as the rule produced it, split into `scheme` and `value` |
| `action.effector-action` | The effector action to run. The effector looks up its plugin and config locally; neither is in the document |
The document is self-contained so the effector can act without calling back. A plugin that
needs more detail than the document carries calls the context route.
The API **builds the document when it sends it**, not when the generation is created, so
`applied` always carries the latest status, links and refs the agent reported, even for a
generation created before that report arrived.
### Responses and retries
| Effector response | API does |
| --- | --- |
| `2xx` | Delivered. The result comes later through the status route |
| `409` | The effector already has a higher generation for this effect: delivered, nothing to do |
| `410` | The agent doesn't have the effector action: the rule action turns `degraded` |
| `401`, `403` | Signature rejected, or the target doesn't match the action's targets: recorded, admins notified, no retries |
| `429`, `5xx`, timeout (10s) | Retry with exponential backoff and jitter for up to 24h |
- The agent applies at most one generation per effect at a time, and drops a generation
older than one it already holds, so the newest always wins
([plugin runtime](plugin-runtime.md#concurrency-and-ordering)).
- At least once: the same generation may arrive twice. The effector deduplicates by
`webhook-id` and generation.
- When retries run out, the effect's applied status becomes `unknown`, and the heartbeat
digest triggers a resync once the agent is back.
- **Redeliver** (an admin action) doesn't resend the same generation, which the agent would
drop as already applied. It creates a new generation with transition `redelivered` and the
same content, so the plugin applies it again.
## Effector → API
All routes take the agent's JWT. An agent only sees and reports on effects it owns.
| Route | Purpose |
| --- | --- |
| `PUT /api/agent/instances/{instanceId}/effector` | Register ([above](#registration)) |
| `POST /api/agent/heartbeat` | Heartbeat ([above](#heartbeat)) |
| `GET /api/agent/effects?plugin=&state=&cursor=` | Page through owned effects, any state. Same document as webhooks |
| `PUT /api/agent/instances/{instanceId}/targets` | Publish listed targets for actions with `publish-targets` ([below](#published-targets)) |
| `GET /api/agent/effects/{effectId}` | One effect, current generation |
| `PUT /api/agent/effects/{effectId}/status` | Report applied state |
| `POST /api/agent/effects/{effectId}/observations` | Report something for a human or the API to decide |
| `GET /api/agent/effects/{effectId}/context` | Extra detail for the effect's subjects |
### Status
```json
{
"generation": 42,
"status": "waiting",
"message": "Pull request opened; waiting for review and merge",
"links": [
{ "rel": "pull-request", "href": "https://github.com/acme/infra/pull/91", "title": "Fix bucket encryption (acme/infra#91)" },
{ "rel": "repository", "href": "https://github.com/acme/infra", "title": "acme/infra" }
],
"refs": { "pr-number": 91 },
"observed-at": "2026-11-30T09:12:04Z"
}
```
| `status` | Meaning |
| --- | --- |
| `in-progress` | The plugin is still working on it (writing a change, calling the provider) |
| `waiting` | The plugin is done; the result now waits for a person in the provider (a pull request to review and merge, a change to approve, a ticket to pick up). The effect stays active until the trigger stops holding, for example when the next collection sees the merged change applied |
| `applied` | The provider reflects this generation |
| `failed` | Couldn't apply. `message` says why; the agent retries according to its own policy |
| `dismissed` | A human rejected the result in the provider (closed the pull request). Not retried |
A plugin can move an effect from `in-progress` to `waiting` to `applied` (or `dismissed`) within
one generation. What each report does to the stored values:
| Field | On each report |
| --- | --- |
| `status`, `message` | Replaced |
| `refs` | **Merged key by key**: keys in the report overwrite stored ones, keys it doesn't mention are kept, and a key set to `null` is removed. A report without `refs` keeps them all, so a later `in-progress` doesn't wipe a stored message ID |
| `links` | Replaced when the report has `links`; kept when it doesn't |
Refs and links survive across generations too, until the plugin changes them.
**`links`** are for people: where to see what the plugin did. Each has a `rel` (a short kind,
such as `message`, `pull-request`, `repository`, `settings`, `ticket`), an `href` and a
`title`. The effect view shows them as clickable links, without CCF knowing anything about the
plugin. They're kept with the effect and sent back in its `applied` block, like `refs`.
**`refs`** stay for the plugin's own state (IDs it needs later) and aren't shown as links.
`href` must be `https`; other schemes are rejected (`422`).
`409` if `generation` is lower than one already reported. `404` if the effector doesn't own
the effect.
### Published targets
For effector actions with `publish-targets: true`
([effector interface](effector-interface.md#published-targets)). The body replaces what the
API stored for those actions:
```json
{
"listed-at": "2026-11-30T09:00:00Z",
"actions": [
{
"name": "notify-platform",
"truncated": false,
"targets": [
{ "identity": "slack-channel:#platform", "label": "platform (412 members)" },
{ "identity": "slack-channel:#platform-alerts", "label": "platform-alerts (38 members)" }
]
}
]
}
```
`422` if an action isn't registered, doesn't have `publish-targets`, or lists an identity
outside its `targets` patterns. `413` above the size limit.
### Observations
An observation is something the plugin saw that a person should decide on. The API only
understands its **kind**. The **type** is the plugin's own label, shown to people.
| `kind` | Meaning | Possible decisions |
| --- | --- | --- |
| `exception-request` | The plugin asks for an exception for `ref` (an identifier in the provider) | Accept (adds an exception to the effect, with an expiry), reject |
| `dismissed` | A human rejected the plugin's result in the provider | Acknowledge, open a risk |
| `notice` | Something worth recording, nothing to change | Acknowledge, open a risk |
```json
{
"kind": "exception-request",
"type": "change-claims-remediation",
"generation": 42,
"ref": "acme/repo-1#91",
"summary": "Change says it remediates POAM-123",
"data": { "claims": ["poam:2b7e…"] },
"observed-at": "2026-11-30T10:01:00Z"
}
```
Effector actions declare the observation types they may send, with their kind, at
registration. Unknown types get `422`. Decisions are made by people in the API
([user interface](user-interface.md#exceptions-and-decisions)). An accepted
`exception-request` adds `{ref, expires, …}` to the effect's `exceptions`, and a new
generation is delivered. What the plugin does with an exception is up to the plugin.
### Context
`GET /api/agent/effects/{effectId}/context` returns, for the effect's **current
subjects only**: the evidence (including the policy output and the input digest), the
controls linked to it with their statement text, and any linked risks or POA&M items. It's
paginated, with a size limit per subject. An effector can't use it to read anything outside
its own effects.
## Versioning
- `ccf-effector-protocol: 1` on every request in both directions. Additive changes (new
fields, new event types) keep version 1. Effectors must ignore unknown fields and answer
`422` to unknown event types.
- A breaking change gets version 2. The API keeps sending version 1 to effectors that
registered with it.
## Decisions
1. **Webhooks only.** No pull mode for deliveries: the API has to reach the agent's URL.
2. **No document size cap** for now. Effect documents carry every current subject; revisit if
sizes become a problem in practice.
3. **Own signing key.** Deliveries are signed with a dedicated Ed25519 key pair, one for the
whole API, not the API's JWT signing key and not one per agent.
4. **One replica in v1.** No change feed, no "as of a token" digest, no retryable `410`;
multiple instances wait for leader election in v2.
## Open questions
None at the moment.