From 01044e62c0fdd7690987e5d55c5df14fa849bbfe Mon Sep 17 00:00:00 2001 From: joaopluigi Date: Thu, 3 Sep 2026 13:43:52 -0300 Subject: [PATCH 1/2] migrate async.manifold to Engine protocol Co-Authored-By: eca-agent --- src/nodely/api/v0.clj | 6 +-- src/nodely/engine/async/manifold_engine.clj | 44 +++++++++++++++++++++ test/nodely/api_test.clj | 2 +- 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 src/nodely/engine/async/manifold_engine.clj diff --git a/src/nodely/api/v0.clj b/src/nodely/api/v0.clj index 1a813dd..27abb24 100644 --- a/src/nodely/api/v0.clj +++ b/src/nodely/api/v0.clj @@ -3,6 +3,7 @@ (:require [nodely.data] [nodely.engine.applicative :as applicative] + [nodely.engine.async.manifold-engine :as engine.async.manifold-engine] [nodely.engine.async.virtual-futures-engine :as engine.async.virtual-futures-engine] [nodely.engine.core :as engine-core] [nodely.engine.core-async.iterative-scheduling-engine :as engine.core-async.iterative-scheduling-engine] @@ -81,9 +82,8 @@ ::eval-key-channel true} :core-async.iterative-scheduling {::protocol-engine? true ::instance-constructor engine.core-async.iterative-scheduling-engine/->CoreAsyncIterativeSchedulingEngine} - :async.manifold {::ns-name 'nodely.engine.manifold - ::opts-fn (constantly nil) - ::enable-deref manifold-failure} + :async.manifold {::protocol-engine? true + ::instance-constructor engine.async.manifold-engine/->AsyncManifoldEngine} :applicative.promesa {::ns-name 'nodely.engine.applicative ::opts-fn #(assoc % ::applicative/context (var-get (resolve 'nodely.engine.applicative.promesa/context))) diff --git a/src/nodely/engine/async/manifold_engine.clj b/src/nodely/engine/async/manifold_engine.clj new file mode 100644 index 0000000..cbcf7f0 --- /dev/null +++ b/src/nodely/engine/async/manifold_engine.clj @@ -0,0 +1,44 @@ +(ns nodely.engine.async.manifold-engine + (:require + [nodely.engine.protocols :as engine.protocols])) + +(def ^:private impl-ns 'nodely.engine.manifold) + +(def enable-deref + "A delay yielding nil when the manifold implementation can be loaded, or a + failure map describing the missing dependency otherwise." + (delay + (try + (require impl-ns) + nil + (catch Exception e + {:msg "Could not locate manifold on classpath." + ::error :missing-ns + ::requested-namespaces [impl-ns] + :cause e})))) + +(defn- impl + "Lazily loads the implementation namespace and resolves `fn-name` within it." + [fn-name] + (requiring-resolve (symbol (name impl-ns) (name fn-name)))) + +(deftype AsyncManifoldEngine [] + engine.protocols/Engine + (-eval [_engine env k _opts] + ((impl 'eval) env k)) + + (-eval-key [_engine env k _opts] + ((impl 'eval-key) env k)) + + (-eval-key-channel [_engine _env _k _opts] + (throw (UnsupportedOperationException. + "Engine :async.manifold does not support eval-key-channel."))) + + (-eval-key-channel-supported? [_engine] + false) + + (-enable-deref [_engine] + enable-deref) + + (-prepare-opts [_engine _opts] + nil)) diff --git a/test/nodely/api_test.clj b/test/nodely/api_test.clj index fd638bf..c9427ba 100644 --- a/test/nodely/api_test.clj +++ b/test/nodely/api_test.clj @@ -128,7 +128,7 @@ 5 (api/eval-key env :z {::api/engine :async.manifold}))))) (testing-require-delay - nodely.engine.manifold nodely.api.v0/manifold-failure + nodely.engine.manifold nodely.engine.async.manifold-engine/enable-deref "Kaboom! We don't have manifold for pretend" :test-manifold-failure (t/testing "without manifold on the classpath" (t/testing "attempting to use manifold" From 46eac1349336d5b832028c7151aa0de681690e55 Mon Sep 17 00:00:00 2001 From: joaopluigi Date: Thu, 3 Sep 2026 14:43:39 -0300 Subject: [PATCH 2/2] rm unused manifold-failure var --- src/nodely/api/v0.clj | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/nodely/api/v0.clj b/src/nodely/api/v0.clj index 27abb24..560dcfd 100644 --- a/src/nodely/api/v0.clj +++ b/src/nodely/api/v0.clj @@ -58,15 +58,6 @@ nodely.engine.core-async.lazy-scheduling] :cause e})))) -(def manifold-failure - (delay - (try (require 'nodely.engine.manifold) - (catch Exception e - {:msg "Could not locate manifold on classpath." - ::error :missing-ns - ::requested-namespaces '[nodely.engine.manifold] - :cause e})))) - (def promesa-failure (delay (try (require 'nodely.engine.applicative.promesa)