Skip to content

test: cover chain-detection disk branches — loadSync restart ownership, BILI_CHAIN_CONTENT parsing, warn-set FIFO - #1174

Closed
ranxianglei wants to merge 1 commit into
masterfrom
2026-09-23_chain-disk-coverage-tests
Closed

ranxianglei wants to merge 1 commit into
masterfrom
2026-09-23_chain-disk-coverage-tests

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #1101

What

#1090's four integration tests all injected _setStoreForTest(new SessionStore({ enabled: false })), leaving three disk-adjacent branches of the chain-detection content fallback with zero coverage. This adds tests/issue1101-chain-disk-coverage.test.ts with exactly the three tests the issue asks for:

  1. store.loadSync restart path — persisted-then-restart integration: real SessionStore({enabled:true}) over a temp dir → plain request creates state → flushAllSessions() → _resetSessionsForTest() (simulated restart, memory empty, disk intact) → the same conversation re-sends the [Bug] 链检测把 bili 自己注入的 ACP 产物判成 bili→bili 链 —— 压缩内核永久跳过,长会话撞 1,048,576 上限 400(v0.1.133 回归) #1086 artifact body → asserted processed, not byte-identical passthrough, zero [chain] warns, session resurrected via loadSync. This is the auto-update-restart ownership path from [Bug] BILI_PERSIST=0 重启后自己的会话被永久判为 bili→bili 链(#1086 残留,#1090 随附) #1100.
  2. BILI_CHAIN_CONTENT env parsing — loadOptions({}) default-on; =0 disables; file chainContentDetection:false honored when env unset; env =1 wins over file. Deterministic via BILI_CONFIG_FILE pointed at a temp dir.
  3. warn-set FIFO eviction — pre-seeds the live warnedChainSessions set to exactly WARNED_CHAIN_SESSION_CAP (4096), fires one real foreign-artifact request through the server, asserts: oldest entry evicted, size stays capped, the triggering session still gets its exactly-one warn.

Finding worth noting

While writing test 3 I confirmed a design detail the tests now document: server.ts seeds artifactSeed only when getStore().enabled — with persistence disabled the content fallback is OFF entirely ("no local state" cannot distinguish a foreign chain from this instance's own session after a restart, so processing is the safe default). The FIFO test therefore runs an enabled store over an empty dir, same as T3 in issue1086-chain-self-exemption.

Verification

  • New file: 3/3 pass.
  • Full suite: 2261 tests, 2259 pass / 0 fail / 2 skipped (pre-existing e2e gates).
  • npm run typecheck clean.
  • Single commit, tests only — no src changes.

…p, BILI_CHAIN_CONTENT parsing, warn-set FIFO (#1101)

Fixes #1101
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-23_chain-disk-coverage-tests (9869ab8)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-1174

Each push to this PR publishes a new version under the pr-1174 npm tag.

Option B — Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

[bot] 🏷 Closing as duplicate.

The three branches this PR covers are already covered on master since #1090 merged (2026-09-22, merge commit ecc7bb1): tests/issue1086-chain-self-exemption.test.ts:525,591,636 — "#1101 T7" (persisted-then-restart, disk branch of hasProcessedState, fresh store instance + boot()), "#1101 T8" (warn-set FIFO eviction at cap 4096), "#1101 T9" (BILI_CHAIN_CONTENT env parse incl. env-over-file precedence). They were written for issue #1101 and shipped inside #1090's branch because the code under test only existed there.

Line-by-line comparison against this PR's diff: same three scenarios, same assertions, no unique branch or edge coverage. This PR's base (master b2f28c6) already contains T7-T9 and the _chainWarnSetForTest / WARNED_CHAIN_SESSION_CAP exports this file imports — the duplication predates the PR.

Only difference: the restart test here resets memory on the SAME store instance, while master's T7 swaps in a fresh SessionStore + boot() — the latter exercises cold-start loadAll discovery, the faithful auto-update-restart model. Keeping one canonical copy (the stricter one, already merged) avoids double-maintaining the same branch coverage.

If you believe there is a scenario T7-T9 miss that this file catches, point at the specific assertion and I will fold it into the canonical file.

中文摘要:这三个分支的覆盖已随 #1090 合入 master(T7/T8/T9),本 PR 与之逐行重复且无独有断言,按查重规则关闭。

@ranxianglei ranxianglei added the duplicate This issue or pull request already exists label Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Test] 链自证磁盘分支零覆盖:store.loadSync 重启路径 / BILI_CHAIN_CONTENT 解析 / warn-set FIFO 淘汰均未测(#1090 随附)

1 participant