






















@@ -335,81 +335,100 @@ Think of the suites as “increasing realism” (and increasing flakiness/cost):
335335- Runs in CI
336336- No real keys required
337337- Should be fast and stable
338-<AccordionGroup>
339-<Accordion title="Projects, shards, and scoped lanes"> - Untargeted `pnpm test` runs twelve smaller shard configs (`core-unit-fast`, `core-unit-src`, `core-unit-security`, `core-unit-ui`, `core-unit-support`, `core-support-boundary`, `core-contracts`, `core-bundled`, `core-runtime`, `agentic`, `auto-reply`, `extensions`) instead of one giant native root-project process. This cuts peak RSS on loaded machines and avoids auto-reply/extension work starving unrelated suites. - `pnpm test --watch` still uses the native root `vitest.config.ts` project graph, because a multi-shard watch loop is not practical. - `pnpm test`, `pnpm test:watch`, and `pnpm test:perf:imports` route explicit file/directory targets through scoped lanes first, so `pnpm test extensions/discord/src/monitor/message-handler.preflight.test.ts` avoids paying the full root project startup tax. - `pnpm test:changed` expands changed git paths into the same scoped lanes when the diff only touches routable source/test files; config/setup edits still fall back to the broad root-project rerun. - `pnpm check:changed` is the normal smart local gate for narrow work. It classifies the diff into core, core tests, extensions, extension tests, apps, docs, release metadata, and tooling, then runs the matching typecheck/lint/test lanes. Public Plugin SDK and plugin-contract changes include one extension validation pass because extensions depend on those core contracts. Release metadata-only version bumps run targeted version/config/root-dependency checks instead of the full suite, with a guard that rejects package changes outside the top-level version field. - Import-light unit tests from agents, commands, plugins, auto-reply helpers, `plugin-sdk`, and similar pure utility areas route through the `unit-fast` lane, which skips `test/setup-openclaw-runtime.ts`; stateful/runtime-heavy files stay on the existing lanes. - Selected `plugin-sdk` and `commands` helper source files also map changed-mode runs to explicit sibling tests in those light lanes, so helper edits avoid rerunning the full heavy suite for that directory. - `auto-reply` has three dedicated buckets: top-level core helpers, top-level `reply.*` integration tests, and the `src/auto-reply/reply/**` subtree. This keeps the heaviest reply harness work off the cheap status/chunk/token tests.
340-</Accordion>
341-342-<Accordion title="Embedded runner coverage">
343-- When you change message-tool discovery inputs or compaction runtime
344- context, keep both levels of coverage.
345-- Add focused helper regressions for pure routing and normalization
346- boundaries.
347-- Keep the embedded runner integration suites healthy:
348- `src/agents/pi-embedded-runner/compact.hooks.test.ts`,
349- `src/agents/pi-embedded-runner/run.overflow-compaction.test.ts`, and
350- `src/agents/pi-embedded-runner/run.overflow-compaction.loop.test.ts`.
351-- Those suites verify that scoped ids and compaction behavior still flow
352- through the real `run.ts` / `compact.ts` paths; helper-only tests are
353- not a sufficient substitute for those integration paths.
354-</Accordion>
355-356-<Accordion title="Vitest pool and isolation defaults">
357-- Base Vitest config defaults to `threads`.
358-- The shared Vitest config fixes `isolate: false` and uses the
359- non-isolated runner across the root projects, e2e, and live configs.
360-- The root UI lane keeps its `jsdom` setup and optimizer, but runs on the
361- shared non-isolated runner too.
362-- Each `pnpm test` shard inherits the same `threads` + `isolate: false`
363- defaults from the shared Vitest config.
364-- `scripts/run-vitest.mjs` adds `--no-maglev` for Vitest child Node
365- processes by default to reduce V8 compile churn during big local runs.
366- Set `OPENCLAW_VITEST_ENABLE_MAGLEV=1` to compare against stock V8
367- behavior.
368-</Accordion>
369-370-<Accordion title="Fast local iteration">
371-- `pnpm changed:lanes` shows which architectural lanes a diff triggers.
372-- The pre-commit hook is formatting-only. It restages formatted files and
373- does not run lint, typecheck, or tests.
374-- Run `pnpm check:changed` explicitly before handoff or push when you
375- need the smart local gate. Public Plugin SDK and plugin-contract
376- changes include one extension validation pass.
377-- `pnpm test:changed` routes through scoped lanes when the changed paths
378- map cleanly to a smaller suite.
379-- `pnpm test:max` and `pnpm test:changed:max` keep the same routing
380- behavior, just with a higher worker cap.
381-- Local worker auto-scaling is intentionally conservative and backs off
382- when the host load average is already high, so multiple concurrent
383- Vitest runs do less damage by default.
384-- The base Vitest config marks the projects/config files as
385- `forceRerunTriggers` so changed-mode reruns stay correct when test
386- wiring changes.
387-- The config keeps `OPENCLAW_VITEST_FS_MODULE_CACHE` enabled on supported
388- hosts; set `OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/abs/path` if you want
389- one explicit cache location for direct profiling.
390-</Accordion>
391-392-<Accordion title="Perf debugging">
393-- `pnpm test:perf:imports` enables Vitest import-duration reporting plus
394- import-breakdown output.
395-- `pnpm test:perf:imports:changed` scopes the same profiling view to
396- files changed since `origin/main`.
397-- When one hot test still spends most of its time in startup imports,
398- keep heavy dependencies behind a narrow local `*.runtime.ts` seam and
399- mock that seam directly instead of deep-importing runtime helpers just
400- to pass them through `vi.mock(...)`.
401-- `pnpm test:perf:changed:bench -- --ref <git-ref>` compares routed
402- `test:changed` against the native root-project path for that committed
403- diff and prints wall time plus macOS max RSS.
404-- `pnpm test:perf:changed:bench -- --worktree` benchmarks the current
405- dirty tree by routing the changed file list through
406- `scripts/test-projects.mjs` and the root Vitest config.
407-- `pnpm test:perf:profile:main` writes a main-thread CPU profile for
408- Vitest/Vite startup and transform overhead.
409-- `pnpm test:perf:profile:runner` writes runner CPU+heap profiles for the
410- unit suite with file parallelism disabled.
411-</Accordion>
412-</AccordionGroup>
338+339+<AccordionGroup>
340+<Accordion title="Projects, shards, and scoped lanes">
341+342+- Untargeted `pnpm test` runs twelve smaller shard configs (`core-unit-fast`, `core-unit-src`, `core-unit-security`, `core-unit-ui`, `core-unit-support`, `core-support-boundary`, `core-contracts`, `core-bundled`, `core-runtime`, `agentic`, `auto-reply`, `extensions`) instead of one giant native root-project process. This cuts peak RSS on loaded machines and avoids auto-reply/extension work starving unrelated suites.
343+- `pnpm test --watch` still uses the native root `vitest.config.ts` project graph, because a multi-shard watch loop is not practical.
344+- `pnpm test`, `pnpm test:watch`, and `pnpm test:perf:imports` route explicit file/directory targets through scoped lanes first, so `pnpm test extensions/discord/src/monitor/message-handler.preflight.test.ts` avoids paying the full root project startup tax.
345+- `pnpm test:changed` expands changed git paths into the same scoped lanes when the diff only touches routable source/test files; config/setup edits still fall back to the broad root-project rerun.
346+- `pnpm check:changed` is the normal smart local gate for narrow work. It classifies the diff into core, core tests, extensions, extension tests, apps, docs, release metadata, and tooling, then runs the matching typecheck/lint/test lanes. Public Plugin SDK and plugin-contract changes include one extension validation pass because extensions depend on those core contracts. Release metadata-only version bumps run targeted version/config/root-dependency checks instead of the full suite, with a guard that rejects package changes outside the top-level version field.
347+- Import-light unit tests from agents, commands, plugins, auto-reply helpers, `plugin-sdk`, and similar pure utility areas route through the `unit-fast` lane, which skips `test/setup-openclaw-runtime.ts`; stateful/runtime-heavy files stay on the existing lanes.
348+- Selected `plugin-sdk` and `commands` helper source files also map changed-mode runs to explicit sibling tests in those light lanes, so helper edits avoid rerunning the full heavy suite for that directory.
349+- `auto-reply` has three dedicated buckets: top-level core helpers, top-level `reply.*` integration tests, and the `src/auto-reply/reply/**` subtree. This keeps the heaviest reply harness work off the cheap status/chunk/token tests.
350+351+</Accordion>
352+353+<Accordion title="Embedded runner coverage">
354+355+- When you change message-tool discovery inputs or compaction runtime
356+ context, keep both levels of coverage.
357+- Add focused helper regressions for pure routing and normalization
358+ boundaries.
359+- Keep the embedded runner integration suites healthy:
360+ `src/agents/pi-embedded-runner/compact.hooks.test.ts`,
361+ `src/agents/pi-embedded-runner/run.overflow-compaction.test.ts`, and
362+ `src/agents/pi-embedded-runner/run.overflow-compaction.loop.test.ts`.
363+- Those suites verify that scoped ids and compaction behavior still flow
364+ through the real `run.ts` / `compact.ts` paths; helper-only tests are
365+ not a sufficient substitute for those integration paths.
366+367+</Accordion>
368+369+<Accordion title="Vitest pool and isolation defaults">
370+371+- Base Vitest config defaults to `threads`.
372+- The shared Vitest config fixes `isolate: false` and uses the
373+ non-isolated runner across the root projects, e2e, and live configs.
374+- The root UI lane keeps its `jsdom` setup and optimizer, but runs on the
375+ shared non-isolated runner too.
376+- Each `pnpm test` shard inherits the same `threads` + `isolate: false`
377+ defaults from the shared Vitest config.
378+- `scripts/run-vitest.mjs` adds `--no-maglev` for Vitest child Node
379+ processes by default to reduce V8 compile churn during big local runs.
380+ Set `OPENCLAW_VITEST_ENABLE_MAGLEV=1` to compare against stock V8
381+ behavior.
382+383+</Accordion>
384+385+<Accordion title="Fast local iteration">
386+387+- `pnpm changed:lanes` shows which architectural lanes a diff triggers.
388+- The pre-commit hook is formatting-only. It restages formatted files and
389+ does not run lint, typecheck, or tests.
390+- Run `pnpm check:changed` explicitly before handoff or push when you
391+ need the smart local gate. Public Plugin SDK and plugin-contract
392+ changes include one extension validation pass.
393+- `pnpm test:changed` routes through scoped lanes when the changed paths
394+ map cleanly to a smaller suite.
395+- `pnpm test:max` and `pnpm test:changed:max` keep the same routing
396+ behavior, just with a higher worker cap.
397+- Local worker auto-scaling is intentionally conservative and backs off
398+ when the host load average is already high, so multiple concurrent
399+ Vitest runs do less damage by default.
400+- The base Vitest config marks the projects/config files as
401+ `forceRerunTriggers` so changed-mode reruns stay correct when test
402+ wiring changes.
403+- The config keeps `OPENCLAW_VITEST_FS_MODULE_CACHE` enabled on supported
404+ hosts; set `OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/abs/path` if you want
405+ one explicit cache location for direct profiling.
406+407+</Accordion>
408+409+<Accordion title="Perf debugging">
410+411+- `pnpm test:perf:imports` enables Vitest import-duration reporting plus
412+ import-breakdown output.
413+- `pnpm test:perf:imports:changed` scopes the same profiling view to
414+ files changed since `origin/main`.
415+- When one hot test still spends most of its time in startup imports,
416+ keep heavy dependencies behind a narrow local `*.runtime.ts` seam and
417+ mock that seam directly instead of deep-importing runtime helpers just
418+ to pass them through `vi.mock(...)`.
419+- `pnpm test:perf:changed:bench -- --ref <git-ref>` compares routed
420+ `test:changed` against the native root-project path for that committed
421+ diff and prints wall time plus macOS max RSS.
422+- `pnpm test:perf:changed:bench -- --worktree` benchmarks the current
423+ dirty tree by routing the changed file list through
424+ `scripts/test-projects.mjs` and the root Vitest config.
425+- `pnpm test:perf:profile:main` writes a main-thread CPU profile for
426+ Vitest/Vite startup and transform overhead.
427+- `pnpm test:perf:profile:runner` writes runner CPU+heap profiles for the
428+ unit suite with file parallelism disabled.
429+430+</Accordion>
431+</AccordionGroup>
413432414433### Stability (gateway)
415434此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。