Skip to content

Lock the bootstrapped Python environment - #965

Draft
fettpl wants to merge 2 commits into
PrimeIntellect-ai:mainfrom
fettpl:agent/932-lock-python-environment
Draft

Lock the bootstrapped Python environment#965
fettpl wants to merge 2 commits into
PrimeIntellect-ai:mainfrom
fettpl:agent/932-lock-python-environment

Conversation

@fettpl

@fettpl fettpl commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • install the bundled Python kernel from a reviewed universal uv.lock with an exact CPython patch, uv release, and seven-day dependency cutoff
  • include the kernel project, lock, constraints, toolchain, and Termux vendoring helper in bootstrap freshness checks
  • build and validate replacement environments before an atomic swap, with rollback and interrupted-swap recovery
  • keep Python skills outside the base lock while constraining their resolution and restoring the exact base after every skill change
  • validate macOS, glibc, musl, Windows, and real Termux/Bionic environments in CI

Solution design

The bundled base runtime is a dedicated non-package uv project. toolchain.json pins CPython 3.11.15, uv 0.11.33, the release-age cutoff, and the reviewed Termux toolchain. constraints.txt is generated from uv.lock and is used only as a constraint for separately installed skills.

Bootstrap validates lock consistency before reusing a warm environment. A stale environment is rebuilt in a sibling directory, validated, and then swapped into place. The prior environment is restored if staging, activation, or post-activation validation fails. The bootstrap marker records the complete artifact digest, target platform, interpreter identity, and uv version.

Linux detects glibc versus musl before selecting wheel tags. Windows receives a native install lane. Termux uses its system Python because uv-managed CPython is unavailable for Android/Bionic. The exact uv release is built from a checksum-pinned source archive. Exact official Termux builds of lxml, NumPy, psutil, and SciPy are version-checked and copied into the staged venv with PEP 738 Android wheel tags; the remaining locked dependencies are built or installed by uv. Termux CI performs both an online install and a new cached-offline install.

Verification

  • npm run refresh-python-lock
  • npm run check:python-lock (macOS ARM64/x64, glibc Linux ARM64/x64, musl Linux ARM64/x64, Windows x64)
  • npx tsx ../../node_modules/vitest/dist/cli.js --run test/kernel-bootstrap.test.ts (28 tests)
  • npm run check
  • clean native macOS ARM64 bootstrap with uv 0.11.33 and Python 3.11.15
  • clean cached-offline native macOS ARM64 bootstrap
  • real aarch64 Termux/Bionic bootstrap with source-built uv 0.11.33, Python 3.14.6, runtime imports, and uv pip check
  • second clean Termux/Bionic bootstrap with UV_OFFLINE=true

Risks and rollout

  • Existing managed kernel environments rebuild once because the bootstrap schema and full artifact digest changed.
  • Termux uses reviewed revisions from its rolling package repository. Native revisions must remain aligned with the Python lock and observe the same seven-day cooldown; the real CI lane fails on drift.
  • Building exact uv on Termux increases the Android CI duration.
  • Custom PRIME_AGENT_KERNEL_PYTHON environments remain an explicit, non-mutating override.

Fixes #932

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.

Lock the bootstrapped Python environment

1 participant