Skip to content

fix(scratchpad): keep cell code away from the agent's code and process (ENG-4191) - #808

Open
martyna-mindsdb wants to merge 2 commits into
stagingfrom
martyna/eng-4191-cell-isolation
Open

martyna-mindsdb wants to merge 2 commits into
stagingfrom
martyna/eng-4191-cell-isolation

Conversation

@martyna-mindsdb

@martyna-mindsdb martyna-mindsdb commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Cloud cells run as the same user as the agent process, which holds the turn's credentials. Two gaps let cell code reach that process: the agent's venv was writable by that user, and a turn exec'd directly could be read through /proc. This closes both on anton's side. The companion scratchpad-controller PR kills processes left over from earlier turns.

Linear: https://linear.app/mindsdb/issue/ENG-4191/notionhubspot-on-web-keep-scratchpad-cell-code-away-from-the-agent

File Change
Dockerfile The venv stays root-owned (the chown to UID 1000 is gone), and PYTHONNOUSERSITE=1 stops Python loading startup files from the writable home folder. The header no longer says the cell loop installs missing packages.
docker/image_smoke.py The writable-venv check is flipped: the build now fails if the runtime user can write anything the agent loads (venv, /app with anton's source and the turn's working directory, the standard library, /usr/local/bin), or if user site-packages are on. The runtime-uv check now says uv builds and fills each pad's venv.
anton/cloud_turn/__main__.py The turn closes /proc access to itself (PR_SET_DUMPABLE=0) before it reads its request. Until now only the resident's forks had this, and exec resets it, so the controller's direct exec and the launcher's fallback ran without it.
tests/test_cloud_turn_proc_access.py New, Linux only: a same-user process can't read the turn's environment while the turn waits for its request, both direct and through the launcher.
tests/test_image_smoke.py Tests for the two new checks.

Why the venv can be read-only: pad packages install into each pad's own venv under the workspace (uv pip install --python <pad venv>), and the cell loop no longer installs anything itself. Nothing at turn time writes to the image venv.

Validation:

  • test_image_smoke.py and the cloud-turn tests pass locally on macOS, where the Linux-only tests skip; CI runs them on Linux.
  • This PR's image build runs the smoke as UID 1000, so it checks the read-only venv and user site on the real image.
  • Still to do on staging, with the controller PR: cell code can't change agent files or read the agent's memory or descriptors, pad installs still work, turns on reused pods still work, and Notion and HubSpot still work on web.

DevOps review: this touches Dockerfile and docker/, so it needs a DevOps approval.

🤖 Generated with Claude Code

…s (ENG-4191)

- The image venv stays root-owned, and the build smoke fails if the runtime
  user can write anything the agent loads (venv, anton's source, stdlib).
- PYTHONNOUSERSITE=1, so no startup file in the writable home is loaded.
- The cloud turn closes /proc access to itself before reading its request,
  on every path, not only when the resident hands it the turn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@martyna-mindsdb
martyna-mindsdb requested a review from a team November 16, 2026 14:24
…v is for now (ENG-4191)

- The read-only check covers /app, the turn's working directory that
  `python -m` puts first on sys.path, and /usr/local/bin.
- The Dockerfile header and the runtime-uv check no longer say the cell loop
  installs missing packages; uv builds and fills each pad's venv.

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

This branch has not been deployed

No deployments
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