Edge Connector

Fleet operations

Run an Edge Connector Fleet - the policy compiler, the MQTT broker, device keys, upgrades, build profiles, environment variables and the Grafana dashboard.

Preview. This page is the operator reference for an Edge Connector Fleet. To set up Fleet and a first device, follow Install.

Policy compiler requirements

The gateway compiles each policy you push with edge-connector/tools/policy_compiler.py. It needs Python 3 and PyYAML on the gateway host. A managed host with Fleet off needs neither.

InstallCompiler
Raw release tarCarried. Provide Python 3 and PyYAML yourself before the first policy push.
Per-user install.sh / install.ps1Runs from the bundled Python environment. It is copied only when Fleet is already on; defenseclaw setup edge-connector --source-dir installs it and turns Fleet on once credential setup succeeds.
Managed Linux RPM or DEB, macOS .pkg, Windows SetupNot carried. With fleet.enabled: true the install stops before it changes anything, unless you supply the compiler (below).

What the compiler produces is in Compile the policy.

MQTT broker setup

The Edge Connector uses MQTT 3.1.1 in both directions:

  • Device to gateway: heartbeats and verdict requests.
  • Gateway to device: signed policy updates and emergency commands.

Any standards-compliant broker works. The examples use Eclipse Mosquitto.

Production MQTT needs TLS with broker certificate verification and per-device topic ACLs, including per-device publish permissions. The two Docker examples below are for an isolated local test on one host only.

Mosquitto 2.x accepts only local connections unless a config file says otherwise. Mount one that listens on 0.0.0.0, and publish the port on loopback only:

# Create a minimal config that accepts remote connections
cat > mosquitto.conf <<'EOF'
listener 1883 0.0.0.0
allow_anonymous true
EOF
chmod 0644 mosquitto.conf

docker run -d --name mosquitto -p 127.0.0.1:1883:1883 \
  -v "$PWD/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro" \
  eclipse-mosquitto:2

Remove the container when the test ends.

Remove the anonymous container first if it runs (docker rm -f mosquitto 2>/dev/null || true). Then:

# Mosquitto's container runs as UID/GID 1883. Make its bind mount readable.
sudo install -d -o 1883 -g 1883 -m 0700 mqtt
docker run --rm -it --user 1883:1883 \
  -v "$PWD/mqtt:/mosquitto/config" --entrypoint mosquitto_passwd \
  eclipse-mosquitto:2 -c /mosquitto/config/passwd dclaw

# Create a config that requires authentication
sudo tee mqtt/mosquitto.conf >/dev/null <<'EOF'
listener 1883 0.0.0.0
allow_anonymous false
password_file /mosquitto/config/passwd
EOF
sudo chown 1883:1883 mqtt/mosquitto.conf
sudo chmod 0600 mqtt/mosquitto.conf mqtt/passwd

docker run -d --name mosquitto -p 127.0.0.1:1883:1883 \
  -v "$PWD/mqtt:/mosquitto/config:ro" \
  eclipse-mosquitto:2

Set the credentials on both sides as environment variables. The Go and C MQTT clients do not read a login from the broker URL.

# Generate one nonzero test HMAC key; copy it securely to the device when it runs elsewhere.
export DCLAW_DEVICE_KEY="$(python3 -c 'import secrets; print(secrets.token_hex(32))')"

# Gateway (Go fleet server)
export DCLAW_DEV_MODE=ON # unmanaged local test only; production rejects zero-key mode
export DCLAW_MQTT_BROKER_URL=tcp://127.0.0.1:1883
export DCLAW_MQTT_USER=dclaw
export DCLAW_MQTT_PASS='<password entered above>'

# Edge devices (C edge connector)
export DCLAW_BROKER_URL=mqtt://127.0.0.1:1883
export DCLAW_MQTT_USER=dclaw
export DCLAW_MQTT_PASS='<password entered above>'

Both sides must use the same broker. Turn Fleet on in ~/.defenseclaw/config.yaml:

fleet:
  enabled: true
  mqtt_broker_url: tcp://127.0.0.1:1883 # local test only

Plaintext MQTT works only with a C development build (-DDCLAW_DEV_MODE=ON); a production build rejects it. For production:

SideSetting
GatewayBroker URL ssl://broker-host:8883, with fleet.mqtt_require_tls: true
DeviceBroker URL mqtts://broker-host:8883, and DCLAW_CA_CERT_PATH
Device, when the broker requires mutual TLSAlso DCLAW_DEVICE_CERT_PATH and DCLAW_DEVICE_KEY_PATH

