Attack search, protection, and recovery for ontology-grounded agents
Aegis finds the ontology edits that hurt an agent most, chooses which triples to lock against them, and undoes the damage when an attack lands.
$ git clone https://github.com/lamng3/aegis.git && cd aegis $ uv sync && uv run python examples/attack_and_recover.py
Attack, then defend
recorded experiment resultsTry it: Drag the sliders: how many edits the attacker gets, and how many triples the defender locks.
Harm runs from 0 to 1 over the ontology's query workload. Top bars: the most harmful chain each search finds. Bottom bars: harm left after the locks, against a two-edit attacker. The numbers come from results/attack_defense/2026-10-18.json; this page computes nothing.
What it does
An agent reads its knowledge graph through an ontology. Aegis treats the ontology like data a database must defend.
What it is
An agent that answers questions over a knowledge graph reads the graph through an ontology. The ontology says which classes a query term covers and which links may be followed, so editing a few ontology triples changes the answers while every fact in the graph stays intact. Aegis studies that threat from both sides.
- Attack. Given a query workload and a budget of k edits, find the chain that lowers answer quality most. Aegis searches the tree of edit chains with greedy, beam, random, and UCT (a bandit at every node).
- Protection. Given room to lock M triples, choose the locks that leave the attacker's best response least harmful.
- Recovery. Every edit is a logged transaction with its undo. Aegis measures what each edit changed, detects the first harmful commit, and rolls back while keeping honest edits.
Pages
Install
git clone https://github.com/lamng3/aegis.git
cd aegis
pip install -e ".[dev]"
python examples/attack_and_recover.py
The code is github.com/lamng3/aegis.