Skip to content

fix(context): preserve initial priority and pinned replay order - #7965

Merged
huangruiteng merged 4 commits into
mainfrom
codex/initial-read-required-order-20261103
Nov 3, 2026
Merged

huangruiteng merged 4 commits into
mainfrom
codex/initial-read-required-order-20261103

Conversation

@loopx-agent

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

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

必读上下文按路径排序时,完整材料索引可能排在行动依据前;固定首读引用再次被规范排序后,合法续页还可能因正文摘要改变而失败。本 PR 保留 typed owner 的首读优先级,把完整索引放在末尾,并按固定引用记录的地址顺序重放。

  • Goal/source and gap: 修复现有上下文 reader 的顺序和兼容恢复;对应 docs/reference/required-work-context.md,与已合入的 #7932 生产者整合。
  • Before → after: producer 已固定地址,consumer 仍可能重排;现在正常引用保留记录顺序,旧规范正文仅在精确 SHA-256 匹配后接受一次有界只读重试。完整索引、显式选择内容和拒绝边界保留。
  • Intended base: main;本次验证基线 2afe4b0a0d2a45b5f7a172f01bdc0542adcdec52。

Author Declaration

Criterion Disposition Owner / path Evidence
必读内容先于完整未读索引,内容仍可完整恢复 implemented context_selection.ts, progressive_context.ts 首读模块与实际 CLI 回归
固定地址引用按记录顺序分页,摘要不变;历史引用严格验证 implemented quota_capture.py recorded/legacy/Unicode/失败批次及导航变化反例
复用 typed owner;拒绝无效选择,不增加公开读取权限 implemented 现有 context_select transport 严格布尔类型、错误优先级、未知选择拒绝及状态不变
实际 Host/模型采用和长程收益 out_of_scope 现有后续集成验收 本 PR 不据 reader 成功认证采用或净成本收益

preserve_selection_order 是现有内部请求的严格布尔参数。TypeScript 先按原规则校验整批选择,再调整成功输出,因此错误顺序和诊断保持一致。普通显式选择仍使用规范顺序;持久化引用格式和公开 CLI 不变。Python 只复用同一个字节序列化函数,没有新增指针排序 owner。

Scope And Continuation

  • 原 fix(context): preserve initial priority and pinned replay order #7965 与当前已合 Pin initial context readers to resolved selections #7932 的实际代码整合,保留两侧原有独立判据,替代此前单行候选规则组合测试的交付依据。
  • 仅复用 #7969 已提出的 crowded JSON 回归上限 42,500 → 43,000,没有采用其余 runtime 改动。原 Windows CI 的 base 本身产生 42,501 字符,原失败保留;POSIX 同负载为 42,281。生产 transport、行数及语义增长预算均未改。增加回归余量保留信息,不删指导文字来压线。
  • 局部整理复用 _context_selection_bytes,统一正常/兼容读取的字节边界。旧式非规范地址列表配规范正文摘要时,最多每页多一次 planner;无匹配摘要仍拒绝。未证明净效率收益。
  • 此 reader 修复切片完整;独立评审、新 head CI、整体 C1、实际 Host/模型采用与完整成本验收继续沿现有工作推进。

Validation

  • Tested revision: 1ad388e5d70d04e802093254c6403ea65f376db8;基线 2afe4b0a0d2a45b5f7a172f01bdc0542adcdec52。75 项 reader 和 98 对预算场景在提交前运行,源码字节与最终提交一致;其余在该提交运行。提交后目标 main 前进至 65bde47b93b1cbd56e52a1e80e7f7d7a574d2750,新增 fix(lark): fail closed on damaged inbox state #7979/fix(codex): support strict Turn result schemas #7976 与这八个路径无重叠;本次仍报告 2afe4b0 验证边界,不宣称新主线全树已测。
  • Run state: finished
  • Input classes: synthetic, public_fixture
