Repository navigation
fix: window credibility as first-class state on every surface (#1849) - #1929
ranxianglei wants to merge 8 commits into
Conversation
When no authoritative context window reaches the proxy (plugin header, runtime-info, launcher, operator-configured, tier negotiation), sizing falls back to published guesses (registry-peek / built-in table / default) and every downstream percentage silently becomes estimate-grade. Persist and surface the verdict: - server: lastWindowAuthoritative on session metadata; sendStats carries windowSource + windowAuthoritative; the window-absence log splits — plugin-present-but-silent escalates to warn, a plain client stays info-grade with guess wording - plugin /acp: status JSON gains windowAuthoritative; the panel shows an ESTIMATE banner (before-footer slot, stripper-safe) exactly when non-authoritative - web UI: session detail badges estimate-grade windows with the source named in the tooltip (zh/en) - dsh-native client: three degradation branches (no resolver, resolver without a window, services never binding) each warn once via console.warn + persistClientEvent (GUI hosts swallow stderr, #1158) No config surface changes. The dsh host-side root cause (web profile structurally producing no window) stays out of scope — this PR makes the degradation visible everywhere it lands.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1940-pr.1929.bd3fb4bThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1929.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…less flavor rejects every resolve (#1849) Live-machine e2e (real dsh 0.1.5-rc.2, throwaway profile, npm-pack tarball): resolveModelInfo exists but rejects every call with 'Cannot read properties of undefined (reading resolveModelInfoFor)' — master's .catch committed a windowless cache silently, so none of the client-side #1849 warnings ever fired. The reject branch now warns with the host's own error (once per process; retryAt-driven retries continue). Also: dsh-native + dsh-settings-ui suites redirect XDG_STATE_HOME — their persistClientEvent output was polluting the developer's real bili.log (40+ stray [dsh-client] lines per full run).
|
Live e2e verification + one real gap found & fixed (follow-up commit 7219ab3, rebased onto the master sync merge). Ran the real thing: dsh 0.1.5-rc.2 headless, throwaway profile, 1. Proxy-side warn fires live. settings.yaml declares 2. Client-side warn had a hole, now closed. Branch-by-branch instrumentation on the live host showed i.e. dsh's own model-catalog registry is uninitialized in this host flavor — their resolver throws instead of returning. That upstream defect stays out of scope here (candidates a–d in the PR description), but our plugin now names it verbatim on both client surfaces. 3. Test hygiene: the dsh-native / dsh-settings-ui suites were leaking Gates after rebase: typecheck ✓, 60/60 targeted (window-warn 4 + dsh-native 42 + dsh-settings-ui 7 + issue1849 7) ✓, build ✓. |
按 PR Review 规范完整过了一遍,对照的是当前 head 结构化七问
非阻塞备注(不拦合并)
测试有效性两份新测试有牙、非恒真/mock-only:分类单测覆盖全部 9 源 + flag 双向优先 + 空/null 边界;e2e 起真代理 + mock upstream,断言 status JSON / stats / 日志三面一致且含否定断言(纯客户端不升级 warn、健康服务绝不 warn、新增 reject 分支用例);dsh 侧断言精确行数 + 消息正则。 CIbuild-artifact、version-guard、全部 e2e lane(codex / pi / opencode / dsh / real-image)、hermetic registry 均绿;head 判定:可合并(人工)。方向对、范围干净(11 文件每一行都服务于目的,无跑题 / 无 whitespace churn / 无 lockfile churn)、wire 忠实、无配置面。上面两条 🟡 都不构成阻塞。 |
, review #1929) A single boot-race reject that recovers on the next cooldown retry must not leave a misleading 'host's model config is NOT reaching the proxy' line; the counter resets on any successful resolve. Warn text now carries the consecutive count.
|
CI 失败定性 + 两条 🟡 已处理。 **CI( 🟡 reject 首次即告警 → 已修( 🟡 #1849 Defect B 跟踪 → 已拆独立 issue #1932(dsh 插件窗口上报不感知真实请求模型/多档位—— 另:#1849 的宿主侧根因(dsh headless |
复核了最新 head 七问(增量复核,未变者简述)
两条 🟡 处置确认
新问题:本 PR 新增用例定时 flake(唯一挡合并项)head 判读:测试定时敏感,不是产品逻辑回归。证据链:
按 §7.2「测试必须确定性、不得依赖环境运气」,这条新用例本身要修,而不是靠重跑碰运气。建议(任选,作者定):
它是全新用例,就地修掉最干净,免得合进去后某次 run 又红。需要的话我可以给具体 patch。 判定代码方向对、两条 🟡 已验证收口、wire 忠实、无配置面——逻辑上可合并。但当前 head 因这条 flaky 测试红着 |
…ow to the proxy (#1849) The headless flavor's llm.resolveModelInfo rejects every call (its model catalog is never initialized) and the web-profile flavor binds neither model service — in both shapes x-bili-plugin-context-window went unstamped forever and the proxy silently sized against registry-peek. The host's own launch config (~/.dsh/settings.yaml) declares this session's model and its contextWindow; read it (line-based, dependency-free, READ-only — same discovery discipline as parseDshSettingsYaml) as the fallback: - resolve rejected / resolver absent / resolved-without-window → the current selection's window from settings.yaml lands in modelInfo.cached, so the existing header stamp (:860) and the #955 runtime-info report carry the REAL number; the degradation warn only fires when even the file cannot supply one - services never bound at all (web profile) → settings.yaml's agent-default-model states the model + window directly - live-verified on real dsh 0.1.5-rc.2 headless: session metadata flips winSrc=registry-peek/auth=false → winSrc=plugin/auth=true
|
#1849 送达修复已并入本 PR( 按 owner 方向落地(不建每模型清单,只取当前 session 所选模型的窗口):
真实 dsh 0.1.5-rc.2 headless 活体验证(宿主 resolver 仍每次抛
测试: |
复核了最新 head 结构化七问
行为变更(旧→新,你已披露、我确认成立)
非阻塞备注(均不拦合并)
测试有效性三份新用例都有牙、含否定断言:reject 兜底断言 header 具体值 CIhead 判定可合并(人工)。范围干净(14 文件每一行服务于目的)、wire 忠实、无 bili 配置面、无缓存影响、测试有牙、CI 全绿。这轮把 #1849 从「看得见」推进到「送得到」,方向与实现都对。上面几条 🟡/⚪ 均不构成阻塞。 |
…indows (#1849) settings.yaml only carries models the user declared. When the headless host never initializes the pi-ai catalog, resolveModelInfo rejects and the settings file may not contain the selected model either (e.g. dsh alias ids like deepseek-flash). Read the host's own bundled sources - @earendil-works/pi-ai dist/providers/all.js (1354 models) and @deepseek-ai/dsh-llm-deepseek resolveAdapterOptions - as a second fallback tier, mirroring what the in-memory route resolution would have served. Settings win over catalog; both are best-effort.
|
Follow-up to 38abfd9 — second fallback tier: the host's bundled model catalog. Why: settings.yaml only carries models the user declared. Two real gaps remain when the headless host never initializes the pi-ai catalog:
What memory actually serves is the merge of settings-declared models and the bundled catalog ( Sources (read-only, best-effort, absolute-path
Priority: service/memory (unchanged, authoritative) → settings.yaml → bundled catalog → previous warn-only behavior. Every tier reports through both existing channels (per-request stamp header + #955 runtime-info table), so the proxy's Live verification (throwaway dsh profile, global settings backed up/restored, diff-verified identical):
Known edge (unchanged): first-request header race — the stamp header is computed before the reject lands; the runtime-info report lands during flight and the proxy sizes from the table (second request onward carries the header). Same shape as the desktop healthy path. Gates: typecheck ✅ · dsh-native 48/48 + launcher 266/266 ✅ · build ✅ |
复核了最新 head 结构化七问(本轮增量)
|
…er for dsh context windows (#1849) dsh-llm-pi-ai resolves a model's window as entry.contextWindow ?? builtin-by-id ?? request.defaultContextWindow — the route's declared default. Mirror that order: scoped settings declaration, bare declaration, bundled catalog, then the route's defaultContextWindow (or the host's 262144 mirror when unset), gated on the model being declared windowless under that provider. Provider-aware parsing now records scoped/bare windows, provider-level defaults, and the declared-but-windowless set (parseDshWindowSources), fixing the old parser's providers-mode swallow of deeper models: blocks.
|
Fourth tier — the route's Gap. Fix. Tests. tests/dsh-native.test.ts 48→52: declared default stamps 400000 + runtime-info + note; unset default mirrors 262144; catalog beats route default for a catalog-known id (memory order); scoped declarations disambiguate one id across two providers. 52/52 green, launcher+dsh-settings-ui+dsh-profile 273 green, typecheck+build green. Live (real dsh 0.1.5-rc.2, throwaway profile, windowless Env note for reproducers: the plugin's |
复核了当前 head 结构化七问(本轮增量)
parser bug 修复确认providers-mode 之前会吞掉更深的 非阻塞备注(均不拦合并)
测试有效性(本轮新用例都带牙且确定)
活体验证(你做的,认可)真实 dsh 0.1.5-rc.2 throwaway 画像,windowless CIhead 判定可合并(人工)。范围干净(14 文件每行服务于 #1849)、wire 忠实、无 bili 配置面、无缓存影响;核心保证(不发造未知模型窗口 + 目录先于 route 默认的内存顺序)代码与测试双钉、CI 全绿。四层兜底把 #1849 的送达面补到与宿主内存解析完全对齐。上面几条 ⚪ 均为前瞻/可选,不构成阻塞——可以合。 |
|
看到你的评审说有阻塞性问题 麻烦修复 另外注意到#1943 |
|
#1943 在本pr没有存在的意义 关闭 |
Fixes #1849
Problem
When no authoritative context window reaches the proxy (plugin header, runtime-info, launcher env, operator-configured route model, tier negotiation), sizing falls back to published guesses (registry-peek / built-in table / default) — and every downstream percentage (nudge bands, /acp panel, Web UI bars, stats) silently becomes estimate-grade. The dsh web-profile flavor is the worst case (#1849): the host structurally never produces a window, a 1M model gets sized against 253725 (~25%), and the only trace is one info line in bili.log.
Design (per the issue's two open points)
windowAuthoritative: boolean, derived per request from the winning source: authoritative =plugin/runtime-info/launcher/configured/anthropic-beta/model-suffix, or operator tuning (compress.modelContextLimit), or the codex REQ: codex 压缩预算协调 + 匿名代理模式拦截伪造(根本解决方案) #321 clamp. Guess =registry-peek/table-or-registry/default.Changes
src/server/context-window.ts:AUTHORITATIVE_WINDOW_SOURCES,isAuthoritativeWindowSource(),sessionWindowAuthoritative(metadata)— explicit flag wins; legacy persisted sessions (no flag) fall back to source classification.src/server.ts: persistsession.metadata.lastWindowAuthoritative(next tolastWindowSource);/__bili/statscarrieswindowSource+windowAuthoritativeper session; the window-absence log splits on plugin presence — a plugin present but silent escalates towarn(actionable defect: the host's own limit is not reaching the proxy), a plain client staysinfo-grade with distinct guess wording (registry guessing is the designed fallback).src/plugin.ts:/__bili/plugin/statusJSON gainswindowAuthoritative; the panel pushes an⚠️ Window X is an ESTIMATE (source: Y) … (#1849)line through the same before-footer slot as the advisory/Web-UI links ([follow-up #1483] Advisory visibility in native/plugin lanes: all three surfaces are effectively invisible #1577 — stripper-safe, before the footer anchor).src/web/sessions-data.ts+client.ts+i18n.ts: session detail badges estimate-grade windows (window est./窗口估算) with the source named in the tooltip — same discipline as 任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839's estimate-grade numerator, now applied to the denominator.src/agent/dsh-native.ts: client-side degradation warning for the three branches (nollm.resolveModelInfo; resolver answer without acontextWindow; model services never binding after 3 stamps = past the inject boot race). Once per process,console.warn+persistClientEvent(GUI hosts swallow stderr, 方式一安装的dsh 原生插件:llm-pi-ai 传输(OpenAI SDK + options.fetch 注入)绕过 globalThis.fetch 拦截,模型请求不进代理、压缩完全不生效 #1158). Reset seam_resetWindowWarningForTest().Config surface
None. No new config fields, env vars, or CLI flags — the verdict is derived from data the proxy already resolves per request.
Compression modes
Wire behavior unchanged in both modes: this adds observability fields (JSON) + a human-only panel line inserted before the stripper's footer anchor. Request bodies are byte-identical.
Tests
tests/issue1849-window-authoritative.test.ts(7): classification unit tests + e2e — guess path marked estimate-grade on status JSON + panel + stats with info-grade log; plugin-present-but-silent escalates to warn; plugin header and runtime-info authoritative with no banner.tests/dsh-native-window-warn.test.ts(3): resolver-without-window warns once durably; no-resolver warns; services-never-bind warns after 3 stamps while healthy services never warn.Gates
npm test: 3668 tests, 3647 pass / 2 fail / 19 skipped — both failures (tests/update-notes.test.ts发版可见性:分级标签的 release 元数据(模型撰写摘要)+ 用户版跨 span 更新说明 + acp_status //acp 面板送达「更新已就绪待重启」(#1577 延伸) #1870 byte-exact assertions) reproduce identically on master (local-env pre-existing, not from this branch)Out of scope
The dsh host-side root cause (web profile structurally producing no window — the issue's candidates a–d) needs a live dsh web instance and belongs to the dsh host; this PR guarantees the degradation is VISIBLE everywhere it lands.
Note for reviewers running locally
Under a bili-proxied shell,
BILI_PROVIDER_REWRITES/BILLION_CONTEXT_PROXYleak into dsh-native suites and makeplanNativeDshreturnoff(attach tests burn their 15s poll budgets). Scrub them (env -u …) when running those suites locally.