mirror of
https://github.com/Twigpine/openrecall.git
synced 2026-11-07 18:30:51 -10:00
* fix(tests): isolate preflight from the real config and always test a fresh Node bundle tests/mcp-preflight.test.ts resolved settings against the real ~/.openrecall/config.json: `envFor` set no OPENRECALL_HOME, so on a machine that had run `openrecall init` the two "missing passphrase" cases found a passphrase and failed (499/501). Every env the file builds now points at a per-module temp home, and a positive control writes a passphrase into a second home and asserts it is not read, while the config-file fallback is shown to be live when OPENRECALL_HOME points at that home. tests/cli-version.test.ts and tests/mcp-stdio.test.ts skipped the Node launcher when dist/openrecall.js was absent and tested a stale one when it was present. scripts/build.ts now exports `bundleCli(outdir)` behind `import.meta.main`, and tests/node-bundle.ts builds the CLI from the current source once per test process into a temp dir, so the Node launcher is always exercised and `bun test` is green with any dist/, stale or missing. The bundle is built in a child bun rather than in-process: inside `bun test`, Bun.build cannot resolve files directly under src/ until the runtime resolver has touched one of them (Bun 1.3.11), and `bun test` runs no `exit` handlers registered during module load, so the dir is named after the pid and dirs of dead pids are swept on the next build. dist is now two files: dist/openrecall.cli.js, the bundle, and dist/openrecall.js, the `bin` entry, a shim that enables Node's compile cache and imports the bundle. The cache covers only modules loaded after it is enabled, so it could not be turned on from inside the bundle. Measured on Node 24.22.2 (darwin arm64), medians: node dist/openrecall.js --version before 39.2 ms after 31.3 ms shim without cache 38.5 ms (10 runs x 3 rounds) MCP stdio initialize round trip before 68.8 ms after 61.9 ms shim without cache 71.8 ms (10 runs x 3 rounds) spawn -> "[openrecall mcp] ready" before 66.9 ms after 59.7 ms shim without cache 67.9 ms (20 runs, interleaved) Both headline gains clear the 5 ms bar, and the extra import hop costs under 1 ms, so the layout stays. Under Node, `openrecall serve` re-spawns argv[1], now the shim, and `launchCommand` pins the shim; tests/package.test.ts covers both from an installed tarball, and tests/cli-version.test.ts asserts the shim imports ./openrecall.cli.js and the bundle carries the version. * fix(tests): drop inherited OPENRECALL_* variables before any test runs A developer's own exports reached every CLI child spawned with `...process.env` and every in-process settings lookup. The worst one is OPENRECALL_PASSPHRASE_FILE: it outranks OPENRECALL_PASSPHRASE, so the launch tests ran under the developer's passphrase instead of the fixture's, and passed only because their namespace was empty. With the variable pointing at a missing file, four tests failed (three in mcp-preflight, one in package). The preload now deletes every inherited OPENRECALL_* variable; tests set the ones they need explicitly, and everything else in the environment is kept. Also documents the two helpers in tests/node-bundle.ts that had no docstring (CodeRabbit's docstring-coverage check).