Introduction to Verification‑Gated Workflows
YANG (Yet Another Next Generation) defines configuration and operational state for network devices. A leaf is the smallest scalar node; path mappings are the ways external systems translate their internal models to YANG datastore paths. Adding a leaf, renaming a path mapping, or changing normalization code can silently break three critical contracts:
- Alerting – thresholds or notifications that depend on the leaf.
- Storage schema – time‑series databases or data lakes expecting a specific metric name or tag.
- Downstream automation – scripts, playbooks, or orchestrators that consume the exported data.
A verification‑gated workflow treats each change as a transaction with explicit pre‑conditions, a commit boundary, and a post‑commit verification gate. This provides observable evidence that the change does not violate any contract before it propagates to a larger fleet.
Designing the Verification‑Gated Workflow
Identifying Key Components and Dependencies
Before touching a device, enumerate the system boundary:
| Component | Depends On | Affected By |
|---|---|---|
| YANG module(s) | Base module, any uses statements | Normalization code, alert definitions, storage schema |
| Normalization layer | YANG leaf definition, external payload schema | Alerting, storage, downstream automation |
| Alerting engine | Leaf value or presence | Normalization code, storage schema |
| Storage schema | Expected metric/field names | Normalization code, downstream consumers |
| Downstream consumers | Telemetry export format | Normalization code, alerting engine |
| Version control (Git) | YANG modules, normalization code | CI/CD pipeline |
| CI/CD pipeline | Build, test, deploy artifacts | All above components |
Create a dependency matrix (as shown) to locate where verification gates must be placed—e.g., after a YANG change but before rebuilding the normalization service.
Creating a Test Environment for Verification
A production‑like testbed should replicate:
- YANG datastore – virtual router or containerized device (Cisco XRv, Juniper vMX, or
netopeer2with a YANG‑capable server) loading the candidate module. - Normalization service – exact version of the translation code pointing at the test datastore.
- Telemetry collector – gNMI or NETCONF subscriber mirroring the production pipeline (Prometheus exporter, Kafka consumer).
- Alerting rule set – copy of production alert rules aimed at the test telemetry.
- Storage schema – temporary database with the same schema version as production, ready to accept the new metric/field.
- Downstream automation harness – smoke‑test playbooks or scripts exercising the leaf via the normal consumption path.
Isolate the testbed using Docker/Kubernetes namespaces or a dedicated lab VRF. Tag all resources with a verification‑gated workflow ID (e.g., vgw-2025-09-26-01) for easy cleanup.
Integrating Verification Tools and Scripts
Select tools invokable from the CI pipeline:
- YANG validation –
pyang,yanglint, or vendor SDK for syntactic/semantic checks and schema‑tree generation. - Schema diff –
yangdiffor custom script highlighting added/removed/renamed leaves and changes totypeorunits. - Unit tests for normalization –
pytest(Python) or table‑driven Go tests feeding sample external payloads and asserting resulting YANG nodes. - Contract tests – using
pactor custom scripts to verify:- Leaf value appears in telemetry under the expected metric name.
- Alert rules fire correctly when the leaf crosses a threshold.
- Downstream playbooks can read the leaf and act without error.
- Post‑commit validation – after applying a NETCONF
<edit-config>:<get>or<get-data>to retrieve the leaf and confirm its value.- gNMI
Subscribeto stream the leaf briefly and verify no gaps. - Query the storage backend to confirm the field is present and correctly typed.
- Dry‑run the alerting engine (e.g.,
amtool test alertfor Prometheus) to ensure no false positives/negatives.
Each step returns a clear PASS/FAIL status and emits structured logs (JSON) for CI consumption.
Implementing YANG Leaf Introductions and Renamings
Using YANG Data Modeling for Leaf Introduction
To keep the change backward‑compatible:
- Place the leaf in a new container or list if it does not belong to an existing node.
- Assign a default value only when semantics allow; otherwise, set
mandatory falseandconfig true(orfalsefor operational data). - Choose a type matching the data semantics (e.g.,
uint32for counters,stringfor descriptors,inet:ip-addressfor addresses). Avoidbinaryoranyxmlunless essential. - Add a description and reference stating the intended use (e.g., “Threshold for interface error rate used by the
interface-error-highalert”). - For operational‑only leaves, locate them under
/oper-dataand treat them as read‑only in normalization code.
Renaming Path Mappings with Minimal Disruption
Renaming is a breaking change for hard‑coded consumers. Limit impact by:
- Introduce an alias – keep the old path as a
leafreforchoicepointing to the new leaf, markeddeprecated true. - Version the external model – increment its version and document the mapping change in release notes.
- Define a deprecation timeline – e.g., 90‑day sunset after which the alias is removed; note this in the YANG
descriptionand external docs. - Update normalization code – accept both old and new external field names, map them to the same internal YANG leaf, and log a warning when the old name is used.
Example YANG Module Code for Leaf Introduction
module acme-interface-telemetry {
namespace "http://example.com/acme/interface/telemetry";
prefix ait;
import ietf-inet-types {
prefix inet;
}
import ietf-yang-types {
prefix yang;
}
organization "Acme Corp.";
contact "netdev@example.com";
description
"Telemetry model for interface performance metrics.
This version adds the 'error-rate-threshold' leaf for
alerting purposes.";
revision 2025-09-26 {
description
"Initial addition of error-rate-threshold leaf.";
reference "ACME‑TEL‑2025‑001";
}
container interfaces {
list interface {
key "name";
leaf name {
type string;
}
leaf ifIndex {
type uint32;
}
leaf admin-status {
type enumeration {
enum up { value 1; }
enum down { value 2; }
}
}
leaf oper-status {
type enumeration {
enum up { value 1; }
enum down { value 2; }
enum testing { value 3; }
}
}
leaf in-errors {
type yang:counter32;
description "Number of inbound packets with errors.";
}
leaf out-errors {
type yang:counter32;
description "Number of outbound packets with errors.";
}
/* NEW LEAF */
leaf error-rate-threshold {
type uint32 {
range "1..100";
}
units "percent";
description
"Configured error‑rate threshold (in percent) that
triggers the interface-error-high alert.";
default 5;
}
}
}
}
Notes:
- The leaf is optional (
mandatory falseby default) and has a sensible default, preserving existing configurations. - The description explicitly ties the leaf to an alert, aiding verification.
Example CLI Commands for Renaming Path Mappings
Assuming the external model previously used error_thr and we now prefer error-rate-threshold in YANG, we retain a deprecated leaf:
leaf error-thr {
type uint32 {
range "1..100";
}
units "percent";
description
"DEPRECATED: Use error-rate-threshold instead.
This leaf will be removed in release 2.0.";
status deprecated;
}
NETCONF workflow using ncclient (bash):
# 1. Validate the candidate module against the device's schema
ncclient --host router01 --username admin --password secret \
--validate --candidate < acme-interface-telemetry.yang
# 2. Apply the configuration: add the new leaf while keeping the deprecated one
ncclient --host router01 --username admin --password secret \
--edit-config --candidate <<EOF
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<interfaces xmlns="http://example.com/acme/interface/telemetry">
<interface>
<name>GigabitEthernet0/0/0/0</name>
<!-- Existing leaves omitted for brevity -->
<error-rate-threshold>7</error-rate-threshold>
<!-- Deprecated leaf can still be set; ignored by new code -->
<error-thr>7</error-thr>
</interface>
</interfaces>
</config>
EOF
# 3. Verify the leaf is present and correctly valued
ncclient --host router01 --username admin --password secret \
--get --filter "<interfaces xmlns='http://example.com/acme/interface/telemetry'>
<interface><name>GigabitEthernet0/0/0/0</name>
<error-rate-threshold/>
</interface>
</interfaces>"
These steps illustrate a verification‑gated approach: validate, commit in a controlled transaction, then run automated checks before promoting the change to a broader fleet. By following this workflow, you can introduce new YANG leaves, rename path mappings, or adjust normalization code without jeopardizing alerts, storage contracts, or downstream automation.