Fixes config-surface-guard + docs-sync CI failures: the docs index tables
are generated from website/config-reference/*.yaml (tools/gen-config-docs.mjs
generate), not hand-edited. Adds the compress.degenerateRetry object entry
(co.degenerateRetry) plus the two leaf seeds (maxAttempts, nudges) with
en/zh/ja descriptions, and regenerates all generated artifacts (docs tables
in all three languages, website nav).
The PR's snapshot-plane commits added config fields (sessions.*, plugin.snapshotCapBytes, snapshot.shadow) and src/server/egress-lane-io.ts without doc seeds, so three CI gates went red on head 02fc8f4c2:
- config-surface-guard: 11 leaf fields lacked website/config-reference seed entries
- docs-coverage: 11 env vars + 2 top-level keys (sessions, plugin) undocumented (BILI_SESSION_CONTENT_STORE_PIN is env-only)
- architecture-docs: reference/architecture.md missing src/server/egress-lane-io.ts
Added the seeds (process.yaml: sessions block + 9 leaves; server.yaml: plugin.snapshotCapBytes + snapshot.shadow; env-only.yaml: BILI_SESSION_CONTENT_STORE_PIN), the file-map line, and the regenerated docs/configuration.{md,zh-CN.md,ja.md} + website artifacts.
Verified locally: all three gates green, generate idempotent, typecheck clean.
PR #6785 CI fix.
Every v12 table that never entered master is deleted except the ones the
ruling keeps (l1_world, orphan_blocks, state_fields, egress_state,
egress_flow). The #5874 v2 snapshot-base plane (fold_journal +
egress_snapshot + egress_scope_rev) shipped no behavior yet — its D-lane
byte cache was bypassed on the plugin lane and its sole write consumer
was this PR — so it is removed wholesale:
- schema.ts: three DDL consts + all probes (incl. the covered_ids /
ids_json DROP-column and scope_rev ADD-column migrations); v12 keeps
l1_world / orphan_blocks / state_fields / egress_state+flow
(probe-first, unchanged).
- snap.ts: fold-journal + egress-snapshot functions deleted; the L1
world / R3 latch functions (stage-0 identity + pf pin) are kept.
- store.ts / shadow.ts / persist.ts: egressCut / egressReadView /
appendFoldJournal / appendEgressSnapshot / bumpEgressScopeRev and all
seven per-write rev-bump sites gone; delete/archive cascades trimmed.
- snapshot-render.ts: the splice (warm serve) and cut blocks gone — the
D-lane reverts to live derive, pre-#5874 behavior.
- config surface: storage.snapBase (enabled/cohorts/cutEveryKUserTurns)
removed from config.ts, knobs.ts, process.yaml + regenerated docs —
the plane never shipped, so there is no compat story to keep.
- tests: the three plane-only suites retired; 111/111 battery +
108/108 lane suites green, typecheck clean.
The byte-level prefix-cache gain the plane would have given is superseded
by the self-contained egress op-log, which serves the FULL rendered view
from the flow tables on every lane.
⚠️ MODEL-FACING TEXT CHANGE — the success compress receipt changes what the
model reads: with the new default (compress.postComPressTail off, the
pre-existing behavior is NOT the default), the receipt no longer re-advises
the remaining foldable ranges after every successful fold, and no longer
emits the 'Uncovered history remains' audit note. With it on (explicit opt-in),
the range list is restored and the uncovered note fires at most once per
nudge-injection cycle (fresh injection re-opens it). The verbatim
context-minimum stop signal is unchanged in both modes.
Consumption-chain reasoning (#6855 discipline): the removed text carried the
only forward-pointing refs the model propagated into its NEXT compress call
(startId/endId copied from the 'Current compressible ranges' list). Removing
it removes the propagation anchor entirely — no phantom-value class possible.
Nothing else in the receipt is altered byte-wise; the stop-signal sentence
(#1387) is preserved verbatim, so models that key on it see identical text.
The per-turn growth nudge (KDD #8) is a separate channel and untouched.
Why: per-receipt re-recommendation drove models into endless fold loops
against explicit user stop requests (#7318: 200+ folds in one night on a
0.1.216 build; #6522 '不要连续推荐' and #5872 are the same family — the
receipt footer drives single-message retry folds). Each fold rewrites the
context prefix and re-bills the prompt cache.
config surface (#1437 discipline, owner decision in-thread 2026-11-20):
adds compress.postComPressTail (boolean, default off) to the existing three-
level compress hierarchy (global/provider/model via mergeCompress); boolean
only (non-boolean rejects the whole block like the sibling requireNudge /
requireRecommendation); no new env var (knob goes through the existing
compress file hierarchy, env-discipline #2030). Docs: config-reference seed
entry + regenerated configuration.md en/zh/ja + website.
Plumbing: the flag is stamped per round on session.transient next to the
existing nudge gate (src/unprompted-gate.ts) and read at the tail decision
point in src/stream.ts — off by default when a session has no stamp
(defensive: never recommend on an unknown posture). The #6522 at-most-once
latch rides on an in-memory Session field (uncoveredReceiptNoted), re-opened
only by an actual nudge injection.
Fixes#7318 (design: default off); implements #6526's at-most-once note (that
PR is superseded — its change was unconditional, this one is gated).
Supersedes: https://github.com/ranxianglei/billion-context/pull/6526
(#7144 follow-up) The #651 pass drops oversized reasoning attached to closed
compress turns only. With tail:true (default off) it extends to ANY closed
round — a tool call whose result arrived with at least one message after it,
or an assistant text turn that is no longer the view's last message. Those
rounds leave the protected window at the next fold anyway, so dropping early
reclaims the tokens now; the in-flight round is never touched.
Strict-echo upstreams are unaffected: #762/#2169 blank-echo normalization
runs after the drop, and planReasoningDrop still disables the whole pass
there. Config knob compress.reasoning.tail (three-level field-wise merge),
docs + website reference regenerated.
Conflicts: kernel version files (master 0.0.193 from the #6132 fold-point
removal + this branch's 0.0.194 -> 0.0.195) and one relay.ts import line
(master dropped relocateCompressCarriers; this branch adds
buildBlockOpsSystemPrompt — the resolved import carries only the latter;
no fold-point call sites survive in the merged relay).
Re-verified on the merged tree: kernel 1631/1631, host targeted 201/201 +
surface/config 374/374, typecheck + build green.
Owner ruling (review of this PR): acp_retire / acp_restore / acp_rewrite
must sit behind ONE switch, default OFF, injected only when ON — the
always-on surface costs ~0.7k estimated tokens per request on every
session of an enabled proxy.
Follows the absorb opt-in pattern end to end:
- kernel: definitions + name consts stay exported, but the 3 tools leave
the default arrays (ACP_TOOLS_{OPENAI,ANTHROPIC,RESPONSES,GOOGLE},
ACP_READONLY_TOOLS_RESPONSES, ACP_TOOL_NAMES); they stay in
ACP_MUTATING_TOOLS (dispatch must drive the compress loop when enabled).
New BLOCK_OP_TOOL_NAMES set + buildBlockOpsSystemPrompt(lane) section
builder; the default prompts are back to "four context-management
tools". New Config.blockOps { enabled } (off by default); absorb/ccr
tool-name predicates include the block ops.
- host: compress.blockOps config (3-level merge like absorb);
blockOpsEnabled / effectiveBlockOpsConfig / storeEffectiveBlockOps
(per-session, plugin tool API parity); isProxyToolFor, the proxy-lane
inject* extras, the responses hybrid lane, the round-2 cache seam, the
plugin manifest + tool API, the MCP dialect note and the system prompt
all inject/advertise the 3 only while enabled; the MCP note, prompt
and per-session metadata stay byte-identical to pre-#5765 while off
(zero footprint: no metadata key written while off — the storage-render
goldens match master byte-for-byte).
- dispatch: enabled calls run the kernel ops exactly as before; a stray
call while disabled gets a model-facing "not enabled on this bili proxy
(compress.blockOps.enabled is not true)" receipt and never touches state.
- wire-contract goldens revert to the master shapes (the default surface
is unchanged), and this commit supersedes the three earlier fix commits
on this branch (test-pin updates + storage-render regen + payload
retunes): with the default surface back to the master shape, those
test files return to the master versions and the 27 red CI tests are
green again without any calibration changes.
- docs: compress.blockOps in configuration.md/.zh-CN.md + website seed;
kernel 0.0.194.
Verified: kernel 1656/1656; host targeted 201/201 (the 15 previously
red CI files + block-ops/snapshot/wire-contract), 348/348 + 63/63
surface/config invariant files; typecheck + build green.
Resolve conflicts after master advanced (PR #5903):
- acp-kernel version -> 0.0.192 (master 0.0.191 + 1 for this PR's kernel/src change); synced kernel/package.json, root package-lock.json, kernel/package-lock.json
- CONFIGURATION.md/.zh-CN.md are redirect stubs now (docs moved to docs/ on master); regenerated docs/configuration*.md so compress.minSummaryLength carries the batch-total wording (#5894)
Add a config-declared egressTransforms[] pipeline that runs user ESM plugins
on every outbound model-request body after all session processing (shed /
compress-loop rewrites) and before transport (re-sign / v1Wrap / fetch), so
body-covering signatures always cover the final shipped bytes. Covers the
relay main send + every recovery re-send and the compress-loop lane; each
plugin is fail-open; hot-reloadable without restart.
- src/egress-transforms.ts: entry parsing, mtime-busted module cache,
fail-open runner (per-plugin timeout, illegal-output skip, content-length
drop on byte change), urlPrefix/provider match
- config.ts: top-level egressTransforms (file-only) + KNOWN_TOP_LEVEL_KEYS
- admin.ts: POST /__bili/config/reload re-reads entries + resets module cache
- relay.ts: pipeline before applyResign on the main send; finalizeEgress now
async and applies the pipeline to all recovery re-sends; the thinking-strip
resend routes through finalizeEgress (completes the unified egress path)
- loop/core.ts + compress-loop-{responses,anthropic}.ts: an egress option on
RequestOptions, applied between shed and resign
- docs/configuration.md en+zh + website config-reference seed
- website/config-reference/compress.yaml: desc_en/desc_zh/site_en/site_zh for
compress.requireNudge now describe the 20-model-round nudge credit window
(#5943) instead of the retired current-turn arm — the PR hand-edited the
generated docs/configuration.{md,zh-CN.md} without updating the single
source of truth, which is what the #2107 docs-sync drift guard caught.
Regenerated website/main.js + website/docs/index.html from the updated seed.
- src/unprompted-gate.ts: UnpromptedGate / UnpromptedGateStamp are referenced
only inside unprompted-gate.ts — drop the leading export per the unused-exports
gate (#1440 P6); UnpromptedGateState stays exported (imported by session.ts).
docs-sync and lifecycle-ledger-guard reds on #5917: the new
network.upstreamFirstByteMs / BILI_UPSTREAM_FIRST_BYTE_MS knob needs its
generated artifacts (CONFIGURATION tables, website i18n tt.network summary)
regenerated via tools/gen-config-docs.mjs, and the env var registered in
LIFECYCLE.md §2.3 (permanent network-tuning family, default = full idle
budget, release gate sets 120000).
Resolve the single textual conflict in src/storage/store.ts, where both
sides independently replaced the O(B^2) Array.some() stale-block sweep
with an O(1) Set lookup (master via #5744, this branch via #5755).
Kept master's incomingBlockIds form: behaviorally byte-identical, already
shipped and reviewed on master, so the merged hunk matches what v0.1.213
already carries. All other files auto-merged cleanly.
The PR updated the generated CONFIGURATION.md table rows directly but left
website/config-reference/compress.yaml at the old per-range wording, so the
CI docs-sync job (generate + git diff --exit-code) reverts the rows and goes
red. Update desc_en/desc_zh/site_en/site_zh in the seed and regenerate.
- upstream-throttle: a saturated hold map (64/64 account-wide, no model-scoped
hold to evict) silently dropped the next model-scoped 429 — now it warns
once and the send is documented as ungoverned (#5199/#5889)
- knobs: network.throttle429Scope matches its value EXACTLY; a typo now warns
once and falls back to credential instead of silently doing so (#5199)
- kernel media-refs: block summaries written by older builds can carry refs
looksEphemeralSignedUrl would reject today; the carry-forward into merged
blocks now applies the same filter so a dead signed URL cannot survive
forever (#5865 review). EPHEMERAL_QUERY_PARAM also gains the Huawei OBS
x-obs-*, Tencent COS x-cos-* and Baidu BCE x-bce-* prefix families.
- native-intercept/dsh-native oversize refusals now say what to DO (restart
host / fix the model window declaration), and dsh durable lines format
numbers with thousands separators (#2924/#4068)
- website: streamKeepaliveMs → streamKeepAliveMs (the real knob name) across
main.js, docs/index.html, config-reference/process.yaml
- CONFIGURATION.md/.zh-CN.md: throttle429Scope exact-match + model-string
aliasing caveat documented
- store/persist: #5755 refs ord-crossing guard (touching rows stay in the
old-refs set until the new-refs commit lands) kept as defense-in-depth
with a regression test
kernel-change: 0.0.186 → 0.0.187 (media-refs carry-forward filter + cloud
prefix families; compress.ts starvation-bound comment corrected)
The feature hand-edited the generated param-ref block in CONFIGURATION.md /
CONFIGURATION.zh-CN.md without touching the declared single source of truth
(website/config-reference/compress.yaml, #2107), which reds two CI jobs:
docs-sync (regenerate-then-diff over CONFIGURATION*.md, website/main.js,
website/docs/index.html) and config-surface-guard (#2643: every nested leaf
field needs a seed key entry). Add the two seed entries with desc text
identical to the merged table rows — regeneration now reproduces the
committed md byte-for-byte (verified: zero drift) — plus the website
main.js site-dict keys and docs table rows the generator owns.
Real-model verification (pi lane, qwen3.8-27b via sglang): the relocated
pair sits at [folded region]-[pair]-[protected messages] in the round-2
re-request and stays pinned there across steady turns; thinking untouched
(switch B still off). Flips resolver/config-doc/LIFECYCLE defaults and
closes the resolveRequestConfig short-circuit hole so the ON default and
an explicit env=off both reach lanes with zero configured compress
settings.
Commit generated CONFIGURATION / website rows for personaSplit and
register BILI_PERSONA_SPLIT in LIFECYCLE.md §1 next to BILI_SUBAGENT_SPLIT
so docs-sync and lifecycle-ledger-guard pass.
The #4313 stamps are deterministic render inputs: minted once per message at
first sight, rendered from stored values never wall clock, prompt variants
resolved once per instance. A live-session cache audit on this session's own
proxy showed identical hit rates (95.0%) with rendering on vs off — the only
non-fold low hits were upstream TTL-eviction fingerprints that fully recovered
on the next turn. So the leak-audit follow-up flips the display gate ON by
default: resolveMessageTimestamps() unset now means `!== false` instead of
`=== true`. Opt-out stays an honest switch: file compress.messageTimestamps:
false or env BILI_MESSAGE_TIMESTAMPS="0" reproduces every pre-#4313 outbound
byte (no time= attribute, original prompt texts, no receipt span). Upgrading
users pay ONE frozen-prefix rewrite per active session at the first restart
that resolves true, then bytes are stable again; storage already recorded the
stamps unconditionally so full history surfaces immediately.
- src/config.ts: resolveMessageTimestamps flip + JSDoc (audit basis, one-time
rewrite disclosure, opt-out paths) + CompressSettings field docs
- tests/preload-test-env.mjs: suite-level pin BILI_MESSAGE_TIMESTAMPS="0" so
every byte-comparing baseline keeps its pre-feature shape (same discipline
as the XDG roots pins); explicit-off and production-default paths are driven
by the suites themselves
- tests/message-timestamps-default-on.test.ts (new): the production expression
resolveMessageTimestamps(loadConfigFile().compress) resolves ON under a
scrubbed env + realistic config without the key, at both exits (prompt
variants + resolve), and file-false stays zero-divergence through it
- tests/issue4313-message-timestamp-toggle.test.ts: flipped to env > file >
default TRUE; OFF cases retargeted to explicit env "0"; two PRODUCTION
DEFAULT pins added (TIMESTAMPED variant selection + receipt span appended)
- docs: yaml seed default/desc/site EN+ZH, gen-config-docs regenerated,
hand-maintained detail sections (CONFIGURATION.md/.zh-CN.md), CHANGELOG
compress.messageTimestamps / BILI_MESSAGE_TIMESTAMPS gate the display
side end-to-end: core pipeline ports (per-instance), fingerprint-span
receipt lines at the single applyRanges site, and the timestamped prompt
variants selected at every host prompt exit via messageTimestampSections.
Off is the default and stays byte-identical to pre-feature master. Docs
(CONFIGURATION.md + zh, website seeds regenerated by the official script,
coverage ok), storage-render goldens regenerated off-default (shape equals
pre-feature master; only state digests drift), new host toggle suite, and
config-surface seeds for both this key and sessions.hardMaxBytes.
New billing.prices config block (USD/Mtok, per model) overrides the bundled
models.dev snapshot. Every settled usage report bills a running USD ledger on
the session (session.stats.costUsd: input/cacheRead/cacheWrite/output), the
panel Saved column converts fold savings into dollars (netSavedUsd), session
rows show spend + saved-$ subtitles, and a web editor at Configuration ->
Billing prices edits overrides with registry prefills (GET/PUT /__bili/pricing).
Resolution per model id: billing.prices -> models.dev snapshot -> unpriced
(tokens only, never fabricated dollars). Optional price fields bill at the
input rate. Invalid shapes reject the whole block at load.
Closes#4899
Per owner feedback the panel does NOT serve the whole website; it renders a
few posts/articles with its own look instead:
- src/web/blogfeed.ts: GET /__bili/blog JSON feed (website/blog/posts/*.md +
website/articles.json manifest, both EN/ZH) rendered server-side with
web/markdown.ts; images ride guarded GET /__bili/blog-assets/<rel>
(traversal/encoding/extension gates); fail-soft, no config surface
- web/markdown.ts gains image refs (http(s)/panel asset route only) and GFM
pipe tables rendered with the panel's .data classes — additive, kernel
handoff output unaffected
- panel gets a 博客/Blog page (card list, click to expand, bilingual via the
existing language toggle which reloads) + nav entry + CSS
- package.json files ships only the needed markdown + figures (+~100KB,
not the whole site)
Review follow-up: the summary-length rows were hand-written into CONFIGURATION.md / CONFIGURATION.zh-CN.md with wording that drifted from website/config-reference/compress.yaml, and website/docs/index.html + website/main.js were never regenerated, so the docs-sync artifact-drift gate went red. Regenerated all four derived files from the seed (node tools/gen-config-docs.mjs generate); the seed wording is the canonical one.
(cherry picked from commit d475598039)
A concurrency-style provider limit (z.ai GLM coding plan: ~9-18 parallel,
dynamic, no Retry-After) plus hosts that re-drive a failed turn every few
seconds made bili's unconditional forwarding self-amplifying: the retry
stream itself occupied the provider slots and pinned the whole account at
the limit for minutes until the client was restarted.
Egress-side governor (src/upstream-throttle.ts): after consecutive 429s for
one origin+credential, further sends are answered locally with zero egress —
429 + Retry-After while under budget (exponential backoff x2 per consecutive
429, jittered [0.5x,1x], capped; upstream Retry-After wins when larger), then
a TERMINAL 424 outside every known SDK retry set ({408,409,429,>=500}) so
hosts give up and surface the error for manual resend. One probe per backoff
window keeps checking (auto-recovery without a restart); ANY resolved
non-429 response clears the hold immediately. State is in-memory per
origin+credential fingerprint (#2131), bounded at 64 keys; process restart
re-learns from live traffic.
Behavior change (default ON): the main forward path no longer forwards every
request verbatim once its origin+credential is held — previously every
re-driven request hit the upstream. Escape hatch: network.throttle429Enabled
= false (BILI_THROTTLE_429=0) restores legacy always-forward behavior.
New config surface (network section, env > file > default):
throttle429Enabled true / throttle429MaxConsecutive 5 /
throttle429BaseDelayMs 2000 / throttle429MaxDelayMs 30000.
Display: acp_status gains an UPSTREAM 429 HOLD block mirroring the #3148
circuit block. Deliberately separate from the #3148 circuit breaker
(pre-response transport deaths) and orthogonal to the approved-but-unshipped
#3606 A1 in-request retry (different layer: this observes the final verdict
per request and gates egress between requests).
Tests: tests/issue4204-throttle-governor.test.ts (10 rows, both-directions
gate discipline).
(cherry picked from commit 21521bdaa4)
Post-merge gate fixes on the merged tree:
- config-surface-guard (#2643, landed after this branch cut): the new
top-level field needed a seed entry in website/config-reference/*.yaml;
added to server.yaml (upstream group) and regenerated the marked doc
blocks via tools/gen-config-docs.mjs (hand-written section prose kept).
- unused-exports: ModelEndpointWire is only used inside
src/model-endpoints.ts — drop the leading export (INTERNAL_ONLY).
Local: both gates green, tsc clean.