Skip to content

Commit

Permalink
Merge pull request #12 from sid597/dg-nodes
Browse files Browse the repository at this point in the history
Dg nodes
  • Loading branch information
sid597 committed May 7, 2024
2 parents 568b8d5 + c072521 commit b1feff3
Show file tree
Hide file tree
Showing 25 changed files with 750 additions and 696 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ the correct context.
I only write to get thoughts of my head, and connect with people who find this worth engaging :)

discourse graphs: https://network-goods.notion.site/The-Discourse-Graph-starter-pack-312374c813b24ec6b4d53a054371ee5a

ologs: https://arxiv.org/pdf/1102.1889.pdf

collective intelligence:https://topos.site/work/collective-intelligence/

applied-category-theory:https://arxiv.org/pdf/1803.05316.pdf



---

We have Google earth to explore any part of the world, but we don't have anything like that for knowledge.
Expand Down Expand Up @@ -44,6 +50,9 @@ which I think is the first layer of abstraction over "here are cursors of all th
software are considered to be bad, yes they are by current definition at the current level of abstraction. If the abstraction
layer is higher conflicts are good for progress.

My very strong intuition as of april 14 is that category-theory is THE missing piece I have been looking since the starting
of this project as a mere thought. I think so because would provide me with the tool that lets me think about the structure and coherence.


---

