chore(repo): base for the package migration

Merge of wip-stage (kfde, bar, settings), wip-cand1 (kfw, kfm), wip-u-nix and wip-u-pkg (the
unified-binaries doc), so the migration is built on the open stacks and does not conflict with them later.
This commit is contained in:
LGUG2Z committed 2026-10-31 11:31:14 -07:00
47 files changed
+1269 -270

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
# Windows: which call sites go through `backend()`
Step 8 of the unified-binaries plan. `komorebi::windows_backend::backend()` returns the shared
`komorebi_backend::Backend` (a stateless `WindowsBackend` over `WindowsApi` and `Window`). The daemon
is switched one cluster at a time; each switch is its own revision marked BEHAVIOUR.
What every switched call changes in the Windows daemon: `WindowsBackend` first asks `IsWindow` and
fails with `Error::WindowGone` for a dead window (hide, restore, minimize, maximize and the other `()`
returning operations are then skipped: before, `Window::hide` of a dead window still ran
`ShowWindow` on it, a no-op, and recorded its handle in `HIDDEN_HWNDS`), and a failure of a window
that died meanwhile is reported as `WindowGone` (the error text changes from the Win32 one). Call sites
use `?` or ignore the result; none inspects the error. `frame` is the exception: it does not ask
`IsWindow` first, so the Win32 error is what callers get.
## Switched
| Cluster | Operation | Sites | Notes | e2e needed |
|---|---|---|---|---|
| focus | `focus(id, mouse_follows)` | 40 (process_event, process_command, workspace, window_manager, focus_manager, stackbar) | `animation/transition.rs` calls `Window::focus` from the slide-in code `Window::focus` defers to: left | commands, focus, focus_follows_mouse, stacking, workspaces, lifecycle |
| frame write | `set_rect(id, rect)` | 2 (workspace layout update, stackbar tab click) | `top = false` only | commands, resize, layouts, stacking, scrolling, workspaces |
| frame read | `frame(id)` | about 55, one revision per file: stackbar_manager (2 files), animation (snapshot, ghost_dispatcher, ghost test), live_resize, pan, scrolling, process_command, process_event, window_manager, border_manager (2 files) | `frame` is a provided method added to the trait for this (WindowsBackend: `Window::window_rect`, one DWM call; error kept). `Window::window_rect`/`WindowsApi::window_rect` remain only inside `window.rs` (the implementation, and `Window::set_position`/`move_to_area`/`center`/`focus` internals) | resize, layouts, stacking, scrolling, borders, animation, commands, lifecycle |
| hide / show | `hide`, `restore` (plain forms) | 23 | | commands, workspaces, stacking, lifecycle_hidden |
| hide / show | `minimize`, `close`, `raise` | 1 + 1 + 4 (process_command), 4 minimize (monitor_reconciliator) | | commands, monitor reconciliation, lifecycle |
| maximize | `maximize(id, bool)` | 5 (workspace.rs) | capability query already in the trait (`supports(Capability::Maximize)`, true here) | maximizing, commands, workspaces |
## Left on purpose (platform-owned subsystems, seam.md rule 5)
- `set_position(.., true)` (window.rs `move_to_area`, `center`, workspace maximize area): the raise-to-front
flag is a Windows detail of the layout/animation code, the shared `set_rect` has none.
- `hide_with_border`, `restore_with_border`: borders are a platform subsystem (own windows and threads).
- `animation/transition.rs`, `animation/ghost*.rs` (except the frame reads above): the DWM ghost and
slide-in machinery.
- `set_opacity`: the adapter writes the plain alpha, `Window::transparent`/`opaque` take the alpha from the
transparency manager and animate.
## Not switched, and what the trait would need (for step 9)
| Operation | Why it stays on the platform API | What the trait would need |
|---|---|---|
| `foreground_window` | `WindowsApi::foreground_window() -> Result<isize>`: a null handle is an `Err` whose message callers pass on; the trait has `Option<WindowId>` | a `Result` variant (`Error::Platform` for "no foreground window"), or accept losing the message |
| `cursor_pos` | `Result<POINT>` vs `Option<(i32, i32)>`; callers `?` it | same: a `Result` return |
| `monitors` / `window` | `monitors()` rebuilds `MonitorInfo` and drops the `Monitor` fields the daemon needs (device id, serial, device, work-area offsets); `window()` asks title, class, exe, path | the daemon-side `Monitor` fields in `MonitorInfo` (or a platform extension), and for step 9 the monitor model moving to the core |
| `monitor_from_point` | never `None` on Windows (`MONITOR_DEFAULTTONEAREST`), `None` outside every monitor on KDE and macOS | an explicit "nearest" flag or two methods |
+73
View File
@@ -0,0 +1,73 @@
# macOS hand-check list
Status: written by the `kfm` agent for the user, 2026-10-31. Nothing here has been run: macOS cannot be built, linked or tested on the Linux host, only type-checked through a fake C compiler (`tools/fast-check`). Every revision below is `type-checks, not run`. Revision ids are jj change ids (stable) with the commit id they had when this was written (commit ids change when a revision is rewritten; use `jj log -r <change id>`).
How to use it: build the unified (or, until they exist, the per-tree) macOS `komorebi`, `komorebic` and `komorebi-bar`, run `cargo test --workspace` on the Mac first (the 399+ unit tests have never run against these changes), then walk the sections in order. For before/after capture use `komorebi-recorder` against a build of the baseline `wip-main` ancestor `ff3711dc` and the tip. A section is done when the "look for" column is true.
## A. Revisions that change what the daemon does (BEHAVIOUR)
| Revision | What changed | Look for on a Mac |
|---|---|---|
| `ummqkuvp` 01b9cbed `fix(mac): take the rule-list locks in one order...` | `window_is_eligible` (window.rs) and `apply_globals` (static_config.rs) now lock floating, ignore, manage, regex in that order; before they locked regex, ignore, manage and ignore, regex, manage. The order is documented at the statics in lib.rs. Same fix as the KDE `ef1d3ef0`. | Run `komorebic reload-configuration` (and `komorebic replace-configuration`) in a loop of 50 while opening and closing windows (new Finder windows, Terminal tabs) at the same time. Before the fix this could hang the daemon (the command is never answered, new windows are not tiled). Expected: no hang, every reload answered. Also check that float rules, ignore rules and manage rules from the config and from `komorebic float-rule`/`ignore-rule`/`manage-rule` still apply to new windows. |
| `nvwvptpv` 866b2840 `use the shared command listener` | The UDS command accept loop and per-client reader are the shared `komorebi-transport` code (`NoPolicy`: no read timeouts, as before); `WindowManager` is a `CommandTarget` (lock with `try_lock_for`). | Every `komorebic` command is answered; a command sent while the daemon is busy gets an answer or a clean error, not a hang; kill the daemon mid-command: the client returns. |
| `ywwwwpwm` 587defe3 `use the shared pause filter` | `allowed_while_paused` lists the commands allowed while paused. | `komorebic toggle-pause`; while paused only `toggle-pause`, `state`, `global-state`, `stop` work, everything else is ignored (and the connection ends); unpause and check windows tile again. |
| `kzynysto` b85827e6 `use the shared subscriber push` | Subscriber sockets are pushed to by the shared `notify_sockets`; the macOS override events are kept. | `komorebic subscribe-socket` (and `subscribe-socket-with-options`): events arrive for focus, move, workspace change, monitor change, theme and config reload; a subscriber that goes away is dropped without breaking the others. The bar is a subscriber, so the bar updating is the check. |
| `ovsplvmn` 5cc38da6 `use EventChannel for the window events` | The window-event channel (capacity 20, try_send, drop warning, `ResizeStep` claim flag) is `komorebi_transport::EventChannel`. | Drag a window edge continuously (live resize) and pan with the trackpad: no stalls, no repeated drop warnings in the log, the layout follows. Move many windows at once (workspace switch with 10+ windows). |
| `lrqkuuzq` a4996ac6 `use SocketMessage from komorebi-protocol` and `sowrttxs` 5c129ab5 `carry DebugWindow as i64` | One `SocketMessage` for all platforms; the wire format must be unchanged. `DebugWindow` takes an i64 (a negative id parses and matches nothing). | Every command of the `komorebic` help works against the daemon; `komorebic debug-window <id>` for a real id; `komorebic state` and `global-state` JSON parse. |
| `qqwoptqt` 975f007a, `yptnnkxv` eb903bcc (animation prefix, Bezier doc) | `AnimationPrefix` gains `Transparency` (ignored by the daemon); schema.json changed the shape of per-prefix animation settings. | Config with `animation.style` / `duration` per prefix (movement, workspace) still loads; animations behave as before. Run `komorebic static-config-schema` and diff with `komorebi-for-mac/schema.json` (two description-level changes and the per-prefix shape are intended). |
| `kvtvnouo` 93e4d511, `stxmqnop` dec91984 (StaticConfig from komorebi-config) | The config data types and their defaults come from `komorebi-config`; `komorebic static-config-schema` prints the macOS view. | A real `komorebi.json` of yours loads with no new warning and every key still takes effect (borders, padding, animations, scrolling, rules, workspaces); `komorebic static-config-schema` matches the checked-in `schema.json` up to the intended description lines. |
| `qukywpss` c46320ea, `zwkwptox` 1e902542, `sxptsttt` 0345fccb (komorebic shares clap definitions, launcher, pan) | `komorebic start` and `stop` use the shared Launcher skeleton (the odd `--config` arguments are kept; "Waiting for komorebi to start..." is flushed); pan commands use the shared module. | `komorebic start --bar`, `start --await-configuration`, `stop`, `stop --bar`; `komorebic pan-*` commands; `komorebic --help` and a few `<command> --help` texts (about 15 help texts changed to the Windows wording). |
| `oywqqkuy` f0b1a448 `register every Window in ax_registry and forget the dead` | `Window::new` registers the window in the id registry (`ax_registry`); entries are removed in `Window::drop` of a dead window, in `reap_window`, and (`forget_pid`) when an application terminates. No AX call is added; the table holds retained AX references and observers. | Open and close 50 windows (Finder, Terminal, Safari) and quit several apps, then check the daemon's memory in Activity Monitor does not climb and nothing behaves differently (focus, tiling, borders). If a quit app's windows were not forgotten the symptom is memory growth only. Run with `RUST_LOG=debug` and check no new errors at app quit. |
| `oqnvyqvw` e0687167 `keep ax_registry in step when a native tab changes a window's id` | The two places that swap a window's id and element in place for native tabs also update the registry (`sync`). | A native-tabbed app (Terminal, Finder, Safari tabs): switch tabs, close the first tab, open a new tab, focus the window with `komorebic focus ...`, move and resize it. Must behave as on the baseline (no window lost, no stuck border). |
| Bar: `nottqpms` 086833af, `zvuyspku` b8de056b, `uxzpkmnk` 7cd85bd4, `yopuwouu` 6da27dda (bar-core, platform hooks) | macOS now builds `sysinfo` 0.39 and `starship-battery` 0.11 (the Windows versions); cpu, battery, memory, date, update widgets are the shared code. | Bar renders; CPU %, memory, battery % and charging state show sane values; date and the calendar icon; clicking CPU, battery, network, update (see bug list D below: these click handlers are broken on macOS and stay broken). |
Revisions in section B change no behaviour on purpose (rename, move, route); they still need the sections C walk-through, because a mechanical mistake would show there.
## B. Mechanical macOS revisions of the `kfm` agent (Step 6 and 11(i))
| Revision | Change |
|---|---|
| `vzxkxzzy` 796c3832 | `Window::frame()` (renamed `window_rect` below) for the 28 sites that read a Window's frame through `MacosApi::window_rect(&w.element)` (window.rs, window_manager.rs, workspace.rs, process_event.rs, process_command.rs, settle.rs, macos_backend.rs) |
| `oootynxk` 7c2e1bea | `Window::is_valid` renamed `Window::alive` |
| `roxrxtru` 49a6dbda | `Window::set_position` renamed `Window::set_rect` (10 callers) |
| `vmnnuzzu` 803a1410 | `Window::set_messaging_timeout` (settle.rs: 3 raw AX sites) |
| `upylxxuw` ecaa3e15 | `Window::close` (the same close-button press as `AdhocWindow::close`) |
| `tsymmvll` d30a3eb6 | step 11(i): `MacosBackend` calls only `Window` methods (new `Window::minimized`); still unused by the daemon |
| `qsrxvsmv` 931b17d7 | `Window::frame` renamed `Window::window_rect` (the Backend and the Windows Window use that name) |
| `xrtqmxkp` 4c9094d7 | native: `komorebi_backend::Registry` (the rules of the id registry; 9 unit and 1 doc test run on Linux) |
| `tmmtuosy` 386c5a79 | `ax_registry` module; `MacosBackend` resolves ids through it (the adapter is still unused by the daemon) |
| `kvkxkqnx` ba22e8dc | `ax_registry::identify`: the 7 sites that turn a system-handed element into a window id (input_event_listener, process_command, process_event x5, window_manager) |
| `kpopuvoy` 01b3bd5c | live-resize step (window_manager.rs) reads the dragged window's frame through `Window::window_rect` |
Hand check: C below. If something breaks and is not the lock order, bisect among these seven first: they only rename and route, so a regression means a call was routed to the wrong receiver (type-check cannot tell a Window from another window of the same type).
## C. Walk-through (the list the plan names)
Do each with the baseline build and the tip build and compare (or record with `komorebi-recorder`).
1. **Focus**: `komorebic focus left|right|up|down`, `cycle-focus`, `focus-window <n>`; mouse-follows-focus on/off (the cursor centres in the window: uses the window frame query); focus a window of a tabbed app (Terminal, Finder): the focus uses `element_to_focus`, check the right tab.
2. **Move and resize**: `move`, `resize-axis`, `resize-edge` and a manual drag of a window; after a drag the layout puts the window back (settle reads the frame with a timeout); live resize of one edge moves the neighbour. A window that refuses a width (a fixed size app) is read back and the neighbours adapt.
3. **Stack**: `stack`, `unstack`, `cycle-stack`, `stack-all`; hidden stack members are parked off-screen (`hide`) and restored (`restore`) correctly; no window left at a hidden corner after unstack or quit.
4. **Workspaces**: switch (`focus-workspace`), send a window (`send-to-workspace`), `move-to-workspace`, with 2 monitors if possible; windows of the workspace you left are hidden, those of the new one restored to where they were; workspace rules after a monitor change.
5. **Scrolling layout**: the scrolling layout, `pan` commands, `scroll-*`; windows slide in from the edge (the arrival/slide code reads the frame).
6. **Pan** (trackpad gesture) and **live resize**: `komorebic pan-*`, three-finger style gestures as you configured them.
7. **Borders**: focused/unfocused/stack colours follow focus and follow animated windows; borders vanish and come back on workspace switch; no border left behind after closing a window (the window's close and borders share the observer code).
8. **Animations**: movement and workspace animations on and off; the ghost images; cancel an animation by issuing a new command in the middle.
9. **Display change**: plug or unplug a monitor or change the resolution: work areas update, workspaces go to the right monitors, workspace rules re-apply. (This is the thread that can deadlock, see bug list A.)
10. **Sleep and wake**: close the lid or sleep, wake: windows are where they were, the daemon answers, the bar returns.
11. **Minimize, unminimize, close**: `komorebic minimize`, `close` (the foreground window), un-minimize a window from the Dock; closing a window removes it from its container (the reaper uses `Window::alive`).
12. **Reload the config** repeatedly (see section A, first row).
## D. Bugs noticed, not fixed here
A. **Possible deadlock, main queue against the window-manager lock** (`docs/dev/seam.md` section 3.3, by reading only, never reproduced). A thread holding the WM lock calls a blocking main-queue dispatch (`destroy_all_borders` at process_event.rs lines about 128/139, process_command.rs, `retile_all`; `hide_borders_on` in window_manager.rs; `activate_finder` in process_event.rs) while the monitor reconciliator has dispatched a closure to main that itself takes the WM lock (monitor_reconciliator.rs about 106 and 383). Then the event thread waits for main, main waits for the lock. `parking_lot`'s deadlock detector cannot see it (the dispatch is a semaphore). Window of exposure: a display change at the instant of one of those events. Structural fix: no closure that runs on main may take the WM lock (or dispatch to main only after the lock is dropped). How to provoke it: spam `komorebic retile` / workspace switches (with ghosts) while plugging or unplugging a monitor; the symptom is a daemon that answers no command (`komorebic state` hangs).
B. **cmd.exe and explorer.exe in the macOS bar** (`komorebi-for-mac/komorebi-bar/src/os.rs`, `BarPlatform::open_system_tool`): the battery click spawns `cmd.exe` (power settings), the update click spawns `explorer.exe` with the release URL; neither exists on macOS. The same file's CPU (task manager) and network settings tools should be Activity Monitor and System Settings. The fix is one function in that file; it was preserved on purpose during the bar move.
C. **Update widget refresh thread polls the Windows repo's GitHub API** on macOS too (update.rs has a second URL that does not go through the hook), and the macOS update link is `.../releases/v..` built for the Windows repo.
D. **Other raw AX sites remain outside `Window`**: window.rs (38 inside `Window`/`AdhocWindow`, expected), application.rs 11 (`Application`, not a window), process_event.rs 7 (events that hand over a bare element: `window_id` of an element, the tab check `AccessibilityApi::window_id(&window.element.0)`), animation/animator.rs 6 (lane threads hold `WindowHandle` clones of the element), border_manager 7 (observers on tracked elements), window_manager.rs 4 (timeouts list holds elements, `window_id` of an element), reaper.rs 2 (`notify_if_gone` takes an element so lanes can use it), input_event_listener.rs 1, process_command.rs 1. They need either an id to AX registry (step 11(ii), not started) or a `WindowHandle` type; they were left alone because routing them changes who owns the element.
D2. **Step 11(ii) status.** Done: the id registry (`ax_registry`, over the tested `komorebi_backend::Registry`), populated at `Window::new`, kept in step for native tabs, emptied on death, reap and application quit; `MacosBackend` resolves ids through it. NOT done, on purpose, because each needs a decision that cannot be verified without a Mac: (a) the animator lanes (`WindowHandle`) keep their own snapshot of the element: a lane must keep writing to the element of the move it was given even if a tab swap replaced the registry entry, and replacing the snapshot by a lookup per write changes what a late write hits; (b) borders keep `tracking_element` (observer sources are added and removed on that exact element, on main); (c) `reaper::notify_if_gone` and the window manager's live-resize `timeouts` list take elements, including application elements, that are not registry entries; (d) `application.rs` is the application, not a window. (e) The model (`Window`, containers, workspaces) still holds `Window` values, not bare `WindowId`s: that is step 11(iii), after steps 8-9. A stale registry id answers `Error::WindowGone` (no panic); a window that was deserialised from state (default system-wide element) is never registered.
E. `MacosBackend` (step 7c/11(i)) needs 11(ii) before it can be used: `windows()` answers only what was `register`ed, `hide` needs the corner, `raise` also focuses, `monitors()` reads a cache nobody fills yet (seam.md section 9.2). `AdhocWindow` (bare foreground element) still has its own minimize, close, hide, restore, raise.
F. In `window.rs` `AdhocWindow::hide` / `Window::hide` duplicate the restore-position bookkeeping (`WINDOW_RESTORE_POSITIONS`), one on a `Window` and one on a bare element; they must stay in step.
## E. What is not checked at all
Everything above. In particular: no macOS test (399+ unit tests incl. those in window.rs for drag state) has run against any of these revisions; the unified binaries do not exist yet; no real Accessibility call was made; `komorebi-recorder` captures need a Mac.
+177
View File
@@ -0,0 +1,177 @@
# One `komorebi`, one `komorebic`, one `komorebi-bar`
Goal: three packages and three binaries that build on Windows, KDE (Linux) and macOS, the platform
chosen by `cfg(target_os)` (generics, `cfg_select!`, exhaustive `match`; no macros as a design tool).
This file records a spike (throwaway revisions on bookmark `wip-u-pkg-spike`, titled `spike:`; nothing
landed on `wip-main`), the layout it recommends, the migration order, the risks and the gates.
Measured on `wip-main` 633e7453 with the light gates only (`nice -n 19`, 3 jobs, persistent target
dirs, `COMMIT_HASH=dev`); no nix build, no e2e, no VM. macOS is type-checked with the fake CC only: it
was never linked or run.
## What the spike did
1. `spike: one root workspace ...` (rev `yuuyzssl`): the 10 KDE and macOS member crates became members
of the root workspace. Their two `[workspace]` manifests were deleted, their `workspace = true`
dependencies were written out, packages renamed (`komorebi-linux`, `komorebic-linux`,
`komorebi-client-linux`, `komorebi-hotkeys-linux`, `version-linux`, and `-macos` for the macOS
ones including `komorebi-bar-macos`); binary and lib names stayed (`[lib] name`, `[[bin]] name`) so
no source file changed. One `Cargo.lock`.
2. `spike: unified komorebic package by #[path] includes`: the root `komorebic` package became the
unified one. `src/main.rs` is a `cfg_select!` over `target_os` that includes the old Windows
`main.rs` (moved to `windows.rs`) and, by `#[path]`, the KDE and macOS `main.rs` where they live.
Dependencies are in `[target.'cfg(...)'.dependencies]` tables. Edits to the old files: `fn main`
became `pub fn main`; `crate::HOME_DIR` became `super::HOME_DIR` in KDE `hotkeys.rs`.
3. `spike: target-gate the macOS daemon crate`: objc2 and friends under
`[target.'cfg(target_os = "macos")'.dependencies]` plus `#![cfg(target_os = "macos")]` in
`komorebi-macos`, to test `cargo check --workspace` on a foreign target.
The script that did step 1 is `S/pkg-spike.py` (scratchpad; rerunnable on a fresh `wip-main`).
## Results
| question | result |
|---|---|
| One lock resolves? | Yes. 859 packages (root) -> 900. All 859 Windows entries unchanged. The KDE lock had 644 and the macOS lock 786 entries, so +41 only. Crates with more than one version: 81 -> 95 (the `sysinfo` 0.38/0.39/0.40, `dirs` 6/7, `parking_lot` 0.12/0.13, `shadow-rs` 1/2, `netdev` 0.40/0.46 splits coexist; nothing needs unifying). |
| Locked versions kept? | Not exactly: crates that only KDE or macOS use were re-resolved to newest: `zbus`/`zbus_macros` 6.1 -> 6.2, `zbus_utils`, `zruntime`, `sysinfo` 0.40.0 -> 0.40.1, `libz-sys`, `unicode-width`. Pin with `cargo update zbus@6.2.0 --precise 6.1.0` (needs the `name@version` spelling) if the VM suites must see the old versions. |
| Windows `cargo check -p komorebic --target x86_64-pc-windows-msvc` (nix develop) | passes, 14.8 s wall warm (11.2 s compile); unified `komorebic` also passes, 7 s. |
| KDE native `cargo check -p komorebi-linux -p komorebic-linux` | passes; 1 m 38 s cold into a fresh lite target dir. Unified `komorebic` on Linux passes (1.4 s after touch) when openssl is available (see risk 2). |
| KDE tests unchanged | `cargo test -p komorebi-linux --lib`: 294 passed. `--test schemas -- --test-threads=1`: 5 passed. All four KDE packages, `--no-fail-fast`, 1 m 26 s warm: 879 passed, 1 failed. The failure is `tests/version.rs`: `komorebi-linux 0.1.0` instead of `komorebi 0.1.0` (clap takes the command name from `CARGO_PKG_NAME`); a renamed package needs `#[command(name = "komorebi")]`. Nothing else depends on the package name. |
| macOS fake-CC `cargo check --target aarch64-apple-darwin -p komorebi-macos -p komorebic-macos -p komorebi-bar-macos --all-targets --locked` | passes, 32 s warm (6 warnings in the bar, as before). Unified `komorebic` on macOS passes, 12 s. Type-check only. |
| Feature unification | Resolver 2 keeps `komorebi-layouts/darwin` off Windows: `cargo tree -p komorebic --target x86_64-pc-windows-msvc -e features -i komorebi-layouts` shows only `default`, the macOS package shows `darwin`. This holds only while the package that asks for `darwin` is not in the same build; `cargo ... --workspace` on one target selects them all (see risk 3). |
| `cargo check --workspace` for Windows (what clippy, fmt, nextest and crane do today) | FAILS in 52 s: `objc2 only works on Apple platforms`. With objc2 target-gated and `#![cfg(target_os = "macos")]`, `komorebi-macos` compiles empty on Windows (spike 3), so the fix is to gate every foreign-platform crate, not to exclude them. Done for one crate only. |
| Same dependency key, different path per target | REJECTED by cargo: `Dependency 'komorebi-client' has different source paths depending on the build target`. Same for `version`. So the unified package must use one key per platform (`komorebi-client-linux`, `komorebi-client-macos`, ...) and the platform module must alias it (`extern crate komorebi_client_linux as komorebi_client;` at the root, or `use komorebi_linux as komorebi;` at the top of each platform module). The spike used `extern crate`. |
| Compile time | No extra cost on a target: a build selects its own target's dependency tables, so Windows never sees zbus or objc2 and Linux never sees `windows`. The only added cost is resolution (`cargo metadata` 6.5 s with the network). |
## Option A or B
Measured size of what would have to move into `#[cfg(target_os)] mod` of one crate (Option B):
daemon `crate::` paths: Windows 669, KDE 447, macOS 587 (35,149 / 32,932 / 34,505 lines, 3 lib+bin
crates each with their own tests and a `komorebi-client` that re-exports them); bar 111 / 90 (7,710 /
5,551 lines); `komorebic` 0 (1,467 / 807 / 1,537 lines).
Recommendation:
- `komorebic`: B. One package `komorebic`, `src/main.rs` = `cfg_select!` choosing `mod windows`,
`mod linux`, `mod macos` (each the present `main.rs`, `hotkeys.rs` for Linux), one clap command name,
target-gated dependencies. Zero `crate::` rewrites, so the files move whole. This is what the spike
built (with `#[path]` instead of the final moves).
- `komorebi-bar`: B, as `bar-unification.md` already plans (`src/bar/{mod,windows,macos}.rs`,
`os/{windows,macos}.rs`); needs the bar stack integrated first.
- `komorebi` (daemon): A. Keep three library crates, rename to `komorebi-windows`, `komorebi-linux`,
`komorebi-macos` (distinct lib names, `komorebi_windows` etc.), each gated to its OS
(`#![cfg(target_os = ...)]`, target-gated dependencies, so `--workspace` works everywhere), each
keeping its own `crate::` paths and its own tests (KDE's 881 run unchanged but for the name). One
thin `komorebi` binary package: `src/main.rs` is a `cfg_select!` over the three daemons'
`main` bodies (each daemon's present `main.rs` becomes `pub fn run()` of its library). Option B for
the daemon would be a rewrite of about 1,700 `crate::` paths (669 + 447 + 587) for no behavioural gain, and it would
put KDE's tests and the VM suites on a moving target.
- `komorebi-client`: one package with `src/{windows,linux,macos}.rs` (211 / 394 / 225 lines, almost all
`pub use komorebi::...`), each starting with `use komorebi_windows as komorebi;` and so on.
## Migration order
Every revision keeps the three existing trees building with their present gates. "Gate" says what
must pass before it counts as landed: `C` compile (fast-check, the three checks), `S` the CLI oracle
(`S/step4/oracle-check.sh`, byte-identical for all three platforms; it reads `komorebic/src/main.rs`
of each tree, so it needs its paths updated in the revision that moves a file), `N` nix evaluation
(`nix flake show`), `NB` a nix build of the checks in an idle window, `E` Windows e2e, `V` KDE VM `fast`.
0. Prerequisites, no moves (any time, small): explicit `#[command(name = ...)]` on the three CLIs;
`build.rs` of `komorebic` stops fetching `applications.json` over the network (the file is checked
in; a build script that needs `reqwest`, and so openssl, on Linux is what stopped the unified
package building natively); `pub fn main` and `crate::` -> `super::` in the `komorebic` files.
Gates C, S. Not behaviour.
1. Package renames inside the present workspaces (KDE: `komorebi-linux` and so on; macOS the same;
Windows daemon `komorebi-windows` last), with `[lib] name` and `[[bin]] name` unchanged. Gates C,
N; the Windows daemon rename is `E` (the executable's inputs change).
2. Workspace merge: delete `komorebi-for-kde/Cargo.toml` and `komorebi-for-mac/Cargo.toml`, add their
crates to the root members, write out the inherited dependencies, one lock (+41 packages), add
`.cargo/config.toml` with `[env] COMMIT_HASH` (KDE's file moves from `komorebi-for-kde/.cargo`;
cargo reads it from the working directory upward only). Same revision gates every foreign crate
(`#![cfg(target_os)]`, target-gated dependencies) so `--workspace` works on all targets. Gates C on
all three, plus KDE tests unchanged. Cargo-wise this is one revision (the spike's script); it must
not be split without breaking `--locked`.
3. Flakes, same integration as 2 (nix cannot be half-merged): the root flake builds all three; the two
nested flakes already take the whole repository as their source (`lib.mkOutputs`), so they become
thin: `workspaceArgs` change from a subdirectory workspace to `-p <package>`. The KDE source filter
must list the new member directories. Gates N, then `NB` (deps, clippy, nextest of each system),
then `V`.
4. `komorebic` unified by `#[path]` (spike 2, minus the hacks): new `komorebic/src/main.rs`, target
tables, aliases. The old `komorebic-linux`/`-macos` packages stay until step 5 so the old names
work. Gates C, S, and `E` for `komorebic.exe` (the Windows main moves to `windows.rs`).
5. `komorebic` real moves, one platform per revision: `komorebi-for-kde/komorebic/src/*` to
`komorebic/src/linux/`, the macOS one to `komorebic/src/macos/`, tests with them, then delete the old
packages. Pure moves (jj does not follow moves, so each is a delete/modify conflict if another stack
touches those files; today none does). Gates C, S, tests.
6. `komorebi-client` unified (modules per platform), same pattern. Gates C, E (Windows client is in the
closure of `komorebi.exe`).
7. `komorebi-bar` unified after the bar stack integrates: `bar-unification.md` plan; Windows bar
screenshot gate and the Mac hand check are owed by that stack.
8. Daemon: three libraries gated to their OS and one thin `komorebi` package with the `cfg_select!`
`main`. KDE `main.rs` and the Windows `main.rs` become `run()` in their libraries. Gates C, `E`, `V`,
Mac hand check.
9. Cutover: one flake output per binary, old per-platform package names, `justfile`, CI
(`.github/workflows`), docs paths, release version (0.1.42 / 0.1.0 / 0.1.1 become one).
## Risks
1. One lock for three platforms: a `cargo update` for one platform moves the others; crane's dummy
source includes every member's manifest and the lock, so any dependency change rebuilds the
dependency derivation of all three systems (today a KDE-only lock change cannot touch Windows). The
`COMMIT_HASH`-constant fix (flow finding 1) must be in first or every commit rebuilds ~1,000 crates.
2. `build.rs` fetching over the network is not usable in a unified package (openssl on Linux); see step 0.
3. `--workspace` commands (clippy, fmt, nextest, crane) select every member on every target: every
foreign crate must compile empty (spike 3 shows it works for the daemon; only one crate was
converted). Without it, feature unification would also turn `komorebi-layouts/darwin` on for
Windows in a whole-workspace build.
4. The one-key-one-path rule forces distinct dependency keys and aliases per platform module.
5. `CARGO_BUILD_TARGET` is set by the root `nix develop` shell, so native Linux checks must run outside it
(as `fast-check` does) or pass `--target x86_64-unknown-linux-gnu`.
6. Command names and `--version` text come from `CARGO_PKG_NAME`/the version crate: pin them or the KDE
`version` test and the docs oracle change. `shadow-rs` major versions differ (2 on Windows, 1 on
macOS); the unified `komorebic` build script can only use one.
7. The KDE VM suites rebuild on any change to the KDE closure: the merge is one full `V` run.
8. Tests that use `CARGO_BIN_EXE_*` or relative paths (`tests/schemas.rs` writes beside the manifest)
must move with their package; not exercised beyond the spike.
## Gates by step, in short
Compile only: 0, 4 (but see `E`), 5, 6 at the Rust level; nix evaluation only: 3 until built. Needs
e2e (Windows guest): anything that changes an input of `komorebi.exe`, `komorebic.exe` or the client
(`tools/e2e-needed` says: 1 for the Windows daemon, 4, 6, 8). Needs the KDE VM: 2, 3, 8. Needs a Mac,
by hand: 4, 7, 8, 9.
Mac hand check (type-check proves none of it): `komorebic --version` and `--help` show the macOS
command set and the name `komorebic`; `komorebic start` finds and starts `komorebi`, `stop` stops it;
`komorebic docgen` unchanged; `komorebi --version`; the daemon starts, tiles and `komorebic state`
answers; `komorebi-bar` opens, `--schema` equals `komorebi-for-mac/schema.bar.json`;
the embedded `applications.json` is the macOS one;
`otool -L` of each binary lists no Windows or Linux-only library.
## Conflicts with the open stacks (sequence in a quiet period)
Paths touched by each bookmark relative to `wip-main`:
| bookmark | touches | moves in this plan that conflict |
|---|---|---|
| wip-u-kfw | `komorebi/src/**`, `crates/komorebi-backend/**` | daemon rename and any move of `komorebi/` (steps 1 Windows, 8) |
| wip-u-kfm | `komorebi-for-mac/komorebi/src/**`, `crates/komorebi-backend/**` | macOS daemon rename and moves (1, 8) |
| wip-u-kfde | `komorebi-for-kde/komorebi/{src,tests}/**` | KDE daemon rename (1) and moves (8); tests are edited |
| wip-u-bar | `Cargo.lock`, `komorebi-for-mac/Cargo.lock`, `komorebi-bar/src/**`, `komorebi-for-mac/komorebi-bar/src/**`, `crates/komorebi-bar-core` | step 2 (locks, manifests) and step 7 |
| wip-u-settings | `Cargo.toml`, `Cargo.lock`, `crates/komorebi-settings` | step 2 (root manifest and lock) |
| wip-u-nix | `flake.nix`, `komorebi-for-kde/flake.nix`, `komorebi-for-kde/nix/**` | step 3 |
Not touched by any open stack, so safe now: `komorebic/**` (all three), the `komorebic` tests, the
`version` crates, the `komorebi-client` crates (steps 0, 4, 5, 6 are free of conflicts except the lock
and root manifest lines of step 2/4). Hard conflicts: every `Cargo.lock` and the root `Cargo.toml`
`members` list (resolve by taking one side and running `cargo metadata`; never hand-merge a lock),
`flake.nix` lines for the extracted binaries. Suggested order: integrate kfw, kfm, kfde, bar, settings,
nix first; then steps 0 and 1; then 2 and 3 as one integration; the rest in any order, daemon (8)
last.
## What landed
Only this file. The spike revisions are on `wip-u-pkg-spike` and can be dropped or cherry-picked.
Step 0 and the renames were not landed because they only pay off with step 2, which edits the locks
and manifests that three open stacks edit.