Repository navigation
perf(runtime): remove redundant source probes and planning encoding - #7688
Conversation
Signed-off-by: aihop <4408344+hhyykk@users.noreply.github.com> (cherry picked from commit ef661aa)
Signed-off-by: aihop <4408344+hhyykk@users.noreply.github.com> (cherry picked from commit 5d580f6312329971f4eb4ef4c5905bd537bffea7)
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
动机 / Motivation
历史 Todo 较多、需要继续下一项工作的用户和 Agent,会反复调用 quota should-run 读取完整规划。原先每次读取会重复查询源码元数据、重复编码完整规划请求,并为唯一任务 ID 编码不必要的去重键。现在保留同一份完整规范化事实和决策,只减少这些重复操作。可验证交付是完整大历史读取保持成功和原有决策,同时减少实际源码 stat 调用和规划 JSON 编码次数。本 PR 只优化已有 Python 宿主观察和编码;不改变 TS 决策、预算、权限、配置、持久化格式或任何大小上限。
验收依据为已合并任务 #7616 ,修订 eda29472f2cc69ca99161651d463415491f8ea20。逐项核对:完整规范化记录表 保持完整规范化事实;TS 保留唯一的诊断、选择和截止时间 owner 保持原决策 owner;2 MiB inline 或 64 MiB snapshot/响应展开上限 保持原限制。源码身份同时对照基线 local-delegation 合同,继续检查物理源码根、解释器、完整字节与哈希后复查。
改动思路 / Approach
源码元数据属于现有运行时身份 owner,记录编码属于现有规划 codec;将这些重复工作在原 owner 合并,比增加 TTL、裁剪事实或加入第二个 Python 选择器更合适。本 PR 只优化已有 Python 宿主观察和编码;不改变 TS 决策、预算、权限、配置、持久化格式或任何大小上限。正向路径是 File/SQLite 的完整 quota should-run 在普通、500 条逆序历史和2500条大历史中选中正确尾部任务,两个 scoped 请求仍由同一个 Node PID 处理。 反向路径是 被排除的 Agent 不获得任务,peer 任务不越界;实际 CLI 请求若故意缺失任务文本会以 blocked_health 拒绝,恢复正常源码后同一夹具回到可继续状态。 这两条真实 caller 路径用于判断保持了哪些行为;单个 helper 的相等断言不能替代安装或完整规划结果。
具体改动 / Changes
审阅 head:ecfdc2944d13c6b5a4581586dddb71a9ba17f016;不可变比较基线:33d9ecd9fd29bce4986da6c9e9a6b758a24f91b3。已逐行读取全 PR,范围是 6 个路径、+122/-46。关键符号如下:
- _scan_runtime_source_snapshot:一次 stat 同时取得 regular-file 类型和失效元数据。
- _runtime_fingerprint_for_snapshot:继续哈希所有选中源码字节,并在哈希后复查拓扑。
- _request_with_info:附加 response sink 后编码,沿用受限 snapshot 传输。
- build_referenced_todo_resume_planning_request:唯一规范化 ID 跳过 JSON key;重复 ID 保留完整事实比较。
6 个相关模块 207 passed、1 个 Linux-only skip。File/SQLite 八组成对真实 CLI 保留完整规范化请求及所有非时间输出;仅在验证观测时钟、事件 ID 派生与来源年龄计算后归一化这些时间信息,fresh/stale、诊断和权限字段全部比较。2500 条历史的请求约 2.87 MB,仍返回全部记录和正确尾部任务,canonical 事实与正文未改。
同一普通夹具中,Python os.stat 调用从1532降为766,规划 envelope 编码从4降为2;2500历史的去重键编码从5008降为6。这里计数的是 Python 调用与编码,未据此声称 OS syscall、p95 或模型成本收益。故意删除实际请求文本会让 CLI 拒绝运行;恢复同一夹具后重新读到完整文本与正常结果。
对主干的风险 / Risks
主要风险是 唯一 ID 快路误合并冲突记录、合并 stat 后漏掉源码变化,或单次编码漏掉响应快照。完整事实冲突、源码变更/错误/链接、1.8 MB 输入与2.4 MB响应等真实 transport 用例均由当前相关测试覆盖;没有 TTL、字段白名单、第二个选择器或安全上限增长。
精确 scope 的 change-quality 回执有效,Ruff、编译、diff 与 RFC 双语检查通过。当前标准 premerge 通过:最终完整 standard premerge 的6项直接检查和18项选中检查全部通过;首轮同 head 的词表检查在120秒超时,基线96.63秒、受控head109.85秒通过,最终完整复核亦通过。全部原件保留,未改变时限,也未声称已归因或解决所有负载下的稳定性。 首轮失败和当前复核分开记录;不查询或等待远端 CI。私有比较器的早期 scope/exit 和时间字段假设错误已保留,修正后回读全部原始成对观测;故意缺失文本的拒绝结果不作为 PR 失败。
我的整体评价 / Verdict
未发现 diff 引入的可执行阻塞问题,当前完整标准检查通过,可以批准这一有界重构;本结论不授予合并权限。源码元数据属于现有运行时身份 owner,记录编码属于现有规划 codec;将这些重复工作在原 owner 合并,比增加 TTL、裁剪事实或加入第二个 Python 选择器更合适。本 PR 只优化已有 Python 宿主观察和编码;不改变 TS 决策、预算、权限、配置、持久化格式或任何大小上限。长程工作与用户操作路径在本次范围内保持:保留原权限、停止、恢复和结果读回,不增加确认轮次;没有把一次成功读回或测试数当成长程模型收益。已检查全部变更及其 quota CLI/runtime 调用方,没有渲染页面变化;任务操作仍使用同一现有 CLI。本次没有重新资格化作者的整套 p50/p95、分词 Token、安装态 App 或长程模型效果;历史超时保留,未将当前通过扩展为所有负载下的资格。
English verdict: APPROVE the bounded refactor; current required checks pass, earlier timeout retained, no merge authority granted.
Follow-up to merged #7616. The complete large-Goal planning path is available, but repeated JSON work and duplicate source metadata probes add cost to the full
quota should-runentrypoint. This removes that redundant host work while retaining complete facts and the existing private snapshot transport.A source file's regular-file type, mtime, ctime and size now come from one stat. The source set, link/error policy, physical release/interpreter identity, full-byte hash and post-hash rescan remain. Unique normalized Todo IDs skip canonical JSON deduplication keys; repeated-ID groups still compare complete normalized records. Snapshot requests are encoded after attaching their response sink. No cache TTL, RPC mode, domain rule or size/permission limit is added.
Validation is bound to product head
ecfdc2944d13c6b5a4581586dddb71a9ba17f016, integrating target main33d9ecd9fd29bce4986da6c9e9a6b758a24f91b3.should_run=true,normal_run, all 2,500 completed records and the selected tail task, with canonical facts/narrative unchanged and no business run created.8505069601a5a722c11eccf5302f72ffb9276fed. Python 3.13.12, Node 24.21.0, SQLite 3.53.4; cold means cold daemon with warm disk cache.Independent same-code daemons calibrate A/A; separate frozen source arms run alternating A/B. Controls must resolve both p50 and p95 within 25 ms and 5%, with paired-bootstrap upper bounds inside the measured resolution and no detected regression. All 16 metrics passed; qualified cohorts contain 19,840 command executions, including controls. Larger-control repeats resolve only previously unqualified warm measurements; original rows and failures remain retained, and rows from different cohorts are not pooled.
Evidence: original eight-case cohort, File warm small-input precision, warm-history precision. Complete outputs match byte for byte within every pair; actual
o200k_baseandcl100k_basecounts are equal in every case. These deterministic reads introduce no model dispatch; this is not a long-horizon generative-model billing claim.The formerly failing 2,500-history inputs qualify functionality rather than using failed baseline latency/empty output as a performance or token reference. The temporary qualification workflow and private experiment material are excluded from this product branch. Current-main overlap is rechecked separately before publication; the numbers above remain explicitly pinned to the tested head and baseline.
中文:续接已合并的 #7616,合并源码文件类型与版本元数据读取,删除重复 JSON 编码。完整事实、原 v1 格式、输入/结果隔离、响应快照与全部安全上限保持。真实 File/SQLite 大历史完整入口、相关回归和标准检查通过;原性能门的八格全部通过,完整输出与真实分词 Token 相等。旧失败/精度不足数据保留,未混合或重写为通过;不声称完成安装态 App 或长程生成计费验证。