-
Notifications
You must be signed in to change notification settings - Fork 81
Add a reference to AS2 Core's requirement that documents must be compacted #359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is incorrect, this requirement is stated very clearly in the ActivityStreams spec, which is normatively referenced by the ActivityPub spec:
Documents that are not thusly serialized are not conformant with the specification.
I'm not sure I understand your point here. Besides This is incorrect. The JSON-LD Compaction Algorithm (as referenced by the normative language above) requires that these be converted into their
This is incorrect. This is not a "valid" ActivityStreams 2.0 document. Here is the ActivityStreams document you gave when it is properly compacted as is compliant with the AS2 spec: {
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://example.com/some-activity",
"type": "Create",
"object": {
"id": "https://example.com/some-object",
"type": "Note",
"content": "hello world",
"published": "2022-12-15"
},
"to": [
"as:Public",
"as:Public"
]
} JSON-LD Playground link demonstrating this: https://tinyurl.com/2ktvsfbg
This isn't mentioned anywhere else in your issue (and I don't think it's related to the problem statement), and it may be worth its own separate ticket on the ActivityStreams repo, but it would be a major breaking change at this point, and I do not think the massive regression in backwards compatibility would be worth it for the minor value that it brings in terms of forward compatibility. I think at this point every major consumer is aware that properties can have array or value types, and new ones become aware of it very quickly in their development lifecycle. I don't think it's worth re-opening that discussion at this stage. |
Ah, I overlooked the requirement in ActivityStreams-Core, which does indeed resolve my concern. In that case, perhaps adding a hint somewhere in ActivityPub linking back to that section of ActivityStreams would be helpful... probably in Section 1 and/or Section 3. |
This makes sense; if people as well-versed in ActiivtyPub as @trwnh can find the requirements here confusing, we should add some clarification to point out this requirement. In particular, that AP documents need to meet all the requirements of AS2 documents, including compaction (called out). However, that's mostly a stylistic detail, and doesn't rise to the level of an error in the text requiring an Erratum. Therefore, I think we should mark this request for the next version of AP, and consider it once we have chartered a working group. |
I filed this issue nearly two years ago, and I think the fundamental issue that people have is that it is not "enough" to read the AP spec, as one must also read AS2-Core. Yes, it's "normatively referenced", but it would still be useful to have a reminder of this outside of the "referenced" section. A one-liner sentence would work, something along the lines of "Please see AS2-Core for requirements regarding objects" under the aforementioned section 3. Right now there's a hint to look toward AS2-Vocab, but not an explicit hint to look toward AS2-Core. There's a normative SHOULD to include the context, but again no reference to the requirement that the output needs to be consistent against the output of compacting with that context. |
Based on this discussion, we started a primer page on use of AS2 in ActivityPub. https://www.w3.org/wiki/ActivityPub/Primer/Activity_Streams_2.0 |
Problem statement in the existing specification
Currently the ActivityPub specification and its examples are written with an implicit assumption that documents will be compacted against the context
http://www.w3.org/ns/activitystreams
, but this is not actually stated anywhere in the specification.EDIT: This statement is instead made in ActivityStreams Core: https://www.w3.org/TR/activitystreams-core/#jsonld
A hint linking back to this section of AS2 should be added to the AP spec, probably under Section 1 Overview and/or Section 3 Objects.
Original issue text
The only existing mention of JSON-LD was added in #102 under
3. Objects
:1. Overview
also has this to say:A note under
5.6 Public addressing
hints at the difficulties and challenges that "simply JSON" implementations will face:Explanation of issues for non-LD-aware implementations
Someone reading the ActivityPub spec without any JSON-LD knowledge would only be made aware of this issue in reference to the Public magic collection, as per the note in
5.6 Public addressing
. Thus, they may implement their parser to understand "all three representations" as the spec told them to. But the following examples would be unaccounted for, and would all break a "plain JSON only" interpretation:Alternate representations for terms and values other than
Public
You can use the full IRI form, shorthand with a prefix, or shorthand without a prefix... for any term or value in the document. What's more, you can even mix them!
Caveats:
type
orid
. You must use the terms as defined (or use the JSON-LD keywords they map to).@type
information to be stripped, and this causes compaction to leave the prefix in@type
of@id
instead of one that implies@value
(unless you are inlining the object). JSON-LD processors will not apply context mapping to raw values.Using
@type
and@id
directlyas:type
will not translate to@type
but tohttps://www.w3.org/ns/activitystreams#type
(which does not get mapped to@type
because it is not defined as such in the activitystreams.jsonld context). But no matter, we can throw a raw@type
in there to further confuse JSON-only implementations. We can also throw a raw@id
if we wanted to.Custom shorthands defined in
@context
For even more confusion, we could define a custom shorthand prefix! Arguably this one is a bit of a stretch, because it could be said that this is somewhat of an "extension", but it doesn't have to be. Consider an entry in
@context
which mapsactivitystreams
similarly to howas
already maps tohttps://www.w3.org/ns/activitystreams#
as a base IRI. Or, perhaps it even maps directly ontoas
. You may say there is no reason to map this custom shorthand, but what if we were providing our own context document instead of the one hosted on w3.org, albeit with the same definitions and mappings to the same base IRI?An example of technically valid JSON-LD that a non-LD-aware "plain JSON" implementation would struggle to comprehend
This is not something a JSON parser should ever have to deal with. Clearly, the LD-aware implementation MUST take extra steps to produce a document that is understood in a consistent way by non-LD-aware implementations.
Recommended changes to the specification
https://www.w3.org/ns/activitystreams
at minimum, and MAY include additional contexts during compaction."This reduces everything to shorthand where possible, making it easier for JSON-only impls to parse.
Recommended changes to the activitystreams.jsonld context, for additional consistency
"@container": "@set"
to all property definitions, except for functional propertiesThis would save JSON consumers from having to account for single string values, forcing an array during compaction. Consumers would then only have to account for IRI representations vs inlined representations.
It would also make it clearer which properties are functional and which ones are not.
endpoints
as a@nest
?This one might be premature, as JSON-LD 1.1 support for the
@nest
keyword is required.The text was updated successfully, but these errors were encountered: