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
28 changes: 17 additions & 11 deletions src/host-plugin-notice.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// #2861: known third-party host-side plugins whose context meter reads the
// host's LOCAL session store. While bili compresses the wire, that store
// diverges from what the model actually sees: dsh's durable log stays lossless
// by architectural invariant, so a meter computed from it reports the unfolded
// local surface (~full history) even though every request carries far fewer
// tokens. This module detects such plugins conservatively from the client's own
// registry (best-effort, read-only, cached) so the web UI tells users their
// figures are pre-compression instead of letting them read "~1M" as a stuck
// compressor. Every fs access is guarded — detection must NEVER fail a request
// #2861: known third-party host-side plugins whose context BREAKDOWN derives
// from the host's LOCAL session store. While bili compresses the wire, that
// store diverges from what the model actually sees: dsh's durable log stays
// lossless by architectural invariant and folds happen outside the host event
// stream (storage: shadow), so the per-category composition / timeline a meter
// computes from it is the PRE-COMPRESSION distribution even though every
// request carries far fewer tokens. (dsh-context's headline size is anchored on
// provider usage and tracks the effective volume — only its split is stale;
// #3303 measured the two equal within one sampling phase.) This module detects
// such plugins conservatively from the client's own registry (best-effort,
// read-only, cached) so the web UI tells users their segment composition is
// pre-compression instead of letting them read a stale split as the model's
// view. Every fs access is guarded — detection must NEVER fail a request
// or a page load.
//
// Detection keys off the dsh profile manifest (package.json): a bundle plugin
Expand Down Expand Up @@ -45,8 +49,10 @@ interface HostPluginEntry {
// One row per known host-side metering plugin — adding the next one adds one
// entry here.
const KNOWN_HOST_PLUGINS: readonly HostPluginEntry[] = [
// #2837: dsh-context meters dsh's durable (lossless) session log, so under
// active compression its figures are the pre-compression local surface.
// #2837/#3303: dsh-context's segment composition / timeline derive from
// dsh's durable (lossless) session log, so under active compression they are
// the pre-compression distribution; its headline size is provider-usage-
// anchored and tracks the effective volume.
{ client: "dsh", id: "dsh-context", depName: "dsh-context", loaderId: "dsh-context", requiresBiliLane: true },
];

Expand Down
4 changes: 2 additions & 2 deletions src/web/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const MESSAGES: Record<Locale, Record<string, string>> = {
"advisory.restartDesc": ":安全版本已安装到磁盘,但当前进程仍在运行受影响版本。原因:",
"advisory.restartHint": "。重启 bili 后生效。",
"hostplug.on": "检测到宿主侧插件",
"hostplug.desc": "它显示/记录的上下文为压缩前的本地口径(本地日志按 dsh 架构要求保持无损),数值不准确;显示有效尺寸需其对 billion-context 做适配。",
"hostplug.desc": "它的分段构成/时间线按压缩前的本地口径估算(本地日志按 dsh 架构要求保持无损),各段比例可能与实际发送内容不符;头部上下文尺寸跟随实际发送量。",
"hostplug.hint": "当前有效上下文以 /acp 或 GET /__bili/plugin/status → contextTokens 为准。",
"hostplug.dismiss_btn": "关闭",
"hostplug.dismissed": "已关闭该提示",
Expand Down Expand Up @@ -646,7 +646,7 @@ export const MESSAGES: Record<Locale, Record<string, string>> = {
"advisory.restartDesc": ": the safe version is installed on disk, but this process is still running the affected version. Reason:",
"advisory.restartHint": ". Restart bili to activate it.",
"hostplug.on": "Host-side plugin detected",
"hostplug.desc": "Its displayed/recorded context figures are the pre-compression local meter (the durable log stays lossless by dsh architecture requirements), so they are not accurate while compression is active; showing the effective size needs a billion-context adaptation.",
"hostplug.desc": "Its segment composition / timeline is estimated from the pre-compression local meter (the durable log stays lossless by dsh architecture requirements), so the per-segment proportions may not match what is actually sent; the headline context size tracks the real sent volume.",
"hostplug.hint": "Authoritative effective context: /acp or GET /__bili/plugin/status → contextTokens.",
"hostplug.dismiss_btn": "Dismiss",
"hostplug.dismissed": "Notice dismissed",
Expand Down
9 changes: 9 additions & 0 deletions tests/issue2861-host-plugin-notice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,12 @@ test("#2861: i18n — hostplug.* key sets are identical across locales and non-e
assert.ok(MESSAGES["zh-CN"][k]?.length > 0 && MESSAGES["en"][k]?.length > 0, `${k} non-empty in both locales`);
}
});

test("#3303: notice scopes the pre-compression claim to segment composition/timeline, not the headline size", () => {
const zh = MESSAGES["zh-CN"]["hostplug.desc"] ?? "";
const en = MESSAGES["en"]["hostplug.desc"] ?? "";
assert.ok(!zh.includes("数值不准确"), "zh desc must not re-assert the headline numbers are inaccurate (the #3303 false alarm)");
assert.ok(zh.includes("分段") || zh.includes("构成"), "zh desc must scope the pre-compression claim to segment composition");
assert.ok(!/not\s+accurate|inaccurate/i.test(en), "en desc must not re-assert the headline figures are inaccurate (the #3303 false alarm)");
assert.ok(/composition|segment|timeline/i.test(en), "en desc must scope the pre-compression claim to segment composition / timeline");
});
Loading