Repository navigation
feat(#1729): session-level dual-stream shape observer with one-shot conflict WARN - #1837
ranxianglei wants to merge 1 commit into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1821-pr.1837.7ca4919This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1837.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review 完成(验证模式:不重做工作,核对代码与声明、本地重跑定向验证、看 CI)。结论:可合(CI 全绿 + rebase 干净 + 声明全部核实)。 ① 审原 issue(方向关)#1729 是真实死锁:同一 session id 上交替出现两种结构互斥的请求流(多轮 loop ~107 msgs/46K ↔ 巨型单消息 1–2 msgs/~165K),没有任何单个请求能同时满足 nudge 三门(T1 pending≥50K ∧ growth≥floor ∧ 当前载荷可压缩)→ usage 贴顶 ~15 分钟无压缩且全链路无告警。issue floor 2 走完三步审核后给出设计规格(纯分类器 + O(1) 会话状态 + 一次性 WARN + ledger 落账 + 零新端点);你 floor 4 实锤辅流身份(dsh-compaction-basic ② 回归审查(触碰的既有行为清单)diff 共 4 文件(+296/-1),逐项判定:
高危模式逐项过:无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式漂移(唯一新增输出:满足双流条件时的一条 warn 行 + 一条可选 ledger 事件)。 ③ 代码审查(主关)
④ 测试有效性新增 6 case( ⑤ diff 整洁度4 文件全部与本 PR 目的相关:union 加 1 行、4 处各加 1 行调用、2 个新文件(模块 + 测试)。无空白重排、无生成物、无 lockfile 变更。干净。 ⑥ 验证证据
结构化七问
合并判定:可合。 合并按钮留给你(系统规则禁止 agent 合并):#1837 |
Part of #1729 — completes the observer scope remaining after #1835
#1729's deadlock had two missing layers. #1835 ships the traffic gate for the identified producer (dsh compaction calls refused at the proxy). This PR ships the general observer the issue scoped as the remaining value: session-level detection of structurally exclusive request shapes sharing one session id, for unclassified personas (autoreview / subagent / future replay variants).
What
New
src/stream-watch.ts+ one call per protocol prepare site (4 sites, post-processTurn,src/server.ts:3387/3620/3869/4162). Each pipeline request is profiled by normalized message count vs token magnitude relative to that request's own model window:monolith: ≤2 msgs ∧ ≥50% of window (the 升级新版本后一开始用的本地模型27B 不压缩,换模型后压缩 桌面版本 #1727 signature: 1–2 msgs at 91–99%)multi-turn: ≥3 msgs (the agent-loop flow)Once BOTH classes have each been seen ≥2 times on one session id → exactly one WARN per session, fingerprinting both shapes (latest msgs/tokens/usage% + truncated nudge verdict) and pointing at #1206/#394/#1835/#1729. The same fingerprint lands in the #1206 conflict ledger (
dual-stream) → visible in acp_status, the web banner, and/__bili/statswith zero new UI plumbing.Why this layer, why these thresholds
The kernel's per-request nudge gate is correct design and stays untouched (kernel contract: never relax gates for one malformed payload). The missing piece was observation: when two producers share a session id, no single request can satisfy
pendingT1≥50000 ∧ growth≥floor ∧ payload-compressible, usage pins near the ceiling, and today nothing aggregates that pattern. The thresholds are internal diagnostic constants (precedent:EMERGENCY_NUDGE_ESCALATION_PCTinsrc/server/budget.ts), window-relative so they scale from a 167K window to a 1M window without retuning. State is O(1) insession.metadata.streamWatch— round-trips through existing wholesale metadata persistence, the one-shot flag survives restarts, old versions ignore the unknown key, corrupt state degrades to fresh.Relationship to the other layers:
dsh.bundle.patch.yml禁用自动压缩在 web profile 下静默失效 #1772: source-layer preset off (dsh doesn't try at all). Three layers: don't try at source + refuse known at traffic + observe unknown at session level.Behavior change disclosure (additive only)
ConflictKindvalue (dual-stream). All consumers verified generic (no exhaustive switches); ledger ring cap unchanged.streamWatch). Persistence format/version unchanged.Config surface
None. No new config field, env var, or CLI flag. Thresholds are internal constants per the precedent above; if tuning ever proves necessary that is a separate owner-gated discussion.
Honest boundaries
Detects the observed signature (giant single-message ↔ multi-turn). Mid-shape variants (e.g. a 5–10-message replay call) classify as multi-turn and blend into the main flow today — threshold evolution would be needed if triage surfaces such a variant. Concurrent same-shape sharing across endpoints is a different signature and out of scope here.
Pre-flight
npm run typecheckcleantests/stream-watch.test.ts(new, 6 cases: classifier boundary table incl. exact-half and 1M-window scaling, one-shot trigger sequence, non-trigger sequences, restart round-trip, corrupt-state tolerance, reason truncation) +tests/issue1206-thirdparty-scan.test.ts(conflict-watch union consumer) = 26/26 passnpm run buildOK, module bundled intodist/index.jssrc/server.ts→ ci-e2e auto-runs)