Repository navigation
perf(control_plane): scope interaction_contract & decision_context RPCs and cut explore CLI test tax - #9601
perf(control_plane): scope interaction_contract & decision_context RPCs and cut explore CLI test tax#9601loopx-agent wants to merge 2 commits into
Conversation
…RPCs and speed up explore CLI tests 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.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 保留显式 measurement context 的公开 explore finding 回归测试。 原 File、SQLite 分支通过正式 CLI 写入共享评估条件和候选分值。候选把这些命令交给 loopx.cli.main(argv),绕过了 entrypoint 的 selected dispatcher。同一变化也触及零分捕获和损坏历史恢复用例。仅在 selected dispatcher 注入一次针对这组输入的失败时,基线三项失败,候选三项通过。把原参数交给公开 CLI 子进程后,健康候选三项通过,注入时三项再次报错。请保留两种 provider 共用的显式 context 子进程用例,以及原公开路径的读回断言。显式条件 · 公开 dispatcher
动机 / Motivation
宿主在构建当轮任务约束和读取 Decision Context 时会多次进入 Effect runtime,基线每次重复确认该 runtime 的源码版本。候选为一次逻辑读取复用版本确认,并减少 Explore 回归用例启动解释器的工作。目标同时要求保留真实 CLI 的参数输入和数据读回。范围覆盖 Turn 前置投影与 Explore 测试。
改动思路 / Approach
两个生产模块复用已有请求作用域。作用域选择 runtime 代码版本,Goal、Agent、绑定 revision 和执行约束继续由原有 typed owner 读取和校验。调用者已经处于外层作用域时会复用它,独立调用首次进入时才解析版本。已有开关和失败路由继续由各能力决定。固定参数的 fixture 可以继续使用进程内 driver。显式共享条件是独立的公开调用,需要保留一条完整 dispatcher 测试。源码版本边界
具体改动 / Changes
read_decision_context_turn_context覆盖resolve_local、本地观察和project_turn_view。遇到 revision 冲突仍重读绑定。_build_interaction_contract_projection和unadmitted_action_selection的作用域覆盖已有执行、读入和仲裁计算。两条 spy 回归确认多次 RPC 共用一个 fingerprint,并覆盖异常时的 scope 清理。Context 入口 · 交互投影- 两个 Explore suite 复用进程内 CLI driver。SQLite 维持独立 runtime 并在每例结束回收。中断后修复回执、hook 派发的读取、分页和用于验证旧分页失效的手工 finding 仍运行子进程。它们未使用
--measurement-context-json。共享条件的public-finding-route回归仍需修复,运行时的one-request-revision由现有工具验证。
对主干的风险 / Risks
六个文件合计 +318/-39。正常输入可写出相同测量事件,但显式 context 经过公开 dispatcher 时发生错误,候选只能验证兼容 parser 和底层 handler。上述注入只模拟选中路由拒绝。精确 head 的真实外部命令在未注入时通过。145 项定向 pytest 通过。标准 premerge 的 10 项目录 canary、8 项风险检查及 4 项直接检查通过。已有中断后的真实入口、单例 File/SQLite 读回、绑定修订重读和作用域异常退出仍有覆盖。本轮独立计数验证了版本复用机制,生产端到端延迟和跨平台 worker 退出仍待验证。
我的整体评价 / Verdict
保留两处运行时 scope 和普通 fixture 的优化即可。让显式共享条件与零分/损坏历史的关键用例重新跑公开命令,能恢复此前可检测的故障,同时保留大部分测试收益。该变更涉及 CLI 和本地测试,未引入渲染界面。结论绑定 a7eae325d098b28a0a2b07ef10697f948c179885。
English verdict: REQUEST_CHANGES for a7eae32. Restore public Explore finding dispatcher coverage. Three base and subprocess-restored cases detected the targeted failure while all three current-head cases missed it.
…estore subprocess coverage for explore finding checks 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.2-sol · OpenAI · runtime_reported · xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
宿主在构建当轮任务约束和读取 Decision Context 时会多次调用 Effect runtime。 同一次读取的多个 RPC 会重复确认 runtime 的源码版本。 候选把确认次数收敛到一次逻辑请求,并在 Explore 测试中保留关键的真实 CLI 调用。 评审范围覆盖 Turn 前置投影和 Explore CLI 测试。 在本机验证真实 CLI、File 和 SQLite,及确定性故障注入。生产请求尾延迟和跨平台 worker 退出未独立计量。远端 CI 未读取。
改动思路 / Approach
缓存只针对此次请求选择的代码版本。已有 TypeScript owner 仍处理绑定修订、执行资格和历史。 复用原版本作用域,保留各层验证及公开入口的关键 subprocess。 新头只改了两份 Explore 测试。显式共享条件、改变评估条件和零分历史恢复再次通过公开子进程,普通用例仍用进程内入口。同一故障只在真实子进程的 selected dispatcher 返回 73。旧受审头三项漏报,当前头 File 和 SQLite 的显式 context 加零分/损坏历史共三项都检出,健康候选通过。 上一轮的 public-finding-route 问题已通过同一故障复验。 上一轮评审 入口覆盖
具体改动 / Changes
- read_decision_context_turn_context 把 resolve_local、观察及 project_turn_view 置于同一次版本作用域。读取途中切换绑定 revision 时,原重读机制继续工作。 Decision Context
- unadmitted_action_selection 与 _build_interaction_contract_projection 分别复用已有局部作用域。一旦进入外层 scope,内部查询用同一代码版本。待办资格、交互和仲裁仍由原投影处理。 未准入选择 交互投影
- 两份 Explore 测试用 entrypoint 的 main 处理普通 fixture,保留 SQLite 每例的 runtime 清理,以及中断恢复、分页和重点测量的独立子进程。当前头在两种 provider 上以子进程提交首个显式共享条件及改变的条件。零分历史测试还从子进程验证非法测量未改日志。 测量 helper 写回 helper
one-request-revision 已验证为单请求内复用版本。public-finding-route 保留已验收的公开参数、退出码和读回。规范修订为 811c1a1。 源码版本边界
对主干的风险 / Risks
作用域若泄漏,会让后续调用复用旧版本;把所有测试移到进程内也可能漏掉真实入口错误。在同一 fixture 和真实本地 Effect runtime 上,已绑定的 Decision Context、交互投影和等待投影均从 2 次 fingerprint 解析降至 1 次,RPC 均为 2 次。 绑定和等待输出的关键字段一致。未绑定保持 absent、1 次解析和 1 次 RPC。原绑定修订更换和未绑定用例在主干及候选通过,显式未准入、有效选择与冲突套件两版均为 64 通过。 四组相关 pytest 共 145 项通过,包括中断后写回、scope 异常清理、绑定 revision 重读和真实 Explore 历史读回。 标准 premerge 的 10 项目录 canary、8 项风险检查及 6 项直接检查均通过。Ruff 和两文件 mypy 通过。
我的整体评价 / Verdict
APPROVE。 公开 CLI 回归重新检出实际 dispatcher 故障。底层版本解析次数下降,原绑定、等待和未准入行为保持。评审绑定当前提交。
English verdict: APPROVE at ff85ff2. Public File and SQLite measurement and recovery tests detect all three injected routing failures again. The production scope reuses one fingerprint across two RPCs while preserving binding and wait behavior.
Summary
Reduce control-plane request-scope RPC/source-fingerprint overhead on hot interaction-contract and decision-context turn-start projection paths, and cut serial verification latency across two Explore CLI test suites while preserving crash-recovery subprocess coverage and zero worker leaks:
@effect_runtime_request_scope):loopx/control_plane/work_items/interaction_contract.py: decorate_build_interaction_contract_projectionandunadmitted_action_selectionso multi-RPC contract assembly (_project_interaction_execution,build_runtime_capability_reentry_packet,_interaction_reads_and_arbitration) resolves the runtime source fingerprint once per request.loopx/capabilities/decision_context/turn_start_hook.py: decorateread_decision_context_turn_contextso sequentialresolve_local+project_turn_view(+ retry on revision conflicts) pin one runtime source fingerprint per call.tests/control_plane/test_effective_turn_replan.py: verifybuild_interaction_contractresolves_runtime_fingerprintonce across>=2RPCs and resets_REQUEST_RUNTIME_REVISIONon both normal completion and injected RPC failure.tests/capabilities/test_decision_context_turn_hook.py: verifyread_decision_context_turn_contextresolves_runtime_fingerprintonce across>=2RPCs and resets_REQUEST_RUNTIME_REVISIONon both normal readback and injected failure.tests/control_plane/test_explore_result_writeback.py&tests/control_plane/test_explore_measurements.py: route standard_run_cliandexplore findingcalls through in-process_invoke_loopx_cli/_invoke_loopx_argvhelpers, scopeisolate_sqlite_runtimeand_teardown_sqlite_runtime()strictly tosqliteprovider runs (reusing pytest's session worker Effect runtime onfileruns), and preserve real subprocess coverage for interrupted crash-recovery replay (via_subprocess=interrupted),hook["required_reads"]child reads, paginated CLInext_commandloops, and manual-finding CLI capture.Local Verification & Paired Benchmarks
ruff checkon all 6 touched files: passed (0errors)mypy --follow-imports=silenton both production modules: passed (no issues found in 2 source files)pytest -n autoon all 4 touched suites:145 passed in 55.66s/tmpcwdpyteston both optimized CLI suites:107 passed in 75.62s.venv/bin/python3 -m pytestserial worker leak-diff census (--basetemp /tmp/w71-leak-py3):107 passed in 73.44s,new_live_pids=0 info_files=0origin/main@811c1a1f6665(3xalternating-n auto+1xserial):tests/control_plane/test_explore_result_writeback.py:-n auto: base[28.34, 24.73, 26.74]median26.74s-> head[23.71, 24.28, 24.09]median24.09s(+9.9%)serial: base110.75s-> head65.76s(+40.6% faster)tests/control_plane/test_explore_measurements.py:-n auto: base[7.69, 7.21, 7.40]median7.40s-> head[7.46, 7.19, 7.35]median7.35s(+0.6%)serial: base13.91s-> head11.25s(+19.1% faster)loopx check --scan-pathon all 6 files:ok=True,errors=0, warnings=0loopx canary premerge --from-git-diff --git-diff-base origin/main:passed(10/10catalog canaries,8/8risk profile smokes,4/4direct checks,manual_holds=0)