Skip to content

feat: lane-less <bili-durable> self-declaration marker for durable-state carriers (#2555) - #2557

Open
ranxianglei wants to merge 4 commits into
masterfrom
2026-10-09_bili-durable-marker
Open

ranxianglei wants to merge 4 commits into
masterfrom
2026-10-09_bili-durable-marker

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

Implements the <bili-durable> self-declaration marker protocol (#2555) — the owner-approved layering from the #2446 discussion: marker as primary channel, protect-tool as auxiliary (#2556), the dsh lane permitlist frozen as legacy fallback.

Any injector (host core, third-party plugin) that emits durable state as an ordinary conversation message stamps the message's first line with the namespaced marker; bili honors it in every session — plugin lane and proxy mode alike.

Why content-embedded, not an API

The marker travels with the message through every surface where out-of-band protection state dies: fork raw-replay (#2383 — new session id, full raw history resend), machine export / conversation transfer, any host re-sending history, and proxy mode (no plugin channel to call). Protection bound to content is replay-self-healing; a protect call is session state that forks forget. The auxiliary tool still exists as #2556 for content-zero-pollution / pre-registration use cases, with the marker documented as durable truth.

Tests

tests/issue2555-bili-durable-marker.test.ts (5 tests): unit matrix (documented shape / unattributed / self-closing / marker-only pin; marker mid-prose, inside a wrapper, lowercase prose, lookalike suffixed tag, non-text, undefined, empty stay foldable; registry still dsh-only) · lane-less proxy-shape session (no plugin headers — #2446 reporter's exact config): real fold via /__bili/plugin/tool, marker + payload survive positionally-covered fold, BLOCKED ref stamped at assignment time · identical content WITHOUT the declaration folds away (pins the marker as the trigger) · dsh-lane composition (marker and legacy carriers co-protected) · effectiveConfig read path stamps BLOCKED on a no-lane session.

Regression: #2419/#2447/#2481/#2446 families 16/16 green; effectiveConfig/durable-adjacent suites (auto-restart, logger-epipe, store, web-logs-view) 38/38 green; npm run typecheck clean. dsh-native not runnable on this machine (known environmental hang, CI covers it).

Fixes #2555

…e carriers (#2555)

The dsh lane permitlist (#2419/#2447/#2481/#2446) is closed-world: it
grows only when a human ships a bili release and structurally cannot
fire in proxy mode (no lane identity on the wire) even for the four
carriers it knows. This adds the injector-side declaration protocol
from the #2446 owner decision: any host core or third-party plugin
stamps its durable-state message's FIRST LINE with the namespaced
bili-durable marker (free-text kind attribute, self-closing accepted,
payload from line two) and bili honors it in EVERY session — plugin
lane and proxy mode alike, no registry entry, no evidence bar (the
injector opting in IS the evidence). The marker lives in the content,
so it survives the whole replay surface where out-of-band protection
state dies: fork raw-replay (#2383), machine export, any host
re-sending history. Tag-name boundary is exact (a suffixed lookalike
tag has not opted in); a marker mid-prose or inside a wrapper does
not pin. Lane table unchanged and frozen as legacy fallback. Zero
kernel change — same Config.isMessageProtected hook.
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-09_bili-durable-marker (2bd2e77)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2757-pr.2557.8a6286b

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr2557.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

PR #2557(2026-10-09_bili-durable-marker @ 3430fc8,base 即当前 master,无漂移,单 commit,+307/−10 / 4 files)已按原 issue #2555 逐点核对完毕。结论:可合并(feat 类按 §7.4 需人工合并;CI 26/27 绿,仅剩 test (windows-latest, 22) 在跑)。

结构化八问

  1. 是什么问题:proxy mode 没有 lane 身份,durable guard 机制(feat: message-level protection hook + dsh durable-state guards (skill catalog #2419, workspace instructions #2447) #2428/fix: pin dsh mcp_catalog durable-state carrier (#2446) #2547)在该形态下结构性地永远不生效——compress 增加按内容标记的硬排除(protectedContentMarkers),保护会话的基础设施注入免于折叠 #2446 reporter 的真实配置正落在此;且 carrier 发射方转向第三方插件后,每 host 写死表的尾追不可持续。
  2. 什么原因导致的:保护是带外的 session/lane 状态——fork raw-replay(DSH 分叉会话后触发大量 preflight overflow compress #2383)、跨机导出、host 重发历史、proxy mode(无插件通道)里全部丢失。根因修法是把保护绑到内容:injector 首行自声明,保护随消息原子迁移。
  3. 影响范围与严重程度:受影响 = proxy-mode 用户 + 任何第三方 carrier 无 lane 条目的会话;表现为 durable 注入状态被静默折叠一次、host 不再重发 → 永久丢失 guidance(MCP catalog、memory baseline 等)。特定配置下的功能缺口,非数据损坏;其余会话无影响。
  4. 怎么修复的:biliDurableMarkerGuard(text-only + 首行锚定 + 精确 tag-name 边界 + 同行 > 收束;kind 自由文本永不解析)与 lane guard 以 OR 组合,挂进既有 kernel Config.isMessageProtected hook——wire path(src/server/handle.ts)与 read path(src/session.ts effectiveConfig())镜像同一组合;零 kernel 改动;registry 保持 dsh-only 并冻结为 legacy fallback。
  5. 是否有回归问题:未发现。既有行为逐项清点:dsh lane 四载体仍受保护(超集组合,本地跑 开启 bili 后「规矩与 skill 好像没被使用」? #2419/dsh 车道:AGENTS.md(workspace instructions,user 消息形态)被折叠后从 wire 消失 —— 与 #2419 同类,但 #2428 白名单只覆盖 <available_skills> #2447/dsh 车道第三个载体:runtime-context 快照(沙箱/审批策略)同属一次性 baseline user 消息,#2428 的文本标记守卫覆盖不到 #2481/compress 增加按内容标记的硬排除(protectedContentMarkers),保护会话的基础设施注入免于折叠 #2446 家族回归 16/16 绿);非 dsh lane 原先无任何 pin → 现仅首行字面 marker 被 pin(即本 feat 本身,误伤面 = 用户显式粘贴协议字符串作首行,属文档化边界);持久化格式不变(guard 仍 read-time 附加、从不落盘——storeEffectiveConfig 存的仍是 pre-guard config,wire/read 两条路径读到的组合一致);wire 字节形状不变(保护只影响 fold 资格,不改消息内容);新增的无条件 {...reqConfig} spread 为浅拷贝,无 identity 依赖。行为变更披露(旧→新):dsh lane 之外的会话此前完全没有硬 pin → 此后首行匹配 <bili-durable…> 的消息在所有会话永久 pin(BLOCKED ref、永不折叠)——有意变更,即本 PR 目的。
  6. 是否破坏缓存:否。pinned 消息保持驻留(稳定前缀,不引入额外失效);缓存/重试/游标/去重策略均未触碰。
  7. 是否改了设计方向:否——沿 compress 增加按内容标记的硬排除(protectedContentMarkers),保护会话的基础设施注入免于折叠 #2446 拍定的分层(marker 主通道 / protect tool 辅助 plugin lane: /__bili/plugin/protect tool (server-side equivalent registration, auxiliary channel) #2556 / 写死表冻结 legacy)扩展,复用既有 kernel hook,registry 纪律不变(测试钉死 keys = ["dsh"])。
  8. 是否引入新配置:否。无 env/config/CLI 新增。

验证记录:本地定向套件 21/21 绿(新增 5 + 回归家族 16),typecheck clean;CI 各 lane/e2e/guard job 全绿,含 real dsh headless profile lane 与 dsh plugin lane(fork adoption)— 覆盖 PR 所述「本机 dsh-native 环境性挂起」的保留项。测试质量:真 server + 经 /__bili/plugin/tool 执行真实 fold,含负向对照(同内容去 marker 正常折叠——钉死 marker 是触发器而非巧合)、BLOCKED ref 在 assignment-time 的时间点断言、registry key 集合钉死。

两条非阻塞观察:① CRLF 边界——首行以 \r 结尾(CRLF emitter)时 endsWith(">") 不命中,属规格符合的行为(规格定义「> 结尾」),JS emitter 用 \n,作为文档化边界可接受;② 协议文档目前只在源码头注释中,而这是面向第三方 injector 的开放世界协议,建议补一小节 injector-facing 说明(TECHNICAL-NOTES.md 或独立协议注记)——建议在本 PR 或随 #2556 一并补,由 owner 定。

判定:代码、测试、方向均成立;最后一个 CI job 转绿后即可合并(人工合并)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

补一条:最后一个 CI job(test (windows-latest, 22))已转绿——27/27 全绿,无 pending。上一条回复的判定不变:可合并(人工合并)。

awork added 2 commits October 10, 2026 00:30
…nchor (#2555)

The first-line anchor splits on \n only, so a CRLF-emitting injector's marker line ended in \r and failed the end-of-line > check — the marker silently did not pin, which is exactly the silent-protection-failure class this protocol exists to close. Strip the trailing \r (terminator, not content) before anchoring. Behavior change: messages whose first line is the marker followed by CRLF are now pinned where they previously folded; no other input changes outcome.
…arker co-pin in one session (#2555)

The issue's test plan requires the dsh-lane combination to hit all four legacy shapes; the existing composition test injected only the marked message. Extend runFoldScenario with optional carriers (injected inside the fold range, BLOCKED count computed unconditionally) and add the five-protected-message scenario: available_skills catalog, Instructions from:, Current runtime context, mcp_catalog and the bili-durable marker all survive one real fold, each stamped BLOCKED at assignment.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Audited this PR line-by-line against the #2555 protocol spec. Implementation is complete and correct; two small gaps found and fixed as labeled additive commits on this branch:

  1. a82877dce fix: treat CRLF as a line terminator in the bili-durable first-line anchor — the guard split on \n only, so a CRLF-emitting injector's marker line ended in \r and failed the end-of-line > check: the marker would silently fail to pin (exactly the silent-protection-failure class this protocol exists to close). Now stripped before anchoring. Behavior change: marker + CRLF ending now pins; no other input changes outcome. Two unit cases added.
  2. 1ad5bad83 test: dsh-lane full combination — the issue's test plan requires "dsh lane 组合仍四形状全中", but the existing composition test injected only the marked message. runFoldScenario now takes optional carriers (injected inside the fold range; BLOCKED count computed unconditionally) and a new scenario proves all four legacy carriers AND the marker co-pin in one session through one real fold (all five stamped BLOCKED at assignment).

Local verification: typecheck clean; new suite 6/6 + regression family (#2419/#2447/#2481/#2446) 16/16 green. CI on the original head was fully green (26/26); CI on the new head is running — first 12 completed checks green, remainder in flight.

This branch has not been deployed

No deployments
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.

durable protection: lane-less <bili-durable> self-declaration marker (injector opt-in protocol)

1 participant