Import host call #942
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #942"
general
weight: 0.35
rewitt94
<!-- This is an auto-generated description by cubic. -->
Summary by cubic
Sandbox code can now
importhost-provided modules: importing a module the sandbox lacks suspends as theimportOS call and binds the host's answer. Anot_foundanswer raisesModuleNotFoundErrornaming the first missing component of a dotted import, and a future is refused.Bindings
external_modules(Python) /externalModules(JS) on the checkout methods names the modules a session may import, each anExternalModulepairing the module's value with its optional.pyistub. The value is a mapping (any mapping in Python) whose public callables become host functions named<module>.<attr>, aClassInstance, aClassType(which crosses as the type it wraps), or a zero-argument callable (async underAsyncMonty/JS) returning one of those, run once per session at the module's first need.ExternalModuleis immutable: it copies and validates its attrs at construction and carries anid; the entries mapping stays live, read at each first import. Host modules cross as real sandboxmoduleobjects, sotype(tools)ismoduleand attribute and call errors raise in the sandbox, and a module exports back with theidit imported with. Passing a module as a value is refused on both sides.TypeError, and a stub name that is not an identifier or that the sandbox or its type checker already provides (now includinghashlib,posixpath, andgenericpath) is refused. Names and dict keys must be plainstridentifiers (keywords refused, non-XID names in JS), an ownundefinedentry is an invalid entry rather than a missing module, and the wire repr quotes a module's name. A throwing getter surfaces at the import, and private names find nothing.moduleson aClassInstanceentry and an entry nested inside itself are refused, as is a factory returning either. In JS a module entry must be an own property, and a plain value's ownthenis never run: it is boxed so calling it fails as not callable instead of being awaited.LoadSubmoduleopcode, capped at 32 components (SyntaxError).ExternalModule.modulesnests submodules; a missing component raisesModuleNotFoundErrornaming the full path, andfrom a.b importkeeps it on the frame. Repeated imports move to the end of the type-check prelude so the latest alias binds, and below a built-in module only a module is a submodule, soimport math.piraisesModuleNotFoundError.Type checking and protocol
import_stubsOS call before it is checked, once per host module it imports that the session has not asked about; an ask naming a module twice is refused. The worker keeps the stubs it receives, carries them in the dump, and adopts the feed's cwd on arrival so a typing rejection after the ask keeps it. Checks resolve the imports from per-module stubs laid out as/<module>.pyi(a package for dotted paths); each committed import is re-injected once into later checks, and a reused worker never resolves a previous session's stubs. Diagnostics in the injected prelude are dropped, so a committedimport x # type: ignorere-emits without its comment. The JS binding refuses keywords and sandbox module names without needing a stub; reserved names split into the sandbox's own modules, refused as host module names, and the checker-only ones, refused only as stub names.__call__on their uuid; the Python and JS wrappers answer withTypeError: 'X' object is not callable.PROTOCOL_VERSIONbumps to 6 — a version 5 parent would answer neither new OS call — whileDUMP_VERSIONstays at 13:LoadAttrImportkeeps its one-operand shape with thefrom ... importmodule name carried on the call frame. ATypingErroranswering anything other than a feed that type-checks is a protocol violation.<sup>Written for commit b886bc28f508e3d236ddc9e301e131968cded224. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/pydantic/monty/pull/942?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/pydantic/monty/942?returnTo=https%3A%2F%2Fgithub.com%2Fpydantic%2Fmonty%2Fpull%2F942&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->