Galaxy Shell / docs
Docs / Architecture and development

Active project in the home directory and Smithay recovery

openspec/specs/project-loading/spec.md · Edit on GitHub ↗

On this page

Active project in the home directory and Smithay recovery

Purpose

Makes the login run the active Git checkout in the home directory, with build preparation, a single independent Smithay recovery fallback and explicit coordination of updates.

Requirements

Requirement: Checkout update changes only the next login

Updating the checkout SHALL change only the origin of the next login: it MUST NOT update processes already open, run git pull automatically or replace the customized UI of the profile. Full text: section File origin.

Scenario: Checkout synchronized

  • WHEN the active checkout is updated
  • THEN running processes keep their loaded code until the next login

Requirement: Paths stay in the home directory

The login configuration project.json SHALL use absolute paths for sourceRoot, fallbackRoot, profile and buildEnv, and all paths SHALL stay inside the home directory. Full text: section File origin.

Scenario: Reading project.json

  • WHEN the login reads project.json
  • THEN all paths are absolute and inside the home directory

Requirement: Build stamp only after success

prepare-project.py SHALL write .project-build.json only after success and only if the sources did not change during the build; npm ci alone MUST NOT count as proof of the Electron distribution. Full text: section File origin.

Scenario: Sources change mid-build

  • WHEN the sources change during the build
  • THEN the stamp is not written

Requirement: Single fallback

A preparation failure or a non-zero exit of the active session SHALL try the fallback exactly once with the same profile; an intentional logout, a requested shutdown and a busy profile MUST NOT trigger it, and if the fallback fails the session ends at the login. Full text: section Recovery.

Scenario: Fallback fails

  • WHEN the fallback also fails
  • THEN the session ends at the login

Requirement: No fallback while locked

A failure while the session is locked MUST NOT start the fallback, and both smithay-session.py and the dispatcher SHALL end the login and record ended-locked. Full text: section Recovery.

Scenario: Locked failure

  • WHEN the active session fails while locked
  • THEN the login ends with ended-locked

Requirement: Recovery does not depend on the shell

Recovery MUST NOT depend on Node, Electron, the provider or the conversation to decide which version to start. Full text: section Recovery.

Scenario: Provider down

  • WHEN the provider is unavailable
  • THEN recovery still chooses the version

Requirement: Known-good fallback is not promoted automatically

The known-good version SHALL be preserved until a new login is validated, the mutable checkout MUST NOT be promoted to fallback automatically, and a manual rollback MUST NOT restore state.json, databases or checkpoints of the profile. Full text: section Recovery.

Scenario: Rollback

  • WHEN the login configuration is rolled back manually
  • THEN only the wrapper or symlink and project.json from previous-login/ are restored

Requirement: Do not renew the recovery release now

The recovery release MUST NOT be renewed and install.sh MUST NOT be run until the owner confirms a physical login with the wgpu renderer. Full text: section Prepare and configure.

Scenario: Installer without fallback-root

  • WHEN install.sh runs without --fallback-root
  • THEN it would register the new release as the recovery, so it must not run before the owner confirms

Requirement: Configuration under coordination.lock

The configurator SHALL hold an exclusive coordination.lock and record start and completion under flock; a busy lock SHALL stop the operation, and the compositor or host MUST NOT be restarted to apply only a next-login configuration. Full text: section Coordination and activation.

Scenario: Busy lock

  • WHEN coordination.lock is busy
  • THEN the operation stops

Requirement: Synchronize by fast-forward only

sync-active-checkout.py SHALL take flock -n on coordination.lock, refuse a checkout that is dirty, not on main or not an ancestor of origin/main, run git merge --ff-only origin/main and prepare the build; it MUST NOT fetch, push or start, signal or restart any process. Full text: section Synchronize the active checkout.

Scenario: Dirty checkout

  • WHEN the active checkout has untracked files
  • THEN the script refuses with dirty-source-root

Requirement: A sync line does not prove the session runs a commit

A synchronized and prepared checkout SHALL change the next login only, and the user MUST NOT be told that the shell is updated from a sync line alone; a process that started before the sync does not run the commit. Full text: section Does the running session have a commit?.

Scenario: Old process

  • WHEN a compositor started before the sync complete line
  • THEN it does not run the commit

Requirement: Separate steps

Publishing to main, preparation, next-login routing and actual execution SHALL be kept as separate steps, and final acceptance of a new login SHALL require the user to follow along and confirmation of the root through the UI and the processes. Full text: section Plan and continuity.

Scenario: Published commit

  • WHEN a commit is published to main
  • THEN the next login is still not declared updated

Requirement: Session restore records only ids and states

The window-session.json record SHALL store only application IDs and window states with no titles, command lines, documents or credentials; applications with no catalog match MUST NOT be run from an arbitrary appId, and there SHALL be no automatic retry in the same login. Full text: section Restoring applications between logins.

Scenario: Unknown application

  • WHEN a saved application has no catalog match
  • THEN it is not run and appears in sessionRestore.unsupported

Requirement: Shared dependencies are immutable

Shared packages SHALL be treated as immutable: files in node_modules MUST NOT be edited and npm ci, install or update MUST NOT be run on that link; links to unmanaged directories are refused. Full text: section Shared cache between worktrees.

Scenario: Dependency change

  • WHEN dependencies must change
  • THEN a separate local installation is used and a new worktree is prepared

Requirement: Shared Rust cache rules

Worktree gates SHALL use the shared cache and MUST NOT use --local only for safety; cargo clean and manual builds MUST NOT be run directly in the shared cache, locks MUST NOT be removed to force concurrency, and when fmt or Clippy did not run this SHALL be reported and not reported as passed. Full text: section Shared cache between worktrees.

Scenario: No rustfmt component

  • WHEN the toolchain has no rustfmt or Clippy component
  • THEN the report says fmt or Clippy did not run

Requirement: Synthetic cores must not inherit the desktop

npm test SHALL use an environment without inherited AGENT_NATIVE_*, DISPLAY and WAYLAND_DISPLAY variables, and tests and QA that start cores manually SHALL apply the same isolation. Full text: section Synthetic cores must not inherit the real desktop (2026-10-28).

Scenario: Core started by a test

  • WHEN a test starts core/server.js
  • THEN it has a disabled backend and no connection to the real socket

Requirement: Host/core update preconditions

Updating host/core in the current session SHALL hold coordination.lock, require ready=true, a connected compositor and no pending turn, approval, preview, change, login or model switch, and terminate only the exact core and, if needed, the exact Electron host, never the parent process, the compositor, process groups or executables by name. Full text: section Update host/core in the current session.

Scenario: Turn pending

  • WHEN a turn is pending
  • THEN the update does not proceed

Requirement: Instance lock files are not deleted

The existence of .instance.guard and .instance.lock MUST NOT be treated as permission to delete them. Full text: section Update host/core in the current session.

Scenario: Stale-looking lock

  • WHEN .instance.lock exists
  • THEN it is not deleted

Requirement: Private Electron runtime

The shared Electron distribution in node_modules MUST NOT be patched; preparation SHALL copy it to runtime/electron-host and disable only the nodeCliInspect fuse, and MUST NOT replace an executable used by a running host. Full text: section Private Electron host runtime.

Scenario: Preparation with a running host

  • WHEN preparation runs while a host runs
  • THEN the running executable is not replaced

Status

Doc status: current contract. Home checkout and Smithay recovery; the immutable-base direction in openspec/specs/immutable-base/spec.md is a separate proposal. Checked 2026-11-12.

Introduction

The product compositor is Smithay. The bridge and the River WM were removed, as were the session scripts and the River release installer. The existing data directory can still be called river-shell: that name preserves the profile, it does not select a backend. River records in docs/ are historical.

File origin

The suggested active folder is ~/galaxy-shell, a normal Git checkout, editable and updated explicitly by the user or the agent. The login reads ~/.config/agent-native-os/project.json, with absolute paths for sourceRoot, fallbackRoot, profile and the buildEnv map. All paths stay inside the home directory. XDG_CONFIG_HOME and XDG_STATE_HOME are respected.

The wrapper at ~/.local/bin/agent-native-smithay-session calls a small Python dispatcher in ~/.local/state/agent-native-os/dispatch/. This dispatcher and the session supervisor are independent copies of the mutable sources, so recovery survives an invalid edit or a missing checkout. The host, core, shell scripts, React seed and compositor are read and built in the active folder. There is no full copy of the application installed on each update.

The configurator copies project-session.py, smithay-session.py, session-supervisor.py, electron_runtime.py (which the supervisor imports) and the three supervisor_policy*.py modules into ~/.local/state/agent-native-os/dispatch/<id>/. The login runs these copies, not the files of the checkout, so the list must hold every module of scripts/ that they import: until 2026-11-11 electron_runtime.py was missing, and the first dispatch folder made after the supervisor began to import it (the install.sh of 2026-11-10) ended the login and the recovery start with ModuleNotFoundError right after the compositor came up. scripts/test/test_project_session.py now checks the imports of the copies. At login, project-session.py runs prepare-project.py --root <sourceRoot>. Then the copy of smithay-session.py starts the compositor binary of sourceRoot, and the copy of session-supervisor.py starts the Electron host and the core of sourceRoot. So:

  • A change to the compositor, the host, the core or the UI needs only a synchronized checkout and a new login.
  • A change to scripts/project-session.py, scripts/smithay-session.py, scripts/session-supervisor.py or the guardians needs the configurator again (scripts/install.sh, see below), which installs a new dispatch directory. A synchronized checkout alone does not change these copies.
  • A change to scripts/supervisor_policy.py can reach the running guardians through scripts/update-supervisors.py (see Updating supervision during a session). The dispatch directory keeps its own copy, so run the configurator too when the next login must start with the new policy.

Before it starts the compositor, prepare-project.py computes the hash of the relevant sources. When needed, it installs the lockfile dependencies, generates the React seed, checks syntax and build, and compiles Rust with session. It writes .project-build.json only after success and only if the sources did not change during the build. The preparer explicitly runs the installer of the Electron package and tests the native executable in Node mode, checking its version. npm ci alone is not proof that this distribution was obtained. The binary and Electron must exist. When the build is reused, the preparer also checks the hashes of the binary, of the three seed files and of the lockfile marker. The runtime/, node_modules/ and target/ directories are local dependencies and artifacts ignored by Git. The runtime must contain pinned Node and OpenCode, or make them available through the configured PATH. The Rust toolchain, npm and the headers and libraries must stay reachable after a reboot.

Updating the checkout changes the origin of the next login. It does not update processes that are already open, does not run git pull automatically and does not replace the customized UI of the profile. The customized CSS stays under read_ui/replace_ui and its journal. Legacy HTML/JavaScript stays preserved in the revisions, but it does not run in the trusted UI and replace_ui cannot edit it. A change to the seed does not overwrite it.

Prepare and configure

With the checkout and the dependencies available, use:

python3 scripts/prepare-project.py --root "$HOME/galaxy-shell"
scripts/install.sh --source-root "$HOME/galaxy-shell" \
  --profile "$HOME/.local/share/agent-native-os/river-shell"

The profile must be the one that the existing session really uses. Do not copy the example without checking it. The installer also records PATH and the build variables of the shell that runs it as buildEnv, so run it from the shell of the user. Without --fallback-root, the installer builds a read-only release of the commit of the checkout with scripts/build-release.py, in ~/.local/share/agent-native-os/releases/, and registers it as the fallback (openspec/specs/immutable-base/spec.md). This needs a clean, prepared checkout. The login still runs the checkout: the release is only the recovery. To renew it, run the installer again. --fallback-root names another copy instead: it must be separate, contain the Smithay compositor and the shell supervisor, and have been validated before. An existing Smithay release can be preserved for this role during the migration. The current production build is at native/smithay/target/release/agent-native-compositor. The earlier path without target is accepted only to recover existing releases.

Warning (GLES removal, step 8). A release built from the current checkout has no GLES. Running scripts/install.sh without --fallback-root (or otherwise renewing the recovery release) would register the new release as the recovery in place of releases/20261110-6566fa54a959, the only way back that still has GLES, which decision H (Step 6 result of openspec/changes/archive/2026-11-10-gles-removal-plan/design.md) depends on. The first renewal does not delete the old release: scripts/configure-project.py reads the registered recovery before it changes the registration and keeps it in the cleanup, so it stays on disk but is no longer the registered recovery, and a later renewal can remove it. Do not renew the recovery and do not run install.sh until the owner confirms a physical login with the wgpu renderer. No code guard is described here.

install-smithay.sh forwards to the same configurator. The compatibility name agent-native-session also starts Smithay now. The configurator refuses sources or artifacts that changed since the preparation. It preserves the previous launcher and configuration in previous-login/ in the dispatcher directory and swaps the files by rename. It does not touch the profile, does not start graphical processes and does not end the current session. The initial preparation of a new checkout requires dependencies, and the configurator does not do it.

The minimal global GDM registration is still needed to offer the user session. If it already calls agent-native-smithay-gdm, it keeps following the user wrapper without reinstalling the whole desktop. scripts/register-smithay-session.sh, run as administrator, updates the Smithay registration. It removes only the obsolete entry agentic-shell.desktop, and only when it identifies the launcher of this project. It does not remove system packages or entries of other desktops. Without administrative privileges, this old entry can stay visible, but the user compatibility wrapper starts Smithay.

Recovery

The direction for this section is an immutable base with an overlay, instead of a separate clone: see immutable-base.md. It is a proposal, and this section stays the current contract until its phases land.

A preparation failure or a non-zero exit of the active session tries the fallback exactly once, with the same profile. The dispatcher prints RECOVERY and writes the phase and the effective root to project-session.json. It does not present the recovery as if it were the current version. The core exposes this record in system_context.supervisors.project. The shell supervisor keeps recovering host/core without restarting a healthy compositor.

