Thoughts on Actor Model versus Fediverse

Hrefna as always posted some intriguing thoughts and mentioned actor behavior on the Fediverse, among which:

On FediDevs chat @trwnh mused further on this:

i’ve thought about this sorta as well – we need a way to know what an actor will do mechanistically. imagine a signal “this actor sends and receives Create” or “this actor wraps everything in Announce” which can be used to denote mastodon profile or lemmy profile for example

because an actor’s behavior is undefined, we should have some way to define it

i would imagine a FEP defining a conformance profile would be able to also define a type and then multitype their actor? there may be a better way but that’s what comes to mind. imagine a lemmy actor has type [Group, FEP-1b12] or some such pattern indicating that their actor behaves according to FEP-1b12

the challenge is then to figure out what each of those mechanisms can be collapsed onto

So I thought I’d add some musings and brainstorming of my own, as Actor Model interests me a lot, but I never fully saw how to neatly map that to the Fediverse…

If I purely think of an actor model, like e.g. Akka, then you have this hierarchy of actors with Actor System at the top of the hierarchy. Any actor can create child actors at will and then gain control over their lifecycle with a strategy pattern (e.g. ‘restart upon failure’). Each actor is wholly independent. It processes msgs from their inbox queue, and that processing changes its internal state that’s not accessible to outsiders. Each actor carries out specialized tasks, they are special-purpose, and state changes may alter their behavior. They may create more child actors as they see fit to delegate work. And may send msgs/events that may or may not trigger additional behavior elsewhere.

If you try to map that onto the Fediverse, how would it look like? Suppose that Actor System represents the User. User spins up an arbitrary set of Fediverse Actors representing what they are interested on doing on the Fediverse. That may be a Microblogging actor and a Calendaring actor and a Podcasting actor. Each of those will manage their own hierarchy of specific child actors for that particular domain or app. E.g. the Microblogging actor may have a set of N child actors that represent the ongoing discussion threads I am engaged with. The Calendaring actor manages all the upcoming Events on my calendar as separate actors.

What does that look like from the perspective of the federated network? If I am a different User (i.e. an Actor System, my root actor) I have no need to know the hierarchy of actors of some other User (or Organization, or Application, or Bot … all actor systems too). All I need to know, and all I perceive are many different types of actors ‘reaching out to me’ in some way or other, or whose events I am subscribed to that activate me.

I would have to know about specific actor types and how I can expect to interact with them. Here’s where the AP extensibility mechanism and possibly “Compliance Profiles” (is “conformance profile” better terminology?) would play a role. The multi-type JSON-LD would only work if it was better defined. In your example of [Group, FEP-1b12] the Group would seem to be like a parent actor type, and FEP-1b12 a specialization and/or child actor (“Lemmy Group”). I would like to have a semantically descriptive term in the body of the JSON-LD, btw. E.g. [Group, fep:Community] or [Group, lemmy:Community] if app-specific. But indeed this whole mechanism needs to be sorted out well then.

What all this gives as a result is a different kind of Fediverse, where encountering a Mastodon actor wouldn’t mean that its endpoint exposes me to a metric ton of functionality that it spits out to me. As a FireFish user encountering a Mastodon actor in the wild, what would I need to know about it? Not nearly as much as currently the case. Both FireFish and Mastodon are Microblogging apps and, suppose they are both well-behaved, implement the common Microblogging Compliance Profiles. Their true communication of exchanging Posts would take place between child actors, and parent actors need not know about that. They delegated that processing and just manage all the delegate tasks à la Actor Model.

That might go as fine-grained as you like. One quality of the actor model is that the number of actors is never an issue. Actors should be incredibly lightweight and there can be millions of them, even within a single actor system. A single toot can be its own actor, and allow remote parties to learn about its side-effects that are caused by incoming msg processing.

3 Likes

For those intrigued by the above… there’s a very long discussion on chat and good-read for additional thoughts.

1 Like

I must say, I’m not really intrigued. I’m too jaded from having written bovine to get excited.

