SDK guide
Explicit Python source selectors
On this page
A driver's native attribute identifies upstream evidence. Runtime objects are constructed only by backends; a source selector is never imported or executed. Existing package.module:Class selectors keep their existing behavior.
For an upstream file that is not importable by module name, use:
native = "pyfile:2230G.py#KEI2230G"
native = "pyfile:2220 Programmable DC Power Supplies.py#KEI2220S"For a function-only module, use:
native = "pyfile:spectrometer.py#*"
backends = {"hardware": ".native:connect", "fake": ".fake:FakeSpectrometer"}#* means the verified public, synchronous, top-level function definitions in that exact file. It is not an arbitrary-member or arbitrary-payload fallback. The first module implementation requires a concrete package fake class with matching public callable signatures. Bound instance/class methods lose only their actual first self/cls parameter; static methods retain all parameters. Recorded calls must bind to the source signature. Default presence is checked without evaluating upstream default expressions; default value equality is not claimed. Imported, conditional, decorated, async, overwritten or dynamically created functions do not establish verified members. Module data/object attributes and factory-produced fake namespaces are outside this initial module support.
The confirmed task entry uses the same selector and exact path. A module entry is at line 1; a class entry uses the actual class-definition line. For example:
{"symbol": "pyfile:spectrometer.py#*", "file": "spectrometer.py", "line": 1}Paths are normalized relative POSIX source paths. Literal spaces are allowed; absolute paths, traversal, backslashes, empty path segments, control characters, wildcard paths and selector delimiters in a path are refused. This source-specific rule does not change the stricter paths used for package contents. A class selector requires a direct undecorated definition in the named file. It may use bases in that file; imported aliases and external-file base members are not guessed. A dotted class entry with an exact space-containing file hint is also supported by registry recon validation; the runtime factory still needs explicit deployment configuration.
With a Git upstream, the selector reads only a regular blob at the task's pinned commit. A missing commit, missing blob, symlink, or gitlink is an error; neither HEAD nor the working tree substitutes for it. A path inside a git submodule is read from the submodule's own object store at the commit the pinned tree's gitlink records, under the same rules as every gate read (declared in the pinned .gitmodules, checked out at exactly that commit); a path that names the gitlink itself stays an error. Synthetic, unpinned tutorial directories remain supported with contained regular files and no symlink traversal.
Known standalone Python 2 print statements can be omitted for AST parsing while preserving line numbers and the legacy-source warning. Other legacy rewrites do not prove a callable signature. Nothing here makes Python 2 modules importable under Python 3 or validates an independent hardware port.
Classes bound with pybind11
Some upstream Python clients exist only as C++ classes bound with pybind11: the clone has no Python class to parse, only the binding source (often generated by the binder tool). A direct Driver or a PythonObjectDriver names such a class with
native = "pybind:modules/comms/python/generated-sources-pybind/mvsim/Comms/Client.cpp#mvsim.Client"The path is the binding source (.cpp, .cc or .cxx) and follows the path rules above; it is read as a regular blob at the task's pinned commit. The name after # is the class's Python name: its scope (mvsim, the namespace of binder's M("mvsim") module getter, :: for each further .) and the class name. The file must declare the class exactly once, as pybind11::class_<...> <var>(M("<scope>"), "<Name>", ...), or as py::class_<...> <var>(<module>, "<Name>", ...) for a name without a scope. Its members are the names of the <var>.def, def_static, def_readwrite, def_readonly, def_property and def_property_readonly calls at the declaration's own brace depth until its block ends; a nested block (binder's nested classes reuse the variable name) adds nothing. Comments are skipped. A declaration without a variable (members bound by chained .def calls) is reported, not read.
G7 then checks the fake's public members and every attribute the driver used against those names (NOT_UPSTREAM), and refuses the selector for any other family (NATIVE_NOT_FOUND), including a Gymnasium or MuJoCo driver whose fake backend is the upstream simulator. When the card lists entry symbols, the native must be one of them, as for package.module:Class. Nothing is imported, compiled or evaluated: macros, templates and preprocessor branches are not followed, and argument shapes, return types, the binding's GIL handling and the behaviour of the bound C++ code are not checked. A package that cannot use the bound class itself (for example because its calls wait without a timeout) may serve the same members from its own backend object; the reviewer reads that code.
G7 also verifies explicit source identity for serial/SCPI drivers before their existing transport command checks. Source identity, function membership and call shape do not prove physical outcome, device limits, cancellation or stop latency. Passing this gate never removes separate provenance, safety or hardware-review requirements.