The recovery start asks for OpenGL and, for an older release, for GLES: the dispatcher (and smithay-session.py --fallback-root) exports both AGENT_NATIVE_GPU_API=gl and AGENT_NATIVE_RENDERER=gles before it starts the fallback, so a known-good release does not repeat a failure of the wgpu renderer on Vulkan. This is a decision of the coordinating session of 2026-11-11 (openspec/changes/archive/2026-11-10-gles-removal-plan/design.md, Step 6 result), not of the owner. The reason: the owner has not yet done a physical login with the default wgpu renderer, and the registered recovery release (releases/20261110-6566fa54a959) still has GLES and uses it only when it gets AGENT_NATIVE_RENDERER=gles. A compositor of step 6 or later has no --renderer, ignores that variable silently (no error, no warning, no log line) and takes AGENT_NATIVE_GPU_API=gl; an older release with GLES takes the first variable and ignores the second. Without the GLES variable a wgpu failure on this machine would take down the login and the recovery together before the owner has seen wgpu on a screen. The AGENT_NATIVE_RENDERER=gles export is removed only when the registered recovery release no longer has GLES. The recovery records gpuApiAsked: "gl" in project-session.json (and in supervisor-smithay-recovery.json), where step 5 and earlier wrote rendererAsked: "gles"; the core passes the file through system_context.supervisors without reading that field. To keep the normal login off Vulkan, create the empty file ~/.config/agent-native-os/gpu-api-gl (from a text console, Ctrl+Alt+F3, when the screen is unusable) and log in again; smithay-session.py then adds --gpu-api gl (openspec/changes/archive/2026-11-10-gles-removal-plan/design.md, Step 5 result), as no-dmabuf adds --no-dmabuf: the compositor never opens the Vulkan device, and a failure of OpenGL ends the start and runs the recovery. If a rollback file exists and its flag is not applied (a release without --gpu-api, which runs on Vulkan only), the login log gets a line "rollback file ... not applied" with the reason. Delete the file to return to the default. The file renderer-gles of 2026-11-10 is no longer supported (step 6, 2026-11-11): a file that is left over is inert on purpose (the owner's "Remover de vez": it is not mapped to --gpu-api gl), so it adds no flag and the login starts as without it, on the wgpu renderer with the default API; one stderr line says that it does nothing and that its replacement is the file gpu-api-gl, which keeps the wgpu renderer on OpenGL. All of these are in the dispatch copies, so they need scripts/install.sh once (see File origin).

An intentional logout and a requested shutdown do not trigger the fallback. A busy profile does not trigger it either: locks are checked before the build and again before the compositor starts. If the fallback fails, the session ends at the login. A failure while the session is locked must not start the fallback, because a fallback built before the lock marker ignores it and starts unlocked. Both smithay-session.py --fallback-root and this dispatcher (project-session.py, with session_locked(env) from smithay-session.py) end the login in that case and record ended-locked (see lock-screen.md). Recovery does not depend on Node, Electron, the provider or the conversation to decide which version to start. Running the recovered environment still requires its dependencies. A compositor crash disconnects Wayland applications and does not recover unsaved documents.

Preserve the known-good version until a new login is validated. Do not promote the mutable checkout to fallback automatically. In a manual rollback of the login configuration, restore the wrapper or symlink and the project.json preserved in previous-login/. Do not restore state.json, databases or checkpoints of the profile.

Coordination and activation

Before you change login routing, read AGENTS.md and coordination.log, and discover the session, compositor, release, profile and supervisors. The configurator holds an exclusive coordination.lock and records start and completion under flock in the log itself. A busy lock stops the operation. Do not restart the compositor or host to apply only a next-login configuration.

A source change approved through the review card (self-maintenance.md) takes coordination.lock, logs start and complete or blocked, and fast-forwards the clean active checkout. That is the "publish" step only. It does not prepare the build, does not touch the login routing and does not restart anything. The core and the compositor change at the next login. The core reads the host pages, the trusted UI bundle and the protected panel assets from the checkout on each request, so those can change at the next reload of the interface.

Synchronize the active checkout

After a commit reaches main, synchronize the active checkout with:

python3 scripts/sync-active-checkout.py --label <worktree-or-chat-id>

The script reads sourceRoot from ~/.config/agent-native-os/project.json and takes flock -n on coordination.lock for the whole operation. Under the lock, it reads coordination.log again and checks the real checkout. It refuses a checkout that is dirty (untracked files count), not on main, or not an ancestor of origin/main. Then it appends a start line to coordination.log, runs git merge --ff-only origin/main and runs prepare-project.py --root <sourceRoot> with the buildEnv of the configuration. At the end it appends complete with result=prepared-no-process-restart, or blocked with a reason code: lock-busy, dirty-source-root, not-on-main, no-origin-main, not-fast-forward, merge-failed or prepare-failed. Each line holds the label, the source, base (the earlier HEAD) and commit (the target). The exit status is 0 on success, 2 for a busy lock, 3 for a refused checkout and 4 for a failed preparation. After a failed preparation the checkout is already fast-forwarded; the next login runs the preparation again and can start the fallback.

The script does not fetch, does not push and does not change the login routing. It never starts, signals or restarts a process. Nothing runs git pull at login. The script does not reinstall the dispatch copies (see File origin).

Does the running session have a commit?

A synchronized and prepared checkout changes the next login only. The compositor, the Electron host and the core that already run keep the code that they loaded, until a new login or the host/core maintenance. A host page or a UI asset can change at the next reload of the interface, because the core reads them from the checkout on each request. To tell whether a running process has a commit, compare its start time with the time of the complete line of the sync that brought the commit:

ps -o pid,lstart,args -p <compositor-pid>,<host-pid>,<core-pid>
grep ' sync-active complete ' "${XDG_STATE_HOME:-$HOME/.local/state}/agent-native-os/coordination.log" | tail

A process that started before that sync does not run the commit. On 2026-10-31 the running compositor, host and core predated six syncs, so the session did not show any of those changes. Do not tell the user that the shell is updated from a sync line alone.

Plan and continuity

Record a persistent plan with the active origin, fallback, profile, process identity and rollback. Check continuity before and after. Keep publishing to main, preparation, next-login routing and actual execution as separate steps. Final acceptance of a new login requires the user to follow along, and it requires confirmation of the root through the UI and through the processes. Synthetic loading tests do not prove DRM or physical input.

Migration evidence of 2026-10-27

npm ci, format:check, check/build:check and 90 Node tests passed. 22 Python tests cover preparation, source changes between logins, build failure, single fallback, logout, busy profile, removal of the old debug launcher, refusal of stale preparation and preservation of the profile. The Smithay crate passed 16 tests with session, cargo fmt and Clippy with warnings treated as errors. The release build in the active folder finished with persistent dependencies, with no /tmp tool paths in the login configuration. ldd resolved the libraries and --help ran without opening a compositor.

Browser: the UI of the new core opened with a synthetic profile. The query /, clearing with Escape and the protected page /recovery were exercised without a provider. Electron: no new instance started in this migration. Real system: next-login routing was configured under lock. Five main processes kept PID and start time, and the hashes of state.json and interface.json stayed the same. The installed dispatcher refused to start inside the existing desktop. There was no new login, no compositor restart and no DRM proof of the new origin.

The active folder was configured at ~/agent-native-os and the existing profile was kept. The Smithay version in use was preserved as recovery. The user River debug launcher was archived and removed. The two user launcher entries now go through the Smithay dispatcher. The old global GDM entry still requires the administrative run of the updated registration, because passwordless sudo was not available. This pending item does not stop the user wrapper from starting Smithay.

Fix after the first login of the active folder

The next login started the DRM compositor from the active folder, but the shell supervisor failed with FileNotFoundError: npm ci had not installed the native Electron distribution. The preparation wrongly recorded a valid build even without this executable. After 90 seconds without a healthy shell, the dispatcher recovered the previous Smithay version. That old version did not include the web clock and battery or the / search. Therefore the first login did not validate the migration of the origin.

The preparation now runs node node_modules/electron/install.js explicitly, requires execute permission and a version consistent with the pinned package, and runs ELECTRON_RUN_AS_NODE to check the real loading. The hashes of Electron and of dist/version are part of the prepared artifacts. The configurator repeats the native proof before it accepts the routing. The Python tests include a missing distribution, missing permission, divergent version, executable error and explicit installer call. A failure now blocks the preparation before the compositor starts.

The fix passed 24 Python tests and 90 Node tests, plus formatting and check/build:check. The installed Electron executable started the real core in Node mode with a synthetic profile and an unavailable provider. Through the browser connected to that core, the bar showed a clock and the real battery. / opened eight suggestions and Escape cleared the query. The QA core was shut down. This proof confirms the native executable and the web flow. Repeating the direct login remains a separate validation step.

Restoring applications between logins

The core writes window-session.json to the profile when it observes real Smithay windows. At the next login, it waits for the protected host. Then it reopens the windows recognized by the local catalog and the shell terminals, and it reapplies the workspace, minimization/maximization and the supported active layout (focus, tile or monocle). Child dialogs are not relaunched separately. The identity of the compositor prevents repeating the openings when only the host/core restart or when the bridge reconnects. Instances that are already visible are counted before others are opened. Windows closed during use leave the record. Disconnection and absence of the host do not erase the last state.

The file stores only application IDs and window states, with no titles, command lines, documents or credentials. Since 2026-10-31 (decision D6 of the tiling specification), each tiled window of the primary output also has its Wayland appId and its cells rectangle in the record. At the next login, after the windows are open and bound, each restored window takes the first saved rectangle with its app id on its workspace, through the typed grid_restore command, which gives all the saved cells of the workspace in one step (capabilities.gridRestore, since 2026-11-04, because the grid fills itself and no cell stays free), or on an older compositor through the typed place command with only_free: true, if those cells are free. A rectangle that cannot be taken is skipped, and that window keeps the cells that the grid gave it. A refusal, a missing capabilities.grid or a malformed rectangle never blocks or fails the restore; an old record without these fields restores without placement. When the compositor already reports the grid layout, the restore does not send the saved grid layout again, because that even fill would take the saved cells. Limit: on each restored workspace, the chat and the windows placed before often hold the saved cells, and then the window stays where the grid placed it. The chat itself has no saved rectangle. Applications with no match in the catalog are not run from an arbitrary appId. They appear in the counter desktop_state.sessionRestore.unsupported. Open failures go to sessionRestore.errors. There is no automatic retry in the same login, including after an interrupted restoration. An invalid file is preserved and blocks only the restoration. The status is a bridge diagnostic, not a new visual interface.

Since 2026-11-01 the restore groups the saved windows by workspace. It shows each saved workspace through the desktop client (setWorkspace with no animation), sends the saved layout of that workspace, opens or reuses and binds the windows of that workspace, places the cells, and replays minimization/maximization last. A replay before the layout or before the cells was lost: in the grid layout a maximization is the zoom of the grid, which a later layout focus, open or place ends, and a window that already runs belongs to the shown workspace only after its bind. A failed replay is an entry in sessionRestore.errors; the window keeps its saved workspace. The workspace that was active at login comes last, so the restore ends there. Before this change every window opened on the active grid, split its chat and left those cells free after the bind. A window that already runs is bound and is not opened again. A failed switch is an entry in sessionRestore.errors, and the windows of that group open on the workspace that the compositor shows. A workspace switch that the core did not send, for example one that the compositor makes, ends the switches of the restore. Since then the core refuses a workspace switch by the user while the restore runs (WorkspaceNavigation.selectConversation, with the message "Aguarde a restauração dos aplicativos antes de trocar de sessão."), a shortcut or wheel switch is dropped without an error, the bars disable the workspace controls from wm.sessionRestore.phase, and a scheduled intent waits for the end of the restore. The restore clears the flag in a finally. The record keeps workspaceLayouts, the layout of each workspace from the compositor snapshot, and still keeps one layout for older cores; the record version stays 1. A record without workspaceLayouts has one layout for the workspace that is active at login. If that record also has no cells, a compositor without the grid wrote it, and its focus (the old default) gives way to the grid default. The grid goes as tile on the wire. A refused layout and a lost connection during placement are entries in sessionRestore.errors; a refused placement is not. A window that the user holds keeps its cells, and each place carries the held set. The restore shows each workspace for a moment at login, and the chat keeps the conversation of the active workspace during those switches.

Documents, tabs, terminal directories and unsaved content depend on the recovery of each application. The bridge has no command that places a window at free coordinates. The record keeps no pixel geometry and no floating flag, so a window that the user moved or resized with the mouse returns to the layout at the next login. The restoration does not promise exact coordinates or sizes, and it does not promise to recover processes that were lost before the first record. Pair is recomposed by the default layout at the next login. The first login with the feature needs a previous record to reopen applications.

Validation: 95 Node tests, including five synthetic restoration scenarios, formatting and check/build:check. There was no logout and no new compositor to validate the real graphical cycle. Acceptance of the next login remains separate. The old global River entry requires administrative authentication when passwordless sudo is not available.

Updating supervision during a session

The prepared dispatch includes the two guardians and the policy modules, pinned together. After the first login with this bootstrap, scripts/update-supervisors.py --policy scripts/supervisor_policy.py transactionally replaces the decision workers and keeps the session processes. The old bootstrap requires a new login before it accepts this command. Guardians and protocol are not replaced at runtime. See the contract and the rollback proofs.

Association fix during login restoration (2026-10-28)

Windows that were already open at the start of the restoration now receive the saved workspace, like the relaunched ones. Before, they were counted to avoid duplication, but they kept the transient association of the login. Normal workspace observation is suspended while the restoration waits for the host or relaunches applications. This stops the selected workspace from competing with the persisted destination. A failure to restore minimization/maximization is reported and does not stop the bind to the saved workspace. Identification still works by application and count, without using titles or commands. Two windows of the same application have no persistent document identity. The profile format stays compatible.

Validation: npm ci, format:check, check/build:check and 178 Node tests with concurrency 1. Regressions cover already-open applications, native update before the host and during relaunch, preservation of the destination after the restoration, and client state failure. An earlier concurrent run showed an ACK rejection in the reconnection fixture. The sequential suite passed without changing the assertions. No session was ended to prove a new graphical login.

The fix was activated in the existing session by a supervised restart of the core/host only. The compositor and the external window stayed the same. The ChatGPT binding was repaired to the first open workspace. API, native state, the next-session record and the verified DRM capture showed the same association, with the application visible and focused. History, sessions, preferences and interface were compared by hash, excluding only the intentional workspace selection. No turn was sent to the provider. This acceptance covers the Electron host and the real composition. It does not replace repeating a full login.

Shared cache between worktrees

New Git worktrees (root with a .git file) automatically use the cache in ${XDG_CACHE_HOME:-$HOME/.cache}/agent-native-os/build-v1. Normal clones, including the active folder in the home directory and the fallback, keep local dependencies. --shared and --local select the mode explicitly. AGENT_NATIVE_BUILD_CACHE_DIR allows another cache directory. No command in this section starts graphical processes, changes the profile or configures the login.

# At the worktree root: install/reuse npm and Electron for development.
python3 scripts/prepare-project.py --root "$PWD" --dependencies-only
cd web-shell
npm run format:check
npm run check
npm test

node_modules of a new worktree becomes a link to a shared full installation. The key includes package.json, package-lock.json, the project .npmrc, the Node/npm version, the system and the architecture. An exclusive lock prevents concurrent installs of the same key. A temporary folder is published only after npm ci and the native Electron check. A failure does not publish a partial installation. Changing the lockfile publishes another entry and swaps only the link of that worktree, which preserves the users of the previous entry. Root install hooks, npm workspaces and local dependencies require --local, because they depend on the checkout. There is no migration to pnpm and no change to the lockfile.

Existing local node_modules installations are not moved or deleted: they stay in the local flow. Links to unmanaged directories are refused. Treat the shared packages as immutable: do not edit files in node_modules, do not run npm ci/install/update on that link and do not run package installers on it. To change dependencies, use a separate local installation, update the manifests and lockfile, and prepare a new worktree again. To prepare in local mode, use a checkout with a local or missing node_modules. The preparer refuses to convert existing links automatically.

# Full build: local UI, shared Rust cache, local final compositor.
python3 scripts/prepare-project.py --root "$PWD"
# Other Rust checks use the same cache, without duplicating target in each worktree.
python3 scripts/prepare-project.py --root "$PWD" --cargo test --locked --features session
# The GPU render tests are ignored by default; a compositor change runs them too.
python3 scripts/prepare-project.py --root "$PWD" --cargo test --locked --features session -- --ignored native_wgpu_ --test-threads=1
python3 scripts/prepare-project.py --root "$PWD" --cargo clippy --locked --features session --all-targets -- -D warnings
# The build without session (nested and headless development) stays warning-free too.
python3 scripts/prepare-project.py --root "$PWD" --cargo clippy --locked --all-targets -- -D warnings
# rustfmt with the crate manifest; no target directory and no cache.
python3 scripts/prepare-project.py --root "$PWD" --cargo fmt --check
python3 scripts/prepare-project.py --root "$PWD" --cargo check --locked --all-targets --features session
# Compile-only gate of the compositor and its tests.
python3 scripts/prepare-project.py --root "$PWD" --cargo check --locked --features session --tests

A full preparation builds the feature session. The wgpu renderer is not a feature since step 10 of openspec/changes/archive/2026-11-10-gles-removal-plan/design.md (2026-11-11): every build links it, the only renderer of a login and of a headless run. The empty wgpu-renderer feature name that step 10 kept for the gate commands went in step 11 (2026-11-12): --features session,wgpu-renderer is now an unknown feature and cargo refuses it. The wgpu-effects feature, which built the GLES-to-Vulkan effects bridge, was removed on 2026-11-10 (openspec/changes/archive/2026-11-10-gles-removal-plan/design.md, step 2).

Build features and the fallback. There is no retry and no build without the renderer (steps 8 and 10 of openspec/changes/archive/2026-11-10-gles-removal-plan/design.md, 2026-11-11). A compile error in native/wgpu-renderer ends the preparation, the binary of before stays in place, and the dispatcher runs the recovery release (the single-fallback rule above). A build without session (the nested and headless development build) refuses --session with "build with --features session for DRM/TTY support" before any socket or backend exists. .project-build.json records the features of the binary in cargoFeatures and its renderer in renderer (wgpu), which scripts/build-release.py copies into the identity of a release. A stamp without renderer is rebuilt once: it was written by a build of steps 8 and 9 (session,wgpu-renderer) or by the old GLES fallback build (session alone, like the build of today), and a release of a stamp without the keys records them as null. A failure of the build keeps the stamp out, so the next preparation of the same sources builds again. After a failure that was not in the sources (a full disk, memory), remove .project-build.json and prepare again. The first preparation after step 10 rebuilds the compositor crate once for the new stamp; later builds reuse the shared cache.

The distribution Rust packages link only cargo and rustc into /usr/bin. rustfmt, cargo-fmt and cargo-clippy stay in the versioned toolchain directory, for example /usr/lib/rust-1.93/bin, so a plain cargo fmt or cargo clippy fails with "no such command" although the components are installed. When one of them is missing from PATH, --cargo appends to PATH, for that cargo run only, the first directory that has all the missing components: the real directory of cargo (the symlink resolved) or the bin directory of rustc --print sysroot. Both belong to the toolchain in use, so no version is hardcoded and a newer toolchain is found the same way. A component that is already on PATH keeps its place. The review card gates (openspec/specs/self-maintenance/spec.md) run fmt the same way.

Only when the toolchain in use has no rustfmt or Clippy component at all does the preparer still report "no such command". Then --cargo check with --all-targets is the fallback gate: it compiles the tests too, but it does not check the format or the Clippy lints. Report that fmt or Clippy did not run, and do not report that they passed.

The Rust cache is separated by the version and identity of rustc and Cargo. Cargo still checks sources, features, dependencies and flags. Branches may need to recompile the compositor crate, but they reuse compatible dependency artifacts. The preparer lock serializes build, test, check and clippy in the same cache, and it stays held until the final executable is copied. The full build atomically copies the binary to native/smithay/target/release/agent-native-compositor of each checkout. This copy is neither a link nor a hardlink: a build from another branch does not replace the executable of that version. --cargo runs only build, test, check, clippy and fmt and does not publish the local executable. Use the full build to prepare an executable version. Cargo hashes the compositor crate without its absolute path, so every worktree writes the same crate outputs in the shared target. Under the lock, the preparer touches the crate sources (including the embedded themes and shaders) before each run, so cargo always rebuilds the crate of this checkout and runs its own tests. Do not use --local for worktree gates only for safety: it rebuilds every dependency from scratch. On 2026-10-31 a shared test run took 6 to 14 seconds, and two worktrees at different commits each reported their own test count. Old local target directories are not deleted. Do not run cargo clean or manual builds directly in the shared cache.

The cache has no automatic collection. Remove an npm entry only after you confirm that no worktree keeps a link to it. Cleaning builds requires that no compilation is in progress. Do not remove locks to force concurrency. The preparer does not migrate dependencies of the session in use, does not clean worktrees and does not turn the cache into a fallback. Publishing this adaptation does not update the active checkout or the supervisors that are already open.

Validation of the adaptation on 2026-10-28: real installation via npm ci, formatting, check/build:check and 178 Node tests passed. The reuse proof checked the same Electron inode in three checkouts, with native execution in Node mode. Two small synthetic crates were compiled by the real Cargo in the same cache, which preserved the independent result of each version. The Python tests cover concurrency, lockfile and runtime changes, install and build failure, and preservation of local installations. No browser, Electron host or compositor was opened for this adaptation. There was no synchronization of the active folder and no change of profile or login.

Synthetic cores must not inherit the real desktop (2026-10-28)

The investigation of spontaneous collapses found HTTP tests that started core/server.js with another data directory but inherited AGENT_NATIVE_COMPOSITOR=smithay and AGENT_NATIVE_SMITHAY_SOCKET from the desktop. The handshake of that core selected its internal workspace 1, and the observation started to compete with the real core for the window bindings. A temporary profile does not isolate an inherited socket. Internal workspace 1 also does not match the first visible workspace when there are archived conversations.

The old startup was reproduced exclusively against a private sentinel socket: it received workspace:1 with no user action. During concurrent suites, the observation of the real desktop recorded repeated toggling of visibility and geometry. The running binary already contained the focus recovery fix. The interference came from other cores controlling the same compositor.

npm test now uses an environment without inherited AGENT_NATIVE_*, DISPLAY and WAYLAND_DISPLAY variables. The tests that start cores also apply this isolation directly, including when node --test runs them. The compositor fixture still passes its private socket explicitly. The regression starts a real core with an inherited environment that points to a private sentinel, and it requires a disabled backend and zero connections to the sentinel. External tests and QA that start cores manually need the same isolation.

Validation of the isolation: npm ci, format:check and check/build:check passed. The full suite passed 184 tests with concurrency 1, run with desktop variables that pointed to another private sentinel: zero connections reached it. The real window was restored to immersive mode through the protected API, which preserved the host, the compositor and the application. The isolation fix does not require restarting the runtime. Worktrees older than the helper still require you to remove the desktop variables explicitly before you run tests. AGENTS.md records this condition.

Automatic setup when worktrees are created

.codex/environments/environment.toml defines the native Codex setup as python3 scripts/setup-worktree.py. This script prepares only npm and Electron through the shared cache, with no compositor build, no application opening and no profile or login changes. If it runs in a normal clone, it does nothing. In worktrees with an earlier local installation, preservation of that directory still applies.

This local repository also has a post-checkout hook installed by python3 scripts/install-worktree-setup.py. It covers git worktree add with an initial checkout, including when the creation tool does not trigger the local Codex environment. It runs only on the initial checkout of a linked worktree. Normal branch switches do not repeat the setup. The setup is idempotent, so running it through both mechanisms reuses the same installation. A failure is propagated and does not present the worktree as ready. The checkout can stay registered for inspection and a new attempt. --no-checkout and old branches without the helper do not get this preparation.

The hook lives in the common Git directory, shared by the worktrees of this repository, and it is not global. The installer is idempotent and refuses to overwrite an existing post-checkout or a core.hooksPath configuration. In another clone, Git distributes the native setup. To also cover creation by Git or tools in that clone, install the hook once. To disable this hook, remove only the post-checkout identified by Agent Native OS managed worktree setup v1. This does not remove the native Codex setup or the cache.

Validation: tests with synthetic Git repositories exercise real worktree creation with paths that contain spaces, single automatic execution, preservation of the source clone, no repetition on a branch switch, refusal of existing hooks and configuration, old branches and propagation of setup failure. The TOML file was checked against the structure that the installed application supports. Activation is restricted to development. It does not synchronize the checkout of the session in use.

Local activation proven on 2026-10-28: the hook was installed in the common Git directory, and the real creation of a temporary worktree of this project automatically prepared node_modules as a link to the existing cache, with the same Electron inode. No compositor target was created. The QA worktree was removed when it finished. format:check, check/build:check, 184 Node tests and 68 Python tests passed. No session process was restarted.

Update host/core in the current session

This procedure applies shell fixes and preserves the compositor and the Wayland applications. It is not the same as testing a new login. Structural changes to the compositor or to the session bootstrap need their own planning. Do not start another compositor, profile or parallel host to replace the real activation.

  1. Discover project.json, the logind session, the effective root of host/core, the profile, the parent supervisor, the PID and start time of the compositor and the private socket. Confirm the health and the recent update of supervisor-shell.json. Old records are not enough.
  2. Acquire coordination.lock with a non-blocking flock and keep it for the whole operation. Reread coordination.log after you get the lock. Preserve WIP and publish validated sources to main. Synchronize the active checkout only by fast-forward, and only if it is clean, and prepare its build.
  3. Query the protected API in memory only. Require ready=true, a connected compositor and no pending turn, approval in any conversation, preview, change, login or model switch. Do not record tokens, message content or credentials.
  4. Persist the plan, the candidate commit, the known-good version for rollback, the profile and the process identities in private state outside Git. Prepare an external guard that is independent of Node/Electron/provider and of the conversation that will be interrupted. The guard must hold the lock and be able to restore the previous sources without restoring or erasing the profile.
  5. Keep hashes of conversations/sessions, selection, preferences, interface and bindings, plus the PID and start time and the identifiers of the external windows. Normalize only the missing defaults busy:false and approval:null, when needed. Do not exclude other fields to make a comparison pass.
  6. Check idleness and the identity of the targets again. Terminate only the exact core and, if needed, the exact Electron host. The existing supervisor does the recovery. Do not signal its parent process, the compositor, process groups or executables by name. If the host does not exit with the core, do not assume an immediate restart: the detection of a missing health signal can wait for the startup tolerance. An additional shutdown of the host must validate its PID and start time again.
  7. Wait for the new host/core in the same profile and supervisor, ready=true and a connection to the same compositor/socket. Check the served assets, the flock that owns the profile, and the continuity of the conversations and of the applications. Do the QA of the real UI with the user: the agent has no mouse or keyboard automation of the live desktop. Alone, the agent can read the protected API and the read-only state of the compositor control socket, and take a capture (capture-tty4.md). When you switch workspace, focus or presentation for the inspection, restore the previous values before the final comparison.
  8. Confirm acceptance to the external guard only after the checks. A failure of startup, continuity or UI must trigger the prepared rollback, without restarting the compositor and without restoring databases, snapshots or conversations. Record the result and release the lock. Keep the known-good recovery separate.

.instance.guard is the lifetime flock of the core. .instance.lock keeps the PID for supervisors and compatibility. The existence of these files is not permission to delete them: a dead core releases the flock when its helper ends. An old live core, recognized by the PID, also blocks the opening of the profile.

The React CSS is loaded in the ShadowRoot of the conversation. The outer host document uses its own stylesheet. Loading trusted-ui.css there too can apply message rules to widgets and controls. Profile customization edits only CSS through the journal. Changes to these trusted sources belong to the checkout.

Activation proven on 2026-10-28

The fixes c572e8b were applied to the existing Smithay session by a supervised restart of host/core only. The external Python guard kept coordination.lock, a persistent plan and a rollback to the previous sources. An incorrect check in the first guard triggered a rollback. Continuity was confirmed before the check was fixed and the operation was repeated. There was no compositor failure and no loss of applications in that attempt.

The final activation confirmed ready=true, the same profile and compositor, and the history and sessions of the 17 conversations and 107 messages, selection, preferences, interface and bindings by hash. The compositor, supervisors and external application kept PID and start time, and the external window kept its identifier, workspace and state. The temporary inspection of an empty workspace showed the three compact widgets in the real Electron. The capture came from the Smithay framebuffer. Workspace, immersive presentation and application focus were restored before the final acceptance. No turn was sent to the provider. The capture, plan and logs stay private outside Git. They do not replace the rediscovery procedure at the next maintenance.

Safe mode entry

scripts/register-smithay-session.sh also registers "Galaxy Shell (modo seguro)". It starts the same login with the overlay of the chat host off. The dispatcher that reads its variable is a copy, so it needs scripts/install.sh to run first. See immutable-base.md, Recovery.

Until 2026-11-09 it also registered "Galaxy Shell (wgpu)", the same login with the experimental wgpu renderer. The owner removed it ("I want to remove it"); the registration now deletes that entry and its wrapper when it finds them, identified by their content, and registers only the two entries above. Since 2026-11-10 wgpu is the default; the compositor no longer reads AGENT_NATIVE_RENDERER (step 6, 2026-11-11), and only the recovery start still exports it, for the registered recovery release. See wgpu-renderer-plan.md, Physical login and Phase 4, the switch.

Private Electron host runtime

On Linux, preparation (including --dependencies-only) copies the Electron distribution into ignored runtime/electron-host/<source-binary-sha256>/ and disables only the nodeCliInspect fuse. The host consumes SIGUSR1 so the disabled inspector does not leave the Linux default termination action in its place. runAsNode stays enabled for the core and overlay builds. The distribution in node_modules, including the shared cache, is never patched. The supervisor, nested QA and npm run desktop require the prepared runtime and refuse an absent or invalid one. Releases embed this private distribution in their own node_modules/electron/dist, so they need no writable runtime directory. Preparation retains previous copies; it never replaces an executable used by a running host. Source changes and preparation do not restart the current session. The helper validates the documented V1 fuse wire and refuses an unknown schema or a missing Node mode.