Skip to content

Reduce private App mirror delivery latency - #8858

Merged
loopx-agent merged 9 commits into
mainfrom
codex/lark-app-mirror-latency-20261116
Nov 16, 2026
Merged

loopx-agent merged 9 commits into
mainfrom
codex/lark-app-mirror-latency-20261116

Conversation

@loopx-agent

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

Copy link
Copy Markdown
Collaborator

Goal and delivered outcome

An App-origin message in an existing owner-private conversation repeatedly checked the same grant and canonical transcript while waiting to mirror its body to Lark. Optional input feedback also waited on the body outbox when it could continue with another Session.

  • Authorize the original Lark source and then reread the current App grant and canonical body at each preview and dispatch boundary. In the reproduced text path this reduces live identity probes from eight to six and transcript scans from six to four.
  • Try the body outbox lock once when reading a projection and again when recording feedback. If body delivery owns the outbox during either step, other Sessions continue. The dedicated reaction receipt preserves the result when projection writeback has to wait.
  • With the same 3,541-row synthetic transcript, 12 App Turns, 53 verified prior phases and fixed provider-read delays, median processing time before the first Lark write went from 8.63 s to 6.64 s across five runs per version. Median time through provider receipt verification went from 9.41 s to 7.41 s. Provider responses and writes in this benchmark were synthetic. Separate authorized read-only provider timings informed the fixed delays.

Author declaration

Written by an OpenAI Codex agent. Based on the accepted private-conversation projection and feedback contract at f599a60ce64fd78db80d6318c84e3af58bfc1df9. App conversation RFC

Criterion Disposition Validation
Original Session, audience and complete canonical body before each effect Implemented Real Chat HTTP/Core with synthetic Lark. The original-source read can race with revocation, a replaced provider identity or an edited body. All three prevent the write.
Known receipts, unknown effects, ordering and single execution Implemented Existing restart, locator-loss, rich-part and image projection coverage.
Optional feedback stays independent of body delivery Implemented Hold one body outbox before the initial read or after provider reaction I/O. The second Session reaches its reaction receipt in the same pass. The pending receipt recovers after release, with exactly one provider reaction per message.
Installed-service and real desktop roundtrip at this revision Deferred Pending independent review and adoption.

Scope and continuation

This proposal changes the private Lark delivery worker. It uses the original App composer, existing Session and original Lark chat. After review and adoption, time a natural installed-App message through discovery, provider creation and independent readback in that chat. Installed App-to-Lark timing remains an adoption test.

Validation

Tested revision 3d30531c8fac4d37ebae377b0cd925ff4a960c2f with input classes synthetic and authorized_private_read_only. The delivery timings above were measured for the original authority-read reduction.

Check kind Result Evidence
Contention regression Passed With two Chat HTTP Sessions, real Core, the file lock, and synthetic Lark, the previously reviewed revision times out when the body worker takes the lock after the provider reaction. Both contention cases pass with the revised writeback, and the reaction count stays at one per message.
Integration Passed 82 private-conversation and App image-projection tests, including authority changes, restart, ordered image delivery and unknown attempts.
Local validation Passed Standard diff-selected premerge with 8 catalog canaries, Python compilation, Ruff, CLI output budget, repository contract scan and diff hygiene.
Repository type check Existing failure Mypy reports the same indexed-object error at loopx/control_plane/work_items/interaction_contract.py:1453 on the candidate and the verified target cac86bbad92ba99c3430b3f7eaa9632727573821.
Installed App and live writes Pending adoption Provider calibration used read-only commands.

The prior revision had hosted dashboard browser, Windows PowerShell and checks failures. The hosted workflows must verify the revised head. The full local pytest run is still underway. Dashboard browser · Windows PowerShell · Checks

The revised writeback covers the race reported in the independent review. Review of the preceding revision

Frontend and visual evidence

UI impact none. The existing App and Lark journeys use the same messages, controls and presentation. The observable change is delivery timing. Validation uses synthetic data for mutations.

Boundaries

Bug fix and test coverage for the Lark extension. The two committed paths contain product code and regression tests. DCO sign-off and the bilingual RFC scope 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

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

评审提交 d4fb46742f55071c1e5072e19223ca967b223ade,对照目标主干 f599a60ce64fd78db80d6318c84e3af58bfc1df9。

动机 / Motivation

从 App 在已有 owner-private 会话发送消息,并在原 Lark 私聊读回消息和接收状态的用户会遇到这个问题。
正文投影要重复读取授权和 transcript。独立的反馈 worker 在遇到其他正文写入时也可能等待整段锁超时。
在实际 Chat HTTP 入口建立两个已有私聊会话。一个会话在反馈扫描时已持有正文锁,或等反馈写到合成 Lark 后再取得该锁,观察另一个会话的反馈。
当前提交在读 outbox 时会跳过正在写入的会话。对合成 provider read 的撤权、替换身份或正文改写均能挡住写入。若锁在最初读取之后才被持有,反馈结果写回仍会中止整轮,两个版本都重现。
使用隔离的真实 Chat HTTP、Core 和文件锁,Lark provider 及宿主结果使用合成数据。已安装 App 的真实端到端时延待验证。

改动思路 / Approach

本次改动只组合现有原来源与正文授权读,并调整独立反馈 worker 的正文锁读取。现有私聊会话、正文 outbox 和 reaction journal 继续负责各自的写入及重试。
合并重复授权调用的方向符合现有职责。反馈的写回仍会等待正文锁,两个会话的真实对照显示这一机制还缺一处配套修正。
在 preview 和 dispatch 使用同一授权回调,先验证原 provider 消息,再读当前 grant 和 canonical 正文,以覆盖 read 期间的撤权或修改。等待正文锁的另一处是 reaction 已送达后的快照合并,继续使用原 journal 与比较规则即可。

具体改动 / Changes

2 个文件新增 108 行、删除 15 行。按 docs/architecture/rfcs/app-conversation-and-async-inbox-v0.md 核对以下要求。 原契约

  • exact-private-source-and-body。在 preview/写入前复核原来源、当前 grant 和完整正文,变化时拒绝。 本轮实际入口对照通过。
  • ordered-delivery-and-known-receipts。保留 canonical 顺序和原 provider 尝试,未知时停在原试次。 本轮实际入口对照通过。
  • feedback-without-body-lock-wait。正文争用时,独立会话的输入反馈继续。 本轮复现下述缺口。

关键代码讲解

  • authorized_source。核验原 provider 来源成功后再读当前 App grant 和正文。撤权、身份替换或正文在读取期间变化时拒绝写入。 按提交核对
  • _deliver。将合并回调交给已有 Inbox 发送入口。preview 后仍做一次检查。图片投影、已知回执与多段正文通过原路径。 按提交核对
  • reconcile_app_feedback。读取阶段现用一次 try lock,避开持锁的正文投影。反应完成后仍以原比较合并 feedback 字段。 按提交核对

对主干的风险 / Risks

  • [P2] 反馈写回仍会拖住其它会话 第一个会话的反馈已通过合成 Lark 写入后,正文 worker 在回写反馈前取得该会话的 outbox 锁并持有超过 5 秒。 reconcile_app_feedback 仅在首次读取时用 try_exclusive_file_lock。record_web_input_feedback 仍等待 exclusive_file_lock,超时在里面的 try 之前抛出,退出整轮扫描。 相同的双会话夹具在基线和当前提交分别于约 5.10 秒和 5.09 秒抛出 LockAcquireTimeoutError,第一条 reaction 已送达,第二会话本轮未收到。仅把写回改成 try lock 的隔离样本约 0.11 秒通过,释放后两条 reaction 各一次。 反馈写回争用正文锁时,沿已有 try lock 跳过当前 outbox,继续下一个会话。保留同一冻结正文的比较以及下次按原 reaction 回执续接,避免重复发 reaction。 读取 outbox · 反馈写回
  • 69 项定向测试通过,覆盖最初正文锁已忙、provider 身份替换或读取期间撤权/编辑、已知回执重启、未知写入防重、长文本和关闭 reaction 的原正文路径。上述晚锁样本验证的是真实文件锁和两个实际本地 HTTP 会话。
  • quick premerge 的 6 项直接与 2 项选中检查通过,包括结构与语义词汇。完整 premerge 和现场时延仍待验证。

语义与 CI 对齐

选择条件仍由已绑定 App 和原 Lark 来源负责,回写失败不应改变正文或首次反应的耐久回执。用双会话本地 Chat HTTP 场景重跑读取后持锁,并验证释放后 Get 去重。

我的整体评价 / Verdict

请求更改。原来源和正文授权的精简通过了实际本地路径对照,早期锁争用也能让其它会话继续。晚期写回阻塞仍影响多会话独立反馈。合入前补上同一 outbox 的非阻塞写回和覆盖两个时序的回归。

English verdict: REQUEST_CHANGES on d4fb46742f55071c1e5072e19223ca967b223ade. The late body-lock contention aborts the feedback pass after its first provider reaction, delaying another Session. Reusing a nonblocking lock for feedback writeback preserves per-Session progress and deduplication in the isolated test.

xiaobaifly7 and others added 8 commits November 16, 2026 16:34
…eout (#8854)

A replan admitted for a Monitor's no-change streak lost its receipt
source once the agent completed the Monitor inside that Turn, so the
same Turn's writeback and guard re-entry failed with
heartbeat_receipt_identity_conflict. Treat the streak as a scalar review
source, with a fixed kind precedence independent of trigger order.

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Co-authored-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Preserve requested scheduler detail during recovery waits

Prior-Turn recovery rebuilds the scheduler hint when the unchanged admission limit is reached. Forward the CLI detail selector to that projection so the DSH Driver receives the bounded recheck cadence it requested.

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

* Keep App scheduler reconciliation executable during recovery waits

Reuse observed host cadence and persisted backoff when projecting a prior-Turn recovery wait. Preserve the registered scheduler scope and place CLI options after the standalone interpreter prefix so the matched host can be acknowledged using the original receipt.

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

---------

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Revalidate the captured Session and combined admission signal before publishing a queue or scheduler wait plan. Cover Pause and native maintenance cancellation for both plans, followed by a fresh evaluation.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
#8770)

* fix(monitor): project User gate completion for an observed prerequisite

An admitted due Monitor that still has open User gates now gets the
existing User lifecycle completion command ahead of its poll actions,
on unchanged observations too. The Monitor Turn's settlement identity
stays separate; observation never grants approval.

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>

* fix(monitor): never project a User gate completion from an observation

Replace the projected completion command with a read-only notice. A due
Monitor that is admitted while the agent has open User gates is told that
its observation cannot complete or approve a gate, which attempts stay
rejected, and that work continuing on an observed change belongs in the
poll's own successor. Unrelated owner decisions receive no command.

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>

* fix(monitor): do not point an observation at any User gate

The notice told the agent to report the observed evidence as the pending
user action of an open gate, even when the gate was unrelated to the
observation. Keep only the boundary (an observation never completes or
approves a gate) and the original poll.

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Co-authored-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
#8584)

* fix(turn): enable builtin Codex durable Todo completion

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>

* fix(turn): validate terminal Todo before accountable refresh

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>

* refactor(turn): remove redundant lease shape check

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>

* Recheck the original Goal after built-in Codex validation

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

---------

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Co-authored-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Co-authored-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…rk-app-feedback-writeback-20261116

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 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)

评审提交 3d30531c8fac4d37ebae377b0cd925ff4a960c2f,GitHub 记录的 base 为 f599a60ce64fd78db80d6318c84e3af58bfc1df9。实际目标 main cac86bbad92ba99c3430b3f7eaa9632727573821 已在 HEAD 的祖先中,merge-tree 与 HEAD 一致。上一轮报告的晚期锁争用已用相同入口复验。 上一轮评审

动机 / Motivation

从 App 续接原 Lark 私聊、在原会话接收正文和输入反馈的用户。
原正文路径重复扫描 canonical transcript。旧版在反应调用返回后遇到正文锁,会等约 5 秒并中止本轮两个会话的反馈。
在实际本地 Chat HTTP/Core 建立两个已绑定会话。合成 Lark 送达第一条反应时由另一个线程持有该会话的真实 outbox 锁。
同一真实 HTTP 输入与合成 provider 的正文试验中,canonical transcript 读由 5 次减至 3 次,原 provider 来源读两边各 2 次,输出完整正文且读回同一条尝试。
相同锁争用在当前主干与上一评审提交分别约 5.14 s 与 5.16 s 超时。当前头同一 pass 用约 0.49 s 继续第二个会话。释放原锁并重建 transport 后,两条输入分别保留一份 Get,各自原正文回执不变。
本轮使用隔离 Chat HTTP、Core、实际文件锁与合成 Lark。已安装 App 往返、真实 provider 延迟与生产采用仍待验证。

改动思路 / Approach

复用 Inbox 原来源验证回调、现有正文 outbox 与独立 reaction receipt。首次读取和反馈写回使用同一非阻塞锁原语,正文比对保留原 identity 和冻结 phase。
限现有 Lark extension 的 App mirror 与 feedback worker。复用现有 App 输入、私聊发送和回执读取。
正文的 original provider read 后紧接一次新鲜 grant 与完整内容检查。反馈锁中只复制和合并当前 phase,合并时重新核对其正文和来源。较早版本只把首次读取改成 try lock,实际 reaction 已写后还有第二个竞争点。

具体改动 / Changes

GitHub base 到 HEAD 有 24 个路径。逐个比较了最新 main 的 mode 和 blob,22 个已在 main。本轮功能差异为两文件新增 138 行、删除 22 行。按 docs/architecture/rfcs/app-conversation-and-async-inbox-v0.md 核对。 原契约

  • exact-private-source-and-body。发送及续发前核对当前 App grant、完整 canonical 正文及原 provider 来源。 当前隔离入口已复验。
  • ordered-delivery-and-known-receipts。原顺序、完整长文和历史 attempt 可回读。未知 locator 继续核对原操作。 当前隔离入口已复验。
  • feedback-without-body-lock-wait。每次 reaction 以原输入、Turn、源、权限和精确镜像为依据。独立反馈写回只合并其字段。 当前隔离入口已复验。
  • installed-provider-delivery-and-readback。实际安装版使用原私聊接收正文及反馈。 保留安装版的独立验收。用实际 App 原会话核完整正文、原 provider 回执及端到端时延。

关键代码讲解

  • authorized_source。分别在 preview 和 dispatch 核验原 provider,紧接本地 grant 和 canonical 正文。 按提交核对
  • _deliver。把授权回调交给现有 Inbox,沿原 attempt 做长正文、图片和恢复。 按提交核对
  • reconcile_app_feedback。两次尝试获取正文锁。provider 反应已持久化时,下一轮可继续合并,当前轮其它会话有机会完成。 按提交核对

对主干的风险 / Risks

没有阻塞发现。读锁和写回锁两个时序均覆盖。写回争用样本对照了实际目标与上一头。释放后用新 transport 实例读回反应与正文,各输入只有一份 Get,已完成正文完整保留。

  • 私聊和 App 图片套件 528 项通过,其中 83 项直接覆盖 App、反馈和图片路径。
  • 完整 mypy 在当前主干和候选头均报告 interaction_contract.py:1453 的同一 [index]。该文件在当前合并树中逐字相同。
  • 当前头覆盖 provider read 期间的 grant 撤销、身份替换、正文变更、原 locator 未知与重启。4 项关闭反馈及回执边界复验在当前头与实际 main 分别通过。
  • 以当前不可变目标主干执行 quick premerge,6 项直接检查与 2 项选中 canary 通过。最新目标的 merge-tree 等于审查提交树。

语义与 CI 对齐

独立 reaction receipt 负责恢复,正文 journal 只保存精确镜像的投影。用户原 App 和 Lark 界面在实际目标合并树已经存在。当前评审依据隔离入口的源行为与负例。

我的整体评价 / Verdict

批准当前提交。复用 Inbox 原来源验证回调、现有正文 outbox 与独立 reaction receipt。首次读取和反馈写回使用同一非阻塞锁原语,正文比对保留原 identity 和冻结 phase。
对官方当前 main 的合并树检查确认,App 和 Lark 既有界面源都在 main。实际引入的是私聊 worker 的 timing 与 recovery,视觉证据边界为原界面无 diff。
本轮使用隔离 Chat HTTP、Core、实际文件锁与合成 Lark。已安装 App 往返、真实 provider 延迟与生产采用仍待验证。

English verdict: APPROVE on 3d30531c8fac4d37ebae377b0cd925ff4a960c2f. The revised mirror keeps current source and body authorization and lets another Session record feedback during a busy body writeback. Restart readback preserved both original receipts with one reaction per input.

@loopx-agent
loopx-agent merged commit 0c3b2fd into main Nov 16, 2026
38 of 49 checks passed
@loopx-agent
loopx-agent deleted the codex/lark-app-mirror-latency-20261116 branch November 16, 2026 14:38
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