Skip to content
LinkState
Go back

Model explanations do not prove generated intent

Introduction to Trust in Automated Systems

Definition of Trust in Automated Systems

Trust in automated systems is the justified belief that a system will behave as intended under specified conditions, without causing unintended harm or violating operational policies. Unlike confidence derived from a fluent narrative (e.g., a language model’s persuasive explanation), trust is grounded in observable, repeatable evidence: artifacts that record state, tests that validate behavior, and execution bounds that limit the blast radius of changes.

Importance of Trust in Automated Systems

Network operators rely on automation to reduce manual toil, accelerate change, and improve consistency. However, each automated action expands the attack surface and the potential for silent failures. Trust enables:

Without trust, automation becomes a source of risk rather than efficiency, leading to change freezes, manual overrides, and erosion of confidence in the automation platform itself.

Limitations of Narrative Confidence

Masking Missing Constraints

A fluent rationale generated by an LLM or a well‑crafted runbook can convincingly explain why a change should succeed while omitting critical constraints such as:

When the narrative hides these constraints, the automation may issue a command that appears syntactically correct but is semantically invalid for the target device, resulting in configuration rejection or, worse, a silent misconfiguration that only surfaces under load.

Stale Inventory and Its Consequences

Automation often relies on an inventory source (CMDB, NetBox, DNS, or dynamic discovery) to determine which devices to touch. If that inventory is stale:

The resulting drift between the automation’s view and the real network creates a false sense of correctness; the system reports success while the actual state diverges.

Impossible Rollback Paths and Their Implications

Narrative confidence may assert that a change is “easily reversible” by invoking a stored previous configuration or by re‑applying a baseline. However, rollback can become impossible when:

If rollback is impossible, the network may remain in a degraded state until manual intervention, increasing mean‑time‑to‑recover (MTTR) and eroding trust in the automation framework.

Artifacts as a Basis for Trust

Types of Artifacts in Automated Systems

Artifact TypeDescriptionTypical Storage
Source‑controlled configurationRendered device configs (Jinja2, Terraform templates) kept in Git.Git repository (e.g., GitHub, GitLab).
Infrastructure state filesTerraform state, Ansible facts, or NetBox export snapshots.Remote backend (S3, Consul, PostgreSQL).
Change recordsImmutable logs of what was attempted, who approved, and the outcome.Audit database, SIEM, or append‑only log (e.g., Elasticsearch).
Policy artifactsOPA policies, Segregation‑of‑Duty (SoD) rules, or RBAC definitions.Policy store (OPA, Kyverno).
Test artifactsTest suites, coverage reports, and validation scripts.CI/CD pipeline artifacts (JUnit XML, SARIF).
Execution proofsSigned command outputs, device‑generated show‑command snapshots before/after.Object store or immutable log.

Role of Artifacts in Ensuring Trust

Artifacts provide verifiable, tamper‑evident evidence that:

  1. Intent – what the operator meant to do (template, policy).
  2. Pre‑condition – the state of the system before change (inventory snapshot, facts).
  3. Execution – the exact commands issued and their raw output.
  4. Post‑condition – the resulting state (post‑change show commands, state diff).

When each of these artifacts is cryptographically signed or stored in an append‑only log, an auditor can reconstruct the entire change lifecycle and confirm that no step deviated from the approved intent.

Examples of Artifacts in Real‑World Scenarios

Tests as a Foundation for Trust

Types of Tests in Automated Systems

Test TypePurposeExample
Unit testsValidate small pieces of logic (e.g., template filters, variable interpolation).Python pytest for a Jinja2 filter that validates ASN format.
Integration testsEnsure components work together (e.g., template → device API).Molecule scenario that applies a rendered config to a virtual vMX via NETCONF and checks BGP session state.
Contract testsVerify that the automation adheres to an external API contract (e.g., NetBox REST).Pact tests between the inventory service and the automation orchestrator.
Property‑based testsAssert invariants across a range of inputs (e.g., “no interface shall have both shutdown and no shutdown”).Hypothesis strategies generating interface configs and asserting mutual exclusion.
Smoke / sanity testsQuick post‑change verification that critical services remain operational.Ansible playbook that runs show ip route summary and ensures route count > 0.
Chaos testsInject faults to validate resilience of the automation itself.Gremlin or LitmusChaos causing a link flap while a config push is in progress; verify that the automation retries or aborts safely.

Role of Tests in Ensuring Trust

Tests convert narrative confidence into empirical evidence. A passing test suite indicates that, under the exercised conditions, the automation behaves as expected. Crucially, tests must be:

When a test fails, the change is blocked before it reaches production, preventing the propagation of erroneous artifacts.

Code Examples for Implementing Tests

Python unit test for a Jinja2 filter that validates an IPv4 address:

# tests/test_ipaddr_filter.py
import ipaddress
import pytest
from jinja2 import Environment

def valid_ipaddr(value):
    try:
        ipaddress.IPv4Address(value)
        return value
    except ipaddress.AddressValueError:
        raise ValueError(f"Not a valid IPv4 address: {value}")

