Resolves no tracked issue.
Prevents session maintenance from deleting a session directory while the owning CLI process is still running. Each session now writes its owner process identifier to process.pid, and cleanup skips sessions whose owner process is alive before applying age and max-session pruning.
This can happen when multiple tuist invocations share the same $XDG_STATE_HOME/tuist/sessions directory, which is common in CI jobs that run several Tuist commands in the same workspace or user account. Each invocation schedules detached session cleanup after setup. Before this change, cleanup treated every session as removable based only on creation date and the global session limit. A long-running command could be one of the oldest sessions while newer commands were created, so another process could remove that active session directory. When the long-running command later tried to finish rendering Noora output through its logs.txt, the file path was gone and the thrown file error escaped through swift_errorInMain.
The analytics upload path was checked because the crash happens after run metadata is printed. AnalyticsArtifactUploadService zips a copied staging directory and does not remove the live session directory, so the root issue is session cleanup not knowing which sessions are still active. Keeping the logger strict is intentional here: if session setup fails for another reason, that error should still be visible instead of being hidden behind a fallback.
Cleanup itself remains best-effort. If a session disappears while maintenance is scanning, if its attributes cannot be read, or if a removal loses a filesystem race, cleanup skips that entry instead of letting the maintenance task fail.
The inactive-session retention cap remains 50 by default and can be raised with TUIST_SESSION_MAX_SESSIONS. Invalid values, zero, and negative values fall back to the default. The CLI debugging and directories docs now describe the session directory layout and the environment override.
How to test locally
mise run cli:lint --fix
tuist generate tuist TuistKit TuistKitTests --no-open
xcodebuild test -workspace Tuist.xcworkspace -scheme Tuist-Workspace -only-testing TuistKitTests/SessionControllerTests CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY=""
xcodebuild build -workspace Tuist.xcworkspace -scheme tuist CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY=""
git diff --check