Skip to content

Describe the subinterpreter backend as what it actually is - #289

Merged
seanwevans merged 1 commit into
mainfrom
claude/docs-subinterpreter-accuracy
Aug 15, 2026
Merged

Describe the subinterpreter backend as what it actually is#289
seanwevans merged 1 commit into
mainfrom
claude/docs-subinterpreter-accuracy

Conversation

@seanwevans

Copy link
Copy Markdown
Owner

The problem

README, SECURITY.md, and docs/threat-model.md all state that guest code under backend="subinterpreter" "runs in a sub-interpreter in the supervisor's own process."

It does not. pyisolate/runtime/thread.py runs each guest in a threading.Thread and execs guest source against a restricted __builtins__ mapping. There is no interpreters / _interpreters / Py_NewInterpreter anywhere in the codebase. The module's own docstring said so:

"This is a greatly simplified placeholder that executes code in a dedicated thread using the standard interpreter."

So the most-read documents disagreed with the implementation, in the feature the project is named after.

Why it matters (and what it doesn't change)

No security claim changes. That backend is documented throughout as an execution cell and explicitly not a boundary against hostile Python — equally true of a thread and of a real sub-interpreter. The threat model's answers are unaffected, and I've said so inline rather than leaving a reader to wonder.

The mechanism does change, and it's observable:

thread (today) sub-interpreter (intended)
Address space shared shared
sys.modules shared with supervisor per-interpreter
Boundary vs hostile Python none none
GIL shared per-interpreter on free-threaded builds

Anyone reasoning about isolation between cells, or about the no-GIL "parallel cells vs scheduled compartments" axis, was working from the wrong model.

The change

Docs only — no behavior.

  • New "Sub-interpreter status" section in the README: current mechanism, the comparison table above, and a pointer to backend="process" for untrusted code.
  • The three documents that made the claim now say "dedicated thread" and link to it; docs/execution-model.md gets the same note.
  • thread.py's docstring rewritten to describe the runtime accurately — and to drop its pointer to an AGENTS.md that does not exist anywhere in the repo.
  • ROADMAP "Now / next" gains the real work: build it on concurrent.interpreters (3.14) / _interpreters (3.12+), or rename the backend to thread. I deliberately did not pick — renaming is a breaking API change and that's your call.

Suite unchanged at 505 passed / 6 skipped; flake8 clean.


Generated by Claude Code

README, SECURITY.md and docs/threat-model.md all stated that guest code
under backend="subinterpreter" "runs in a sub-interpreter in the
supervisor's own process". It does not. pyisolate/runtime/thread.py runs
each guest in a threading.Thread and execs guest source against a
restricted __builtins__ mapping -- its own module docstring called itself
"a greatly simplified placeholder that executes code in a dedicated thread
using the standard interpreter".

No security claim changes: that backend is documented throughout as an
execution cell and not a boundary against hostile Python, which is equally
true of a thread and of a real sub-interpreter. What changes is the
mechanism a reader should assume. The difference is observable -- a thread
shares sys.modules and the GIL with the supervisor, a sub-interpreter does
not -- so anyone reasoning about isolation, or about the no-GIL parallel-
cell axis, was working from the wrong model.

Add a "Sub-interpreter status" section to the README stating the current
mechanism, comparing it with the intended one, and pointing untrusted
workloads at backend="process". Reference it from the three documents that
made the claim and from docs/execution-model.md. Record landing the real
implementation (concurrent.interpreters on 3.14, _interpreters on 3.12+),
or renaming the backend, as a Now/next roadmap item.

Also fix thread.py's docstring, which pointed readers at an AGENTS.md that
does not exist anywhere in the repository.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ebvMQ3vLxdK3joymz6Feg
@seanwevans
seanwevans merged commit d1889c0 into main Aug 15, 2026
18 checks passed
@seanwevans
seanwevans deleted the claude/docs-subinterpreter-accuracy branch August 15, 2026 21:00
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.

2 participants