Skip to content

fix(lark): reset noop recovery backoff when Turn or session inputs change - #9119

Merged
huangruiteng merged 1 commit into
mainfrom
cursor/reset-noop-recovery-backoff-6db6
Nov 20, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
cursor/reset-noop-recovery-backoff-6db6

Conversation

@Duang777

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

  • Outcome basis / optional anchor: Self-found on main after perf(lark,native_chat): back off noop recovery retries and cache recovery lookups #9096 (8e9a28a866da06cc6fd63e78709910fe35dad564, then rebased onto current main). Not taken from an issue list. duang777 (@Duang777) did not claim or close any issue.
  • Goal/source and gap: No-op context recovery backoff keyed only the Lark delivery receipt and the external-request journal, and treated a None fingerprint as a stable identity. A Turn, session, or events change, or a fingerprint the platform cannot supply, left the delivery path out of pending_delivery_paths() until exponential backoff expired (about 2–31 minutes).
  • Observable before → after, with the validation row that proves it: Before, rewriting only the Turn file five seconds after a no-op kept the path hidden, and a fingerprint that is always None advanced the probe from 60s to 120 + jitter (observed 1224.0 instead of 1120.0). After, those input changes clear backoff immediately, and an untrusted fingerprint stays on the 60s probe. Proved by tests/test_lark_steward_directory_scan_perf.py.
  • Issue/task and intended base: Related to perf(lark,native_chat): back off noop recovery retries and cache recovery lookups #9096 only as the merge that introduced the narrow key. This PR does not close perf(lark,native_chat): back off noop recovery retries and cache recovery lookups #9096 or any other issue. Base: main.

Author Declaration

  • Written by: duang777 (@Duang777); agent Grok 4.7

Implemented against

  • Specification and revision: no written specification; the request in this PR is the basis
  • Criteria:
Criterion (spec clause) Disposition Symbol / path Test or command
Unchanged trustworthy fingerprints still back off, and rewriting the external-request file resets immediately implemented LarkPrivateConversations._context_recovery_fingerprints tests/test_lark_steward_directory_scan_perf.py::test_reconcile_request_backs_off_repeated_noop_recovery_and_resets_on_change
After one no-op, rewriting only the Turn, session, or events file clears backoff inside the 60s window implemented LarkPrivateConversations.pending_delivery_paths tests/test_lark_steward_directory_scan_perf.py::test_noop_recovery_backoff_resets_when_turn_session_or_events_change
A None fingerprint is not an identity; the path returns on the 60s probe instead of exponential backoff implemented LarkPrivateConversations._record_context_recovery_noop_backoff tests/test_lark_steward_directory_scan_perf.py::test_noop_recovery_backoff_does_not_pin_when_fingerprint_unavailable
  • Self-check before submission: Read the recovery backoff path, recover_failed_request early returns, and optional_file_fingerprint / store path helpers. Ran the new tests on unmodified main (they failed), then the same tests plus the steward scan file, adjacent recovery tests, ruff, git diff --check, and loopx canary premerge on the fix (they passed). Did not add a new recover_failed_request return shape. Did not run the full repository pytest suite.

Scope And Continuation

  • Completed scope and remaining work: Backoff now follows the delivery receipt, external request, Turn, session, and events fingerprints. If any token is None, the entry is not stored and the probe stays at 60s. Route-fence misses and mid-verification aborts that return the same request without rewriting those files still increment the streak. A quota or capacity change with the same property has that limit.
  • Slice boundary / successor: Complete within this scope for the fingerprint key. Splitting those transient returns needs a new public result from recover_failed_request; that refactor is left out.

Validation

  • Tested revision: f9128ba05dcf067871cf66f36c7b77267d349dfe
  • Run state: finished
  • Input classes: synthetic
Check kind Result Public-safe evidence / limitation
regression_parity failed On unmodified main 8e9a28a866da06cc6fd63e78709910fe35dad564, before the fix: uv run --extra test python -m pytest -q tests/test_lark_steward_directory_scan_perf.py::test_reconcile_request_backs_off_repeated_noop_recovery_and_resets_on_change tests/test_lark_steward_directory_scan_perf.py::test_noop_recovery_backoff_resets_when_turn_session_or_events_change tests/test_lark_steward_directory_scan_perf.py::test_noop_recovery_backoff_does_not_pin_when_fingerprint_unavailable → 1 passed, 2 failed. Turn rewrite at +5s left pending_delivery_paths() empty. Always-None fingerprints set the second probe to 1224.0 instead of 1120.0.
unit passed Same three tests, then uv run --extra test python -m pytest -q tests/test_lark_steward_directory_scan_perf.py tests/test_context_recovery_discovery.py tests/test_lark_delivery_wakeup.py tests/test_lark_private_conversations.py::test_private_recovery_discovery_keeps_negative_and_attempt_backoff tests/test_lark_private_conversations.py::test_private_recovery_backlog_uses_released_capacity_before_retry_delay on f9128ba05dcf067871cf66f36c7b77267d349dfe → 34 passed.
static passed uv run --extra test python -m ruff check loopx/extensions/lark/private_conversations.py tests/test_lark_steward_directory_scan_perf.py; git diff --check origin/main...HEAD; uv run --extra test loopx canary premerge --from-git-diff --git-diff-base origin/main → passed (changed_files=2, catalog 2, risk-profile smokes 8, no failures).
  • Coverage and gaps: The tests cover unchanged backoff, external-request reset, Turn/session/events reset, and the None fingerprint cadence. They do not execute a real Windows host; file_change_fingerprint is patched to return None. Fence-miss and mid-verification returns are not separated from other no-ops. Full-suite pytest was not run.

See validation disclosure guidance.

Frontend / Visual Evidence

  • UI impact: none
  • Before: N/A
  • After: N/A
  • First viewport and preview: N/A
  • States and viewports shown: N/A
  • Source data: none
  • Attention review: N/A
  • Craft review: N/A

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring (no functional changes)
  • Documentation update
  • Test update

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)
  • Benchmark boundary (adapters, runners, verifiers, scoring, evidence)
  • Capability or extension (providers, adapters, skills)
  • Public docs or presentation surface (README, protocols, dashboard)
  • Build, packaging, installer, or CI
  • Host or runtime integration

Technical Direction

  • Direction / acceptance reference, when applicable: Operator surface and IM integration. No roadmap id. Scheduling fix for Lark private context-recovery probes.

Shared-authority RFC fixture impact

  • Production-scale fixture schema: N/A
  • Semantic dimensions changed, or reviewed no-impact rationale: N/A
  • Provider conformance arms run: N/A
  • Read-only legacy/file/PostgreSQL three-arm rehearsal (required for promotion, runtime-routing, or compatibility-projection changes): N/A

Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths (including .loopx/, .codex/goals/, and live ACTIVE_GOAL_STATE.md).
  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.
  • I kept the change scoped to the linked issue/task.
  • Existing English/Chinese RFC pairs (including ledger entries) both have a diff, and the local premerge check python3 scripts/check_rfc_bilingual.py --base origin/main --head HEAD passes, or no paired RFC changed.
  • I completed the visual evidence section for UI changes, or marked UI impact none.
  • Every commit includes a DCO Signed-off-by trailer (git commit -s).
Open in Web Open in Cursor 

…ange

#9096 keyed no-op context recovery backoff on the delivery receipt and
external-request journal only, and treated a missing fingerprint as a
stable identity. A Turn, session, or events mutation could stay hidden
until exponential backoff expired. On Windows both fingerprints stay
None, so rewriting the external-request file never cleared the wait.

Fingerprint the delivery receipt, external request, Turn, session, and
events files with optional_file_fingerprint and the chat store path
helpers. When any token is None, keep the 60s probe and do not extend
the exponential streak.

Signed-off-by: Duang777 <[email protected]>

@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 | low

动机 / Motivation

真实 Lark/provider、Windows 与已安装服务仍未验证;本次只资格化局部退避输入边界。

使用 Lark 私聊恢复 native turn、且前次恢复返回 no-op 的用户;后台 pending delivery 扫描和恢复调用者。no-op 退避缓存只比较 delivery receipt 与 external request;turn、session 或 events 原子更新后,候选仍受旧退避时间限制。无法取得可信 stat token 时仍可能累积指数退避。前次 no-op 后第 5 秒仅更新 turn、session 或 events:base 不返回候选,head 立即重新检查;所有输入未变时,两版仍按原指数退避与 jitter 探测。真实输入推进后及时重试原恢复 owner,同时保留静止输入的退避,避免把新进展误当成旧 no-op。stat token 不可信时只维持 60 秒普通探测。

没有找到本次局部退避键修复单独接受的验收规格;不以作者新测试自证,按基点真实调用者的恢复及时性、静止输入退避和 Core 权限边界作独立反例。参照基点 cc5392e9538e81487e9e551b915dabc68c085c25,本次检查 head f9128ba05dcf067871cf66f36c7b77267d349dfe。不重写 Core 恢复结果协议、不承诺 route fence 或 quota 在文件不变时也会即时唤醒,不改变 Lark 发消息权限,不声称真实 Lark 客户端、Windows 或生产服务已升级。

改动思路 / Approach

复用 optional_file_fingerprint、ChatSessionStore 的既有三个路径 helper 和原恢复候选队列;五个 token 是进程内失效提示,实际是否恢复仍由 Core 决定。本 PR 只修正 no-op backoff 的输入身份和不可信 fingerprint 降级,不改变持久状态格式、Core 恢复决策或消息内容。已有 owner 足够,修补其输入边界比新增协议或状态机更小。未将共享投影、缓存 hint、测试数或历史评审当成实际写权或已部署结果。

五个已存在文件的 stat token 一起决定缓存失效;不可信 token 不累积指数退避。没有新增 opt-in 或开关。完整检查了生产变更、helper 定义、调用方与测试,不新增领域专用的通用 Goal 义务,也没有 opt-in/default-off 声称。

具体改动 / Changes

_context_recovery_fingerprints(loopx/extensions/lark/private_conversations.py):组合 receipt、external request、turn、session、events 五个 stat token;任一不可信返回 None。

_record_context_recovery_noop_backoff(loopx/extensions/lark/private_conversations.py):仅可信且相同身份累积 streak;不可信清缓存并回到 60 秒探测。

pending_delivery_paths / reconcile_request(loopx/extensions/lark/private_conversations.py):输入变化清退避;原 native recovery 与待投递优先顺序保持。

正向路径:使用实际 ChatSessionStore 文件与真实 Lark transport discovery/reconcile 入口,分别 atomic replace turn/session/events:head 第 5 秒返回候选,base 均不返回。

反向与恢复路径:输入不变时两版下一次 no-op 后相同退避;receipt/external 更新两版都立即返回;无可信 token 时 head 保持 60 秒、base 继续累积到更长退避。

四文件 pytest 共 606 passed(1 条非失败 collection warning),14 个同 fixture base/head 对照通过,Ruff 与 standard premerge 全部通过。对照使用相同输入类别、真实临时文件和明确 source-checkout provenance;基点用 immutable module 装载,未运行活跃用户 Goal。未查询 CI,review 结论与 merge readiness 分开。

对主干的风险 / Risks

最强回归反例是 输入进展立即使旧 no-op 缓存失效,静止输入保留 backoff,不可信 token 不积累长退避。 无法成立。对照的旧行为为:base 在 turn/session/events 更新后的第 5 秒仍无候选;不可用 token 的第二次 no-op 仍增长。新行为为:head 在三类 native 文件更新后均立即有候选;不可信 token 回到 60 秒;静止输入和原两个文件变化行为保持。。这些观察支持有意差异,同时保留负例边界。回退该局部逻辑无需持久状态迁移。

实际文件系统、ChatSessionStore、discovery/reconcile 已运行;probe 的 Core 恢复结果和 monotonic 为受控替身,不证明真实 provider、Lark 发信或 Windows;None token 是不可信分支模拟。没有组件、网页首屏或 Lark 消息内容改动,故截图不适用;真实服务和平台限制仍保留,不能从本地构建或模拟恢复结果推出已上线资格。

我的整体评价 / Verdict

APPROVE,当前 head 未发现新增阻断缺陷。复用 optional_file_fingerprint、ChatSessionStore 的既有三个路径 helper 和原恢复候选队列;五个 token 是进程内失效提示,实际是否恢复仍由 Core 决定。本 PR 只修正 no-op backoff 的输入身份和不可信 fingerprint 降级,不改变持久状态格式、Core 恢复决策或消息内容。真实输入推进后及时重试原恢复 owner,同时保留静止输入的退避,避免把新进展误当成旧 no-op。stat token 不可信时只维持 60 秒普通探测。这是一项有实际调用者和独立正反例的有限修补,避免为局部恢复问题扩展新的公共协议或状态 owner。

四文件 pytest 共 606 passed(1 条非失败 collection warning),14 个同 fixture base/head 对照通过,Ruff 与 standard premerge 全部通过。不重写 Core 恢复结果协议、不承诺 route fence 或 quota 在文件不变时也会即时唤醒,不改变 Lark 发消息权限,不声称真实 Lark 客户端、Windows 或生产服务已升级。进一步跨 owner 重构和真实服务升级应沿已有验收与权限边界,不因本次 review 自动获得资格。

English verdict: APPROVE — f9128ba; the bounded recovery change is supported by base/head counterfactuals and preserved authority boundaries. Live deployment and the explicitly untested platforms are not qualified by this review.

@huangruiteng
huangruiteng merged commit 1df9dfc into main Nov 20, 2026
35 of 45 checks passed
@huangruiteng
huangruiteng deleted the cursor/reset-noop-recovery-backoff-6db6 branch November 20, 2026 07:15
@loopx-agent

Copy link
Copy Markdown
Collaborator

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

合并后补审

[P2] 恢复过程中更新的输入不应进入旧退避

Core 核对原消息时发现 Session 已更新,当次返回原请求。Lark 随后才采样指纹,把新的 Session 当作刚刚检查过的版本记入退避。下次比较看到同一新标记,就保留旧截止时间。实际本地入口在第 5 秒能读到 Core 仍认定可恢复,但 Lark 到第 60 秒才重新发现。同样结果出现在当前主干 d400a9c。这次恢复被延迟,原请求、模型启动次数和投递记录保持原样。记录退避的位置 调用位置

建议比较尝试前后的输入标记,仅在可信且相同的情况下累计空操作退避。回归用例在真实 source verification 与 Core 返回之间更新原 Session,断言下一轮扫描重新列出候选,并用静止输入对照确认退避保留。

动机 / Motivation

Lark 私聊中的用户已经收到一次失败通知,后台等原会话的条件改变后恢复处理。 过去,旧探测只比较投递回执和请求日志。现在会话、Turn 或事件文件在一次空操作之后变化,也能使下一次扫描立即重新考虑原请求。 静止输入保留退避,可信输入在恢复返回后变化会提前重新入队,无法取得可靠文件标记时保留普通探测周期。 本次补审覆盖 Lark 恢复候选扫描,以及 Core 拒绝过时会话证据后的重新发现。
若会话在恢复过程中推进,新输入会被误记为本次空操作已经检查过的版本,下一次扫描仍需等完整探测周期。

改动思路 / Approach

沿用原 Lark 退避表和 Core 恢复判断。五条现有文件路径的标记只用于判别缓存失效。需将空操作与它实际检查的文件版本关联,扫描才可区分静止与已推进输入。 Lark 私聊投递发现、Core 原消息核验、结果传递至该进程内退避表。

具体改动 / Changes

精确提交 f9128ba,目标基点 cc5392e。该退避窗口没有单独发布的接受规格,以 PR 自述的用户可见目标及原 Core 回收边界核验。

关键代码讲解

新增 _context_recovery_fingerprints 组合五个已有来源。缺可信标记沿用 60 秒探测。pending_delivery_paths 只在下次输入不同于保存标记时清期限。原成功、静止、来源更新和拒绝验证均保留。基线、评审提交和当前主干均在恢复期间更新 Session 时表现出相同的等待。补丁已覆盖恢复返回后的变化,恢复窗口内的变化需要单独核验。

对主干的风险 / Risks

精确提交 34 项目标测试通过。新增隔离用例在基线、PR 提交和当前主干稳定复现同一时序。 用真实本地恢复链路在原消息核验期间推进同一 Session。Core 丢弃旧观察,5 秒时仍可识别候选,Lark 扫描却等到第 60 秒才重新列出它。没有发新消息或开启新 Turn。 静止输入沿用指数退避。投递回执或外部请求在调用返回后更新时,扫描会使旧缓存失效。恢复授权和持久状态仍由原 owner 管理。 真实 Lark 服务、Windows 和远端 CI 未复验。

我的整体评价 / Verdict

改动不涉及网页或卡片布局。已核验真实本地 Session 存储、Core 路由与 Lark 投递扫描,外部客户端与账号均使用隔离替身。 建议在 Lark transport 内修正这一时序并复测静止与输入推进两条路径。

English verdict: REQUEST_CHANGES — An input revision that changes during recovery can remain hidden until the 60-second probe.

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