mod: Phase 1 — report schema + policy engine on Prolog, 31/31
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m5s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m5s
Reports → Prolog facts (report/3, classification/2, report_count/2); ordered policy rules compile to policy_action/3 clauses, first match wins via pl-query-one. Decisions carry their proof (matching rule + conditions + evidence). Spam/abuse keyword classification, repeated-report escalation via Prolog join+arithmetic, no-rule→keep default. Registry api + conformance harness. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
44
lib/mod/api.sx
Normal file
44
lib/mod/api.sx
Normal file
@@ -0,0 +1,44 @@
|
||||
;; 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.
|
||||
|
||||
(define mod/*reports* (list))
|
||||
(define mod/*counter* 0)
|
||||
(define mod/*rules* mod/default-rules)
|
||||
|
||||
(define
|
||||
mod/reset!
|
||||
(fn
|
||||
()
|
||||
(begin (set! mod/*reports* (list)) (set! mod/*counter* 0))))
|
||||
|
||||
(define
|
||||
mod/report
|
||||
(fn
|
||||
(by about reason)
|
||||
(begin
|
||||
(set! mod/*counter* (+ mod/*counter* 1))
|
||||
(let
|
||||
((id (str "r" mod/*counter*)))
|
||||
(let
|
||||
((r (mod/mk-report id by about reason)))
|
||||
(begin (append! mod/*reports* r) r))))))
|
||||
|
||||
(define
|
||||
mod/get-report
|
||||
(fn
|
||||
(id)
|
||||
(reduce
|
||||
(fn (acc r) (if (= (mod/report-id r) id) r acc))
|
||||
nil
|
||||
mod/*reports*)))
|
||||
|
||||
(define
|
||||
mod/decide
|
||||
(fn
|
||||
(id)
|
||||
(let
|
||||
((r (mod/get-report id)))
|
||||
(if (nil? r) nil (mod/decide-report r mod/*reports* mod/*rules*)))))
|
||||
Reference in New Issue
Block a user