<commit_before>(ns replikativ.p2p.hooks
  "Allows pull hooks to automatically update publications by pulling/merging
  to more CRDTs synchronously to the update propagation."
  (:require #?(:clj
                [clojure.core.async :as async
                 :refer [>! timeout chan put! go-loop pub sub unsub close! chan]]
               :cljs
                [cljs.core.async :as async :refer [>! timeout chan put! pub sub unsub close!]])

            [replikativ.crdt.materialize :refer [pub->crdt]]
            [replikativ.platform-log :refer [debug info warn error]]
            [replikativ.protocols :refer [PHasIdentities PPullOp -identities -downstream -pull]]
            #?(:clj [full.async :refer [go-for <? go-try]])
            [konserve.protocols :refer [IEDNAsyncKeyValueStore -assoc-in -get-in -update-in]]
            [konserve.store :refer [new-mem-store]])
  #?(:cljs (:require-macros [cljs.core.async.macros :refer [go go-loop alt!]]
                            [full.cljs.async :refer [go-for <? go-try]])))


;; requirement for pull-hooks:
;; - atomic, may not accidentally introduce conflicts/unwanted inconsistencies
;; - only create downstream update, do not change crdt state here!
;; - like an atomic membrane for this middleware, track state internally


(defn hook-dispatch [{:keys [type]}]
  (case type<commit_msg>add missing dependency<commit_after>(ns replikativ.p2p.hooks
  "Allows pull hooks to automatically update publications by pulling/merging
  to more CRDTs synchronously to the update propagation."
  (:require #?(:clj
                [clojure.core.async :as async
                 :refer [>! timeout chan put! go-loop pub sub unsub close! chan go]]
               :cljs
                [cljs.core.async :as async :refer [>! timeout chan put! pub sub unsub close!]])

            [replikativ.crdt.materialize :refer [pub->crdt]]
            [replikativ.platform-log :refer [debug info warn error]]
            [replikativ.protocols :refer [PHasIdentities PPullOp -identities -downstream -pull]]
            #?(:clj [full.async :refer [go-for <? go-try]])
            [konserve.protocols :refer [IEDNAsyncKeyValueStore -assoc-in -get-in -update-in]]
            [konserve.store :refer [new-mem-store]])
  #?(:cljs (:require-macros [cljs.core.async.macros :refer [go go-loop alt!]]
                            [full.cljs.async :refer [go-for <? go-try]])))


;; requirement for pull-hooks:
;; - atomic, may not accidentally introduce conflicts/unwanted inconsistencies
;; - only create downstream update, do not change crdt state here!
;; - like an atomic membrane for this middleware, track state internally


(defn hook-dispatch [{:keys [type]}]
  (case type
{'fraction_non_alphanumeric': 0.12083024462564863, 'fraction_numerical': 0.0007412898443291327, 'mean_word_length': 2.748611111111111, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3491505', 'n_tokens_mistral': 822, 'n_tokens_neox': 823, 'n_words': 248}