Repository navigation
refactor: move Bus to packages/bus - #13715
Conversation
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]>
|
| ->subscribe($listener) | ||
| ->subscribe($listener); | ||
|
|
||
| $bus->dispatch($event); | ||
|
|
||
| $this->assertSame([[$event::class, 'clock:resolved'], [$event::class, 'clock:resolved']], $calls); |
There was a problem hiding this 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)
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!
| "Utopia\\Bus\\": "src/Utopia/Bus", | ||
| "Utopia\\Agents\\": "packages/agents/src" | ||
| "Utopia\\Agents\\": "packages/agents/src", | ||
| "Utopia\\Bus\\": "packages/bus/src" |
There was a problem hiding this 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.
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.|
Post-merge check: Remaining, both manual: submit https://github.com/utopia-php/bus to Packagist, then |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
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]>
Summary
Second package on the plan in
rfc/monorepo.md.Buswas the last occupant ofsrc/Utopia/: autoloaded from the root, never published. It now lives atpackages/busin the standard shape:utopia-php/span(it was implicit before, supplied by the root)Utopia\Bus\ => src/,Utopia\Bus\Tests\ => tests/, aphpstan.neon, a unit test fordispatch(every subscribed listener called with resolved injections; dispatch without a resolver refused)utopia-php/busrepository:mirror.yml, README banner; the mirror ruleset is already applied viabin/monorepo absorb bussrc/Utopia/is gone;AGENTS.mdno longer describes it. Root autoload regenerated withbin/monorepo autoload. No history import: Bus never had a repository of its own, sosplitsynthesises its history from this repository's root, exactly the casedocs/distribution.mddescribes for a package written in the monorepo.Also
Package
phpunit.xmlfiles now bootstrapvendor/autoload.php, as the monorepo's packages do. Without it PHPUnit fell back to the root autoloader, so a registry-modebin/monorepo testnever proved the package installs and tests standalone. Caught because the firsttest busrun failed on exactly that.After merge
The first
Splitrun pushespackages/busto the empty mirror and creates itsmain. Then the mirror can be submitted to Packagist and a first release cut withbin/monorepo release bus 0.1.0.Verification
bin/monorepo validate: all packages validbin/monorepo check bus: clean;bin/monorepo test busandtest agentsgreen on a fresh package vendorvendor/bin/phpunit --testsuite packages: 136 tests, 4 skipped, greentests/unit/Busgreen🤖 Generated with Claude Code