Edge Connector

Edge Connector policies

Write Edge Connector policies with capability sequences, destination rules, and canary thresholds.

Preview. Edge Connector policies are YAML files compiled into binary DFA tables by the policy compiler. The compiled tables are either statically linked into the binary or distributed via OTA.

Policy structure

~/.defenseclaw/policy.yaml
name: my-device-policy
version: 1

skill_actions:
  critical:
    runtime: disable    # BLOCK
  high:
    runtime: disable    # BLOCK
  medium:
    runtime: warn       # ALLOW + log

iot_extensions:
  capability_sequences:
    - sequence: [net_fetch, exec_shell]
      action: block
  destination_allowlist:
    - "1.1.1.1" # illustrative; replace with an approved public IP
  canary:
    baseline_blocks_per_min: 5

Capability sequences

Define dangerous multi-step patterns. When a session completes a configured sequence, the final tool call is blocked.

iot_extensions:
  capability_sequences:
    - sequence: [net_fetch, exec_shell]
      action: block
    - sequence: [net_fetch, actuate]
      action: block
    - sequence: [sensor_read, net_fetch, exec_shell]
      action: block

The compiler turns these into DFA tables, evaluated in constant time per input symbol. Sequences are tracked per session_id.

RuleLimit
Capabilities per sequenceOne to four known capabilities
actionallow, block, warn or escalate
Unknown capabilities, actions, severity names, malformed valuesRejected before any output is written; exit code 65
Unreadable input fileShort error; exit code 1

Destination rules

iot_extensions:
  destination_allowlist:
    - "1.1.1.1" # illustrative public IP; replace with one approved for your service
    - "2606:4700:4700::1111" # illustrative public IPv6, written without brackets

1.1.1.1 and the IPv6 address are examples. Replace them with addresses approved for your service.

How the device matches a destination:

  • Hostname destinations are blocked on every build profile. Network tools need a nonempty destination, so list a public IPv4 or globally scoped IPv6 literal.
  • Write an IPv6 entry without brackets (2606:4700:4700::1111, not [2606:4700:4700::1111]); the compiler refuses a bracketed one. The device takes the host out of each destination, removes any brackets and compares it with the entries as text, ignoring case. So https://[2606:4700:4700::1111]:443/ matches the unbracketed entry.
  • Write the address in the form the tool sends. The parser does not prove the address is routable.
  • Private, loopback and link-local addresses, numeric aliases (octal, hex or decimal forms) and malformed ports are blocked even if listed.
  • A destination that is not on the allowlist is blocked.

What policy cannot change

These are fixed in the C build. The compiler rejects the matching YAML keys, so a policy cannot appear to turn on a control the device would ignore.

Fixed behaviorRejected keys
Rate limits: 60 tool calls, 30 network requests and 10 actuations per minute (Stage 2)iot_extensions.rate_limits
Escalation mode per capability (Stage 7)iot_extensions.escalation_mode
Content patterns for secrets, credentials, PII, exfiltration, injection text and dangerous commandscontent_inspection and custom regex settings
The SSRF guard for private and metadata addressesdestination_denylist, ssrf_protection, hostname entries

By default an undecided call stays blocked when the gateway is unreachable. DCLAW_STRICT_MODE=0 allows speculative execution on builds that support it, also when the MQTT publish fails; keep the default in production.

Compile the policy

python3 edge-connector/tools/policy_compiler.py \
  --input ~/.defenseclaw/policy.yaml \
  --profile standard \
  --version 1 \
  --output-header policy_tables.h \
  --output-binary policy.bin
OutputUse
C header (policy_tables.h)Static linking into the binary.
Binary blob (policy.bin)An unsigned development stub when no signing key is given. Do not publish it to production devices.

For production, push the policy with defenseclaw edge-connector policy push or the Fleet policy-push API, which compiles it and HMAC-signs the update with DCLAW_OTA_HMAC_KEY. The C receiver does not accept the compiler's optional Ed25519 --signing-key output.

Canary deployment

Each device that receives a new policy starts its own ten-minute canary window. The Fleet policy endpoint publishes to the whole tenant/fleet topic; it does not select a subset of devices.

iot_extensions:
  canary:
    baseline_blocks_per_min: 5

The device restores its previous policy if its block count exceeds five times the per-minute baseline for three consecutive minutes in that window. The device decides this; the gateway does not start a rollback.

After a rollback:

  • Signed heartbeats carry a persistent CANARY_ROLLBACK flag until a newer signed policy installs.
  • The reported policy_version stays at the highest accepted version (the anti-rollback watermark), not the version now active.
  • So check the flag and the device's active policy before you read the Fleet version count as policy adoption.