Skip to content

Reduce the runtime request for scoped capture reads and discovery - #8097

Merged
huangruiteng merged 1 commit into
mainfrom
codex/native-capture-read-reuse-1105
Nov 5, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/native-capture-read-reuse-1105

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

A scoped capture read used to send the structure of the entire file to the TypeScript selector. Listing one nested field sent all values as well. Wide captures paid this cost on each page, even when the response contained one small field.

The file adapter now sends the branches needed to resolve the requested pointers and the descendants needed for scoped discovery. The existing TypeScript selector still decides address validity, ordering and error recovery. The reader renders values and field metadata from the original digest-verified file. Root discovery and initial reads continue to receive full navigation input.

Validation includes actual CLI reads for escaped keys, overlapping pointers, large numbers, missing paths, invalid indices, scoped listings, and digest-bound recovery. A synthetic request-budget regression fails on main and passes here. The focused native reader and capture suites passed 166 tests. This is an internal transport optimization. User-facing body savings and end-to-end task cost are separate measures.

Standard premerge passed on this head. It reported one existing maintainability advisory in the work-item interaction contract, outside these two files.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent | gpt-6.1-sol | OpenAI | runtime_reported | max

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

Exact head: 51eb4fb; base: 4b7afef.

动机 / Motivation

Agent 或操作员通过 quota context-read 从已保存的 capture 读取一小段当前材料。过去只列出 selected 子树,也会把无关正文和整棵地址结构送入 TypeScript;现在只运输选址和指定发现深度所需的结构,返回的原始值与错误恢复保持一致。同一 242,021 字节合成文件的 scoped listing,请求从 242,150 字节降至 194 字节;36 组实际 CLI 观察在 base/head 逐项相同。本 PR 不改变可读范围、必读义务、准入或结算,也不声称模型 token、端到端延迟或长期成果改善。

改动思路 / Approach

地址有效性、排序和拒绝继续由已有 TypeScript selector 决定;Python 只构造运输结构并从原文件渲染,避免增加第二个规则或持久状态。当前边界仅是既有文件 reader 的内部请求和对应回归;不改 CLI、schema、配置、Host 生命周期或其他调用方。这保留了最短使用路径:已知 pointer 直接读取,未知路径沿现有 parent recovery 修正,无需增加设置、确认或重新准入。只替换长字符串仍会发送无关地址树,另建 selector 协议则扩大维护边界;现有 adapter 足以解决这个具体问题。数组仍需保留长度,不能把局部请求缩小泛化为所有输入或完整任务成本都降低。

具体改动 / Changes

依据 docs/reference/required-work-context.md,spec_revision 4b7afef2215067dd1171f308b93c9336e1c6e5d9。以下用规范已有术语指代未编号条款:RFC 6901、context_capture_selection_v1、Reader failures、performs no admission 均在已测边界 implemented;没有为本次优化另造验收门。完整两文件 diff 为 +95/−14,包含现有运输函数替换和 parity/negative/budget 测试,没有新模块、持久状态或公开 schema。

关键代码讲解

  • context_selection_transport 从原始 selector 构造路径前缀,仅保留必要祖先与发现深度内子节点;root discovery 保留原输入,数组保留长度。它不决定一个地址是否合法。
  • context_selection_view 将结构交既有 typed owner 验证,继续保留整批拒绝、历史 order 重试和 selection digest 校验;无效输入不能变成成功子集。
  • context_selection_bytes 仍从已校验原文件取值和计算 metadata。运输中的 null 占位不会变成返回值,large integer、signed zero、Unicode 和成员计数保持原来源。

对主干的风险 / Risks

No blocking finding。 最强反例是剪枝改变无效地址的诊断优先级、丢失可恢复 parent 或把占位值返回给调用者。本次独立的 36 组实际 CLI base/head 对照覆盖 root、escaped/empty keys、overlap、重复地址、scalar/null 子路径、非法/越界/unsafe index 和混合失败批次;完整输出与 exit status 相同,仅规范化 continuation/recovery 中的解释器前缀,未删除值、类型、错误、hash 或 cursor。原文件始终不变。另测 450,000 个零的 900,030 字节数组,两版本的标量选择和大容器分页都成功,因此没有把请求体膨胀猜测发布为缺陷。

PASS:reader-reference、decision-capture、first-read、unread-reachability 四模块共 173 passed,changed-file Ruff 与 compile 通过。将候选的同一 scoped-discovery budget 测试放到 immutable base 后,实际请求为 100,169 B,预算断言失败;该测试在 head 的完整 cohort 通过。独立宽文件对照的 242,150→194 B 计量是内部请求,返回正文不变。

标准 premerge 执行 6 项 direct、13 项 selected,没有新增阻断检查失败;_admitted_interaction_next_cli_actions 的既有 maintainability advisory 另作 base/head 归因。首次 gate 因 exact-scope quality receipt 缺失而未通过;随后记录 cqr_c1aa55452b3183b56de7,verify 确认为当前 base/head、两文件和完整 diff 指纹匹配,重新执行标准 premerge 的最终 gate 通过。既有 advisory 仍保留 failed:完整 base/head structured diagnostics 在只移除 repository_root 后相同,failing owner、checker、policy、fixture 与 environment 的摘要也相同;没有改写成通过或跳过。CI 按配置未查询、轮询或等待。

语义与 CI 对齐

复用现有 selector、page/reference vocabulary 和 file IO owner;没有新增 obligation、权限或关闭路径。该变化不需要独立 UI editor,也不依赖浏览器画面证明内部运输等价。保留文件完整读取与原版本恢复,不通过放宽 digest 或删除负例换取更小请求。

我的整体评价 / Verdict

APPROVE,限定于这个完整两文件 head。长期工作与用户路径均 preserved:相同必要事实、错误修正和后续分页保留,已测宽输入减少重复内部运输,新增人为交互为零。检查了 quota context-read 的 CLI、文件 reader 和 TypeScript selector;本次没有渲染页面、布局或可见控件变更,视觉评审不适用。未验证范围:无页面视觉变更;未验证已安装 Host 的自然模型采用。模型 token、端到端成本和跨平台 timing 继续未知;这些未测收益不作为批准依据。发布记录是作者账号下的 COMMENTED 结论,独立于 formal approval、merge readiness 和维护者合并授权。

English verdict: APPROVE — 51eb4fb reduces scoped selector request material while preserving the verified reader values, diagnostics, pagination and authority boundaries.

@huangruiteng
huangruiteng merged commit 7004bb0 into main Nov 5, 2026
32 of 42 checks passed
@huangruiteng
huangruiteng deleted the codex/native-capture-read-reuse-1105 branch November 5, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants