Skip to content

Add FEP-5711 inverse properties for collections to Vocabulary API #373

@dahlia

Description

@dahlia

Summary

Add support for FEP-5711 Inverse Properties for Collections vocabulary to Fedify's Vocabulary API. This FEP defines inverse properties for ActivityPub collections that help identify the relationship between collections and their parent objects/actors.

Problem

Currently, Fedify's Vocabulary API does not include the vocabulary properties defined in FEP-5711. This FEP introduces important inverse properties such as likesOf, sharesOf, repliesOf, inboxOf, outboxOf, followersOf, followingOf, and likedOf that provide two-way verification mechanisms for collections and help prevent spoofing attacks.

Without these properties, developers cannot:

  • Verify that a collection is legitimately associated with a specific object or actor
  • Implement proper anti-spoofing measures for collection relationships
  • Use these standardized inverse properties in their ActivityPub implementations
  • Take advantage of the improved interoperability that these properties provide

Proposed Solution

Add the following properties from FEP-5711 to Fedify's Vocabulary API:

Object-related inverse properties

  • likesOf — identifies the object for which a collection serves as the likes property
  • sharesOf — identifies the object for which a collection serves as the shares property
  • repliesOf — identifies the object for which a collection serves as the replies property

Actor-related inverse properties

  • inboxOf — identifies the actor for which a collection serves as the inbox property
  • outboxOf — identifies the actor for which a collection serves as the outbox property
  • followersOf — identifies the actor for which a collection serves as the followers property
  • followingOf — identifies the actor for which a collection serves as the following property
  • likedOf — identifies the actor for which a collection serves as the liked property

All properties should be:

  • Added to the appropriate collection types (Collection, OrderedCollection, etc.)
  • Functional properties (single value)
  • Have proper domain (as:Collection) and range (as:Object) specifications
  • Include proper TypeScript types and documentation

Alternatives Considered

  1. Wait for wider adoption — However, FEP-5711 provides clear security and interoperability benefits that justify early adoption
  2. Custom implementation by developers — This would lead to inconsistent implementations and defeat the purpose of having a standardized vocabulary API
  3. Manual property addition — Fedify's vocabulary API is code-generated, making manual additions impractical

Scope / Dependencies

Affected components

  • Vocabulary API code generation (YAML files in fedify/vocab/ directory)
  • Collection-related type definitions
  • TypeScript type exports
  • Preloaded JSON-LD contexts (packages/fedify/src/runtime/contexts.ts)
  • Documentation and examples

Dependencies

  • FEP-5711 specification
  • Context definition: https://w3id.org/fep/5711

Implementation approach

  • Add properties to existing collection YAML files in the vocabulary directory
  • Follow existing patterns for property definitions
  • IMPORTANT: Add the FEP-5711 context to preloadedContexts in packages/fedify/src/runtime/contexts.ts since https://w3id.org/fep/5711 does not currently serve a JSON-LD context document, which would cause JSON-LD processors to malfunction
  • Add appropriate TypeScript types and accessors
  • Update documentation with usage examples

Critical implementation note

The https://w3id.org/fep/5711 URL does not currently serve a working JSON-LD context. To prevent JSON-LD processor errors, the context definition must be added to Fedify's preloadedContexts object with the appropriate property mappings for all 8 inverse properties:

"https://w3id.org/fep/5711": {
  "@context": {
    "likesOf": {
      "@id": "https://w3id.org/fep/5711#likesOf",
      "@type": "@id"
    },
    "sharesOf": {
      "@id": "https://w3id.org/fep/5711#sharesOf",
      "@type": "@id"
    },
    "repliesOf": {
      "@id": "https://w3id.org/fep/5711#repliesOf",
      "@type": "@id"
    },
    "inboxOf": {
      "@id": "https://w3id.org/fep/5711#inboxOf",
      "@type": "@id"
    },
    "outboxOf": {
      "@id": "https://w3id.org/fep/5711#outboxOf",
      "@type": "@id"
    },
    "followersOf": {
      "@id": "https://w3id.org/fep/5711#followersOf",
      "@type": "@id"
    },
    "followingOf": {
      "@id": "https://w3id.org/fep/5711#followingOf",
      "@type": "@id"
    },
    "likedOf": {
      "@id": "https://w3id.org/fep/5711#likedOf",
      "@type": "@id"
    }
  }
}

This addition aligns with Fedify's policy of accepting vocabulary contributions that are specified in FEPs, making it a straightforward addition to the project.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions