Skip to content

feat: openshell user sandbox - #484

Merged
kunal0137 merged 7 commits into
devfrom
feat/openshell-user-sandbox
Nov 17, 2026
Merged

kunal0137 merged 7 commits into
devfrom
feat/openshell-user-sandbox

Conversation

@kunal0137

@kunal0137 kunal0137 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Monolith side of the OpenShell user sandbox in SEMOSS/Semoss#3336 (replaces #461, same branch moved from a fork into this repo). With SANDBOX_MODE=OPENSHELL each user has one sandbox that outlives any single session. Monolith decides when a user's claim on it starts, refreshes, and ends.

This calls OpenShellUserSandboxes methods added in SEMOSS/Semoss#3336, so merge that PR first.

Changes Made

  • NoUserInSessionFilter: any authenticated request refreshes the user's sandbox lease (at most once a minute per session), not only Python calls. The owner is also saved on the session, because dropping a login provider can leave nothing to derive the owner from by the time the session is destroyed.
  • UserSessionLoader: when a session ends, the user's Python worker and chroot are no longer shut down per session in OpenShell mode. The lease is released instead, and the sandbox is deleted when the user's last session anywhere ends. A server stop destroys every session but is not the user leaving, so it keeps the lease and the user's Python variables. Only a logout, an app-ended session or a real timeout ends the claim.
  • SessionResource: sessions the app ends on purpose (logout cancel and invalidate flows) go through endSession, which sets the new IS_SESSION_ENDED attribute before invalidating, so cleanup treats them as over.

How to Test

  1. With CHROOT_ENABLE=true and SANDBOX_MODE=OPENSHELL, log in and run a Python cell so the sandbox exists.
  2. Log in from a second session as the same user. Log out of the first and confirm the sandbox and the worker stay.
  3. Log out of the last session and confirm the sandbox is deleted.
  4. Stop and start Tomcat with a session open and confirm the user's sandbox and Python variables are still there.

Notes

  • Not compiled here: it builds against the Semoss artifact, so it needs the Semoss change from #3336 to be available first.
  • The diff is 3 files, +90/-23. Line endings in NoUserInSessionFilter match dev (CRLF).

kunal0137 and others added 7 commits October 24, 2026 00:54
…active

Every authenticated request refreshes the user's sandbox lease (at most once
a minute per session, for the session timeout). A session ending releases
its lease; the sandbox goes when the user's last session does, rather than
with whichever session happened to start it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sessionDestroyed also fires when Tomcat stops. Treat only a logout or an idle
timeout as the session being over; otherwise keep the sandbox lease and do
not clear the insight's python variables, which live on in the user's worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onIsOver

Users without a primary login keep the per-session cleanup; the expiry
slack is a named constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The filter records the sandbox owner on the session while the user is
logged in; session cleanup uses it, because a provider logout has already
dropped the token the owner was derived from.
…ndbox

# Conflicts:
#	src/prerna/web/conf/NoUserInSessionFilter.java
#	src/prerna/web/conf/UserSessionLoader.java
@kunal0137
kunal0137 requested a review from a team as a code owner November 17, 2026 18:44
@snyk-io

snyk-io Bot commented Nov 17, 2026

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@kunal0137
kunal0137 merged commit f200817 into dev Nov 17, 2026
8 of 10 checks passed
@kunal0137
kunal0137 deleted the feat/openshell-user-sandbox branch November 17, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant