Repository navigation
[PR] fix: route the fork lane through the network storage backend (#4911) - #4924
Conversation
The MySQL full-mode fork lane never reached the unified backend: UnifiedShadow's sync facades (lastLiveSeq/cloneSessionRows) return miss values when sync === null, so MysqlBackend's ready-made twins had no callers. The fork endpoint is async, so wire it through new async twins following the established viaAsync pattern: - shadow: lastLiveSeqAsync / cloneSessionRowsAsync (sqlite delegates to the identical sync bodies; mysql routes through the backend on the serial queue; a failed/disabled sidecar degrades to the kernel-only fork and never fails the fork) - persist: unifiedLastLiveSeqAsync / unifiedCloneSessionRowsAsync replace the now-orphaned sync wrappers - plugin: handlePluginFork awaits them (the withSessionLock callback becomes async; lock scope and ordering are unchanged) - store/backend: UnifiedStore.cloneSessionRows reports false for an absent parent (SqliteBackend no longer resolves an unconditional true — matches MysqlBackend semantics) Tests: the contract suite gains a fork-clone block in both lanes (inclusive throughSeq, seq/msgId/hash fidelity, lineage columns, per-row refcount bump, idempotent replay, absent parent -> false); the mysql e2e proves the awaited clone lands real rows and that the sync facades still miss by design. Docs: the storage.backend rows list fork among the async-twin paths (seeds + generated md en/zh).
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6406-pr.4924.b394ab2This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4924.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…qlite twin relies on (#4911) mysql-contract CI caught ER_NO_DEFAULT_FOR_FIELD at MysqlBackend.cloneSessionRows: the fork row clone's 5-column sessions INSERT leans on column defaults exactly like the sqlite twin (schema.ts: meta_json TEXT NOT NULL DEFAULT '{}'), but the mysql DDL never gave those five json columns defaults — tables created by the pre-wiring DDL reject the clone in strict mode. Align the DDL and heal existing tables idempotently (information_schema probe + MODIFY, the #4390 pattern).
|
(ai: zhipuai-lb/glm-5.3) 深审通过 + 已推一个修 CI 的增量提交(edc2185)。 本 PR 的接线方案我逐项核过: CI 红的根因(mysql-contract:ER_NO_DEFAULT_FOR_FIELD):孪生分歧——克隆的 5 列 sessions INSERT 依赖列默认值,SQLite DDL 给了(schema.ts:118-122 增量提交 edc2185:DDL 五个 json 列对齐 遗留(不阻塞,已在 #4911 记录):MySQL 克隆的幂等 COUNT 检查仍在事务外——并发重复 fork 撞 PK 回滚后走 kernel-only 降级,数据正确只是降级,与 SQLite 侧(事务内检查)不一致,后续可顺手对齐。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.878-master.c499b14 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #4911
What this fixes
In MySQL full-mode deployments the fork endpoint's unified-store row clone (and its inclusive throughSeq bound) never reached the backend:
UnifiedShadow's sync facades return miss values whensync === null(network backends), soMysqlBackend.cloneSessionRows/.lastLiveSeqhad no callers. Fork children on mysql silently ran kernel-only with an empty unified transcript.Approach
The fork endpoint (
handlePluginFork) is async, so it now awaits new async twins following the establishedviaAsyncpattern:shadow.ts:lastLiveSeqAsync/cloneSessionRowsAsync— sqlite delegates to the identical sync bodies (zero behavior change); mysql routes through the backend on the serial shadow queue; a failed/disabled sidecar degrades to the kernel-only fork (the fork itself never fails for a storage nicety — existing contract).persist.ts:unifiedLastLiveSeqAsync/unifiedCloneSessionRowsAsyncreplace the sync wrappers (now orphaned; removed rather than left as dead code).plugin.ts: fork block awaits them; thewithSessionLockcallback becomes async (it accepts() => T | Promise<T>), lock scope and ordering unchanged.store.ts+backend.ts:UnifiedStore.cloneSessionRowsreportsfalsefor an absent parent;SqliteBackendresolves that value instead of an unconditionaltrue(previously inconsistent withMysqlBackend, which returns false).Sync window reads (
messagesForIds/uncoveredRows/messageIdRows) stay miss-by-design on network backends: their callers are the four prepare-* lanes' sync hot paths and snapshot render; routing them would be a pipeline rearchitecture decision, out of scope here (degradation to JSON envelope / legacy render is safe and documented). Same mechanism family as this issue — kept in one issue, not split.Fixed in passing (labeled): the stale mysql selection notice in
backendSelectionNoticestill claimed the hot path "stays on sqlite until then" (step 3 landed in #3931).Behavior changes (old → new)
SqliteBackend.cloneSessionRowsresolvedtrue→ nowfalse(matches MysqlBackend; the fork debug log line now fires honestly in that case).storage.backend="mysql": reworded to describe the current wiring (log text only).Config surface
No fields added/renamed/re-semantics'd. Description-text updates only for
storage.backend/BILI_STORAGE_BACKEND(fork added to the async-twin path list) — seeds updated and md regenerated (tools/gen-config-docs.mjs, en+zh).Tests
tests/storage-backend-contract.test.ts: new fork-clone contract block — sqlite lane always runs; mirrored into the mysql lane (CI runs the mysql:8.0 service): inclusive throughSeq, per-row seq/msgId/contentHash fidelity, lineage columns, per-row refcount bump, idempotent replay, absent parent → false.tests/storage-backend-mysql-e2e.test.ts: awaited clone lands real rows on real MySQL (read back through another async twin); regression guards pin that the sync facades still miss by design.