Can't use clojure.core functions in rules?

I was wondering if anyone has seen this before:

  • I have a bunch of rules defined (example below)
  • Rules 1, 3, 4, 6, & 7 all work fine
  • Rules 2, 5, & 8 all fail
  • The failing rules contain ‘fn-expr(s)’
  • I am running on datomic cloud
  • ALL rules work when running the query through the bastion (i.e. locallyi at the repl)
  • I get the following exception message when running through API Gatway (i.e. in my environment):
      :db.error\/invalid-rule-fn
      The following forms do not name predicates or fns:
      (* * -)
      {:cognitect.anomalies/category
       :cognitect.anomalies/incorrect,
       :cognitect.anomalies/message
       "The following forms do not name predicates or fns: (* * -)",
       :symbols (* * -)
       :db\/error :db.error\/invalid-rule-fn}```
    
  • I have clojure.core/* and clojure.core/- in the :allow key in my ion-config
  • I tried using the fully qualified fn name in the rule (No luck either)
  • The attribute_groups example in day of datomic cloud appears to be doing the same thing.
    (https://github.com/cognitect-labs/day-of-datomic-cloud/blob/229b069cb6aff4e274d7d1a9dcddf7fc72dd89ee/tutorial/attribute_groups.clj#L28)

MY RULES BELOW:

(def sort-calcs
  
  '[;; WORKS
    [(rule-1 [?p] ?value)
     [?p :q.p/t :my-val]
     [?p :m.p/p ?value]]

    ;; FAILS
    [(rule-2 [?v ?p] ?value)
     [?v :f/m ?ms]
     [?p :q.p/t :my-val]
     [?p :m.p/rp ?r]
     [?p :m.p/p ?pa]
     [?p :q.p/t ?tl]
     [(* ?r 0.01 ?ms)  ?ra]
     [(* ?tl ?pa) ?tot]
     [(- ?tot ?ra) ?value]]

    ;; WORKS
    [(rule-3 [?p] ?value)
     [?p :q.p/t :my-val-2]
     [?p :m.p/p ?value]]

    ;; WORKS
    [(rule-4 [?p] ?value)
     [?p :q.p/t :my-val-2]
     [?p :m.p/r ?value]]

    ;; FAILS
    [(rule-5 [?v ?p] ?value)
     [?v :f/m ?ms]
     [?p :q.p/t :my-val]
     [?p :m.p/rp ?r]
     [(* ?ms ?r 0.01) ?value]]

    ;; WORKS
    [(rule-6 [?v] ?value)
     [?v :f/sp ?value]]

    ;; WORKS
    [[rule-7 [?v] ?value]
     [?v :v/dis ?value]]

    ;; FAILS
    [(rule-8 [?v ?p] ?value)
     [?v :f/sp ?pr]
     [?p :q.p/t :my-val-2]
     [?p :m.p/ma ?a]
     [(- ?a ?pr) ?value]]])

I could use some guidance on what to do next.

I’ve reproduced this behavior and will be looking into it.

-M

Just checking in to see if there are any workarounds I can employ in the meantime, or if I have to wait for a future release to get around this issue.

Unfortunately there isn’t a workaround, however we have resolved the issue and the fix will be included in the next release.

This issue has been resolved by the latest release of Datomic Cloud: