Skip to content

fix(chat): timestamp return delivery after verification - #8311

Merged
huangruiteng merged 1 commit into
mainfrom
codex/manager-return-transaction-clock
Nov 9, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/manager-return-transaction-clock

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Problem

The return worker captured one timestamp at the start of each drain. A provider verification that finished later could produce a delivery receipt with delivered_at set to the start of the drain.

Change

Keep one cutoff for scanning eligible returns and read the clock again for each delivery transaction. Callers supplying now still get a fixed clock. The restart recovery test verifies the completion time and keeps the assertion that the provider is not sent a second reply.

Validation

  • The new assertion fails on the base commit when provider verification advances the clock by seven seconds.
  • python -m pytest -q tests/test_manager_context_roundtrip.py passed all 118 tests on the fix.
  • git diff --check passed.

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: model_agent, gpt-6.1-sol, OpenAI, runtime_reported, reasoning effort max

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

用户让同一个会话自动接回委托结果时,会用已送达时间判断对方何时真正收到结论。 原版在一批扫描开始就记下时间。验证晚七秒完成时,收据仍显示扫描开始时已送达,失败重试也提前起算。 一次七秒的模拟验证延迟后,恢复的送达时间与验证完成时刻一致。失败重试也从失败结果出现时开始计时。显式传入固定时间时,两条路径都沿用该时间。 本轮验证原生回传、重试和时间读回。真实安装版、Lark 提供方与跨宿主采用有各自的验收。 当前可确认重启后读回原结果及其时间。安装端的原会话到达与可见性仍保留在 M3。

改动思路 / Approach

宿主只提供观察时刻,原 TypeScript 事务继续负责已送达状态、重试和收据。 改动范围是现有回传 worker 的时间采样和重启回归。 原有读者和事务继续使用同一套状态与权限边界。该改动落在实际调用点,沿用现有的拒绝和恢复路径。一次七秒的模拟验证延迟后,恢复的送达时间与验证完成时刻一致。失败重试也从失败结果出现时开始计时。显式传入固定时间时,两条路径都沿用该时间。

具体改动 / Changes

关键代码讲解

  • drain。每次扫描保留一个时间基点,单笔事务从局部时钟取时。显式 now 仍可固定全部阶段。 提交源码
  • _pending_return_paths。每批最多读取 128 条候选,持续使用同一扫描基点,较慢的处理不会扩大本次扫描范围。 提交源码
  • _return_transaction。准备、记录尝试和结算仍调用原生事务,时间随每次调用更新。验证结果先产生,送达时间随后取样。 提交源码
  • deliveryOutcome。沿用 TypeScript 对验证结果的分类。已验证时用结算时刻形成送达收据,失败时由原公式计算下次重试。 提交源码

两个改动文件分别是现有 worker 与恢复回归。App 与 Lark 仍从已有 ReturnService 接入,原有来源与权限检查继续由相同事务处理。 对照的规范为 docs/architecture/rfcs/capable-manager-semantic-handoff-v0.md,版本 e2371c4。A8 的重启、原结果读回和无重复发送已用原生事务核对。A10 的时间值已在本地回读,真实安装版和 Lark 的同一会话验收仍归 M3。 固定版本的规范

对主干的风险 / Risks

若把扫描时间继续传给结算,延迟七秒的已验证回复会提前标记送达,失败后可提前七秒重试。定向用例逐阶段读原生请求与落盘状态,验证到期前跳过、到期时仅送达一次。完整套件只有一条现有 Hypothesis 收集警告。

PASS。完整 roundtrip 套件 118 项通过。三个定向场景在当前提交和当前主干组合均通过,基线在两个动态时间断言上按预期失败。 UNVERIFIED。远端 CI 与合入资格另按配置核验。

语义与 CI 对齐

Wall-clock delivered_at and retry deadlines follow the actual settle observation; fixed injected now and stable scan scope are retained. 该变化沿用现有语义词汇、同一持久化契约和已有错误归属。同一测试还在当前主干组合通过。评审结论随本提交记录,合入资格另走现有核验。

我的整体评价 / Verdict

未发现阻塞项。核对了回传状态与原会话投影,本次改动只改变已有时间值的来源,渲染布局没有变化。 界面仍显示同一收据字段。真实 App 和 Lark 的展示留给原有端到端验收。 原有继续执行和重试路径得到验证,用户无需重复提交原请求。当前可确认重启后读回原结果及其时间。安装端的原会话到达与可见性仍保留在 M3。

English verdict: APPROVE. At 4ede2eb, the fixed scan cutoff and explicit clock are preserved. Restart readback and retry timing now follow verified settlement, with the same result and no duplicate delivery.

@huangruiteng
huangruiteng merged commit a84205c into main Nov 9, 2026
29 of 42 checks passed
@huangruiteng
huangruiteng deleted the codex/manager-return-transaction-clock branch November 9, 2026 09:37
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