Skip to content

feat(v3): 房间事件通道归属 source:"room" → user="Room"(不再冒充 Codex)#203

Open
raysonmeng wants to merge 1 commit into
feat/v3-web-dashboardfrom
feat/v3-backlog-room-source
Open

feat(v3): 房间事件通道归属 source:"room" → user="Room"(不再冒充 Codex)#203
raysonmeng wants to merge 1 commit into
feat/v3-web-dashboardfrom
feat/v3-backlog-room-source

Conversation

@raysonmeng

Copy link
Copy Markdown
Owner

摘要 / Summary

房间事件不再冒充本机受信 Codex:经独立 source:"room" 渲染成 user="Room"(而非 user="Codex"),让通道层框定本身就标「外部不可信」。修安全 review 抓出的 MEDIUM(channel 归属混淆)。

⚠️ 请勿合并 / DO NOT MERGE —— 试用期。base = feat/v3-web-dashboard(backlog sibling)。

变更 / Changes(commit 1b83214

  • types.ts: MessageSource += "room"
  • daemon.ts: systemMessage 加可选 source 参(默认 "codex"),仅房间事件注入用 "room"(其余十余处 system 消息字节不变)
  • claude-adapter.ts: pushViaChannel 按 source 分支 user/user_id/source_type(room→Room/room/room);formatSource room→"Room"drainMessages 批头按实际 sender 归属(codex-only from Codex 不变 / room-only from Room / mixed from Codex/Room);CLAUDE_INSTRUCTIONS + get_messages desc 补 room 不可信说明
  • 出站 source 守卫对 "room" 天然 fail-closed(强化防回环)

测试 / Test plan

  • bun run check 全绿(1856 pass);新增 message-delivery 测试覆盖 room/codex/mixed 三路 + v1 回归
  • Cross-review:opus 深审 v1 流不破 + 3 轮(连续两轮 0 真实 issue 收敛

v1 单机流不破(实证)

Codex 消息仍 user="Codex";所有非房间 systemMessage 默认 "codex"handleReply 硬编码 source:"claude"——无任何非房间消息会拿到 "room"

🤖 Generated with Claude Code

房间事件经 daemon systemMessage 注入时硬编码 source:"codex",被 MCP 通道渲染成
user="Codex"——与本机受信 Codex 搭档同一身份标签,误导。改为独立 source:"room"
→ user="Room",使通道外层框定本身就标不可信(内层 UNTRUSTED 文本前缀保留,双重框定)。

- types.ts: MessageSource 加 "room"(纯通道归属,不参与 reply/forward 路径)
- daemon.ts: systemMessage 加可选 source 参数(默认 "codex"),仅房间事件这一路
  stamp "room";其它 system 消息(ready/waiting/turn_aborted/budget resume)不变
- claude-adapter.ts pushViaChannel: 按 message.source 分支 user/user_id/source_type
  (room→Room/room/room,其余维持 Codex);formatSource 加 room→"Room";fallback
  drain body 改用 formatSource(msg.source) 避免房间事件误标 "Codex:";MCP 工具说明
  补 user="Room" = 房间外部不可信通报的契约段
- 不破坏 v1 单机流:Codex 搭档消息仍 source:"codex"/user="Codex"(已加回归测试)

Make room events use a distinct source:"room" → user="Room" so the channel
label itself frames them as untrusted external input, instead of borrowing the
trusted local Codex partner's user="Codex". The inner UNTRUSTED text prefix is
kept (double framing). systemMessage gains an optional source param (default
"codex"); only the room-event path passes "room". pushViaChannel/formatSource/
fallback-drain branch on message.source; the v1 single-machine Claude↔Codex flow
is unchanged (regression-tested).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012rhWKm1VUSnEVxmjpYwNfc
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.

1 participant