However, I can share my vision of what a requirement for a clean specification underlying a Fediverse would be. I often call this specification FriendPub:

  • Actors are defined in a way that a user can have many actors and compose them
  • Actors are composed through Follow relationships
  • The required behavior of Actors is small, but can vary. For example a user could add a Timeline Actor to their processing chain, and a page like everyone knows from the Mastodon Profile would be generated. By making this an Actor it leaves choices up to the user. This Actor could be reused to show a timeline from multiple people, etc …
  • The end of one side of the processing chain are Device Actors, that represent an user’s devices.
  • The other end could be something like the current ActivityPub Actor

On a final note, @stevebate 's minimal AP Actor GitHub - steve-bate/activitypub-mincore: An exploration into an ActivityPub Minimal Core. probably satisfies most of the stuff I want up there. I think the big social problem here is that it means removing a lot of stuff from ActivityPub that makes the specification heavy to implement.

2 Likes

Tooted some showerthoughts on actors on the fedi this morning, in response to @hrefna. I don’t know how useful this is in practice, but it strikes me that in actor-based applications the top-level actor represents the entire application e.g. a full-blown webshop or banking app.

On the Fediverse our Person actors are like top-level actor systems. A Mastodon actor represents the full microblogging app, a single “email” address that exposes the full “API” to the world for integration. That’s a complex actor right there.

In the sketch I drew yesterday on the Social Web and App Free Computing topic, when I as a person am interacting witht the Recipe, then that involves a long-running task with the remote RecipeService that offered me this dynamic view. The business logic is owned by that service, and not by Mastodon that only displays it in a timeline.

So I shouldn’t exchange Recipe activities with the Mastodon actor, but with RecipeService in the context of both the Mastodon actor and the particular Recipe I want to cook. The top-level Person actor in an actor model would spin up a child actor hierarchy dynamically, delegating all this processing.

If some person provides an Ingredient for the Recipe and that information is exchanged between (remote or local, but network-transparent) child actors, then these don’t need intricate Inboxes. I can only find information on our particular prior exchanges/transactions.

And after the Activity has been processed by all actors involved, the child actors will be killed, they no longer need to exist. And the msg exchanges related to them can be discarded. Only higher level actors remain. If I want to have further interaction with the Recipe then new actor hierarchies are spun up.


Here’s text quoted from my showerthought toots:

We think of actor comms on fedi to be mostly Person-to-Person. That’s like top-level Akka actor systems. In a typical actor model millions of actors may exist in intricate hierarchies spun up as biz-logic processing required.

In that analogy a remote Person actor (or child actor thereof) would receive msg of dynamically created child actor that represents the context/logic of one particular exchange. And inbox represent the prior state exchange.

PersonActor (actor system): “I interact on ActivityX to PersonY”. Instantiates ActivityXActor, delegates task, moves on doing other stuff.

ActivityXActor: “Let’s do some processing. Done. Oh, PersonY is remote”. Instantiates SendMessageActor, delegates task, waits.

SendMessageActor federates processing result to PersonY, receives response. Hands back result to ActivityXActor. End-of-life, stops executing.

Etcetera.

In a typical actor model you get something like network-transparent ActorRefs. The processing of the business logic weaves itself into an intricate processing tree of child actors either locally or remotely. Each actor only has tiny amount of knowledge about the world it lives, is purely focused on its own task. The top of the hierarchy is where is where humans consume the overview. The top of the tree represents some high-level abstraction. What humans experience is the aggregate of all side-effects created by the actor hierarchy as it operates.

Map this dynamic behavior to AS/AP just as the transport protocol and each actor is dedicated, focused.

2 Likes

Copying from chat in response to @helge :

I have this inkling that with our deep technical focus we may be missing the forest because of the trees. What should AP conceptually allow me to do? Well, participate in meaningful activities between agents. Like e.g. “organize a conference”. We look at a single msg Create{Note} that makes that statement and the technical mechanisms. A single tree. The forest is the sending of an Organize{Conference} that is the start of a 2-month long message exchange that models everything that happens in the domain of “Conference Organization”. That single message is like a neuron firing and lighting up parts of the brain for prolonged time, as a thought pattern is followed.

Another analogy is the automotive supply chain. Build{Car} and this spreads out into countless message hubs around the globe, where parts are supplied to eventually see this shining car rolling from the conveyor belt.