Check kind Result Evidence / limitation
integration passed test_context_read_reference.py + test_context_first_read.py:75 passed,保留生产者导航变化、固定/legacy 重放、Unicode、错误优先级及完整索引覆盖。
real_entrypoint / real_backend passed 完整 test_context_delivery_cli.py:88 passed,实际 File/SQLite CLI,含关闭、冷源、拒绝与恢复。
unit / static passed npm run test:control-plane:6,108 tests,6,031 passed、0 failed、77 平台/可选条件跳过;typecheck、原配置 strict mypy 17 文件、四个变更 Python 文件 Ruff 通过。
regression_parity passed 相同 base/head 负载的 cli-output-base-head-differential-smoke.py:base 98、candidate 98,candidate-only 0、review-required 0。
real_entrypoint / real_backend passed 从该 head 新建非 editable wheel,在 checkout 外调用真实 producer → File/SQLite authority → initial reader/full recovery。两种后端选中事实与完整源逐项一致,未知选择 exit 1、原状态不变,各仅一个 guard receipt、零 spend;四个生产文件 Git/wheel/安装字节一致。
manual passed 包外小型夹具没有未读索引,不冒充索引负载资格;索引完整性由上述 owning 模块覆盖。私有验证先因缺目录在准入前失败,随后一个“索引必存在”的错误假设被实际 source 否定;修正验证环境/条件断言后完成原夹具,未重复准入或修改产品代码。
static passed diff-scoped 语义 advisory、完整 registered-vocabulary smoke、双语 RFC 检查、diff 检查、8 路径公开边界扫描(0 errors/0 warnings)、chat bundle 与 wheel build。语义扫描不证明全部语义形式。
manual passed change-quality cqr_cf8eedb0073014128dca 与最终八文件 fingerprint 匹配,pass/valid;safe-fix allowed,applied 0;0 blocker、1 warning、1 advisory。
integration passed 标准 premerge:6 项直接检查通过,19 项选中检查、0 阻断、0 manual hold;18 项选中检查通过,1 项既有 maintainability ratchet 原始 exit 1 由现有规则标为 advisory_inherited_failure,未改阈值或把原失败重记为通过。
real_entrypoint not_run 新 head 原生 Windows CI 未在本机执行;原 Windows 42,501/42,500 失败不能追认为通过。远端 CI、独评、merge-readiness 仍需验证。

历史 669dd7517、96a23027a 的固定引用续页失败,以及此前 candidate-only 组合证据均保留其原边界;不据当前成功重写旧结果。没有执行合并、全局安装、真实 Host 切换或模型效果实验。

Frontend / Visual Evidence

  • UI impact: none。修复既有 reader 内部行为,无新配置或 UI 操作;前端截图 N/A。

Type of Change

  • Bug fix
  • Documentation update
  • Test update

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)

Technical Direction

沿现有整体 roadmap 的上下文交付/恢复边界改善真实 caller 可靠性;不将 reader 通过等同整体 C1 或长程效果闭合。

Shared-authority RFC fixture impact

N/A:未新增 authority provider、存储路由或兼容迁移;File/SQLite 使用现有真实 CLI 夹具,PostgreSQL owner 未改。

Boundary Checklist

  • Diff 与本文不含私有状态、凭证、原始轨迹、内部链接或本机路径。
  • 未复制其他维护者拥有的工作;复用公开已有 producer 与 budget 依赖。
  • 范围保持在原 reader 修复;无配对 RFC 变化,双语检查通过。
  • UI impact none。
  • 每个新增提交含 DCO sign-off。

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…nned-native-reader-order-20261103

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@loopx-agent loopx-agent changed the title fix(context): read required work before the unread-material index fix(context): preserve initial priority and pinned replay order Nov 3, 2026

Copy link
Copy Markdown
Collaborator

该组合问题已给出独立修复 #7972,精确 head 357893f8739fe223b97285a3bf427f9bdbf15af4。TypeScript 继续校验地址,reader IO 按不可变引用中已冻结的序列化顺序重放,再校验完整摘要;普通显式选读仍按规范排序。

已在当前 main d1bd973 + #7932 b9aab0e + 本 PR 669dd75 的受控组合验证:仅撤回修复的 7 行时,8 KiB/64 KiB 两例原生私有引用续页均复现 selected view digest changed;恢复后 76 项组合读取测试通过。独立补丁的 280 项 reader、19 项 TypeScript 与 quick premerge 也通过,历史配方拒绝/同 capture 完整恢复及原 SHA 均保留。原有 machine-view 分页用例单独通过不能覆盖这条私有引用路径,已补上对应回归。

#7972 已交独立 review,结论尚待返回。两项共同采用时请一并带上该修复并复核精确组合;该证据覆盖读取兼容性,模型与科研效果仍由后续运行验证。

@mergify

mergify Bot commented Nov 3, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @loopx-agent.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

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 HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 3, 2026
Preserve both navigation and digest-order recovery tests from PRs #7932 and #7965. Reuse the Windows-only regression-budget calibration already proposed in #7969; production transport and semantic growth guards remain unchanged.

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: actor_kind=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。同一 recorded-order 引用在基线第一页失败,当前头连续48/6页成功;旧 canonical-body 布局两边均成功。初始必读事实优先出现,两种既有正文布局都能按完整摘要校验恢复。本次不改变 admission、工作所有权、结算或权限,也不认证模型保留、安装采用和长程科学收益。

需要解决的是连续读取时当前控制和停止条件排在庞大导航索引之后,以及旧引用中“记录的指针顺序”和“当时正文的规范顺序”并不总相同。只修其中一种,会让有效的旧引用在下一页失败,增加恢复和人工核对成本。本次按这个具体读取问题验收,不用完整父项目的科学实验结果代替判断。

改动思路 / Approach

复用 TS 地址验证与原始 Python 字节渲染,将顺序修复留在既有 reader 边界,避免第二套选择语义。当前边界是优先读取与既有引用兼容,不把完整 Host 采用或长程实验作为本次修复的前置条件。

TS 仍先完成整批地址验证,普通显式选择继续规范排序;持久化引用才恢复记录顺序。Python 使用验证后的原始 JSON 值序列化,并检查完整 selection SHA。记录顺序与旧摘要不匹配时,只对同一来源和同一地址集合尝试一次原规范渲染;两次都不匹配就拒绝。它没有增加第二套权限、状态或选择解释器。

相同不可变引用 基线 当前头
recorded-order 正文 两种预算均首屏拒绝 48/6 页,352194B 完全相同
旧 canonical-body 正文 48/6 页成功 48/6 页成功
当前主干 producer 冻结的地址 主干15/2页 候选 consumer15/2页,同为96483B

表格来自独立真实 CLI 回放;页面预算分别为8192和64000字节,不是模型保留或实际采用证明。

具体改动 / Changes

7个文件共311行新增、19行删除:生产变化位于三个既有选择/传输模块,另有双语参考文档和三个测试文件。依据 docs/reference/required-work-context.md 的原始 Turn、完整摘要与恢复约束,immutable_reader_compatibility、initial_priority_without_authority 在本次范围内满足;Host采用与长程收益明确不在本次验收内。

规范不可变版本:2afe4b0a0d2a45b5f7a172f01bdc0542adcdec52。

关键代码讲解

  1. capturedContextSelection 严格检查新内部 bool;resolveSelection 对整批指针保留原验证、错误优先级与脱敏诊断,验证成功后才调整记录顺序。普通显式读取不启用它。
  2. _context_selection_bytes 提取既有原始值渲染,避免把不安全整数、浮点和Unicode值交给另一套数字解释。read_context_capture 用完整摘要区分两种既有布局,最多多一次只读 canonical 计划;不改写旧引用。
  3. initialContextReadPointers 把可选 unread index 移到当前控制、完整必读来源和结算条件之后,原事实、未知义务和原始完整恢复均保留。已独立验证最新主干7932 producer 实际生成的 resolved-address 引用可被该 consumer 读取;没有把作者的组合实验当作本次独立证据。

对主干的风险 / Risks

主要风险是持久化布局歧义、Unicode/数字重序列化和整批错误语义变化。独立当前8模块192项 Python 测试、18项 TS 定向测试、TS类型检查均 PASS;完整 TS suite 独立运行6099项,6022 PASS、77项环境条件 skip、0失败;真实原始引用回放覆盖两种布局、重复指针和两个字节预算,capture/descriptor不变且未创建registry/runtime。普通显式选择、无效地址、未知schema和完整恢复由当前测试共同覆盖。该内部 bool 是局部渲染参数,没有扩张执行、Agent生命周期或授权。

语义与 CI 对齐

风险分级 standard premerge 为 PASS:6项直接检查、19项选中检查、0项阻塞失败。维护性 ratchet 的原始命令在独立 base/head 均 exit1,完全相同的未改动 render_canonical_todo_sections 历史问题,magnitude_regressions=0,保留为非阻塞 advisory。自制跨版本探针的前三次导入/引用构造错误已保留,修正为真实 reference codec 后的 v4 才作为 PASS 证据。wait_for_ci=false,CI 未查询、轮询或等待,也未猜测成功或失败原因。

最新主干的 producer 与该分支存在独立演进:这里的混合版本读取检查证明边界互通,不证明冲突解决后的组合头已验收。若 rebase/解决冲突改变头,必须重新检查受影响语义和 merge readiness;不要求本 PR 修复无关历史 ratchet 或补齐完整父实验。

我的整体评价 / Verdict

未发现阻塞 finding。这个有真实 CLI 消费者的窄修复完成优先读取和两种旧引用兼容,长程影响限于持续读取/恢复可靠性,用户体验减少重复恢复步骤;不声称完整长程收益。提取原始渲染是本次有价值且可回退的局部整理。兼容层有未结束原 Turn 的持久化消费者,保留是必要的,退役应等待这些消费者完成;没有新增公共词汇或CLI。

检查 quota context-read 与 required-work-context:未改变浏览器、消息卡片或其他渲染页面,无需截图。无渲染页面变更;模型实际采用与安装运行时未验收。 审核结论为 APPROVE;未知 CI 不阻塞这个已独立覆盖的结论。批准后的原生 closeout、当前头 merge readiness 和合并权限仍分别读取;本审核不执行合并。

English verdict: APPROVE a1e9144. Both persisted selection layouts and the current producer interoperate under independent exact-byte CLI replay; required local validation passes, with an unchanged baseline advisory and CI not consulted.

@loopx-agent
loopx-agent requested a review from maxliux5 as a code owner November 3, 2026 09:09
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 3, 2026
@huangruiteng
huangruiteng merged commit 31885a6 into main Nov 3, 2026
6 of 7 checks passed
@huangruiteng
huangruiteng deleted the codex/initial-read-required-order-20261103 branch November 3, 2026 09:13
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