Repository navigation
fix(browser): pin Python backend import provenance - #6291
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; gpt-6.1-sol; OpenAI; runtime_reported; reasoning_effort=xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机
未发现阻塞问题。审阅精确 head aa252c1f7debe95e1dc5031dff7643289b24b792,基线 36a2f71064b74cb14db9701bf33fb834c9878f04。运行源码浏览器验收的维护者在创建 Goal 场景中遇到导入错误;该错误使验证在业务断言前中止。旧启动按脚本路径执行,裸解释器找不到 LoopX;新启动仍选原解释器,并明确从本工作树导入。打包工作区在未安装 LoopX 的 Python 3.11 下完成目录选择、预览、503 后保留输入、目录失效拒绝、恢复后确认及真实注册表和状态文件读回。本 PR 限于浏览器验证的启动来源,不改变用户界面、生产状态规则或 CI 工作流,也不宣称完整 CI、模型运行或发布优先级合格。
没有独立书面规范;依据已复现的 CI 导入故障和既有 fixture.startServer 的安装环境隔离约束判断,不把 PR 作者声明当作验收证据。
改动思路
复用现有解释器选择器并集中两个真实调用方的导入边界;单独安装源码只修 CI 环境,给后端无条件补路径会污染安装态验证。本批只交付可回读的浏览器验证启动修复;确认、状态写入、模型分派和 UI 所有权保持在既有边界。最小替代方案是只在 CI 安装源码(#6287);它仍不能证明第二个动作后端使用指定安装包。22 行的共享启动构造器有两个实际消费者,维持现有 resolveTestPython 优先级,不新增状态、协议、权限、调度器或产品配置。
具体改动
scripts/test-python.mjs:80的testPythonCommand选择原解释器,用-I -u -c隔离导入。源码模式仅补本工作树;显式安装模式不补源码,并拒绝同一 checkout 的 editable 来源。test-python.d.mts给返回命令及参数数组补类型。fixture.mjs的startServer复用该边界,仍分别验证 source/installed Chat 资源。goal-workspace-selection.mjs:16用runpy保留脚本__file__和 argv;原 readiness、预览、确认、注册表读回与终止清理保持。- 155 行 focused 回归覆盖裸解释器、真实 Node→Python→HTTP、缺包、editable、外部 PYTHONPATH 与合法安装导入。最小导入夹具只测试 loader;真实独立 wheel 和打包前端另行验证,不以夹具冒充安装产品验收。
精确基线/当前版本用同一打包场景、同一后端 fixture 和 Python 3.11 比较:旧安装态正向通过;注入外部 PYTHONPATH 后,旧动作后端报 foreign package imported,而当前版本通过创建及持久化读回。裸解释器的旧源码启动也真实复现 ModuleNotFoundError,当前版本已通过。丢弃的仅是动态路径/端口/PID,错误及业务断言均保留。
对主干的风险
本地测试默认导入更严格,刻意依赖外部 PYTHONPATH 或 editable checkout 的“安装态”验证会拒绝;这是已披露且有反例的预期纠正。轮子位于 site-packages 的合法安装保留,解释器显式覆盖、版本拒绝和发现顺序由原五项 resolver 测试验证。没有产品 shared-state 分类、prose denylist 或 actor authority 命名变化,也没有把约束称为可忽略指导。
集成后 11 项 Python 回归、5 项 resolver、两种真实打包创建旅程、Chat 构建、TypeScript/Ruff/mypy/语法与差异检查均通过;最终原生 canary 的 4 项直接检查、2 项目录 smoke、1 项公共边界扫描及 CQR 均通过。主干移动导致的旧 CQR 拒绝如实保留;最终凭证绑定本次冻结基线和 head。未读取/等待此 PR 的远端 CI(当前 Goal review policy),原生 Linux/Windows、live-model 与整个 CI suite 仍未验。
我的整体评价
APPROVE。这是有两个真实调用方、正向保持和错误来源反例的有界验证修复,源码创建与安装包创建都已读回,完成本 PR 的目的。本批只交付可回读的浏览器验证启动修复;确认、状态写入、模型分派和 UI 所有权保持在既有边界。后续相邻重构已采用共享导入边界;无需新增抽象或拆成多个 PR。#6287 CI 安装、#6274 容量验证和 Pages 部署仍独立推进。此作者自评记录不等于独立维护者批准或 merge 授权。
English verdict: APPROVE - aa252c1. The shared test launcher fixes clean-source backend imports and keeps the installed action backend isolated. Matched immutable-base/current packaged journeys, missing/editable/foreign-import negatives, real HTTP/registry readback and focused native validation passed; full remote CI and live-model qualification remain separate.
Goal And Delivered Outcome
The Python-backed
goal-workspace-selectionbrowser scenario launches its backend by script path, so a clean interpreter cannot import the checked-outloopxpackage. The baseline browser job failed withModuleNotFoundError. Both browser backends now use the existing interpreter resolver plus one isolated import launcher: source mode selects this checkout; explicitLOOPX_PYTHON_BINmode uses its installed package and rejects borrowing the checkout. The scenario usesrunpyto retain its script arguments and fixture location.Related #6287 installs the checkout in CI. This complementary fix makes the source launch reproducible without that installation and enforces the installed-profile boundary in the action backend. It changes no workflow, assertion, timeout, user-facing UI or production runtime rule.
Author Declaration
Written by: model_agent, OpenAI GPT-6 / OpenAI.
Specification: the reproduced import defect and the existing installed-interpreter isolation contract in
examples/personal-workspace-browser/fixture.mjs, baseline36a2f71064b74cb14db9701bf33fb834c9878f04.resolveTestPythonunchanged; five resolver tests passtestPythonCommand; bare Python 3.11 backend HTTP and packaged creation journeyScope And Continuation
Complete within the browser-launcher scope. The shared command builder is a bounded companion refactor that gives both current callers one import-provenance owner. No new capability, protocol vocabulary, provider or Python control-plane decision owner. The broader CI capacity trial in #6274 and source-install workflow repair in #6287 retain their separate acceptance; this PR supplies no organization-wide release priority or full-suite qualification.
Validation
Tested revision: aa252c1. Run state: finished. Inputs: synthetic, public_fixture.
pytest tests/test_browser_workspace_backend_provenance.py tests/presentation/test_chat_bundle_launcher.py: 11 passed; actual Node→Python→HTTP backend plus source/installed missing/editable/foreign-PYTHONPATH casesgoal-workspace-selectionwith bare source interpreter and independently built/installed wheel: both pass directory selection, desktop/mobile/keyboard, retained input after 503, unavailable-directory refusal, recovery, confirmation and registry/state readback. Model dispatch and status are synthetic. Data and Effect processes are isolatednode --experimental-strip-types --test tests/control_plane_ts/test_python_runtime.test.ts: 5 passedThe native premerge initially held a stale quality receipt after main advanced; that failure is retained. The final receipt and premerge bind the integrated head and frozen base above.
Frontend / Visual Evidence
UI impact: none. Frontend behavior is exercised through the existing packaged scene, including its unchanged error/recovery states and desktop/mobile assertions. CLI interpreter discovery is reused; Lark is unaffected.
Boundary Checklist