mod: Phase 2 — evidence accumulation + proof trees + audit log, 60/60
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m7s

Reports carry an :evidence list, asserted as evidence/3 facts; reviewer-remove
rule (highest precedence) lets human review override classification. Proof tree
built constructively by re-querying each rule body goal against the same DB with
the report id bound, so derivations carry real unification bindings. Append-only
audit log records decision + proof + evidence snapshot per decide, monotonic seq,
never mutates prior entries. +29 audit tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-06 17:37:02 +00:00
parent 8dfc987095
commit 6e825e1283
10 changed files with 400 additions and 31 deletions

View File

@@ -1,8 +1,9 @@
;; lib/mod/api.sx — report registry + public entry points.
;;
;; mod/report files a report (assigning a sequential id) into the in-memory
;; registry; mod/decide resolves an id and runs the policy engine against the
;; current registry and rule set.
;; registry; mod/add-evidence accumulates evidence onto a filed report;
;; mod/decide resolves an id, runs the policy engine against the current registry
;; and rule set, and commits the decision to the append-only audit log.
(define mod/*reports* (list))
(define mod/*counter* 0)
@@ -12,7 +13,10 @@
mod/reset!
(fn
()
(begin (set! mod/*reports* (list)) (set! mod/*counter* 0))))
(begin
(set! mod/*reports* (list))
(set! mod/*counter* 0)
(mod/audit-reset!))))
(define
mod/report
@@ -35,10 +39,34 @@
nil
mod/*reports*)))
(define
mod/add-evidence
(fn
(id kind val)
(let
((r (mod/get-report id)))
(if
(nil? r)
nil
(let
((updated (mod/attach-evidence r (mod/mk-evidence kind val))))
(begin
(set!
mod/*reports*
(map
(fn (x) (if (= (mod/report-id x) id) updated x))
mod/*reports*))
updated))))))
(define
mod/decide
(fn
(id)
(let
((r (mod/get-report id)))
(if (nil? r) nil (mod/decide-report r mod/*reports* mod/*rules*)))))
(if
(nil? r)
nil
(let
((d (mod/decide-report r mod/*reports* mod/*rules*)))
(begin (mod/log-decision! d (mod/report-evidence r)) d))))))