Skip to content

feat(plugin): expose isolated forks and attributed context observations - #2017

Merged
ranxianglei merged 18 commits into
ranxianglei:masterfrom
yingzhongshuoqi:2026-10-04_plugin-fork-context-provenance
Oct 4, 2026
Merged

ranxianglei merged 18 commits into
ranxianglei:masterfrom
yingzhongshuoqi:2026-10-04_plugin-fork-context-provenance

Conversation

@yingzhongshuoqi

@yingzhongshuoqi yingzhongshuoqi commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #2018. Companion host integration: EKKOLearnAI/ekko-studio#3279 and EKKOLearnAI/ekko-studio#3282.

Add a discoverable public plugin fork contract and attributed effective-context observations. Hosts use the existing loopback/trusted-origin admin gate; they do not import private persistence functions or copy session files.

  • Manifest advertises protocol-1 snapshot/fork endpoints alongside the five existing public tools.
  • Snapshot exposes an opaque revision and ordered raw/ref/identity proof with a verifiable text/tool projection. Unverifiable multimodal history, corrupted originals and foreign placeholders fail closed.
  • Fork validates parent revision and ordered prefix, independently clones raw messages, refs, nested blocks/originals and CCR state, and reports exact, expanded or unavailable semantics. Receipts support exact-payload idempotency across restart; conflicting children and stale/incomplete parents fail closed.
  • First child outbound requests retain inherited compression state. Parent, child and sibling mutation, search and decompression remain independent.
  • Status separates current usage / estimate / unavailable observations, timestamp, model, window and generation from accumulated billing/cache tokens. Manual changes do not overwrite usage calibration or deduct compression credit twice.
  • Explicit main-turn intent is not heuristically demoted to side traffic; auxiliary and unknown callers retain their existing policy.
  • Integrates upstream nativeCaller routing: host-confirmed native IDs are not redirected by another session's witness. An unconfirmed explicit ID conflicting with its witness returns 409 TOOL_CONVERSATION_CONFLICT; unknown native IDs return 404.
  • Publish a valid Responses terminal-frame context observation before forwarding the completion frame, so hosts can immediately read it before upstream EOF. Billing/cache settlement still happens once at EOF, including late usage; missing/zero input usage is not fabricated.

Current-Head Validation

