Repository navigation
feat(context): read digest-bound details from one capture - #7597
Conversation
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; model=gpt-6.1-sol; provider=OpenAI; reasoning_effort=max; declaration_source=runtime_reported.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
需要从已保存决策中补读几条精确材料的 Agent,以及验证原生上下文基线的 Host adapter。旧 reader 只能分页读取整个 capture;只需要一条任务的尾部约束,也会收到无关历史。新入口批量读取明确的 JSON pointer,保留原 capture 摘要与独立的详情摘要;详情 EOF 只说明该视图结束,不能证明完整上下文已读。本 head 提供可直接使用的同 capture 批量详情 CLI,并阻止详情被原生 hook 当成 full baseline;原始全量读取和权限保持。本 PR 不切换默认必读集合、不交付必要视图或改同 Turn 压缩策略,也不授予准入、结算或安装权限。原生输入 producer、scope、必读指引与恢复的联合接入仍待后续实现;#7600 的组合运行时需要自己的 exact-head 评审,真实模型采用和整轮成本收益未证。
改动思路 / Approach
复用现有不可变 reader、pager、command builder 和 native baseline owner。TypeScript 只验证 JSON pointer 并返回地址;Python 从原始对象取值与序列化,避免把大整数经过 JavaScript number 后再送回。没有另建分页、相关性分类或保留状态。可单独使用的原始 capture 详情 reader;必要输入和同 Turn 恢复策略尚未切换。后续必要输入接入仍须一起切换 scope、指引与恢复,不能凭本 PR 省略当前必读项。
| 读取方式 | 字节坐标与摘要 | native full baseline |
|---|---|---|
| 不传 selector | 原始 capture / 原 SHA | 既有完整字节校验 |
| 显式 batch,包括根选择 | 派生视图 / 原 SHA+selection SHA | 不可建立 |
具体改动 / Changes
依据 immutable base fb331f45c355152a4c1658af1e097f60a5840154 的Required work context:original-capture-authority、full-baseline-only、lossless-bounded-off-parity 在此 head implemented;joint-consumer-replacement deferred。这些是现有未编号条文的 reviewer labels。全文检查8文件 +283/-11,其中 production +92/-11;没有状态迁移或预算修改。
关键代码讲解
- capturedContextSelection去重并排序 pointers,只访问 own properties;数组索引须是安全规范整数。
~1/~0、空键、根与 null 均有明确含义。任一路径不存在时整批拒绝,不能把缺失当 null。 - read_context_capture先校验原始 SHA,再通过 typed endpoint 取得地址,保留 Python 原值并生成独立 selection digest。非零偏移缺摘要或选择发生变化均拒绝;既有 pager 按 UTF-8 和完整 stdout 上限返回,next_command 保留两摘要和全部 selectors。
- capture_page_range在共享 native hook 校验链入口排除 selected markers。详情 EOF 和根选择均不能晋升 full baseline;正常 full-page 校验仍可建立基线,失败保留原始恢复引用。
对主干的风险 / Risks
PASS:独立 actual CLI 4项通过,保留 2**100+17、1.0、-0.0、null、Unicode 尾部与引号路径;同 harness 的 base 全量控制通过,新 selector 被旧 parser 拒绝。原文件不变,缺失 registry/runtime 没有被创建。独立 public PostToolUse 反例将带 detail marker 的原字节页送入真实 hook:base错误晋升(1失败/1正常控制通过),head两项均通过。focused Python 340通过,TS77通过,typecheck/Ruff通过;68项显式 native-binary 用例跳过,未当作实际 Host 或模型验证。
标准 premerge 6项 direct通过、19项 selected中18通过。唯一 FAIL 是 quota_should_run/multi_agent/json 的25,836字符大于25,500。不可变 base 同一 smoke 在同一断言失败;独立同夹具96项结构/语义/尺度观察全部一致,选择分支未触达该 native-off producer。故归为 pre-existing unrelated,不阻断这次代码评审;该本地 required failure 仍是单独的合并门,没有调预算、缩夹具或洗掉旧失败。未查询、轮询或等待远端 CI。
语义与 CI 对齐
本次扩展现有 capture projection vocabulary,仅新增派生详情 body/metadata,没有新的 actor lifecycle、任务权限或保留 ACK。无 selector 的 file-only 路径和原始字节控制保持,shared native verifier 的更严格详情排除是明确且经反例验证的变化。读取大源仍会解析并送入 typed endpoint;没有测量这部分完整成本,不能从详情较短推断整轮提速。
我的整体评价 / Verdict
批准 7076f2c9bd529cc27eb0a8edfe8967ef8d8461a0 的共享 reader 增量。long-horizon 方面有精确绑定与防止误晋升的工程改进,长期效果和净费用收益未证;user experience 方面现有 CLI 可一次展开多个准确详情,无额外用户设置或审批,集成后的 native 旅程仍待 #7600 独立资格。兼容边界保持一套 pager/验证 owner,已应用地址计划与原值序列化的有界分工,当前无需再添抽象。没有发现当前阻塞缺陷;上述预算红项、可选 Host 跳过、安装与模型未知均保留。
English verdict: APPROVE.
Captured-context readers currently return the entire saved JSON, even when a caller needs a few exact details. Add repeatable
quota context-read --selectRFC 6901 pointers so a caller can expand a batch from the same immutable capture without reading live Goal state or repeating admission.The page retains the original capture digest and adds a derived-selection digest. UTF-8 offsets and EOF describe the selected view; continuation commands preserve both digests and all selectors. Missing paths, changed captures/selections and unbound continuation offsets fail closed. No-selector reads retain their original bytes and behavior. Detail pages, including a root selection, cannot establish a full-context baseline through the native hook.
The existing typed Turn-envelope endpoint resolves pointers; Python retains file IO, original JSON values and byte serialization so large integers are not rounded by the JS boundary. Selection reuses the existing page budget, command builder and error path. The new
context_capture_selection_v1describes detail delivery only; it introduces no lifecycle or authority state.This is the shared reader prerequisite for progressive native input. It does not change default required reads, publish a necessary-only view, update the installed host, or demonstrate lower end-to-end model cost. The native input owner must integrate scope, instructions, recovery and acceptance together; candidate and outcome detail consumers should reuse this reader rather than create separate pagination/baseline owners. No frontend operation or baseline is added in this slice; the native consumer journey remains pending that integration.
Validation at
7076f2c9bd529cc27eb0a8edfe8967ef8d8461a0(based onmainatfb331f45c):loopx checkreports its deliberately absent registry, so it is not an all-green Goal health check.No merge or installation is included. Scope-fit: one existing CLI consumer and a shared typed selection helper; page serialization and retention verification remain with their existing owners. The remaining native publication/consumer integration is intentionally separate for independent review and rollback.