Repository navigation
PoC: consume the wordpress/abilities package for the core-facing abilities (roadmap step 2 of #1289) - #1333
PoC: consume the wordpress/abilities package for the core-facing abilities (roadmap step 2 of #1289)#1333nikmclaughlin wants to merge 5 commits into
Conversation
Pin a snapshot of nikmclaughlin/wordpress-abilities @ 3afb1e7 (main + PR WordPress#12 add/mcp-public-meta + PR WordPress#15 add/trio-show-in-rest + PR WordPress#16 add/trio-trunk-sync): src/, the optional multi-copy arbitration loader, composer.json, LICENSE, and a VENDORED.md recording the pin, the in/out set, the PoC swap-out path, and the arbitration contract. This is the PoC dependency of roadmap step 2 in WordPress/ai WordPress#1289; not a merge candidate for production (see VENDORED.md for the named swap-out path). PoC for WordPress#1289 (package consumption) — not for merge.
…lete the in-repo copies
- ai.php: require the vendored package's arbitration loader at file scope and
register the copy (wordpress_abilities_register('0.1.0', ...)); newest-copy
wins lazily, keeping the plugin + MCP adapter bundle safe.
- Custom_Abilities::register(): after the gated-ability loop, register the
package through Registrar::register_all(), behind two new filters:
wpai_register_wordpress_abilities (bool, default true) and
wpai_wordpress_abilities_args (array, passed to the Registrar; its
callable is the per-ability selection policy). The experiment's default-off
gate is unchanged. The requires_core_object_exposure() conditional now loads
the package's support polyfills for third-party gated abilities (the
Show_In_Abilities replacement).
- Gated_Abilities: default registry trimmed to Post_Utilities only.
- Delete the in-repo trio and wrappers (Content, Users, Settings, their gated
wrappers) and the Show_In_Abilities polyfill: the package ships equivalent
polyfills, its Registrar carries the Gate-2 stand-down (WordPress#1240/WordPress#1251
semantics), and it stamps provenance meta. Delete, don't dormant (P4).
PoC for WordPress/ai WordPress#1289 — not for merge.
- New tests/Integration/Includes/Abilities/WordpressAbilitiesConsumptionTest: all 18 package abilities register with provenance meta while the experiment is enabled; a pre-registered core/content-query is kept, not overridden (WordPress#1240/WordPress#1251 acceptance criteria pinned in the plugin for the first time); the Registrar declares the content/media categories; the declare-categories opt-out leaves package-categorized abilities loudly unregistered (Gate 8); the REST abilities v1 list route serves the package set with provenance and a REST run of core/content-query round-trips a post created through core/content-create; the experiment gate stops every package registration and hook when off; both wpai filters and the wpai_gated_abilities boundary behavior; polyfill exposure for third-party gated abilities; idempotent re-registration with no notices. Mirrors the MCP-adapter PoC's consumption suite, adapted to the experiment gating (fresh registration windows via reflection, as the package's own RegistrarTest does). - Update Custom_AbilitiesTest for the queued package registration. - Update Gated_AbilitiesTest for the trimmed registry. - Delete the trio's and Show_In_Abilities's PHPUnit suites with their classes. PoC for WordPress/ai WordPress#1289 — not for merge.
Rewrite docs/experiments/custom-abilities.md for the new shape: the registry resolves to plugin-owned utilities plus the package registration via the Registrar; document wpai_register_wordpress_abilities and wpai_wordpress_abilities_args, the wpai_gated_abilities boundary change (additions still work; package abilities are no longer in that filter), the Registrar's category declarations, core-provided stand-down, provenance meta, and the removal of Show_In_Abilities in favor of the package's polyfills. CHANGELOG: note the core-facing abilities move to the wordpress/abilities package, the core-provided stand-down on 7.2+, and the wpai_gated_abilities breaking change. PoC for WordPress/ai WordPress#1289 — not for merge.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1333 +/- ##
=============================================
- Coverage 85.03% 83.93% -1.11%
+ Complexity 4832 4471 -361
=============================================
Files 190 183 -7
Lines 17950 16590 -1360
=============================================
- Hits 15263 13924 -1339
+ Misses 2687 2666 -21
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The sibling PoC (WordPress/mcp-adapter WordPress#430) pins the package at 00d65cf (main + PR WordPress#12); this PoC pins 3afb1e7 (main + WordPress#12 + the trio stack WordPress#15/WordPress#16). Same package, same lineage base, different pin — correct the earlier 'shared single integration ref' wording.
|
Left this comment on the issue and realized I should have left it here but any reason to not consume this package as a composer dependency as opposed to copying all the code in? |
|
I found a gap in the shared loading contract when comparing this with WordPress/mcp-adapter#430. The snapshots differ ( The adapter draft also exposes Could we give different runtime revisions distinct versions and test both plugins active in both load orders before settling on the loading contract? Those tests should also cover the AI experiment being disabled while the adapter remains active. Checked against |
|
Thanks @euvoor, the two PoCs were pinned to different commits to account for historical drift so that each individual PoC could function in the current "staging" state while my abilities package is an untagged, personally-owned, stacked-on-open-PRs package. Basically, all of that is why this PoC is marked as "not a merge candidate" 😅 Once we move the package to a WP-owned repo we can begin versioning and including as a composer dependency rather than the vendoring approach used here. In my own tests, the package's arbitration loader and JP autoloader used in the MCP Adapter were both able to ensure only the latest version was loaded, though further testing is welcome there, especially once the package moves to core ownership. |
|
Thanks @nikmclaughlin, that explains the temporary pins. I checked the package loader with distinct version labels, and it selects the newer copy in either registration order. The case I’d like to verify next is the interaction with the plugins’ actual autoloaders. In a small Composer-only reproduction, prepending the older copy’s loader serves its I can put together a co-installation test covering both plugin load orders, different bundled versions, and the AI experiment disabled while MCP stays active. It would check the files actually defining the classes and the resulting ability registration/discovery. That should give us concrete coverage for the Composer migration. |
|
Thanks @euvoor , I'm preparing the repo for transfer now, then we'll need a proper composer publish under the 'WordPress' org before it can be consumed there. Any reason for your tests to be needed before any of that, or would you be okay running the test on the final PR before the new dependency gets merged into the plugin? |
|
That timing works for me, @nikmclaughlin. No need to hold up the transfer or Composer publication for these tests. I’ll run the co-installation checks against the final dependency PR before it merges: both plugin load orders, different bundled versions, and the AI experiment disabled while MCP stays active. That will let us verify class loading and ability registration/discovery with the package and autoloaders that will actually ship. |
Summary
Tests consumption of the
wordpress-abilitiespackage from its current location to provide core-facing abilities for the Custom Abilities experiment.wordpress-abilities) is still under personal ownership (nikmclaughlin/wordpress-abilities). On approval, the package will be moved to a WordPress-owned repository.The vendored set of abilities in
includes/Vendor/Abilities/pins3afb1e7ofnikmclaughlin/wordpress-abilities, which is the same package as the sibling MCP-adapter PoC WordPress/mcp-adapter#430, but a different pin. The version used here includes two additional PRs on top of the MCP Adapter ref (15 and 16) which cover gaps discovered in this work.Why?
The AI plugin is the original staging ground for core abilities.
core/content-query,core/users-query, andcore/settings-getare maintained here as near-verbatim class copies of core'sWP_Abilities_{Content,Users,Settings}(synced by hand at 1.5.0 through #1206/#1207/#1208), with the rest of the core-facing set in flight as open PRs. Every option integrators have today (wait for core; depend on the whole AI plugin; fork and re-sync) is a downside the central package removes. That argument is in #1289. This PoC proves the consumption pattern end to end in this plugin to aid in that discussion.What the PoC demonstrates:
coreifytooling) that centralizes and streamlines drift maintenancecore/settings-get,core/users-queryandcore/content-querywhen WordPress core does not provide them #1240 / PR Abilities: Only register the plugin's copies of core abilities when WordPress core does not provide them #1251) are made in one place and encoded in the package Registrar's Gate. The Registrar resolves availability before any consumer selection, so a consumer filter can never veto a core-provided name.How?
Everything rides on the Custom Abilities experiment (its default-off gating is unchanged):
ai.php— after the autoloader require, requires the vendored copy'swordpress-abilities-loader.phpand callswordpress_abilities_register( '0.1.0', ... )at plugin file scope. The loader only records the copy, classes resolve lazily, and noWordPress\Abilities\PSR-4 prefix is added toincludes/autoload.php. The loader's spl autoloader handles multi-copy arbitration.Custom_Abilities::register()— after the gated-ability loop, registers the package viaRegistrar::register_all(), behind two new filters:wpai_register_wordpress_abilities(bool, defaulttrue) andwpai_wordpress_abilities_args. These adapt the existingwpai_gated_abilitiesbehavior, though constitute a breaking change (discussed below).Gated_Abilities— the default registry trims toPost_Utilitiesonly.ai/get-post-terms+ the deprecatedai/get-post-detailskeep working exactly as before.includes/Abilities/{Content,Users,Settings}/), their gated wrappers,Show_In_Abilities, and their PHPUnit suites. The package ships the equivalent polyfills, its Registrar carries the stand-down, and its per-ability suites plus this plugin's consumption test. The plugin's e2e specs are untouched to ensure parity across migration.abilities/v1REST routes, the Abilities Explorer, the MCP Access experiment, the CLI, and the wholeai/*feature surface. No new abilities, no UI.wpai_gated_abilitiessemanticsToday the
wpai_gated_abilitiesfilter can add, remove, and replace the core-facing abilities because their classes are in-repo. After this migration they are not plugin classes anymore, so the filter keeps a narrower shape:Abstract_Gated_Abilityregisters as before, including through therequires_core_object_exposure()path.wpai_wordpress_abilities_args→Registrar::register_all()args, whosefiltercallable does the per-ability selection. This selection filter can never veto core-provided names, matching Only register the plugin's copies ofcore/settings-get,core/users-queryandcore/content-querywhen WordPress core does not provide them #1240, andpublic_onlynarrows tometa.public. Thewordpress_abilities_declare_categoriesfilter (package-side contract) provides a filtering options for category declarations.wpai_gated_abilitiesexamples in the docs and the Gated_Abilities tests were updated to the new boundary with a breaking-change note in the changelog entry.Use of AI Tools
AI assistance: Yes
Tools: goose agent for planning and implementation
Models (via Ollama cloud):
GLM 5.3for planning and orchestration,GLM 5.3 Flashfor implementation, validation, and testing.Used for: Implementation and tests of this PoC, driven fully by an approved written plan. The orchestrator and validator agents reviewed the work, while test gates were run on the plugin's own tooling.
Testing Instructions
Gates used for this branch (all four from the repo's own tooling):
composer install+ asset build first (npm run build— the asset-dependent suites fail without it, identically ondevelop, so it is a dev-setup step, not a PoC result).npm run lint:php→ phpcs clean (the vendored path is pre-excluded).npm run lint:php:stan→ PHPStan level 8 clean.npm run test:php→ 2441 tests, 0 errors, 0 failures, 53 skipped. The three ability test classes are the PoC's core:WordpressAbilitiesConsumptionTest(12 tests: registration + provenance, Only register the plugin's copies ofcore/settings-get,core/users-queryandcore/content-querywhen WordPress core does not provide them #1240/Abilities: Only register the plugin's copies of core abilities when WordPress core does not provide them #1251 conflict semantics, Registrar-declared categories + Gate-8 opt-out, REST list/run parity incl. acore/content-create→core/content-queryround-trip, experiment gating, both new filters + thewpai_gated_abilitiesboundary, polyfill exposure, idempotence),Custom_AbilitiesTest,Gated_AbilitiesTest.npm run test:e2e -- tests/e2e/specs/abilities/→ all 23 existing specs pass, untouched — identical names, schemas, and permission behavior is the strongest parity signal the migration is behavior-preserving.wp eval 'var_dump( wordpress_abilities_loaded_version() );'→0.1.0after any package class resolution; with the experiment enabled,wp_has_ability( 'core/content-query' )→truewith provenance meta (source = wordpress/abilities,package_version = 0.1.0).Manual checks mirroring the plan's §8 are listed in the updated
docs/experiments/custom-abilities.md(enable/disable, Explorer listing,wpai_gated_abilitiesextension, selection viawpai_wordpress_abilities_args).Changelog Entry
Cross-references
wordpress-abilitiesas central ability provider #1289wordpress-abilitiespackage mcp-adapter#430Open Questions
wpai_gated_abilitiesselection filter: is the args pass-through implemented here a suitable replacement for the existing selection?