Repository navigation
feat: per-install rollout gating (registry, bucketing, nested cohorts) - #3104
Conversation
#3062) Adds src/rollout.ts: ROLLOUT_FEATURES registry (ships EMPTY — zero behavior change until adopters add entries), sha256 bucketing on a per-install UUID (persisted at stateDir()/rollout-id.json, config-pinnable), env>file>registry precedence, and nested base cohorts (A->B patterned rollouts) with cycle guards. New `rollout` config block + BILI_ROLLOUT_<FEATURE> env family, docs regenerated (en+zh), seeds for both doc gates, 21-test suite. Fixes #3062
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3566-pr.3104.97860a2This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3104.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) #3104 审核完成,结论:可合并(详见末尾 CI 判定)。八问:
CI 判定:head 3c4510f 共 35 项检查——31 绿(全部静态门 + 全部真客户端 e2e lane;codex lane 的一次 ETIMEDOUT 是 Windows runner 基础设施抖动,同 lane 在 master 上绿,我已触发重跑并转绿)。剩 4 红 = test ubuntu×2/windows×2,失败的全部是与 PR 无关的既有问题:storage-render 四个 golden 在 master 裸树上本就红(我在 master 上复现出相同 digest)。根因分层:#3093 把 收工判定:PR 自身表面全绿、零回归、规格符合性逐条通过;4 红 lane 属 master 既有缺陷(#3113/#3119)。建议直接合并;若想等全绿,先合 #3119 再 rebase 本 PR 即可。 |
Three user-facing traps found in review, all fixed:
1. Shorthand overrides were silently dropped: overrideFor only read
objects, so "simhashV2": true (force on) or "simhashV2": 20
(percent) — the shapes users naturally write first — became {}, the
config force silently vanished and the bucket kept deciding. The
shorthand forms are now accepted and equivalent to {enabled}/{percent}.
2. Wrong-typed fields ("enabled": "true", "percent": "100") failed
strict equality / percentBp and fell back to the bucket with zero
feedback. The startup warn now names every such entry (and non-object
entries, and unknown features) instead of only inert objects.
3. The derived-id fallback (unwritable state dir) hashed process.env
HOSTNAME — a bash-ism absent on Windows, so every affected Windows
box collided on one shared id and moved through cohorts in lockstep.
It now derives from os.hostname() + OS home (USERPROFILE) + user
name via the exported derivedInstallId().
Type widened honestly (features accepts boolean|number shorthands);
docs regenerated; 4 new tests (25/25 green), tsc clean.
Review 追加:三处"用户配置被静默吞掉"的陷阱 + Windows 修复(f582d4d)对 #3062 机制逐行 review 后发现:判定逻辑(优先级/单调性/嵌套/环)没有硬 bug,但存在用户以为打开了、实际静默没生效的三条路径,已直接修在本分支: ① 布尔/数字缩写被静默丢弃(最常见写法)用户自然写法 ② 类型写错静默降级
③ Windows 派生 id 全员撞车(state dir 不可写时的兜底路径)旧兜底哈希 类型与文档
验证
CI 全绿后可合;合入即修复上述三条,注册表仍为空、无行为变化。 |
…3104 review) Review follow-up on f582d4d: a number shorthand outside 0-100 (e.g. "x": 200) was accepted by overrideFor, rejected by percentBp, and skipped by the warn loop's blanket number bypass - silently OFF for unknown features, silent fall-back to the baked-in plan for registered ones, with zero feedback. Same silent-no-op class this commit set out to kill. warnRolloutConfigProblems now range-checks numeric shorthands and names them like every other ignored entry; tests pin the resolver fall-through (no cohort widening) and both warn/no-warn cases.
review) Review follow-up on f582d4d: os.userInfo() throws when the running uid has no passwd entry (common in containers) and os.hostname() can fail with ENOSYS on minimal hosts - both called inline inside the persist-failure catch, so an exception there escapes rolloutInstallId and takes the proxy down at boot. The whole point of the fallback is to never crash; degrade each lookup independently to "" instead.
(ai: vllm-qwen/qwen3.8-27b) f582d4d 逐行审完并独立验证。结论:三处修复方向与实现都正确,但我在同一条路径上找到两个残留漏洞,已直接修在本分支(两个独立小 commit: 对你三处修复的独立验证
回归清点(本轮 diff 触碰的既有行为,逐项)
验证(均在 46cd18d 由我实跑):rollout 套件 25/25 ✓(含我新增的越界断言:resolver 不扩 cohort + 警告点名/范围内不点名)、typecheck ✓、build ✓、unused-exports ✓。全量交给 CI——push 后 17 个 check-runs 已开跑,出结果我再补一句。 八问
判定:可合——机制主体与你这三处修复经独立验证成立,我又顺手堵了同路径的两个洞(越界数字静默吞掉、exotic host 启动崩溃)。CI 全绿后合并即可。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.402-master.6c78389 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Fixes #3062
What
New
src/rollout.ts— a per-install gradual-rollout engine:ROLLOUT_FEATURESregistry (ships EMPTY — zero behavior change in this PR; feature adopters add entries in their own PRs with the percent/salt/base they want).stateDir()/rollout-id.json(machine-global state, stable across releases; pinnable viarollout.installId; heals corrupt files in place; derived fallback when state dir is unwritable). Empty registry ⇒ the id file is never even created — strictly zero observable change.sha256(salt + "\n" + id)→readUInt32BE(0) % 10000basis points (BP_MAX=10000). Monotonic: enabled-at-X% stays enabled at every Y>X.basere-scopes a feature's bucketing to its parent's cohort, with visited-set cycle guards (cycles fail closed).BILI_ROLLOUT_<FEATURE>,0/false=off else on) > configenabled> config/registrypercent> OFF (unknown features fail closed).[rollout] install <id8> — feature=on/off(source, bucket b/10000 vs Nbp[, base X])line per feature when the registry is non-empty;warnInertRolloutEntries()warns on config entries that can't resolve (建议:compress.stripImages默认开启——否则带图消息不可压缩会形成只升不降的输入地板撑爆上下文 #2607 discipline).Config surface
rolloutblock —rollout.installId,rollout.features.<name>.{enabled,percent,salt,base}— plus theBILI_ROLLOUT_<FEATURE>env family (dynamic name, documented in the seeds with the expectedcheck-coveragenotice).src/knobs.tsis scalar env>file>default only (no nesting, no registry, no per-install identity);providers/compressare provider/model-scoped, not feature-boolean gating; nothing anywhere provides a stable per-machine install identity (native session ids are per-conversation by design).rolloutadded toFileConfig+KNOWN_TOP_LEVEL_KEYS(no unknown-key warning noise); seeds added towebsite/config-reference/rollout.yamlso both doc gates pass;CONFIGURATION.md/CONFIGURATION.zh-CN.md/website regenerated viatools/gen-config-docs.mjs.Testing
tests/rollout.test.ts— 21 tests: determinism/range, monotonicity, ~10% distribution over 4000 ids, salt reshuffle, precedence ladder (env>enabled>percent>registry), invalid-percent fall-through, nested cohorts (incl. 25%×50%≈12.5%, config base re-scope), cycle guards (self/x↔y) without hanging, deep chains, install-id persistence/pre-existing-file-wins/corrupt-heal/unwritable-fallback/config pin, inert-entry warnings.npm run typecheck✓, rollout suite 21/21 ✓,npm run build✓,check:unused-exports✓,gen-config-docs check-coverage+config-surface-guard✓.npm testtrees on one machine; documented as tests: two concurrent full-suite runs on one machine corrupt each other — need a per-machine suite lock (fail-fast) #3103).Not in scope
ROLLOUT_FEATURESentry (separate PR per feature, with its own percent/salt rationale).