Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves topic routing for agent-initiated Feishu sends by resolving topic IDs into native reply anchors. Example: A scheduled send targets the session for topic omt_19dfad8930cf5ce6.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a current Feishu proactive-delivery bug, with no introduced correctness or security blocker found; exact-head CI remains pending. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Feishu plugin translates session and delivery thread identities into provider reply requests for outbound text, media, payloads, and message actions. flowchart TD
A[Topic session] --> B[Delivery route]
B --> C[Feishu outbound adapter]
D[Message action] --> E[Topic anchor owner]
E --> F[Sender authority scope]
C --> F
F --> G[Topic root lookup]
G --> H[Feishu threaded reply]
Technical reviewBest possible solution: Land the focused proactive-routing repair through the existing Feishu routing and authority owners while leaving inbound session identity to separate work. Do we have a high-confidence way to reproduce the issue? Current-main source exposes both missing steps: session conversation projection omits the topic thread ID, and sends without a native inbound anchor cannot resolve an omt_ topic into an om_ reply target; contributor live readback corroborates the failure. Is this the best way to solve the issue? The patch repairs the plugin-owned session projection and send boundary, preserves native anchors and routing guards, replaces the existing outbound wrapper, and avoids rekeying sessions or adding public configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ed51affd7873. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +221, Tests +419, Other -1. Total +639 across 15 files. Added test files: 4. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (13 earlier review cycles; latest 8 shown)
Reviewed October 31, 2026, 10:31 AM ET / 14:31 UTC (Revision 14). |
|
Reworked the patch; the PR body now describes the new design. Point-by-point: [P1] Preserve stored topic sessions when changing the key — fixed. The session key no longer resolves anything: [P1] Keep the session key stable through lookup failures — fixed. There is no lookup on the key path any more (the inbound Where the topic→message mapping went. A Feishu reply addresses a message, not a topic, so that conversion now happens at the send boundary: Proof status. Added a live-API trace to the PR body (real credentials, read-only, ids redacted) showing the topic resolving to its reply anchor and the starter/quote-reply pair landing in one session, plus Also flagging one deliberate expectation change from the rework: 中文摘要:两条 P1 都已修复——会话键改为直接取事件里的 |
|
Revision 3 pushed ( [P1] Failed lookup changes delivery — fixed. [P1] Existing-session upgrade / quote-reply key continuity — decided and documented. A topic's key is now the event's [P1] After-fix delivery proof — added, and it found a real gap. I patched the local install, restarted the Gateway, and gave a topic session a proactive delivery with no inbound message (
The missing piece is now fix #3 in this revision: core derives proactive delivery from the session key and asks Checks (this revision): feishu shard 98 files / 1544 tests passed; Remaining gap: an inbound→reply round trip with a real user message was not run — the local CLI token lacks 中文摘要:第 3 版已推送。评审两条 P1 均已修(查询失败保留 target、升级键延续给出明确决策);并按评审要求做了真机验证——发现并补上了最后一个缺口: |
41eef04 to
e82021a
Compare
|
CI analysis and fixes (force-pushed as
Local verification of the same gates: 中文:CI 两处失败分别是 knip 死代码(该解析函数只需模块内私有)与断言安全 ratchet(去掉一处断言、另一处补 |
7d32e05 to
e0cfe34
Compare
|
Addressed the remaining P2/security-boundary finding: the topic lookup now runs inside @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Run the production outbound adapter and message action against the real Lark SDK over a loopback server. Allowed calls issue auth -> topic lookup -> threaded reply; retiring the sender while the auth request is held produces zero HTTP requests and rejects before dispatch.
|
Added the requested real-transport authority proof. The production outbound adapter and message action now run against the real Lark SDK over a loopback server: allowed calls show auth → topic lookup → threaded reply; retiring the sender while the auth request is held produces zero HTTP requests and rejects before dispatch on both paths. The PR body's Evidence section records both cases. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Dropped the mock-only wrapper test; the production-adapter transport cases now carry the resolved-anchor and retirement coverage. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Related: #160330 (proactive-delivery half)
What Problem This Solves
In a Feishu topic chat, an agent-initiated send — heartbeat, scheduled job, message tool, sticker — posted a top-level message. In a topic chat a top-level message creates a new topic, so replies drifted out of the discussion and the session's context no longer matched the visible thread.
Two independent gaps caused it:
session-conversation.ts).om_…), never a topic (omt_…). Even when the target carried a topic id, the send path had no way to turn it into a reply anchor.What Changed
session-conversation.ts:40— topic-scoped session keys now reportthreadId = topic id; ordinary group/direct sessions keepundefined. Core can therefore derive a topic delivery target from the session key.send.ts:366-460— newresolveFeishuReplyAnchorMessageId: mapsomt_…to the topic's oldest message (im.message.listwithcontainer_id_type=thread,sort_type=ByCreateTimeAsc,page_size=1), cached peraccount:topic(512 entries; topic order is immutable). Message ids pass through without a lookup. A failed lookup keeps the topic id so the send owner still refuses an unsafe top-level fallback.topic-anchors.ts:35-72— the action path (message tool, sticker, cron/heartbeat-driven tool sends) resolves the session topic to that anchor when there is no inbound native message. Existing guards are preserved: opt-outtopLevel/threadId:null, requester account must equal the sending account, provider must be Feishu, and the session chat must equal the requested destination.outbound-send-anchor.ts— wrapssendText/sendMedia/sendPayloadso every outbound send resolves its topic target before replying;outbound.tsuses it in place of the pure send-context wrapper.channel.ts:1514— declarespreserveHeartbeatThreadIdForGroupRoute: true(Telegram precedent) so a heartbeat reuses the session's recorded route thread id.action-target.ts— owns the action target/message-id helpers and resolves the action's anchor insidewithFeishuSendContext, so the credentialed topic lookup is fenced by the sender scope. Extracting it also keepschannel.tsunder its line-cap ratchet.channel-runtime-loader.ts— one lazy loader shared by the plugin entry and the topic-anchor owner (replaces the local loader inchannel.ts).Scope: session identity is not rekeyed
This revision does not change how inbound messages key sessions. Feishu's message-receive event reports
chat_typeasp2p/group(nottopic_group), and distinguishing native topic chats from ordinary group threads requireschat_modefrom the chat owner. Changing that is a separate owner decision; existing session keys stay byte-identical. This PR fixes the proactive-delivery half of #160330, which is what the live evidence covers.Evidence: real Feishu proof (2026-10-31)
A private topic chat was created through the bot API (
oc_3abd…854d); root messageom_x100b616a25df…→ threadomt_19806e78…. The rebased checkout ran against the real Feishu API with this app's credentials. Ids are shortened; no credentials or message content beyond test markers.resolveFeishuReplyAnchorMessageId({ threadId: "omt_19806e78…" })om_x100b616a25df…(topic root)resolveSessionConversationforfeishu:group:oc_3abd…:topic:omt_19806e78…threadId = omt_19806e78…send(message-tool shape, no inbound message)om_x100b616a37ff…→ same threadomt_19806e78…sendTextwiththreadId = omt_19806e78…(heartbeat shape)om_x100b616a323f…→ same threadomt_19806e78…om_x100b616a3493…→ new threadomt_19806f6c…Readback:
lark-cli im +threads-messages-list --thread omt_19806e78… --as botlists the root plus three replies;+chat-messages-listshows one non-system topic for the session, while the unanchored send created a second topic. The topic chat is a temporary test fixture created solely for this proof; it is independent of the patch and its messages/chat are not modified by this PR.A real-transport authority proof runs the production
feishuOutbound.sendTextand message-action paths against the real Lark SDK over a loopback server:POST auth→GET /im/v1/messages(topic root) →POST /im/v1/messages/om_topic_root/replywithreply_in_thread: trueVerification
vitest run --config test/vitest/vitest.extension-feishu.config.ts→ 93 files / 946 tests passed.threadIdand heartbeat flag (2). These tests cannot pass onmain— the resolver, wrapper,threadIdfield and heartbeat flag do not exist there.tsc -p tsconfig.extensions.json --noEmit→ no errors inextensions/feishu(tsgo is blocked on this host by glibc 2.32–2.34).Review notes
withFeishuSendContexton both the outbound wrapper and the action path, soclient.tscaptures the sender scope and revalidates cancellation/handoff immediately before the credentialedmessage.listrequest. The lookup uses the sending account's configured client (createConfiguredFeishuClient({ cfg, accountId })), the cache key includes the account, and the action path still requiresrequesterAccountId === accountIdplus destination-chat equality before inferring an anchor. A real-transport test retires the sender while the auth request is held and asserts zero HTTP requests for both production entry paths.message.listper topic, then replies reuse it.im.message.list) and reuses the existing threaded reply path. It does not recall messages, update/delete chats, or add scopes, permissions, config or SDK surface.Gaps
im:message.send_as_user. Inbound session identity is unchanged by this PR and covered by the existing channel-boundary tests; the live proof covers the changed path — agent-initiated sends.中文摘要
本版修复飞书话题群里「智能体主动发送(心跳 / 定时 / 工具)会新开话题」这条路径:会话键向 core 上报话题 id,发送边界再把
omt_…解析成该话题最旧的一条om_…消息作为回复锚点(按账号 + 话题缓存;查询失败保留话题 id),并让心跳复用会话记录的 thread id。入站会话键不变。真实飞书话题群已验证 action 与 outbound 两条主动发送都落回原话题,而未加锚点的发送会新建话题。