Repository navigation
perf(quota): reuse observed prefixes in appended Todo notes - #8523
Conversation
loopx-agent
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · max
评审 head 90d929e5e879bc1ce1b879f268ed056f89325635,实际 base d3ac3bd8d69821ae5843b7cef5fdb6dcbc7cae74。
动机
继续使用同一原生会话的操作者需要读到当前 Todo 的新增要求,并能回查完整原文。 一个已完整交付的长备注只追加一句。当前 main 再交付整段,候选版本在来源和会话条件相符时送出追加文字。 File 和 SQLite 的同条件 CLI 对照中,原前缀为 22,469 字节,追加内容为 59 字节。首读工具输出分别从 41,560 降至 17,461 字节、从 41,586 降至 17,487 字节。 本次覆盖原生 CLI、生命周期 hook 与隔离状态。模型采用、完整流程成本和发布环境仍属独立验收。 还需在真实模型会话中测量追加内容的采用及整个流程的成本。
改动思路
TypeScript 选择可复用的字段和前缀。Python reader 固定本轮 capture 和选择摘要,native hook 核对实际交付的连续字节。 交付边界是同一 Goal、Agent、Todo 和会话周期内的首读呈现,以及原捕获恢复。 GitHub 的 8 个变更文件和本地 diff 一致,合并树干净,提交带 DCO。
具体改动
关键代码讲解
- observedTextAppend 核对旧笔记摘要、UTF-8 字节边界和当前来源。读者会看到 append_to_observed_text 标记、前缀长度和新文字。
- write_initial_context_read_reference 给当前选区定摘要。context-read 用同次 capture 的 literal fallback 处理作用域变化。
- verified_context_selection 先核对回传的正文、页区间和摘要。只交付末页不会推进,补齐后才登记可供下次追加使用的证明。
对照 docs/guides/context-delivery.md 在 d3ac3bd8d69821ae5843b7cef5fdb6dcbc7cae74 的约束,核验 Observed note scope, Complete read coverage, Original capture recovery。原始来源、适用条件和回读均通过实际 CLI 对照。
对主干的风险
245 项 Python 通过,14 项原生 opt-in 用例跳过。 43 项 TypeScript context 测试、TypeScript 类型检查、配置的 mypy、变更文件 Ruff,以及6 项直接检查和 19 项选定预合并检查通过。本机 Change Quality 收据 cqr_b84c1a71f71f57c11b28 已回读。两个 TypeScript digest 架构用例在当前 main 和 head 上以同样的诊断失败,来自同一个未改动的 benchmark inventory。关闭 context delivery 和 delta 后,使用同一 capture 实测逐字节读回一致。
语义与 CI 对齐
追加是现有首读的显式呈现方式。旧 digest 仍支持等值复用,源码测试覆盖跨 Todo、改写和未完整观察。切换周期时旧游标拒绝续读,按原捕获取回完整正文。
我的整体评价
同一会话中只追加文字时,这个边界有实际字节收益。保留原捕获、旧 digest 兼容和 readback 证据后,当前提交符合评审范围。 影响面是已有 CLI 和原生工具的文本交付。当前 diff 未改变公开 App、Lark 或 Web 首屏。 独验使用源码 CLI 和合成生命周期事件。模型理解、其他安装环境和完整工作流成本未测试。
English verdict: APPROVE 90d929e — verified exact UTF-8 append delivery, legacy proof reuse and complete fallback on File and SQLite.
songoow
left a comment
There was a problem hiding this comment.
动机 / Motivation
同一个原生会话继续处理 Todo 的 Agent,需要及时收到追加要求,并能随时恢复完整备注。 一段长备注已经完整交付,后来只追加一条要求:原实现再次发送全文,这个版本在精确前缀证明仍有效时只发送新增文字。 真实 File/SQLite CLI 验证了追加标记、UTF-8 字节边界、完整观察后链式复用,以及压缩或重写后的全文回退。 本次不改变 Todo 权限、准入或结算,不声称模型一定理解追加指令,也不以局部字节减少证明整个工作流成本下降。
审查 head 90d929e,实际基线 d3ac3bd。独立读取基线 docs/guides/context-delivery.md,核对 N1(同会话、epoch、Todo 与 source 身份)、N2(完整真实交付覆盖)、N3(当前控制与原捕获恢复)。原有 author self-review 仅作为线索,没有继承其 APPROVE 或测试结论。 另核对当前 main beff0f3e55d1f70eceebbd8e78c11f1cff34643b:上述 context owner、reader、native lifecycle、Turn adapter 与合同等 16 个相关路径相对实际基线没有差异;中间的 snapshot 错误来源修复不改动正文/观察证明,未据此重复长测试。
改动思路 / Approach
已有 TS context owner 负责前缀与身份判断,Python 只固定原捕获、渲染并验证真实交付字节,复用现有 observation journal。 当前范围是同一兼容会话中 selected Todo 备注的精确追加呈现;权限、settlement 与未知 source 继续由原 owner 决定。
原 digest 可以证明全文相等,但无法指出旧正文结束的字节位置。给同一个证明增加 UTF-8 长度,就能用当前正文验证旧前缀;不必保存第二份旧备注或建立新的通用 delta 服务。这里有意扩展“正文变化即全文”的旧规则:只有精确追加可复用,改写仍回到全文。首读指令明确要求把 suffix 接到之前正文,完整原文始终可从同一 capture 读取。
具体改动 / Changes
关键代码讲解
observedTextAppend检查长度、UTF-8 边界和绑定 source 的前缀 hash。observedFirstRead还计算分组、索引和附加说明的开销,只有有收益且准确选中 note 才生成 append 描述;旧 digest 仍只用于全文相等复用。_context_selection_bytes从已校验的原捕获取值,输出 exact suffix、append_to_observed_text和prefix_bytes,并把完整渲染选区固定到 digest。它不修改 canonical Todo。reader 的显式完整读取和观察失效回退都使用原捕获。verified_context_selection验证实际交付的内容、offset、view digest 和 source;生命周期 owner 只有合并出完整覆盖区间后才发布新 proof。只交付末页不会让下一轮错误地以为全部追加内容已读;补齐后才能链式追加。
独立验证:新的 note 场景 8/8 通过(248.40 秒),覆盖 File/SQLite、原观察完整/部分、无关 Todo 和当前证据变化、前缀改写、Unicode 追加、末页先到、二次追加、跨 Todo 和 compaction 原文恢复。另有 progressive-off 两例 2/2 通过,恢复 JSON 与原捕获相同,未出现观察复用。TS context/selection/source 四组共 78/78 通过;完整 control-plane typecheck 与 base-to-head diff check 通过。
对主干的风险 / Risks
最重要的风险是把部分观察或旧会话证明当成完整前缀,导致旧要求从上下文消失。本轮直接检查了 source 绑定、native journal 的 epoch 校验、精确页字节检查和完整范围合并,并通过真实 CLI 与合成 Host hook 触发了这些反例。没有新计数器、授权写入或 settlement 变更;回退只影响展示成本,不可将 hash/EOF 当成模型理解的凭据。
语义与 CI 对齐
这是明确标记的 literal append,不是语义摘要。旧正文仍然有效,新增正文完整可见,修改前缀、partial read、不同 Todo 和 compaction 都不能借用 proof。feature-off 的真实读取保持完整捕获。远端 packet 没有可用 check rollup,本轮不把未知 CI 当作通过;作者历史测试数字及未独立复验的全量环境结论也没有计入上述结果。
我的整体评价 / Verdict
这个增量在现有 owner 内交付了可复用的行为,实际调用路径和失败恢复都可验证,未发现需要阻止合入的新问题。三种状态——相等、精确追加、需要全文——仍在一个 TS 判定处,Python 只处理原始字节和 Host I/O,规模与目的相称。
检查的是 quota reader 的机器可读文本与 private native journal,未修改 App、网页或其他渲染界面。 真实模型理解、安装环境采用及整段工作流净成本未验证。 本结论仅批准这个精确 head 的实现,不把局部 tool response 改善扩大为全流程性能或 merge-ready 结论。
Reviewer: model_agent · GPT-6 Astra Pro · OpenAI · self_reported
English verdict: APPROVE
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEADFor a same-repository clone whose Keep the DCO |
81d23f5 to
afecb37
Compare
cocolord
left a comment
There was a problem hiding this comment.
Reviewer: model_agent, GPT-5, OpenAI, self_reported
动机 / Motivation
同一个原生会话继续处理一个已交付过的 Todo 备注时,操作者需要看到新追加的要求,同时还能随时恢复完整备注。旧行为在长备注后只追加一句话时仍重新发送整段正文,增加 reader 输出和模型输入负担;这个 PR 在同一 capture、同一 selected Todo、同一 provider/source 身份,并且旧正文是当前 UTF-8 文本精确前缀时,只呈现追加 suffix。可观察结果是 first-read 页面包含 append_to_observed_text 与 prefix_bytes,完整正文仍可通过原 recovery command 读取。非目标是不改变准入、Todo 权限、settlement 或把局部字节减少宣称为端到端成本收益。剩余 gap 是 unchanged head 的 merge-readiness 和远端 CI 仍需闭合后才能合入。
改动思路 / Approach
实现保持现有 owner 划分:TypeScript progressive context owner 决定哪些字段可以被复用并生成带长度的前缀证明;Python capture/reader 只在 digest-pinned 原捕获上渲染已验证选择,不重新解释 Todo 权限或状态。rebase 到最新 main 时,先保留 reader 的 ContextSelectionDigestChanged recovery 保护,再合入 inline initial-read fallback page 验证;最终路径同时保留这些主干恢复语义,并把 text_append 传入对应 selection view,所以 suffix 优化不会吞掉 selection digest 或 fallback page 的 fail-safe。
具体改动 / Changes
reusableFirstReadFields 只在 selected Todo source 唯一、selected_todo_text_verified=true、authority read 来自 provider 且非 legacy fallback、Todo id/source identity 匹配时,把 /todo/note 标成可 append 的字段。observedTextAppend 要求旧 proof 形如 length:digest,校验 prefix byte 边界不是 UTF-8 continuation byte,再用绑定 source identity 的 prefix digest 匹配旧观察;改写、短文本、不同 source 或不同 Todo 都返回 undefined。
_context_selection_target 先把 reference/inline page 的 target 解析从 verified_context_selection 中抽出,避免最新 main 合并后触发 oversized decision ratchet;_context_selection_bytes 在 pinned selection 中只输出 suffix、append_to_observed_text 和 prefix_bytes;如果 append 目标未渲染或 prefix 不在当前字符串内,会抛错并走普通恢复。observed_first_read_reference 同时写入 compact reference 和 full fallback reference,observed_remaining_read_reference 在剩余页缺少 text append 时剔除该 pointer,避免只读末页就刷新完整 proof。文档中英文同步说明:这是同会话精确前缀的读取优化,不是 full-read 证明,也不改变 off path。这里没有预先独立写好的 acceptance specification 定义这个 append 优化,所以 review 依据当前 problem_context、owner 边界和 exact-head validation 判断。
验证:tests/control_plane/test_context_first_read.py::test_native_first_read_reuses_only_the_observed_selected_todo_note 8/8 通过;在为最新 main 的 inline initial-read fallback 解冲突后,又抽出 _context_selection_target 让 verified_context_selection 低于 maintainability ratchet,抽取后 focused regression 仍是 8/8 通过。scripts/check_rfc_bilingual.py --base origin/main --head HEAD 通过。完整 loopx canary premerge --from-git-diff --git-diff-base origin/main 在 exact head afecb37 上通过 19/19,包含 maintainability ratchet、semantic vocabulary、CLI budget、risk-profile smokes 和 public boundary。
对主干的风险 / Risks
主要风险是把 partial observation 当成完整前缀,导致旧备注正文从后续上下文中消失。当前实现通过 native journal 的 session/epoch/target/recovery digest 检查、prefix length+hash、真实交付区间合并和 fallback reference 把这个风险限制住;测试还刻意先交付 suffix 最后一页,确认 proof 不会提前更新。另一个风险是语义上把“追加”误用到改写:当前只有当前 bytes 以旧 UTF-8 前缀开头且 source identity 匹配才发 suffix,前缀改写、scope mismatch、不同 Todo、未完整观察或 compaction 恢复都会回到完整读取。
我的整体评价 / Verdict
这是一个边界清楚的正向减税切片:减少重复 Todo note 正文穿过 first-read reader,但不移动 authority、state、admission 或 settlement owner。冲突已按主干 recovery 与 inline initial-read fallback 语义解决,maintainability ratchet 也通过 helper 抽取闭合,focused real-path 和 premerge 都闭合;剩余风险是上线后真实模型是否更好利用 suffix 展示,这不是合入阻塞。当前结论只批准 exact head afecb37,合入仍以 unchanged head 的 merge-readiness 为准。
English verdict: APPROVE - 8523@afecb3730d6c70f29f6abdaa5642ffdf289330fb. Rebased conflicts resolved by preserving ContextSelectionDigestChanged recovery and inline initial-read fallback validation while threading text_append; focused native Todo-note append test passed 8/8 after helper extraction and full premerge passed 19/19.
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com> Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com> Co-authored-by: TRAE CLI <traecli@bytedance.com> Signed-off-by: huangruiteng <huangrt01@163.com>
afecb37 to
b88c30d
Compare
cocolord
left a comment
There was a problem hiding this comment.
Reviewer: model_agent, GPT-5, OpenAI, self_reported
动机 / Motivation
同一个原生会话继续处理一个已交付过的 Todo 备注时,操作者需要看到新追加的要求,同时还能随时恢复完整备注。旧行为在长备注后只追加一句话时仍重新发送整段正文,增加 reader 输出和模型输入负担;这个 PR 在同一 capture、同一 selected Todo、同一 provider/source 身份,并且旧正文是当前 UTF-8 文本精确前缀时,只呈现追加 suffix。可观察结果是 first-read 页面包含 append_to_observed_text 与 prefix_bytes,完整正文仍可通过原 recovery command 读取。非目标是不改变准入、Todo 权限、settlement 或把局部字节减少宣称为端到端成本收益。剩余 gap 是 unchanged head 的 merge-readiness 和远端 CI 仍需闭合后才能合入。
改动思路 / Approach
实现保持现有 owner 划分:TypeScript progressive context owner 决定哪些字段可以被复用并生成带长度的前缀证明;Python capture/reader 只在 digest-pinned 原捕获上渲染已验证选择,不重新解释 Todo 权限或状态。rebase 到最新 main 时,先保留 reader 的 ContextSelectionDigestChanged recovery 保护,再合入 inline initial-read fallback page 验证;最终路径同时保留这些主干恢复语义,并把 text_append 传入对应 selection view,所以 suffix 优化不会吞掉 selection digest 或 fallback page 的 fail-safe。
具体改动 / Changes
reusableFirstReadFields 只在 selected Todo source 唯一、selected_todo_text_verified=true、authority read 来自 provider 且非 legacy fallback、Todo id/source identity 匹配时,把 /todo/note 标成可 append 的字段。observedTextAppend 要求旧 proof 形如 length:digest,校验 prefix byte 边界不是 UTF-8 continuation byte,再用绑定 source identity 的 prefix digest 匹配旧观察;改写、短文本、不同 source 或不同 Todo 都返回 undefined。
_context_selection_target 先把 reference/inline page 的 target 解析从 verified_context_selection 中抽出,避免最新 main 合并后触发 oversized decision ratchet;_context_selection_bytes 在 pinned selection 中只输出 suffix、append_to_observed_text 和 prefix_bytes;如果 append 目标未渲染或 prefix 不在当前字符串内,会抛错并走普通恢复。observed_first_read_reference 同时写入 compact reference 和 full fallback reference,observed_remaining_read_reference 在剩余页缺少 text append 时剔除该 pointer,避免只读末页就刷新完整 proof。文档中英文同步说明:这是同会话精确前缀的读取优化,不是 full-read 证明,也不改变 off path。这里没有预先独立写好的 acceptance specification 定义这个 append 优化,所以 review 依据当前 problem_context、owner 边界和 exact-head validation 判断。
验证:tests/control_plane/test_context_first_read.py::test_native_first_read_reuses_only_the_observed_selected_todo_note 8/8 通过;在为最新 main 的 inline initial-read fallback 解冲突后,又抽出 _context_selection_target 让 verified_context_selection 低于 maintainability ratchet,抽取后 focused regression 在 b88c30d 上仍是 8/8 通过。scripts/check_rfc_bilingual.py --base origin/main --head HEAD 通过。完整 loopx canary premerge --from-git-diff --git-diff-base origin/main 已按最新 origin/main 6c11d3e 重新通过 19/19,包含 maintainability ratchet、semantic vocabulary、CLI budget、risk-profile smokes 和 public boundary。
对主干的风险 / Risks
主要风险是把 partial observation 当成完整前缀,导致旧备注正文从后续上下文中消失。当前实现通过 native journal 的 session/epoch/target/recovery digest 检查、prefix length+hash、真实交付区间合并和 fallback reference 把这个风险限制住;测试还刻意先交付 suffix 最后一页,确认 proof 不会提前更新。另一个风险是语义上把“追加”误用到改写:当前只有当前 bytes 以旧 UTF-8 前缀开头且 source identity 匹配才发 suffix,前缀改写、scope mismatch、不同 Todo、未完整观察或 compaction 恢复都会回到完整读取。
我的整体评价 / Verdict
这是一个边界清楚的正向减税切片:减少重复 Todo note 正文穿过 first-read reader,但不移动 authority、state、admission 或 settlement owner。冲突已按主干 recovery 与 inline initial-read fallback 语义解决,maintainability ratchet 也通过 helper 抽取闭合,focused real-path 和 premerge 都闭合;剩余风险是上线后真实模型是否更好利用 suffix 展示,这不是合入阻塞。当前结论只批准 exact head b88c30d,合入仍以 unchanged head 的 merge-readiness 为准。
English verdict: APPROVE - 8523@b88c30dbc6cb84d73f1860c491334503c035f4ac. Rebased conflicts resolved by preserving ContextSelectionDigestChanged recovery and inline initial-read fallback validation while threading text_append; focused native Todo-note append test passed 8/8 after helper extraction and full premerge passed 19/19.
b88c30d to
2f0a5c3
Compare
huangruiteng
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-5 · OpenAI · self_reported
动机 / Motivation
使用同一原生会话继续推进 Todo 的 Agent 会遇到一种很具体的浪费:一段长备注已经完整交付,用户只追加一条新要求,下一轮却再次收到整段旧正文。旧实现只认完整摘要相等,因此“旧正文加新后缀”会落入 full delivery;Agent 和操作者要为重复内容支付上下文成本,也更容易淹没真正新增的要求。
这个 PR 在已有 selected Todo note reuse 上加了一个窄分支:只有同一 Goal、Agent、Todo、reader 和 authority source 下,当前正文确实以旧正文为 UTF-8 前缀时,才交付后缀。普通改写、只观察到一部分、来源不兼容、标识跨 session 或发生 compaction 仍返回完整备注。局部 evidence 只证明交付字节和恢复路径,不声称模型一定理解后缀,也不证明整条工作流净成本下降。
改动思路 / Approach
入口仍是既有的 progressive context 和原生 context-read;canonical Todo 读取、准入、quota 与 settlement 都没有新增 owner。TypeScript 的 context owner 决定“完全相同”“精确追加”或“需要全文”三种展示,并把旧 proof 扩展成“UTF-8 byte length + 原 digest”。Python reader 只从同一份 digest-pinned capture 渲染实际 suffix;native hook 核对完整 selection 页、旧 proof、来源和前缀边界;typed reducer 只在完整 suffix view 被观察后发布更长正文的新 proof。
当前 PR 边界是:只有同一 Goal、Agent、Todo、reader 和 authority source 下,当前正文确实以旧正文为 UTF-8 前缀时,才交付后缀。
flowchart LR
A[完整观察旧 note] --> B{同一 source 且当前 note 以旧正文开头?}
B -- 否 --> F[同一 capture 的完整 note]
B -- 是 --> C[suffix + presentation + prefix_bytes]
C --> D{Host 完整观察 suffix 页?}
D -- 否 --> R[不推进 proof]
D -- 是 --> E[发布新长度证明]
这张图是精确 head 2f0a5c3111 的源码行为示意图,不是执行或模型理解证据。现有 selected-Todo proof、reader、journal 和 recovery owner 足以表达这次变化,因此没有必要新增第二份旧 note、通用 delta 服务或 provider cache 语义;当前 PR 的边界就是 appended note presentation,失败时仍回到原有全文路径。
具体改动 / Changes
关键代码讲解
observedTextAppend和observedSectionProof把旧 proof 扩展为<prefix-bytes>:<sha256>。它验证数字长度、UTF-8 continuation byte 边界和同一 source 下 prefix digest;legacy 64-hex digest 仍可做等于判断,但不会授权 append。contextReadSectionDigests的observedFirstRead生成 suffix 选区。它的收益判断保留现有 recovery guidance 空间;没有足够字节收益时仍选择全文。_context_selection_bytes只从原 capture 的 byte slice 渲染presentation=append_to_observed_text和prefix_bytes,拒绝越界、不可 UTF-8 切分或未命中选择。verified_context_selection先验证同 capture、完整选区、页区间和 journal epoch;呈现页不直接算作完整正文覆盖,只有observed_text_append与旧 proof 同时成立才允许 reducer 推进。test_native_first_read_reuses_only_the_observed_selected_todo_note在 File/SQLite 上覆盖 complete/partial、证据变更、Unicode、二次追加、跨 Todo、重写和 compaction;TS 用例另行锁住错误 prefix、来源变化与 legacy proof 反例。
判断依据是变更前的 context-delivery.md(6c11d3e3e640d6a45d465b52f75c7b933e3681f5):
| criterion_id | 合同要求 | 当前 head |
|---|---|---|
SPEC-NOTE-SCOPE |
note 复用绑定同一 Goal、Agent、Todo、reader、authority source;仅证据或元数据变化不产生新正文。 | implemented:reusableFirstReadFields 与 observedTextAppend;真实 CLI 矩阵覆盖 source 与跨 Todo。 |
SPEC-OBSERVED-COVERAGE |
依靠实际观察到的字段覆盖,不以文件存在证明保留。 | implemented:private journal proof 与完整 suffix range 才推进;TS 反例拒绝 partial/wrong proof。 |
SPEC-FALLBACK |
partial、正文变化、身份不兼容或 compaction 返回全文,恢复读同一 capture。 | implemented:observed_first_read_fallback、_context_selection_target 与 reader fallback;8 个真实场景通过。 |
SPEC-NONCLAIM |
不把观察交付扩展成模型理解或完整流程净收益。 | implemented:双语文档和 PR 正文均明确保留这两个未验证边界。 |
对主干的风险 / Risks
最强的回归是:旧 proof 被错误用于一个已经改写、只读到一部分或来自另一来源的 note,导致旧要求从模型输入中消失。实现用三项独立条件封住该路径:只接受带长度的新 proof;旧 digest 只能证明全文相等;suffix 页只有在同一 capture 的完整 selection 观察后,才由 reducer 推进 proof。不同 Todo/session/source、非 UTF-8 边界、partial page、元数据失效和 compaction 都会回退 full,真实 File/SQLite fixture 已覆盖这些分支。
这次没有新增 provider authority、quota admission、settlement、canonical Todo mutation 或公开 App/Web 呈现,因此没有 actor 生命周期或权限扩张。append_to_observed_text 是既有 private selection presentation 的局部扩展,双语 guide 明确它的读法、全文恢复和边界;不是新的持久业务协议。disabled/ordinary reader 不需要理解该 marker,显式 --select、recovery command 和 compaction 路径继续返回完整正文。
验证状态:核心真实 CLI 矩阵 PASS(8/8);相关 Python context 套件 PASS(276 passed,14 个明确 opt-in skip);四组 TypeScript context 测试 PASS(79/79);control-plane typecheck、配置内 mypy、Ruff、RFC paired check PASS;premerge canary PASS(19/19)。精确 head 推送后的 GitHub 工作流仍在排队,因此不作为通过证据;本轮适用不变量已由本地真实路径和仓库原生 canary 独立覆盖。
语义与 CI 对齐
这是 intentional behavior delta:旧路径在 append 时重发全文,新路径在证明成立时只送 suffix;非 append 分支保持原合同。该模式扩展现有 Todo-note observed presentation,不改变 authoritative state 或失败恢复 owner。新增 TS counterfactual 和真实 CLI 矩阵分别证明反例拒绝、完整观察推进和 full fallback,而不是只依据绿色 CI 或文档文字。
我的整体评价 / Verdict
这个改动解决了现有 owner 内可复现的重复交付,且没有用“delta”名义引入语义摘要、第二份 canonical 状态或新的权限路径。它的复杂度集中在证明、字节边界和观察覆盖,均是省略旧正文所必需的安全条件;同时删除了 ratchet 风险,把 selection target 解析从超大验证函数中分开。剩余风险是真实模型对 append marker 的采用和整条工作流净收益仍未验证,但两者都不被本 PR 的局部字节改进冒充。
没有发现阻塞问题。建议保留当前边界,以本结论批准精确 head 2f0a5c311130fbc017ee96ef0cbf78503c0f4b54,后续用真实模型会话单独衡量采用与总成本。
English verdict: APPROVE 2f0a5c3 — verified exact UTF-8 suffix delivery, legacy compatibility and full fallback across File and SQLite; no blocking finding.
huangruiteng
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-5 · OpenAI · self_reported
动机 / Motivation
使用同一原生会话继续推进 Todo 的 Agent 会遇到一种很具体的浪费:一段长备注已经完整交付,用户只追加一条新要求,下一轮却再次收到整段旧正文。旧实现只认完整摘要相等,因此“旧正文加新后缀”会落入 full delivery;Agent 和操作者要为重复内容支付上下文成本,也更容易淹没真正新增的要求。
这个 PR 在已有 selected Todo note reuse 上加了一个窄分支:只有同一 Goal、Agent、Todo、reader 和 authority source 下,当前正文确实以旧正文为 UTF-8 前缀时,才交付后缀。普通改写、只观察到一部分、来源不兼容、标识跨 session 或发生 compaction 仍返回完整备注。局部 evidence 只证明交付字节和恢复路径,不声称模型一定理解后缀,也不证明整条工作流净成本下降。
改动思路 / Approach
入口仍是既有的 progressive context 和原生 context-read;canonical Todo 读取、准入、quota 与 settlement 都没有新增 owner。TypeScript 的 context owner 决定“完全相同”“精确追加”或“需要全文”三种展示,并把旧 proof 扩展成“UTF-8 byte length + 原 digest”。Python reader 只从同一份 digest-pinned capture 渲染实际 suffix;native hook 核对完整 selection 页、旧 proof、来源和前缀边界;typed reducer 只在完整 suffix view 被观察后发布更长正文的新 proof。
当前 PR 边界是:只有同一 Goal、Agent、Todo、reader 和 authority source 下,当前正文确实以旧正文为 UTF-8 前缀时,才交付后缀。
flowchart LR
A[完整观察旧 note] --> B{同一 source 且当前 note 以旧正文开头?}
B -- 否 --> F[同一 capture 的完整 note]
B -- 是 --> C[suffix + presentation + prefix_bytes]
C --> D{Host 完整观察 suffix 页?}
D -- 否 --> R[不推进 proof]
D -- 是 --> E[发布新长度证明]
这张图是精确 head 2f0a5c3111 的源码行为示意图,不是执行或模型理解证据。现有 selected-Todo proof、reader、journal 和 recovery owner 足以表达这次变化,因此没有必要新增第二份旧 note、通用 delta 服务或 provider cache 语义;当前 PR 的边界就是 appended note presentation,失败时仍回到原有全文路径。
具体改动 / Changes
关键代码讲解
observedTextAppend和observedSectionProof把旧 proof 扩展为<prefix-bytes>:<sha256>。它验证数字长度、UTF-8 continuation byte 边界和同一 source 下 prefix digest;legacy 64-hex digest 仍可做等于判断,但不会授权 append。contextReadSectionDigests的observedFirstRead生成 suffix 选区。它的收益判断保留现有 recovery guidance 空间;没有足够字节收益时仍选择全文。_context_selection_bytes只从原 capture 的 byte slice 渲染presentation=append_to_observed_text和prefix_bytes,拒绝越界、不可 UTF-8 切分或未命中选择。verified_context_selection先验证同 capture、完整选区、页区间和 journal epoch;呈现页不直接算作完整正文覆盖,只有observed_text_append与旧 proof 同时成立才允许 reducer 推进。test_native_first_read_reuses_only_the_observed_selected_todo_note在 File/SQLite 上覆盖 complete/partial、证据变更、Unicode、二次追加、跨 Todo、重写和 compaction;TS 用例另行锁住错误 prefix、来源变化与 legacy proof 反例。
判断依据是变更前的 context-delivery.md(6c11d3e3e640d6a45d465b52f75c7b933e3681f5):
| criterion_id | 合同要求 | 当前 head |
|---|---|---|
SPEC-NOTE-SCOPE |
note 复用绑定同一 Goal、Agent、Todo、reader、authority source;仅证据或元数据变化不产生新正文。 | implemented:reusableFirstReadFields 与 observedTextAppend;真实 CLI 矩阵覆盖 source 与跨 Todo。 |
SPEC-OBSERVED-COVERAGE |
依靠实际观察到的字段覆盖,不以文件存在证明保留。 | implemented:private journal proof 与完整 suffix range 才推进;TS 反例拒绝 partial/wrong proof。 |
SPEC-FALLBACK |
partial、正文变化、身份不兼容或 compaction 返回全文,恢复读同一 capture。 | implemented:observed_first_read_fallback、_context_selection_target 与 reader fallback;8 个真实场景通过。 |
SPEC-NONCLAIM |
不把观察交付扩展成模型理解或完整流程净收益。 | implemented:双语文档和 PR 正文均明确保留这两个未验证边界。 |
对主干的风险 / Risks
最强的回归是:旧 proof 被错误用于一个已经改写、只读到一部分或来自另一来源的 note,导致旧要求从模型输入中消失。实现用三项独立条件封住该路径:只接受带长度的新 proof;旧 digest 只能证明全文相等;suffix 页只有在同一 capture 的完整 selection 观察后,才由 reducer 推进 proof。不同 Todo/session/source、非 UTF-8 边界、partial page、元数据失效和 compaction 都会回退 full,真实 File/SQLite fixture 已覆盖这些分支。
这次没有新增 provider authority、quota admission、settlement、canonical Todo mutation 或公开 App/Web 呈现,因此没有 actor 生命周期或权限扩张。append_to_observed_text 是既有 private selection presentation 的局部扩展,双语 guide 明确它的读法、全文恢复和边界;不是新的持久业务协议。disabled/ordinary reader 不需要理解该 marker,显式 --select、recovery command 和 compaction 路径继续返回完整正文。
验证状态:核心真实 CLI 矩阵 PASS(8/8);相关 Python context 套件 PASS(276 passed,14 个明确 opt-in skip);四组 TypeScript context 测试 PASS(79/79);control-plane typecheck、配置内 mypy、Ruff、RFC paired check PASS;premerge canary PASS(19/19)。精确 head 推送后的 GitHub 工作流仍在排队,因此不作为通过证据;本轮适用不变量已由本地真实路径和仓库原生 canary 独立覆盖。
语义与 CI 对齐
这是 intentional behavior delta:旧路径在 append 时重发全文,新路径在证明成立时只送 suffix;非 append 分支保持原合同。该模式扩展现有 Todo-note observed presentation,不改变 authoritative state 或失败恢复 owner。新增 TS counterfactual 和真实 CLI 矩阵分别证明反例拒绝、完整观察推进和 full fallback,而不是只依据绿色 CI 或文档文字。
我的整体评价 / Verdict
这个改动解决了现有 owner 内可复现的重复交付,且没有用“delta”名义引入语义摘要、第二份 canonical 状态或新的权限路径。它的复杂度集中在证明、字节边界和观察覆盖,均是省略旧正文所必需的安全条件;同时删除了 ratchet 风险,把 selection target 解析从超大验证函数中分开。剩余风险是真实模型对 append marker 的采用和整条工作流净收益仍未验证,但两者都不被本 PR 的局部字节改进冒充。
没有发现阻塞问题。建议保留当前边界,以本结论批准精确 head 2f0a5c311130fbc017ee96ef0cbf78503c0f4b54,后续用真实模型会话单独衡量采用与总成本。
English verdict: APPROVE 2f0a5c3 — verified exact UTF-8 suffix delivery, legacy compatibility and full fallback across File and SQLite; no blocking finding.
cocolord
left a comment
There was a problem hiding this comment.
Reviewer: model_agent, GPT-5, OpenAI, self_reported
动机 / Motivation
同一个原生会话继续处理一个已交付过的 Todo 备注时,操作者需要看到新追加的要求,同时还能随时恢复完整备注。旧行为在长备注后只追加一句话时仍重新发送整段正文,增加 reader 输出和模型输入负担;这个 PR 在同一 capture、同一 selected Todo、同一 provider/source 身份,并且旧正文是当前 UTF-8 文本精确前缀时,只呈现追加 suffix。可观察结果是 first-read 页面包含 append_to_observed_text 与 prefix_bytes,完整正文仍可通过原 recovery command 读取。非目标是不改变准入、Todo 权限、settlement 或把局部字节减少宣称为端到端成本收益。剩余 gap 是 unchanged head 的 merge-readiness 和远端 CI 仍需闭合后才能合入。
改动思路 / Approach
实现保持现有 owner 划分:TypeScript progressive context owner 决定哪些字段可以被复用并生成带长度的前缀证明;Python capture/reader 只在 digest-pinned 原捕获上渲染已验证选择,不重新解释 Todo 权限或状态。rebase 到最新 main 时,先保留 reader 的 ContextSelectionDigestChanged recovery 保护,再合入 inline initial-read fallback page 验证;最终路径同时保留这些主干恢复语义,并把 text_append 传入对应 selection view,所以 suffix 优化不会吞掉 selection digest 或 fallback page 的 fail-safe。
具体改动 / Changes
reusableFirstReadFields 只在 selected Todo source 唯一、selected_todo_text_verified=true、authority read 来自 provider 且非 legacy fallback、Todo id/source identity 匹配时,把 /todo/note 标成可 append 的字段。observedTextAppend 要求旧 proof 形如 length:digest,校验 prefix byte 边界不是 UTF-8 continuation byte,再用绑定 source identity 的 prefix digest 匹配旧观察;改写、短文本、不同 source 或不同 Todo 都返回 undefined。
_context_selection_target 先把 reference/inline page 的 target 解析从 verified_context_selection 中抽出,避免最新 main 合并后触发 oversized decision ratchet;_context_selection_bytes 在 pinned selection 中只输出 suffix、append_to_observed_text 和 prefix_bytes;如果 append 目标未渲染或 prefix 不在当前字符串内,会抛错并走普通恢复。observed_first_read_reference 同时写入 compact reference 和 full fallback reference,observed_remaining_read_reference 在剩余页缺少 text append 时剔除该 pointer,避免只读末页就刷新完整 proof。文档中英文同步说明:这是同会话精确前缀的读取优化,不是 full-read 证明,也不改变 off path。这里没有预先独立写好的 acceptance specification 定义这个 append 优化,所以 review 依据当前 problem_context、owner 边界和 exact-head validation 判断。
验证:tests/control_plane/test_context_first_read.py::test_native_first_read_reuses_only_the_observed_selected_todo_note 8/8 通过;在为最新 main 的 inline initial-read fallback 解冲突后,又抽出 _context_selection_target 让 verified_context_selection 低于 maintainability ratchet,抽取后 focused regression 在 2f0a5c3 上仍是 8/8 通过;新增的 tests/control_plane_ts/progressive_context.test.ts 也单跑通过 8/8,覆盖精确前缀、legacy digest 和不同 source fallback。scripts/check_rfc_bilingual.py --base origin/main --head HEAD 通过。完整 loopx canary premerge --from-git-diff --git-diff-base origin/main 已按最新 origin/main 6c11d3e 重新通过 19/19,包含 maintainability ratchet、semantic vocabulary、CLI budget、risk-profile smokes 和 public boundary。
对主干的风险 / Risks
主要风险是把 partial observation 当成完整前缀,导致旧备注正文从后续上下文中消失。当前实现通过 native journal 的 session/epoch/target/recovery digest 检查、prefix length+hash、真实交付区间合并和 fallback reference 把这个风险限制住;测试还刻意先交付 suffix 最后一页,确认 proof 不会提前更新。另一个风险是语义上把“追加”误用到改写:当前只有当前 bytes 以旧 UTF-8 前缀开头且 source identity 匹配才发 suffix,前缀改写、scope mismatch、不同 Todo、未完整观察或 compaction 恢复都会回到完整读取。
我的整体评价 / Verdict
这是一个边界清楚的正向减税切片:减少重复 Todo note 正文穿过 first-read reader,但不移动 authority、state、admission 或 settlement owner。冲突已按主干 recovery 与 inline initial-read fallback 语义解决,maintainability ratchet 也通过 helper 抽取闭合,focused real-path 和 premerge 都闭合;剩余风险是上线后真实模型是否更好利用 suffix 展示,这不是合入阻塞。当前结论只批准 exact head 2f0a5c3,合入仍以 unchanged head 的 merge-readiness 为准。
English verdict: APPROVE - 8523@2f0a5c311130fbc017ee96ef0cbf78503c0f4b54. Rebased conflicts resolved by preserving ContextSelectionDigestChanged recovery and inline initial-read fallback validation while threading text_append; focused native Todo-note append test passed 8/8 after helper extraction and full premerge passed 19/19.
Problem
The native progressive reader already reuses an exact selected Todo note after the Host observes it in full. A small append makes that exact comparison fail, so a continuing session receives the entire note again.
Change
Reuse the existing selected-Todo field proof with one additional fact: the observed UTF-8 byte length. Send a suffix only when the current note begins with the exact proven prefix for the same selected Todo and source. The suffix uses the existing selected reader and immutable full fallback.
A complete observed suffix view can advance the proof. Rewrites, incomplete reads, different scopes, non-UTF-8 boundaries and compaction keep the ordinary full path. Legacy 64-hex proofs still permit exact equality but cannot authorize an append.
The latest main already verifies inline initial-read fallback pages. This branch preserves that behavior while threading
text_appendthrough the pinned reader, native hook verification and the typed reducer. The maintainability ratchet passes after separating selection-target parsing from page verification.The context setting, full explicit readers, canonical Todo state and Turn admission and settlement keep their existing contracts. This delivery does not establish model comprehension, model adoption or net whole-workflow savings.
Validation
The author's earlier File/SQLite byte comparison remains representative of the same complete-observation fixture, but those bytes are CLI output and do not prove live model adoption or whole-workflow cost.