Skip to content

refactor: move Bus to packages/bus - #13715

Merged
loks0n merged 1 commit into
mainfrom
feat/absorb-bus
Sep 15, 2026
Merged

loks0n merged 1 commit into
mainfrom
feat/absorb-bus

Conversation

@loks0n

@loks0n loks0n commented Sep 15, 2026

Copy link
Copy Markdown
Member

Summary

Second package on the plan in rfc/monorepo.md. Bus was the last occupant of src/Utopia/: autoloaded from the root, never published. It now lives at packages/bus in the standard shape:

  • manifest declaring its one dependency, utopia-php/span (it was implicit before, supplied by the root)
  • Utopia\Bus\ => src/, Utopia\Bus\Tests\ => tests/, a phpstan.neon, a unit test for dispatch (every subscribed listener called with resolved injections; dispatch without a resolver refused)
  • mirror plumbing for the new, empty utopia-php/bus repository: mirror.yml, README banner; the mirror ruleset is already applied via bin/monorepo absorb bus

src/Utopia/ is gone; AGENTS.md no longer describes it. Root autoload regenerated with bin/monorepo autoload. No history import: Bus never had a repository of its own, so split synthesises its history from this repository's root, exactly the case docs/distribution.md describes for a package written in the monorepo.

Also

Package phpunit.xml files now bootstrap vendor/autoload.php, as the monorepo's packages do. Without it PHPUnit fell back to the root autoloader, so a registry-mode bin/monorepo test never proved the package installs and tests standalone. Caught because the first test bus run failed on exactly that.

After merge

The first Split run pushes packages/bus to the empty mirror and creates its main. Then the mirror can be submitted to Packagist and a first release cut with bin/monorepo release bus 0.1.0.

Verification

  • bin/monorepo validate: all packages valid
  • bin/monorepo check bus: clean; bin/monorepo test bus and test agents green on a fresh package vendor
  • vendor/bin/phpunit --testsuite packages: 136 tests, 4 skipped, green
  • Root PHPStan clean on all 50 Appwrite files that consume Bus; tests/unit/Bus green

🤖 Generated with Claude Code

Second package on the plan in rfc/monorepo.md. Bus was the last occupant
of src/Utopia/, autoloaded from the root but never published; it now sits
under packages/bus in the standard shape with a manifest that declares its
one dependency (utopia-php/span), a unit test for dispatch, and the mirror
plumbing for the new utopia-php/bus repository. src/Utopia/ is gone and
AGENTS.md no longer describes it.

Package phpunit.xml files now bootstrap vendor/autoload.php, as the
monorepo's do: without it PHPUnit fell back to the root autoloader, so a
registry-mode run never proved the package installs and tests standalone.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@loks0n loks0n self-assigned this Sep 15, 2026
@greptile-apps

greptile-apps Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The source relocation appears behaviorally safe, but the explicit testing requirement must be satisfied by replacing the implementation-coupled duplicate-listener test before merging.

Fix All in Claude CodeFindings

  1. P2 Test Mirrors Subscription Internals ▶
  2. P2 Bus Documentation Path Is Stale ▶
Fix with agent prompt
### Issue 1
packages/bus/tests/BusTest.php:44-49
This test subscribes the same listener instance twice and expects duplicate output, so it mirrors the Bus's internal append-and-iterate behavior instead of proving that every distinct listener is called. Production registers multiple distinct listeners, and this test could still pass if one listener were invoked twice while another were dropped. Replace the duplicate subscription with two independently observable listeners using distinct injections. The repository requires tests to verify observable behavior rather than implementation details, so this must be addressed 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
composer.json:30
The Bus mapping now correctly points to `packages/bus/src`, but the monorepo RFC's target `composer.json` example still points to the deleted `src/Utopia/Bus` directory and its introduction describes that directory as the current loading mechanism. This makes the migration documentation contradict both the generated root mapping and its own target shape, which may mislead future monorepo work. Update those RFC references as part of this relocation.

---

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

Summary

This PR extracts the existing synchronous Bus implementation into a standalone monorepo package while preserving its namespace and root integration.

  • Adds the package manifest, mirror workflow, standalone analysis/test configuration, documentation, and initial Bus tests.
  • Remaps root production and test autoloading to packages/bus.
  • Makes package PHPUnit runs bootstrap their package-local Composer autoloader.
  • Leaves stale Bus-location references in the monorepo RFC and introduces an implementation-coupled multi-listener test.

Reviews (1) · Last reviewed commit: "refactor: move Bus to packages/bus"

Comment on lines +44 to +49
->subscribe($listener)
->subscribe($listener);

$bus->dispatch($event);

$this->assertSame([[$event::class, 'clock:resolved'], [$event::class, 'clock:resolved']], $calls);

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 Mirrors Subscription Internals

This test subscribes the same listener instance twice and expects duplicate output, so it mirrors the Bus's internal append-and-iterate behavior instead of proving that every distinct listener is called. Production registers multiple distinct listeners, and this test could still pass if one listener were invoked twice while another were dropped. Replace the duplicate subscription with two independently observable listeners using distinct injections. The repository requires tests to verify observable behavior rather than implementation details, so this must be addressed 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/bus/tests/BusTest.php
Line: 44-49

Comment:
**Test Mirrors Subscription Internals**

This test subscribes the same listener instance twice and expects duplicate output, so it mirrors the Bus's internal append-and-iterate behavior instead of proving that every distinct listener is called. Production registers multiple distinct listeners, and this test could still pass if one listener were invoked twice while another were dropped. Replace the duplicate subscription with two independently observable listeners using distinct injections. The repository requires tests to verify observable behavior rather than implementation details, so this must be addressed 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 composer.json
"Utopia\\Bus\\": "src/Utopia/Bus",
"Utopia\\Agents\\": "packages/agents/src"
"Utopia\\Agents\\": "packages/agents/src",
"Utopia\\Bus\\": "packages/bus/src"

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 Bus Documentation Path Is Stale

The Bus mapping now correctly points to packages/bus/src, but the monorepo RFC's target composer.json example still points to the deleted src/Utopia/Bus directory and its introduction describes that directory as the current loading mechanism. This makes the migration documentation contradict both the generated root mapping and its own target shape, which may mislead future monorepo work. Update those RFC references as part of this relocation.

Prompt To Fix With AI
This is a comment left during a code review.
Path: composer.json
Line: 30

Comment:
**Bus Documentation Path Is Stale**

The Bus mapping now correctly points to `packages/bus/src`, but the monorepo RFC's target `composer.json` example still points to the deleted `src/Utopia/Bus` directory and its introduction describes that directory as the current loading mechanism. This makes the migration documentation contradict both the generated root mapping and its own target shape, which may mislead future monorepo work. Update those RFC references as part of this relocation.

---

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

@loks0n
loks0n merged commit 6ef3e65 into main Sep 15, 2026
51 of 52 checks passed
@loks0n

loks0n commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

Post-merge check: Split run 35033297044 on the merge commit succeeded. utopia-php/bus went from an empty repository to main at 8c816d4001, a single parentless commit whose tree is packages/bus at the merge, exactly what bin/monorepo split bus --dry-run predicted. The same run advanced utopia-php/agents to 7032aafac5 for the phpunit.xml bootstrap change.

Remaining, both manual: submit https://github.com/utopia-php/bus to Packagist, then bin/monorepo release bus 0.1.0.

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/absorb-bus (after).

Metric Before After Change
🚀 Requests/sec 206.09 211.15 ⚪ +2.5%
⏱️ Latency P50 84.88 ms 81.44 ms ⚪ -4%
⏱️ Latency P95 196.81 ms 195.66 ms ⚪ -0.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 81.44 195.66 13,452 211.15 -1.16
Account 158.66 299.19 708 11.74 +3.39
TablesDB 77.31 146.56 7,316 117.78 -11.93
Storage 77.77 174.9 3,540 58.58 +2.73
Functions 120.99 237.82 1,888 31.88 -5.74

Top API waits (after)

API request Max wait (ms)
account.name.update 589.93
account.prefs.update 389.66
functions.delete 384.8
functions.create 383.78
functions.variables.update 380.78

pull Bot pushed a commit to erickirt/appwrite that referenced this pull request Sep 16, 2026
The dispatch test subscribed one listener twice, which only showed the bus appends and iterates; it now subscribes two distinct listeners with distinct injections and checks that a listener of another event is skipped. The RFC's root autoload example and prose still pointed at src/Utopia/Bus, which appwrite#13715 removed.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant