Skip to content

chore: absorb cli into packages/cli - #13928

Merged
ChiragAgg5k merged 45 commits into
mainfrom
chore/absorb-cli
Sep 28, 2026
Merged

ChiragAgg5k merged 45 commits into
mainfrom
chore/absorb-cli

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

Summary

Moves utopia-php/cli into packages/cli so Appwrite loads it directly. Wave 3 of #13828, following the playbook in rfc/monorepo.md.

Stacked on #13921 (servers, which cli requires). Merge #13921 first; GitHub then retargets this PR to main. If chore/absorb-servers moves, it is merged in (never rebased).

Commit What
Add 'packages/cli/' from commit '39d590ff…' Subtree import from the mirror with full history. Mirror head is the 0.24.4 tag Appwrite already locks, and its tree matches packages/cli in utopia-php/monorepo, so no version gap
chore(cli): mirror plumbing mirror.yml calls this repository's mirror-redirect.yml; README banner points here; psalm.xml and phpcs.xml removed
refactor: load cli from packages/ Root autoload + replace entries, utopia-php/cli dropped from require and the lock, step A shape, standalone phpstan.neon / rector.php, baseline, RFC phase 8 line

Step A

Change Detail
src/CLI/* → src/ src/ is byte-identical to 0.24.4 apart from the move and Pint formatting (fn ( spacing, two lines)
tests/CLI/* → tests/ Namespace Utopia\Tests → Utopia\CLI\Tests, matching the new autoload-dev
Removed tests/input.txt Piped to PHPUnit on stdin by the old test script; no test reads stdin any more. Script is now plain phpunit
require-dev Dropped utopia-php/console 0.0.* (unused); swoole/ide-helper 4.8.8 → 6.*, matching the root, for the Swoole adapter's analysis
phpunit.xml PHPUnit 12 shape used by the other packages (tests, tests/E2E excluded). No test needs Swoole or coroutines, so there is no tests/E2E
phpstan.neon Standalone, level max over src + tests (the mirror had only Psalm)
rector.php PHP sets + type declarations; skips ClassPropertyAssignToConstructorPromotionRector and ReadOnlyPropertyRector. Rector makes no changes
phpstan-baseline.neon 71 findings: 39 in src (unvalued array types and mixed offsets in CLI, untyped adapter callbacks), 32 in tests (nullable ?Task fixture in TaskTest). Added to the RFC phase 8 list

Nothing to hoist: the package requires only php and utopia-php/servers (in packages/ via #13921). app/cli.php is the only direct Utopia\CLI user, but every task and bin/* script runs through it; the still-vendored platform requires utopia-php/cli, and replace now satisfies it.

Validation

Check Result
bin/monorepo validate all packages valid
bin/monorepo check cli Rector, Pint, PHPStan level max (with baseline) pass
bin/monorepo test cli 27 tests / 43 assertions
Root vendor/bin/phpunit packages/cli/tests 27 tests / 43 assertions (the full packages suite with --filter needs igbinary, missing on the host)
Autoload Utopia\CLI\CLI resolves to packages/cli/src/CLI.php; vendor/utopia-php/cli gone
Host PHPStan app/cli.php and Tasks/{Doctor,Maintenance,Migrate,Schedule,Interval}.php: no errors
composer update --lock lock diff vs chore/absorb-servers drops only utopia-php/cli (plus content hash)
composer validate --no-check-publish valid (only the existing utopia-php/platform exact-constraint warning)
bin/monorepo split cli --dry-run fdd3f77b, fast-forwards from mirror head 39d590ff, tree identical to packages/cli
composer lint, git diff --check clean

Merge and follow-up

Merge after #13921, with a merge commit. A squash drops the git-subtree-* annotation and orphans the package from its mirror.

utopia-php/cli already has the main ruleset (id 17499608: deletion, non-fast-forward, pull request) with the split app (4016286) as an always-bypass actor, so the absorb ran with --skip-ruleset. There is no classic branch protection on main.

After merge
Confirm Split pushes to utopia-php/cli
Retire remove packages/cli from utopia-php/monorepo (no open PR there touches it)
Triage mirror PRs utopia-php/cli#34 and #32 (2023, style fixes for #33/#31), #29 (GitHub Actions migration, superseded by this repo's CI), #26 (trait example)
Triage mirror issues utopia-php/cli#33 (ternary to null coalescing), #31 (file permissions)

🤖 Generated with Claude Code

loks0n and others added 30 commits October 20, 2025 22:05
Adapt to breaking changes in utopia-php/di 0.3 which removes
the Dependency class in favor of Container::set(string $id,
callable $factory, array $dependencies).
chore: update utopia-php/servers from 0.2 to 0.3
CLI args arrive as strings via getopt. When a param's validator is
`Boolean` (loose mode), strings like "true"/"false"/"1"/"0" pass
validation but remain strings. If the action callback declares a
`bool` parameter, PHP's implicit string-to-bool cast turns any
non-empty string except "0" into `true` -- so `--commit=false`
silently becomes `true` and the action runs as if `--commit=true`
had been passed.

Validators in utopia-php are pure (validate only, never mutate), so
the coercion has to happen here at the dispatch boundary in
`CLI::getParams()`. After validation, if the param's validator
(unwrapping `Nullable`) is `Boolean` and the value is still a string,
we run it through `filter_var(..., FILTER_VALIDATE_BOOLEAN)` before
handing it to the callback.

Bool defaults and non-string inputs pass through untouched, so this
is a safe, additive change for existing callers.
Optional params with `--flag=` (or default `''`) bypass `validate()`
entirely, so they reach `coerce()` un-validated. The previous version
ran them through `filter_var($value, FILTER_VALIDATE_BOOLEAN)`, which
silently returns `false` for empty strings -- a behaviour change for
callers (e.g. Cloud's `Patch.php`) that use `''` as a three-state
"not set" sentinel before resolving to `null`.

Now coerce returns early for empty strings, and uses
`FILTER_NULL_ON_FAILURE` for everything else so any unrecognised
input falls back to the original value rather than getting
silently downgraded to `false`.

Spotted by Greptile review on PR #52.
One pinned toolchain (pint, phpstan, rector) in the root composer.json,
one canonical pint.json for every package, run via bin/monorepo check
(--fix to apply) in CI alongside tests. phpstan.neon and rector.php
stay per-package as they encode per-library decisions.

Applies the canonical style to cli, platform and queue, the Stringable
interface rector wants on client's PSR-7 classes, and drops the
now-pointless nullsafe operators phpstan flags in http's RouterTest.

Co-Authored-By: Claude Fable 5 <[email protected]>
Packages no longer declare pint/phpstan/rector dev dependencies, QA
scripts, or QA workflows — bin/monorepo check is the single gate,
running before merge. Mirror CI keeps only test workflows. Lock files
regenerated to match (and unpinned from stale dependency snapshots).

Co-Authored-By: Claude Fable 5 <[email protected]>
bin/monorepo absorb runs it: import with history, strip hoisted QA,
write a mirror.yml that closes mirror PRs with a redirect to the
monorepo, banner the README, and create the mirror ruleset (PR-only,
split app bypassed). Applied to all five packages; manual steps
documented in the README.

Co-Authored-By: Claude Fable 5 <[email protected]>
One phpunit (^12) pinned in the root composer.json; packages no longer
declare it. Package test scripts call `phpunit`, resolved from the
root vendor/bin which bin/monorepo puts on PATH; mirror workflows get
it via setup-php's tools input.

Migrates the phpunit 9 era leftovers: cli and platform phpunit.xml
schemas, cli's @dataProvider annotation to an attribute. cli's mirror
test matrix moves to 8.3-8.5 (phpunit 12 needs >=8.3). bin/monorepo
absorb now strips phpunit and rewrites test scripts for incoming
libraries.

Co-authored-by: Claude Fable 5 <[email protected]>
Intra-utopia requires move from X.Y.* pins to ^X.Y across cli, http,
platform, queue and servers (client and pools already used carets).
For 0.x siblings the range is equivalent today, but the style is
uniform and minors flow through automatically once packages reach 1.0.
servers' broad 'validators 0.*' narrows to ^0.2, matching the released
line.

Co-authored-by: Claude Fable 5 <[email protected]>
Every uses: ref is upgraded to its latest major (checkout v6,
create-github-app-token v3) and pinned to the tag's commit SHA in
ratchet's format. The validate job now runs ratchet lint over root and
package workflows, so unpinned refs fail CI. Four leftover QA-only
codeql workflows (cli, pools, telemetry, validators) are deleted — they
invoke the composer check script that QA hoisting removed.

Co-Authored-By: Claude Fable 5 <[email protected]>
- Drop the 17 per-package mirror CI workflows: they were inert in the monorepo
  and only re-tested, on the mirror, code the monorepo's own matrix already
  gated pre-merge. absorb now strips all incoming workflows and writes only
  mirror.yml; the ratchet lint over packages/* (no uses: left to pin) goes too.
- Make absorb's mirror ruleset idempotent: update whatever branch ruleset
  already exists in place instead of skipping on a name clash (the gap that left
  auth's mirror without the split-app bypass).
- Remove the standalone `import` command — unused, and it left a package without
  mirror.yml/banner/ruleset. import_package() stays as absorb's helper.
- Trim absorbing.md/creating.md/README to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Hoist PHPStan level 5 to the monorepo root
build: hoist baseline rector + phpstan configs to the root
loks0n and others added 7 commits July 6, 2026 01:10
docs: enforce documentation style with Vale
docs: centralize CODE_OF_CONDUCT and CONTRIBUTING at the monorepo root
chore: stop committing package lock files
…bc08'

git-subtree-dir: packages/cli
git-subtree-mainline: a2bec32
git-subtree-split: 39d590f
@ChiragAgg5k ChiragAgg5k added the absorb History-preserving package absorption; merge commit required label Sep 26, 2026
@greptile-apps

greptile-apps Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High risk] Moves CLI package from external dependency into monorepo.

The PR appears safe to merge based on the changes since the previous review and the current state of the prior threads.

Summary

This PR moves the CLI package into packages/cli, switches root Composer autoloading and replacement to the local package, and adds package-level test and analysis configuration. The CLI files have not changed since the previous review.

Reviews (9) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

Comment thread packages/cli/tests/CLITest.php Resolved
Comment thread packages/cli/README.md Resolved
Comment thread packages/cli/README.md Resolved
Comment thread packages/cli/README.md Resolved
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → chore/absorb-cli (after).

Metric Before After Change
🚀 Requests/sec 191.65 184.48 ⚪ -3.7%
⏱️ Latency P50 90.43 ms 94.22 ms ⚪ +4.2%
⏱️ Latency P95 210.64 ms 218.24 ms ⚪ +3.6%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 94.22 218.24 11,400 184.48 +7.6
Account 182.71 336.18 600 10.19 +8.31
TablesDB 90.98 175.72 6,200 102.2 +11.62
Storage 87.55 194.66 3,000 51.2 +16.01
Functions 134.58 259.74 1,600 28 -1.77

Top API waits (after)

API request Max wait (ms)
account.name.update 553.64
functions.variables.update 482.38
functions.create 419.43
functions.variables.create 388.63
account.prefs.update 383.47

@ChiragAgg5k
ChiragAgg5k changed the base branch from chore/absorb-servers to main September 27, 2026 12:19
Comment thread packages/cli/tests/TaskTest.php Resolved
# Conflicts:
#	LICENSE.md
#	composer.lock
#	packages/cli/LICENSE.md
#	packages/cli/src/Adapter.php
#	packages/cli/src/Adapters/Generic.php
#	packages/cli/src/Adapters/Swoole.php
#	packages/cli/src/CLI.php
#	packages/cli/src/Task.php
#	packages/cli/tests/TaskTest.php
#	packages/console/LICENSE
Tests for packages/cli run in appwrite/appwrite's CI now, so the utopia-php/monorepo badge no longer reflects them; other absorbed packages keep only the downloads and Discord badges.
@ChiragAgg5k
ChiragAgg5k merged commit 1b1a206 into main Sep 28, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

absorb History-preserving package absorption; merge commit required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants