2.3 KiB
ADR 0008: Editor Module Boundaries and lib/bin Split
Status
Accepted
Context
The in-process editor grew to ~15k LOC in a flat src/ root with manual plugin tuples in main.rs. Stubs, domain logic, and UI cross-cuts lived side by side, making navigation, review, and repeat render-target bugs harder to prevent (see Outstanding Issues Audit Phase A).
Decision
-
lib + bin split:
crates/editorexposeseditoras a library (src/lib.rs) with a thin binary (src/bin/main.rs) that callsconfigure_editor_appandregister_game_editor_plugins. -
Domain modules under
src/with flat re-exports at the crate root for stablecrate::scene_iopaths:scene/— I/O, schema plugin, viewport render-target setupviewport/— camera, selection, gizmos, render views, panel settingsplay/— PIE session, editor mode state, net editor profilesassets/— catalog, asset DB, prefab overridesproject/— workspace, project I/O, settings UIext/— extensibility, BRP, command queue, game panel adapters, hot reloadhistory/— undo commands + plugin (commands in submodule)ui/— egui shell (asset browser split into submodules)
-
EditorPluginGroupinlib.rsis the single ordered plugin registration surface. Order is documented indocs/editor/architecture.md. -
Shared
scenecrate owns schema stamp/migrate/validate; editor save/load andxtask validate-levelsboth use it. -
Dependency rules:
sim,protocol,settings,shared,scenemust not depend oneditororbevy_egui.editormay depend ongame;gamemust not depend oneditor.- Game-specific editor panels register via
game::editor_ext::editor_panel_setups(); editor wraps them asEditorPlugin(ADR 0007).
-
Stub policy: unwired modules live in domain folders (
net_editor,prefab_overridesv2 fields), not at an ambiguous crate root.
Consequences
- Third-party and game panels can embed or extend the editor library without forking the binary.
- Domain moves are incremental; flat re-exports avoid wide import churn.
- New workspace crates require an ADR update when they cross the dependency rules above.
cargo test -p editorbecomes viable as logic tests are added to the library.