Datalog engine for LLM agents auto-invalidates derived facts on observation change during kernel VR
LLM memory was reimplemented as a Datalog store to maintain valid conclusions under changing observations during vulnerability research. The system retracts derived facts automatically when base observations are withdrawn. This bridges LLM agents and established incremental program analysis techniques.
The author replaced vector retrieval memory with a Datalog engine after observing that standard RAG systems retained invalidated conclusions such as "attacker controls kernel object" after an LLDB trace disproved an upstream points-to fact. Facts are asserted as Datalog tuples; rules encode reachability and exploitability. On retraction of a single base fact, the system recomputes only the affected stratum instead of replaying the full transcript.
Incremental evaluation follows the standard semi-naive fixpoint algorithm used in Soufflé and earlier Datalog-based static analyzers. In one 4-hour session the engine retracted 31 derived facts after two observation corrections, whereas the prior embedding store left 19 stale conclusions in the context window. This matches the incremental maintenance properties documented in program analysis literature for call-graph reachability.
The approach connects LLM agent state to the same relational model used in binary analysis frameworks such as Ghidra's P-code analysis and CodeQL queries. It eliminates the need for the model to re-derive logical consequences from raw history. Operational deployment requires an external Datalog runtime with retraction support and a thin interface that converts natural-language assertions into ground atoms.
Next steps include integration with existing Soufflé or Ascent engines and evaluation on public vulnerability corpora to measure reduction in re-exploration time. A production version would expose rule sets for common exploit primitives such as use-after-free reachability.
Datalog-LLM agent: reaches 80% fact-consistency retention after 8-hour sessions on Linux kernel subsystems within 6 months
Sources (3)
- [1]Primary Source(https://pwning.systems/posts/llm-memory-program-analysis/)
- [2]Soufflé: On Synthesis of Program Analyzers(https://souffle-lang.github.io/pdf/souffle-synthesis.pdf)
- [3]MemGPT: Towards LLMs as Operating Systems(https://arxiv.org/abs/2310.08560)