Every full test run left about 40 directories in the temp dir, even when it
passed. On the Windows dev machine about 16,000 had piled up by mid-October.
A full run with TEMP pointed at an empty folder showed where each one came
from:
- function-ref (20) and ts-field-classification (3): each case's `finally`
cleared `tmpDir` right after `cg.destroy()`, so the `afterEach` that removes
the dir found nothing to remove.
- npm-sdk (3) and liveness-watchdog (3) never removed the dirs they made.
- extraction's #1502 suite (3) made a dir in `beforeEach` and had no
`afterEach`; pr19-improvements' schema-version case (1) made one inline.
- setup-home-sandbox (6 on Windows): Vitest runs no hooks for a file whose
every test is skipped, so each platform-gated file left its home sandbox.
Each sandbox now records itself in a per-run registry, and a global
teardown removes whatever is still listed and names any dir still in use.
With the fix, the same full run leaves nothing behind but Node's own reused
compile cache. test-home-sandbox gains two tests: a file's home is listed in
the run's registry, and the teardown removes every listed home, then the
registry.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Running the suite on a machine with Claude Code configured could wire the
CodeGraph prompt hook into the developer's own ~/.claude/settings.json:
every upgrade test whose fake upgrade succeeded ran the real post-upgrade
prompt-hook self-heal, which detected the real global Claude profile and
wrote it. Daemon suites likewise left records in the real
~/.codegraph/daemons. On Windows a HOME-only redirect would not have
helped, since os.homedir() reads USERPROFILE there.
- The prompt-hook writer is now injected through UpgradeDeps
(wirePromptHook); the CLI passes the real defaultWirePromptHook and the
upgrade tests a recorder. New tests pin that a successful upgrade calls
the recorder and that the real writer never touches a configured profile.
- A vitest setupFiles entry gives every engine test file a throwaway home:
HOME/USERPROFILE (plus HOMEDRIVE/HOMEPATH/APPDATA/LOCALAPPDATA on
Windows), XDG_CONFIG_HOME, and GIT_CONFIG_GLOBAL (seeded with a dummy
identity) point into it, and CLAUDE_CONFIG_DIR/CODEX_HOME/COPILOT_HOME/
HERMES_HOME are cleared. Spawned CLI/MCP children inherit it. A sandbox
test asserts os.homedir(), the Claude profile, the daemon registry, a
child process and git's global config all resolve inside it.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A vitest pool worker is the one launch path that never received
`--liftoff-only`, so the suite compiled tree-sitter grammars on the
turboshaft tier. Once ~640 extraction tests have warmed a grammar function
up, its background tier-up job (Turboshaft LoopUnrollingPhase, symbolized
from the native stack) exhausts a compiler Zone and aborts the worker:
`Fatal process out of memory: Zone`, which vitest reports only as "Worker
exited unexpectedly" with the file's remaining tests unrun.
Pass WASM_RUNTIME_FLAGS through poolOptions.forks.execArgv, so the test
process matches the bundled launcher, the CLI re-exec and refresh-launcher.
V8 flags are process-global, so parse worker threads are covered too.
Linux x64, Node 24.15, `__tests__/extraction.test.ts` (655 tests):
without the flag 3 of 4 runs died at the same test (639 passed);
with it 2 of 2 passed, in 19–24s instead of 34–41s. Neither
`--no-wasm-loop-unrolling` nor `--no-wasm-dynamic-tiering` prevents it.
(cherry picked from commit 565ec815e6)
Co-authored-by: danusha2345 <danusha2345@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
* test: build dist/ before the suite when it is missing or stale (#1879)
About thirty suites spawn dist/bin/codegraph.js, the parallel resolver loads
its worker from dist/, and the `codegraph ui` suites serve dist/viewer/. On a
fresh checkout `npm ci && npm test` failed them on spawn timeouts and a
missing-viewer error that never mentioned the build; after an edit without a
rebuild they quietly exercised the old code.
A Vitest globalSetup now rebuilds each half only when it is missing or older
than its sources: `tsc` + copy-assets when anything under src/ is newer than
dist/bin/codegraph.js, `build:ui` when ui/src/ is newer than
dist/viewer/index.html. A current dist/ costs one mtime walk.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(tests): build missing or stale test prerequisites (#1879)
Dist-dependent tests launched missing or stale compiled outputs without a build prerequisite.
Retain the contributor's shared setup and track build inputs and individual outputs for reliable invalidation.
Resolve TypeScript locally, preserve asset copying and engine/UI separation, and report build failures directly.
Add regression coverage for cold builds, warm runs, configuration changes, and missing assets.
Co-authored-by: danusha2345 <ewidusoc498@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: danusha2345 <ewidusoc498@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
`ui/src` now builds two ways from one tree: the static app `codegraph ui`
serves, and — via `svelte-package` — a Svelte library the Pro app imports.
A forked component would be a second answer to the same question about the
same graph, so there is no fork.
Everything a screen knows arrives through a `GraphAdapter`: eleven methods
answering the wire shapes verbatim, with `createHttpAdapter()` (the loopback
JSON API) as the default and a host's in-process engine reads as the point.
`lib/api.ts` became a one-line-per-call facade over it, which is why no call
site in the views changed. The payload types moved to `lib/wire.ts` — no
imports, no runtime — so a host can depend on the vocabulary alone.
Two more seams and one guard:
- `lib/navigation.ts` holds the href builders behind a `NavigationDriver`, so
a host addresses its own URL space. The app's half — the hash parser and the
live route, which attach window listeners at module scope — stays in
`router.svelte.ts` and is pruned out of the package: rendering a Symbol view
must not install a hash router in somebody else's application.
- `lib/theme.css` carries the design tokens and maps Svelte Flow's `--xy-*`
variables onto them, so a host never sees library defaults. Dark now also
answers to a bare `[data-theme]`, which is how `<CodegraphUi theme>` themes
a container rather than the document.
- `scripts/check-ui-package.mjs` prunes the app's shell, resolves the
extensionless specifiers svelte-package leaves behind, and asserts that
nothing but `lib/adapter.js` reaches the network.
The search box, its keyboard and its panel are one component now
(`SearchPalette`), because splitting them is what breaks a palette.
`__tests__/ui-package.test.ts` mounts the three screens from the package entry
against a mock adapter in jsdom; it runs as a second vitest project so the
`browser` resolve condition it needs cannot reach the engine's suites.
Versioned with the engine. Prepared, not published: `private: true` is the
guard and `pack-npm.sh` only packs a tarball under CODEGRAPH_PACK_UI=1.