Download src/snapkitty/lisp/mutation/journal.cljs from Snapkitty/snapkitty-clojure-lisp-bridge: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/Snapkitty/snapkitty-clojure-lisp-bridge/resolve/main/src/snapkitty/lisp/mutation/journal.cljs
- Command line
-
hf download hf://Snapkitty/snapkitty-clojure-lisp-bridge/src/snapkitty/lisp/mutation/journal.cljs
-
curl -L -o journal.cljs https://huggingface.co/Snapkitty/snapkitty-clojure-lisp-bridge/resolve/main/src/snapkitty/lisp/mutation/journal.cljs
1.27 kB
| ;; PH2.S2 — Mutation Journal | |
| ;; From SKC-LISP-WORLD-COQ-001 <mutation-event> | |
| (ns snapkitty.lisp.mutation.journal | |
| "Typed, validated, journaled mutations") | |
| (defrecord MutationEvent | |
| [mutation-id | |
| generation-before | |
| generation-after | |
| actor | |
| target | |
| operation | |
| old-digest | |
| new-digest | |
| precondition | |
| proof-receipt | |
| timestamp-policy]) | |
| (defonce mutation-counter (atom 0)) | |
| (defn next-mutation-id [] | |
| (swap! mutation-counter inc)) | |
| (defn create-mutation-event | |
| [generation-before generation-after target operation old-digest new-digest] | |
| (->MutationEvent | |
| (next-mutation-id) | |
| generation-before | |
| generation-after | |
| 0 ; actor | |
| target | |
| operation | |
| old-digest | |
| new-digest | |
| "" ; precondition | |
| nil ; proof-receipt | |
| 0)) ; timestamp-policy | |
| (defn mutation-gate-passed? [evt] | |
| (and (< (:generation-before evt) (:generation-after evt)) | |
| (not= (:old-digest evt) (:new-digest evt)) | |
| (not= (:operation evt) ""))) | |
| (defn journal-append [journal evt] | |
| "Append-only mutation log" | |
| (if (mutation-gate-passed? evt) | |
| (conj journal evt) | |
| (throw (ex-info "Mutation gate failed" {:event evt})))) | |