Skip to content

fix: avoid implicit consumer autoload in ECS checks - #55

Merged
coisa merged 6 commits into
mainfrom
codex/isolated-ecs-bootstrap
Oct 27, 2026
Merged

coisa merged 6 commits into
mainfrom
codex/isolated-ecs-bootstrap

Conversation

@coisa

@coisa coisa commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #54.

ECS's CLI bootstrap loads the working directory's vendor/autoload.php even when the formatter uses a separate tool installation. Run the native public ECS factory/check command through a packaged internal worker instead, retaining the consumer cwd, native configuration/cache, selected absolute arguments and explicit custom-checker bootstrap. Capture installation paths before executable configuration can change Composer's installed-package metadata. The ordinary Composer binary-proxy bootstrap remains intentional when the tool shares the consumer installation; explicit PHP configuration remains trusted executable code.

Validation: 85 tests / 627 assertions, Composer strict/platform, syntax of 29 PHP entrypoints/files, PER, actionlint and fragments passed. Focused regressions cover tracked/ignored application autoload sentinels, check/fix/post-verification, spaces/tabs/newlines, explicit custom checkers, cwd/relative metadata, cache invalidation, exit codes, Composer proxy and packaged worker. The actual worker also passed an ECS 13.3.11 smoke check/fix/verification and config-error case; contributor lock uses 13.3.8. Independent review approved final 9b8d27e after preserving main 9cf4af3 and the concurrent remote merge. Each || in the multiline provider guard is now on its own line; the formatter accepts and preserves the requested layout. Current-HEAD hosted CI and external reviews remain pending. No consumer formatting, semantic refactoring or release is included.

Refs #58 for the separate enforcement-policy gap: the installed preset also accepts the previous mixed layout. This PR's local whitespace correction does not implement a new rule or claim PER already prohibits it.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 55358866-41c2-45b0-a7d7-8b330ab31f20
Commits

Reviewing files that changed from the base of the PR and between 918c0a3 and c932b2b.

Files selected for processing: 11
  • .changelog/isolated-formatter-bootstrap.md
  • README.md
  • bin/ecs-worker
  • docs/architecture.md
  • docs/automation.md
  • src/ServiceProvider/StandardsServiceProvider.php
  • src/Standards/StandardsRunner.php
  • tests/Fixtures/BootstrapFixer.php.inc
  • tests/Fixtures/explicit-bootstrap-config.php.inc
  • tests/Integration/EcsBootstrapTest.php
  • tests/Standards/StandardsRunnerTest.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes

    • Formatter checks and fixes now use the tool’s installed runtime without automatically loading the target project’s Composer autoloader. This helps prevent unintended interactions with the project’s dependencies.
    • Explicit configuration can still load project autoloaders and custom checkers. The project’s working directory and relative configuration paths are preserved.
    • Fix mode continues to run a follow-up check, and errors are reported with a failure status.
  • Documentation

    • Clarified formatter runtime behavior, configuration options, and Composer installation details.

The formatter now uses a packaged worker and ECS public APIs instead of the ECS CLI bootstrap. The worker receives the tool’s Composer autoloader, the ECS engine path, configuration, mode, and selected files. Integration tests cover default and explicit bootstrap behavior.

Changes: Isolated ECS formatter execution

Layer / File(s) Summary
Worker protocol and execution
bin/ecs-worker, README.md, docs/architecture.md, docs/automation.md, .changelog/isolated-formatter-bootstrap.md
The worker validates its arguments and paths, loads supplied autoloaders, and runs ECS’s native check command. Documentation describes the worker’s bootstrap behavior and the preserved consumer working directory and configuration context.
Runner path resolution and command wiring
src/ServiceProvider/StandardsServiceProvider.php, src/Standards/StandardsRunner.php
The provider resolves and validates the ECS engine directory. The runner invokes the worker for check and fix modes and runs a check after fixing.
Bootstrap behavior and integration coverage
tests/Fixtures/*, tests/Integration/EcsBootstrapTest.php, tests/Standards/StandardsRunnerTest.php
Fixtures and tests cover default and explicit consumer bootstrap, check and fix behavior, configuration errors, packaged worker execution, Composer binary proxies, and runner status handling.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant StandardsRunner
  participant ECSWorker
  participant ComposerAutoloaders
  participant ECSContainerFactory
  participant CheckCommand
  StandardsRunner->>ECSWorker: worker paths, config, mode, source paths
  ECSWorker->>ComposerAutoloaders: load supplied autoloaders
  ECSWorker->>ECSContainerFactory: create container with config
  ECSWorker->>CheckCommand: run with mode and selected files
  CheckCommand->>ECSWorker: return command status
Loading

Possibly related issues

  • php-fast-forward/code-standards#1 — The PR implements ECS execution behavior through the standalone package’s worker and public APIs.
  • php-fast-forward/dev-tools#240 — The PR advances the ECS implementation in the Code Standards domain without changing the orchestration boundary.
  • php-fast-forward/dev-tools#197 — The packaged worker separates ECS bootstrap from implicit consumer autoloading.
  • php-fast-forward/code-standards#2 — The PR tests worker inclusion in a Composer archive, while the issue’s broader fresh-install and compatibility scope may remain.
  • php-fast-forward/code-standards#24 — The runner retains a check after fix operations, as described by the issue.
Merge Risk: Minimal · up to c932b

No actionable issue is identified from the supplied changes; normal validation can proceed before merging.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title concisely and accurately identifies the main change: preventing implicit loading of the consumer autoloader during ECS checks.
Linked Issues check Passed Objective [#54]: the default isolated ECS path must not import the consumer vendor/autoload.php. Evidence at head c932b2b: bin/ecs-worker does not run the ECS CLI bootstrap. It requires only this tool…
Out of Scope Changes check Passed Every changed area maps to the objective of [#54] or supports it. bin/ecs-worker is the new internal worker and implements the isolated check/fix path. src/Standards/StandardsRunner.php and its test (…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi…
Description check Passed The pull request description directly explains the ECS bootstrap, worker, autoload, configuration, cache, path, and validation changes reflected in the changeset.
Full details: Linked Issues check

Explanation

Objective [#54]: the default isolated ECS path must not import the consumer vendor/autoload.php. Evidence at head c932b2b: bin/ecs-worker does not run the ECS CLI bootstrap. It requires only this tool's Composer autoloader ($autoload) and the installed PHP_CodeSniffer autoloader under the resolved engine directory. It then calls EasyCodingStandardContainerFactory::createFromArgv and CheckCommand::run directly. src/Standards/StandardsRunner.php now builds the process command as [PHP_BINARY, worker, autoload, engine, config, --check|--fix, '--', ...files]. Dry-run and exit behavior are kept: the check run follows a fix run, the first nonzero status is returned, and the worker returns the command status. The engine path is resolved in StandardsServiceProvider's constructor, before user configuration runs. Configuration paths are passed as absolute values and the worker rejects non-absolute paths. Objective [#54]: native configuration semantics are retained. The worker runs with the consumer cwd and passes --config to the native factory. No blanket chdir or vendor patch is used. Objective [#54]: explicit consumer bootstrap is an opt-in boundary. tests/Fixtures/explicit-bootstrap-config.php.inc and the docs describe this boundary. Objective [#54]: tests. tests/Integration/EcsBootstrapTest.php covers tracked and ignored autoload sentinels, default check/fix, explicit configuration and context, cache invalidation, error exit codes, worker protocol rejection, archive inclusion, and the Composer binary-proxy path. The test names do not name an explicit no-source or lock-mutation assertion, and the test file body was not read. Lock-mutation coverage is therefore taken from the PR description and the context fixture, not confirmed in the test body. Core implementation requirements are supported by source evidence.

Full details: Out of Scope Changes check

Explanation

Every changed area maps to the objective of [#54] or supports it. bin/ecs-worker is the new internal worker and implements the isolated check/fix path. src/Standards/StandardsRunner.php and its test (constructor and argument change) route formatting through the worker. src/ServiceProvider/StandardsServiceProvider.php captures the engine directory and worker and autoload paths; this change is required by the new runner constructor. tests/Fixtures/BootstrapFixer.php.inc and tests/Fixtures/explicit-bootstrap-config.php.inc are test fixtures for sentinel and explicit-configuration cases. tests/Integration/EcsBootstrapTest.php is the requested regression suite. README.md, docs/architecture.md, docs/automation.md and the .changelog entry document the new bootstrap contract and the preserved Composer proxy behavior. No unrelated consumer formatting, semantic refactor, or release change was found in the summarized changes. Whole-PR file coverage was taken from the supplied summary, not from a complete diff read.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 23 functions across 4 files. (7 skipped: 7 unsupported.)

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the paths at night
The worker keeps the bootstraps right
A fixer turns each marker new
Then checks the files once more through
The carrots wait; the checks are done

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Changelog

✅ Contribution check passed.

Head: 9b8d27ec72ca780770d96476073f8657fc62d73d

Base: 9cf4af37edde4da71aaf66a084b910bef9848fa9

Contribution: 1 new valid fragment(s). Policy: ordinary.

  • isolated-formatter-bootstrap.md — fixed, patch

    Checks and fixes through ECS's public APIs without implicitly loading a separate consumer vendor autoloader. Preserves consumer cwd, native configuration and cache behavior, explicit custom-checker opt-in, and the tool's own Composer bootstrap.

coisa commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T01:52:34.841267Z 9b8d27e New commits
🔒 Security Review ✅ Completed 2026-10-27T01:53:23.360120Z 9b8d27e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: d1ecaea1e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: d1ecaea1e9

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@coisa
coisa marked this pull request as ready for review October 27, 2026 01:34
@coisa
coisa merged commit baadc95 into main Oct 27, 2026
25 checks passed
@coisa
coisa deleted the codex/isolated-ecs-bootstrap branch October 27, 2026 02:02
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.

Prevent implicit consumer bootstrap during isolated default style checks

1 participant