Skip to content

chore: absorb registry into packages/registry - #13889

Merged
ChiragAgg5k merged 61 commits into
mainfrom
chore/absorb-registry
Sep 26, 2026
Merged

ChiragAgg5k merged 61 commits into
mainfrom
chore/absorb-registry

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

Summary

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

  1. Add 'packages/registry/' from commit 'dbaa3cd5…': subtree import from the standalone utopia-php/registry repository's main with full history. The head is 21 commits past the 0.6.0 tag, but none of them change behaviour: typed docblocks, Pint formatting, a get(): mixed return type, and CI/QA files.
  2. chore(registry): mirror plumbing: absorb replaces the repo's three workflows (tests, linter, codeql-analysis) with mirror.yml, adds the README banner, removes psalm.xml, the Dockerfile and the committed composer.lock, and ignores composer.lock.
  3. refactor: load registry from packages/:
    • Adds the root autoload and replace entries, drops the "utopia-php/registry": "0.5.*" require line, and removes the package from the lock.
    • Step A of the standard shape:
      • src/Registry/Registry.php moves up to src/.
      • tests/Registry/RegistryTest.php moves up to tests/, and its namespace goes from the bare Utopia\Tests to Utopia\Registry\Tests, with a matching autoload-dev entry.
      • docker-compose.yml is deleted. It only built the removed Dockerfile to run PHPUnit, and the package has no e2e tier.
      • phpunit.xml moves to the PHPUnit 12 schema. The old one used attributes PHPUnit 12 no longer accepts (backupStaticAttributes, convert*ToExceptions).
      • vimeo/psalm leaves require-dev. minimum-stability goes from dev to stable, matching the other packages.
      • The dead Travis badge leaves the README.
    • Adds a standalone phpstan.neon (level max, src and tests) and the standard rector.php. No baseline. The package passes level max once two property docblocks describe what they already hold ($registry is array<string, array<string, mixed>>, context then name; $callbacks is array<string, callable>) and the test class stops typing its registry as nullable. Rector added arrow-function return types in the tests.

There's nothing to hoist, since the package requires only PHP.

0.5.0 → 0.6.0 upgrade

Appwrite locked 0.5.0 (March 2021), so this PR also moves it to the package head. What changed since 0.5.0:

  • New has(string $name): bool, which checks whether a callback is registered.
  • get(string $name, bool $fresh = false): mixed: $fresh is now typed bool, with a mixed return type.
  • The four properties are typed (array $callbacks, array $fresh, array $registry, string $context).
  • The package now requires PHP 8.0 instead of 7.4.

None of this breaks Appwrite. No class extends Registry (typed properties would break a subclass that redeclares them untyped), and every get() call passes either one argument or a literal true (Tasks/Migrate.php). No call site needed changes. The 14 files that use Utopia\Registry are app/cli.php, app/init/registers.php, app/mqtt.php, app/realtime.php, Health/Stats/Get.php, Tasks/{Doctor,Migrate}.php, Workers/{Mails,Notifications}.php, the three realtime message handlers, and the Mails and Notifications worker unit tests.

Cloud: appwrite/cloud gets Utopia\Registry through appwrite/server-ce's 0.5.* requirement and will load the 0.6 head from packages/registry once it takes this version of server-ce. It doesn't subclass Registry, and its get() calls pass true (app/{cli,http,realtime,worker}.php), so it sees no break either.

Validation

  • bin/monorepo validate: all packages valid
  • bin/monorepo check registry: Rector, Pint, and PHPStan level max pass with no baseline
  • bin/monorepo test registry: 7 tests / 13 assertions
  • vendor/bin/phpunit --testsuite packages --filter 'Utopia\\Registry': 7 tests / 13 assertions under the root autoloader
  • vendor/bin/phpunit tests/unit/Platform/Workers/{MailsTest,NotificationsTest}.php: 5 tests / 15 assertions and 26 tests / 171 assertions (both construct a Registry)
  • Root PHPStan (host, level 4) over all 14 files that use Utopia\Registry: no errors
  • Utopia\Registry\Registry resolves to packages/registry/src/Registry.php from the root autoloader, and vendor/utopia-php/registry is gone
  • composer validate --no-check-publish: valid (only the existing utopia-php/platform exact-constraint warning)
  • composer.lock: the only change is the removal of utopia-php/registry 0.5.0 (plus content-hash)
  • bin/monorepo split registry --dry-run: be11128c, which fast-forwards from the mirror head dbaa3cd5
  • composer lint (full repo) and git diff --check

Merge and follow-up

Warning

Merge with a merge commit, not a squash. A squash drops the git-subtree-* annotation, and the mirror then rejects the split.

utopia-php/registry had no rulesets. absorb created the canonical main ruleset (id 23943548, targeting the default branch main), with the split app as an always-bypass actor.

After merge:

  • Confirm Split pushes to utopia-php/registry.
  • Triage the mirror's one open PR, Feat: Migrate from travis to Github actions workflow utopia-php/registry#13 ("Migrate from travis to Github actions workflow", 2023). It's obsolete: CI for the package runs here and the mirror keeps only mirror.yml. Close it with a pointer to this repository.
  • The mirror still has a stale master branch (same commit as main) and four old feature branches (feat-allow-params, feat-allow-querying, feat-github-action, chore/dependabot-automation-20260826). Split only pushes main, so master will fall behind. Consider deleting it so nobody installs dev-master expecting it to track main.

