Skip to content

fix(bridge): deny deleting peer experts through the tunnel - #1862

Closed
fengyue-xve wants to merge 1 commit into
TencentCloud:developfrom
fengyue-xve:fix/peer-expert-delete-guard
Closed

fengyue-xve wants to merge 1 commit into
TencentCloud:developfrom
fengyue-xve:fix/peer-expert-delete-guard

Conversation

@fengyue-xve

Copy link
Copy Markdown
Contributor

Summary

Fixes #1849: in云端协同 mode, the hub's 「专家」 module could delete a peer (bridge) expert.

Two layers caused it:

  1. Tunnel policy let the delete through: DELETE /api/agents/{id} matched _AGENT_RESOURCE and was tunneled to the peer, where it ran as the connection owner — the peer-side owner check (_assert_agent_owner) cannot stop it, because the request identity is the owner themselves.
  2. UI offered the affordance: list_remote_agents maps bridge shadow experts with is_owner: true, so the delete button rendered for them too.

Changes:

  • tunnel_policy.py: deny tunneling a bare agent-resource DELETE /api/agents/{id} (local or bridge: shadow id). Agent sub-surfaces (threads / files / avatar / skills / …) stay deletable, and editing (PATCH /api/agents/{id}) still tunnels.
  • Dashboard: AgentExpertsTable and AgentCard hide the delete button for bridge experts, with a new render test (AgentExpertsTable.bridgeDelete.test.tsx).

Target branch

  • Base is develop (feature / fix — default)
  • Base is main (release/* or hotfix/* only)

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactor / chore
  • Release / hotfix

Test plan

  • Added/updated tests:
    • tests/unit/bridge/test_tunnel_policy.py — new test_denies_deleting_the_agent_itself: bare DELETE (local id, bridge: id, trailing slash) denied; sub-path DELETE and PATCH still allowed. Ran locally: 7 passed.
    • dashboard: AgentExpertsTable.bridgeDelete.test.tsx renders a local + a bridge expert and asserts exactly one Delete button remains (the local row). Ran locally with vitest: 1 passed.
  • make all passes locally — ran the targeted backend test module, ruff (check + format), and the targeted vitest file; full CI will cover the rest.

Checklist

  • Updated CHANGELOG.md (if user-facing)
  • README / docs updated (if needed)

@fengyue-xve
fengyue-xve force-pushed the fix/peer-expert-delete-guard branch 2 times, most recently from 22ff4cc to 4231dd1 Compare October 10, 2026 08:06
DELETE /api/agents/{id} was tunneled to the peer and executed there as
the connection owner, so the peer-side owner check could not stop the
hub's experts list from deleting a peer's expert. Reject bare
agent-resource DELETEs in the tunnel policy and hide the delete
affordance for bridge experts in the experts table and card.

Fixes TencentCloud#1849
@fengyue-xve
fengyue-xve force-pushed the fix/peer-expert-delete-guard branch from 4231dd1 to fe9f091 Compare October 10, 2026 08:08
@jubaoliang

Copy link
Copy Markdown
Collaborator

GitHub PR 提交规范

✅ PR 必备清单

1. 📸 提供视觉证明(截图/录屏)

必须贴截图,无论放在 PR 描述中还是评论里——让 reviewer 看到"人",证明是经过人工检查、用心完成的。

2. 🧪 测试用例完整 & CI 通过

  • ✅ 新增功能 → 新增对应测试
  • ✅ Bug 修复 → 添加回归测试
  • ✅ 所有 CI Workflow 必须通过 → 不要期望 reviewer 去 fix 你的 CI

3. 🔄 与 AI 协作:确认理解一致

  • 需求明确后,让 AI 重复一遍需求,确认理解无误
  • 代码生成后,主动追问:
    • "这个实现是否满足所有需求点?"
    • "是否有遗漏的场景?"

4. 🎯 代码质量:最小修改 & 追问优化

  • 坚守最小修改原则,一个 PR 只解决一个问题
  • AI 生成代码后,必问:
    • 是否还有优化空间?
    • 所有异常是否妥善处理?
    • 是否有冗余代码?

📋 Quick Checklist(可直接放进 PR 模板)

- [ ] 📸 已提供 UI 截图/功能演示
- [ ] 🧱 测试用例已添加并通过
- [ ] ✅ CI Workflow 全部通过
- [ ] 🤖 已与 AI 对齐需求理解
- [ ] 🎯 遵循最小修改原则,代码结构清晰
- [ ] 📝 已询问并处理代码优化建议

核心原则:PR 是沟通,不是交接。让 reviewer 轻松,就是让自己更快合入。


🔍 本 PR 自动检查发现的问题

  • ❌ CI Workflow 未通过:当前存在失败的 check,请先修复到全绿
  • 📸 本 PR 涉及前端改动,但描述中未提供截图/录屏等视觉证明

以上为 automated 检查提示,请补充后 @ 我重新评审。

@jubaoliang jubaoliang closed this Oct 21, 2026
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.

2 participants