Skip to content
Closed
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
36 changes: 36 additions & 0 deletions .github/workflows/announcements-gate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: announcements-gate

on:
# #5548 §五.4: the ONLY new CI touchpoint for the announcement surface —
# validate announcements/remote.json with the client's own validator module
# so a bad push is blocked before merge (PR) or right after land (push).
pull_request:
types: [opened, synchronize, reopened]
branches: [master, agent-relay] # #3468: agent PRs target the relay branch
paths:
- "announcements/remote.json"
- ".github/workflows/announcements-gate.yml"
push:
branches: [master]
paths:
- "announcements/remote.json"
workflow_dispatch:

concurrency:
group: announcements-gate-${{ github.ref }}
cancel-in-progress: ${{ github.event_name != 'schedule' }}

jobs:
validate:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci --no-audit --no-fund
- run: node --import tsx scripts/validate-remote-announcements.ts
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ The full file-by-file map lives in [reference/architecture.md](reference/archite

15. **全量重发水位快路径(full-resend watermark fastpath — #5403/#5418,rollout `pluginFullResendWatermark` 实验性灰度(默认约 5% 安装开启,owner 裁定 2026-11-02:先小流量灰度,web 面板一次性公告+快速开关同步出厂)) — 插件车道(dsh threads 模型等宿主)**每轮把完整历史重发**一次;legacy 路径每轮对整包 body 做一次 `JSON.parse` + `openaiToCore` 全量转换,`snapshotMessages` 再把 AST 钉进 `session.lastMessages` 跨轮驻留——这是 #5403 OOM(81 MiB 入站 → 数百 MB 常驻)的生产者对。机制:每个成功响应上服务端盖 `x-bili-pf-seq` = 该请求 messages 元素数 T(由 `src/server/fastpath-scan.ts` 的**结构扫描**测出——单遍字符遍历,零分配、零解析);客户端下一轮把它作为 `x-bili-pf-count` 回带;v2 身份通道:再回带 `x-bili-pf-tail-ids` = 上一锚点元素 + 全部新增元素的**宿主 msgid** 逐段百分号编码(宿主 body 不带 id,但注入的 shim 能从宿主上下文读到并代发,#4491 同一套逐元素筛查;owner 层级 msgid>顺序>hash #11——缺字段=纯计数模式零回归;**无对齐证明**(owner 裁定 2026-11-02:宿主本就压缩/改写历史,证明永远对不上且自伤)——坏槽位随 `?` 占位符旅行不毒邻居(压缩后 `acp_summary` 槽不再杀整份列表),整份解析失败才清空存储列表;长度/重复/坏段=**静默降级本轮、不计熔断**(重盖戳自愈),锚点 id 仅在两侧都是已知 id 时校验。v4 计数降级(owner 裁定 2026-11-02):某轮带形状合格且宽度与服务端账本吻合(`len = T − K + 1`,服务端重验)的 tail-ids 列表时,K 取自**服务端账本**(seed.stampT)而非客户端回显——`x-bili-pf-count` 该轮降级为纯诊断(缺失/错乱回显不产生 miss,决策串留痕 `hit(no-count)`/`hit(count-off=N)`,永不喂熔断);无合格列表时旧阶梯逐字节不变;前缀收缩(compaction/truncation)的宽度算式出非正值、id 列表不可能满足,credited ahead/seed-stale 照旧触发;零增量轮(T==K)即便带合格单元素列表也保 no-progress(空窗会钉空 lastMessages 基线)。客户端收敛为**一台状态机**(`src/agent/pf-channel.ts`)+ **一个发戳点**:全局 fetch 拦截(`src/agent/native-intercept.ts`)对全部插件车道模型请求盖头(`/bili/` 路由分支、provider URL 重写分支、以及直连代理的自分支——provider URL 直指 bili 根,dsh profile bundle 即此类;三条出网点盖戳+学习对称),车道之间只剩「在哪拿到 msgid」的薄采集适配器——dsh `hostMsgIdsOf` 的逐槽变体 `pfSlotIdsOf`(`?` 占位,见上);pi 共享 entry walker 两族(anthropic `laneMsgIdsForWire` / chat-completions `laneMsgIdsForOpenAiWire`,后者的 config-assembled 前导 system 槽无 branch entry,用合成 `bili-ps-N` 位置令牌覆盖——链不会死在第一个 system 元素上,槽位挪动仍诚实断锚);opencode 复用 transform 钩子已对齐的同一份验证列表;omp 在 fetch 层把宿主 `before_provider_request` 暂存的 branch 条目与实际出体对齐(`ompTurnMsgIds`,与增量信封共用这同一份;**仅 anthropic wire 回合**——其严格 count+role 证明桥不过 config-assembled 前导 system 段,若对 openai 形失败清空会抹掉共享钩子对同一会话刚落下的列表;openai 形回合由共享 `laneMsgIdsForOpenAiWire` 解析器单独覆盖,#2583 逐模型 egress)。pi/opencode/omp 解析器仍是全有全无:整份验证失败立即清空存储列表(陈旧锚点比没字段更糟;dsh 逐槽采集不受此限,见上)。命中条件 = K 由回带 count(v4 下由账本算式)定出、进程内种子恰在 K 盖戳且模型未换、头部 8 元素的 system 与种子逐字一致、窗口首无 system/developer(hoist 险)——全部通过时,管道输入从「全量解析」换成「上一轮的 canonical cores(模块级 WeakMap,不进 Session 面板)+ 仅尾窗 [K..T) 新解析」,尾窗 cores 的 cluster id/wireIndex 按前缀重编号(`openaiToCore` 的 ClusterCounter 按调用内次序编号、prune first-user-pin 依赖 wireIndex 连续,K=1 合并情形有回归钉)。任何疑点(无/坏/旧 stamp——除 v4 账本级 tail-ids 撑场、模型切换、头部漂移、扫描失败、熔断器)整轮走**原封未动的 legacy 全量路径**并重新盖戳,客户端一轮收敛;5 次连续「可证实」miss 触发熔断持有一小时(持有期间继续扫描并盖戳把真值教回客户端,否则旧 stamp 永不收敛)。退出开关:`rollout.features.pluginFullResendWatermark: true/false`(或百分比)/ env BILI_ROLLOUT_PLUGIN_FULL_RESEND_WATERMARK=1/0,web「配置」页快速配置也有同效三态开关。诚实边界:① **保元素数的前缀字节改写不可检测**(代价即跳过逐条复核的信任模型变化——§7.4 需人工评审,不得自动合并);② kernel 按位置区分 user content-array 图片在尾部 vs 历史中部的渲染,**多模态尾部一旦进入缓存,该段历史此后永久降级回 legacy 全量轮**(宁降级不偏离);③ marker-strip 计数随种子账本继承(中部区从不重扫);④ pf-* 握手头是**协议头不是 hop 头**:转发上游前剥掉(`UPSTREAM_HOP_HEADERS`)。本地实测(dog 机,2026-11-02):真实 pi REPL + sglang openai 线,turn1 no-stamp → turn2-4 连续 `fastpath HIT T=4/6/8`(单进程会话内回环生效;每次 `pi -p` 是新进程,戳表不跨进程)。证据:`tests/issue5403-watermark-fastpath.test.ts`(A/B hermetic 双代理:出站字节逐字一致仅 time attr 归一、stamp 逐轮收敛、pf-* 头不出代理、驻留带 lastMessages 8684B→1210B @ 8 回合语料)、`tests/fastpath.test.ts`(verdict 阶梯全表)、`tests/fastpath-scanner.test.ts`(对抗集+50k 规模)、`tests/lane-decisions-matrix.test.ts` 行。实测收益:命中轮跳过全量解析/转换/钉存(服务端 CPU 与 RSS 峰值消失);未命中轮只多付一次结构扫描。**与增量车道(#3248/#4491)的关系——可同开、互不双处理**:两机制服务同一痛点(插件宿主全量重发)但按请求形状分轨:dsh 的 divert 只接 **anthropic wire**(`wireMessagesLookAnthropic` 门,OpenAI tool 形态走全量重发,#3433),而 #5403 这类 chat-completions(openai profile)会话增量车道根本不发散 → 水位快路径正是那些会话的专属机制;anthropic-wire 会话则反之由增量车道接管。同一请求恒走其中一条路(dsh shim 逐回合二选一),服务端对带 `x-bili-plugin-turn` 标记的请求跳过水位判定(不打混合标,KDD 行首阶梯 `incrementalTurn` 行),增量响应不盖 pf-seq、改盖 `x-bili-applied-seq`;divert 合成重入请求的头上游是显式白名单(不含 pf-*)→ pf-* 头绝不到模型端点。残留无害情形:某会话混用时旧 pf-count 可能多陪跑一轮验证(服务端当轮重盖真值即收敛)。附带发现另案登记:legacy 自身存在 mid-history 图片压平 quirk(与本特性无关)。

16. **公告面三来源(unified announcement surface — #5548,设计 v2 owner 已批准)** —— Web UI 公告只有**一套渲染器**(`src/web/client.ts` 的 `renderAnnouncementBanners`:textContent-only、零 innerHTML 外部数据、顶部最多 5 条横幅其余进面板列表),三个来源汇入同一个 `notices[]` 载荷(`GET /__bili/notices` + overview):**A 内置声明**(`src/notices.ts` 的 `BUILTIN_NOTICES` 表,与代码行为绑定、评审门在代码里)、**B 本地 JSON**(`~/.config/billion-context/announcements/*.json`,每文件一条记录 ≤64KB,loader `src/local-announcements.ts` 按 name:size:mtime 签名 memo、坏文件单独跳过+warnOnce)、**C 远程 GitHub raw**(本仓库 master 的 `announcements/remote.json` `{v:1,entries:[…]}`,发布/撤回 = git push;fetcher `src/remote-announcements.ts` 按自更新同节奏(复用其 egress 出口、独立计时)、timeout 8s、非关键路径 A/B 先行渲染 C 到齐补渲染、成功落 last-known-good 快照 `<cacheDir>/announcements-remote-snapshot.json`、失败展示上次快照、首次失败则无 C)。同 id 冲突 **B > C > A**。三来源共用同一白名单校验器(`validateNoticeRecord`:未知字段丢弃+debug 日志、坏值只杀本条记录;文本上限 title≤120/desc≤600/hint≤300;ctaUrl http(s)≤200)与同一套 targeting(`versions` 匹配器精确钉/比较符/^caret/区间列表 AND 组合、脏版本号按数值体比、本地版本不可解析→带 gate 的记录隐藏宁缺毋滥;`percent` 分桶 sha256(installId|id)%100——installId 是 state 目录持久化的稳定 uuid `src/install-id.ts`,不可持久化时隐藏而非闪动;`since` 闭/`until` 开时间窗)。关闭语义三态:persistent(默认;存储键升级为 `id@sha16(normalized record)`——内容改动复现一次,旧裸 id 键仍生效所以升级不会让已关横幅复活;store FIFO 上限 200 键)、instance(仅进程内存,重启复现)、always(不渲染关闭按钮,永不隐藏,重大事故用)。排序 priority desc → publishedAt desc(kind 默认 incident 90 > upgrade-advisory 80 > warning 70 > deprecation 60 > suggestion 50 > new-feature 40 > other 30,显式 priority 覆盖)。逃生门 env `BILI_ANNOUNCEMENTS_URL`(path-relocation 类,缺省官方 raw 地址,防火墙中继用)。CI 门 `.github/workflows/announcements-gate.yml` 对触碰 `announcements/remote.json` 的 PR/push 跑与客户端同一个校验模块(`scripts/validate-remote-announcements.ts`:schema+体量帽+matcher 可解析性+时间格式)——坏推送合并前拦住。信任边界 A(评审门) > B(owner 本机权限) > C(repo push 权);单向广播、**零遥测**(隐私红线);任何来源不可用/坏格式只是该来源缺席,天花板 = 无横幅,永不红屏。模块边界:纯函数层全在 `src/notices.ts`(无 fs/io),fs 只在 install-id/local-announcements/remote-announcements 三个薄模块。测试:`tests/notices-registry.test.ts`、`tests/notices-local-lane.test.ts`、`tests/remote-announcements.test.ts`(四注入:断网/慢响应/坏JSON/超大文件)+ P1 客户端渲染测试 `tests/web-notices-banner.test.ts`。新增内置横幅 = 往 `BUILTIN_NOTICES` 加一条记录(约 10 行 diff,不改其他文件)。

### Install-Lane & Update-Ownership Contract (#1196)

Every bili presence on a machine follows ONE contract — decide changes against it, not ad hoc:
Expand Down
Loading
Loading