We need not go that complex, and OTOH we also don’t need to simplify to Send{Note}.

We model real-world activities, and that that happens to be some JSON(-LD) msg over HTTP is like the lowest-level technical implementation detail.

A single AP msg is like assembly language level.

There’s a spectrum from simple to ultra-complex. We are at 1 in a range from 1 to 100. Every system needs modeling, whether there’s a fedi inbetween or not. Preferably every system focuses on what it is modeling and how that fulfills the needs of people that want a particular solution.

Here’s where ultimately low-level technical infra concerns need to meet with higher level design considerations. We may spend too much time on the low-level, and with focus on our own particular app silo, without thinking about how it may be woven into an ever more intricate Social Web tapestry.

1 Like

A system for sending notes between people is at least less parsable to adversaries who are seeing like a state. The more transparent people’s social organisations become, via being machine readable, the more easily they can be controlled.

1 Like

I don’t know about that. An adversary may just scrape the fedi plain text into a big enough AI and do the inferencing. You list a different concern. Other implementation details should take care what is public or not, depending on the thread model. In the example above an authoritative state may learn some delicious recipes with which to suppress the population :stuck_out_tongue_winking_eye:

Question is: are we satisfied into squishing the fediverse into timelines of microblogging notes, or it worthwhile for it to be a versatile protocol for the (untuitive) exchange of all kinds of human activity?

1 Like

It reminds me of a joke in the agile development community related to the similar-sounding “use cases” and “user stories”…

“A user story is to a use case as a gazelle is to a gazebo.” - Alastair Cockburn

Maybe something similar could be said about “ActivityPub/AS2 Actor” and “computational actor”? However, I’ll continue monitoring the thread, take more showers ;-), and maybe I’ll eventually see the light.

1 Like

Ha ha :joy: certainly. I thought I found a better way, and the other day asked the latest Q-star GPT model “Given the discussions on Fediverse, provide me quality specs that would support it”. The thing started crunching, and an hour later my computer suddenly halted. It was then I learned about Sam Altman’s firing.

1 Like

The logical conclusion is to build a distributed computer on top of ActivityPub. (/j)

2 Likes

I hope @hrefna will copy this thread to the forum, but she just gave an excellent elaboration on the actor model in relation to AS/AP Fediverse:

2 Likes

Updating this thread with recent fedi discussions on the subject…

In reaction to proposed ACK mechanism by @hrefna I brought up honoring the “actor model” nature of AS/AP versus adding another “out of bound” mechanism to handle ACK’s. And @hrefna then pointed out a number of significant differences…

Maybe (in addition to my subsequent fedi replies) I should add that “actor model” is not the best terminology to use. They are a ton of flavors of the original actor model. Like AS/AP “actor-based” may be better. Quoting from the thread:

In the actor model actors are:

  1. Lightweight
  2. Transient
  3. With a queue

When considering an Actors + DDD architecture that sits in front of a bounded context / aggregate root is indeed lightweight: it is a proxy that invokes business logic on the aggregate based on incoming msgs. But the aggregate need not be lightweight, and can have intricate logic.

The actor can be transient too. The ActorRef need not be transient. It is used to instantiate the actor if it no longer exists. In this case the lifecycle of an actor may depend on how expensive it is to hydrate the aggregate root’ state from its event history. Either the actor or the aggregate may be cached for a certain amount of time.

The queue is entirely internal to the actor. From the perspective of the ActivityPub network it does not exist. It does not equal to inbox, which is more analogous to the event bus, while the actor’s queue is more akin to the command bus. The strategy of picking msg from this queue is also opaque to the network. The actor lives in the Service layer of the system and may e.g. give priority to processing certain msgs based on specific metadata.

Another thread by @hrefna reflecting on actor model:

Imho, the Fediverse isn’t going anywhere much beyond what it currently is, if some major missing parts and methodology for creating interoperable services aren’t added. These missing parts are fedi’s Achilles Heel (and also where e.g. Meta may pounce).

In reaction to @hrefna pointing out yet more sore points, and despite earlier discussion on how actors in the fedi differ from a true actor model, today my stubborn (silly?) thought pattern recurred again and I once more projected the paradigm of Actor Model / CQRS / Event Sourcing to reflect upon: