chore(architecture): enforce layer boundaries
This commit is contained in:
22
AGENTS.md
22
AGENTS.md
@@ -6,7 +6,7 @@ Follow these rules for the whole repository. More specific `AGENTS.md` files ove
|
||||
- `core/`: pure domain models only. See `core/AGENTS.md`.
|
||||
- `commands/`: the only write path for application state.
|
||||
- `editor/`: transient editor/app state types and app store, e.g. viewport/camera and selection.
|
||||
- `keybinds/`: keybind resolution; global consumer first, command fallback second.
|
||||
- `input/`: keyboard, pointer, mouse, touch, pen, and wheel resolution; global consumer first, command fallback second.
|
||||
- `renderer/`: renders the current `ImageDocument` using the graphics backend, e.g. WebGL.
|
||||
- `view/`: React UI shell and controls only.
|
||||
|
||||
@@ -16,13 +16,13 @@ Follow these rules for the whole repository. More specific `AGENTS.md` files ove
|
||||
- Commands are the only code allowed to create, replace, or mutate persistent or transient state.
|
||||
- React must not own, manage, derive authoritative, or alter document/editor state.
|
||||
- React may hold only local ephemeral UI details with no app meaning, e.g. open popover, hovered button, uncontrolled input draft before command submit.
|
||||
- Do not update state directly from React event handlers, renderer callbacks, effects, stores, services, or keybind handlers. Dispatch a command instead.
|
||||
- Do not update state directly from React event handlers, renderer callbacks, effects, stores, services, or input handlers. Dispatch a command instead.
|
||||
|
||||
## Commands
|
||||
- Every state change must be modeled as a command with an explicit id, payload, and context.
|
||||
- Commands must be deterministic and testable; avoid DOM, React, WebGL, timers, network, and filesystem access inside command execution.
|
||||
- Commands return/apply the next state; they should preserve domain invariants and validate payloads before changing state.
|
||||
- UI actions, menus, toolbar buttons, keybinds, and renderer interactions all request changes by dispatching commands.
|
||||
- UI actions, menus, toolbar buttons, keyboard shortcuts, pointer/wheel gestures, and renderer interactions all request changes by dispatching commands.
|
||||
|
||||
## React / View
|
||||
- React displays current state and exposes user intent.
|
||||
@@ -36,18 +36,18 @@ Follow these rules for the whole repository. More specific `AGENTS.md` files ove
|
||||
- Renderer interactions may emit intents/events that are translated into commands.
|
||||
- Keep rendering backend details isolated behind renderer APIs; do not leak WebGL objects into `core/`, `commands/`, or React state.
|
||||
|
||||
## Keybinds
|
||||
- Keybind handling is ordered and explicit.
|
||||
- First check the global keybind consumer/map.
|
||||
- If the global consumer handles the keybind, stop.
|
||||
- If not consumed globally, the keybind may be consumed by dispatching a command.
|
||||
- Keybind handlers must not mutate state directly.
|
||||
- Avoid ad-hoc component-local shortcuts unless they are purely local UI behavior and cannot affect app/editor/document state.
|
||||
## Input
|
||||
- Input handling is ordered and explicit for keyboard, pointer, mouse, touch, pen, and wheel events.
|
||||
- First check the global input consumer/map.
|
||||
- If the global consumer handles the input, stop.
|
||||
- If not consumed globally, input may be consumed by dispatching a command.
|
||||
- Input handlers must not mutate state directly.
|
||||
- Avoid ad-hoc component-local shortcuts/gestures unless they are purely local UI behavior and cannot affect app/editor/document state.
|
||||
|
||||
## Imports
|
||||
- `core/` imports nothing from app layers.
|
||||
- `commands/` may import `core/` and `editor/`; avoid importing React or renderer backend APIs.
|
||||
- `editor/` may import `core/` types and command dispatch infrastructure; it must not import React, renderer, storage, or backend APIs.
|
||||
- `keybinds/` may import command dispatch types; it must not mutate state directly.
|
||||
- `input/` may import command dispatch types and shared geometry types; it must not mutate state directly.
|
||||
- `renderer/` may import `core/` and `editor/` types; it must not import React components.
|
||||
- `view/` may import UI components and command dispatch interfaces; avoid importing renderer internals except through stable view-facing adapters.
|
||||
|
||||
Reference in New Issue
Block a user