diff --git a/CHANGELOG.md b/CHANGELOG.md index e538ab57a5..f5d97d4ecd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,14 @@ Versions follow the merge of a `*_release-v*` branch; CI publishes to npm on tag - **测试钉住契约**:tests/storage-bun-sqlite.test.ts —— 假 Database 那几组经测试缝 `setBunDatabaseFactoryForTests` 在 Node CI 上同样可跑(记号双写、字面量外只重写一次、BigInt/Uint8Array/null 归一、事务必须 `.immediate()`、阶梯第 0 步优先、被钉的 `{builtin, host}` 探针袋视为 Node 主机);真内置那几组仅在 bun 下跑(真 BEGIN 与回滚、嵌套事务不提前提交、写完锁立刻交还,以及真 UnifiedStore 端到端:开库跑 PRAGMA 阶梯 + quick_check + 迁移、命名参数插入、读回、close 触发 WAL checkpoint 后重开仍在)。 - **既有存储套件在 bun 下实测**:7 处写死 `openSqliteDatabase(path, "node:sqlite")` 的裸句柄改为随动自动探测后,block-bounds 1/0、fork-clone-media 3/0、issue4982 18/0、unified-remap 3/0 全绿;storage-unified 从 4 通过/13 失败变成 14 通过/4 跳过/0 失败(三条只驱动 `node:sqlite` 的 leg 现按驱动探针跳过);storage-ingest-watermark 15/1、bounded-load 4/1、engine-proofs 7/5、plugin-fork 51/5、engine-bootstrap 维持 43/1。与改动前同机基线相比:多通过 24 条,零回归。剩余失败与存储引擎无关:bun 的 node:test 垫片没有 `t.mock`(oven-sh/bun#5090)、Node 专用套件顶层静态 `import("node:sqlite")`、以及子进程 harness 在 bun 下的 ERR_SERVER_NOT_RUNNING。 +### #3248 — 增量车道 GA:全新安装开箱即用 + +- **行为变更(旧→关→开)**:增量车道(宿主只发对话增量、不再每轮全量重发历史,#3248/#5155/#5156)此前 `rollout.features.pluginIncrementalTurns` 打包值为 `percent: 0`——**每个安装都要运营者手动开**。四个当年阻塞它的缺陷已全部关闭并修复:#3343(marker divert 缺回环校验,安全)、#3433(dsh-native 未接入 `wireMessagesLookAnthropic`,OpenAI 车道会丢 `tool_calls`)、#3352(opencode 原生零收益)、#3369(一次瞬时失败永久降级)。现在打包值改为 **`percent: 100`**:新装用户无需任何配置文件、环境变量或面板操作,装上即走增量车道。 +- **为什么默认翻转是安全的**:快车道只在**全部**验证命中时接手——请求体形状(`incrementalTurnBodyShape`)、宿主 GET 探针、统一存储 sidecar、回执。任何一项不满足就整轮回落到原有的全量重发路径,字节与从前完全一致。所以这个默认值只改变**宿主发出多少字节**(#5156 的收益),不改变任何正确性保证。安全面同理:形状化请求在进入 `applyTurn` 之前先过 `adminGateDenial` 回环校验(#3343),非回环/隧道/不可信来源一律 403,默认开启不扩大攻击面。 +- **单一开关 + 两个逃生口**:文件 `rollout.features.pluginIncrementalTurns: false`(或任意 percent 灰度)、环境变量 `BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=0`。两者语义与顺序不变:env > config > 打包 percent > 关闭(fail closed)。 +- **升级提示**:已在跑增量车道的安装字节不变(它们本来就开着);从默认关升上来的安装,第一个回合起即走增量路径,无需重启以外的任何操作。需要保回旧行为的用户设上面任一逃生口即可。 +- 测试:`tests/incremental-lane.test.ts` 的探针用例按新契约翻转(默认报 enabled,env `0` 才关);503 用例改由 env 逃生口驱动;新增 `tests/rollout.test.ts` 内的 GA 打包值 + 双逃生口断言,以及 `tests/incremental-lane-default-on.test.ts`(干净 XDG 根、无配置文件、真实 `featureEnabled`/`incrementalTurnsEnabled`/`GET /__bili/plugin/turn` 三段驱动;反向对照证明默认回退到 0 时 1/2/5 三条必须变红)。 + ### #5079 — `prompt_cache_key` 自注入默认关闭,`promptCache.routing` 一个开关管住两条 wire - **行为变更(旧→新)**:此前 bili 在插件车道对一切目的地默认给请求体盖 `prompt_cache_key=<会话 id>`(#2218/#2649 定案,Responses wire 仅对 `api.openai.com` 注入)。由于大量服务见到该字段会直接拒绝、且这类服务无法枚举,**默认反转为关闭**:`promptCache.routing` 缺省值从 `"auto"` 变为 `"disabled"`(无法识别的值同样落到 `"disabled"`)。客户端自带的 key 不受影响:任何模式下都原样转发(A/B 探测记忆对已证实拒收的 origin+model 组合照常撤键)。 diff --git a/docs/configuration.ja.md b/docs/configuration.ja.md index e4c4ab55e0..0b543f10f0 100644 --- a/docs/configuration.ja.md +++ b/docs/configuration.ja.md @@ -105,6 +105,7 @@ | `rollout.features.identityChannelHarvest` | boolean \| number | 0 (off) | BILI_ROLLOUT_IDENTITY_CHANNEL_HARVEST | IDチャネル収穫コホートゲート (#5825):インストールごとの環境スイッチなしで、ループバック専用のトランスクリプト/sqlite収穫(`src/identity-harvest.ts`: claude-code / codebuddy / mcode / goose / qwen レーン)を許可する。インストールごとのスイッチ(`BILI_IDENTITY_HARVEST`)もこのキーも設定されていない場合、クライアントストレージは一切読み取られない。オーナー裁定 2026-11-07:このコホートキーは `rollout.features.pluginLaneServerHistory`(承認済みIDの行固定を管理)とは意図的に分離されている — いずれかのイネーブラーが収穫を有効化できる。デフォルト 0%;小規模コホートでの degrade warn-once レートの観察後に引き上げる。`identity-channels.md` を参照。 | | `rollout.features.pluginLaneServerHistory` | boolean \| number | 0 (off) | BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY | プラグインレーンのサーバー所有履歴 (#4491):有効化されたインストールにおいて、(a) プラグインレーンのリクエストは `messages` と並行して内部 `biliMsgIds` 配列を持ち、メッセージIDをクライアント提供のIDに固定できる(上流転送前に常に除去;不正な配列は警告付きで無視、ID汚染形状は増分レーンでハードフェイル);(b) ループバック専用の `POST /__bili/plugin/render` エンドポイントは、統合トランスクリプトからレンダリングされた送信プレフィックスを提供する(折り畳み領域はサマリアンカーに縮小;デシンクは非2xxにデグレードし、シムはローカル履歴にフォールバック);(c) 増分レーンのプローブは `serverHistory` をアドバタイズする。デフォルト 0% — ロールアウトされるまで挙動は変わらない。 | | `rollout.features.pluginFullResendWatermark` | boolean \| number | 5 (experimental grey) | BILI_ROLLOUT_PLUGIN_FULL_RESEND_WATERMARK | フルリセンドウォーターマークファストパス (#5403/#5418):前回のレスポンスに `x-bili-pf-seq` ス tamp を持っていたプラグインレーンのチャットコンプリートターンでは、エコーされたカウントにより再送信プレフィックスをアサートする(構造スキャン、フルパースなし);ヒット時にパイプラインはスタッシュされた正規プレフィックスコアと新しいテールウィンドウのみを消費する(バイト同一の送信プロベナンス;疑義がある場合はターンごとに未変更のフルパースパスにフォールバックし再スタンプ、5回のクレジットミスでレーンを1時間保持)。クライアントがスタンプを `x-bili-pf-count` としてエコーバックすることを要求(dsh/pi/opencode/omp は対応;未適応レーンはヒットしない)。実験的グレースケールロールアウト — インストールの約5%でデフォルトON(オーナー裁定 2026-11-02:GA前に小規模コホート;Web UIで全インストールに一度限りの導入通知、クイック設定に3状態スイッチ)。`true` で強制、`false`(またはパーセンテージ)/ 環境変数 = 0 でオフ。`technical-notes.md` の「Full-resend watermark fastpath」を参照。 | +| `rollout.features.pluginIncrementalTurns` | boolean \| number | 100 (on) | BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS | インクリメンタルターンレーン (#3248):有効化されたインストールでは、ネイティブプラグインホストが各ターンで会話の差分のみ(ホスト msgid エンベロープ付き)を送信し、履歴全体を再送信しない。bili は統合トランスクリプトから送信リクエストを再構築し、通常のフォールド/レンダリングパイプラインを処理する。このバージョンから GA——新規インストールはデフォルトで差分方式。統合ストレージ sidecar を持たないインストールは自動的にフルリセンドのまま(プローブが storage=legacy-only を報告)。false / パーセンテージ上書き、または BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=0 でオフにできる。 | | `maskHosts` | boolean | true | BILI_LOG_MASK_HOSTS | ログ内の非公開ターゲットホストを としてマスクする。認証情報ヘッダーは常にマスクされる。 | | `security.adminRelay` | boolean | false | — | エンベディングホスト(現在は dsh web)が、リモートブラウザからパネルを開けるように(#3373)、その自身のエントリーオリジンを通じて /__bili/ 管理サーフェス全体をリレーすることを許可する。フェイルクローズ、ファイルのみ。リレーされたホップはローカル非ブラウザクライアントとしてプロキシに到達する(ループバックソース + ループバック Host、Origin なし)ため、管理ゲートは変更されない。これを有効にすると、ホスト Web エントリーに到達できる者に設定編集と認証情報の書き込みが露出する — まずそのエントリー(認証 / リバースプロキシ)を保護すること。 | | `subagentSplit` | boolean | true | BILI_SUBAGENT_SPLIT | Claude Code サブエージェントは、メインセッションのキューに並ぶ代わりに、独自のセッション名前空間(\|sub:)を取得します。Anthropic-wire 専用 — Responses wire ではこのスイッチは no-op です(`subagentSplit` / BOTH-mechanisms スコープ注記を参照)。 | @@ -2023,6 +2024,7 @@ ACP ネイティブエージェント(現在は `pi` 拡張機能)は、プ | `BILI_ROLLOUT_` | `rollout.features.enabled` | unset (bucket math decides) | | `BILI_ROLLOUT_IDENTITY_CHANNEL_HARVEST` | `rollout.features.identityChannelHarvest` | 0 (off) | | `BILI_ROLLOUT_PLUGIN_FULL_RESEND_WATERMARK` | `rollout.features.pluginFullResendWatermark` | 5 (experimental grey) | +| `BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS` | `rollout.features.pluginIncrementalTurns` | 100 (on) | | `BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY` | `rollout.features.pluginLaneServerHistory` | 0 (off) | | `BILI_SESSION_CONTENT_STORE_PIN` | `sessions.contentStorePin` | false | | `BILI_SESSION_GC` | `sessions.gc.enabled` | false | diff --git a/docs/configuration.md b/docs/configuration.md index 0ce26ea7e3..372f2ee4e5 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -106,6 +106,7 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed | `rollout.features.identityChannelHarvest` | boolean \| number | 0 (off) | BILI_ROLLOUT_IDENTITY_CHANNEL_HARVEST | Identity-channel harvest cohort gate (#5825): allows the loopback-only transcript/sqlite harvest (src/identity-harvest.ts: claude-code / codebuddy / mcode / goose / qwen lanes) without any per-install env switch, when neither the per-install switch (BILI_IDENTITY_HARVEST) nor this key is set nothing ever reads client storage. Owner ruling 2026-11-07: this cohort key is deliberately separate from rollout.features.pluginLaneServerHistory (which governs row PINNING of admitted ids) — either enabler may activate harvesting. Default 0%; raise after small-cohort observation of the degrade warn-once rate. See identity-channels.md. | | `rollout.features.pluginLaneServerHistory` | boolean \| number | 0 (off) | BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY | Plugin-lane server-owned history (#4491): for enabled installs, (a) plugin-lane requests may carry an internal `biliMsgIds` array parallel to `messages` that pins message identity to client-supplied ids (always stripped before upstream forwarding; malformed arrays are ignored with a warning, id-poisoning shapes hard-fail on the incremental lane); (b) the loopback-only `POST /__bili/plugin/render` endpoint serves the outbound prefix rendered from the unified transcript (folded regions collapse to summary anchors; any desync degrades to a non-2xx so the shim falls back to its local history); (c) the incremental-lane probe advertises `serverHistory`. Default 0% — no behavior change until rolled out. | | `rollout.features.pluginFullResendWatermark` | boolean \| number | 5 (experimental grey) | BILI_ROLLOUT_PLUGIN_FULL_RESEND_WATERMARK | Full-resend watermark fastpath (#5403/#5418): plugin-lane chat-completions turns whose previous response carried an x-bili-pf-seq stamp assert the resent prefix via the echoed count (structural scan, no full parse); on a hit the pipeline consumes stashed canonical prefix cores plus only the new tail window (byte-identical outbound provenance; ANY doubt falls back to the untouched full-parse path per turn and re-stamps, five credited misses hold the lane for one hour). Requires the client to echo the stamp back as x-bili-pf-count (dsh/pi/opencode/omp do; unadapted lanes never hit). EXPERIMENTAL grey rollout — ON by default for roughly 5% of installs (owner ruling 2026-11-02: small cohort before GA; one-time intro notice in the web UI for every install, tri-state switch in quick config). Force it with `true`, turn off with `false` (or a percent) / env = 0. See technical-notes.md “Full-resend watermark fastpath”. | +| `rollout.features.pluginIncrementalTurns` | boolean \| number | 100 (on) | BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS | Incremental turn lane (#3248): for enabled installs, native plugin hosts send only the conversation delta each turn (with the host-msgid envelope) instead of re-sending the whole history; bili rebuilds the outbound request from the unified transcript through the normal fold/render pipeline. GA since this version — fresh installs are delta-by-default. Installs without the unified-storage sidecar stay on full-resend automatically (probe reports storage=legacy-only). Opt out with false / a percent override, or BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=0. | | `maskHosts` | boolean | true | BILI_LOG_MASK_HOSTS | Mask non-public target hosts in logs as ; credential headers are always masked regardless. | | `security.adminRelay` | boolean | false | — | Let an embedding host (dsh web today) relay the ENTIRE /__bili/ admin surface through its own entry origin so a remote browser can open the panel (#3373). Fail-closed, file-only. The relayed hop reaches the proxy as a local non-browser client (loopback source + loopback Host, no Origin), so the admin gate stays unchanged; enabling it exposes config editing and credential writes to whoever can reach the host web entry — protect that entry (auth / reverse proxy) first. | | `subagentSplit` | boolean | true | BILI_SUBAGENT_SPLIT | Claude Code subagents get their own session namespace (\|sub:) instead of queueing behind the main session. Anthropic-wire only — on the Responses wire this switch is a no-op (see the `subagentSplit` / BOTH-mechanisms scope note). | @@ -2034,6 +2035,7 @@ File keys resolve only when the matching env var is unset. Defaults in parenthes | `BILI_ROLLOUT_` | `rollout.features.enabled` | unset (bucket math decides) | | `BILI_ROLLOUT_IDENTITY_CHANNEL_HARVEST` | `rollout.features.identityChannelHarvest` | 0 (off) | | `BILI_ROLLOUT_PLUGIN_FULL_RESEND_WATERMARK` | `rollout.features.pluginFullResendWatermark` | 5 (experimental grey) | +| `BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS` | `rollout.features.pluginIncrementalTurns` | 100 (on) | | `BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY` | `rollout.features.pluginLaneServerHistory` | 0 (off) | | `BILI_SESSION_CONTENT_STORE_PIN` | `sessions.contentStorePin` | false | | `BILI_SESSION_GC` | `sessions.gc.enabled` | false | diff --git a/docs/configuration.zh-CN.md b/docs/configuration.zh-CN.md index 20982b7278..1c9f6f7b39 100644 --- a/docs/configuration.zh-CN.md +++ b/docs/configuration.zh-CN.md @@ -106,6 +106,7 @@ | `rollout.features.identityChannelHarvest` | boolean \| number | 0(关) | BILI_ROLLOUT_IDENTITY_CHANNEL_HARVEST | 身份信道采集的灰度门(#5825):当安装级开关(BILI_IDENTITY_HARVEST)未设置时,允许仅由本灰度键激活回环专属的转录/SQLite 采集(claude-code / codebuddy / mcode / goose / qwen 车道);两者都不设则永不读客户端存储。owner 裁定 2026-11-07:本灰度键与 rollout.features.pluginLaneServerHistory(它管已接纳 id 的行钉住)刻意分离——任一使能方可激活采集。默认 0%,小流量观察退化率后再抬。见 identity-channels.zh-CN.md。 | | `rollout.features.pluginLaneServerHistory` | boolean \| number | 0(关) | BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY | 插件车道服务端正史(#4491):对已放量的安装,(a) 插件车道请求可携带与 `messages` 平行的内部字段 `biliMsgIds`,把消息身份钉在客户端提供的 id 上(转发上游前一律剥掉;格式错误的数组告警后忽略,身份投毒形态在增量车道直接硬失败);(b) 仅回环可达的 `POST /__bili/plugin/render` 端点从统一存储渲染出站前缀(折叠区收敛为摘要锚点;任何失步都返回非 2xx,shim 退回本地历史);(c) 增量车道探测响应通告 `serverHistory`。默认 0%,放量前无行为变化。 | | `rollout.features.pluginFullResendWatermark` | boolean \| number | 5(实验性灰度) | BILI_ROLLOUT_PLUGIN_FULL_RESEND_WATERMARK | 全量重发水位快路径(#5403/#5418):插件车道 chat-completions 回合若上一轮响应盖有 x-bili-pf-seq,则用回声计数声明重发前缀(结构扫描,不做全量解析);命中时管线只消费钉存的前缀核 + 新增尾巴窗口(出站字节同源可证;任何疑点当轮回退未动过的全量解析路径并重新盖戳,连续五次计名失配将车道按住一小时)。需客户端把戳回声为 x-bili-pf-count(适配的车道回带;其余车道不会命中)。**实验性灰度**——默认仅约 5% 的安装开启(owner 裁定 2026-11-02:先小流量再 GA;web 面板对全部安装显示一次性公告、快速配置提供三态开关);`true` 强制开、`false`(或百分比)/ env = 0 关。见 technical-notes.zh-CN.md「全量重发水位快路径」。 | +| `rollout.features.pluginIncrementalTurns` | boolean \| number | 100(开) | BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS | 增量回合车道(#3248):对已放量的安装,原生插件宿主每回合只发对话增量(带宿主 msgid 信封),不再整段重发历史;bili 从统一 transcript 重建出站请求并走正常折叠/渲染管道。本版本起 GA——全新安装开箱即增量。没有统一存储 sidecar 的安装自动保持全量重发(探测响应 storage=legacy-only)。用 false / percent 覆盖或 BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=0 可关。 | | `maskHosts` | boolean | true | BILI_LOG_MASK_HOSTS | 日志中把非公开目标主机遮成 ;凭据头无论此开关如何总是遮盖。 | | `security.adminRelay` | boolean | false | — | 允许宿主(当前为 dsh web)把它自己入口域名下的整个 /__bili/ 管理面中继到本机代理,使远程浏览器能打开面板(#3373)。默认关闭、仅配置文件。中继跳到达代理时是本机非浏览器客户端(回环源地址 + 回环 Host、无 Origin 头),管理端门槛不变;开启后,凡能访问宿主 web 入口的人都能改配置、写凭据——请先给入口加鉴权/反代。 | | `subagentSplit` | boolean | true | BILI_SUBAGENT_SPLIT | Claude 子代理拥有独立会话命名空间(\|sub:),不再排队在主会话锁后。仅 anthropic 线路 —— Responses 线路上本开关无效(见 `subagentSplit` / BOTH-mechanisms 作用域说明)。 | @@ -2011,6 +2012,7 @@ ACP 原生 agent(当前为 `pi` 扩展)会在每个进程内向代理上报 | `BILI_ROLLOUT_` | `rollout.features.enabled` | unset (bucket math decides) | | `BILI_ROLLOUT_IDENTITY_CHANNEL_HARVEST` | `rollout.features.identityChannelHarvest` | 0 (off) | | `BILI_ROLLOUT_PLUGIN_FULL_RESEND_WATERMARK` | `rollout.features.pluginFullResendWatermark` | 5 (experimental grey) | +| `BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS` | `rollout.features.pluginIncrementalTurns` | 100 (on) | | `BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY` | `rollout.features.pluginLaneServerHistory` | 0 (off) | | `BILI_SESSION_CONTENT_STORE_PIN` | `sessions.contentStorePin` | false | | `BILI_SESSION_GC` | `sessions.gc.enabled` | false | diff --git a/docs/plugin-protocol.md b/docs/plugin-protocol.md index ff4dae5743..907c783ef4 100644 --- a/docs/plugin-protocol.md +++ b/docs/plugin-protocol.md @@ -209,9 +209,9 @@ Lineage-only declaration (#2408): a host that cannot drive the full fork protoco Incremental turns (#3248; not yet advertised in the plugin manifest — detect by trying the endpoint and handling the 503): a host that keeps its own full local history may stop resending it. `POST /__bili/plugin/turn` (same `/__bili/` gate; headers `x-bili-plugin` + optional `x-bili-plugin-model`, `x-bili-plugin-context-window`, `x-bili-plugin-max-output`) with `{ conversationId, sinceSeq, resync?, system?, path?, request, messages }`. The first turn (or any recovery) sends `sinceSeq: 0` + the full `messages[]` (`resync: true` is implied on seed — a wholesale replacement never 409s and works whether the canonical is empty or already live); every later turn sends ONLY what the client added since the last ack — including the previous assistant reply (client-owned). `request` carries anthropic params (model, max_tokens, temperature, top_p, top_k, stop_sequences, stream, tools, tool_choice, metadata, thinking, service_tier, parallel_tool_calls); `system` is sticky (omit to keep the last one); `path` defaults to `/v1/messages` (bare relative rides the lane's default upstream; the `/bili//…` form is explicit). The response is the upstream body streamed through, with `x-bili-applied-seq` = the canonical length after applying the delta — echo that value as the next turn's `sinceSeq`. `409 { error: "seq-mismatch" | "turn-in-flight", serverSeq }` means the client MUST recover with a resync turn (`sinceSeq: serverSeq` if it still has the history, else `resync: true` full seed). `503` means the lane runs without `storage.unified` (the canonical log lives in the unified messages table). The lane owns no session identity of its own: the assembled request carries the client's own `x-bili-plugin-conversation`, so incremental and normal full-resend traffic for one conversation share one session, one fold ledger and one canonical — switching modes needs no ceremony, and a conversation may interleave them (e.g. fall back to full resend while a resync is pending). Folding, nudges, tools and the plugin tool endpoints all work unchanged on the assembled body; the model never sees the difference. v1 caveats: the canonical log is the session's messages table — a turn is acked after the assembled body is persisted (best-effort immediate flush; a crash in between surfaces as 409 → resync), and the pipeline still walks the assembled prefix (O(full) CPU, cheap and zero-hit — the server-authored fast path is tracked on #3248). A `resync: true` that replaces a diverged canonical records a base-seq epoch (`session_ext` key `inc:base-seq`): the stale branch's rows stay in the append-only log for audit, but cold rebuilds slice past them — one resync heals, restarts included. On legacy-only storage (no ext surface) the marker degrades and cold rebuilds serve the full row union (409 → resync once, as before). -Marker divert (#3248 phase 2 — native extensions): instead of switching the provider URL to the turn endpoint, a host may send the incremental body on its ORDINARY model request. Stamp `x-bili-plugin-turn: 1` on the request (the lane requires `x-bili-plugin` too, as for every plugin signal); the body shape — top-level `conversationId` + `sinceSeq` + `messages`, no top-level `model` — is the final word: a marker'd body that is NOT incremental-shaped rides the normal pipeline byte-identically, so a host may stamp the marker whenever the feature is enabled and only convert turns it wants. Incremental-SHAPED turns are lane traffic and carry the same trust class as the direct turn endpoint (#3343): non-loopback / tunnel / untrusted-origin callers get 403 on them (their capability probe already 403s, so a well-behaved host never sends deltas from afar), and management prefixes (`/__bili/`, `/__acp/`) never ride the divert. The lane forwards the assembled request to the ORIGINAL request path (bare or `/bili/…` — no provider reconfiguration). Capability probe: `GET /__bili/plugin/turn` → `{ ok, protocol: 1, feature: "pluginIncrementalTurns", enabled, storage }` (loopback-gated like every `/__bili/` surface; a 404 = older server, stay full-resend). Gating: rollout feature `pluginIncrementalTurns` (default 0% = every install byte-identical to before) — enable with `rollout.features.pluginIncrementalTurns: true` (or a percent) in the bili config, or `BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=1`; the feature additionally requires a live unified sidecar (shadow or full). When disabled mid-flight the lane answers 503 on incremental-shaped turns — fall back to a plain full-resend request. Reference host wiring: pi rides its `before_provider_headers` (marker) + `before_provider_request` (payload replacement) + `after_provider_response` (ack) extension events; dsh-native rides the fetch patch's `beforeSend` (body conversion) + `headersFor` (marker) + `onResponse` (ack). pi-native inherits the pi wiring unchanged (same extension factory — only proxy discovery differs). opencode rides its `http.request` hook (an `incremental` adapter callback appended after routing/stamping swaps the request body via `replaceRequestPayload` and stamps the marker on the replaced request; acks land on the fetch intercept's `onResponse`). omp has no header events at all — its native adapter reads the extension-stamped `prompt_cache_key` body field as the conversation id inside `beforeSend`, stamps the plugin headers directly on the request init (identity upgrades, never forks: wire mode already resolves the same value via `preferPromptCacheKeyIdentity`), and acks on `onResponse`. Non-Anthropic wire shapes (OpenAI `tool_calls`/`role:"tool"`) are detected by `wireMessagesLookAnthropic` and left on full resend — the lane's message ingestion is the anthropic wire. Planned turns are single-in-flight per URL and age out after 30s (a network-dead request must not block the URL forever). The shared client state machine lives in `src/agent/incremental-client.ts` (probe TTL cache, prefix-hash diffing, sticky system, per-conversation dead flag) — new native hosts should reuse it rather than re-implement the diffing. +Marker divert (#3248 phase 2 — native extensions): instead of switching the provider URL to the turn endpoint, a host may send the incremental body on its ORDINARY model request. Stamp `x-bili-plugin-turn: 1` on the request (the lane requires `x-bili-plugin` too, as for every plugin signal); the body shape — top-level `conversationId` + `sinceSeq` + `messages`, no top-level `model` — is the final word: a marker'd body that is NOT incremental-shaped rides the normal pipeline byte-identically, so a host may stamp the marker whenever the feature is enabled and only convert turns it wants. Incremental-SHAPED turns are lane traffic and carry the same trust class as the direct turn endpoint (#3343): non-loopback / tunnel / untrusted-origin callers get 403 on them (their capability probe already 403s, so a well-behaved host never sends deltas from afar), and management prefixes (`/__bili/`, `/__acp/`) never ride the divert. The lane forwards the assembled request to the ORIGINAL request path (bare or `/bili/…` — no provider reconfiguration). Capability probe: `GET /__bili/plugin/turn` → `{ ok, protocol: 1, feature: "pluginIncrementalTurns", enabled, storage }` (loopback-gated like every `/__bili/` surface; a 404 = older server, stay full-resend). Gating: rollout feature `pluginIncrementalTurns` (GA: default 100% — opt out with `rollout.features.pluginIncrementalTurns: false` (or a percent) in the bili config, or `BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=0`); the feature additionally requires a live unified sidecar (shadow or full), so legacy-only storage stays on the full-resend path regardless. When disabled mid-flight the lane answers 503 on incremental-shaped turns — fall back to a plain full-resend request. Reference host wiring: pi rides its `before_provider_headers` (marker) + `before_provider_request` (payload replacement) + `after_provider_response` (ack) extension events; dsh-native rides the fetch patch's `beforeSend` (body conversion) + `headersFor` (marker) + `onResponse` (ack). pi-native inherits the pi wiring unchanged (same extension factory — only proxy discovery differs). opencode rides its `http.request` hook (an `incremental` adapter callback appended after routing/stamping swaps the request body via `replaceRequestPayload` and stamps the marker on the replaced request; acks land on the fetch intercept's `onResponse`). omp has no header events at all — its native adapter reads the extension-stamped `prompt_cache_key` body field as the conversation id inside `beforeSend`, stamps the plugin headers directly on the request init (identity upgrades, never forks: wire mode already resolves the same value via `preferPromptCacheKeyIdentity`), and acks on `onResponse`. Non-Anthropic wire shapes (OpenAI `tool_calls`/`role:"tool"`) are detected by `wireMessagesLookAnthropic` and left on full resend — the lane's message ingestion is the anthropic wire. Planned turns are single-in-flight per URL and age out after 30s (a network-dead request must not block the URL forever). The shared client state machine lives in `src/agent/incremental-client.ts` (probe TTL cache, prefix-hash diffing, sticky system, per-conversation dead flag) — new native hosts should reuse it rather than re-implement the diffing. -中文增量要点(#3248):`POST /__bili/plugin/turn`,首次/恢复用 `sinceSeq:0` 全量(种子隐含 `resync:true`,永不 409);此后每轮只发新增(含上一轮 assistant 回复,客户端自持)。响应即上游原文,`x-bili-applied-seq` 为应用后的长度,下一轮作 `sinceSeq` 回传。409 必须按 serverSeq 对齐或全量重同步;503 表示未开 storage.unified。会话身份沿用客户端自己的 conversation id——增量与全量重发同一会话可任意切换,折叠/工具/状态栏不变。阶段 2(标记分流):普通模型请求上盖 `x-bili-plugin-turn: 1` 头 + 增量形状 body(顶层 conversationId/sinceSeq/messages、无顶层 model)即可,增量形状 turn 属 lane 流量,与直连 turn 端点同信任级(#3343):非回环/隧道/不可信源一律 403(其探针本就 403,正常宿主不会远程发增量);管理前缀(`/__bili/`、`/__acp/`)永不走分流。lane 按原始 URL 转发;探针 `GET /__bili/plugin/turn`;开关 rollout `pluginIncrementalTurns`(默认 0%=零变化,`BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=1` 或配置强制开)。客户端状态机在 src/agent/incremental-client.ts,新宿主复用勿重写。已接宿主:pi/pi-native(同一扩展工厂,后者零代码继承)、dsh-native(fetch 补丁 beforeSend/headersFor/onResponse)、opencode(http.request 钩子 incremental 适配回调换 body+盖章)、omp(无头事件通道,读 body 里 prompt_cache_key 当会话 id,直接在 init 上盖章);OpenAI 工具形状(tool_calls/role:tool)自动回退全量重发;每 URL 单飞行+30s 过期。 +中文增量要点(#3248):`POST /__bili/plugin/turn`,首次/恢复用 `sinceSeq:0` 全量(种子隐含 `resync:true`,永不 409);此后每轮只发新增(含上一轮 assistant 回复,客户端自持)。响应即上游原文,`x-bili-applied-seq` 为应用后的长度,下一轮作 `sinceSeq` 回传。409 必须按 serverSeq 对齐或全量重同步;503 表示未开 storage.unified。会话身份沿用客户端自己的 conversation id——增量与全量重发同一会话可任意切换,折叠/工具/状态栏不变。阶段 2(标记分流):普通模型请求上盖 `x-bili-plugin-turn: 1` 头 + 增量形状 body(顶层 conversationId/sinceSeq/messages、无顶层 model)即可,增量形状 turn 属 lane 流量,与直连 turn 端点同信任级(#3343):非回环/隧道/不可信源一律 403(其探针本就 403,正常宿主不会远程发增量);管理前缀(`/__bili/`、`/__acp/`)永不走分流。lane 按原始 URL 转发;探针 `GET /__bili/plugin/turn`;开关 rollout `pluginIncrementalTurns`(已 GA:默认 100%,`rollout.features.pluginIncrementalTurns: false` 或 `BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=0` 可关;另需统一存储 sidecar 在线,legacy-only 存储不受影响)。客户端状态机在 src/agent/incremental-client.ts,新宿主复用勿重写。已接宿主:pi/pi-native(同一扩展工厂,后者零代码继承)、dsh-native(fetch 补丁 beforeSend/headersFor/onResponse)、opencode(http.request 钩子 incremental 适配回调换 body+盖章)、omp(无头事件通道,读 body 里 prompt_cache_key 当会话 id,直接在 init 上盖章);OpenAI 工具形状(tool_calls/role:tool)自动回退全量重发;每 URL 单飞行+30s 过期。 中文集成要点:fork 协议现为 2(服务端同时接受 1);先读取 manifest 能力及 snapshot,按原文、role、工具身份确认匹配前缀,仅提交该前缀的 orderedMessages,不猜测多模态分支点。被 `compress.protectedTools` 硬排除的消息在两个数组中均为 `"ref": null`(参与顺序与身份、无地址 ref),与其他前缀条目一样逐字提交;ref 合法值仅 `mNNNNN` 字符串或 `null`。父 revision 变化必须重新取快照并重新匹配。子会话使用独立稳定 id,首次请求可追加尚未出站的模型回复,不能重置继承的 refs/blocks。手动摘要使用 snapshot 的 refs 和 `expectedRevision: snapshot.parentRevision` 调用公开 tool;摘要期间历史发生变化时返回 409,不执行旧摘要。状态栏读取 `contextTokens`、`contextTokensSource`、`contextTokensAt`、`model`、`contextLimit`、`contextGeneration`、`sessionId` 与 `sessionRevision`,不得用累计账单 input/cache 冒充有效上下文。手动 compress/decompress 后为独立时间及 generation 的 estimate,不改累计账单或 last-usage 基线;下一次正数 usage 才恢复 usage,零值或缺失 usage 不得复活旧观测。未知来源返回 unavailable,tokens/time/generation 为 null。 diff --git a/src/rollout.ts b/src/rollout.ts index 4ff2ace44b..a554a0af0e 100644 --- a/src/rollout.ts +++ b/src/rollout.ts @@ -49,11 +49,13 @@ export interface RolloutPlan { export const ROLLOUT_FEATURES: Record = { // #3248 incremental turns: lets a native extension send only the delta of // a conversation (marker `x-bili-plugin-turn` on ordinary model requests) - // once enabled for this install. Default 0% — every client keeps the - // byte-identical full-resend behavior. Operators force it on with - // `rollout.features.pluginIncrementalTurns: true` (or a percent), or - // `BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=1`. - pluginIncrementalTurns: { percent: 0 }, + // once enabled for this install. Default 100% — GA: the full-resend path + // is still what runs whenever any verification misses (body shape, probe, + // sidecar, ack), so the default changes only how many bytes the host + // sends (#5156), never a correctness guarantee. Escape hatches: + // `rollout.features.pluginIncrementalTurns: false` (or a percent), or + // `BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=0`. + pluginIncrementalTurns: { percent: 100 }, // #5403/#5418 full-resend watermark fastpath: plugin-lane turns re-send // the ENTIRE history each turn; on a verified hit (count watermark // stamped by the previous response) the server stops re-parsing and diff --git a/tests/incremental-lane-default-on.test.ts b/tests/incremental-lane-default-on.test.ts new file mode 100644 index 0000000000..52623d8d06 --- /dev/null +++ b/tests/incremental-lane-default-on.test.ts @@ -0,0 +1,129 @@ +// #3248/#5156 GA follow-up (nails the PRODUCTION default end-to-end): a fresh +// install must answer "the incremental lane is enabled" from the version's +// baked-in rollout plan alone — no BILI_ROLLOUT_* env var, no +// `rollout.features` entry in the config file, no operator action. Both escape +// hatches (file `enabled: false`, env "0") must still turn the lane off. +// +// This drives the honest production expressions instead of copies of their +// predicates: a fresh XDG root with NO config file, the real `featureEnabled` / +// `incrementalTurnsEnabled` entry points, and a real `startServer` asked through +// its real GET probe on the turn path. +import assert from "node:assert/strict"; +import http from "node:http"; +import { once } from "node:events"; +import test from "node:test"; +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { defaultConfig } from "acp-kernel"; +import { startServer } from "../src/server.ts"; +import type { ProxyOptions } from "../src/config.ts"; +import { SessionStore, _setStoreForTest } from "../src/persist.ts"; +import { _resetPluginStateForTest } from "../src/plugin.ts"; +import { _resetSessionsForTest } from "../src/session.ts"; +import { _setForTest as _setRegistryForTest } from "../src/registry.ts"; +import { resetToolRingForTest } from "../src/tool-ring.ts"; +import { __resetIncrementalLaneForTests, incrementalTurnsEnabled } from "../src/incremental-lane.ts"; +import { ROLLOUT_FEATURES, featureEnabled, resolveRollout, rolloutEnvName, rolloutInstallId } from "../src/rollout.ts"; + +process.env.NODE_ENV = "test"; + +const FEATURE = "pluginIncrementalTurns"; +const ENV_VAR = rolloutEnvName(FEATURE); +const testRoot = mkdtempSync(join(tmpdir(), "bili-incr-ga-")); +test.after(() => rmSync(testRoot, { recursive: true, force: true })); + +const KEYS = [ENV_VAR, "BILI_CONFIG_FILE", "XDG_STATE_HOME", "XDG_DATA_HOME", "XDG_CACHE_HOME", "XDG_CONFIG_HOME", "BILI_STORAGE_UNIFIED"]; +const savedEnv = new Map(); +for (const key of KEYS) savedEnv.set(key, process.env[key]); +test.after(() => { + for (const [key, value] of savedEnv) { + if (value === undefined) delete process.env[key]; + else process.env[key] = value; + } +}); + +/** A believable fresh install: an empty config dir, so loadConfigFile() carries + * no `rollout` section at all — the state a new user's machine is in. */ +function freshInstall(): string { + const dir = mkdtempSync(join(testRoot, "root-")); + for (const key of ["XDG_STATE_HOME", "XDG_DATA_HOME", "XDG_CACHE_HOME", "XDG_CONFIG_HOME"]) process.env[key] = dir; + mkdirSync(join(dir, "billion-context"), { recursive: true }); + delete process.env[ENV_VAR]; + delete process.env.BILI_CONFIG_FILE; + return dir; +} + +test("GA default: the baked-in plan ships the lane at 100%, not behind a canary", () => { + const plan = ROLLOUT_FEATURES[FEATURE]; + assert.ok(plan !== undefined, "the feature must be registered in the version plan"); + assert.equal(plan.percent, 100, "the version plan must ship the lane at 100% (GA)"); +}); + +test("GA default: a fresh install with no config file resolves the lane ON", () => { + freshInstall(); + assert.equal(featureEnabled(FEATURE), true, "no operator action may be required for a fresh install"); + const decision = resolveRollout(FEATURE, { id: rolloutInstallId() }); + assert.equal(decision.enabled, true); + assert.equal(decision.source, "bucket", "GA still resolves through the bucketing tier (100% = every bucket)"); +}); + +test("GA default: escape hatch 1 — file `enabled: false` still turns the lane off", () => { + const dir = freshInstall(); + writeFileSync(join(dir, "billion-context", "billion-context.json"), + JSON.stringify({ rollout: { features: { [FEATURE]: { enabled: false } } } }), "utf8"); + assert.equal(featureEnabled(FEATURE), false, "a user who opted out must stay off"); +}); + +test("GA default: escape hatch 2 — env \"0\" resolves off through the top tier", () => { + freshInstall(); + process.env[ENV_VAR] = "0"; + try { + assert.equal(featureEnabled(FEATURE), false); + const decision = resolveRollout(FEATURE, { id: rolloutInstallId() }); + assert.equal(decision.source, "env", "the env tier is the top of the ladder"); + assert.equal(decision.enabled, false); + } finally { + delete process.env[ENV_VAR]; + } +}); + +test("GA default: the real GET probe on the turn path reports the lane enabled", async () => { + const dir = freshInstall(); + process.env.BILI_STORAGE_UNIFIED = "full"; + _resetSessionsForTest(); + _resetPluginStateForTest(); + resetToolRingForTest(); + __resetIncrementalLaneForTests(); + const store = new SessionStore({ dir: join(dir, "sessions"), enabled: true, debounceMs: 60000 }); + _setStoreForTest(store); + _setRegistryForTest({}); + const upstream = http.createServer((req, res) => { + req.on("data", () => undefined); + req.on("end", () => { + res.writeHead(200, { "content-type": "application/json" }); + res.end(JSON.stringify({ id: "msg_test", role: "assistant", content: [{ type: "text", text: "answer" }], usage: { input_tokens: 10, output_tokens: 1 } })); + }); + }); + upstream.listen(0, "127.0.0.1"); + await once(upstream, "listening"); + const addr = upstream.address(); + assert.ok(addr !== null && typeof addr === "object"); + const upstreamUrl = `http://127.0.0.1:${addr.port}`; + const proxy = await startServer({ port: 0, host: "127.0.0.1", upstream: upstreamUrl, routes: { [upstreamUrl]: { models: { "claude-test": { context: 400000 } } } }, modelContextLimit: 400000, kernelConfig: defaultConfig(400000), compress: { injectTool: true, injectNudge: false }, promptCache: { routing: "auto" }, sessionHeader: "x-acp-session", log: false, debug: false, passthrough: false, autoUpdate: false, mitm: { enabled: false, domains: [] } } as ProxyOptions); + if (!(proxy as unknown as { listening?: boolean }).listening) await once(proxy, "listening"); + const base = `http://127.0.0.1:${(proxy.address() as { port: number }).port}`; + try { + assert.equal(incrementalTurnsEnabled(), true, "the effective gate must resolve the lane on for a fresh install"); + const response = await fetch(`${base}/__bili/plugin/turn`, { method: "GET", headers: { "x-bili-plugin": "dsh" } }); + assert.equal(response.status, 200); + const body = (await response.json()) as { enabled?: boolean; feature?: string; storage?: string }; + assert.equal(body.feature, FEATURE); + assert.equal(body.storage, "unified", "full mode keeps the sidecar gate live"); + assert.equal(body.enabled, true, "a fresh install must see the lane enabled with no operator action"); + } finally { + await new Promise((resolve) => proxy.close(() => resolve())); + store.closeQuietly(); + await new Promise((resolve) => upstream.close(() => resolve())); + } +}); diff --git a/tests/incremental-lane.test.ts b/tests/incremental-lane.test.ts index 2408a2831d..0f4ff5d270 100644 --- a/tests/incremental-lane.test.ts +++ b/tests/incremental-lane.test.ts @@ -329,18 +329,18 @@ test("incremental lane: legacy-only storage answers 503 with the enablement hint test("incremental marker divert: probe reports the rollout state", async () => { const h = await harness("full"); try { - const off = await h.probe(); - assert.equal(off.status, 200); - const offBody = off.body as { ok: boolean; enabled: boolean; feature: string; protocol: number }; - assert.equal(offBody.ok, true); - assert.equal(offBody.feature, "pluginIncrementalTurns"); - assert.equal(offBody.protocol, 1); - assert.equal(offBody.enabled, false, "default rollout percent is 0 — probe must report disabled"); - process.env.BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS = "1"; + const on = await h.probe(); + assert.equal(on.status, 200); + const onBody = on.body as { ok: boolean; enabled: boolean; feature: string; protocol: number }; + assert.equal(onBody.ok, true); + assert.equal(onBody.feature, "pluginIncrementalTurns"); + assert.equal(onBody.protocol, 1); + assert.equal(onBody.enabled, true, "GA default is 100% — the probe reports the lane enabled with no operator action"); + process.env.BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS = "0"; try { - const on = await h.probe(); - assert.equal(on.status, 200); - assert.equal((on.body as { enabled: boolean }).enabled, true, "env force flips the probe"); + const off = await h.probe(); + assert.equal(off.status, 200); + assert.equal((off.body as { enabled: boolean }).enabled, false, "the env escape hatch still turns the lane off"); } finally { delete process.env.BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS; } @@ -402,6 +402,9 @@ test("incremental marker divert: marker on a non-incremental body rides the norm }); test("incremental marker divert: rollout off answers 503 on shaped turns only", async () => { + // GA is ON by default (src/rollout.ts), so the OFF path is driven through + // the env escape hatch instead of relying on the baked-in plan. + process.env.BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS = "0"; const h = await harness("full"); try { const shaped = await h.markerTurn("/v1/messages", { conversationId: "conv-marker-off", sinceSeq: 0, request: { max_tokens: 512 }, messages: [userTurn(1)] }); @@ -411,6 +414,7 @@ test("incremental marker divert: rollout off answers 503 on shaped turns only", const plain = await h.markerRaw("/v1/messages", { model: "claude-test", max_tokens: 512, messages: [{ role: "user", content: "plain while off" }] }); assert.equal(plain.status, 200); } finally { + delete process.env.BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS; await h.close(); } }); diff --git a/tests/rollout.test.ts b/tests/rollout.test.ts index b96c96d187..adeac9b349 100644 --- a/tests/rollout.test.ts +++ b/tests/rollout.test.ts @@ -379,6 +379,25 @@ test("derivedInstallId: discriminates hosts/users — no cross-machine collision assert.equal(a, rollout.derivedInstallId("C:\\Users\\dog", "DESKTOP-ABC", "dog"), "deterministic across restarts"); }); +test("pluginIncrementalTurns ships GA: the baked-in plan is 100% and both escape hatches still work", () => { + // #3248/#5156: the incremental lane is GA. A fresh install must answer + // "enabled" from the baked-in plan alone — no env var, no config file. + const id = randomUUID(); + const shipped = rollout.ROLLOUT_FEATURES.pluginIncrementalTurns?.percent; + assert.equal(shipped, 100, "the version plan ships the lane at 100% (GA), not behind a canary"); + const on = rollout.resolveRollout("pluginIncrementalTurns", { id, env: {}, file: {} }); + assert.equal(on.enabled, true, "a fresh install enables the lane with no operator action"); + assert.equal(on.source, "bucket", "GA still resolves through the bucketing tier (percent 100 = every bucket)"); + // Escape hatch 1: the config boolean forces it off for an install. + const cfg = rollout.resolveRollout("pluginIncrementalTurns", { id, env: {}, file: { features: { pluginIncrementalTurns: { enabled: false } } } }); + assert.equal(cfg.enabled, false, "config enabled:false still turns the lane off"); + assert.equal(cfg.source, "config"); + // Escape hatch 2: the env tier wins over everything. + const env = rollout.resolveRollout("pluginIncrementalTurns", { id, env: { BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS: "0" }, file: {} }); + assert.equal(env.enabled, false, "BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=0 still turns the lane off"); + assert.equal(env.source, "env"); +}); + test("cleanup hooks", () => { // Restore env for other suites sharing this process (defensive). if (previousConfigFile === undefined) delete process.env.BILI_CONFIG_FILE; diff --git a/website/config-reference/rollout.yaml b/website/config-reference/rollout.yaml index 70c94a109f..79cc91f4c7 100644 --- a/website/config-reference/rollout.yaml +++ b/website/config-reference/rollout.yaml @@ -83,3 +83,12 @@ entries: desc_en: "Full-resend watermark fastpath (#5403/#5418): plugin-lane chat-completions turns whose previous response carried an x-bili-pf-seq stamp assert the resent prefix via the echoed count (structural scan, no full parse); on a hit the pipeline consumes stashed canonical prefix cores plus only the new tail window (byte-identical outbound provenance; ANY doubt falls back to the untouched full-parse path per turn and re-stamps, five credited misses hold the lane for one hour). Requires the client to echo the stamp back as x-bili-pf-count (dsh/pi/opencode/omp do; unadapted lanes never hit). EXPERIMENTAL grey rollout — ON by default for roughly 5% of installs (owner ruling 2026-11-02: small cohort before GA; one-time intro notice in the web UI for every install, tri-state switch in quick config). Force it with `true`, turn off with `false` (or a percent) / env = 0. See technical-notes.md “Full-resend watermark fastpath”." desc_zh: "全量重发水位快路径(#5403/#5418):插件车道 chat-completions 回合若上一轮响应盖有 x-bili-pf-seq,则用回声计数声明重发前缀(结构扫描,不做全量解析);命中时管线只消费钉存的前缀核 + 新增尾巴窗口(出站字节同源可证;任何疑点当轮回退未动过的全量解析路径并重新盖戳,连续五次计名失配将车道按住一小时)。需客户端把戳回声为 x-bili-pf-count(适配的车道回带;其余车道不会命中)。**实验性灰度**——默认仅约 5% 的安装开启(owner 裁定 2026-11-02:先小流量再 GA;web 面板对全部安装显示一次性公告、快速配置提供三态开关);`true` 强制开、`false`(或百分比)/ env = 0 关。见 technical-notes.zh-CN.md「全量重发水位快路径」。" desc_ja: "フルリセンドウォーターマークファストパス (#5403/#5418):前回のレスポンスに `x-bili-pf-seq` ス tamp を持っていたプラグインレーンのチャットコンプリートターンでは、エコーされたカウントにより再送信プレフィックスをアサートする(構造スキャン、フルパースなし);ヒット時にパイプラインはスタッシュされた正規プレフィックスコアと新しいテールウィンドウのみを消費する(バイト同一の送信プロベナンス;疑義がある場合はターンごとに未変更のフルパースパスにフォールバックし再スタンプ、5回のクレジットミスでレーンを1時間保持)。クライアントがスタンプを `x-bili-pf-count` としてエコーバックすることを要求(dsh/pi/opencode/omp は対応;未適応レーンはヒットしない)。実験的グレースケールロールアウト — インストールの約5%でデフォルトON(オーナー裁定 2026-11-02:GA前に小規模コホート;Web UIで全インストールに一度限りの導入通知、クイック設定に3状態スイッチ)。`true` で強制、`false`(またはパーセンテージ)/ 環境変数 = 0 でオフ。`technical-notes.md` の「Full-resend watermark fastpath」を参照。" + - key: rollout.features.pluginIncrementalTurns + type: "boolean | number" + default: "100 (on)" + default_zh: "100(开)" + env: BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS + group: behavior + desc_en: "Incremental turn lane (#3248): for enabled installs, native plugin hosts send only the conversation delta each turn (with the host-msgid envelope) instead of re-sending the whole history; bili rebuilds the outbound request from the unified transcript through the normal fold/render pipeline. GA since this version — fresh installs are delta-by-default. Installs without the unified-storage sidecar stay on full-resend automatically (probe reports storage=legacy-only). Opt out with false / a percent override, or BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=0." + desc_zh: "增量回合车道(#3248):对已放量的安装,原生插件宿主每回合只发对话增量(带宿主 msgid 信封),不再整段重发历史;bili 从统一 transcript 重建出站请求并走正常折叠/渲染管道。本版本起 GA——全新安装开箱即增量。没有统一存储 sidecar 的安装自动保持全量重发(探测响应 storage=legacy-only)。用 false / percent 覆盖或 BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=0 可关。" + desc_ja: "インクリメンタルターンレーン (#3248):有効化されたインストールでは、ネイティブプラグインホストが各ターンで会話の差分のみ(ホスト msgid エンベロープ付き)を送信し、履歴全体を再送信しない。bili は統合トランスクリプトから送信リクエストを再構築し、通常のフォールド/レンダリングパイプラインを処理する。このバージョンから GA——新規インストールはデフォルトで差分方式。統合ストレージ sidecar を持たないインストールは自動的にフルリセンドのまま(プローブが storage=legacy-only を報告)。false / パーセンテージ上書き、または BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=0 でオフにできる。"