Expand Down
90 changes: 37 additions & 53 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,59 +1,43 @@
{:paths ["src" "resources"]
{:paths ["src" "resources"]
:mvn/repos {"nexus-releases" {:url "https://nexus.redplanetlabs.com/repository/maven-public-releases"}}
:deps {com.hyperfiddle/electric {:mvn/version "v2-alpha-536-g0c582f78"}
org.clojure/data.xml {:mvn/version "0.2.0-alpha8"}
com.hyperfiddle/rcf {:mvn/version "20220926-202227"}
info.sunng/ring-jetty9-adapter
{:mvn/version "0.14.3" ; (Jetty 9) is Java 8 compatible;
:exclusions [org.slf4j/slf4j-api info.sunng/ring-jetty9-adapter-http3]} ; no need
:deps {com.hyperfiddle/electric {:git/url "https://github.com/hyperfiddle/electric" :git/sha "b32ac98df7d7ec87f225d47354671be172ffa87e"}
com.hyperfiddle/rcf {:mvn/version "20220926-202227"}
ring/ring {:mvn/version "1.11.0"} ; comes with Jetty

;; Electric IC version requires 1.12 but rama is fixed on 1.11.1 so I have included the newer changes
;; by importing data.xml above according to this comment
;; https://clojurians.slack.com/archives/C7Q9GSHFV/p1704475238085959?thread_ts=1704210542.998019&cid=C7Q9GSHFV

;org.clojure/clojure {:mvn/version "1.12.0-alpha4"}
org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/clojurescript {:mvn/version "1.11.60"}
org.clojure/tools.logging {:mvn/version "1.2.4"}
ch.qos.logback/logback-classic {:mvn/version "1.2.11"}
datascript/datascript {:mvn/version "1.5.2"}
com.rpl/rama {:mvn/version "0.11.9"}
com.rpl/rama-helpers {:mvn/version "0.9.3"}
com.rpl/specter {:mvn/version "1.1.4"}
io.github.nextjournal/clojure-mode {:git/tag "v0.3.0" :git/sha "694abc7"}
ring-basic-authentication/ring-basic-authentication {:mvn/version "1.1.1"}}
:aliases {:dev
{:extra-deps
{binaryage/devtools {:mvn/version "1.0.6"}
net.clojars.wkok/openai-clojure {:mvn/version "0.14.0"}
;; Electric IC version requires 1.12 but rama is fixed on 1.11.1 so I have included the newer changes
;; by importing data.xml above according to this comment
;; https://clojurians.slack.com/archives/C7Q9GSHFV/p1704475238085959?thread_ts=1704210542.998019&cid=C7Q9GSHFV
com.google.guava/guava {:mvn/version "33.1.0-jre"}
org.clojure/data.xml {:mvn/version "0.2.0-alpha8"}
org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/clojurescript {:mvn/version "1.11.60"}
org.clojure/tools.logging {:mvn/version "1.2.4"}
ch.qos.logback/logback-classic {:mvn/version "1.2.11"}
datascript/datascript {:mvn/version "1.5.2"}
com.rpl/rama {:mvn/version "0.12.1"}
com.rpl/rama-helpers {:mvn/version "0.9.3"}
com.rpl/specter {:mvn/version "1.1.4"}
net.clojars.wkok/openai-clojure {:mvn/version "0.14.0"}
io.github.nextjournal/clojure-mode {:git/tag "v0.3.0" :git/sha "694abc7"}
reagent/reagent {:mvn/version "1.2.0"}
com.rpl/rama {:mvn/version "0.10.0"}
com.rpl/rama-helpers {:mvn/version "0.9.1"}
thheller/shadow-cljs {:mvn/version "2.25.2"}}
:jvm-opts
["-Xss2m" ; https://github.com/hyperfiddle/photon/issues/11
"-XX:-OmitStackTraceInFastThrow"] ;; RCF
org.apache.logging.log4j/log4j-slf4j2-impl {:mvn/version "2.23.1"}}
:aliases {:dev {:extra-paths ["src-dev"]
:extra-deps {io.github.clojure/tools.build {:mvn/version "0.9.6"
:exclusions [com.google.guava/guava ; Guava version conflict between tools.build and clojurescript.
org.slf4j/slf4j-nop]} ; clashes with app logger}
thheller/shadow-cljs {:mvn/version "2.25.2"}}}

:exec-fn user/main
:exec-args {}}
:nrepl {:extra-deps
{cider/cider-nrepl {:mvn/version "0.29.0"}}
:main-opts
["-m" "nrepl.cmdline"
"--port" "9001"]}

;; nrepl
:nrepl
{:extra-deps
{cider/cider-nrepl {:mvn/version "0.29.0"}}
:main-opts
["-m" "nrepl.cmdline"
"--port" "9001"]}
:prod {:extra-paths ["src-prod"]}

:build
{:extra-paths ["src-build"]
:ns-default build
:extra-deps {io.github.clojure/tools.build {:mvn/version "0.9.5" :exclusions [com.google.guava/guava]}
io.github.seancorfield/build-clj {:git/tag "v0.8.0" :git/sha "9bd8b8a"}
com.rpl/rama {:mvn/version "0.10.0"}
com.rpl/rama-helpers {:mvn/version "0.9.1"}
net.clojars.wkok/openai-clojure {:mvn/version "0.14.0"}
io.github.nextjournal/clojure-mode {:git/sha "694abc7"}
thheller/shadow-cljs {:mvn/version "2.25.2"}}
:jvm-opts ["-Xss2m"]}}}
; use `clj -X:build build-client`, NOT -T! build/app classpath contamination cannot be prevented
:build {:extra-paths ["src-build"]
:ns-default build
:extra-deps {io.github.clojure/tools.build {:mvn/version "0.9.6"
:exclusions [com.google.guava/guava ; Guava version conflict between tools.build and clojurescript.
org.slf4j/slf4j-nop]} ; clashes with app logger}
thheller/shadow-cljs {:mvn/version "2.25.2"}}}}}
3 changes: 1 addition & 2 deletions resources/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<title>Electric Starter App</title>
<title>Softland</title>
</head>
<body style="margin: 0px; background: beige; color: white;">
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
34 changes: 14 additions & 20 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
{:deps {:aliases [:dev]}
:nrepl {:port 9002}
{:nrepl {:port 9002}
:builds
{:dev
{:target :browser
:devtools {:watch-dir "resources/public" ; live reload CSS
:hud #{:errors :progress}
:ignore-warnings true} ; warnings don't prevent hot-reload
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:main {:entries [user]
:init-fn user/start!}}
:build-hooks [(hyperfiddle.electric.shadow-cljs.hooks/reload-clj)
(shadow.cljs.build-report/hook {:output-to "target/build_report.html"})
(user/rcf-shadow-hook)]}
:prod
{:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:module-hash-names true
:modules {:main {:entries [user] :init-fn user/start!}}}}}
{:dev {:target :browser
:devtools {:watch-dir "resources/public"
:loader-mode :default}
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:main {:entries [dev]
:init-fn dev/start!}}
:build-hooks [(hyperfiddle.electric.shadow-cljs.hooks/reload-clj)]}
:prod {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:module-hash-names true
:modules {:main {:entries [prod] :init-fn prod/start!}}}}}
115 changes: 59 additions & 56 deletions src-build/build.clj
Original file line number Diff line number Diff line change
@@ -1,62 +1,65 @@
(ns build
"build electric.jar library artifact and demos"
(:require [clojure.tools.build.api :as b]
[org.corfield.build :as bb]
[shadow.cljs.devtools.api :as shadow-api] ; so as not to shell out to NPM for shadow
[shadow.cljs.devtools.server :as shadow-server]))
(:require
[clojure.tools.build.api :as b]
[clojure.tools.logging :as log]
[shadow.cljs.devtools.api :as shadow-api]
[shadow.cljs.devtools.server :as shadow-server]))

(def electric-user-version (b/git-process {:git-args "describe --tags --long --always --dirty"}))

(def lib 'com.hyperfiddle/electric)
(def version (b/git-process {:git-args "describe --tags --long --always --dirty"}))
(def basis (b/create-basis {:project "deps.edn"}))
(defn build-client ; invoke with `clj -X ...`
"build Electric app client, invoke with -X
e.g. `clojure -X:build:prod build-client :debug false :verbose false :optimize true`
Note: Electric shadow compilation requires application classpath to be available, so do not use `clj -T`"
[argmap]
(let [{:keys [optimize debug verbose]
:or {optimize true, debug false, verbose false}
:as config}
(assoc argmap :hyperfiddle.electric/user-version electric-user-version)]
(b/delete {:path "resources/public/js"})
(b/delete {:path "resources/electric-manifest.edn"})

(defn clean [opts]
(bb/clean opts))
; bake user-version into artifact, cljs and clj
(b/write-file {:path "resources/electric-manifest.edn" :content config})

; "java.lang.NoClassDefFoundError: com/google/common/collect/Streams" is fixed by
; adding com.google.guava/guava {:mvn/version "31.1-jre"} to deps,
; see https://hf-inc.slack.com/archives/C04TBSDFAM6/p1692636958361199
(shadow-server/start!)
(as->
(shadow-api/release :prod
{:debug debug,
:verbose verbose,
:config-merge
[{:compiler-options {:optimizations (if optimize :advanced :simple)}
:closure-defines {'hyperfiddle.electric-client/ELECTRIC_USER_VERSION electric-user-version}}]})
shadow-status (assert (= shadow-status :done) "shadow-api/release error")) ; fail build on error
(shadow-server/stop!)
(log/info "Client build successful. Version:" electric-user-version)))

(def class-dir "target/classes")
(defn default-jar-name [{:keys [version] :or {version version}}]
(format "target/%s-%s-standalone.jar" (name lib) version))

(defn clean-cljs [_]
(b/delete {:path "resources/public/js"}))

(defn build-client
"Prod optimized ClojureScript client build. (Note: in dev, the client is built
on startup)"
[{:keys [optimize debug verbose version]
:or {optimize true, debug false, verbose false, version version}}]
(println "Building client. Version:" version)
(shadow-server/start!)
(shadow-api/release :prod {:debug debug,
:verbose verbose,
:config-merge [{:compiler-options {:optimizations (if optimize :advanced :simple)}
:closure-defines {'hyperfiddle.electric-client/ELECTRIC_USER_VERSION version}}]})
(shadow-server/stop!))

(defn uberjar [{:keys [jar-name version optimize debug verbose]
:or {version version, optimize true, debug false, verbose false}}]
(println "Cleaning up before build")
(clean nil)

(println "Cleaning cljs compiler output")
(clean-cljs nil)

(build-client {:optimize optimize, :debug debug, :verbose verbose, :version version})

(println "Bundling sources")
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})

(println "Compiling server. Version:" version)
(b/compile-clj {:basis basis
:src-dirs ["src"]
:ns-compile '[prod]
:class-dir class-dir})

(println "Building uberjar")
(b/uber {:class-dir class-dir
:uber-file (str (or jar-name (default-jar-name {:version version})))
:basis basis
:main 'prod}))

(defn noop [_]) ; run to preload mvn deps

(defn uberjar
[{:keys [optimize debug verbose ::jar-name, ::skip-client]
:or {optimize true, debug false, verbose false, skip-client false}
:as args}]
; careful, shell quote escaping combines poorly with clj -X arg parsing, strings read as symbols
(log/info `uberjar (pr-str args))
(b/delete {:path "target"})

(when-not skip-client
(build-client {:optimize optimize, :debug debug, :verbose verbose}))

(b/copy-dir {:target-dir class-dir :src-dirs ["src" "src-prod" "resources"]})
(let [jar-name (or (some-> jar-name str) ; override for Dockerfile builds to avoid needing to reconstruct the name
(format "target/electricfiddle-%s.jar" electric-user-version))
aliases [:prod]]
(log/info `uberjar "included aliases:" aliases)
(b/uber {:class-dir class-dir
:uber-file jar-name
:basis (b/create-basis {:project "deps.edn" :aliases aliases})})
(log/info jar-name)))

;; clj -X:build:prod build-client
;; clj -X:build:prod uberjar :build/jar-name "app.jar"
;; java -cp app.jar clojure.main -m prod
49 changes: 49 additions & 0 deletions src-dev/dev.cljc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
(ns dev
(:require
app.electric-flow
[hyperfiddle.electric :as e]
#?(:clj [app.server-jetty :as jetty])
#?(:clj [shadow.cljs.devtools.api :as shadow])
#?(:clj [shadow.cljs.devtools.server :as shadow-server])
#?(:clj [clojure.tools.logging :as log])))

(comment (-main)) ; repl entrypoint

#?(:clj ;; Server Entrypoint
(do
(def config
{:host "0.0.0.0"
:port 8080
:resources-path "public/"
:manifest-path ; contains Electric compiled program's version so client and server stays in sync
"public/js/manifest.edn"})

(defn -main [& args]
(log/info "Starting Electric compiler and server...")

(shadow-server/start!)
(shadow/watch :dev)
(comment (shadow-server/stop!))

(def server (jetty/start-server!
(fn [ring-request]
(e/boot-server {} app.electric-flow/main ring-request))
config))

(comment (.stop server)))))


#?(:cljs ;; Client Entrypoint
(do
(def electric-entrypoint (e/boot-client {} app.electric-flow/main nil))

(defonce reactor nil)

(defn ^:dev/after-load ^:export start! []
(set! reactor (electric-entrypoint
#(js/console.log "Reactor success:" %)
#(js/console.error "Reactor failure:" %))))

(defn ^:dev/before-load stop! []
(when reactor (reactor)) ; stop the reactor
(set! reactor nil))))
16 changes: 16 additions & 0 deletions src-dev/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Options: http://logback.qos.ch/manual/layouts.html -->
<configuration scan="true" scanPeriod="5 seconds">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%highlight(%-5level) %logger: %msg%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="STDOUT" />
</root>

<!-- org.eclipse.jetty, datomic -->
<logger name="electric-starter-app" level="DEBUG" additivity="false"><appender-ref ref="STDOUT" /></logger>
<logger name="org.eclipse.jetty.server" level="WARN" additivity="false"><appender-ref ref="STDOUT" /></logger>
</configuration>
1 change: 1 addition & 0 deletions src-dev/user.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(ns user (:require [dev]))
12 changes: 12 additions & 0 deletions src-prod/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- Options: http://logback.qos.ch/manual/layouts.html -->
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%highlight(%-5level) %logger: %msg%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Loading

0 comments on commit b1feff3

Please sign in to comment.