Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
test: keep Git sandbox text bytes stable across platforms (#13366)
Adam Eivy632adface0d0
diff --git a/server/lib/README.md b/server/lib/README.mdindex 2f5fc159a7..ac290bb8ff 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -827,7 +827,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub|---|---|| `browserSuiteGate.js` | `probeChromeH264(path)` runs the H.264 probe as an owned, deadline-bound child (own process group, SIGTERM→SIGKILL ladder awaiting `close`) and resolves `{ ok }` or `{ ok:false, cause }` — `missing-executable`, `codec-unavailable`, `probe-timeout`, `teardown-failed` (answered, then exited nonzero: never trusted, never a missing codec), `no-answer`; `describeH264Probe` is its path/PID-free one-liner; `chromeWithH264(path)` (async) returns the path only when that Chrome decodes H.264, null when the executable or codec is genuinely absent, and `{ probeFailure }` when the probe itself failed (reported by `browserSuiteCanRun` as a lifecycle failure, not a missing prerequisite); `browserSuiteCanRun(label, prerequisites)` is the `canRun` guard for the cross-workspace `*.browser.test.js` suites (Chrome + ffmpeg + the client bundler). Pass `{ name: discoveredValue }`; a falsy value is missing. Returns `false` with a visible skip log locally, but throws naming the missing prerequisites when `PORTOS_REQUIRE_BROWSER_SUITES` is set; `browserSuiteBlockReason(prerequisites)` is that verdict alone (the same wording, or `null`) for a caller that only reports, such as `scripts/pregate.js` — the flag the CI `database` job sets for the browser suites the planner selected (#10312). `resolveTestChrome(env)` is the one Chrome candidate list (`CHROME_PATH`, Playwright's bundled Chromium, then the macOS app and the Linux package paths) shared by the suites, the pregate probe and the test memo's tool keying, and `resolveClientBundler(repoRoot)` the one client bundler probe (resolved Vite, React plugin and Tailwind PostCSS paths, or `undefined` when any is missing; non-`MODULE_NOT_FOUND` errors throw) (#12293). || `dbTestGate.js` | `requireDbOrSkip(label, dbReady, reason)` keeps a missing local test database as a visible skipped suite, but throws when `PORTOS_REQUIRE_DB` is set so CI cannot pass after DB-backed suites disappear. |-| `gitTestRepo.js` | Shared real-git sandbox for integration tests (#4394): one initialized template (working tree + bare origin) per worker, then `fs.cp` into a fresh temp dir. `makeGitSandbox({ origin })`, `attachBareOrigin(scratch, repo)`, `materializeGitRepo(dest)`, `destroyGitSandbox`, plus `SKIP_HEAVY_INTEGRATION` (`VITEST_FAST=1`). `resetGitSandbox({ scratch, repo, initialHead })` / `resetGitWorktreeSandbox(repo, initialHead)` restore a sandbox in place (branches, worktrees, remote) so a `describe` can build one sandbox in `beforeAll` and reset between tests instead of paying the fs.cp/rm cycle per test (#5902). Every entry point runs `assertTempPath` first, so a path outside `os.tmpdir()` throws instead of `git init`-ing or `rm -rf`-ing a real checkout (#4554). Fixture-local maintenance/GC detachment is disabled so awaited Git operations retain their writers through teardown. Still real git — just not rebuilt from `init`+`commit`+`push` in every `beforeEach`. |+| `gitTestRepo.js` | Shared real-git sandbox for integration tests (#4394): one initialized template (working tree + bare origin) per worker, then `fs.cp` into a fresh temp dir. `makeGitSandbox({ origin })`, `attachBareOrigin(scratch, repo)`, `materializeGitRepo(dest)`, `destroyGitSandbox`, plus `SKIP_HEAVY_INTEGRATION` (`VITEST_FAST=1`). `resetGitSandbox({ scratch, repo, initialHead })` / `resetGitWorktreeSandbox(repo, initialHead)` restore a sandbox in place (branches, worktrees, remote) so a `describe` can build one sandbox in `beforeAll` and reset between tests instead of paying the fs.cp/rm cycle per test (#5902). Every entry point runs `assertTempPath` first, so a path outside `os.tmpdir()` throws instead of `git init`-ing or `rm -rf`-ing a real checkout (#4554). Fixture-local maintenance/GC detachment is disabled so awaited Git operations retain their writers through teardown. Primary fixtures pin `core.autocrlf=false` and `core.eol=lf` so copied/materialized checkouts preserve exact text bytes under host CRLF defaults. Still real git — just not rebuilt from `init`+`commit`+`push` in every `beforeEach`. || `mirrorParity.js` | Source-extraction and comparison primitives for declaration-level contract tests: the vendored `aiToolkit/` copy of `TOOL_USE_RE` (`localModelHeuristics.mirror.test.js`), and the bootstrap sequence's body assertions (`bootstrap*.test.js`). A pure module the browser needs is imported by the client rather than mirrored, so no client↔server copy test should need these: `stripCommentsAndNormalize` (so per-side commentary may diverge but logic may not), `extractDeclaration(src, name)` (balanced `{}`/`()`/`[]` walk over `function` / `async function` / `const`), and `compareDeclaration(serverSrc, clientSrc, name)`. Use these instead of hand-rolling a brace-walker per mirror. Pure — no `vitest` import — so callers own the assertions. || `mockPathsDataRoot.js` | Best-effort bounded `recordTempRootOwner` sidecar observations and shared Vitest helpers for `PATHS.data → temp dir`, no-peer record creation guards, deterministic federation-identity doubles (`mockTestIdentity`), and `ownTestBodies(it)` → `{ it, drain }`, which owns each test body so teardown can `await drain()` before removing a fixture root — a body left running by Vitest's fail-fast cancellation otherwise recreates the removed root (`test temp leak:`). || `settingsTestUtil.js` | `bindSettingsFile(dataRoot)` → `writeSettingsFile`/`mergeSettingsFile`: direct settings.json disk writes that also drop the `getSettings()` read cache (dynamic-import reset) so a stale cache can't survive a bypass-`save()` write. |diff --git a/server/lib/gitTestRepo.js b/server/lib/gitTestRepo.jsindex 35f80af6b9..7c2fb5c830 100644--- a/server/lib/gitTestRepo.js+++ b/server/lib/gitTestRepo.js@@ -92,6 +92,9 @@ async function buildTemplate() {await execGit(['init', '-b', 'main', repo], scratch);await keepMaintenanceAttached(repo);await configureIdentity(repo);+ // Copied fixtures must preserve exact text bytes regardless of host Git defaults.+ await execGit(['config', 'core.autocrlf', 'false'], repo);+ await execGit(['config', 'core.eol', 'lf'], repo);await writeFile(join(repo, 'initial.txt'), 'initial');await execGit(['add', '-A'], repo);await execGit(['commit', '-m', 'initial'], repo);diff --git a/server/services/git.rebasePush.test.js b/server/services/git.rebasePush.test.jsindex 68eef85561..28d9bf3b65 100644--- a/server/services/git.rebasePush.test.js+++ b/server/services/git.rebasePush.test.js@@ -1,4 +1,4 @@-import { afterEach, describe, expect, it } from 'vitest';+import { afterEach, describe, expect, it, vi } from 'vitest';import { readFile, writeFile } from 'fs/promises';import { existsSync } from 'fs';import { join } from 'path';@@ -10,6 +10,7 @@ import { getGitInfo, rebaseAndPushDefaultBranch } from './git.js';describe.skipIf(SKIP_HEAVY_INTEGRATION)('rebase and push the default branch', () => {let sandbox;afterEach(async () => {+ vi.unstubAllEnvs();if (sandbox) await destroyGitSandbox(sandbox.scratch);sandbox = null;});@@ -33,8 +34,11 @@ describe.skipIf(SKIP_HEAVY_INTEGRATION)('rebase and push the default branch', ()return repo;};- it('reports origin divergence independently of tracking and publishes both sides without a merge commit', async () => {+ it('reports origin divergence independently of tracking and publishes exact bytes under global CRLF defaults', async () => {const repo = await prepare();+ const globalConfig = join(sandbox.scratch, 'synthetic-global.gitconfig');+ await writeFile(globalConfig, '[core]\n\tautocrlf = true\n\teol = crlf\n');+ vi.stubEnv('GIT_CONFIG_GLOBAL', globalConfig);await execGit(['fetch', 'origin'], repo);await execGit(['branch', '--unset-upstream'], repo);expect(await getGitInfo(repo)).toMatchObject({ originComparison: { ahead: 1, behind: 1 } });