Repository navigation
refactor(lark): read the event-line prefixes from their owner - #7589
Conversation
`event_collector_runtime` already parsed the provider's stdout lines by their prefix, but `goal_topic_runtime` and `team_plan_confirmation` compiled the same two bodies locally. Both consumers now import `EVENT_READY_PREFIX` and `EVENT_DIAGNOSTIC_PREFIX` from the owner, and an architecture census rejects a new local copy. The wire values are unchanged. The `"[event] exited "` token stays local: it has one consumer and a paired reason regex in the same block. Signed-off-by: CTYQAQ <135084081+CTYQAQ@users.noreply.github.com>
c8c9f18 to
351412e
Compare
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
未发现当前精确 head 351412e 的阻断问题,结论为 APPROVE。
动机 / Motivation
维护 Lark 消息和团队计划回调监听器的开发者。
同一提供方的就绪与诊断行前缀原来分散在三个模块;现在两个监听器读取既有共同定义,原就绪判断、消息路由和失败恢复保持。
已验证真实子进程事件流的就绪、断线和回调恢复不变,并删除三处重复字面量。
本次不改变 Lark wire format、身份权限、回调批准权或外部消息发送。 基线已有正确wire值;本次价值在于消除会随格式更新漂移的重复知识,不冒称修复了线上事件丢失或完成了真实账户接入。
改动思路 / Approach
这两个值是既有提供方 stdout framing 的知识,复用现有 event_collector_runtime 即可;路由、确认与重试继续由原 owner 决定。
本 PR 完成既有两个监听器的前缀归一及相称回归,不增加状态、provider 或第二个解析器。
最小方案正是从已拥有相同值的模块导入,而不是新建protocol模块、listener或配置。消息流仍先识别ready,再识别exited,最后忽略一般diagnostic;team-plan回调仍先忽略diagnostic,再解析JSON/schema及交给原handler。单消费者exited字串及reason regex留在其原逻辑块合理,无需把相邻内容都抽走。这个直接关系用文字足够,不额外绘图。
具体改动 / Changes
没有针对本次常量整理的独立书面规格;依据明确的维护结果和原消费者行为验证,不把作者新增census当作规范。不可变比较基线为 b6db7f7。完整3文件 +64/-6:两生产文件 +5/-6,新增架构测试59行。既有event_collector_runtime本身未改,导入依赖和实际消费者均已检查。
关键代码讲解
- EVENT_READY_PREFIX / EVENT_DIAGNOSTIC_PREFIX 是原提供方framing定义;字符串值未变。它们只描述stdout行,不能授予消息执行、批准或发送权限。
- stream_lark_goal_topic_profile 保留profile选择、ready先于diagnostic的顺序、事件分发与最终close/wait。子进程存在不能当作就绪;signal或未知退出仍由原逻辑报source_disconnected。
- start_team_plan_review_callback_stream 保留绑定chat的过滤、schema检查和handler异常隔离;只是消费共同diagnostic前缀,没有新decoder或持久状态。
两生产文件在移除明确的常量赋值/import差别并归一私有别名后,其余AST完全相同。新增测试做有界literal普查和对象来源断言;它只能覆盖所枚举的字面写法,不能独自证明所有等价拼写或真实运行。
对主干的风险 / Risks
最强反例是ready被更宽diagnostic前缀吞掉,或诊断/回调错误阻断后续消息。独立19场景在不可变base与当前head完整相同:17条真实子进程/stdout链、2条无配置不启动控制,涵盖ready有无、真实未匹配业务事件、四类退出、非法JSON/schema、handler首次拒绝后的合法后继及线程/子进程回收。保留完整健康变化、返回值、输出、callback正文和argv,无归一化。provider内容与handler是合成边界,没有连接真实Lark或调用模型。
在导入消费者前故意更换共同ready值,四个仅凭ready就绪的独立oracle失败,而当前head通过;不能只凭对象相等或census绿灯断言重构等价。实际callback首次handler拒绝后第二条仍被处理,close后线程结束且子进程已reap。
PASS:十个相关/架构模块479项,零skip;不可变base六个旧相邻模块236项。Ruff、配置17文件mypy、完整TS typecheck、diff/DCO/双语差分通过。标准premerge 6项direct与10项selected全部通过,无失败/跳过/人工hold;精确CQR有效。未查询或等待CI。
作者已披露长回传测试历史一次失败。本轮当前完整模块通过,另对同一具名case在base/head各运行3次均通过,原测试与处理逻辑未变;这不能改写旧失败或认证长期flake已修复。没有用放宽断言、删除有效覆盖或只保留最后一次成功来取得资格。
语义与 CI 对齐
复用既有Lark provider语法,不新增Core状态词汇、权限或默认listener。机器判断及原异常恢复仍是原逻辑,不把硬行为称为可选建议。差分语义advisory无支持的新carrier,真实stream对照及mutation才是本次行为证据;更广的身份/确认/持久作用域由原owner与现有测试保持。
我的整体评价 / Verdict
APPROVE,当前维护结果完整且相称。long_horizon 与 user_experience 均为 preserved:真实管道的错误恢复、后续callback和回收不变,原用户不增加配置、复制或确认步骤。移除重复知识有明确消费者,不靠PR或测试数量证明长期收益。
这两个值是既有提供方 stdout framing 的知识,复用现有 event_collector_runtime 即可;路由、确认与重试继续由原 owner 决定。 本 PR 完成既有两个监听器的前缀归一及相称回归,不增加状态、provider 或第二个解析器。
有界整理已应用,单消费者exited块保持原位,不需要额外框架或人为后继。已检查 Lark 消息与回调的现有入口;仅改变内部常量来源,没有卡片、页面或布局变化,视觉评审不适用。 真实 Lark 网络与个人账户、正式安装、原生 Windows 和长期运行未在本轮验证。 本评审不认证上述外部采用,不授予合并、外发或安装权限。
English verdict: APPROVE — 351412e. All19 real-pipe scenarios match the immutable base; a ready-prefix mutation fails four independent cases. 479 Python tests, static checks, standard premerge and exact-scope CQR pass. The disclosed historical timing failure and live-provider qualification remain separate.
Goal And Delivered Outcome
loopx/extensions/lark/event_collector_runtime.pyalready read the provider's stdout lines by these prefixes, so it is the owner the other two sites now import from.goal_topic_runtime.py(_EVENT_READY_PREFIX,_EVENT_DIAGNOSTIC_PREFIX) andteam_plan_confirmation.py(_EVENT_DIAGNOSTIC_PREFIX) compiled the same two bodies locally. A wire-format change had three sites to find, and nothing failed if one of them drifted.loopx/**/*.pyfinds"[event] ready "in 2 modules and"[event] "in 3 before, and only in the owner after; re-adding a local copy failstest_only_the_owner_states_each_event_line_prefix.mainat53dcb03082985bf894b1fca8813ab9f6e92503c5.Author Declaration
Implemented against
53dcb03082985bf894b1fca8813ab9f6e92503c5.event_collector_runtime.EVENT_READY_PREFIX,.EVENT_DIAGNOSTIC_PREFIXloopx/**/*.pygoal_topic_runtime,team_plan_confirmationtest_every_consumer_holds_the_owners_object"[event] exited "token into the owner toogoal_topic_runtime._EVENT_EXIT_REASONScope And Continuation
Validation
staticpassedpython -m ruff checkon the two changed files and the new guardunitpassedtests/extensions/test_lark_goal_topic_runtime.py,test_lark_realtime_dispatch.py,test_lark_event_collector_runtime.py— 128 passedunitpassedtests/extensions/test_lark_team_plan_confirmation.py— 6 passed;tests/test_steward_team_plan_preview.py+tests/architecture/test_lark_identity_shape_owner.py— 102 passedunitpassedtests/test_lark_private_conversations.py— 234 passedregression_paritypassed_EVENT_DIAGNOSTIC_PREFIX = "[event] "inteam_plan_confirmation.pyfails the census (1 failed, 1 passed); restored tree passesintegrationpassedtests/architecture/test_top_level_module_budget.py+tests/test_stage2c_dependency_lock.py+ the new guard — 9 passedb6db7f7c415b356ac94ebfc643977d381a314eb9after submission; the branch patch-id is unchanged (afe06181…), and the suites were re-run on the rebased tree (245 passed together). The first rebased run oftests/test_lark_private_conversations.pyreported 233 passed + 1 failure intest_app_long_return_keeps_all_parts_and_does_not_repeat_identical_parts; a repeat run of the same file passed 234/234, that case passes 3/3 in isolation, and no commit in the rebase range touchesloopx/extensions/lark/or that file. It is a pre-existing timing flake, also red in the 2026-10-27 scheduled run onmain(run 40604536330).Frontend / Visual Evidence
N/A — no user-visible surface changed.