Repository navigation
fix(#1729): refuse dsh native compaction calls at the proxy gate - #1835
Merged
Merged
Conversation
dsh-compaction-basic answers context pressure by replaying the whole conversation prefix and appending its fixed COMPACTION_INSTRUCTION as the final user message, under the SAME session id (KV prefix-cache reuse). In the desktop lane those calls ride bili as a second producer on the main conversation — the #1729 deadlock — and when one lands, dsh durably shadows the replayed surface range: the original messages never ride a future request again, destroying the proxy's compression substrate. That loss is irreversible; every cost of refusing is dsh-side, caught, and recoverable, so the guard is unconditional. - src/server/dsh-compaction-guard.ts: two-signal AND identification (per the claudeSubagentSplit #970 discipline — both signals must agree, failure direction is "stop intercepting"): 1. MARKER: final user message starts with the versioned instruction prefix (verbatim from @deepseek-ai/dsh-compaction-basic, tracked per dsh release like MAIN_SYSTEM_PREFIXES); 2. SHAPE: whole request <= 4 messages (observed live: 2 msgs at ~152K tokens in the #1727 logs; a normal turn — even one quoting the template — carries its full history and cannot fit). openai + anthropic wire shapes; google/responses out of scope v1. - src/server.ts: guard runs after identity resolution, BEFORE the #388 side-request lane and any pipeline work — refused locally (403, non-retryable, protocol-shaped), kernel state untouched, WARN once per session. Not gated on the dsh plugin marker: a dsh host routed through a global bili without the plugin bundle is covered too. The refusal message rides into dsh's own warn line ("step compaction failed: <message>; continuing the turn"). - tests/dsh-compaction-guard.test.ts: 10 cases — observed production shapes, content-parts, anthropic shape, quoting/mid-history non- matches, count bar, protocol scope, refusal bodies, live-template prefix check. Deliberate residual costs, on record: manual /compact is refused too (same envelope — the traffic layer cannot tell the trigger), and dsh's context-overflow recovery loses its compaction path (the original 400 surfaces; bili's nudge/truncate is the defense). The source-layer fix (preset auto:false, #1827) remains complementary: it makes dsh not even try, so nothing reaches this gate. Refs #1729 (deadlock producer), #1772/#1827 (source-layer preset), #1206 ([conflict] name-scan), #394 (shared-session hazard class).
Contributor
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1817-pr.1835.74f24adThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1835.tgz
npm install -g packageInstall instructions are refreshed on each push. |
LoveDoLove
pushed a commit
to LoveDoLove-Forked-Projects/billion-context
that referenced
this pull request
Oct 10, 2026
…w ledger; fail fast doomed evidence probes Root cause of the ranxianglei#2490 turn-37→40 death: the host's raw ledger (replayed whole by every refused dsh native-compaction envelope) is invisible to bili's folded view, so the output clamp planned against the small folded input while the host re-sent the full raw history every turn — a 1M window with ~200K folded input let max_tokens=384000 through and one 7.5MB assistant turn landed un-folding. Two guards: - ledger floor: the ranxianglei#1835 guard now records the refused replay size on the session (high-water bytes + count) and clampOutgoingOutput plans against max(folded estimate, ledger floor) on the openai/google/responses lanes. Only ever tightens; cap < floor surrenders to preflight as before. - doomed probe: the ranxianglei#2313 forward-once-for-evidence bet assumes some tokenizer might fit the payload. Beyond window×7.5 BYTES of core text (densest live-route billing observed ~6.8 B/token, ranxianglei#2122) none can, so the probe is a guaranteed 400 with an 8MB body — fail fast 502 with the byte math instead of paying it. tests/issue2490-ledger-floor-doomed-probe.test.ts: 6 pins (floor unit trio, incident clamp 384K→55K, guard accounting e2e, doomed-probe e2e, ranxianglei#2313 control).
YunzhouLi-hub
pushed a commit
to YunzhouLi-hub/billion-context
that referenced
this pull request
Oct 11, 2026
…t dsh native compaction The ranxianglei#1117 passthrough lane relays byte-untouched with 'no session, no injection, no guard' — which made it the one lane dsh's agentless background compaction could still LAND through: the takeover gate refuses attribution for agentless callers while the settings overlay has already routed the URL to /bili/, so the native patch stamps x-bili-passthrough and the call relays verbatim BELOW the ranxianglei#1835 pipeline guard (field report: 49 compaction starts, 45 refused through the pipeline, 4 landed through this lane, each landing later tripping ranxianglei#1001 as an 'unannounced' rewrite). Same refusal applied at this lane too: marker-decisive detection (ranxianglei#2193 — message count never gates), raw-ASCII sniff prefilter so ordinary background traffic (title-gen, plugin calls) pays no JSON.parse, bounded decode for content-encoded bodies (the relay still forwards the ORIGINAL bytes), honors allowDshCompaction (ranxianglei#2028), fail-open on undecodable bodies (the ranxianglei#1835 failure direction), and a process-level refusal count since the lane has no session for the ranxianglei#2490 ledger.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1729 — kills the deadlock's second producer at the traffic level. Complementary to #1827 (source-layer preset): the preset makes dsh not even try; this gate refuses whatever still tries (manual /compact, native presets chosen explicitly, hosts without the plugin bundle).
What lands vs what refuses — the asymmetry that justifies the gate
Letting a dsh compaction call through is irreversible: a landed checkpoint durably shadows the replayed surface range (
shadowedSeqs/shadowedRange, surface replacement generation) — the original messages never ride a future request again, and the proxy's compression substrate is destroyed alongside bili's own state anchors (the #1729 deadlock). Every cost of refusing is dsh-side, caught, and recoverable:agent/pre-step)warn "step compaction failed …; continuing the turn"— benign, turn proceedsrequest-error)/compactIdentification — two-signal AND (claudeSubagentSplit #970 discipline)
COMPACTION_INSTRUCTIONprefix (machine-appended by dsh-compaction-basic's summarizer; tracked per dsh release likeMAIN_SYSTEM_PREFIXES);Both must agree; a reworded template degrades to today's behavior. openai + anthropic wire shapes in v1; google/responses out of scope. Not gated on the dsh plugin marker — a dsh host routed through a global bili without the bundle is covered too.
Wiring
Guard sits after identity resolution, before the #388 side-request lane (a compaction call is full-budget, only this gate catches it) and before any pipeline work: refused locally (403, non-retryable, protocol-shaped), kernel state untouched, one WARN per session. The refusal text rides into dsh's own warn line, so the host log self-explains.
Tests: 10 cases in
tests/dsh-compaction-guard.test.ts(observed shapes, content-parts, anthropic, quoting/mid-history non-matches, count bar, protocol scope, refusal bodies, live-template prefix check). Typecheck green.