Check the broker hostname and certificate chain before you deploy. Use per-device broker topic ACLs: the gateway cannot tell from an MQTT PUBLISH packet which client sent it.

Device keys and registration

The gateway rejects a missing or invalid device HMAC key by default.

  • Pre-register every production device through the authenticated Fleet API over HTTPS, or through the trusted same-host TLS proxy, and put the returned key on the device. The remote install does this for you.
  • defenseclaw edge-connector register uses the endpoint setup edge-connector saved. Set that endpoint to your HTTPS gateway URL for production.
  • The default loopback HTTP endpoint works only when Fleet explicitly allows HTTP key delivery (Fleet credential delivery). The default refuses it with key_delivery_requires_tls.
  • MQTT auto-registration, and the zero-key fallback with DCLAW_DEV_MODE=ON, are for unmanaged local development only. Managed deployments never allow the fallback.
  • For more than one device, use the per-device keys that registration issues, not one shared test key.
  • A C device binds its emergency sequence to its tenant and fleet. Moving it to another tenant or fleet needs a trusted flash reset and new provisioning; a new identity with the old emergency state refuses to start.

Fleet commands

Run these on the gateway host. Each takes --tenant-id and --fleet-id (1 by default) where it names a device or fleet.

CommandWhat it does
defenseclaw edge-connector devicesLists the registered devices.
defenseclaw edge-connector device DEVICE_IDShows one device.
defenseclaw edge-connector register DEVICE_IDRegisters a device by hand (--tags adds tags).
defenseclaw edge-connector decommission DEVICE_IDRemoves one device.
defenseclaw edge-connector decommission-batch --ids ID1,ID2Removes several devices.
defenseclaw edge-connector healthShows online and offline device counts.
defenseclaw edge-connector policy push FILECompiles, signs and publishes a policy. Tenant and fleet default to the file's metadata, then 1.
defenseclaw edge-connector policy versionsLists the stored policy versions, newest first.
defenseclaw edge-connector policy emergency COMMANDSends block-all, enter-lockdown, release-lockdown, revoke-sessions or force-sync to the fleet. Use it during an incident.
defenseclaw edge-connector testChecks the Fleet pipeline end to end (--device-id, --broker-url, --timeout).

Upgrade gateway and devices together

Keep the Fleet gateway and every device on the same version. Heartbeat and registration messages carry a boot counter and the last applied emergency sequence, and the gateway rejects the older, shorter signed frames.

  1. Upgrade the Edge Connector on each device together with the Fleet gateway.
  2. Confirm heartbeats resume (defenseclaw edge-connector devices) before you rely on device status or policy distribution.

The gateway replays missed emergency commands in signed order from its durable history, up to 32 per signed registration or heartbeat; later heartbeats request the next page. A gap in that history, or an unavailable store, fails closed. A message published to the broker does not prove the device applied it.

Flash partitions that hold an unsigned policy are kept but refused at boot, in a development build too. Back up the device state and re-sign or reprovision the policy before you start the new connector. Then check the signed flash policy and the authenticated heartbeat.

Build profiles

Set the profile with -DDCLAW_PROFILE=<profile>, or --profile on the remote install. The default is STANDARD. The values come from edge-connector/CMakeLists.txt.

SettingMINIMALSTANDARDEDGE
MQTToffonon
Content scanoffonon
PII redactionoffonon
Bloom filteroffoffon
Speculative executionoffonon
Audit ring size64127127
Verdict cache size064256
Heartbeat interval (s)03010
Audit RAM buffer41632
Canary window (s)0600600
Max sessions41664
DCLAW_ESCALATION_PAYLOAD_MAX (bytes)25610242048
Pending ring size41664

Environment variables

The gateway and device DCLAW_* variables below, and DCLAW_FLEET_API_URL, are also in the registry at internal/envvars/registry.json and on environment variables. The Python adapter variables are on Integrate with an agent.

Gateway (Go Fleet server)

VariableRequiredWhat it does
DCLAW_FLEET_API_TOKENyesAdmin bearer token for the Fleet API. With no token, every request is rejected.
DCLAW_FLEET_TENANT_TOKENSnoTenant-scoped tokens, token:tid,....
DCLAW_MQTT_BROKER_URLif fleet.mqtt_broker_url is unsetBroker address. Use TLS and fleet.mqtt_require_tls: true in production.
DCLAW_MQTT_USER, DCLAW_MQTT_PASSif the broker needs a loginBroker credentials. The client does not read a login from the URL.
DCLAW_TLS_CA_CERTfor private broker CAsCA PEM for the Go MQTT client; otherwise the system trust store.
DCLAW_TLS_CLIENT_CERT, DCLAW_TLS_CLIENT_KEYfor broker mTLSClient certificate and key.
DCLAW_REQUIRE_TLSnoRequire TLS for the Go MQTT client.
DCLAW_TLS_SKIP_VERIFYnever in productionSkips broker certificate verification, in explicit unmanaged development only.
DCLAW_OTA_HMAC_KEYto push policyNonzero 32-byte hex secret that signs policy. Must match the device.
DCLAW_EMERGENCY_KEYfor emergency commandsSeparate nonzero 32-byte hex secret. Must match the device.
DCLAW_DEVICE_KEYif no per-device key storeFleet-wide fallback device HMAC key for a one-device test. Per-device keys override it.
DCLAW_FLEET_AUTO_REGISTERnoLets devices self-register by MQTT heartbeat. Unmanaged development only.
DCLAW_PRODUCTIONnoForces the production MQTT security checks (already the default).
DCLAW_DEV_MODEnoON enables development MQTT behavior on unmanaged hosts only.

Device (C engine)

VariableWhat it does
DCLAW_TENANT_ID, DCLAW_FLEET_ID, DCLAW_DEVICE_IDNumeric identity assigned at registration.
DCLAW_BROKER_URLBroker URL. Production builds require mqtts://broker-host:8883.
DCLAW_OTA_HMAC_KEY, DCLAW_EMERGENCY_KEY, DCLAW_DEVICE_KEYSame secrets as the gateway side.
DCLAW_AUDIT_KEYNonzero 32-byte hex key for the audit HMAC chain. Production builds refuse to start without it.
DCLAW_CA_CERT_PATHBroker CA PEM for TLS server verification.
DCLAW_CRL_PATHOptional revocation list. An unreadable or invalid explicit list stops TLS setup.
DCLAW_DEVICE_CERT_PATH, DCLAW_DEVICE_KEY_PATHClient certificate and key when the broker requires mTLS.
DCLAW_TLS_INSECUREDevelopment only. Production C builds reject it.
DCLAW_FLASH_PATHFlash backing file. Default /var/lib/defenseclaw/flash.bin. A production override must stay under /var/lib/defenseclaw/ or /etc/defenseclaw/.
DCLAW_IPC_SOCKET_PATHIPC socket. Default /run/defenseclaw/defenseclaw.sock.
DCLAW_IPC_ALLOWED_UID, DCLAW_IPC_ALLOWED_GIDLocal user and group allowed to use the socket.
DCLAW_STRICT_MODEOn by default: an undecided call waits for a Fleet verdict and stays blocked when the gateway is unreachable. 0 allows speculative execution for the read and network capabilities on builds that support it (capability mapping).

Installer and CLI

VariableWhat it does
DCLAW_FLEET_API_URLFleet API URL for the remote installer and the defenseclaw edge-connector commands. Use HTTPS for production key delivery.

Compile-time constants

Changing these means rebuilding the C library.

ConstantDefaultWhat it does
DCLAW_PROFILESTANDARDBuild profile.
DCLAW_DEV_MODEOFFDevelopment build: relaxes the audit-key and zero-key checks and allows plaintext MQTT. Keep OFF in production. A runtime variable of the same name controls the Go side.
DCLAW_ALLOW_HMAC_OTAOFFProduction builds need ON to accept HMAC-signed policy updates.
DCLAW_ESCALATION_PAYLOAD_MAXper profileLargest content snippet sent to Fleet.
DCLAW_POLICY_PATHembeddedPolicy tables compiled into the binary through policy_tables.h.

Grafana dashboard

The Fleet dashboard (defenseclaw-fleet) shows device status, heartbeats, block and allow verdicts, Fleet alerts, cache activity and rollback counters. It ships in the defenseclaw-fleet-assets.tar.gz release asset, at bundles/local_observability_stack/grafana/dashboards/defenseclaw-fleet.json; its source is edge-connector/dashboards/fleet-dashboard.json. It stays empty until Prometheus scrapes the authenticated Fleet metrics endpoint.

Before you start

  • Fleet is on (fleet.enabled: true) and the admin DCLAW_FLEET_API_TOKEN is in the environment. Tenant-scoped tokens cannot scrape global Fleet metrics.
  • The user observability stack exists: run defenseclaw setup local-observability up. The recipe uses its default directory, $HOME/.defenseclaw/observability-stack.
  • A container can reach the gateway at host.docker.internal:18970. Docker Desktop on macOS provides that name. The bundled Prometheus has no Fleet scrape target by default, because the gateway API listens only on 127.0.0.1:18970.

On Linux, set gateway.api_bind to the Docker bridge's host IP only if your firewall limits access to the Docker network; this moves the whole gateway REST API. Managed enterprise installs require loopback and cannot make that change: run Prometheus on the host, or put a separately secured metrics-only proxy in front. Keep the token secret and use TLS for any nonlocal access.

Turn on the scrape

Set FLEET_ASSETS to the absolute path of the extracted Fleet archive, then run the recipe. It restarts the stack with the Grafana sign-in mode that setup saved in .grafana-access-mode (in password mode it adds docker-compose.password.yml and the saved admin password). It starts nothing if Grafana would allow anonymous access the saved mode does not allow, or anonymous access that is not read-only (Viewer).

FLEET_ASSETS="/path/to/extracted-assets"
cd "$HOME/.defenseclaw/observability-stack"
test -n "$DCLAW_FLEET_API_TOKEN" || { echo 'Fleet API token is empty' >&2; exit 1; }
install -d -m 0700 "$HOME/.defenseclaw/fleet-secrets"
printf '%s' "$DCLAW_FLEET_API_TOKEN" > "$HOME/.defenseclaw/fleet-secrets/metrics-token"
chgrp "$(id -g)" "$HOME/.defenseclaw/fleet-secrets/metrics-token"
chmod 0640 "$HOME/.defenseclaw/fleet-secrets/metrics-token"
mkdir -p prometheus/scrape.d grafana/dashboards
cp "$FLEET_ASSETS/bundles/local_observability_stack/prometheus/examples/fleet.yml" prometheus/scrape.d/fleet.yml
cp "$FLEET_ASSETS/bundles/local_observability_stack/grafana/dashboards/defenseclaw-fleet.json" grafana/dashboards/defenseclaw-fleet.json
chmod 0755 prometheus/scrape.d
chmod 0644 prometheus/scrape.d/fleet.yml # Prometheus runs as a non-root user
export FLEET_METRICS_TOKEN_FILE="$HOME/.defenseclaw/fleet-secrets/metrics-token"
export FLEET_METRICS_TOKEN_GID="$(id -g)"
compose=(docker compose --project-directory "$PWD" --project-name defenseclaw-observability -f docker-compose.yml)
case "$(cat .grafana-access-mode)" in
  password)
    compose+=(-f docker-compose.password.yml)
    GRAFANA_ADMIN_PASSWORD="$(cat .grafana-admin-password)"
    export GRAFANA_ADMIN_PASSWORD
    anonymous=false ;;
  no-password) anonymous=true ;;
  *) echo 'Grafana sign-in mode unknown: run defenseclaw setup local-observability up first' >&2; exit 1 ;;
esac
compose+=(-f "$FLEET_ASSETS/bundles/local_observability_stack/docker-compose.fleet.yml")
effective="$("${compose[@]}" config)"
grep -E "^ +GF_AUTH_ANONYMOUS_ENABLED: \"?$anonymous\"?\$" >/dev/null <<<"$effective" ||
  { echo 'Grafana sign-in would not match .grafana-access-mode; nothing was started' >&2; exit 1; }
if [ "$anonymous" = true ]; then
  grep -E '^ +GF_AUTH_ANONYMOUS_ORG_ROLE: "?Viewer"?$' >/dev/null <<<"$effective" ||
    { echo 'Anonymous Grafana access would not be read-only (Viewer); nothing was started' >&2; exit 1; }
fi
"${compose[@]}" up -d

The token file stays in the private fleet-secrets directory, outside the bundle, so bundle upgrades cannot copy it. It needs group-read permission because Prometheus runs as a non-root user; the optional Compose file grants only this file's group to that container.

Check it

In Prometheus, open Status → Targets at http://127.0.0.1:9090/targets. defenseclaw-fleet must be UP.

You seeMeaning
401The token is wrong.
connection refusedThe gateway bind or the target address is unreachable.

Turn it off

Remove prometheus/scrape.d/fleet.yml and run defenseclaw setup local-observability up. That command restarts the stack without the Fleet overlay, so run the recipe again after it whenever you want to keep the scrape.

With another Prometheus instance, import the JSON and point its defenseclaw-prometheus data source at that instance. On an existing managed stack, the normal refresh keeps your Grafana and Prometheus configuration; use --refresh-config only after backing up custom files, or copy the Fleet dashboard and scrape settings into the installed bundle by hand.

Next steps