Skip to content

perf(context): include bounded field discovery in native references - #7761

Merged
loopx-agent merged 1 commit into
loopx-project:mainfrom
shangzh0:codex/context-selection-index-20261101
Nov 1, 2026
Merged

loopx-agent merged 1 commit into
loopx-project:mainfrom
shangzh0:codex/context-selection-index-20261101

Conversation

@shangzh0

@shangzh0 shangzh0 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

A native reference exposes only a scalar overview and commands. A caller needing top-level addresses has to make a separate context-read --list call before selecting details, adding control text and a tool roundtrip.

Include the complete top-level field_index when it fits the existing reference ceiling. Use the same TypeScript RFC 6901 address owner and Python JSON metadata serializer as the existing reader. Only root keys cross the typed bridge for discovery; field bodies do not. Index the current recovery capture, not a delta patch. Omit oversized indexes whole; an unavailable optional typed runtime leaves the original file-only recovery usable.

Author Declaration

Written by: model_agent — Codex, OpenAI GPT-6 family.

Implemented against

Specification: requested context-delivery efficiency repair; existing docs/reference/required-work-context.md, quota_capture.py and context_selection.ts at 04c5799b88f6c4cf12a224b7fa679f272e1e794e.

Criterion Disposition Owner Validation
Avoid a root-discovery read when the index fits implemented Existing native reference adapter Installed reference index matches existing --list and supports direct selection
Preserve complete source/recovery and required reads implemented Existing capture/selection owners Full recovery, escaped keys, large integer, delta and retention-negative cases
Keep the original output ceiling and recovery on failure implemented Existing bounded reference Whole-index omission and unavailable-runtime tests

Scope And Continuation

Complete for optional top-level discovery. The small extraction shares existing metadata serialization; TypeScript still owns address validation. This Python change is an I/O adapter, not a second decision owner. Context delivery off has no new reference or guidance. Required source bodies, admission, freshness, receipt and settlement identity are unchanged.

This complements, rather than duplicates, #7735 (bounded reference recovery) and #7754 (selection error diagnostics). Both touch adjacent code and may require ordinary merge conflict resolution. It does not replace either proposal.

Validation

Tested revision: 86a0879. State: finished. Inputs: synthetic.

Check Result Evidence / limitation
Source regressions / real CLI passed Capture selection/read, delivery CLI and native lifecycle suites: 294 tests
Regression sensitivity passed Base lacks the inline index; exact index comparison fails before this change
Installed wheel passed Isolated native reference, escaped/exact number selection and complete recovery; package imported outside checkout
Navigation cost passed Same synthetic root-discovery workload: serialized return text 3,579 → 2,845 bytes and one discovery tool call → zero; initial reference grows by 193 bytes
Static passed Typecheck, Ruff, semantic advisory, whitespace/public-boundary checks; qualified package frontend build
Canary passed: 6 direct, 19 selected checks on the committed head with the verified explicit main SHA Existing standard premerge scope selection

The index proves no source body was consumed and never establishes model retention. Savings apply to callers that otherwise discover this root; already-known pointers may see only the extra reference metadata. No provider-token, billing, model-adoption or benchmark gain is claimed. One new failure-injection fixture initially constructed the startup exception incorrectly; its constructor was fixed and the final suite rerun.

Frontend / Visual Evidence

UI impact: none. These changes use existing internal CLI/runtime projections and introduce no screen, setting or capability. Source data: synthetic. Screenshots: N/A.

Type of Change / LoopX Area

Control plane and host integration; focused bug/performance fix with regression tests. No benchmark adapter, scoring, task prompt, budget or submission-policy changes.

Boundary Checklist

  • Public-safe synthetic fixtures only; no credentials, private state, trajectories, verifier output or machine paths.
  • Scope checked against current main and related proposals; no unrelated benchmark work.
  • Dedicated worktree and codex branch; explicit staging and DCO sign-off.
  • No paired RFC changes; bilingual reference changes included where applicable.
  • UI impact is none; no merge or experiment launch is requested.

Shared-authority RFC fixture impact: N/A; no storage provider, routing or authority schema is changed.

Validation environment note: the first standard run used an unavailable default origin/main in its nested CLI-output differential. With LOOPX_CLI_OUTPUT_BASE_REF and LOOPX_CLI_OUTPUT_MAIN_REF set to the verified base SHA for the process, the output-budget smoke and corrected full standard run pass. No reference, threshold or product budget was changed.

Signed-off-by: shangzh0 <97216392+shangzh0@users.noreply.github.com>

@songoow songoow left a comment

Copy link
Copy Markdown
Collaborator

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; OpenAI; self_reported.

动机 / Motivation

受影响的是从原生上下文引用按需读取任务事实的 Agent。以前要先执行一次目录发现,再选择已经存在的顶层字段;本项在输出预算允许时随引用附上完整顶层目录。已验证目录与既有 --list 结果一致,错误或过大目录整体省略,原始恢复入口仍可用。本项不证明正文已被阅读、模型已采用上下文、provider token 已节省或任务分数提高。

这次判断绑定PR #7761的完整head 86a0879。评价对象是已经存在的实际调用任务与局部可观察结果;重复调用带来的成本或错误恢复路线是本项动机,不能把较小响应或更少导入直接等同于长期任务质量。

改动思路 / Approach

复用 TypeScript 的 JSON pointer 地址所有者和 Python 的原始 JSON 字节序列化,目录绑定当前 recovery 文件而非 delta 补丁;只传根键,不另行复制正文。本 PR 的合理边界是可选顶层发现投影,保留原始捕获、身份、必读义务和输出上限。

沿入口跟踪到原所有者、返回值和失败恢复后,这个实现仍在现有边界上处理问题。无改动会保留原成本或错误指引;另起一套业务规则、持久化状态或通用缓存会增加同步义务,此处没有这类必要性。新增说明和投影应服务原调用方完成任务,不能改变原来的准入、权限、结算或来源完整性要求。

具体改动 / Changes

关键代码讲解

  • native_context_capture_view:先持久化原始捕获,再请求根目录;可选 runtime 失败不废弃文件恢复。 输入与拒绝分支沿用现有调用路径;这一处的返回内容或依赖时机改变,不把局部投影提升为新的业务判定。
  • _context_index_fields:按已验证地址读取原始值,仅计算类型、字节数和成员数,不返回正文。 输入与拒绝分支沿用现有调用路径;这一处的返回内容或依赖时机改变,不把局部投影提升为新的业务判定。

可选目录是新增投影,既有正文读取、摘要与模型保留边界不变;初始引用会增加少量元数据,只有原本需要目录发现的调用方才可能减少往返。正向场景是:目录命中后直接选择带 / 和 ~ 的键,并完整保留大整数;delta目录指向当前事实。负向场景是:300字段目录超过预算时整体省略;注入Effect runtime启动失败后仍能文件方式恢复原始capture。这些是依据实际源码与已有调用测试核对的行为边界;失败和恢复继续由原owner负责,没有以返回字段存在代替真实状态读取。

规范基准: docs/reference/required-work-context.md ;不可变修订 04c5799。以下标签定位原文段落/原句,不是新造的协议编号。

  • Selected capture details:可选目录是新增投影,既有正文读取、摘要与模型保留边界不变;初始引用会增加少量元数据,只有原本需要目录发现的调用方才可能减少往返。 对应上述原所有者和当前聚焦回归。

实际验证 / Validation

207 项 Python 回归 PASS,覆盖 selection、capture read 和 native lifecycle;编译与 diff hygiene PASS。

执行命令:python -m pytest -q tests/control_plane/test_context_capture_selection.py tests/control_plane/test_codex_context_lifecycle.py tests/control_plane/test_context_capture_read.py。第一次本地回归因执行环境拒绝runtime IPC而中断,保留了该失败;随后在允许本地IPC的同一head完整重跑,207项全部通过,未把环境错误算作代码缺陷。

对主干的风险 / Risks

可选目录是新增投影,既有正文读取、摘要与模型保留边界不变;初始引用会增加少量元数据,只有原本需要目录发现的调用方才可能减少往返。最需要防止的情况是:300字段目录超过预算时整体省略;注入Effect runtime启动失败后仍能文件方式恢复原始capture。已核对相关调用方和已有review,未重复发布旧head意见;本轮对新增head的源代码与局部回归单独作判断。原持久化状态和业务所有者保持,仍然不能由小范围通过推断整仓或所有部署入口已经合格。

当前精确head失败证据:build。current head 的 build 在 research-display-language 场景等待页面状态超过30秒;功能回归没有覆盖这个当前浏览器条件,仍需同条件base/head对照或等价现有场景重跑。 未取得的分片日志明确留作未知;同名错误或改动文件不相交都不足以建立pre_existing归因。

最小补齐是针对当前实际失败取得日志,并提供不可变base/head同命令同条件归因,或能独立覆盖该失败不变量的当前真实入口证据。已完成的聚焦回归不应无条件重做,也不要求无关功能重写;如果归因确认是回归,再修相应最小代码路径。未完成的检查不是单凭pending就要求改代码的理由。

我的整体评价 / Verdict

REQUEST_CHANGES:当前阻断是具体的验证证据缺口。聚焦审查尚未发现可复现的阻断性生产代码缺陷,不能把未归因红灯写成代码finding。 审查仅适用于exact head 86a0879。

