Skip to content

fix(python): build the _telemetry extension out of tree - #2118

Merged
jepsontaylor merged 2 commits into
mainfrom
fix/telemetry-out-of-tree
Nov 4, 2026
Merged

jepsontaylor merged 2 commits into
mainfrom
fix/telemetry-out-of-tree

Conversation

@jepsontaylor

Copy link
Copy Markdown
Contributor

Post-release cleanup (after #2115).

Problem. python/ was a mixed maturin project, and maturin editable installs copy the extension into the python-source dir, so every cold uv sync (CI on xbabe2-ci included) wrote python/src/jope/_telemetry.cpython-*.so into the tree. R9094 hid that with a .gitignore entry, which also hid stray artifacts from the receipt dirty_source_after check.

Fix.

  • New python/native distribution jope-native (maturin, module jope_native._telemetry, same crates/jope-telemetry python feature; no Rust change). python/pyproject.toml depends on it via [tool.uv.sources] jope-native = { path = "native", editable = false }, so the .so only exists in the venv's site-packages; the build uses the cargo target dir. uv cache-keys include the Rust sources so edits trigger a rebuild.
  • jope is now a pure-Python hatchling package (still editable). python/src/jope/_telemetry.py aliases sys.modules["jope._telemetry"] to the extension, so all imports, class/exception identity and __file__ (hashed by run_fused_closed_loop.py) are unchanged.
  • .gitignore: the _telemetry*.so/.pyd ignores are removed (tightened). A stray in-tree .so would shadow the alias, so it must stay visible to git status / receipt.py.
  • test_telemetry_smoke.py::test_extension_is_built_out_of_tree asserts the extension loads from outside python/src and no .so/.pyd exists there.
  • uv.lock adds only jope-native. Bookkeeping: PYTHON_EXCEPTIONS.md (2 FFI shims), README At-a-glance counts and docs/parity/test-inventory.json (+1 test).

Local verification (xbabe2, cold uv cache, fresh venv): uv sync --locked ... builds jope-native from the path source; git status --porcelain --untracked-files=all stays clean; python lane via receipt.py: dirty_source=[], dirty_source_after=[], pytest 472 passed / 0 failed, training-proof, benchmark, dl-offline group, flywheel-offline all pass. run_v2_offline.py passed standalone (237/237) but takes about 604 s wall on the loaded host, just over the lane's 600 s timeout. That happens on main as well and is unrelated to this change. deploy/ci/check.sh (hygiene) passes, including coverage validate, paper-trace, repo-layout and test inventory.

Approved-by: Jepson (t271u, 2026-11-03 16:57 MST): "Please start on what you think is best, we want to get to a clean main and work to simplify updates ASAP"

@jepsontaylor
jepsontaylor marked this pull request as draft November 4, 2026 00:37
@jepsontaylor
jepsontaylor marked this pull request as ready for review November 4, 2026 00:37
@jepsontaylor
jepsontaylor marked this pull request as draft November 4, 2026 01:20
@jepsontaylor
jepsontaylor marked this pull request as ready for review November 4, 2026 01:20
@neverhumanbot
neverhumanbot force-pushed the fix/telemetry-out-of-tree branch from 4b2adc4 to 3175dce Compare November 4, 2026 01:41
@jepsontaylor
jepsontaylor marked this pull request as draft November 4, 2026 01:41
@jepsontaylor
jepsontaylor marked this pull request as ready for review November 4, 2026 01:41
maturin editable installs copy a mixed project's extension module into its
python-source directory, so every cold `uv sync` (including CI on xbabe2-ci)
wrote python/src/jope/_telemetry.cpython-*.so into the source tree. main hid
that with a .gitignore entry, which also hid stray artifacts from the
receipt dirty-source check.

- New python/native distribution `jope-native` (maturin, module
  jope_native._telemetry, same crates/jope-telemetry `python` feature, no Rust
  change). uv installs it from a path source with editable = false, so the
  .so lives only in the venv's site-packages and the build uses the cargo
  target dir. uv cache-keys cover the Rust sources so edits rebuild it.
- jope itself is now a pure-Python hatchling package (editable as before).
  python/src/jope/_telemetry.py aliases sys.modules["jope._telemetry"] to the
  extension, so imports, class identity and __file__ (hashed by
  run_fused_closed_loop.py) are unchanged.
- .gitignore no longer ignores python/src/jope/_telemetry*.so/.pyd: a stray
  one would shadow the alias and must stay visible to git status and
  receipt.py. test_telemetry_smoke asserts the extension is loaded from
  outside python/src and that no .so/.pyd exists there.
- uv.lock: adds jope-native only. PYTHON_EXCEPTIONS.md registers the two new
  FFI shim files.

Approved-by: Jepson (t271u, 2026-11-03 16:57 MST): "Please start on what you
think is best, we want to get to a clean main and work to simplify updates ASAP"

Agent-Session: wt-telemetry-oot
Agent-Model: gpt-6-luna medium
Agent-Task: fix/telemetry-out-of-tree
…/src

Review follow-up: a native artifact anywhere under the editable source root, not only python/src/jope, must fail the smoke test.

Agent-Session: wt-telemetry-oot
Agent-Model: gpt-6-luna medium
Agent-Task: fix/telemetry-out-of-tree
@neverhumanbot
neverhumanbot force-pushed the fix/telemetry-out-of-tree branch from 3175dce to c5690a1 Compare November 4, 2026 02:09
@jepsontaylor
jepsontaylor marked this pull request as draft November 4, 2026 02:09
@jepsontaylor
jepsontaylor marked this pull request as ready for review November 4, 2026 02:09
@jepsontaylor
jepsontaylor merged commit 6204af9 into main Nov 4, 2026
17 checks passed
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