Skip to content

fix(session): refuse stale effectiveConfig stamps via config-file epoch - #3431

Merged
ranxianglei merged 3 commits into
masterfrom
2026-10-16_config-epoch
Oct 17, 2026
Merged

ranxianglei merged 3 commits into
masterfrom
2026-10-16_config-epoch

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What this fixes

Every wire request stamps the session's resolved config snapshot (metadata.effectiveConfig), but the stamp was only refreshed on the session's next wire request on the same instance. Consequences:

  • Tool-path readers (plugin tool API, /__bili/plugin/status panels, nudge re-anchor) executed settings the user had already deleted from the config file — the October incident: a user-disabled externalSummary chain kept running for days off one old stamp.
  • On a multi-instance machine (several bili instances sharing sessions), the tool path reads whatever instance last served a wire request, so a session carries that instance's stamp — config edits on the file never reach the tool path at all.

The fix

configFileEpoch() (src/config.ts): sha256 of the live config file content. Content-keyed on purpose — byte-identical files validate cross-instance (identical file tier ⇒ a foreign stamp is still a correct resolution), any edit diverges the hash. Cost mirrors loadConfigFile()'s existing per-call read (page-cache hit).

  • storeEffectiveConfig stamps metadata.effectiveConfigEpoch next to the snapshot; forks inherit the key (plugin.ts copy list).
  • effectiveConfig refuses the snapshot when the epoch no longer matches the live file and re-resolves the file tier (global compress.*, including externalSummary) onto the fallback config. Provider/model cascade levels are deliberately NOT re-resolved (they need the request URL) — the session's next wire request re-stamps the full cascade.
  • The nudge growth-margin reader (session.ts) takes the same guard.
  • Legacy snapshots without an epoch keep the old merge semantics — no behavior change for old sessions.
  • /__bili/memory-family surfaces are untouched; only the stamp guard changed.

Deliberate trade-off

When a stamp goes stale, provider/model-level compress overrides (routes in the config file) are dropped from the tool-path read until the next wire request re-stamps them — the live global tier is re-resolved, so a deleted chain stays deleted (the incident class this fixes) and a globally-configured knob keeps working. Losing a provider-scoped knob for one request window is strictly safer than executing retired settings.

Tests

  • New tests/config-epoch.test.ts (5): same-source stamp wins; edited file refuses the stamp + re-resolves the live tier; retired externalSummary cannot ride a stale stamp (the incident, end-to-end shape); byte-identical file at a different path validates, diverged content refuses; legacy stamps (no epoch) keep old semantics.
  • Goldens re-pinned: metadata digest gains exactly the epoch key (content-hash is deterministic across runs — a path-keyed variant broke golden determinism and was rejected).
  • Green locally: plugin-fork 55 (fork inheritance), persona/compress-settings/issue2582 102, issue833/admin/status-panel family 31, side-lane/continuity 10, memory-diagnostics 3, golden-storage-render 5×3 runs, tsc clean.

Fixes the incident class tracked as ⑥ on #2960.

…ch (#3430)

Every wire request stamps metadata.effectiveConfig, but the stamp only
refreshed on the NEXT wire request — tool-path readers (plugin tool API,
status panels, nudge re-anchor) kept executing settings the user had
already deleted from the config file, and a session on a multi-instance
machine could carry a foreign instance's stamp for days (the October
externalSummary incident: a user-disabled summary chain kept running).

- configFileEpoch() (src/config.ts): sha256 of the live config file
  content — content-keyed so byte-identical files validate cross-instance
  while any edit diverges; cost mirrors loadConfigFile()'s per-call read.
- storeEffectiveConfig stamps metadata.effectiveConfigEpoch next to the
  snapshot; forks inherit the key (plugin.ts copy list).
- effectiveConfig refuses the snapshot when the epoch no longer matches
  and re-resolves the live file tier (global compress.*, including
  externalSummary) onto the fallback; provider/model cascade levels are
  deliberately re-stamped by the next wire request (they need the
  request URL). The nudge growth-margin reader takes the same guard.
- Legacy snapshots without an epoch keep the old merge semantics.
- Goldens re-pinned: metadata digest gains the epoch key only.
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-16_config-epoch (ffe07f7)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4081-pr.3431.894df59

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-pr3431.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] 🏷 (ai: vllm-qwen/qwen3.8-27b)

收到。这是一个 [PR] 工单,对应 PR #3431(分支 2026-10-16_config-epoch)——已完成的工作,我不重做,改为核对代码、验证测试、确认 CI 状态后给出结论。

查重: 不重复——本工单即 PR #3431 的镜像;检索 open/closed 未发现其他 effectiveConfig 陈旧 stamp / config epoch 类在途条目(最接近的是 #2960 ⑥ 事件记录,本 PR 正是其修复)。

开始核对。

…nt refs at #2960⑥

Review fix-up for the config-epoch guard: the staleEffectiveStamp docstring claimed
the epoch hashes the resolved path (cross-instance stamps never validate), which
contradicts the implementation (sha256 of file CONTENT — byte-identical files do
validate, tests/config-epoch.test.ts case 4) and the configFileEpoch docstring.
Also re-point the '#3430' references: that number is the unrelated vscode
cancel-flake PR; the incident class is tracked as ⑥ on #2960.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

PR #3431(code epoch 拒绝过期 effectiveConfig stamp)审核完毕。结论:可合——原 head 6f035159b CI 43 项检查全绿;我顺手修了新增注释里的两处事实错误(见下),已推 fix-up commit a1c28f71c,新 head CI 进行中(36/42 已完成且全绿,余为长测试分片)。合并由你操作:#3431

结构化八问

  1. 是什么问题:会话的配置快照(metadata.effectiveConfig)只在同一实例的下一个 wire 请求时刷新,工具路径(plugin tool API、/__bili/plugin/status 面板、nudge re-anchor)拿着没有请求上下文的旧快照执行配置——用户已从配置文件删掉的设置继续生效。十月事故(用户禁用的 externalSummary 链跑了数天)即此类;多实例机器上 stamp 还可能长期属于另一实例。
  2. 什么原因导致的:快照落盘时不带"来源身份"——读取方无从判断解析时刻的配置文件是否还是当前文件,于是无条件信任旧快照。缺的是来源校验,不是刷新频率。
  3. 影响范围与严重程度:所有走插件模式工具路径的会话(任何"文件已改但会话还没发下一个 wire 请求"的窗口);严重度 = 执行已退役配置(行为偏差,非数据丢失);wire 路径不受影响(每次请求现解析)。
  4. 怎么修复的:stamp 旁加 effectiveConfigEpoch = 活配置文件的 sha256(内容键:字节相同的文件跨实例互认,任何编辑都改变哈希)。读取端发现纪元不符 → 拒绝快照,把 file 层(global compress.*,含 externalSummary)重解到裸 fallback 上;provider/model 级联不重解(需要请求 URL),由下一次 wire 请求重新盖全量 stamp。无纪元的旧快照保持旧语义;fork 拷贝清单继承纪元键。
  5. 是否有回归问题:逐项审过既有行为——fresh-stamp 路径与原逻辑字节一致(新分支仅在"有字符串纪元且不匹配"时触发,旧会话零变化);nudge margin 读者 stale 时回退 kernel 默认间隔(defaultConfig(1) → growthFloor==growthCap==50000 扁平 50K,合理);fork 拷贝纯增量;未触碰 kernel/、update.ts、config schema、持久化版本、wire 形状。有意的行为变更(已在 PR 披露):stale 窗口内 provider-scoped compress 覆盖被丢弃直到下次 wire 请求(文档化的取舍,比执行退役设置更安全);metadata 新增一个键 → golden 仅 metadata 段 digest 重钉,其余 digest 不变。
  6. 是否破坏缓存:不涉及——会话身份/去重键/增量游标均未动;state digest 因新 metadata 键漂移属预期且已被 golden 钉住。
  7. 是否改了设计方向:不转向——在既有 stamp 机制上加守卫,单一投影([Bug] recommend/apply 对同一区间的 turn-integrity 判定永久不一致:acp_status 反复推荐的区间被 apply 侧整段拒绝(0.1.196,Range would split N turn(s) at the protected-zone boundary) #3236)等既有决策不受影响。
  8. 是否引入新配置:不涉及——无新 env/config/CLI 面。

独立验证(非照抄 PR 描述)

  • applyCompressSettings(src/compress-settings.ts:259)对未声明字段是"继承 base";而 fallback opts.kernelConfig 是裸 defaultConfig(src/config.ts:1346,不含文件设置)→ 被删的旋钮(stale 路径下)确实留不下来,事件类修复成立,不是纸面成立。
  • effectiveConfig() 调用点仅 src/plugin.ts:1454/1781,nudge 读者自带守卫,handle.ts:2090 是盖章侧不是绕过读取点——无旁路。
  • 本地定向测试绿:config-epoch 5 + golden-storage-render 5 + plugin-fork/compress-settings/issue1595-nudge-reanchor/dsh-persona-fingerprint 共 111 通过。
  • base 新鲜度:base 落后 master 4 个提交,但那 4 个只动 ci.yml + vscode-copilot.test.ts,与本 PR 文件零重叠,无冲突风险,无需 rebase。
  • 测试有效性:5 个新用例断言具体解析值(777_000 压过 123_456、删除后 externalSummaryEnabled(read) === false、字节相同跨路径认/内容分叉拒、legacy 保持旧语义),回归时抓得住,非恒真断言。

顺手修的注释缺陷(commit a1c28f71c,docs-only 零行为)

查重结论(首条回复已给):不重复——本 issue 即 PR #3431 镜像,最近相关项 #2960⑥ 是本 PR 所修的事件记录。

@ranxianglei
ranxianglei merged commit 78d9e4a into master Oct 17, 2026
42 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.500-master.78d9e4a (rolling master tag).

npm install -g billion-context@0.0.500-master.78d9e4a  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

ranxianglei pushed a commit that referenced this pull request Oct 17, 2026
…data key (#3422)

Rebased onto master 2164823: the digests also fold in #3431's
config-file epoch metadata stamp (master-side change landed on the
same lines since the branch diverged). Regenerated with
scripts/update-storage-render-goldens.ts; diff is digest-only.
ranxianglei pushed a commit that referenced this pull request Oct 17, 2026
…data key (#3422)

Rebased onto master 2164823: the digests also fold in #3431's
config-file epoch metadata stamp (master-side change landed on the
same lines since the branch diverged). Regenerated with
scripts/update-storage-render-goldens.ts; diff is digest-only.
ranxianglei pushed a commit that referenced this pull request Oct 17, 2026
…data key (#3422)

Rebased onto master 2164823: the digests also fold in #3431's
config-file epoch metadata stamp (master-side change landed on the
same lines since the branch diverged). Regenerated with
scripts/update-storage-render-goldens.ts; diff is digest-only.
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.

1 participant