def test_valid_ipaddr():
    env = Environment()
    env.filters["valid_ipaddr"] = valid_ipaddr
    template = env.from_string("{{ ip | valid_ipaddr }}")
    assert template.render(ip="10.0.0.1") == "10.0.0.1"

def test_invalid_ipaddr():
    env = Environment()
    env.filters["valid_ipaddr"] = valid_ipaddr
    template = env.from_string("{{ ip | valid_ipaddr }}")
    with pytest.raises(ValueError):
        template.render(ip="999.999.999.999")

Ansible integration test using Molecule to verify BGP session state:

# molecule/default/converge.yml
- name: Apply BGP config and verify
  hosts: all
  become: true
  tasks:
    - name: Render and push BGP config
      ansible.builtin.template:
        src: bgp.j2
        dest: /etc/frr/frr.conf
      notify: restart frr

    - name: Wait for BGP ESTABLISHED
      ansible.builtin.wait_for:
        host: "{{ ansible_host }}"
        port: 179
        timeout: 30
      register: bgp_check
      until: bgp_check.elapsed > 0

    - name: Confirm BGP summary shows ESTABLISHED
      ansible.builtin.command: vtysh -c "show ip bgp summary"
      register: bgp_summary
      changed_when: false
      failed_when: "'Estab' not in bgp_summary.stdout"

CLI Examples for Running Tests

# Run unit tests with pytest
pytest -q tests/

# Execute Molecule scenario (requires Docker or podman)
molecule test --all

# Run Ansible playbook in check mode to see diff without applying
ansible-playbook -i inventory.yml site.yml --check --diff

# Execute OPA test suite
opa test . -v

Bounded Execution for Trust

Definition of Bounded Execution

Bounded execution is the practice of limiting the scope, duration, and side‑effects of an automated operation so that any failure remains contained within a predefined blast radius. Bounds can be expressed as:

Importance of Bounded Execution in Ensuring Trust

Even with perfect artifacts and tests, automation can encounter unknown edge cases (e.g., a bug in the device OS). Bounded execution ensures that:

Implementing Bounded Execution in Automated Systems

1. Semaphore‑based concurrency limiter (example in Python using asyncio.Semaphore):

import asyncio
from typing import List

SEM_LIMIT = 10  # max concurrent devices

async def configure_device(sem: asyncio.Semaphore, device: str):
    async with sem:
        # Placeholder for actual NETCONF/SSH call
        print(f"Configuring {device}")
        await asyncio.sleep(1)  # simulate work

async def run_batch(devices: List[str]):
    sem = asyncio.Semaphore(SEM_LIMIT)
    await asyncio.gather(*[configure_device(sem, d) for d in devices])

# Usage
asyncio.run(run_batch(["rtr01", "rtr02", "...", "rtrN"]))

2. Time‑boxed execution with a watchdog (bash wrapper):

#!/usr/bin/env bash
set -euo pipefail

TIMEOUT=300   # seconds
MAX_DEVICES=20

# Get list of targets from inventory (example: NetBox API)
TARGETS=$(curl -s http://netbox/api/dcim/devices/?limit=1000 | jq -r '.results[].primary_ip4.address' | cut -d/ -f1)

# Trim to max devices
TARGETS=$(echo "$TARGETS" | head -n $MAX_DEVICES)

# Execute with timeout
timeout "$TIMEOUT" ansible-playbook -i <(echo "$TARGETS") site.yml

if [ $? -eq 124 ]; then
    echo "Execution exceeded $TIMEOUT seconds – aborting"
    exit 1
fi

3. Declarative rollback boundaries using Terraform’s -target and state snapshots:

# Take a snapshot before apply
terraform state pull > pre-apply.tfstate

# Apply only a subset of resources (bounded by tag)
terraform apply -target='aws_security_group.[*]"tag:Environment"="staging"' -auto-approve

# On failure, restore snapshot
terraform state push pre-apply.tfstate

Troubleshooting Common Issues in Bounded Execution

SymptomLikely CauseDiagnostic Steps
Semaphore starvation (tasks wait forever)Deadlock inside the bounded function (e.g., a blocking SSH call that never returns).Add timeouts to the underlying device interaction; enable asyncio debug mode (PYTHONASYNCIODEBUG=1).
Timeout false positivesNetwork latency spikes or device slow‑path processing exceed the watchdog.Measure baseline latency with ping/tcpdump; increase timeout gradually while monitoring success rate.
Partial rollbackSnapshot taken before change omitted some mutable state (e.g., dynamic ARP entries).Extend snapshot to include relevant operational data (show arp, show mac address-table).
Exceeding device limitInventory query returns more devices than the semaphore allows, causing queue buildup.Add pagination or chunking to the inventory source; log the number of devices selected.

Scaling Limitations of Trust in Automated Systems

Horizontal Scaling Limitations

Vertical Scaling Limitations


Share this post on:

Previous Post
Offload intent vs capture reality after NIC upgrades
Next Post
When STP IGP and BGP Recovered in the Wrong Order