Where are the "range" and "functional" of ActivityPub properties defined?

Activity Vocabulary has tables which indicate several aspects of each defined property, including

  • functional — is it single-value, or not?
  • range — indicates the type of value the property term can have
  • subproperty of — meaning that the term is a specialization of the referenced term

Here’s a good example.

I haven’t been able to find something like this for the properties added by ActivityPub.

For example, take following. The ActivityPub Recommendation says:

A link to an [ActivityStreams] collection of the actors that this actor is following; see 5.4 Following Collection

Every actor SHOULD have a following collection. This is a list of everybody that the actor has followed, added as a side effect. The following collection MUST be either an OrderedCollection or a Collection and MAY be filtered on privileges of an authenticated user or as appropriate when no authentication is given.

Based on the above, I would have thought the range was Collection (like it is for replies), but looking at the examples and data returned by a Mastodon instance, I see the following property being set like this:

"following": "https://example.org/users/johndoe/following",

So what’s the correct range?

Also, can an Object have multiple values for following, or is it “functional”?

Where are these aspects of all of the ActivityPub properties defined?

1 Like

There is ActivityStreams 2.0 Terms and the associated JSON-LD context document at https://www.w3.org/ns/activitystreams.jsonld but otherwise there is no other information provided, outside of what is in the spec document.

In the specific example of something like following: you are correct that its range is a Collection (MUST be either an OrderedCollection or a Collection). What you are seeing is a JSON-LD @id (or ActivityPub id, although the latter is an alias for the former). If you fetch the document at that IRI, you should see an object being returned with type (Ordered)Collection as specified in ActivityPub.

As far as functional values go, you can assume that all properties that link to an @id are functional, as the ActivityPub spec defines these properties as pointing to a single object generally.

In summary:

  • They’re pretty much all functional
  • The range is whatever type is specified (e.g. Collection/OrderedCollection)
  • There are no subproperties relevant within ActivityPub
3 Likes

Thank you! It looks like a bunch of the properties ActivityPub adds are either Collections or OrderedCollections, so that clears up a lot of my confusion.

A few aren’t though… are the endpoints, preferredUsername, source, and streams properties also functional?

I’m especially confused by streams. The spec says “A list of supplementary Collections which may be of interest”. There aren’t even any examples, so I’m pretty confused about what this is supposed to be. How is a list of Collections represented in the JSON-LD?

I would assume yes, except for streams. That one is an array so it’s very clearly not functional. It’s not super well-defined, but it can be construed to be similar to categories on a blog in its intent: streams · Issue #299 · w3c/activitypub · GitHub

1 Like

Ok, that makes sense to me, though I’ve been surprised by properties being non-“functional” more than once already, so I’m reluctant to guess.

Actually, one example of this is content. This table in Activity Vocabulary does not state that content functional, which I believe means it is non-functional, ie: multi-valued.

However, source is meant to match up with content:

ActivityPub extends the Object by supplying the source property. The source property is intended to convey some sort of source from which the content markup was derived, as a form of provenance, or to support future editing by clients. In general, clients do the conversion from source to content, not the other way around.

This reads to me like it’s assuming that there’s only one content per Object. Is this a bug in one or the other spec, and if not, how does one figure out which content the source generates?

The natural langauge properties (name, summary, content) are not marked functional, yes, but they’re a bit weird in that they generally use the *Map properties to provide multiple values rather than being an array. In that sense, one could imagine a sourceMap property to map sources to different languages? But this is not included in the ActivityStreams JSON-LD context document. So as currently defined, source is a JSON object and nothing more. It’s not particularly well-defined which properties you might find inside, either, although it is assumed that content and mediaType will be in there – the real answer is “it depends on the ActivityPub client”. Whatever you put into source is expected to be used by you the client. If a different client edits the source and doesn’t understand your source, you may lose the source property as it could be overwritten. See the example provided where Alyssa tries to use org mode in one client which is not understood by some other client.