Skip to content

Abilities: observe wp_ability_invoked for entry-point telemetry#239

Open
ibrahimhajjaj wants to merge 1 commit into
Automattic:mainfrom
ibrahimhajjaj:feat/ability-invoked-observer
Open

Abilities: observe wp_ability_invoked for entry-point telemetry#239
ibrahimhajjaj wants to merge 1 commit into
Automattic:mainfrom
ibrahimhajjaj:feat/ability-invoked-observer

Conversation

@ibrahimhajjaj
Copy link
Copy Markdown
Contributor

Summary

Adopts wp_ability_invoked on the lifecycle bridge, re-emitting it as the substrate action agents_api_ability_invoked. Part of #94 (next lifecycle hook after the wp_pre_execute_ability / wp_ability_execute_result slices already on the bridge).

wp_ability_invoked fires at the top of WP_Ability::execute() for every call, before any processing, regardless of outcome. That covers the gap the existing observers leave: agents_api_ability_executed (from wp_ability_execute_result) only fires on the registered callback's success path, so invocations that fail input validation, fail the permission check, or get short-circuited by wp_pre_execute_ability never surface to a substrate observer. An entry-point observer lets consumers record every attempt, not just the ones that produced a result.

Changes

  • src/Abilities/class-wp-agent-ability-lifecycle-bridge.php: new ACTION_ABILITY_INVOKED const, observe_invoked() handler, and the wp_ability_invoked registration in register(). The observer re-emits the action and returns nothing (it is an action, not a filter), so it cannot alter execution.
  • tests/ability-lifecycle-bridge-smoke.php: cases for the invoked observer carrying raw input + the ability instance, and firing for calls that never reach a result.

Testing

  • php tests/ability-lifecycle-bridge-smoke.php — 18 assertions, all pass.
  • composer test — full suite green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant