Substrate
Recovery
Aegis treats the ontology like a database treats its data: every edit is a logged transaction with its undo, checked on commit, and reversible.
Transactions and the log
VersionedOntology applies each action atomically with its undo actions; apply_chain is all or nothing. Every commit records digests of the state before and after, so any state can be rebuilt (forensics.state_at) and rollback checks it restored the exact prior state.
v = VersionedOntology(onto)
v.apply(inject_concept("Steel"))
v.apply_chain([remove_relation("Alloy", "subClassOf", "Metal"),
inject_relation("Alloy", "subClassOf", "Material")])
v.rollback_to(1)
Storage backends
| Backend | Stores | Rollback |
|---|---|---|
MemoryBackend() | Python lists | Truncates the log |
JsonlBackend(dir) | base.json and log.jsonl | Truncates the log |
OntoDBBackend(dir, binary=...) | Transactions on an RDF database, read back with SPARQL | Compensating transactions in the database's write-ahead log |
migrate(src, dst) replays one backend's history into another.
Health checks and constraints
HealthMonitor runs checks on every commit: no_subclass_cycles, domain_range, disjoint, and an OWL reasoner's satisfiability (aegis.reasoning.satisfiable). VersionedOntology.constrain rejects an action before it reaches the log.
Detection
Detector re-scores only the queries a commit can reach, alarms when harm passes a threshold, rolls back to the commit before the first alarm, and keeps a Bloom filter of suspect classes. ScoreMonitor records the workload score per commit.
Decisions and repair
aegis.decide rejects a pending chain past a threshold, repairs committed damage by compensating the fewest commits that explain it while keeping later edits, and rolls back when repair cannot. Detector.accept makes a reviewed, honest state the new baseline.
Agent memory
aegis.memory applies the same attacks and defenses to a shared agent memory store: forged, removed, rewired, or tampered findings; impact per memory; guards on writers and provenance; and repair by attribution, which keeps honest work done after the attack.