Skip to content

chore: absorb di into packages/di - #13885

Merged
ChiragAgg5k merged 83 commits into
mainfrom
chore/absorb-di
Sep 25, 2026
Merged

ChiragAgg5k merged 83 commits into
mainfrom
chore/absorb-di

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

Summary

This moves utopia-php/di into packages/di, so Appwrite loads it directly. It's wave 1 of #13828, follows the playbook in rfc/monorepo.md, and comes in three commits:

  1. Add 'packages/di/' from commit 'a72d8ee1…': subtree import from the mirror with full history. The mirror head is the 0.3.6 commit Appwrite already locks, so the dependency graph doesn't change.
  2. chore(di): mirror plumbing: mirror.yml now points here and the README banner is refreshed. There were no banned files to remove.
  3. refactor: load di from packages/:
    • Adds the root autoload and replace entries and removes the package from the lock. Appwrite never required it directly. It came in through utopia-php/http, utopia-php/queue and utopia-php/servers, and replace now satisfies all three.
    • Hoists psr/container: ^2.0 into the root require, the same constraint the package declares. The lock stays at 2.0.2.
    • Step A of the standard shape, including the prefix change the RFC asks for:
      • The main autoload declared the bare Utopia\ prefix plus a stray Tests\E2E\ => tests/e2e (a directory that doesn't exist). It now declares only Utopia\DI\ → src/. This is safe because all three classes (Container, Exceptions\ContainerException, Exceptions\NotFoundException) already live under Utopia\DI\. di is now off the bare-Utopia\ list the RFC tracks.
      • src/DI/* moves up to src/.
      • Adds an autoload-dev entry for Utopia\DI\Tests\ → tests/, the namespace ContainerTest already declared. The suite has no services tier, so there is no tests/E2E.
      • phpunit.xml uses the standard unit suite with tests/E2E excluded.
    • phpstan.neon and rector.php used to include the monorepo root configs (../../), which validate rejects. Both are now standalone. PHPStan runs at level max over src and passes with no baseline. rector.php keeps its one skip (ThrowWithPreviousExceptionRector).
    • Drops the unused require-dev (phpbench/phpbench had no benchmarks, and swoole/ide-helper was only scanned by the old PHPStan config).
    • Pint formatting (empty class and constructor bodies, fn ( spacing).

Appwrite uses Utopia\DI\Container in 13 files (app/http.php, app/realtime.php, app/mqtt.php, app/init/resources.php, the worker, realtime and MQTT connection init, Tasks/Specs.php, Promises/Swoole.php, Realtime/Message/Dispatcher.php, SDK/Specification/Format.php, Mqtt/Handler.php). They now load it from packages/di/src.

Validation

  • bin/monorepo validate: all packages valid
  • bin/monorepo check di: Rector, Pint and PHPStan level max pass (no baseline)
  • bin/monorepo test di: unit 31 tests / 39 assertions. There is no e2e tier.
  • vendor/bin/phpunit --testsuite packages --filter 'Utopia\\DI': 31 tests / 39 assertions pass under the root autoloader
  • Utopia\DI\Container resolves to packages/di/src/Container.php from the root autoloader, and vendor/utopia-php/di is no longer installed
  • Root PHPStan on Tasks/Specs.php, Promises/Swoole.php, Realtime/Message/Dispatcher.php, SDK/Specification/Format.php, Mqtt/Handler.php, app/init/resources.php, app/init/worker/message.php: no errors
  • composer validate --no-check-publish: valid. The one warning is the existing utopia-php/platform exact pin.
  • composer update --lock: the lock diff removes only utopia-php/di (plus the content hash)
  • bin/monorepo split di --dry-run: 837bd827, which fast-forwards from the mirror head a72d8ee1
  • git diff --check, composer lint on the package sources

Merge and follow-up

Merge with a merge commit.

The utopia-php/di mirror already has the canonical main ruleset (id 17508424), with the split app as an always-bypass actor, so the absorb ran with --skip-ruleset.

After merge: confirm Split pushes to utopia-php/di. Then remove packages/di from utopia-php/monorepo. http, queue and servers there still require utopia-php/di from Packagist, and the mirror keeps serving that. The mirror has no open PRs, and neither does the monorepo for di.

🤖 Generated with Claude Code

ChiragAgg5k and others added 17 commits March 13, 2026 11:15
…and-readme

Improve set() defaults and refresh README examples
chore: add missing logo in readme
When calling set() to override an already-resolved dependency, the stale
cached value in $concrete was still returned by get(). Now set() clears
the cache entry so the new factory is used on the next get() call.
Fix set() not clearing cached instance on override
Strip hoisted QA tooling, add the mirror PR redirect, apply the
canonical style, and migrate the phpunit.xml schema.
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]>
build: hoist baseline rector + phpstan configs to the root
docs: enforce documentation style with Vale
docs: centralize CODE_OF_CONDUCT and CONTRIBUTING at the monorepo root
chore: stop committing package lock files
…2a9'

git-subtree-dir: packages/di
git-subtree-mainline: b866958
git-subtree-split: a72d8ee
@ChiragAgg5k ChiragAgg5k added the absorb History-preserving package absorption; merge commit required label Sep 24, 2026
@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge with no new blocking findings.

Fix All in Claude CodeFindings

  1. P2 Test locks in resolution path ▶
  2. P2 Conflicting contribution directions ▶
Fix with agent prompt
### Issue 1
packages/di/tests/ContainerTest.php:267-271
This test expects a child lookup to fail because the parent factory resolves dependencies through the parent container. That assertion mirrors the current implementation rather than an independently stated container contract. The repository requires tests to check intended observable behavior, not implementation details. Please test the intended child-scope behavior before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 2
packages/di/README.md:undefined-112
The new banner says development and pull requests belong in `appwrite/appwrite`, but this section still tells contributors to fork `utopia-php/monorepo` and submit a PR there. Contributors following this section may send DI changes to the former development repository. Please align the instructions with the banner.

---

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

Summary

The PR moves Utopia DI into packages/di, switches root Composer autoloading to the in-tree package, and removes the installed DI dependency from the lockfile.

  • The changes since the previous review do not modify the DI package or introduce a new finding.

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

Comment on lines +267 to +271
// Parent factory is resolved through parent->get(), which looks in parent's scope
// The child provides 'name' but parent resolves its own dependencies from its own container
// This should throw because 'name' is not in parent
$this->expectException(NotFoundExceptionInterface::class);
$child->get('greeter');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Test locks in resolution path

This test expects a child lookup to fail because the parent factory resolves dependencies through the parent container. That assertion mirrors the current implementation rather than an independently stated container contract. The repository requires tests to check intended observable behavior, not implementation details. Please test the intended child-scope behavior before merging.

Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/di/tests/ContainerTest.php
Line: 267-271

Comment:
**Test locks in resolution path**

This test expects a child lookup to fail because the parent factory resolves dependencies through the parent container. That assertion mirrors the current implementation rather than an independently stated container contract. The repository requires tests to check intended observable behavior, not implementation details. Please test the intended child-scope behavior before merging.

**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

---

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

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

Comment thread packages/di/README.md

Fork the [utopia-php monorepo](https://github.com/utopia-php/monorepo), create a feature branch, and send us a pull request.

You can refer to the [Contributing Guide](https://github.com/utopia-php/monorepo/blob/main/CONTRIBUTING.md) for more info.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Conflicting contribution directions

The new banner says development and pull requests belong in appwrite/appwrite, but this section still tells contributors to fork utopia-php/monorepo and submit a PR there. Contributors following this section may send DI changes to the former development repository. Please align the instructions with the banner.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/di/README.md
Line: 112

Comment:
**Conflicting contribution directions**

The new banner says development and pull requests belong in `appwrite/appwrite`, but this section still tells contributors to fork `utopia-php/monorepo` and submit a PR there. Contributors following this section may send DI changes to the former development repository. Please align the instructions with the banner.

---

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

Fix in Claude Code Fix in Codex

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

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

Metric Before After Change
🚀 Requests/sec 194.79 202.67 ⚪ +4%
⏱️ Latency P50 88.98 ms 86.11 ms ⚪ -3.2%
⏱️ Latency P95 211.37 ms 197.18 ms 🟢 -6.7%
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 86.11 197.18 12,540 202.67 -14.18
Account 161.56 298.77 660 11.1 -40.83
TablesDB 82.97 154.72 6,820 111.73 -9.36
Storage 81.15 172.89 3,300 56.15 +2.19
Functions 120.46 235.74 1,760 30.72 -19.88

Top API waits (after)

API request Max wait (ms)
functions.variables.update 546.03
account.prefs.update 398.94
storage.buckets.create 388.33
account.name.update 378.64
functions.create 370.15

@ChiragAgg5k
ChiragAgg5k merged commit c482f5c into main Sep 25, 2026
50 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the chore/absorb-di branch September 25, 2026 08:04
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.

5 participants