Repository navigation
[PR] Rebase #1444 onto master: declarable model endpoints + commandcode wire family - #6032
Conversation
…#1295) - F1: reject userinfo in normalizeMatch (loudly, like search/hash) instead of silently minting a credentials-less origin claim - F3: rewrap user branch mirrors unwrap's text-part join — block-content user messages are never silently blanked mid-forward (WC-2) - F4: warn when a provider explicitProtocol pin overrides a declaration - F6: declared-endpoint probes (GET/HEAD/empty-body POST) are not flagged "unrecognized path"; undeclared paths still warn (scoped carve-out) - F7: drop dead meta.reasoningEffort (reasoning_effort round-trips via extraParams) - F8: document why the host-side loader uses console.error - F9: coverage — commandcode plugin pipe (tag-echo strip / verbatim relay / terminal fragment drop / in-band truncation), commandcode branches of the three stream-error emitters, duplicate-tool-name verbatim replay pin - F2/F5: WC-2 empty-message note; docs for two-gate URL semantics (declare the URL the request lands on) + userinfo rejection
…ndcode rewrap before chain stamp; port commandcode error shape into nativeErrorChunk/legacyCompletionChunk
…rror trailing args (anthropicCacheMarks, streamErrorShape) around the commandcode ternary
…ict against split pipeline (ranxianglei#1440)
…erence + unexport internal ModelEndpointWire Post-merge gate fixes on the merged tree: - config-surface-guard (ranxianglei#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.
|
Full local suite, chunked ( All 15 are environment, none is a regression from this merge. Each failing file was re-run in isolation and/or against an unmodified master checkout (
Reproduce the environment classes: The suites this PR actually adds or touches still pass 124/124, and |
…e source map The architecture-docs CI guard (ranxianglei#5930) requires every tracked src/ file to appear in reference/architecture.md. Merging master exposed three modules the PR adds without registering, so the guard fails on the merged head 0f502f4 with: FAIL: reference/architecture.md missing: src/commandcode-wire.ts FAIL: reference/architecture.md missing: src/loop/adapter-commandcode.ts FAIL: reference/architecture.md missing: src/model-endpoints.ts Ran the guard's own logic against this tree: 311 src files, 0 missing, 0 ghosts, ledger/page/SVG checks green.
5ed8cb0 to
c7ac7b5
Compare
|
Pushed Root cause of That is exactly what the job log on Fix: registered the three modules in the source map next to their siblings:
Verified with the guard's own logic against this tree: 311 src files, 0 missing, 0 ghosts, ledger/page/SVG checks green. master's Worth folding into the PR itself so it does not depend on this branch. |
…yout) Move WIRE-CONTRACTS.md/.zh-CN.md from repo root to docs/wire-contracts.md(.zh-CN.md), list them in docs/index.md + docs/index.zh-CN.md, and retarget the six inbound (WIRE-CONTRACTS.md) pointers. Root keeps only README/AGENTS/CHANGELOG + redirect stubs per the 2026-11-08 doc-layout ruling (ranxianglei#5920); new docs must live under docs/ and be indexed in the same PR. Review-driven fix for ranxianglei#6032 (feature ranxianglei#1295); no code behavior change - doc links/comments only.
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复. Among open Reviewed #6032 — head now
Two pre-merge gaps found, both now resolved on the branch:
Soft (non-blocking): 结构化结论(八问)
判定: 代码正确、可合并(mergeable=true,无冲突),两处合并前缺口已在分支上解决,待 owner 批准。 按仓库政策我不执行合并——@ranxianglei,请在你方便时 approve/merge。若你倾向保留 #1444 作为追踪 PR,把本分支 tip 并入 |
|
CI is green on The
PR is |
(ai: vllm-qwen/qwen3.8-27b) Verified independently against the CI mirror: 0 failed / 0 pending on the current head State, confirmed live: PR One optional (non-blocking) item still open from the review: the PR body lacks the AGENTS.md "config surface" section for the new top-level Handing off to @ranxianglei: the ball is in your court — approve/merge when ready. Per repo policy I don't merge PRs. If you'd rather keep #1444 as the tracking PR, merging this branch's tip into |
|
The soft blocker from your review is addressed: the PR body now carries a full Contents, per AGENTS.md → Configuration Surface Discipline rule 1 (line 137 of
Also folded in: the doc-conflict resolution (prose into |
(ai: vllm-qwen/qwen3.8-27b) Confirmed live: the PR body now carries a One point to leave for you rather than me: the section asserts owner sign-off was given on #1295 before implementation. That's a reasonable basis (it's the tracked feature this implements), but confirming that sign-off is yours at merge time, not something I can adjudicate. Final state — nothing left on the code/doc side:
|
pipePluginJsonlWithStrip flushed its tag-echo/marker filters after every JSONL line. The filters hold partial tag heads and marker prefixes across deltas by design; a per-line flush destroyed that state, so a render tag split across two text-delta lines leaked its ref into client-visible prose, a held prefix at the terminal frame was silently dropped, and a forged marker line completed across deltas escaped stripping. The SSE pipe (pipePluginChatWithStrip) already resolves tails only before terminal frames / EOF / read failure — mirror that here: one filter instance per prose field, tails written back as synthetic lines of the original event type before finish/error/EOF/truncation. Regression tests pin all three facets (ranxianglei#1295).
…(relative link + index/architecture lines) The ranxianglei#1444 feature branch polished these five lines after this PR's tip was cut: the wire-contracts ledger reference becomes a clickable relative link (the file lives next to configuration.md), the docs index row states the ledger's permanence rule, and the architecture source map carries the longer comments with adapter-commandcode.ts in position. Taking the ranxianglei#1444 versions verbatim makes this PR a superset of the feature branch, so either merge path offered in the PR body (merge tip into the feature branch, or replace its head) lands identical docs.
ranxianglei
left a comment
There was a problem hiding this comment.
Review — sound, ready to merge. One blocking bug found on the branch and fixed here (two commits pushed to your branch).
What I pushed to this branch
1. 1a928c3ac — fix: keep commandcode plugin-pipe filter state across deltas (cherry-picked from the #1444 feature branch, original commit f03e8925c).
The branch cut that produced this PR predates that fix, so the pipePluginJsonlWithStrip that was about to land in src/plugin.ts was the pre-fix version: one shared tag-echo/marker filter, flushed after every JSONL line. Those filters are designed to hold partial tag heads and marker prefixes across deltas, so the per-line flush (a) leaked a render tag split across two text-delta lines into client-visible prose, (b) silently dropped a held prefix at the terminal frame, and (c) let a forged marker line completed across deltas escape stripping. As a replacement for #1444 this would have shipped the bug the feature branch already fixed. The cherry-pick carries the same diff plus its three regression tests; tests/commandcode-plugin-pipe.test.ts is 8/8 locally.
2. 48dc0d5ff — docs: adopt the #1444 branch's wire-contracts doc wording.
The feature branch polished five one-liners after this PR's tip was cut (the wire-contracts.md reference becomes a clickable relative link in docs/configuration.md/.zh-CN.md, the docs-index row states the ledger's permanence rule, reference/architecture.md comments + adapter ordering). Taking those verbatim makes git diff between this PR and the #1444 feature branch empty — the two trees are byte-identical, so both merge paths offered in the PR description now work cleanly (merge this tip into 2026-09-26_model-endpoint-patterns, or replace that branch's head: no conflicts either way, nothing lost).
Verification
- CI on head
48dc0d5ff: all 40 active checks pass (ubuntu 22/24 + windows 22 test shards, all static guards, kernel/mysql/lock/lifecycle gates); the 16 e2e/persona lanes are skipped-by-design as usual. - Local (reviewer box):
tsc --noEmitclean after kernel + pi-subagents build. All targeted suites green:tests/model-endpoints.test.ts(9),tests/commandcode-wire.test.ts(15),tests/adapter-commandcode.test.ts(10),tests/commandcode-endpoint.test.ts,tests/commandcode-plugin-pipe.test.ts(8 incl. the three new cross-delta regressions),tests/native-intercept.test.ts. - A full local
npm testin this sandbox is not conclusive: 45tests/dsh-native.test.tswaitFor timeouts reproduced byte-identically on clean master4be21b08e(same 45 test names, same 15s signature) — environmental (sandbox network restrictions + shared-box load), not a PR regression. Your reported full local run (10683/10762 pass, 15 environmental fails re-verified on master) plus the green CI shards corroborate.
Substantive findings from reading the diff (no further action needed)
- Single config source (
src/model-endpoints.ts) feeding both the proxy classifier (src/server/handle.ts) and the client-side fetch claim (src/agent/native-intercept.tsvia the dsh/omp/opencode/pi natives) is the right shape for #1295. Match semantics are tight: absolute URL prefix, same origin, path-segment boundary, longest-prefix, root pattern claims the whole origin; malformed entries fail loudly with index-specific messages;loadDeclaredModelEndpoints()never throws (host-process safety, one warn). - Priority ladder explicit URL pin > declared protocol (providers table /
/bili/marker) > global patterns > built-in suffix heuristics, with a one-time pin-vs-declaration conflict warn. Correctly keeps the URL pin winning. - commandcode codec (
src/commandcode-wire.ts): strict fidelity — any unconvertible shape relays verbatim per the #1284 precedent; round-trip meta preserves the system slot, tool names, and error-result identity; WC-1..WC-6 ledgered indocs/wire-contracts.md(+zh). The rewrap at the final forward boundary insrc/server/relay.tsruns after all flat-body mutations, so what goes out is the canonical envelope. - Loop adapter (
src/loop/adapter-commandcode.ts): real tool calls get verbatim raw-line replay +passthroughadjudication — checked againstsrc/loop/core.ts(if (tc.passthrough) continue;beforeadapter.emitToolCall), so no double emission; proxy tools never forward upstream; non-JSON lines verbatim round-1 only; degenerate-turn warning suppressed when a real call was seen. - #371 fake-completion retry disabled for commandcode at both sites — correct, since its
finish/errorframes are terminators, not retryable partials. - Classifier delta worth knowing (
src/server/handle.ts): master setprotocolfrom an explicit pin / declared protocol even for GET and empty-body POSTs; now those getprotocol = null, so a non-declared probe of a pinned route can reachlogUnrecognizedPathwhere master was silent. Log noise only — forwarding behavior is unchanged.
Non-blocking nits (left as-is, author's call)
src/model-endpoints.ts:124— the config-read warn is labeledbili-native:but that path fires from every native loader (dsh/omp/opencode/pi). A neutral prefix ([model-endpoints]) would read better in logs.- With that: nothing else. The feature is complete, documented (EN+ZH+website), ledgered, and the merge question from the description is now unambiguous either way.
…de-adapter vs separatorSlots conflict in relay.ts
(ai: vllm-qwen/qwen3.8-27b) Conflict resolved & pushed (attempt 1/3, succeeded). Upstream PR #6032 was What I did this run:
Local verification (targeted, per test discipline — full suite is CI's job):
Live status (verified this run, mirror cache): sha now 结构化八问:
判定:冲突已消除并推送成功(fast-forward、无强推),本地验证全绿;远程 CI 在新 head 上重跑中、当前 0 失败,跑完转 clean 后即可合并。 |
… import split (logRequestCost → request-cost.js; keep declPinConflictWarned)
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Status: conflict resolved and pushed — the PR is now mergeable ( What happened this run:
Live state (verified against the PR's current head this run):
Caveat (stated plainly): No behavior changes, no new config, and no cache / retry / cursor logic touched — this run is pure conflict resolution plus a build refresh. 八问(供人工 reviewer)
收工判定:冲突已清( |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1163-master.e1e33a9 # this exact build
npm install -g billion-context@master # always the newest merged build
|
What this is
Upstream #1444 has been sitting 1725 commits behind master with 11 conflicted files (
mergeable_state: dirty) since 2026-09-26. This PR carries the same feature set, rebased onto current master (4be21b08), so #1444 can be advanced by merging this instead of resolving those conflicts by hand.Base =
master, head = @suyeku1's fork. 31 files, +2161/−38, 0 behind master. Merge commit80e9d205ebhas two parents —b7c9a02302(2026-09-26_model-endpoint-patternstip) and4be21b08(master) — so merging it back into the feature branch is a fast-forward. Your own merge0f502f4on #1444 has the same two parents and the same tree modulo line ordering, so the two routes converge.Scope
New (verbatim from #1444)
src/model-endpoints.ts,src/commandcode-wire.ts,src/loop/adapter-commandcode.ts,docs/wire-contracts.md,docs/wire-contracts.zh-CN.md, and 5 test files (model-endpoints,commandcode-wire,adapter-commandcode,commandcode-endpoint,commandcode-plugin-pipe).Merged (both sides kept)
src/server/relay.ts— master'smessageTimestampSections(...)system-prompt line and the PR'screateCommandcodeAdapter(...)branch.src/server/handle.ts— master's ingest-size guards (IngestBodyTooLargeError,knobLimitsIngestBytes,knobNoInjectTool) and the declared-endpoint matcher +declPinConflictWarned.src/agent/{dsh-native,native-intercept,opencode-native,omp-native,opencode,pi-native}.ts,src/config.ts,src/server.ts,src/stream-error.ts,src/plugin.ts,tests/native-intercept.test.ts.src/plugin.tsalso needed a lost closing brace restored where the two added helpers met.Config surface
New top-level key in
billion-context.json. Per AGENTS.md → Configuration Surface Discipline, in full:What is added.
modelEndpointPatterns: Array<{ match: string, wire: "anthropic" | "openai" | "responses" | "google" | "commandcode" }>, default[].matchis an absolutehttp(s)URL prefix — userinfo, query and hash are rejected loudly at startup rather than silently dropped; matching is longest-prefix on an origin-equal, path-segment boundary (…/alpha/generatedoes not claim…/alpha/generate2).wireis validated against that closed set. Documented as a generated parameter-table row plus a prose section indocs/configuration.mdanddocs/configuration.zh-CN.md, with the table row seeded fromwebsite/config-reference/server.yaml(the block is<!-- bili:gen param-ref -->, never hand-edited).Why the existing surface cannot express it. Two facts, no current mechanism carries both:
protocolfield is a closed union. It is typedWireProtocol = "anthropic" | "openai" | "responses" | "google"(src/util.ts:144). The motivating family,commandcode, is not a fifth protocol: it is an openai-completions conversation wrapped in a CLI envelope with a bare-JSONL response, so it must select the unmodified OpenAI pipeline and an envelope codec (wireFamily). Overloadingprotocolwould either misdescribe the pipeline or widen a union the proxy treats as exhaustive in every switch.isModelApiUrl(src/agent/native-intercept.ts:305) and dsh's takeover gate (src/agent/dsh-native.ts:2356) execute inside the host agent process. The providers table is loaded byloadRoutes(src/config.ts:1451) in the proxy, together withACP_PROVIDERS, alias folding and legacy-key rejection; no module undersrc/agent/reads it. Aprovidersdeclaration therefore moves only the classifier — the client would still not claim the URL, the request stays uncompressed, and that is precisely the dsh使用插件dsh-commandcode-provider反代go套餐的话,不进billion-context压缩 #1290 symptom this closes.Mechanisms considered.
protocolunion, and the wrong process for the claim gate.compresshierarchy — tunes how much to compress for a route; it never answers "is this URL a model API at all", the question both gates must answer before compression is reachable.JSON.parse(env.…)appears nowhere insrc/); every existingBILI_*mirror is a scalar.explicitProtocol/ the/bili/<protocol>/marker — a per-request pin from the caller; here the operator declares a property of the endpoint, which is why the/bili/marker deliberately still outranks a declaration.Owner sign-off. The shape was approved on #1295 before implementation — #1444's body describes both commits as "implementing the owner-approved plan", satisfying rule 3 (sign-off before implementation, recorded with the rationale).
Compat / migration. Additive and inert by default: absent or
[]→parseModelEndpointPatternsreturns[]→matchModelEndpointreturnsundefined→ both gates fall through to today's built-in tables byte-for-byte (your review verified this independently). Nothing is renamed or re-semanticized, no existing config needs rewriting, no version bump (release flow owns that). Declarations are read at process start — restart bili, and any native client whose fetch patch must claim the endpoint — which the docs section states.How the two doc conflicts were resolved
CONFIGURATION.md/CONFIGURATION.zh-CN.mdare now 2-line pointers todocs/configuration.mdon master, so the PR's sections moved:## Model Endpoint Patterns/## 模型端点声明) went intodocs/configuration.mdanddocs/configuration.zh-CN.md, just before## Compression Tuning;modelEndpointPatternsseed went intowebsite/config-reference/server.yaml, thennode tools/gen-config-docs.mjs generateproducedwebsite/main.js+website/docs/index.html(10 blocks from 335 seed entries, i18n 254 keys ok);node tools/gen-config-docs.mjs check-coverage→ 202 env names + 62 top-level keys documented, exit 0.Post-review commits
Two gaps surfaced once this branch was based on master; both are fixed on the branch and both are independent of the conflict resolution:
architecture-docswas red (c7ac7b55) — the three newsrc/modules were never registered inreference/architecture.md, and that guard ([Bug][config] 0.1.212: effectiveConfigEpoch stamps the live file hash onto a snapshot resolved from startup-captured opts — config edits silently keep the pre-edit chain until reload #5930) had never run on the old feature base. Registered next to their siblings; the guard now reports 311 src files, 0 missing, 0 ghosts.WIRE-CONTRACTS.mdsat at the repo root (9724f1de, byework-agent) — violates the 2026-11-08 doc-layout ruling ([PR] docs: batch-migrate 14 root-level documents into docs/ (consolidation + master index + redirect placeholders) | docs: 14 个根级文档一次性迁入 docs/(集中 + 总目录 + 重定向占位) #5920). Moved todocs/wire-contracts.md/.zh-CN.md, indexed indocs/index.md+docs/index.zh-CN.md, six inbound references retargeted.Verification
The 15 full-suite failures were each re-run in isolation and/or against an unmodified master checkout built from the same tarball; every one is environmental and reproduces on master or passes in isolation (host-marker
'dsh' !== 'pi', no.gitforgit rev-parse, Windows ephemeral ports landing in fetch's blocked-port list). CI is the authoritative matrix: 56 checks = 40 success + 16 skipped-by-design + 0 failed,architecture-docsandlintincluded.Not in this PR
npm testcannot be spawned on Windows (spawn ENAMETOOLONGat 1150 file args throughscripts/test-suite-lock.mjs); that is the reason for the chunked runner, not a shard change.master, so the normal matrix runs.Merge path
If you'd rather keep #1444 as the tracking PR: merge this branch's tip into
2026-09-26_model-endpoint-patternsand #1444 becomes mergeable against master immediately. Otherwise this can replace #1444's head.