Skip to content

fix(#1309): route dsh auto-review traffic to the side-passthrough lane - #1861

Closed
ranxianglei wants to merge 2 commits into
masterfrom
2026-10-02_dsh-autoreview-side
Closed

ranxianglei wants to merge 2 commits into
masterfrom
2026-10-02_dsh-autoreview-side

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

Fixes #1309 for the DSH auto-review class.

The request shape (source-verified, @deepseek-ai/dsh-experimental-auto-review)

dsh's Auto permission preset fires one review LLM request before every tool call — classifyRisk():

  • fixed system: REVIEW_POLICY, byte-identical across 0.1.7-rc.2 → 0.2.0-rc.2, opening "You are the final authorization reviewer for exactly one pending tool call…"
  • exactly one user message = reviewUserText(snapshot): five stable JSON sections (ENVIRONMENT / PROJECT_INSTRUCTIONS / FILTERED_HISTORY / PENDING_ACTION), join("\n\n")
  • no tools, no max_tokens, temperature: 0, same session id → ctx.llm.stream

The #388 budget heuristic (max_tokens<=200) can never catch it → full pipeline: refs consumed, snapshots rewritten, nudge baseline skewed, and 3 consecutive review calls trip the silent orphan-GC that deactivates every compressed block (#1307/#1308; 72.4% compress-failure rate in the wild).

The stable signal #1309 asked for

Not shape (every shape disjunct breaks #1075's genuine-short-view semantics) — the machine-authored system prompt. No human turn begins with REVIEW_POLICY; it is package-internal and versioned like MAIN_SYSTEM_PREFIXES (#970 discipline).

Two-signal AND, failure direction = "stop side-routing" (degrades to today's behavior):

  1. MARKER: messages[0] is a system message starting with the versioned REVIEW_POLICY prefix;
  2. SHAPE: ≤2 messages, no tools, user message opens with the stable ENVIRONMENT header.

Routing

Into the existing #388 side-passthrough lane — FORWARDED (legitimate host traffic; the opposite verdict from #1729's compaction refusal), zero kernel contact: no ref consumption, no snapshot refresh, no nudge baseline, no usage, no orphan-GC visibility. Shape heuristics untouched — fix-1075-side-request suite stays green. One info log per session; the passthrough log line now names the lane reason.

Cross-module regressions pin that #1729 and this detector can never collide: the compaction marker lives in the final user message, reviewUserText starts with ENVIRONMENT.

Future aux personas (WebSearch, classifiers): same template — version-track their fixed prompt, never their size.

Tests: tests/dsh-autoreview-side.test.ts (11), plus compaction-guard 10/10, #1075 6/6, side-request-isolation 18/18, orphan-GC 4/4, #1307 2/2 — all green; typecheck clean. (Local dsh-native.test.ts attach-mode failures reproduce on clean master — environmental, not from this change.)

dsh-experimental-auto-review (the desktop Auto permission preset) fires
one review LLM request before EVERY tool call: fixed REVIEW_POLICY
system prompt + exactly one user message (reviewUserText snapshot JSON),
no tools, no max_tokens, temperature 0 — under the MAIN session id.
The #388 budget heuristic (max_tokens<=200) can never catch it, so it
ran the full pipeline: consuming refs, rewriting snapshots, skewing
the nudge baseline, and 3 consecutive review calls tripped the silent
orphan-GC that deactivated every compressed block (#1307/#1308; 72.4%
compress failure rate in the wild).

#1309 left the routing open: every SHAPE-based disjunct (message
count / budget / overlap) breaks #1075's genuine-short-view semantics.
The stable signal #1309 asked for exists at the traffic level — the
review request's system prompt is machine-authored, package-internal,
and no human turn begins with it.

- src/server/dsh-autoreview-side.ts: two-signal AND identification
  (claudeSubagentSplit #970 discipline; failure direction = "stop
  side-routing", degrading to today's behavior):
  1. MARKER: messages[0] is a system message starting with the
     versioned REVIEW_POLICY opening — byte-identical across
     0.1.7-rc.2 → 0.2.0-rc.2, tracked per dsh release like
     MAIN_SYSTEM_PREFIXES;
  2. SHAPE: <=2 messages, no tools, user message opens with the
     stable "ENVIRONMENT" header of reviewUserText().
  openai chat wire shape v1 (the desktop lane; qwen/deepseek alike).
- src/server.ts: matching requests join the #388 side-passthrough
  lane — FORWARDED (legitimate host traffic, unlike the #1729
  compaction refusal; cross-module regression tests pin that the two
  detectors can never collide: the compaction marker lives in the
  final user message, reviewUserText starts with "ENVIRONMENT"), with
  zero kernel contact: no ref consumption, no snapshot refresh, no
  nudge baseline, no usage, no orphan-GC visibility. Shape heuristics
  untouched — #1075's short-view semantics hold (suite green). One
  info log per session on first routing; passthrough log line now
  names the lane reason.
- tests/dsh-autoreview-side.test.ts: 11 cases — real classifyRisk()
  wire shape, string/content-parts forms, marker-position negatives
  (later system / quoted mid-system), tools guard, ENVIRONMENT guard,
  count bar, protocol scope, both cross-module #1729 regressions,
  live-package string checks.

Fixes #1309 for the auto-review class; the marker-over-shape
discipline is the template for future aux personas (WebSearch,
classifiers): version-track their fixed prompt, never their size.
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-02_dsh-autoreview-side (e207ef6)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1851-pr.1861.45968a8

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

Option B — Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

[bot] 🏷 协调备注(来自 #1309 线程):另一个 open PR #1431(anchor affinity 判别器,同为 Fixes #1309)与本 PR 撞在 src/server.ts 同一处 side gate 的 OR 项上。我已独立审查本 PR:#1729 双向不相交性对 master 源码核实成立(guard :2449 先于 side gate :2472;前缀常量与检查位置均不同)、测试有牙、head CI 全绿——本 PR 可合。owner 正在 #1309 定夺去留;若本 PR 先合,#1431 预计关闭为 superseded(或按 owner 决定 rebase 到本 PR 之后)。合并前留意这一层即可,代码本身无需改动。

@ranxianglei

Copy link
Copy Markdown
Owner Author

ework 进行review

@ranxianglei

Copy link
Copy Markdown
Owner Author

这个是让auto-review自动过,不是设计方向

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.

[跟进] 辅助请求(auto-review/classifier)需统一隔离策略——与 #1075 冲突,需 owner 拍板

1 participant