Skip to content

[PR] feat: compress.protectedContentMarkers — user-declared durable content carriers (#2446 Option A) | [PR] feat: compress.protectedContentMarkers — user-declared durable content carriers (#2446 方案A) - #2576

Closed
ranxianglei wants to merge 3 commits into
2026-10-09_plugin-protect-toolfrom
2026-10-09_config-protected-markers
Closed

ranxianglei wants to merge 3 commits into
2026-10-09_plugin-protect-toolfrom
2026-10-09_config-protected-markers

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #2446 (方案A — the proxy-mode/config lane).

What

New compress.protectedContentMarkers (string[]): any TEXT message containing any declared substring is a durable content carrier — same HARD exclusion as protectedTools (untagged BLOCKED ref, covered by neither suggested nor explicit folds, both compression modes, every wire), but keyed on message text instead of tool name.

  • src/config.ts — CompressSettings.protectedContentMarkers, parse (empty array / non-string / blank entries reject loudly), COMPRESS_SETTING_FIELDS.
  • src/compress-settings.ts — mergeCompress whitelist passthrough (three-level cascade global→provider→model, whole-array replace).
  • src/durable-message-guards.ts — protectedContentMarkerGuard(markers) factory (undefined for empty list — the guard chain never grows a dead predicate).
  • src/server/handle.ts — wire path: request-resolved markers stamped onto session.metadata (delete when empty) + composed into isMessageProtected alongside lane/marker/registered guards.
  • src/session.ts — protectedContentMarkersOf(session) + read-path composition in effectiveConfig (plugin-tool readers see the same list without request context).
  • CONFIGURATION.md + CONFIGURATION.zh-CN.md — table row + full section (⚠ over-pinning / paste risk documented, prefer host-native mechanisms when available).

Why this shape

The durable-message protocol now has three host-native channels: built-in lane table (host-identity evidence), bili-durable first-line markers (#2555), POST /__bili/plugin/protect (#2556). All require the HOST to cooperate. #2446's gap: a third-party host (dsh's system-reminder carriers — Instructions from:, <mcp_catalog>) injects standing instructions bili knows nothing about, and in proxy mode bili has no client identity at all, so no lane evidence can ever apply. 方案A is the operator's declarative escape hatch: the user declares the carrier signature once; a config marker reproduces any lane entry one-to-one (same substring granularity as the built-in guards).

Config surface (per AGENTS.md §3)

  • Added: compress.protectedContentMarkers: string[] (default none).
  • Why existing surface can't express it: protectedTools/protectedLatestTools key on tool name; lane/marker/protect channels require host cooperation or plugin mode. Proxy-mode, text-keyed, user-declared pinning has no carrier.
  • Mechanisms considered: lane table (needs host identity — absent in proxy mode), plugin protect endpoint (plugin lane: /__bili/plugin/protect tool (server-side equivalent registration, auxiliary channel) #2556 — plugin-mode only), bili-durable markers (needs the host to emit them). 方案A complements all three.
  • Compat: purely additive key; absent ⇒ behavior byte-identical (guard stays undefined). Empty array rejects as typo (same as protectedTools). No persistence-format change (markers live in session metadata as a plain string array, read-time re-resolved).
  • Docs: CONFIGURATION.md + zh-CN mirrored (table row + section with over-pinning warning).

Tests

tests/issue2446-config-markers.test.ts (4): config validation matrix (accept/trim/reject empty·non-array·non-string·blank); lane-less real fold — configured carrier survives untagged (the 8-refs-for-9-messages pin: BLOCKED_REF is never advertised) while post-carrier neighbors fold; composition — config marker + bili-durable (#2555) co-protect in one session; absent markers — the SAME carrier text folds (protection comes from the knob, not the text).

Local: 4/4 green, typecheck clean, regression family green (2555/2419/2447/2481/2446-catalog 18/18; 2556-protect 4/4).

§7.4 self-check

awork added 2 commits October 10, 2026 10:47
…on test

Review follow-up on #2576: in the #2555-composition test both carriers share
the substring "never force-push master", so that assertion is satisfied even if
the config-marker guard silently stops protecting while a bili-durable marker is
also present. Assert the CARRIER-unique token "never merge PRs" survives, which
only holds if the config-marker channel itself survived the fold.
…s docs-sync drift)

Review follow-up on #2576: the feature's table row was hand-added to
CONFIGURATION.md / CONFIGURATION.zh-CN.md but the single-source seed
website/config-reference/compress.yaml was never updated, so the #2107 docs-sync
drift guard (gen-config-docs.mjs generate + git diff --exit-code) regenerates the
table without the row and fails. Add the compress.protectedContentMarkers seed
entry (id ct.pcm, EN/ZH desc + site) and regenerate index.html/main.js; verified
locally that generate is idempotent and both docs-sync and docs-coverage pass.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 已审 PR #2576(compress.protectedContentMarkers,#2446 方案A)。结论:可合 —— 方向对、实现干净、双压缩模式都覆盖、无回归;我在 review 中顺手修了两处(一处是 merge-blocking 的文档种子漂移,一处是测试强度),均已作为独立标注 commit 推送到 PR 分支。新 head b77e6e067,CI 重跑中。

我做了什么(review 中的两处顺手修,已推送)

两处都是 test-only / docs-only,不碰生产 src/;我已本地实测跑通它们实际影响的门禁。

结构化八问

  1. 是什么问题:给 proxy 模式补一条「用户自报内容载体」的持久消息保护通道——第三方 host(如 dsh 往 user 轮次注入 Instructions from:/<mcp_catalog> 常驻指令)在 proxy 模式下 bili 完全无 client identity,三条 host 原生通道(lane 表 / bili-durable 首行标记 durable protection: lane-less <bili-durable> self-declaration marker (injector opt-in protocol) #2555 / POST protect plugin lane: /__bili/plugin/protect tool (server-side equivalent registration, auxiliary channel) #2556)都要求 host 配合、无法生效,故让 operator 一次性声明载体子串。
  2. 什么原因导致的:根因不在「缺某个守卫」,而在「proxy 模式没有身份证据来源」。lane 表靠 host-identity 证据、marker/protect 靠 host 主动上报,proxy 模式下两者皆无。方案A 把决策权交回 operator(声明式配置),是唯一不依赖 host 配合、又不污染 wire 的层。修在配置/策略层,方向正确——不是伪造身份,也不是在传输层过滤 payload。
  3. 影响范围与严重程度:纯增量能力,默认关闭(absent ⇒ guard undefined ⇒ 字节级等同改动前),仅 operator 显式声明时生效。唯一产品级权衡是「子串任意位置匹配」可能误钉住(用户粘贴恰好含标记的消息被永久保护 → 上下文无界增长);文档已明确 ⚠ 警告并建议用长而具体的标记。非阻塞。
  4. 怎么修复的:新增 read-side 谓词工厂 protectedContentMarkerGuard(markers)(空列表返回 undefined,链上不长死谓词;命中 = text 消息且含任一子串),OR 进既有 isMessageProtected 组合守卫的两条消费路径——wire 路径(src/server/handle.ts 每请求从三级 resolveCompress 结果 stamp 到 session.metadata)+ plugin 读路径(src/session.ts effectiveConfig 从 metadata 重解析)。走的是 kernel 既有 host-hook(kernel/src/protected.ts:189 首个判断、覆盖所有内容类型、优先于工具名),因此与 protectedTools 得到完全相同的硬排除(untagged BLOCKED ref,suggested/explicit 两种折叠都排除,两种压缩模式、所有 wire)。
  5. 是否有回归问题:逐项过——config parse(往既有 tuple 循环加一 key,trim+loud-reject 与 protectedTools 一致);compress-settings(mergeCompress 加一行 pick();applyCompressSettings 正确地没动——markers 非 kernel Config 字段,bili 自己读 resolve 输出建 hook);durable-message-guards(纯新增导出,未改既有函数);handle/session 组合守卫(cfgGuard 为空时回落到与改动前完全一致的三元式 ⇒ absent 字节级不变,Test 4 验证)。高危模式逐项:无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式漂移。结论:无回归。(附注非缺陷:fork-adoption plugin.ts:1219 未显式拷贝该 key,与 plugin lane: /__bili/plugin/protect tool (server-side equivalent registration, auxiliary channel) #2556 的 protectedRawIds 行为一致,且 markers 每请求由 handle 重 stamp 自愈。)
  6. 是否破坏缓存:不涉及。markers 是 read-side 策略,不改重试/游标/去重键/前缀缓存;absent 行为字节级不变,present 只是让被保护消息保持可见(更稳的前缀,与 protectedTools 既有影响一致)。
  7. 是否改了设计方向:无架构转向。是给 durable-message 协议补第 4 条(config/operator)通道,与三条 host 原生通道互补而非替代;边界干净——operator 声明载体签名,粒度与内置 lane 守卫一致(同一 substring 粒度)。查重:确认这是 compress 增加按内容标记的硬排除(protectedContentMarkers),保护会话的基础设施注入免于折叠 #2446 指定的方案A lane,与 durable protection: lane-less <bili-durable> self-declaration marker (injector opt-in protocol) #2555/plugin lane: /__bili/plugin/protect tool (server-side equivalent registration, auxiliary channel) #2556 机制不同,非重复。
  8. 是否引入新配置:是。compress.protectedContentMarkers: string[],默认 none(absent)。纯增量 key、无需迁移(absent = no-op);按 §3 env 纪律正确地做成 config-file key(经 compress 三级级联解析、最深层整体替换),不新增 env var。CONFIGURATION.md + zh-CN 已镜像(表格行 + 完整 section + 过度钉住警告 + 优先 host 原生机制)——补齐种子后 en/zh/site 三处一致。

CI 判定

新 head b77e6e067 正在重跑。原 head 的 10 条 e2e/registry/hermetic lane 全绿;我的两处改动均 test-only/docs-only,不碰生产代码,且已本地实测跑通其影响的两个门禁(docs-sync 幂等复现 + docs-coverage rc=0)。

合并判定:可合。feat + config-surface 变更 ⇒ 需人工 review、不可 auto-merge(§7.4);stacked on #2574,待其合并后 base 自动 retarget master。建议 owner 人工确认后合并。

@ranxianglei ranxianglei changed the title feat: compress.protectedContentMarkers — user-declared durable content carriers (#2446 方案A) [PR] feat: compress.protectedContentMarkers — user-declared durable content carriers (#2446 Option A) | [PR] feat: compress.protectedContentMarkers — user-declared durable content carriers (#2446 方案A) Oct 16, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)

目标 issue #2446 已关(修复以其他方式落地)。列车审查时确认:内容已落地/不再需要,关单处理。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant