Skip to content

feat: in-process pi compression entry (true non-server native) — deprecates billion-context-pi - #2008

Open
ranxianglei wants to merge 6 commits into
masterfrom
2026-10-03_pi-inprocess-port
Open

ranxianglei wants to merge 6 commits into
masterfrom
2026-10-03_pi-inprocess-port

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Closes #1988

What

Vendors the billion-context-pi compression core into this repo as a new tsup entry dist/agent/pi-inprocess.js (source: src/agent/pi-inprocess/, 46 files) and makes it the default pi extension (package.json pi.extensions). Compression runs in pi's own process; model traffic goes direct to upstream — no local server, no fetch patching, no watchdog. The old server-based native (dist/agent/pi-native.js) stays reachable behind the new kill-switch BILI_PI_INPROC=0.

This is the prep step for fully retiring billion-context-pi (Phase 3 = deprecating the npm package after migration evidence — deliberately NOT part of this PR).

Config surface (owner-gated section)

Key Kind Default Semantics
BILI_PI_INPROC env string unset (= ON) accepts 0 / false / off / no (case-insensitive). When set, the pi entry delegates at load time to the server-based native path instead of running in-process. Read once at extension load → restart pi after changing.

Why a new key instead of an existing mechanism: BILI_NATIVE_PI governs the server-based entry's plan (off/attach/spawn) and does not exist in the in-process entry's decision space; BILLION_CONTEXT_PLUGIN=0 disables the shared plugin tooling, not the engine posture. The new key follows the existing kill-switch family convention (BILI_* per-lane switches) and gives a one-line rollback for the default-mode flip below. No config.json field touched; no CLI flag.

Behavior changes (disclosed)

  1. Default pi mode flips: server-based → in-process. Users upgrading npm:billion-context get in-process compression without opting in. Rollback: BILI_PI_INPROC=0 (restart pi); repo-level: revert this commit.
  2. README recommendation flips: the pi row of "Which do I need?" now points at billion-context (in-process); the bcp package is marked deprecated pending retirement.
  3. Model traffic in default pi sessions goes direct to upstream — proxy-side facilities (web UI panel /__bili, /acp-cache report, image billing/compression) do not apply to in-process sessions (they never traversed the proxy). Known gap, disclosed; follow-up fix: address all code review findings (condense, routing, session-id, dead code) #2 below.
  4. New npm exports: billion-context/pi (runtime entry: createAcpExtension / createRuntime / deriveChildState), billion-context/contract (sidecar schema constants + types), billion-context/contract/schema (JSON Schema file). These are the migration target for bcp host-adapter consumers (docs/host-adapter.md).
  5. Build-time devDependencies added (NOT runtime deps for consumers): typebox@1.3.34 (bundled inline into the pi-inprocess entry, same discipline as acp-kernel), @earendil-works/pi-coding-agent@0.83.0 + @earendil-works/pi-tui@0.83.0 (kept external — host-provided at runtime; typecheck only).
  6. Producer string & log prefixes: sidecar producer becomes billion-context@<version> (was billion-context-pi@…); console/log prefixes [bcp] → [bili-pi]; stand-down messages [billion-context-pi] → [billion-context]. The sidecar FORMAT itself is unchanged (v1, byte-compatible) — existing bcp state loads with zero migration; extras (liveRefOrigins / derivedFrom / activePack) carried through.
  7. Self-updater repointed: the pi copy now tracks the billion-context package (channel-based dist-tag from host deps), installed into pi's extension node_modules root; throttle/marker files renamed .billion-context-pi-* → .bili-pi-inproc-* under the agent dir (one-time reset; prevents cross-suppression by a legacy co-resident updater). Install-Lane Contract §2 compliant (self-heal through its own install channel; converges with the global-driven pi update lane within ~one check cycle).
  8. version.ts fix (affects ALL entries): nested dist/agent/*.js previously resolved a missing dist/package.json and silently fell back to "dev"; it now walks up to the real package root (name-guarded). Version strings in logs/status panels are corrected for every agent entry.
  9. acp-kernel: pin unchanged (0.0.100). The ported code needed exactly one cast widening for the kernel's new CompactionSummaryMessage union member (live-only-tail.ts).

Both-modes reasoning (§6)

In-process mode is a THIRD posture alongside pluginMode/proxyMode (KDD #7): like pluginMode the agent OWNS compression — call+result live in the client's own history and no acp_summary carrier is injected on the wire (the wire is direct; there is no proxy at all). Proxy-mode and plugin-mode paths are untouched except the pi-native.ts refactor (module-level bootstrap extracted into idempotent startPiNative(); standalone-entry behavior preserved incl. sync marker stamping — covered by the existing pi-native tests). Mutual-exclusion protocol unchanged: installer entry swap + BILLION_CONTEXT_NATIVE marker (value-distinguishes pi vs pi-inprocess; non-clobbering first-writer-wins) + both entries warn on co-resident legacy bcp (<0.1.72 lacks marker support = double-compression risk, stated in the warning).

Tests

  • Ported bcp core suite: 77 flat test files (tests/pi-inprocess-*.test.ts) + fixtures; delegate/fleet/TUI tests excluded (those surfaces were not ported).
  • New repo-side wiring suite tests/pi-inprocess-wiring.test.ts: kill-switch parsing + delegation (no spawn), marker symmetry (own marker ignored, foreign honored, never clobbered), every stand-down signal, legacy bcp sidecar adoption, contract smoke, no-server-spawn assertions.
  • Local targeted battery (ported suite + directly affected existing suites): 876 tests, 873 pass, 0 fail, 3 skip; typecheck clean; build clean (dist-import-annotations OK). Full regression + e2e left to CI on this head.

Scope notes / follow-ups (separate issues post-merge, 来源 marker → this PR)

  1. delegate/fleet subagents + TUI widgets (bcp extras beyond the compression core) — config fields still parse but are inert in this build.
  2. Sessions-dir mirror: write in-process state into ~/.local/share/billion-context/sessions/ so the web UI panel sees these sessions (deferred: panel-shape coupling risk could hit proxy users' /__bili page).
  3. Proxy-only feature parity for the in-process engine (image billing Bill images and text separately — the image estimate's ±15× error bar poisons every window decision (dual-channel accounting) #1843/Feature: image pre-compression for screenshot-heavy tool results (resize/quality routing) #1095, CCR retrieve, apig-resign bili 改写带 body 签名的模型请求,CodeArts(华为 APIG SDK-HMAC-SHA256)全部 401 #1884, output steering, chain checkpoint [design] chain checkpoint step 3: carrier stamp shape on role-alternation-strict wires (anthropic/google) #1421).
  4. Phase 3: deprecate npm:billion-context-pi (needs migration evidence first).

Post-rebase update (head 3a4ab65)

Rebased onto current master (33d58e5, v0.1.181). Conflicts resolved: README pi row (union of both changes), tsup.config.ts (kept object-form entry map; noExternal union = master's ws + this PR's typebox). package.json / lock / CONFIGURATION.md / TECHNICAL-NOTES.md auto-merged.

Two follow-on items, one per commit:

  1. feat commit (amended) — master widened the typecheck gate to cover tests/ (2e6e508). The ported suite needed typing fixes across ~33 files under acp-kernel 0.0.101 + pi-coding-agent 0.83.0 strict typings. All typing-only; where host types diverge from runtime data (AgentMessage.content typed parts-only while pi also delivers plain strings), fixtures stay byte-exact and bridge via casts. zh docs synced in the same commit (README.zh-CN.md, CONFIGURATION.zh-CN.md BILI_PI_INPROC row).
  2. fix commit (labeled) — clears 12 residual PRE-EXISTING test type errors that postdate 2e6e508's "clear all" claim (issue1987/issue1993 preflight tests from Gate tests/ under CI typecheck — clear all pre-existing test type errors (#1970) #1990, ws-bridge, codex-responses-ws). They leave master CI red (runs 37132951612 / 37131170170) and block this PR's gate; fixed here so the gate goes green repo-wide.

Battery after remediation: npm run typecheck 0 errors; build OK; targeted suite 876 tests / 873 pass / 0 fail / 3 skip.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到,开始 review。初步状态:PR open、非 draft,GitHub 报 mergeable: false / dirty(疑似与 master 有冲突),先核对分支与 CI,再按七问出结论。稍后更新。

ranxianglei pushed a commit that referenced this pull request Oct 3, 2026
Conflict resolution (union of intent):
- tsup.config.ts: noExternal gains both "ws" (master, preflight transport
  resilience) and "typebox" (this PR, inlined build-time dep).
- README.md: pi row keeps this PR's in-process-default semantics (#1988) plus
  master's #2000 entry points (bili pi launcher / bili plugin install pi).
ranxianglei pushed a commit that referenced this pull request Oct 3, 2026
…ess changes (#2008)

Mirror the EN doc updates this PR introduced (pi row in 'Which do I need?', native-vs-standalone paragraph, install note bullet, status paragraph, BILI_PI_INPROC env-var row, acp_summary carrier reference) into the zh-CN twins. AGENTS.md 7.3: keep zh/en in sync.
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-03_pi-inprocess-port (bd6d0ad)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2037-pr.2008.8f0886b

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr2008.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review 完成 — 判定:HOLD(方向通过、代码质量良好,3 个合并阻塞项,均已验证非猜测)

Review 期间已完成的分支工作(2 个额外 commit,已推送,fast-forward):

  1. 58d3400e 同步 master(原 PR mergeable:false/dirty)。冲突仅 2 处:README.md + tsup.config.ts,均按意图并集解决(tsup noExternal 同时保留两侧新增的 ws+typebox;README pi 行合并 docs(#1998): default pi recommendation to billion-context in README (en/zh) #2000 推荐措辞与本 PR 的 in-process 默认)。PR 现为 mergeable:true。
  2. 4d482317 补 zh 文档同步:PR 正文只改了 EN 文档,违反 §7.3 zh/en 同步——已镜像 README.zh-CN.md 4 处、CONFIGURATION.zh-CN.md 的 BILI_PI_INPROC 环境变量行、TECHNICAL-NOTES.zh-CN.md 引用路径。(master 的 docs(#1998): default pi recommendation to billion-context in README (en/zh) #2000 也有同样遗漏。)

结构化七问:

  1. 是什么问题:非缺陷,是 feature PR review——把 billion-context-pi 的压缩核心 vendor 进 billion-context 成为进程内 pi 入口(Provide a true native, non-server implementation for the pi version. | 为pi版本提供非server的真native实现 #1988),设为默认 pi 形态,为下线 bcp 做准备。
  2. 什么原因/方向是否成立:方向合理,与 Provide a true native, non-server implementation for the pi version. | 为pi版本提供非server的真native实现 #1988 里 owner「直接做」的决策完全一致;设计契合 Install-Lane 契约(单写者、host channel 更新路径)与压缩模式纪律(in-process ≈ pluginMode 姿态:agent 自持压缩,wire 无 acp_summary carrier,摘要载体是 tool call)。无方向性问题。
  3. 怎么实现的:46 模块 → 新 tsup 入口 dist/agent/pi-inprocess.js(+contract);默认 lane 切换;BILI_PI_INPROC=0 kill switch(动态 import,刻意避免静态 import 在 module eval 时 spawn 代理);marker pi-inprocess 仅在真正接管时于任何 await 前同步盖章(避免拒绝服务时反而解除 legacy 武装);三信号 stand-down(BILLION_CONTEXT_PROXY / /bili/ baseUrl / BILLION_CONTEXT_NATIVE)每事件懒检查;legacy bcp<0.1.72 共存告警每进程一次。这些核心路径逐一 spot-check:正确。
  4. 是否有回归问题:逐项审过既有行为,未发现无意回归:tsup array→object 转换保留全部既有输出名(build 验证);startPiNative() 幂等重构保持 standalone 加载期行为(pi-native 套件绿);version.ts 上行查找有包名 guard;noExternal/external 增项不影响既有 bundle;自动合并文件(package.json/lockfile/CONFIGURATION/TECHNICAL-NOTES)无语义漂移。但发现一个真实覆盖缺口——见阻塞③(e2e 断言钉死旧架构)。
  5. 是否破坏缓存:否。sidecar 格式 v1 字节兼容(read-compat 测试绿);session id/ref 空间不变;prefix cache 头部 system 稳定性不受影响(in-process 不走代理 wire);updater 节流 marker 改名(.billion-context-pi-*→.bili-pi-inproc-*)导致一次性重置——有意为之,防跨抑制。
  6. 是否改了设计方向:是,且已明确披露、正是 Provide a true native, non-server implementation for the pi version. | 为pi版本提供非server的真native实现 #1988 所要求:pi 默认模式 server-based→in-process(模型流量直连上游,绕过 image billing 等 proxy 侧能力——已知 gap,deferred);BILI_PI_INPROC=0 保留旧路径。不是漂移。
  7. 是否引入新配置:新增环境变量 BILI_PI_INPROC(默认开;接受 0/false/off/no,大小写不敏感;加载时读一次,改后需重启)——CONFIGURATION.md en/zh 均已记录。无新 config.json 字段、无 CLI flag,acp-kernel pin 未动。

合并阻塞项(CI 实测,head 4d482317):

① typecheck 门禁红:CI 的 npm run typecheck(ci.yml:38)在当前 head 报 185 错:

② e2e-native-pi(真 pi e2e)红,与 PR 直接相关:tests/e2e/e2e-native-pi.test.ts 未被本 PR 更新,其断言钉死旧架构——期望上游请求带 x-bili-plugin: pi stamp(只有 server-based 代理居中时才存在);新默认 in-process 下流量直连上游、无代理、无 stamp → 3 个子测挂(request must be plugin-stamped (x-bili-plugin), got null ×2、instance record must exist after a native run)。已核实:进程内入口有自己的 /acp 本地状态路径(commands.ts 的 statusHandler 读自身 runtime,不依赖代理 instance record),功能上没问题——是 e2e 断言要更新到新姿态(断言直连流量 + 本地 /acp;可选保留一条 BILI_PI_INPROC=0 lane 覆盖旧路径)。这正是 §7.5 说的「首遍不完整:漏了相邻路径」。

③ 建议合并顺序:先合 #2007(修 master 那 12 个)→ 本 PR re-sync → 修 ① 的 173 + ② 的 e2e → CI 绿 → 合。否则本 PR 修完 CI 仍会因 master 残留而红。

CI 证据(head 4d482317,10 条 workflow 全部完成):红 3——CI、ci-image(同一原因:typecheck 门禁,日志与本地实测逐条一致)、e2e-native-pi(见②);绿 7——含 e2e-local-registry(self-update 链)、e2e-native-dsh/opencode、E2E real codex、e2e-fake-codex、Windows codex overlay、PR Build Artifact。本地侧:wiring+pi-native 套件 20/20;抽样移植套件 84 例 81 过 0 败 3 skip;build 绿(dist/agent/pi-inprocess.js 2.73MB + contract 入口就位)。

其他发现(不阻塞):AGENTS.md 里 "master pins acp-kernel 0.0.100" 一句已过时——master 实际 pin 0.0.101(本 PR 未动 pin,auto-merge 取到的是 0.0.101)。一词陈旧,留给 owner 顺手处理。

判定:HOLD。 方向、设计、代码质量全部通过;被 ① 173 个测试 typing 错误 + ② e2e-native-pi 断言更新 + ③ #2007 合并顺序卡住。三项修完预计即可合入。若需要,我可以在本分支继续:分别以独立 commit 修 ① 和重写 ② 的断言,CI 绿后回报。

@ranxianglei
ranxianglei force-pushed the 2026-10-03_pi-inprocess-port branch from 4d48231 to 3a4ab65 Compare October 3, 2026 16:49
@ranxianglei

Copy link
Copy Markdown
Owner Author

[bot] 🏷 Rebased onto current master (33d58e5, v0.1.181) and pushed (head 3a4ab65). Two follow-on commits on top of the rebased feat:

  1. feat (amended) — master's new typecheck gate (tests/ under root tsconfig, 2e6e508) surfaced ~33 type errors in the ported suite under acp-kernel 0.0.101 + pi-coding-agent 0.83.0 strict typings; all fixed typing-only (fixtures stay byte-exact where host types diverge from runtime data). zh docs synced in the same commit.
  2. fix (labeled) — clears 12 residual pre-existing test type errors that postdate 2e6e508's "clear all" claim (issue1987/issue1993 preflight tests from Gate tests/ under CI typecheck — clear all pre-existing test type errors (#1970) #1990, ws-bridge, codex-responses-ws). They leave master CI red (runs 37132951612 / 37131170170) and would block this PR's gate regardless of my diff.

Local battery: typecheck 0 errors; build OK; targeted suite 876 tests / 873 pass / 0 fail / 3 skip. Watching CI.

@ranxianglei
ranxianglei force-pushed the 2026-10-03_pi-inprocess-port branch from 3a4ab65 to edd68b5 Compare October 3, 2026 17:05
@ranxianglei
ranxianglei force-pushed the 2026-10-03_pi-inprocess-port branch from edd68b5 to a739d26 Compare October 3, 2026 17:06
@ranxianglei

Copy link
Copy Markdown
Owner Author

e2e-native-pi fix (head a739d26)

The e2e-native-pi job on the previous head went red — expected, and it exposed a real gap in this PR's E2E coverage:

Root cause: the suite drove real pi with the repo root installed as a package and asserted the server-based lane's behavior (per-request x-bili-plugin stamping, proxy instance records, proxy-side session persistence). This PR flips package.json pi.extensions[0] to the in-process entry, so hermetic pi now loads the default in-process lane by design — direct traffic, no proxy — and the old assertions failed (expected 'pi', actual null, instance record must exist).

Fix — the suite now covers BOTH postures of the pi lane:

  • the four original Native-mode (plugin) lanes have no E2E coverage — /acp, acp_status and compress interception regressions ship undetected #1239 tests are pinned to the server-based lane via BILI_PI_INPROC=0 (behavior unchanged, titles updated);
  • a new fifth test exercises the default in-process lane and asserts the non-server guarantees explicitly: every upstream request direct (no x-bili-plugin stamp, no conversation header), zero proxy instances spawned, acp_status/compress still execute in-process, compression is real (≥1 block lands in a .acp.json sidecar next to pi's session files; receipt asserted against the in-process shape from compress-tool.ts, which differs from the proxy/pluginMode receipt text), and /acp exits clean with no proxy behind it.

Also added ACP_AUTO_UPDATE=0 to every spawned pi env (existing updater seam, not a new config surface): without it the in-process entry's session_start self-update check would resolve against the real npm registry from CI and could install into the checkout.

Verified locally before pushing: full gated suite green 5/5 against real pi 0.83.6 (previously-failing assertions included). Working tree content is byte-identical to what the previous CI run saw (only the commit split changed: the e2e update moved into the feat commit; the typecheck-gate fix commit keeps its 4-file scope).

EN TECHNICAL-NOTES.md already says src/agent/pi-inprocess/messages.ts;
the zh twin still cited billion-context-pi's src/messages.ts after the
rebase. One-line zh/en sync.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Round 2 验证完成 — 两个阻塞项均已解决并独立核实,剩一个我顺手修掉的小问题。判定:CI 绿即可合。

对上一轮阻塞项的独立核实(不是只看你说绿):

① typecheck:新 head a739d26e 本地 npm run typecheck = 0 errors(此前 185)。173 个移植测试的 typing 修复折进了 feat commit,做法是适配 pinned kernel 的真实类型面(如 runId: 0→"r0"、补 directBlockIds/compressedTokens、state.rules ??=),不是删断言——全量 diff 断言行净增(+48/−36),round-trip 测试仍钉住 byRef.m00000 === "a"、nextBlockId、blockId 等核心不变量。CI 侧 ci-image(自带 typecheck 步骤)已转绿佐证。

② e2e-native-pi:读了新增第五个测试的断言,有牙:逐请求断言直连(x-bili-plugin 与 conversation header 均为 null)、hermetic state 下 instance 记录数为 0、acp_status 返回真实状态报告(正则钉 ACTIVE SURFACE…CONTEXT BREAKDOWN)、compress 回执匹配进程内专属形态(▣ ACP | … blocks: b\d+=m\d+,与 proxy/pluginMode 回执文本区分)、磁盘上 ≥1 个 .acp.json sidecar 带压缩块、/acp 无代理下干净退出。四个原测试钉在 BILI_PI_INPROC=0 后行为不变。CI e2e-native-pi 已绿。tests/e2e/README.md 也同步更新了两姿态说明。✓

其他核对:

顺手修掉的一个小问题(独立标注 commit,已推送):75c686ea —— rebase 后 TECHNICAL-NOTES.zh-CN.md:72 仍引用 billion-context-pi 的 src/messages.ts,而 EN 版(TECHNICAL-NOTES.md:186)已指向 vendor 后的 src/agent/pi-inprocess/messages.ts。一行 zh/en 同步,doc-only。

CI 现状:a739d26e 上 10 条 workflow 中 9 条已绿(含两条此前红的 e2e-native-pi、ci-image),主 CI(全量 test matrix)检查时 in_progress;我推的 doc-only 75c686ea 会再触发一轮。

判定:READY(待最终 CI 绿)。 方向、设计、代码、测试有效性、diff 整洁度全部通过;无回归发现;无缓存破坏;设计变更即 #1988 本身且已披露;唯一新配置 BILI_PI_INPROC 文档齐备。CI 全绿后由人合并即可。另留一句:AGENTS.md "master pins acp-kernel 0.0.100" 一词陈旧(master 实为 0.0.101),不属本 PR,留给 owner 顺手处理。

ework-agent added 2 commits October 4, 2026 01:14
…refix (#2008)

The repo's #816/#828/#1615 family gate (tests/text-safe.test.ts) scans
src/ for raw negative .slice(-N) on strings outside its allowlist and
failed CI on this head: four vendored sites predate #1615 on the
bcp side. Replace them with the dependency-free clamps from
src/text-safe.ts (the gate's own prescription):

- compress-tool.ts summaryFingerprintLine: head/tail excerpts are
  model-visible integrity fingerprints — both cuts now clamped
- live-only-tail.ts weakMessageSig: internal dedup signature tail
- update.ts entry-import smoke reason + auto-install-failed log tail

Byte-identical output for ASCII input; surrogate-boundary cuts become
safe instead of emitting lone halves. No behavior change otherwise.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Round 3 — 修正我上一轮的 READY:最终 head 的主 CI 出了第 4 个阻塞项,已定位并修掉(已推送 aa20c20f)。

先认错:上一轮说「待最终 CI 绿」时,全量 test matrix 在更早的 head 上还没跑完就被新 push 顶替了,所以我没看到它红。最终 head 0c835f1c 的主 CI 实际是红的——不是 master 残留,是本 PR 自己的问题。

根因(已本地复现):仓库的 #816/#828/#1615 家族闸门 tests/text-safe.test.ts("no raw negative string slices outside the allowlist")会扫描整个 src/,禁止字符串上的裸 .slice(-N)(surrogate 半字会炸上游 JSON)。vendor 进来的 bcp 代码有 4 处这类调用(bcp 侧早于 #1615;同一指纹函数的代理侧孪生 src/stream.ts 早已用 clamp,移植时退化了):

  • src/agent/pi-inprocess/compress-tool.ts:327 — summaryFingerprintLine 的 tail 摘录(模型可见的完整性指纹)
  • src/agent/pi-inprocess/live-only-tail.ts:34 — weakMessageSig 内部去重签名 tail
  • src/agent/pi-inprocess/update.ts:329/371 — 入口冒烟失败 reason、auto-install-failed 日志 tail

作者本地跑的是定向电池(pi-inprocess 套件 + 直接受影响套件),没覆盖 tests/text-safe.test.ts 这个扫描器,所以本地绿、CI 红——典型 §7.5「首遍不完整:漏了相邻路径」。

修复(独立标注 commit aa20c20f,fast-forward 已推):全部改走依赖为零的 src/text-safe.ts 的 safePrefix/safeSuffix(闸门自己指定的修法),3 文件 5 处——指纹函数连 head 侧的正向切也一并 clamp(同函数同家族,模型可见文本的头尾摘录按 text-safe.ts 头部契约必须走 clamp)。ASCII 输入输出字节不变;只有 surrogate 边界处的切法从「可能出孤半」变成安全回退——严格变好,无行为漂移。

本地验证:闸门测试转绿;gate + compress-tool + live-only-tail(+cache) + state + wiring 共 77/77 过;npm run typecheck 0 错;build 绿(pi-inprocess 入口 2.73MB,text-safe 内联)。

顺带确认(master 侧,不属本 PR):master 自身在 29553b0b(v0.1.182 release 后)的同名 CI job 也是红的——正是已知 12 个残留 typecheck 错误(#2003 跟踪),与本 PR 的闸门失败是两回事。再次建议:合 #2008 前把 #2007 关闭(superseded),它的 4 个文件已被本 PR 的 fix commit 覆盖。

另外:你们会话在我 doc fix 之上又加了一个 devlog-only commit(0c835f1c,内容属实),review 结论不受影响;我的修复已 rebase 到其上。

判定:HOLD(等 aa20c20f 的 CI)。 这是最后一个已知阻塞项;matrix 绿后即为 READY,由人合并。CI 完成后我再回报一次。

…pare (#2008)

Windows CI checkouts materialize text fixtures as CRLF (core.autocrlf);
the in-memory template buildAcpSystemPrompt produces LF, so the
byte-identical assertion failed only on windows-latest (ubuntu green).
Normalize at read time — the fixture records an LF template, CRLF is a
checkout artifact. Verified A/B locally: test passes with both a
CRLF-converted and the original LF fixture.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Round 4 — aa20c20f 的 CI 回来了:9/10 绿,主 CI 仅 Windows job 红(ubuntu 两档全绿)。已定位并修掉(已推送 bd6d0ad5)。

根因(已本地复现):tests/pi-inprocess-surface-config.test.ts 把内存中生成的 system prompt(LF)逐字节对比磁盘上的 fixture 文件。Windows runner 的 git checkout 按 core.autocrlf=true 把 .txt fixture 物化成 CRLF → 只有 windows-latest(node 22/24 两个 job)挂,ubuntu 绿。移植自 bcp 的测试,bcp 侧没有 Windows CI matrix,从未在这个轴上跑过——又一处 §7.5「首遍不完整」,这次是平台维度而不是套件覆盖维度。

修复(独立标注 commit bd6d0ad5,已推):读 fixture 时归一化 CRLF→LF 再比对(fixture 记录的是 LF 模板,CRLF 只是 checkout 产物),一行 + 注释说明平台成因。本地 A/B 验证:把 fixture 转成 CRLF 跑测试 → 过;还原 LF 原版跑 → 过。typecheck 0 错。全仓仅此一处消费该 fixture,无同类隐患(Windows 日志里也只有这一个 failing test)。

判定:HOLD(等 bd6d0ad5 的 CI,重点看两个 windows job)。 这是第 4 个也是目前最后一个已知阻塞项;绿了即为 READY,由人合并。CI 完成后我再回报。分支现有 6 个 commit:feat + typecheck 残留修复 + zh doc + devlog + slice-family 修复 + CRLF 修复——每个都是独立标注、单一目的,diff 整洁度保持。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Round 5(终局)— head bd6d0ad5 的 CI 全绿:10/10 workflow SUCCESS,含主 CI 全量 test matrix(ubuntu×2 + windows-latest×2 node 档)与全部 e2e/registry/overlay lane。最后一个阻塞项已清除。

判定:READY。 四轮 review 的全部发现均已闭环:① 173 个移植测试 typing 错误(作者修)② e2e-native-pi 双姿态覆盖(作者修)③ master 残留 typecheck(fix commit 内,建议合前关闭 #2007 为 superseded)④ slice-family 闸门违规(review 修,aa20c20f)⑤ Windows CRLF fixture(review 修,bd6d0ad5);外加 review 期间的 master-sync 冲突解决(58d3400e→rebase 后并入)、zh 文档同步 ×2、devlog 记录。方向、设计、代码、测试有效性、diff 整洁度、回归面、缓存面全部通过;行为变更(pi 默认 server-based→in-process)即 #1988 本身且全程披露;唯一新配置 BILI_PI_INPROC en/zh 文档齐备。

可以合并了(人工操作): #2008 ——按仓库规则我不执行合并。合并前请顺手处理两件事:1) 关闭 #2007(superseded by this PR 的 fix commit);2) AGENTS.md "master pins acp-kernel 0.0.100" 一词陈旧(master 实为 0.0.101)。

收工。

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a true native, non-server implementation for the pi version. | 为pi版本提供非server的真native实现

1 participant