RootResolver
Resolves the Milpa HOST APPLICATION's filesystem root — the directory holding its `composer.json`, `plugins/`, `scripts/`, etc. — the one piece of topology every `coa:*` devtools command needs and none of them can safely assume about their own location. The pre-extraction commands computed this as `dirname(__DIR__, 3)` from their own file — correct only because the command class happened to live at a fixed depth under the host's `src/app/Commands/`. That assumption breaks the moment the underlying machinery is Composer-vendored (`vendor/milpa/devtools/...`, any install depth, global installs, other host apps with a different layout): the walk lands somewhere under `vendor/`, not at the host root, and the failure is silent — `plugins/`, `scripts/` etc. are just not found under the wrong root (or, worse, a same-named directory is found there instead). Resolution order (first hit wins): 1. an explicit root passed to the constructor — host wiring always wins (e.g. a container binding the app root once from a known-good source, or a test fixture); 2. `Composer\InstalledVersions::getRootPackage()['install_path']` — the Composer-canonical answer to "where is the application that required me", correct regardless of install depth or path-repo vs. registry install, valid the instant Composer's generated autoloader is on the include path (which it always is for any Composer-managed PHP process — this is not an optional dependency, see `composer-runtime-api` in composer.json); 3. walk up from `getcwd()` looking for the nearest ancestor `composer.json` — a last-resort fallback for the pathological case where Composer's own runtime API is unavailable (e.g. this package used outside a Composer-managed process entirely). Throws {@see RootNotFoundException} instead of returning a plausible-looking wrong path when none of the three resolves — callers get an honest, loud failure.
RootResolver::__construct()
public function __construct(?string $explicitRoot = null):Parameters
| Name | Type | Description |
|---|---|---|
| $explicitRoot | ?string |
RootResolver::resolve()
public function resolve(): stringResolves the host application's root directory per the three-tier order documented above.