关系网注入分档恢复 + lookup_relation按需工具 + 独立封顶 #119
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/114-relationship-injection-tiers-and-cap"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #114
做了什么
一、恢复注入分档
_full_frozen_snapshot/_run_event_driven_turn两处每轮自动查询隐式同群/同事件共现——2026-07-13 那次"修复漏实现"更新把 ADR-0008 原定的"按需"档误做成了"每轮自动",诊断出_run_event_driven_turn那个调用点当时就已经是空转(sender_ids至多 1 个 id)。gather_implicit_relations已无生产调用方,直接删除;render_relationship_snapshot的implicit_pairs参数与implicit_lines渲染段同步删除。lookup_relation(user_a_id, user_b_id):恢复"同群按需"这一档,不经工具港、计入run_limit、恒可见(不受能力位/渐进解锁门控)。知情-gate(is_relationship_edge_visible)同样接入——主动工具调用不能绕过被动注入已经守住的敏感数据闸,命中但不可见时退回隐式判断而非报错/泄漏。gather_relationship_edges拉取逻辑本身一行未改。二、独立封顶
arise_max_relationship_lines_per_turn(默认 10),只接在render_relationship_snapshot——在知情-gate 过滤之后截断显式边渲染行数。两轴 review 抓到的一处真实 bug(已修复)
最初实现里
gather_relationship_edges也独立截断了一次(同一个 limit),但它不知道current_chat_id,没有能力过滤可见性——两层截断复合后,一条对当前 chat 不可见的边可能在 gather 层就抢占了截断名额,导致最终渲染的可见边数少于上限,即便系统里还有更多真正可见的边。这正是"独立封顶"这条 AC 本身警告过要避免的不确定性("封顶多少条取决于恰好有多少条不可见"),只是发生在 gather 层而不是最初以为的 render 层。修复:截断只在
render_relationship_snapshot一处进行(唯一知道可见性的地方),gather_relationship_edges只负责拉取+去重。新增端到端测试test_invisible_edges_do_not_steal_the_cap_from_visible_ones复现并钉住这个场景——只有跑完整 gather→render 流水线才能抓到,单独测任一函数都测不出。其余 3 处修复:
_handle_lookup_relationdocstring 误称与自动路径"共用存储读取"(实际是不同存储方法);两处弱断言!= "同事"改成精确==;user_a_id/user_b_id的类型校验从静默str()强转改成isinstance显式拒绝非字符串,同_sanitized_query_arg/_handle_update_profile既有模式。测试
Test plan
uv run pytest全量通过uv run ruff check干净docs分支本地提交(不推送)