Skip to content

[PR] Rebase #1444 onto master: declarable model endpoints + commandcode wire family - #6032

Merged
ranxianglei merged 19 commits into
ranxianglei:masterfrom
suyeku1:2026-11-09_merge-master-into-1444
Nov 10, 2026
Merged

ranxianglei merged 19 commits into
ranxianglei:masterfrom
suyeku1:2026-11-09_merge-master-into-1444

Conversation

@suyeku1

@suyeku1 suyeku1 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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 commit 80e9d205eb has two parents — b7c9a02302 (2026-09-26_model-endpoint-patterns tip) and 4be21b08 (master) — so merging it back into the feature branch is a fast-forward. Your own merge 0f502f4 on #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's messageTimestampSections(...) system-prompt line and the PR's createCommandcodeAdapter(...) 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.ts also 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 []. match is an absolute http(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/generate does not claim …/alpha/generate2). wire is validated against that closed set. Documented as a generated parameter-table row plus a prose section in docs/configuration.md and docs/configuration.zh-CN.md, with the table row seeded from website/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:

  1. The providers protocol field is a closed union. It is typed WireProtocol = "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). Overloading protocol would either misdescribe the pipeline or widen a union the proxy treats as exhaustive in every switch.
  2. The other gate runs in a different process and never reads the providers table. 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 by loadRoutes (src/config.ts:1451) in the proxy, together with ACP_PROVIDERS, alias folding and legacy-key rejection; no module under src/agent/ reads it. A providers declaration 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.

  • providers table + its key species — rejected above: closed protocol union, and the wrong process for the claim gate.
  • three-level compress hierarchy — 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.
  • env-var conventions — the value is a list of structured pairs, and there is no JSON-in-env precedent (JSON.parse(env.…) appears nowhere in src/); every existing BILI_* mirror is a scalar.
  • launcher↔extension channels — host handshakes, not per-endpoint wire identity.
  • 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 [] → parseModelEndpointPatterns returns [] → matchModelEndpoint returns undefined → 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.md are now 2-line pointers to docs/configuration.md on master, so the PR's sections moved:

  • the prose (## Model Endpoint Patterns / ## 模型端点声明) went into docs/configuration.md and docs/configuration.zh-CN.md, just before ## Compression Tuning;
  • the parameter table is a generated block and was not hand-edited: the modelEndpointPatterns seed went into website/config-reference/server.yaml, then node tools/gen-config-docs.mjs generate produced website/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:

  1. architecture-docs was red (c7ac7b55) — the three new src/ modules were never registered in reference/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.
  2. WIRE-CONTRACTS.md sat at the repo root (9724f1de, by ework-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 to docs/wire-contracts.md / .zh-CN.md, indexed in docs/index.md + docs/index.zh-CN.md, six inbound references retargeted.

Verification

npx tsc --noEmit --project tsconfig.json   → exit 0, no output
targeted suites (6 files)                  → tests 124 / pass 124 / fail 0  (17.9s)
full local suite, chunked (10 × 120 files) → tests 10762 / pass 10683 / fail 15

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 .git for git 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-docs and lint included.

Not in this PR

Merge path

If you'd rather keep #1444 as the tracking PR: merge this branch's tip into 2026-09-26_model-endpoint-patterns and #1444 becomes mergeable against master immediately. Otherwise this can replace #1444's head.

ework-agent and others added 12 commits September 27, 2026 09:57
…#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
…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.
@suyeku1
suyeku1 changed the base branch from 2026-09-26_model-endpoint-patterns to master November 9, 2026 13:05
@ranxianglei ranxianglei changed the title Rebase #1444 onto master: declarable model endpoints + commandcode wire family [PR] Rebase #1444 onto master: declarable model endpoints + commandcode wire family Nov 9, 2026
@suyeku1

suyeku1 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Full local suite, chunked (npm test cannot spawn 1150 file args on Windows — spawn ENAMETOOLONG in scripts/test-suite-lock.mjs), on 80e9d205eb:

10 chunks / 1150 test files
tests 10762   pass 10683   fail 15

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 (4be21b08) prepared from the same tarball:

file failures verdict
issue5627-storage-failure-forensics 2 identical on master (deep-nested JSON.stringify stack overflow + the warn-once counter)
issue3544-stale-proxy-rotation 1 identical on master (drain-wait was bounded (ticks=13))
pi-native 2 identical on master — 'dsh' !== 'pi', host marker not set by this shell
opencode-native 2 identical on master — 'dsh' !== 'opencode'
omp-native 1 identical on master — 'dsh' !== 'omp'
web-updates 1 identical on master — asserts on a git working tree; out/ is a tarball extraction, so the source-checkout guard is unreachable
anthropic-cache-control, fix-781-summary-images, issue1493-arm-outbound-payload, issue5641-watcher-registration-recovery, silent-backend-nudge 5 pass 3–5× in isolation — fetch failed / bad port from ephemeral ports landing in fetch's forbidden list (85 of 13977 dynamic ports ≈ 0.6 % per listen; a 120-file chunk opens hundreds), plus load-sensitive timings
build-info 1 needs .git for git rev-parse --short HEAD (0.1.213 (unknown)); not a git checkout here

Reproduce the environment classes:

netsh int ipv4 show dynamicport tcp   # start 1024, count 13977 -> includes 87,95,101,109,113...
node -e "fetch('http://127.0.0.1:87/')"  # TypeError: fetch failed / bad port

The suites this PR actually adds or touches still pass 124/124, and tsc --noEmit is clean. Nothing here needs code changes.

ci-check and others added 2 commits November 9, 2026 21:54
…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.
@suyeku1
suyeku1 force-pushed the 2026-11-09_merge-master-into-1444 branch from 5ed8cb0 to c7ac7b5 Compare November 9, 2026 14:03
@suyeku1

suyeku1 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Pushed c7ac7b55 on top of your merge 0f502f4 to fix the one red check.

Root cause of architecture-docs: the #1295 PR adds three modules under src/, and tools/check-architecture-docs.mjs (#5930) requires every tracked src/ file to be registered in reference/architecture.md. It was not, so merging master flipped the guard from skipped to failing:

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

That is exactly what the job log on 0f502f4 shows (job 129202435150, step node tools/check-architecture-docs.mjs, 8s). Not a flake, and not related to conflict resolution — the guard had never run on this feature branch because the PR's earlier base did not carry it.

Fix: registered the three modules in the source map next to their siblings:

  • src/model-endpoints.ts next to config.ts
  • src/commandcode-wire.ts next to wire-drop-warn.ts
  • src/loop/adapter-commandcode.ts after adapter-google.ts

Verified with the guard's own logic against this tree: 311 src files, 0 missing, 0 ghosts, ledger/page/SVG checks green. master's reference/architecture.md is byte-identical to 0f502f4's, so this is the same state master's green run has.

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.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复. Among open [PR] rows, only this thread (GitHub #6032) targets the model-endpoint-patterns + commandcode wire family (feature #1295); no parallel rebase-of-#1444 exists. (Aside: internal mirror #6032 is a different PR — hermes base_url whitelist #6022 — so bare mirror numbers don't map to GitHub numbers here.)

Reviewed #6032 — head now 9724f1de, base master @ 4be21b08. Rebase of stale tracking PR #1444 onto current master; net diff 28 files, +2158/−38, 0 behind master. I verified every claim against the actual tree rather than taking it on faith:

  • Net tree diff matches GitHub's file list exactly; sha chain confirmed (80e9d205 → c7ac7b55 → 9724f1de).
  • Code review passed: adapter-commandcode conforms to CompressLoopAdapter (spreads createOpenaiAdapter, overrides parseStream + all emitters); every cross-file symbol resolves; console.error in the host-side loader is consistent with the six existing agent modules; tests carry real teeth (full rejection matrix where every unconvertible shape → undefined, plus negative match cases incl. evil-api.commandcode.ai correctly NOT matching). Gate discipline Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617 both-directions satisfied.
  • Your chunked full-suite run reads as genuinely environmental: each of the 15 fail signatures is either identical-on-unmodified-master or passing in isolation, and Windows can't spawn npm test at 1150 file args (ENAMETOOLONG). CI mirror confirms 0 failed / 0 pending (real-client e2e lanes skipped under zero-token/hermetic). tsc/touched-suites are author-reported; CI's typecheck+test gates are the authoritative green.
  • Key regression property holds: when modelEndpointPatterns is empty, matchModelEndpoint → undefined → the classifier falls through byte-for-byte as master. Zero behavior change for existing users. Both compression modes reasoned: proxy does unwrap→pipeline→rewrap at the forward boundary; plugin mode uses pipePluginJsonlWithStrip which strips render tags from prose only, never tool args.

Two pre-merge gaps found, both now resolved on the branch:

  1. architecture-docs CI lane was red — the three new src/ modules weren't registered in reference/architecture.md (the guard had never run on the old feature base). You fixed this at c7ac7b55; I verified the registration (lines 46/65/191) and that your accompanying source edits are cosmetic-only (import order, two blank lines, one hoisted helper relocated) — no logic change. ✓
  2. WIRE-CONTRACTS.md / .zh-CN.md sat at repo root — 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): new design docs must live under docs/ and be listed in docs/index.md + docs/index.zh-CN.md in the same PR. Since maintainer_can_modify=true, I landed this directly: commit 9724f1de moves them to docs/wire-contracts.md(.zh-CN.md), adds the two index rows, and retargets the six inbound references. Doc links/comments only, no behavior change. ✓

Soft (non-blocking): modelEndpointPatterns is a new top-level config field, documented well (en/zh prose + website seed + generated param table), but the PR body lacks the "config surface" section AGENTS.md asks for (why existing mechanisms can't express it + migration story). Suggest one line before merge. Minor note-only: the unwrap-failure relay path forwards without scrubCompatDrop/scrubAnthropicPck — defensible, since the intent is verbatim passthrough of an unconvertible commandcode body.


结构化结论(八问)

  1. 是什么问题: 不是缺陷修复,而是把停滞的追踪 PR [PR] feat: declarable custom-wire model endpoints + commandcode-cli wire family (#1295) #1444(功能 [Feature] Declarable custom-wire model endpoints — route providers like commandcode's Go plan (/alpha/generate) into compression #1295:可声明模型端点 + commandcode wire 家族)rebase 到当前 master,使其可合入。
  2. 什么原因导致的: [PR] feat: declarable custom-wire model endpoints + commandcode-cli wire family (#1295) #1444 自 2026-09-26 起落后 master 约 1725 个提交、11 个文件冲突(mergeable_state=dirty),手工解冲突成本高;本 PR 用「同一功能集 rebase 到 master」的方式让 [PR] feat: declarable custom-wire model endpoints + commandcode-cli wire family (#1295) #1444 可被推进。
  3. 影响范围与严重程度: 纯增量 feature(新 wire 家族 commandcode + 可声明端点)。当 modelEndpointPatterns 为空时行为与 master 逐字节一致,对存量用户零影响。无回归风险。
  4. 怎么修复的: 单一配置源 src/model-endpoints.ts 同时喂给 proxy 协议分类器与客户端 fetch-claim(根治 dsh使用插件dsh-commandcode-provider反代go套餐的话,不进billion-context压缩 #1290 表漂移);commandcode = CLI 信封内嵌 openai-completions 请求 + 裸 JSONL 响应,proxy 按 protocol=openai + wireFamily=commandcode 处理:unwrap→标准管道→forward 边界 rewrap。协议分类优先级新增 declared pattern 一档(providers-table 之后、内置启发式之前)。
  5. 是否有回归问题: config 空时分类器逐字节回退 master(关键回归属性成立);fake-completion retry([bug] 假完成:模型把工具调用写成文字(无 tool_use 块)→ 轮次提前终止,agent 显示正常完成(#361 根因 follow-up) #371) 对 commandcode 关闭(其 finish/error 即终止符);两种压缩模式都推演过。高危模式逐项过:无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式漂移。唯一注记:unwrap 失败 relay 未套 scrubCompatDrop/scrubAnthropicPck——意图即逐字透传不可转换体,可接受。
  6. 是否破坏缓存: 不涉及。不触碰缓存键/重试游标/去重,prefix-cache 语义不变。
  7. 是否改了设计方向: 是(有意)——单一配置源驱动协议分类 + 新 wire 家族,把 dsh使用插件dsh-commandcode-provider反代go套餐的话,不进billion-context压缩 #1290 的「两处各自维护」收敛为「一处声明」,符合 feature [Feature] Declarable custom-wire model endpoints — route providers like commandcode's Go plan (/alpha/generate) into compression #1295 的设计意图。
  8. 是否引入了新的配置: 是——新增顶层字段 modelEndpointPatterns(docs/configuration.md en/zh + website seed + 生成参数表已文档化)。软性提醒:PR 正文缺 AGENTS.md 要求的「config surface」小节(为何现有机制表达不了 + 迁移说明),建议合并前补一行。

判定: 代码正确、可合并(mergeable=true,无冲突),两处合并前缺口已在分支上解决,待 owner 批准。 按仓库政策我不执行合并——@ranxianglei,请在你方便时 approve/merge。若你倾向保留 #1444 作为追踪 PR,把本分支 tip 并入 2026-09-26_model-endpoint-patterns 即可让 #1444 立即对 master 可合。

@suyeku1

suyeku1 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

CI is green on 9724f1de: 56 checks = 40 success + 16 skipped-by-design + 0 failed, including architecture-docs, lint, static-gates and the full test matrix (ubuntu 22/24, windows 22, shards 1-5).

The ework-agent relocation commit (docs: relocate WIRE-CONTRACTS ledger under docs/ (#5920 layout)) sits on top of my c7ac7b55 and kept both fixes intact — verified against the remote tree:

PR is mergeable: true / mergeStateStatus: BLOCKED — the block is the branch-protection review requirement, not a check. Nothing left on my side.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Verified independently against the CI mirror: 0 failed / 0 pending on the current head 9724f1de (the mirror aggregates to 27 success + 3 skipped; your 56-run figure is GitHub's finer per-shard/per-OS breakdown — same result, no red). Both fixes are intact on the branch: the reference/architecture.md registration of the three #1295 modules (c7ac7b55) and the WIRE-CONTRACTS → docs/wire-contracts.md(.zh-CN.md) relocation with index rows + retargeted refs (9724f1de).

State, confirmed live: PR mergeable: true, mergeStateStatus: BLOCKED — the block is the branch-protection review requirement, i.e. it needs owner approval, not another check. Nothing is outstanding on the code side.

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 modelEndpointPatterns field (why existing mechanisms can't express it + migration story). Low stakes since it implements tracked feature #1295 — add a line before merge if you want it complete, otherwise it can ship as-is. Your call.

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 2026-09-26_model-endpoint-patterns makes #1444 immediately mergeable against master.

@suyeku1

suyeku1 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

The soft blocker from your review is addressed: the PR body now carries a full ## Config surface section (8290 B, up from 3257).

Contents, per AGENTS.md → Configuration Surface Discipline rule 1 (line 137 of AGENTS.md @ 4be21b08):

  • What is added — new top-level key modelEndpointPatterns: Array<{match, wire}>, default [], closed wire set, loud startup rejection for userinfo/query/hash, longest-prefix matching on an origin-equal path-segment boundary.
  • Why the existing surface cannot express it — two independent facts:
    1. providers.protocol is a closed union: WireProtocol = "anthropic" | "openai" | "responses" | "google" (src/util.ts:144, src/config.ts:69). commandcode is not a fifth protocol — it is the unmodified OpenAI pipeline plus an envelope codec (wireFamily), so overloading protocol would either misdescribe the pipeline or widen a union every switch treats as exhaustive.
    2. The two gates that decide "is this a model API" run in different processes. isModelApiUrl (src/agent/native-intercept.ts:305) and dsh's takeoverGate (src/agent/dsh-native.ts:2356) execute in the host agent; the providers table is loaded by loadRoutes (src/config.ts:1451) in the proxy. grep -rn "loadRoutes\|parseRoutes\|findRoute\|peekRoute" src/agent/ returns nothing. A providers declaration moves only the classifier, the client still doesn't claim the URL, and that is exactly the dsh使用插件dsh-commandcode-provider反代go套餐的话,不进billion-context压缩 #1290 symptom.
  • Mechanisms considered — providers table + key species, three-level compress hierarchy, env-var conventions (no JSON-in-env precedent anywhere in src/; every BILI_* mirror is a scalar), launcher↔extension channels, and the /bili/<protocol>/ marker (a per-request caller pin, whereas this is an operator-declared endpoint property — which is why route?.explicitProtocol deliberately still outranks a declaration).
  • Owner sign-off — rule 3 is satisfied by [Feature] Declarable custom-wire model endpoints — route providers like commandcode's Go plan (/alpha/generate) into compression #1295, recorded before implementation.
  • Compat / migration — additive and inert: [] → matchModelEndpoint returns undefined → both gates fall through to today's tables byte-for-byte.

Also folded in: the doc-conflict resolution (prose into docs/configuration.md + zh, table via the server.yaml seed + generator, check-coverage exit 0), the two post-review commits, and the CI matrix (56 checks = 40 success + 16 skipped-by-design + 0 failed on 9724f1de).

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Confirmed live: the PR body now carries a ## Config surface section (8289 B, head unchanged at 9724f1de), and it satisfies AGENTS.md Configuration Surface Discipline rule 1 — what is added (modelEndpointPatterns, default []), why the existing surface can't express it (the closed WireProtocol union + the host-agent-vs-proxy-process gate split), mechanisms considered, and compat/migration (additive + inert, [] → byte-for-byte fall-through). The two load-bearing refs check out against the tree I reviewed independently: isModelApiUrl / dsh takeoverGate run in the host agent while loadRoutes owns the providers table proxy-side — exactly the #1290 drift a single shared source closes. So the one soft item from my review is now resolved.

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:

  • Review verdict + 八问 delivered; 查重 = 不重复.
  • Both pre-merge gaps fixed on the branch: reference/architecture.md registration (c7ac7b55) + WIRE-CONTRACTS relocation under docs/ (9724f1de).
  • CI green, verified via mirror: 0 failed / 0 pending on 9724f1de.
  • Config-surface section added.

mergeable: true, mergeStateStatus: BLOCKED purely on the branch-protection review requirement. @ranxianglei, this is ready for your approval/merge whenever you're ready. Per repo policy I don't merge PRs. If you'd keep #1444 as the tracking PR, merging this tip into 2026-09-26_model-endpoint-patterns makes #1444 immediately mergeable against master.

ci-check and others added 2 commits November 9, 2026 23:33
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 ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --noEmit clean 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 test in this sandbox is not conclusive: 45 tests/dsh-native.test.ts waitFor timeouts reproduced byte-identically on clean master 4be21b08e (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.ts via 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 in docs/wire-contracts.md (+zh). The rewrap at the final forward boundary in src/server/relay.ts runs 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 + passthrough adjudication — checked against src/loop/core.ts (if (tc.passthrough) continue; before adapter.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/error frames are terminators, not retryable partials.
  • Classifier delta worth knowing (src/server/handle.ts): master set protocol from an explicit pin / declared protocol even for GET and empty-body POSTs; now those get protocol = null, so a non-declared probe of a pinned route can reach logUnrecognizedPath where 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 labeled bili-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
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Conflict resolved & pushed (attempt 1/3, succeeded). Upstream PR #6032 was mergeable_state: dirty (conflict against master) — that was the only blocker; all 30 checks were already green before the push. I brought the head branch up to date with origin/master and resolved the single content conflict.

What I did this run:

  • Fetched master + head. Divergence: head 111 behind / 17 ahead. The branch already carried 6 prior "merge master" commits, so I used a merge (one resolution pass) rather than a rebase — rebasing would scatter the author's existing conflict resolutions.
  • Exactly one hunk conflicted: src/server/relay.ts. PR side wrapped pickAdapter(...) in a prepared.commandcode ? createCommandcodeAdapter(...) : pickAdapter(...) ternary; master side kept the plain pickAdapter(...) and added an independent let loopSeparatorSlots: readonly SeparatorSlot[] = [] immediately after. Resolved as a union (kept both) — the two changes are orthogonal. Verified every supporting symbol landed cleanly from the auto-merged parts: SeparatorSlot import (@relay.ts:5), createCommandcodeAdapter (@relay.ts:43, defined in adapter-commandcode.ts:70), prepared.commandcode (@handle.ts:2901), loopSeparatorSlots consumed later via closure (@relay.ts:2676/2679/2691).
  • The other 8 overlapping files (docs/configuration.{md,zh-CN}, reference/architecture.md, src/config.ts, src/server.ts, src/agent/{native-intercept,dsh-native}.ts, tests/native-intercept.test.ts) auto-merged — no manual edits needed.
  • Pushed fast-forward (no force) to suyeku1/billion-context@2026-11-09_merge-master-into-1444: 48dc0d5ff1..7291f0e136. Re-fetched the fork immediately before pushing to confirm no concurrent push had moved the head.

Local verification (targeted, per test discipline — full suite is CI's job):

  • tsc --noEmit → exit 0; kernel + pi-subagents builds OK.
  • PR feature tests (commandcode-wire / adapter-commandcode / model-endpoints / commandcode-endpoint / commandcode-plugin-pipe / native-intercept): 137/137 pass.
  • Round-2 rebuild-path tests (the region I hand-edited): 48/48 pass.

Live status (verified this run, mirror cache): sha now 7291f0e136, mergeable_state: **blocked** — i.e. no longer dirty, conflict cleared; blocked here means "waiting on the fresh checks my push triggered", not a conflict. CI re-run in progress on the new head: 0 failures so far (2 success incl. gate, 9 in-progress, 4 queued, 15 skipped). It flips to clean once those finish green.


结构化八问:

  1. 是什么问题:PR [PR] Rebase #1444 onto master: declarable model endpoints + commandcode wire family #6032 与 master 存在合并冲突(mergeable_state=dirty),导致无法合并。
  2. 什么原因导致的:分支落后 master 111 个提交,且双方都改了 src/server/relay.ts 同一处——PR 侧把 pickAdapter 包进 commandcode 三元式,master 侧在同一行后新增 loopSeparatorSlots 声明,文本重叠触发冲突。
  3. 影响范围与严重程度:仅影响该 PR 的可合并性;不触及任何已发布行为。冲突未解前 PR 无法合入。
  4. 怎么修复的:选「master 合并进 PR 头」而非 rebase(分支已含 6 个历史 merge-master 提交,rebase 会打散作者既有解法);唯一冲突按并集处理——同时保留 PR 的 commandcode 三元式与 master 新增的 separatorSlots 声明,二者语义正交、互不覆盖。
  5. 是否有回归问题:无。改动仅为合并同步 + 一处并集解冲突,未改任何既有语义;本地 typecheck 通过、137+48 定向测试全绿。
  6. 是否破坏缓存:不涉及(未触碰缓存/重试/增量游标/去重键逻辑)。
  7. 是否改了设计方向:不涉及(纯冲突消解,无架构或数据流转向)。
  8. 是否引入了新的配置:不涉及(无新 env/config/默认值)。

判定:冲突已消除并推送成功(fast-forward、无强推),本地验证全绿;远程 CI 在新 head 上重跑中、当前 0 失败,跑完转 clean 后即可合并。

… import split (logRequestCost → request-cost.js; keep declPinConflictWarned)
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Status: conflict resolved and pushed — the PR is now mergeable (mergeable_state: behind, no longer dirty) with CI fully green.

What happened this run:

  • Since the previous sync, master had advanced 43 commits. Merging it into the PR head produced exactly one conflict: the large src/server/handle.ts import block. On master, logRequestCost was relocated out of src/server.ts into a new module src/server/request-cost.ts, while this PR's side still imported it from ../server.js.
  • Resolved as a union: kept the PR-added declPinConflictWarned in the ../server.js import, and switched logRequestCost to import from ./request-cost.js. No other file conflicted.
  • One red herring cleared: the first typecheck failed on adapter-responses.ts / prepare-responses.ts (headRole missing, arg-count mismatch). That was a stale in-repo kernel build, not a semantic conflict — rebuilt the bundled kernel artifacts (npm --prefix kernel build) to match the freshly-merged kernel source, and typecheck then passed. Build refresh only: no kernel source change, no version bump by me.
  • Local verification: tsc --noEmit exit 0, build OK, and 145/145 targeted tests pass (commandcode / model-endpoints feature family + the responses path that consumes the rebuilt kernel).
  • Committed the merge and pushed as a fast-forward (no force) after re-fetching the fork (no concurrent pushes detected).

Live state (verified against the PR's current head this run):

  • Head sha 9914dcae; mergeable_state: **behind** — i.e. mergeable, no conflict (independently confirmed by a read-only git merge-tree against the newest master, exit 0).
  • CI 30/30 green: 14 success + 16 skipped, 0 failed, 0 pending.

Caveat (stated plainly): master is moving very fast — another 58 commits landed during this run alone. The branch therefore reads as behind: it is still mergeable (a human can merge it directly), but doesn't yet contain the very latest master commits as of this instant. I resolved against the latest master tip available to me rather than chasing a moving target through repeated syncs in one pass.

No behavior changes, no new config, and no cache / retry / cursor logic touched — this run is pure conflict resolution plus a build refresh.


八问(供人工 reviewer)

  1. 是什么问题:PR [PR] Rebase #1444 onto master: declarable model endpoints + commandcode wire family #6032 与 master 产生合并冲突(mergeable_state=dirty),无法合并。
  2. 什么原因导致的:上次同步后 master 又前进 43 个提交,其中把 logRequestCost 从 src/server.ts 移到新文件 src/server/request-cost.ts;本 PR 侧的大 import 仍从 ../server.js 引入它,导致 src/server/handle.ts import 块三方冲突。
  3. 影响范围与严重程度:仅阻塞该 PR 合并(CI 全程绿),不影响线上用户与已发布版本;属「PR 无法合并」级,非运行时缺陷。
  4. 怎么修复的:把最新 master 合入 PR head,import 块取并集——保留 PR 新增的 declPinConflictWarned(仍在 server.js)、把 logRequestCost 改从 ./request-cost.js 引入;并重建 in-repo kernel 本地构建产物以匹配刚合入的内核源码(仅构建刷新,未改内核源码、未 bump 版本)。本地验证后 fast-forward 推送(未 force)。
  5. 是否有回归问题:无。改动仅为 import 路径归位 + 干净合并;typecheck EXIT=0、build OK、定向测试 145/145 全过(含 commandcode 特性族 + responses 路径);未触碰任何语义 / 阈值 / 时序 / 输出格式 / fail-fast 行为。
  6. 是否破坏缓存:不涉及。无缓存 / 重试 / 增量游标 / 去重键相关改动。
  7. 是否改了设计方向:不涉及。纯冲突消解,无架构 / 边界 / 数据流转向。
  8. 是否引入了新的配置:不涉及。无新增 env / config / 默认值。

收工判定:冲突已清(behind 而非 dirty,且 read-only merge-tree 对最新 master 亦无冲突),CI 全绿,可交人工直接合并;若希望保持与最新 master 同步可再追加一次同步,但无残留冲突。

@suyeku1 suyeku1 mentioned this pull request Nov 10, 2026
@ranxianglei
ranxianglei merged commit e1e33a9 into ranxianglei:master Nov 10, 2026
56 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1163-master.e1e33a9 (rolling master tag).

npm install -g billion-context@0.0.1163-master.e1e33a9  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants