Add datalog-based invariant verification system

Implement a new datalog verification layer using datafrog that:

- Compiles rulespec to datalog on plan_approve
- Extracts facts from action envelope using selectors
- Executes datalog rules on plan_verify
- Writes evaluation results to datalog_evaluation.txt (shadow mode)

Key components:
- crates/g3-core/src/tools/datalog.rs: Full datalog module with:
  - compile_rulespec(): Validates and compiles rulespec
  - extract_facts(): Extracts facts from envelope YAML
  - execute_rules(): Runs datafrog iteration
  - 23 comprehensive tests

- crates/g3-core/src/tools/plan.rs:
  - execute_plan_approve(): Now compiles rulespec on approval
  - shadow_datalog_verify(): Runs datalog and writes to eval file

Results are written to .g3/sessions/<id>/datalog_evaluation.txt
for inspection, NOT injected into context window (shadow mode).
This commit is contained in:
Dhanji R. Prasanna
2026-02-06 13:50:54 +11:00
parent bcd50190c6
commit abfac197ab
6 changed files with 1199 additions and 4 deletions

7
Cargo.lock generated
View File

@@ -927,6 +927,12 @@ dependencies = [
"syn",
]
[[package]]
name = "datafrog"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"
[[package]]
name = "deranged"
version = "0.5.5"
@@ -1443,6 +1449,7 @@ dependencies = [
"async-trait",
"base64 0.22.1",
"chrono",
"datafrog",
"futures-util",
"g3-computer-control",
"g3-config",