Skip to content

refactor(lark): read the event-line prefixes from their owner - #7589

Merged
huangruiteng merged 1 commit into
loopx-project:mainfrom
CTYQAQ:refactor/lark-event-prefix-owner
Oct 29, 2026
Merged

huangruiteng merged 1 commit into
loopx-project:mainfrom
CTYQAQ:refactor/lark-event-prefix-owner

Conversation

@CTYQAQ

@CTYQAQ CTYQAQ commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

  • Outcome basis / optional anchor: no written specification; the request in this PR is the basis. loopx/extensions/lark/event_collector_runtime.py already read the provider's stdout lines by these prefixes, so it is the owner the other two sites now import from.
  • Goal/source and gap: goal_topic_runtime.py (_EVENT_READY_PREFIX, _EVENT_DIAGNOSTIC_PREFIX) and team_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.
  • Observable before → after, with the validation row that proves it: a literal census over loopx/**/*.py finds "[event] ready " in 2 modules and "[event] " in 3 before, and only in the owner after; re-adding a local copy fails test_only_the_owner_states_each_event_line_prefix.
  • Issue/task and intended base: no issue; base main at 53dcb03082985bf894b1fca8813ab9f6e92503c5.

Author Declaration

  • Written by: model_agent (Qoder); operator CTYQAQ

Implemented against

  • Specification and revision: no written specification; the request in this PR is the basis. The owner module and both parse blocks are read at 53dcb03082985bf894b1fca8813ab9f6e92503c5.
  • Criteria:
Criterion (spec clause) Disposition Symbol / path Test or command
each event-line prefix is stated once, in the owner implemented event_collector_runtime.EVENT_READY_PREFIX, .EVENT_DIAGNOSTIC_PREFIX literal census over loopx/**/*.py
every consumer holds the owner's object implemented goal_topic_runtime, team_plan_confirmation test_every_consumer_holds_the_owners_object
a new local copy fails closed implemented new census test mutation row below
fold the "[event] exited " token into the owner too out_of_scope goal_topic_runtime._EVENT_EXIT_REASON one consumer, paired with a reason regex in the same block; left for a change that needs it
  • Self-check before submission: read both parse blocks and preserved their branch order (ready, exited, then diagnostic); changed no wire value; ran the affected suites, the architecture gates and ruff; re-added a local copy to prove the census fails.

Scope And Continuation

  • Completed scope and remaining work: complete within this scope.
  • Slice boundary / successor: the exited token stays local per the out_of_scope row; no follow-up is needed unless that line gains a second consumer.

Validation

  • Tested revision: 351412e
  • Run state: finished
  • Input classes: synthetic, public_fixture
Check kind Result Public-safe evidence / limitation
static passed python -m ruff check on the two changed files and the new guard
unit passed tests/extensions/test_lark_goal_topic_runtime.py, test_lark_realtime_dispatch.py, test_lark_event_collector_runtime.py — 128 passed
unit passed tests/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 passed
unit passed tests/test_lark_private_conversations.py — 234 passed
regression_parity passed re-adding _EVENT_DIAGNOSTIC_PREFIX = "[event] " in team_plan_confirmation.py fails the census (1 failed, 1 passed); restored tree passes
integration passed tests/architecture/test_top_level_module_budget.py + tests/test_stage2c_dependency_lock.py + the new guard — 9 passed
  • Coverage and gaps: the changed blocks are the stdout line filters exercised by the goal-topic and collector suites; no new branch was introduced.
  • Rebase note: rebased onto b6db7f7c415b356ac94ebfc643977d381a314eb9 after 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 of tests/test_lark_private_conversations.py reported 233 passed + 1 failure in test_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 touches loopx/extensions/lark/ or that file. It is a pre-existing timing flake, also red in the 2026-10-27 scheduled run on main (run 40604536330).

Frontend / Visual Evidence

N/A — no user-visible surface changed.

`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>
@CTYQAQ
CTYQAQ force-pushed the refactor/lark-event-prefix-owner branch from c8c9f18 to 351412e Compare October 28, 2026 15:49

@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 · 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.

@huangruiteng
huangruiteng merged commit c61f867 into loopx-project:main Oct 29, 2026
2 checks passed
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