Skip to content

fix(nokv): preserve completed helper replies across process exit - #9485

Merged
huangruiteng merged 1 commit into
loopx-project:mainfrom
Duang777:codex/core-recovery-fix-20261126
Nov 27, 2026
Merged

huangruiteng merged 1 commit into
loopx-project:mainfrom
Duang777:codex/core-recovery-fix-20261126

Conversation

@Duang777

Copy link
Copy Markdown
Collaborator

The NoKV subprocess transport discarded complete helper replies when the process emitted exit before stdout drained. A read could become unavailable, a completed CAS publication could lose its applied acknowledgement, and an open refusal could lose its typed reason code. A real Python subprocess reproduction failed for both read and publication before the fix.

The transport now waits for the child's close event before failing outstanding requests. New requests to an exited helper are rejected immediately, and a late stdin error from that exited process cannot discard buffered replies. Existing framing, response limits, deadlines, SDK admission, provider CAS and receipt recovery remain with their existing owners. No write is retried automatically.

The owning acceptance is the shared authority-provider RFC's source transport and recovery boundary. Both language versions record the delivered delta and its limits. This changes the existing optional NoKV provider adapter; it adds no capability, setting, CLI flag, frontend interaction or persisted schema. File, SQLite and PostgreSQL implementations are unchanged.

Validation:

  • Red: both real-subprocess read and CAS reply regressions failed on the original transport. Each observed process exit before subsequent stdout delivery.
  • Green: 802 TypeScript cases passed across NoKV transport, authority-store conformance, qualification-harness tests and the new process regressions, with no skips.
  • Four process regressions cover complete read and CAS replies, rejection of requests after exit, preserved typed open refusal, and rejection of an unterminated reply.
  • Control-plane TypeScript typecheck, 56 Python helper/SDK-boundary tests and Ruff passed.
  • Standard diff-scoped premerge passed with five catalog canaries, eight risk-profile smokes, direct checks and a clean scan of all five proposed files. The final branch was rebased onto current target main and its four process regressions and standard premerge passed again.
  • The bilingual RFC diff check passed. The semantic advisory found no supported production vocabulary additions; the test's read/publish variants are local fixture cases.

The subprocess and SDK fixtures are synthetic. A live NoKV SDK stack, installed application adoption, Windows runtime behavior and D2/D3 qualification were not exercised. This proposal makes no provider-promotion or installed-product claim. Remote CI and maintainer review remain pending.

The sibling sweep found one TypeScript child-process handler that rejected helper responses on process exit: this transport. Its local shutdown wait uses exit only to decide whether to terminate the child and does not discard stdout replies. The TCP/HTTPS handlers use connection close with their existing business-work drain rules. No new abstraction or broader refactor was needed for this bounded fix.

Signed-off-by: Duang777 <duangjl007@gmail.com>
@Duang777
Duang777 force-pushed the codex/core-recovery-fix-20261126 branch from 3be6ac1 to 91f74db Compare November 26, 2026 08:17
@Duang777

Duang777 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Rebased the author branch onto main b963e9182. The new head is 91f74db4472218d653097b77907c1f9861077ac2; the five-file NoKV transport repair is unchanged. The commit retains DCO sign-off.

Validation at this head passed: 399 NoKV transport/conformance and stdout-drain cases, control-plane TypeScript typecheck, and standard diff-scoped premerge with a 300-second per-check limit. The worktree is clean, and no lockfile is included. The earlier 802-case and Python checks remain source-specific historical evidence.

The previous head's package browser failure stopped at the chat-recovery assertion for the old deferred-reason label. The same failure was reproduced in packaged Chat on an isolated, unmodified main checkout at b963e9182, without the NoKV changes. Applying only the scenario patch from #9437 at 73d12b2411 to that same checkout made the complete packaged chat-recovery scenario pass. This is a shared baseline validation hold, unrelated to helper reply draining. The browser fixture is synthetic and does not qualify installed-product adoption.

Current-head CI and maintainer review remain required. Main has subsequently advanced; after the shared browser fix lands, synchronize again and qualify the resulting combination. No merge has been performed.

@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.2-sol · OpenAI · runtime_reported · xhigh

动机 / Motivation

在可选 NoKV 适配器上做源码验证与资格检查的维护者,需要读取存储或确认一笔刚完成的发布。 原实现会在子进程 exit 时清空待处理请求。进程已输出完整回应,回执仍可能在 stdout 里,操作端却看到断开。 当发布已经完成且调用者只看到断开,会引入一次不必要的回读,原始操作的结果也更难诊断。

一个 helper 在成功发布后立即退出。原来调用者无法从这一请求确认结果。现在先接收已缓冲的完整回应,进程退出后发出的请求仍立即失败。 真实 Python 子进程的完整读结果、CAS 发布回执和带原因码的拒绝从 3 项失败变为 3 项通过;缺少换行的半帧在两个版本均未产生成功回执。 在 macOS 上以真正的 Node/Python 子进程验证协议,并在本地 File/SQLite 上复跑相同 provider 筛选夹具。真实 NoKV SDK 驱动、安装态和 Windows 未验证。D2/D3 的资格由各自流程决定。

改动思路 / Approach

传输层知道请求和 stdout 的生命周期,在这里等待完整回复,既可保留 typed refusal,也可保留 CAS 结果。各业务调用者继续采用原来的恢复入口。 变更位于明确启用的 NoKV JSONL 适配器内,File/SQLite 选择、持久化格式、授权与原操作规则保持原 owner。 已完整送达的请求直接结束;不可用时保留原 NoKV 错误,调用者经既有重连与原操作识别回读。

具体改动 / Changes

核对精确提交 91f74db4472218d653097b77907c1f9861077ac2 相比分叉基线 b963e9182ce18ca5a5530d399d452fdb2369e85d 的 5 个文件,+124/−2。采用候选前的公开规范判断适用范围。 规范

关键代码讲解

  • NoKVJsonLinesTransport constructor。让已发出的请求在 stdout 排空后才因断开被拒绝。 源码

  • NoKVJsonLinesTransport.exchange。进程已经退出时先拒绝新请求,无需写入 stdin 或占用超时。 源码

  • NoKVJsonLinesTransport.onStdout。继续按完整 JSON 行和请求 ID 解析并结算缓冲中的回执。 源码

  • §1。NoKV 为可选持久化适配器。LoopX 决定业务语义,provider 保留原 CAS 及回执。 验证入口

  • §8。安装 provider 不自动启用共享模式。保留默认本地路径与显式选择。 验证入口

对主干的风险 / Risks

子进程的 exit 与所有 stdio 关闭允许有间隔。新请求在 exit 时即可被拒绝,在途请求仍受既有 deadline 约束;缺少有效完整回执的请求仍失败。 候选仍拒绝退出后发起的新读请求,以及子进程断开时留在管道里的半帧。独立的回执恢复、超时、CAS 世代和 workspace 校验仍经原入口验证。

语义与 CI 对齐

基线与候选各 39 项相同 File/SQLite 入口断言通过,默认选择、显式选择、回执及已有迁移检查保持;半帧在两端都被拒绝。 标准预合并含中英文 RFC 同改、公共边界及八项风险 smoke 都通过;TypeScript 类型检查通过。 NoKV 相关用例共 802 项通过。首轮并行检查发生在源码归档补齐前,资格 harness 因缺少模块未运行。补齐同一提交后,单独重跑 11 项通过。 本轮按项目策略跳过远端 CI 查询。目标主干在检查时可无冲突合并,合入资格仍由独立门禁决定。

我的整体评价 / Verdict

APPROVE。 同头检查未发现阻断问题。保留已经生成的发布回执减少重复确认,也保留原操作身份和恢复判断。半帧不构成宣告成功的依据。 有完整失败原因或成功回执时,调用者能继续用原 CLI/恢复工作流;未完成的回应仍要求原操作恢复。 检查的是 NoKV JSONL 子进程适配器和既有本地 provider 选择。该变更无可视呈现。 无新增界面。安装态和真实 NoKV SDK 环境未验证。

English verdict: APPROVE at 91f74db. Complete JSONL replies now survive helper exit while new calls are fenced immediately. The old revision loses three completed replies in the same real subprocess fixture. Default and explicit File/SQLite paths passed the paired checks.

@huangruiteng
huangruiteng merged commit a3e9d5f into loopx-project:main Nov 27, 2026
36 of 50 checks passed
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.

3 participants