Chapter 3 of 10
Ontology-constrained planning and validation
Semantic control
About 4 minutes · includes examples, an exercise, and references
Chapter at a glance
- •Carry stable entity identifiers and resolution evidence in executable plans.
- •Use ontology semantics for meaning and SHACL or schemas for explicit operational validity.
- •Treat graph absence according to declared completeness and freshness.
An ontology gives an agent a shared vocabulary for goals, entities, relations, and action arguments. It can help resolve that “Atlas” is a Project, that a Project has an owning Team, and that a ChangeRequest targets a Service. It can also support inferred classifications used during planning. Ontology grounding is valuable only when the ontology release, inference rules, and operational constraints are explicit.
Map user language to stable identifiers through an entity-linking step that can return alternatives or abstain. Labels and synonyms help retrieval but do not establish identity. The plan should carry the selected IRI and resolution evidence. If a write targets an ambiguous entity, stop for clarification. A human-readable plan can render labels while the executable form retains identifiers.
Use class and property definitions to validate action arguments. If restartService requires a Service and the selected entity is known only as an Application, the ontology may establish a subclass relation—or it may not. Do not let the model assume colloquial equivalence. Range and domain entailments can add types but are not closed-world input validation. SHACL or JSON Schema verifies that required explicit fields are present and well formed.
Represent action schemas in an ontology only where semantic reuse helps. A class of ProductionWriteAction can inherit risk controls. Properties can connect an action proposal to target, evidence, expected effect, and required approval. However, a policy engine remains responsible for live authorization. OWL inference cannot check a rapidly changing approval, budget, or separation-of-duties rule by itself.
Preconditions may be queried from the knowledge graph, but the result has a release and completeness boundary. No recorded active incident does not prove no incident exists. For a high-risk action, require an authoritative live tool or a graph freshness guarantee. Annotate preconditions as open-world informational, validated closed-world, or externally verified. This prevents absence from becoming permission.
SHACL can validate a proposed plan graph before execution. Shapes require action type, target node kind, evidence count, change window, and approval reference. SPARQL-based constraints can check controlled relations, but custom queries need bounded cost and clear authorization. Validate both the individual action and cross-step invariants such as “no production execution before staging verification.”
Ontology constraints can guide decomposition. If a requested goal concerns a RegulatedService, the agent can add required compliance evidence because the class definition or policy mapping says it is needed. This is a transparent rule, not a model intuition. Record which axiom or policy introduced the step. Avoid excessive inference that adds actions users did not authorize; a derived requirement can block or request approval, not silently broaden external effects.
Ontology version changes can invalidate stored plans. A new disjointness axiom may reveal bad identity; a new shape may require evidence; a deprecated property may change a query. Pin every trajectory to an ontology and shapes release. Before resuming a paused plan under a new release, rerun semantic validation and show material differences.
Reasoning explanations should be evidence objects. If a service is classified as Critical because it supports a regulated workflow, preserve the asserted relations, axiom identifiers, reasoner version, and release. The action proposal cites that derivation. If support is retracted, plans depending on the classification enter needs-review rather than continuing from stale state.
Evaluate entity-link accuracy, semantic type validity, intended and forbidden entailments, SHACL plan conformance, policy separation, ontology-change invalidation, and user comprehension of explanations. The purpose is to make agent decisions more constrained and inspectable—not merely to add a graph lookup before the same unconstrained loop.
Key points
- Carry stable entity identifiers and resolution evidence in executable plans.
- Use ontology semantics for meaning and SHACL or schemas for explicit operational validity.
- Treat graph absence according to declared completeness and freshness.
- Pin plans to ontology releases and invalidate dependent steps after semantic change.
A SHACL gate for production actions
Read the expected behavior in the surrounding walkthrough, then copy and run this reference implementation.
@prefix ex: <https://agent.example/ontology/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
ex:ProductionActionShape a sh:NodeShape ;
sh:targetClass ex:ProductionWriteAction ;
sh:property [
sh:path ex:targets ; sh:minCount 1 ; sh:maxCount 1 ;
sh:class ex:ProductionResource ;
] ;
sh:property [
sh:path ex:hasEvidence ; sh:minCount 2 ; sh:nodeKind sh:IRI ;
] ;
sh:property [
sh:path ex:requiresApproval ; sh:minCount 1 ; sh:class ex:ApprovalGrant ;
] .Worked examples
Toy
Ambiguous target blocked
Two services share the label Checkout.
The resolver returns two Service IRIs and no confident selection. The plan remains in clarification state; a valid action schema cannot compensate for unresolved identity.
- IRI candidates
- Abstention
- No write proposal
System
Derived critical-service control
A service becomes Critical through a dependency on a regulated workflow.
The reasoner emits an explanation tied to ontology and graph releases. Policy adds a required approval gate, and a later edge retraction invalidates the pending action.
- Derivation path
- Policy mapping
- Dependency invalidation
Exercise
Ground and validate an agent plan
Represent a three-step plan as RDF and validate it against ontology meaning and SHACL operations.
- Resolve every target to a stable IRI.
- Label preconditions by completeness and freshness.
- Add a derived risk classification with explanation.
- Change the ontology release and rerun validation.
Success criteria
- No label is treated as identity.
- OWL is not used as a missing-field validator.
- Derived controls identify their axioms and support.
- A semantic change cannot leave a stale plan executable.
Reflect: Which graph inference should inform the plan but never directly authorize the action?
References and further reading
- OWL 2 Web Ontology Language PrimerThe W3C primer for OWL classes, properties, individuals, restrictions, inference, and ontology design.
- Shapes Constraint Language (SHACL)The W3C Recommendation for validating RDF data graphs against reusable node and property shapes.
- SPARQL 1.1 Query LanguageThe W3C Recommendation for graph patterns, filters, aggregation, property paths, subqueries, and RDF datasets.