Repository navigation
[PR] fix(#5925): fail the #4805 membership gate closed on absent evidence - #5926
ranxianglei wants to merge 2 commits into
Conversation
The settle-side anchor-pollution defense (#4805) failed open when a request carried no message ids at all: probeRequestMembership deletes the verdict on empty id lists and isForeignMembership(undefined) read as 'member', so a side-lane sample under a shared session id settled over the main conversation's anchor. Right after a fold (credit window open) it nets to max(0, tiny - credit) = 0, growth drops below the nudge floor, and compression stops until window overflow — failed requests return no usage, so the anchor cannot heal itself. - ONE three-state admission predicate (membershipBlocksSettlement): proven member admits, proven foreign refuses, absent verdict admits only while no needle is planted (bootstrap unchanged). Applied at BOTH scale-state writers: settleUsageReport's anchor family AND noteOutboundContextEstimates — the same foreign request also rewrote localInputEstimate, pinning effectiveTokenCount's min(localInputEstimate, raw) fallback at foreign scale even with the anchor guarded. - resetSessionCompression clears the needle: the rebuilt conversation starts a fresh host id generation; a dead pre-rebase needle would stall bootstrap forever under the fail-closed gate. - The compress-credit meter branch is deliberately NOT gated with anchorImpossible: #5135 proved the guard fires on the session's own honest credited anchor when the client resends covered originals. Behavior change: a no-id usage sample after the conversation's id family is known now skips the anchor write (previously admitted) — it still bills cumulatively, and the anchor heals through the next id-carrying report. The outbound estimate channel applies the same rule. Bootstrap (no family known) is unchanged in both.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.8596-pr.5926.3b9d10fThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5926.tgz
npm install -g packageInstall instructions are refreshed on each push. |
CI caught a second pin of the pre-fix behavior that the local targeted run missed: tests/request-membership-http.test.ts asserted end-to-end over HTTP that a no-ID sample settles after either foreign or member evidence (the old abstain-and-admit semantics). Flip it deliberately: the verdict still clears on a no-ID request (abstention unchanged), but while the id family is known the sample is refused and the anchor heals through the next id-carrying report. One extra heal turn per variant; forwarded count 10 -> 12.
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 This is the single fix PR for #5925 (two residual holes in the #4805 anchor-pollution defense); family map checked live — #4805 (closed, original fix #4849), #4425 (write-side aux-settle clearing, different mechanism, still open), #5135/#5136 (closed, the regression this PR correctly avoids), #4859 (closed decision request) — none overlaps this diff's scope. One open [PR] row targets this thread, satisfying one-fix-PR-per-thread. 标签: bug / p1 / scope/wiring(会话不可恢复类——压缩停摆到窗口溢出;p1 按 owner 修订不可降档。wiring:修复在服务端 scale-state 写者,车道无关)。 Reviewed at head
Local at 结构化八问
判定:建议合并 —— 待 |
Closes #5925
What this fixes
Two residual holes in the #4805 anchor-pollution defense (reported against v0.1.213, still present on master):
probeRequestMembershipdeletes the verdict when a request carries no message ids at all, andisForeignMembership(undefined)evaluates to "member" — so a side-lane sample under a shared session id settled over the main conversation's anchor. Right after a fold (credit window open) it nets tomax(0, tiny − credit) = 0, growth drops below the nudge floor (default 22500), and compression stops until window overflow — and failed requests return no usage, so the anchor cannot heal itself.localInputEstimate(noteOutboundContextEstimatesruns at the relay send chokepoint for every outbound, no membership check) — even with the anchor write guarded,effectiveTokenCount's fallbackmin(localInputEstimate, raw)stays pinned at foreign scale.Fix
One three-state admission predicate (
membershipBlocksSettlement) applied at BOTH scale-state writers:settleUsageReport: the gate uses the predicate; the refusal log distinguishes proven-foreign from absent-evidence and names the needle.noteOutboundContextEstimates: early-returns under the same predicate.resetSessionCompressionclears the needle + payload scale: the rebuilt conversation starts a fresh host id generation, so a dead pre-rebase needle would stall bootstrap forever under the fail-closed gate.Behavior change (intended, disclosed)
Cumulative billing (
inputTokens/ USD ledger) is unaffected in every case — refusals only protect this conversation's anchor family.Why slot 1 of the reporter's patch is not taken
Adding
!anchorImpossibleto the compress-credit early return would regress #5135: in that incident shape the session's own honest post-fold credited anchor (180K) faced a resent upper of ~38.7M chars (client resends covered originals, ≈64× tower), soanchorImpossiblelegitimately fires there, and gating the credit branch manufactures a false OVER-LIMIT demotion right after a successful fold.tests/issue5135-post-fold-credit.test.tspins that shape. With hole 2 closed at the writers, polluted anchors can no longer reach the meter through the main path. The baseline readers (statusInputBaseline/usageGradeInputBaseline) are safe by construction: they take no message list, cannot compute the guard, and are protected at their single writer side.Tests
tests/issue5925-membership-fail-closed.test.ts(7 cases): core refusal + cumulative billing, post-fold impact chain (credited anchor survives), bootstrap preserved, estimate-channel gate with control, heal, rebase needle clear, predicate truth table.tests/issue4805-anchor-pollution.test.tsT3e deliberately updated: it pinned the old fail-open settle; it now asserts refusal + heal, still parametrized over previous member/foreign verdicts.No config surface change. No kernel change.