Skip to content

[PR] chore(batch): land 7 open BBleae fixes in one history-preserving batch - #6455

Merged
ranxianglei merged 9 commits into
masterfrom
bbleae-dry
Nov 12, 2026
Merged

ranxianglei merged 9 commits into
masterfrom
bbleae-dry

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

chore(batch): land 7 open BBleae fixes in one history-preserving batch

Lands 7 of the 8 currently-open PRs from contributor @BBleae as a single,
reviewable batch. Every commit is cherry-picked with its original author, date and message
intact
(git cherry-pick -x appends a Cherry-picked-from: <upstream sha> trailer, so each
commit is individually attributable and can be dropped by the maintainer with an interactive
rebase if any one is ever disputed). The source PRs stay open and untouched until this merges —
after merge they will be closed as superseded.

Each change was line-by-line reviewed against the surrounding code (not just CI): storage
refcount/sweep semantics, the kernel's block-ops bounds, the pnpm lockfile format, and the
SQLite pragma ordering were all checked by hand.

Held out of this batch: #6353 (dsh in-history system prompt as a durable carrier) is a
larger behavior change — a new fifth durable/* identity that alters what may fold — and is
being reviewed separately on its own PR before landing.

What's in it (7 PRs, 9 commits)

PR Fix
#6314 dsh-ledger: ignore the pnpm peer-resolution suffix (1.2.3(@types/node@…)) when comparing lock versions, keep it verbatim when rewriting — lock comparison no longer oscillates
#6315 acp_rewrite held to the same bounds compress enforces (min/max summary length + net shrink, with the "never block an improvement" exception); numeric blockId accepted
#6316 advisory reason and release-note summary/summaryZh from remote documents are flattened to one line and capped (80/500/400 chars) at parse time; the publish side mirrors the caps
#6318 a failed archive sweep no longer leaves a JSONL line for a still-active session (append moved inside the sweep transaction, sqlite + mysql twins); restore takes the newest line for a session; warns when duplicates exist
#6322 the dsh desktop copy updating itself in place now arms the boot smoke like the other lanes (#2082 follow-up: a package that loads-but-throws was previously swapped in after passing only node --check)
#6324 PRAGMA auto_vacuum = INCREMENTAL now set BEFORE journal_mode = WAL — a brand-new index.db really gets INCREMENTAL (SQLite only honors auto_vacuum while the file is still empty)
#6331 the one-time ref/ledger alignment (#5608-D/#4316) is armed only after a compress actually created a block — a refused/no-op compress no longer rewrites every <acp> tag's time= attribute on the next save

Verification:

Notes:

To remove an individual fix from this batch: interactive-rebase out the commit(s) whose
Cherry-picked-from: trailer matches the upstream SHA; every fix is self-contained.

Closes #6306
Closes #6317
Closes #6319
Closes #6320
Closes #6321
Closes #6323
Closes #6330

BBleae and others added 9 commits November 12, 2026 22:36
…ions and keep it when rewriting

pnpm appends a peer-resolution suffix to an importer's resolved version
when the package or one of its dependencies has a satisfied peer:
`version: 0.1.213(@types/node@16.9.1)`. The ledger code took the whole
scalar for the version. A healthy profile was reported as copy-vs-lock,
and convergence (`bili doctor --fix`, the pass after an in-place update)
rewrote the line to the bare version: a write where nothing had drifted,
leaving the importer without the suffix its snapshots key carries.

- splitPeerSuffix(): split the scalar at the first "(".
- readPnpmLockResolution returns the version without the suffix, so the
  state and the findings carry a plain version.
- patchNestedEntries compares the version part only; when the version
  really moves it swaps that part and keeps the suffix and the quoting
  the line already had.
- tests/issue3496-dsh-ledger-convergence.test.ts: v9 fixture with a peer
  suffix; healthy triple gives no finding and zero writes; real drift
  changes only the two importer lines and keeps the suffix; multi-peer,
  quoted and v6-v8 nested shapes.

packages:/snapshots: stay untouched as before (#3509, #3570).
(cherry picked from commit 9ae09b3)
…ccept a numeric blockId

acp_rewrite only checked "non-empty" and "not identical", so it stored
summaries compress refuses for the same block: over
compress.maxSummaryLength, under compress.minSummaryLength, or larger than
the content the block folded. The stored summary rides in the resident view
on every request, so a block could end up costing more than the messages it
replaced.

executeAcpRewrite now judges each rewrite before the kernel call:
- compress.minSummaryLength / maxSummaryLength of the resolved config
  (0 or absent = unbounded, as in compress), with compress's wording;
- net shrink: a summary not smaller than the folded content
  (compressedTokens, defaultCountTokens) is refused, unless it shrinks the
  summary it replaces;
- unknown/inactive ids and blank or identical text keep the kernel's
  existing reasons; in a batch the other items still land.

blockId also accepts a non-negative integer (single form and items), the
way acp_retire / acp_restore already do; before, a number was read as a
missing argument.

Host-side only; kernel/** is untouched. Docs line for compress.blockOps
updated in both languages.

(cherry picked from commit 8cffeaf)
…vement' exception (#6319)

The net-shrink refusal in executeAcpRewrite has an exception: a rewrite that
shrinks the summary it replaces is always allowed, even when the stored summary
was already larger than the folded content. The PR's two new tests cover the
refusals (too long / no net shrink / too short) and the numeric blockId, but not
this exception branch. Add a case that pins it so a future tightening of the
check cannot silently start refusing bloat cleanup.

(cherry picked from commit 59d1e98)
…mote reason/summary

acp_status prints an advisory's id + reason on its CRITICAL ADVISORY line
and one line per release-note summary under CRITICAL UPDATE, straight
into model context. Both parsers kept that text as-is apart from a trim:
no length cap, line breaks preserved.

Bound it where the documents are parsed (boundedLine in text-safe.ts):
whitespace / control runs become one space, over-long text is cut on a
code-point boundary and ends in an ellipsis. Entries are kept, never
skipped. Caps: summary / summaryZh 400 (the producer-side contract),
reason 500, id 80. Text inside the bounds is unchanged.

(cherry picked from commit d5248f1)
…g the client caps (#6306)

The release-notes workflow already rejects summary/summaryZh over 400 chars
at publish time; the advisories workflow had no length check at all, so an
over-long reason/id would ship and only get truncated client-side (and the
truncated id would then collide in the per-process warn dedupe). Same
mechanism as the client caps in this PR — one producer-side mirror, same
numbers (id 80, reason 500).

(cherry picked from commit 7b7b337)
…matching entry

archiveSession appended the session's export line to archive.jsonl and
only then ran the sweep transaction. When the sweep failed (write lock
held by another process past busy_timeout, a constraint error), the line
stayed in the log while the session stayed active and kept growing. The
next successful archive appended a second line; restoreArchived took the
first matching line, i.e. the stale one, and then removed every line of
that session, so the newer export was lost. Each failed attempt (gc
retries included) also added another full copy of the session to the log.

- archiveSession (sqlite + mysql): serialize the line before the sweep,
  append it as the last step inside the sweep transaction. A sweep that
  cannot start or fails midway writes nothing; the line is still on disk
  before COMMIT, so a committed sweep always has its export.
- restoreArchived (sqlite + mysql): scan the log from the end so the
  newest line of a session wins, and warn when more than one line of
  that session is dropped. Logs written by earlier versions can already
  hold such pairs.
- tests/storage-archive-failed-sweep.test.ts: 4 cases (failed sweep
  leaves no line and the later archive restores in full; newest line
  wins; both for sqlite and for the mysql backend on a stub driver).

(cherry picked from commit 047da26)
…elf in place (#2082)

The #2082 boot smoke (PR #2091) was wired into refreshDshDesktopCopy only,
the lane where another bili process refreshes the dsh desktop profile copy.
When the running proxy IS that copy, hostManagedInstall exempts the layout
(#1575) and the copy updates itself through the plain self-update lanes:
checkForUpdate (periodic check, `bili update`) and forceInstallVersion
(advisory force-install, web-panel install). Both called installViaTarball
without bootSmoke, so a tarball whose entry parses but throws at load was
swapped into the copy dsh respawns its plugin from.

Arm the smoke on both lanes when the install dir is the dsh desktop copy.
Other install layouts keep their current behaviour.

(cherry picked from commit 4e7ac09)
…eally gets INCREMENTAL

SQLite only honours PRAGMA auto_vacuum while the database file is still
empty. storagePragmas() switched to WAL first, which already writes
page 1, and issued auto_vacuum = INCREMENTAL last, so every newly created
index.db kept auto_vacuum = 0. PRAGMA incremental_vacuum
(gc({vacuum:"incremental"}), `bili storage gc --vacuum incremental`,
?vacuum=incremental) then reclaimed nothing: the freelist only grew and
the file never shrank without the offline full VACUUM.

- storagePragmas(): auto_vacuum is now the first pragma, with a comment
  on why it has to stay there.
- gc() doc comment: describes what incremental does and when it is a
  no-op (comment only).
- tests/storage-auto-vacuum.test.ts: pragma order; a new index.db reads
  auto_vacuum = 2; fill, delete, gc(incremental) empties the freelist and
  shrinks the file; a file created the old way stays at 0 until one full
  VACUUM converts it.

Existing databases are not migrated: on a non-empty file the pragma only
takes effect at the next full VACUUM.

(cherry picked from commit d5a52e0)
applyRanges set session.pendingLedgerAlign right after committing the
kernel's returned state, before the blocksCreated === 0 returns. A refused
compress (range too small, cannot anchor, already compressed) and the no-op
class armed the one-time #4316 alignment too, so the next save ran it after
a call that folded nothing.

Set the marker past those returns. A compress that created a block arms it
exactly as before (#5608-D).

(cherry picked from commit b3286db)
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: bbleae-dry (ad3cb8d)

Latest build — install this exact version

npm install -g billion-context@0.0.9346-pr.6455.8c49e2a

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
ad3cb8d billion-context@0.0.9346-pr.6455.8c49e2a build
3ef9020 billion-context@0.0.9341-pr.6455.ca92e0a build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title chore(batch): land 8 open BBleae fixes in one history-preserving batch [PR] chore(batch): land 8 open BBleae fixes in one history-preserving batch Nov 12, 2026
@ranxianglei ranxianglei changed the title [PR] chore(batch): land 8 open BBleae fixes in one history-preserving batch chore(batch): land 7 open BBleae fixes in one history-preserving batch Nov 12, 2026
@ranxianglei ranxianglei changed the title chore(batch): land 7 open BBleae fixes in one history-preserving batch [PR] chore(batch): land 7 open BBleae fixes in one history-preserving batch Nov 12, 2026
@ranxianglei
ranxianglei merged commit 259cd87 into master Nov 12, 2026
94 of 95 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1181-master.259cd87 (rolling master tag).

npm install -g billion-context@0.0.1181-master.259cd87  # 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.

ranxianglei added a commit to Louie0806/billion-context that referenced this pull request Nov 14, 2026
(cherry picked from commit a7fe295)

The code half of that commit was already on master via ranxianglei#6324/ranxianglei#6455, so
only the regression test is added here.
ranxianglei pushed a commit that referenced this pull request Nov 14, 2026
…merge commit

These files (issue-number lists recording the superseded closings of the
previous four batches #6439/#6455/#6464/#6482) are present in neither
parent of the #6574 merge commit yet appear in its result, and survive to
the branch tip. They are not part of any source PR, are referenced
nowhere, are not mentioned in the PR description, and the previous four
batch merges never committed such files to master. Process scratch data
does not belong at the repo root; the closing record already lives in
GitHub history.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][update] dsh desktop copy does not run boot smoke test during self-update; packages that throw errors on load get s | [Bug][update] dsh 桌面副本自更新时不跑 boot smoke,加载即抛错的包会被换进去(#2082 后续) [Bug][dsh] dsh-ledger treats the peer suffix after the version in pnpm lockfile as part of the version: healthy profiles | [Bug][dsh] dsh-ledger 把 pnpm lockfile 里版本后面的 peer 后缀当成版本的一部分:健康的 profile 被报 copy-vs-lock,bili doctor --fix 还会改写 lockfile [Bug][blockOps] The summary stored by acp_rewrite is not subject to compress's length min/max bounds or net-shrinkage ch | [Bug][blockOps] acp_rewrite 存进去的摘要不受 compress 的长度上下限和净收缩检查约束;blockId 不接受数字 [Bug][storage] Stale entries remain in archive.jsonl after a failed archive sweep; subsequent restore picks up the stale | [Bug][storage] 归档清扫失败后 archive.jsonl 留下过期行;之后恢复会拿回过期的导出、丢掉较新的那份 [Bug][advisory][update-notes] Remote reason / summary has no length limit, preserves newlines, and is passed into ac | [Bug][advisory][update-notes] 远程的 reason / summary 不限长、保留换行,原样进到 acp_status(模型上下文)

2 participants