                                                                                                     #js ["transitive-edge" "when" "get-right-connected" "connected"]
                                                                                                     #js ["transitive-edge" "know" "output-transitive-connected" "connected"]])
 
-(.add-facts kn "know" "clause-fields" #js ["clause-id" "constant|variable" "key" "val"] #js [#js ["get-left-edge" "variable" "x" "xx"]
+(.add-facts kn "know" "clause-fields" #js ["clause-id" "constant|variable|aggregate" "key" "val"] #js [#js ["get-left-edge" "variable" "x" "xx"]
                                                                                              #js ["get-left-edge" "variable" "y" "yy"]
                                                                                              #js ["get-right-connected" "variable" "x" "yy"]
                                                                                              #js ["get-right-connected" "variable" "y" "zz"]

              :when (not (#{"=constant" "=variable" "=function" "filter"} name))]
        (let [fields (get @clause-id->fields clause-id)
              var->key (atom {})]
          (doseq [[_ field-type key val] fields
                  :when (not (#{"aggregate-variable" "aggregate-function"} key))]
            (if (= field-type "constant")
              ;; rewrite (foo 1) to (foo x) (constant= x 1)
              (let [new-var (new-id)

                                                                                                    #js ["-function-edge" "when" "-make-str" "=function"]
                                                                                                    #js ["-function-edge" "forget" "-know-str" "str-edge"]])

(.add-facts kn "know" "clause-fields" #js ["clause-id" "constant|variable|aggregate" "key" "val"] #js [#js ["-get-function-edge" "variable" "x" "xx"]
                                                                                             #js ["-get-function-edge" "variable" "y" "yy"]
                                                                                             #js ["-make-str" "variable" "variable" "zz"]
                                                                                             #js ["-make-str" "constant" "js" "\"edge \" + xx + \" \" + yy"]
