Repository navigation
Conversation
Signed-off-by: aihop <4408344+hhyykk@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=max.
动机
需要在命令行反复读取多个 Goal 状态的用户和 Agent。
同一次 quota 读取过去多次扫描执行代码;现在该次读取共享代码版本,下一次独立调用仍使用调用者当次提供的状态。
真实 File/SQLite 输出与拒绝语义保持一致,公共读取的重复代码扫描减少,完整摘要命令的耗时下降。
本改动不更改配额、权限、Todo 状态或 provider 路由,也不交付完整原生 CLI 或安装态 App。
完整原生 CLI、托管及安装态 App、长期任务收益和完整成本仍由迁移主线继续验收。
改动思路
沿用原有请求作用域,避免在每个视图复制缓存或判断规则。 只包住一次公共 quota 读取的代码版本生命周期。
build_quota_should_run 是已有公共决策组合入口,给它加原有 context decorator,兼容 facade 和没有外层 scope 的程序调用者即可共享一次执行代码版本。这里只固定执行代码身份;status 仍来自调用者当次参数,provider 和 callback 继续按原路径读,不缓存准入结果。已有外层 scope 时仍加入原生命周期。将相同包装散放在各个视图更难保持一致;另建数据缓存还会引入新鲜度问题。
这是调用路径及代码版本生命周期的有界改进。状态和准入规则仍由既有 typed owner 决定,观察来源缺失仍明确显示;没有额外 provider、协议操作、领域状态、权限判断或同步状态副本。
具体改动
评审完整 head cdc0c89e13c13a7f53427b60ad881c18583d6049,实际 PR merge-base 为 a590609a357f7cde17289b5ceba9f85a9fcb46cc。先固定接受的 docs/architecture/rfcs/typescript-control-plane-migration-v0.md,规范修订 a590609a357f7cde17289b5ceba9f85a9fcb46cc,再读完整提案。
规范逐项映射:§2.4 复用既有 owner,未双跑语义;§2.8 以同输入基线/当前入口核验成本;§5 分开报告生产 LOC、代码搬移和兼容边界;§6 比较完整输出、真实 File/SQLite、失败恢复和反例敏感性;§7 从正常 wheel/sdist 的实际 console 执行。以上在本切片 implemented;Stage 3 的完整 native CLI/App 收敛 deferred,剩余边界如动机所述。这里不以零语义删除、目录移动或更少 RPC 宣称完成整个迁移阶段。
关键代码讲解
build_quota_should_run: 完整公共读取在既有代码 scope 内运行;暂停和拒绝仍从当前输入产生。effect_runtime_request_scope: 未改动的 owner 负责嵌套加入、异常退出与 ContextVar 清理,下一独立请求重新解析代码。
生产代码 +3/-0(含空行;导入和 decorator 两条执行语句),不增加桥接调用或兼容分支。独立公共读取的实际代码扫描从 11 次降为 1 次;第二次暂停输入仍为 skip,嵌套外层 scope 仍只扫描一次。基线和去掉 decorator 的私有变体触发同一独立断言失败,当前 head 通过。
199 项相关 Python 测试通过;标准 premerge 的 6 项直接检查和 18 项选中检查全部通过。
每个 PR 独立比较 40 组真实 File/SQLite CLI 结果,覆盖五个命令、四个 manager-view、单 Goal 范围、未知范围、坏参数、损坏来源和暂停/恢复。另补 cap 与新来源的反例。每个 PR 的正常 wheel、sdist 各 25 个 console 案例通过:独立环境、空 cwd、无源码 PYTHONPATH,包内生产字节和 native 根已核。注册、state 和历史源文件保持不变。
比较保留完整字段、错误全文、权限、覆盖率、新鲜度标签、持久化时间及文件/库存 revision,只规范化明确的观察时钟和观察耗时。portfolio 的来源 digest 由捕获的原始 status 重算,原始快照和 manager context 的派生身份也独立核验,再比较规范化后的含义;没有直接删掉 opaque ID 掩盖差异。
本机同一 SQLite 八 Goal 输入、相同 Python/Node,准备完整字节码并预热原生运行时后,每臂 15 次新 Python 进程的真实 python -m loopx.entrypoint:摘要 p50 3361.68→1067.82 ms,p95 3493.07→1120.95 ms。这里没有计入 #6993 或已存在外层 scope 的额外收益。
对主干的风险
最关键的风险是代码 scope 跨请求泄漏,或入口搬移改变拒绝顺序、隐藏来源不完整和旧状态。实际负例保留:未知 Goal 的原合同是 code 0、空结果与 missing_goal_ids/不完整覆盖,不是凭空改为拒绝码;坏 registry 和无对应 mode 的 exact Todo 保持原错误;暂停后可见任务从 8 变 7,恢复后回到 8。未配置全局目录的 gates/todos 仍报来源不可用,不能称全局来源全健康。cap 下其余行明确 omitted,新注册的坏来源不会闯入已限定的 Goal 读取;显式读坏来源保持 unknown。
原生调用的方法序列保持一致;没有发起真实工作、外部 provider 投递或修改活跃 Goal。旧缺陷/私有变体会失败,当前 head 通过;包构建使用当前源码重建忽略的 Chat 资源后正常完成,最初错误构建调用和旧资源拒绝均保留。没有弱化断言、删掉失败或修改 budget。未查询、轮询或等待远程 CI。
冷原生启动、daemon RSS、PostgreSQL、Windows、安装态 App/Lark/模型以及长程净收益和完整成本仍未验证;本次不改变它们的原验收或授予推广资格。
我的整体评价
未发现本次精确 head 的阻断问题,结论 APPROVE。交付判断为 justified_increment:真实调用者获得可测的读取成本改善,边界可独立验证和回滚;不把这一结果等同整体 Stage 3、Goal 完成或模型收益。long_horizon 判为 preserved:当前状态、暂停、范围、失败恢复与后续读取语义保留;user_experience 判为 improved:同一读任务减少本地等待,无新增准备、权限或确认轮次。
沿用原有请求作用域,避免在每个视图复制缓存或判断规则。 只包住一次公共 quota 读取的代码版本生命周期。 兼容保留有真实调用方;采用现有 typed vocabulary/owner,没有新增领域状态分类或以 prose 猜测规则。保留已说明的未测边界。APPROVE 不授予合并、安装或发布权限。
English verdict: APPROVE — cdc0c89e13c13a7f53427b60ad881c18583d6049. Reuse the existing executable request scope at the public quota reader; current-state and failure behavior remain equivalent. 199 focused tests,40 full real-provider CLI pairs,50 installed console cases and matched normal-CLI measurements support this bounded improvement.
Goal And Delivered Outcome
A public quota read composes several existing typed decisions. When the caller has no outer executable-revision scope, each decision rescans the TS code tree. Global summaries and Todo views pay this cost repeatedly, although the runtime already supports a bounded request scope.
Put that existing scope at
build_quota_should_run, the shared public decision interface. The compatibility facade and global-view adapters inherit it. Status remains a caller-supplied snapshot; provider/callback reads retain their existing behavior. No decision result or source fact is cached by this change.Basis: TypeScript control-plane migration RFC Stage 3 caller adoption at
1a9933cce84d9ad94d3eb83490b4404741c7834a; targetmain. Observable before → after: repeated code-identity scans become one per quota read while native calls, decisions, pause/refusal signals and view coverage remain unchanged.Author Declaration
Implemented against
Specification:
docs/architecture/rfcs/typescript-control-plane-migration-v0.md, revision1a9933cce84d9ad94d3eb83490b4404741c7834a.quota/should_run.pyinterface; facade/global viewsSelf-check: production/test/docs guard review, related tests, real disposable providers, historical regression sensitivity and normal installed artifacts. No live task or external provider execution was launched.
Scope And Continuation
quota should-run, Chat workers and the proposed perf(portfolio): share executable revision across one evidence read #6990 portfolio outer scope already provide this lifetime; their gains are not counted here. The benchmark uses previously unscoped global views on main without perf(cli): reuse selected dispatch for manager Inbox commands #6989/perf(portfolio): share executable revision across one evidence read #6990.should_run.pybut changes acceptance guard logic; it adds no executable request scope. Its related acceptance hunks are already represented on this base. perf(portfolio): share executable revision across one evidence read #6990 changes the portfolio parent lifetime, perf(cli): reuse selected dispatch for manager Inbox commands #6989 changes Inbox CLI dispatch, Add projection envelopes to global todos and risks #5598 changes global projection envelopes, and refactor(todos): compose full readback in one TypeScript transaction #6874/perf(control-plane): reuse acceptance reads within one Todo snapshot #6984 change Todo reads. This changes distinct production/test hunks and does not repeat those implementations. Shared RFC edits are separate paragraphs.Validation
cdc0c89e13c13a7f53427b60ad881c18583d6049ona590609a357f7cde17289b5ceba9f85a9fcb46cc. Performance dataset predates this Lark-only rebase; measured quota/native/global/CLI files have unchanged hashes. The 189 related tests and installed artifacts were rerun on this final head.Early fixture/test construction failures were corrected before qualification. Incomplete artificial frontier rows, missing run-artifact profiles and small exploratory timings are excluded; the final fixture uses native public Todo creation and real observation files. No failing scenario was removed to obtain a passing result.
Complete-command performance
Pinned main
1a9933cce84d9ad94d3eb83490b4404741c7834aversus this HEAD; Linux, Python 3.11, Node 24.21.0 / SQLite 3.53.4. Same disposable fixture and sequential arms, 15 samples per arm; nearest-index p95. Each sample starts a new Python CLI process and includes startup/imports, parser, real status/quota reads, public source scanning, view projection and output. The managed native runtime is warm.Both complete packages are precompiled with the same interpreter and get one untimed CLI warmup; bytecode writing is disabled during timed CLI children. Compiled module sets are checked equal. This measures a prepared installation/cache state, not first-ever compilation or cold native startup. Each CLI proves its actual Python and TS roots.
Initial CLI timings had four extra setup-module bytecode files in the candidate and are excluded from gain claims. The primary row is the controlled rerun. Earlier post-import view timings remain supporting experiments; all their behavior and method observations remain in parity checks.
Global views still perform their status read and final envelope sealing separately; this does not claim one scan for the whole view. Native method sequences/counts are unchanged. The speedup removes repeated executable-tree IO, not RPCs, state reads or scheduling checks.
Every public output matches across arms and samples after normalizing only the top-level observation timestamp and projection-envelope read/serve clocks and elapsed-age fields. Null clock/age values remain null. Persisted progress timestamps, source-updated times, freshness/coverage/alert flags, Goals/Todos, reasons, omissions and boundary fields remain in the comparison. The unconfigured local global-directory source is disclosed identically by both views; no all-healthy or complete global-inventory claim is made. Raw local samples remain private.
This measures local evidence-read overhead, not long-horizon task quality, model/token savings, cold native startup, PostgreSQL or all of LoopX. Already-scoped consumers should not be credited with another equivalent speedup.
Portable reproduction
Save the three scripts outside both checkouts. Install their Python test dependencies and run
npm ciin both checkouts. Select the same Python and qualified Node version, use empty output directories, and run sequentially on an idle host:The fixture directory is shared deliberately so persisted source bytes and identities remain comparable. Setup creates synthetic canonical stores and public Todos only; it performs no work attempt. The qualifier disables usage pings, records every sample/native method/source proof and stops its managed runtime. A small explicit public scan directory keeps unrelated repository scans out of both arms.
setup_goals.pySHA256:338c2b0e33b541107bbb41b43dd6b5fc375fc10c61a91c147745d640f0b71165.qualify_global.pySHA256:e9e8343c7c7cf5e243adbfdd756b0cd1101bcd796ef2f9b54f66a2fb79cf07af.qualify_cli.pySHA256:a30c0ad45b31f3c9eb16c0fdcb8cee023a45448af78cf1047d048bac8cd290ef.Coverage/gaps: full repository suite, Windows, PostgreSQL, browser/model roundtrips, live provider delivery and hosted CI results are separate and were not claimed by the local checks. No TS semantic implementation changed; real typed transport and affected Python callers were exercised.
Frontend / Visual Evidence
UI impact: none. Existing read interfaces and output shapes remain unchanged; no new capability or screen is introduced.
Change Area
Technical Direction
TypeScript migration Stage 3, existing executable request-scope owner. Domain/authority owners and provider routing remain unchanged.
Shared-authority RFC fixture impact
Boundary Checklist