Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed
| `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.watermarkV6MsgId` | boolean \| number | 0 (off) | BILI_ROLLOUT_WATERMARK_V6_MSG_ID | Composite-identity incremental fastpath v6 (#5643): plugin-lane full-resend turns whose client echoes complete per-element host ids (x-bili-pf-tail-ids tail window + x-bili-plugin-conversation carrier) judge the resent prefix by identity set-difference instead of count — only NEW elements are parsed incrementally, frozen cores ride byte-stable from the unified-storage sidecar. HARD identity gate: a missing/malformed/mis-width/inconsistent id list is refused with HTTP 400 and zero side effects (five consecutive strikes park the lane 60 min, loud fallback thereafter) — never a silent legacy fallback. Nested inside pluginFullResendWatermark (cohort ⊆ the v5 grey population) and requires the unified-storage sidecar (nodes without it stay on the baseline lanes unchanged). Default OFF — opens only by explicit rollout. |
| `rollout.features.watermarkV6Render` | boolean \| number | 0 (off) | BILI_ROLLOUT_WATERMARK_V6_RENDER | v6 render-snapshot plane (#5664): on composite-identity v6 hit-turns, steady engaged turns replay ONLY the last W frozen cores plus the new tail window through the kernel and splice previously-emitted outbound bytes back verbatim instead of re-running the full-view scan (per-turn byte check verifyRenderWindow; cumulative estimate bases advance incrementally instead of re-scanning all n rows). ANY single red gate condition (arm turn / title-gen / plane-unavailable / pressure >= 90% of model limit / snapshot-lane / blocks-active / fold-pending / absorb-active / ccr-on / markers / hydrate-failed / caps-mismatch / scheduled audit every Nth round / rows-misaligned) falls back to the untouched full-view legacy pass for that one turn and re-captures — structurally byte-identical to pre-change when red. Storage: three unified-store sidecar tables (pf_render / pf_render_log / pf_render_ckpt, schema v12, cascade-deleted with the session); MySQL/network backends degrade soft (plane unavailable -> legacy). Tunables: BILI_PF_RENDER_WINDOW (W, default 8) and BILI_PF_RENDER_AUDIT_EVERY (N, default 8). Nested inside watermarkV6MsgId (cohort is a subset of the v6 msgid population). Default OFF — opens only by explicit rollout. |
| `maskHosts` | boolean | true | BILI_LOG_MASK_HOSTS | Mask non-public target hosts in logs as <private-host>; 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 (<session>\|sub:<agent-id>) 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). |
Expand Down Expand Up @@ -434,6 +435,8 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed
| `BILI_MITM_HOSTS` | string[] (csv) | unset | — | Launcher channel: MITM whitelist hosts handed to the spawned proxy (distinct from the config-file twin BILI_MITM_DOMAINS). |
| `BILI_PLUGIN_AGENT` | boolean-ish | off | — | Spawn channel: marks a plugin-agent process. |
| `BILI_IMAGE_RESCALE_MAX_DIM` | integer | 1600 | — | Longest-edge trigger threshold (px) for the egress image downscale pass (#3400); non-numeric or below 128 ignored (default applies). Env-only by design. |
| `BILI_PF_RENDER_WINDOW` | integer | 8 | — | Bounded render window W for the v6 render-snapshot plane (#5664): how many frozen cores ride the bounded kernel pass beside the new tail window on each steady turn. Probe evidence across three strategies showed a suffix-only W-pass reproduces every element's outbound bytes exactly, so 8 is plenty; values below 1 or non-numeric fall back to 8, capped at 64. Only meaningful while rollout.features.watermarkV6Render is on. |
| `BILI_PF_RENDER_AUDIT_EVERY` | integer | 8 | — | Scheduled audit cadence N for the v6 render-snapshot plane (#5664): every N engaged hit-turns force ONE full legacy pass whose capture diff re-verifies the stored outbound rows end-to-end (bounds messageRefs/rules merge lag to <= N rounds). Values below 2 or non-numeric fall back to 8, capped at 1024. Any legacy round (red-gate fallback included) resets the counter — it IS an audit. Only meaningful while rollout.features.watermarkV6Render is on. |

<!-- /bili:gen -->

Expand Down Expand Up @@ -1935,6 +1938,7 @@ File keys resolve only when the matching env var is unset. Defaults in parenthes
| `BILI_ROLLOUT_PLUGIN_FULL_RESEND_WATERMARK` | `rollout.features.pluginFullResendWatermark` | 5 (experimental grey) |
| `BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY` | `rollout.features.pluginLaneServerHistory` | 0 (off) |
| `BILI_ROLLOUT_WATERMARK_V6_MSG_ID` | `rollout.features.watermarkV6MsgId` | 0 (off) |
| `BILI_ROLLOUT_WATERMARK_V6_RENDER` | `rollout.features.watermarkV6Render` | 0 (off) |
| `BILI_SESSION_CONTENT_STORE_PIN` | `sessions.contentStorePin` | false |
| `BILI_SESSION_GC` | `sessions.gc.enabled` | false |
| `BILI_SESSION_GC_INTERVAL_MS` | `sessions.gc.intervalMs` | 3600000 |
Expand Down
4 changes: 4 additions & 0 deletions CONFIGURATION.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
| `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.watermarkV6MsgId` | boolean \| number | 0(关) | BILI_ROLLOUT_WATERMARK_V6_MSG_ID | 复合身份增量快路径 v6(#5643):插件车道全量重发回合,当客户端回带逐元素宿主 id(x-bili-pf-tail-ids 尾窗 + x-bili-plugin-conversation 载体)时,用身份集合差而非计数判定重发前缀——仅增量解析新增元素,冻结核自统一存储 sidecar 逐字骑乘。身份硬门:id 列表缺失/格式错/宽度不符/一致性断裂一律以 HTTP 400 拒绝且零副作用(连续五次连击按住车道 60 分钟,之后响亮降级)——绝不静默回退 legacy。嵌套于 pluginFullResendWatermark(人群 ⊆ v5 灰度人群),并依赖统一存储 sidecar(无此设施的节点原样走基线车道)。默认关——仅由显式放量开启。 |
| `rollout.features.watermarkV6Render` | boolean \| number | 0(关) | BILI_ROLLOUT_WATERMARK_V6_RENDER | v6 渲染快照平面(#5664):复合身份 v6 命中回合中,稳态轮只把最近 W 个冻结核 + 新增尾窗送入内核、把此前已出站的字节逐字拼回,不再跑全量视图扫描(每轮字节校验 verifyRenderWindow;累计估算基数增量推进而非重扫全部 n 行)。任一红色门控条件(arm 轮/title-gen/plane-unavailable/压力 ≥ 模型上限 90%/snapshot-lane/blocks-active/fold-pending/absorb-active/ccr-on/markers/hydrate-failed/caps-mismatch/每 N 轮计划审计/rows-misaligned)当轮回退未动过的全量 legacy 路径并重新捕获——红色时与改动前结构上逐字节一致。存储:统一存储三张 sidecar 表(pf_render / pf_render_log / pf_render_ckpt,schema v12,随会话级联删除);MySQL/网络后端软降级(plane 不可用 → legacy)。可调项:BILI_PF_RENDER_WINDOW(W,默认 8)与 BILI_PF_RENDER_AUDIT_EVERY(N,默认 8)。嵌套于 watermarkV6MsgId(人群 ⊆ v6 msgid 人群)。默认关——仅由显式放量开启。 |
| `maskHosts` | boolean | true | BILI_LOG_MASK_HOSTS | 日志中把非公开目标主机遮成 <private-host>;凭据头无论此开关如何总是遮盖。 |
| `security.adminRelay` | boolean | false | — | 允许宿主(当前为 dsh web)把它自己入口域名下的整个 /__bili/ 管理面中继到本机代理,使远程浏览器能打开面板(#3373)。默认关闭、仅配置文件。中继跳到达代理时是本机非浏览器客户端(回环源地址 + 回环 Host、无 Origin 头),管理端门槛不变;开启后,凡能访问宿主 web 入口的人都能改配置、写凭据——请先给入口加鉴权/反代。 |
| `subagentSplit` | boolean | true | BILI_SUBAGENT_SPLIT | Claude 子代理拥有独立会话命名空间(<session>\|sub:<agent-id>),不再排队在主会话锁后。仅 anthropic 线路 —— Responses 线路上本开关无效(见 `subagentSplit` / BOTH-mechanisms 作用域说明)。 |
Expand Down Expand Up @@ -434,6 +435,8 @@
| `BILI_MITM_HOSTS` | string[] (csv) | unset | — | 启动器通道:传给被派生代理的 MITM 白名单主机(区别于配置文件对应项 BILI_MITM_DOMAINS)。 |
| `BILI_PLUGIN_AGENT` | boolean-ish | off | — | 派生通道:标记插件 agent 进程。 |
| `BILI_IMAGE_RESCALE_MAX_DIM` | integer | 1600 | — | 出站图片降采样 pass 的最长边触发阈值(像素,#3400);非数字或低于 128 的取值按默认处理。设计上仅环境变量。 |
| `BILI_PF_RENDER_WINDOW` | integer | 8 | — | v6 渲染快照平面(#5664)的有界渲染窗口 W:每个稳态轮送入内核的冻结核数量(与新增尾窗并列)。三种策略的探针证据表明后缀 W-pass 能逐字节复现每个元素的出站字节,8 已足够;低于 1 或非数字的取值回退为 8,上限 64。仅在 rollout.features.watermarkV6Render 开启时有意义。 |
| `BILI_PF_RENDER_AUDIT_EVERY` | integer | 8 | — | v6 渲染快照平面(#5664)的计划审计周期 N:每 N 个命中轮强制跑一次全量 legacy pass,其捕获 diff 对已存出站行做端到端复验(把 messageRefs/rules 合并滞后钉在 ≤ N 轮内)。低于 2 或非数字的取值回退为 8,上限 1024。任何 legacy 轮(含红色门控回退)都会清零计数——它本身就是一次审计。仅在 rollout.features.watermarkV6Render 开启时有意义。 |

<!-- /bili:gen -->

Expand Down Expand Up @@ -1912,6 +1915,7 @@ ACP 原生 agent(当前为 `pi` 扩展)会在每个进程内向代理上报
| `BILI_ROLLOUT_PLUGIN_FULL_RESEND_WATERMARK` | `rollout.features.pluginFullResendWatermark` | 5 (experimental grey) |
| `BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY` | `rollout.features.pluginLaneServerHistory` | 0 (off) |
| `BILI_ROLLOUT_WATERMARK_V6_MSG_ID` | `rollout.features.watermarkV6MsgId` | 0 (off) |
| `BILI_ROLLOUT_WATERMARK_V6_RENDER` | `rollout.features.watermarkV6Render` | 0 (off) |
| `BILI_SESSION_CONTENT_STORE_PIN` | `sessions.contentStorePin` | false |
| `BILI_SESSION_GC` | `sessions.gc.enabled` | false |
| `BILI_SESSION_GC_INTERVAL_MS` | `sessions.gc.intervalMs` | 3600000 |
Expand Down
52 changes: 52 additions & 0 deletions src/persist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2291,6 +2291,58 @@ export class SessionStore {
if (Array.isArray(reg)) this.shadow.pfDeleteAll(reg);
}

/** #5664 render snapshot plane facade — same guard shape as the identity
* plane: null/empty/false = "plane unavailable right now" and the v6
* lane fails soft onto the legacy full path for that turn only.
* A failed render commit is logged once, then fails soft for THIS turn
* (same as pfCommitTurn above). */
pfRenderAvailable(): boolean {
if (!this.shadow || this.shadow.stats.disabled) return false;
try {
return this.shadow.pfRenderAvailable();
} catch {
return false;
}
}

pfRenderRows(sid: string): { pos: number; rowJson: string | null }[] {
if (!this.shadow || this.shadow.stats.disabled) return [];
return this.shadow.pfRenderRows(sid);
}

pfRenderCommit(
sid: string,
args: {
rows: { pos: number; rowJson: string | null }[];
logEntries: { kind: string; payloadJson: string }[];
checkpointMetaJson?: string;
ts?: number;
},
): number | null {
if (!this.shadow || this.shadow.stats.disabled) return null;
try {
return this.shadow.pfRenderCommit(sid, args);
} catch (err) {
this.log("warn", `[persist] pf render commit failed (${sid}): ${String(err)}`); // loud once, fail-soft for THIS turn
return null;
}
}

pfRenderMeta(
sid: string,
): {
ckpt: { ckptLsSeq: number; metaJson: string; checksum: string; updatedAt: number } | null;
log: { lsSeq: number; kind: string; payloadJson: string; ts: number }[];
} | null {
if (!this.shadow || this.shadow.stats.disabled) return null;
return this.shadow.pfRenderMeta(sid);
}

pfRenderCkptIntact(sid: string): boolean {
if (!this.shadow || this.shadow.stats.disabled) return false;
return this.shadow.pfRenderCkptIntact(sid);
}

/** #5312: reversible single-block archive / restore (see UnifiedStore). */
unifiedArchiveBlock(sessionId: string, blockId: string, archiveDir?: string): { ok: boolean; exportPath?: string; reason?: string; contentRowsDeleted?: number } | null {
if (!this.shadow || this.shadow.stats.disabled) return null;
Expand Down
9 changes: 9 additions & 0 deletions src/rollout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ export const ROLLOUT_FEATURES: Record<string, RolloutPlan> = {
// `BILI_ROLLOUT_WATERMARK_V6_MSG_ID=1`; bucketed growth stays nested
// inside the v5 watermark cohort.
watermarkV6MsgId: { percent: 0, base: "pluginFullResendWatermark" },
// #5664 station-3 fast emit: v6 identity lanes with a healthy render
// snapshot plane serve steady hit turns by splicing the cached outbound
// rows (frozen prefix verbatim + bounded window-pass over the last cores)
// instead of rescanning n rows; every red gate condition (pressure,
// caps mismatch, audit cadence, hydrate failure, byte-mismatch vs the
// stored suffix) falls back to this branch's baseline path byte-for-byte.
// Requires watermarkV6MsgId + the pf_render plane; nested cohort bucketing
// inside the v6 lane. Default 0%.
watermarkV6Render: { percent: 0, base: "watermarkV6MsgId" },
// #4804 WS delta continuation: codex/opencode WebSocket clients that keep a
// previous_response_id checkpoint stop reconstructing full history on every
// turn — the session augments the delta with the server-committed previous
Expand Down
Loading
Loading