Skip to content

Conversation

@pfefferle
Copy link
Member

@pfefferle pfefferle commented Oct 6, 2025

Adds support for FEP-8fcf to synchronize followers collections across servers. This includes generating and processing Collection-Synchronization headers, computing partial follower digests, exposing a new /followers-sync REST endpoint, and scheduling async reconciliation jobs when mismatches are detected. New methods and traits are introduced for digest computation, header parsing, and reconciliation, with hooks for monitoring sync events. This improves data consistency and interoperability with other ActivityPub servers supporting FEP-8fcf.

Proposed changes:

  • Adds Collection-Synchronization header generation and processing for FEP-8fcf protocol
  • Implements partial follower digest computation using XOR'd SHA256 hashes
  • Provides new /followers/sync REST endpoint for synchronization
  • Includes async reconciliation scheduler for handling digest mismatches

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Go to '..'

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Added support for FEP-8fcf follower synchronization, improving data consistency across servers with new sync headers, digest checks, and reconciliation tasks.

Adds support for FEP-8fcf to synchronize followers collections across servers. This includes generating and processing Collection-Synchronization headers, computing partial follower digests, exposing a new /followers-sync REST endpoint, and scheduling async reconciliation jobs when mismatches are detected. New methods and traits are introduced for digest computation, header parsing, and reconciliation, with hooks for monitoring sync events. This improves data consistency and interoperability with other ActivityPub servers supporting FEP-8fcf.
Included a reference to FEP-8fcf (Followers collection synchronization across servers) in the list of supported FEPs to reflect updated protocol support.
Moved FEP-8fcf Collection-Synchronization header parsing and validation from Followers class to Http class, and generalized synchronization handling into the Collection trait. Removed the Followers_Sync trait and updated controllers to use the new process_collection_synchronization method. This refactor enables support for synchronizing additional collection types beyond followers and centralizes related logic for easier maintenance.
Changed the REST endpoint path from /followers-sync to /followers/sync in documentation, URL generation, and route registration to ensure consistency and clarity in the API.
@pfefferle pfefferle self-assigned this Oct 9, 2025
Refactored code to remove redundant '\Activitypub\' class name prefixes when calling static methods within the same namespace. This improves code readability and consistency.
Moved Collection-Synchronization (FEP-8fcf) logic from REST controllers and trait to a dedicated handler class (Collection_Sync). Removed related code from trait-collection.php, class-http.php, and REST controllers, and registered the new handler in class-handler.php. This improves separation of concerns and centralizes collection sync logic.
@pfefferle pfefferle requested a review from Copilot October 13, 2025 17:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements FEP-8fcf (Followers collection synchronization across servers) to improve data consistency and interoperability with other ActivityPub servers. The implementation adds Collection-Synchronization headers to outgoing activities, provides endpoints for partial follower collections, and includes async reconciliation when digest mismatches are detected.

Key changes:

  • Adds Collection-Synchronization header generation and processing for FEP-8fcf protocol
  • Implements partial follower digest computation using XOR'd SHA256 hashes
  • Provides new /followers-sync REST endpoint for synchronization
  • Includes async reconciliation scheduler for handling digest mismatches

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
includes/scheduler/class-follower.php New scheduler for handling async follower reconciliation
includes/rest/class-inbox-controller.php Adds Collection trait for synchronization support
includes/rest/class-followers-controller.php Implements new /followers/sync endpoint for partial collections
includes/handler/class-collection-sync.php New handler for processing Collection-Synchronization headers
includes/collection/class-remote-actors.php Fixes missing namespace import for Webfinger
includes/collection/class-followers.php Adds FEP-8fcf digest computation and partial followers methods
includes/class-scheduler.php Registers new Follower scheduler
includes/class-http.php Adds Collection-Synchronization header to outgoing activities
includes/class-handler.php Registers new Collection_Sync handler
docs/fep-8fcf-implementation.md Documentation for FEP-8fcf implementation
FEDERATION.md Updates supported FEPs list

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Introduces 'page', 'per_page', and 'order' parameters to the followers sync REST endpoint for improved pagination and sorting. Updates the controller to handle these parameters and enhances test coverage with extensive e2e tests for pagination, authority filtering, error handling, and response consistency. Also updates Playwright config to ensure proper rewrite structure for test environment.
Deleted the static get_authority method from Collection_Sync as it is no longer used in the codebase.
Corrects the regular expression in detect_collection_type to match '/followers/sync' instead of '/followers-sync', ensuring accurate detection of followers collections.
The webServer command now runs an additional command to set the WordPress permalink structure to '/postname' after starting the environment. This ensures tests run with the correct permalink settings.
Added a 'wp rewrite flush' command to the Playwright webServer setup to ensure rewrite rules are properly applied before running tests.
Removed the old 'fep-8fcf-implementation.md' and added a new, more comprehensive 'collection-synchronization.md' documentation. The new doc provides detailed information on the FEP-8fcf prototype, including implementation details, REST endpoints, privacy considerations, action hooks, compatibility, testing, and future enhancements.
Removed additional WordPress CLI commands from the webServer command, leaving only 'npm run env-start' for environment setup.
Moved test cases out of nested blocks in the 'Partial Followers Sync Endpoint' and 'Collection Response Format' suites for improved readability and consistency. No logic changes were made.
Updated the afterStart lifecycle script to flush rewrite rules after setting the permalink structure, ensuring changes take effect immediately.
The Collection trait was removed from the Inbox_Controller class as it is no longer used. This helps clean up the code and avoid unnecessary dependencies.
Consolidated the default value note for the frequency parameter into the @param line in the docblock for clarity.
Introduces a transient cache to prevent duplicate collection syncs per user and actor. Refactors frequency logic into a new get_frequency() method for consistency and maintainability.
@pfefferle
Copy link
Member Author

@obenland now it runs only once a week (outgoing and incoming).

Updated Followers::compute_partial_digest() to delegate digest computation to Signature::compute_collection_digest(), improving code reuse and consistency. Updated documentation in both the code and collection-synchronization.md to reflect this change and clarify method responsibilities.
pfefferle and others added 5 commits October 21, 2025 08:52
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
Refactored the Signature class method compute_collection_digest to get_collection_digest for clarity and consistency. Updated all references and documentation to use the new method name.
Deleted docs/collection-synchronization.md, which described the FEP-8fcf followers collection synchronization implementation, its components, API, and testing instructions.
The get_url_authority function now returns only the scheme and host, omitting the port even if specified. This simplifies the function and matches the updated docblock.
Changed the default value of user_id from 0 to false and updated the conditional check to use strict comparison. This ensures that user_id is properly validated before proceeding.
@pfefferle pfefferle requested a review from obenland October 21, 2025 07:00
Copy link
Member

@obenland obenland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, just a couple of minor things I noticed, then it should be good to go

pfefferle and others added 5 commits October 21, 2025 16:13
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
@pfefferle pfefferle requested a review from obenland October 21, 2025 14:28
@pfefferle pfefferle merged commit 8f0c9e2 into trunk Oct 22, 2025
14 checks passed
@pfefferle pfefferle deleted the add/fep-8fcf branch October 22, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants