Liking cljdoc? Tell your friends :D

hive-cppb

Collect → Promote → Pipeline → Boundary: a tiny Clojure macro layer that codifies a stratified architecture for data-enrichment workflows. Pure data flows down; effects live only at the boundary.

License: Apache 2.0.

The four roles

RoleMacroPurityReturns
CollectordefcollectorPure-or-effectful-leafResult
PromoterdefpromoterPureResult
PipelinedefpipelinePure orchestrationResult
BoundarydefboundaryEffectful edgeEffect

Invariants (enforced by convention, not the compiler):

  1. Collectors are independent — none depends on another's output.
  2. Promoters are composable — order may vary; data → enriched data.
  3. Pipeline is pure orchestration; no I/O.
  4. Boundary is thin — one fn, Result → response-or-side effect.
  5. Data flows DOWN; effects live ONLY at the boundary.

Install

;; deps.edn
io.github.hive-agi/hive-cppb {:git/tag "v0.1.0" :git/sha "<sha>"}

Example

(require '[hive-cppb.core :as cppb
           :refer [defcollector defpromoter defpipeline defboundary]]
         '[hive-dsl.result :as r])

(defcollector fetch-numbers [_]   (r/ok [1 2 3 4 5]))
(defcollector fetch-user    [seed] (r/ok {:id (:user-id seed) :name "alice"}))

(defpromoter add-totals [data]
  (r/ok (assoc data :total (reduce + (:fetch-numbers data)))))

(defpipeline build-report [seed]
  :collectors [fetch-numbers fetch-user]
  :promoters  [add-totals])

(defboundary print-report! [result]
  :on-success (println "OK:" value)
  :on-failure (println "ERR:" (:error error)))

(-> (build-report {:user-id 7}) print-report!)
;; OK: {:fetch-numbers [1 2 3 4 5] :fetch-user {:id 7 :name "alice"} :total 15}

Property-based test scaffolding

hive-cppb.test ships law-checks for each role:

(require '[hive-cppb.test :as cppb-test]
         '[clojure.test.check.generators :as gen])

(deftest add-totals-laws
  (cppb-test/promoter-laws #'add-totals
    (gen/hash-map :fetch-numbers (gen/vector gen/small-integer))))

Run the tests

clj -M:test

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close