evaluate_compliance_policy
Evaluate already-retrieved device data against a compliance policy. Returns pass/fail/skipped counts and per-rule results without any additional data fetching.
Instructions
Evaluate already-retrieved observations against a declarative compliance policy.
Pure, bounded, read-only evaluation only -- this never calls
invoke_tool/invoke_read_tool or any backend itself, and never fetches
anything. Fetch device/config/inventory state first (e.g. one or more
invoke_read_tool results), then pass the already-retrieved data here
as observations alongside a declarative policy. The architecture
is inspired by NAPALM's compliance_report (a fixed comparison-
operator dispatch table evaluated over structured state) and by
Nornir-style aggregate run counts, but is implemented independently
in pipeline/compliance.py with this repository's own bounds and
conventions -- no eval/exec, no arbitrary expressions, no dynamic
imports, and no write/destructive tool is ever reachable from here.
Args: observations: bounded (max 100) list of objects, one per device/ entity already retrieved by the caller (e.g. a single invoke_read_tool result, or one element of a list response). Never fetched by this tool. policy: bounded (max 50) list of rule objects, each with "field" (a dotted/indexed path, e.g. "interfaces[0].status" or "firmware.version" -- Mapping key lookup and Sequence integer indexing only, never eval/attribute access), "operator" (one of "eq", "ne", "lt", "le", "gt", "ge", "contains", "in", "regex_fullmatch", "version_gte", "version_range", "exists", "not_exists"), and "expected" (required for every operator except exists/not_exists). Optional per-rule "id" (defaults to "rule_"), "severity" ("critical"/"error"/"warning"/ "info", default "error", informational only -- it does not change pass/fail logic), and "optional" (bool, default False -- a missing field on an optional rule is reported "skipped" instead of "error"). A structurally invalid policy (unknown operator, malformed field path, an "expected" shape that does not match its operator, an unparsable regex/ version value, or exceeding a bound) is rejected before any observation is evaluated. policy_id: free-text label carried through into the report and artifact only. max_result_entries: bounded per-rule result detail cap (default 200, max 500). Aggregate counts always reflect the true total even when the detail list is capped -- see "results_truncated"/"results_total".
Returns "ok", "compliant" (True only when every rule for every observation passed or was explicitly skipped -- never True while any "fail"/"error" result exists), "counts" (pass/fail/error/skipped totals), "observations" (per-observation compliant flag + counts), "results" (bounded per-rule detail), "results_total"/ "results_truncated", and "artifact" (a compliance_report-shaped payload suitable for pipeline.artifact_contracts.write_artifact -- never written to disk by this tool). A structurally invalid policy/ observations input fails closed with "ok": False and a bounded "error" message before any rule evaluation begins.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| policy | Yes | ||
| policy_id | No | ad-hoc | |
| observations | Yes | ||
| max_result_entries | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||