prometeu-studio/docs/studio/pull-requests/PR-01-studio-event-bus-foundation.md
2026-03-24 13:42:39 +00:00

4.1 KiB

PR-01 - StudioEventBus Foundation

Briefing

The Studio now has a normative event model in spec, but prometeu-studio still relies on direct UI wiring.

This PR introduces the generic StudioEventBus foundation that later Studio code will use for:

  • shell-level observation,
  • workspace-local activity,
  • workspace-to-global propagation,
  • project launcher and shell interactions.

The implementation should be based conceptually on the C# event system located at:

/Users/niltonconstantino/personal/workspace.personal/unity/My-Local-Packages/Packages/intrepid-general-utilities/Runtime/SimpleEvents

The generic bus machinery should live in shared infrastructure, not in the Studio components module.

The bus must be thread-safe because background work such as asset recognition, tree refresh triggers, diagnostics updates, and other asynchronous Studio tasks may publish events from outside the UI thread.

Objective

Implement the typed Studio event infrastructure so future Studio work can publish and observe events without string routing or ad hoc direct coupling.

The generic event bus core should be introduced in prometeu-infra, while Studio-specific bus composition remains in Studio code.

Dependencies

Scope

  • introduce a generic typed event bus foundation in prometeu-infra
  • introduce Studio-specific global and workspace bus composition on top of that foundation
  • introduce a workspace-local bus model
  • support automatic workspace-to-global propagation
  • introduce DTO-style event payload contracts
  • add the minimum initial event set needed by the shell wave
  • add tests for propagation and subscription behavior

Non-Goals

  • implementing every future Studio event now
  • integrating the full packer event lane now
  • redesigning the whole shell in this PR
  • moving visual controls into prometeu-studio-components
  • placing the generic bus core inside prometeu-studio-components

Execution Method

  1. Use /Users/niltonconstantino/personal/workspace.personal/unity/My-Local-Packages/Packages/intrepid-general-utilities/Runtime/SimpleEvents as the architectural reference point.
  2. Port the useful baseline ideas into Java rather than copying Unity-specific structure literally.
  3. Introduce the generic event bus machinery in prometeu-infra.
  4. Keep the generic layer unaware of Studio shell semantics.
  5. Introduce the Studio-specific event contract and bus composition above that generic layer.
  6. Use typed DTO events, preferably immutable.
  7. Make subscription and unsubscription explicit and safe.
  8. Implement one global bus and one workspace bus type for Studio.
  9. Ensure every workspace event is automatically republished to the global bus.
  10. Keep propagation one-way: workspace to global.
  11. Make publication and subscription management thread-safe.
  12. Add tests for:
  • typed subscription
  • unsubscription
  • workspace-to-global propagation
  • no accidental global-to-workspace rebroadcast
  • concurrent publication and subscription safety

Acceptance Criteria

  • prometeu-infra has a generic typed event bus foundation
  • Studio code has a global and workspace bus composition built on top of that foundation
  • workspace buses exist and can be attached to the global bus
  • every workspace-published event is observable on the global bus
  • callers do not need to publish the same event twice manually
  • event payloads are DTO-style and not string-based
  • publication and subscription handling are safe under concurrent access
  • automated tests cover the propagation baseline

Validation

  • unit tests for bus behavior
  • basic smoke coverage for publish/subscribe and nested propagation
  • concurrent test coverage for thread-safe event publication

Affected Artifacts

  • prometeu-infra
  • prometeu-studio application infrastructure
  • future shell integration points
  • tests for Studio UI foundation code