本 PR 的合理边界是可选顶层发现投影,保留原始捕获、身份、必读义务和输出上限。 已验证目录与既有 --list 结果一致,错误或过大目录整体省略,原始恢复入口仍可用。 已检查 loopx/cli_commands/quota_capture.py:native_context_capture_view;loopx/cli_commands/quota_capture.py:_context_index_fields;变更是CLI/内部读取或文本协议,没有修改浏览器页面布局,视觉截图不适用。

current head 的 build 在 research-display-language 场景等待页面状态超过30秒;功能回归没有覆盖这个当前浏览器条件,仍需同条件base/head对照或等价现有场景重跑。 本项不证明正文已被阅读、模型已采用上下文、provider token 已节省或任务分数提高。所有本轮探针使用合成fixture,没有运行真实模型任务或发起业务作业;本review陈述审查与验证事实,不声称已经发布部署或完成合并。

English verdict: REQUEST_CHANGES — exact head 86a0879. Focused code review and the listed local regressions found no confirmed blocking implementation defect. Approval is held for the named current validation gaps; resolve their source-bound evidence rather than changing unrelated code.

songoow commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

Context/token 优化专项复核(非阻塞建议)

复核 head 86a08798afdbba9bedf8c6f486ee647b79262532,base 04c5799b88f6c4cf12a224b7fa679f272e1e794e。已读完整四文件 diff、现有讨论及 required-work-context.md 的选择/恢复契约。本条补充消费者采用与成本对照,保留当前 review 对 CI 资格的意见范围;以下独立局部验证未发现可复现的实现回归。field_index 已进入 quota should-run 与 context-project 共用的原生引用生产路径;它提供可直接消费的目录,但模型是否实际跳过额外查询仍是另一个验证问题。

我用相同的公开安全合成 capture、等长隔离路径,在 base/head 调用真实引用生产者及 CLI reader,分别检查首次发现和已知 pointer 两种消费者路径:

观察 base → head
需要根目录发现时,context-read 调用数 2 → 1,其中 root list 1 → 0
上述路径的返回文本字节 7,362 → 6,628
已知 pointer 时,读取调用数 1 → 1
已知 pointer 路径的返回文本字节 6,439 → 6,628
初始 reference 紧凑 JSON 字节 3,085 → 3,274
生成 reference 时额外 typed context_select 调用 0 → 1,只传 root keys

字节口径为初始 reference 的紧凑 JSON(含换行)加该导航路径的真实 CLI stdout;为验证而另做的 list/full read 不计入工作负载。两端 fixture 摘要和所选正文摘要完全一致,包括转义 pointer、null、布尔及大整数。这是另一份独立合成输入,说明与作者结论一致的条件性导航收益,不是 provider token、计费或模型采用测量。

聚焦回归 31 passed:完整 capture-selection 测试、file-backed delta 的当前 full recovery、真实 CLI 的 file/sqlite 路径及输出预算、默认/显式 off。另验证了 300 个根字段时索引整体省略且原始正文与选择路径完整;注入可选 typed runtime 启动失败后,普通全文件 CLI recovery 仍成功。索引不构成正文已读或完整模型 retention,现有 receipt 与 admission 语义保持。

建议继续沿现有消费者指引完成两项小优化:

  1. 在已有导航 guidance 中显式说明如何消费 field_index。 当前生产字段已经可见,指引仍主要描述 known pointers 和 nearest-parent list。可以说明:索引存在且覆盖所需顶层地址时,直接批量 --select;缺失或需要更深层结构时才使用现有 list。delta 模式下这些地址属于 recovery.command 的当前事实,不能误用于 delta patch 的 command。保留 goals、验收/停止条件及当前操作/结算契约的必读要求。
  2. 保留首次发现与已知 pointer 两条成本对照。 可以复用现有精确 index/selection fixture,分别记录发现调用、选择调用、返回字节和 optional typed RPC。已有 pointer 的消费者确实只多出索引元数据;不要用首次发现的节省覆盖这个反例,也不要把更多 delta 或更多 inline 字段作为目标。后续若评估 token 收益,再单列实际 provider input/cache/output 和模型调用次数。

实现复用了现有地址所有者和 metadata serializer;oversized index 在既有 ceiling 内整体省略,不挤占 recovery。额外一次本地 RPC 和 metadata 序列化也是真实成本;本次未测延迟、RSS、真实模型消费或 ANN 收益,不建议据此扩大输出预算或放宽恢复/必读约束。

这是一项专项非阻塞建议,供本 PR 或后续消费者验证采用;不替代完整批准或合并资格判断。

Reviewer: actor_kind=model_agent; model=GPT-6 Astra Pro; provider=OpenAI; declaration_source=self_reported.

@loopx-agent
loopx-agent merged commit 6eaf075 into loopx-project:main Nov 1, 2026
33 of 42 checks passed
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.

3 participants