Repository navigation
fix(storage): drop better-sqlite3 optional dep (#2823) - #2825
Conversation
… contract (#2823) pnpm >=10's strict build-script gate (strictDepBuilds) blocks any unlisted install script as a hard error, so dsh plugin-market installs/updates on fresh profiles failed with [ERR_PNPM_IGNORED_BUILDS] better-sqlite3. Unified storage is OFF by default (legacy file persistence), so dropping the optional native engine is low-impact: the driver already prefers built-in node:sqlite when the native module is absent, and when no engine is available at all UnifiedShadow.maybeOpen degrades to legacy-only (one warn, never bricks). - package.json / package-lock.json: remove better-sqlite3 (sharp stays). - src/storage/driver.ts: add setSqliteEnginesUnavailableForTests seam so tests force the "no engine" path deterministically; keep the opportunistic require("better-sqlite3") probe for hosts that still ship it. - tests/storage-engine-proofs.test.ts: pin the contract -- maybeOpen -> null; SessionStore runs legacy-only, writes survive, no index.db. - CHANGELOG.md: [Unreleased] entry. Gates green on this head: typecheck + targeted storage tests + build. Closes #2823
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3131-pr.2825.767a6a4This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2825.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…e3 dep drop (#2825 review) The line still said 'better-sqlite3 primary, node:sqlite fallback'; after the optional dependency was removed in this PR, fresh installs always run on the built-in node:sqlite engine, with the native module used only opportunistically when a host already has it. Also fixes the zh typo 兑底 -> 兜底 in the same span.
[bot] 🏷 PR #2825 审查完成 — 代码核对通过,本地定向验证全绿,可合(CI 转绿后) 拉取分支逐行核对了 1. 是什么问题 2. 什么原因导致的 3. 影响范围与严重程度 4. 怎么修复的 5. 是否有回归问题
6. 是否破坏缓存:不涉及(不动压缩/前缀缓存/会话身份任何机制)。 7. 是否改了设计方向:不涉及。存储架构不变,只是收缩了可选引擎的声明面;"探测保留、缺失降级"的既有分层原样工作。 8. 是否引入新配置:无。唯一导出是测试缝 本地定向验证记录(PR head,Node 22,better-sqlite3 确实未装):
顺手小修(独立 commit CI 状态:审查时 kernel-guard / version-guard / lock-sync / config-surface-guard / lane-guard / unused-exports / pi-subagents-guard / docs-sync / docs-coverage / e2e / real-codex persona-continuity 均已 success,其余在跑,无 failure; 判定:内容正确、范围干净、契约钉死,CI 转绿后可合。 合并后按 PR 所述走标准流程发 v0.1.194(纯版本 bump),发布到 npm 才是对报告者更新失败的最终解决。合并由人来操作:#2825 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.293-master.e0f4c0c # this exact build
npm install -g billion-context@master # always the newest merged build
|
…f-download (#2833) Engine acquisition no longer depends on host install-time build-script approval (the strictDepBuilds gate behind #2823/#2825): - detectEngine order: built-in node:sqlite (Node >= 22.5) -> host better-sqlite3 require probe -> registered self-downloaded loader -> none (legacy-only per the #2825 contract) - new src/storage/engine-bootstrap.ts: one-time download of the pinned better-sqlite3 13.0.3 npm tarball (in-tarball N-API prebuilds for all 8 platform-arch targets, no build scripts), sha512-pinned in-repo, extracted via a dependency-free gunzip+ustar reader into <cache>/sqlite/better-sqlite3-<version>, atomic publish, 6h cooldown after failure, proxy-aware via the existing network.proxy chain - storage.sqliteAutoDownload (default true) / BILI_SQLITE_AUTO_DOWNLOAD gate the network fetch only; a cached copy is used even when false - wired into bili start before the first store open (bounded ~10s); enablement log now records engine/source for field diagnosis
resolveStorageMode now lands on 'shadow' when neither storage.unified nor BILI_STORAGE_UNIFIED is set: the JSON envelope stays the sole source of truth (zero behavior change) while every session write is mirrored into index.db with digest reconciliation — fleet-wide parity telemetry before the full-mode default flip. Explicit legacy opts out; garbage still degrades to legacy; engine-less lanes stay legacy-only (#2825 contract). The test corpus runs on an explicit legacy baseline (tests/preload-storage-baseline.mjs wired into npm test and scripts/run-ci-tests.mjs) so the 600-suite wire/e2e corpus keeps its legacy dir-shape assumptions; the storage family pins and overrides its own modes, the resolveStorageMode matrices pin the new default, and the web-sessions stamp test now asserts shadow for absent-everywhere.
What
Remove the
better-sqlite3optional dependency and pin the "no SQLite engine available" degrade contract with regression tests.Why (root cause)
Fresh dsh plugin-market installs/updates of billion-context fail on pnpm ≥10 with:
pnpm ≥10 enables a strict build-script gate (
strictDepBuildsdefaults true): any dependency shipping an install/build script is blocked unless explicitly allowed in the project allowlist, and an unlisted script is a hard install error. dsh's plugin manager runs pnpm non-interactively with a fixed allowlist covering only its own native deps, never third-party plugin deps — sobetter-sqlite3(which needs its postinstall to fetch/build its native binding) is unlisted → hard error → dsh reports the update as failed. The deeper defect is dsh-side (an optional dep treated like a required one instead of skipped gracefully); that is tracked separately and deferred per owner.Why removing it here is safe (compat tested)
storage.unified.node:sqlitewhen the native module is absent (src/storage/driver.ts).UnifiedShadow.maybeOpendegrades to legacy-only with one warn and never bricks construction (src/storage/shadow.ts) — same contract as [Bug][storage] corrupt index.db bricks SessionStore construction in shadow/full mode (violates the sidecar never-breaks-legacy policy) #2771.UnifiedShadow.maybeOpen→null;SessionStoreruns legacy-only, writes survive, and noindex.dbis created (tests/storage-engine-proofs.test.ts). Verified on Node 22 (wherenode:sqliteexists) using a test seam to force the no-engine path deterministically.require("better-sqlite3")probe is kept, so hosts that still have the native module keep using it.Behavior change (flagged)
better-sqlite3shipped as anoptionalDependenciesentry; hosts whose package manager allowed its build script used the native SQLite engine, everyone else already fell back to built-innode:sqlite.better-sqlite3is no longer declared; fresh installs always use built-innode:sqlite. Hosts that already have the native module installed keep using it via the retained probe.index.dbworkload, and the unified store is off by default.sharpis left untouched: it ships prebuilt binaries (no build-script gate trip) and was not part of the reported error.Gates
Green on this head:
typecheck, targeted storage tests (no SQLite engine | CAS refcounts | corrupt index.db→ 4/4), andbuild(dist self-contained; probe retained). Full suite + e2e left to CI.Release
This is the content fix. A standard-flow release v0.1.194 follows after merge (version bump only) — publishing it to npm is what resolves the reporter's update failure.
Closes #2823