Repository navigation
feat: side-lane regression hardening — pure lane gates, truth tables, canaries, CI lane guard (#2170) - #2175
Conversation
… runtime canaries, CI lane guard (#2170) Measures 1/2/4/5 from #2170 (measure 3's recorded golden fixture stays a follow-up; the e2e lane itself ships here): - demoteGate()/resolveSideLane() extracted into src/server/side-request.ts as pure functions; server.ts wires them with the detect/strip effects still lazily short-circuited. resolveSideLane takes no fork input (the #2164 structural guarantee); demoteGate keeps the !publicForkPrefix veto. - tests/side-lane-truth-table.test.ts: exhaustive tables pinning both gates and the reason strings. - tests/side-lane-invariants.test.ts: observation-transparency, seeded ordering-fuzz vs main-only baseline, splitSessionWarnings unit. - Runtime canaries: post-lane SIDE-EFFECT LEAK counter on the session + /__bili/status splitSessions warnings (the #2165 shape). - ci.yml lane-guard job; new ci-e2e-dsh.yml dedicated dsh plugin lane.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2237-pr.2175.f757558This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2175.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 PR #2175 review 结论(对应原 issue #2170,五项加固措施) 验证了什么(不止读 diff):
结构化七问
测试有效性:真值表是对旧内联表达式逐字拷贝的参考公式做穷举对照——任何 conjunct/veto/reason 改动必翻 cell,断言有牙(唯一固有弱点:函数与拷贝的参考公式被同步修改时表仍会通过,已由 lane-guard 配对 + 人审缓解,可接受)。invariants (A)/(B) 是真服务器 + mock upstream,deterministic LCG(失败可从 seed 复现)、 diff 整洁度:7 文件 +501/−7,单一线性提交,每一行都服务于本 PR 目的,无 lockfile/version/空白噪音,分支命名合规,version 未动。 判定:可合。 措施 1/2/4/5 忠实实现 #2170 规格,equivalence 有穷举证明,CI 23/23 绿,rebase 干净。发现 A/B 都是 measure 4 canary 语义层面的跟进项(措辞/一行收紧级别),不阻塞本 PR;若 owner 认可,我可以直接在本分支补一个标注清楚的小 commit(措辞调整 + leak canary 收紧),或在 #2170 线程记为 follow-up。measure 3 的 golden fixture 按作者声明留在 #2170 跟踪。请 @ranxianglei 择机合并:#2175 |
…a forks; leak canary lane-eligible only Finding A (ework review): dsh auto-review classifyRisk forks onto |sub:<fp> BY DESIGN (#1916/#1307/#1314) and rides the child's main pipeline, so every healthy Auto-tier dsh conversation tripped splitSessionWarnings — the canary's most common production trigger would have been the designed state. Fix: requests deliberately namespaced onto a |sub: key (#970 claude subagents, #1916 dsh persona reviews, codex/claude-over-Responses instructions personas) stamp session.metadata.personaNamespace at resolution time; splitSessionWarnings skips marked sessions. Also widened detection to the #2165-reported shape itself (traffic-less raw twin + live fork now warns); only stale or fully idle groups stay silent. Finding B: the SIDE-EFFECT LEAK canary counted count_tokens / /responses/compact / session-less requests that legitimately route past the #388 lane — false diagnostic signal. Now fires only for lane-eligible side-shaped requests, making it a true structural assertion (unreachable by construction). Tests: unit table gains persona-marked / mixed-sibling / #2165-shape cases; new (D) integration proves a design persona fork stamps the child and keeps /__bili/status splitSessions clean. 16 suites, 134/134 green.
|
Review findings A and B both confirmed by code reading and repro, fixed in the latest push: A (split canary vs design persona forks) — real. B (leak canary false positives) — real. count_tokens / 16 suites 134/134 green locally (incl. new negative/positive canary cases + mixed-sibling case: a marked sibling must not hide a drifting twin). Chose provenance stamping over rewording because the mark also future-proofs #970 codex/claude persona splits, which share the shape. |
…ons dir Found while reviewing #2175: all four test-matrix jobs went red on this PR's merge commit with 'not ok - #2152 ... /__bili/overview answers 200' (got 500). Master itself (4af31e0) is red on the same jobs — pre-existing, not caused by this PR. Root cause: /__bili/overview walks the disk session store, and a missing sessions dir rejects loudly by design (#1937 pins 'no prior snapshot → reject, never silent empty'). The parity test never isolated BILI_SESSIONS_DIR, so on a fresh CI runner — where the ambient default state dir has never existed — the overview 500s. Dev machines always have the dir, which is why it only failed in CI. Reproduced locally by running the suite with HOME/XDG_DATA_HOME pointed at empty dirs: ENOENT scandir + 500 before the fix, green after. Fix: pin BILI_SESSIONS_DIR to a mkdtemp'd dir for the test's lifetime (restore + rmrf in finally). Test-only; no production behavior touched — the #1937 missing-dir contract stays exactly as pinned.
[bot] 🏷 第 2 轮 review(A/B 修复验证 + 新发现 C) A、B 两处修复已在代码级逐条核对并本地验证,结论:修法成立。另外本轮发现 CI 四个 test-matrix job 全红,排查后确认是 master 侧既有问题,非本 PR 引入,已按「小问题直接修」在 PR 分支补了一个 test-only commit( 1. 是什么问题 2. 什么原因导致的
3. 怎么修复的
4. 是否有回归问题 5. 是否破坏缓存 6. 是否改了设计方向 7. 是否引入了新的配置 行为变更披露(旧→新):
验证证据:定向套件 41/41 绿(e615575 上:truth-table、invariants、dsh-persona-fingerprint、fork-side-request-lane、side-request-isolation)+ web-sessions 14/14 + parity 在干净 HOME/XDG 下通过(即 CI 失败模式)+ 判定:可合(待 |
[bot] 🏷 CI 跟进(695f5c7):23/23 全绿 ✅
最终判定:可合。 合并由人操作:#2175 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.50-master.d5dfb37 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Implements #2170 (measures 1, 2, 4, 5 in full; measure 3's e2e lane ships, its recorded golden fixture stays the follow-up noted in the issue).
Why
The #2156 → #2157 → #2164 chain showed the side-lane decision (the
#388passthrough) is regression-critical but only guarded by behavior tests that happened to exist. #2157 shipped a fork-child pollution regression with every existing suite green — the fork-child title shape simply wasn't tested. This PR makes each layer of that failure mechanically harder to repeat.Measure 1 — pure lane gates (
src/server/side-request.ts)demoteGate(signals)— the seven cheap conjuncts of the heuristic demotion (was an inline conjunction insrc/server.ts).resolveSideLane(signals) → {lane, demoted, reason}— the#388lane decision + the three reason shapes.src/server.tswires them; the two request-body effects (detectAcpArtifactsfull-history re-encode,stripLeakedBiliToolsmutation) stay in the caller and stay lazily short-circuited behinddemoteGate— no hot-path behavior change.resolveSideLanehas no fork input — intent-certain side requests ride the lane under a fork receipt because there is no fork field to consult.demoteGatekeeps the deliberate!publicForkPrefixveto (early fork-child mainline turns false-positive the leak-shape heuristic).Measure 2 — truth tables + invariants (
tests/)side-lane-truth-table.test.ts: exhaustive tables (every signal combination) for both gates against reference formulas copied from the pre-dsh 回归防护:泳道判定真值表 + 侧请求不变量 + dsh e2e lane + 运行时金丝雀 + lane-guard(5 项) #2170 inline expressions; reason-string pins; the fork-veto cell and the fork-free side cell are explicitly asserted.side-lane-invariants.test.ts(real server + mock upstream, dsh anthropic wire): (A) observation-transparency — side requests hit the upstream but leavestats.requests,parentRevision, usage baseline and snapshot contents bit-for-bit unchanged; (B) ordering-independence — seeded LCG interleavings of 4 main + 3 side turns converge to the main-only baseline (exactly the ordering that manifested fix: side requests must not claim the persona namespace anchor (#2156) #2157's regression); (C)splitSessionWarningsunit table.Measure 4 — runtime canaries
SIDE-EFFECT LEAKcanary insrc/server.ts: today unreachable; any side-shaped request that reaches the full pipeline incrementssession.metadata.sideEffectLeaksand logs loudly.splitSessionWarnings()insrc/session.ts(the#2165failure shape: one conversation live under both the raw id and a|sub:fork). Surfaced as a newsplitSessionskey on/__bili/status(additive JSON) plus one rate-limited log line per base.Measure 5 — CI lane guard (
.github/workflows/ci.yml)New
lane-guardjob (PR-only,kernel-guardmechanics): lane logic changed (src/server/side-request.ts, or lane-symbol lines insrc/server.ts) without touching a dedicated side-lane suite → red with an explanatory message.Measure 3 — dedicated dsh e2e lane (
.github/workflows/ci-e2e-dsh.yml)e2e-dsh-plugin-lane: runs the 12 fork/side/dsh-shaped suites sequentially in one named check (paths-filtered). Follow-up recorded in #2170: capture a real dsh transcript as a golden fixture.Verification
tsc --noEmitclean./__bili/statusconsumers re-run green (advisory-panel, opencode-acp-command, acp-status, update-notes).Closes #2170 (fixture follow-up tracked there).