Skip to content

[PR] feat: plugin-lane server-owned history — msgid pinning + transcript render endpoint | 插件车道服务端正史:msgid 钉身份 + 正史渲染端点 - #4505

Merged
ranxianglei merged 3 commits into
masterfrom
2026-10-24_plugin-lane-server-history
Oct 24, 2026
Merged

ranxianglei merged 3 commits into
masterfrom
2026-10-24_plugin-lane-server-history

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #4491

Server-side core of the plugin-lane server-history design (owner-finalized 2026-10-24): clients become event sources, the unified transcript becomes the identity authority. Default rollout 0% — zero behavior change until rolled out.

What landed

  • rollout: new gate pluginLaneServerHistory (default 0%; env force-on BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY); documented en+zh.
  • msgid pin (src/msgid-pin.ts): the biliMsgIds body channel — an array parallel to messages, ALWAYS stripped before upstream forwarding (prompt_cache_key discipline), strictly validated (reserved acp_summary_ prefix, duplicates, control/space chars, oversize, non-string, length mismatch).
  • prepare-anthropic: plugin-mode turns pin client ids onto the converted core messages before ref assignment / fold coverage / rawTail ingest — so kernel refs, fold bookkeeping and unified rows all key off CLIENT identity. Id-set algebra observation runs best-effort: vanish-reason classification (compressed vs deleted) + generation-switch detection, surfaced as logs + bounded session-metadata counters.
  • msgid algebra (src/msgid-algebra.ts, pure): the judgment layer over ordered id lists — append / vanish(reason) / edit / epoch flip. The store already does the mechanical row work (append, tombstone via retired_at, reactivate-at-original-seq, branch views); this module only judges.
  • incremental lane: optional msgIds parallel to messages (identity-poisoning shapes hard-fail 400; a mere count mismatch degrades to content-derived ids since wire↔core mapping is not always 1:1); every assembled body re-stamps the canonical ids so the pipeline pins exactly what the lane owns; probe advertises serverHistory.
  • render endpoint (src/plugin-render.ts, POST /__bili/plugin/render {conversationId, untilSeq}, loopback-only like every /__bili/ surface): serves the outbound prefix rendered from the unified transcript — view-pointer ordered, fold regions collapse to acp_summary_<blockId> anchors past each block's last covered row, ledgerSeq stamped ([PR] storage: seq ledger foundations — block interval bounds + ledgerSeq ref stamping (#4316 layer 3, phase 1) #4346). Degrade matrix: gate off → 404 feature-off; storage unreadable / cold session / unparsable row / dangling pointer → 503 with reason. Never guesses.

Config surface (mandatory section)

  • Added: rollout.features.pluginLaneServerHistory (boolean | number, default 0) + env tier BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY.
  • Why the existing surface cannot express it: it is a NEW capability cohort; the rollout.features table is the designated mechanism for feature gates (same shape as snapshotRender and pluginIncrementalTurns). No existing key covers "plugin lanes may pin identity / use the render endpoint".
  • Considered alternatives: riding the pluginIncrementalTurns gate — rejected: the render endpoint and pinning must roll out independently of the incremental lane (a host can consume one without the other). A dedicated config section — rejected per the owner-gated configuration-surface discipline (no invented shapes without sign-off; the issue itself is the application, as its 配置面 section states).
  • Compat/migration: none — default off is fully inert; nothing to migrate.

Host id reachability audit (the issue's prerequisite research)

host verdict evidence
pi NO earendil-works/pi @ main packages/ai/src/types.ts: UserMessage/SystemMessage/ToolResultMessage carry no id; AssistantMessage.responseId? is an OPTIONAL provider-specific identifier, not host-stable identity. The agent loop converts to wire messages only at the LLM-call boundary, so before_provider_request payloads expose no stable message ids. The issue's table cell "插件 API 层(CoreMessage.id)" does not exist in pi's source. Pinning needs an upstream host change (host-stamped ids) — not something we can fabricate client-side (that would be a mask).
opencode unverified our adapters see wire bodies only; whether opencode's plugin/SDK layer exposes internal msg ids at an interception point needs opencode-side audit
dsh unverified (issue itself flags 存疑) ids live in the host session DB; the fetch intercept sees serialized bodies only
omp unverified adapter sees wire bodies only; no id channel evidence

Consequence: no host lane is wired in this PR — the server-side core is delivered generic and hermetically tested; the first consumer follows whichever host the audit lands on.

Stake status (先 RED 后 GREEN)

  • S1 id set algebra (append / vanish-tombstone / edit-keeps-seq semantics) — ✅ tests/msgid-algebra.test.ts
  • S2 compression signature (batch vanish + summary carrier → compressed; pure vanish → deleted) — ✅ same file
  • S3 epoch (mass re-mint → controlled rebuild, threshold + min-length floors) — ✅ same file
  • S4 render endpoint — ✅ tests/plugin-render-endpoint.test.ts (happy path = pure codec over stored canonical rows; full degrade matrix both directions)
  • S5 pi end-to-end — ⚠️ server half only (pin chain through stored rows + poison/count-mismatch guard rails, hermetic); client-shim wiring blocked by the audit (no host id channel exists today)
  • S6 degradation (unreachable/off → local history fallback contract) — ✅ endpoint degrade matrix + gate-off probe state

Behavior changes (disclosure)

At the 0% default: none. When the gate is ON for an install:

  1. biliMsgIds top-level body fields are accepted and stripped (previously such a field — sent by no one today — would have been forwarded to the real upstream);
  2. the /__bili/plugin/turn probe gains an additive serverHistory key;
  3. lane-assembled bodies carry biliMsgIds internally and have it stripped pre-upstream;
  4. a new loopback-only endpoint exists. Outbound bytes to upstream are unchanged in every case (strip verified by test against a mock that IS the upstream).

Tests

Targeted local run green: 149/149 across the touched areas (incremental-lane family incl. ack-pull/recovery/direct-send/divert-authz, snapshot-render family, rollout, anthropic cache-control + pck identity/verbatim, plus the three new test files). Full-suite verdict = remote CI on the pushed head.

Deliberate follow-ups (tracked, not bundled)

  • First-host shim wiring (blocked: audit found no host id channel today).
  • Persisting tombstone reasons into dead_refs (needs a schema migration — v1 keeps reasons in logs/metadata counters).
  • Render-prefix cache-mark replay (v1 renders mark-free prefixes on purpose: marks are per-turn computed artifacts, replaying stored copies desyncs the prefix from the next assembled turn).

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-24_plugin-lane-server-history (a7fd378)

Latest build — install this exact version

npm install -g billion-context@0.0.5434-pr.4505.fb07b63

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
a7fd378 billion-context@0.0.5434-pr.4505.fb07b63 build
19382fc billion-context@0.0.5433-pr.4505.40db739 build
54b3b0d billion-context@0.0.5428-pr.4505.1b1d910 build
4d9ff5a billion-context@0.0.5425-pr.4505.277cfe1 build
58fa0f5 billion-context@0.0.5422-pr.4505.bda612b build
0627cfa billion-context@0.0.5421-pr.4505.13e5b66 build
2e26e6a billion-context@0.0.5419-pr.4505.62ca7d5 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr4505.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title feat: plugin-lane server-owned history — msgid pinning + transcript render endpoint | 插件车道服务端正史:msgid 钉身份 + 正史渲染端点 [PR] feat: plugin-lane server-owned history — msgid pinning + transcript render endpoint | 插件车道服务端正史:msgid 钉身份 + 正史渲染端点 Oct 24, 2026
ranxianglei pushed a commit that referenced this pull request Oct 24, 2026
…orts gate #1440 P6)

loadMarks, VanishReason, VanishedEntry, AlignStats, AlignOptions and
MsgIdValidation are referenced only inside their declaring files — drop
the leading `export` per the gate's INTERNAL_ONLY prescription. Pure
visibility change, zero behavioral diff.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

接单。这是 agent 已完成的 [PR](Closes #4491),不重做——进入核对流程:拉分支读代码、跑定向验证、看 CI、按八问出独立审核结论。

查重: 不重复 —— open PR 里引用 #4491 的只有本 PR;无同机制并行条目(宿主 id 可达性审计是本 issue 的前置研究,PR 正文已含审计结论表)。

标签: scope/wiring + p3(请求管道/身份钉定+新 loopback 端点,属协议接线域;默认 0% rollout 完全惰性,当前无用户可见影响)。

CI 初查(head 2e26e6a,40 个 check):22 success / 16 skipped / 2 failure(unused-exports、docs-sync)——两条都是零依赖脚本门禁,本地可复现,正在定位修复中。最终八问结论随后补。

@ranxianglei

Copy link
Copy Markdown
Owner Author

在 daemon 的基底(2e26e6a)上补了车道流 e2e 覆盖(58fa0f5):msgid-pin / msgid-algebra / plugin-render-endpoint 三套钉的是校验、纯函数和端点,缺的是带 id 的完整 turn 流。新增 tests/msgid-lane-flow.test.ts 5 例:

  1. 钉 id 落行:rollout 开时装配体重钉 biliMsgIds → 管线会话/统一存储行携带客户端 id(编辑=同 id 追加新行,绝不换回旧 seq——409-loop 契约;旧行原字节留档);上游永不见 biliMsgIds(管线剥离)。
  2. undo→redo 同内容:身份 join 命中旧行原 seq 复活,零新行(Four storage-layer defects: identity hash contaminated with positional metadata (truncation triggers identity swap) / sw | 存储层四缺陷:身份哈希掺位置元数据(截断即换血)/清扫删除回退历史/渲染接缝图片只比长度/fork 谱系死列 #4390 纪律)。
  3. delta 重复认领已存在 id → 400(身份投毒拒绝,canonical 不受损)。
  4. divergent resync 带 id + 后续 delta → 无 409 循环,tip 单调。
  5. 无 msgIds 轮 = 字节等价对照组。

rollout 关时的行为也钉了:lane 仍接受 msgIds 钉内存 canonical,但管线会话/行走内容派生 h_ id——两态都是设计内。门全绿(18+58 桩/测试,tsc 0,unused-exports clean——六符号 0627cfa 已先行收口)。

ranxianglei pushed a commit that referenced this pull request Oct 24, 2026
…aneServerHistory (docs-sync gate)

The PR hand-wrote the pluginLaneServerHistory row into the generated
param-ref blocks of CONFIGURATION.md / CONFIGURATION.zh-CN.md without
adding the matching entry to website/config-reference/rollout.yaml, so
gen-config-docs regeneration deleted the rows and git diff went red.

Add the seed entry (the sanctioned source of truth), regenerate, and
commit the generated state. Regeneration normalizes the ZH default cell
from 0(关) to 0 (off) — the generator has one default field per entry,
and every sibling ZH row already carries its English default — and
drops backticks from the descriptions, which the seed validator
forbids. Also adds the BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY row to
both env-map tables.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

docs-sync 红已修:4d9ff5a,叠在你刚推的 58fa0f5 之上(分支现序:2e26e6a0 → 0627cfa unused-exports 收口 → 58fa0f5 lane-flow e2e → 4d9ff5a docs-sync)。

是什么问题:docs-sync 门禁 = gen-config-docs generate 全量重生成后 git diff --exit-code。PR 最初把 rollout.features.pluginLaneServerHistory 两行手写进了 CONFIGURATION.md / CONFIGURATION.zh-CN.md 的生成区块(区块头明言「不要手改本区块」),却没在 website/config-reference/rollout.yaml 加对应种子条目——重生成时这两行被删,diff 必红。手写行里带反引号和中文本地化默认值(0(关))也印证了这点:种子校验器禁止 desc 含反引号,default 字段单值双语共用,这两样都只能是人工产物。

修法:补上缺失的种子条目(key/type/default/env/group/desc_en/desc_zh 齐全,env 名按 src/rollout.ts 的 BILI_ROLLOUT_+UPPER_SNAKE 派生规则核对过),跑一次 generate,提交重生成后的状态。本地已用 CI 同款命令(generate → 四文件 git diff --exit-code)模拟验证 PASS;check-coverage 也 PASS(新 env 名落在 "expected for dynamic names" notice 列,与 BILI_ROLLOUT_<FEATURE> 同类,不红)。生成器幂等性验过(连跑三次无漂移)。

八问:

  1. 是什么问题:CI 门禁(docs-sync)红——配置文档生成块与种子不一致;非运行时缺陷。
  2. 什么原因导致的:文档行绕过了 seed→generate 流程直接手写进生成块;根因是流程绕过,生成器本身无 bug。
  3. 影响范围与严重程度:仅 CI 流水线;运行时、用户可见行为零影响。
  4. 怎么修复的:以种子为唯一事实源——补条目、让生成器产出行。以后该特性文档变更走种子即不再复发此红。
  5. 是否有回归问题:无。其余 293 条种子未动;website/main.js、docs/index.html 生成后零 diff(本条目无 id/render/site_group,不触 site 侧四个块)。两处文档措辞差异见下,均为生成器强制归一,无语义漂移。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:未改;反而把现状拉回既有设计(seed→generate→diff 门禁)。
  8. 是否引入了新的配置:未新增。BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY 是既有派生机制的 env,代码里早已存在(src/rollout.ts:77-78),本次只是补文档登记。

文档措辞差异披露(行为变更类,按规上报):

  • 中文文档该行 Default 单元格:0(关) → 0 (off)(生成器每条目只有一个 default 字段;中文表所有相邻行本就是英文默认值如 "the version's baked-in plan",此次反而变得一致);
  • 描述里的代码式记号(biliMsgIds / messages / POST /__bili/plugin/render / serverHistory)去掉反引号(种子校验器禁止反引号),语义不变;
  • 两份文档的 env-map 表各新增一行该 env 的登记(生成器对带 env 的条目自动产出)。

lane-flow e2e(58fa0f5)已确认在本分支基底内,我的修复不触碰任何测试/源码文件,只动种子 + 两个生成产物。等 CI 全绿即可合。

ci-check and others added 3 commits October 24, 2026 18:01
…nder endpoint, rollout gate (#4491)

Server-side core of the plugin-lane server history design (owner-finalized
2026-10-24): clients become event sources, the unified transcript becomes
the identity authority.

- rollout: new gate pluginLaneServerHistory (default 0%; env force-on
  BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY); documented en+zh
- msgid-pin: biliMsgIds body channel (always stripped pre-upstream; strict
  validation: reserved acp_summary_ prefix, duplicates, control chars,
  oversize, length mismatch)
- prepare-anthropic: plugin-mode turns pin client ids onto the converted
  core messages; id-set algebra observation (vanish reasons compressed vs
  deleted, generation-switch detection) logged + bounded metadata counters
- msgid-algebra: pure append/tombstone-reason/epoch judgment layer over
  ordered id lists (store keeps doing the mechanical row work)
- incremental lane: optional msgIds parallel to messages (poison shapes
  hard-fail 400, count mismatch degrades); assembled bodies re-stamp the
  canonical ids; probe advertises serverHistory
- plugin-render: POST /__bili/plugin/render {conversationId, untilSeq} —
  loopback-only, serves the prefix rendered from the unified transcript
  (fold regions collapse to anchors past each block's last covered row),
  degrades honestly (gate off 404, storage/cold/desync 503)
- tests: algebra stakes (S1-S3), pin validation matrix both directions,
  endpoint stakes incl. degradation matrix + pin chain through stored rows

Host audit (issue prerequisite): pi verdict NO with source evidence
(no stable message ids at the fetch interception point); opencode/dsh/omp
unverified. No host lane is wired yet — first consumer follows the audit.
…orts gate #1440 P6)

loadMarks, VanishReason, VanishedEntry, AlignStats, AlignOptions and
MsgIdValidation are referenced only inside their declaring files — drop
the leading `export` per the gate's INTERNAL_ONLY prescription. Pure
visibility change, zero behavioral diff.
… base (#4491)

The msgid-pin / msgid-algebra / plugin-render-endpoint suites pin
validation, the pure algebra and the render endpoint in isolation.
This adds the missing lane-flow coverage — full turns with client ids
riding the body:

- pin carries client ids into the unified rows (rollout on: the
  assembled body re-stamps biliMsgIds so the pipeline session re-pins;
  rollout off: only the in-memory canonical is pinned), edits land as
  FRESH rows under the same client id — never a swap onto an old seq
  (the 409-loop contract), biliMsgIds never leaks upstream;
- undo→redo with identical content revives at the ORIGINAL seq via the
  #4390 identity join (zero new rows);
- a delta re-claiming a live canonical id hard-fails 400;
- divergent resync with ids then a delta — no 409 loop, tip monotonic;
- id-less turns stay byte-identical (control case).

Also un-exports six internal symbols the new modules exported without
src readers (unused-export gate) — loadMarks, the msgid-algebra option
types, MsgIdValidation.
@ranxianglei

Copy link
Copy Markdown
Owner Author

review

@ranxianglei
ranxianglei force-pushed the 2026-10-24_plugin-lane-server-history branch from 19382fc to a7fd378 Compare October 24, 2026 10:05
@ranxianglei
ranxianglei merged commit aeea173 into master Oct 24, 2026
22 of 23 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.797-master.aeea173 (rolling master tag).

npm install -g billion-context@0.0.797-master.aeea173  # 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 24, 2026
…aneServerHistory (docs-sync gate)

The PR hand-wrote the pluginLaneServerHistory row into the generated
param-ref blocks of CONFIGURATION.md / CONFIGURATION.zh-CN.md without
adding the matching entry to website/config-reference/rollout.yaml, so
gen-config-docs regeneration deleted the rows and git diff went red.

Add the seed entry (the sanctioned source of truth), regenerate, and
commit the generated state. Regeneration normalizes the ZH default cell
from 0(关) to 0 (off) — the generator has one default field per entry,
and every sibling ZH row already carries its English default — and
drops backticks from the descriptions, which the seed validator
forbids. Also adds the BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY row to
both env-map tables.
ranxianglei pushed a commit that referenced this pull request Oct 24, 2026
…nc regenerates clean

#4505 added the flag (src/rollout.ts) and hand-wrote its doc rows but never registered it in website/config-reference/rollout.yaml, so every docs-sync run regenerates without the row and fails git diff --exit-code. Adding the seed entry restores idempotency; the generator normalizes the row (no backticks in generated descs, single default cell) and adds the env-map row it had been missing.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

记录备查:本 PR 审核期间备好的 docs-sync 修复(4d9ff5a1f,见 floor 9)未进入最终合并的 head——re-cut 后的谱系(ad98e7e2c → 02af8da16 → a7fd378)不含该提交(合并树中种子条目 grep = 0),因此 merge aeea173a4 之后 master 立即红在 docs-sync:重生成会删掉手写的 pluginLaneServerHistory 行。已按机制立项 #4533([no-dispatch]),修复 PR #4534 将该提交 verbatim cherry-pick 回 master。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant