Skip to content

fix(deploy): build every node venv on the .python-version floor interpreter through one lookup (#20932) - #20969

Closed
mrveiss wants to merge 6 commits into
mainfrom
issue-20932-venv-floor-interpreter
Closed

mrveiss wants to merge 6 commits into
mainfrom
issue-20932-venv-floor-interpreter

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Thinking Path

Once autobot_shared refuses interpreters below the .python-version floor at import (#20903), a node venv built with a bare python3 is unusable on any node whose python3 is older, and a hard-coded python3.14 is right only until the next floor bump. The Ansible side already had one derivation (python_interpreter_binary), so the fix extends that role rather than adding a second lookup; scripts outside Ansible get one small shared shell helper that mirrors how install.sh provisions Python from deadsnakes. A guard then keeps both from coming back.

What Changed

  • roles/python_interpreter/tasks/resolve.yml (new): the single derivation of python_interpreter_version / python_interpreter_binary from .python-version; tasks/main.yml includes it instead of carrying its own copy. Roles that only need the name call it with tasks_from: resolve.
  • Bare python3 replaced with the floor binary: slm_agent role, enroll-node.yml (npu-worker and ai-stack paths, now also installing the interpreter first), dependency_patching/update-venv.yml (both pip fallbacks).
  • Hard-coded python3.14 replaced with {{ python_interpreter_binary }}: npu-worker, tts-worker, agent_config, backend, backend_services, ai-stack, slm_manager, redis/chromadb (create step, pip fallbacks, ensure_venv_version targets). In ai-stack and slm_manager the stale-venv version checks derive from the same variable instead of a 3.14 literal.
  • scripts/lib/python_floor.sh (new, with python_floor_test.sh, registered in repo_tests/shell_lib_test.py): version | binary | ensure; ensure installs from deadsnakes when missing and otherwise refuses with a clear message; no fallback version. Used by deploy-autobot-native.sh, setup_repair.sh, code_analysis/install.sh, bootstrap-slm.sh (through a one-line remote command, so the file stays at its size ceiling) and deploy_autobot.py (through the helper).
  • Guard repo_tests/venv_builders_use_floor_interpreter_20932_test.py: no bare or hard-coded python3[.N] -m venv and no venv_python: python3.N in the deploy and infrastructure paths; control strings for both directions; every allowlist entry needs a reason and must still match.
  • Review fixes: the resolve tasks and the include calls that run only them are tagged always (a --tags venv run no longer leaves python_interpreter_binary undefined); slm_agent and both enroll-node.yml create tasks run ensure_venv_version first; python_floor_venv_matches (version check on a venv's bin/python) is used by deploy-autobot-native.sh and setup_repair.sh to rebuild a venv on an older interpreter; deadsnakes provisioning is Ubuntu-only (/etc/os-release ID=ubuntu), other OSes are refused naming the OS and interpreter, and the hidden || true is gone; auto-install prints a notice and is documented in the helper header; .python-version without a trailing newline reads correctly; the venv dir for the remote command must match ^[A-Za-z0-9_./-]+$.
  • repo_tests/python_version_declaration_drift_test.py: one line now reads the derivation from resolve.yml (where it moved).

Not in this PR:

Verification

  • ~/.venv-python-suite/bin/python -m pytest repo_tests/venv_builders_use_floor_interpreter_20932_test.py repo_tests/python_version_declaration_drift_test.py repo_tests/ansible_pip_venv_creation_test.py repo_tests/shell_lib_test.py -q
  • bash scripts/lib/python_floor_test.sh (21 cases, including a floor bump to 3.15 and a missing interpreter refusing)
  • ansible-playbook --syntax-check on enroll-node.yml and deploy-full.yml; autobot-slm-backend/ansible/tests/check_venv_producers.py; autobot-slm-backend/tests/services/test_role_registry.py.
  • No playbook was run against any host.

Risks

  • slm_agent and enroll-node now install the floor interpreter (deadsnakes) on nodes that did not have it; that is the intent, but it is a new apt step on those paths.
  • A venv built on an older interpreter is now removed and rebuilt on the floor (slm_agent, enroll-node, native and repair scripts): an expected one-time rebuild per such node.
  • Rollback: revert this commit.

Model Used

Claude Sonnet 5.5 (claude-sonnet-5-5)

Issue Link

Refs #20932

Changelog fragment

  • Added changelog/unreleased/{issue}-{slug}.md — or N/A (internal change)

Checklist

  • Code follows AutoBot patterns from CLAUDE.md
  • Tests added or updated (or N/A with reason)
  • Documentation updated if behavior changed
  • Pre-commit hooks pass (git commit runs them automatically)
  • PR targets main (not release)
  • No secrets or credentials in the diff

Single-issue rationale: install-slm.sh must follow this change in the same PR once its two open PRs land, so it cannot be batched with another issue.

@mrveiss mrveiss added the phase:M1.1 install.sh completes, fails loudly and is safe label Nov 6, 2026
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 22097e0 and fb041e3.

Files selected for processing: 25

  • autobot-backend/code_analysis/install.sh
  • autobot-infrastructure/autobot-slm-backend/scripts/bootstrap-slm.sh
  • autobot-infrastructure/shared/scripts/deploy_autobot.py
  • autobot-infrastructure/shared/scripts/setup/setup_repair.sh
  • autobot-slm-backend/ansible/deploy-autobot-native.sh
  • autobot-slm-backend/ansible/playbooks/enroll-node.yml
  • autobot-slm-backend/ansible/roles/agent_config/tasks/python_env.yml
  • autobot-slm-backend/ansible/roles/ai-stack/tasks/main.yml
  • autobot-slm-backend/ansible/roles/backend/tasks/main.yml
  • autobot-slm-backend/ansible/roles/backend_services/tasks/main.yml
  • autobot-slm-backend/ansible/roles/dependency_patching/tasks/update-venv.yml
  • autobot-slm-backend/ansible/roles/npu-worker/tasks/main.yml
  • autobot-slm-backend/ansible/roles/python_interpreter/tasks/main.yml
  • autobot-slm-backend/ansible/roles/python_interpreter/tasks/resolve.yml
  • autobot-slm-backend/ansible/roles/redis/tasks/chromadb.yml
  • autobot-slm-backend/ansible/roles/slm_agent/tasks/main.yml
  • autobot-slm-backend/ansible/roles/slm_manager/tasks/main.yml
  • autobot-slm-backend/ansible/roles/tts-worker/tasks/main.yml
  • repo_tests/_reach_roots_record.py
  • repo_tests/python_version_declaration_drift_test.py
  • repo_tests/reach_scope_claim_17844_test.py
  • repo_tests/shell_lib_test.py
  • repo_tests/venv_builders_use_floor_interpreter_20932_test.py
  • scripts/lib/python_floor.sh
  • scripts/lib/python_floor_test.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No new hardcoded values of either class — ssot and other both block.

Known backlog in pipeline-scripts/hardcoded_values_baseline.txt is suppressed and tracked in #14371.

This was referenced Nov 6, 2026
@mrveiss

mrveiss commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Code review (code-reviewer pass) at b9c58d0

Verdict: APPROVE-READY — all seven earlier findings are fixed at this head; no new findings.

Earlier finding Status at this head Evidence (file:line)
(M) resolve.yml tagged always Fixed. Both tasks in resolve.yml and every include_role ... tasks_from: resolve caller (ai-stack, backend, update-venv, chromadb, slm_manager, python_interpreter main) carry tags: ['always']. roles/python_interpreter/tasks/resolve.yml (both tasks), roles/python_interpreter/tasks/main.yml (resolve include), plus the 5 caller files in the delta
(M) ensure_venv_version before slm_agent / enroll-node creates; shared mismatch rebuild in scripts Fixed. slm_agent runs it before the pip install, after the interpreter include (roles/slm_agent/tasks/main.yml, task "Enforce venv target Python version (#20932)"). enroll-node runs it before both venv creates. Scripts call the shared python_floor_venv_matches and rm -rf on mismatch in setup_repair.sh and deploy-autobot-native.sh. playbooks/enroll-node.yml (two new include_role tasks), scripts/lib/python_floor.sh (python_floor_venv_matches)
(M) deadsnakes gated to Ubuntu, clear refusal, no ` true`
(L) no-trailing-newline read Fixed with read ... || [ -n "$text" ]; test "no trailing newline still reads" added. scripts/lib/python_floor.sh python_floor_version
(L) install notice Fixed. A banner naming the command and packages is printed before installing; the header documents the no-prompt behaviour. scripts/lib/python_floor.sh _python_floor_provision and header
(L) venv-dir validation Fixed. ^[A-Za-z0-9_./-]+$ check; test "venv dir with metachar refused". scripts/lib/python_floor.sh python_floor_remote_venv_cmd
(L) drift test reduced to the 2-line retarget Fixed. git diff origin/main...head on repo_tests/python_version_declaration_drift_test.py is only main.yml -> resolve.yml (2 lines). repo_tests/python_version_declaration_drift_test.py:373-375

New findings at this head: none

Not checked: I ran no tests (neither the shell tests nor pytest) and no Ansible runs; this is a read of the diff. Behaviour of --tags runs against live hosts is unverified. CI status was not assessed.

@mrveiss

mrveiss commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Landed on main via merge train #21031 (merge commit 361d419); every commit of head b9c58d0 is in main.

@mrveiss mrveiss closed this Nov 7, 2026
@mrveiss
mrveiss deleted the issue-20932-venv-floor-interpreter branch November 7, 2026 14:19
timothybrush pushed a commit to timothybrush/AutoBot-AI that referenced this pull request Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

phase:M1.1 install.sh completes, fails loudly and is safe

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant