Skip to content

fix(codex): keep Windows rollout reads from blocking native rotation - #7222

Open
BigDataDZ wants to merge 3 commits into
mainfrom
codex/windows-rollout-rotation-20261024
Open

BigDataDZ wants to merge 3 commits into
mainfrom
codex/windows-rollout-rotation-20261024

Conversation

@BigDataDZ

@BigDataDZ BigDataDZ commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

On native Windows, the local Codex observer and visible conversation readers open their rollout with ordinary Python read sharing, preventing the host from renaming or natively replacing that file during observation or history/content readback. The existing rotation regression also used os.replace, which cannot overwrite an open Windows destination even with delete sharing. A read-only observer should allow native host rotation and recover the replacement's state.

The provider now opens Windows rollout files with GENERIC_READ, OPEN_EXISTING and read/write/delete sharing. The returned binary stream owns a noninheritable handle and cannot write or create the source. The same transport now covers visible history paging and content reads, repairing the companion gap in this PR. Existing activity identity checks discard a mid-read replacement; the next observation recovers the new completed event. Visible reads retain the opened snapshot; subsequent paging resets for the replacement identity and old content references are rejected. POSIX keeps its existing Path.open("rb") behavior. The Windows fixture uses real ReplaceFileW, with and without observation caching; POSIX retains os.replace.

  • Outcome basis: reproduced native Windows failure under the existing bounded local Codex activity contract; intended base main, implementation baseline 19ccb632845ceae49ca6463ef26e868e2dcc1a45. No issue closeout is claimed.
  • Owner and placement: provider-specific OS IO in loopx/hosts; shared typed activity/state decisions remain unchanged. This stable Python provider adapter does not add a parallel semantic owner, capability or configuration input.

Author Declaration

Criterion Disposition Evidence
Read-only provider does not interfere with native rotation implemented Actual rename/native replacement; reader write attempts fail, source remains intact, handle closes and is noninheritable.
Replacement invalidates old facts and recovers the current source implemented Existing race regression, optional cache off/on: unknown during replacement, then exact replacement completion timestamp.
Bounded reads, source identity, session/header and cache boundaries remain implemented Full cursor and host-activity suites, including real byte-budget instrumentation and synthetic SQLite thread lookup; existing visible-history paging, content, stale-reference and privacy cases pass.

Scope And Continuation

Complete within this scoped repair. A small provider IO seam keeps Win32 handle mechanics separate from the existing cursor, visible-history projection and typed decisions. The bounded future-facing pass reuses that seam at both previously omitted history call sites without a new module or semantic owner. The owning reference and existing native Windows CI now cover the reader/cursor suites. No frontend, Lark, CLI option, scheduler, model or execution authority changes; no new screen or control is needed. Maintainer review/merge and installed live-host qualification remain separate.

Validation

  • Tested revision: db4ed16a88e0c254a63ae5b9bbd47a7b146b4cd6.
  • Run state: finished. Input classes: synthetic.
Check kind Result Public-safe evidence / limitation
real_entrypoint / real_backend passed Native Windows, CPython 3.12.10, local file IO and SQLite 3.49.1 in disposable synthetic homes. tests/test_codex_rollout_file.py, tests/test_codex_rollout_cursor.py, tests/test_host_thread_activity.py, tests/presentation/test_codex_attached_conversation.py: 147 passed, 25 skipped. Production observe_codex_threads, read_messages and read_content use real file/mmap/SQLite backends. Desktop Unix-peer HTTP cases skip on Windows; packaged frontend and installed live-host validation were not run.
regression_parity passed Original reader behavior fails both native replacement/cache cases with sharing violation 32; corrected reader passes. Both newly added visible message/content reader cases were first run red with native ReplaceFileW sharing violation 32, then pass with the shared reader, including replacement reset/readback and stale-content rejection. Independent native probes confirm ordinary reader blocks rename and ReplaceFileW, while shared reader permits both. os.replace of an open Windows destination remains unsupported by that OS operation.
static / unit passed Ruff and whitespace pass for the companion delta. Earlier workflow YAML and committed bilingual RFC check; advisory coinage scan has no supported new vocabulary carriers; full semantic vocabulary smoke passes with its existing coverage limitations.
manual passed Independent author-side inspection found no actionable issue and reran 42 cursor/history tests on the current change. Restoring ordinary Path.open process-locally makes both new visible-reader cases fail again with native sharing violation 32. Earlier relative and long Unicode path probes belong to the original reader qualification; they are not new current-head runs.
integration failed Broader module-budget/workflow run: 533 passed, 22 failed initially. Adding existing Git Bash to the test session PATH resolves 21 missing-shell cases (21 passed on rerun); the remaining test_six_shards_execute_each_test_once_and_merge_portable_coverage expects a diagnostic stack marker absent on this Windows host. The identical assertion fails when replayed against the unchanged baseline workflow. No timeout, assertion or CI gate was weakened.

Coverage and gaps: native reader ownership, source replacement/append, bounded recovery and actual provider readback are covered. Local POSIX execution, live UNC shares, allocation-failure fault injection and an actual installed Codex writer were not exercised. Native synthetic fixtures establish file/observer mechanics, not live-host adoption. The remaining workflow diagnostic failure is preserved; hosted CI and maintainer review are pending. No live Codex store, real Goal, model/provider Turn, global upgrade, publication or self-merge was performed.

Frontend / Visual Evidence

UI impact: none. Before/after/first viewport/craft review: N/A; this changes an existing provider's file access, with no presentation change.

Type / Area / Direction

Bug fix, documentation and focused validation; host/runtime integration and CI. Core control-plane reliability through the existing provider boundary. No shared-authority fixture or registered vocabulary change.

Signed-off-by: BigDataDZ <76271875+BigDataDZ@users.noreply.github.com>
Signed-off-by: BigDataDZ <76271875+BigDataDZ@users.noreply.github.com>
Signed-off-by: BigDataDZ <76271875+BigDataDZ@users.noreply.github.com>
@BigDataDZ BigDataDZ changed the title fix(codex): keep Windows activity reads from blocking log rotation fix(codex): keep Windows rollout reads from blocking native rotation Oct 24, 2026

@loopx-agent loopx-agent 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.1-sol | OpenAI | runtime_reported | reasoning_effort=max

Exact head: db4ed16a88e0c254a63ae5b9bbd47a7b146b4cd6

动机

在 Windows 上读取 Codex 活动状态和可见历史的用户。 宿主在观察器或历史读取器打开日志期间轮换文件时,读取器应放行原生替换,随后丢弃旧状态、恢复新日志;可见历史仍应保持已打开快照,下一页重置。 本轮真实 SQLite、文件、mmap 及公开读者的 POSIX 对照保持相同,替换后重置和旧内容引用拒绝通过;Windows 原生分支尚无本轮独立执行结果,不能据此认证目标平台问题已修复。 本轮不安装到真实 Codex、不启动宿主写者,也不将作者的 Windows 声明或 POSIX 通过称为独立 Windows 通过。

改动思路

把平台句柄规则放在现有 hosts provider IO 边界是合理的;活动游标和历史投影共用同一个只读打开器,源身份、分页和状态判断仍由各原 owner 持有。Windows 默认申请读取访问并允许读写删除共享,POSIX 原路径不变。 当前边界是三个真实日志读入口的文件打开、替换和恢复,不应新建状态协议、配置开关或把文件共享提升为执行权限。

No change leaves the reported Windows sharing defect. A shared OS provider seam at all three real readers is smaller than rewriting cursor/history ownership. The remaining action is native execution evidence, not speculative new machinery. 原权威输入和失败恢复边界保留:只读观察器不会成为宿主写者;打印安装指导不会成为自动安装授权。这里用文字说明前后行为即可,不引入未核实图示或新的用户确认步骤。

具体改动

接受的修改前规格为 docs/reference/protocols/host-integration-surface-v0.md,不可变版本 19ccb632845ceae49ca6463ef26e868e2dcc1a45。exact-session-read-only:implemented,pr7222-original-tests.log; source inspection; actual POSIX source byte hashes unchanged;bounded-completed-event-recovery:implemented,172 original tests and 5 complete base/head consumer pairs;replacement-cache-source-validation:deferred,POSIX source replacement/cache paths pass, but the new Windows transport and mapped visible history replacement were not independently executed here.。新增文档和作者自定义清单不是独立验收来源;平台实现仍需符合原始只读、来源恢复或既有目录与回滚契约。

关键代码讲解

  • open_rollout:OS IO and handle ownership;Windows reads gain sharing DELETE; POSIX direct Path.open unchanged。输入由原调用者提供,错误/重试仍归原 owner;未把内部助手变成新执行能力。

  • _rollout_activity:Bounded exact-source activity observation;same pre/post source guards and cursor, now shared opener。输入由原调用者提供,错误/重试仍归原 owner;未把内部助手变成新执行能力。

  • read_messages:Visible opened-snapshot mmap and cursor reset;same source stamps and projection through shared opener。输入由原调用者提供,错误/重试仍归原 owner;未把内部助手变成新执行能力。

  • read_content:Read authorized content_ref against file source;same stale-ref rejection and display limit through shared opener。输入由原调用者提供,错误/重试仍归原 owner;未把内部助手变成新执行能力。

完整审查7个路径 +206/-12,包括全部生产分支、相邻未修改消费者、持久测试和文档/工作流影响。没有新增共享状态、枚举、CLI参数或第二策略owner;Python保留为现有平台IO或安装渲染适配层,不扩展无关迁移。

对主干的风险

暂缓批准:新增 Win32 分支的关键后置条件尚未独立执行。 这不是已经证明的代码缺陷,也不要求为本机平台限制修改源码。当前机器只能进入 POSIX 分支;还原旧 Path.open 后同样172通过,5组完整观察也同样通过,恰好说明这些结果不能区分新的 Windows 修复是否有效。最小补充是在同一个不可变头上提供可独立重放的原生 Windows base/head 结果:普通读取控制应出现原共享冲突,头部应允许真实 ReplaceFileW;缓存关/开分别由unknown恢复到替换日志的精确完成时间;可见消息/mmap仍返回已打开快照,下一页重置,旧内容引用被拒绝;读取不能创建或写入源,句柄关闭且不继承。可直接重跑四个现有模块及新增具体用例,不需要新协议、迁移或放宽断言。

独立本机四模块本头 172 passed;相同套件接回旧打开器为 172 passed。5组真实SQLite/文件/mmap公开观察完整相等,无语义归一化,覆盖open、idle、abort、不完整尾记录、错误header;另实际替换后分页重置、旧内容拒绝且读者未改写源。local quick premerge 6直接+4选中检查通过。这些支持POSIX兼容和架构放置,不能认证Win32目标平台。

作者声明的原生Windows 147 passed/25 skipped、red/green sharing violation32和42项补充验证均已读,来源明确保留为作者声明;其更广533通过22失败、21项shell PATH恢复及1项基线诊断断言失败也未重写为本轮已验证。这些不是新代码缺陷的证明。本轮未查询或等待远程CI,当前wait_for_ci=false;没有用远程CI缺失作为阻塞。

API静态核对依据:Microsoft CreateFileW 将共享删除和本句柄访问权分开;Microsoft ReplaceFileW 描述被替换文件的访问/共享条件。这支持代码所用机制的方向,但并非实际Windows调用、CRT句柄转移或mmap恢复的执行证明。

我的整体评价

REQUEST_CHANGES(目标平台验证缺口),未发现已复现的新代码缺陷;problem_context 为 not_yet_proven,long_horizon 与 user_experience 的 Windows 实际改善同样未证明。架构判断 retain,设计边界和代码量合理,当前 hold 来自最强主张的真实后端证据缺口。 把平台句柄规则放在现有 hosts provider IO 边界是合理的;活动游标和历史投影共用同一个只读打开器,源身份、分页和状态判断仍由各原 owner 持有。Windows 默认申请读取访问并允许读写删除共享,POSIX 原路径不变。 当前边界是三个真实日志读入口的文件打开、替换和恢复,不应新建状态协议、配置开关或把文件共享提升为执行权限。

检查了现有活动、历史和内容读取路径;无页面、布局、组件或视觉素材改动,视觉评审不适用。 本轮未独立执行 Windows CreateFileW/open_osfhandle/ReplaceFileW、Windows mmap 轮换、UNC/长路径和失败清理,也未执行 live Codex 写者或已安装 App。 通过、失败与未测试范围分别保留;合并、安装采用和其他PR验收仍须单独满足其现有边界,本轮未合并或安装到个人宿主。

English verdict: REQUEST_CHANGES for an unresolved target-platform validation gap, not a demonstrated code defect. POSIX parity and local repository checks pass, but they never execute the changed Win32 path. Independently replay the unchanged-head native replacement, mapped-history and recovery cases; author-reported Windows runs are clearly attributed and are not this reviewer’s execution.

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.

2 participants