Skip to content

chore: absorb orchestration into packages/orchestration - #14054

Merged
ChiragAgg5k merged 309 commits into
mainfrom
chore/absorb-orchestration
Oct 1, 2026
Merged

ChiragAgg5k merged 309 commits into
mainfrom
chore/absorb-orchestration

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Moves utopia-php/orchestration into packages/orchestration. Wave 5 of #13828, following the playbook in rfc/monorepo.md. orchestration is a standalone repository that was never in utopia-php/monorepo, so it gets the full playbook and needs no retire PR. The import is the mirror head f453ea7, the 0.20.0 release.

Appwrite itself does not use Utopia\Orchestration: no file under app/, src/ or tests/ references it, and composer.lock does not contain it. Its consumers are open-runtimes/executor, and appwrite-labs/edge through the executor. They keep requiring utopia-php/orchestration from Packagist, which the split now feeds from here. So there is no require line to remove and no version gap to close; the root gains only the autoload, autoload-dev and replace entries every package has.

Important

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

Commits

Commit What
Add 'packages/orchestration/' from commit 'f453ea7…' Subtree import from the mirror main with full history
chore(orchestration): mirror plumbing mirror.yml replaces test.yml, linter.yml, codeql-analysis.yml; pint.json, psalm.xml, Dockerfile and composer.lock removed; hoisted QA stripped from composer.json; README banner; CONTRIBUTING.md now points at appwrite/appwrite
refactor: load orchestration from packages/ Root wiring, step A shape, QA config, RFC baseline line
test(orchestration): wait on the daemon instead of fixed sleeps testRunRemove and testUsageStats poll for the state they assert instead of sleeping 1 and 2 seconds (below)
docs(orchestration): strip trailing whitespace from the README 8 blank lines in its code samples, so git diff --check is clean over the branch

What changed

Area Change
Root composer.json Autoload, autoload-dev and replace entries added. No require line to remove: Appwrite never required it
Hoisting Nothing: its only requirement, utopia-php/console 0.2.*, is already in packages/console (still on the bare Utopia\ prefix, see BARE). ext-curl is used by DockerAPI but not declared; the root already requires it
composer.lock Content hash only
src/ src/Orchestration/* moved up to src/. Byte-identical to 0.20.0 otherwise: Pint makes no change and Rector skips its 10 rules that would rewrite src
Unit tier tests/ OrchestrationTest (parseCommandString()), under Utopia\Orchestration\Tests\. It used to run once per adapter inside the Docker suites, though it never touches Docker
tests/E2E/ Base, DockerAPITest, DockerCLITest and the Resources/ fixtures, under Utopia\Orchestration\Tests\E2E\. 14 @depends annotations become #[Depends] attributes: PHPUnit 12 ignores the annotations, which upstream's PHPUnit 9 read, so a failed testCreateContainer would no longer skip the tests that use its container
E2E on the host Upstream ran PHPUnit inside a tests compose container with the host's Docker socket mounted, and passed HOST_DIR so the containers it started could bind-mount the fixtures by their host path. The tier now runs on the host like every other package, so the fixture path is __DIR__ . '/Resources' and HOST_DIR and the hard-coded /usr/src/code are gone. testUsageStats counted every running container on the daemon and expected exactly one (the old test container); it now counts against what was running before it started, since a host daemon may run other containers
Fixed sleeps testRunRemove slept 1 second before asserting an auto-removed container was gone, and testUsageStats slept 2 seconds before running screen in containers that apk add it on start. Both raced a slow daemon: a still-exiting TestContainerRM failed testRunRemove and then skewed testUsageStats' container count. They now poll (30 and 120 seconds at most) for the state they assert
docker-compose.yml Removed. Its only service was the in-container runner above, so the e2e tier needs nothing but the host's Docker daemon (/var/run/docker.sock, which DockerAPI hard-codes, and the docker CLI for DockerCLI). The Dockerfile it built went with the plumbing commit
composer.json scripts test runs the unit suite; test:e2e runs the e2e suite with Composer\Config::disableProcessTimeout, because the suite (fixed sleeps, image pulls, CPU stress containers) runs past Composer's 300-second default
phpunit.xml PHPUnit 12; unit and e2e suites
phpstan.neon Standalone, level max over src and tests (excluding the Resources/ fixtures), with phpstan-baseline.neon holding 146 findings: 140 in src, mostly offset access, arithmetic and arguments on the decoded mixed Docker Engine API responses in DockerAPI (121) and array|string values from parsed CLI output in DockerCLI (18); 6 in the e2e tests. Upstream analysed level 6 under PHPStan 1. Added to the RFC phase 8 list
rector.php Standalone; skips the 10 rules that would rewrite src (constructor promotion, typed properties from constructor and from assigns, closure and arrow-fn types, closure to arrow fn, private method array return types, str_contains, catch variables), scoped to src only

Validation

Check Result
bin/monorepo validate all packages valid
bin/monorepo check orchestration Rector, Pint, PHPStan level max (with baseline) pass
bin/monorepo test orchestration unit 1 test / 4 assertions OK
bin/monorepo test orchestration e2e At df61233: 34 tests / 194 assertions OK in 2:35. At 97558b6 (polling), with the host at load 30–60: all 17 DockerAPITest tests pass in both runs; DockerCLITest errors only where DockerCLI::run()'s fixed 30-second docker run timeout (in src, unchanged) expired. CI's Packages / orchestration at 75fca16 (PHP 8.5.11, the runner's own daemon): check passes, unit 1 test / 4 assertions OK, e2e 34 tests / 198 assertions OK in 1:36
vendor/bin/phpunit --testsuite packages in appwrite/appwrite:2.3.0 9030 tests / 25885 assertions OK, 17 skipped; 2 warnings and 2 deprecations, none in orchestration (http's FPM Response and RouteTest, nats' lcg_value())
… --testsuite packages --filter 'Utopia\\Orchestration\\Tests' in appwrite/appwrite:2.3.0 1 test / 4 assertions OK
Utopia\Orchestration\Orchestration resolves to packages/orchestration/src/Orchestration.php; no vendor/utopia-php/orchestration
composer validate --no-check-publish valid
composer lint passes
bin/monorepo split orchestration --dry-run 75fca16, fast-forward of the mirror head f453ea7 (+4 commits), tree identical to packages/orchestration
git diff --check clean

The e2e tier ran in composer:2 (PHP 8.5.10) against an isolated docker:dind daemon (Docker 29.8.2, no other containers), with its socket mounted at /var/run/docker.sock and the worktree mounted at its host path. That reproduces a CI runner: DockerAPI hard-codes the socket path, and the fixtures are bind-mounted by host path.

There is no Appwrite-side check beyond the above: no Appwrite file uses the package.

Mirror state

Ruleset None existed. absorb created the main ruleset (id 24307503): deletion and non-fast-forward blocked, PRs required with 0 approvals, the split app (4016286) the only always-bypass actor
Classic branch protection on main Still present: 1 required approval, enforce_admins on. Rulesets cannot override it, so Split will be refused until it is removed, as was done for balancer in #13886. Not removed here; it needs a maintainer to drop it before merge

After merge

Step
Remove the classic protection Before merge, so the first Split push lands (see above)
Merge with a merge commit A squash orphans the package from its mirror
Confirm Split The Split run for orchestration is green and the mirror fast-forwards from f453ea7
Triage mirror issues and PRs Port what is still wanted here, then close each with a pointer (see below)
Monorepo PRs None: orchestration never lived in utopia-php/monorepo

Open on utopia-php/orchestration:

# Type Title Author
utopia-php/orchestration#68 PR Add Docker mount value object @TorstenDittmann
utopia-php/orchestration#63 PR feat: v2 containers @loks0n
utopia-php/orchestration#37 PR (draft) Escape commands passed to run and execute @stnguyen90
utopia-php/orchestration#35 Issue [Feature] - Adding Docker Swarm adapter @byawitz
utopia-php/orchestration#33 PR Feat: Migrate from travis to Github actions workflow @sahilsaha7773
utopia-php/orchestration#25 PR feat: add analyzer @byt3h3ad

PineappleIOnic and others added 30 commits September 17, 2021 16:20
+ Added a detach parameter to the execute() function
+ Added tests for detach parameter
Added `CONTRIBUTING.md` file
byawitz and others added 21 commits October 19, 2025 16:36
- replace assertEquals with assertSame
…ommands

Refactor DockerCLI for console 0.2 commands
…5897b6988db813'

git-subtree-dir: packages/orchestration
git-subtree-mainline: 514e2ac
git-subtree-split: f453ea7
@ChiragAgg5k ChiragAgg5k added the absorb History-preserving package absorption; merge commit required label Oct 1, 2026
@ghost

ghost commented Oct 1, 2026 •

Copy link
Copy Markdown

🔵 Tier A · Mergeable after minor fixes

The existing readiness-timeout finding remains partially unresolved: DockerAPI's final exec inspection request does not receive the timeout and can still block indefinitely.

Imports Utopia Orchestration into packages/orchestration and adds root Composer wiring, mirror plumbing, and package-local QA configuration. Separates Docker-independent unit tests from host-based Docker E2E tests and replaces two fixed waits with polling. The latest commits correct the README's execute examples and add a timeout to readiness probes.

Latest changes: Corrects execute examples and output documentation in the README, and passes a 10-second timeout to the screen readiness probe.

Verdict New comments Fixed Still open
✅ Approved 0 1 1
Fix with agent prompt
### Issue 1
packages/orchestration/tests/E2E/Base.php:633-642
**Bound each readiness probe as well as the polling loop**

The probe calls `execute()` with its default unlimited timeout, so a stalled Docker exec can block inside the callback indefinitely; `waitUntil()` cannot enforce its 120-second deadline until that call returns. Please give the readiness probe finite request/command timeouts so a slow or unresponsive daemon produces a bounded test failure.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
📂 Walkthrough · 9
File Change
composer.json, composer.lock Adds orchestration production/test autoload and replacement wiring; refreshes the lock hash.
packages/orchestration/.github/workflows/mirror.yml, packages/orchestration/.gitignore Adds mirror redirection and ignores local dependencies and generated artifacts.
packages/orchestration/README.md, packages/orchestration/CONTRIBUTING.md, packages/orchestration/CODE_OF_CONDUCT.md, packages/orchestration/LICENSE Imports package documentation and license, redirects contributions, and corrects execute examples and output documentation.
packages/orchestration/composer.json, packages/orchestration/phpunit.xml Defines standalone dependencies and separate unit and E2E commands and suites.
packages/orchestration/phpstan.neon, packages/orchestration/phpstan-baseline.neon, packages/orchestration/rector.php Adds package-local analysis, baseline, and source-preserving Rector exclusions.
packages/orchestration/src/* Imports the orchestration facade, Docker adapters, models, and exceptions into flat source paths.
packages/orchestration/tests/OrchestrationTest.php Places command parsing coverage in the Docker-independent unit suite.
packages/orchestration/tests/E2E/* Imports adapter suites and fixtures, updates dependencies and host paths, and adds polling with a timeout argument on readiness probes.
rfc/monorepo.md Records orchestration's static-analysis baseline for later reduction.
⏳ Still open from earlier reviews · 1
✅ Fixed since the last review · 1
  • Update the execute examples to match the published signature · packages/orchestration/README.md:43

Reviewed the commits since 795032d · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · See the inline comments. Summary

Comment thread packages/orchestration/README.md Resolved
Comment on lines +633 to +642
$installed = self::waitUntil(function () use ($containerId): bool {
$output = '';
try {
static::getOrchestration()->execute($containerId, ['which', 'screen'], $output);
} catch (\Exception) {
return false;
}

return true;
}, 120);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bound each readiness probe as well as the polling loop

The probe calls execute() with its default unlimited timeout, so a stalled Docker exec can block inside the callback indefinitely; waitUntil() cannot enforce its 120-second deadline until that call returns. Please give the readiness probe finite request/command timeouts so a slow or unresponsive daemon produces a bounded test failure.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/orchestration/tests/E2E/Base.php
Line: 633-642

Comment:
**Bound each readiness probe as well as the polling loop**

The probe calls `execute()` with its default unlimited timeout, so a stalled Docker exec can block inside the callback indefinitely; `waitUntil()` cannot enforce its 120-second deadline until that call returns. Please give the readiness probe finite request/command timeouts so a slow or unresponsive daemon produces a bounded test failure.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

🟡 Minor · testing · Reply if this doesn't apply.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in the latest push: the which screen probe passes timeout: 10, so a stalled exec fails that probe after 10 seconds, and waitUntil() can reach its 120-second deadline.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The probe now passes timeout: 10 in Base.php:638, but one request remains unbounded: DockerAPI.php:617 inspects the exec status without forwarding $timeout, so it still uses the default -1.

Please pass $timeout to that final call() too. Otherwise, a stall during inspection can still prevent waitUntil() from reaching its deadline.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

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

Metric Before After Change
🚀 Requests/sec 189.19 188.46 ⚪ -0.4%
⏱️ Latency P50 92.17 ms 91.27 ms ⚪ -1%
⏱️ Latency P95 210.81 ms 214.95 ms ⚪ +2%
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 91.27 214.95 11,856 188.46 +4.14
Account 177.17 341.52 624 10.35 +22.69
TablesDB 86.92 162.32 6,448 105.01 -9.2
Storage 85.32 180.17 3,120 52.52 -2.25
Functions 134.15 268.1 1,664 28.58 +24.75

Top API waits (after)

API request Max wait (ms)
functions.variables.update 571.13
functions.delete 492.31
account.name.update 487.04
account.prefs.update 425.12
functions.variables.create 410.04

…ss probe

The README showed execute() taking separate stdout and stderr strings,
but its fourth parameter is the environment array, so both examples
threw a TypeError. They now pass the single output string, then the
environment and timeout, and the parameter list says what each adapter
writes into it.

The screen readiness probe called execute() with no timeout, so a
stalled exec could hold waitUntil() past its 120 second deadline
indefinitely. Each probe is now capped at 10 seconds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · Looks good to merge. Summary

@ChiragAgg5k
ChiragAgg5k merged commit 0705142 into main Oct 1, 2026
58 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.