Reconciled stack (maintainer, credits preserved): contributor history through 9609bb7 + 29e2be93 (D-B snapshot cap replay) + d9b44fc3 (revision-cache #2017-E + x-bili-plugin-agent: main docs) + 830da41e (knobs.ts registration of the cap, #2030 discipline) + merges to current master. The fork head branch now carries this stack (maintainerCanModify).

  • Parent-rerun Responses terminal usage, plugin status provenance, context provenance ledger/outbound and role compatibility: 53 passed, 0 failed, 0 skipped. These exercise real loopback HTTP streams with deterministic fixture upstreams, not paid-model calls.
  • npm run typecheck: exit 0.
  • npm run build: exit 0; dist-import-annotations OK.
  • git diff --check origin/master...HEAD: exit 0.
  • Companion Ekko head abfd30889352109fcbd732cdb119ce91cd4953e5 public HTTP integration against this current bili build: 3 passed, 0 failed.
  • The upstream-sync agent reported 123 focused and 39 supplementary tests passed on ac8d88e; those results are supplementary, not a parent-rerun full-suite claim for 9609bb7.

Earlier acceptance at aa7b0ef included 32 assertions and seven real gpt-6.1-sol HTTP 200 responses through isolated Hermes broker/worker and Ekko runtime, including first child outbound, independent search/decompression and post-recovery delivery. Tools were dispatched by the probe rather than chosen by the model. These historical runs are not current-head paid-model acceptance. No additional paid-model/cold-start/full-suite exercise was performed for this closeout.

Earlier full local suites had DNS/transport classification failures and skips; the full local suite is not claimed green. Current focused tests emit a MaxListenersExceededWarning from repeated test server lifecycle listeners, without failures. Required official checks remain the merge gate.

Compatibility And Review

Status contextTokens now means an attributed effective observation (null when unavailable), not a historical input-token total. Explicit tool identities fail closed rather than silently adopting a conflicting witness, except host-confirmed nativeCaller IDs from the upstream contract. Merge-state counters persist across restart. Plugin raw history snapshots and status revision hashing have history-dependent memory/persistence/CPU cost.

Config Surface

One new knob, registered per the #2030 discipline: BILI_PUBLIC_SNAPSHOT_CAP_BYTES > plugin.snapshotCapBytes > 16777216 (0 disables retention), resolved through src/knobs.ts with the env tier byte-exact to the original parser. Documented in CONFIGURATION.md en/zh + reference/env-vars.md. Uses the existing x-bili-plugin-agent main intent and upstream nativeCaller request marker; manifest fork capabilities are public protocol discovery, not configuration. No CLI flags, kernel-pin changes or package-version bumps.

This is a cross-repository public API, identity and persistent-state change. Human review and merge are required; no automatic merge or npm release is enabled. Please review the latest head and merge into current master only after required checks pass. A prior owner-bot comment reviewed f44dd24 and is not approval of this head.

Local production has the earlier development build 0.1.181 on the single original 8787 service; this final PR sync/terminal-frame patch has not been installed there. Ekko is delivered separately as an uninstalled local custom FPK.

Remote CI

Evaluate checks at the current fork head (see Reconciled stack above). Earlier heads' check results are not attributed to the new commits. Fork CI cannot use upstream provider secrets.

Maintainer Coordination Still Open

The latest #2032 coordination comment is acknowledged. #2032 is currently an open draft, not merged into master. Merge order and the shared statusInputBaseline reader need maintainer agreement; this PR currently supplies attributed usage/estimate/unavailable observations and exposes unavailable as null with an explicit source marker. This is not a claim that #2032 integration or shared panel unknown rendering is resolved.

The maintainer comment mentions a 16 MiB BILI_PUBLIC_SNAPSHOT_CAP_BYTES follow-up at d333385. That symbol is absent from this contributor head 9609bb7. Resolved in the reconciled stack: the cap now rides at 29e2be93 (with tests) and is registered through knobs.ts at 830da41e. The #2032 statusInputBaseline coordination stays open until #2032 merges upstream.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到,开始独立 review。先报基础事实:

  • Draft PR,open,mergeable;head f44dd240,2 commits,base 与当前 master 齐平(落后 0 commit),无陈旧基线问题。
  • 规模:12 文件,+1383/-45。核心:src/plugin.ts(+342)、tests/plugin-fork.test.ts(+639)、tests/plugin-status-provenance.test.ts(+246)、src/cache-ledger.ts/src/persist.ts/src/session.ts/src/server.ts 小改、两个 manifest golden、PLUGIN.md 文档。
  • 无 ework-agent-pr 标记 → 按外部贡献者 PR 走完整 review 流程(审原 issue → 回归清点 → 代码 → 测试有效性 → diff 整洁度)。

接下来逐层审查,结论会按结构化七问回帖。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

独立 review 完成(外部贡献者 PR,无 agent 标记,走完整流程)。先给独立验证证据,均在 PR head f44dd240 本地执行:

  • typecheck 基线对比(补完作者标注 "in progress" 的部分):base 33d58e5e 与 PR head 各自 clean install(npm ci)后跑 npm run typecheck,错误集逐条完全一致——共 12 个错误,全部落在 4 个未改动的测试文件(codex-responses-ws×4、issue1987-preflight-baseline-anchor×5、issue1993-preflight-400×1、ws-bridge×2),本 PR 零新增 typecheck 错误。即 master 的 typecheck 当前就是红的(既有问题,PR 正文已披露,属同一线程在跟踪,不重复立项)。
  • 定向测试(plugin-fork + plugin-status-provenance + tool-ring):50/50 通过。(首轮失败是我本地环境 node_modules 用了陈旧 lockfile 缺 ws 所致,重装后全绿,与 PR 无关。)
  • build:tsup 通过(acp-kernel inline)。
  • wire-contract:15/15 通过;重跑官方 scripts/update-wire-contract-goldens.ts,输出与提交的 golden 逐字节一致 → golden 系正规再生。
  • kernel 审计:acp-kernel 0.0.100 对 messageRefs 的使用全部是点查或 highestUsedIndex+1 单调游标,不存在「假设每个 ref 必对应活消息」的遍历 → 子会话克隆父级完整 ref map 的设计安全(ref 编号只增不复用,符合 never-reuse 契约)。
  • 安全门禁:snapshot/fork 路由在 /__bili/* 下,代码核实与既有 plugin 端点同一 admin gate(loopback-only + tunnel-marker 拒绝 + trusted-origin),PLUGIN.md 的安全声明成立。

结构化七问

  1. 是什么问题:功能需求(feat(plugin): public isolated conversation forks and attributed context observations #2016)——外部 host(Ekko Studio)需要公开、带 revision 校验的 fork API:从父会话任意点分叉上下文,父/子/兄弟完全隔离;status 要能区分「实测 usage」与「有效上下文估计」。不是修 bug。
  2. 什么原因导致的 / 方向判断:根机制是 host 此前只能复用父会话 id(兄弟互染)或拷会话文件(绕过持久化边界)。本 PR 在源头做身份分离:子会话独立 id + 独立克隆的状态(raw 消息/refs/嵌套块/originals/CCR)+ revision 校验的有序前缀验证,防止从过期/错位历史分叉。打的是根本原因,非症状遮蔽;与 feat(plugin): public isolated conversation forks and attributed context observations #2016 的方向一致。
  3. 怎么修复的(机制层):manifest 宣告 protocol-1 能力 → GET snapshot 返回不透明 revision + raw/ref/identity 证明 + 可验证文本投影(多模态历史 fail-closed)→ POST fork 校验 parent revision + orderHash + 前缀逐条 identity,块分区(跨界块以 inactive/expanded 继承),克隆状态与 content store,crash-safe publish(flushSync 先于注册)→ 子会话首个出站请求再验继承前缀(不符 409 且不外发)→ tool 端点支持 expectedRevision 乐观锁。Receipt 提供跨重启幂等。
  4. 是否有回归问题:对 diff 触碰路径逐项清点既有行为(manifest/status/tool/persist load-save/cache-ledger settle/request 路径/nudge 渲染),未发现无意回归;有 5 处有意行为变更,见下节 A–E(A/B 已在 PR 正文+PLUGIN.md 披露,C/D/E 需要 owner 知悉)。
  5. 是否破坏缓存:prompt cache 不受影响(子会话继承 system/baseline,head 消息稳定)。计费/缓存 ledger 语义不变——provenance 观察是独立账本,手动压缩 credit 只扣一次(测试钉死 contextTokens == max(0, usage − credit));零 usage / 缺 usage 的上游响应不会把先前 measured generation 重新打标(有测试钉住)。
  6. 是否改了设计方向:无架构转向——仍是单代理进程、单写者持久化(多进程共享同一 state dir 明确声明不支持,与 native模式下自动更新问题需要解决 #991 契约一致);新公开 API 经 manifest 发现 opt-in,既有调用方 wire shape 不变。
  7. 是否引入新的配置:无。没有新 env/config 字段/CLI flag/版本 bump/kernel pin 变更(acp-kernel 保持 0.0.100);manifest capabilities.fork 是协议能力发现,不是配置项。

行为变更披露(旧值 → 新值 + 原因)

  • A. status.contextTokens 语义:旧 = stats.lastInputTokens(上一次 provider input tokens,首响应前为 0)→ 新 = 可归因观察(unavailable=null / estimate / usage),并新增 contextTokensSource/At/Generation、sessionRevision。消费端已核实:src/agent/pi.ts 的 renderAcpStatus 对 null 优雅处理(旧值会显示 "context: 0",新值省略该行);web UI 读 stats.contextTokens,不受影响。原因:feat(plugin): public isolated conversation forks and attributed context observations #2016 要求区分有效上下文与计费数据。
  • B. tool 路由反转(零注入会话身份:移除模型可见 conversation_id,以出站 tool_use 环见证路由 MCP 工具调用(fixes #1611 的非注入路线) #1685):旧 = 唯一出站 witness 存在时静默覆盖 body 里显式 conversationId(reroute + 日志)→ 新 = 显式 id 恒赢,witness 不含解析出的 session → 409 TOOL_CONVERSATION_CONFLICT(fail closed)。现有 host(dsh/opencode/pi/kimi subagent)body 不带 conversationId,路径不变且有测试钉住;只有「两者都发且不一致」的调用方从 200 变 409。原因:fork 兄弟会话共享历史,witness 推断歧义必须失败关闭。
  • C. mergeState 重启后保留 lastPassIds/hiddenOrphanRefs/terminalStreak/nextRuleId:旧 = 每次代理重启这 4 个字段重置为初始值 → 新 = 从磁盘恢复。影响所有会话(不只 fork):terminal streak 与规则计数重启后延续而非归零。这是修复一个既有的重启重置缺陷(与旁边已有 absorbed 保留同模式),也是 fork 正确性的前置条件。
  • D. 所有 pluginAgent 会话无条件捕获+持久化原始历史快照(pluginSnapshot):即使从不用 fork,内存与会话文件大小随历史长度增长,每请求一次 structuredClone。fail-closed provenance 的代价,建议上线后观察实际开销(不阻塞)。
  • E. 性能提示:handlePluginStatus 每次调用都对整份状态算 sha256(sessionRevision),成本随会话规模增长。轻微。
  • F. 健壮性提示:post-tool 的 estimate 记账靠正则匹配 decompress/retrieve 结果文本格式识别恢复内容,kernel 文案若变化,estimate 会静默偏低(不影响压缩本身正确性)。轻微。

测试有效性

真测试,断言有牙:真实 HTTP 过真实 proxy + mock upstream;真实进程重启测试(spawn 子进程验证持久化子会话、CCR original 独立恢复、replay 幂等);12 路并发 fork 竞态(恰好一个 201、其余 200 replay);精确 token 算术;generation 单调性(含 Date.now 固定到同一时间戳的用例);多模态 fail-closed;absorb 边界矩阵(before/after-absorb、hidden carrier、block-summary)。该出回归时抓得住。

diff 整洁度

12 个文件全部与目的相关,golden 经官方脚本再生,无空白/重排噪音。干净。

全量套件说明

作者自报:全量 3,857 例,3,833 通过 / 2 失败(main-path-transport-retry、tunnel-guard,transport/DNS 断言)/ 22 跳过,并明确声明不构成 green 主张。按本地测试纪律,全量回归交给远程 CI;那 2 个失败看描述是环境相关(DNS),CI 结果出来后可定归属。

判定

按 §7.4 不可 auto-merge(feat + 持久化状态扩展 + 公开 API/wire surface + 跨仓配套 EKKOLearnAI/ekko-studio#3279),需人工 review/merge——与 PR 自身声明一致。

结论:未发现阻塞缺陷,建议 owner review 后合并。 机制打到根因(身份分离 + revision 校验 + 处处 fail-closed),安全门禁成立,零新增 typecheck 错误,定向测试 50/50,build/golden/wire-contract 全绿;C/D/E 三处行为/资源变更请 owner 明确知悉(上文已列)。

Resolve WebSocket test typing per upstream while retaining runtime address validation in the preflight baseline test. Preserve public snapshot/fork provenance and tool-witness behavior alongside integer output budgets and the bugfix release channel.

Validation: typecheck and build pass; focused fork/tool-witness/budget/WebSocket tests 141/141 pass. Full isolated suite: 3937 pass, 2 pre-existing DNS classification failures, 22 skipped. Real Codex E2E preflight blocked by spawn codex ENOENT. No push or release performed.
Preserve the contributor branch history while integrating origin/master e6b2857. Retain explicit fork identity and revision guards, honor host-stamped native callers on witness collisions, and cover the combined routing contract.
ranxianglei pushed a commit that referenced this pull request Oct 4, 2026
…CHILD_CONFLICT

Review fix on #2017 (issue #2016). publishForkSession's disk-existence probe
called loadSync without protocol meta, which per the kernel store contract
resolves namespaced records only after discovery (prior write or loadAll).
A store instance that neither wrote nor discovered an established child file
(cross-process / externally moved file shapes) missed it, so a conflicting
retry reached flushSync and could overwrite the child. Probe with the child's
meta and surface the resulting conflict as 409 CHILD_CONFLICT per the
PLUGIN.md section 8 contract instead of generic 503 FORK_FAILED.

Regression test pins the kernel-documented no-discovery boundary: fails on
the pre-fix probe (201 clobber), passes with the meta-aware probe.
@ranxianglei

Copy link
Copy Markdown
Owner

Rebased onto current master (e6b28571) and realigned the branch with the PR head — the remote branch had been force-reset to ce734975 on an older base, which is what showed up as CONFLICTING. All credit for the implementation stays with @yingzhongshuoqi; the three original commits ride unchanged in content (794523fb → 3387fb54 → ffe456b8).

Two maintainer-side changes on top:

  1. Merged routing ladder — src/plugin.ts conflicted textually and semantically with Codex Code Mode 压缩失败:MCP shim 忽略每次调用的 _meta.threadId,错误使用过期 env ID #2024 (both rewrote the handlePluginTool precedence). The merged ladder keeps Codex Code Mode 压缩失败:MCP shim 忽略每次调用的 _meta.threadId,错误使用过期 env ID #2024's rung 0 (host-stamped nativeCaller outranks a colliding witness, unresolvable native ids fail loudly) and adopts this PR's fail-closed rung 1 (resolvable non-native id contradicted by a unique witness → 409 TOOL_CONVERSATION_CONFLICT, replacing 零注入会话身份:移除模型可见 conversation_id,以出站 tool_use 环见证路由 MCP 工具调用(fixes #1611 的非注入路线) #1685's witness-wins-with-info-log). The tests/mcp-native-thread.test.ts control leg now pins the 409.

  2. Review D-B cap — raw snapshots are capped by BILI_PUBLIC_SNAPSHOT_CAP_BYTES (default 16 MiB, 0 disables): an over-cap session stops being forkable (409 SNAPSHOT_UNAVAILABLE with the capped reason) instead of retaining an unbounded raw copy forever; an under-cap resend restores it. D-C (child inherits the parent's full issued-ref namespace) is documented in PLUGIN.md.

Local verification at d3333857: typecheck 0 errors; plugin-fork 22/22 (incl. two new cap tests), plugin-status-provenance 7/7, mcp-native-thread 8/8, tool-ring 24/24, plugin-agent 63/63, cache-ledger 37/37, wire-contract-golden 5/5, wire-contract 15/15.

Remaining open items for the owner: D-A is now accepted by implementation (fail-closed 409 for contradicted resolvable ids) — flag if you want #1685's witness-wins restored instead; D-B cap default (16 MiB) is a judgment call, env-tunable.

@yingzhongshuoqi

yingzhongshuoqi commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor Author

@ranxianglei Final contributor update is pushed at 9609bb7, preserving the original PR history and merging current master 6edfc6f. Please re-review this head and merge into current master after the required checks pass.

The conflict resolution retains fork revision/identity guards while honoring upstream host-confirmed nativeCaller routing. The final follow-up fixes Responses completion-frame versus EOF observation timing without double billing. The last upstream sync also retains #1996 placement-only system-message repair. Parent verification at 9609bb7: 53 focused tests passed, typecheck/build/dist-import checks passed, and companion Ekko public HTTP integration passed 3 tests against this build. New-head CI results must be evaluated independently; the previous bot review at f44dd24 is not approval of this head. PR body distinguishes current verification, historical model evidence and rollout limitations. No auto-merge or npm publishing is requested.

CI update: all 16 checks on 9609bb7 have completed successfully. Please review this exact head and merge after human approval; this is not an approval or an automatic-merge request.

Coordination follow-up: The #2032 draft statusInputBaseline/unknown-panel integration and the maintainer-side snapshot-cap follow-up at d333385 remain open decisions; the cap symbol is not in contributor head 9609bb7. The PR body now explicitly records both rather than claiming them resolved. Please reconcile the shared status reader and cap follow-up, review this exact head, then merge after human approval. No auto-merge or production changes were performed for this follow-up.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[协调注记,来源:#2029 / PR #2032 审查]

PR #2032(#2029 的修复,draft)引入了从 src/acp-status.ts 导出的 statusInputBaseline(session)——provenance-aware 的状态读取基线:usage / bounded overflow-arm 值原值透传,否则回退保留的真实用量锚点(lastUsageGradeTokens,#1569),无锚点时为 0(unknown)。它同时把 plugin JSON 的 contextTokens 从 raw lastInputTokens 回显改为该基线。对本 PR 的 observation contract 有两个协调点:

  1. contextTokens 冲突:两个 PR 都赋值该字段。建议顺序(owner 确认):先合 fix: keep status baselines usage-grade after failures #2032,本 PR rebase 时以 statusInputBaseline(session) 作为 attributed current-context observation 的数据源,而不是各自维护一份取值逻辑。
  2. unknown 的表达:无真实锚点时基线为 0(Status readers still trust estimate-grade failure baselines after #1846 #2029 spec:"or unknown (0)")。对外展示/JSON 不得把它渲染成「实际占用 0%」——observation contract 里应把 unknown 表达为 null/absent 或显式 no-data 标记,而不是复用数字 0 字段制造歧义。panel 文案("Context …: 0% (0 / N)")是 kernel 对给定数字的渲染;若需要独立的 no-data 呈现,属于本 PR 范围内的 kernel/panel 侧变更,不要在 bili 侧对 panel 输出做字符串改写。

相关:#2029、#2032。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

PR #2017 第二轮独立复审结论(新 head af4ada31)

复审范围:第一轮审的是 f44dd240;本轮针对 rebase 到 master e6b28571、与 #2024 合并路由、外加两个 follow-up(aa7b0efc main intent、af4ada31 Responses 终帧时序)之后的最终 head。全部增量 diff 逐行读过,本地独立验证(不依赖任何一方自报数据)。

一、是什么问题:外部贡献者的公开 plugin fork 契约(snapshot/fork 端点)+ 归因有效上下文观察功能(companion:EKKOLearnAI/ekko-studio#3279)。本轮审的是维护者侧冲突解决 + 贡献者最终推送后的新 head 是否引入回归或遗漏。

二、什么原因/怎么修的(机制层面):

  • manifest opt-in 暴露 snapshot/fork 端点,位于 /__bili/* admin gate 之下(loopback-only + tunnel 拒绝 + trusted-origin,代码中核实);
  • snapshot = 不透明 revision(全状态 sha256)+ 有序 raw/ref/identity 证明 + 文本投影;不可验证历史(本 head 新增 audio part 拒绝)fail closed 409;
  • fork 校验父 revision 与有序前缀,独立克隆消息/refs/嵌套块/CCR store,报告 exact/expanded/unavailable;幂等 receipt 跨重启;并发 fork 单进程内串行;
  • 子会话首个出站请求经前缀身份校验门,保留继承的压缩状态;此后父/子/兄弟完全独立;
  • status 区分 usage/estimate/unavailable 当前观察与累计 billing/cache token;本 head 新增 forward() 时发布真实出站上界估计(行为变更 G),以及 Responses 终帧写入前先发布 usage 观察(仅观察、无双重计费,8 个测试钉住:无重复 settle、迟到 usage 修正、零值不伪造等);
  • 路由阶梯与 Codex Code Mode 压缩失败:MCP shim 忽略每次调用的 _meta.threadId,错误使用过期 env ID #2024 合并:host-stamped nativeCaller(rung-0)压过冲突 witness;显式 conversationId 被非 native witness 矛盾 → 409 fail-closed(取代 零注入会话身份:移除模型可见 conversation_id,以出站 tool_use 环见证路由 MCP 工具调用(fixes #1611 的非注入路线) #1685 的 witness-wins 静默改道);
  • x-bili-plugin-agent: main 否决 side demotion,保证宿主主请求能捕获历史从而可 fork。

三、是否有回归问题:未发现阻塞性回归。逐项清点既有行为变更:A(status.contextTokens 语义变化,已核实的消费者均 null-safe)、B/C(路由 fail-closed、mergeState 重启保留——均已在 PR body 披露)、G(forward() 出站估计只写 stats/contextTokens* 字段,billing 字段在 settleUsageReport 前不动,测试钉住 inputTokens/cacheSamples/requests 不变)、终帧观察(proxy mode 不受影响,plugin mode 仅观察)。两种压缩模式均已推演。对最新 master(6edfc6f7,含 #1996/#1994)模拟合并:干净树,仅 server.ts auto-merge,无冲突。独立验证:typecheck 0 错误(第一轮发现的 12 个预存错误在本分支已随 18c58a5b + master 侧修复解决);本地定向测试 265/265(plugin-fork/provenance/terminal/outbound/ledger 70 + mcp-native-thread/tool-ring/cache-ledger/wire-contract×2/side-request-isolation/issue1958/provider-protocol/plugin-agent 195);build 通过 + dist-import 注解 OK;wire goldens 官方脚本重生成逐字节一致;CI 16/16 全绿(API 确认全部 completed/success,不再是「还在跑」)。

四、是否破坏缓存:未破坏。前缀缓存语义不变(head system 字节稳定、cache-key 输入未动)。持久化扩展(pluginSnapshot / forkContentStore / publicSnapshotStoredRefs 高水位 / stats 有效视图)crash-safe:publishForkSession 先 flushSync 后写内存,evictOldest 跳过 inFlight 且 flush 失败拒绝淘汰未持久化会话(第一轮逐行核实)。CCR 克隆复用 master 既有 cloneStoreForRefs(#1341)。

五、是否改了设计方向:新增公开 API 面(manifest capability 发现、opt-in,默认客户端不受影响)+ 跨仓 companion ekko-studio#3279——需要人工 review/merge,与 owner 定位一致。无架构漂移:机制全部落在既有 session/persist/admin-gate 设施上。

六、是否引入新配置:本 head 无新增配置/env/CLI(CONFIGURATION.md 中英文相对 e6b2857 零差异)。⚠️ 但有一处需要你裁决的差异:你的评论说 D-B cap(BILI_PUBLIC_SNAPSHOT_CAP_BYTES,默认 16 MiB)已实现并在 d3333857 上验证,但 af4ada31 中该 env var、cap 逻辑与 cap 测试均不存在(git grep 为空;d3333857 不在仓库对象库中,即未推送;plugin-fork 实际约 28 个测试而非 22,无一涉及 cap)。也就是 cap 提交没有进入被推送的 head,第一轮的 flag D(所有 pluginAgent 会话无条件在内存/磁盘保留原始快照)在本 head 仍开放。请决定:合并前把 cap 提交推上来,或明确接受 D 保持开放。
另有一处小遗漏:x-bili-plugin-agent: main 的新语义在任何 .md 中都未见文档(grep 为空),建议合并前在 PLUGIN.md 补一行(分支在贡献者 fork 内,我无权直接推)。

七、收工判定:独立验证全绿、无阻塞缺陷;建议完成上述两项(D-B cap 裁决 + main-intent 文档一行)后由人工合并。auto-merge 不适用(§7.4:feat + 持久化扩展 + 公开 API + 跨仓)。对你列的两条 open items 的回答:D-A fail-closed 409 是正确选择(fork 兄弟场景下 witness-wins 正是本 PR 要消灭的歧义类,#1685 的教训支持这一点);D-B 默认 16 MiB 合理,前提是它真的进分支。合并操作按规则只能人工执行,请自行合并:#2017

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

PR #2017 第二轮独立复审结论(新 head af4ada31)

复审范围:第一轮审的是 f44dd240;本轮覆盖 rebase 到 master e6b28571、与 #2024 路由合并后的最终 head,以及两个后续修复(aa7b0efc main intent、af4ada31 Responses 终帧时序)。全部增量 diff 逐行审读;本地独立验证均在本 head 上执行,不依赖任何一方自报数据。

一、是什么问题:外部贡献者的公开 plugin fork 契约(snapshot/fork 端点)+ 归因有效上下文观测特性(companion:EKKOLearnAI/ekko-studio#3279)。本轮审的是维护者侧冲突解决 + 贡献者最终推送后,新 head 是否引入回归或遗漏。

二、什么原因导致的 / 怎么修复的(机制层面):

  • manifest opt-in 暴露 snapshot/fork 端点,位于 /__bili/* admin gate 之下(loopback-only + tunnel 拒绝 + trusted-origin,已在代码中核实);
  • snapshot = 不透明 revision(全状态 sha256)+ 有序 raw/ref/identity 证明 + 文本投影;不可验证历史 fail-closed 409,本 head 新增 audio part 也拒绝;
  • fork 校验父 revision 与有序前缀,独立克隆消息/refs/嵌套块/CCR store,报告 exact/expanded/unavailable;幂等 receipt 跨重启;单进程内串行化并发 fork;本 head 新增 CCR store 全量完整性校验(payload↔ref 双向链接 + sha256 复核),磁盘损坏 fail-closed;
  • 子会话首个出站请求经前缀 identity 校验门,保留继承的压缩状态,此后父/子/兄弟完全独立(D-C,已写入 PLUGIN.md);
  • status 区分 usage/estimate/unavailable 当前观测与累计 billing/cache tokens;本 head 两处增强:forward() 时发布真实出站上界 estimate,Responses 终帧写入前先发布 usage 观测——均为 observation-only,不触碰计费(settleUsageReport 仍单次入账),有专项测试钉住无双重计费、迟到 usage 修订、重复 completion 只结算一次;
  • 路由阶梯与 Codex Code Mode 压缩失败:MCP shim 忽略每次调用的 _meta.threadId,错误使用过期 env ID #2024 正确合并:host-stamped nativeCaller(rung-0)优先于冲突 witness;显式 conversationId 与非原生 witness 冲突 → 409 fail-closed(取代 零注入会话身份:移除模型可见 conversation_id,以出站 tool_use 环见证路由 MCP 工具调用(fixes #1611 的非注入路线) #1685 witness-wins 静默改道);
  • x-bili-plugin-agent: main 否决 side demotion,保证 host 主请求能捕获历史从而可 fork。

三、是否有回归问题:未发现阻断性回归。行为变更逐项清点:A(status.contextTokens 语义变化——消费方 null-safe 已逐个核实)、B(路由改道反转 → fail-closed)、C(mergeState 跨重启保留 lastPassIds/hiddenOrphanRefs/terminalStreak/nextRuleId——PR body 已披露,属潜在重置 bug 修复)、G(forward() 出站 estimate 仅写 stats/contextTokens* 展示字段,billing 字段在 settle 前不变,测试钉死 inputTokens/cacheSamples/requests 不被触碰)、终帧观测(proxy mode 不受影响,plugin mode 纯观测)。两种压缩模式均已推演。对最新 master(6edfc6f7,含 #1996/#1994)模拟合并:clean tree,仅 server.ts 自动合并,无冲突。独立验证结果:typecheck 0 错误(第一轮的 12 个预存错误在本分支已随修复消除);本地定向测试 265/265(fork/provenance/terminal/outbound/ledger 5 文件 70 + mcp-native-thread/tool-ring/cache-ledger/wire-contract×2/side-request-isolation/issue1958/provider-protocol/plugin-agent 9 文件 195);build 通过 + dist-import annotations OK;wire goldens 官方脚本重生成字节一致;CI 16/16 全绿(API 确认 contributor 所说的 "still running" 已全部 completed/success)。

四、是否破坏缓存:不涉及。前缀缓存语义未变(head system 字节稳定、缓存键输入未动)。持久化扩展(pluginSnapshot/forkContentStore/publicSnapshotStoredRefs 高水位/stats effective view)为 crash-safe:publishForkSession 先 flushSync 再落表,evictOldest 跳过 inFlight、flush 失败拒绝驱逐未持久化会话(第一轮已逐行核实);CCR 克隆复用 master 既有 cloneStoreForRefs(#1341)。

五、是否改了设计方向:新增公开 API surface(manifest capability discovery,opt-in,默认客户端零影响),跨仓 companion ekko-studio#3279——需人工 review/merge,与 owner 定位一致。无架构漂移:机制全部落在现有 session/persist/admin-gate 基础设施上。

六、是否引入新的配置:此 head 没有任何新 config/env/CLI(CONFIGURATION.md zh/en 相对 e6b2857 零 diff)。⚠️ 但有一处必须 owner 裁定的不一致:评论中描述 D-B cap(BILI_PUBLIC_SNAPSHOT_CAP_BYTES,默认 16 MiB)已实现并在 d333385 验证("plugin-fork 22/22 incl. two new cap tests"),但 af4ada31 中该 env、cap 逻辑与 cap 测试均不存在(git grep 为空;d3333857 不在仓库对象库中;plugin-fork.test.ts 实际约 28 个测试且无一涉及 cap)。即 cap 提交没有进入被推送的 head,第一轮 flag D(所有 pluginAgent 会话无条件在内存+磁盘保留原始快照)在此 head 仍未关闭。请二选一:合并前补推 cap 提交,或明确接受 D 保持 open(建议前者——这是该特性的主要资源面)。另有一处小遗漏:x-bili-plugin-agent: main 新语义在所有 .md 中均无文档(grep 为空),建议合并前在 PLUGIN.md 补一行;分支在贡献者 fork 下我无权直接推送。

七、判定:独立验证全绿,无阻断缺陷。建议完成上述两项(D-B cap 裁定 + main-intent 一行文档)后由人工合并;auto-merge 不适用(§7.4:feat + 持久化扩展 + 公开 API + 跨仓)。对你 open items 的回答:D-A 的 fail-closed 409 方向正确(fork sibling 场景下 witness-wins 正是本 PR 要消灭的歧义类,#1685 教训支持);D-B 若推送,16 MiB 默认值合理。合并操作本身 human-only,请自行合并:#2017

… (BILI_PUBLIC_SNAPSHOT_CAP_BYTES, default 16 MiB, 0 disables); child refs-namespace inheritance documented in PLUGIN.md
…h; document x-bili-plugin-agent: main

Status polling re-hashed the entire history plus the CCR store (payload by
payload) on every call (review item E). forkSnapshot() is a pure function of
the session content, so the revision is now cached keyed by revisionEpoch —
a monotone counter bumped by markDirty after every mutation. Unchanged
sessions answer revision reads in O(1); any mutation invalidates and the
next read recomputes. The tool expectedRevision check uses the same cached
read under the session lock and still fails closed (409) on staleness,
pinned by a new provenance test.

PLUGIN.md: one paragraph for x-bili-plugin-agent: main (veto of side-request
demotion for full main turns) — previously undocumented (ework second-round
open item).
@ranxianglei

Copy link
Copy Markdown
Owner

Reconciliation of the two stacks (maintainer-side, credits preserved):

  • Base = contributor final head 9609bb79 (original PR history + ac8d88e3 fork-safe native tool routing merge with Codex Code Mode 压缩失败:MCP shim 忽略每次调用的 _meta.threadId,错误使用过期 env ID #2024 + aa7b0efc main-intent + af4ada31 Responses terminal-frame observation + master 6edfc6f7). My earlier 7ef673d8 stack is dropped in favor of the contributor's; both implemented the same fail-closed ladder, theirs keeps their history.
  • 29e2be93 — D-B replayed on top of 9609bb79: BILI_PUBLIC_SNAPSHOT_CAP_BYTES (default 16 MiB, 0 disables) raw-snapshot retention cap, fail-closed 409 when exceeded, capped/recovery behavior + anti-eviction interaction covered by 2 tests (ework round-2 open item ①).
  • d9b44fc3 — review item E fixed: sessionRevisionOf() caches the fork revision behind revisionEpoch (monotone counter bumped by markDirty), so status polling no longer re-hashes the whole history + CCR store per call; mutation invalidates; expectedRevision reads the same cache under the session lock and still fails closed. Pinned by a new provenance test (identical revision on unchanged session, moves after a turn, stale revision → 409). Also documents x-bili-plugin-agent: main in PLUGIN.md (ework round-2 open item ②).
  • D's remaining known cost (per-request structuredClone under the cap) stays bounded and observable via the cap; F (regex wording coupling) remains disclosed as-is.

Verification on d9b44fc3 (clean env): typecheck 0 errors; plugin-fork 30, plugin-status-provenance 8, mcp-native-thread 8, tool-ring 24, plugin-agent + cache-ledger 100 — all green.

#2032 coordination: agreed — contextTokens should source from statusInputBaseline(session) once #2032 lands; this PR keeps its observation contract and will rebase onto it. Unknown stays contextTokensSource: "unavailable" with contextTokens: null here (never a rendered 0).

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

PR #2017 第三轮独立复审结论(reconciled stack d9b44fc3)

本轮范围:base rebalance(af4ada31→9609bb79,已核实为纯 master 内容)+ 两个新提交(29e2be93 D-B cap、d9b44fc3 revision cache + main-intent 文档)。全部 diff 逐行审读;本地独立验证在 d9b44fc3 上执行。另确认 PR body Fixes #2016→Fixes #2018 是有意 retarget(#2018 是你的 re-scoped tracking issue),不算问题。

一、是什么问题:第二轮的两个 open item(D-B raw-snapshot cap 未落地、main-intent 未文档化)与第一轮 flag E(status 轮询每次全量重哈希)已由维护者侧在贡献者最终 head 之上实现。本轮审这三处修复是否正确、有无新回归。

二、什么原因 / 怎么修的:

  • 29e2be93:新增 publicSnapshotCapBytes() 按请求读 BILI_PUBLIC_SNAPSHOT_CAP_BYTES(默认 16 MiB = 16_777_216,0 禁用,非有限值回落默认——动态生效无需重启)。rememberPluginMessages 中 structuredClone 后以 stableJson(candidate).length 计量,超限 → pluginSnapshot=undefined + metadata.publicSnapshotCapped=true;下次请求回落限下自动恢复保留(非粘性锁定)。超限后 snapshot/fork 均 409 SNAPSHOT_UNAVAILABLE 并带明确 cap 原因。两个新测试钉住 fail-closed 与恢复路径。
  • d9b44fc3:sessionRevisionOf() 以 revisionEpoch(markDirty 内单调自增)为键缓存 parentRevision;未变会话 O(1) 应答 status,任何变更失效后下次读重算;expectedRevision 走同一缓存读且在 session lock 下,stale 仍 409。epoch/cache 仅内存(已核实 persist.ts/buildRecord 不序列化它们;重启后首次读重算一次,语义正确)。新 provenance 测试钉住「未变相同 / 变更后移动 / fresh 被接受 / stale 409」。
  • PLUGIN.md 补齐 main-intent 段落(第二轮 open item ② 关闭)、cap 语义与 child 继承完整 ref namespace 的说明。

三、是否有回归问题:未发现阻断性回归。机制层面推演:revision cache 的失效模式只有「欠失效」(某变异路径漏调 markDirty)——但届时 fork 仍独立校验 ordered prefix + identity hash,expectedRevision 过期只是弱化变更信号,完整性由前缀校验兜底,方向仍是 fail-closed;stats-only 变更(settleUsageReport 等)不在 revision 哈希输入({sessionId,messages,state,blockContents,contentStore})内,无需失效,与缓存前语义一致。markDirty 调用点覆盖 8 个 src 模块(stream/server/session/plugin/cache-ledger/fork-adoption/decompress-shared/conflict-watch)。独立验证:typecheck 0 错误;本地定向测试 14 个文件 268/268(含 2 个新 cap 测试与 1 个新 revision-cache 测试);build 通过;wire goldens 官方脚本重生成字节一致;对最新 master(d19a5468)模拟合并 clean tree 无冲突;当前 PR head 9609bb79 CI 16/16 全绿。
一处边界澄清(非缺陷):cap 约束的是 raw snapshot 副本本身;CCR payload 保留遵循既有 #1341 生命周期语义,不在该 cap 范围内。

四、是否破坏缓存:不涉及。前缀缓存语义未变;revision cache 是 status 读路径的优化,mutation 驱动失效,未引入新的缓存陈旧面。

五、是否改了设计方向:无。两处修复都落在既有 session/persist/plugin 设施边界内。

六、是否引入新的配置:有——新增 env BILI_PUBLIC_SNAPSHOT_CAP_BYTES(默认 16 MiB,0 禁用,按请求动态读取,无迁移)。合并前需补两个合规小项:① PR body 的 Config Surface 一节仍写着 "No new ... environment variables",与事实矛盾,须按仓库 Configuration Surface Discipline 更新(key/默认值/理由/兼容);② CONFIGURATION.md 中英文缺该 env 镜像(§7.3 docs 规则)。均为文档级小修,你或贡献者补一个 commit 即可。

七、判定:代码本身独立验证全绿、无阻断缺陷,第二轮两个 open item 均已关闭。但合并前有 🔴 一个 merge-readiness 问题:refs/pull/2017/head 目前仍是 9609bb79(head 分支在贡献者 fork 内);29e2be93/d9b44fc3 只存在于本仓库同名分支——现在直接合并 PR 会丢掉 cap 与 revision-cache 修复。请先把 reconciled stack 推到 PR head 分支(随后 CI 会在 d9b44fc3 上跑,目前它 0 check-runs),确认全绿 + 上述两个文档项补齐,再人工合并。auto-merge 不适用(§7.4)。#2032 协调项(contextTokens 届时改从 statusInputBaseline(session) 取、本 PR 保持 observation contract 并 rebase)知悉,本 PR 范围内无需动作。合并链接:#2017

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

PR #2017 第四轮复审结论(head 090c7cf1,rebalance-only)

本轮触发点:refs/pull/2017/head 已从 9609bb79 前进到 090c7cf1 —— 第三轮的 🔴 merge-readiness 阻塞项(把 reconciled stack 推到 PR head 分支)已解决,cap(29e2be93)与 revision-cache(d9b44fc3)修复现在都在 PR 内。

增量内容核实:d9b44fc3..090c7cf1 只有三个 "Merge branch 'master'" 提交,零新增 PR 侧提交。用纯 PR 内容 diff 对比法验证(merge-base 法):新 head 相对 master 30e64f0f 的 PR 自有内容与 d9b44fc3 时的逐字节一致(差异仅为 master 侧改动导致的 hunk 行号偏移)。即第三轮对代码的全部结论原样沿用,本轮审的是「同一份代码 × 新基线」的交互。rebalance 带入的新 master 内容:#2030 knobs.ts、#1603/#1632 update 退避/install-dir、#2033 usage-grade anchor、#1999 responses re-voice、#2037 文档重组(env 纪律移入 reference/env-vars.md)等。

独立验证(均在本 head 本地执行):typecheck 0 错误;定向测试 14 文件 268/268;build 通过 + dist-import annotations OK;wire goldens 官方脚本重生成字节一致;CI 在本 head 16/16 completed/success;PR 状态 open / 非 draft / mergeable_state=clean(base 即当前 master)。

结构化七问

  1. 是什么问题:head 同步后的复审——确认新 head 含已审代码、且与新 master 无交互回归。
  2. 什么原因 / 机制:本轮无新机制(PR 内容逐字节未变),仅基线从 d19a5468 时代移到当前 master。
  3. 怎么修的:不涉及(无代码变更,只验证)。
  4. 是否有回归问题:未发现。交互审计:新 master 的改动(knobs/update/responses 文案/文档)与 fork/provenance 路径正交;全部 PR 专项测试在新基线上重跑全绿;两种压缩模式推演结论不变。
  5. 是否破坏缓存:不涉及(同第三轮结论)。
  6. 是否改了设计方向 / 配置:有一个新发现(合规项,非缺陷):rebalance 后本 PR 自己的基线里已包含 彻底整治环境变了滥用,除非必要都走配置文件 #2030 的 src/knobs.ts,其头部明文规定「新行为 knob 默认必须注册进 knobs.ts 并带 config-file key;env-only 仅限六个豁免类别且读点须注释说明」。而 BILI_PUBLIC_SNAPSHOT_CAP_BYTES 目前是 publicSnapshotCapBytes() 里裸读 process.env(src/plugin.ts),既不在 knobs.ts、无 config-file key,也不属于任何豁免类别(非 secret/进程间通道/第三方约定/bootstrap/host 侧)。合并前需补一个机械性小提交:在 knobs.ts 注册为 BILI_PUBLIC_SNAPSHOT_CAP_BYTES > <config key> > 16 MiB,并在 CONFIGURATION.md 中英文 + reference/env-vars.md 补镜像(第三轮 item ③ 由此升级)。另第三轮 item ② 仍未关:PR body 的 Config Surface 一节仍写 "No new ... environment variables",与事实矛盾;Remote CI 一节还引用旧 head 9609bb79,建议一并刷新。两处都是文档级,你或贡献者一个 commit 可完成(head 分支在贡献者 fork yingzhongshuoqi/billion-context 内,我无权直接推)。
  7. 判定:代码独立验证全绿、无阻塞缺陷,第三轮两个 open item 中 ① 已关闭、②③ 待上述小提交。补完两项文档/合规项后即可人工合并;auto-merge 不适用(§7.4)。fix: keep status baselines usage-grade after failures #2032 协调项知悉:master 上尚无 statusInputBaseline(本 head 内 grep 为空,fix: keep status baselines usage-grade after failures #2032 未合入),届时按既定方案 rebase 即可,本 PR 现在无需动作。合并链接:feat(plugin): expose isolated forks and attributed context observations #2017

…h knobs.ts (ranxianglei#2030 discipline)

New master (ranxianglei#2030) requires every behavior knob to resolve env > config
file > default through src/knobs.ts. The snapshot cap was a bare
process.env read in plugin.ts; it now resolves BILI_PUBLIC_SNAPSHOT_CAP_
BYTES > plugin.snapshotCapBytes > 16 MiB (0 disables) with the env tier
byte-exact to the pre-migration parser (Number(env): set-but-garbage
falls back to default, "" resolves to 0). CONFIGURATION.md en/zh gain
the plugin block, the mapping-table row and the semantics row;
reference/env-vars.md lists plugin.* in the tunables home. Precedence
pinned in tests/knobs-config-precedence.test.ts (default / file tier /
garbage env / empty-string quirk / garbage file).
@ranxianglei

Copy link
Copy Markdown
Owner

Round-4 compliance items closed at 300fd03c (fork head; also synced to the origin branch):

  1. knobs.ts registration — BILI_PUBLIC_SNAPSHOT_CAP_BYTES > plugin.snapshotCapBytes > 16 MiB now resolves through src/knobs.ts (830da41e): env tier byte-exact to the original plugin.ts parser (set-but-garbage → default; "" → 0 = disable, pinned in the quirks test), file tier strict-typed, hot-reload via the standard knob path. plugin.ts delegates and no longer reads process.env directly.
  2. Documentation mirror — CONFIGURATION.md en/zh: new plugin block + mapping-table row (plugin.snapshotCapBytes → default 16777216) + semantics row (fail-closed 409, re-evaluated per request, 0 disables). reference/env-vars.md lists plugin.* in the tunables home.
  3. PR body — Config Surface now states the knob instead of "no new env vars"; Remote CI no longer pins the stale 9609bb79 head; the "cap not in head" note is marked resolved with commit pointers. #2032 coordination stays explicitly open.
  4. Precedence pinned in tests/knobs-config-precedence.test.ts (default / file tier / garbage env / empty-string quirk / garbage file), plus the fork cap tests unchanged and green.

Verification on 300fd03c: typecheck 0 errors; plugin-fork + provenance + knobs-precedence + web-conflict-banner 59/59. CI runs on the fork head.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

PR #2017 第五轮复审结论(head 300fd03c,合规项收尾验证)

本轮范围很小:090c7cf1..300fd03c = 一个 master 同步(#2045/#2046 web conflict popup)+ 合规提交 830da41e + 收尾 merge。830da41e 的完整 diff(244 行)已逐行审读,增量内容核实为纯 PR 侧改动、无夹带。

合规项逐条核实(均关闭):

  • ① knobs 注册:knobs.ts 新增 publicSnapshotCapBytes() = BILI_PUBLIC_SNAPSHOT_CAP_BYTES > plugin.snapshotCapBytes > 16_777_216。env 层与迁移前解析器逐字节一致——我对照了原实现(Number(env) + isFinite && >=0 终判):set-but-garbage→默认、""→0(停用)、负数→默认、未设→file 层,四个分支全部由新测试钉住(default / file=999 / garbage-env / empty-string quirk / garbage-file)。plugin.ts 删除本地裸读函数改为委托,无其他改动;config.ts 仅加可选 plugin 块(纯增量,既有用户配置零影响)。
  • ② 文档镜像:CONFIGURATION.md 中英文各 +9 行(plugin 块 + 映射表行 + 语义行,含 fail-closed 409 / 每请求重评估 / 0 停用语义,与实现一致);reference/env-vars.md 把 plugin.* 列入 tunables home。中英同步。
  • ③ PR body:Config Surface 一节现在如实描述该 knob(不再是 "no new env vars");Remote CI 一节不再钉死旧 head。剩余 3 处 9609bb79 字样均为正当的历史溯源语境(reconciled stack 谱系、补充验证归属、已划线的 resolved 注记),非陈旧引用。

结构化七问

  1. 是什么问题:第四轮两项合规遗留(knob 未按 彻底整治环境变了滥用,除非必要都走配置文件 #2030 纪律注册、文档/PR body 缺镜像)的闭环验证。
  2. 什么原因 / 机制:rebalance 带入 彻底整治环境变了滥用,除非必要都走配置文件 #2030 后,knob 必须走 knobs.ts 三层解析;本提交完成注册并保留历史解析怪癖。
  3. 怎么修的:不涉及(只验证,未改码)。
  4. 是否有回归问题:未发现。该提交本身零运行时行为变化(env 语义逐字节保持,配置键纯增量);rebalance 带入的 master 侧改动(和billion-context兼容的插件不用web弹窗报警 #2045/fix: no web conflict popup for auto-disabled bili siblings; full detail (#2045) #2046)其专项测试本地亦全绿。独立验证:typecheck 0 错误;定向测试 14 文件 275/275(含新增优先级断言);master 侧 web-conflict-banner + thirdparty-scan 26/26;build 通过 + dist-import annotations OK;wire goldens 重生成字节一致。
  5. 是否破坏缓存:不涉及。
  6. 是否改了设计方向 / 配置:有且仅此一处——正式引入 knob BILI_PUBLIC_SNAPSHOT_CAP_BYTES(默认 16 MiB,0 停用留存),现同时可用配置键 plugin.snapshotCapBytes 表达(env 优先),三处文档齐备;符合 Configuration Surface Discipline。
  7. 判定:代码与文档全部就绪,无阻塞缺陷。CI 在 300fd03c 上目前 12/16 success、4 个仍在跑(当前 mergeable_state=blocked 是必需检查未完成导致的瞬态,非文本冲突——merge-base 即当前 master e4d6bfe6)。剩余检查转绿后即可人工合并;auto-merge 不适用(§7.4)。fix: keep status baselines usage-grade after failures #2032 协调项按 PR body 声明保持 open,fix: keep status baselines usage-grade after failures #2032 合入后 rebase 即可。合并链接:feat(plugin): expose isolated forks and attributed context observations #2017

@ranxianglei
ranxianglei merged commit 9e2b007 into ranxianglei:master Oct 4, 2026
16 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 4, 2026
ranxianglei pushed a commit that referenced this pull request Oct 8, 2026
… MiB

#2394 G3. The public fork API retains a raw wire-history snapshot per
plugin session for adopt-on-fork; sessions whose serialization exceeds
the cap fail closed (409 SNAPSHOT_UNAVAILABLE) and degrade to a bare
fresh session + full raw replay. The 16 MiB default sits below real
long-session sizes — the #2383 incident's ~5M-token dsh session
serialized to ~20MB+, so fork adoption could never apply there and
every fork degraded to raw replay (the storm #2387 stops at the bottom).

Owner instruction in the #2383 thread (sign-off for this default change):
"调大吧 调成100M?" — implemented exactly as asked.

config surface: default-value change ONLY. plugin.snapshotCapBytes /
BILI_PUBLIC_SNAPSHOT_CAP_BYTES fallback tier moves 16 MiB -> 100 MiB;
no new keys/fields/env vars, override precedence unchanged, no migration
(explicit overrides keep their values). 100 MiB keeps the #2017 D-B
fail-closed bound while giving ~5x headroom over the largest observed
incident session.

behavior change: OLD un-forkable above 16 MiB -> NEW un-forkable above
100 MiB; worst-case retained snapshot per very-long plugin session
<= ~100 MB (was <= ~16 MB). '0' = disable-retention and env parsing are
unchanged.
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.

Expose isolated context forks and provenance for Ekko integration

2 participants