Skip to content

fix(desktop): enforce project and session isolation - #69508

Open
diffen77 wants to merge 8 commits into
NousResearch:mainfrom
diffen77:fix/desktop-project-session-isolation-v5
Open

diffen77 wants to merge 8 commits into
NousResearch:mainfrom
diffen77:fix/desktop-project-session-isolation-v5

Conversation

@diffen77

Copy link
Copy Markdown

Summary

  • keep task-scoped project create/switch from mutating the profile-global Desktop project pointer
  • make project-scoped new-session creation atomic with its immutable workspace target
  • bind every Desktop prompt submission to the intended durable stored session and reject stale runtime mappings before queueing or persistence
  • require backend contract v5 for upgraded Desktop clients while preserving non-Desktop callers

Incident

Prevents recurrence of #54527, including the confirmed cross-project contamination where Snabbgross prompts were persisted in a Mission Control conversation.

Verification

  • scripts/run_tests.sh tests/tools/test_project_tools.py tests/test_tui_gateway_server.py -q — 405 passed
  • Desktop Vitest — 81 passed
  • npm run typecheck — passed
  • ESLint — 0 errors (1 pre-existing hook warning)
  • git diff --check — passed

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/desktop Electron desktop app (apps/desktop/*) comp/tui Terminal UI (ui-tui/ + tui_gateway/) comp/tools Tool registry, model_tools, toolsets area/sessions Session lifecycle, resume, persistence, history sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Jul 22, 2026
@diffen77

Copy link
Copy Markdown
Author

Final closeout candidate pushed: 09d26f8cb807ec7df09c76c8034e1bb0ccf18d1a, based on origin/main 15dc65eeda397a5d4d35edd6779141eeb8139944. This integrates the reviewed durable-session P1 closure across submit/interrupt/rewind/tile/delegate paths, including legacy omission compatibility and concurrent session-switch recovery. Independent exact-head review: PASS, no P0/P1. Gates at this head: scripts/run_tests.sh 413/413; focused Desktop 74/74 plus session-context-drift coverage; typecheck, targeted ESLint, production build, and git diff --check pass. Awaiting required upstream CI/maintainer approval; no direct-main mutation.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused project-routing and durable-session work. The current-main premise remains valid: tools/project_tools.py:105 and :126 still mutate the profile-global active pointer, while Desktop submit still routes only by runtime id (apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts:599-609).

Problems

  • The contract must not remain v5. Current main already reserves v5 for large remote attachments (tui_gateway/server.py:4644-4648, apps/desktop/src/store/updates.ts:93-97, commit 254aeda122). A v5 remote would pass the client gate but lack this branch's durable-binding validation.
  • The same runtime-only mutation remains on Desktop redirect: index.ts:708 sends only session_id, and tui_gateway/methods_session.py:2963-2972 validates only the runtime lookup. This PR does not change that path.
  • Current main split RPC handlers out of server.py (tui_gateway/server.py:13293-13304), so the server-side portion needs to be transplanted into methods_prompt.py / methods_session.py.

Suggested changes

  • Allocate the next contract version and cover v5 skew.
  • Bind and validate session.redirect, or document and test a deliberate exclusion.
  • Rework the handler changes against the current module split.

This is an automated hermes-sweeper review.

Comment thread tui_gateway/server.py
# v3: adds approvals.mode config RPCs and session.info reconciliation.
# v4: session.create fast=false is an explicit per-session normal-tier override.
DESKTOP_BACKEND_CONTRACT = 4
# v5: every Desktop prompt.submit is bound to its durable stored session.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current main already uses contract v5 for the merged large-attachment WebSocket capability (254aeda122; current tui_gateway/server.py:4644-4648). Please allocate a new contract version for durable-session binding; otherwise a current v5 remote passes the Desktop gate but does not implement this validation.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/desktop Electron desktop app (apps/desktop/*) comp/tools Tool registry, model_tools, toolsets comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants