Skip to content

Keep ready native context readable and reuse observed scope - #8393

Open
loopx-agent wants to merge 3 commits into
mainfrom
codex/reuse-observed-write-scope-20261109
Open

loopx-agent wants to merge 3 commits into
mainfrom
codex/reuse-observed-write-scope-20261109

Conversation

@loopx-agent

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

Copy link
Copy Markdown
Collaborator

A large write scope can fill the native first page before it delivers the decision, selected Todo and required reads. Ready Turns now expose those controls in a complete opening and link the exact remaining selection. An eligible warm Turn can reuse the already delivered, unchanged scope for the same registered route and Todo.

Goal And Delivered Outcome

  • Advance C1 native context delivery through an independently reversible change for main. Related to C1: unify work sources and validate recovery #8266.
  • Keep current guards, stops, lease preparation and required reads in the opening. The linked selection starts with the complete current write scope and must be read before work. Both parts pin the original capture.
  • Reuse the same typed scope owner for the cold opening and warm observation. The complete capture and the ordinary reader remain available for recovery and existing cursors.

Author Declaration

  • Written by model_agent, OpenAI Codex.

Implemented against

Criterion Disposition Owner Evidence
Deliver the ready decision, stops and read obligations before a long write scope implemented Shared initial selection and existing bounded reader A complete first page on File and SQLite. The linked read and the ordinary read deliver the same selected leaves.
Reuse an unchanged scope after complete observation for the same native session, registered route and Todo implemented Turn boundary projection and native observation journal Native guard, paged reader and PostToolUse. A changed guard still arrives inline.
Recover the complete scope when observation, scope or route changes implemented Original capture and exact reader Partial delivery, registry rebind, scope edit, PostCompact and explicit off. Linked reads preserve the original receipt and do not spend quota.

Scope And Continuation

  • In three matched cold runs per backend with 290 paths, all tested controls arrived on page one instead of page three. The opening was 5,833 bytes on File and 5,835 on SQLite, down from a 12,000-byte partial page. The complete guard and reader output grew by 472 bytes on each backend, about 1.1%. Both versions used four reader calls.
  • In the packaged 270-path warm fixture, the full current reader after PostCompact was 34,869 bytes on File and 34,895 on SQLite. The observed-field read was 20,977 and 21,003 bytes respectively. Both saved 13,892 bytes and one page. An immediate explicit scope reread added 13,951 bytes, leaving a 59-byte premium versus the ordinary reader.
  • The cold improvement is earlier delivery of usable controls. The warm saving applies when the retained scope is usable. These measurements cover CLI output; natural model adoption, model cost and accepted outcomes remain in the original single-session C1 comparison.

Validation

  • Tested c0052d15934d99b05a6af241a8ab42518a54c670 against 73e49c4889774effa019c197fc8958d9f7505efb.
  • Run state: finished. Input classes: synthetic.
Check kind Result Public-safe evidence
regression_parity passed The wide-scope regression fails on the baseline. Both current parts preserve exact scope, selected leaves, capture digest and original receipt.
real_entrypoint passed Actual File and SQLite guard and context readers, including partial reads, observed reuse, changed guard and scope, route change, PostCompact and off.
real_backend passed 289 source tests passed on the exact head. 14 opt-in native-host cases were skipped.
integration passed 127 TypeScript tests, 12 exact-wheel tests with 180 CLI subprocesses pinned to the wheel, and six File/SQLite tests on the local C1 integration. The explicit C1 complete-envelope path also moved the controls from page three to page one on both backends with the same 472-byte total increase.
static passed TypeScript typecheck, Ruff and local standard premerge. Six direct checks and 19 selected checks passed.
  • Coverage and gaps: The source run retains its explicit native-host skips. The package and C1 checks used isolated synthetic Goals. Model and installation qualification are separate.

Frontend / Visual Evidence

  • UI impact: none.

Type of Change

  • Bug fix
  • Test update
  • Documentation update

LoopX Area

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

Shared-authority RFC fixture impact

N/A. The change is to first-read presentation.

Boundary Checklist

  • Diff and review materials contain public-safe evidence.
  • Scope is native first-read presentation.
  • No paired RFC changed. Both guide languages are updated.
  • UI impact marked none.
  • DCO sign-off present.

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

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 Reuse observed write scopes in native first reads Keep ready native context readable and reuse observed scope Nov 8, 2026

@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, reasoning_effort=max

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

动机 / Motivation

原生会话需要先读到当前 Todo、租约、停止条件和必读项,再判断可以开始的工作。基线的长写入范围会占满首读,关键控制条件必须翻页。候选让冷首读完整显示控制条件,并允许已完整收到的同一路由范围复用。评审覆盖原生 ready 首读、范围复用和同一捕获的恢复。复用其他已读字段时,变化后的长写入范围仍会挤走当前控制条件。

改动思路 / Approach

保留同一份捕获和现有读取 owner,在写入范围仍需交付时保住完整首段。评审覆盖原生 ready 首读、范围复用和同一捕获的恢复。可以沿已分开的首段和范围续读保留当前控制条件,并在同一路由已完整收到范围后复用它。范围与授权继续由现有 Turn 和租约 owner 核验。 基线验收规则

具体改动 / Changes

评审 c0052d1 对 73e49c4 的 8 个路径,+328/−32。complete-ready-opening 的冷场景通过,有其他已读字段时失败。current-scope-binding 与 capture-and-disabled-parity 在实际 File/SQLite 首读与恢复通过。whole-episode-qualification 仍沿现有 C1 对照验证。

关键代码讲解

  • readyWriteScope 用当前 ready 状态、注册路由、Goal、Agent、Todo 和边界生成范围的来源身份。nativeContextReadPlan 把宽范围放进同一捕获的续段,首段保留控制和 execution preparation。 范围条件 · 选择规划
  • _bounded_initial_read 为首段及续段核验真实输出预算,并保留同一捕获的摘要。实际 native_context_capture_view 仍会先采用普通 observed reader,再判断是否交付完整首段。 有界读取 · 原生导航

对主干的风险 / Risks

P2 · 复用其他字段时,新的长范围会遮住控制条件。 在同一会话先用原生读回完整收到 Goal 正文,不读取范围,再改动 290 条范围的末项并生成新的 ready Turn。File 和 SQLite 的基线与候选都从 12,000 字节的截断页开始。首段只读到六项检查中的 effective_action。选定 Todo、当前回执身份、租约状态、停止条件和需要父级批准的动作都要翻页。候选冷首读能用 5,886 字节交付全部六项。其他字段的合法复用使分段分支无法到达。请在当前范围仍需交付时保留完整首段,并沿同一摘要验证续段和已完整观察范围的复用。 分支

我的整体评价 / Verdict

请求修改。实际两种后端的普通游标最终都读到当前范围、guard 和原回执,已完整观察范围的测试也由三页降为两页。250 项 Python、154 项 TypeScript(1 项环境跳过)及 standard premerge 的 6 项直接检查、19 项自动检查通过。补齐混合观察场景后复验首段。模型是否实际使用这些信息、完整成本和安装版资格仍待对应验证。

English verdict: REQUEST_CHANGES. Reusing an unrelated observed Goal narrative bypasses the complete opening when the current write scope is still wide and needs delivery.

result["first_read_command"] = context_capture_read_command(Path(current["path"]), current["sha256"],
reference_file=first, page_bytes=first_page_bytes,
max_page_output_bytes=first_output_bytes, reader_argv=reader_argv)
elif (not page_attached and initial_read_plan and initial_read_plan.get("prefer_linked_opening") is True

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.

[P2] 已读其他字段时仍须保留完整首段

同一会话只完整读取 Goal 正文,然后改动 290 条写入范围的末项。已有正文观测会先选择普通 observed reader,跳过这里的分段。在实际 File/SQLite 入口,新的 ready 首读都是 12,000 字节截断页,缺选定 Todo、回执身份、租约状态、停止条件与父级批准条件。请在当前范围仍需交付且会遮住控制条件时保留分段,并同时复验已完整观察范围的暖读和同一捕获续段。

This branch has not been deployed

No deployments
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.

1 participant