11 Commits
Author SHA1 Message Date
ci-check 231d22d635 docs: document hermetic preload for bare targeted test runs (#5107)
Supplement to the hermetic-data-roots fix: bare targeted runs outside
npm test do not load the preloads on their own; document carrying the
preload explicitly so they resolve throwaway roots instead of the
production tree.
2026-10-29 16:53:30 +08:00
ci-check 659995d172 fix: keep test suite off the production sessions dir (#5107)
Running the repo test suite locally on a machine that also has bili
installed leaked test sessions into the developer's real sessions tree
(and its index.db): child processes spawned by e2e tests inherit the
ambient env and resolve the default data roots to the user's own
directories.

Two layers, both under existing test-infra seams:

1. tests/preload-test-env.mjs — global --import preload (same pattern as
   preload-storage-baseline.mjs) that unconditionally redirects the
   ambient BILI_SESSIONS_DIR / BILI_CONFIG_FILE / XDG_* roots to a
   per-test-process mkdtemp root. Wired into scripts/test-suite-lock.mjs
   realSuiteArgs(), scripts/run-ci-tests.mjs PRELOAD_ARGS, and the
   test:e2e* npm scripts (the codex e2e suites are exactly what
   polluted the tree).

2. Leak guard in scripts/test-suite-lock.mjs run-mode: snapshot the
   production sessions dir before the suite, diff after. NEW files fail
   the run with a banner; modified pre-existing files only warn (a
   concurrently live bili instance can touch its own sessions mid-run).
   Escape hatch BILI_TEST_LEAK_GUARD=0, documented in
   reference/env-vars.md next to BILI_TEST_FORCE.

Regression coverage in tests/test-suite-lock.test.ts: unit tests for the
snapshot/diff/message primitives, a probe proving the preload rewrites
src/paths.ts defaults before any user code runs, and CLI end-to-end runs
via the BILI_TEST_SUITE_CMD seam (leak -> red, clean -> green+silent,
pre-existing modification -> warn-only, escape hatch honored).

Behavior change (disclosed): `npm test` now redirects the ambient
data-root env for every test process — tests relying on the developer's
real XDG/HOME-resolved defaults get a hermetic root instead — and a
green run can turn red if NEW files appear in the production sessions
dir during it. New env var: BILI_TEST_LEAK_GUARD (test-infra escape
hatch only, unset = guard enforced).
2026-10-29 16:53:30 +08:00
ework-agent f53028c6e3 test: sandbox suite default dirs in the storage baseline preload
Suites that build stores/servers without pinning a directory resolve
through the XDG defaults into the developer's real ~/.local/{share,state,
cache}/billion-context — envelopes, index.db rows, and state bookkeeping
land beside production data (found triaging #5082: a local run of
tests/anthropic-cache-control.test.ts wrote sess-1639-* rows and
sessions/anthropic/127.0.0.1_* envelopes into the live sessions dir; the
legacy storage baseline stops the SQLite rows but not the files).

The preload now points XDG_DATA_HOME/XDG_STATE_HOME/XDG_CACHE_HOME at a
per-run temp tree via ||= (empty counts as unset, matching the lock
script's XDG handling); explicit env and tests pinning their own dirs win
unchanged. Contract pinned by tests/preload-sandbox-dirs.test.ts;
reference/testing.md documents the recommended targeted-run form.
2026-10-29 14:49:38 +08:00
ework-agent b8cad881be ci: shard the test suite across the matrix to cut wall time ~3x (#3143)
The suite outgrew one runner: ~656 top-level files (~190k LOC) serialized
through --test-concurrency=4 on a single 4-core leg took ~17-20 min (windows
slowest; measured 1225s on the last full green run). Add a `shard` matrix
dimension to the test job so each leg runs a balanced slice; run-ci-tests.mjs
now partitions deterministically + totally (LPT bin-packing over file size)
so the union of all shards == allFiles and no test is skipped. Same tests,
assertions, env, OS and node versions — zero coverage loss. Wall drops ~3x
(~20 -> ~7 min).
2026-10-14 14:57:38 +08:00
ework-agent e6ba45cd85 fix(ci): single-phase c=4 + parallel static-gates — serial live phase cost more than it saved (#2816)
Baseline-log arithmetic (sum of per-test durations vs step wall) proves the
old runner default was already concurrent, so the two-phase split's serial
live phase only idled 3+ cores for 3-4 min without buying stability. Run the
whole suite at explicit concurrency=4 (keeps the LIVE_FILES tripwire), and
move typecheck/kernel/pi-subagents/build into a parallel static-gates job off
the test critical path.
2026-10-12 11:15:35 +08:00
ework-agent e0e3759f25 docs(ci): correct the stale 2-vCPU/serial premise in the schedule rationale (#2816)
Baseline logs from the pre-PR flow show interleaved output from multiple
test files in the same seconds on ubuntu-latest: current hosted runners are
4-vCPU, so availableParallelism()-1 == 3 and the old flat glob was NOT
serial. The two-phase split isolates spawning suites from pool contention;
it does not turn serial into parallel. Comment-only.
2026-10-12 11:00:52 +08:00
ework-agent c2914c34ab test(ci): two-phase schedule for the main CI test job (#2816)
The node built-in runner defaults file concurrency to availableParallelism()-1 == 1 on 2-vCPU runners, so the flat tests/*.test.ts glob ran all 600+ suites strictly serially, each paying a node+tsx spawn in turn. scripts/run-ci-tests.mjs splits the same suites into: live (process-spawning, concurrency=1 — #1248 requires quiet-machine conditions) and pool (everything else, concurrency=4 — no spawners by construction, listen(0) ports, XDG-isolated homes), with a self-check that fails the job when a new spawning suite lands unregistered. Same tests/assertions/env; local npm test untouched. Plus two targeted suite speedups: image-request-budget hoists the shared ~100MB body (5 builds -> 3) and claude-native pre-warms the Windows CA (existing #1807 pattern) in the three remaining fresh-home hook e2e tests.
2026-10-12 10:14:26 +08:00
ework-agent 23d67bef33 fix(#2611): retry npm registry fetches in e2e CI setup to ride out transient blips
A transient runner-to-registry ECONNRESET during setup-phase `npm i -g` /
`npm ci` reds an otherwise-green PR with no test code ever running (#2541 run
38032380794; rerun-failed-jobs green on the same head). Root cause: npm's
built-in fetch retry defaults to only 2 tries. Raise it to 5 via a job-level
env block on every job that touches the registry, so a ~10s jitter rides out
instead of aborting setup. Job-level placement covers the global CLI install
AND `npm ci` AND any build-time fetch in that job. Bounded: worst case ~+2 min
of backoff before a genuine sustained outage still fails fast (jobs carry their
own timeout-minutes).

Applied to the 9 e2e/setup workflows with executable registry installs (12
jobs total). Deliberately NOT applied around `npm publish` (artifact/release
lanes): a publish is non-idempotent, so a fetch-retry re-POST can trip E409 /
double-publish, which is worse than the original failure mode. Documents the
required pattern in reference/testing.md so new lanes inherit it.
2026-10-10 15:22:49 +08:00
ranxianglei 4f42990828 test(e2e): drive the #1628 failure class end-to-end — unwritable target, real-baseline hop, cache-lane doctor
Closes the three verification gaps left after the #1628 triage: the
unwritable-target wall had no real-chain e2e (only mock-logger unit
tests), the no-op protocol had no local form (a self-built fake baseline
cannot validate the LIVE old updater), and cache-lane doctor ran only
by hand.

- unwritable install dir (posix): chmod 0o555 on the real extracted
  install, assert the loud failure + one-per-process location
  diagnostic + zero disk flip + no leaked update lock
- real published baseline (BILI_E2E_REAL_BASELINE): download one real
  published tarball, prove the live old updater hops onto this dist;
  CI resolves the baseline via npm view before the run
- cache-lane doctor: opencode lane layout, doctor --json must resolve
  the update target to the running copy
2026-10-04 14:15:10 +08:00
ework-agent 0be2a7a016 docs: align typecheck script references with the src+tests gate (#1970) 2026-10-03 20:20:44 +08:00
ework-agent c9a9842e2f docs(agents): slim AGENTS.md, move procedures to reference/ 2026-10-03 00:18:03 +08:00