CI run 36102348905: all 4 golden tests failed on windows-latest because GitHub Actions checkouts materialize committed-LF files as CRLF in the worktree; runtime-generated canonical text uses LF. Normalize disk content to LF so the gate is platform-deterministic while still catching any real content drift.
Consolidates the #1301 served-surface gate and the #1302 kernel-export gate
into one wire-contract suite and extends it per owner decision on #1304
(items 1+2+3, plus the 4-protocol scripted-client matrix phase):
- tests/wire-contract-fakes.ts: WIRE_RULES ledger (WC-001..WC-006, each with
production/doc provenance) + strictest-known validation for all four wires
(anthropic /v1/messages, openai chat, responses, google v1beta) + four
validation-parity fake upstreams on listen(0) with canned per-wire replies.
- tests/wire-contract.test.ts: four layers — ledger self-check (every rule id
has a live enforcement clause), A kernel exports, B bili-built surfaces,
C plugin manifest (default + opt-in), D live proxy-mode forward of one
client-shaped turn per protocol through the matching fake (asserts the
forwarded tool set is exactly bili's intended surface and the fake's
strictest validation accepts it). The anthropic lane reproduces #1299
end-to-end. Supersedes tests/kernel-pin-wire-schema.test.ts and
tests/issue1299-anthropic-top-level.test.ts (all their assertions kept).
- tests/wire-contract-golden.test.ts + tests/golden/wire-contract/*.json:
byte-equal golden snapshots of every advertised tool schema at both layers
(kernel exports, bili surfaces, plugin manifest default+opt-in); manifest
version normalized to <VERSION> so release commits don't churn it.
- scripts/update-wire-contract-goldens.ts: explicit regeneration path.
- AGENTS.md §7.3: institutional rule — every upstream rejection/validation
constraint becomes a permanent wire-contract rule inside the fixing PR;
the ledger only grows.
A request whose path matches no known wire protocol (e.g. a third-party
plugin's custom wire such as commandcode's Go plan POST /alpha/generate) was
relayed byte-for-byte with ZERO signal — neither compression nor any
explanation. That contradicts the #1158 "tell me why it didn't compress"
promise and the #897 loud-not-silent principle. Make both ends loud.
Client (native-intercept + dsh-native):
- New optional NativeInterceptState.onUnroutedModelUrl hook, fired for every
request the fetch patch lets through WITHOUT routing because its URL misses
isModelApiUrl. Undefined hosts stay silent (no behavior change for others).
- dsh wires it to log each distinct unrouted endpoint once per process via
console.error + persistClientEvent (the durable channel GUI hosts need),
bounded at 256 distinct endpoints like gateRefusals.
Proxy (server/observability + server + acp-status):
- getUnrecognizedPathStats() aggregates the existing per-path warn map.
- /__bili/stats gains an `unrecognizedPaths` field (count + per-path counts).
- acp_status gains an "UNRECOGNIZED PATHS (instance-level)" section while such
requests exist, mirroring the UNDECRYPTED TRAFFIC section.
Docs: README troubleshooting section explaining the limitation + the new
signals + the workaround (use the provider's standard protocol endpoint).
Behavior change (intended): non-model-API URLs previously went direct silently;
each such endpoint now logs once per process. /__bili/stats and acp_status gain
additive fields/sections. No existing threshold/default/timing/output-format
changed. This does NOT make custom wires compressible — that is a separate
feature (custom request/response codec + config seam) pending owner decision.
Regression tests: native-intercept (hook fires for a custom wire, not for a
routed model endpoint) + dump-observability (per-path counts exposed).
The /__bili/plugin/manifest route read absorbEnabled(config)/rulesEnabled(config) off the raw kernel-default config (opts.kernelConfig), while the per-request path resolves opts.compress onto it via applyCompressSettings. A user enabling compress.absorb.enabled in their config file therefore got [ACP absorb] prompts on the wire but no callable absorb tool registered by hosts that register only manifest tools (Pi native plugin) — the prompts could never be executed.
Resolve the global compress settings at the manifest route so both paths agree; per-session/provider enablement stays execution-time-gated. Adds enabled + disabled regression tests exercising the real file-config path.
Fixes#1278
On Windows every claude launch rides a .cmd shim through cmd.exe /d /s /c,
whose quote-toggle parsing strips embedded quotes (#679). The native-install
override injected the ANTHROPIC_BASE_URL override as an inline --settings JSON
string, so claude received a quoteless {env:{...}} and died with
"Invalid JSON provided to --settings" before any session could start.
Deliver the same object via a temp settings file on win32 (path carries no
quotes; cleaned up in the existing tmpFiles finally-block). Claude accepts a
file path for --settings with identical precedence to the inline string, so
the delivered settings are unchanged. POSIX keeps the byte-identical inline
form — no shell re-parses argv there. Same fix class as codex's #681
overlay-file gating. Adds LauncherDeps.platform so tests drive the win32
paths from a POSIX host; regression suite asserts the comspec line carries a
parseable-JSON file path and the child env carrier stays consistent.
Unset compress.ccr no longer arms anything: the server stamp keeps the raw
three-level merge (resolvedCcrCfg = compressCfg.ccr), applyCompressSettings
loses the default-on else-branch, and resolveRequestConfig returns base
unchanged when nothing is configured. Flip CCR on only via an explicit
compress.ccr.enabled=true at some level, after local verification. Tests,
READMEs (en/zh) and CONFIGURATION (en/zh) updated to the opt-in contract;
preflight e2e pins dropped — the default-off boundary is now a tripwire
against accidental default flips.
resolveDecompressRange consulted the fold-time content store only when zero
refs were found in the exec-time view, assuming view/store mutual exclusion
per ref that nothing enforces: a covered ref left visible in the view
contributed its view text, which for arrival-stored refs (oversized tool
results — the primary CCR case) is the 📦 placeholder, not the original,
while the ack still claimed a full restore; a partially visible span
silently dropped the missing refs.
Per-ref selection supersedes the all-or-nothing fallback: each picked ref
prefers retrieveByRef(store) when present (store entries are immutable
originals — append-only, first write wins, refs never reissued), else falls
back to the view text (pre-CCR folds have no entries). Span order stays
deterministic (coverage num order). Regression test: an arrival-stored ref
whose view copy is the placeholder inside a restored span yields the stored
full original (verified to fail against the pre-fix code).
- server.ts: resolvedCcrCfg now re-applies the #1179 default-on
(resolveCompress returns the raw merge; applyCompressSettings owns the
unset-means-enabled default this arming path bypassed) — with no ccr key
at any level the session previously NEVER armed: 'on by default in
proxy mode' was dead at its only enforcement point (reviewer-caught
wiring gap, confirmed against the real server path).
- decompress-shared.ts: range restore falls back to the fold-time
content store when covered originals left the client's re-sent view
(native-compaction archive adoption, client-side trimming, restart
with a compacted client) — keyed by the coverage's own ref numbers;
honest failure text when neither view nor store has them.
- decompress-shared.ts: plugin-mode error names the real constraint
(proxy-mode only) instead of unsatisfiable 'enable compress.ccr.enabled'.
- decompress-shared.ts: client retries dedupe on the deterministic
injection id — no duplicate full-text message, no rangeRestores
inflation; temp files 0600 with the span in the filename.
- tests: store-fallback + retry-dedupe + no-config default-on e2e
(real server path); codex-official tool list gains acp_retrieve
(intended default-on ripple in proxy mode).
Follow-up: unbounded store growth tracked in #1282.
The consumedFoldSeq gate served two roles in recordCacheSample: gating the
decomposeSample pending list (compRepay attribution — must fire once per
fold) AND driving the per-fold requestsAfter counter. Because each fold left
pendRefs after its first post-fold sample, requestsAfter froze at 1 and
pushFold's k = requestsAfter freeze capped turnsToNextFold at 1 for every
fold regardless of actual cadence. The kernel batch reference path
(buildCacheReport) counts ALL samples after a fold into requestsAfter and
the inter-fold window into turnsToNextFold, so the incremental ledger diverged
from batch for any fold followed by >= 2 requests: paidBack was systematically
false (breakeven is usually >= 2) and savedSoFar/grossSaved/netTokens were
understated by ~(N-1)x for every provider.
Decouple the concerns: the counting loop now iterates every elapsed fold
(f.at <= s.at); the consumedFoldSeq gate remains on the pending list only,
so compRepay/T attribution semantics are unchanged. With counting fixed, the
existing pushFold freeze of k = requestsAfter becomes exactly the batch-path
turnsToNextFold window under chronological sample arrival — no new persistent
field, no ledger format change.
Adds a regression fixture with three full-hit samples between folds
(S=12140/sigma=1000 -> breakevenTurns ~2.5): asserts field-for-field parity
between incremental and kernel batch reports (turnsToNextFold, paidBack,
requestsAfter, savedSoFar, economics summary), plus hand-computed values.
Before the fix this fixture failed with k=1/paidBack=false vs batch
k=3/paidBack=true; the existing single-sample fixture could not catch the
bug because k=1 coincides on both paths there.
Behavior change (disclosed): turnsToNextFold in /acp_cache fold economics
goes from min(1, actual cadence) to the true inter-fold request count;
paidBack flips false->true where measured cadence actually reaches
breakevenTurns; savedSoFar/grossSaved/netTokens scale up accordingly.
Fixes#1286
Review follow-ups for #1273:
- The plugin arm now also requires opts.compress.ccr.enabled === true — the
exact source the plugin manifest reads (server.ts:969). Route/model-scoped
enablement with the base flag off previously armed the store and emitted
placeholders while the manifest never advertised acp_retrieve: silent loss.
Route-scoped-only enablement stays proxy-mode-only (the proxy injects the
tool itself, per-request).
- storeEffectiveCcr(undefined) now clears pendingRetrievals: a retrieve queued
on a lane that later switches to a non-CCR wire would otherwise flush as a
stale trailing full-text message when the lane re-arms. Not persisted either
way; this only tightens the in-memory window.
- e2e: acp_retrieve now driven through the real POST /__bili/plugin/tool
endpoint (covers the conversation gate + ack round-trip), and a new
regression test pins both halves of the route-scoped behavior (plugin lane
verbatim, proxy lane armed).
Fixes#1273 (review)
a3ec90f9 changed contentStoreTokens from chars÷4 to the kernel's CJK-aware defaultCountTokens but left five 'chars ÷ 4' descriptions behind (README en/zh, CONFIGURATION en/zh, session-gc module header). No behavior change.
Reviewer fix: the behavior change disclosed in the PR body (plugin mode arms
CCR on anthropic/openai wires while acp_retrieve is manifest-advertised) was
not mirrored in the docs, which still stated 'proxy mode only / native-tools
wires only' as the v1 scope gate.
CCR v1 shipped proxy-mode-only with a hard !pluginMode gate, so no real lane
could turn it on. This wires the bili side of the three-repo contract:
- plugin manifest advertises acp_retrieve only while ccr.enabled (#1192 rule),
on anthropic/openai wires only — never responses, which the proxy disarms.
- arming gate now allows plugin mode on exactly those round-trippable wires
(ccrPluginWireOk); responses/google stay out so a placeholder is never
emitted where it cannot be retrieved (silent loss, #1097).
- prepare* drains pending retrievals in plugin mode so the full original rides
back request-only (ephemeral, never persisted).
- global ccr config threaded into the manifest so advertising reflects operator
config, not just the kernel default.
Adds tests/ccr-plugin.test.ts: manifest scoping + wire-scope unit tests + a
plugin-lane e2e (fake upstream, zero tokens) proving store->placeholder->
retrieve->full-text round-trip.