Skip to content

[PR] chore(branch): land 14 single-purpose fixes as one history-preserving batch (waves 7+8) - #6758

Merged
ranxianglei merged 29 commits into
masterfrom
batch8-wave8
Nov 14, 2026
Merged

ranxianglei merged 29 commits into
masterfrom
batch8-wave8

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Supersedes #6723 and #6755 (which was accidentally merged into the batch7-wave7 branch instead of master). Head contains both waves: 14 of Afloat16's single-purpose fixes, each merged in with a real merge commit so every original commit and author is preserved in the first-parent history.

Wave 7:

| #6716 | 2026-11-14_linear-coverage-timestamps | #6715 | compression-receipt coverage times: the covered-id dedupe scanned the array per id (covered.some, O(n²) on stamped 20k-message folds) → Map, boundary-ref resolution and "never invent a range" semantics unchanged |
| #6718 | 2026-11-14_frozen-message-whitespace | #6717 | frozen-snapshot message re-parse stripped ALL trailing blank lines from every body (content at the end of a message was silently eaten) and lost the ref marker when a body started with a blank line → only the single separator newline before the next header is removed; leading/trailing blanks survive verbatim |
| #6722 | 2026-11-14_linear-cache-usage-alignment | #6721 | cache-diff usage alignment: each usage sample re-scanned every request from the back (O(samples×requests) on 10k-request logs) → single forward pointer over the two sorted lists, same 50 ms admission boundary and stable ordering |

Wave 8:

| #6725 | 2026-11-14_jsonl-historian-null | #6724 | historian JSONL export crashed on a stored content of literal JSON null (message.text on a non-object) → non-object rows now stay verbatim in full exports |
| #6727 | 2026-11-14_jsonl-ccr-originals | #6726 | full JSONL export dereferenced CCR placeholders to the indexed ENTRY metadata instead of the stored original bytes → resolve byRef→byHash, disk store fills gaps, corrupt/missing mirror keeps the placeholder |
| #6733 | 2026-11-14_join-message-content | #6732 | message readers decoded content with one content-store lookup PER ROW → metadata query stays separate, bodies fetched in bounded 500-row batches (sqlite JOIN for pointer reads, same on the mysql backend) |
| #6735 | 2026-11-14_keepalive-body-failures | #6734 | keepalive pings swallowed every resp.text() error (a 200 with a truncated/gzip-mangled body was treated as a normal miss) → body read errors now use the fail-streak budget, 429 keeps first-response disarming, an old response cannot spend the replacement snapshot's budget |
| #6739 | 2026-11-14_keepalive-rotated-timers | #6737 | credential rotation deleted the registry entry but never cancelled the scheduled ping — the dropped snapshot stayed referenced until its old cadence fired → disarm(..., "credential-rotated") |
| #6738 | 2026-11-14_cache-diff-insertion-boundaries | #6736 | cache-diff "mid-insert append" misclassified inserting a WHOLE message between existing ones as a semantic append (byte shape is identical) → require same element count with exactly one span growing by the insertion; growth before the root array now reports preArray divergence |
| #6742 | 2026-11-14_usage-log-attribution-tags | #6740 | usage-log parsing attributed samples to the new logger's [v=]/[sess=] tags (or a request scope) instead of the explicit session → strip logger tags, require the session tag directly before [acp-usage], never invent one |
| #6743 | 2026-11-14_nested-upstream-error-codes | #6741 | upstream alert errno extraction only read the outer error.code — native fetch failures nest the errno in cause → walk the cause chain (depth-capped, cycle-safe), outer nonempty code keeps precedence |
| #6747 | 2026-11-14_linear-fold-registration | #6744 | batch fold registration re-scanned the whole fold list to close open records per block (O(folds×blocks)) → closeFrom cursor; batch/individual parity kept |
| #6748 | 2026-11-14_linear-handoff-capture | #6746 | handoff reply metering re-encapsulated the entire accumulated text on every delta (O(n²)) → incremental byte accounting with surrogate-pair junction correction; exact UTF-8 budget boundaries kept |
| #6750 | 2026-11-14_diagnostics-unicode-bounds | #6749 | diagnostics truncation used plain slice, which can split a surrogate pair at the bound → safePrefix everywhere the bound applies (log tails, config, conflict detail, topic) |

Verification: as reported in #6723 and #6755 (per-PR added-line audits clean, tsc clean, 297 test assertions passing across all 14 touched test files on node 22.23.4 with the CI preload chain).

After this merges, the 14 source PRs become branch ancestors of master and close with their Closes keywords.

Closes #6715 #6717 #6721 #6724 #6726 #6732 #6734 #6736 #6737 #6740 #6741 #6744 #6746 #6749

Afloat16 and others added 28 commits November 14, 2026 20:09
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: batch8-wave8 (1d71c20)

Latest build — install this exact version

npm install -g billion-context@0.0.10023-pr.6758.20f615e

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

Recent builds (commit → version)

commit version build
1d71c20 billion-context@0.0.10023-pr.6758.20f615e build
35283ef billion-context@0.0.10013-pr.6758.d75998e build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title chore(branch): land 14 single-purpose fixes as one history-preserving batch (waves 7+8) [PR] chore(branch): land 14 single-purpose fixes as one history-preserving batch (waves 7+8) Nov 14, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

查重: 不重复 — 但发现一个需要处理的状态: 本 PR 是 waves 7+8 的合并批次 PR。它声明 Supersedes #6723 和 #6755。我核实了实际状态:

已完成的核查(初步):

正在进行: 逐文件审 13 个源文件的回归风险 + 13 个测试文件的有效性。完成后按八问体例给完整 review 结论。

… test

buildSessionCacheReport stamps generatedAt: Date.now() at build time. The
batch/individual parity test deepEqual'd two reports built 1ms apart, so it
flaked whenever the two builds straddled a millisecond boundary (CI red on
ubuntu 22/1 and windows 22/4: generatedAt ...904 vs ...905). Normalize
generatedAt to 0 before the comparison — it is a generation-time marker, not
part of the ledger/report parity being asserted. All ledger data already
matched; only the wall-clock field differed.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Review of batch8-wave8 — 14 single-purpose fixes (waves 7+8)

查重: Not a duplicate. This supersedes #6723 (batch7-wave7→master, still open — needs owner close, I can't close PRs) and #6755 (accidentally merged into batch7-wave7, already closed). All 14 source PRs (#6715 #6717 #6721 #6724 #6726 #6732 #6734 #6736 #6737 #6740 #6741 #6744 #6746 #6749) are open and auto-close on merge via their Closes keywords.

Structure verified: branch batch8-wave8 → master. 14 real merge commits (by ranxianglei) + 14 original fix commits (by Afloat16) — authorship preserved in first-parent history. 32 files +2331/−85. Test-merge vs current master: clean (no conflicts; master was 7 ahead: #6711, #6676).

Code review — all 13 source files verified, each fix is single-purpose and correct:

CI was red on 2 shards — diagnosed and fixed (not a code regression):

  • Both shards (ubuntu 22/1, windows 22/4) failed the same test: batches and individual calls produce identical complete ledgers and reports across usage samples (tests/cache-fold-registration.test.ts, new in this PR for the Batch cache-fold registration repeatedly rescans the complete ledger #6744 fix).
  • Root cause: a 1ms generatedAt flake. buildSessionCacheReport stamps generatedAt: Date.now() at build time; the test deepEqual'd two reports built 1ms apart, so it flaked when the builds straddled a millisecond boundary (CI: generatedAt …904 vs …905). All ledger data (folds/economics/totals) matched — only the wall-clock field differed.
  • Fix: normalize generatedAt to 0 before the comparison (it's a generation-time marker, not part of the parity being asserted). Committed + pushed to batch8-wave8 (new head 1d71c20d). Verified locally: 5 consecutive runs, all 10 tests pass, 0 fail.
  • CI is re-running on the fixed head (13 checks in progress at time of writing).

8问 (structured review):

  1. 是什么问题: 批量交付 PR,把 Afloat16 的 14 个单点修复(wave 7+8)以保留历史的批次形式合入 master。不是单个 bug,是 14 个独立修复的集合。
  2. 什么原因导致的: 不涉及(批量交付类)。14 个修复各自针对自己的根因(O(n²) 性能、导出崩溃、误分类、导出丢数据、定时器悬挂等),我逐一审核,根因定位都正确。
  3. 影响范围与严重程度: 触及存储读取路径、cache-diff、cache-keepalive、cache-ledger、export、handoff、stream、upstream-alerts、web 诊断/sessions-data。修复的都是真实缺陷(崩溃、误分类、导出丢数据、O(n²) 性能、定时器悬挂)。批次本身低风险——每个修复单点、已逐一审核。
  4. 怎么修复的: 每个修复单点、real merge commit 保留作者归属。我额外修了一个 CI 红的 flaky 测试(generatedAt 1ms 时间戳)——deepEqual 前把 generatedAt 归一化为 0,已 push 到 PR 分支。
  5. 是否有回归问题: 无。逐一审核 13 个源文件,全部行为保持或有意修复。关键核对:storage getContent 语义保持、缺 hash→'' 全变体保持、instrumentation 保留;acp-cache-diff 插入边界/用量对齐/日志归属均正确(有意变更已标注);cache-keepalive handleFailure 自守卫 stale entry、disarm 取消定时器;cache-ledger closeFrom 游标保持 batch/individual 对等;export null/非对象保持 verbatim、缺 CCR 镜像保持占位符(均有意);handoff 存储形状与阈值不变。
  6. 是否破坏缓存: 不破坏。cache-diff 与 cache-ledger 的修复实际改进了缓存计账正确性,无缓存失效策略变更。
  7. 是否改了设计方向: 没有。所有修复都在现有架构内。export CCR 导出从「元数据」改为「原文」是有意修复,非设计转向。
  8. 是否引入了新的配置: 没有。无新 env/config/默认值。

行为变更披露(有意,非回归): src/export.ts CCR 导出从「解析到索引 entry 元数据」改为「解析 byRef→byHash 原文」(#6726 修复目标);缺 CCR 镜像时从「导出空串」改为「保持占位符」(同为修复目标)。两处都是修复意图,已在上面标注。

判定: 14 个修复全部正确、行为保持(或有意修复);唯一 CI 红是 flaky 测试,已修并 push。新 head CI 转绿后即可合。待办:#6723 仍需 owner 关闭(我无权关 PR)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

CI update: now fully green on the fixed head 1d71c20d — 15 success + 15 skipped, 0 failures. The generatedAt 1ms flake fix resolved both previously-red shards (ubuntu 22/1, windows 22/4).

PR is ready to merge. Only remaining item: #6723 still needs owner close (I can't close PRs).

@ranxianglei
ranxianglei merged commit f21b601 into master Nov 14, 2026
54 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1199-master.f21b601 (rolling master tag).

npm install -g billion-context@0.0.1199-master.f21b601  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Louie0806 added a commit to Louie0806/billion-context that referenced this pull request Nov 14, 2026
…fted-name-leak

Syncs the lane onto master f21b601 (PR ranxianglei#6758, batch8-wave8: 30 commits,
32 files). One file overlapped with the lane and auto-merged cleanly:

- src/storage/mysql.ts: upstream batched the `content` hydration in
  `readMessagesWithHashes` behind a CHUNK of 500 and inlined the bytes into the
  metadata SELECT via `LEFT JOIN content c`. The lane's only touch there is the
  `export` on MYSQL_SCHEMA_VERSION (consumed by the migration-dedup test), which
  survives unchanged at line 77.

Verified on the merged tree: kernel build 0, tsc --noEmit 0 errors, all five
gates 0, config-docs fixed point holds (no drift), and the suites are green
(issue5175 66/0, tag-echo 79/0, issue2190-degen-close 32/0,
issue3905-announcement-tail 19/0, issue2303-draft-tail 14/0,
notice-registry 5/0, persist-zstd 17/0, plugin-fork 58/0).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment