Skip to content

Move the canFeature policy out of the Activity vocabulary layer#3406

Merged
pfefferle merged 4 commits into
trunkfrom
update/move-interaction-policy-to-models
Jun 12, 2026
Merged

Move the canFeature policy out of the Activity vocabulary layer#3406
pfefferle merged 4 commits into
trunkfrom
update/move-interaction-policy-to-models

Conversation

@pfefferle

@pfefferle pfefferle commented Jun 12, 2026

Copy link
Copy Markdown
Member

Proposed changes:

  • Activity classes are generic vocabulary and must not contain application logic. The FEP-7aa9 canFeature computation (driven by the activitypub_default_feature_policy site option) moves out of Activity\Actor directly into the User and Blog models, each computing the policy fresh and merging with an explicitly set interaction policy only when one is present.
  • A shared model-layer trait was considered and discarded during review: its implicit requirements on the using class (inherited accessor, actor methods) made it too easy to use incorrectly, so the two models intentionally carry the implementation themselves.
  • This also fixes two behavior leaks:
    • Activity\Actor represents remote actors too — the old override injected the local site's canFeature policy into foreign actor representations on re-serialization. Generic actors now fall back to the plain property accessor.
    • The Application actor no longer advertises a consent policy at all (per FEP-7aa9, absence of policy means no consent), matching its role as a system actor.

Other information:

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

Testing instructions:

  • Run the interaction policy tests: npm run env-test -- --filter Test_Interaction_Policy — the four pre-existing model tests pass unchanged, plus two new ones covering the generic-actor and Application-actor behavior.
  • Fetch an author or blog profile with an ActivityPub Accept header and confirm interactionPolicy.canFeature still reflects the Default Starter Kit policy setting.
  • Fetch the Application actor profile and confirm it carries no interactionPolicy.

Activity classes are generic vocabulary and must not contain application
logic. The canFeature computation (FEP-7aa9) moves from Activity\Actor
into a model-layer trait used by the User and Blog models. The generic
Actor class no longer injects the local site policy into remote actor
representations, and the Application actor stops advertising a consent
policy altogether.
Copilot AI review requested due to automatic review settings June 12, 2026 15:26
@pfefferle pfefferle self-assigned this Jun 12, 2026
@pfefferle pfefferle requested a review from a team June 12, 2026 15:26

Copilot AI left a comment

Copy link
Copy Markdown

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 moves FEP-7aa9 interactionPolicy.canFeature computation out of the generic Activity vocabulary layer and into the model layer, so that only local actors (blog/author) advertise the site’s consent policy while remote and system actors do not.

Changes:

  • Introduces a model-layer Interaction_Policy trait and applies it to the User and Blog models.
  • Removes the interaction policy computation from Activity\Actor to prevent leaking local policy into remote actor re-serialization.
  • Adds/extends PHPUnit coverage for generic actors and the Application actor behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/phpunit/tests/includes/model/class-test-interaction-policy.php Adds tests ensuring generic actors don’t emit local policy and Application emits no interactionPolicy.
includes/model/trait-interaction-policy.php New trait that computes canFeature from the activitypub_default_feature_policy option for local actors.
includes/model/class-user.php Applies the new interaction policy trait so user actors still emit canFeature.
includes/model/class-blog.php Applies the new interaction policy trait so blog actors still emit canFeature.
includes/activity/class-actor.php Removes policy computation from the vocabulary-layer actor to avoid app-logic leakage to remote actors/system actor.
.github/changelog/update-move-interaction-policy-to-models Adds a patch changelog entry describing the behavior change.

Comment thread includes/model/trait-interaction-policy.php Outdated
Declare the methods the trait relies on as abstract, so using it in a
class that does not provide them fails at compile time, and document
the Activity\Actor inheritance requirement.
Inline the canFeature computation into the User and Blog models and
only merge with an interaction policy when one is explicitly set. The
trait's implicit requirements on the using class (inherited accessor,
actor methods) made it too easy to use incorrectly.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread includes/model/class-user.php
Comment thread includes/model/class-blog.php
@pfefferle pfefferle merged commit f23f672 into trunk Jun 12, 2026
13 checks passed
@pfefferle pfefferle deleted the update/move-interaction-policy-to-models branch June 12, 2026 15:53
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.

2 participants