Repository navigation
feat(plugin): expose isolated forks and attributed context observations - #2017
Conversation
[bot] 🏷 收到,开始独立 review。先报基础事实:
接下来逐层审查,结论会按结构化七问回帖。 |
独立 review 完成(外部贡献者 PR,无 agent 标记,走完整流程)。先给独立验证证据,均在 PR head
结构化七问
行为变更披露(旧值 → 新值 + 原因)
测试有效性真测试,断言有牙:真实 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 失败( 判定按 §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.
…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.
|
Rebased onto current master ( Two maintainer-side changes on top:
Local verification at 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. |
|
@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. |
…ork-context-provenance
PR #2032(#2029 的修复,draft)引入了从
|
PR #2017 第二轮独立复审结论(新 head 复审范围:第一轮审的是 一、是什么问题:外部贡献者的公开 plugin fork 契约(snapshot/fork 端点)+ 归因有效上下文观察功能(companion:EKKOLearnAI/ekko-studio#3279)。本轮审的是维护者侧冲突解决 + 贡献者最终推送后的新 head 是否引入回归或遗漏。 二、什么原因/怎么修的(机制层面):
三、是否有回归问题:未发现阻塞性回归。逐项清点既有行为变更: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( 四、是否破坏缓存:未破坏。前缀缓存语义不变(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 裁决 + 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 |
PR #2017 第二轮独立复审结论(新 head 复审范围:第一轮审的是 一、是什么问题:外部贡献者的公开 plugin fork 契约(snapshot/fork 端点)+ 归因有效上下文观测特性(companion:EKKOLearnAI/ekko-studio#3279)。本轮审的是维护者侧冲突解决 + 贡献者最终推送后,新 head 是否引入回归或遗漏。 二、什么原因导致的 / 怎么修复的(机制层面):
三、是否有回归问题:未发现阻断性回归。行为变更逐项清点: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( 四、是否破坏缓存:不涉及。前缀缓存语义未变(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)。 七、判定:独立验证全绿,无阻断缺陷。建议完成上述两项(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).
|
Reconciliation of the two stacks (maintainer-side, credits preserved):
Verification on #2032 coordination: agreed — |
PR #2017 第三轮独立复审结论(reconciled stack 本轮范围:base rebalance( 一、是什么问题:第二轮的两个 open item(D-B raw-snapshot cap 未落地、main-intent 未文档化)与第一轮 flag E(status 轮询每次全量重哈希)已由维护者侧在贡献者最终 head 之上实现。本轮审这三处修复是否正确、有无新回归。 二、什么原因 / 怎么修的:
三、是否有回归问题:未发现阻断性回归。机制层面推演: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( 四、是否破坏缓存:不涉及。前缀缓存语义未变;revision cache 是 status 读路径的优化,mutation 驱动失效,未引入新的缓存陈旧面。 五、是否改了设计方向:无。两处修复都落在既有 session/persist/plugin 设施边界内。 六、是否引入新的配置:有——新增 env 七、判定:代码本身独立验证全绿、无阻断缺陷,第二轮两个 open item 均已关闭。但合并前有 🔴 一个 merge-readiness 问题: |
PR #2017 第四轮复审结论(head 本轮触发点: 增量内容核实: 独立验证(均在本 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)。 结构化七问
|
…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).
…n-fork-context-provenance
|
Round-4 compliance items closed at
Verification on |
PR #2017 第五轮复审结论(head 本轮范围很小: 合规项逐条核实(均关闭):
结构化七问
|
… 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.
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.
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: maindocs) +830da41e(knobs.ts registration of the cap, #2030 discipline) + merges to current master. The fork head branch now carries this stack (maintainerCanModify).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 throughsrc/knobs.tswith 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 at29e2be93(with tests) and is registered through knobs.ts at830da41e. The #2032 statusInputBaseline coordination stays open until #2032 merges upstream.