NuGuard Policy Engine Guide
This guide explains how NuGuard’s policy engine works, what inputs it expects, which checks it performs, and how to use it from the CLI.
What the Policy Engine Does
NuGuard’s policy engine handles four related jobs:
- Parse a cognitive policy from Markdown into a structured model
- Lint the policy for completeness and common mistakes
- Cross-check the policy against an AI-SBOM for structural gaps
- Assess an AI-SBOM against a compliance framework such as OWASP LLM Top 10
Core Concepts
Cognitive Policy
A cognitive policy is a Markdown document that describes how an AI application should behave.
The parser recognizes these sections:
Allowed TopicsRestricted TopicsRestricted ActionsHuman in the Loop/HITL TriggersData ClassificationRate Limits
AI-SBOM
The policy engine uses the AI-SBOM as the evidence source for structural checks and compliance assessment.
The SBOM should be generated with nuguard sbom generate and contain detailed inventory and metadata about the AI system’s components.
Parsing
Policy parsing is rule-based, not LLM-based.
Recognized heading aliases
Examples:
Allowed TopicsandPermitted TopicsRestricted TopicsandForbidden TopicsRestricted ActionsandProhibited ActionsHuman in the Loop,HITL Triggers, andHuman Approval Required
Example policy
# Cognitive Policy
## Allowed Topics
- Customer support
- Order status
## Restricted Topics
- Medical advice
- Legal advice
## Restricted Actions
- Refund without user confirmation
- Account deletion without verification
## HITL Triggers
- Password reset requests
- Financial changes over $500
## Data Classification
- PII: name, email, phone
- Internal: user_id, tenant_id
## Rate Limits
- requests_per_minute: 60
- tokens_per_day: 100000
Linting
Run it with:
nuguard policy validate --file cognitive_policy.md
Current lint rules
POLICY-001: no allowed topics and no restricted topicsPOLICY-002: HITL triggers exist but restricted actions are emptyPOLICY-003: a HITL trigger is too short and likely too vaguePOLICY-004: a rate limit value is invalid (<= 0)POLICY-005: all sections are emptyPOLICY-006: duplicate entries within a section
Exit behavior
0: no issues1: warnings only2: errors present3: CLI or file error
Policy-to-SBOM Cross-Check
Run it with:
nuguard policy check --policy cognitive_policy.md --sbom app.sbom.json
This compares declared policy requirements against the structural evidence in the SBOM.
Current structural checks
CHECK-001: HITL triggers exist but noGUARDRAILnode exists in the SBOMCHECK-002: a restricted action does not match anyTOOLnode in the SBOMCHECK-003: policy declares data classification requirements butDATASTOREnodes lack classification, classified-field, PII, PHI, or PFI metadataCHECK-004: policy declares rate limits butAPI_ENDPOINTnodes do not exposerate_limitedorrate_limit_detailmetadataCHECK-005: HITL triggers exist but there are noAUTHnodes in the SBOM
Why this matters
This step helps catch policy drift, for example:
- the policy says a human approval gate should exist, but the system inventory shows no guardrail component
- the policy restricts an action, but the named tool is not actually present in the SBOM
- the policy talks about sensitive data handling, but the SBOM has no datastore classification evidence
Compliance Assessment
Compliance assessment is a more complex form of cross-checking where the policy engine evaluates how well the SBOM aligns with a set of controls defined by a framework such as OWASP LLM Top 10.
Run it with:
nuguard policy check --sbom app.sbom.json --framework owasp-llm-top10
Supported built-in frameworks currently include:
owasp-llm-top10nist-ai-rmfeu-ai-act
Assessment pipeline
The implemented flow is:
- Build an assessment-ready snapshot from the SBOM
- Load framework controls
- Evaluate each control deterministically from SBOM evidence
- Optionally fall back to an LLM when a control is not assessable from the SBOM alone
- Aggregate the results into a weighted compliance score
LLM fallback
The --llm flag enables LLM fallback for controls that cannot be fully assessed from SBOM evidence alone.
Example:
nuguard policy check \
--sbom app.sbom.json \
--framework owasp-llm-top10 \
--llm
CLI Usage
Validate a policy
nuguard policy validate --file cognitive_policy.md
Cross-check policy and SBOM
nuguard policy check \
--policy cognitive_policy.md \
--sbom app.sbom.json
Run framework assessment
nuguard policy check \
--sbom app.sbom.json \
--framework owasp-llm-top10
Run both together
nuguard policy check \
--policy cognitive_policy.md \
--sbom app.sbom.json \
--framework owasp-llm-top10
Use nuguard.yaml
If sbom and policy are already defined in nuguard.yaml, you can run:
nuguard policy check
Output Behavior
Text mode
--format text prints:
- a policy lint table for
validate - a gap table for policy-to-SBOM cross-checks
- assessment summaries for framework runs
JSON mode
--format json is intended for automation and integrations.
Typical Workflow
Recommended order:
- Start a starter policy:
nuguard init
- Fill in the policy content
- Generate an SBOM:
nuguard sbom generate --source . --output app.sbom.json
- Lint the policy:
nuguard policy validate --file cognitive_policy.md
- Cross-check policy and SBOM:
nuguard policy check --policy cognitive_policy.md --sbom app.sbom.json
- Run a framework assessment if needed:
nuguard policy check --sbom app.sbom.json --framework owasp-llm-top10
Troubleshooting Notes
Common issues:
- the policy file exists but contains only headers, producing an “all sections empty” error
- the SBOM lacks
GUARDRAIL,TOOL,DATASTORE, orAPI_ENDPOINTevidence expected by the policy - the policy uses names that do not match SBOM component names closely enough
- the assessment framework name is misspelled
Related docs: