close
Skip to content

refactor: cleanup Main bootstrap class#404

Merged
dkotter merged 8 commits intoWordPress:developfrom
justlevine:refactor/main-bootrapper
Apr 13, 2026
Merged

refactor: cleanup Main bootstrap class#404
dkotter merged 8 commits intoWordPress:developfrom
justlevine:refactor/main-bootrapper

Conversation

@justlevine
Copy link
Copy Markdown
Contributor

@justlevine justlevine commented Apr 9, 2026

What?

Closes

This PR cleans up some of root-file tech debt. More specifically it:

  1. Colocates all constants into the root ai.php file
  2. Cleans out inc/bootstrap.php for a WordPress/AI/Main class
  3. Moves the requirement checks out of the Main bootstrapper into a WordPress/AI/Requirements class.

And then some cleanup resulting from that.

  • Moving the new settings meta functions from the global namespace into the settings class where they are used.
  • Add an admin notice for missing build/build.php
  • Remove the unused Loader::is_initialized() method, and a public init() method.

Why?

Pre-7.0 cleanup. The Requirements class will likely also become the registry for per-specific features.

How?

See diff.

Use of AI Tools

Opencode + GLM 5.1 to do a first pass of backfilling unit tests, followed by manual deslopping and backfilling cases it didn't get correctly.

Testing Instructions

npm run test:php

Testing Instructions for Keyboard

Screenshots or screencast

Before After
Open WordPress Playground Preview

@justlevine justlevine requested a review from Copilot April 9, 2026 18:07
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: justlevine <justlevine@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Copy Markdown
Contributor

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

Refactors the plugin bootstrap by replacing the procedural includes/bootstrap.php flow with a Main singleton and a dedicated Requirements checker, while moving settings metadata helpers into Settings_Page and updating integration tests accordingly.

Changes:

  • Introduces includes/Main.php as the new bootstrap entry (hooking into plugins_loaded/init) and removes includes/bootstrap.php.
  • Adds includes/Requirements.php and routes requirement failures through admin notices (incl. missing build/build.php).
  • Moves settings feature metadata generation into includes/Settings/Settings_Page.php and updates tests to use the new APIs/loader lifecycle.

Reviewed changes

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

Show a summary per file
File Description
ai.php Defines plugin constants, loads autoloader, boots the new Main class.
includes/Main.php New class-based bootstrap replacing procedural bootstrap logic.
includes/Requirements.php Centralized runtime requirements checks + admin notice handling.
includes/Settings/Settings_Page.php Colocates settings feature-group/metadata helpers into Settings_Page.
includes/Features/Loader.php Adds init() and makes registration/initialization internals private; removes is_initialized().
includes/bootstrap.php Removed legacy bootstrap implementation.
tests/bootstrap.php (Context) Activates plugin via ai.php, now gated by Requirements.
tests/Integration/Includes/MainTest.php Adds integration coverage for new Main behaviors.
tests/Integration/Includes/RequirementsTest.php Adds integration coverage for new Requirements behavior.
tests/Integration/Includes/Settings/Settings_PageTest.php Renames/re-namespaces and updates tests for settings metadata now on Settings_Page.
tests/Integration/Includes/Experiment_RegistryTest.php Updates to Loader::init() and reflection-based initialized assertions.
tests/Integration/Includes/Experiment_LoaderTest.php Updates tests for new Loader API and private methods.
tests/Integration/Includes/Experiments/*/*Test.php Updates experiment integration tests to use Loader::init() (or manual registration where needed).
phpunit.xml.dist Removes ai.php from coverage include list.
docs/ARCHITECTURE_OVERVIEW.md Updates architecture docs to reflect Main/Requirements and removal of bootstrap.php.
docs/RELEASE_INSTRUCTIONS.md Updates version-bump instructions to reference ai.php as the constant source.
Comments suppressed due to low confidence (1)

tests/Integration/Includes/Settings/Settings_PageTest.php:247

  • This helper uses reflection to invoke a private method, but it never calls $method->setAccessible( true ). Invoking a private method without setting it accessible will throw a ReflectionException/fatal and fail the test run. Add setAccessible(true) before invoke() (or refactor the production code to expose this behavior via a public API that can be tested without reflection).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread includes/Requirements.php
Comment thread includes/Requirements.php
Comment thread includes/Settings/Settings_Page.php Outdated
Comment thread includes/Settings/Settings_Page.php Outdated
Comment thread tests/Integration/Includes/MainTest.php
@justlevine
Copy link
Copy Markdown
Contributor Author

justlevine commented Apr 9, 2026

I'm not sure why these tests are failing. They're passing locally. In the meantime, feedback appreciated on the architecture 🙇

edit: was the now-enforced dependency checks looking for the build.php. Added a test const to skip it.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 88.93805% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.15%. Comparing base (bee0e30) to head (fa21ba6).
⚠️ Report is 9 commits behind head on develop.

Files with missing lines Patch % Lines
includes/Main.php 74.62% 17 Missing ⚠️
includes/Requirements.php 93.75% 5 Missing ⚠️
includes/Settings/Settings_Page.php 95.94% 3 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #404      +/-   ##
=============================================
+ Coverage      65.75%   68.15%   +2.40%     
- Complexity       763      808      +45     
=============================================
  Files             53       53              
  Lines           3863     3925      +62     
=============================================
+ Hits            2540     2675     +135     
+ Misses          1323     1250      -73     
Flag Coverage Δ
unit 68.15% <88.93%> (+2.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread includes/Features/Loader.php Outdated
Comment thread includes/Features/Loader.php
Comment thread includes/Settings/Settings_Page.php Outdated
Comment thread includes/Settings/Settings_Page.php Outdated
justlevine and others added 3 commits April 13, 2026 19:02
Co-authored-by: Darin Kotter <darin.kotter@gmail.com>
Co-authored-by: Darin Kotter <darin.kotter@gmail.com>
@justlevine justlevine force-pushed the refactor/main-bootrapper branch from 8a90df5 to fa21ba6 Compare April 13, 2026 16:23
@justlevine justlevine requested a review from dkotter April 13, 2026 16:27
Copy link
Copy Markdown
Collaborator

@dkotter dkotter left a comment

Choose a reason for hiding this comment

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

Looks good to me and tests well!

@dkotter dkotter merged commit aba36a2 into WordPress:develop Apr 13, 2026
18 checks passed
@github-project-automation github-project-automation Bot moved this from Needs review to Done in WordPress AI Planning & Roadmap Apr 13, 2026
@justlevine justlevine deleted the refactor/main-bootrapper branch April 13, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

4 participants