Repository navigation
feat(link-ref): 保证来源链接查询参数完整性 - #2035
Conversation
|
你好,这是自动评审的初步意见(最终以维护者审阅为准)。我本地已把该分支 rebase 到最新 master(1648f8ee0,仅本地、未推送),build 与 40 个相关测试文件(1129 例,含 Bun 1.4.3 ledger)均通过。以下几个问题建议修改: P2|enabled turn 初始来源零 URL 时,后续 MCP/工具结果永远登记不上 P2|不平衡的 Markdown 反引号会让真实 LinkRef 漏检,占位符原文外发 P2|MCP worker IPC 的作用域未钉住实时 turn P2|两个模型可写、用户可见的出口未展开
P3(择要)
整体架构(四元组账本、fail-closed、模式冻结、disabled 字节兼容、fs-policy 隔离)质量不错,上述主要是边界一致性问题。欢迎讨论,谢谢! |
…ntegrity # Conflicts: # src/adapters/backend/remote-runner-backend.ts # src/cli.ts # src/core/worker-pool.ts # src/daemon.ts # src/global-config.ts # src/types.ts # src/utils/pending-input-queue.ts # src/worker.ts # test/remote-runner-outbound-send.test.ts
|
你好,交叉复审又发现 3 个本轮新实现引入的问题(已由两位评审独立探针复现),建议合并前修复,改动都很小;另有 2 项跟进。这是自动评审意见,最终以维护者审阅为准。 ①(合并前修) ②(合并前修)CRLF 文档里 fenced code 不再是字面量(相对旧实现是回归) ③(合并前修)completion proposal 里用 LinkRef 会把整条 final 一起拒掉 跟进项(可写入 PR 已知限制/后续 PR)
上一轮的 4 个 P2 修复都已逐条探针+变异验证通过,这轮只剩以上三点。谢谢! |
Resolve conflicts for deepcoldy#2035: additive union with newer master routes (deferred-topic + link-refs), adopt deepcoldy#2040 sandbox tree rename, align final-output render snapshot, and drop the source-text-pinned test removed by deepcoldy#2057/deepcoldy#2058. Tree equals reviewed rebase.
…er merge The merge resolution dropped master deepcoldy#2046's deferred-topic route from routeHasNarrowUntrustedAuth, replacing it with link-refs/register. Both must remain: isolated deferred-topic claims otherwise miss the narrow capability aperture and fail. Restores the 5 ipc-deferred-topic-route cases.
# Conflicts: # src/cli.ts # src/core/dashboard-ipc-server.ts
… aperture resolve was reachable only via the outer host-HMAC gate, unlike register. In an isolated session (Linux bwrap / macOS Seatbelt) the CLI presents a rotating per-turn capability but has no HMAC secret, so a capability-only request was rejected 401 before the handler's own capability check and every enabled isolated send carrying a ref failed with link_ref_ledger_unavailable. Add resolve to routeHasNarrowUntrustedAuth (the handler still calls sessionCliIpcAuth and 403s on its own) and add a real authRequired server test plus a set-level aperture invariant.
Earlier stack-of-merges both reintroduced tests removed by deepcoldy#2057/deepcoldy#2058 (git add -A picked up stray untracked files) and dropped deepcoldy#1620 Orca files. Reset the tree to the reviewed linear rebase result (base db667c6): zero resurrected deleted tests, all master Orca files present, link-ref core byte-identical, resolve/register/deferred-topic/ chat-manager all in the narrow untrusted-auth aperture.
Supersedes the earlier stack-of-merges which had both resurrected deepcoldy#2057/deepcoldy#2058-deleted tests and dropped deepcoldy#1620 Orca files. Tree now equals the reviewed linear rebase on f894190: zero resurrected deleted tests, all current-master files retained, link-refs/resolve in the narrow aperture with real-server and set-invariant tests.
Tree equals the reviewed linear rebase (67072e1ef) on 7d0a0d7: zero deepcoldy#2057/deepcoldy#2058-deleted test resurrections, all current-master files (including deepcoldy#1620 Orca and deepcoldy#1841) retained, link-refs/register+resolve both in routeHasNarrowUntrustedAuth with real-server/set-invariant tests.
Merge current master (7d0a0d7) with the reviewed LinkRef result tree 49e8dd5 (zero deepcoldy#2057/deepcoldy#2058 test resurrections, all master Orca/card/ tmux files retained, link-refs/register+resolve in the narrow untrusted aperture). This makes current master a parent so GitHub three-way merge uses master itself as the base; content is byte-identical to the reviewed clean linear rebase and no existing branch history is rewritten.
Bring the branch to current master (e9d0f8b, deepcoldy#1758/deepcoldy#2074/deepcoldy#1005/deepcoldy#2016); content is the clean merge with the reviewed LinkRef tree: link-ref register+resolve in the narrow aperture, zero deepcoldy#2057/deepcoldy#2058 resurrections.
|
已合并。CI 期间两条 master 侧墙钟 flake 的豁免说明(可审计): ① test/dashboard-ipc.test.ts:1016
② test/card-footer-extension.test.ts:195 因果排除:本 PR 对 src/cli.ts 零新增顶层静态 import(link-ref 全部 await import),native-subagent hook 冷启动路径不加载 link-ref,import cli.ts 稳态 ~425ms,对 6s 预算有 14 倍余量。 合并 head 4eedac4 最终 CI 十腿全绿(同 SHA rerun 后)。follow-up:将上述 nonce 6s / setsid 3-5s / cli-update-target 15s 墙钟等待改为基于事件或抬阈值,消除 CI 高峰反复踩线。 |
|
🚀 Released in v3.49.0 |
背景
当模型在最终回答中重新书写来源链接时,可能意外丢失查询参数,例如将:
`https://example.test/problem
改写为:
https://example.test/problem排查发现,参数并不是在 Botmux 或飞书发送过程中被截断,而是在模型生成最终
botmux send命令前已经丢失。此时正文和--expected-link都只剩 base URL,原有校验仍会通过,发送层也已经没有足够信息恢复完整链接。过去基于“同域名、同路径”的自动补参或拒发无法可靠解决:
解决方案
引入 turn 级不可变 LinkRef,让模型通过引用而不是重新书写来传递来源链接。
来源链接登记后会生成类似下面的引用:
模型需要引用原始来源链接时输出该 LinkRef。Botmux 在真正发送消息、计算幂等指纹或上传附件之前,从宿主侧账本中将其逐字展开为原始 URL。
URL 不经过解析重建,因此能够保留:
主要改动
1. LinkRef 公共能力
新增以下核心组件:
UrlSourceExtractor:提取模型可见内容中的 HTTP(S) URL 原始字节;LinkRefLedger:保存 turn 级不可变 URL 映射;LinkRefPresenter:生成提供给模型的 companion 引用说明;OutboundLinkRefResolver:在宿主发送前展开 LinkRef;2. 来源覆盖
纳入 Botmux 可以在交给模型前拦截的来源:
群上下文会先完成最终去重,再登记实际发送给模型的内容,避免把未进入模型上下文的 URL 错误加入账本。
延迟队列在 turn promotion、最终上下文确定后才登记链接;写入失败重试会复用相同 ref 和 companion,避免同一次 turn 产生漂移。
3. 发送出口覆盖
LinkRef 展开已接入:
botmux send;展开发生在所有外部副作用之前。展开后的内容参与:
--expected-link校验;4. 普通 URL 保持原语义
本方案不会比较普通 URL 的域名和路径,也不会对普通 URL 自动补参。
因此:
未知、过期或跨 turn 的 LinkRef 会在发送副作用前 fail closed,避免把内部占位符直接泄漏给用户;该规则不影响普通 URL。
授权链接与敏感信息
授权链接属于必须保持可用的业务链接,因此链接中的以下参数不会被擅自删除:
codetokensignaturestateredirect_uri它们会作为完整 URL 的一部分逐字保存和恢复。
同时,本实现不会无条件登记所有字符串:
LinkRef 还绑定以下作用域,不能跨边界复用:
appIdsessionIdturnIddispatchAttemptRef ID 使用不可预测的 128-bit 随机值。
配置与灰度
支持三种模式:
disabled:完全关闭;observe:只扫描并记录脱敏指标,不创建可用引用,也不改变输出;enabled:启用登记、companion 注入和发送前展开。优先级为:
linkRefs.mode;linkRefs.mode;disabled。每个 turn 在接纳时冻结有效模式。运行中修改配置只影响之后接纳的新 turn,避免出现前半轮注入 LinkRef、后半轮停止解析的状态。
默认兼容性
默认模式为
disabled。该模式下:因此合入代码本身不会自动开启功能或改变现有 Bot 行为。
建议灰度顺序
disabled完成发布;observe,确认扫描量和过滤指标;enabled;不采用按请求随机百分比灰度,避免同一会话前后行为不一致。
性能与容量控制
disabled模式不进入扫描和账本路径,与现有发送耗时保持一致。enabled模式通过以下方式限制额外开销:本 PR 不对 enabled 模式的额外耗时做零开销承诺;灰度阶段应继续观察登记和解析耗时指标。
生命周期与可靠性
测试覆盖
新增端到端用例覆盖:
验证结果:
bun run build:通过;git diff --check origin/master...HEAD:通过。全量 Node 测试结果:
失败项:
cli-update-targetdashboard-ipcipc-current-execution-routeplugin-mcp-sandboxworker-codex-actor-launcher.integrationworker-codex-startup-readiness.integration这些失败已通过 master 对照或同机单独复跑确认属于既有基线、环境或不稳定用例,不是本次 LinkRef 改动引入。其中:
cli-update-target在 master 同样超时;dashboard-ipc在本分支和 master 单独运行均通过;非目标与限制
Review 重点
建议重点关注:
disabled模式是否完全绕过新逻辑;