Repository navigation
perf(lark): batch source reads for completed stop receipts - #6670
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent — gpt-6.1-sol / OpenAI; runtime_reported; reasoning_effort=max.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
准确 head:7c601a2844a842adde522e558ee4ba95da9a9d9e。全量差异评审未发现本次范围内的阻断问题。作者与评审来自同一执行 Agent,这是公开自评,不冒充独立同事或 GitHub 正式自批。
动机
群话题中发出停止请求的成员。成员停止一个正在执行的话题后,旧路径先后读取停止消息和已准入的话题根;候选仅在 Core 已完成且冻结目标后合成一次读取。原话题停止回执的来源校验少一次串行网络读取,仍保留两次新鲜身份核验。
三组交替的同一真实来源只读样本中,来源校验中位数从 5.92 秒降到 3.74 秒,完整校验结果一致。这说明去掉串行读取有具体价值;样本不足以证明分位数或整条链路时延。本 PR 不宣称整条停止链路已达到 5 秒,也不关闭实际宿主取消、网页时效或社区准出验收。完整安装态停止回执、物理终止、新 Turn 竞争及网页最终态仍待原社区试点验收。
改动思路
同一适配器保留一份来源与权限判定,只把已经绑定的两个提供方读取合批;不新增缓存、权限 owner 或持久状态。当前 PR 只交付已完成停止回执的来源读取优化和现有安全边界回归,整条试点准出留在原验收工作中。
| 输入状态 | 原版 | 候选 |
|---|---|---|
| 已完成、目标冻结且身份/来源匹配的群停止命令 | 读停止消息,验证后串行读根消息 | 精确合批这两个已绑定 ID,再执行同一判定 |
| 普通、状态命令、缺失或冲突的 Core 证明 | 来源优先,再判断根 | 保留原路径 |
| 根提及、发送者、App 或来源变化 | 拒绝原回复,保留原记录 | 同样拒绝;恢复后原路一次回复 |
不改动会继续保留实测串行成本;缓存身份会削弱下一次检查的真实性。把所有根消息都提前读又会扩大未准入输入的读取范围。因此在当前适配器限定这个已完成命令的批读,比新增通用缓存或把提供方 IO 搬进 Core 更合适。Core 仍决定停止对象,Inbox 仍负责真实发送、读回与未知效果恢复。
具体改动
规格:docs/development/testing-and-quality.md,固定修订 a7da3af6a5d7e9cbf75bd9a44bee26242a746c7d,按Roadmap-Aligned Optimization逐项核对。社区 Topic/stop/replay 接受标准作为原父任务的后续实体验收,未降级。
| 规格项 | 本 head 的判断 |
|---|---|
| Locate the cost before selecting an abstraction | implemented:同来源交替对照与实际 Python 进程等待采样;不把进程等待解释为提供方 CPU 根因 |
| Share contracts, qualify implementations | implemented:保留 Core、绑定、Inbox 单一判定 owner;真实 raw mget 核对完整字段;原生入口五组对照 |
| Treat migration as a hypothesis, not a cause | out_of_scope:没有状态迁移或提供方切换 |
| Qualify the intended outcome | implemented:原始来源组件与真实 Core/回执入口分别验证,完整停止 SLA 继续未资格 |
| Keep the delivered boundary honest | implemented:仅认定组件优化,已有试点继续承担安装、终止、网页和完整准出 |
关键代码讲解
_completed_stop_sources只向现有 App 发出一个含两个 ID 的 raw mget。必须恰有两个 mapping、字符串 ID 集合与请求完全一致;缺失、重复、额外项、畸形 ID 和提供方错误都返回失败,不补读更广来源。_source_message从现存 Core 完成状态、冻结标记、binding/source/request 关系推导局部资格。两次身份观测仍独立新鲜;批读与第二次观测 join 后进入原有发送者、chat、类型、root/parent/thread 和根 @ 检查。没有新增可写布尔字段或权限缓存。reconcile_request是未改动的实际消费者。原终态先经_deliver的来源与提供方全文核验,再写回原记录。已验证的 attempt 继续防止重复效果;重新 admit 同一完成命令的原返回是command_recorded,后续 reconcile 可报告处理一行,却不会再发送,这一既有语义也已在两版对照中保留。completed-stop 测试经实际 native Core 建立冻结停止对象,检验一次批读、两次身份观测及后续根提及移除;补充六种 Core 证明、十三种来源/授权、六种提供方形状与独立观测 barrier。测试提供方与宿主是合成的,没有伪装成生产发送。相邻类型标注和 App-ID 正则直接引用原 owner,strict mypy 已清零。
对主干的风险
最强反例是事件伪造一个根、旧根 @ 或旧身份被缓存,而合批绕过当前权限。当前 head 先要求原 Core 的准确来源及冻结目标,后续仍使用同一来源判定;真实 raw mget 也已独立验证保留完整 ancestry、mentions 与 body,展示用 shortcut 未用于授权。缺证明的旧记录仍走原来源优先路径,因此安装回退不需要迁移记录。
最终 head 的三个相关模块共 247 tests 通过,46 项受影响/旧 provenance 检查也通过;Ruff、strict mypy、编译、公开边界及风险 premerge 的 5 direct+10 selected 检查通过。额外五组完整原版/候选适配器经 admit、原生 Core、reconcile_request、Inbox、终态读回与重复事件保持相同结果;来源/根/App/不完整数据故障恢复后只有一次消息及反应。实际终态入口的批读 oracle 在原版失败、候选通过。
早期 reviewer harness 错把既有 replay 返回值和 reconcile 处理行数当成新效果数;原失败保留,按未变的公开合同修正为同时核对原返回、冻结 target、无第二条消息/反应,没有删掉副作用断言。早期两个时延对照分别与观察/类型检查重叠,均保留但不计入本次独占采样结论。当前版本相关实现没有变更;最新 main 的相邻备份改动未触碰这些 Lark/native Chat 路径。
语义与 CI 对齐
本次复用既有 Core command/status/target、身份及 Inbox 词汇,没有新增 shared authority、schema 或状态 owner。semantic advisory 与完整树治理检查通过。当前 Goal 明确不查、不等待 hosted CI;不以远端缺少状态作为语义证据。真实提供方证据限于只读 source 组件;没有据此声称安装态、物理取消、更新的 Turn 竞争、网页最终态或完整社区 golden 已通过。
我的整体评价
justified_increment:本切口移除有对照证据的一次串行 IO,能从原回执消费者使用,单独可测试、可回退;没有理由为此新建状态、缓存、consumer 或让用户再做设置。long_horizon 为 preserved:原冻结目标、durable reply、拒绝后恢复和重放效果保持;user_experience 为 improved,明确只指同一来源校验组件减少等待且增加零个用户交互回合。
observable_semantics 为 intentional_change_validated:同一原生入口的结果、原 Topic、完整正文、目标与副作用一致,唯一有意变化是已完成命令的读取合批。change_proportionality 为 proportionate,architecture assessment 为 retain;没有独立默认开关或公开 actor 生命周期变化。完整端到端 SLA 和试点准出仍由原验收工作继续,不能把本 PR 合并或局部快了 36.8% 当作社区已准出。
English verdict: APPROVE - 7c601a2; batch only exact Core-completed target-frozen stop sources, retaining independent fresh identities and shared provenance checks. 247 tests, five native baseline/head refusal-recovery-replay pairs, a failing-before/passing-head public-entrypoint IO oracle, strict static/premerge checks and matched read-only Lark component evidence pass. Full installed stop/web SLA and production adoption remain unqualified.
Goal And Delivered Outcome
Completed group
/stopreceipts currently perform two serial canonical message reads to verify the command and its admitted Topic root. Batch those exact IDs only when the persisted Core request is alreadycommand_completed, its target is frozen, and its binding, source and request identity match the current transport record. Retain both fresh App identity checks and the existing sender, ancestry, root mention and grant validation.The bounded outcome is lower source-verification IO for this completed-stop path. In three alternating read-only pairs against the same real Lark source, the component median was 5.92 s at base and 3.74 s at this head (36.8% lower), with identical verified projections. This small sample does not establish end-to-end stop latency or a percentile SLA.
main; baselinea7da3af6a5d7e9cbf75bd9a44bee26242a746c7d.Implemented against
The narrow optimization request above is the implementation basis. The existing optimization evidence guide and community interaction acceptance provide the review frame (S5/S10).
_completed_stop_sourcesand Core-proof predicate; exact two-ID raw mget, two independent fresh identity observations, malformed/missing/extra-result rejectionScope And Continuation
Only the Lark conversation adapter and its synthetic regression tests change. Ordinary admission, unbound/legacy commands and other controls keep their source-first path. Raw provider mget preserves complete envelopes; partial or ambiguous results fail closed. Adjacent annotations and the direct import of the existing App-ID pattern make the touched adapter pass strict type checking.
The existing community pilot work retains packaged adoption, complete stop/termination/web timing, concurrent Topic safety and the full release pack. This independently reversible adapter slice needs no new setting, authority, schema, consumer or follow-up task. No developer-group promotion is requested.
Validation
7c601a2844a842adde522e558ee4ba95da9a9d9e.Earlier exploratory timings overlapped an observer or typecheck and are excluded from the reported controlled comparison. The initial typecheck failures were resolved; strict mypy is now clean. Profiling locates wall time in subprocess waits, not a proven provider CPU cause. No hosted CI is fetched or awaited under the current review policy.
Frontend / Visual Evidence
UI impact: none. No rendered content or interaction layout changes; screenshots are not applicable.
Type And Area
Performance fix and test update; Lark extension/runtime integration. Shared-authority migration fixture impact: N/A — no storage routing or authority change.
Boundary Checklist