🤖 Generated with Claude Code

@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: 4/5

[High risk] Moves a dependency package into the monorepo.

The PR is not ready to merge because the timing-dependent tests still violate the repository’s test requirement.

Fix All in Claude CodeFindings

  1. P2 Timing-dependent registry tests ▶
  2. P2 Fresh retrieval goes untested ▶
  3. P2 Contribution steps target mirror ▶
Fix with agent prompt
### Issue 1
packages/registry/tests/RegistryTest.php:77-83
`testSetFresh` sleeps for one microsecond before comparing `microtime()` values, but that does not guarantee different timestamps. `testContextSwitching` also compares timestamps, without a delay. Correct registry behavior can therefore produce a test failure. Use a deterministic callback instead. AGENTS.md directs tests to avoid sleeps; this repository requirement needs to be satisfied before merging.

### Issue 2
packages/registry/tests/RegistryTest.php:61-65
`testGetFresh` requests a fresh value before anything has been cached. The test would still pass if `get($name, true)` stopped replacing cached values, leaving that behavior without direct coverage. Cache a value first, then check that a fresh request returns a different resource.

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 3
packages/registry/CONTRIBUTING.md:undefined-38
These instructions tell contributors to update `master` and open a pull request against this repository, but the README identifies it as a read-only mirror and directs development to `appwrite/appwrite`. Following the instructions sends contributors to the wrong branch or repository. Update the contribution steps to match the mirror arrangement.

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!

---

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

Summary

This PR moves Utopia Registry into packages/registry, loads it through the root Composer autoloader, and removes the external package dependency.

  • Adds the package’s mirror workflow, tooling configuration, source, and tests.
  • The merge since the previous review made no further changes to the registry package.

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

Comment on lines +77 to +83
$copy2 = $this->registry->get('fresh');
usleep(1);
$copy3 = $this->registry->get('fresh');

$this->assertNotEquals($copy1, $copy2);
$this->assertNotEquals($copy2, $copy3);
$this->assertNotEquals($copy1, $copy3);

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 Timing-dependent registry tests testSetFresh sleeps for one microsecond before comparing microtime() values, but that does not guarantee different timestamps. testContextSwitching also compares timestamps, without a delay. Correct registry behavior can therefore produce a test failure. Use a deterministic callback instead. AGENTS.md directs tests to avoid sleeps; this repository requirement needs to be satisfied before merging.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/registry/tests/RegistryTest.php
Line: 77-83

Comment:
**Timing-dependent registry tests** `testSetFresh` sleeps for one microsecond before comparing `microtime()` values, but that does not guarantee different timestamps. `testContextSwitching` also compares timestamps, without a delay. Correct registry behavior can therefore produce a test failure. Use a deterministic callback instead. AGENTS.md directs tests to avoid sleeps; this repository requirement needs to be satisfied before merging.

**Context Used:** AGENTS.md ([source](https://github.com/appwrite/appwrite/blob/main/AGENTS.md))

---

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

Comment on lines +61 to +65
public function testGetFresh(): void
{
$this->registry->set('array', fn (): ArrayObject => new ArrayObject(['test']));
$this->assertCount(1, $this->array(true));
}

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 Fresh retrieval goes untested testGetFresh requests a fresh value before anything has been cached. The test would still pass if get($name, true) stopped replacing cached values, leaving that behavior without direct coverage. Cache a value first, then check that a fresh request returns a different resource.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/registry/tests/RegistryTest.php
Line: 61-65

Comment:
**Fresh retrieval goes untested** `testGetFresh` requests a fresh value before anything has been cached. The test would still pass if `get($name, true)` stopped replacing cached values, leaving that behavior without direct coverage. Cache a value first, then check that a fresh request returns a different resource.

---

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

For the initial start, fork the project and use git clone command to download the repository to your computer. A standard procedure for working on an issue would be to:

1. `git pull`, before creating a new branch, pull the changes from upstream. Your master needs to be up to date.

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 Contribution steps target mirror These instructions tell contributors to update master and open a pull request against this repository, but the README identifies it as a read-only mirror and directs development to appwrite/appwrite. Following the instructions sends contributors to the wrong branch or repository. Update the contribution steps to match the mirror arrangement.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/registry/CONTRIBUTING.md
Line: 38

Comment:
**Contribution steps target mirror** These instructions tell contributors to update `master` and open a pull request against this repository, but the README identifies it as a read-only mirror and directs development to `appwrite/appwrite`. Following the instructions sends contributors to the wrong branch or repository. Update the contribution steps to match the mirror arrangement.

---

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

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

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

Metric Before After Change
🚀 Requests/sec 163.52 186.92 🟢 +14.3%
⏱️ Latency P50 103.84 ms 92.46 ms 🟢 -11%
⏱️ Latency P95 256.77 ms 216.29 ms 🟢 -15.8%
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 92.46 216.29 11,685 186.92 -40.48
Account 190.78 357.07 615 10.17 -35.18
TablesDB 88.54 163.47 6,355 103.44 -37.28
Storage 85.5 183.29 3,075 51.97 -28.77
Functions 135.01 269.16 1,640 28.37 -35.65

Top API waits (after)

API request Max wait (ms)
tablesdb.rows.delete 512.77
functions.variables.create 488.09
account.name.update 478.78
functions.create 429.37
account.prefs.update 425.04

@ChiragAgg5k
ChiragAgg5k merged commit 9aa01b4 into main Sep 26, 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.