# Remote subscriptions

**URL:** <https://forum.anoma.net/t/remote-subscriptions/1831>\
**Category:** Protocol Design\
**Tags:** architecture\
**Created:** [July 17, 2025, 5:31pm UTC](https://forum.anoma.net/t/remote-subscriptions/1831 "2025-07-17T17:31:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ray](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@ray](https://forum.anoma.net/u/ray)\
**Post date:** [July 17, 2025, 5:31pm UTC](https://forum.anoma.net/t/remote-subscriptions/1831/1 "2025-07-17T17:31:56Z")

</div>

![image](https://europe1.discourse-cdn.com/flex013/uploads/anoma1/original/2X/3/392c6ae932546dbc6ac84a78f1efd44f05571616.png)

> **[Excalidraw — Collaborative whiteboarding made easy](https://excalidraw.com/#json=RcBQcio7ftYAtla8YHh8N,tQMwmwssERld-xp1zVcXkA)**
>
> Excalidraw is a virtual collaborative whiteboard tool that lets you easily sketch diagrams that have a hand-drawn feel to them.

Here are some considerations on remote subscriptions. Within a trusted scope (i.e., within a particular node) the event broker works for subscriptions by filtering based on subscriber-provided filter functions.

One approach might be to extend this across the network. However, it doesn’t extend across trust domains because a filter function is an Elixir function, and it could just do arbitrary things besides filter, so this is to be avoided.

The better approach is a filter DSL, which I’ve mentioned before. The simplest filter DSL can merely be an Elixir pattern as a string, which is turned into a filter function on the remote side; patterns are powerful and most filtering can just be done in function heads (i.e., most filters look like `def filter(pattern) do true end; def filter(_) do false end`). In theory this could be extended to a more powerful language if it proves necessary. Patterns have no side-effects, they just match or don’t (and bind variables, but this part isn’t relevant here, it can just be an invocation of the predicate `match?/2`).

It’s worth considering the possibility of timeouts on subscriptions as well; some subscriptions may be one-shot (you expect to receive exactly one event, e.g. “the status of this specific transaction”) and not requiring the subscriber to clean up is useful ergonomics.

---

<div class="post-metadata">

**Author:** ![cwgoes](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.anoma.net/cwgoes/32/22_2.png) [@cwgoes](https://forum.anoma.net/u/cwgoes)\
**Post date:** [July 24, 2025, 1:25pm UTC](https://forum.anoma.net/t/remote-subscriptions/1831/2 "2025-07-24T13:25:42Z")

</div>

Minor note: one way to make remote-code-injection less-bad is _gas metering_ (everyone’s favourite topic, I know, but it could come in handy here) – with some reputation measurement between nodes (even ad hoc), incentive-wise I bet we could get away with running arbitrary filter functions as long as they are properly sandboxed and gas-limited. I’m not sure if that’s more or less work than developing a small filter DSL, but I thought it might be worth considering.

Also cc @tg-x as we have some parallel questions in the P2P pub/sub design.

---

<div class="post-metadata">

**Author:** ![ray](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@ray](https://forum.anoma.net/u/ray)\
**Post date:** [July 24, 2025, 3:32pm UTC](https://forum.anoma.net/t/remote-subscriptions/1831/3 "2025-07-24T15:32:44Z")

</div>

Trivial counterexample:

```auto
def filter(_) do
  :init.stop()
  true # why not?
end

```

---

<div class="post-metadata">

**Author:** ![cwgoes](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.anoma.net/cwgoes/32/22_2.png) [@cwgoes](https://forum.anoma.net/u/cwgoes)\
**Post date:** [July 25, 2025, 12:42pm UTC](https://forum.anoma.net/t/remote-subscriptions/1831/4 "2025-07-25T12:42:19Z")

</div>

Why is that a counterexample? If `:init.stop()` is exposed, that seems like improper sandboxing, which I specifically mentioned as a requirement.

---

<div class="post-metadata">

**Author:** ![ray](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@ray](https://forum.anoma.net/u/ray)\
**Post date:** [July 25, 2025, 4:14pm UTC](https://forum.anoma.net/t/remote-subscriptions/1831/5 "2025-07-25T16:14:01Z")

</div>

You can’t will “sandboxing” into existence just by saying it, though. Whatever it means, it has to become some actual implementation, e.g., creating filter functions from a limited filter DSL.
