Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 21 additions & 37 deletions .claude/commands/upgrade-assessment.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ Usage: `/upgrade-assessment <targetVersion>` — the target must match
`/upgrade-hop`; do not ask again. Never ask for attestation or approval.
Then print the non-blocking run notice per `write-scope.md` ("Required run-notice wording"):
instance, version pair, individual routine commands (the `next-steps` status helper,
PHPStan (the baseline run at the current PHP and the target-PHP run, plus the isolated latest-stable `composer require --dev phpstan/phpstan` inside `.ccua/tools/phpstan/` only; PHPCompatibility likewise via `composer require --dev squizlabs/php_codesniffer phpcompatibility/php-compatibility` inside `.ccua/tools/phpcs/` only, installed automatically when the project has no usable `vendor/bin/phpcs`, with no extra question), one UCT
PHPStan (the baseline run at the current PHP and the target-PHP run, plus the isolated latest-stable `composer require --dev phpstan/phpstan` inside `.commerce-upgrade/tools/phpstan/` only), one UCT
scan with `--ignore-current-version-compatibility-issues` or baseline and target scans,
read-only `composer_probe.py` lookups, normalization, controlled URL/source helpers), ambient
developer mounts (expected, never read, never a blocker), the standing local/dev non-production
profile and files written. Run routines automatically. If a production signal withdraws the
standing profile, return a human-run runbook for each blocked step.
Third-party target-release resolution (`composer_probe.py --op resolve|fetch` in the scratch
directory `.ccua/tools/resolve`, see the specification below, 3.5) is not routine: list it in
directory `.commerce-upgrade/tools/resolve`, see the specification below, 3.5) is not routine: list it in
the notice as a separate exact-action step and run it only after that approval; if declined,
third-party Composer/UCT/PHP columns stay `Not assessed` with the reason.
2. Apply `environment-detection` for `dockerType`, `containerPrefix`, PHP and service
Expand All @@ -60,7 +60,7 @@ Apply `uct-install`'s **Assessment prerequisite** before collecting UCT evidence
generating scan-dependent reports. Reuse its Magento, Composer and standalone probes in
the verified environment; do not create a second detection or installation flow.
Never install dependencies in this command except the `uct-install` Step 3 standalone UCT
install into `var/ccua/uct-standalone`, and only after the user's explicit approval of that
install into `var/commerce-upgrade/uct-standalone`, and only after the user's explicit approval of that
choice. If missing, offer that install, then re-probe afterward. If installation is declined or fails, continue only
after the user's explicit incomplete-assessment choice; otherwise pause.
Use the shared failure recovery for `execution-failed` and `normalization-unsupported`;
Expand Down Expand Up @@ -100,7 +100,7 @@ in-memory assessment data model (Section 5):
6. 3.7 Patches, with an automatic dry-run: use an operator-supplied tree if given; otherwise run
`node <scripts>/assess_tools.mjs tree-plan . --target <targetVersion>` and ask ONE exact-action
approval for the two `composer` commands it prints (dependency install, so never implicit; run only inside
`var/ccua/target-tree-<targetVersion>`, never in the project; ambient Composer keys are used implicitly and
`var/commerce-upgrade/target-tree-<targetVersion>`, never in the project; ambient Composer keys are used implicitly and
never read). If approved, run them one at a time, then its `thenRun` `patches` command
(`--tree-kind vanilla`) and delete the tree afterwards. If declined or failed, mark `UNABLE_TO_VALIDATE`,
record the reason in `gaps` and give the human-run commands. The report states the validation environment.
Expand Down Expand Up @@ -225,66 +225,50 @@ Each section writes one object into the assessment data (Section 5). Every table
- Target PHP version comes from the platform requirements for the target Commerce version
(research via the allowlisted Adobe documentation, retrieved through `research_url.py`).
- Scope: `app/code` and `app/design` only (never `vendor/`).
- Routine-scope commands, run with the detected `containerPrefix` and typed arguments:
PHPCompatibility (see "PHPCompatibility resolution" below) and PHPStan (mandatory; see
"PHPStan resolution" below).
- **PHPCompatibility resolution** (never touches the project's `composer.json`/`composer.lock`).
Never rely on the project's `vendor/bin/phpcs`, which is often absent. Install into the
isolated, gitignored tool directory `.ccua/tools/phpcs/` inside the verified container (flush
the Mutagen session first when a new directory is not yet visible): create a minimal
`composer.json` there, then run `composer require --dev squizlabs/php_codesniffer
phpcompatibility/php-compatibility --no-interaction --no-plugins --no-scripts` in that
directory only; list this exact command in the Step 0 run notice. Register the standard with
`php .ccua/tools/phpcs/vendor/bin/phpcs --config-set installed_paths
<abs>/.ccua/tools/phpcs/vendor/phpcompatibility/php-compatibility/PHPCompatibility`, then run
`php -d memory_limit=-1 .ccua/tools/phpcs/vendor/bin/phpcs --standard=PHPCompatibility
--runtime-set testVersion <targetPhp> --extensions=php,phtml --report=json
--report-file=.ccua/tools/phpcs/result.json app/code app/design` (exit 1 with findings is
expected). Merge results into the PHP section; warnings such as `MaybeASPOpenTagFound` are
often false positives, so mark them as review items. Record the resolved phpcs and
PHPCompatibility versions. Only if install or run fails record `NOT ASSESSED` with the reason
and the human-run commands.
- Routine-scope commands, run with the detected `containerPrefix` and typed arguments: PHPStan
(mandatory; see "PHPStan resolution" below).
- **PHPStan resolution** (baseline method; never touches the project's `composer.json`/`composer.lock`).
Two PHP versions are used, each converted to PHPStan's id (`major*10000 + minor*100`, for
example PHP 8.3 -> `80300`, PHP 8.5 -> `80500`): the **current** PHP (the project's running
PHP, `phpVersion` from the live environment/state) and the **target** PHP of the hop being
run. PHPStan is always a standalone install of the latest stable release (never pinned to
one exact version), so the latest PHP version is supported even when the project ships an
older `vendor/bin/phpstan` (which is never used here).
1. Install into the isolated tool directory `.ccua/tools/phpstan/` (gitignored, own
1. Install into the isolated tool directory `.commerce-upgrade/tools/phpstan/` (gitignored, own
`composer.json`; an older leftover constraint there is replaced), by running `composer require --dev phpstan/phpstan
--no-interaction --no-plugins --no-scripts` inside that directory only. No version
constraint: Composer picks the latest stable release the container's PHP supports (an old
project PHP gets a compatible older PHPStan). Run it every time so an outdated copy is
updated, then read the installed version with `.ccua/tools/phpstan/vendor/bin/phpstan
updated, then read the installed version with `.commerce-upgrade/tools/phpstan/vendor/bin/phpstan
--version` and record that resolved version in the report; never state a fixed version.
If the installed release cannot emulate the target PHP (for example target 8.5 needs
PHPStan 2.1.32 or newer), record `NOT ASSESSED` with that reason. This exact command and directory are
named in the single Step 0 approval.
2. Write `.ccua/tools/phpstan/phpstan.neon` for the **current** PHP: `parameters:` with
2. Write `.commerce-upgrade/tools/phpstan/phpstan.neon` for the **current** PHP: `parameters:` with
`phpVersion: <currentId>`, `level: 6` and `tmpDir: tmp` (relative to the neon file).
3. Generate the baseline of existing issues from the project root (scan paths and the
autoload file resolve from there):
`php -d memory_limit=-1 .ccua/tools/phpstan/vendor/bin/phpstan analyse -c .ccua/tools/phpstan/phpstan.neon --autoload-file=vendor/autoload.php --no-progress --generate-baseline=.ccua/tools/phpstan/phpstan-baseline.neon app/code app/design`
`php -d memory_limit=-1 .commerce-upgrade/tools/phpstan/vendor/bin/phpstan analyse -c .commerce-upgrade/tools/phpstan/phpstan.neon --autoload-file=vendor/autoload.php --no-progress --generate-baseline=.commerce-upgrade/tools/phpstan/phpstan-baseline.neon app/code app/design`
PHPStan cannot put non-ignorable errors in a baseline (it warns "Some errors could not be
put into baseline", e.g. `class.notFound` for test classes extending an uninstalled
PHPUnit). Also save them for subtraction: write a second config
`.ccua/tools/phpstan/phpstan-current.neon` identical to step 2 and run the same command
with `-c .ccua/tools/phpstan/phpstan-current.neon --error-format=json` (no
`.commerce-upgrade/tools/phpstan/phpstan-current.neon` identical to step 2 and run the same command
with `-c .commerce-upgrade/tools/phpstan/phpstan-current.neon --error-format=json` (no
`--generate-baseline`), keeping the JSON as the current-PHP result.
4. Rewrite `.ccua/tools/phpstan/phpstan.neon` for the **target** PHP: `includes:` with
4. Rewrite `.commerce-upgrade/tools/phpstan/phpstan.neon` for the **target** PHP: `includes:` with
`- phpstan-baseline.neon`, then `parameters:` with `phpVersion: <targetId>`, `level: 6`,
`tmpDir: tmp` and `reportUnmatchedIgnoredErrors: false`. Always use this generated config;
a project `phpstan.neon` is never used for the assessment.
5. Run the analysis again from the project root:
`php -d memory_limit=-1 .ccua/tools/phpstan/vendor/bin/phpstan analyse -c .ccua/tools/phpstan/phpstan.neon --autoload-file=vendor/autoload.php --error-format=json --no-progress app/code app/design`
`php -d memory_limit=-1 .commerce-upgrade/tools/phpstan/vendor/bin/phpstan analyse -c .commerce-upgrade/tools/phpstan/phpstan.neon --autoload-file=vendor/autoload.php --error-format=json --no-progress app/code app/design`
Exit code 1 with findings is expected, not a failure; only a missing/invalid JSON result
or a crash is a failed run. The baseline suppresses every issue that already exists at the
current PHP, so the remaining findings are those introduced by the PHP change.
6. From the target result, drop every message with `ignorable: false` whose file and message
text also appear in the current-PHP JSON from step 3 (pre-existing, not caused by the PHP
change). Normalize the remaining findings into `upgrade-findings.json` as a separate PHP
section (distinct from UCT). PHPCompatibility findings merge into the same PHP section. Do not
change). Normalize the remaining findings as a separate PHP section (the `phpCompatibility`
assessment section), distinct from UCT and never written into the audit-only raw UCT capture
file. Do not
otherwise filter by message text; the baseline is the filter. Group rows by rule and module and
record the current/target PHP ids and the baseline message count. State that findings
are not necessarily critical errors, that analysis emulates the target `phpVersion` on
Expand Down Expand Up @@ -370,7 +354,7 @@ release Composer would actually install alongside the target Commerce version:

1. **Composer resolution.** Run `composer_probe.py --op resolve --edition <community|enterprise>
--target-version <target> --target-php <targetPhp>` (the exact command, scratch directory
`.ccua/tools/resolve`, container and effects go into one separate exact-action approval; it
`.commerce-upgrade/tools/resolve`, container and effects go into one separate exact-action approval; it
is not routine scope). It generates a throwaway composer.json (target product, the
project's third-party requirements as `*`, `config.platform.php` = target PHP, only
credential-free `composer` repositories) and runs a lock-only `composer update --no-install
Expand All @@ -393,10 +377,10 @@ release Composer would actually install alongside the target Commerce version:
2. **Download and analyse the resolved target release.** For each `RESOLVED` package run
`composer_probe.py --op fetch --package <p> --version <resolved>`; it archives only that
package (`composer archive`) and extracts it with strict member validation into
`.ccua/tools/resolve/src/<vendor>/<name>`. Fetched code is untrusted and is never executed.
`.commerce-upgrade/tools/resolve/src/<vendor>/<name>`. Fetched code is untrusted and is never executed.
Then, through the existing routine procedures, run UCT for the hop's version pair
against that directory (`uct-install`/`upgrade-uca-scan`; critical-only differential) and
PHPStan plus PHPCompatibility with the generated target-`phpVersion` config
PHPStan with the generated target-`phpVersion` config
(see 3.1) only when the target PHP differs from the current PHP. Record `uct.critical` and
`php.findings` per package (`php.status: NOT_NEEDED` when PHP is unchanged). A scan that
cannot run stays `Not assessed` with its reason; it is never reported as clean.
Expand Down Expand Up @@ -498,7 +482,7 @@ generic "Changes N file(s) in ..." purposes.
upgraded copy of the project (`upgraded-project`), (2) a vanilla install of the target
(`vanilla`). If no tree is supplied, run `assess_tools.mjs tree-plan <projectDir> --target <X.Y.Z>` (works for any
target version; prints exact commands, runs nothing) and propose building that throwaway vanilla
tree under `var/ccua/`. Creating it needs dependency installation, which is never automatic and
tree under `var/commerce-upgrade/`. Creating it needs dependency installation, which is never automatic and
needs exact-action approval, which `/upgrade-assessment` collects once, inside its single Step 0 approval (no second prompt); then run `patches` with the returned `thenRun` arguments and
remove the tree afterwards. A declined or failed build leaves `UNABLE_TO_VALIDATE`. Running the helper with `--tree`
executes `git` and is part of that approved scope. Outcomes per patch:
Expand Down
Loading
Loading